From 9f2f18ed924d74a432a7850abb80189189265cbd Mon Sep 17 00:00:00 2001 From: Brian Cox Date: Tue, 13 Aug 2019 09:52:09 -0700 Subject: [PATCH] buildsys tweaks for various platforms incl. AIX + XL C, Solaris + Oracle Studio --- config.h.in | 33 +++++++++++++++- configure | 75 ++++++++++++++++++++++++++++++++++--- configure.ac | 26 +++++++++---- src/core/error.h | 4 +- src/core/unixfsservices.cpp | 50 ++++++++++++------------- 5 files changed, 147 insertions(+), 41 deletions(-) diff --git a/config.h.in b/config.h.in index 6d143fa..6afbdcd 100644 --- a/config.h.in +++ b/config.h.in @@ -48,8 +48,8 @@ /* Define to 1 if you have the header file. */ #undef HAVE_DOOR_H -/* Define to 1 if you have the `exec' function. */ -#undef HAVE_EXEC +/* Define to 1 if you have the `execve' function. */ +#undef HAVE_EXECVE /* Define to 1 if you have the `fclose' function. */ #undef HAVE_FCLOSE @@ -75,6 +75,12 @@ /* Uses the GNU gcc compiler */ #undef HAVE_GCC +/* Define to 1 if you have the `getaddrinfo' function. */ +#undef HAVE_GETADDRINFO + +/* Define to 1 if you have the `getgrgid' function. */ +#undef HAVE_GETGRGID + /* Define to 1 if you have the `gethostbyname' function. */ #undef HAVE_GETHOSTBYNAME @@ -165,6 +171,9 @@ /* Define to 1 if you have the `posix_fadvise' function. */ #undef HAVE_POSIX_FADVISE +/* Define to 1 if you have the `posix_spawn' function. */ +#undef HAVE_POSIX_SPAWN + /* Define to 1 if you have the header file. */ #undef HAVE_PWD_H @@ -180,6 +189,12 @@ /* Define to 1 if you have the `readlinkat' function. */ #undef HAVE_READLINKAT +/* Define to 1 if you have the `setgid' function. */ +#undef HAVE_SETGID + +/* Define to 1 if you have the `setuid' function. */ +#undef HAVE_SETUID + /* Define to 1 if you have the header file. */ #undef HAVE_SIGNUM_H @@ -413,6 +428,20 @@ /* Define to empty if `const' does not conform to ANSI C. */ #undef const +/* Define to the equivalent of the C99 'restrict' keyword, or to + nothing if this is not supported. Do not define if restrict is + supported directly. */ +#undef restrict +/* Work around a bug in Sun C++: it does not support _Restrict or + __restrict__, even though the corresponding Sun C compiler ends up with + "#define restrict _Restrict" or "#define restrict __restrict__" in the + previous line. Perhaps some future version of Sun C++ will work with + restrict; if so, hopefully it defines __RESTRICT like Sun C does. */ +#if defined __SUNPRO_CC && !defined __RESTRICT +# define _Restrict +# define __restrict__ +#endif + /* Define to `unsigned int' if does not define. */ #undef size_t diff --git a/configure b/configure index 724272e..25e640a 100755 --- a/configure +++ b/configure @@ -4900,8 +4900,10 @@ if test "x${CXX}" = "xgxlc++"; then $as_echo "#define HAVE_IBM_GXLC 1" >>confdefs.h - CFLAGS=${CFLAGS:-"-O -pipe"} - CXXFLAGS=${CXXFLAGS:-"-O -pipe"} + export OBJECT_MODE=64 + CFLAGS=${CFLAGS:-"-O -maix64 -Wx,-qinfo=all" } + CXXFLAGS=${CXXFLAGS:-"-O -maix64 -Wx,-qinfo=all"} + ARFLAGS=${ARFLAGS:-"-X 64"} else $as_echo "#define HAVE_IBM_GXLC 0" >>confdefs.h @@ -4913,8 +4915,10 @@ if test "x${CXX}" = "xxlc++_r"; then $as_echo "#define HAVE_IBM_XLC 1" >>confdefs.h - CFLAGS=${CFLAGS:-"-O -maix64 -Wx,-qinfo=all" } - CXXFLAGS=${CXXFLAGS:-"-O -maix64 -Wx,-qinfo=all"} + export OBJECT_MODE=64 + CFLAGS=${CFLAGS:-"-O -q64 -qinfo=all"} + CXXFLAGS=${CXXFLAGS:-"-O -q64 -qinfo=all"} + ARFLAGS=${ARFLAGS:-"-X 64"} else $as_echo "#define HAVE_IBM_XLC 0" >>confdefs.h @@ -6402,6 +6406,53 @@ rm -rf conftest* fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C/C++ restrict keyword" >&5 +$as_echo_n "checking for C/C++ restrict keyword... " >&6; } +if ${ac_cv_c_restrict+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_c_restrict=no + # The order here caters to the fact that C++ does not require restrict. + for ac_kw in __restrict __restrict__ _Restrict restrict; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +typedef int * int_ptr; + int foo (int_ptr $ac_kw ip) { + return ip[0]; + } +int +main () +{ +int s[1]; + int * $ac_kw t = s; + t[0] = 0; + return foo(t) + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_c_restrict=$ac_kw +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + test "$ac_cv_c_restrict" != no && break + done + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_restrict" >&5 +$as_echo "$ac_cv_c_restrict" >&6; } + + case $ac_cv_c_restrict in + restrict) ;; + no) $as_echo "#define restrict /**/" >>confdefs.h + ;; + *) cat >>confdefs.h <<_ACEOF +#define restrict $ac_cv_c_restrict +_ACEOF + ;; + esac + + for ac_func in broken_ac_check_func do : ac_fn_cxx_check_func "$LINENO" "broken_ac_check_func" "ac_cv_func_broken_ac_check_func" @@ -6425,7 +6476,7 @@ _ACEOF fi done -for ac_func in gethostname gethostbyname gethostid getuid +for ac_func in getaddrinfo gethostname gethostbyname gethostid getuid do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_cxx_check_func "$LINENO" "$ac_func" "$as_ac_var" @@ -6547,7 +6598,19 @@ _ACEOF fi done -for ac_func in fork exec socket +for ac_func in fork execve posix_spawn socket +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_cxx_check_func "$LINENO" "$ac_func" "$as_ac_var" +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + +for ac_func in setuid setgid getgrgid do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_cxx_check_func "$LINENO" "$ac_func" "$as_ac_var" diff --git a/configure.ac b/configure.ac index 9394a69..2ec4e50 100644 --- a/configure.ac +++ b/configure.ac @@ -67,8 +67,11 @@ fi if test "x${CXX}" = "xgxlc++"; then AC_DEFINE(HAVE_IBM_GXLC, 1, [Uses the gxlc++ compiler]) - CFLAGS=${CFLAGS:-"-O -pipe"} - CXXFLAGS=${CXXFLAGS:-"-O -pipe"} +dnl OBJECT_MODE needs to be set while compiling + export OBJECT_MODE=64 + CFLAGS=${CFLAGS:-"-O -maix64 -Wx,-qinfo=all" } + CXXFLAGS=${CXXFLAGS:-"-O -maix64 -Wx,-qinfo=all"} + ARFLAGS=${ARFLAGS:-"-X 64"} else AC_DEFINE(HAVE_IBM_GXLC, 0, [Uses the gxlc++ compiler]) fi @@ -76,8 +79,11 @@ fi if test "x${CXX}" = "xxlc++_r"; then AC_DEFINE(HAVE_IBM_XLC, 1, [Uses the IBM XL C++ compiler]) - CFLAGS=${CFLAGS:-"-O -maix64 -Wx,-qinfo=all" } - CXXFLAGS=${CXXFLAGS:-"-O -maix64 -Wx,-qinfo=all"} +dnl OBJECT_MODE needs to be set while compiling + export OBJECT_MODE=64 + CFLAGS=${CFLAGS:-"-O -q64 -qinfo=all"} + CXXFLAGS=${CXXFLAGS:-"-O -q64 -qinfo=all"} + ARFLAGS=${ARFLAGS:-"-X 64"} else AC_DEFINE(HAVE_IBM_XLC, 0, [Uses the IBM XL C++ compiler]) fi @@ -235,6 +241,10 @@ AC_CHECK_MEMBERS([struct stat.st_rdev, struct stat.st_blocks, struct stat.st_fla dnl detect large file support & use it where available AC_SYS_LARGEFILE +dnl detect whether C++ compiler supports any variant of 'restrict' keyword +dnl (the macro says 'C' but works for both C & C++) +AC_C_RESTRICT + dnl ****************************************** dnl Check whether AC_CHECK_FUNC(S) lies to us dnl ****************************************** @@ -244,7 +254,7 @@ dnl ############################# dnl Checks for standard functions dnl ############################# AC_CHECK_FUNCS(strftime) -AC_CHECK_FUNCS(gethostname gethostbyname gethostid getuid) +AC_CHECK_FUNCS(getaddrinfo gethostname gethostbyname gethostid getuid) AC_CHECK_FUNCS(mkstemp mktemp tmpnam break) AC_CHECK_FUNCS(swab tzset _exit popen) @@ -263,8 +273,10 @@ dnl posix fns that make filesystem changes AC_CHECK_FUNCS(chown chmod link symlink) dnl posix syslog fns AC_CHECK_FUNCS(openlog syslog closelog) -dnl assorted other posix fns -AC_CHECK_FUNCS(fork exec socket) +dnl posix process & networking stuff +AC_CHECK_FUNCS(fork execve posix_spawn socket) +dnl posix user & group stuff +AC_CHECK_FUNCS(setuid setgid getgrgid) dnl check for posix_fadvise AC_CHECK_HEADERS(fcntl.h, [AC_CHECK_FUNCS(posix_fadvise)]) diff --git a/src/core/error.h b/src/core/error.h index 03b824b..a98f5f8 100644 --- a/src/core/error.h +++ b/src/core/error.h @@ -127,7 +127,9 @@ protected: // to be added to the exception class. /////////////////////////////////////////////////////////////////////////////// -#if HAVE_GCC || HAVE_IBM_GXLC +// TODO: make use of 'explicit' more portable here, and/or figure out why +// this doesn't work on so many compilers +#if HAVE_GCC || HAVE_IBM_XLC || HAVE_IBM_GXLC || HAVE_ORACLE_SUNCC # define TSS_BEGIN_EXCEPTION_EXPLICIT #else # define TSS_BEGIN_EXCEPTION_EXPLICIT explicit diff --git a/src/core/unixfsservices.cpp b/src/core/unixfsservices.cpp index 509b4e3..3cdca6a 100644 --- a/src/core/unixfsservices.cpp +++ b/src/core/unixfsservices.cpp @@ -47,37 +47,37 @@ // STANDARD LIBRARY INCLUDES //========================================================================= -#include -#include +//#include +//#include -#include +//#include #include #include -#include +//#include -#if HAVE_SYS_TIME_H -#include -#endif +//#if HAVE_SYS_TIME_H +//#include +//#endif -#if HAVE_SYS_PARAM_H -#include -#endif +//#if HAVE_SYS_PARAM_H +//#include +//#endif -#if HAVE_SYS_MOUNT_H -#include -#endif +//#if HAVE_SYS_MOUNT_H +//#include +//#endif -#if HAVE_SYS_USTAT_H +/*#if HAVE_SYS_USTAT_H #include -#endif +#endif*/ -#if HAVE_WCHAR_H -#include -#endif +//#if HAVE_WCHAR_H +//#include +//#endif -#if HAVE_SYS_SYSMACROS_H -#include -#endif +//#if HAVE_SYS_SYSMACROS_H +//#include +//#endif #if HAVE_SYS_UTSNAME_H #include @@ -101,8 +101,8 @@ #include #endif -#include -#include +#//include +#//include //========================================================================= // INCLUDES @@ -116,10 +116,10 @@ // -jeb 7/26/99 // reduced to sys/statfs.h. Linux is OK and doesn't deserve // special treatment. 20010317-PH -#ifdef HAVE_SYS_STATFS_H +/*#ifdef HAVE_SYS_STATFS_H #include #endif //HAVE_SYS_STATFS_H - +*/ //========================================================================= // DEFINES AND MACROS