Skip to content

Commit 9a10ff4

Browse files
authored
bpo-11063: Add a configure check for uuid_generate_time_safe (GH-4287)
1 parent bf9d317 commit 9a10ff4

File tree

4 files changed

+48
-9
lines changed

4 files changed

+48
-9
lines changed

Modules/_uuidmodule.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,10 @@
44
#include <uuid/uuid.h>
55

66

7-
/* bpo-11063: libuuid on macOS doesn't provide uuid_generate_time_safe(),
8-
only uuid_generate_time(). */
9-
#ifndef __APPLE__
10-
# define HAVE_TIME_SAFE
11-
#endif
12-
13-
147
static PyObject *
158
py_uuid_generate_time_safe(void)
169
{
17-
#ifdef HAVE_TIME_SAFE
10+
#ifdef HAVE_UUID_GENERATE_TIME_SAFE
1811
uuid_t out;
1912
int res;
2013

@@ -45,7 +38,7 @@ PyInit__uuid(void)
4538
{
4639
PyObject *mod;
4740
assert(sizeof(uuid_t) == 16);
48-
#ifdef HAVE_TIME_SAFE
41+
#ifdef HAVE_UUID_GENERATE_TIME_SAFE
4942
int has_uuid_generate_time_safe = 1;
5043
#else
5144
int has_uuid_generate_time_safe = 0;

configure

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9512,6 +9512,37 @@ _ACEOF
95129512
fi
95139513
# Dynamic linking for HP-UX
95149514

9515+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for uuid_generate_time_safe" >&5
9516+
$as_echo_n "checking for uuid_generate_time_safe... " >&6; }
9517+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
9518+
/* end confdefs.h. */
9519+
#include <uuid/uuid.h>
9520+
int
9521+
main ()
9522+
{
9523+
9524+
#ifndef uuid_generate_time_safe
9525+
uuid_t out;
9526+
uuid_generate_time_safe(out);
9527+
#endif
9528+
9529+
;
9530+
return 0;
9531+
}
9532+
_ACEOF
9533+
if ac_fn_c_try_compile "$LINENO"; then :
9534+
9535+
$as_echo "#define HAVE_UUID_GENERATE_TIME_SAFE 1" >>confdefs.h
9536+
9537+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
9538+
$as_echo "yes" >&6; }
9539+
else
9540+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
9541+
$as_echo "no" >&6; }
9542+
9543+
fi
9544+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
9545+
95159546
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing sem_init" >&5
95169547
$as_echo_n "checking for library containing sem_init... " >&6; }
95179548
if ${ac_cv_search_sem_init+:} false; then :

configure.ac

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2677,6 +2677,18 @@ AC_CHECK_LIB(sendfile, sendfile)
26772677
AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
26782678
AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
26792679

2680+
AC_MSG_CHECKING(for uuid_generate_time_safe)
2681+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <uuid/uuid.h>]], [[
2682+
#ifndef uuid_generate_time_safe
2683+
uuid_t out;
2684+
uuid_generate_time_safe(out);
2685+
#endif
2686+
]])],
2687+
[AC_DEFINE(HAVE_UUID_GENERATE_TIME_SAFE, 1, Define if uuid_generate_time_safe() exists.)
2688+
AC_MSG_RESULT(yes)],
2689+
[AC_MSG_RESULT(no)]
2690+
)
2691+
26802692
AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
26812693
# posix4 on Solaris 2.6
26822694
# pthread (first!) on Linux

pyconfig.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,6 +1187,9 @@
11871187
/* Define to 1 if you have the <utime.h> header file. */
11881188
#undef HAVE_UTIME_H
11891189

1190+
/* Define if uuid_generate_time_safe() exists. */
1191+
#undef HAVE_UUID_GENERATE_TIME_SAFE
1192+
11901193
/* Define to 1 if you have the `wait3' function. */
11911194
#undef HAVE_WAIT3
11921195

0 commit comments

Comments
 (0)