]> granicus.if.org Git - python/commitdiff
bpo-32399: Starting with AIX6.1 there is support in libc.a for uuid (RFC4122) (#4974)
authorMichael Felt <aixtools@users.noreply.github.com>
Sat, 30 Dec 2017 21:39:20 +0000 (22:39 +0100)
committerAntoine Pitrou <pitrou@free.fr>
Sat, 30 Dec 2017 21:39:20 +0000 (22:39 +0100)
Starting with AIX6.1 there is support in libc.a for uuid (RFC4122)
This patch provides the changes needed for this integration with the OS.

On AIX the base function is uuid_create() rather than uuid_generate_time()
The AIX uuid_t typedef is more aligned to the UUID field based definition
while the Linux typedef that is more aligned with UUID bytes
(or perhaps UUID bytes_le) definitions.

Misc/NEWS.d/next/Core and Builtins/2017-12-22-13-38-17.bpo-32399.wlH12z.rst [new file with mode: 0644]
Modules/_uuidmodule.c
configure
configure.ac
pyconfig.h.in

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 (file)
index 0000000..ab18f26
--- /dev/null
@@ -0,0 +1 @@
+Add AIX uuid library support for RFC4122 using uuid_create() in libc.a
index d4bc3c7b0d4be8e7efe9a0dd9dfdc82c413c8f2a..1b37511c2286785c3205b02c5b8cae1cdcf6b376 100644 (file)
@@ -1,22 +1,33 @@
 #define PY_SSIZE_T_CLEAN
 
 #include "Python.h"
+#ifdef HAVE_UUID_UUID_H
 #include <uuid/uuid.h>
+#endif
+#ifdef HAVE_UUID_H
+#include <uuid.h>
+#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
 }
 
index 2728f67b577aa8b53f41d4d6117867423318c308..da2c43fe7a2c5fa4e3fa617c8fd933dad7e1bbb0 100755 (executable)
--- 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 <uuid.h>
+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
index 027109c65d2169c68b0aff4e27397e1bc4778baa..9a84e90e34cf3e042c298fd287c83118c167ade2 100644 (file)
@@ -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 <uuid/uuid.h>]], [[
 #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 <uuid.h>]], [[
+#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
index d828d48af8c1b990646930e6c08683c4ad1161d3..4cf2f035c233550b1bf73f21c4632de8b8508a35 100644 (file)
 /* Define to 1 if you have the <utime.h> 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 <uuid.h> header file. */
+#undef HAVE_UUID_H
+
+/* Define to 1 if you have the <uuid/uuid.h> header file. */
+#undef HAVE_UUID_UUID_H
+
 /* Define to 1 if you have the `wait3' function. */
 #undef HAVE_WAIT3