On Jan 24, 2013, at 9:24 AM, Steffen Gutmann <muib...@yahoo.com> wrote:
> Hi John! > >> But that's not the *real* problem. That problem is that configure writes a > >> value to G_BYTE_ORDER in $PREFIX/lib/glib-2.0/glibconfig.h, there's only >> one, and that's used not only in glib itself (where separate runs of >> configure for each architecture will take care of the problem for that >> particular build) but in other dependent libraries. Setup_universal_build() >> tries to finesse that by building separate trees for each architecture, but >> I >> was never able to get it to work right and gave up. The correct fix would >> determine endianess at compile time rather than at configure time. > > > I have attached a new diff for glib. It's basically the same as the previous > one but the __POWERPC__ and __i386__ defines have been replaced by > __BIG_ENDIAN__ and __LITTLE_ENDIAN__ which seems more appropriate here. > > It's very much okay that these defines are Apple-only. Note the 3 case > if-then-elseif-else statement: > > +#if defined(__BIG_ENDIAN__) > + #define G_BYTE_ORDER G_BIG_ENDIAN > +#elif defined(__LITTLE_ENDIAN__) > + #define G_BYTE_ORDER G_LITTLE_ENDIAN > +#else > + #define G_BYTE_ORDER $g_byte_order > +#endif > > Thus, if neither __BIG_ENDIAN__ not __LITTLE_ENDIAN__ is defined, we fall > back to whatever the configure script finds as the endianess. > > With that change the relevant part of the glibconfig.h file turns into: > > ... > #if defined(__BIG_ENDIAN__) > #define GINT16_TO_BE(val)((gint16) (val)) > #define GUINT16_TO_BE(val)((guint16) (val)) > #define GINT16_TO_LE(val)((gint16) GUINT16_SWAP_LE_BE (val)) > #define GUINT16_TO_LE(val)(GUINT16_SWAP_LE_BE (val)) > #elif defined(__LITTLE_ENDIAN__) > #define GINT16_TO_LE(val)((gint16) (val)) > #define GUINT16_TO_LE(val)((guint16) (val)) > #define GINT16_TO_BE(val)((gint16) GUINT16_SWAP_LE_BE (val)) > #define GUINT16_TO_BE(val)(GUINT16_SWAP_LE_BE (val)) > #else > #define GINT16_TO_LE(val)((gint16) (val)) > #define GUINT16_TO_LE(val)((guint16) (val)) > #define GINT16_TO_BE(val)((gint16) GUINT16_SWAP_LE_BE (val)) > #define GUINT16_TO_BE(val)(GUINT16_SWAP_LE_BE (val)) > #endif > #if defined(__BIG_ENDIAN__) > #define GINT32_TO_BE(val)((gint32) (val)) > #define GUINT32_TO_BE(val)((guint32) (val)) > #define GINT32_TO_LE(val)((gint32) GUINT32_SWAP_LE_BE (val)) > #define GUINT32_TO_LE(val)(GUINT32_SWAP_LE_BE (val)) > #elif defined(__LITTLE_ENDIAN__) > #define GINT32_TO_LE(val)((gint32) (val)) > #define GUINT32_TO_LE(val)((guint32) (val)) > #define GINT32_TO_BE(val)((gint32) GUINT32_SWAP_LE_BE (val)) > #define GUINT32_TO_BE(val)(GUINT32_SWAP_LE_BE (val)) > #else > #define GINT32_TO_LE(val)((gint32) (val)) > #define GUINT32_TO_LE(val)((guint32) (val)) > #define GINT32_TO_BE(val)((gint32) GUINT32_SWAP_LE_BE (val)) > #define GUINT32_TO_BE(val)(GUINT32_SWAP_LE_BE (val)) > #endif > #if defined(__BIG_ENDIAN__) > #define GINT64_TO_BE(val)((gint64) (val)) > #define GUINT64_TO_BE(val)((guint64) (val)) > #define GINT64_TO_LE(val)((gint64) GUINT64_SWAP_LE_BE (val)) > #define GUINT64_TO_LE(val)(GUINT64_SWAP_LE_BE (val)) > #elif defined(__LITTLE_ENDIAN__) > #define GINT64_TO_LE(val)((gint64) (val)) > #define GUINT64_TO_LE(val)((guint64) (val)) > #define GINT64_TO_BE(val)((gint64) GUINT64_SWAP_LE_BE (val)) > #define GUINT64_TO_BE(val)(GUINT64_SWAP_LE_BE (val)) > #else > #define GINT64_TO_LE(val)((gint64) (val)) > #define GUINT64_TO_LE(val)((guint64) (val)) > #define GINT64_TO_BE(val)((gint64) GUINT64_SWAP_LE_BE (val)) > #define GUINT64_TO_BE(val)(GUINT64_SWAP_LE_BE (val)) > #endif > #define GLONG_TO_LE(val)((glong) GINT32_TO_LE (val)) > #define GULONG_TO_LE(val)((gulong) GUINT32_TO_LE (val)) > #define GLONG_TO_BE(val)((glong) GINT32_TO_BE (val)) > #define GULONG_TO_BE(val)((gulong) GUINT32_TO_BE (val)) > #define GINT_TO_LE(val)((gint) GINT32_TO_LE (val)) > #define GUINT_TO_LE(val)((guint) GUINT32_TO_LE (val)) > #define GINT_TO_BE(val)((gint) GINT32_TO_BE (val)) > #define GUINT_TO_BE(val)((guint) GUINT32_TO_BE (val)) > #define GSIZE_TO_LE(val)((gsize) GUINT32_TO_LE (val)) > #define GSSIZE_TO_LE(val)((gssize) GINT32_TO_LE (val)) > #define GSIZE_TO_BE(val)((gsize) GUINT32_TO_BE (val)) > #define GSSIZE_TO_BE(val)((gssize) GINT32_TO_BE (val)) > #if defined(__BIG_ENDIAN__) > #define G_BYTE_ORDER G_BIG_ENDIAN > #elif defined(__LITTLE_ENDIAN__) > #define G_BYTE_ORDER G_LITTLE_ENDIAN > #else > #define G_BYTE_ORDER G_LITTLE_ENDIAN > #endif > ... > > Isn't that almost exactly what we want? > > Other modules that build on top of glib will then naturally use the right > endianess. > > The only other case I found that needs special handling is libffi. But maybe > there are more things to check. Do you know of any other problems that need > specific handling for universal builds? Ah, I see how it works. Sorry for being dense. The other universal build problem used to be gtk-update-icon-cache and making sure that it generated the right-endian cache for the architecture. Maybe your GLib fix will handle that. Are you going to open a Glib bug for this and submit your patch, or are you going to leave that for me? Ditto the libffi pull request? Regards, John Ralls _______________________________________________ Gtk-osx-users-list mailing list Gtk-osx-users-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-osx-users-list