diff options
author | wrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68> | 2006-03-02 22:53:49 +0000 |
---|---|---|
committer | wrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68> | 2006-03-02 22:53:49 +0000 |
commit | 180bd0c3964b878474ee5d6abd1c47e9365be4d2 (patch) | |
tree | ea2e8fed44ccecf086afec22a5db50b01750538c | |
parent | 043cadf6e4a54013cb493bca7144679bdd51cf09 (diff) | |
download | libapr-180bd0c3964b878474ee5d6abd1c47e9365be4d2.tar.gz |
Address bug 37999 and other exceptions to the existing uuid detection code;
favor uuid_create or uuid_generate if they live in the clib, and perform
a true compile/link test on our suspected success case, disabling the
code if this fails.
More sets of eyes and feedback to dev@apr requested before we backport this
patch to APR 1.2.x
Authored by: wrowe, maxb
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@382541 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | configure.in | 54 | ||||
-rw-r--r-- | misc/unix/rand.c | 8 |
2 files changed, 57 insertions, 5 deletions
diff --git a/configure.in b/configure.in index 8d29a20aa..999517e53 100644 --- a/configure.in +++ b/configure.in @@ -1803,15 +1803,61 @@ AC_SUBST(rand) dnl ----------------------------- Checking for UUID Support echo "${nl}Checking for OS UUID Support..." -osuuid="0" -AC_CHECK_HEADERS(uuid/uuid.h uuid.h) +AC_CHECK_HEADERS(uuid.h sys/uuid.h uuid/uuid.h, break) -# Check for uuid_generate in libc or libuuid +apr_revert_save_LIBS=$LIBS + +# Prefer the flavor(s) that live in libc; +AC_SEARCH_LIBS(uuid_create, uuid) AC_SEARCH_LIBS(uuid_generate, uuid) +if test "$ac_cv_search_uuid_create" = "none required" -o \ + "$ac_cv_search_uuid_generate" = "none required"; then + LIBS=$apr_revert_save_LIBS +fi -AC_CHECK_FUNCS([uuid_generate uuid_create], [osuuid=1; break]) +AC_CHECK_FUNCS(uuid_create uuid_generate) + +AC_CACHE_CHECK([for os uuid usability], [apr_cv_osuuid], [ +# Ensure this test closely mirrors misc/unix/rand.c! +uuid_includes=" ${nl} +#if defined(HAVE_SYS_TYPES_H) ${nl} +#include <sys/types.h> ${nl} +#endif ${nl} +#if defined(HAVE_UNISTD_H) ${nl} +#include <unistd.h> ${nl} +#endif ${nl} +#if defined(HAVE_UUID_H) ${nl} +#include <uuid.h> ${nl} +#elif defined(HAVE_SYS_UUID_H) ${nl} +#include <sys/uuid.h> ${nl} +#elif defined(HAVE_UUID_UUID_H) ${nl} +#include <uuid/uuid.h> ${nl} +#endif ${nl} +" + apr_cv_osuuid=no + if test $ac_cv_func_uuid_create = yes; then + AC_TRY_LINK([$uuid_includes], [ + uuid_t g; + uint32_t s; + uuid_create(&g, &s); + if (s == uuid_s_ok) s = 0; + ], [apr_cv_osuuid=yes], [apr_cv_func_uuid_create=no]) + fi + if test $ac_cv_func_uuid_generate = yes; then + AC_TRY_LINK([$uuid_includes], [ + uuid_t g; + uuid_generate(g); + ], [apr_cv_osuuid=yes], [apr_cv_func_uuid_generate=no]) + fi +]) +if test $apr_cv_osuuid = yes; then + osuuid="1" +else + osuuid="0" + LIBS=$apr_revert_save_LIBS +fi AC_SUBST(osuuid) diff --git a/misc/unix/rand.c b/misc/unix/rand.c index 1763bb413..2e0d8353e 100644 --- a/misc/unix/rand.c +++ b/misc/unix/rand.c @@ -35,8 +35,10 @@ #if APR_HAVE_SYS_UN_H #include <sys/un.h> #endif -#ifdef HAVE_UUID_H +#if defined(HAVE_UUID_H) #include <uuid.h> +#elif defined(HAVE_SYS_UUID_H) +#include <sys/uuid.h> #elif defined(HAVE_UUID_UUID_H) #include <uuid/uuid.h> #endif @@ -45,6 +47,8 @@ #define SHUT_RDWR 2 #endif +#if APR_HAS_OS_UUID + #if defined(HAVE_UUID_CREATE) APR_DECLARE(apr_status_t) apr_os_uuid_get(unsigned char *uuid_data) @@ -72,6 +76,8 @@ APR_DECLARE(apr_status_t) apr_os_uuid_get(unsigned char *uuid_data) } #endif +#endif /* APR_HAS_OS_UUID */ + #if APR_HAS_RANDOM APR_DECLARE(apr_status_t) apr_generate_random_bytes(unsigned char *buf, |