|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-08-14 13:42 UTC] jhohle at godaddy dot com
Description:
------------
OS X ships with a very old version of uuid ported from
e2fsprogs. It doesn't have many of the macros defined in
earlier version, but does have most of the functions (6 out of
10) exposed by the uuid extension.
In addition, there is no shared library for uuid, it appear to
be part of libc.
The attached patch adds checks for compiling on __APPLE__,
removing any missing methods, defining missing macros, and
removing the linking requirement. It should should compile
cleanly on all previous platforms, plus OS X, as well as pass
all tests (tested by compiling on Linux and OS X).
Reproduce code:
---------------
diff -r uuid-1.0.2/config.m4 uuid-1.0.2.mine/config.m4
11c11,12
<
---
> PHP_CHECK_FUNC_LIB(uuid_time, uuid)
> PHP_CHECK_FUNC_LIB(uuid_mac, uuid)
18d18
< PHP_SUBST(UUID_SHARED_LIBADD)
20c20,33
< PHP_ADD_LIBRARY_WITH_PATH(uuid, $PHP_UUID_DIR/lib, UUID_SHARED_LIBADD)
---
> AC_MSG_CHECKING(PHP version)
> AC_TRY_COMPILE([], [
> #ifdef __APPLE__
> #error compiling on darwin
> #endif
> ],
> [],
> [export UUID_ON_MAC=true])
>
>
> if test $UUID_ON_MAC != "true"; then
> PHP_SUBST(UUID_SHARED_LIBADD)
> PHP_ADD_LIBRARY_WITH_PATH(uuid, $PHP_UUID_DIR/lib, UUID_SHARED_LIBADD)
> fi
38d50
< PHP_SUBST(UUID_SHARED_LIBADD)
diff -r uuid-1.0.2/php_uuid.h uuid-1.0.2.mine/php_uuid.h
147a148,149
>
> #if HAVE_UUID_TIME
155a158
> #endif /* HAVE_UUID_TIME */
156a160
> #if HAVE_UUID_MAC
164a169
> #endif /* HAVE_UUID_MAC */
187a193,201
> #ifndef UUID_TYPE_DCE_TIME
> #ifdef __APPLE__
> /* UUID Type definitions */
> #define UUID_TYPE_DCE_TIME 1
> #define UUID_TYPE_DCE_RANDOM 4
> #endif /* __MACOS__ */
> #endif /* UUID_TYPE_DCE_TIME */
>
>
197c211
< #endif /* PHP_HAVE_UUID */
---
> #endif /* HAVE_UUID */
diff -r uuid-1.0.2/tests/uuid_mac.phpt uuid-1.0.2.mine/tests/uuid_mac.phpt
7a8,9
> if(!function_exists('uuid_mac')) die('skip not compiled in (HAVE_UUID_MAC)');
>
diff -r uuid-1.0.2/tests/uuid_time.phpt uuid-1.0.2.mine/tests/uuid_time.phpt
7a8,9
> if(!function_exists('uuid_time')) die('skip not compiled in (HAVE_UUID_TIME)');
>
diff -r uuid-1.0.2/uuid.c uuid-1.0.2.mine/uuid.c
42a43
> #if HAVE_UUID_TIME
43a45,46
> #endif /* HAVE_UUID_TIME */
> #if HAVE_UUID_MAC
44a48
> #endif /* HAVE_UUID_MAC */
Actual result:
--------------
============================================================
=========
PHP : /usr/bin/php
PHP_SAPI : cli
PHP_VERSION : 5.2.6
ZEND_VERSION: 2.2.0
PHP_OS : Darwin - Darwin ***.local 9.4.0 Darwin Kernel
Version 9.4.0: Mon Jun 9 19:30:53 PDT 2008; root:xnu-
1228.5.20~1/RELEASE_I386 i386
INI actual : /Users/***/src/uuid-1.0.2.mine
More .INIs :
CWD : /Users/***/src/uuid-1.0.2.mine
Extra dirs :
============================================================
=========
Running selected tests.
PASS uuid_compare() function [tests/uuid_compare.phpt]
PASS uuid_create() function [tests/uuid_create.phpt]
PASS uuid_is_null() function [tests/uuid_is_null.phpt]
PASS uuid_is_valid() function [tests/uuid_is_valid.phpt]
SKIP uuid_mac() function [tests/uuid_mac.phpt] reason: not
compiled in (HAVE_UUID_MAC)
PASS uuid_parse() function [tests/uuid_parse.phpt]
SKIP uuid_time() function [tests/uuid_time.phpt] reason: not
compiled in (HAVE_UUID_TIME)
SKIP uuid_type() function [tests/uuid_type.phpt] reason: not
compiled in (HAVE_UUID_TYPE)
PASS uuid_unparse() function [tests/uuid_unparse.phpt]
SKIP uuid_variant() function [tests/uuid_variant.phpt]
reason: not compiled in (HAVE_UUID_VARIANT)
============================================================
=========
Number of tests : 10 6
Tests skipped : 4 ( 40.0%) --------
Tests warned : 0 ( 0.0%) ( 0.0%)
Tests failed : 0 ( 0.0%) ( 0.0%)
Tests passed : 6 ( 60.0%) (100.0%)
------------------------------------------------------------
---------
Time taken : 0 seconds
============================================================
=========
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 05:00:02 2025 UTC |
Here is a better patch (diff -urp) diff -urp uuid-1.0.2/config.m4 uuid-1.0.2.mine/config.m4 --- uuid-1.0.2/config.m4 2008-04-01 08:59:22.000000000 -0700 +++ uuid-1.0.2.mine/config.m4 2008-08-14 10:16:56.000000000 -0700 @@ -8,16 +8,29 @@ PHP_ARG_WITH(uuid, whether uuid is avail if test "$PHP_UUID" != "no"; then PHP_CHECK_FUNC_LIB(uuid_type, uuid) PHP_CHECK_FUNC_LIB(uuid_variant, uuid) - + PHP_CHECK_FUNC_LIB(uuid_time, uuid) + PHP_CHECK_FUNC_LIB(uuid_mac, uuid) PHP_ADD_INCLUDE($PHP_UUID_DIR/include) export OLD_CPPFLAGS="$CPPFLAGS" export CPPFLAGS="$CPPFLAGS $INCLUDES -DHAVE_UUID" AC_CHECK_HEADER([uuid/uuid.h], [], AC_MSG_ERROR('uuid/uuid.h' header not found)) - PHP_SUBST(UUID_SHARED_LIBADD) - PHP_ADD_LIBRARY_WITH_PATH(uuid, $PHP_UUID_DIR/lib, UUID_SHARED_LIBADD) + AC_MSG_CHECKING(PHP version) + AC_TRY_COMPILE([], [ +#ifdef __APPLE__ +#error compiling on darwin +#endif +], +[], +[export UUID_ON_MAC=true]) + + + if test $UUID_ON_MAC != "true"; then + PHP_SUBST(UUID_SHARED_LIBADD) + PHP_ADD_LIBRARY_WITH_PATH(uuid, $PHP_UUID_DIR/lib, UUID_SHARED_LIBADD) + fi export CPPFLAGS="$OLD_CPPFLAGS" export OLD_CPPFLAGS="$CPPFLAGS" @@ -35,7 +48,6 @@ if test "$PHP_UUID" != "no"; then export CPPFLAGS="$OLD_CPPFLAGS" - PHP_SUBST(UUID_SHARED_LIBADD) AC_DEFINE(HAVE_UUID, 1, [ ]) PHP_NEW_EXTENSION(uuid, uuid.c , $ext_shared) diff -urp uuid-1.0.2/php_uuid.h uuid-1.0.2.mine/php_uuid.h --- uuid-1.0.2/php_uuid.h 2008-04-01 08:59:22.000000000 -0700 +++ uuid-1.0.2.mine/php_uuid.h 2008-08-14 09:00:23.000000000 -0700 @@ -145,6 +145,8 @@ ZEND_END_ARG_INFO() #endif #endif /* HAVE_UUID_VARIANT */ + +#if HAVE_UUID_TIME PHP_FUNCTION(uuid_time); #if (PHP_MAJOR_VERSION >= 5) ZEND_BEGIN_ARG_INFO_EX(uuid_time_arg_info, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) @@ -153,7 +155,9 @@ ZEND_END_ARG_INFO() #else /* PHP 4.x */ #define uuid_time_arg_info NULL #endif +#endif /* HAVE_UUID_TIME */ +#if HAVE_UUID_MAC PHP_FUNCTION(uuid_mac); #if (PHP_MAJOR_VERSION >= 5) ZEND_BEGIN_ARG_INFO_EX(uuid_mac_arg_info, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) @@ -162,6 +166,7 @@ ZEND_END_ARG_INFO() #else /* PHP 4.x */ #define uuid_mac_arg_info NULL #endif +#endif /* HAVE_UUID_MAC */ PHP_FUNCTION(uuid_parse); #if (PHP_MAJOR_VERSION >= 5) @@ -185,6 +190,15 @@ ZEND_END_ARG_INFO() } // extern "C" #endif +#ifndef UUID_TYPE_DCE_TIME +#ifdef __APPLE__ +/* UUID Type definitions */ +#define UUID_TYPE_DCE_TIME 1 +#define UUID_TYPE_DCE_RANDOM 4 +#endif /* __MACOS__ */ +#endif /* UUID_TYPE_DCE_TIME */ + + /* mirrored PHP Constants */ #define UUID_TYPE_DEFAULT 0 #define UUID_TYPE_TIME UUID_TYPE_DCE_TIME @@ -194,7 +208,7 @@ ZEND_END_ARG_INFO() #define UUID_TYPE_NULL -1 #define UUID_TYPE_INVALID -42 -#endif /* PHP_HAVE_UUID */ +#endif /* HAVE_UUID */ #endif /* PHP_UUID_H */ diff -urp uuid-1.0.2/tests/uuid_mac.phpt uuid- 1.0.2.mine/tests/uuid_mac.phpt --- uuid-1.0.2/tests/uuid_mac.phpt 2008-04-01 08:59:22.000000000 -0700 +++ uuid-1.0.2.mine/tests/uuid_mac.phpt 2008-08-14 10:21:57.000000000 -0700 @@ -5,6 +5,8 @@ uuid_mac() function if(!extension_loaded('uuid')) die('skip '); +if(!function_exists('uuid_mac')) die('skip not compiled in (HAVE_UUID_MAC)'); + ?> --FILE-- <?php diff -urp uuid-1.0.2/tests/uuid_time.phpt uuid- 1.0.2.mine/tests/uuid_time.phpt --- uuid-1.0.2/tests/uuid_time.phpt 2008-04-01 08:59:22.000000000 -0700 +++ uuid-1.0.2.mine/tests/uuid_time.phpt 2008-08-14 10:22:50.000000000 -0700 @@ -5,6 +5,8 @@ uuid_time() function if(!extension_loaded('uuid')) die('skip '); +if(!function_exists('uuid_time')) die('skip not compiled in (HAVE_UUID_TIME)'); + ?> --FILE-- <?php diff -urp uuid-1.0.2/uuid.c uuid-1.0.2.mine/uuid.c --- uuid-1.0.2/uuid.c 2008-04-01 08:59:22.000000000 -0700 +++ uuid-1.0.2.mine/uuid.c 2008-08-14 08:52:05.000000000 -0700 @@ -40,8 +40,12 @@ function_entry uuid_functions[] = { #if HAVE_UUID_VARIANT PHP_FE(uuid_variant , uuid_variant_arg_info) #endif /* HAVE_UUID_VARIANT */ +#if HAVE_UUID_TIME PHP_FE(uuid_time , uuid_time_arg_info) +#endif /* HAVE_UUID_TIME */ +#if HAVE_UUID_MAC PHP_FE(uuid_mac , uuid_mac_arg_info) +#endif /* HAVE_UUID_MAC */ PHP_FE(uuid_parse , uuid_parse_arg_info) PHP_FE(uuid_unparse , uuid_unparse_arg_info) { NULL, NULL, NULL }