From f556e5b971932902a6d49815d5094657f50eb262 Mon Sep 17 00:00:00 2001 From: Jarkko Hietaniemi Date: Sat, 26 Feb 2000 03:10:47 +0000 Subject: Rhapsody/Darwin patches from Wilfredo Sanchez. p4raw-id: //depot/cfgperl@5262 --- Configure | 4 +- INSTALL | 2 +- MANIFEST | 5 +- Makefile.SH | 16 ++- README.threads | 2 +- ext/DynaLoader/dl_dyld.xs | 226 ++++++++++++++++++++++++++++++++++++++++++ ext/DynaLoader/dl_rhapsody.xs | 219 ---------------------------------------- hints/darwin.sh | 63 ++++++++++++ hints/rhapsody.sh | 64 ++++++------ installperl | 11 +- pp_sys.c | 2 +- 11 files changed, 352 insertions(+), 262 deletions(-) create mode 100644 ext/DynaLoader/dl_dyld.xs delete mode 100644 ext/DynaLoader/dl_rhapsody.xs create mode 100644 hints/darwin.sh diff --git a/Configure b/Configure index 0abed23af4..76c189d70a 100755 --- a/Configure +++ b/Configure @@ -20,7 +20,7 @@ # $Id: Head.U,v 3.0.1.9 1997/02/28 15:02:09 ram Exp $ # -# Generated on Sat Feb 26 04:42:42 EET 2000 [metaconfig 3.0 PL70] +# Generated on Sat Feb 26 05:10:12 EET 2000 [metaconfig 3.0 PL70] # (with additional metaconfig patches by perlbug@perl.com) cat >/tmp/c1$$ <> extra.pods -@test -f vms/perlvms.pod && $(LNS) ../vms/perlvms.pod pod/perlvms.pod && echo "pod/perlvms.pod" >> extra.pods +install-strip: + $(MAKE) STRIPFLAGS=-s install + install: all install.perl install.man install.perl: all installperl @@ -542,7 +550,7 @@ install.perl: all installperl cd ../pod; $(MAKE) compile; \ else :; \ fi - $(LDLIBPTH) ./perl installperl + $(LDLIBPTH) ./perl installperl $(STRIPFLAGS) install.man: all installman $(LDLIBPTH) ./perl installman diff --git a/README.threads b/README.threads index 1f5f7ea070..15d36de644 100644 --- a/README.threads +++ b/README.threads @@ -51,7 +51,7 @@ from the "Problems" section. * OpenBSD - * NeXTstep, OpenStep (Rhapsody?) + * NeXTstep, OpenStep * OS/2 diff --git a/ext/DynaLoader/dl_dyld.xs b/ext/DynaLoader/dl_dyld.xs new file mode 100644 index 0000000000..688e4745f8 --- /dev/null +++ b/ext/DynaLoader/dl_dyld.xs @@ -0,0 +1,226 @@ +/* dl_dyld.xs + * + * Platform: Darwin (Mac OS) + * Author: Wilfredo Sanchez + * Based on: dl_next.xs by Paul Marquess + * Based on: dl_dlopen.xs by Anno Siegel + * Created: Aug 15th, 1994 + * + */ + +/* + And Gandalf said: 'Many folk like to know beforehand what is to + be set on the table; but those who have laboured to prepare the + feast like to keep their secret; for wonder makes the words of + praise louder.' +*/ + +/* Porting notes: + +dl_dyld.xs is based on dl_next.xs by Anno Siegel. + +dl_next.xs is in turn a port from dl_dlopen.xs by Paul Marquess. It +should not be used as a base for further ports though it may be used +as an example for how dl_dlopen.xs can be ported to other platforms. + +The method used here is just to supply the sun style dlopen etc. +functions in terms of NeXT's/Apple's dyld. The xs code proper is +unchanged from Paul's original. + +The port could use some streamlining. For one, error handling could +be simplified. + +This should be useable as a replacement for dl_next.xs, but it has not +been tested on NeXT platforms. + + Wilfredo Sanchez + +*/ + +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" + +#define DL_LOADONCEONLY + +#include "dlutils.c" /* SaveError() etc */ + +#undef environ +#undef bool +#import + +static char * dl_last_error = (char *) 0; +static AV *dl_resolve_using = Nullav; + +static char *dlerror() +{ + return dl_last_error; +} + +int dlclose(handle) /* stub only */ +void *handle; +{ + return 0; +} + +enum dyldErrorSource +{ + OFImage, +}; + +static void TranslateError + (const char *path, enum dyldErrorSource type, int number) +{ + dTHX; + char *error; + unsigned int index; + static char *OFIErrorStrings[] = + { + "%s(%d): Object Image Load Failure\n", + "%s(%d): Object Image Load Success\n", + "%s(%d): Not an recognisable object file\n", + "%s(%d): No valid architecture\n", + "%s(%d): Object image has an invalid format\n", + "%s(%d): Invalid access (permissions?)\n", + "%s(%d): Unknown error code from NSCreateObjectFileImageFromFile\n", + }; +#define NUM_OFI_ERRORS (sizeof(OFIErrorStrings) / sizeof(OFIErrorStrings[0])) + + switch (type) + { + case OFImage: + index = number; + if (index > NUM_OFI_ERRORS - 1) + index = NUM_OFI_ERRORS - 1; + error = Perl_form_nocontext(OFIErrorStrings[index], path, number); + break; + + default: + error = Perl_form_nocontext("%s(%d): Totally unknown error type %d\n", + path, number, type); + break; + } + safefree(dl_last_error); + dl_last_error = savepv(error); +} + +static char *dlopen(char *path, int mode /* mode is ignored */) +{ + int dyld_result; + NSObjectFileImage ofile; + NSModule handle = NULL; + + dyld_result = NSCreateObjectFileImageFromFile(path, &ofile); + if (dyld_result != NSObjectFileImageSuccess) + TranslateError(path, OFImage, dyld_result); + else + { + // NSLinkModule will cause the run to abort on any link error's + // not very friendly but the error recovery functionality is limited. + handle = NSLinkModule(ofile, path, TRUE); + } + + return handle; +} + +void * +dlsym(handle, symbol) +void *handle; +char *symbol; +{ + void *addr; + + if (NSIsSymbolNameDefined(symbol)) + addr = NSAddressOfSymbol(NSLookupAndBindSymbol(symbol)); + else + addr = NULL; + + return addr; +} + + + +/* ----- code from dl_dlopen.xs below here ----- */ + + +static void +dl_private_init(pTHX) +{ + (void)dl_generic_private_init(aTHX); + dl_resolve_using = get_av("DynaLoader::dl_resolve_using", GV_ADDMULTI); +} + +MODULE = DynaLoader PACKAGE = DynaLoader + +BOOT: + (void)dl_private_init(aTHX); + + + +void * +dl_load_file(filename, flags=0) + char * filename + int flags + PREINIT: + int mode = 1; + CODE: + DLDEBUG(1,PerlIO_printf(Perl_debug_log, "dl_load_file(%s,%x):\n", filename,flags)); + if (flags & 0x01) + Perl_warn(aTHX_ "Can't make loaded symbols global on this platform while loading %s",filename); + RETVAL = dlopen(filename, mode) ; + DLDEBUG(2,PerlIO_printf(Perl_debug_log, " libref=%x\n", RETVAL)); + ST(0) = sv_newmortal() ; + if (RETVAL == NULL) + SaveError(aTHX_ "%s",dlerror()) ; + else + sv_setiv( ST(0), PTR2IV(RETVAL) ); + + +void * +dl_find_symbol(libhandle, symbolname) + void * libhandle + char * symbolname + CODE: + symbolname = Perl_form_nocontext("_%s", symbolname); + DLDEBUG(2, PerlIO_printf(Perl_debug_log, + "dl_find_symbol(handle=%lx, symbol=%s)\n", + (unsigned long) libhandle, symbolname)); + RETVAL = dlsym(libhandle, symbolname); + DLDEBUG(2, PerlIO_printf(Perl_debug_log, + " symbolref = %lx\n", (unsigned long) RETVAL)); + ST(0) = sv_newmortal() ; + if (RETVAL == NULL) + SaveError(aTHX_ "%s",dlerror()) ; + else + sv_setiv( ST(0), PTR2IV(RETVAL) ); + + +void +dl_undef_symbols() + PPCODE: + + + +# These functions should not need changing on any platform: + +void +dl_install_xsub(perl_name, symref, filename="$Package") + char * perl_name + void * symref + char * filename + CODE: + DLDEBUG(2,PerlIO_printf(Perl_debug_log, "dl_install_xsub(name=%s, symref=%x)\n", + perl_name, symref)); + ST(0) = sv_2mortal(newRV((SV*)newXS(perl_name, + (void(*)(pTHX_ CV *))symref, + filename))); + + +char * +dl_error() + CODE: + RETVAL = LastError ; + OUTPUT: + RETVAL + +# end. diff --git a/ext/DynaLoader/dl_rhapsody.xs b/ext/DynaLoader/dl_rhapsody.xs deleted file mode 100644 index 768e99ed2f..0000000000 --- a/ext/DynaLoader/dl_rhapsody.xs +++ /dev/null @@ -1,219 +0,0 @@ -/* dl_rhapsody.xs - * - * Platform: Apple Rhapsody 5.0 - * Based on: dl_next.xs by Paul Marquess - * Based on: dl_dlopen.xs by Anno Siegel - * Created: Aug 15th, 1994 - * - */ - -/* - And Gandalf said: 'Many folk like to know beforehand what is to - be set on the table; but those who have laboured to prepare the - feast like to keep their secret; for wonder makes the words of - praise louder.' -*/ - -/* Porting notes: - -dl_next.xs is itself a port from dl_dlopen.xs by Paul Marquess. It -should not be used as a base for further ports though it may be used -as an example for how dl_dlopen.xs can be ported to other platforms. - -The method used here is just to supply the sun style dlopen etc. -functions in terms of NeXTs rld_*. The xs code proper is unchanged -from Paul's original. - -The port could use some streamlining. For one, error handling could -be simplified. - -Anno Siegel - -*/ - -#include "EXTERN.h" -#include "perl.h" -#include "XSUB.h" - -#define DL_LOADONCEONLY - -#include "dlutils.c" /* SaveError() etc */ - -#undef environ -#import - -static char * dl_last_error = (char *) 0; -static AV *dl_resolve_using = Nullav; - -static char *dlerror() -{ - return dl_last_error; -} - -int dlclose(handle) /* stub only */ -void *handle; -{ - return 0; -} - -enum dyldErrorSource -{ - OFImage, -}; - -static void TranslateError - (const char *path, enum dyldErrorSource type, int number) -{ - dTHX; - char *error; - unsigned int index; - static char *OFIErrorStrings[] = - { - "%s(%d): Object Image Load Failure\n", - "%s(%d): Object Image Load Success\n", - "%s(%d): Not an recognisable object file\n", - "%s(%d): No valid architecture\n", - "%s(%d): Object image has an invalid format\n", - "%s(%d): Invalid access (permissions?)\n", - "%s(%d): Unknown error code from NSCreateObjectFileImageFromFile\n", - }; -#define NUM_OFI_ERRORS (sizeof(OFIErrorStrings) / sizeof(OFIErrorStrings[0])) - - switch (type) - { - case OFImage: - index = number; - if (index > NUM_OFI_ERRORS - 1) - index = NUM_OFI_ERRORS - 1; - error = Perl_form_nocontext(OFIErrorStrings[index], path, number); - break; - - default: - error = Perl_form_nocontext("%s(%d): Totally unknown error type %d\n", - path, number, type); - break; - } - safefree(dl_last_error); - dl_last_error = savepv(error); -} - -static char *dlopen(char *path, int mode /* mode is ignored */) -{ - int dyld_result; - NSObjectFileImage ofile; - NSModule handle = NULL; - - dyld_result = NSCreateObjectFileImageFromFile(path, &ofile); - if (dyld_result != NSObjectFileImageSuccess) - TranslateError(path, OFImage, dyld_result); - else - { - // NSLinkModule will cause the run to abort on any link error's - // not very friendly but the error recovery functionality is limited. - handle = NSLinkModule(ofile, path, TRUE); - } - - return handle; -} - -void * -dlsym(handle, symbol) -void *handle; -char *symbol; -{ - void *addr; - - if (NSIsSymbolNameDefined(symbol)) - addr = NSAddressOfSymbol(NSLookupAndBindSymbol(symbol)); - else - addr = NULL; - - return addr; -} - - - -/* ----- code from dl_dlopen.xs below here ----- */ - - -static void -dl_private_init(pTHX) -{ - (void)dl_generic_private_init(aTHX); - dl_resolve_using = get_av("DynaLoader::dl_resolve_using", GV_ADDMULTI); -} - -MODULE = DynaLoader PACKAGE = DynaLoader - -BOOT: - (void)dl_private_init(aTHX); - - - -void * -dl_load_file(filename, flags=0) - char * filename - int flags - PREINIT: - int mode = 1; - CODE: - DLDEBUG(1,PerlIO_printf(Perl_debug_log, "dl_load_file(%s,%x):\n", filename,flags)); - if (flags & 0x01) - Perl_warn(aTHX_ "Can't make loaded symbols global on this platform while loading %s",filename); - RETVAL = dlopen(filename, mode) ; - DLDEBUG(2,PerlIO_printf(Perl_debug_log, " libref=%x\n", RETVAL)); - ST(0) = sv_newmortal() ; - if (RETVAL == NULL) - SaveError(aTHX_ "%s",dlerror()) ; - else - sv_setiv( ST(0), PTR2IV(RETVAL) ); - - -void * -dl_find_symbol(libhandle, symbolname) - void * libhandle - char * symbolname - CODE: - symbolname = Perl_form_nocontext("_%s", symbolname); - DLDEBUG(2, PerlIO_printf(Perl_debug_log, - "dl_find_symbol(handle=%lx, symbol=%s)\n", - (unsigned long) libhandle, symbolname)); - RETVAL = dlsym(libhandle, symbolname); - DLDEBUG(2, PerlIO_printf(Perl_debug_log, - " symbolref = %lx\n", (unsigned long) RETVAL)); - ST(0) = sv_newmortal() ; - if (RETVAL == NULL) - SaveError(aTHX_ "%s",dlerror()) ; - else - sv_setiv( ST(0), PTR2IV(RETVAL) ); - - -void -dl_undef_symbols() - PPCODE: - - - -# These functions should not need changing on any platform: - -void -dl_install_xsub(perl_name, symref, filename="$Package") - char * perl_name - void * symref - char * filename - CODE: - DLDEBUG(2,PerlIO_printf(Perl_debug_log, "dl_install_xsub(name=%s, symref=%x)\n", - perl_name, symref)); - ST(0) = sv_2mortal(newRV((SV*)newXS(perl_name, - (void(*)(pTHX_ CV *))symref, - filename))); - - -char * -dl_error() - CODE: - RETVAL = LastError ; - OUTPUT: - RETVAL - -+# end. diff --git a/hints/darwin.sh b/hints/darwin.sh new file mode 100644 index 0000000000..fd61e424b0 --- /dev/null +++ b/hints/darwin.sh @@ -0,0 +1,63 @@ +## +# Darwin (Mac OS) hints +# Wilfredo Sanchez +## + +## +# Paths +## + +# BSD paths +prefix='/usr'; +siteprefix='/usr/local'; +vendorprefix='/usr/local'; usevendorprefix='define'; + +# 4BSD uses /usr/share/man, not /usr/man. +# Don't put man pages in /usr/lib; that's goofy. +man1dir='/usr/share/man/man1'; +man3dir='/usr/share/man/man3'; + +# Where to put modules. +privlib='/System/Library/Perl'; +sitelib='/Local/Library/Perl'; +vendorlib='/Network/Library/Perl'; + +## +# Tool chain settings +## + +# Since we can build fat, the archname doesn't need the processor type +archname='darwin'; + +# nm works. +usenm='true'; + +# Libc is in libsystem. +libc='/System/Library/Frameworks/System.framework/System'; + +# Optimize. +optimize='-O3'; + +# We have a prototype for telldir. +ccflags="${ccflags} -pipe -fno-common -DHAS_TELLDIR_PROTOTYPE"; + +# Shared library extension is .dylib. +# Bundle extension is .bundle. +ld='cc'; +so='dylib'; +dlext='bundle'; +dlsrc='dl_dyld.xs'; usedl='define'; +cccdlflags=''; +lddlflags="${ldflags} -bundle -undefined suppress"; +ldlibpthname='DYLD_LIBRARY_PATH'; +useshrplib='true'; + +## +# System libraries +## + +# vfork works +usevfork='true'; + +# malloc works +usemymalloc='n'; diff --git a/hints/rhapsody.sh b/hints/rhapsody.sh index c564c8827e..933081ba09 100644 --- a/hints/rhapsody.sh +++ b/hints/rhapsody.sh @@ -3,57 +3,65 @@ # Wilfredo Sanchez ## -# Since we can build fat, the archname doesn't need the processor type -archname='rhapsody'; +## +# Paths +## -# Perl5.003 precedes this platform -d_bincompat3='undef'; +# BSD paths +prefix='/usr'; +siteprefix='/usr/local'; +vendorprefix='/usr/local'; usevendorprefix='define'; -# Libc is in libsystem. -libc='/System/Library/Frameworks/System.framework/System'; +# 4BSD uses /usr/share/man, not /usr/man. +# Don't put man pages in /usr/lib; that's goofy. +man1dir='/usr/share/man/man1'; +man3dir='/usr/share/man/man3'; + +# Where to put modules. +privlib='/System/Library/Perl'; +sitelib='/Local/Library/Perl'; +vendorlib='/Network/Library/Perl'; + +## +# Tool chain settings +## + +# Since we can build fat, the archname doesn't need the processor type +archname='rhapsody'; # nm works. usenm='true'; + +# Libc is in libsystem. +libc='/System/Library/Frameworks/System.framework/System'; # Optimize. optimize='-O3'; # We have a prototype for telldir. -# We are not NeXTStep. -ccflags="${ccflags} -pipe -fno-common -DHAS_TELLDIR_PROTOTYPE -UNeXT -U__NeXT__"; +ccflags="${ccflags} -pipe -fno-common -DHAS_TELLDIR_PROTOTYPE"; -# Don't use /usr/local/lib; we may have junk there. -libpth='/lib /usr/lib'; - -# Shared library extension in .dylib. -# Bundle extension in .bundle. +# Shared library extension is .dylib. +# Bundle extension is .bundle. ld='cc'; so='dylib'; dlext='bundle'; -dlsrc='dl_rhapsody.xs'; +dlsrc='dl_dyld.xs'; +usedl='define'; cccdlflags=''; lddlflags="${ldflags} -bundle -undefined suppress"; +ldlibpthname='DYLD_LIBRARY_PATH'; useshrplib='true'; -libperl='Perl'; -framework_path='/System/Library/Frameworks/Perl.framework'; base_address='0x4be00000'; -# 4BSD uses /usr/share/man, not /usr/man. -# Don't put man pages in /usr/lib; that's goofy. -man1dir='/usr/share/man/man1'; -man3dir='/usr/share/man/man3'; - -# Where to put modules. -privlib='/System/Library/Perl'; -sitelib='/Local/Library/Perl'; - +## +# System libraries +## + # vfork works usevfork='true'; # malloc works usemymalloc='n'; -case "$ldlibpthname" in -'') ldlibpthname=DYLD_LIBRARY_PATH ;; -esac diff --git a/installperl b/installperl index 7c0bed7acf..920f0367b5 100755 --- a/installperl +++ b/installperl @@ -8,7 +8,7 @@ BEGIN { } use strict; -use vars qw($Is_VMS $Is_W32 $Is_OS2 $Is_Cygwin $nonono $versiononly $depth); +use vars qw($Is_VMS $Is_W32 $Is_OS2 $Is_Cygwin $nonono $dostrip $versiononly $depth); BEGIN { $Is_VMS = $^O eq 'VMS'; @@ -50,6 +50,7 @@ my $perl_verbase = defined($ENV{PERLNAME_VERBASE}) while (@ARGV) { $nonono = 1 if $ARGV[0] eq '-n'; + $dostrip = 1 if $ARGV[0] eq '-s'; $versiononly = 1 if $ARGV[0] eq '-v'; shift; } @@ -196,7 +197,7 @@ elsif ($^O eq 'mpeix') { elsif ($^O ne 'dos') { safe_unlink("$installbin/$perl_verbase$ver$exe_ext"); copy("perl$exe_ext", "$installbin/$perl_verbase$ver$exe_ext"); - strip("$installbin/$perl_verbase$ver$exe_ext") if $^O =~ /^(rhapsody)$/; + strip("$installbin/$perl_verbase$ver$exe_ext"); chmod(0755, "$installbin/$perl_verbase$ver$exe_ext"); } else { @@ -259,9 +260,9 @@ foreach my $file (@corefiles) { # HP-UX (at least) needs to maintain execute permissions # on dynamically-loadable libraries. So we do it for all. if (copy_if_diff($file,"$installarchlib/CORE/$file")) { - if ($file =~ /\.(so|\Q$dlext\E)$/) { + if ($file =~ /\.(\Q$so\E|\Q$dlext\E)$/) { chmod(0555, "$installarchlib/CORE/$file"); - strip("-S", "$installarchlib/CORE/$file") if $^O =~ /^(rhapsody)$/; + strip("-S", "$installarchlib/CORE/$file") if $^O =~ /^(rhapsody|darwin)$/; } else { chmod(0444, "$installarchlib/CORE/$file"); } @@ -651,6 +652,8 @@ sub strip { my(@args) = @_; + return unless $dostrip; + my @opts; while (@args && $args[0] =~ /^(-\w+)$/) { push @opts, shift @args; diff --git a/pp_sys.c b/pp_sys.c index 9e3ad5203f..ffe6af9ff7 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -928,7 +928,7 @@ PP(pp_sselect) /* If SELECT_MIN_BITS is greater than one we most probably will want * to align the sizes with SELECT_MIN_BITS/8 because for example * in many little-endian (Intel, Alpha) systems (Linux, OS/2, Digital - * UNIX, Solaris, NeXT, Rhapsody) the smallest quantum select() operates + * UNIX, Solaris, NeXT, Darwin) the smallest quantum select() operates * on (sets/tests/clears bits) is 32 bits. */ growsize = maxlen + (SELECT_MIN_BITS/8 - (maxlen % (SELECT_MIN_BITS/8))); # else -- cgit v1.2.1