diff options
author | NAKAMURA Takumi <geek4civic@gmail.com> | 2011-02-09 04:18:48 +0000 |
---|---|---|
committer | NAKAMURA Takumi <geek4civic@gmail.com> | 2011-02-09 04:18:48 +0000 |
commit | e29b0aca51e3568a92869daa70c4a0351750fd1e (patch) | |
tree | 8d1829f0069c79afc3a5e02cf97bd42e5dbd3163 | |
parent | fd289497a5e8f83c6d83f1eb7e30fdc52621bf15 (diff) | |
download | external_llvm-e29b0aca51e3568a92869daa70c4a0351750fd1e.zip external_llvm-e29b0aca51e3568a92869daa70c4a0351750fd1e.tar.gz external_llvm-e29b0aca51e3568a92869daa70c4a0351750fd1e.tar.bz2 |
lib/Support/Errno.cpp: Check strerror_s() with HAVE_DECL_STRERROR_S in config.h.*.
AC_CHECK_FUNCS seeks a symbol only in libs. We should check the declaration in string.h.
FIXME: I have never seen mingw(s) have strerror_s() (not _strerror_s()).
FIXME: Autoconf/CMake may seek strerror_s() with the definition MINGW_HAS_SECURE_API in future.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125172 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | autoconf/configure.ac | 5 | ||||
-rwxr-xr-x | cmake/config-ix.cmake | 2 | ||||
-rwxr-xr-x | configure | 90 | ||||
-rw-r--r-- | include/llvm/Config/config.h.cmake | 7 | ||||
-rw-r--r-- | include/llvm/Config/config.h.in | 7 | ||||
-rw-r--r-- | lib/Support/Errno.cpp | 2 |
6 files changed, 102 insertions, 11 deletions
diff --git a/autoconf/configure.ac b/autoconf/configure.ac index 5a65d35..9259633 100644 --- a/autoconf/configure.ac +++ b/autoconf/configure.ac @@ -1391,12 +1391,15 @@ AC_CHECK_FUNCS([powf fmodf strtof round ]) AC_CHECK_FUNCS([getpagesize getrusage getrlimit setrlimit gettimeofday ]) AC_CHECK_FUNCS([isatty mkdtemp mkstemp ]) AC_CHECK_FUNCS([mktemp posix_spawn realpath sbrk setrlimit strdup ]) -AC_CHECK_FUNCS([strerror strerror_r strerror_s setenv ]) +AC_CHECK_FUNCS([strerror strerror_r setenv ]) AC_CHECK_FUNCS([strtoll strtoq sysconf malloc_zone_statistics ]) AC_CHECK_FUNCS([setjmp longjmp sigsetjmp siglongjmp writev]) AC_C_PRINTF_A AC_FUNC_RAND48 +dnl Check the declaration "Secure API" on Windows environments. +AC_CHECK_DECLS([strerror_s]) + dnl Check symbols in libgcc.a for JIT on Mingw. if test "$llvm_cv_os_type" = "MingW" ; then AC_CHECK_LIB(gcc,_alloca,AC_DEFINE([HAVE__ALLOCA],[1],[Have host's _alloca])) diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake index 9e2cbe1..c2fe431 100755 --- a/cmake/config-ix.cmake +++ b/cmake/config-ix.cmake @@ -149,7 +149,7 @@ check_symbol_exists(strtoll stdlib.h HAVE_STRTOLL) check_symbol_exists(strtoq stdlib.h HAVE_STRTOQ) check_symbol_exists(strerror string.h HAVE_STRERROR) check_symbol_exists(strerror_r string.h HAVE_STRERROR_R) -check_symbol_exists(strerror_s string.h HAVE_STRERROR_S) +check_symbol_exists(strerror_s string.h HAVE_DECL_STRERROR_S) check_symbol_exists(memcpy string.h HAVE_MEMCPY) check_symbol_exists(memmove string.h HAVE_MEMMOVE) check_symbol_exists(setenv stdlib.h HAVE_SETENV) @@ -18679,8 +18679,7 @@ done - -for ac_func in strerror strerror_r strerror_s setenv +for ac_func in strerror strerror_r setenv do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` { echo "$as_me:$LINENO: checking for $ac_func" >&5 @@ -19199,6 +19198,93 @@ _ACEOF fi +{ echo "$as_me:$LINENO: checking whether strerror_s is declared" >&5 +echo $ECHO_N "checking whether strerror_s is declared... $ECHO_C" >&6; } +if test "${ac_cv_have_decl_strerror_s+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +#ifndef strerror_s + char *p = (char *) strerror_s; + return !p; +#endif + + ; + 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); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (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_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (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_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_have_decl_strerror_s=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_have_decl_strerror_s=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_have_decl_strerror_s" >&5 +echo "${ECHO_T}$ac_cv_have_decl_strerror_s" >&6; } +if test $ac_cv_have_decl_strerror_s = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_STRERROR_S 1 +_ACEOF + + +else + cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_STRERROR_S 0 +_ACEOF + + +fi + + + if test "$llvm_cv_os_type" = "MingW" ; then { echo "$as_me:$LINENO: checking for _alloca in -lgcc" >&5 echo $ECHO_N "checking for _alloca in -lgcc... $ECHO_C" >&6; } diff --git a/include/llvm/Config/config.h.cmake b/include/llvm/Config/config.h.cmake index 50b369b..bf69375 100644 --- a/include/llvm/Config/config.h.cmake +++ b/include/llvm/Config/config.h.cmake @@ -62,6 +62,10 @@ /* Define to 1 if you have the <ctype.h> header file. */ #cmakedefine HAVE_CTYPE_H ${HAVE_CTYPE_H} +/* Define to 1 if you have the declaration of `strerror_s', and to 0 if you + don't. */ +#cmakedefine01 HAVE_DECL_STRERROR_S + /* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'. */ #cmakedefine HAVE_DIRENT_H ${HAVE_DIRENT_H} @@ -368,9 +372,6 @@ /* Define to 1 if you have the `strerror_r' function. */ #cmakedefine HAVE_STRERROR_R ${HAVE_STRERROR_R} -/* Define to 1 if you have the `strerror_s' function. */ -#cmakedefine HAVE_STRERROR_S ${HAVE_STRERROR_S} - /* Define to 1 if you have the <strings.h> header file. */ #cmakedefine HAVE_STRINGS_H ${HAVE_STRINGS_H} diff --git a/include/llvm/Config/config.h.in b/include/llvm/Config/config.h.in index 041010c..14c44b4 100644 --- a/include/llvm/Config/config.h.in +++ b/include/llvm/Config/config.h.in @@ -78,6 +78,10 @@ /* Define to 1 if you have the <ctype.h> header file. */ #undef HAVE_CTYPE_H +/* Define to 1 if you have the declaration of `strerror_s', and to 0 if you + don't. */ +#undef HAVE_DECL_STRERROR_S + /* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'. */ #undef HAVE_DIRENT_H @@ -384,9 +388,6 @@ /* Define to 1 if you have the `strerror_r' function. */ #undef HAVE_STRERROR_R -/* Define to 1 if you have the `strerror_s' function. */ -#undef HAVE_STRERROR_S - /* Define to 1 if you have the <strings.h> header file. */ #undef HAVE_STRINGS_H diff --git a/lib/Support/Errno.cpp b/lib/Support/Errno.cpp index 312d91e..18c6581 100644 --- a/lib/Support/Errno.cpp +++ b/lib/Support/Errno.cpp @@ -50,7 +50,7 @@ std::string StrError(int errnum) { # else strerror_r(errnum,buffer,MaxErrStrLen-1); # endif -#elif defined(HAVE_STRERROR_S) // Windows. +#elif HAVE_DECL_STRERROR_S // "Windows Secure API" if (errnum) strerror_s(buffer, errnum); #elif defined(HAVE_STRERROR) |