cvs: php4 / configure.in /ext/standard dl.c Zend Zend.m4 zend.h zend_extensions.c

From: Date: Thu, 04 Apr 2002 00:24:34 +0000
Subject: cvs: php4 / configure.in /ext/standard dl.c Zend Zend.m4 zend.h zend_extensions.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-10846@lists.php.net to get a copy of this message
sniper Wed Apr 3 19:24:34 2002 EDT Modified files: /php4 configure.in /Zend Zend.m4 zend.h zend_extensions.c /php4/ext/standard dl.c Log: - OS X support for dynamically loaded extensions. (patch by Marko) # NEWS entry coming up.. Index: php4/configure.in diff -u php4/configure.in:1.332 php4/configure.in:1.333 --- php4/configure.in:1.332 Mon Apr 1 18:25:48 2002 +++ php4/configure.in Wed Apr 3 19:24:33 2002 @@ -1,4 +1,4 @@ -dnl ## $Id: configure.in,v 1.332 2002/04/01 23:25:48 sniper Exp $ -*- sh -*- +dnl ## $Id: configure.in,v 1.333 2002/04/04 00:24:33 sniper Exp $ -*- sh -*- dnl ## Process this file with autoconf to produce a configure script. divert(1) @@ -379,6 +379,7 @@ langinfo.h \ limits.h \ locale.h \ +mach-o/dyld.h \ netinet/in.h \ pwd.h \ resolv.h \ Index: Zend/Zend.m4 diff -u Zend/Zend.m4:1.30 Zend/Zend.m4:1.31 --- Zend/Zend.m4:1.30 Tue Dec 11 04:10:52 2001 +++ Zend/Zend.m4 Wed Apr 3 19:24:33 2002 @@ -1,5 +1,5 @@ dnl -dnl $Id: Zend.m4,v 1.30 2001/12/11 09:10:52 sniper Exp $ +dnl $Id: Zend.m4,v 1.31 2002/04/04 00:24:33 sniper Exp $ dnl dnl This file contains Zend specific autoconf functions. dnl @@ -36,10 +36,9 @@ CFLAGS=echo $CFLAGS | sed -e 's/-g//' fi -dnl Hack to work around a Mac OS X cpp problem -dnl Known versions needing this workaround are 5.3 and 5.4 -if test "$ac_cv_prog_gcc" = "yes" -a "uname -s" = "Rhapsody"; then - CPPFLAGS="$CPPFLAGS -traditional-cpp" +dnl Use the standard cpp instead of the precompiling one on Darwin / Mac OS X +if test "$ac_cv_prog_gcc" = "yes" -a "uname -s" = "Darwin"; then + CPPFLAGS="$CPPFLAGS -no-cpp-precomp" fi AC_CHECK_HEADERS( Index: Zend/zend.h diff -u Zend/zend.h:1.152 Zend/zend.h:1.153 --- Zend/zend.h:1.152 Thu Mar 14 23:33:05 2002 +++ Zend/zend.h Wed Apr 3 19:24:33 2002 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend.h,v 1.152 2002/03/15 04:33:05 sebastian Exp $ */ +/* $Id: zend.h,v 1.153 2002/04/04 00:24:33 sniper Exp $ */ #ifndef ZEND_H #define ZEND_H @@ -63,6 +63,18 @@ # include <dlfcn.h> #endif +#if HAVE_MACH_O_DYLD_H +#include <mach-o/dyld.h> + +/* MH_BUNDLE loading functions for Mac OS X / Darwin */ +void *zend_mh_bundle_load (char* bundle_path); +int zend_mh_bundle_unload (void *bundle_handle); +void *zend_mh_bundle_symbol(void *bundle_handle, const char *symbol_name); +const char *zend_mh_bundle_error(void); + +#endif /* HAVE_MACH_O_DYLD_H */ + + #if defined(HAVE_LIBDL) # ifndef RTLD_LAZY @@ -80,6 +92,14 @@ # else # define DL_FETCH_SYMBOL dlsym # endif +# define DL_ERROR dlerror +# define DL_HANDLE void * +# define ZEND_EXTENSIONS_SUPPORT 1 +#elif defined(HAVE_MACH_O_DYLD_H) +# define DL_LOAD(libname) zend_mh_bundle_load(libname) +# define DL_UNLOAD(handle) zend_mh_bundle_unload(handle) +# define DL_FETCH_SYMBOL(h,s) zend_mh_bundle_symbol(h,s) +# define DL_ERROR zend_mh_bundle_error # define DL_HANDLE void * # define ZEND_EXTENSIONS_SUPPORT 1 #elif defined(ZEND_WIN32) Index: Zend/zend_extensions.c diff -u Zend/zend_extensions.c:1.39 Zend/zend_extensions.c:1.40 --- Zend/zend_extensions.c:1.39 Sun Jan 6 10:21:09 2002 +++ Zend/zend_extensions.c Wed Apr 3 19:24:33 2002 @@ -33,7 +33,7 @@ handle = DL_LOAD(path); if (!handle) { #ifndef ZEND_WIN32 - fprintf(stderr, "Failed loading %s: %s\n", path, dlerror()); + fprintf(stderr, "Failed loading %s: %s\n", path, DL_ERROR()); #else fprintf(stderr, "Failed loading %s\n", path); #endif @@ -216,3 +216,64 @@ } return NULL; } + +/* + * Support for dynamic loading of MH_BUNDLEs on Darwin / Mac OS X + * + */ + +#if HAVE_MACH_O_DYLD_H + +void *zend_mh_bundle_load(char* bundle_path) +{ + NSObjectFileImage bundle_image; + NSModule bundle_handle; + NSSymbol bundle_init_nssymbol; + void (*bundle_init)(void); + + if (NSCreateObjectFileImageFromFile(bundle_path, &bundle_image) != NSObjectFileImageSuccess) { + return NULL; + } + + bundle_handle = NSLinkModule(bundle_image, bundle_path, NSLINKMODULE_OPTION_PRIVATE); + NSDestroyObjectFileImage(bundle_image); + + /* call the init function of the bundle */ + bundle_init_nssymbol = NSLookupSymbolInModule(bundle_handle, "__init"); + if (bundle_init_nssymbol != NULL) { + bundle_init = NSAddressOfSymbol(bundle_init_nssymbol); + bundle_init(); + } + + return bundle_handle; +} + +int zend_mh_bundle_unload(void *bundle_handle) +{ + NSSymbol bundle_fini_nssymbol; + void (*bundle_fini)(void); + + /* call the fini function of the bundle */ + bundle_fini_nssymbol = NSLookupSymbolInModule(bundle_handle, "__fini"); + if (bundle_fini_nssymbol != NULL) { + bundle_fini = NSAddressOfSymbol(bundle_fini_nssymbol); + bundle_fini(); + } + + return (int) NSUnLinkModule(bundle_handle, NULL); +} + +void *zend_mh_bundle_symbol(void *bundle_handle, const char *symbol_name) +{ + NSSymbol symbol; + symbol = NSLookupSymbolInModule(bundle_handle, symbol_name); + return NSAddressOfSymbol(symbol); +} + +const char *zend_mh_bundle_error(void) +{ + /* Witness the state of the art error reporting */ + return NULL; +} + +#endif /* HAVE_MACH_O_DYLD_H */ \ No newline at end of file Index: php4/ext/standard/dl.c diff -u php4/ext/standard/dl.c:1.67 php4/ext/standard/dl.c:1.68 --- php4/ext/standard/dl.c:1.67 Sat Mar 23 10:37:27 2002 +++ php4/ext/standard/dl.c Wed Apr 3 19:24:34 2002 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: dl.c,v 1.67 2002/03/23 15:37:27 hholzgra Exp $ */ +/* $Id: dl.c,v 1.68 2002/04/04 00:24:34 sniper Exp $ */ #include "php.h" #include "dl.h" @@ -30,7 +30,7 @@ #include "build-defs.h" #endif -#ifdef HAVE_LIBDL +#if defined(HAVE_LIBDL) || HAVE_MACH_O_DYLD_H #include <stdlib.h> #include <stdio.h> @@ -45,10 +45,10 @@ #define GET_DL_ERROR() php_win_err() #else #include <sys/param.h> -#define GET_DL_ERROR() dlerror() +#define GET_DL_ERROR() DL_ERROR() #endif -#endif +#endif /* defined(HAVE_LIBDL) || HAVE_MACH_O_DYLD_H */ /* {{{ proto int dl(string extension_filename) @@ -83,7 +83,7 @@ /* }}} */ -#ifdef HAVE_LIBDL +#if defined(HAVE_LIBDL) || HAVE_MACH_O_DYLD_H #ifdef ZTS #define USING_ZTS 1

« previous php.cvs (#10846) next »