summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorMichael Felt <aixtools@users.noreply.github.com>2017-12-30 21:39:20 (GMT)
committerAntoine Pitrou <pitrou@free.fr>2017-12-30 21:39:20 (GMT)
commit0d3ccb4395cccb11a50289c84c9a0dbbac03c647 (patch)
tree605efdb3abe3c0e95259f660b28facbfccc00d55 /Modules
parent0c36bed1c46d07ef91d3e02e69e974e4f3ecd31a (diff)
downloadcpython-0d3ccb4395cccb11a50289c84c9a0dbbac03c647.zip
cpython-0d3ccb4395cccb11a50289c84c9a0dbbac03c647.tar.gz
cpython-0d3ccb4395cccb11a50289c84c9a0dbbac03c647.tar.bz2
bpo-32399: Starting with AIX6.1 there is support in libc.a for uuid (RFC4122) (#4974)
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.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_uuidmodule.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/Modules/_uuidmodule.c b/Modules/_uuidmodule.c
index d4bc3c7..1b37511 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 <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
}