-
-
Save memreflect/70d940f5de622587d10cd79dc12b3d32 to your computer and use it in GitHub Desktop.
Fix for ossp-uuid name collision on FreeBSD when compiling swi-prolog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
${CC} -O3 -fPIC -I/usr/local/include -c libuuid-ossp_uuid.c \ | |
&& rm -f libuuid-ossp.a \ | |
&& ${AR} ${ARFLAGS} libuuid-ossp.a libuuid-ossp_uuid.o \ | |
&& ${RANLIB} ${RANLIBFLAGS} libuuid-ossp.a \ | |
&& rm -f libuuid-ossp_uuid.o | |
*/ | |
#include <stdarg.h> | |
#include <stdlib.h> | |
#include <dlfcn.h> | |
#include "libuuid-ossp_uuid.h" | |
static void* libuuid; | |
__attribute__((constructor)) | |
static void load_libuuid( void | |
) | |
{ | |
libuuid = dlopen("/usr/local/lib/libossp-uuid.so", | |
RTLD_LAZY | RTLD_LOCAL); | |
if (!libuuid) | |
abort(); | |
} | |
__attribute__((destructor)) | |
static void unload_libuuid( void | |
) | |
{ | |
if (libuuid) | |
dlclose(libuuid); | |
} | |
OSSP1( uuid_create | |
, uuid_t** , uuid | |
) | |
OSSP1( uuid_destroy | |
, uuid_t* , uuid | |
) | |
OSSP2( uuid_clone | |
, const uuid_t* , uuid | |
, uuid_t** , uuid_clone | |
) | |
OSSP2( uuid_isnil | |
, const uuid_t* , uuid | |
, int* , result | |
) | |
OSSP3( uuid_compare | |
, const uuid_t* , uuid | |
, const uuid_t* , uuid2 | |
, int* , result | |
) | |
OSSP4( uuid_import | |
, uuid_t* , uuid | |
, uuid_fmt_t , fmt | |
, const void* , data | |
, size_t , data_len | |
) | |
OSSP4( uuid_export | |
, const uuid_t* , uuid | |
, uuid_fmt_t , fmt | |
, void* , data | |
, size_t* , data_len | |
) | |
OSSP2( uuid_load | |
, uuid_t* , uuid | |
, const char* , name | |
) | |
char* ossp_uuid_error( uuid_rc_t rc | |
) | |
{ | |
return ((char* (*)(uuid_rc_t))dlfunc(libuuid, "uuid_error"))(rc); | |
} | |
unsigned long ossp_uuid_version( void | |
) | |
{ | |
return ((unsigned long(*)(void))dlfunc(libuuid, "uuid_version"))(); | |
} | |
uuid_rc_t ossp_uuid_make( uuid_t* uuid | |
, unsigned int mode | |
, ... | |
) | |
{ | |
va_list ap; | |
dlfunc_t fptr; | |
typedef uuid_rc_t make_simple( uuid_t* | |
, unsigned int | |
); | |
typedef uuid_rc_t make_v35( uuid_t* | |
, unsigned int | |
, uuid_t* | |
, const char* | |
); | |
fptr = dlfunc(libuuid, "uuid_make"); | |
if (mode & (UUID_MAKE_V3 | UUID_MAKE_V5)) { | |
uuid_rc_t rc; | |
uuid_t* namespace; | |
const char* name; | |
va_start(ap, mode); | |
namespace = va_arg(ap, uuid_t*); | |
name = va_arg(ap, const char*); | |
rc = ((make_v35*)fptr)(uuid, mode, namespace, name); | |
va_end(ap); | |
return rc; | |
} | |
return ((make_simple*)fptr)(uuid, mode); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef LIBUUID_OSSP_UUID_H | |
#define LIBUUID_OSSP_UUID_H 1 | |
#include <ossp/uuid.h> | |
#ifdef __cplusplus | |
extern "C" { | |
#endif | |
#define OSSP_DECL(name, ...) \ | |
uuid_rc_t ossp_##name(__VA_ARGS__) | |
#define OSSP_DECL1(name, T1, P1) \ | |
OSSP_DECL(name, T1 P1) | |
#define OSSP_DECL2(name, T1, P1, T2, P2) \ | |
OSSP_DECL(name, T1 P1, T2 P2) | |
#define OSSP_DECL3(name, T1, P1, T2, P2, T3, P3) \ | |
OSSP_DECL(name, T1 P1, T2 P2, T3 P3) | |
#define OSSP_DECL4(name, T1, P1, T2, P2, T3, P3, T4, P4) \ | |
OSSP_DECL(name, T1 P1, T2 P2, T3 P3, T4 P4) | |
#define OSSP_DECLn(n, name, ...) \ | |
OSSP_DECL##n(name, __VA_ARGS_) | |
#define OSSP_HEAD(name, ...) \ | |
OSSP_DECL(name, __VA_ARGS__) { \ | |
dlfunc_t f = dlfunc(libuuid, #name) | |
#define OSSP_TAIL } | |
#define OSSP1(name, T1, P1) \ | |
OSSP_HEAD(name, T1 P1); \ | |
typedef uuid_rc_t ossp_func_t(T1); \ | |
return ((ossp_func_t*)f)(P1); \ | |
OSSP_TAIL | |
#define OSSP2(name, T1, P1, T2, P2) \ | |
OSSP_HEAD(name, T1 P1, T2 P2); \ | |
typedef uuid_rc_t ossp_func_t(T1, T2); \ | |
return ((ossp_func_t*)f)(P1, P2); \ | |
OSSP_TAIL | |
#define OSSP3(name, T1, P1, T2, P2, T3, P3) \ | |
OSSP_HEAD(name, T1 P1, T2 P2, T3 P3); \ | |
typedef uuid_rc_t ossp_func_t(T1, T2, T3); \ | |
return ((ossp_func_t*)f)(P1, P2, P3); \ | |
OSSP_TAIL | |
#define OSSP4(name, T1, P1, T2, P2, T3, P3, T4, P4) \ | |
OSSP_HEAD(name, T1 P1, T2 P2, T3 P3, T4 P4); \ | |
typedef uuid_rc_t ossp_func_t(T1, T2, T3, T4); \ | |
return ((ossp_func_t*)f)(P1, P2, P3, P4); \ | |
OSSP_TAIL | |
OSSP_DECL1( uuid_create | |
, uuid_t** , uuid | |
); | |
OSSP_DECL1( uuid_destroy | |
, uuid_t* , uuid | |
); | |
OSSP_DECL2( uuid_clone | |
, const uuid_t* , uuid | |
, uuid_t** , uuid_clone | |
); | |
OSSP_DECL2( uuid_isnil | |
, const uuid_t* , uuid | |
, int* , result | |
); | |
OSSP_DECL3( uuid_compare | |
, const uuid_t* , uuid | |
, const uuid_t* , uuid2 | |
, int* , result | |
); | |
OSSP_DECL4( uuid_import | |
, uuid_t* , uuid | |
, uuid_fmt_t , fmt | |
, const void* , data | |
, size_t , data_len | |
); | |
OSSP_DECL4( uuid_export | |
, const uuid_t* , uuid | |
, uuid_fmt_t , fmt | |
, void* , data | |
, size_t* , data_len | |
); | |
OSSP_DECL2( uuid_load | |
, uuid_t* , uuid | |
, const char* , name | |
); | |
char* ossp_uuid_error( uuid_rc_t rc | |
); | |
unsigned long ossp_uuid_version( void | |
); | |
uuid_rc_t ossp_uuid_make( uuid_t* uuid | |
, unsigned int mode | |
, ... | |
); | |
#ifdef __cplusplus | |
} | |
#endif | |
#endif /* !LIBUUID_OSSP_UUID_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In the toplevel source directory of swi-prolog 8.2.1, | |
this patch can be applied using: | |
patch < /path/to/this/patch | |
The following instructions are meant to be executed inside your | |
build directory, notated as ${BUILDDIR} below: | |
1. Create libuuid-ossp.a as stated at the top of | |
libuuid-ossp_uuid.c above, adjusting the commands to work | |
with the ports system as necessary. | |
2. Run cmake with the following parameters: | |
# Necessary since we override UUID_LIBRARY | |
-DHAVE_OSSP_UUID_H:BOOL=ON | |
# Necessary for this patch to find libuuid-ossp_uuid.h | |
-DLIBUUID_INCLUDE_DIR:FILEPATH="${BUILDDIR}" | |
# Path to our UUID lib. | |
-DUUID_LIBRARY:FILEPATH="${BUILDDIR}/libuuid-ossp.a" | |
# Necessary for the compiler to correctly find <ossp/uuid.h> | |
# in /usr/local/include | |
-DCMAKE_C_FLAGS:STRING="-isystem /usr/local/include" | |
diff -ur packages/clib/uuid.c packages/clib/uuid.c | |
--- packages/clib/uuid.c 2020-05-31 14:47:37.000000000 +0000 | |
+++ packages/clib/uuid.c 2020-09-15 23:51:01.569225000 +0000 | |
@@ -49,6 +49,8 @@ | |
#include <uuid.h> | |
#endif | |
+#include "libuuid-ossp_uuid.h" | |
+ | |
/* Seems to be defined in some MinGW installations. The | |
* ossp-uuid header defines the types using typedef, so | |
* we can safely kill these macros | |
@@ -136,9 +138,9 @@ | |
{ case UUID_MAKE_V1: | |
case UUID_MAKE_MC: | |
case UUID_MAKE_V4: | |
- uuid_create(&uuid); | |
- if ( (urc=uuid_make(uuid, mode)) != UUID_RC_OK ) | |
- return PL_warning("UUID: make: %s\n", uuid_error(urc)); | |
+ ossp_uuid_create(&uuid); | |
+ if ( (urc=ossp_uuid_make(uuid, mode)) != UUID_RC_OK ) | |
+ return PL_warning("UUID: make: %s\n", ossp_uuid_error(urc)); | |
break; | |
case UUID_MAKE_V3: | |
case UUID_MAKE_V5: | |
@@ -147,12 +149,12 @@ | |
if ( !ns ) | |
return PL_existence_error("uuid_context", options); | |
- uuid_create(&uuid); | |
- uuid_create(&uuid_ns); | |
- uuid_load(uuid_ns, ns); | |
- if ( (urc=uuid_make(uuid, mode, uuid_ns, str)) != UUID_RC_OK ) | |
- return PL_warning("UUID: make: %s\n", uuid_error(urc)); | |
- uuid_destroy(uuid_ns); | |
+ ossp_uuid_create(&uuid); | |
+ ossp_uuid_create(&uuid_ns); | |
+ ossp_uuid_load(uuid_ns, ns); | |
+ if ( (urc=ossp_uuid_make(uuid, mode, uuid_ns, str)) != UUID_RC_OK ) | |
+ return PL_warning("UUID: make: %s\n", ossp_uuid_error(urc)); | |
+ ossp_uuid_destroy(uuid_ns); | |
break; | |
} | |
default: | |
@@ -165,8 +167,8 @@ | |
void *ptr = buf; | |
size_t datalen = sizeof(buf); | |
- if ( (urc=uuid_export(uuid, UUID_FMT_STR, &ptr, &datalen)) != UUID_RC_OK ) | |
- return PL_warning("UUID: export: %s\n", uuid_error(urc)); | |
+ if ( (urc=ossp_uuid_export(uuid, UUID_FMT_STR, &ptr, &datalen)) != UUID_RC_OK ) | |
+ return PL_warning("UUID: export: %s\n", ossp_uuid_error(urc)); | |
rc = PL_unify_chars(UUID, PL_ATOM|REP_ISO_LATIN_1, (size_t)-1, buf); | |
} else if ( format == ATOM_integer ) | |
{ char buf[UUID_LEN_SIV+1]; | |
@@ -174,8 +176,8 @@ | |
size_t datalen = sizeof(buf); | |
term_t tmp = PL_new_term_ref(); | |
- if ( (urc=uuid_export(uuid, UUID_FMT_SIV, &ptr, &datalen)) != UUID_RC_OK ) | |
- return PL_warning("UUID: export: %s\n", uuid_error(urc)); | |
+ if ( (urc=ossp_uuid_export(uuid, UUID_FMT_SIV, &ptr, &datalen)) != UUID_RC_OK ) | |
+ return PL_warning("UUID: export: %s\n", ossp_uuid_error(urc)); | |
rc = ( PL_chars_to_term(buf, tmp) && | |
PL_unify(UUID, tmp) | |
); | |
@@ -184,7 +186,7 @@ | |
return FALSE; | |
} | |
- uuid_destroy(uuid); | |
+ ossp_uuid_destroy(uuid); | |
return rc; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is mega-patch integrating all of the above information into a single patch. | |
It creates the .c and .h file above inside the source tree and integrates them | |
into the CMake build. | |
It also patches packages/clib/cmake/FindLibUUID.cmake to avoid the need for | |
specifying UUID_LIBRARY and everything, which complicates the build command. | |
The only requirement is that -DCMAKE_C_FLAGS=/usr/local/include is used, | |
which I believe the ports system takes care of automatically. | |
In theory, it should be as simple as creating a port, adding a dependency on | |
libossp-uuid.so:misc/ossp-uuid, and dropping this file in the port's 'files/' | |
directory, but I don't know for certain. | |
I'm also not sure if this sort of patch violates any port standards, but the | |
SWI-Prolog testsuite reported 100% success when I used it outside the ports tree. | |
diff -Naur packages/clib/CMakeLists.txt packages/clib/CMakeLists.txt | |
--- packages/clib/CMakeLists.txt 2020-05-31 14:47:37.000000000 +0000 | |
+++ packages/clib/CMakeLists.txt 2020-09-16 02:47:36.174552000 +0000 | |
@@ -67,10 +67,11 @@ | |
endif(UNIX) | |
if(LIBUUID_FOUND) | |
+ configure_file(libuuid-ossp_uuid.c.in libuuid-ossp_uuid.c) | |
clib_plugin(uuid | |
- C_SOURCES uuid.c | |
+ C_SOURCES uuid.c ${CMAKE_CURRENT_BINARY_DIR}/libuuid-ossp_uuid.c | |
C_LIBS ${UUID_LIBRARY} | |
- C_INCLUDE_DIR ${LIBUUID_INCLUDE_DIR} | |
+ C_INCLUDE_DIR ${LIBUUID_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} | |
PL_LIBS uuid.pl) | |
endif() | |
diff -Naur packages/clib/cmake/FindLibUUID.cmake packages/clib/cmake/FindLibUUID.cmake | |
--- packages/clib/cmake/FindLibUUID.cmake 2020-05-31 14:47:37.000000000 +0000 | |
+++ packages/clib/cmake/FindLibUUID.cmake 2020-09-16 02:02:03.582810000 +0000 | |
@@ -25,7 +25,7 @@ | |
string(REPLACE "-l" "" LIBUUID_LIB ${LIBUUID_LIBFLAG}) | |
find_library(UUID_LIBRARY | |
- NAMES ${LIBUUID_LIB} | |
+ NAMES ${LIBUUID_LIB} ossp-uuid | |
PATHS ${LIBUUID_LIBRARY_DIR} | |
NO_DEFAULT_PATH) | |
if(NOT UUID_LIBRARY AND LIBUUID_LIB MATCHES "ossp") | |
diff -Naur packages/clib/libuuid-ossp_uuid.c.in packages/clib/libuuid-ossp_uuid.c.in | |
--- packages/clib/libuuid-ossp_uuid.c.in 1970-01-01 00:00:00.000000000 +0000 | |
+++ packages/clib/libuuid-ossp_uuid.c.in 2020-09-16 02:40:40.199884000 +0000 | |
@@ -0,0 +1,108 @@ | |
+/* | |
+ ${CC} -O3 -fPIC -I/usr/local/include -c libuuid-ossp_uuid.c \ | |
+ && rm -f libuuid-ossp.a \ | |
+ && ${AR} ${ARFLAGS} libuuid-ossp.a libuuid-ossp_uuid.o \ | |
+ && ${RANLIB} ${RANLIBFLAGS} libuuid-ossp.a \ | |
+ && rm -f libuuid-ossp_uuid.o | |
+*/ | |
+#include <stdarg.h> | |
+#include <stdlib.h> | |
+#include <dlfcn.h> | |
+#include "libuuid-ossp_uuid.h" | |
+ | |
+static void* libuuid; | |
+ | |
+__attribute__((constructor)) | |
+static void load_libuuid( void | |
+ ) | |
+{ | |
+ libuuid = dlopen("@UUID_LIBRARY@", | |
+ RTLD_LAZY | RTLD_LOCAL); | |
+ if (!libuuid) | |
+ abort(); | |
+} | |
+ | |
+__attribute__((destructor)) | |
+static void unload_libuuid( void | |
+ ) | |
+{ | |
+ if (libuuid) | |
+ dlclose(libuuid); | |
+} | |
+ | |
+OSSP1( uuid_create | |
+ , uuid_t** , uuid | |
+ ) | |
+OSSP1( uuid_destroy | |
+ , uuid_t* , uuid | |
+ ) | |
+OSSP2( uuid_clone | |
+ , const uuid_t* , uuid | |
+ , uuid_t** , uuid_clone | |
+ ) | |
+OSSP2( uuid_isnil | |
+ , const uuid_t* , uuid | |
+ , int* , result | |
+ ) | |
+OSSP3( uuid_compare | |
+ , const uuid_t* , uuid | |
+ , const uuid_t* , uuid2 | |
+ , int* , result | |
+ ) | |
+OSSP4( uuid_import | |
+ , uuid_t* , uuid | |
+ , uuid_fmt_t , fmt | |
+ , const void* , data | |
+ , size_t , data_len | |
+ ) | |
+OSSP4( uuid_export | |
+ , const uuid_t* , uuid | |
+ , uuid_fmt_t , fmt | |
+ , void* , data | |
+ , size_t* , data_len | |
+ ) | |
+OSSP2( uuid_load | |
+ , uuid_t* , uuid | |
+ , const char* , name | |
+ ) | |
+ | |
+char* ossp_uuid_error( uuid_rc_t rc | |
+ ) | |
+{ | |
+ return ((char* (*)(uuid_rc_t))dlfunc(libuuid, "uuid_error"))(rc); | |
+} | |
+unsigned long ossp_uuid_version( void | |
+ ) | |
+{ | |
+ return ((unsigned long(*)(void))dlfunc(libuuid, "uuid_version"))(); | |
+} | |
+uuid_rc_t ossp_uuid_make( uuid_t* uuid | |
+ , unsigned int mode | |
+ , ... | |
+ ) | |
+{ | |
+ va_list ap; | |
+ dlfunc_t fptr; | |
+ typedef uuid_rc_t make_simple( uuid_t* | |
+ , unsigned int | |
+ ); | |
+ typedef uuid_rc_t make_v35( uuid_t* | |
+ , unsigned int | |
+ , uuid_t* | |
+ , const char* | |
+ ); | |
+ | |
+ fptr = dlfunc(libuuid, "uuid_make"); | |
+ if (mode & (UUID_MAKE_V3 | UUID_MAKE_V5)) { | |
+ uuid_rc_t rc; | |
+ uuid_t* namespace; | |
+ const char* name; | |
+ va_start(ap, mode); | |
+ namespace = va_arg(ap, uuid_t*); | |
+ name = va_arg(ap, const char*); | |
+ rc = ((make_v35*)fptr)(uuid, mode, namespace, name); | |
+ va_end(ap); | |
+ return rc; | |
+ } | |
+ return ((make_simple*)fptr)(uuid, mode); | |
+} | |
diff -Naur packages/clib/libuuid-ossp_uuid.h packages/clib/libuuid-ossp_uuid.h | |
--- packages/clib/libuuid-ossp_uuid.h 1970-01-01 00:00:00.000000000 +0000 | |
+++ packages/clib/libuuid-ossp_uuid.h 2020-09-16 01:54:15.090533000 +0000 | |
@@ -0,0 +1,101 @@ | |
+#ifndef LIBUUID_OSSP_UUID_H | |
+#define LIBUUID_OSSP_UUID_H 1 | |
+ | |
+#include <ossp/uuid.h> | |
+ | |
+#ifdef __cplusplus | |
+extern "C" { | |
+#endif | |
+ | |
+#define OSSP_DECL(name, ...) \ | |
+ uuid_rc_t ossp_##name(__VA_ARGS__) | |
+#define OSSP_DECL1(name, T1, P1) \ | |
+ OSSP_DECL(name, T1 P1) | |
+#define OSSP_DECL2(name, T1, P1, T2, P2) \ | |
+ OSSP_DECL(name, T1 P1, T2 P2) | |
+#define OSSP_DECL3(name, T1, P1, T2, P2, T3, P3) \ | |
+ OSSP_DECL(name, T1 P1, T2 P2, T3 P3) | |
+#define OSSP_DECL4(name, T1, P1, T2, P2, T3, P3, T4, P4) \ | |
+ OSSP_DECL(name, T1 P1, T2 P2, T3 P3, T4 P4) | |
+#define OSSP_DECLn(n, name, ...) \ | |
+ OSSP_DECL##n(name, __VA_ARGS_) | |
+ | |
+#define OSSP_HEAD(name, ...) \ | |
+ OSSP_DECL(name, __VA_ARGS__) { \ | |
+ dlfunc_t f = dlfunc(libuuid, #name) | |
+#define OSSP_TAIL } | |
+ | |
+#define OSSP1(name, T1, P1) \ | |
+ OSSP_HEAD(name, T1 P1); \ | |
+ typedef uuid_rc_t ossp_func_t(T1); \ | |
+ return ((ossp_func_t*)f)(P1); \ | |
+ OSSP_TAIL | |
+ | |
+#define OSSP2(name, T1, P1, T2, P2) \ | |
+ OSSP_HEAD(name, T1 P1, T2 P2); \ | |
+ typedef uuid_rc_t ossp_func_t(T1, T2); \ | |
+ return ((ossp_func_t*)f)(P1, P2); \ | |
+ OSSP_TAIL | |
+ | |
+#define OSSP3(name, T1, P1, T2, P2, T3, P3) \ | |
+ OSSP_HEAD(name, T1 P1, T2 P2, T3 P3); \ | |
+ typedef uuid_rc_t ossp_func_t(T1, T2, T3); \ | |
+ return ((ossp_func_t*)f)(P1, P2, P3); \ | |
+ OSSP_TAIL | |
+ | |
+#define OSSP4(name, T1, P1, T2, P2, T3, P3, T4, P4) \ | |
+ OSSP_HEAD(name, T1 P1, T2 P2, T3 P3, T4 P4); \ | |
+ typedef uuid_rc_t ossp_func_t(T1, T2, T3, T4); \ | |
+ return ((ossp_func_t*)f)(P1, P2, P3, P4); \ | |
+ OSSP_TAIL | |
+ | |
+OSSP_DECL1( uuid_create | |
+ , uuid_t** , uuid | |
+ ); | |
+OSSP_DECL1( uuid_destroy | |
+ , uuid_t* , uuid | |
+ ); | |
+OSSP_DECL2( uuid_clone | |
+ , const uuid_t* , uuid | |
+ , uuid_t** , uuid_clone | |
+ ); | |
+OSSP_DECL2( uuid_isnil | |
+ , const uuid_t* , uuid | |
+ , int* , result | |
+ ); | |
+OSSP_DECL3( uuid_compare | |
+ , const uuid_t* , uuid | |
+ , const uuid_t* , uuid2 | |
+ , int* , result | |
+ ); | |
+OSSP_DECL4( uuid_import | |
+ , uuid_t* , uuid | |
+ , uuid_fmt_t , fmt | |
+ , const void* , data | |
+ , size_t , data_len | |
+ ); | |
+OSSP_DECL4( uuid_export | |
+ , const uuid_t* , uuid | |
+ , uuid_fmt_t , fmt | |
+ , void* , data | |
+ , size_t* , data_len | |
+ ); | |
+OSSP_DECL2( uuid_load | |
+ , uuid_t* , uuid | |
+ , const char* , name | |
+ ); | |
+ | |
+char* ossp_uuid_error( uuid_rc_t rc | |
+ ); | |
+unsigned long ossp_uuid_version( void | |
+ ); | |
+uuid_rc_t ossp_uuid_make( uuid_t* uuid | |
+ , unsigned int mode | |
+ , ... | |
+ ); | |
+ | |
+#ifdef __cplusplus | |
+} | |
+#endif | |
+ | |
+#endif /* !LIBUUID_OSSP_UUID_H */ | |
diff -Naur packages/clib/uuid.c packages/clib/uuid.c | |
--- packages/clib/uuid.c 2020-05-31 14:47:37.000000000 +0000 | |
+++ packages/clib/uuid.c 2020-09-16 01:52:37.568312000 +0000 | |
@@ -49,6 +49,8 @@ | |
#include <uuid.h> | |
#endif | |
+#include "libuuid-ossp_uuid.h" | |
+ | |
/* Seems to be defined in some MinGW installations. The | |
* ossp-uuid header defines the types using typedef, so | |
* we can safely kill these macros | |
@@ -136,9 +138,9 @@ | |
{ case UUID_MAKE_V1: | |
case UUID_MAKE_MC: | |
case UUID_MAKE_V4: | |
- uuid_create(&uuid); | |
- if ( (urc=uuid_make(uuid, mode)) != UUID_RC_OK ) | |
- return PL_warning("UUID: make: %s\n", uuid_error(urc)); | |
+ ossp_uuid_create(&uuid); | |
+ if ( (urc=ossp_uuid_make(uuid, mode)) != UUID_RC_OK ) | |
+ return PL_warning("UUID: make: %s\n", ossp_uuid_error(urc)); | |
break; | |
case UUID_MAKE_V3: | |
case UUID_MAKE_V5: | |
@@ -147,12 +149,12 @@ | |
if ( !ns ) | |
return PL_existence_error("uuid_context", options); | |
- uuid_create(&uuid); | |
- uuid_create(&uuid_ns); | |
- uuid_load(uuid_ns, ns); | |
- if ( (urc=uuid_make(uuid, mode, uuid_ns, str)) != UUID_RC_OK ) | |
- return PL_warning("UUID: make: %s\n", uuid_error(urc)); | |
- uuid_destroy(uuid_ns); | |
+ ossp_uuid_create(&uuid); | |
+ ossp_uuid_create(&uuid_ns); | |
+ ossp_uuid_load(uuid_ns, ns); | |
+ if ( (urc=ossp_uuid_make(uuid, mode, uuid_ns, str)) != UUID_RC_OK ) | |
+ return PL_warning("UUID: make: %s\n", ossp_uuid_error(urc)); | |
+ ossp_uuid_destroy(uuid_ns); | |
break; | |
} | |
default: | |
@@ -165,8 +167,8 @@ | |
void *ptr = buf; | |
size_t datalen = sizeof(buf); | |
- if ( (urc=uuid_export(uuid, UUID_FMT_STR, &ptr, &datalen)) != UUID_RC_OK ) | |
- return PL_warning("UUID: export: %s\n", uuid_error(urc)); | |
+ if ( (urc=ossp_uuid_export(uuid, UUID_FMT_STR, &ptr, &datalen)) != UUID_RC_OK ) | |
+ return PL_warning("UUID: export: %s\n", ossp_uuid_error(urc)); | |
rc = PL_unify_chars(UUID, PL_ATOM|REP_ISO_LATIN_1, (size_t)-1, buf); | |
} else if ( format == ATOM_integer ) | |
{ char buf[UUID_LEN_SIV+1]; | |
@@ -174,8 +176,8 @@ | |
size_t datalen = sizeof(buf); | |
term_t tmp = PL_new_term_ref(); | |
- if ( (urc=uuid_export(uuid, UUID_FMT_SIV, &ptr, &datalen)) != UUID_RC_OK ) | |
- return PL_warning("UUID: export: %s\n", uuid_error(urc)); | |
+ if ( (urc=ossp_uuid_export(uuid, UUID_FMT_SIV, &ptr, &datalen)) != UUID_RC_OK ) | |
+ return PL_warning("UUID: export: %s\n", ossp_uuid_error(urc)); | |
rc = ( PL_chars_to_term(buf, tmp) && | |
PL_unify(UUID, tmp) | |
); | |
@@ -184,7 +186,7 @@ | |
return FALSE; | |
} | |
- uuid_destroy(uuid); | |
+ ossp_uuid_destroy(uuid); | |
return rc; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment