babl r400 - in trunk: . babl
- From: martinn svn gnome org
- To: svn-commits-list gnome org
- Subject: babl r400 - in trunk: . babl
- Date: Wed, 25 Mar 2009 19:02:35 +0000 (UTC)
Author: martinn
Date: Wed Mar 25 19:02:35 2009
New Revision: 400
URL: http://svn.gnome.org/viewvc/babl?rev=400&view=rev
Log:
Handle variadic macros in a portable way
Apply patch from Gary V. Vaughan that adds configure time checks for
variadic macros and adapts the definitions of such macros in-code
accordingly so that babl can be compiled on more platforms.
Modified:
trunk/ChangeLog
trunk/acinclude.m4
trunk/babl/babl-internal.h
trunk/configure.ac
Modified: trunk/acinclude.m4
==============================================================================
--- trunk/acinclude.m4 (original)
+++ trunk/acinclude.m4 Wed Mar 25 19:02:35 2009
@@ -18,3 +18,65 @@
fi
done
])
+
+
+# BABL_VARIADIC_MACROS
+# --------------------
+# check for flavours of variadic macros
+AC_DEFUN([BABL_VARIADIC_MACROS],
+[AC_BEFORE([$0], [AC_PROG_CXX])
+AC_REQUIRE([AC_PROG_CPP])
+AC_CACHE_CHECK([for GNUC variadic macros],
+ [babl_cv_prog_gnuc_variadic_macros],
+ [# gcc-2.95.x supports both gnu style and ISO varargs, but if -ansi
+ # is passed ISO vararg support is turned off, and there is no work
+ # around to turn it on, so we unconditionally turn it off.
+ { echo '#if __GNUC__ == 2 && __GNUC_MINOR__ == 95'
+ echo ' yes '
+ echo '#endif'; } > conftest.c
+ if ${CPP} conftest.c | grep yes > /dev/null; then
+ babl_cv_prog_c_variadic_macros=no
+ babl_cv_prog_cxx_variadic_macros=no
+ fi
+ AC_TRY_COMPILE([],[int a(int p1, int p2, int p3);
+#define call_a(params...) a(1,params)
+call_a(2,3);
+ ],
+ babl_cv_prog_gnuc_variadic_macros=yes,
+ babl_cv_prog_gnuc_variadic_macros=no)
+])
+if test x$babl_cv_prog_gnuc_variadic_macros = xyes; then
+ AC_DEFINE(BABL_GNUC_VARIADIC_MACROS, 1, [Define if the C pre-processor supports GNU style variadic macros])
+fi
+
+AC_CACHE_CHECK([for ISO C99 variadic macros in C],
+ [babl_cv_prog_c_variadic_macros],
+ [AC_TRY_COMPILE([],[int a(int p1, int p2, int p3);
+#define call_a(...) a(1,__VA_ARGS__)
+call_a(2,3);
+ ],
+ babl_cv_prog_c_variadic_macros=yes,
+ babl_cv_prog_c_variadic_macros=no)
+])
+if test x$babl_cv_prog_c_variadic_macros = xyes ; then
+ AC_DEFINE(BABL_ISO_VARIADIC_MACROS, 1, [Define if the C pre-processor supports variadic macros])
+fi
+
+AC_PROVIDE_IFELSE([AC_PROG_CXX],
+ [AC_CACHE_CHECK([for ISO C99 variadic macros in C++],
+ [babl_cv_prog_cxx_variadic_macros],
+ [AC_LANG_PUSH(C++)
+ AC_TRY_COMPILE([],[int a(int p1, int p2, int p3);
+#define call_a(...) a(1,__VA_ARGS__)
+call_a(2,3);
+ ],
+ babl_cv_prog_cxx_variadic_macros=yes,
+ babl_cv_prog_cxx_variadic_macros=no)
+ AC_LANG_POP])],
+ [# No C++ compiler
+ babl_cv_prog_cxx_variadic_macros=no])
+if test x$babl_cv_prog_cxx_variadic_macros = xyes ; then
+ AC_DEFINE(BABL_ISO_CXX_VARIADIC_MACROS, 1, [Define if the C++ pre-processor supports variadic macros])
+fi
+])
+
Modified: trunk/babl/babl-internal.h
==============================================================================
--- trunk/babl/babl-internal.h (original)
+++ trunk/babl/babl-internal.h Wed Mar 25 19:02:35 2009
@@ -162,19 +162,57 @@
hack_hack ();
}
+#if defined(__cplusplus) && defined(BABL_ISO_CXX_VARIADIC_MACROS)
+# define BABL_ISO_VARIADIC_MACROS 1
+#endif
+
+#if defined(BABL_ISO_VARIADIC_MACROS)
+
+#define babl_log(...) \
+ real_babl_log(__FILE__, __LINE__, __func__, __VA_ARGS__)
+
+#define babl_fatal(...) do{ \
+ real_babl_log(__FILE__, __LINE__, __func__, __VA_ARGS__); \
+ babl_die();} \
+while(0)
+
+#elif defined(BABL_GNUC_VARIADIC_MACROS)
+
#define babl_log(args...) \
real_babl_log(__FILE__, __LINE__, __func__, args)
#define babl_fatal(args...) do{ \
- real_babl_log(__FILE__, __LINE__, __func__, args);\
+ real_babl_log(__FILE__, __LINE__, __func__, args); \
babl_die();} \
while(0)
+#else
+
+static inline void
+babl_log (const char *format, ...)
+{
+ va_list args;
+ va_start (args, format);
+ real_babl_log (__FILE__, __LINE__, __func__, format, args);
+ va_end (args);
+}
+static inline void
+babl_fatal (const char *format, ...)
+{
+ va_list args;
+ va_start (args, format);
+ real_babl_log (__FILE__, __LINE__, __func__, format, args);
+ va_end (args);
+ babl_die();
+}
+
+#endif
+
#define babl_assert(expr) do{ \
if(!(expr)) \
{ \
- babl_fatal("Eeeeek! Assertion failed: `" #expr "`"); \
+ real_babl_log(__FILE__, __LINE__, __func__, "Eeeeek! Assertion failed: `" #expr "`"); \
assert(expr); \
} \
}while(0)
Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Wed Mar 25 19:02:35 2009
@@ -100,6 +100,8 @@
AC_STDC_HEADERS
AM_SANITY_CHECK
+BABL_VARIADIC_MACROS
+
WEBSITE_HOST=pippin.gimp.org
AC_SUBST(WEBSITE_HOST)
WEBSITE_LOCATION=public_html/babl/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]