summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorMalcolm Beattie <mbeattie@sable.ox.ac.uk>1997-11-11 16:36:22 +0000
committerMalcolm Beattie <mbeattie@sable.ox.ac.uk>1997-11-11 16:36:22 +0000
commite5687acb0c7cb7e00d80dde70d5d9163677bffea (patch)
tree85408ddaa2ae5aac8fb957f4ee0e9cc81e5c49ff /ext
parent2faa37ccf8e46b865687f0ab4992b29a75eb79ea (diff)
parent4a8966581a604869d2f8db229d9d60d76ee72dcf (diff)
downloadperl-e5687acb0c7cb7e00d80dde70d5d9163677bffea.tar.gz
Initial integration of ansi branch into mainline (untested).
p4raw-id: //depot/perl@230
Diffstat (limited to 'ext')
-rw-r--r--ext/DynaLoader/dl_dlopen.xs2
-rw-r--r--ext/Fcntl/Fcntl.xs7
-rw-r--r--ext/GDBM_File/GDBM_File.xs9
-rw-r--r--ext/IO/IO.xs7
-rw-r--r--ext/Opcode/Opcode.pm2
-rw-r--r--ext/Opcode/Opcode.xs32
-rw-r--r--ext/POSIX/POSIX.xs7
-rw-r--r--ext/SDBM_File/sdbm/hash.c4
-rw-r--r--ext/SDBM_File/sdbm/pair.c45
-rw-r--r--ext/SDBM_File/sdbm/sdbm.c66
-rw-r--r--ext/SDBM_File/sdbm/sdbm.h9
-rw-r--r--ext/SDBM_File/sdbm/util.c7
-rw-r--r--ext/Socket/Socket.xs11
-rw-r--r--ext/Thread/Thread.xs110
-rw-r--r--ext/attrs/attrs.xs7
15 files changed, 146 insertions, 179 deletions
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.pm b/ext/Opcode/Opcode.pm
index dcc5d745a4..b71e8b43cf 100644
--- a/ext/Opcode/Opcode.pm
+++ b/ext/Opcode/Opcode.pm
@@ -438,7 +438,7 @@ These ops are related to multi-threading.
A handy tag name for a I<reasonable> default set of ops. (The current ops
allowed are unstable while development continues. It will change.)
- :base_core :base_mem :base_loop :base_io :base_orig
+ :base_core :base_mem :base_loop :base_io :base_orig :base_thread
If safety matters to you (and why else would you be using the Opcode module?)
then you should not rely on the definition of this, or indeed any other, optag!
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..5bc629f402 100644
--- a/ext/SDBM_File/sdbm/sdbm.h
+++ b/ext/SDBM_File/sdbm/sdbm.h
@@ -49,7 +49,7 @@ typedef struct {
extern datum nullitem;
-#ifdef __STDC__
+#if defined(__STDC__) || defined(__cplusplus)
#define proto(p) p
#else
#define proto(p) ()
@@ -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 */
@@ -262,3 +268,4 @@ extern long sdbm_hash proto((char *, int));
#endif
#endif /* Include guard */
+
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 f5bb2220b2..841b5698a1 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;
@@ -68,15 +82,17 @@ void *arg;
#else
Thread thr = (Thread) arg;
LOGOP myop;
- dSP;
+ djSP;
I32 oldmark = TOPMARK;
I32 oldscope = scopestack_ix;
I32 retval;
AV *returnav;
int i, ret;
dJMPENV;
+ DEBUG_L(PerlIO_printf(PerlIO_stderr(), "new thread %p waiting to start\n",
+ thr));
- /* Don't call *anything* requiring dTHR until after pthread_setspecific */
+ /* Don't call *anything* requiring dTHR until after SET_THR() */
/*
* Wait until our creator releases us. If we didn't do this, then
* it would be potentially possible for out thread to carry on and
@@ -192,15 +208,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)
{
- dTHR;
+#ifdef USE_THREADS
dSP;
Thread savethread;
int i;
@@ -214,8 +230,8 @@ char *class;
thr = new_struct_thread(thr);
SPAGAIN;
DEBUG_L(PerlIO_printf(PerlIO_stderr(),
- "%p: newthread, tid is %u, preparing stack\n",
- savethread, thr->tid));
+ "%p: newthread (%p), tid is %u, preparing stack\n",
+ savethread, thr, thr->tid));
/* The following pushes the arg list and startsv onto the *new* stack */
PUSHMARK(sp);
/* Could easily speed up the following greatly */
@@ -223,9 +239,8 @@ char *class;
XPUSHs(SvREFCNT_inc(*av_fetch(initargs, i, FALSE)));
XPUSHs(SvREFCNT_inc(startsv));
PUTBACK;
-
#ifdef THREAD_CREATE
- THREAD_CREATE(thr, threadstart);
+ err = THREAD_CREATE(thr, threadstart);
#else
/* On your marks... */
MUTEX_LOCK(&thr->mutex);
@@ -239,6 +254,8 @@ char *class;
MUTEX_UNLOCK(&thr->mutex);
#endif
if (err) {
+ DEBUG_L(PerlIO_printf(PerlIO_stderr(),
+ "%p: create of %p failed %d\n", savethread, thr, err));
/* Thread creation failed--clean up */
SvREFCNT_dec(thr->cvcache);
remove_thread(thr);
@@ -257,26 +274,32 @@ char *class;
sv = newSViv(thr->tid);
sv_magic(sv, thr->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);
}
MODULE = Thread PACKAGE = Thread
+PROTOTYPES: DISABLE
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)
@@ -284,6 +307,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);
@@ -308,11 +332,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);
@@ -335,6 +361,7 @@ detach(t)
croak("can't detach thread");
/* NOTREACHED */
}
+#endif
void
equal(t1, t2)
@@ -347,26 +374,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, thr->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
@@ -379,13 +414,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);
@@ -402,12 +442,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);
@@ -420,12 +462,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);
@@ -439,16 +483,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.
@@ -464,7 +510,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)));
}
}
@@ -498,6 +544,7 @@ list(class)
for (svp = AvARRAY(av); n > 0; n--, svp++)
PUSHs(*svp);
(void)sv_2mortal((SV*)av);
+#endif
MODULE = Thread PACKAGE = Thread::Signal
@@ -532,3 +579,4 @@ await_signal()
RETVAL = c ? psig_ptr[c] : &sv_no;
OUTPUT:
RETVAL
+
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: