mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 15:06:14 +01:00
Fix G_STMT_START / G_STMT_END on Solaris. (#321972, Andrew Paprocki)
2005-11-28 Matthias Clasen <mclasen@redhat.com> Fix G_STMT_START / G_STMT_END on Solaris. (#321972, Andrew Paprocki) * configure.in: Check whether do { } while (0) works. * glib/gmacros.h: Use do { } while (0) for G_STMT_START / G_STMT_END if it works.
This commit is contained in:
parent
d98433b85e
commit
6796398522
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
||||
2005-11-28 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
Fix G_STMT_START / G_STMT_END on Solaris. (#321972,
|
||||
Andrew Paprocki)
|
||||
|
||||
* configure.in: Check whether do { } while (0) works.
|
||||
|
||||
* glib/gmacros.h: Use do { } while (0) for G_STMT_START /
|
||||
G_STMT_END if it works.
|
||||
|
||||
2005-11-28 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* glib/gthread.c (g_static_rw_lock_wait, g_static_rw_lock_signal):
|
||||
|
@ -1,3 +1,13 @@
|
||||
2005-11-28 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
Fix G_STMT_START / G_STMT_END on Solaris. (#321972,
|
||||
Andrew Paprocki)
|
||||
|
||||
* configure.in: Check whether do { } while (0) works.
|
||||
|
||||
* glib/gmacros.h: Use do { } while (0) for G_STMT_START /
|
||||
G_STMT_END if it works.
|
||||
|
||||
2005-11-28 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* glib/gthread.c (g_static_rw_lock_wait, g_static_rw_lock_signal):
|
||||
|
@ -1,3 +1,13 @@
|
||||
2005-11-28 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
Fix G_STMT_START / G_STMT_END on Solaris. (#321972,
|
||||
Andrew Paprocki)
|
||||
|
||||
* configure.in: Check whether do { } while (0) works.
|
||||
|
||||
* glib/gmacros.h: Use do { } while (0) for G_STMT_START /
|
||||
G_STMT_END if it works.
|
||||
|
||||
2005-11-28 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* glib/gthread.c (g_static_rw_lock_wait, g_static_rw_lock_signal):
|
||||
|
15
configure.in
15
configure.in
@ -700,6 +700,21 @@ main (void) {
|
||||
}],[g_can_inline=yes],[g_can_inline=no])
|
||||
AC_MSG_RESULT($g_can_inline)
|
||||
|
||||
dnl *** check for working do while(0) macros ***
|
||||
AC_CACHE_CHECK([for working do while(0) macros], g_support_dowhile_macros, [
|
||||
AC_TRY_COMPILE([],[
|
||||
#define STMT_START do
|
||||
#define STMT_END while(0)
|
||||
#define STMT_TEST STMT_START { i = 0; } STMT_END
|
||||
int main(void) { int i = 1; STMT_TEST; return i; }],
|
||||
[g_support_dowhile_macros=yes],
|
||||
[g_support_dowhile_macros=no],
|
||||
[g_support_dowhile_macros=yes])
|
||||
])
|
||||
if test x$g_support_dowhile_macros = xyes; then
|
||||
AC_DEFINE(HAVE_DOWHILE_MACROS, 1, [define for working do while(0) macros])
|
||||
fi
|
||||
|
||||
# check for flavours of varargs macros
|
||||
AC_MSG_CHECKING(for ISO C99 varargs macros in C)
|
||||
AC_TRY_COMPILE([],[
|
||||
|
@ -194,23 +194,26 @@
|
||||
* can be used as a single statement, as in
|
||||
* if (x) G_STMT_START { ... } G_STMT_END; else ...
|
||||
*
|
||||
* For gcc we will wrap the statements within `({' and `})' braces.
|
||||
* For SunOS they will be wrapped within `if (1)' and `else (void) 0',
|
||||
* and otherwise within `do' and `while (0)'.
|
||||
* When GCC is compiling C code in non-ANSI mode, it will use the
|
||||
* compiler __extension__ to wrap the statements wihin `({' and '})' braces.
|
||||
* When compiling on platforms where configure has defined
|
||||
* HAVE_DOWHILE_MACROS, statements will be wrapped with `do' and `while (0)'.
|
||||
* For any other platforms (SunOS4 is known to have this issue), wrap the
|
||||
* statements with `if (1)' and `else (void) 0'.
|
||||
*/
|
||||
#if !(defined (G_STMT_START) && defined (G_STMT_END))
|
||||
# if defined (__GNUC__) && !defined (__STRICT_ANSI__) && !defined (__cplusplus)
|
||||
# define G_STMT_START (void) __extension__ (
|
||||
# define G_STMT_END )
|
||||
# else
|
||||
# if (defined (sun) || defined (__sun__))
|
||||
# define G_STMT_START if (1)
|
||||
# define G_STMT_END else (void)0
|
||||
# else
|
||||
# define G_STMT_START do
|
||||
# define G_STMT_END while (0)
|
||||
# endif
|
||||
# endif
|
||||
# if defined (__GNUC__) && !defined (__STRICT_ANSI__) && !defined (__cplusplus)
|
||||
# define G_STMT_START (void) __extension__ (
|
||||
# define G_STMT_END )
|
||||
# else /* !(__GNUC__ && !__STRICT_ANSI__ && !__cplusplus) */
|
||||
# if defined (HAVE_DOWHILE_MACROS)
|
||||
# define G_STMT_START do
|
||||
# define G_STMT_END while (0)
|
||||
# else /* !HAVE_DOWHILE_MACROS */
|
||||
# define G_STMT_START if (1)
|
||||
# define G_STMT_END else (void) 0
|
||||
# endif /* !HAVE_DOWHILE_MACROS */
|
||||
# endif /* !(__GNUC__ && !__STRICT_ANSI__ && !__cplusplus) */
|
||||
#endif
|
||||
|
||||
/* Allow the app programmer to select whether or not return values
|
||||
|
Loading…
Reference in New Issue
Block a user