From 0b42c37e7d91a517372108e99105556f5146b0b5 Mon Sep 17 00:00:00 2001 From: Tim Janik Date: Mon, 7 Sep 1998 09:43:54 +0000 Subject: [PATCH] check for all three inline keywords individually. Mon Sep 7 07:53:21 1998 Tim Janik * configure.in: check for all three inline keywords individually. * glib.h: inlining hassle. for compilers that don't allow the `inline' keyword, mostly because of strict ANSI C compliance or dumbness, we try to fall back to either `__inline__' or `__inline'. we define G_CAN_INLINE, if the compiler seems to be actually *capable* to do function inlining, in which case inline function bodys do make sense. we also define G_INLINE_FUNC to properly export the function prototypes if no inlinig can be performed. we special case most of the stuff, so inline functions can have a normal implementation by defining G_INLINE_FUNC to extern and G_CAN_INLINE to 1. * ltconfig: (compiler PIC flag test): special case linux for non aout systems to honour lcc's position independant code (cases "linux*aout)" and "linux*)" got added). (this needs to go into libtool which does an advanced test, checking for __LCC__). * autogen.sh: take $CC=lcc into account by invoking automake with --include-deps so lcc isn't scared by gcc's auto-dependancy generation code. care about $ACLOCAL_FLAGS. optionally feature autoheader. * minor fixups in other places to cure some of lcc's warnings. --- ChangeLog | 26 +++++++++ ChangeLog.pre-2-0 | 26 +++++++++ ChangeLog.pre-2-10 | 26 +++++++++ ChangeLog.pre-2-12 | 26 +++++++++ ChangeLog.pre-2-2 | 26 +++++++++ ChangeLog.pre-2-4 | 26 +++++++++ ChangeLog.pre-2-6 | 26 +++++++++ ChangeLog.pre-2-8 | 26 +++++++++ acconfig.h | 5 ++ autogen.sh | 27 +++++++--- configure.in | 59 ++++++++++++++++++-- garray.c | 2 +- glib.h | 130 ++++++++++++++++++++++++++++----------------- glib/garray.c | 2 +- glib/glib.h | 130 ++++++++++++++++++++++++++++----------------- glib/gmessages.c | 1 + glib/gscanner.c | 4 +- glib/gutils.c | 8 +-- glibconfig.h.in | 6 +-- gmessages.c | 1 + gscanner.c | 4 +- gutils.c | 8 +-- ltconfig | 16 ++++++ testglib.c | 2 +- tests/testglib.c | 2 +- 25 files changed, 484 insertions(+), 131 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4a3d932b..47b5bd3a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,29 @@ +Mon Sep 7 07:53:21 1998 Tim Janik + + * configure.in: check for all three inline keywords individually. + + * glib.h: inlining hassle. for compilers that don't allow the `inline' + keyword, mostly because of strict ANSI C compliance or dumbness, we try + to fall back to either `__inline__' or `__inline'. + we define G_CAN_INLINE, if the compiler seems to be actually *capable* + to do function inlining, in which case inline function bodys do make + sense. we also define G_INLINE_FUNC to properly export the function + prototypes if no inlinig can be performed. we special case most of the + stuff, so inline functions can have a normal implementation by defining + G_INLINE_FUNC to extern and G_CAN_INLINE to 1. + + * ltconfig: (compiler PIC flag test): special case linux for non + aout systems to honour lcc's position independant code (cases + "linux*aout)" and "linux*)" got added). (this needs to go into + libtool which does an advanced test, checking for __LCC__). + + * autogen.sh: take $CC=lcc into account by invoking automake with + --include-deps so lcc isn't scared by gcc's auto-dependancy + generation code. care about $ACLOCAL_FLAGS. optionally feature + autoheader. + + * minor fixups in other places to cure some of lcc's warnings. + Sun Sep 6 19:08:53 PDT 1998 Manish Singh * configure.in: added -std1 check for ANSI compliance (from gtk) diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 4a3d932b..47b5bd3a 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,29 @@ +Mon Sep 7 07:53:21 1998 Tim Janik + + * configure.in: check for all three inline keywords individually. + + * glib.h: inlining hassle. for compilers that don't allow the `inline' + keyword, mostly because of strict ANSI C compliance or dumbness, we try + to fall back to either `__inline__' or `__inline'. + we define G_CAN_INLINE, if the compiler seems to be actually *capable* + to do function inlining, in which case inline function bodys do make + sense. we also define G_INLINE_FUNC to properly export the function + prototypes if no inlinig can be performed. we special case most of the + stuff, so inline functions can have a normal implementation by defining + G_INLINE_FUNC to extern and G_CAN_INLINE to 1. + + * ltconfig: (compiler PIC flag test): special case linux for non + aout systems to honour lcc's position independant code (cases + "linux*aout)" and "linux*)" got added). (this needs to go into + libtool which does an advanced test, checking for __LCC__). + + * autogen.sh: take $CC=lcc into account by invoking automake with + --include-deps so lcc isn't scared by gcc's auto-dependancy + generation code. care about $ACLOCAL_FLAGS. optionally feature + autoheader. + + * minor fixups in other places to cure some of lcc's warnings. + Sun Sep 6 19:08:53 PDT 1998 Manish Singh * configure.in: added -std1 check for ANSI compliance (from gtk) diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 4a3d932b..47b5bd3a 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,29 @@ +Mon Sep 7 07:53:21 1998 Tim Janik + + * configure.in: check for all three inline keywords individually. + + * glib.h: inlining hassle. for compilers that don't allow the `inline' + keyword, mostly because of strict ANSI C compliance or dumbness, we try + to fall back to either `__inline__' or `__inline'. + we define G_CAN_INLINE, if the compiler seems to be actually *capable* + to do function inlining, in which case inline function bodys do make + sense. we also define G_INLINE_FUNC to properly export the function + prototypes if no inlinig can be performed. we special case most of the + stuff, so inline functions can have a normal implementation by defining + G_INLINE_FUNC to extern and G_CAN_INLINE to 1. + + * ltconfig: (compiler PIC flag test): special case linux for non + aout systems to honour lcc's position independant code (cases + "linux*aout)" and "linux*)" got added). (this needs to go into + libtool which does an advanced test, checking for __LCC__). + + * autogen.sh: take $CC=lcc into account by invoking automake with + --include-deps so lcc isn't scared by gcc's auto-dependancy + generation code. care about $ACLOCAL_FLAGS. optionally feature + autoheader. + + * minor fixups in other places to cure some of lcc's warnings. + Sun Sep 6 19:08:53 PDT 1998 Manish Singh * configure.in: added -std1 check for ANSI compliance (from gtk) diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 4a3d932b..47b5bd3a 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,29 @@ +Mon Sep 7 07:53:21 1998 Tim Janik + + * configure.in: check for all three inline keywords individually. + + * glib.h: inlining hassle. for compilers that don't allow the `inline' + keyword, mostly because of strict ANSI C compliance or dumbness, we try + to fall back to either `__inline__' or `__inline'. + we define G_CAN_INLINE, if the compiler seems to be actually *capable* + to do function inlining, in which case inline function bodys do make + sense. we also define G_INLINE_FUNC to properly export the function + prototypes if no inlinig can be performed. we special case most of the + stuff, so inline functions can have a normal implementation by defining + G_INLINE_FUNC to extern and G_CAN_INLINE to 1. + + * ltconfig: (compiler PIC flag test): special case linux for non + aout systems to honour lcc's position independant code (cases + "linux*aout)" and "linux*)" got added). (this needs to go into + libtool which does an advanced test, checking for __LCC__). + + * autogen.sh: take $CC=lcc into account by invoking automake with + --include-deps so lcc isn't scared by gcc's auto-dependancy + generation code. care about $ACLOCAL_FLAGS. optionally feature + autoheader. + + * minor fixups in other places to cure some of lcc's warnings. + Sun Sep 6 19:08:53 PDT 1998 Manish Singh * configure.in: added -std1 check for ANSI compliance (from gtk) diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 4a3d932b..47b5bd3a 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,29 @@ +Mon Sep 7 07:53:21 1998 Tim Janik + + * configure.in: check for all three inline keywords individually. + + * glib.h: inlining hassle. for compilers that don't allow the `inline' + keyword, mostly because of strict ANSI C compliance or dumbness, we try + to fall back to either `__inline__' or `__inline'. + we define G_CAN_INLINE, if the compiler seems to be actually *capable* + to do function inlining, in which case inline function bodys do make + sense. we also define G_INLINE_FUNC to properly export the function + prototypes if no inlinig can be performed. we special case most of the + stuff, so inline functions can have a normal implementation by defining + G_INLINE_FUNC to extern and G_CAN_INLINE to 1. + + * ltconfig: (compiler PIC flag test): special case linux for non + aout systems to honour lcc's position independant code (cases + "linux*aout)" and "linux*)" got added). (this needs to go into + libtool which does an advanced test, checking for __LCC__). + + * autogen.sh: take $CC=lcc into account by invoking automake with + --include-deps so lcc isn't scared by gcc's auto-dependancy + generation code. care about $ACLOCAL_FLAGS. optionally feature + autoheader. + + * minor fixups in other places to cure some of lcc's warnings. + Sun Sep 6 19:08:53 PDT 1998 Manish Singh * configure.in: added -std1 check for ANSI compliance (from gtk) diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 4a3d932b..47b5bd3a 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,29 @@ +Mon Sep 7 07:53:21 1998 Tim Janik + + * configure.in: check for all three inline keywords individually. + + * glib.h: inlining hassle. for compilers that don't allow the `inline' + keyword, mostly because of strict ANSI C compliance or dumbness, we try + to fall back to either `__inline__' or `__inline'. + we define G_CAN_INLINE, if the compiler seems to be actually *capable* + to do function inlining, in which case inline function bodys do make + sense. we also define G_INLINE_FUNC to properly export the function + prototypes if no inlinig can be performed. we special case most of the + stuff, so inline functions can have a normal implementation by defining + G_INLINE_FUNC to extern and G_CAN_INLINE to 1. + + * ltconfig: (compiler PIC flag test): special case linux for non + aout systems to honour lcc's position independant code (cases + "linux*aout)" and "linux*)" got added). (this needs to go into + libtool which does an advanced test, checking for __LCC__). + + * autogen.sh: take $CC=lcc into account by invoking automake with + --include-deps so lcc isn't scared by gcc's auto-dependancy + generation code. care about $ACLOCAL_FLAGS. optionally feature + autoheader. + + * minor fixups in other places to cure some of lcc's warnings. + Sun Sep 6 19:08:53 PDT 1998 Manish Singh * configure.in: added -std1 check for ANSI compliance (from gtk) diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 4a3d932b..47b5bd3a 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,29 @@ +Mon Sep 7 07:53:21 1998 Tim Janik + + * configure.in: check for all three inline keywords individually. + + * glib.h: inlining hassle. for compilers that don't allow the `inline' + keyword, mostly because of strict ANSI C compliance or dumbness, we try + to fall back to either `__inline__' or `__inline'. + we define G_CAN_INLINE, if the compiler seems to be actually *capable* + to do function inlining, in which case inline function bodys do make + sense. we also define G_INLINE_FUNC to properly export the function + prototypes if no inlinig can be performed. we special case most of the + stuff, so inline functions can have a normal implementation by defining + G_INLINE_FUNC to extern and G_CAN_INLINE to 1. + + * ltconfig: (compiler PIC flag test): special case linux for non + aout systems to honour lcc's position independant code (cases + "linux*aout)" and "linux*)" got added). (this needs to go into + libtool which does an advanced test, checking for __LCC__). + + * autogen.sh: take $CC=lcc into account by invoking automake with + --include-deps so lcc isn't scared by gcc's auto-dependancy + generation code. care about $ACLOCAL_FLAGS. optionally feature + autoheader. + + * minor fixups in other places to cure some of lcc's warnings. + Sun Sep 6 19:08:53 PDT 1998 Manish Singh * configure.in: added -std1 check for ANSI compliance (from gtk) diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 4a3d932b..47b5bd3a 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,29 @@ +Mon Sep 7 07:53:21 1998 Tim Janik + + * configure.in: check for all three inline keywords individually. + + * glib.h: inlining hassle. for compilers that don't allow the `inline' + keyword, mostly because of strict ANSI C compliance or dumbness, we try + to fall back to either `__inline__' or `__inline'. + we define G_CAN_INLINE, if the compiler seems to be actually *capable* + to do function inlining, in which case inline function bodys do make + sense. we also define G_INLINE_FUNC to properly export the function + prototypes if no inlinig can be performed. we special case most of the + stuff, so inline functions can have a normal implementation by defining + G_INLINE_FUNC to extern and G_CAN_INLINE to 1. + + * ltconfig: (compiler PIC flag test): special case linux for non + aout systems to honour lcc's position independant code (cases + "linux*aout)" and "linux*)" got added). (this needs to go into + libtool which does an advanced test, checking for __LCC__). + + * autogen.sh: take $CC=lcc into account by invoking automake with + --include-deps so lcc isn't scared by gcc's auto-dependancy + generation code. care about $ACLOCAL_FLAGS. optionally feature + autoheader. + + * minor fixups in other places to cure some of lcc's warnings. + Sun Sep 6 19:08:53 PDT 1998 Manish Singh * configure.in: added -std1 check for ANSI compliance (from gtk) diff --git a/acconfig.h b/acconfig.h index 9c4e45f2..60cc36f5 100644 --- a/acconfig.h +++ b/acconfig.h @@ -64,6 +64,9 @@ #undef G_VA_COPY #undef G_VA_COPY_AS_ARRAY +#undef G_HAVE___INLINE +#undef G_HAVE___INLINE__ +#undef G_HAVE_INLINE #undef GLIB_MAJOR_VERSION #undef GLIB_MINOR_VERSION @@ -74,6 +77,8 @@ /* #undef PACKAGE */ /* #undef VERSION */ + + /* Leave that blank line there!! Autoheader needs it. If you're adding to this file, keep in mind: diff --git a/autogen.sh b/autogen.sh index d9da49b0..06b9ab19 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,11 +1,15 @@ #!/bin/sh # Run this to generate all the initial makefiles, etc. +PROJECT=GLib +TEST_TYPE=-f +FILE=glib.h + DIE=0 (autoconf --version) < /dev/null > /dev/null 2>&1 || { echo - echo "You must have autoconf installed to compile GLIB." + echo "You must have autoconf installed to compile $PROJECT." echo "Download the appropriate package for your distribution," echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" DIE=1 @@ -13,7 +17,7 @@ DIE=0 (libtool --version) < /dev/null > /dev/null 2>&1 || { echo - echo "You must have libtool installed to compile GLIB." + echo "You must have libtool installed to compile $PROJECT." echo "Get ftp://alpha.gnu.org/gnu/libtool-1.0h.tar.gz" echo "(or a newer version if it is available)" DIE=1 @@ -21,7 +25,7 @@ DIE=0 (automake --version) < /dev/null > /dev/null 2>&1 || { echo - echo "You must have automake installed to compile GLIB." + echo "You must have automake installed to compile $PROJECT." echo "Get ftp://ftp.cygnus.com/pub/home/tromey/automake-1.2d.tar.gz" echo "(or a newer version if it is available)" DIE=1 @@ -31,8 +35,8 @@ if test "$DIE" -eq 1; then exit 1 fi -test -f glib.h || { - echo "You must run this script in the top-level GLIB directory" +test $TEST_TYPE $FILE || { + echo "You must run this script in the top-level $PROJECT directory" exit 1 } @@ -41,10 +45,17 @@ if test -z "$*"; then echo "to pass any to it, please specify them on the $0 command line." fi -aclocal -automake +case $CC in +*lcc | *lcc\ *) am_opt=--include-deps;; +esac + +aclocal $ACLOCAL_FLAGS +automake $am_opt autoconf +# optionally feature autoheader +(autoheader --version) < /dev/null > /dev/null 2>&1 && autoheader + ./configure "$@" echo -echo "Now type 'make' to compile GLIB." +echo "Now type 'make' to compile $PROJECT." diff --git a/configure.in b/configure.in index c45184b5..4c64fcae 100644 --- a/configure.in +++ b/configure.in @@ -143,11 +143,61 @@ AC_CHECK_SIZEOF(int) AC_CHECK_SIZEOF(void *) AC_CHECK_SIZEOF(long long) -# long doubles were not used, and a portability problem -# AC_C_LONG_DOUBLE +dnl long doubles were not used, and a portability problem +dnl AC_C_LONG_DOUBLE AC_C_CONST -AC_C_INLINE +dnl AC_C_INLINE is useless to us since it bails out too early, we need to +dnl truely know which ones of `inline', `__inline' and `__inline__' are +dnl actually supported. +AC_MSG_CHECKING(for __inline) +AC_CACHE_VAL(glib_cv_has__inline,[ + AC_TRY_RUN([ + __inline int foo () { return 0; } + int main () { return foo (); } + ], + glib_cv_has__inline=yes + , + glib_cv_has__inline=no + ,) +]) +AC_MSG_RESULT($glib_cv_has__inline) +case x$glib_cv_has__inline in +yes) AC_DEFINE(G_HAVE___INLINE) +esac +AC_MSG_CHECKING(for __inline__) +AC_CACHE_VAL(glib_cv_has__inline__,[ + AC_TRY_RUN([ + __inline__ int foo () { return 0; } + int main () { return foo (); } + ], + glib_cv_has__inline__=yes + , + glib_cv_has__inline__=no + ,) +]) +AC_MSG_RESULT($glib_cv_has__inline__) +case x$glib_cv_has__inline__ in +yes) AC_DEFINE(G_HAVE___INLINE__) +esac +AC_MSG_CHECKING(for inline) +AC_CACHE_VAL(glib_cv_hasinline,[ + AC_TRY_RUN([ + inline int foo () { return 0; } + int main () { return foo (); } + ], + glib_cv_hasinline=yes + , + glib_cv_hasinline=no + ,) +]) +AC_MSG_RESULT($glib_cv_hasinline) +case x$glib_cv_hasinline in +yes) AC_DEFINE(G_HAVE_INLINE) +esac + + +dnl header file checks AC_CHECK_HEADERS(float.h, AC_DEFINE(HAVE_FLOAT_H)) AC_CHECK_HEADERS(limits.h, AC_DEFINE(HAVE_LIMITS_H)) AC_CHECK_HEADERS(values.h, AC_DEFINE(HAVE_VALUES_H)) @@ -244,7 +294,8 @@ AC_MSG_RESULT($gtk_ok) dnl ********************** dnl *** va_copy checks *** dnl ********************** -dnl we currently check for all three cases, so we get all results in config.log +dnl we currently check for all three va_copy possibilities, so we get +dnl all results in config.log for bug reports. AC_MSG_CHECKING(for an implementation of va_copy()) AC_CACHE_VAL(glib_cv_va_copy,[ AC_TRY_RUN([ diff --git a/garray.c b/garray.c index 3dac053e..4425f1d2 100644 --- a/garray.c +++ b/garray.c @@ -178,7 +178,7 @@ static GMemChunk *ptr_array_mem_chunk = NULL; GPtrArray* -g_ptr_array_new () +g_ptr_array_new (void) { GRealPtrArray *array; diff --git a/glib.h b/glib.h index 12f3fbad..72857820 100644 --- a/glib.h +++ b/glib.h @@ -23,7 +23,7 @@ */ #include -/* support standard arg inline functions for assertment macros +/* include varargs functions for assertment macros */ #include @@ -95,6 +95,17 @@ #endif /* HAVE_VALUES_H */ +/* the #pragma } statment is used to fix up emacs' c-mode which gets + * confused by extern "C" {. the ansi standard says that compilers + * have to ignore #pragma directives that they don't know about, + * so we should be save in using this. + */ +#ifdef __cplusplus +extern "C" { +#pragma } +#endif /* __cplusplus */ + + /* Provide definitions for some commonly used macros. * Some of them are only provided if they haven't already * been defined. It is assumed that if they are already @@ -155,6 +166,57 @@ #endif /* G_CODE_GENERATION */ +/* inlining hassle. for compilers that don't allow the `inline' keyword, + * mostly because of strict ANSI C compliance or dumbness, we try to fall + * back to either `__inline__' or `__inline'. + * we define G_CAN_INLINE, if the compiler seems to be actually + * *capable* to do function inlining, in which case inline function bodys + * do make sense. we also define G_INLINE_FUNC to properly export the + * function prototypes if no inlinig can be performed. + * we special case most of the stuff, so inline functions can have a normal + * implementation by defining G_INLINE_FUNC to extern and G_CAN_INLINE to 1. + */ +#ifndef G_INLINE_FUNC +# define G_CAN_INLINE 1 +#endif +#ifdef G_HAVE_INLINE +# if defined (__GNUC__) && defined (__STRICT_ANSI__) +# undef inline +# define inline __inline__ +# endif +#else /* !G_HAVE_INLINE */ +# undef inline +# if defined (G_HAVE___INLINE__) +# define inline __inline__ +# else /* !inline && !__inline__ */ +# if defined (G_HAVE___INLINE) +# define inline __inline +# else /* !inline && !__inline__ && !__inline */ +# define inline /* don't inline, then */ +# ifndef G_INLINE_FUNC +# undef G_CAN_INLINE +# endif +# endif +# endif +#endif +#ifndef G_INLINE_FUNC +# ifdef __GNUC__ +# ifdef __OPTIMIZE__ +# define G_INLINE_FUNC extern inline +# else +# undef G_CAN_INLINE +# define G_INLINE_FUNC extern +# endif +# else /* !__GNUC__ */ +# ifdef G_CAN_INLINE +# define G_INLINE_FUNC static inline +# else +# define G_INLINE_FUNC extern +# endif +# endif /* !__GNUC__ */ +#endif /* !G_INLINE_FUNC */ + + /* Provide simple macro statement wrappers (adapted from Perl): * G_STMT_START { statements; } G_STMT_END; * can be used as a single statement, as in @@ -180,31 +242,6 @@ #endif -/* ANSI does not permit the keyword `inline'. - */ -#if defined (__STRICT_ANSI__) -# undef inline -# ifdef __GNUC__ -# define inline __inline__ -# else /* !__GNUC__ */ -# define inline /* don't inline */ -# endif /* !__GNUC__ */ -#endif /* __STRICT_ANSI__ */ - -/* When using gcc we want to use `extern inline' to avoid random - * warnings with -Wall. */ -#ifdef __GNUC__ -/* We want to also have a non-inlined version of the function - * available. We implement this by redefining GLIB_INLINE in a glib - * implementation file. */ -# ifndef GLIB_INLINE -# define GLIB_INLINE extern inline -# endif -#else -# undef GLIB_INLINE -# define GLIB_INLINE inline -#endif - /* Provide macros to feature the GCC function attribute. */ #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) @@ -242,8 +279,8 @@ /* Hacker macro to place breakpoints for x86 machines. * Actual use is strongly deprecated of course ;) */ -#if defined (__i386__) -#define G_BREAKPOINT() G_STMT_START{ __asm__ ("int $03"); }G_STMT_END +#if defined (__i386__) && defined (__GNUC__) +#define G_BREAKPOINT() G_STMT_START{ __asm__ volatile ("int $03"); }G_STMT_END #else /* !__i386__ */ #define G_BREAKPOINT() #endif /* __i386__ */ @@ -423,17 +460,6 @@ #endif /* !G_DISABLE_CHECKS */ -#ifdef __cplusplus -/* the #pragma } statment is used to fix up emacs' c-mode which gets - * confused by extern "C" {. the ansi standard says that compilers - * have to ignore #pragma directives that they don't know about, - * so we should be save in using this. - */ -extern "C" { -#pragma } -#endif /* __cplusplus */ - - /* 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 @@ -1212,19 +1238,12 @@ gchar* g_get_current_dir (void); #endif - /* Bit tests */ - -/* Prototypes are required for inline functions to pacify gcc when - * some warnings are enabled. */ -gint g_bit_nth_lsf (guint32 mask, gint nth_bit); -gint g_bit_nth_msf (guint32 mask, gint nth_bit); -guint g_bit_storage (guint number); - -GLIB_INLINE gint +G_INLINE_FUNC gint g_bit_nth_lsf (guint32 mask, gint nth_bit) +#ifdef G_CAN_INLINE { do { @@ -1235,9 +1254,13 @@ g_bit_nth_lsf (guint32 mask, while (nth_bit < 32); return -1; } -GLIB_INLINE gint +#else +; +#endif +G_INLINE_FUNC gint g_bit_nth_msf (guint32 mask, gint nth_bit) +#ifdef G_CAN_INLINE { if (nth_bit < 0) nth_bit = 33; @@ -1250,8 +1273,12 @@ g_bit_nth_msf (guint32 mask, while (nth_bit > 0); return -1; } -GLIB_INLINE guint +#else +; +#endif +G_INLINE_FUNC guint g_bit_storage (guint number) +#ifdef G_CAN_INLINE { register guint n_bits = 0; @@ -1262,6 +1289,9 @@ g_bit_storage (guint number) } while (number); return n_bits; } +#else +; +#endif /* String Chunks diff --git a/glib/garray.c b/glib/garray.c index 3dac053e..4425f1d2 100644 --- a/glib/garray.c +++ b/glib/garray.c @@ -178,7 +178,7 @@ static GMemChunk *ptr_array_mem_chunk = NULL; GPtrArray* -g_ptr_array_new () +g_ptr_array_new (void) { GRealPtrArray *array; diff --git a/glib/glib.h b/glib/glib.h index 12f3fbad..72857820 100644 --- a/glib/glib.h +++ b/glib/glib.h @@ -23,7 +23,7 @@ */ #include -/* support standard arg inline functions for assertment macros +/* include varargs functions for assertment macros */ #include @@ -95,6 +95,17 @@ #endif /* HAVE_VALUES_H */ +/* the #pragma } statment is used to fix up emacs' c-mode which gets + * confused by extern "C" {. the ansi standard says that compilers + * have to ignore #pragma directives that they don't know about, + * so we should be save in using this. + */ +#ifdef __cplusplus +extern "C" { +#pragma } +#endif /* __cplusplus */ + + /* Provide definitions for some commonly used macros. * Some of them are only provided if they haven't already * been defined. It is assumed that if they are already @@ -155,6 +166,57 @@ #endif /* G_CODE_GENERATION */ +/* inlining hassle. for compilers that don't allow the `inline' keyword, + * mostly because of strict ANSI C compliance or dumbness, we try to fall + * back to either `__inline__' or `__inline'. + * we define G_CAN_INLINE, if the compiler seems to be actually + * *capable* to do function inlining, in which case inline function bodys + * do make sense. we also define G_INLINE_FUNC to properly export the + * function prototypes if no inlinig can be performed. + * we special case most of the stuff, so inline functions can have a normal + * implementation by defining G_INLINE_FUNC to extern and G_CAN_INLINE to 1. + */ +#ifndef G_INLINE_FUNC +# define G_CAN_INLINE 1 +#endif +#ifdef G_HAVE_INLINE +# if defined (__GNUC__) && defined (__STRICT_ANSI__) +# undef inline +# define inline __inline__ +# endif +#else /* !G_HAVE_INLINE */ +# undef inline +# if defined (G_HAVE___INLINE__) +# define inline __inline__ +# else /* !inline && !__inline__ */ +# if defined (G_HAVE___INLINE) +# define inline __inline +# else /* !inline && !__inline__ && !__inline */ +# define inline /* don't inline, then */ +# ifndef G_INLINE_FUNC +# undef G_CAN_INLINE +# endif +# endif +# endif +#endif +#ifndef G_INLINE_FUNC +# ifdef __GNUC__ +# ifdef __OPTIMIZE__ +# define G_INLINE_FUNC extern inline +# else +# undef G_CAN_INLINE +# define G_INLINE_FUNC extern +# endif +# else /* !__GNUC__ */ +# ifdef G_CAN_INLINE +# define G_INLINE_FUNC static inline +# else +# define G_INLINE_FUNC extern +# endif +# endif /* !__GNUC__ */ +#endif /* !G_INLINE_FUNC */ + + /* Provide simple macro statement wrappers (adapted from Perl): * G_STMT_START { statements; } G_STMT_END; * can be used as a single statement, as in @@ -180,31 +242,6 @@ #endif -/* ANSI does not permit the keyword `inline'. - */ -#if defined (__STRICT_ANSI__) -# undef inline -# ifdef __GNUC__ -# define inline __inline__ -# else /* !__GNUC__ */ -# define inline /* don't inline */ -# endif /* !__GNUC__ */ -#endif /* __STRICT_ANSI__ */ - -/* When using gcc we want to use `extern inline' to avoid random - * warnings with -Wall. */ -#ifdef __GNUC__ -/* We want to also have a non-inlined version of the function - * available. We implement this by redefining GLIB_INLINE in a glib - * implementation file. */ -# ifndef GLIB_INLINE -# define GLIB_INLINE extern inline -# endif -#else -# undef GLIB_INLINE -# define GLIB_INLINE inline -#endif - /* Provide macros to feature the GCC function attribute. */ #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) @@ -242,8 +279,8 @@ /* Hacker macro to place breakpoints for x86 machines. * Actual use is strongly deprecated of course ;) */ -#if defined (__i386__) -#define G_BREAKPOINT() G_STMT_START{ __asm__ ("int $03"); }G_STMT_END +#if defined (__i386__) && defined (__GNUC__) +#define G_BREAKPOINT() G_STMT_START{ __asm__ volatile ("int $03"); }G_STMT_END #else /* !__i386__ */ #define G_BREAKPOINT() #endif /* __i386__ */ @@ -423,17 +460,6 @@ #endif /* !G_DISABLE_CHECKS */ -#ifdef __cplusplus -/* the #pragma } statment is used to fix up emacs' c-mode which gets - * confused by extern "C" {. the ansi standard says that compilers - * have to ignore #pragma directives that they don't know about, - * so we should be save in using this. - */ -extern "C" { -#pragma } -#endif /* __cplusplus */ - - /* 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 @@ -1212,19 +1238,12 @@ gchar* g_get_current_dir (void); #endif - /* Bit tests */ - -/* Prototypes are required for inline functions to pacify gcc when - * some warnings are enabled. */ -gint g_bit_nth_lsf (guint32 mask, gint nth_bit); -gint g_bit_nth_msf (guint32 mask, gint nth_bit); -guint g_bit_storage (guint number); - -GLIB_INLINE gint +G_INLINE_FUNC gint g_bit_nth_lsf (guint32 mask, gint nth_bit) +#ifdef G_CAN_INLINE { do { @@ -1235,9 +1254,13 @@ g_bit_nth_lsf (guint32 mask, while (nth_bit < 32); return -1; } -GLIB_INLINE gint +#else +; +#endif +G_INLINE_FUNC gint g_bit_nth_msf (guint32 mask, gint nth_bit) +#ifdef G_CAN_INLINE { if (nth_bit < 0) nth_bit = 33; @@ -1250,8 +1273,12 @@ g_bit_nth_msf (guint32 mask, while (nth_bit > 0); return -1; } -GLIB_INLINE guint +#else +; +#endif +G_INLINE_FUNC guint g_bit_storage (guint number) +#ifdef G_CAN_INLINE { register guint n_bits = 0; @@ -1262,6 +1289,9 @@ g_bit_storage (guint number) } while (number); return n_bits; } +#else +; +#endif /* String Chunks diff --git a/glib/gmessages.c b/glib/gmessages.c index 12a2c59b..83d30732 100644 --- a/glib/gmessages.c +++ b/glib/gmessages.c @@ -16,6 +16,7 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ +#include #include #include #include diff --git a/glib/gscanner.c b/glib/gscanner.c index f25b11d0..85773680 100644 --- a/glib/gscanner.c +++ b/glib/gscanner.c @@ -630,7 +630,7 @@ g_scanner_cur_token (GScanner *scanner) GValue g_scanner_cur_value (GScanner *scanner) { - register GValue v; + GValue v; v.v_int = 0; g_return_val_if_fail (scanner != NULL, v); @@ -1138,8 +1138,8 @@ g_scanner_get_token_ll (GScanner *scanner, register gboolean in_string_dq; static guchar ch; register GTokenType token; - register GValue value; register GString *gstring; + GValue value; config = scanner->config; (*value_p).v_int = 0; diff --git a/glib/gutils.c b/glib/gutils.c index 419487eb..8a3b03d7 100644 --- a/glib/gutils.c +++ b/glib/gutils.c @@ -25,10 +25,10 @@ #include #include -/* When using gcc, we want to have a non-inlined version of the - * `extern inline'd functions in glib.h. We do this here. */ -#define GLIB_INLINE - +/* implement Glib's inline functions + */ +#define G_INLINE_FUNC extern +#define G_CAN_INLINE 1 #include "glib.h" const guint glib_major_version = GLIB_MAJOR_VERSION; diff --git a/glibconfig.h.in b/glibconfig.h.in index 09ab3271..aef9bd0c 100644 --- a/glibconfig.h.in +++ b/glibconfig.h.in @@ -9,9 +9,6 @@ /* Define if you have the vprintf function. */ #undef HAVE_VPRINTF -/* Define as __inline if that's what the C compiler calls it. */ -#undef inline - /* Define if you have the ANSI C header files. */ #undef STDC_HEADERS @@ -39,6 +36,9 @@ #undef G_VA_COPY #undef G_VA_COPY_AS_ARRAY +#undef G_HAVE___INLINE +#undef G_HAVE___INLINE__ +#undef G_HAVE_INLINE #undef GLIB_MAJOR_VERSION #undef GLIB_MINOR_VERSION diff --git a/gmessages.c b/gmessages.c index 12a2c59b..83d30732 100644 --- a/gmessages.c +++ b/gmessages.c @@ -16,6 +16,7 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ +#include #include #include #include diff --git a/gscanner.c b/gscanner.c index f25b11d0..85773680 100644 --- a/gscanner.c +++ b/gscanner.c @@ -630,7 +630,7 @@ g_scanner_cur_token (GScanner *scanner) GValue g_scanner_cur_value (GScanner *scanner) { - register GValue v; + GValue v; v.v_int = 0; g_return_val_if_fail (scanner != NULL, v); @@ -1138,8 +1138,8 @@ g_scanner_get_token_ll (GScanner *scanner, register gboolean in_string_dq; static guchar ch; register GTokenType token; - register GValue value; register GString *gstring; + GValue value; config = scanner->config; (*value_p).v_int = 0; diff --git a/gutils.c b/gutils.c index 419487eb..8a3b03d7 100644 --- a/gutils.c +++ b/gutils.c @@ -25,10 +25,10 @@ #include #include -/* When using gcc, we want to have a non-inlined version of the - * `extern inline'd functions in glib.h. We do this here. */ -#define GLIB_INLINE - +/* implement Glib's inline functions + */ +#define G_INLINE_FUNC extern +#define G_CAN_INLINE 1 #include "glib.h" const guint glib_major_version = GLIB_MAJOR_VERSION; diff --git a/ltconfig b/ltconfig index 4cd56263..8d9d4e35 100755 --- a/ltconfig +++ b/ltconfig @@ -549,6 +549,22 @@ else link_static_flag='-Bstatic' ;; + linux*aout) + can_build_shared=no + ;; + + linux*) + case "$CC" in + *lcc | *lcc\ *) + wl=-Wl + link_static_flag='-static' + pic_flag= + ;; + *) + can_build_shared=no + esac + ;; + *) can_build_shared=no ;; diff --git a/testglib.c b/testglib.c index 01b6366b..d0440224 100644 --- a/testglib.c +++ b/testglib.c @@ -706,7 +706,7 @@ main (int argc, gbarray = g_byte_array_new (); for (i = 0; i < 10000; i++) - g_byte_array_append (gbarray, "abcd", 4); + g_byte_array_append (gbarray, (guint8*) "abcd", 4); for (i = 0; i < 10000; i++) { diff --git a/tests/testglib.c b/tests/testglib.c index 01b6366b..d0440224 100644 --- a/tests/testglib.c +++ b/tests/testglib.c @@ -706,7 +706,7 @@ main (int argc, gbarray = g_byte_array_new (); for (i = 0; i < 10000; i++) - g_byte_array_append (gbarray, "abcd", 4); + g_byte_array_append (gbarray, (guint8*) "abcd", 4); for (i = 0; i < 10000; i++) { -- 2.34.1