fielding 98/09/15 12:47:46
Modified: src CHANGES Configure src/helpers GuessOS src/include ap_config.h hsregex.h src/main http_main.c src/os/unix os.c src/regex regcomp.c regex2.h regexec.c regfree.c Log: Added RHAPSODY (Mac OS X Server) support. MAP_TMPFILE defined as an alternate mechanism for mmap'd shared memory for RHAPSODY. ap_private_extern defined to hide symbols that conflict with loaded dynamic libraries on the NEXT and RHAPSODY platforms. Submitted code was modified by Roy to use ap_private_extern instead of directly using __private_extern__, and MAP_TMPFILE instead of TMP_MAP_ANON, as suggested by Dean. Submitted by: Wilfredo Sanchez <[EMAIL PROTECTED]> Reviewed by: Roy Fielding, Dean Gaudet Revision Changes Path 1.1059 +6 -0 apache-1.3/src/CHANGES Index: CHANGES =================================================================== RCS file: /home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.1058 retrieving revision 1.1059 diff -u -r1.1058 -r1.1059 --- CHANGES 1998/09/15 00:15:16 1.1058 +++ CHANGES 1998/09/15 19:47:36 1.1059 @@ -1,5 +1,11 @@ Changes with Apache 1.3.2 + *) PORT: Added RHAPSODY (Mac OS X Server) support. MAP_TMPFILE defined + as an alternate mechanism for mmap'd shared memory for RHAPSODY. + ap_private_extern defined to hide symbols that conflict with loaded + dynamic libraries on the NEXT and RHAPSODY platforms. + [Wilfredo Sanchez <[EMAIL PROTECTED]>] + *) Delete PID file on clean shutdowns. [Charles Randall <[EMAIL PROTECTED]>] PR#2947 1.288 +15 -2 apache-1.3/src/Configure Index: Configure =================================================================== RCS file: /home/cvs/apache-1.3/src/Configure,v retrieving revision 1.287 retrieving revision 1.288 diff -u -r1.287 -r1.288 --- Configure 1998/09/10 08:58:42 1.287 +++ Configure 1998/09/15 19:47:36 1.288 @@ -483,13 +483,13 @@ DBM_LIB="" ;; *-next-nextstep*) - OS='NeXT' + OS='NeXTStep' OPTIM='-O' CFLAGS="$CFLAGS -DNEXT" DEF_WANTHSREGEX=yes ;; *-next-openstep*) - OS='Openstep for Mach' + OS='OpenStep/Mach' CC='cc' OPTIM='-O' CFLAGS="$CFLAGS -DNEXT" @@ -498,6 +498,11 @@ LDFLAGS_SHLIB='-dynamiclib -undefined warning' DEF_WANTHSREGEX=yes ;; + *-apple-rhapsody*) + OS='Mac OS X Server' + CFLAGS="$CFLAGS -DRHAPSODY" + DEF_WANTHSREGEX=yes + ;; *-dec-osf*) OS='DEC OSF/1' CFLAGS="$CFLAGS -DOSF1" @@ -853,6 +858,14 @@ LDFLAGS_SHLIB_EXPORT="" SHLIB_SUFFIX_DEPTH=2 ;; + *-apple-rhapsody*) + LD_SHLIB="cc" + CFLAGS_SHLIB="" + LDFLAGS_SHLIB="-bundle -undefined suppress" + LDFLAGS_SHLIB_EXPORT="" + SHLIB_SUFFIX_DEPTH=0 + #DEF_SHARED_CORE=yes + ;; *-solaris2*) case $CC in */gcc|gcc ) CFLAGS_SHLIB="-fpic" ;; 1.45 +7 -0 apache-1.3/src/helpers/GuessOS Index: GuessOS =================================================================== RCS file: /home/cvs/apache-1.3/src/helpers/GuessOS,v retrieving revision 1.44 retrieving revision 1.45 diff -u -r1.44 -r1.45 --- GuessOS 1998/07/28 17:07:13 1.44 +++ GuessOS 1998/09/15 19:47:39 1.45 @@ -229,6 +229,13 @@ echo "${MACHINE}-tandem-sysv4"; exit 0; ;; + Rhapsody:*:*:*) + case "${MACHINE}" in + Power*) MACHINE=powerpc ;; + esac + echo "${MACHINE}-apple-rhapsody${RELEASE}"; exit 0 + ;; + "RISC iX":*) echo "arm-whatever-riscix"; exit 0; ;; 1.232 +48 -0 apache-1.3/src/include/ap_config.h Index: ap_config.h =================================================================== RCS file: /home/cvs/apache-1.3/src/include/ap_config.h,v retrieving revision 1.231 retrieving revision 1.232 diff -u -r1.231 -r1.232 --- ap_config.h 1998/08/13 02:59:32 1.231 +++ ap_config.h 1998/09/15 19:47:40 1.232 @@ -360,6 +360,43 @@ #define NO_USE_SIGACTION #define HAVE_SYSLOG 1 +#elif defined(RHAPSODY) /* Mac OS X Server */ +#define HAVE_GMTOFF +#define HAVE_MMAP +#define USE_MMAP_FILES +#define USE_MMAP_SCOREBOARD +#define MAP_TMPFILE +#define HAVE_RESOURCE +#define HAVE_SYS_RESOURCE_H /* apaci should catch this but doesn't */ +#define HAVE_SNPRINTF +#define JMP_BUF jmp_buf +#define USE_LONGJMP +#define USE_FLOCK_SERIALIZED_ACCEPT +#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT +/* + * If you are using APACI, (you should be on Rhapsody) these + * values are set at configure time. These are here as reference; + * the apache that is built into Rhapsody is configured with + * these values. + */ +#if 0 +#define HTTPD_ROOT "/Local/Library/WebServer" +#define DOCUMENT_LOCATION HTTPD_ROOT "/Documents" +#define DEFAULT_XFERLOG "Logs/Access" +#define DEFAULT_ERRORLOG "Logs/Errors" +#define DEFAULT_PIDLOG "Logs/Process" +#define DEFAULT_SCOREBOARD "Logs/Status" +#define DEFAULT_LOCKFILE "Logs/Lock" +#define SERVER_CONFIG_FILE "Configuration/Server" +#define RESOURCE_CONFIG_FILE "Configuration/Resources" +#define TYPES_CONFIG_FILE "Configuration/MIME" +#define ACCESS_CONFIG_FILE "Configuration/Access" +#define DEFAULT_USER_DIR "Library/Web Documents" +#define DEFAULT_USER "nobody" +#define DEFAULT_GROUP "nogroup" +#define DEFAULT_PATH "/bin:/usr/bin:/usr/local/bin" +#endif + #elif defined(LINUX) #if LINUX > 1 @@ -803,6 +840,17 @@ #endif #ifndef CORE_EXPORT_NONSTD #define CORE_EXPORT_NONSTD API_EXPORT_NONSTD +#endif + +/* On OpenStep and Rhapsody, symbols that conflict with loaded dylibs + * (eg. System framework) need to be declared as private symbols with + * __private_extern__. + * For other systems, make that a no-op. + */ +#if defined(RHAPSODY) || defined(NEXT) +#define ap_private_extern __private_extern__ +#else +#define ap_private_extern #endif /* So that we can use inline on some critical functions, and use 1.11 +6 -0 apache-1.3/src/include/hsregex.h Index: hsregex.h =================================================================== RCS file: /home/cvs/apache-1.3/src/include/hsregex.h,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- hsregex.h 1998/07/09 00:04:57 1.10 +++ hsregex.h 1998/09/15 19:47:40 1.11 @@ -16,6 +16,12 @@ #endif #endif +#if defined(RHAPSODY) || defined(NEXT) +#define ap_private_extern __private_extern__ +#else +#define ap_private_extern +#endif + typedef off_t regoff_t; typedef struct { int re_magic; 1.392 +23 -2 apache-1.3/src/main/http_main.c Index: http_main.c =================================================================== RCS file: /home/cvs/apache-1.3/src/main/http_main.c,v retrieving revision 1.391 retrieving revision 1.392 diff -u -r1.391 -r1.392 --- http_main.c 1998/09/15 01:19:32 1.391 +++ http_main.c 1998/09/15 19:47:41 1.392 @@ -451,7 +451,8 @@ #endif /* a clean exit from a child with proper cleanup */ -static void __attribute__((noreturn)) clean_child_exit(int code) +static void clean_child_exit(int code) __attribute__ ((noreturn)); +static void clean_child_exit(int code) { if (pchild) { ap_child_exit_modules(pchild, server_conf); @@ -1725,6 +1726,25 @@ m = mmap((caddr_t) 0xC0000000, &len, PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, NOFD, 0); } +#elif defined(MAP_TMPFILE) + { + char mfile[] = "/tmp/apache_shmem_XXXX"; + int fd = mkstemp(mfile); + if (fd == -1) { + perror("open"); + fprintf(stderr, "httpd: Could not open %s\n", mfile); + exit(APEXIT_INIT); + } + m = mmap((caddr_t) 0, SCOREBOARD_SIZE, + PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + if (m == (caddr_t) - 1) { + perror("mmap"); + fprintf(stderr, "httpd: Could not mmap %s\n", mfile); + exit(APEXIT_INIT); + } + close(fd); + unlink(mfile); + } #else m = mmap((caddr_t) 0, SCOREBOARD_SIZE, PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0); @@ -1976,7 +1996,8 @@ } /* a clean exit from the parent with proper cleanup */ -static void __attribute__((noreturn)) clean_parent_exit(int code) +static void clean_parent_exit(int code) __attribute__((noreturn)); +static void clean_parent_exit(int code) { /* Clear the pool - including any registered cleanups */ ap_destroy_pool(pconf); 1.14 +96 -10 apache-1.3/src/os/unix/os.c Index: os.c =================================================================== RCS file: /home/cvs/apache-1.3/src/os/unix/os.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- os.c 1998/07/13 11:32:49 1.13 +++ os.c 1998/09/15 19:47:44 1.14 @@ -26,29 +26,103 @@ * dynamic shared object (DSO) mechanism */ +#ifdef RHAPSODY +#include <mach-o/dyld.h> +#include "httpd.h" +#include "http_log.h" + +ap_private_extern +void undefined_symbol_handler(const char *symbolName) +{ + ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, NULL, + "dyld found undefined symbol: %s\n" + "Aborting.\n", + symbolName); + abort(); +} + +ap_private_extern +NSModule multiple_symbol_handler (NSSymbol s, NSModule old, NSModule new) +{ + /* + * Since we can't unload symbols, we're going to run into this + * every time we reload a module. Workaround here is to just + * rebind to the new symbol, and forget about the old one. + * This is crummy, because it's basically a memory leak. + * (See Radar 2262020 against dyld). + */ + +#ifdef DEBUG + ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_DEBUG, NULL, + "dyld found a multiply defined symbol %s in modules:\n" + "%s\n%s\n", + NSNameOfSymbol(s), + NSNameOfModule(old), NSNameOfModule(new)); +#endif + + return(new); +} + +ap_private_extern +void linkEdit_symbol_handler (NSLinkEditErrors c, int errorNumber, + const char *fileName, const char *errorString) +{ + ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, NULL, + "dyld errors during link edit for file %s\n%s\n", + fileName, errorString); + abort(); +} + +#endif + +void ap_os_dso_init() +{ +#if defined(RHAPSODY) + NSLinkEditErrorHandlers handlers; + + handlers.undefined = undefined_symbol_handler; + handlers.multiple = multiple_symbol_handler; + handlers.linkEdit = linkEdit_symbol_handler; + + NSInstallLinkEditErrorHandlers(&handlers); +#endif +} + void *ap_os_dso_load(const char *path) { #if defined(HPUX) || defined(HPUX10) shl_t handle; handle = shl_load(path, BIND_IMMEDIATE|BIND_VERBOSE|BIND_NOSTART, 0L); return (void *)handle; -#else -#if defined(OSF1) ||\ + +#elif defined(RHAPSODY) + NSObjectFileImage image; + if (NSCreateObjectFileImageFromFile(path, &image) != + NSObjectFileImageSuccess) + return NULL; + return NSLinkModule(image, path, TRUE); + +#elif defined(OSF1) ||\ (defined(__FreeBSD_version) && (__FreeBSD_version >= 220000)) return dlopen((char *)path, RTLD_NOW | RTLD_GLOBAL); + #else return dlopen(path, RTLD_NOW | RTLD_GLOBAL); #endif -#endif } -void ap_os_dso_unload(void *handle) +void ap_os_dso_unload(void *handle) { #if defined(HPUX) || defined(HPUX10) shl_unload((shl_t)handle); + +#elif defined(RHAPSODY) + NSUnLinkModule(handle,FALSE); + #else dlclose(handle); #endif + return; } @@ -63,23 +137,35 @@ if (status == -1 && errno == 0) /* try TYPE_DATA instead */ status = shl_findsym((shl_t *)&handle, symname, TYPE_DATA, &symaddr); return (status == -1 ? NULL : symaddr); -#else /* ndef HPUX */ -#ifdef DLSYM_NEEDS_UNDERSCORE - char symbol[256]; + +#elif defined(RHAPSODY) + NSSymbol symbol; + char *symname2 = (char*)malloc(sizeof(char)*(strlen(symname)+2)); + sprintf(symname2, "_%s", symname); + symbol = NSLookupAndBindSymbol(symname2); + free(symname2); + return NSAddressOfSymbol(symbol); + +#elif DLSYM_NEEDS_UNDERSCORE + char *symbol = (char*)malloc(sizeof(char)*(strlen(symname)+2)); + void *retval; sprintf(symbol, "_%s", symname); - return dlsym(handle, symbol); + retval = dlsym(handle, symbol); + free(symbol); + return retval; + #else return dlsym(handle, symname); #endif -#endif /* ndef HPUX */ } const char *ap_os_dso_error(void) { #if defined(HPUX) || defined(HPUX10) return strerror(errno); +#elif defined(RHAPSODY) + return NULL; #else return dlerror(); #endif } - 1.9 +1 -0 apache-1.3/src/regex/regcomp.c Index: regcomp.c =================================================================== RCS file: /home/cvs/apache-1.3/src/regex/regcomp.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- regcomp.c 1998/07/13 11:32:52 1.8 +++ regcomp.c 1998/09/15 19:47:45 1.9 @@ -83,6 +83,7 @@ = #define REG_PEND 0040 = #define REG_DUMP 0200 */ +ap_private_extern API_EXPORT(int) /* 0 success, otherwise REG_something */ regcomp(preg, pattern, cflags) regex_t *preg; 1.7 +6 -0 apache-1.3/src/regex/regex2.h Index: regex2.h =================================================================== RCS file: /home/cvs/apache-1.3/src/regex/regex2.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- regex2.h 1998/07/09 00:04:56 1.6 +++ regex2.h 1998/09/15 19:47:45 1.7 @@ -8,6 +8,12 @@ = #endif = #endif = + = #if defined(RHAPSODY) || defined(NEXT) + = #define ap_private_extern __private_extern__ + = #else + = #define ap_private_extern + = #endif + = = typedef off_t regoff_t; = typedef struct { = int re_magic; 1.6 +1 -0 apache-1.3/src/regex/regexec.c Index: regexec.c =================================================================== RCS file: /home/cvs/apache-1.3/src/regex/regexec.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- regexec.c 1998/02/04 18:18:55 1.5 +++ regexec.c 1998/09/15 19:47:45 1.6 @@ -111,6 +111,7 @@ * when choosing which matcher to call. Also, by this point the matchers * have been prototyped. */ +ap_private_extern API_EXPORT(int) /* 0 success, REG_NOMATCH failure */ regexec(preg, string, nmatch, pmatch, eflags) const regex_t *preg; 1.4 +1 -0 apache-1.3/src/regex/regfree.c Index: regfree.c =================================================================== RCS file: /home/cvs/apache-1.3/src/regex/regfree.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- regfree.c 1998/02/04 18:18:55 1.3 +++ regfree.c 1998/09/15 19:47:45 1.4 @@ -10,6 +10,7 @@ - regfree - free everything = API_EXPORT(void) regfree(regex_t *); */ +ap_private_extern API_EXPORT(void) regfree(preg) regex_t *preg;