diff options
author | Larry Wall <lwall@netlabs.com> | 1994-05-04 23:00:00 +0000 |
---|---|---|
committer | Larry Wall <lwall@netlabs.com> | 1994-05-04 23:00:00 +0000 |
commit | 85e6fe838fb25b257a1b363debf8691c0992ef71 (patch) | |
tree | fd5340cd6c3bbabfc21d3b0cac48e7ab3a481ebf /ext | |
parent | 2304df62caa7d9be70e8b8bcdb454e139c9c103d (diff) | |
download | perl-85e6fe838fb25b257a1b363debf8691c0992ef71.tar.gz |
perl 5.0 alpha 9perl-5a9
[editor's note: the sparc executables have not been included,
and emacs backup files have been removed]
Diffstat (limited to 'ext')
-rw-r--r-- | ext/dbm/ODBM_File.xs | 2 | ||||
-rwxr-xr-x | ext/dbm/SDBM_File.so | bin | 0 -> 73728 bytes | |||
l--------- | ext/dbm/perl | 1 | ||||
-rwxr-xr-x | ext/dbm/sdbm/Makefile | 47 | ||||
-rw-r--r-- | ext/dbm/sdbm/Makefile.SH | 80 | ||||
-rw-r--r-- | ext/dbm/sdbm/README.too | 6 | ||||
-rw-r--r-- | ext/dbm/sdbm/dbm.h | 4 | ||||
-rw-r--r-- | ext/dbm/sdbm/hash.c | 1 | ||||
-rw-r--r-- | ext/dbm/sdbm/libsdbm.a | bin | 0 -> 35114 bytes | |||
-rw-r--r-- | ext/dbm/sdbm/libsdbm_pure_q552_110.a | bin | 0 -> 11826 bytes | |||
-rw-r--r-- | ext/dbm/sdbm/makefile.sdbm | 55 | ||||
-rw-r--r-- | ext/dbm/sdbm/pair.c | 7 | ||||
-rw-r--r-- | ext/dbm/sdbm/sdbm.c | 28 | ||||
-rw-r--r-- | ext/dbm/sdbm/sdbm.h | 150 | ||||
-rw-r--r-- | ext/dbm/sdbm/tune.h | 11 | ||||
-rw-r--r-- | ext/dl/dl_hpux.c | 71 | ||||
-rw-r--r-- | ext/dl/dl_next.c | 69 | ||||
-rw-r--r-- | ext/dl/dl_sunos.c | 56 | ||||
-rwxr-xr-x | ext/dl/eg/test | bin | 0 -> 24576 bytes | |||
-rwxr-xr-x | ext/dl/eg/test1 | bin | 0 -> 24576 bytes | |||
-rw-r--r-- | ext/posix/POSIX.xs | 175 | ||||
-rw-r--r-- | ext/posix/typemap | 10 | ||||
-rw-r--r-- | ext/typemap | 65 |
23 files changed, 676 insertions, 162 deletions
diff --git a/ext/dbm/ODBM_File.xs b/ext/dbm/ODBM_File.xs index 74554c71e6..04d7b9e7cf 100644 --- a/ext/dbm/ODBM_File.xs +++ b/ext/dbm/ODBM_File.xs @@ -19,7 +19,9 @@ typedef void* ODBM_File; static int dbmrefcnt; +#ifndef DBM_REPLACE #define DBM_REPLACE 0 +#endif MODULE = ODBM_File PACKAGE = ODBM_File PREFIX = odbm_ diff --git a/ext/dbm/SDBM_File.so b/ext/dbm/SDBM_File.so Binary files differnew file mode 100755 index 0000000000..87f4749b2c --- /dev/null +++ b/ext/dbm/SDBM_File.so diff --git a/ext/dbm/perl b/ext/dbm/perl new file mode 120000 index 0000000000..899dc46edb --- /dev/null +++ b/ext/dbm/perl @@ -0,0 +1 @@ +../../perl
\ No newline at end of file diff --git a/ext/dbm/sdbm/Makefile b/ext/dbm/sdbm/Makefile new file mode 100755 index 0000000000..80b09cd37b --- /dev/null +++ b/ext/dbm/sdbm/Makefile @@ -0,0 +1,47 @@ +# +# This Makefile is for the library part of sdbm. For the +# Full package, see makefile.sdbm. +# +# Makefile for public domain ndbm-clone: sdbm +# DUFF: use duff's device (loop unroll) in parts of the code +# +# +CC = cc +ranlib = /usr/bin/ranlib +TOP = ../../.. +LDFLAGS = +CLDFLAGS = +SMALL = +LARGE = + +# To use an alternate make, set in config.sh. +MAKE = make + +SHELL = /bin/sh +CCCMD = `sh $(shellflags) $(TOP)/cflags $@` + +.c.o: + $(CCCMD) -I$(TOP) -DSDBM -DDUFF $*.c + +LIBOBJS = sdbm.o pair.o hash.o +LIBSRCS = sdbm.c pair.c hash.c +HDRS = tune.h sdbm.h pair.h $(TOP)/config.h + +libsdbm.a: $(LIBOBJS) + ar cr libsdbm.a $(LIBOBJS) + $(ranlib) libsdbm.a + +$(LIBOBJS): $(HDRS) + +lint: + lint -abchx $(LIBSRCS) + +clean: + rm -f *.o *.a mon.out core + +realclean: clean + rm -f dbu libsdbm.a dbd dba dbe x-dbu *.dir *.pag + rm -f makefile Makefile + +purge: realclean + diff --git a/ext/dbm/sdbm/Makefile.SH b/ext/dbm/sdbm/Makefile.SH new file mode 100644 index 0000000000..9a19fa2ed5 --- /dev/null +++ b/ext/dbm/sdbm/Makefile.SH @@ -0,0 +1,80 @@ +if test -f config.sh; then TOP=.; +elif test -f ../config.sh; then TOP=..; +elif test -f ../../config.sh; then TOP=../..; +elif test -f ../../../config.sh; then TOP=../../..; +elif test -f ../../../../config.sh; then TOP=../../../..; +else + echo "Can't find config.sh."; exit 1 +fi +case $CONFIG in +'') + . $TOP/config.sh + ;; +esac +: This forces SH files to create target in same directory as SH file. +: This is so that make depend always knows where to find SH derivatives. + +case "$0" in +*/*) cd `expr X$0 : 'X\(.*\)/'` ;; +esac + +echo "Extracting ext/dbm/sdbm/Makefile (with variable substitutions)" +: This section of the file will have variable substitutions done on it. +: Move anything that needs config subs from !NO!SUBS! section to !GROK!THIS!. +: Protect any dollar signs and backticks that you do not want interpreted +: by putting a backslash in front. You may delete these comments. +$spitshell >Makefile <<!GROK!THIS! +# +# This Makefile is for the library part of sdbm. For the +# Full package, see makefile.sdbm. +# +# Makefile for public domain ndbm-clone: sdbm +# DUFF: use duff's device (loop unroll) in parts of the code +# +# +CC = $cc +ranlib = $ranlib +TOP = $TOP +LDFLAGS = $ldflags +CLDFLAGS = $ldflags +SMALL = $small +LARGE = $large $split + +# To use an alternate make, set $altmake in config.sh. +MAKE = ${altmake-make} + +!GROK!THIS! + +: In the following dollars and backticks do not need the extra backslash. +$spitshell >>Makefile <<'!NO!SUBS!' +SHELL = /bin/sh +CCCMD = `sh $(shellflags) $(TOP)/cflags $@` + +.c.o: + $(CCCMD) -I$(TOP) -DSDBM -DDUFF $*.c + +LIBOBJS = sdbm.o pair.o hash.o +LIBSRCS = sdbm.c pair.c hash.c +HDRS = tune.h sdbm.h pair.h $(TOP)/config.h + +libsdbm.a: $(LIBOBJS) + ar cr libsdbm.a $(LIBOBJS) + $(ranlib) libsdbm.a + +$(LIBOBJS): $(HDRS) + +lint: + lint -abchx $(LIBSRCS) + +clean: + rm -f *.o *.a mon.out core + +realclean: clean + rm -f dbu libsdbm.a dbd dba dbe x-dbu *.dir *.pag + rm -f makefile Makefile + +purge: realclean + +!NO!SUBS! +chmod 755 Makefile +$eunicefix Makefile diff --git a/ext/dbm/sdbm/README.too b/ext/dbm/sdbm/README.too index d60ccf0f4b..c2d095944d 100644 --- a/ext/dbm/sdbm/README.too +++ b/ext/dbm/sdbm/README.too @@ -1,3 +1,9 @@ This version of sdbm merely has all the dbm_* names translated to sdbm_* so that we can link ndbm and sdbm into the same executable. (It also has the bad() macro redefined to allow a zero-length key.) + + +Fri Apr 15 10:15:30 EDT 1994. + +Additional portability/configuration changes for libsdbm by Andy Dougherty +doughera@lafcol.lafayette.edu. diff --git a/ext/dbm/sdbm/dbm.h b/ext/dbm/sdbm/dbm.h index dce48fed07..1196953d96 100644 --- a/ext/dbm/sdbm/dbm.h +++ b/ext/dbm/sdbm/dbm.h @@ -26,7 +26,9 @@ #define NULL ((char *) 0) #endif -#include <ndbm.h> +#ifdef I_NDBM +# include <ndbm.h> +#endif datum fetch(); datum firstkey(); diff --git a/ext/dbm/sdbm/hash.c b/ext/dbm/sdbm/hash.c index 9b55a7f571..eb585ac102 100644 --- a/ext/dbm/sdbm/hash.c +++ b/ext/dbm/sdbm/hash.c @@ -7,6 +7,7 @@ * hashing routine */ +#include "config.h" #include "sdbm.h" /* * polynomial conversion ignoring overflows diff --git a/ext/dbm/sdbm/libsdbm.a b/ext/dbm/sdbm/libsdbm.a Binary files differnew file mode 100644 index 0000000000..baf4b73942 --- /dev/null +++ b/ext/dbm/sdbm/libsdbm.a diff --git a/ext/dbm/sdbm/libsdbm_pure_q552_110.a b/ext/dbm/sdbm/libsdbm_pure_q552_110.a Binary files differnew file mode 100644 index 0000000000..3b426e8154 --- /dev/null +++ b/ext/dbm/sdbm/libsdbm_pure_q552_110.a diff --git a/ext/dbm/sdbm/makefile.sdbm b/ext/dbm/sdbm/makefile.sdbm new file mode 100644 index 0000000000..c959c1fab5 --- /dev/null +++ b/ext/dbm/sdbm/makefile.sdbm @@ -0,0 +1,55 @@ +# +# makefile for public domain ndbm-clone: sdbm +# DUFF: use duff's device (loop unroll) in parts of the code +# +CFLAGS = -O -DSDBM -DDUFF -DBSD42 -pic +#LDFLAGS = -p + +OBJS = sdbm.o pair.o hash.o +SRCS = sdbm.c pair.c hash.c dbu.c dba.c dbd.c util.c +HDRS = tune.h sdbm.h pair.h +MISC = README CHANGES COMPARE sdbm.3 dbe.c dbe.1 dbm.c dbm.h biblio \ + readme.ms readme.ps + +all: dbu dba dbd dbe + +dbu: dbu.o sdbm util.o + cc $(LDFLAGS) -o dbu dbu.o util.o libsdbm.a + +dba: dba.o util.o + cc $(LDFLAGS) -o dba dba.o util.o +dbd: dbd.o util.o + cc $(LDFLAGS) -o dbd dbd.o util.o +dbe: dbe.o sdbm + cc $(LDFLAGS) -o dbe dbe.o libsdbm.a + +sdbm: $(OBJS) + ar cr libsdbm.a $(OBJS) + ranlib libsdbm.a +### cp libsdbm.a /usr/lib/libsdbm.a + +dba.o: sdbm.h +dbu.o: sdbm.h +util.o:sdbm.h + +$(OBJS): sdbm.h tune.h pair.h + +# +# dbu using berkelezoid ndbm routines [if you have them] for testing +# +#x-dbu: dbu.o util.o +# cc $(CFLAGS) -o x-dbu dbu.o util.o +lint: + lint -abchx $(SRCS) + +clean: + rm -f *.o mon.out core + +purge: clean + rm -f dbu libsdbm.a dbd dba dbe x-dbu *.dir *.pag + +shar: + shar $(MISC) makefile $(SRCS) $(HDRS) >SDBM.SHAR + +readme: + nroff -ms readme.ms | col -b >README diff --git a/ext/dbm/sdbm/pair.c b/ext/dbm/sdbm/pair.c index a3941716d9..575b34c6c1 100644 --- a/ext/dbm/sdbm/pair.c +++ b/ext/dbm/sdbm/pair.c @@ -11,14 +11,11 @@ static char rcsid[] = "$Id: pair.c,v 1.10 90/12/13 13:00:35 oz Exp $"; #endif +#include "config.h" #include "sdbm.h" #include "tune.h" #include "pair.h" -#ifndef BSD42 -#include <memory.h> -#endif - #define exhash(item) sdbm_hash((item).dptr, (item).dsize) /* @@ -195,7 +192,7 @@ datum key; } } #else -#ifdef MEMMOVE +#ifdef HAS_MEMMOVE memmove(dst, src, m); #else while (m--) diff --git a/ext/dbm/sdbm/sdbm.c b/ext/dbm/sdbm/sdbm.c index d4ecdceb07..d09adccdd3 100644 --- a/ext/dbm/sdbm/sdbm.c +++ b/ext/dbm/sdbm/sdbm.c @@ -11,27 +11,22 @@ static char rcsid[] = "$Id: sdbm.c,v 1.16 90/12/13 13:01:31 oz Exp $"; #endif +#include "config.h" #include "sdbm.h" #include "tune.h" #include "pair.h" -#include <sys/types.h> -#include <sys/stat.h> -#ifdef BSD42 -#include <sys/file.h> -#else -#include <fcntl.h> -#include <memory.h> +#ifdef I_FCNTL +# include <fcntl.h> #endif -#include <errno.h> -#include <string.h> - -#ifdef __STDC__ -#include <stddef.h> +#ifdef I_SYS_FILE +# include <sys/file.h> #endif -#ifndef NULL -#define NULL 0 +#ifdef I_STRING +# include <string.h> +#else +# include <strings.h> #endif /* @@ -41,9 +36,9 @@ static char rcsid[] = "$Id: sdbm.c,v 1.16 90/12/13 13:01:31 oz Exp $"; extern int errno; #endif -extern char *malloc proto((unsigned int)); +extern Malloc_t malloc proto((MEM_SIZE)); extern void free proto((void *)); -extern long lseek(); +extern Off_t lseek(); /* * forward @@ -522,3 +517,4 @@ register DBM *db; return ioerr(db), nullitem; } + diff --git a/ext/dbm/sdbm/sdbm.h b/ext/dbm/sdbm/sdbm.h index e2fc762aab..f94b054999 100644 --- a/ext/dbm/sdbm/sdbm.h +++ b/ext/dbm/sdbm/sdbm.h @@ -89,3 +89,153 @@ extern long sdbm_hash proto((char *, int)); #define dbm_error sdbm_error; #define dbm_clearerr sdbm_clearerr; #endif + +/* Most of the following is stolen from perl.h. */ +#ifndef H_PERL /* Include guard */ + +/* + * The following contortions are brought to you on behalf of all the + * standards, semi-standards, de facto standards, not-so-de-facto standards + * of the world, as well as all the other botches anyone ever thought of. + * The basic theory is that if we work hard enough here, the rest of the + * code can be a lot prettier. Well, so much for theory. Sorry, Henry... + */ + +#include <errno.h> +#ifdef HAS_SOCKET +# ifdef I_NET_ERRNO +# include <net/errno.h> +# endif +#endif + +#ifdef MYMALLOC +# ifdef HIDEMYMALLOC +# define malloc Mymalloc +# define realloc Myremalloc +# define free Myfree +# endif +# define safemalloc malloc +# define saferealloc realloc +# define safefree free +#endif + +#if defined(__STDC__) || defined(_AIX) || defined(__stdc__) || defined(__cplusplus) +# define STANDARD_C 1 +#endif + +#if defined(STANDARD_C) +# define P(args) args +#else +# define P(args) () +#endif + +#include <stdio.h> +#include <ctype.h> +#include <setjmp.h> + +#ifdef I_UNISTD +#include <unistd.h> +#endif + +#ifndef MSDOS +# ifdef PARAM_NEEDS_TYPES +# include <sys/types.h> +# endif +# include <sys/param.h> +#endif + +#ifndef _TYPES_ /* If types.h defines this it's easy. */ +# ifndef major /* Does everyone's types.h define this? */ +# include <sys/types.h> +# endif +#endif + +#ifdef I_UNISTD +#include <unistd.h> +#endif + +#include <sys/stat.h> + +#ifndef SEEK_SET +# ifdef L_SET +# define SEEK_SET L_SET +# else +# define SEEK_SET 0 /* Wild guess. */ +# endif +#endif + +/* Use all the "standard" definitions? */ +#ifdef STANDARD_C +# include <stdlib.h> +# ifdef I_STRING +# include <string.h> +# endif +# define MEM_SIZE size_t +#else +# ifdef I_MEMORY +# include <memory.h> +# endif + typedef unsigned int MEM_SIZE; +#endif /* STANDARD_C */ + +#if defined(HAS_MEMCMP) && defined(mips) && defined(ultrix) +# undef HAS_MEMCMP +#endif + +#ifdef HAS_MEMCPY +# if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY) +# ifndef memcpy + extern char * memcpy P((char*, char*, int)); +# endif +# endif +#else +# ifndef memcpy +# ifdef HAS_BCOPY +# define memcpy(d,s,l) bcopy(s,d,l) +# else +# define memcpy(d,s,l) my_bcopy(s,d,l) +# endif +# endif +#endif /* HAS_MEMCPY */ + +#ifdef HAS_MEMSET +# if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY) +# ifndef memset + extern char *memset P((char*, int, int)); +# endif +# endif +# define memzero(d,l) memset(d,0,l) +#else +# ifndef memzero +# ifdef HAS_BZERO +# define memzero(d,l) bzero(d,l) +# else +# define memzero(d,l) my_bzero(d,l) +# endif +# endif +#endif /* HAS_MEMSET */ + +#ifdef HAS_MEMCMP +# if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY) +# ifndef memcmp + extern int memcmp P((char*, char*, int)); +# endif +# endif +#else +# ifndef memcmp +# define memcmp(s1,s2,l) my_memcmp(s1,s2,l) +# endif +#endif /* HAS_MEMCMP */ + +/* we prefer bcmp slightly for comparisons that don't care about ordering */ +#ifndef HAS_BCMP +# ifndef bcmp +# define bcmp(s1,s2,l) memcmp(s1,s2,l) +# endif +#endif /* HAS_BCMP */ + +#ifdef I_NETINET_IN +# include <netinet/in.h> +#endif + +#endif /* Include guard */ diff --git a/ext/dbm/sdbm/tune.h b/ext/dbm/sdbm/tune.h index 9d8a35b90b..b95c8c8634 100644 --- a/ext/dbm/sdbm/tune.h +++ b/ext/dbm/sdbm/tune.h @@ -6,17 +6,6 @@ #define BYTESIZ 8 -#ifdef SVID -#include <unistd.h> -#endif - -#ifdef BSD42 -#define SEEK_SET L_SET -#define memset(s,c,n) bzero(s, n) /* only when c is zero */ -#define memcpy(s1,s2,n) bcopy(s2, s1, n) -#define memcmp(s1,s2,n) bcmp(s1,s2,n) -#endif - /* * important tuning parms (hah) */ diff --git a/ext/dl/dl_hpux.c b/ext/dl/dl_hpux.c new file mode 100644 index 0000000000..57adcc6188 --- /dev/null +++ b/ext/dl/dl_hpux.c @@ -0,0 +1,71 @@ +/* +Date: Mon, 25 Apr 94 14:15:30 PDT +From: Jeff Okamoto <okamoto@hpcc101.corp.hp.com> +To: doughera@lafcol.lafayette.edu +Cc: okamoto@hpcc101.corp.hp.com, Jarkko.Hietaniemi@hut.fi, ram@acri.fr, + john@WPI.EDU, k@franz.ww.TU-Berlin.DE, dmm0t@rincewind.mech.virginia.edu, + lwall@netlabs.com +Subject: dl.c.hpux + +This is what I hacked around and came up with for HP-UX. (Or maybe it should +be called dl_hpux.c). Notice the change in suffix from .so to .sl (the +default suffix for HP-UX shared libraries). + +Jeff +*/ +#include <dl.h> + +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" + +static int +XS_DynamicLoader_bootstrap(ix, ax, items) +register int ix; +register int ax; +register int items; +{ + if (items < 1 || items > 1) { + croak("Usage: DynamicLoader::bootstrap(package)"); + } + { + char* package = SvPV(ST(1),na); + shl_t obj = NULL; + int (*bootproc)(); + char tmpbuf[1024]; + char tmpbuf2[128]; + AV *av = GvAVn(incgv); + I32 i; + + for (i = 0; i <= AvFILL(av); i++) { + (void)sprintf(tmpbuf, "%s/auto/%s/%s.sl", + SvPVx(*av_fetch(av, i, TRUE), na), package, package); + if (obj = shl_load(tmpbuf, + BIND_IMMEDIATE | BIND_NONFATAL | BIND_NOSTART,0L)) + break; + } + if (obj != (shl_t) NULL) + croak("Can't find loadable object for package %s in @INC", package); + + sprintf(tmpbuf2, "boot_%s", package); + i = shl_findsym(&obj, tmpbuf2, TYPE_PROCEDURE, &bootproc); + if (i == -1) + croak("Shared object %s contains no %s function", tmpbuf, tmpbuf2); + bootproc(); + + ST(0) = sv_mortalcopy(&sv_yes); + } + return ax; +} + +int +boot_DynamicLoader(ix,sp,items) +int ix; +int sp; +int items; +{ + char* file = __FILE__; + + newXSUB("DynamicLoader::bootstrap", 0, XS_DynamicLoader_bootstrap, file); +} + diff --git a/ext/dl/dl_next.c b/ext/dl/dl_next.c new file mode 100644 index 0000000000..66e95121de --- /dev/null +++ b/ext/dl/dl_next.c @@ -0,0 +1,69 @@ +/* dl_next.c + Author: tom@smart.bo.open.de (Thomas Neumann). + Based on dl_sunos.c +*/ +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" + +#include <mach-o/rld.h> +#include <streams/streams.h> + +static int +XS_DynamicLoader_bootstrap(ix, ax, items) +register int ix; +register int ax; +register int items; +{ + if (items < 1 || items > 1) { + croak("Usage: DynamicLoader::bootstrap(package)"); + } + { + char* package = SvPV(ST(1),na); + int rld_success; + NXStream *nxerr = NXOpenFile(fileno(stderr), NX_READONLY); + int (*bootproc)(); + char tmpbuf[1024]; + char tmpbuf2[128]; + AV *av = GvAVn(incgv); + I32 i; + + for (i = 0; i <= AvFILL(av); i++) { + char *p[2]; + p[0] = tmpbuf; + p[1] = 0; + sprintf(tmpbuf, "%s/auto/%s/%s.so", + SvPVx(*av_fetch(av, i, TRUE), na), package, package); + if (rld_success = rld_load(nxerr, (struct mach_header **)0, p, + (const char *)0)) + { + break; + } + } + if (!rld_success) { + NXClose(nxerr); + croak("Can't find loadable object for package %s in @INC", package); + + } + sprintf(tmpbuf2, "_boot_%s", package); + if (!rld_lookup(nxerr, tmpbuf2, (unsigned long *)&bootproc)) { + NXClose(nxerr); + croak("Shared object %s contains no %s function", tmpbuf, tmpbuf2); + } + NXClose(nxerr); + (*bootproc)(); + ST(0) = sv_mortalcopy(&sv_yes); + } + return ax; +} + +int +boot_DynamicLoader(ix,sp,items) +int ix; +int sp; +int items; +{ + char* file = __FILE__; + + newXSUB("DynamicLoader::bootstrap", 0, XS_DynamicLoader_bootstrap, file); +} diff --git a/ext/dl/dl_sunos.c b/ext/dl/dl_sunos.c new file mode 100644 index 0000000000..badd66d678 --- /dev/null +++ b/ext/dl/dl_sunos.c @@ -0,0 +1,56 @@ +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" + +#ifdef I_DLFCN +# include <dlfcn.h> +#endif + +static int +XS_DynamicLoader_bootstrap(ix, ax, items) +register int ix; +register int ax; +register int items; +{ + if (items < 1 || items > 1) { + croak("Usage: DynamicLoader::bootstrap(package)"); + } + { + char* package = SvPV(ST(1),na); + void* obj = 0; + int (*bootproc)(); + char tmpbuf[1024]; + char tmpbuf2[128]; + AV *av = GvAVn(incgv); + I32 i; + + for (i = 0; i <= AvFILL(av); i++) { + (void)sprintf(tmpbuf, "%s/auto/%s/%s.so", + SvPVx(*av_fetch(av, i, TRUE), na), package, package); + if (obj = dlopen(tmpbuf,1)) + break; + } + if (!obj) + croak("Can't find loadable object for package %s in @INC", package); + + sprintf(tmpbuf2, "boot_%s", package); + bootproc = (int (*)())dlsym(obj, tmpbuf2); + if (!bootproc) + croak("Shared object %s contains no %s function", tmpbuf, tmpbuf2); + bootproc(); + + ST(0) = sv_mortalcopy(&sv_yes); + } + return ax; +} + +int +boot_DynamicLoader(ix,sp,items) +int ix; +int sp; +int items; +{ + char* file = __FILE__; + + newXSUB("DynamicLoader::bootstrap", 0, XS_DynamicLoader_bootstrap, file); +} diff --git a/ext/dl/eg/test b/ext/dl/eg/test Binary files differnew file mode 100755 index 0000000000..2a8b92570e --- /dev/null +++ b/ext/dl/eg/test diff --git a/ext/dl/eg/test1 b/ext/dl/eg/test1 Binary files differnew file mode 100755 index 0000000000..e9a37e9e53 --- /dev/null +++ b/ext/dl/eg/test1 diff --git a/ext/posix/POSIX.xs b/ext/posix/POSIX.xs index 0c48b9ef52..a439494dac 100644 --- a/ext/posix/POSIX.xs +++ b/ext/posix/POSIX.xs @@ -13,7 +13,9 @@ #include <limits.h> #include <locale.h> #include <math.h> +#ifdef I_PWD #include <pwd.h> +#endif #include <setjmp.h> #include <signal.h> #ifdef I_STDARG @@ -30,7 +32,7 @@ #include <sys/types.h> #include <sys/utsname.h> #include <sys/wait.h> -#ifndef CR3 +#if defined(I_TERMIOS) && !defined(CR3) #include <termios.h> #endif #include <time.h> @@ -44,7 +46,7 @@ typedef HV* POSIX__SigAction; #define HAS_UNAME #ifndef HAS_GETPGRP -#define getpgrp(a,b) not_here("getpgrp") +#define getpgrp() not_here("getpgrp") #endif #ifndef HAS_NICE #define nice(a) not_here("nice") @@ -55,9 +57,6 @@ typedef HV* POSIX__SigAction; #ifndef HAS_SETPGID #define setpgid(a,b) not_here("setpgid") #endif -#ifndef HAS_SETPGRP -#define setpgrp(a,b) not_here("setpgrp") -#endif #ifndef HAS_SETSID #define setsid() not_here("setsid") #endif @@ -2090,7 +2089,7 @@ isalnum(charstring) CODE: char *s; RETVAL = 1; - for (s = charstring; *s; s++) + for (s = charstring; *s && RETVAL; s++) if (!isalnum(*s)) RETVAL = 0; OUTPUT: @@ -2102,7 +2101,7 @@ isalpha(charstring) CODE: char *s; RETVAL = 1; - for (s = charstring; *s; s++) + for (s = charstring; *s && RETVAL; s++) if (!isalpha(*s)) RETVAL = 0; OUTPUT: @@ -2114,7 +2113,7 @@ iscntrl(charstring) CODE: char *s; RETVAL = 1; - for (s = charstring; *s; s++) + for (s = charstring; *s && RETVAL; s++) if (!iscntrl(*s)) RETVAL = 0; OUTPUT: @@ -2126,7 +2125,7 @@ isdigit(charstring) CODE: char *s; RETVAL = 1; - for (s = charstring; *s; s++) + for (s = charstring; *s && RETVAL; s++) if (!isdigit(*s)) RETVAL = 0; OUTPUT: @@ -2138,7 +2137,7 @@ isgraph(charstring) CODE: char *s; RETVAL = 1; - for (s = charstring; *s; s++) + for (s = charstring; *s && RETVAL; s++) if (!isgraph(*s)) RETVAL = 0; OUTPUT: @@ -2150,7 +2149,7 @@ islower(charstring) CODE: char *s; RETVAL = 1; - for (s = charstring; *s; s++) + for (s = charstring; *s && RETVAL; s++) if (!islower(*s)) RETVAL = 0; OUTPUT: @@ -2162,7 +2161,7 @@ isprint(charstring) CODE: char *s; RETVAL = 1; - for (s = charstring; *s; s++) + for (s = charstring; *s && RETVAL; s++) if (!isprint(*s)) RETVAL = 0; OUTPUT: @@ -2174,7 +2173,7 @@ ispunct(charstring) CODE: char *s; RETVAL = 1; - for (s = charstring; *s; s++) + for (s = charstring; *s && RETVAL; s++) if (!ispunct(*s)) RETVAL = 0; OUTPUT: @@ -2186,7 +2185,7 @@ isspace(charstring) CODE: char *s; RETVAL = 1; - for (s = charstring; *s; s++) + for (s = charstring; *s && RETVAL; s++) if (!isspace(*s)) RETVAL = 0; OUTPUT: @@ -2198,7 +2197,7 @@ isupper(charstring) CODE: char *s; RETVAL = 1; - for (s = charstring; *s; s++) + for (s = charstring; *s && RETVAL; s++) if (!isupper(*s)) RETVAL = 0; OUTPUT: @@ -2210,7 +2209,7 @@ isxdigit(charstring) CODE: char *s; RETVAL = 1; - for (s = charstring; *s; s++) + for (s = charstring; *s && RETVAL; s++) if (!isxdigit(*s)) RETVAL = 0; OUTPUT: @@ -2370,7 +2369,7 @@ sigaction(sig, action, oldaction = 0) # interface look beautiful, which is hard. if (!siggv) - gv_fetchpv("SIG", TRUE); + gv_fetchpv("SIG", TRUE, SVt_PVHV); { struct sigaction act; @@ -2406,7 +2405,7 @@ sigaction(sig, action, oldaction = 0) act.sa_mask = *sigset; } else - sigemptyset(act.sa_mask); + sigemptyset(& act.sa_mask); /* Set up any desired flags. */ svp = hv_fetch(action, "FLAGS", 5, FALSE); @@ -2415,11 +2414,11 @@ sigaction(sig, action, oldaction = 0) /* Now work around sigaction oddities */ if (action && oldaction) - RETVAL = sigaction(sig, act, oact); + RETVAL = sigaction(sig, & act, & oact); else if (action) - RETVAL = sigaction(sig, act, (struct sigaction*)0); + RETVAL = sigaction(sig, & act, (struct sigaction*)0); else if (oldaction) - RETVAL = sigaction(sig, (struct sigaction*)0, oact); + RETVAL = sigaction(sig, (struct sigaction*)0, & oact); if (oldaction) { /* Get back the mask. */ @@ -2473,135 +2472,99 @@ void _exit(status) int status -int +SysRet close(fd) int fd -int +SysRet dup(fd) int fd -int +SysRet dup2(fd1, fd2) int fd1 int fd2 -int -fstat(fd, buf) - int fd - struct stat * buf = (struct stat*)sv_grow(ST(2),sizeof(struct stat)); - CLEANUP: - SvCUR(ST(2)) = sizeof(struct stat); - -int -getpgrp(pid) - int pid - -int -link() - -int +SysRet lseek() + int fd + Off_t offset + int whence -int -lstat() - -int -mkdir() - -int +SysRet nice(incr) int incr int pipe() + PPCODE: + int fds[2]; + sp--; + if (pipe(fds) != -1) { + EXTEND(sp,2); + PUSHs(sv_2mortal(newSViv(fds[0]))); + PUSHs(sv_2mortal(newSViv(fds[1]))); + } -int +SysRet read() + CODE: + int fd; + char * buffer; + size_t nbytes; -int -rename() - -int -rmdir() + RETVAL = read(fd, buffer, nbytes); + croak("POSIX::read() not implemented yet\n"); + OUTPUT: + RETVAL -int -setgid() +SysRet +setgid(gid) + Gid_t gid -int +SysRet setpgid(pid, pgid) pid_t pid pid_t pgid -int -setpgrp(pid, pgrp) - int pid - int pgrp - pid_t setsid() -int -setuid() - -int -stat() - -int -symlink() - -int -system() +SysRet +setuid(uid) + Uid_t uid pid_t tcgetpgrp(fd) int fd -int +SysRet tcsetpgrp(fd, pgrp_id) int fd pid_t pgrp_id int -times(tms) - struct tms * tms = (struct tms*)sv_grow(ST(1), sizeof(struct tms)); - CLEANUP: - SvCUR(ST(1)) = sizeof(struct tms); - -int -umask() - -void uname() PPCODE: - struct utsname utsname; + struct utsname buf; sp--; - if (uname(&utsname) >= 0) { + if (uname(&buf) >= 0) { EXTEND(sp, 5); - PUSHs(sv_2mortal(newSVpv(utsname.sysname, 0))); - PUSHs(sv_2mortal(newSVpv(utsname.nodename, 0))); - PUSHs(sv_2mortal(newSVpv(utsname.release, 0))); - PUSHs(sv_2mortal(newSVpv(utsname.version, 0))); - PUSHs(sv_2mortal(newSVpv(utsname.machine, 0))); + PUSHs(sv_2mortal(newSVpv(buf.sysname, 0))); + PUSHs(sv_2mortal(newSVpv(buf.nodename, 0))); + PUSHs(sv_2mortal(newSVpv(buf.release, 0))); + PUSHs(sv_2mortal(newSVpv(buf.version, 0))); + PUSHs(sv_2mortal(newSVpv(buf.machine, 0))); } -int -unlink() - -int -utime() - -int -wait() - -int -waitpid(pid, statusp, options) - int pid - int &statusp - int options - OUTPUT: - statusp - -int +SysRet write() + CODE: + int fd; + char * buffer; + size_t nbytes; + RETVAL = write(fd, buffer, nbytes); + croak("POSIX::write() not implemented yet\n"); + OUTPUT: + RETVAL diff --git a/ext/posix/typemap b/ext/posix/typemap index 4cf2975c9d..e339f10c49 100644 --- a/ext/posix/typemap +++ b/ext/posix/typemap @@ -1,6 +1,10 @@ -mode_t T_INT -pid_t T_INT -fd T_INT +mode_t T_NV +pid_t T_NV +Uid_t T_NV +Time_t T_NV +Gid_t T_NV +Off_t T_NV +fd T_IV FILE * T_PTR FileHandle T_PTROBJ POSIX::SigSet T_PTROBJ diff --git a/ext/typemap b/ext/typemap index 24895dc890..1d0c9baef3 100644 --- a/ext/typemap +++ b/ext/typemap @@ -1,13 +1,14 @@ # $Header$ # basic C types -int T_INT -unsigned T_U_INT -unsigned int T_U_INT -long T_LONG -unsigned long T_U_LONG -short T_SHORT -unsigned short T_U_SHORT +int T_IV +unsigned T_IV +unsigned int T_IV +long T_NV +unsigned long T_NV +short T_IV +unsigned short T_IV char T_CHAR +unsigned char T_U_CHAR char * T_STRING unsigned char * T_STRING caddr_t T_STRING @@ -20,10 +21,12 @@ AV * T_AVOBJ HV * T_HVOBJ CV * T_CVOBJ -I32 T_LONG -I16 T_SHORT +I32 T_IV +I16 T_IV +I8 T_IV U32 T_U_LONG U16 T_U_SHORT +U8 T_IV Result T_U_CHAR Boolean T_U_CHAR double T_DOUBLE @@ -55,6 +58,8 @@ T_CVOBJ croak(\"$var is not of type ${ntype}\") T_SYSRET $var NOT IMPLEMENTED +T_IV + $var = ($type)SvIV($arg) T_INT $var = (int)SvIV($arg) T_ENUM @@ -75,37 +80,53 @@ T_U_CHAR $var = (unsigned char)SvIV($arg) T_FLOAT $var = (float)SvNV($arg) +T_NV + $var = ($type)SvNV($arg) T_DOUBLE - $var = SvNV($arg) + $var = (double)SvNV($arg) T_STRING $var = SvPV($arg,na) T_PTR $var = ($type)(unsigned long)SvNV($arg) T_PTRREF - if (SvROK($arg)) - $var = ($type)(unsigned long)SvNV((SV*)SvRV($arg)); + if (SvROK($arg)) { + unsigned long tmp; + tmp = (unsigned long)SvNV((SV*)SvRV($arg)); + $var = ($type) tmp; + } else croak(\"$var is not a reference\") T_PTROBJ - if (sv_isa($arg, \"${ntype}\")) - $var = ($type)(unsigned long)SvNV((SV*)SvRV($arg)); + if (sv_isa($arg, \"${ntype}\")) { + unsigned long tmp; + tmp = (unsigned long)SvNV((SV*)SvRV($arg)); + $var = ($type) tmp; + } else croak(\"$var is not of type ${ntype}\") T_PTRDESC if (sv_isa($arg, \"${ntype}\")) { - ${type}_desc = (\U${type}_DESC\E*)(unsigned long)SvNV((SV*)SvRV($arg)); + unsigned long tmp; + tmp = (unsigned long)SvNV((SV*)SvRV($arg)); + ${type}_desc = (\U${type}_DESC\E*) tmp; $var = ${type}_desc->ptr; } else croak(\"$var is not of type ${ntype}\") T_REFREF - if (SvROK($arg)) - $var = *($type)(unsigned long)SvNV((SV*)SvRV($arg)); + if (SvROK($arg)) { + unsigned long tmp; + tmp = (unsigned long)SvNV((SV*)SvRV($arg)); + $var = *($type) tmp; + } else croak(\"$var is not a reference\") T_REFOBJ - if (sv_isa($arg, \"${ntype}\")) - $var = *($type)(unsigned long)SvNV((SV*)SvRV($arg)); + if (sv_isa($arg, \"${ntype}\")) { + unsigned long tmp; + tmp = (unsigned long)SvNV((SV*)SvRV($arg)); + $var = *($type) tmp; + } else croak(\"$var is not of type ${ntype}\") T_OPAQUE @@ -136,6 +157,8 @@ T_HVOBJ $arg = newRV((SV*)$var); T_CVOBJ $arg = newRV((SV*)$var); +T_IV + sv_setiv($arg, (I32)$var); T_INT sv_setiv($arg, (I32)$var); T_SYSRET @@ -163,8 +186,10 @@ T_U_CHAR sv_setiv($arg, (I32)$var); T_FLOAT sv_setnv($arg, (double)$var); +T_NV + sv_setnv($arg, (double)$var); T_DOUBLE - sv_setnv($arg, $var); + sv_setnv($arg, (double)$var); T_STRING sv_setpv($arg, $var); T_PTR |