From ff5070329c34c74082570c925e2a2b9089b99b29 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Mon, 3 Aug 2015 16:04:29 -0500 Subject: [svn-r27457] Merge of r27278 from trunk. Fixes HDFFV-9119 and HDFFV-9421. Changes that allow the autotools to correctly deal with inline functions. - Inline markup schemes are now checked with AC_COMPILE_IFELSE tests instead of AC_C_INLINE. - The inline designator is now H5_INLINE instead of H5_inline. This is now set in H5private.h instead of H5pubconf.h. Tested on: h5committest --- configure | 88 +++++++++++++++++++++++++----------------------- configure.ac | 32 ++++++++++++------ release_docs/RELEASE.txt | 15 +++++++-- src/H5Oshared.h | 16 ++++----- src/H5VMprivate.h | 22 ++++++------ src/H5config.h.in | 15 +++++---- src/H5private.h | 21 +++++++++--- 7 files changed, 123 insertions(+), 86 deletions(-) diff --git a/configure b/configure index f7c4286..5e654a7 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.ac Id: configure.ac 27431 2015-07-26 12:41:43Z hdftest . +# From configure.ac Id: configure.ac 27451 2015-08-02 09:49:57Z hdftest . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for HDF5 1.8.16-snap11. # @@ -26135,48 +26135,60 @@ $as_echo "#define const /**/" >>confdefs.h fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 -$as_echo_n "checking for inline... " >&6; } -if ${ac_cv_c_inline+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_cv_c_inline=no -for ac_kw in inline __inline__ __inline; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifndef __cplusplus -typedef int foo_t; -static $ac_kw foo_t static_foo () {return 0; } -$ac_kw foo_t foo () {return 0; } -#endif +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the compiler understands __inline__" >&5 +$as_echo_n "checking if the compiler understands __inline__... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +static __inline__ void f(void){return;}; _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_c_inline=$ac_kw + +$as_echo "#define HAVE___INLINE__ 1" >>confdefs.h + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - test "$ac_cv_c_inline" != no && break -done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the compiler understands __inline" >&5 +$as_echo_n "checking if the compiler understands __inline... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +static __inline void f(void){return;}; +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +$as_echo "#define HAVE___INLINE 1" >>confdefs.h + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5 -$as_echo "$ac_cv_c_inline" >&6; } +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -case $ac_cv_c_inline in - inline | yes) ;; - *) - case $ac_cv_c_inline in - no) ac_val=;; - *) ac_val=$ac_cv_c_inline;; - esac - cat >>confdefs.h <<_ACEOF -#ifndef __cplusplus -#define inline $ac_val -#endif +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the compiler understands inline" >&5 +$as_echo_n "checking if the compiler understands inline... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +static inline void f(void){return;}; _ACEOF - ;; -esac +if ac_fn_c_try_compile "$LINENO"; then : +$as_echo "#define HAVE_INLINE 1" >>confdefs.h + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __attribute__ extension" >&5 $as_echo_n "checking for __attribute__ extension... " >&6; } @@ -33383,16 +33395,6 @@ if test "X$HDF_CXX" = "Xyes"; then chmod 755 c++/src/h5c++ fi -## We don't want inline defined for C++ compilers -## Don't worry about the C++ ifdef wrappers in the H5pubconf file, since -## 'H5_inline' isn't a C++ keyword. -cat >> src/H5config.h <, specifically gfortran or m. ## This sed script corrects "-l " first and then "-l " with no library name. diff --git a/configure.ac b/configure.ac index 5d43f9c..c9d3f1b 100644 --- a/configure.ac +++ b/configure.ac @@ -1632,7 +1632,27 @@ AC_CHECK_FUNCS([tmpfile asprintf vasprintf vsnprintf waitpid]) ## Check compiler characteristics ## AC_C_CONST -AC_C_INLINE + +AC_MSG_CHECKING([if the compiler understands __inline__]) +AC_COMPILE_IFELSE( + [AC_LANG_SOURCE([[static __inline__ void f(void){return;};]])], + [AC_DEFINE([HAVE___INLINE__], [1], [Define if the compiler understands __inline__]) AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no])] +) + +AC_MSG_CHECKING([if the compiler understands __inline]) +AC_COMPILE_IFELSE( + [AC_LANG_SOURCE([[static __inline void f(void){return;};]])], + [AC_DEFINE([HAVE___INLINE], [1], [Define if the compiler understands __inline]) AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no])] +) + +AC_MSG_CHECKING([if the compiler understands inline]) +AC_COMPILE_IFELSE( + [AC_LANG_SOURCE([[static inline void f(void){return;};]])], + [AC_DEFINE([HAVE_INLINE], [1], [Define if the compiler understands inline]) AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no])] +) AC_MSG_CHECKING([for __attribute__ extension]) AC_TRY_COMPILE(,[int __attribute__((unused)) x], @@ -3106,16 +3126,6 @@ if test "X$HDF_CXX" = "Xyes"; then chmod 755 c++/src/h5c++ fi -## We don't want inline defined for C++ compilers -## Don't worry about the C++ ifdef wrappers in the H5pubconf file, since -## 'H5_inline' isn't a C++ keyword. -cat >> src/H5config.h <, specifically gfortran or m. ## This sed script corrects "-l " first and then "-l " with no library name. diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index bb86225..be0080d 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -57,8 +57,19 @@ New Features Configuration ------------- - - - (XYZ - YYYY/MM/DD HDFFV-####) + - Inline functions now correctly annotated w/ Autotools builds. + + The method used to detect the appropriate inline markup scheme was + nonfunctional in Autotools builds. The Autotools have been modified + to correctly detect the compiler's inline markup symbol and apply it + to the source. Note that only a very small number of internal + functions are marked inline so this was not a very big change or + likely to significantly affect performance. + + As a part of this change, the H5_inline symbol no longer appears in + H5pubconf.h. + + (DER - 2015/08/13 HDFFV-9119, HDFFV-9421) diff --git a/src/H5Oshared.h b/src/H5Oshared.h index 3ec5709..2ac2a98 100644 --- a/src/H5Oshared.h +++ b/src/H5Oshared.h @@ -47,7 +47,7 @@ * *------------------------------------------------------------------------- */ -static H5_inline void * +static H5_INLINE void * H5O_SHARED_DECODE(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, unsigned mesg_flags, unsigned *ioflags, const uint8_t *p) { @@ -107,7 +107,7 @@ done: * *------------------------------------------------------------------------- */ -static H5_inline herr_t +static H5_INLINE herr_t H5O_SHARED_ENCODE(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg) { const H5O_shared_t *sh_mesg = (const H5O_shared_t *)_mesg; /* Pointer to shared message portion of actual message */ @@ -162,7 +162,7 @@ done: * *------------------------------------------------------------------------- */ -static H5_inline size_t +static H5_INLINE size_t H5O_SHARED_SIZE(const H5F_t *f, hbool_t disable_shared, const void *_mesg) { const H5O_shared_t *sh_mesg = (const H5O_shared_t *)_mesg; /* Pointer to shared message portion of actual message */ @@ -215,7 +215,7 @@ done: * *------------------------------------------------------------------------- */ -static H5_inline herr_t +static H5_INLINE herr_t H5O_SHARED_DELETE(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, void *_mesg) { H5O_shared_t *sh_mesg = (H5O_shared_t *)_mesg; /* Pointer to shared message portion of actual message */ @@ -267,7 +267,7 @@ done: * *------------------------------------------------------------------------- */ -static H5_inline herr_t +static H5_INLINE herr_t H5O_SHARED_LINK(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, void *_mesg) { H5O_shared_t *sh_mesg = (H5O_shared_t *)_mesg; /* Pointer to shared message portion of actual message */ @@ -318,7 +318,7 @@ done: * *------------------------------------------------------------------------- */ -static H5_inline void * +static H5_INLINE void * H5O_SHARED_COPY_FILE(H5F_t *file_src, void *_native_src, H5F_t *file_dst, hbool_t *recompute_size, unsigned *mesg_flags, H5O_copy_t *cpy_info, void *udata, hid_t dxpl_id) @@ -382,7 +382,7 @@ done: * *------------------------------------------------------------------------- */ -static H5_inline herr_t +static H5_INLINE herr_t H5O_SHARED_POST_COPY_FILE(const H5O_loc_t *oloc_src, const void *mesg_src, H5O_loc_t *oloc_dst, void *mesg_dst, unsigned *mesg_flags, hid_t dxpl_id, H5O_copy_t *cpy_info) @@ -453,7 +453,7 @@ done: * *------------------------------------------------------------------------- */ -static H5_inline herr_t +static H5_INLINE herr_t H5O_SHARED_DEBUG(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE *stream, int indent, int fwidth) { diff --git a/src/H5VMprivate.h b/src/H5VMprivate.h index 7310b47..372a8aa 100644 --- a/src/H5VMprivate.h +++ b/src/H5VMprivate.h @@ -121,7 +121,7 @@ H5_DLL ssize_t H5VM_memcpyvv(void *_dst, * *------------------------------------------------------------------------- */ -static H5_inline hsize_t H5_ATTR_UNUSED +static H5_INLINE hsize_t H5_ATTR_UNUSED H5VM_vector_reduce_product(unsigned n, const hsize_t *v) { hsize_t ret_value = 1; @@ -153,7 +153,7 @@ done: * *------------------------------------------------------------------------- */ -static H5_inline htri_t H5_ATTR_UNUSED +static H5_INLINE htri_t H5_ATTR_UNUSED H5VM_vector_zerop_u(int n, const hsize_t *v) { htri_t ret_value=TRUE; /* Return value */ @@ -188,7 +188,7 @@ done: * *------------------------------------------------------------------------- */ -static H5_inline htri_t H5_ATTR_UNUSED +static H5_INLINE htri_t H5_ATTR_UNUSED H5VM_vector_zerop_s(int n, const hssize_t *v) { htri_t ret_value=TRUE; /* Return value */ @@ -225,7 +225,7 @@ done: * *------------------------------------------------------------------------- */ -static H5_inline int H5_ATTR_UNUSED +static H5_INLINE int H5_ATTR_UNUSED H5VM_vector_cmp_u (unsigned n, const hsize_t *v1, const hsize_t *v2) { int ret_value=0; /* Return value */ @@ -267,7 +267,7 @@ done: * *------------------------------------------------------------------------- */ -static H5_inline int H5_ATTR_UNUSED +static H5_INLINE int H5_ATTR_UNUSED H5VM_vector_cmp_s (unsigned n, const hssize_t *v1, const hssize_t *v2) { int ret_value=0; /* Return value */ @@ -304,7 +304,7 @@ done: * *------------------------------------------------------------------------- */ -static H5_inline void H5_ATTR_UNUSED +static H5_INLINE void H5_ATTR_UNUSED H5VM_vector_inc(int n, hsize_t *v1, const hsize_t *v2) { while (n--) *v1++ += *v2++; @@ -351,7 +351,7 @@ static const unsigned char LogTable256[] = * *------------------------------------------------------------------------- */ -static H5_inline unsigned H5_ATTR_UNUSED +static H5_INLINE unsigned H5_ATTR_UNUSED H5VM_log2_gen(uint64_t n) { unsigned r; /* r will be log2(n) */ @@ -408,7 +408,7 @@ static const unsigned MultiplyDeBruijnBitPosition[32] = * *------------------------------------------------------------------------- */ -static H5_inline unsigned H5_ATTR_UNUSED +static H5_INLINE unsigned H5_ATTR_UNUSED H5VM_log2_of2(uint32_t n) { #ifndef NDEBUG @@ -431,7 +431,7 @@ H5VM_log2_of2(uint32_t n) * *------------------------------------------------------------------------- */ -static H5_inline unsigned H5_ATTR_UNUSED +static H5_INLINE unsigned H5_ATTR_UNUSED H5VM_limit_enc_size(uint64_t limit) { return (H5VM_log2_gen(limit) / 8) + 1; @@ -460,7 +460,7 @@ static const unsigned char H5VM_bit_clear_g[8] = {0x7F, 0xBF, 0xDF, 0xEF, 0xF7, * *------------------------------------------------------------------------- */ -static H5_inline hbool_t H5_ATTR_UNUSED +static H5_INLINE hbool_t H5_ATTR_UNUSED H5VM_bit_get(const unsigned char *buf, size_t offset) { /* Test the appropriate bit in the buffer */ @@ -487,7 +487,7 @@ H5VM_bit_get(const unsigned char *buf, size_t offset) * *------------------------------------------------------------------------- */ -static H5_inline void H5_ATTR_UNUSED +static H5_INLINE void H5_ATTR_UNUSED H5VM_bit_set(unsigned char *buf, size_t offset, hbool_t val) { /* Set/reset the appropriate bit in the buffer */ diff --git a/src/H5config.h.in b/src/H5config.h.in index 8b4648f..c7488d1 100644 --- a/src/H5config.h.in +++ b/src/H5config.h.in @@ -144,6 +144,9 @@ /* Define to 1 if you have the `get_fpc_csr' function. */ #undef HAVE_GET_FPC_CSR +/* Define if the compiler understands inline */ +#undef HAVE_INLINE + /* Define if library will contain instrumentation to detect correct optimization operation */ #undef HAVE_INSTRUMENTED_LIBRARY @@ -367,6 +370,12 @@ /* Define to 1 if you have the `_scrsize' function. */ #undef HAVE__SCRSIZE +/* Define if the compiler understands __inline */ +#undef HAVE___INLINE + +/* Define if the compiler understands __inline__ */ +#undef HAVE___INLINE__ + /* Define if your system can't handle converting floating-point values to long long. */ #undef HW_FP_TO_LLONG_NOT_WORKS @@ -595,12 +604,6 @@ /* Define to empty if `const' does not conform to ANSI C. */ #undef const -/* Define to `__inline__' or `__inline' if that's what the C compiler - calls it, or to nothing if 'inline' is not supported under any name. */ -#ifndef __cplusplus -#undef inline -#endif - /* Define to `long int' if does not define. */ #undef off_t diff --git a/src/H5private.h b/src/H5private.h index 828b3e3..6534f6f 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -183,11 +183,22 @@ #endif /*H5_HAVE_WIN32_API*/ -/* H5_inline */ -#ifndef H5_inline -#define H5_inline -#endif /* H5_inline */ - +/* Various ways that inline functions can be declared */ +#if defined(H5_HAVE___INLINE__) + /* GNU (alternative form) */ + #define H5_INLINE __inline__ +#elif defined(H5_HAVE___INLINE) + /* Visual Studio */ + #define H5_INLINE __inline +#elif defined(H5_HAVE_INLINE) + /* GNU, C++ + * Use "inline" as a last resort on the off-chance that there will + * be C++ problems. + */ + #define H5_INLINE inline +#else + #define H5_INLINE +#endif /* inline choices */ #ifndef F_OK # define F_OK 00 -- cgit v0.12