diff options
-rw-r--r-- | CHANGES | 3 | ||||
-rw-r--r-- | dso/unix/dso.c | 9 | ||||
-rw-r--r-- | test/Makefile.in | 18 | ||||
-rw-r--r-- | test/testdso.c | 51 |
4 files changed, 56 insertions, 25 deletions
@@ -1,5 +1,8 @@ Changes with APR b1 + *) Correct shared library support on Darwin to not fatally error out + when a shared library does not exist. [Justin Erenkrantz] + *) Added optimized atomic CAS support for Linux/x86 (available only when APR is configured with --enable-nonportable-atomics=yes) [Brian Pane] diff --git a/dso/unix/dso.c b/dso/unix/dso.c index a6d3860e2..8f97b7555 100644 --- a/dso/unix/dso.c +++ b/dso/unix/dso.c @@ -124,8 +124,11 @@ APR_DECLARE(apr_status_t) apr_dso_load(apr_dso_handle_t **res_handle, #elif defined(DSO_USE_DYLD) NSObjectFileImage image; NSModule os_handle = NULL; + NSObjectFileImageReturnCode dsoerr; char* err_msg = NULL; - if (NSCreateObjectFileImageFromFile(path, &image) == NSObjectFileImageSuccess) { + dsoerr = NSCreateObjectFileImageFromFile(path, &image); + + if (dsoerr == NSObjectFileImageSuccess) { #if defined(NSLINKMODULE_OPTION_RETURN_ON_ERROR) && defined(NSLINKMODULE_OPTION_NONE) os_handle = NSLinkModule(image, path, NSLINKMODULE_OPTION_RETURN_ON_ERROR | @@ -135,7 +138,9 @@ APR_DECLARE(apr_status_t) apr_dso_load(apr_dso_handle_t **res_handle, #endif NSDestroyObjectFileImage(image); } - else if (NSAddLibrary(path) == TRUE) { + else if ((dsoerr == NSObjectFileImageFormat || + dsoerr == NSObjectFileImageInappropriateFile) && + NSAddLibrary(path) == TRUE) { os_handle = (NSModule)DYLD_LIBRARY_HANDLE; } else { diff --git a/test/Makefile.in b/test/Makefile.in index 1f0ff9151..5d670ded3 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -55,7 +55,7 @@ TARGETS = $(PROGRAMS) $(NONPORTABLE) LOCAL_LIBS=../libapr.la -CLEAN_TARGETS = testfile.tmp testdso@EXEEXT@ mod_test.so +CLEAN_TARGETS = testfile.tmp testdso@EXEEXT@ mod_test.slo INCDIR=../include INCLUDES=-I$(INCDIR) @@ -76,9 +76,8 @@ testflock@EXEEXT@: testflock.lo $(LOCAL_LIBS) testfmt@EXEEXT@: testfmt.lo $(LOCAL_LIBS) $(LINK) testfmt.lo $(LOCAL_LIBS) $(ALL_LIBS) -### why the export-dynamic? -testdso@EXEEXT@: testdso.lo mod_test.so $(LOCAL_LIBS) - $(LINK) -export-dynamic testdso.lo $(LOCAL_LIBS) $(ALL_LIBS) +testdso@EXEEXT@: testdso.lo mod_test.la libmod_test.la $(LOCAL_LIBS) + $(LINK) testdso.lo $(LOCAL_LIBS) $(ALL_LIBS) testoc@EXEEXT@: testoc.lo occhild@EXEEXT@ $(LOCAL_LIBS) $(LINK) testoc.lo $(LOCAL_LIBS) $(ALL_LIBS) @@ -86,9 +85,16 @@ testoc@EXEEXT@: testoc.lo occhild@EXEEXT@ $(LOCAL_LIBS) occhild@EXEEXT@: occhild.lo $(LOCAL_LIBS) $(LINK) occhild.lo $(LOCAL_LIBS) $(ALL_LIBS) -mod_test.so: mod_test.lo $(LOCAL_LIBS) - $(LINK) -shared mod_test.o $(LOCAL_LIBS) $(ALL_LIBS) +# FIXME: -prefer-pic is only supported with libtool-1.4+ +mod_test.slo: mod_test.c + $(LIBTOOL) --mode=compile $(COMPILE) -prefer-pic -c $< && touch $@ +mod_test.la: mod_test.slo $(LOCAL_LIBS) + $(LINK) --mode=link $(COMPILE) -rpath $(shell pwd) -avoid-version -module mod_test.lo $(LT_LDFLAGS) $(ALL_LDFLAGS) -o $@ + +libmod_test.la: mod_test.slo $(LOCAL_LIBS) + $(LINK) --mode=link $(COMPILE) -rpath $(shell pwd) -avoid-version mod_test.lo $(LT_LDFLAGS) $(ALL_LDFLAGS) -o $@ + testargs@EXEEXT@: testargs.lo $(LOCAL_LIBS) $(LINK) testargs.lo $(LOCAL_LIBS) $(ALL_LIBS) diff --git a/test/testdso.c b/test/testdso.c index 4231dcb04..512f7298e 100644 --- a/test/testdso.c +++ b/test/testdso.c @@ -65,22 +65,27 @@ #endif #ifdef NETWARE -#define LIB_NAME "mod_test.nlm" +# define LIB_NAME "mod_test.nlm" #else -# ifndef BEOS -# define LIB_NAME ".libs/mod_test.so" -# else +# ifdef BEOS # define LIB_NAME "mod_test.so" +# else +# ifdef DARWIN +# define LIB_NAME ".libs/mod_test.so" +# define LIB_NAME2 ".libs/libmod_test.dylib" +# else +# define LIB_NAME ".libs/mod_test.so" +# define LIB_NAME2 ".libs/libmod_test.so" +# endif # endif #endif -int main (int argc, char ** argv) +void test_shared_library(const char *libname, apr_pool_t *pool) { apr_dso_handle_t *h = NULL; apr_dso_handle_sym_t func1 = NULL; apr_dso_handle_sym_t func2 = NULL; apr_status_t status; - apr_pool_t *cont; void (*function)(void); void (*function1)(int); int *retval; @@ -88,19 +93,11 @@ int main (int argc, char ** argv) getcwd(filename, 256); strcat(filename, "/"); - strcat(filename, LIB_NAME); - - apr_initialize(); - atexit(apr_terminate); - - if (apr_pool_create(&cont, NULL) != APR_SUCCESS) { - fprintf(stderr, "Couldn't allocate context."); - exit(-1); - } + strcat(filename, libname); fprintf(stdout,"Trying to load DSO now....................."); fflush(stdout); - if ((status = apr_dso_load(&h, filename, cont)) != APR_SUCCESS){ + if ((status = apr_dso_load(&h, filename, pool)) != APR_SUCCESS){ char my_error[256]; apr_strerror(status, my_error, sizeof(my_error)); fprintf(stderr, "%s!\n", my_error); @@ -161,6 +158,26 @@ int main (int argc, char ** argv) exit (-1); } fprintf(stdout,"OK\n"); - +} + +int main (int argc, char ** argv) +{ + apr_pool_t *pool; + + apr_initialize(); + atexit(apr_terminate); + + if (apr_pool_create(&pool, NULL) != APR_SUCCESS) { + fprintf(stderr, "Couldn't allocate context."); + exit(-1); + } + + fprintf(stdout,"=== Checking module library ===\n"); + test_shared_library(LIB_NAME, pool); +#ifdef LIB_NAME2 + fprintf(stdout,"=== Checking non-module library ===\n"); + test_shared_library(LIB_NAME2, pool); +#endif + return 0; } |