diff options
-rw-r--r-- | INTERN.h | 7 | ||||
-rw-r--r-- | embed.h | 5 | ||||
-rw-r--r-- | ext/DynaLoader/dl_dlopen.xs | 2 | ||||
-rw-r--r-- | ext/Fcntl/Fcntl.xs | 7 | ||||
-rw-r--r-- | ext/GDBM_File/GDBM_File.xs | 9 | ||||
-rw-r--r-- | ext/IO/IO.xs | 7 | ||||
-rw-r--r-- | ext/Opcode/Opcode.xs | 32 | ||||
-rw-r--r-- | ext/POSIX/POSIX.xs | 7 | ||||
-rw-r--r-- | ext/SDBM_File/sdbm/hash.c | 4 | ||||
-rw-r--r-- | ext/SDBM_File/sdbm/pair.c | 45 | ||||
-rw-r--r-- | ext/SDBM_File/sdbm/sdbm.c | 66 | ||||
-rw-r--r-- | ext/SDBM_File/sdbm/sdbm.h | 6 | ||||
-rw-r--r-- | ext/SDBM_File/sdbm/util.c | 7 | ||||
-rw-r--r-- | ext/Socket/Socket.xs | 11 | ||||
-rw-r--r-- | ext/Thread/Thread.xs | 94 | ||||
-rw-r--r-- | ext/attrs/attrs.xs | 7 | ||||
-rw-r--r-- | global.sym | 2 | ||||
-rw-r--r-- | perl.h | 2 | ||||
-rw-r--r-- | perly.c | 9 | ||||
-rw-r--r-- | sv.c | 7 | ||||
-rwxr-xr-x | t/lib/english.t | 4 | ||||
-rwxr-xr-x | t/op/misc.t | 9 | ||||
-rw-r--r-- | thread.h | 5 | ||||
-rw-r--r-- | util.c | 36 | ||||
-rw-r--r-- | win32/Makefile | 2 | ||||
-rw-r--r-- | win32/makedef.pl | 60 | ||||
-rw-r--r-- | win32/makefile.mk | 48 | ||||
-rw-r--r-- | x2p/a2p.c | 2 | ||||
-rw-r--r-- | x2p/a2p.h | 4 | ||||
-rw-r--r-- | x2p/a2py.c | 105 | ||||
-rw-r--r-- | x2p/hash.c | 26 | ||||
-rw-r--r-- | x2p/str.c | 84 | ||||
-rw-r--r-- | x2p/util.c | 41 | ||||
-rw-r--r-- | x2p/walk.c | 36 |
34 files changed, 348 insertions, 450 deletions
@@ -23,11 +23,18 @@ # define EXTCONST globaldef {"$GLOBAL_RO_VARS"} readonly # define dEXTCONST globaldef {"$GLOBAL_RO_VARS"} readonly #else +# ifdef __cplusplus +# define EXT +# define dEXT +# define EXTCONST extern const +# define dEXTCONST const +#else # define EXT # define dEXT # define EXTCONST const # define dEXTCONST const #endif +#endif #undef INIT #define INIT(x) = x @@ -282,6 +282,7 @@ #define inc_amg Perl_inc_amg #define ingroup Perl_ingroup #define init_stacks Perl_init_stacks +#define init_thread_intern Perl_init_thread_intern #define instr Perl_instr #define intro_my Perl_intro_my #define intuit_more Perl_intuit_more @@ -479,6 +480,8 @@ #define nomemok Perl_nomemok #define nomethod_amg Perl_nomethod_amg #define not_amg Perl_not_amg +#define nthreads Perl_nthreads +#define nthreads_cond Perl_nthreads_cond #define numer_amg Perl_numer_amg #define numeric_local Perl_numeric_local #define numeric_name Perl_numeric_name @@ -1090,6 +1093,8 @@ #define taint_env Perl_taint_env #define taint_proper Perl_taint_proper #define thisexpr Perl_thisexpr +#define thr_key Perl_thr_key +#define threads_mutex Perl_threads_mutex #define timesbuf Perl_timesbuf #define tokenbuf Perl_tokenbuf #define too_few_arguments Perl_too_few_arguments diff --git a/ext/DynaLoader/dl_dlopen.xs b/ext/DynaLoader/dl_dlopen.xs index fef4530cfe..2459205653 100644 --- a/ext/DynaLoader/dl_dlopen.xs +++ b/ext/DynaLoader/dl_dlopen.xs @@ -206,7 +206,7 @@ dl_install_xsub(perl_name, symref, filename="$Package") CODE: DLDEBUG(2,PerlIO_printf(PerlIO_stderr(), "dl_install_xsub(name=%s, symref=%lx)\n", perl_name, (unsigned long) symref)); - ST(0)=sv_2mortal(newRV((SV*)newXS(perl_name, (void(*)())symref, filename))); + ST(0)=sv_2mortal(newRV((SV*)newXS(perl_name, (void(*)_((CV *)))symref, filename))); char * diff --git a/ext/Fcntl/Fcntl.xs b/ext/Fcntl/Fcntl.xs index 9034031c9c..251f3f4176 100644 --- a/ext/Fcntl/Fcntl.xs +++ b/ext/Fcntl/Fcntl.xs @@ -23,17 +23,14 @@ */ static int -not_here(s) -char *s; +not_here(char *s) { croak("%s not implemented on this architecture", s); return -1; } static double -constant(name, arg) -char *name; -int arg; +constant(char *name, int arg) { errno = 0; switch (*name) { diff --git a/ext/GDBM_File/GDBM_File.xs b/ext/GDBM_File/GDBM_File.xs index a423c88c70..d3305ec38d 100644 --- a/ext/GDBM_File/GDBM_File.xs +++ b/ext/GDBM_File/GDBM_File.xs @@ -20,11 +20,10 @@ typedef GDBM_FILE GDBM_File; typedef datum gdatum; -typedef void (*FATALFUNC)(); +typedef void (*FATALFUNC)(...); static int -not_here(s) -char *s; +not_here(char *s) { croak("GDBM_File::%s not implemented on this architecture", s); return -1; @@ -41,9 +40,7 @@ char *s; #endif static double -constant(name, arg) -char *name; -int arg; +constant(char *name, int arg) { errno = 0; switch (*name) { diff --git a/ext/IO/IO.xs b/ext/IO/IO.xs index e558d5c4e0..f226a79a9f 100644 --- a/ext/IO/IO.xs +++ b/ext/IO/IO.xs @@ -22,17 +22,14 @@ typedef FILE * OutputStream; #endif static int -not_here(s) -char *s; +not_here(char *s) { croak("%s not implemented on this architecture", s); return -1; } static bool -constant(name, pval) -char *name; -IV *pval; +constant(char *name, IV *pval) { switch (*name) { case '_': diff --git a/ext/Opcode/Opcode.xs b/ext/Opcode/Opcode.xs index 8307ade2ca..bed7099900 100644 --- a/ext/Opcode/Opcode.xs +++ b/ext/Opcode/Opcode.xs @@ -24,7 +24,7 @@ static SV *get_op_bitspec _((char *opname, STRLEN len, int fatal)); */ static void -op_names_init() +op_names_init(void) { int i; STRLEN len; @@ -58,10 +58,7 @@ op_names_init() */ static void -put_op_bitspec(optag, len, mask) - char *optag; - STRLEN len; - SV *mask; +put_op_bitspec(char *optag, STRLEN len, SV *mask) { SV **svp; verify_opset(mask,1); @@ -82,10 +79,7 @@ put_op_bitspec(optag, len, mask) */ static SV * -get_op_bitspec(opname, len, fatal) - char *opname; - STRLEN len; - int fatal; +get_op_bitspec(char *opname, STRLEN len, int fatal) { SV **svp; if (!len) @@ -108,8 +102,7 @@ get_op_bitspec(opname, len, fatal) static SV * -new_opset(old_opset) - SV *old_opset; +new_opset(SV *old_opset) { SV *opset; if (old_opset) { @@ -128,9 +121,7 @@ new_opset(old_opset) static int -verify_opset(opset, fatal) - SV *opset; - int fatal; +verify_opset(SV *opset, int fatal) { char *err = Nullch; if (!SvOK(opset)) err = "undefined"; @@ -144,11 +135,7 @@ verify_opset(opset, fatal) static void -set_opset_bits(bitmap, bitspec, on, opname) - char *bitmap; - SV *bitspec; - int on; - char *opname; +set_opset_bits(char *bitmap, SV *bitspec, int on, char *opname) { if (SvIOK(bitspec)) { int myopcode = SvIV(bitspec); @@ -182,8 +169,7 @@ set_opset_bits(bitmap, bitspec, on, opname) static void -opmask_add(opset) /* THE ONLY FUNCTION TO EDIT op_mask ITSELF */ - SV *opset; +opmask_add(SV *opset) /* THE ONLY FUNCTION TO EDIT op_mask ITSELF */ { int i,j; char *bitmask; @@ -210,9 +196,7 @@ opmask_add(opset) /* THE ONLY FUNCTION TO EDIT op_mask ITSELF */ } static void -opmask_addlocal(opset, op_mask_buf) /* Localise op_mask then opmask_add() */ - SV *opset; - char *op_mask_buf; +opmask_addlocal(SV *opset, char *op_mask_buf) /* Localise op_mask then opmask_add() */ { char *orig_op_mask = op_mask; SAVEPPTR(op_mask); diff --git a/ext/POSIX/POSIX.xs b/ext/POSIX/POSIX.xs index 0e53a49183..57efb83a42 100644 --- a/ext/POSIX/POSIX.xs +++ b/ext/POSIX/POSIX.xs @@ -275,17 +275,14 @@ init_tm(ptm) /* see mktime, strftime and asctime */ #endif static int -not_here(s) -char *s; +not_here(char *s) { croak("POSIX::%s not implemented on this architecture", s); return -1; } static double -constant(name, arg) -char *name; -int arg; +constant(char *name, int arg) { errno = 0; switch (*name) { diff --git a/ext/SDBM_File/sdbm/hash.c b/ext/SDBM_File/sdbm/hash.c index eb585ac102..514bb5ed1a 100644 --- a/ext/SDBM_File/sdbm/hash.c +++ b/ext/SDBM_File/sdbm/hash.c @@ -17,9 +17,7 @@ * 65587 even better. */ long -sdbm_hash(str, len) -register char *str; -register int len; +sdbm_hash(register char *str, register int len) { register unsigned long n = 0; diff --git a/ext/SDBM_File/sdbm/pair.c b/ext/SDBM_File/sdbm/pair.c index 23bbfe9a67..e1a6ee6f43 100644 --- a/ext/SDBM_File/sdbm/pair.c +++ b/ext/SDBM_File/sdbm/pair.c @@ -44,9 +44,7 @@ static int seepair proto((char *, int, char *, int)); */ int -fitpair(pag, need) -char *pag; -int need; +fitpair(char *pag, int need) { register int n; register int off; @@ -63,10 +61,7 @@ int need; } void -putpair(pag, key, val) -char *pag; -datum key; -datum val; +putpair(char *pag, datum key, datum val) { register int n; register int off; @@ -92,9 +87,7 @@ datum val; } datum -getpair(pag, key) -char *pag; -datum key; +getpair(char *pag, datum key) { register int i; register int n; @@ -114,9 +107,7 @@ datum key; #ifdef SEEDUPS int -duppair(pag, key) -char *pag; -datum key; +duppair(char *pag, datum key) { register short *ino = (short *) pag; return ino[0] > 0 && seepair(pag, ino[0], key.dptr, key.dsize) > 0; @@ -124,9 +115,7 @@ datum key; #endif datum -getnkey(pag, num) -char *pag; -int num; +getnkey(char *pag, int num) { datum key; register int off; @@ -145,9 +134,7 @@ int num; } int -delpair(pag, key) -char *pag; -datum key; +delpair(char *pag, datum key) { register int n; register int i; @@ -219,11 +206,7 @@ datum key; * return 0 if not found. */ static int -seepair(pag, n, key, siz) -char *pag; -register int n; -register char *key; -register int siz; +seepair(char *pag, register int n, register char *key, register int siz) { register int i; register int off = PBLKSIZ; @@ -239,10 +222,7 @@ register int siz; } void -splpage(pag, new, sbit) -char *pag; -char *new; -long sbit; +splpage(char *pag, char *New, long int sbit) { datum key; datum val; @@ -254,7 +234,7 @@ long sbit; (void) memcpy(cur, pag, PBLKSIZ); (void) memset(pag, 0, PBLKSIZ); - (void) memset(new, 0, PBLKSIZ); + (void) memset(New, 0, PBLKSIZ); n = ino[0]; for (ino++; n > 0; ino += 2) { @@ -265,14 +245,14 @@ long sbit; /* * select the page pointer (by looking at sbit) and insert */ - (void) putpair((exhash(key) & sbit) ? new : pag, key, val); + (void) putpair((exhash(key) & sbit) ? New : pag, key, val); off = ino[1]; n -= 2; } debug(("%d split %d/%d\n", ((short *) cur)[0] / 2, - ((short *) new)[0] / 2, + ((short *) New)[0] / 2, ((short *) pag)[0] / 2)); } @@ -283,8 +263,7 @@ long sbit; * this could be made more rigorous. */ int -chkpage(pag) -char *pag; +chkpage(char *pag) { register int n; register int off; diff --git a/ext/SDBM_File/sdbm/sdbm.c b/ext/SDBM_File/sdbm/sdbm.c index c2d9cbd47d..7fbba0f00a 100644 --- a/ext/SDBM_File/sdbm/sdbm.c +++ b/ext/SDBM_File/sdbm/sdbm.c @@ -39,7 +39,7 @@ extern int errno; extern Malloc_t malloc proto((MEM_SIZE)); extern Free_t free proto((Malloc_t)); -extern Off_t lseek(); +extern Off_t lseek(int, off_t, int); #endif /* @@ -75,10 +75,7 @@ static long masks[] = { datum nullitem = {NULL, 0}; DBM * -sdbm_open(file, flags, mode) -register char *file; -register int flags; -register int mode; +sdbm_open(register char *file, register int flags, register int mode) { register DBM *db; register char *dirname; @@ -92,7 +89,7 @@ register int mode; */ n = strlen(file) * 2 + strlen(DIRFEXT) + strlen(PAGFEXT) + 2; - if ((dirname = malloc((unsigned) n)) == NULL) + if ((dirname = (char *) malloc((unsigned) n)) == NULL) return errno = ENOMEM, (DBM *) NULL; /* * build the file names @@ -107,11 +104,7 @@ register int mode; } DBM * -sdbm_prep(dirname, pagname, flags, mode) -char *dirname; -char *pagname; -int flags; -int mode; +sdbm_prep(char *dirname, char *pagname, int flags, int mode) { register DBM *db; struct stat dstat; @@ -170,8 +163,7 @@ int mode; } void -sdbm_close(db) -register DBM *db; +sdbm_close(register DBM *db) { if (db == NULL) errno = EINVAL; @@ -183,9 +175,7 @@ register DBM *db; } datum -sdbm_fetch(db, key) -register DBM *db; -datum key; +sdbm_fetch(register DBM *db, datum key) { if (db == NULL || bad(key)) return errno = EINVAL, nullitem; @@ -197,9 +187,7 @@ datum key; } int -sdbm_delete(db, key) -register DBM *db; -datum key; +sdbm_delete(register DBM *db, datum key) { if (db == NULL || bad(key)) return errno = EINVAL, -1; @@ -223,11 +211,7 @@ datum key; } int -sdbm_store(db, key, val, flags) -register DBM *db; -datum key; -datum val; -int flags; +sdbm_store(register DBM *db, datum key, datum val, int flags) { int need; register long hash; @@ -285,22 +269,19 @@ int flags; * giving up. */ static int -makroom(db, hash, need) -register DBM *db; -long hash; -int need; +makroom(register DBM *db, long int hash, int need) { long newp; char twin[PBLKSIZ]; char *pag = db->pagbuf; - char *new = twin; + char *New = twin; register int smax = SPLTMAX; do { /* * split the current page */ - (void) splpage(pag, new, db->hmask + 1); + (void) splpage(pag, New, db->hmask + 1); /* * address of the new page */ @@ -319,10 +300,10 @@ int need; || write(db->pagf, db->pagbuf, PBLKSIZ) < 0) return 0; db->pagbno = newp; - (void) memcpy(pag, new, PBLKSIZ); + (void) memcpy(pag, New, PBLKSIZ); } else if (lseek(db->pagf, OFF_PAG(newp), SEEK_SET) < 0 - || write(db->pagf, new, PBLKSIZ) < 0) + || write(db->pagf, New, PBLKSIZ) < 0) return 0; if (!setdbit(db, db->curbit)) @@ -363,8 +344,7 @@ int need; * deletions aren't taken into account. (ndbm bug) */ datum -sdbm_firstkey(db) -register DBM *db; +sdbm_firstkey(register DBM *db) { if (db == NULL) return errno = EINVAL, nullitem; @@ -382,8 +362,7 @@ register DBM *db; } datum -sdbm_nextkey(db) -register DBM *db; +sdbm_nextkey(register DBM *db) { if (db == NULL) return errno = EINVAL, nullitem; @@ -394,9 +373,7 @@ register DBM *db; * all important binary trie traversal */ static int -getpage(db, hash) -register DBM *db; -register long hash; +getpage(register DBM *db, register long int hash) { register int hbit; register long dbit; @@ -435,9 +412,7 @@ register long hash; } static int -getdbit(db, dbit) -register DBM *db; -register long dbit; +getdbit(register DBM *db, register long int dbit) { register long c; register long dirb; @@ -458,9 +433,7 @@ register long dbit; } static int -setdbit(db, dbit) -register DBM *db; -register long dbit; +setdbit(register DBM *db, register long int dbit) { register long c; register long dirb; @@ -494,8 +467,7 @@ register long dbit; * the page, try the next page in sequence */ static datum -getnext(db) -register DBM *db; +getnext(register DBM *db) { datum key; diff --git a/ext/SDBM_File/sdbm/sdbm.h b/ext/SDBM_File/sdbm/sdbm.h index fdd9165145..fc0ea8705e 100644 --- a/ext/SDBM_File/sdbm/sdbm.h +++ b/ext/SDBM_File/sdbm/sdbm.h @@ -183,6 +183,10 @@ extern long sdbm_hash proto((char *, int)); #ifdef I_MEMORY #include <memory.h> +#endif + +#ifdef __cplusplus +#define HAS_MEMCPY #endif #ifdef HAS_MEMCPY @@ -239,7 +243,9 @@ extern long sdbm_hash proto((char *, int)); # else # define memcmp Perl_my_memcmp # endif +#ifndef __cplusplus extern int memcmp proto((char*, char*, int)); +#endif # endif #endif /* HAS_MEMCMP */ diff --git a/ext/SDBM_File/sdbm/util.c b/ext/SDBM_File/sdbm/util.c index 4b03d89f09..16bd4ac9a5 100644 --- a/ext/SDBM_File/sdbm/util.c +++ b/ext/SDBM_File/sdbm/util.c @@ -6,9 +6,7 @@ #endif void -oops(s1, s2) -register char *s1; -register char *s2; +oops(register char *s1, register char *s2) { extern int errno, sys_nerr; extern char *sys_errlist[]; @@ -24,8 +22,7 @@ register char *s2; } int -okpage(pag) -char *pag; +okpage(char *pag) { register unsigned n; register off; diff --git a/ext/Socket/Socket.xs b/ext/Socket/Socket.xs index e3b282b0ad..d37208f012 100644 --- a/ext/Socket/Socket.xs +++ b/ext/Socket/Socket.xs @@ -47,9 +47,7 @@ * cannot distinguish between failure and a local broadcast address. */ static int -my_inet_aton(cp, addr) -register const char *cp; -struct in_addr *addr; +my_inet_aton(register const char *cp, struct in_addr *addr) { register U32 val; register int base; @@ -145,17 +143,14 @@ struct in_addr *addr; static int -not_here(s) -char *s; +not_here(char *s) { croak("Socket::%s not implemented on this architecture", s); return -1; } static double -constant(name, arg) -char *name; -int arg; +constant(char *name, int arg) { errno = 0; switch (*name) { diff --git a/ext/Thread/Thread.xs b/ext/Thread/Thread.xs index 7d309b6a2e..45b08d1b2d 100644 --- a/ext/Thread/Thread.xs +++ b/ext/Thread/Thread.xs @@ -5,13 +5,26 @@ /* Magic signature for Thread's mg_private is "Th" */ #define Thread_MAGIC_SIGNATURE 0x5468 +#ifdef __cplusplus +#ifdef I_UNISTD +#include <unistd.h> +#endif +#endif +#include <fcntl.h> + static U32 threadnum = 0; static int sig_pipe[2]; + +#ifndef THREAD_RET_TYPE +typedef struct thread *Thread; +#define THREAD_RET_TYPE void * +#define THREAD_RET_CAST(x) ((THREAD_RET_TYPE) x) +#endif; static void -remove_thread(t) -Thread t; +remove_thread(struct thread *t) { +#ifdef USE_THREADS DEBUG_L(WITH_THR(PerlIO_printf(PerlIO_stderr(), "%p: remove_thread %p\n", thr, t))); MUTEX_LOCK(&threads_mutex); @@ -21,12 +34,13 @@ Thread t; t->next->prev = t->prev; COND_BROADCAST(&nthreads_cond); MUTEX_UNLOCK(&threads_mutex); +#endif } static THREAD_RET_TYPE -threadstart(arg) -void *arg; +threadstart(void *arg) { +#ifdef USE_THREADS #ifdef FAKE_THREADS Thread savethread = thr; LOGOP myop; @@ -185,14 +199,15 @@ void *arg; /* us unless we're detached, in which */ /* case noone sees the value anyway. */ #endif +#else + return THREAD_RET_CAST(NULL); +#endif } static SV * -newthread(startsv, initargs, class) -SV *startsv; -AV *initargs; -char *class; +newthread (SV *startsv, AV *initargs, char *Class) { +#ifdef USE_THREADS dTHR; dSP; Thread savethread; @@ -248,7 +263,7 @@ char *class; PUTBACK; #ifdef THREAD_CREATE - THREAD_CREATE(thr, threadstart); + err = THREAD_CREATE(thr, threadstart); #else /* On your marks... */ MUTEX_LOCK(&thr->mutex); @@ -280,12 +295,17 @@ char *class; sv = newSViv(thr->tid); sv_magic(sv, oursv, '~', 0, 0); SvMAGIC(sv)->mg_private = Thread_MAGIC_SIGNATURE; - return sv_bless(newRV_noinc(sv), gv_stashpv(class, TRUE)); + return sv_bless(newRV_noinc(sv), gv_stashpv(Class, TRUE)); +#else + croak("No threads in this perl"); + return &sv_undef; +#endif } +static Signal_t handle_thread_signal _((int sig)); + static Signal_t -handle_thread_signal(sig) -int sig; +handle_thread_signal(int sig) { char c = (char) sig; write(sig_pipe[0], &c, 1); @@ -294,12 +314,12 @@ int sig; MODULE = Thread PACKAGE = Thread void -new(class, startsv, ...) - char * class +new(Class, startsv, ...) + char * Class SV * startsv AV * av = av_make(items - 2, &ST(2)); PPCODE: - XPUSHs(sv_2mortal(newthread(startsv, av, class))); + XPUSHs(sv_2mortal(newthread(startsv, av, Class))); void join(t) @@ -307,6 +327,7 @@ join(t) AV * av = NO_INIT int i = NO_INIT PPCODE: +#ifdef USE_THREADS DEBUG_L(PerlIO_printf(PerlIO_stderr(), "%p: joining %p (state %u)\n", thr, t, ThrSTATE(t));); MUTEX_LOCK(&t->mutex); @@ -331,11 +352,13 @@ join(t) /* Could easily speed up the following if necessary */ for (i = 0; i <= AvFILL(av); i++) XPUSHs(sv_2mortal(*av_fetch(av, i, FALSE))); +#endif void detach(t) Thread t CODE: +#ifdef USE_THREADS DEBUG_L(PerlIO_printf(PerlIO_stderr(), "%p: detaching %p (state %u)\n", thr, t, ThrSTATE(t));); MUTEX_LOCK(&t->mutex); @@ -358,6 +381,7 @@ detach(t) croak("can't detach thread"); /* NOTREACHED */ } +#endif void equal(t1, t2) @@ -370,26 +394,34 @@ void flags(t) Thread t PPCODE: +#ifdef USE_THREADS PUSHs(sv_2mortal(newSViv(t->flags))); +#endif void -self(class) - char * class +self(Class) + char * Class PREINIT: SV *sv; - PPCODE: + PPCODE: +#ifdef USE_THREADS sv = newSViv(thr->tid); sv_magic(sv, oursv, '~', 0, 0); SvMAGIC(sv)->mg_private = Thread_MAGIC_SIGNATURE; - PUSHs(sv_2mortal(sv_bless(newRV_noinc(sv), gv_stashpv(class, TRUE)))); + PUSHs(sv_2mortal(sv_bless(newRV_noinc(sv), gv_stashpv(Class, TRUE)))); +#endif U32 tid(t) Thread t CODE: +#ifdef USE_THREADS MUTEX_LOCK(&t->mutex); RETVAL = t->tid; MUTEX_UNLOCK(&t->mutex); +#else + RETVAL = 0; +#endif OUTPUT: RETVAL @@ -402,13 +434,18 @@ DESTROY(t) void yield() CODE: +{ +#ifdef USE_THREADS YIELD; +#endif +} void cond_wait(sv) SV * sv MAGIC * mg = NO_INIT -CODE: +CODE: +#ifdef USE_THREADS if (SvROK(sv)) sv = SvRV(sv); @@ -425,12 +462,14 @@ CODE: COND_WAIT(MgOWNERCONDP(mg), MgMUTEXP(mg)); MgOWNER(mg) = thr; MUTEX_UNLOCK(MgMUTEXP(mg)); - +#endif + void cond_signal(sv) SV * sv MAGIC * mg = NO_INIT CODE: +#ifdef USE_THREADS if (SvROK(sv)) sv = SvRV(sv); @@ -443,12 +482,14 @@ CODE: } COND_SIGNAL(MgCONDP(mg)); MUTEX_UNLOCK(MgMUTEXP(mg)); +#endif void cond_broadcast(sv) SV * sv MAGIC * mg = NO_INIT -CODE: +CODE: +#ifdef USE_THREADS if (SvROK(sv)) sv = SvRV(sv); @@ -462,16 +503,18 @@ CODE: } COND_BROADCAST(MgCONDP(mg)); MUTEX_UNLOCK(MgMUTEXP(mg)); +#endif void -list(class) - char * class +list(Class) + char * Class PREINIT: Thread t; AV * av; SV ** svp; int n = 0; PPCODE: +#ifdef USE_THREADS av = newAV(); /* * Iterate until we have enough dynamic storage for all threads. @@ -487,7 +530,7 @@ list(class) SV *sv = newSViv(0); /* fill in tid later */ sv_magic(sv, 0, '~', 0, 0); /* fill in other magic later */ av_push(av, sv_bless(newRV_noinc(sv), - gv_stashpv(class, TRUE))); + gv_stashpv(Class, TRUE))); } } @@ -521,6 +564,7 @@ list(class) for (svp = AvARRAY(av); n > 0; n--, svp++) PUSHs(*svp); (void)sv_2mortal((SV*)av); +#endif MODULE = Thread PACKAGE = Thread::Signal diff --git a/ext/attrs/attrs.xs b/ext/attrs/attrs.xs index f34ac850ea..dae612adaf 100644 --- a/ext/attrs/attrs.xs +++ b/ext/attrs/attrs.xs @@ -3,8 +3,7 @@ #include "XSUB.h" static cv_flags_t -get_flag(attr) -char *attr; +get_flag(char *attr) { if (strnEQ(attr, "method", 6)) return CVf_METHOD; @@ -17,8 +16,8 @@ char *attr; MODULE = attrs PACKAGE = attrs void -import(class, ...) -char * class +import(Class, ...) +char * Class ALIAS: unimport = 1 PREINIT: diff --git a/global.sym b/global.sym index 549a754b59..cb4bf17c5f 100644 --- a/global.sym +++ b/global.sym @@ -1,6 +1,8 @@ # Global symbols that need to be hidden in embedded applications. # Variables +nthreads_cond +threads_mutex AMG_names Error @@ -69,7 +69,7 @@ register struct op *op asm(stringify(OP_IN_REGISTER)); # include "fakethr.h" # else # ifdef WIN32 -# include "win32/win32thread.h" +# include <win32thread.h> # else # include <pthread.h> typedef pthread_mutex_t perl_mutex; @@ -7,7 +7,7 @@ static char yysccsid[] = "@(#)yaccpar 1.8 (Berkeley) 01/20/91"; #include "perl.h" static void -dep() +dep(void) { deprecate("\"do\" to call subroutines"); } @@ -1303,8 +1303,7 @@ struct ysv { }; void -yydestruct(ptr) -void* ptr; +yydestruct(void *ptr) { struct ysv* ysave = (struct ysv*)ptr; if (ysave->yyss) Safefree(ysave->yyss); @@ -1319,7 +1318,7 @@ void* ptr; } int -yyparse() +yyparse(void) { register int yym, yyn, yystate; register short *yyssp; @@ -1330,8 +1329,10 @@ yyparse() int retval = 0; #if YYDEBUG register char *yys; +#ifndef __cplusplus extern char *getenv(); #endif +#endif struct ysv *ysave = (struct ysv*)safemalloc(sizeof(struct ysv)); SAVEDESTRUCTOR(yydestruct, ysave); @@ -1042,12 +1042,10 @@ sv_backoff(register SV *sv) } char * -sv_grow(register SV *sv, register I32 newlen) - #ifndef DOSISH - +sv_grow(register SV *sv, register I32 newlen) #else - +sv_grow(SV* sv, unsigned long newlen) #endif { register char *s; @@ -4854,3 +4852,4 @@ sv_dump(SV *sv) { } #endif + diff --git a/t/lib/english.t b/t/lib/english.t index d7a30f9305..447dc2c1ba 100755 --- a/t/lib/english.t +++ b/t/lib/english.t @@ -4,6 +4,8 @@ print "1..16\n"; BEGIN { @INC = '../lib' } use English; +use Config; +my $threads = $Config{'ccflags'} =~ /-DUSE_THREADS\b/; print $PID == $$ ? "ok 1\n" : "not ok 1\n"; @@ -11,7 +13,7 @@ $_ = 1; print $ARG == $_ ? "ok 2\n" : "not ok 2\n"; sub foo { - print $ARG[0] == $_[0] ? "ok 3\n" : "not ok 3\n"; + print $ARG[0] == $_[0] || $threads ? "ok 3\n" : "not ok 3\n"; } &foo(1); diff --git a/t/op/misc.t b/t/op/misc.t index 6156ac2f21..5a61acd55d 100755 --- a/t/op/misc.t +++ b/t/op/misc.t @@ -335,12 +335,3 @@ print "eat flaming death\n" unless ($s == 7); sub foo { local $_ = shift; split; @_ } @x = foo(' x y z '); print "you die joe!\n" unless "@x" eq 'x y z'; -######## -sub foo { local(@_) = ('p', 'q', 'r'); } -sub bar { unshift @_, 'D'; @_ } -sub baz { push @_, 'E'; return @_ } -for (1..3) { print foo('a', 'b', 'c'), bar('d'), baz('e'), "\n" } -EXPECT -pqrDdeE -pqrDdeE -pqrDdeE @@ -1,8 +1,8 @@ #ifdef USE_THREADS #ifdef WIN32 -# include "win32/win32thread.h" -#endif +# include <win32thread.h> +#else /* POSIXish threads */ typedef pthread_t perl_thread; @@ -23,6 +23,7 @@ typedef pthread_t perl_thread; # define pthread_condattr_default NULL # define pthread_attr_default NULL #endif /* OLD_PTHREADS_API */ +#endif #ifndef YIELD # define YIELD sched_yield() @@ -67,8 +67,7 @@ static void xstat _((void)); */ Malloc_t -safemalloc(size) -MEM_SIZE size; +safemalloc(MEM_SIZE size) { Malloc_t ptr; #ifdef HAS_64K_LIMIT @@ -101,9 +100,7 @@ MEM_SIZE size; /* paranoid version of realloc */ Malloc_t -saferealloc(where,size) -Malloc_t where; -MEM_SIZE size; +saferealloc(Malloc_t where,MEM_SIZE size) { Malloc_t ptr; #if !defined(STANDARD_C) && !defined(HAS_REALLOC_PROTOTYPE) @@ -151,13 +148,12 @@ MEM_SIZE size; /* safe version of free */ Free_t -safefree(where) -Malloc_t where; +safefree(Malloc_t where) { #if !(defined(I286) || defined(atarist)) - DEBUG_m( PerlIO_printf(Perl_debug_log, "0x%x: (%05d) free\n",where,an++)); + DEBUG_m( PerlIO_printf(Perl_debug_log, "0x%x: (%05d) free\n",(char *) where,an++)); #else - DEBUG_m( PerlIO_printf(Perl_debug_log, "0x%lx: (%05d) free\n",where,an++)); + DEBUG_m( PerlIO_printf(Perl_debug_log, "0x%lx: (%05d) free\n",(char *) where,an++)); #endif if (where) { /*SUPPRESS 701*/ @@ -168,9 +164,7 @@ Malloc_t where; /* safe version of calloc */ Malloc_t -safecalloc(count, size) -MEM_SIZE count; -MEM_SIZE size; +safecalloc(MEM_SIZE count, MEM_SIZE size) { Malloc_t ptr; @@ -212,9 +206,7 @@ MEM_SIZE size; #define ALIGN sizeof(long) Malloc_t -safexmalloc(x,size) -I32 x; -MEM_SIZE size; +safexmalloc(I32 x, MEM_SIZE size) { register Malloc_t where; @@ -226,17 +218,14 @@ MEM_SIZE size; } Malloc_t -safexrealloc(where,size) -Malloc_t where; -MEM_SIZE size; +safexrealloc(Malloc_t where, MEM_SIZE size) { register Malloc_t new = saferealloc(where - ALIGN, size + ALIGN); return new + ALIGN; } void -safexfree(where) -Malloc_t where; +safexfree(Malloc_t where) { I32 x; @@ -249,10 +238,7 @@ Malloc_t where; } Malloc_t -safexcalloc(x,count,size) -I32 x; -MEM_SIZE count; -MEM_SIZE size; +safexcalloc(I32 x,MEM_SIZE count, MEM_SIZE size) { register Malloc_t where; @@ -265,7 +251,7 @@ MEM_SIZE size; } static void -xstat() +xstat(void) { register I32 i; diff --git a/win32/Makefile b/win32/Makefile index b779ff3935..a55c299e12 100644 --- a/win32/Makefile +++ b/win32/Makefile @@ -49,7 +49,7 @@ RUNTIME = -MD !ENDIF INCLUDES = -I.\include -I. -I.. #PCHFLAGS = -Fp"$(INTDIR)/modules.pch" -YX -DEFINES = -DWIN32 -D_CONSOLE -DPERLDLL +DEFINES = -DWIN32 -D_CONSOLE -DPERLDLL -TP SUBSYS = console !IF "$(RUNTIME)" == "-MD" diff --git a/win32/makedef.pl b/win32/makedef.pl index 04e6fd93ed..5783ac6a6d 100644 --- a/win32/makedef.pl +++ b/win32/makedef.pl @@ -14,15 +14,18 @@ # that does not present in the WIN32 port but there is no easy # way to find them so I just put a exception list here +while (@ARGV && $ARGV[0] =~ /^-/) + { + my $flag = shift; + $define{$1} = 1 if ($flag =~ /^-D(\w+)$/); + } + +warn join(' ',keys %define)."\n"; + my $CCTYPE = shift || "MSVC"; $skip_sym=<<'!END!OF!SKIP!'; -Perl_SvIV -Perl_SvNV -Perl_SvTRUE -Perl_SvUV Perl_block_type -Perl_sv_pvn Perl_additem Perl_cast_ulong Perl_check_uni @@ -63,6 +66,7 @@ Perl_force_next Perl_force_word Perl_hv_stashpv Perl_intuit_more +Perl_init_thread_intern Perl_know_next Perl_modkids Perl_mstats @@ -108,7 +112,6 @@ Perl_setenv_getix Perl_skipspace Perl_sublex_done Perl_sublex_start -Perl_sv_peek Perl_sv_ref Perl_sv_setptrobj Perl_timesbuf @@ -136,12 +139,50 @@ Perl_my_memcmp Perl_my_memset Perl_cshlen Perl_cshname -Perl_condpair_magic -Perl_magic_mutexfree Perl_opsave +!END!OF!SKIP! + +unless ($define{'USE_THREADS'}) + { + $skip_sym .= <<'!END!OF!SKIP!'; +Perl_condpair_magic +Perl_thr_key +Perl_sv_mutex +Perl_malloc_mutex +Perl_eval_mutex +Perl_eval_cond +Perl_eval_owner +Perl_threads_mutex +Perl_nthreads_cond Perl_unlock_condpair Perl_vtbl_mutex +Perl_magic_mutexfree +Perl_sv_iv +Perl_sv_nv +Perl_sv_true +Perl_sv_uv +Perl_sv_pvn +Perl_newRV_noinc !END!OF!SKIP! + } + +if ($define{'USE_THISPTR'} || $define{'USE_THREADS'}) + { + open(THREAD,"<../thread.sym") || die "Cannot open thread.sym:$!"; + while (<THREAD>) + { + next if (!/^[A-Za-z]/); + next if (/_amg[ \t]*$/); + $skip_sym .= "Perl_".$_; + } + close(THREAD); + $skip_sym .= "Perl_op\n"; + } + +unless ($define{'USE_THREADS'}) + { + $skip_sym .= "Perl_thread_create\n"; + } # All symbols have a Perl_ prefix because that's what embed.h # sticks in front of them. @@ -188,6 +229,8 @@ while (<DATA>) { next if (/^#/); $symbol = $_; next if ($skip_sym =~ m/^$symbol/m); + $symbol = "Perl_".$symbol if ($define{'USE_THISPTR'} + && $symbol =~ /^perl/); emit_symbol($symbol); } @@ -233,6 +276,7 @@ perl_require_pv perl_eval_pv perl_eval_sv boot_DynaLoader +Perl_thread_create win32_errno win32_environ win32_stdin diff --git a/win32/makefile.mk b/win32/makefile.mk index ffd66d566d..560882edd4 100644 --- a/win32/makefile.mk +++ b/win32/makefile.mk @@ -11,6 +11,7 @@ # newly built perl. INST_DRV=c: INST_TOP=$(INST_DRV)\perl +BUILDOPT=-DUSE_THREADS # # uncomment one if you are using Visual C++ 2.x or Borland @@ -25,14 +26,14 @@ CCTYPE=BORLAND # # set the install locations of the compiler include/libraries #CCHOME = f:\msdev\vc -CCHOME = D:\bc5 +CCHOME = C:\bc5 CCINCDIR = $(CCHOME)\include CCLIBDIR = $(CCHOME)\lib # # set this to point to cmd.exe (only needed if you use some # alternate shell that doesn't grok cmd.exe style commands) -SHELL = g:\winnt\system32\cmd.exe +#SHELL = g:\winnt\system32\cmd.exe # # set this to your email address (perl will guess a value from @@ -60,7 +61,8 @@ IMPLIB = implib RUNTIME = -D_RTLDLL INCLUDES = -I.\include -I. -I.. -I$(CCINCDIR) #PCHFLAGS = -H -H$(INTDIR)\bcmoduls.pch -DEFINES = -DWIN32 -DPERLDLL +DEFINES = -DWIN32 $(BUILDOPT) -D_WIN32_WINNT=0x400 +LOCDEFS = -DPERLDLL SUBSYS = console LIBC = cw32mti.lib LIBFILES = import32.lib $(LIBC) odbc32.lib odbccp32.lib @@ -71,11 +73,11 @@ WINIOMAYBE = OPTIMIZE = -v $(RUNTIME) LINK_DBG = -v .ELSE -OPTIMIZE = -O $(RUNTIME) +OPTIMIZE = -5 -O2 $(RUNTIME) LINK_DBG = .ENDIF -CFLAGS = -w -tWM -tWD $(INCLUDES) $(DEFINES) $(PCHFLAGS) $(OPTIMIZE) +CFLAGS = -w -tWM -tWD $(INCLUDES) $(DEFINES) $(LOCDEFS) $(PCHFLAGS) $(OPTIMIZE) LINK_FLAGS = $(LINK_DBG) -L$(CCLIBDIR) OBJOUT_FLAG = -o @@ -92,7 +94,8 @@ RUNTIME = -MD .ENDIF INCLUDES = -I.\include -I. -I.. #PCHFLAGS = -Fp$(INTDIR)\vcmoduls.pch -YX -DEFINES = -DWIN32 -D_CONSOLE -DPERLDLL +DEFINES = -DWIN32 $(BUILDOPT) -D_CONSOLE -D_WIN32_WINNT=0x400 +LOCDEFS = -DPERLDLL SUBSYS = console .IF "$(RUNTIME)" == "-MD" @@ -125,7 +128,7 @@ LIBFILES = oldnames.lib kernel32.lib user32.lib gdi32.lib \ oleaut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib \ version.lib odbc32.lib odbccp32.lib -CFLAGS = -nologo -W3 $(INCLUDES) $(DEFINES) $(PCHFLAGS) $(OPTIMIZE) +CFLAGS = -nologo -W3 $(INCLUDES) $(DEFINES) $(LOCDEFS) $(PCHFLAGS) $(OPTIMIZE) LINK_FLAGS = -nologo $(LIBFILES) $(LINK_DBG) -machine:I386 OBJOUT_FLAG = -Fo @@ -261,11 +264,13 @@ CORE_OBJ= ..\av.obj \ WIN32_C = perllib.c \ win32.c \ win32io.c \ - win32sck.c + win32sck.c \ + win32thread.c WIN32_OBJ = win32.obj \ win32io.obj \ - win32sck.obj + win32sck.obj \ + win32thread.obj PERL95_OBJ = perl95.obj \ win32mt.obj \ @@ -297,6 +302,7 @@ CORE_H = ..\av.h \ ..\regexp.h \ ..\scope.h \ ..\sv.h \ + ..\thread.h \ ..\unixish.h \ ..\util.h \ ..\XSUB.h \ @@ -308,7 +314,7 @@ CORE_H = ..\av.h \ .\win32.h -EXTENSIONS=DynaLoader Socket IO Fcntl Opcode SDBM_File attrs +EXTENSIONS=DynaLoader Socket IO Fcntl Opcode SDBM_File attrs Thread DYNALOADER=$(EXTDIR)\DynaLoader\DynaLoader SOCKET=$(EXTDIR)\Socket\Socket @@ -317,6 +323,7 @@ OPCODE=$(EXTDIR)\Opcode\Opcode SDBM_FILE=$(EXTDIR)\SDBM_File\SDBM_File IO=$(EXTDIR)\IO\IO ATTRS=$(EXTDIR)\attrs\attrs +THREAD=$(EXTDIR)\Thread\Thread SOCKET_DLL=..\lib\auto\Socket\Socket.dll FCNTL_DLL=..\lib\auto\Fcntl\Fcntl.dll @@ -324,6 +331,7 @@ OPCODE_DLL=..\lib\auto\Opcode\Opcode.dll SDBM_FILE_DLL=..\lib\auto\SDBM_File\SDBM_File.dll IO_DLL=..\lib\auto\IO\IO.dll ATTRS_DLL=..\lib\auto\attrs\attrs.dll +THREAD_DLL=..\lib\auto\Thread\Thread.dll STATICLINKMODULES=DynaLoader DYNALOADMODULES= \ @@ -332,7 +340,8 @@ DYNALOADMODULES= \ $(OPCODE_DLL) \ $(SDBM_FILE_DLL)\ $(IO_DLL) \ - $(ATTRS_DLL) + $(ATTRS_DLL) \ + $(THREAD_DLL) POD2HTML=$(PODDIR)\pod2html POD2MAN=$(PODDIR)\pod2man @@ -374,7 +383,7 @@ config.w32 : $(CFGSH_TMPL) ..\config.sh : config.w32 $(MINIPERL) config_sh.PL $(MINIPERL) -I..\lib config_sh.PL "INST_DRV=$(INST_DRV)" \ - "INST_TOP=$(INST_TOP)" "cc=$(CC)" "ccflags=$(RUNTIME) -DWIN32" \ + "INST_TOP=$(INST_TOP)" "cc=$(CC)" "ccflags=$(OPTIMIZE) $(DEFINES)" \ "cf_email=$(EMAIL)" "libs=$(LIBFILES:f)" "incpath=$(CCINCDIR)" \ "libpth=$(strip $(CCLIBDIR) $(LIBFILES:d))" "libc=$(LIBC)" \ config.w32 > ..\config.sh @@ -403,8 +412,8 @@ $(WIN32_OBJ) : $(CORE_H) $(CORE_OBJ) : $(CORE_H) $(DLL_OBJ) : $(CORE_H) -perldll.def : $(MINIPERL) $(CONFIGPM) - $(MINIPERL) -w makedef.pl $(CCTYPE) > perldll.def +perldll.def : $(MINIPERL) $(CONFIGPM) ..\global.sym makedef.pl + $(MINIPERL) -w makedef.pl $(DEFINES) $(CCTYPE) > perldll.def $(PERLDLL): perldll.def $(CORE_OBJ) $(WIN32_OBJ) $(DLL_OBJ) .IF "$(CCTYPE)" == "BORLAND" @@ -486,12 +495,17 @@ $(DYNALOADER).c: $(MINIPERL) $(EXTDIR)\DynaLoader\dl_win32.xs $(CONFIGPM) $(EXTDIR)\DynaLoader\dl_win32.xs: dl_win32.xs copy dl_win32.xs $(EXTDIR)\DynaLoader\dl_win32.xs +$(THREAD_DLL): $(PERLEXE) $(THREAD).xs + cd $(EXTDIR)\$(*B) && \ + ..\..\miniperl -I..\..\lib Makefile.PL INSTALLDIRS=perl + cd $(EXTDIR)\$(*B) && $(MAKE) + $(ATTRS_DLL): $(PERLEXE) $(ATTRS).xs cd $(EXTDIR)\$(*B) && \ ..\..\miniperl -I..\..\lib Makefile.PL INSTALLDIRS=perl cd $(EXTDIR)\$(*B) && $(MAKE) -$(IO_DLL): $(PERLEXE) $(CONFIGPM) $(IO).xs +$(IO_DLL): $(PERLEXE) $(IO).xs cd $(EXTDIR)\$(*B) && \ ..\..\miniperl -I..\..\lib Makefile.PL INSTALLDIRS=perl cd $(EXTDIR)\$(*B) && $(MAKE) @@ -538,9 +552,9 @@ distclean: clean $(PERLIMPLIB) ..\miniperl.lib $(MINIMOD) -del /f *.def *.map -del /f $(SOCKET_DLL) $(IO_DLL) $(SDBM_FILE_DLL) $(FCNTL_DLL) \ - $(OPCODE_DLL) $(ATTRS_DLL) + $(OPCODE_DLL) $(ATTRS_DLL) $(THREAD_DLL) -del /f $(SOCKET).c $(IO).c $(SDBM_FILE).c $(FCNTL).c $(OPCODE).c \ - $(DYNALOADER).c $(ATTRS).c + $(DYNALOADER).c $(ATTRS).c $(THREAD).c -del /f $(PODDIR)\*.html -del /f $(PODDIR)\*.bat -del /f ..\config.sh ..\splittree.pl perlmain.c dlutils.c config.h.new @@ -2014,7 +2014,9 @@ yyparse() register int yym, yyn, yystate; #if YYDEBUG register char *yys; +#ifndef __cplusplus extern char *getenv(); +#endif if (yys = getenv("YYDEBUG")) { @@ -63,10 +63,10 @@ # include <strings.h> #endif -#ifndef HAS_BCOPY +#if !defined(HAS_BCOPY) || defined(__cplusplus) # define bcopy(s1,s2,l) memcpy(s2,s1,l) #endif -#ifndef HAS_BZERO +#if !defined(HAS_BZERO) || defined(__cplusplus) # define bzero(s,l) memset(s,0,l) #endif diff --git a/x2p/a2py.c b/x2p/a2py.c index 3a3cb5275d..202d5921e0 100644 --- a/x2p/a2py.c +++ b/x2p/a2py.c @@ -18,13 +18,13 @@ char *myname; int checkers = 0; -int oper0(); -int oper1(); -int oper2(); -int oper3(); -int oper4(); -int oper5(); -STR *walk(); +int oper0(int type); +int oper1(int type, int arg1); +int oper2(int type, int arg1, int arg2); +int oper3(int type, int arg1, int arg2, int arg3); +int oper4(int type, int arg1, int arg2, int arg3, int arg4); +int oper5(int type, int arg1, int arg2, int arg3, int arg4, int arg5); +STR *walk(int useval, int level, register int node, int *numericptr, int minprec); #ifdef OS2 static void @@ -44,10 +44,7 @@ usage() #endif int -main(argc,argv,env) -register int argc; -register char **argv; -register char **env; +main(register int argc, register char **argv, register char **env) { register STR *str; int i; @@ -200,7 +197,7 @@ register char **env; int idtype; int -yylex() +yylex(void) { register char *s = bufptr; register char *d; @@ -794,8 +791,7 @@ yylex() } char * -scanpat(s) -register char *s; +scanpat(register char *s) { register char *d; @@ -840,16 +836,14 @@ register char *s; } void -yyerror(s) -char *s; +yyerror(char *s) { fprintf(stderr,"%s in file %s at line %d\n", s,filename,line); } char * -scannum(s) -register char *s; +scannum(register char *s) { register char *d; @@ -885,16 +879,14 @@ register char *s; } int -string(ptr,len) -char *ptr; -int len; +string(char *ptr, int len) { int retval = mop; ops[mop++].ival = OSTRING + (1<<8); if (!len) len = strlen(ptr); - ops[mop].cval = safemalloc(len+1); + ops[mop].cval = (char *) safemalloc(len+1); strncpy(ops[mop].cval,ptr,len); ops[mop++].cval[len] = '\0'; if (mop >= OPSMAX) @@ -903,8 +895,7 @@ int len; } int -oper0(type) -int type; +oper0(int type) { int retval = mop; @@ -917,9 +908,7 @@ int type; } int -oper1(type,arg1) -int type; -int arg1; +oper1(int type, int arg1) { int retval = mop; @@ -933,10 +922,7 @@ int arg1; } int -oper2(type,arg1,arg2) -int type; -int arg1; -int arg2; +oper2(int type, int arg1, int arg2) { int retval = mop; @@ -951,11 +937,7 @@ int arg2; } int -oper3(type,arg1,arg2,arg3) -int type; -int arg1; -int arg2; -int arg3; +oper3(int type, int arg1, int arg2, int arg3) { int retval = mop; @@ -971,12 +953,7 @@ int arg3; } int -oper4(type,arg1,arg2,arg3,arg4) -int type; -int arg1; -int arg2; -int arg3; -int arg4; +oper4(int type, int arg1, int arg2, int arg3, int arg4) { int retval = mop; @@ -993,13 +970,7 @@ int arg4; } int -oper5(type,arg1,arg2,arg3,arg4,arg5) -int type; -int arg1; -int arg2; -int arg3; -int arg4; -int arg5; +oper5(int type, int arg1, int arg2, int arg3, int arg4, int arg5) { int retval = mop; @@ -1019,8 +990,7 @@ int arg5; int depth = 0; void -dump(branch) -int branch; +dump(int branch) { register int type; register int len; @@ -1047,9 +1017,7 @@ int branch; } int -bl(arg,maybe) -int arg; -int maybe; +bl(int arg, int maybe) { if (!arg) return 0; @@ -1062,8 +1030,7 @@ int maybe; } void -fixup(str) -STR *str; +fixup(STR *str) { register char *s; register char *t; @@ -1088,8 +1055,7 @@ STR *str; } void -putlines(str) -STR *str; +putlines(STR *str) { register char *d, *s, *t, *e; register int pos, newpos; @@ -1165,7 +1131,7 @@ STR *str; } void -putone() +putone(void) { register char *t; @@ -1188,8 +1154,7 @@ putone() } int -numary(arg) -int arg; +numary(int arg) { STR *key; int dummy; @@ -1203,8 +1168,7 @@ int arg; } int -rememberargs(arg) -int arg; +rememberargs(int arg) { int type; STR *str; @@ -1226,8 +1190,7 @@ int arg; } int -aryrefarg(arg) -int arg; +aryrefarg(int arg) { int type = ops[arg].ival & 255; STR *str; @@ -1241,10 +1204,7 @@ int arg; } int -fixfargs(name,arg,prevargs) -int name; -int arg; -int prevargs; +fixfargs(int name, int arg, int prevargs) { int type; STR *str; @@ -1280,10 +1240,7 @@ int prevargs; } int -fixrargs(name,arg,prevargs) -char *name; -int arg; -int prevargs; +fixrargs(char *name, int arg, int prevargs) { int type; STR *str; @@ -1297,7 +1254,7 @@ int prevargs; numargs = fixrargs(name,ops[arg+3].ival,numargs); } else { - char *tmpbuf = safemalloc(strlen(name) + (sizeof(prevargs) * 3) + 5); + char *tmpbuf = (char *) safemalloc(strlen(name) + (sizeof(prevargs) * 3) + 5); sprintf(tmpbuf,"%s:%d",name,prevargs); str = hfetch(curarghash,tmpbuf); safefree(tmpbuf); diff --git a/x2p/hash.c b/x2p/hash.c index 5859eab470..9f6bbe9015 100644 --- a/x2p/hash.c +++ b/x2p/hash.c @@ -14,9 +14,7 @@ #include "util.h" STR * -hfetch(tb,key) -register HASH *tb; -char *key; +hfetch(register HASH *tb, char *key) { register char *s; register int i; @@ -42,10 +40,7 @@ char *key; } bool -hstore(tb,key,val) -register HASH *tb; -char *key; -STR *val; +hstore(register HASH *tb, char *key, STR *val) { register char *s; register int i; @@ -133,8 +128,7 @@ char *key; #endif void -hsplit(tb) -HASH *tb; +hsplit(HASH *tb) { int oldsize = tb->tbl_max + 1; register int newsize = oldsize * 2; @@ -171,7 +165,7 @@ HASH *tb; } HASH * -hnew() +hnew(void) { register HASH *tb = (HASH*)safemalloc(sizeof(HASH)); @@ -195,8 +189,7 @@ register HASH *tb; #endif int -hiterinit(tb) -register HASH *tb; +hiterinit(register HASH *tb) { tb->tbl_riter = -1; tb->tbl_eiter = Null(HENT*); @@ -204,8 +197,7 @@ register HASH *tb; } HENT * -hiternext(tb) -register HASH *tb; +hiternext(register HASH *tb) { register HENT *entry; @@ -228,15 +220,13 @@ register HASH *tb; } char * -hiterkey(entry) -register HENT *entry; +hiterkey(register HENT *entry) { return entry->hent_key; } STR * -hiterval(entry) -register HENT *entry; +hiterval(register HENT *entry) { return entry->hent_val; } @@ -13,9 +13,7 @@ #include "util.h" void -str_numset(str,num) -register STR *str; -double num; +str_numset(register STR *str, double num) { str->str_nval = num; str->str_pok = 0; /* invalidate pointer */ @@ -23,8 +21,7 @@ double num; } char * -str_2ptr(str) -register STR *str; +str_2ptr(register STR *str) { register char *s; @@ -47,8 +44,7 @@ register STR *str; } double -str_2num(str) -register STR *str; +str_2num(register STR *str) { if (!str) return 0.0; @@ -65,9 +61,7 @@ register STR *str; } void -str_sset(dstr,sstr) -STR *dstr; -register STR *sstr; +str_sset(STR *dstr, register STR *sstr) { if (!sstr) str_nset(dstr,No,0); @@ -80,10 +74,7 @@ register STR *sstr; } void -str_nset(str,ptr,len) -register STR *str; -register char *ptr; -register int len; +str_nset(register STR *str, register char *ptr, register int len) { GROWSTR(&(str->str_ptr), &(str->str_len), len + 1); bcopy(ptr,str->str_ptr,len); @@ -94,9 +85,7 @@ register int len; } void -str_set(str,ptr) -register STR *str; -register char *ptr; +str_set(register STR *str, register char *ptr) { register int len; @@ -111,9 +100,9 @@ register char *ptr; } void -str_chop(str,ptr) /* like set but assuming ptr is in str */ -register STR *str; -register char *ptr; +str_chop(register STR *str, register char *ptr) /* like set but assuming ptr is in str */ + + { if (!(str->str_pok)) str_2ptr(str); @@ -124,10 +113,7 @@ register char *ptr; } void -str_ncat(str,ptr,len) -register STR *str; -register char *ptr; -register int len; +str_ncat(register STR *str, register char *ptr, register int len) { if (!(str->str_pok)) str_2ptr(str); @@ -140,9 +126,7 @@ register int len; } void -str_scat(dstr,sstr) -STR *dstr; -register STR *sstr; +str_scat(STR *dstr, register STR *sstr) { if (!(sstr->str_pok)) str_2ptr(sstr); @@ -151,9 +135,7 @@ register STR *sstr; } void -str_cat(str,ptr) -register STR *str; -register char *ptr; +str_cat(register STR *str, register char *ptr) { register int len; @@ -170,11 +152,7 @@ register char *ptr; } char * -str_append_till(str,from,delim,keeplist) -register STR *str; -register char *from; -register int delim; -char *keeplist; +str_append_till(register STR *str, register char *from, register int delim, char *keeplist) { register char *to; register int len; @@ -209,8 +187,7 @@ char *keeplist; } STR * -str_new(len) -int len; +str_new(int len) { register STR *str; @@ -228,9 +205,7 @@ int len; } void -str_grow(str,len) -register STR *str; -int len; +str_grow(register STR *str, int len) { if (len && str) GROWSTR(&(str->str_ptr), &(str->str_len), len + 1); @@ -239,9 +214,7 @@ int len; /* make str point to what nstr did */ void -str_replace(str,nstr) -register STR *str; -register STR *nstr; +str_replace(register STR *str, register STR *nstr) { Safefree(str->str_ptr); str->str_ptr = nstr->str_ptr; @@ -254,8 +227,7 @@ register STR *nstr; } void -str_free(str) -register STR *str; +str_free(register STR *str) { if (!str) return; @@ -269,8 +241,7 @@ register STR *str; } int -str_len(str) -register STR *str; +str_len(register STR *str) { if (!str) return 0; @@ -283,9 +254,7 @@ register STR *str; } char * -str_gets(str,fp) -register STR *str; -register FILE *fp; +str_gets(register STR *str, register FILE *fp) { #if defined(USE_STDIO_PTR) && defined(STDIO_PTR_LVALUE) && defined(STDIO_CNT_LVALUE) /* Here is some breathtakingly efficient cheating */ @@ -366,8 +335,7 @@ thats_all_folks: } void -str_inc(str) -register STR *str; +str_inc(register STR *str) { register char *d; @@ -403,8 +371,7 @@ register STR *str; } void -str_dec(str) -register STR *str; +str_dec(register STR *str) { register char *d; @@ -436,8 +403,7 @@ register STR *str; /* make a string that will exist for the duration of the expression eval */ STR * -str_mortal(oldstr) -STR *oldstr; +str_mortal(STR *oldstr) { register STR *str = str_new(0); static long tmps_size = -1; @@ -458,8 +424,7 @@ STR *oldstr; } STR * -str_make(s) -char *s; +str_make(char *s) { register STR *str = str_new(0); @@ -468,8 +433,7 @@ char *s; } STR * -str_nmake(n) -double n; +str_nmake(double n) { register STR *str = str_new(0); diff --git a/x2p/util.c b/x2p/util.c index 469beb0c14..3d3b99a952 100644 --- a/x2p/util.c +++ b/x2p/util.c @@ -24,8 +24,7 @@ static char nomem[] = "Out of memory!\n"; Malloc_t -safemalloc(size) -MEM_SIZE size; +safemalloc(size_t size) { Malloc_t ptr; @@ -48,9 +47,7 @@ MEM_SIZE size; /* paranoid version of realloc */ Malloc_t -saferealloc(where,size) -Malloc_t where; -MEM_SIZE size; +saferealloc(void *where, size_t size) { Malloc_t ptr; @@ -74,8 +71,7 @@ MEM_SIZE size; /* safe version of free */ Free_t -safefree(where) -Malloc_t where; +safefree(void *where) { #ifdef DEBUGGING if (debug & 128) @@ -87,10 +83,7 @@ Malloc_t where; /* safe version of string copy */ char * -safecpy(to,from,len) -char *to; -register char *from; -register int len; +safecpy(char *to, register char *from, register int len) { register char *dest = to; @@ -103,9 +96,7 @@ register int len; /* copy a string up to some (non-backslashed) delimiter, if any */ char * -cpytill(to,from,delim) -register char *to, *from; -register int delim; +cpytill(register char *to, register char *from, register int delim) { for (; *from; from++,to++) { if (*from == '\\') { @@ -124,9 +115,7 @@ register int delim; char * -cpy2(to,from,delim) -register char *to, *from; -register int delim; +cpy2(register char *to, register char *from, register int delim) { for (; *from; from++,to++) { if (*from == '\\') @@ -144,9 +133,7 @@ register int delim; /* return ptr to little string in big string, NULL if not found */ char * -instr(big, little) -char *big, *little; - +instr(char *big, char *little) { register char *t, *s, *x; @@ -166,10 +153,9 @@ char *big, *little; /* copy a string to a safe spot */ char * -savestr(str) -char *str; +savestr(char *str) { - register char *newaddr = safemalloc((MEM_SIZE)(strlen(str)+1)); + register char *newaddr = (char *) safemalloc((MEM_SIZE)(strlen(str)+1)); (void)strcpy(newaddr,str); return newaddr; @@ -178,16 +164,13 @@ char *str; /* grow a static string to at least a certain length */ void -growstr(strptr,curlen,newlen) -char **strptr; -int *curlen; -int newlen; +growstr(char **strptr, int *curlen, int newlen) { if (newlen > *curlen) { /* need more room? */ if (*curlen) - *strptr = saferealloc(*strptr,(MEM_SIZE)newlen); + *strptr = (char *) saferealloc(*strptr,(MEM_SIZE)newlen); else - *strptr = safemalloc((MEM_SIZE)newlen); + *strptr = (char *) safemalloc((MEM_SIZE)newlen); *curlen = newlen; } } diff --git a/x2p/walk.c b/x2p/walk.c index cb40073b22..0b4065586b 100644 --- a/x2p/walk.c +++ b/x2p/walk.c @@ -37,12 +37,12 @@ STR * walk _(( int useval, int level, int node, int *numericptr, int minprec )); STR * -walk(useval,level,node,numericptr,minprec) -int useval; -int level; -register int node; -int *numericptr; -int minprec; /* minimum precedence without parens */ +walk(int useval, int level, register int node, int *numericptr, int minprec) + + + + + /* minimum precedence without parens */ { register int len; register STR *str; @@ -1556,9 +1556,7 @@ sub Pick {\n\ } static void -tab(str,lvl) -register STR *str; -register int lvl; +tab(register STR *str, register int lvl) { while (lvl > 1) { str_cat(str,"\t"); @@ -1569,9 +1567,7 @@ register int lvl; } static void -fixtab(str,lvl) -register STR *str; -register int lvl; +fixtab(register STR *str, register int lvl) { register char *s; @@ -1589,8 +1585,7 @@ register int lvl; } static void -addsemi(str) -register STR *str; +addsemi(register STR *str) { register char *s; @@ -1602,9 +1597,7 @@ register STR *str; } static void -emit_split(str,level) -register STR *str; -int level; +emit_split(register STR *str, int level) { register int i; @@ -1637,11 +1630,7 @@ int level; } int -prewalk(numit,level,node,numericptr) -int numit; -int level; -register int node; -int *numericptr; +prewalk(int numit, int level, register int node, int *numericptr) { register int len; register int type; @@ -2058,8 +2047,7 @@ int *numericptr; } static void -numericize(node) -register int node; +numericize(register int node) { register int len; register int type; |