diff --git a/Misc/NEWS.d/next/Core and Builtins/2017-12-22-13-38-17.bpo-32399.wlH12z.rst b/Misc/NEWS.d/next/Core and Builtins/2017-12-22-13-38-17.bpo-32399.wlH12z.rst new file mode 100644 index 00000000000..ab18f268c81 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2017-12-22-13-38-17.bpo-32399.wlH12z.rst @@ -0,0 +1 @@ +Add AIX uuid library support for RFC4122 using uuid_create() in libc.a diff --git a/Modules/_uuidmodule.c b/Modules/_uuidmodule.c index d4bc3c7b0d4..1b37511c228 100644 --- a/Modules/_uuidmodule.c +++ b/Modules/_uuidmodule.c @@ -1,22 +1,33 @@ #define PY_SSIZE_T_CLEAN #include "Python.h" +#ifdef HAVE_UUID_UUID_H #include +#endif +#ifdef HAVE_UUID_H +#include +#endif static PyObject * py_uuid_generate_time_safe(void) { + uuid_t uuid; #ifdef HAVE_UUID_GENERATE_TIME_SAFE - uuid_t out; int res; - res = uuid_generate_time_safe(out); - return Py_BuildValue("y#i", (const char *) out, sizeof(out), res); + res = uuid_generate_time_safe(uuid); + return Py_BuildValue("y#i", (const char *) uuid, sizeof(uuid), res); +#elif HAVE_UUID_CREATE +/* + * AIX support for uuid - RFC4122 + */ + unsigned32 status; + uuid_create(&uuid, &status); + return Py_BuildValue("y#i", (const char *) &uuid, sizeof(uuid), (int) status); #else - uuid_t out; - uuid_generate_time(out); - return Py_BuildValue("y#O", (const char *) out, sizeof(out), Py_None); + uuid_generate_time(uuid); + return Py_BuildValue("y#O", (const char *) uuid, sizeof(uuid), Py_None); #endif } diff --git a/configure b/configure index 2728f67b577..da2c43fe7a2 100755 --- a/configure +++ b/configure @@ -9516,6 +9516,21 @@ _ACEOF fi # Dynamic linking for HP-UX +# checks for uuid.h location +for ac_header in uuid/uuid.h uuid.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uuid_generate_time_safe" >&5 $as_echo_n "checking for uuid_generate_time_safe... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -9546,6 +9561,37 @@ $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +# AIX provides support for RFC4122 (uuid) in libc.a starting with AIX 6.1 (anno 2007) +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for RFC4122 - uuid support on AIX" >&5 +$as_echo_n "checking for RFC4122 - uuid support on AIX... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ + +#ifndef uuid_create +void *x = uuid_create +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +$as_echo "#define HAVE_UUID_CREATE 1" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +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 + # 'Real Time' functions on Solaris # posix4 on Solaris 2.6 # pthread (first!) on Linux diff --git a/configure.ac b/configure.ac index 027109c65d2..9a84e90e34c 100644 --- a/configure.ac +++ b/configure.ac @@ -2681,6 +2681,9 @@ AC_CHECK_LIB(sendfile, sendfile) AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX +# checks for uuid.h location +AC_CHECK_HEADERS([uuid/uuid.h uuid.h]) + AC_MSG_CHECKING(for uuid_generate_time_safe) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ #ifndef uuid_generate_time_safe @@ -2692,6 +2695,18 @@ void *x = uuid_generate_time_safe [AC_MSG_RESULT(no)] ) +# AIX provides support for RFC4122 (uuid) in libc.a starting with AIX 6.1 (anno 2007) +AC_MSG_CHECKING(for RFC4122 - uuid support on AIX) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ +#ifndef uuid_create +void *x = uuid_create +#endif +]])], + [AC_DEFINE(HAVE_UUID_CREATE, 1, Define if uuid_create() exists. AIX support for uuid:RFC4122) + AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no)] +) + # 'Real Time' functions on Solaris # posix4 on Solaris 2.6 # pthread (first!) on Linux diff --git a/pyconfig.h.in b/pyconfig.h.in index d828d48af8c..4cf2f035c23 100644 --- a/pyconfig.h.in +++ b/pyconfig.h.in @@ -1191,9 +1191,18 @@ /* Define to 1 if you have the header file. */ #undef HAVE_UTIME_H +/* Define if uuid_create() exists. AIX support for uuid:RFC4122 */ +#undef HAVE_UUID_CREATE + /* Define if uuid_generate_time_safe() exists. */ #undef HAVE_UUID_GENERATE_TIME_SAFE +/* Define to 1 if you have the header file. */ +#undef HAVE_UUID_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UUID_UUID_H + /* Define to 1 if you have the `wait3' function. */ #undef HAVE_WAIT3