diff --git a/qse/configure b/qse/configure index c3419361..cd4a9c4d 100755 --- a/qse/configure +++ b/qse/configure @@ -17382,6 +17382,18 @@ fi done +for ac_header in crt_externs.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "crt_externs.h" "ac_cv_header_crt_externs_h" "$ac_includes_default" +if test "x$ac_cv_header_crt_externs_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_CRT_EXTERNS_H 1 +_ACEOF + +fi + +done + for ac_header in uci.h do : ac_fn_c_check_header_mongrel "$LINENO" "uci.h" "ac_cv_header_uci_h" "$ac_includes_default" @@ -18056,11 +18068,55 @@ if test "x$ac_cv_lib_ssl_SSL_library_init" = xyes; then : $as_echo "#define HAVE_SSL 1" >>confdefs.h + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ERR_get_error in -lcrypto" >&5 +$as_echo_n "checking for ERR_get_error in -lcrypto... " >&6; } +if ${ac_cv_lib_crypto_ERR_get_error+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lcrypto $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char ERR_get_error (); +int +main () +{ +return ERR_get_error (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_crypto_ERR_get_error=yes +else + ac_cv_lib_crypto_ERR_get_error=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_ERR_get_error" >&5 +$as_echo "$ac_cv_lib_crypto_ERR_get_error" >&6; } +if test "x$ac_cv_lib_crypto_ERR_get_error" = xyes; then : + + SSL_LIBS="${SSL_LIBS} -lcrypto" + +fi + + $as_echo "#define HAVE_SSL_LIBRARY_INIT 1" >>confdefs.h fi + fi @@ -19732,21 +19788,36 @@ fi if test ${ac_cv_sizeof___int128_t} -gt 0 then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking __int128_t with %" >&5 +$as_echo_n "checking __int128_t with %... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { -__int128_t x = 0; x %= 10; + + volatile __int128_t x, base; + x = (__int128_t)&base; + base = (__int128_t)&x; + x = x % base; + return (int)x; + ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + else - ac_cv_sizeof___int128_t=0 + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + ac_cv_sizeof___int128_t=0 + fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext diff --git a/qse/configure.ac b/qse/configure.ac index 3eba9fd7..43de85a3 100644 --- a/qse/configure.ac +++ b/qse/configure.ac @@ -108,6 +108,7 @@ AC_CHECK_HEADERS([net/if.h net/if_dl.h], [], [], [ #include #include ]) AC_CHECK_HEADERS([sys/stropts.h sys/macstat.h linux/ethtool.h linux/sockios.h]) +AC_CHECK_HEADERS([crt_externs.h]) AC_CHECK_HEADERS([uci.h]) dnl check data types @@ -235,9 +236,15 @@ else SSL_LIBS="-lssl" AC_DEFINE(HAVE_SSL, 1, [ssl support]) + dnl additional check + AC_CHECK_LIB([crypto], [ERR_get_error], [ + SSL_LIBS="${SSL_LIBS} -lcrypto" + ]) + dnl only for consistency with AC_CHECK_FUNCS AC_DEFINE(HAVE_SSL_LIBRARY_INIT, 1) ]) + fi AC_SUBST(SSL_LIBS) @@ -331,10 +338,23 @@ dnl Changing ac_cv_sizeof___int128_t here doesn't corret SIZEOF___INT128_T dnl since it's already generated. It only affects QSE_SIZEOF___INT128_T below. if test ${ac_cv_sizeof___int128_t} -gt 0 then + AC_MSG_CHECKING([__int128_t with %]) AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([], [__int128_t x = 0; x %= 10;])], - [], - [ac_cv_sizeof___int128_t=0] + [AC_LANG_PROGRAM([], [ + volatile __int128_t x, base; + x = (__int128_t)&base; + base = (__int128_t)&x; + x = x % base; + return (int)x; + ])], + + [ + AC_MSG_RESULT(yes) + ], + [ + AC_MSG_RESULT(no) + ac_cv_sizeof___int128_t=0 + ] ) fi diff --git a/qse/include/qse/config.h.in b/qse/include/qse/config.h.in index f8dc0de0..d9c3c013 100644 --- a/qse/include/qse/config.h.in +++ b/qse/include/qse/config.h.in @@ -75,6 +75,9 @@ /* Define to 1 if you have the `cosl' function. */ #undef HAVE_COSL +/* Define to 1 if you have the header file. */ +#undef HAVE_CRT_EXTERNS_H + /* Define to 1 if you have the declaration of `cygwin_conv_path', and to 0 if you don't. */ #undef HAVE_DECL_CYGWIN_CONV_PATH diff --git a/qse/include/qse/types.h b/qse/include/qse/types.h index b580d3a5..487c7032 100644 --- a/qse/include/qse/types.h +++ b/qse/include/qse/types.h @@ -73,7 +73,8 @@ typedef enum qse_tri_t qse_tri_t; /** @typedef qse_uint_t * The qse_uint_t type defines an unsigned integer type as large as a pointer. */ -#if (defined(hpux) || defined(__hpux) || defined(__hpux__)) && \ +#if (defined(hpux) || defined(__hpux) || defined(__hpux__) || \ + (defined(__APPLE__) && defined(__MACH__))) && \ (QSE_SIZEOF_VOID_P == QSE_SIZEOF_LONG) typedef long qse_int_t; typedef unsigned long qse_uint_t; diff --git a/qse/lib/cmn/env.c b/qse/lib/cmn/env.c index 97c6bd44..8dccc42f 100644 --- a/qse/lib/cmn/env.c +++ b/qse/lib/cmn/env.c @@ -28,6 +28,11 @@ # include #endif +#if defined(HAVE_CRT_EXTERNS_H) + /* MacOSX/darwin. _NSGetEnviron() */ +# include +#endif + #define STRSIZE 4096 #define ARRSIZE 128 @@ -410,7 +415,6 @@ static qse_char_t* get_env (qse_env_t* env, const qse_char_t* name, int* free) return QSE_NULL; } - #elif defined(QSE_ENV_CHAR_IS_WCHAR) static qse_wchar_t* get_env (qse_env_t* env, const qse_wchar_t* name, int* free) { @@ -470,8 +474,13 @@ static qse_wchar_t* get_env (qse_env_t* env, const qse_wchar_t* name, int* free) static qse_mchar_t* get_env (qse_env_t* env, const qse_mchar_t* name, int* free) { + + #if defined(HAVE_CRT_EXTERNS_H) + qse_mchar_t** p = *(_NSGetEnviron()); + #else extern char** environ; qse_mchar_t** p = environ; + #endif if (p) { @@ -633,8 +642,13 @@ done: return 0; #else + + #if defined(HAVE_CRT_EXTERNS_H) + qse_mchar_t** p = *(_NSGetEnviron()); + #else extern char** environ; qse_mchar_t** p = environ; + #endif if (p) { diff --git a/qse/lib/cmn/pio.c b/qse/lib/cmn/pio.c index 69e48cef..7eab3494 100644 --- a/qse/lib/cmn/pio.c +++ b/qse/lib/cmn/pio.c @@ -38,6 +38,9 @@ # if defined(HAVE_SPAWN_H) # include # endif +# if defined(HAVE_CRT_EXTERNS_H) +# include /* MacOSX/darwin. _NSGetEnviron() */ +# endif #endif static qse_ssize_t pio_input ( @@ -445,18 +448,30 @@ int qse_pio_init ( posix_spawnattr_t psattr; qse_pio_pid_t pid; param_t param; + #if defined(HAVE_CRT_EXTERNS_H) + #define environ (*(_NSGetEnviron())) + #else extern char** environ; + #endif #elif defined(QSE_SYSCALL0) && defined(SYS_vfork) qse_pio_pid_t pid; param_t param; + #if defined(HAVE_CRT_EXTERNS_H) + #define environ (*(_NSGetEnviron())) + #else extern char** environ; + #endif char** envarr; int highest_fd; int dummy; #else qse_pio_pid_t pid; param_t param; + #if defined(HAVE_CRT_EXTERNS_H) + #define environ (*(_NSGetEnviron())) + #else extern char** environ; + #endif #endif QSE_MEMSET (pio, 0, QSE_SIZEOF(*pio));