From: Wouter Wijngaards Date: Fri, 11 Dec 2015 12:44:44 +0000 (+0000) Subject: - OSX portability, detect if sbrk is deprecated. X-Git-Tag: release-1.5.8~56 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=46ca8274b8f2a50939e053c4ab19817ab61f7cfb;p=thirdparty%2Funbound.git - OSX portability, detect if sbrk is deprecated. git-svn-id: file:///svn/unbound/trunk@3582 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/config.h.in b/config.h.in index e90f036cf..3364395c4 100644 --- a/config.h.in +++ b/config.h.in @@ -293,7 +293,7 @@ /* Define to 1 if you have the `recvmsg' function. */ #undef HAVE_RECVMSG -/* Define to 1 if you have the `sbrk' function. */ +/* define if you have the sbrk() call */ #undef HAVE_SBRK /* Define to 1 if you have the `sendmsg' function. */ diff --git a/configure b/configure index 8136b8242..6f627b512 100755 --- a/configure +++ b/configure @@ -18123,7 +18123,7 @@ if test "$ac_res" != no; then : fi -for ac_func in tzset sigprocmask fcntl getpwnam getrlimit setrlimit setsid sbrk chroot kill chown sleep usleep random srandom recvmsg sendmsg writev socketpair glob initgroups strftime localtime_r setusercontext _beginthreadex endservent endprotoent fsync +for ac_func in tzset sigprocmask fcntl getpwnam getrlimit setrlimit setsid chroot kill chown sleep usleep random srandom recvmsg sendmsg writev socketpair glob initgroups strftime localtime_r setusercontext _beginthreadex endservent endprotoent fsync do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" @@ -18182,6 +18182,33 @@ fi done +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sbrk" >&5 +$as_echo_n "checking for sbrk... " >&6; } +# catch the warning of deprecated sbrk +old_cflags="$CFLAGS" +CFLAGS="$CFLAGS -Werror" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default + +int main(void) { void* cur = sbrk(0); printf("%u\n", (unsigned)(size_t)((char*)cur - (char*)sbrk(0))); 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; } + +$as_echo "#define HAVE_SBRK 1" >>confdefs.h + + +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 +CFLAGS="$old_cflags" + # check if setreuid en setregid fail, on MacOSX10.4(darwin8). if echo $build_os | grep darwin8 > /dev/null; then diff --git a/configure.ac b/configure.ac index 76950d0f4..49075254b 100644 --- a/configure.ac +++ b/configure.ac @@ -1013,10 +1013,23 @@ AC_INCLUDES_DEFAULT #endif ]) AC_SEARCH_LIBS([setusercontext], [util]) -AC_CHECK_FUNCS([tzset sigprocmask fcntl getpwnam getrlimit setrlimit setsid sbrk chroot kill chown sleep usleep random srandom recvmsg sendmsg writev socketpair glob initgroups strftime localtime_r setusercontext _beginthreadex endservent endprotoent fsync]) +AC_CHECK_FUNCS([tzset sigprocmask fcntl getpwnam getrlimit setrlimit setsid chroot kill chown sleep usleep random srandom recvmsg sendmsg writev socketpair glob initgroups strftime localtime_r setusercontext _beginthreadex endservent endprotoent fsync]) AC_CHECK_FUNCS([setresuid],,[AC_CHECK_FUNCS([setreuid])]) AC_CHECK_FUNCS([setresgid],,[AC_CHECK_FUNCS([setregid])]) +AC_MSG_CHECKING([for sbrk]) +# catch the warning of deprecated sbrk +old_cflags="$CFLAGS" +CFLAGS="$CFLAGS -Werror" +AC_COMPILE_IFELSE([AC_LANG_SOURCE(AC_INCLUDES_DEFAULT +[[ +int main(void) { void* cur = sbrk(0); printf("%u\n", (unsigned)(size_t)((char*)cur - (char*)sbrk(0))); return 0; } +]])], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_SBRK, 1, [define if you have the sbrk() call]) + ], [AC_MSG_RESULT(no)]) +CFLAGS="$old_cflags" + # check if setreuid en setregid fail, on MacOSX10.4(darwin8). if echo $build_os | grep darwin8 > /dev/null; then AC_DEFINE(DARWIN_BROKEN_SETREUID, 1, [Define this if on macOSX10.4-darwin8 and setreuid and setregid do not work]) diff --git a/doc/Changelog b/doc/Changelog index 3171d9fa3..681b203e2 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -2,6 +2,7 @@ - remove NULL-checks before free, patch from Michael McConville. - updated ax_pthread.m4 to version 21 with clang support, this removes a warning from compilation. + - OSX portability, detect if sbrk is deprecated. 10 December 2015: Wouter - 1.5.7 release