summaryrefslogtreecommitdiff
path: root/dso/unix
diff options
context:
space:
mode:
authorWilfredo Sanchez <wsanchez@apache.org>2001-04-18 17:47:10 +0000
committerWilfredo Sanchez <wsanchez@apache.org>2001-04-18 17:47:10 +0000
commit7485d62a5543a2cfc5e0006a0196794482a47362 (patch)
treefc17389fd891b03358dbc2f87374e2af02c53139 /dso/unix
parentf521d2dc67e0609822c5cdbc88a2c164cbc39ec8 (diff)
downloadapr-7485d62a5543a2cfc5e0006a0196794482a47362.tar.gz
Add dyld support
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@61529 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'dso/unix')
-rw-r--r--dso/unix/dso.c50
1 files changed, 48 insertions, 2 deletions
diff --git a/dso/unix/dso.c b/dso/unix/dso.c
index 6ff0baf3f..2c7f20c70 100644
--- a/dso/unix/dso.c
+++ b/dso/unix/dso.c
@@ -73,6 +73,8 @@ static apr_status_t dso_cleanup(void *thedso)
#if defined(HPUX) || defined(HPUX10) || defined(HPUX11)
shl_unload((shl_t)dso->handle);
+#elif defined(DARWIN)
+ NSUnLinkModule(dso->handle, FALSE);
#else
if (dlclose(dso->handle) != 0)
return APR_EINIT;
@@ -87,9 +89,28 @@ APR_DECLARE(apr_status_t) apr_dso_load(apr_dso_handle_t **res_handle,
{
#if defined(HPUX) || defined(HPUX10) || defined(HPUX11)
shl_t os_handle = shl_load(path, BIND_IMMEDIATE|BIND_VERBOSE|BIND_NOSTART, 0L);
+
+#elif defined(DARWIN)
+ NSObjectFileImage image;
+ NSModule os_handle;
+ char* err_msg = NULL;
+ if (NSCreateObjectFileImageFromFile(path, &image) != NSObjectFileImageSuccess) {
+ err_msg = "cannot create object file image";
+ }
+ else {
+#ifdef NSLINKMODULE_OPTION_PRIVATE
+ os_handle = NSLinkModule(image, path,
+ NSLINKMODULE_OPTION_PRIVATE |
+ NSLINKMODULE_OPTION_RETURN_ON_ERROR);
+#else
+ os_handle = NSLinkModule(image, path, TRUE);
+#endif
+ }
+
#elif defined(OSF1) || defined(SEQUENT) || defined(SNI) ||\
(defined(__FreeBSD_version) && (__FreeBSD_version >= 220000))
void *os_handle = dlopen((char *)path, RTLD_NOW | RTLD_GLOBAL);
+
#else
void *os_handle = dlopen(path, RTLD_NOW | RTLD_GLOBAL);
#endif
@@ -100,6 +121,9 @@ APR_DECLARE(apr_status_t) apr_dso_load(apr_dso_handle_t **res_handle,
#if defined(HPUX) || defined(HPUX10) || defined(HPUX11)
(*res_handle)->errormsg = strerror(errno);
return errno;
+#elif defined(DARWIN)
+ (*res_handle)->errormsg = (err_msg) ? err_msg : "link failed";
+ return APR_EDSOOPEN;
#else
(*res_handle)->errormsg = dlerror();
return APR_EDSOOPEN;
@@ -136,7 +160,29 @@ APR_DECLARE(apr_status_t) apr_dso_sym(apr_dso_handle_sym_t *ressym,
return APR_EINIT;
*ressym = symaddr;
return APR_SUCCESS;
-#else /* not HP-UX; use dlsym()/dlerror() */
+
+#elif defined(DARWIN)
+ void *retval = NULL;
+ NSSymbol symbol;
+ char *symname2 = (char*)malloc(sizeof(char)*(strlen(symname)+2));
+ sprintf(symname2, "_%s", symname);
+#ifdef NSLINKMODULE_OPTION_PRIVATE
+ symbol = NSLookupSymbolInModule((NSModule)handle->handle, symname2);
+#else
+ symbol = NSLookupAndBindSymbol(symname2);
+#endif
+ free(symname2);
+ if (symbol == NULL) {
+ handle->errormsg = "undefined symbol";
+ return APR_EINIT;
+ }
+ retval = NSAddressOfSymbol(symbol);
+ if (retval == NULL) {
+ handle->errormsg = "cannot resolve symbol";
+ return APR_EINIT;
+ }
+
+#else /* use dlsym()/dlerror() */
#if defined(DLSYM_NEEDS_UNDERSCORE)
void *retval;
@@ -159,7 +205,7 @@ APR_DECLARE(apr_status_t) apr_dso_sym(apr_dso_handle_sym_t *ressym,
*ressym = retval;
return APR_SUCCESS;
-#endif /* not HP-UX; use dlsym()/dlerror() */
+#endif /* use dlsym()/dlerror() */
}
APR_DECLARE(const char *) apr_dso_error(apr_dso_handle_t *dso, char *buffer, apr_size_t buflen)