reimplemented the endian stuff, using inline asm for x86. #define g_htonl

* glib.h: reimplemented the endian stuff, using inline asm for x86.
#define g_htonl and friends.

* testglib.c: new tests for the endian stuff

* configure.in: care for AIX in gmodule linker flags test (from Joel Becker
<jlbec@raleigh.ibm.com>). Check $host_os for linux instead of existance of
/usr/include/linux

* gutils.c: buh-bye evil warning. Thou hast been #ifdef'd out of thine
existance!

-Yosh
This commit is contained in:
Manish Singh 1998-10-27 06:19:42 +00:00
parent a8d04aa3e3
commit 215251e99d
15 changed files with 609 additions and 104 deletions

View File

@ -1,3 +1,17 @@
Mon Oct 26 22:12:03 PST 1998 Manish Singh <yosh@gimp.org>
* glib.h: reimplemented the endian stuff, using inline asm
for x86. #define g_htonl and friends.
* testglib.c: new tests for the endian stuff
* configure.in: care for AIX in gmodule linker flags test (from
Joel Becker <jlbec@raleigh.ibm.com>). Check $host_os for linux
instead of existance of /usr/include/linux
* gutils.c: buh-bye evil warning. Thou hast been #ifdef'd out
of thine existance!
Tue Oct 27 03:00:50 1998 Tim Janik <timj@gtk.org>
* glib.h: removed dummy structure definitions for struct _GCache,

View File

@ -1,3 +1,17 @@
Mon Oct 26 22:12:03 PST 1998 Manish Singh <yosh@gimp.org>
* glib.h: reimplemented the endian stuff, using inline asm
for x86. #define g_htonl and friends.
* testglib.c: new tests for the endian stuff
* configure.in: care for AIX in gmodule linker flags test (from
Joel Becker <jlbec@raleigh.ibm.com>). Check $host_os for linux
instead of existance of /usr/include/linux
* gutils.c: buh-bye evil warning. Thou hast been #ifdef'd out
of thine existance!
Tue Oct 27 03:00:50 1998 Tim Janik <timj@gtk.org>
* glib.h: removed dummy structure definitions for struct _GCache,

View File

@ -1,3 +1,17 @@
Mon Oct 26 22:12:03 PST 1998 Manish Singh <yosh@gimp.org>
* glib.h: reimplemented the endian stuff, using inline asm
for x86. #define g_htonl and friends.
* testglib.c: new tests for the endian stuff
* configure.in: care for AIX in gmodule linker flags test (from
Joel Becker <jlbec@raleigh.ibm.com>). Check $host_os for linux
instead of existance of /usr/include/linux
* gutils.c: buh-bye evil warning. Thou hast been #ifdef'd out
of thine existance!
Tue Oct 27 03:00:50 1998 Tim Janik <timj@gtk.org>
* glib.h: removed dummy structure definitions for struct _GCache,

View File

@ -1,3 +1,17 @@
Mon Oct 26 22:12:03 PST 1998 Manish Singh <yosh@gimp.org>
* glib.h: reimplemented the endian stuff, using inline asm
for x86. #define g_htonl and friends.
* testglib.c: new tests for the endian stuff
* configure.in: care for AIX in gmodule linker flags test (from
Joel Becker <jlbec@raleigh.ibm.com>). Check $host_os for linux
instead of existance of /usr/include/linux
* gutils.c: buh-bye evil warning. Thou hast been #ifdef'd out
of thine existance!
Tue Oct 27 03:00:50 1998 Tim Janik <timj@gtk.org>
* glib.h: removed dummy structure definitions for struct _GCache,

View File

@ -1,3 +1,17 @@
Mon Oct 26 22:12:03 PST 1998 Manish Singh <yosh@gimp.org>
* glib.h: reimplemented the endian stuff, using inline asm
for x86. #define g_htonl and friends.
* testglib.c: new tests for the endian stuff
* configure.in: care for AIX in gmodule linker flags test (from
Joel Becker <jlbec@raleigh.ibm.com>). Check $host_os for linux
instead of existance of /usr/include/linux
* gutils.c: buh-bye evil warning. Thou hast been #ifdef'd out
of thine existance!
Tue Oct 27 03:00:50 1998 Tim Janik <timj@gtk.org>
* glib.h: removed dummy structure definitions for struct _GCache,

View File

@ -1,3 +1,17 @@
Mon Oct 26 22:12:03 PST 1998 Manish Singh <yosh@gimp.org>
* glib.h: reimplemented the endian stuff, using inline asm
for x86. #define g_htonl and friends.
* testglib.c: new tests for the endian stuff
* configure.in: care for AIX in gmodule linker flags test (from
Joel Becker <jlbec@raleigh.ibm.com>). Check $host_os for linux
instead of existance of /usr/include/linux
* gutils.c: buh-bye evil warning. Thou hast been #ifdef'd out
of thine existance!
Tue Oct 27 03:00:50 1998 Tim Janik <timj@gtk.org>
* glib.h: removed dummy structure definitions for struct _GCache,

View File

@ -1,3 +1,17 @@
Mon Oct 26 22:12:03 PST 1998 Manish Singh <yosh@gimp.org>
* glib.h: reimplemented the endian stuff, using inline asm
for x86. #define g_htonl and friends.
* testglib.c: new tests for the endian stuff
* configure.in: care for AIX in gmodule linker flags test (from
Joel Becker <jlbec@raleigh.ibm.com>). Check $host_os for linux
instead of existance of /usr/include/linux
* gutils.c: buh-bye evil warning. Thou hast been #ifdef'd out
of thine existance!
Tue Oct 27 03:00:50 1998 Tim Janik <timj@gtk.org>
* glib.h: removed dummy structure definitions for struct _GCache,

View File

@ -1,3 +1,17 @@
Mon Oct 26 22:12:03 PST 1998 Manish Singh <yosh@gimp.org>
* glib.h: reimplemented the endian stuff, using inline asm
for x86. #define g_htonl and friends.
* testglib.c: new tests for the endian stuff
* configure.in: care for AIX in gmodule linker flags test (from
Joel Becker <jlbec@raleigh.ibm.com>). Check $host_os for linux
instead of existance of /usr/include/linux
* gutils.c: buh-bye evil warning. Thou hast been #ifdef'd out
of thine existance!
Tue Oct 27 03:00:50 1998 Tim Janik <timj@gtk.org>
* glib.h: removed dummy structure definitions for struct _GCache,

View File

@ -421,7 +421,22 @@ if test -z "$G_MODULE_IMPL"; then
fi
dnl *** shl_load() in libdld (HP-UX)
if test -z "$G_MODULE_IMPL"; then
G_MODULE_LDFLAGS='-Wl,-E'
AC_MSG_CHECKING(how to export all symbols)
SAVED_LDFLAGS=$LDFLAGS
LDFLAGS="$LDFLAGS -Wl,-E"
AC_TRY_LINK(,[ return 0; ],
[ G_MODULE_LDFLAGS="-Wl,-E" ],[
LDFLAGS="$SAVED_LDFLAGS -bexpall"
AC_TRY_LINK(,[ return 0; ],
G_MODULE_LDFLAGS="-bexpall",
G_MODULE_LDFLAGS="none"
)
])
LDFLAGS=$SAVED_LDFLAGS
AC_MSG_RESULT($G_MODULE_LDFLAGS)
if test "x$G_MODULE_LDFLAGS" = "xnone"; then
G_MODULE_LDFLAGS=
fi
AC_CHECK_LIB(dld, shl_load,
G_MODULE_LIBS=-ldld
G_MODULE_IMPL=G_MODULE_IMPL_DLD
@ -429,9 +444,11 @@ if test -z "$G_MODULE_IMPL"; then
fi
dnl *** additional checks for G_MODULE_IMPL_DL
if test "$G_MODULE_IMPL" = "G_MODULE_IMPL_DL"; then
if test -d /usr/include/linux; then
case "$host_os" in
linux*)
G_MODULE_LDFLAGS='-rdynamic'
fi
;;
esac
LIBS_orig="$LIBS"
LDFLAGS_orig="$LDFLAGS"
LIBS="$LIBS $G_MODULE_LIBS"

266
glib.h
View File

@ -335,7 +335,7 @@ extern "C" {
* Actual use is strongly deprecated of course ;)
*/
#if defined (__i386__) && defined (__GNUC__)
#define G_BREAKPOINT() G_STMT_START{ __asm__ volatile ("int $03"); }G_STMT_END
#define G_BREAKPOINT() G_STMT_START{ __asm__ __volatile__ ("int $03"); }G_STMT_END
#else /* !__i386__ */
#define G_BREAKPOINT()
#endif /* __i386__ */
@ -502,54 +502,6 @@ extern "C" {
#endif /* !G_DISABLE_CHECKS */
/* Portable endian checks and conversions
*/
#define G_LITTLE_ENDIAN 1234
#define G_BIG_ENDIAN 4321
#define G_PDP_ENDIAN 3412 / /* unused, need specific PDP check */
#ifdef WORDS_BIGENDIAN
#define G_BYTE_ORDER G_BIG_ENDIAN
#else
#define G_BYTE_ORDER G_LITTLE_ENDIAN
#endif
#define GULONG_SWAP_LE_BE(long_val) (((gulong) \
(((gulong) (long_val)) & 0x000000ffU) << 24) | \
(((gulong) (long_val)) & 0x0000ff00U) << 8) | \
(((gulong) (long_val)) & 0x00ff0000U) >> 8) | \
(((gulong) (long_val)) & 0xff000000U) >> 24)))
#define GULONG_SWAP_LE_PDP(long_val) (((gulong) \
(((gulong) (long_val)) & 0x0000ffffU) << 16) | \
(((gulong) (long_val)) & 0xffff0000U) >> 16)))
#define GULONG_SWAP_BE_PDP(long_val) (((gulong) \
(((gulong) (long_val)) & 0x000000ffU) << 8) | \
(((gulong) (long_val)) & 0x0000ff00U) >> 8) | \
(((gulong) (long_val)) & 0x00ff0000U) << 8) | \
(((gulong) (long_val)) & 0xff000000U) >> 8)))
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
# define GLONG_TO_LE(long_val) ((glong) (long_val))
# define GULONG_TO_LE(long_val) ((gulong) (long_val))
# define GLONG_TO_BE(long_val) ((glong) GULONG_SWAP_LE_BE (long_val))
# define GULONG_TO_BE(long_val) (GULONG_SWAP_LE_BE (long_val))
# define GLONG_FROM_LE(long_val) ((glong) (long_val))
# define GULONG_FROM_LE(long_val) ((gulong) (long_val))
# define GLONG_FROM_BE(long_val) ((glong) GULONG_SWAP_LE_BE (long_val))
# define GULONG_FROM_BE(long_val) (GULONG_SWAP_LE_BE (long_val))
#elif G_BYTE_ORDER == G_BIG_ENDIAN
# define GLONG_TO_LE(long_val) ((glong) GULONG_SWAP_LE_BE (long_val))
# define GULONG_TO_LE(long_val) (GULONG_SWAP_LE_BE (long_val))
# define GLONG_TO_BE(long_val) ((glong) (long_val))
# define GULONG_TO_BE(long_val) ((gulong) (long_val))
# define GLONG_FROM_LE(long_val) ((glong) GULONG_SWAP_LE_BE (long_val))
# define GULONG_FROM_LE(long_val) (GULONG_SWAP_LE_BE (long_val))
# define GLONG_FROM_BE(long_val) ((glong) (long_val))
# define GULONG_FROM_BE(long_val) ((gulong) (long_val))
#endif
/* Provide type definitions for commonly used types.
* These are useful because a "gint8" can be adjusted
* to be 1 byte (8 bits) on all platforms. Similarly and
@ -645,6 +597,222 @@ typedef guint32 GQuark;
typedef gint32 GTime;
/* Portable endian checks and conversions
*/
#define G_LITTLE_ENDIAN 1234
#define G_BIG_ENDIAN 4321
#define G_PDP_ENDIAN 3412 /* unused, need specific PDP check */
#ifdef WORDS_BIGENDIAN
#define G_BYTE_ORDER G_BIG_ENDIAN
#else
#define G_BYTE_ORDER G_LITTLE_ENDIAN
#endif
/* Basic bit swapping functions
*/
#define GUINT16_SWAP_LE_BE_CONSTANT(val) ((guint16) ( \
(((guint16) (val) & (guint16) 0x00ffU) << 8) | \
(((guint16) (val) & (guint16) 0xff00U) >> 8)))
#define GUINT32_SWAP_LE_BE_CONSTANT(val) ((guint32) ( \
(((guint32) (val) & (guint32) 0x000000ffU) << 24) | \
(((guint32) (val) & (guint32) 0x0000ff00U) << 8) | \
(((guint32) (val) & (guint32) 0x00ff0000U) >> 8) | \
(((guint32) (val) & (guint32) 0xff000000U) >> 24)))
/* Intel specific stuff for speed
*/
#if defined (__i386__) && (defined __GNUC__)
# define GUINT16_SWAP_LE_BE_X86(val) \
(__extension__ \
({ register guint16 __v; \
if (__builtin_constant_p (val)) \
__v = GUINT16_SWAP_LE_BE_CONSTANT (val); \
else \
__asm__ __volatile__ ("rorw $8, %w0" \
: "=r" (__v) \
: "0" ((guint16) (val)) \
: "cc"); \
__v; }))
# define GUINT16_SWAP_LE_BE(val) \
((guint16) GUINT16_SWAP_LE_BE_X86 ((guint16) (val)))
# if !defined(__i486__) && !defined(__i586__) \
&& !defined(__pentium__) && !defined(__pentiumpro__) && !defined(__i686__)
# define GUINT32_SWAP_LE_BE_X86(val) \
(__extension__ \
({ register guint32 __v; \
if (__builtin_constant_p (val)) \
__v = GUINT32_SWAP_LE_BE_CONSTANT (val); \
else \
__asm__ __volatile__ ("rorw $8, %w0\n\t" \
"rorl $16, %0\n\t" \
"rorw $8, %w0" \
: "=r" (__v) \
: "0" ((guint32) (val)) \
: "cc"); \
__v; }))
# else /* 486 and higher has bswap */
# define GUINT32_SWAP_LE_BE_X86(val) \
(__extension__ \
({ register guint32 __v; \
if (__builtin_constant_p (val)) \
__v = GUINT32_SWAP_LE_BE_CONSTANT (val); \
else \
__asm__ __volatile__ ("bswap %0" \
: "=r" (__v) \
: "0" ((guint32) (val))); \
__v; }))
# endif /* processor specific 32-bit stuff */
# define GUINT32_SWAP_LE_BE(val) \
((guint32) GUINT32_SWAP_LE_BE_X86 ((guint32) (val)))
#else /* !__i386__ */
# define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_CONSTANT (val))
# define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_CONSTANT (val))
#endif /* __i386__ */
#ifdef HAVE_GINT64
#define GUINT64_SWAP_LE_BE(val) ((guint64) ( \
(((guint64) (val) & (guint64) 0x00000000000000ffU) << 56) | \
(((guint64) (val) & (guint64) 0x000000000000ff00U) << 40) | \
(((guint64) (val) & (guint64) 0x0000000000ff0000U) << 24) | \
(((guint64) (val) & (guint64) 0x00000000ff000000U) << 8) | \
(((guint64) (val) & (guint64) 0x000000ff00000000U) >> 8) | \
(((guint64) (val) & (guint64) 0x0000ff0000000000U) >> 24) | \
(((guint64) (val) & (guint64) 0x00ff000000000000U) >> 40) | \
(((guint64) (val) & (guint64) 0xff00000000000000U) >> 56)))
#endif
#define GUINT16_SWAP_LE_PDP(val) ((guint16) (val))
#define GUINT16_SWAP_BE_PDP(val) (GUINT16_SWAP_LE_BE (val))
#define GUINT32_SWAP_LE_PDP(val) ((guint32) ( \
(((guint32) (val) & (guint32) 0x0000ffffU) << 16) | \
(((guint32) (val) & (guint32) 0xffff0000U) >> 16)))
#define GUINT32_SWAP_BE_PDP(val) ((guint32) ( \
(((guint32) (val) & (guint32) 0x00ff00ffU) << 8) | \
(((guint32) (val) & (guint32) 0xff00ff00U) >> 8)))
#if G_BYTE_ORDER == G_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))
# define GINT16_FROM_LE(val) ((gint16) (val))
# define GUINT16_FROM_LE(val) ((guint16) (val))
# define GINT16_FROM_BE(val) ((gint16) GUINT16_SWAP_LE_BE (val))
# define GUINT16_FROM_BE(val) (GUINT16_SWAP_LE_BE (val))
# 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))
# define GINT32_FROM_LE(val) ((gint32) (val))
# define GUINT32_FROM_LE(val) ((guint32) (val))
# define GINT32_FROM_BE(val) ((gint32) GUINT32_SWAP_LE_BE (val))
# define GUINT32_FROM_BE(val) (GUINT32_SWAP_LE_BE (val))
# ifdef HAVE_GINT64
# 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))
# define GINT64_FROM_LE(val) ((gint64) (val))
# define GUINT64_FROM_LE(val) ((guint64) (val))
# define GINT64_FROM_BE(val) ((gint64) GUINT64_SWAP_LE_BE (val))
# define GUINT64_FROM_BE(val) (GUINT64_SWAP_LE_BE (val))
# endif
#elif G_BYTE_ORDER == G_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))
# define GINT16_FROM_BE(val) ((gint16) (val))
# define GUINT16_FROM_BE(val) ((guint16) (val))
# define GINT16_FROM_LE(val) ((gint16) GUINT16_SWAP_LE_BE (val))
# define GUINT16_FROM_LE(val) (GUINT16_SWAP_LE_BE (val))
# 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))
# define GINT32_FROM_BE(val) ((gint32) (val))
# define GUINT32_FROM_BE(val) ((guint32) (val))
# define GINT32_FROM_LE(val) ((gint32) GUINT32_SWAP_LE_BE (val))
# define GUINT32_FROM_LE(val) (GUINT32_SWAP_LE_BE (val))
# ifdef HAVE_GINT64
# 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))
# define GINT64_FROM_BE(val) ((gint64) (val))
# define GUINT64_FROM_BE(val) ((guint64) (val))
# define GINT64_FROM_LE(val) ((gint64) GUINT64_SWAP_LE_BE (val))
# define GUINT64_FROM_LE(val) (GUINT64_SWAP_LE_BE (val))
# endif
#else
/* PDP stuff not implemented */
#endif
#if (SIZEOF_LONG == 8)
# define GLONG_TO_LE(val) ((glong) GINT64_TO_LE (val))
# define GULONG_TO_LE(val) ((gulong) GUINT64_TO_LE (val))
# define GLONG_TO_BE(val) ((glong) GINT64_TO_BE (val))
# define GULONG_TO_BE(val) ((gulong) GUINT64_TO_BE (val))
# define GLONG_FROM_LE(val) ((glong) GINT64_FROM_LE (val))
# define GULONG_FROM_LE(val) ((gulong) GUINT64_FROM_LE (val))
# define GLONG_FROM_BE(val) ((glong) GINT64_FROM_BE (val))
# define GULONG_FROM_BE(val) ((gulong) GUINT64_FROM_BE (val))
#elif (SIZEOF_LONG == 4)
# 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 GLONG_FROM_LE(val) ((glong) GINT32_FROM_LE (val))
# define GULONG_FROM_LE(val) ((gulong) GUINT32_FROM_LE (val))
# define GLONG_FROM_BE(val) ((glong) GINT32_FROM_BE (val))
# define GULONG_FROM_BE(val) ((gulong) GUINT32_FROM_BE (val))
#endif
#if (SIZEOF_INT == 8)
# define GINT_TO_LE(val) ((gint) GINT64_TO_LE (val))
# define GUINT_TO_LE(val) ((guint) GUINT64_TO_LE (val))
# define GINT_TO_BE(val) ((gint) GINT64_TO_BE (val))
# define GUINT_TO_BE(val) ((guint) GUINT64_TO_BE (val))
# define GINT_FROM_LE(val) ((gint) GINT64_FROM_LE (val))
# define GUINT_FROM_LE(val) ((guint) GUINT64_FROM_LE (val))
# define GINT_FROM_BE(val) ((gint) GINT64_FROM_BE (val))
# define GUINT_FROM_BE(val) ((guint) GUINT64_FROM_BE (val))
#elif (SIZEOF_INT == 4)
# 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 GINT_FROM_LE(val) ((gint) GINT32_FROM_LE (val))
# define GUINT_FROM_LE(val) ((guint) GUINT32_FROM_LE (val))
# define GINT_FROM_BE(val) ((gint) GINT32_FROM_BE (val))
# define GUINT_FROM_BE(val) ((guint) GUINT32_FROM_BE (val))
#elif (SIZEOF_INT == 2)
# define GINT_TO_LE(val) ((gint) GINT16_TO_LE (val))
# define GUINT_TO_LE(val) ((guint) GUINT16_TO_LE (val))
# define GINT_TO_BE(val) ((gint) GINT16_TO_BE (val))
# define GUINT_TO_BE(val) ((guint) GUINT16_TO_BE (val))
# define GINT_FROM_LE(val) ((gint) GINT16_FROM_LE (val))
# define GUINT_FROM_LE(val) ((guint) GUINT16_FROM_LE (val))
# define GINT_FROM_BE(val) ((gint) GINT16_FROM_BE (val))
# define GUINT_FROM_BE(val) ((guint) GUINT16_FROM_BE (val))
#endif
/* Portable versions of host-network order stuff
*/
#define g_ntohl(val) (GUINT32_FROM_BE (val))
#define g_ntohs(val) (GUINT16_FROM_BE (val))
#define g_htonl(val) (GUINT32_TO_BE (val))
#define g_htons(val) (GUINT16_TO_BE (val))
/* Glib version.
* we prefix variable declarations so they can
* properly get exported in windows dlls.

View File

@ -335,7 +335,7 @@ extern "C" {
* Actual use is strongly deprecated of course ;)
*/
#if defined (__i386__) && defined (__GNUC__)
#define G_BREAKPOINT() G_STMT_START{ __asm__ volatile ("int $03"); }G_STMT_END
#define G_BREAKPOINT() G_STMT_START{ __asm__ __volatile__ ("int $03"); }G_STMT_END
#else /* !__i386__ */
#define G_BREAKPOINT()
#endif /* __i386__ */
@ -502,54 +502,6 @@ extern "C" {
#endif /* !G_DISABLE_CHECKS */
/* Portable endian checks and conversions
*/
#define G_LITTLE_ENDIAN 1234
#define G_BIG_ENDIAN 4321
#define G_PDP_ENDIAN 3412 / /* unused, need specific PDP check */
#ifdef WORDS_BIGENDIAN
#define G_BYTE_ORDER G_BIG_ENDIAN
#else
#define G_BYTE_ORDER G_LITTLE_ENDIAN
#endif
#define GULONG_SWAP_LE_BE(long_val) (((gulong) \
(((gulong) (long_val)) & 0x000000ffU) << 24) | \
(((gulong) (long_val)) & 0x0000ff00U) << 8) | \
(((gulong) (long_val)) & 0x00ff0000U) >> 8) | \
(((gulong) (long_val)) & 0xff000000U) >> 24)))
#define GULONG_SWAP_LE_PDP(long_val) (((gulong) \
(((gulong) (long_val)) & 0x0000ffffU) << 16) | \
(((gulong) (long_val)) & 0xffff0000U) >> 16)))
#define GULONG_SWAP_BE_PDP(long_val) (((gulong) \
(((gulong) (long_val)) & 0x000000ffU) << 8) | \
(((gulong) (long_val)) & 0x0000ff00U) >> 8) | \
(((gulong) (long_val)) & 0x00ff0000U) << 8) | \
(((gulong) (long_val)) & 0xff000000U) >> 8)))
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
# define GLONG_TO_LE(long_val) ((glong) (long_val))
# define GULONG_TO_LE(long_val) ((gulong) (long_val))
# define GLONG_TO_BE(long_val) ((glong) GULONG_SWAP_LE_BE (long_val))
# define GULONG_TO_BE(long_val) (GULONG_SWAP_LE_BE (long_val))
# define GLONG_FROM_LE(long_val) ((glong) (long_val))
# define GULONG_FROM_LE(long_val) ((gulong) (long_val))
# define GLONG_FROM_BE(long_val) ((glong) GULONG_SWAP_LE_BE (long_val))
# define GULONG_FROM_BE(long_val) (GULONG_SWAP_LE_BE (long_val))
#elif G_BYTE_ORDER == G_BIG_ENDIAN
# define GLONG_TO_LE(long_val) ((glong) GULONG_SWAP_LE_BE (long_val))
# define GULONG_TO_LE(long_val) (GULONG_SWAP_LE_BE (long_val))
# define GLONG_TO_BE(long_val) ((glong) (long_val))
# define GULONG_TO_BE(long_val) ((gulong) (long_val))
# define GLONG_FROM_LE(long_val) ((glong) GULONG_SWAP_LE_BE (long_val))
# define GULONG_FROM_LE(long_val) (GULONG_SWAP_LE_BE (long_val))
# define GLONG_FROM_BE(long_val) ((glong) (long_val))
# define GULONG_FROM_BE(long_val) ((gulong) (long_val))
#endif
/* Provide type definitions for commonly used types.
* These are useful because a "gint8" can be adjusted
* to be 1 byte (8 bits) on all platforms. Similarly and
@ -645,6 +597,222 @@ typedef guint32 GQuark;
typedef gint32 GTime;
/* Portable endian checks and conversions
*/
#define G_LITTLE_ENDIAN 1234
#define G_BIG_ENDIAN 4321
#define G_PDP_ENDIAN 3412 /* unused, need specific PDP check */
#ifdef WORDS_BIGENDIAN
#define G_BYTE_ORDER G_BIG_ENDIAN
#else
#define G_BYTE_ORDER G_LITTLE_ENDIAN
#endif
/* Basic bit swapping functions
*/
#define GUINT16_SWAP_LE_BE_CONSTANT(val) ((guint16) ( \
(((guint16) (val) & (guint16) 0x00ffU) << 8) | \
(((guint16) (val) & (guint16) 0xff00U) >> 8)))
#define GUINT32_SWAP_LE_BE_CONSTANT(val) ((guint32) ( \
(((guint32) (val) & (guint32) 0x000000ffU) << 24) | \
(((guint32) (val) & (guint32) 0x0000ff00U) << 8) | \
(((guint32) (val) & (guint32) 0x00ff0000U) >> 8) | \
(((guint32) (val) & (guint32) 0xff000000U) >> 24)))
/* Intel specific stuff for speed
*/
#if defined (__i386__) && (defined __GNUC__)
# define GUINT16_SWAP_LE_BE_X86(val) \
(__extension__ \
({ register guint16 __v; \
if (__builtin_constant_p (val)) \
__v = GUINT16_SWAP_LE_BE_CONSTANT (val); \
else \
__asm__ __volatile__ ("rorw $8, %w0" \
: "=r" (__v) \
: "0" ((guint16) (val)) \
: "cc"); \
__v; }))
# define GUINT16_SWAP_LE_BE(val) \
((guint16) GUINT16_SWAP_LE_BE_X86 ((guint16) (val)))
# if !defined(__i486__) && !defined(__i586__) \
&& !defined(__pentium__) && !defined(__pentiumpro__) && !defined(__i686__)
# define GUINT32_SWAP_LE_BE_X86(val) \
(__extension__ \
({ register guint32 __v; \
if (__builtin_constant_p (val)) \
__v = GUINT32_SWAP_LE_BE_CONSTANT (val); \
else \
__asm__ __volatile__ ("rorw $8, %w0\n\t" \
"rorl $16, %0\n\t" \
"rorw $8, %w0" \
: "=r" (__v) \
: "0" ((guint32) (val)) \
: "cc"); \
__v; }))
# else /* 486 and higher has bswap */
# define GUINT32_SWAP_LE_BE_X86(val) \
(__extension__ \
({ register guint32 __v; \
if (__builtin_constant_p (val)) \
__v = GUINT32_SWAP_LE_BE_CONSTANT (val); \
else \
__asm__ __volatile__ ("bswap %0" \
: "=r" (__v) \
: "0" ((guint32) (val))); \
__v; }))
# endif /* processor specific 32-bit stuff */
# define GUINT32_SWAP_LE_BE(val) \
((guint32) GUINT32_SWAP_LE_BE_X86 ((guint32) (val)))
#else /* !__i386__ */
# define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_CONSTANT (val))
# define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_CONSTANT (val))
#endif /* __i386__ */
#ifdef HAVE_GINT64
#define GUINT64_SWAP_LE_BE(val) ((guint64) ( \
(((guint64) (val) & (guint64) 0x00000000000000ffU) << 56) | \
(((guint64) (val) & (guint64) 0x000000000000ff00U) << 40) | \
(((guint64) (val) & (guint64) 0x0000000000ff0000U) << 24) | \
(((guint64) (val) & (guint64) 0x00000000ff000000U) << 8) | \
(((guint64) (val) & (guint64) 0x000000ff00000000U) >> 8) | \
(((guint64) (val) & (guint64) 0x0000ff0000000000U) >> 24) | \
(((guint64) (val) & (guint64) 0x00ff000000000000U) >> 40) | \
(((guint64) (val) & (guint64) 0xff00000000000000U) >> 56)))
#endif
#define GUINT16_SWAP_LE_PDP(val) ((guint16) (val))
#define GUINT16_SWAP_BE_PDP(val) (GUINT16_SWAP_LE_BE (val))
#define GUINT32_SWAP_LE_PDP(val) ((guint32) ( \
(((guint32) (val) & (guint32) 0x0000ffffU) << 16) | \
(((guint32) (val) & (guint32) 0xffff0000U) >> 16)))
#define GUINT32_SWAP_BE_PDP(val) ((guint32) ( \
(((guint32) (val) & (guint32) 0x00ff00ffU) << 8) | \
(((guint32) (val) & (guint32) 0xff00ff00U) >> 8)))
#if G_BYTE_ORDER == G_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))
# define GINT16_FROM_LE(val) ((gint16) (val))
# define GUINT16_FROM_LE(val) ((guint16) (val))
# define GINT16_FROM_BE(val) ((gint16) GUINT16_SWAP_LE_BE (val))
# define GUINT16_FROM_BE(val) (GUINT16_SWAP_LE_BE (val))
# 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))
# define GINT32_FROM_LE(val) ((gint32) (val))
# define GUINT32_FROM_LE(val) ((guint32) (val))
# define GINT32_FROM_BE(val) ((gint32) GUINT32_SWAP_LE_BE (val))
# define GUINT32_FROM_BE(val) (GUINT32_SWAP_LE_BE (val))
# ifdef HAVE_GINT64
# 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))
# define GINT64_FROM_LE(val) ((gint64) (val))
# define GUINT64_FROM_LE(val) ((guint64) (val))
# define GINT64_FROM_BE(val) ((gint64) GUINT64_SWAP_LE_BE (val))
# define GUINT64_FROM_BE(val) (GUINT64_SWAP_LE_BE (val))
# endif
#elif G_BYTE_ORDER == G_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))
# define GINT16_FROM_BE(val) ((gint16) (val))
# define GUINT16_FROM_BE(val) ((guint16) (val))
# define GINT16_FROM_LE(val) ((gint16) GUINT16_SWAP_LE_BE (val))
# define GUINT16_FROM_LE(val) (GUINT16_SWAP_LE_BE (val))
# 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))
# define GINT32_FROM_BE(val) ((gint32) (val))
# define GUINT32_FROM_BE(val) ((guint32) (val))
# define GINT32_FROM_LE(val) ((gint32) GUINT32_SWAP_LE_BE (val))
# define GUINT32_FROM_LE(val) (GUINT32_SWAP_LE_BE (val))
# ifdef HAVE_GINT64
# 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))
# define GINT64_FROM_BE(val) ((gint64) (val))
# define GUINT64_FROM_BE(val) ((guint64) (val))
# define GINT64_FROM_LE(val) ((gint64) GUINT64_SWAP_LE_BE (val))
# define GUINT64_FROM_LE(val) (GUINT64_SWAP_LE_BE (val))
# endif
#else
/* PDP stuff not implemented */
#endif
#if (SIZEOF_LONG == 8)
# define GLONG_TO_LE(val) ((glong) GINT64_TO_LE (val))
# define GULONG_TO_LE(val) ((gulong) GUINT64_TO_LE (val))
# define GLONG_TO_BE(val) ((glong) GINT64_TO_BE (val))
# define GULONG_TO_BE(val) ((gulong) GUINT64_TO_BE (val))
# define GLONG_FROM_LE(val) ((glong) GINT64_FROM_LE (val))
# define GULONG_FROM_LE(val) ((gulong) GUINT64_FROM_LE (val))
# define GLONG_FROM_BE(val) ((glong) GINT64_FROM_BE (val))
# define GULONG_FROM_BE(val) ((gulong) GUINT64_FROM_BE (val))
#elif (SIZEOF_LONG == 4)
# 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 GLONG_FROM_LE(val) ((glong) GINT32_FROM_LE (val))
# define GULONG_FROM_LE(val) ((gulong) GUINT32_FROM_LE (val))
# define GLONG_FROM_BE(val) ((glong) GINT32_FROM_BE (val))
# define GULONG_FROM_BE(val) ((gulong) GUINT32_FROM_BE (val))
#endif
#if (SIZEOF_INT == 8)
# define GINT_TO_LE(val) ((gint) GINT64_TO_LE (val))
# define GUINT_TO_LE(val) ((guint) GUINT64_TO_LE (val))
# define GINT_TO_BE(val) ((gint) GINT64_TO_BE (val))
# define GUINT_TO_BE(val) ((guint) GUINT64_TO_BE (val))
# define GINT_FROM_LE(val) ((gint) GINT64_FROM_LE (val))
# define GUINT_FROM_LE(val) ((guint) GUINT64_FROM_LE (val))
# define GINT_FROM_BE(val) ((gint) GINT64_FROM_BE (val))
# define GUINT_FROM_BE(val) ((guint) GUINT64_FROM_BE (val))
#elif (SIZEOF_INT == 4)
# 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 GINT_FROM_LE(val) ((gint) GINT32_FROM_LE (val))
# define GUINT_FROM_LE(val) ((guint) GUINT32_FROM_LE (val))
# define GINT_FROM_BE(val) ((gint) GINT32_FROM_BE (val))
# define GUINT_FROM_BE(val) ((guint) GUINT32_FROM_BE (val))
#elif (SIZEOF_INT == 2)
# define GINT_TO_LE(val) ((gint) GINT16_TO_LE (val))
# define GUINT_TO_LE(val) ((guint) GUINT16_TO_LE (val))
# define GINT_TO_BE(val) ((gint) GINT16_TO_BE (val))
# define GUINT_TO_BE(val) ((guint) GUINT16_TO_BE (val))
# define GINT_FROM_LE(val) ((gint) GINT16_FROM_LE (val))
# define GUINT_FROM_LE(val) ((guint) GUINT16_FROM_LE (val))
# define GINT_FROM_BE(val) ((gint) GINT16_FROM_BE (val))
# define GUINT_FROM_BE(val) ((guint) GUINT16_FROM_BE (val))
#endif
/* Portable versions of host-network order stuff
*/
#define g_ntohl(val) (GUINT32_FROM_BE (val))
#define g_ntohs(val) (GUINT16_FROM_BE (val))
#define g_htonl(val) (GUINT32_TO_BE (val))
#define g_htons(val) (GUINT16_TO_BE (val))
/* Glib version.
* we prefix variable declarations so they can
* properly get exported in windows dlls.

View File

@ -552,7 +552,9 @@ g_iochannel_close_and_free (GIOChannel *channel)
void
g_iochannel_wakeup_peer (GIOChannel *channel)
{
#ifdef NATIVE_WIN32
static guint message = 0;
#endif
g_return_if_fail (channel != NULL);

View File

@ -552,7 +552,9 @@ g_iochannel_close_and_free (GIOChannel *channel)
void
g_iochannel_wakeup_peer (GIOChannel *channel)
{
#ifdef NATIVE_WIN32
static guint message = 0;
#endif
g_return_if_fail (channel != NULL);

View File

@ -321,6 +321,11 @@ main (int argc,
#endif
};
guint n_dirname_checks = sizeof (dirname_checks) / sizeof (dirname_checks[0]);
guint16 gu16t1 = 0x44afU, gu16t2 = 0xaf44U;
guint32 gu32t1 = 0x02a7f109U, gu32t2 = 0x09f1a702U;
#ifdef HAVE_GINT64
guint64 gu64t1 = 0x1d636b02300a7aa7U, gu64t2 = 0xa77a0a30026b631dU;
#endif
g_print ("TestGLib v%u.%u.%u (i:%u b:%u)\n",
glib_major_version,
@ -811,5 +816,18 @@ main (int argc,
string = NULL;
g_print (string);
g_print ("endian macro tests...");
#if G_BYTE_ORDER == G_BIG_ENDIAN
g_print ("big endian...");
#else
g_print ("little endian...");
#endif
g_assert (GUINT16_SWAP_LE_BE (gu16t1) == gu16t2);
g_assert (GUINT32_SWAP_LE_BE (gu32t1) == gu32t2);
#ifdef HAVE_GINT64
g_assert (GUINT64_SWAP_LE_BE (gu64t1) == gu64t2);
#endif
g_print ("ok\n");
return 0;
}

View File

@ -321,6 +321,11 @@ main (int argc,
#endif
};
guint n_dirname_checks = sizeof (dirname_checks) / sizeof (dirname_checks[0]);
guint16 gu16t1 = 0x44afU, gu16t2 = 0xaf44U;
guint32 gu32t1 = 0x02a7f109U, gu32t2 = 0x09f1a702U;
#ifdef HAVE_GINT64
guint64 gu64t1 = 0x1d636b02300a7aa7U, gu64t2 = 0xa77a0a30026b631dU;
#endif
g_print ("TestGLib v%u.%u.%u (i:%u b:%u)\n",
glib_major_version,
@ -811,5 +816,18 @@ main (int argc,
string = NULL;
g_print (string);
g_print ("endian macro tests...");
#if G_BYTE_ORDER == G_BIG_ENDIAN
g_print ("big endian...");
#else
g_print ("little endian...");
#endif
g_assert (GUINT16_SWAP_LE_BE (gu16t1) == gu16t2);
g_assert (GUINT32_SWAP_LE_BE (gu32t1) == gu32t2);
#ifdef HAVE_GINT64
g_assert (GUINT64_SWAP_LE_BE (gu64t1) == gu64t2);
#endif
g_print ("ok\n");
return 0;
}