From cvs-return-3640-apmail-apr-cvs-archive=apr.apache.org@apr.apache.org Mon Jun 24 07:01:21 2002 Return-Path: Delivered-To: apmail-apr-cvs-archive@apr.apache.org Received: (qmail 69657 invoked by uid 500); 24 Jun 2002 07:01:20 -0000 Mailing-List: contact cvs-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Reply-To: dev@apr.apache.org Delivered-To: mailing list cvs@apr.apache.org Received: (qmail 69646 invoked from network); 24 Jun 2002 07:01:20 -0000 Date: 24 Jun 2002 07:01:19 -0000 Message-ID: <20020624070119.70085.qmail@icarus.apache.org> From: jerenkrantz@apache.org To: apr-cvs@apache.org Subject: cvs commit: apr/test Makefile.in testdso.c X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N jerenkrantz 2002/06/24 00:01:19 Modified: . CHANGES dso/unix dso.c test Makefile.in testdso.c Log: Correct shared library support on Darwin to not fatally error out when a shared library does not exist. This does retain the Mach-O bundle and Mach-O dynamically linked shared library support on Darwin. Also improvements relating to testdso: - Get testdso to actually link. - Add support for a second DSO to load in testdso. - Build mod_test.slo and libmod_test.slo with and without the -module option. This checks that both types of dynamic libraries can be loaded. Revision Changes Path 1.298 +3 -0 apr/CHANGES Index: CHANGES =================================================================== RCS file: /home/cvs/apr/CHANGES,v retrieving revision 1.297 retrieving revision 1.298 diff -u -r1.297 -r1.298 --- CHANGES 22 Jun 2002 08:06:48 -0000 1.297 +++ CHANGES 24 Jun 2002 07:01:18 -0000 1.298 @@ -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] 1.55 +7 -2 apr/dso/unix/dso.c Index: dso.c =================================================================== RCS file: /home/cvs/apr/dso/unix/dso.c,v retrieving revision 1.54 retrieving revision 1.55 diff -u -r1.54 -r1.55 --- dso.c 2 May 2002 13:28:24 -0000 1.54 +++ dso.c 24 Jun 2002 07:01:18 -0000 1.55 @@ -124,8 +124,11 @@ #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 @@ #endif NSDestroyObjectFileImage(image); } - else if (NSAddLibrary(path) == TRUE) { + else if ((dsoerr == NSObjectFileImageFormat || + dsoerr == NSObjectFileImageInappropriateFile) && + NSAddLibrary(path) == TRUE) { os_handle = (NSModule)DYLD_LIBRARY_HANDLE; } else { 1.84 +13 -7 apr/test/Makefile.in Index: Makefile.in =================================================================== RCS file: /home/cvs/apr/test/Makefile.in,v retrieving revision 1.83 retrieving revision 1.84 diff -u -r1.83 -r1.84 --- Makefile.in 13 May 2002 16:35:05 -0000 1.83 +++ Makefile.in 24 Jun 2002 07:01:18 -0000 1.84 @@ -55,7 +55,7 @@ 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 @@ 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 @@ 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) 1.21 +34 -17 apr/test/testdso.c Index: testdso.c =================================================================== RCS file: /home/cvs/apr/test/testdso.c,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- testdso.c 10 May 2002 03:56:19 -0000 1.20 +++ testdso.c 24 Jun 2002 07:01:19 -0000 1.21 @@ -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 @@ 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 @@ 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; }