Skip to content

Commit 0d3ccb4

Browse files
aixtoolspitrou
authored andcommitted
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.
1 parent 0c36bed commit 0d3ccb4

File tree

5 files changed

+88
-6
lines changed

5 files changed

+88
-6
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add AIX uuid library support for RFC4122 using uuid_create() in libc.a

Modules/_uuidmodule.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,33 @@
11
#define PY_SSIZE_T_CLEAN
22

33
#include "Python.h"
4+
#ifdef HAVE_UUID_UUID_H
45
#include <uuid/uuid.h>
6+
#endif
7+
#ifdef HAVE_UUID_H
8+
#include <uuid.h>
9+
#endif
510

611

712
static PyObject *
813
py_uuid_generate_time_safe(void)
914
{
15+
uuid_t uuid;
1016
#ifdef HAVE_UUID_GENERATE_TIME_SAFE
11-
uuid_t out;
1217
int res;
1318

14-
res = uuid_generate_time_safe(out);
15-
return Py_BuildValue("y#i", (const char *) out, sizeof(out), res);
19+
res = uuid_generate_time_safe(uuid);
20+
return Py_BuildValue("y#i", (const char *) uuid, sizeof(uuid), res);
21+
#elif HAVE_UUID_CREATE
22+
/*
23+
* AIX support for uuid - RFC4122
24+
*/
25+
unsigned32 status;
26+
uuid_create(&uuid, &status);
27+
return Py_BuildValue("y#i", (const char *) &uuid, sizeof(uuid), (int) status);
1628
#else
17-
uuid_t out;
18-
uuid_generate_time(out);
19-
return Py_BuildValue("y#O", (const char *) out, sizeof(out), Py_None);
29+
uuid_generate_time(uuid);
30+
return Py_BuildValue("y#O", (const char *) uuid, sizeof(uuid), Py_None);
2031
#endif
2132
}
2233

configure

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9516,6 +9516,21 @@ _ACEOF
95169516
fi
95179517
# Dynamic linking for HP-UX
95189518

9519+
# checks for uuid.h location
9520+
for ac_header in uuid/uuid.h uuid.h
9521+
do :
9522+
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
9523+
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
9524+
if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
9525+
cat >>confdefs.h <<_ACEOF
9526+
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
9527+
_ACEOF
9528+
9529+
fi
9530+
9531+
done
9532+
9533+
95199534
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for uuid_generate_time_safe" >&5
95209535
$as_echo_n "checking for uuid_generate_time_safe... " >&6; }
95219536
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -9546,6 +9561,37 @@ $as_echo "no" >&6; }
95469561
fi
95479562
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
95489563

9564+
# AIX provides support for RFC4122 (uuid) in libc.a starting with AIX 6.1 (anno 2007)
9565+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for RFC4122 - uuid support on AIX" >&5
9566+
$as_echo_n "checking for RFC4122 - uuid support on AIX... " >&6; }
9567+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
9568+
/* end confdefs.h. */
9569+
#include <uuid.h>
9570+
int
9571+
main ()
9572+
{
9573+
9574+
#ifndef uuid_create
9575+
void *x = uuid_create
9576+
#endif
9577+
9578+
;
9579+
return 0;
9580+
}
9581+
_ACEOF
9582+
if ac_fn_c_try_compile "$LINENO"; then :
9583+
9584+
$as_echo "#define HAVE_UUID_CREATE 1" >>confdefs.h
9585+
9586+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
9587+
$as_echo "yes" >&6; }
9588+
else
9589+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
9590+
$as_echo "no" >&6; }
9591+
9592+
fi
9593+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
9594+
95499595
# 'Real Time' functions on Solaris
95509596
# posix4 on Solaris 2.6
95519597
# pthread (first!) on Linux

configure.ac

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2681,6 +2681,9 @@ AC_CHECK_LIB(sendfile, sendfile)
26812681
AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
26822682
AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
26832683

2684+
# checks for uuid.h location
2685+
AC_CHECK_HEADERS([uuid/uuid.h uuid.h])
2686+
26842687
AC_MSG_CHECKING(for uuid_generate_time_safe)
26852688
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <uuid/uuid.h>]], [[
26862689
#ifndef uuid_generate_time_safe
@@ -2692,6 +2695,18 @@ void *x = uuid_generate_time_safe
26922695
[AC_MSG_RESULT(no)]
26932696
)
26942697

2698+
# AIX provides support for RFC4122 (uuid) in libc.a starting with AIX 6.1 (anno 2007)
2699+
AC_MSG_CHECKING(for RFC4122 - uuid support on AIX)
2700+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <uuid.h>]], [[
2701+
#ifndef uuid_create
2702+
void *x = uuid_create
2703+
#endif
2704+
]])],
2705+
[AC_DEFINE(HAVE_UUID_CREATE, 1, Define if uuid_create() exists. AIX support for uuid:RFC4122)
2706+
AC_MSG_RESULT(yes)],
2707+
[AC_MSG_RESULT(no)]
2708+
)
2709+
26952710
# 'Real Time' functions on Solaris
26962711
# posix4 on Solaris 2.6
26972712
# pthread (first!) on Linux

pyconfig.h.in

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,9 +1191,18 @@
11911191
/* Define to 1 if you have the <utime.h> header file. */
11921192
#undef HAVE_UTIME_H
11931193

1194+
/* Define if uuid_create() exists. AIX support for uuid:RFC4122 */
1195+
#undef HAVE_UUID_CREATE
1196+
11941197
/* Define if uuid_generate_time_safe() exists. */
11951198
#undef HAVE_UUID_GENERATE_TIME_SAFE
11961199

1200+
/* Define to 1 if you have the <uuid.h> header file. */
1201+
#undef HAVE_UUID_H
1202+
1203+
/* Define to 1 if you have the <uuid/uuid.h> header file. */
1204+
#undef HAVE_UUID_UUID_H
1205+
11971206
/* Define to 1 if you have the `wait3' function. */
11981207
#undef HAVE_WAIT3
11991208

0 commit comments

Comments
 (0)