summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
authorDerick Rethans <derick@php.net>2002-07-18 11:16:34 +0000
committerDerick Rethans <derick@php.net>2002-07-18 11:16:34 +0000
commit0650a59aea7223768210574129c61d790924a919 (patch)
treece1609dccd94c325f2cd57686ea3b349f746444f /Zend
parent658503f6eeb02c5a3435294f8abf18eddb0ae4bc (diff)
downloadphp-git-0650a59aea7223768210574129c61d790924a919.tar.gz
- MFZE1 - MacOSX fixes by Marko Karppinen
Diffstat (limited to 'Zend')
-rw-r--r--Zend/zend.h11
-rw-r--r--Zend/zend_extensions.c61
2 files changed, 72 insertions, 0 deletions
diff --git a/Zend/zend.h b/Zend/zend.h
index d0c2667b6d..d948eeba4f 100644
--- a/Zend/zend.h
+++ b/Zend/zend.h
@@ -80,6 +80,17 @@
# 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
diff --git a/Zend/zend_extensions.c b/Zend/zend_extensions.c
index 45769d654a..6e50ae1398 100644
--- a/Zend/zend_extensions.c
+++ b/Zend/zend_extensions.c
@@ -216,3 +216,64 @@ ZEND_API zend_extension *zend_get_extension(char *extension_name)
}
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 */