Skip to content

bpo-32399: Starting with AIX6.1 there is support in libc.a for uuid (RFC4122) #4974

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Dec 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add AIX uuid library support for RFC4122 using uuid_create() in libc.a
23 changes: 17 additions & 6 deletions Modules/_uuidmodule.c
Original file line number Diff line number Diff line change
@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a comment that this is AIX-specific?

/*
* 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
}

Expand Down
48 changes: 47 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -9125,7 +9125,7 @@ then
LDCXXSHARED='$(CXX) -shared'
else
LDSHARED='$(CC) -b'
LDCXXSHARED='$(CXX) -shared'
LDCXXSHARED='$(CXX) -b'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look related.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note those lines originate from #2519. Perhaps @datalogics-robb can comment on why LDCXXSHARED='$(CXX) -b' in configure.ac becomes LDCXXSHARED='$(CXX) -shared' in configure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked at #2519 and it looks like the changes in configure were editted manually, rather than generated from configure.ac (my two cents).

If the line is suppossed to be with -shared, then configure.ac needs to be fixed. I do not know HPUX, so cannot help.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I've been AFK for a week, but yes this change looks good. -shared is a gcc/g++ flag and should definitely not be in a non-gcc clause.

fi ;;
Darwin/1.3*)
LDSHARED='$(CC) -bundle'
Expand Down Expand Up @@ -9504,6 +9504,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
Expand Down Expand Up @@ -9534,6 +9549,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
Expand Down
15 changes: 15 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
9 changes: 9 additions & 0 deletions pyconfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -1191,9 +1191,18 @@
/* 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

Expand Down