summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Wegner <swegner@hdfgroup.org>2008-09-17 14:04:35 (GMT)
committerScott Wegner <swegner@hdfgroup.org>2008-09-17 14:04:35 (GMT)
commit036aa878b0c167e4c39a290a75b5dc241ac4f218 (patch)
tree1d1cc1def6d68befff2515ae2f7a59d540fd3093
parent95149cc0957dd05585388c8d8532d84269bf0075 (diff)
downloadhdf5-036aa878b0c167e4c39a290a75b5dc241ac4f218.zip
hdf5-036aa878b0c167e4c39a290a75b5dc241ac4f218.tar.gz
hdf5-036aa878b0c167e4c39a290a75b5dc241ac4f218.tar.bz2
[svn-r15639] Purpose: Check for __func__ keyword during configure
Description: In some of the new H5EA* code, many new C99 features are being used. Most of them are portable to all compilers, but the __func__ keyword in particular isn't supported in Visual Studio on Windows. Instead, Windows defines the __FUNCTION__ keyword, which can be used as a direct substitute. We now check for the __func__ keyword during configure and define the feature flag H5_HAVE_C99_FUNC. There was previously a check for __FUNCTION__, and the feature flags H5_HAVE_FUNCTION. In H5EApkg.h, we check for the presents of each of these in order to see which to use. If neither are avaiable, fail. Tested: h5committest (kagiso, smirom, linew)
-rwxr-xr-xconfigure60
-rw-r--r--configure.in8
-rw-r--r--src/H5EApkg.h32
-rw-r--r--src/H5config.h.in3
-rwxr-xr-xwindows/src/H5pubconf.h3
5 files changed, 90 insertions, 16 deletions
diff --git a/configure b/configure
index ec00c0e..c483a1e 100755
--- a/configure
+++ b/configure
@@ -46356,6 +46356,64 @@ fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: checking for __func__ extension" >&5
+echo $ECHO_N "checking for __func__ extension... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+#ifdef FC_DUMMY_MAIN
+#ifndef FC_DUMMY_MAIN_EQ_F77
+# ifdef __cplusplus
+ extern "C"
+# endif
+ int FC_DUMMY_MAIN() { return 1; }
+#endif
+#endif
+int
+main ()
+{
+ const char *fname = __func__;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_C99_FUNC 1
+_ACEOF
+
+ { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ echo "$as_me:$LINENO: checking for __FUNCTION__ extension" >&5
echo $ECHO_N "checking for __FUNCTION__ extension... $ECHO_C" >&6; }
cat >conftest.$ac_ext <<_ACEOF
@@ -46376,7 +46434,7 @@ cat >>conftest.$ac_ext <<_ACEOF
int
main ()
{
-(void)__FUNCTION__
+ const char *fname = __FUNCTION__;
;
return 0;
}
diff --git a/configure.in b/configure.in
index fe49b4e..6e2a4e1 100644
--- a/configure.in
+++ b/configure.in
@@ -2062,8 +2062,14 @@ AC_TRY_COMPILE(,[int __attribute__((unused)) x],
AC_MSG_RESULT([yes]),
AC_MSG_RESULT([no]))
+AC_MSG_CHECKING([for __func__ extension])
+AC_TRY_COMPILE(,[ const char *fname = __func__; ],
+ AC_DEFINE([HAVE_C99_FUNC], [1],
+ [Define if the compiler understand the __func__ keyword])
+ AC_MSG_RESULT([yes]),
+ AC_MSG_RESULT([no]))
AC_MSG_CHECKING([for __FUNCTION__ extension])
-AC_TRY_COMPILE(,[(void)__FUNCTION__],
+AC_TRY_COMPILE(,[ const char *fname = __FUNCTION__; ],
AC_DEFINE([HAVE_FUNCTION], [1],
[Define if the compiler understand the __FUNCTION__ keyword])
AC_MSG_RESULT([yes]),
diff --git a/src/H5EApkg.h b/src/H5EApkg.h
index 74ed3fb..5f6f10f 100644
--- a/src/H5EApkg.h
+++ b/src/H5EApkg.h
@@ -111,9 +111,18 @@ H5_DECLARE_PKG_VAR(H5_MY_PKG_INIT, H5_MY_PKG)
/* API re-entrance variable */
extern hbool_t H5_api_entered_g; /* Has library already been entered through API? */
+/* Use FUNC to safely handle variations of C99 __func__ keyword handling */
+#ifdef H5_HAVE_C99_FUNC
+#define FUNC __func__
+#elif defined(H5_HAVE_FUNCTION)
+#define FUNC __FUNCTION__
+#else
+#error "We need __func__ or __FUNCTION__ to test function names!"
+#endif
+
/* Macros for entering different scopes of routines */
#define H5_PACKAGE_ENTER(pkg, pkg_init, init) \
- FUNC_ENTER_NAME_CHECK(H5_IS_PKG(__func__)) \
+ FUNC_ENTER_NAME_CHECK(H5_IS_PKG(FUNC)) \
\
/* The library should be initialized already */ \
HDassert(H5_INIT_GLOBAL); \
@@ -123,13 +132,13 @@ extern hbool_t H5_api_entered_g; /* Has library already been entered through
H5_GLUE4(H5_CHECK_PACKAGE_INIT_, init, _, pkg_init)(pkg) \
\
/* Push the name of this function on the function stack */ \
- H5_PUSH_FUNC(__func__) \
+ H5_PUSH_FUNC(FUNC) \
\
/* Enter scope for this type of function */ \
{
#define H5_PRIVATE_ENTER(pkg, pkg_init) \
- FUNC_ENTER_NAME_CHECK(H5_IS_PRIV(__func__)) \
+ FUNC_ENTER_NAME_CHECK(H5_IS_PRIV(FUNC)) \
\
/* The library should be initialized already */ \
HDassert(H5_INIT_GLOBAL); \
@@ -138,20 +147,15 @@ extern hbool_t H5_api_entered_g; /* Has library already been entered through
H5_GLUE3(H5_PKG_, pkg_init, _INIT)(pkg) \
\
/* Push the name of this function on the function stack */ \
- H5_PUSH_FUNC(__func__) \
+ H5_PUSH_FUNC(FUNC) \
\
/* Enter scope for this type of function */ \
{{
-/* Remove this shim and change H5TRACE* macros when this change is permanent -QAK */
-#ifdef H5_DEBUG_API
-#define FUNC __func__
-#endif
-
#define H5_PUBLIC_ENTER(pkg, pkg_init) \
- FUNC_ENTER_API_VARS(__func__) \
+ FUNC_ENTER_API_VARS(FUNC) \
FUNC_ENTER_API_THREADSAFE; \
- FUNC_ENTER_NAME_CHECK(H5_IS_PUB(__func__)) \
+ FUNC_ENTER_NAME_CHECK(H5_IS_PUB(FUNC)) \
\
/* Clear thread error stack when entering public functions */ \
H5E_clear_stack(NULL); \
@@ -175,10 +179,10 @@ extern hbool_t H5_api_entered_g; /* Has library already been entered through
H5_api_entered_g = TRUE; \
\
/* Start logging MPI's MPE information */ \
- BEGIN_MPE_LOG(__func__) \
+ BEGIN_MPE_LOG(FUNC) \
\
/* Push the name of this function on the function stack */ \
- H5_PUSH_FUNC(__func__) \
+ H5_PUSH_FUNC(FUNC) \
\
/* Enter scope for this type of function */ \
{{{
@@ -291,7 +295,7 @@ func_init_failed: \
* error number, a description of the error (as a printf-like format string),
* and an optional set of arguments for the printf format arguments.
*/
-#define H5E_PRINTF(...) H5E_printf_stack(NULL, __FILE__, __func__, __LINE__, H5E_ERR_CLS_g, H5_MY_PKG_ERR, __VA_ARGS__)
+#define H5E_PRINTF(...) H5E_printf_stack(NULL, __FILE__, FUNC, __LINE__, H5E_ERR_CLS_g, H5_MY_PKG_ERR, __VA_ARGS__)
/*
* H5_LEAVE macro, used to facilitate control flow between a
diff --git a/src/H5config.h.in b/src/H5config.h.in
index 429b613..a12f3bc 100644
--- a/src/H5config.h.in
+++ b/src/H5config.h.in
@@ -58,6 +58,9 @@
/* Define to 1 if you have the `BSDgettimeofday' function. */
#undef HAVE_BSDGETTIMEOFDAY
+/* Define if the compiler understand the __func__ keyword */
+#undef HAVE_C99_FUNC
+
/* Define if the function stack tracing code is to be compiled in */
#undef HAVE_CODESTACK
diff --git a/windows/src/H5pubconf.h b/windows/src/H5pubconf.h
index 0d7fe0b..8b7330d 100755
--- a/windows/src/H5pubconf.h
+++ b/windows/src/H5pubconf.h
@@ -78,6 +78,9 @@
/* Define to 1 if you have the `BSDgettimeofday' function. */
/* #undef H5_HAVE_BSDGETTIMEOFDAY */
+/* Define if the compiler understand the __func__ keyword */
+/* #undef H5_HAVE_C99_FUNC */
+
/* Define if the function stack tracing code is to be compiled in */
/* #undef H5_HAVE_CODESTACK */