develooper Front page | perl.perl5.porters | Postings from December 2000

[PATCH] Fcntl constants speedup

Thread Next
From:
Nicholas Clark
Date:
December 17, 2000 08:29
Subject:
[PATCH] Fcntl constants speedup
Message ID:
20001217162924.E97668@plum.flirble.org
Why do all the XS constant() routines (that I've looked at) have a second
unused integer argument after the name argument?
I assume that they return double because perl did all arithmetic (except
logical operations such as |) as doubles

Following patch speeds up Fcntl's constant routine (ever so slightly, but
now that == likes IVs there will be knock on speedups)

Before:

./perl -Ilib -MBenchmark -MFcntl -e 'timethese (1000000, {"Get"=> q($foo = O_NDELAY; undef \&Fcntl::O_NDELAY)})'
Benchmark: timing 1000000 iterations of Get...
       Get:  6 wallclock secs ( 5.53 usr +  0.00 sys =  5.53 CPU) @ 180831.83/s (n=1000000)

./perl -Ilib -MBenchmark -MFcntl -e 'timethese (1000000, {"Get"=> q($foo = O_NDELAY; undef \&Fcntl::O_NDELAY)})'
Benchmark: timing 1000000 iterations of Get...
       Get:  3 wallclock secs ( 4.27 usr +  0.00 sys =  4.27 CPU) @ 234192.04/s (n=1000000)

It's 3 parts
1: change the return value from double to IV
2: drop the 2nd argument
3: redo the switch statment slightly to reduce the length of strings compared.

I'm not sure if changing the switch statement from

static IV
constant(char *name)
{
    errno = 0;
    switch (*name) {
    case '_':
	if (strEQ(name, "_S_IFMT")) /* Yes, on name _S_IFMT return S_IFMT. */

to

static IV
constant(char *name)
{
    errno = 0;
    switch (*(name++)) {
    case '_':
	if (strEQ(name, "S_IFMT")) /* Yes, on name _S_IFMT return S_IFMT. */


is a good idea. It doesn't seem to change the speed much on x86, but I'm
worried that in general it works against architectures that find it more
efficient to to strcmp on 2 word aligned strings. (It seems reasonable to
assume that char *name and the string constants will both be optimally
aligned if the platform has optimal alignment. I know that for ARM the
assembler aligned the constants on 4 byte boundaries, and that on ARM 
a faster strcmp() can be written for 2 word aligned strings.
(the timing crossover for word being faster than byte is about 12
characters, which is shorter than the length of strings in the dhrystone
benchmark. However, I have no idea whether perl's strings usually differ
early enough to care.)

Redoing the switch statement also made the binary smaller:

   text    data     bss     dec     hex filename
   5347       0       0    5347    14e3 ext/Fcntl/Fcntl.o
   5944       0       0    5944    1738 ../bleadperl/ext/Fcntl/Fcntl.o

I experimented with adding more switch tables on later letters
(eg $1 in /F_(.).*/ but the compiler starts making jump tables and the
object file gets bigger. bigger may mean faster, may mean slower...)

Mostly it might all be too trivial to worry about (after that first name++
or not name++) and shifting AF_INET and PF_INET to the start of Socket.xs'
linear search.

Attached is the sanity checker program I wrote that can compare the
constants generated by 2 (or more) implementations to find coding bugs.

Nicholas Clark

--- ext/Fcntl/Fcntl.xs.orig	Tue Aug  1 03:31:40 2000
+++ ext/Fcntl/Fcntl.xs	Sat Dec 16 21:15:25 2000
@@ -40,13 +40,13 @@
     return -1;
 }
 
-static double
-constant(char *name, int arg)
+static IV
+constant(char *name)
 {
     errno = 0;
-    switch (*name) {
+    switch (*(name++)) {
     case '_':
-	if (strEQ(name, "_S_IFMT")) /* Yes, on name _S_IFMT return S_IFMT. */
+	if (strEQ(name, "S_IFMT")) /* Yes, on name _S_IFMT return S_IFMT. */
 #ifdef S_IFMT
 	  return S_IFMT;
 #else
@@ -54,218 +54,219 @@
 #endif
 	break;
     case 'F':
-	if (strnEQ(name, "F_", 2)) {
-	    if (strEQ(name, "F_ALLOCSP"))
+	if (*name == '_') {
+	    name++;
+	    if (strEQ(name, "ALLOCSP"))
 #ifdef F_ALLOCSP
 	        return F_ALLOCSP;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "F_ALLOCSP64"))
+	    if (strEQ(name, "ALLOCSP64"))
 #ifdef F_ALLOCSP64
 	        return F_ALLOCSP64;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "F_COMPAT"))
+	    if (strEQ(name, "COMPAT"))
 #ifdef F_COMPAT
 	        return F_COMPAT;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "F_DUP2FD"))
+	    if (strEQ(name, "DUP2FD"))
 #ifdef F_DUP2FD
 	        return F_DUP2FD;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "F_DUPFD"))
+	    if (strEQ(name, "DUPFD"))
 #ifdef F_DUPFD
 	        return F_DUPFD;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "F_EXLCK"))
+	    if (strEQ(name, "EXLCK"))
 #ifdef F_EXLCK
 	        return F_EXLCK;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "F_FREESP"))
+	    if (strEQ(name, "FREESP"))
 #ifdef F_FREESP
 	        return F_FREESP;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "F_FREESP64"))
+	    if (strEQ(name, "FREESP64"))
 #ifdef F_FREESP64
 	        return F_FREESP64;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "F_FSYNC"))
+	    if (strEQ(name, "FSYNC"))
 #ifdef F_FSYNC
 	        return F_FSYNC;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "F_FSYNC64"))
+	    if (strEQ(name, "FSYNC64"))
 #ifdef F_FSYNC64
 	        return F_FSYNC64;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "F_GETFD"))
+	    if (strEQ(name, "GETFD"))
 #ifdef F_GETFD
 	        return F_GETFD;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "F_GETFL"))
+	    if (strEQ(name, "GETFL"))
 #ifdef F_GETFL
 	        return F_GETFL;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "F_GETLK"))
+	    if (strEQ(name, "GETLK"))
 #ifdef F_GETLK
 	        return F_GETLK;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "F_GETLK64"))
+	    if (strEQ(name, "GETLK64"))
 #ifdef F_GETLK64
 	        return F_GETLK64;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "F_GETOWN"))
+	    if (strEQ(name, "GETOWN"))
 #ifdef F_GETOWN
 	        return F_GETOWN;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "F_NODNY"))
+	    if (strEQ(name, "NODNY"))
 #ifdef F_NODNY
 	        return F_NODNY;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "F_POSIX"))
+	    if (strEQ(name, "POSIX"))
 #ifdef F_POSIX
 	        return F_POSIX;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "F_RDACC"))
+	    if (strEQ(name, "RDACC"))
 #ifdef F_RDACC
 	        return F_RDACC;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "F_RDDNY"))
+	    if (strEQ(name, "RDDNY"))
 #ifdef F_RDDNY
 	        return F_RDDNY;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "F_RDLCK"))
+	    if (strEQ(name, "RDLCK"))
 #ifdef F_RDLCK
 	        return F_RDLCK;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "F_RWACC"))
+	    if (strEQ(name, "RWACC"))
 #ifdef F_RWACC
 	        return F_RWACC;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "F_RWDNY"))
+	    if (strEQ(name, "RWDNY"))
 #ifdef F_RWDNY
 	        return F_RWDNY;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "F_SETFD"))
+	    if (strEQ(name, "SETFD"))
 #ifdef F_SETFD
 	        return F_SETFD;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "F_SETFL"))
+	    if (strEQ(name, "SETFL"))
 #ifdef F_SETFL
 	        return F_SETFL;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "F_SETLK"))
+	    if (strEQ(name, "SETLK"))
 #ifdef F_SETLK
 	        return F_SETLK;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "F_SETLK64"))
+	    if (strEQ(name, "SETLK64"))
 #ifdef F_SETLK64
 	        return F_SETLK64;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "F_SETLKW"))
+	    if (strEQ(name, "SETLKW"))
 #ifdef F_SETLKW
 	        return F_SETLKW;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "F_SETLKW64"))
+	    if (strEQ(name, "SETLKW64"))
 #ifdef F_SETLKW64
 	        return F_SETLKW64;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "F_SETOWN"))
+	    if (strEQ(name, "SETOWN"))
 #ifdef F_SETOWN
 	        return F_SETOWN;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "F_SHARE"))
+	    if (strEQ(name, "SHARE"))
 #ifdef F_SHARE
 	        return F_SHARE;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "F_SHLCK"))
+	    if (strEQ(name, "SHLCK"))
 #ifdef F_SHLCK
 	        return F_SHLCK;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "F_UNLCK"))
+	    if (strEQ(name, "UNLCK"))
 #ifdef F_UNLCK
 	        return F_UNLCK;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "F_UNSHARE"))
+	    if (strEQ(name, "UNSHARE"))
 #ifdef F_UNSHARE
 	        return F_UNSHARE;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "F_WRACC"))
+	    if (strEQ(name, "WRACC"))
 #ifdef F_WRACC
 	        return F_WRACC;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "F_WRDNY"))
+	    if (strEQ(name, "WRDNY"))
 #ifdef F_WRDNY
 	        return F_WRDNY;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "F_WRLCK"))
+	    if (strEQ(name, "WRLCK"))
 #ifdef F_WRLCK
 	        return F_WRLCK;
 #else
@@ -274,79 +275,79 @@
 	    errno = EINVAL;
 	    return 0;
 	}
-        if (strEQ(name, "FAPPEND"))
+        if (strEQ(name, "APPEND"))
 #ifdef FAPPEND
             return FAPPEND;
 #else
             goto not_there;
 #endif
-        if (strEQ(name, "FASYNC"))
+        if (strEQ(name, "ASYNC"))
 #ifdef FASYNC
             return FASYNC;
 #else
             goto not_there;
 #endif
-        if (strEQ(name, "FCREAT"))
+        if (strEQ(name, "CREAT"))
 #ifdef FCREAT
             return FCREAT;
 #else
             goto not_there;
 #endif
-	if (strEQ(name, "FD_CLOEXEC"))
+	if (strEQ(name, "D_CLOEXEC"))
 #ifdef FD_CLOEXEC
 	    return FD_CLOEXEC;
 #else
 	    goto not_there;
 #endif
-	if (strEQ(name, "FDEFER"))
+	if (strEQ(name, "DEFER"))
 #ifdef FDEFER
 	    return FDEFER;
 #else
 	    goto not_there;
 #endif
-        if (strEQ(name, "FDSYNC"))
+        if (strEQ(name, "DSYNC"))
 #ifdef FDSYNC
             return FDSYNC;
 #else
             goto not_there;
 #endif
-        if (strEQ(name, "FEXCL"))
+        if (strEQ(name, "EXCL"))
 #ifdef FEXCL
             return FEXCL;
 #else
             goto not_there;
 #endif
-        if (strEQ(name, "FLARGEFILE"))
+        if (strEQ(name, "LARGEFILE"))
 #ifdef FLARGEFILE
             return FLARGEFILE;
 #else
             goto not_there;
 #endif
-        if (strEQ(name, "FNDELAY"))
+        if (strEQ(name, "NDELAY"))
 #ifdef FNDELAY
             return FNDELAY;
 #else
             goto not_there;
 #endif
-        if (strEQ(name, "FNONBLOCK"))
+        if (strEQ(name, "NONBLOCK"))
 #ifdef FNONBLOCK
             return FNONBLOCK;
 #else
             goto not_there;
 #endif
-        if (strEQ(name, "FRSYNC"))
+        if (strEQ(name, "RSYNC"))
 #ifdef FRSYNC
             return FRSYNC;
 #else
             goto not_there;
 #endif
-        if (strEQ(name, "FSYNC"))
+        if (strEQ(name, "SYNC"))
 #ifdef FSYNC
             return FSYNC;
 #else
             goto not_there;
 #endif
-        if (strEQ(name, "FTRUNC"))
+        if (strEQ(name, "TRUNC"))
 #ifdef FTRUNC
             return FTRUNC;
 #else
@@ -354,28 +355,29 @@
 #endif
 	break;
     case 'L':
-    	if (strnEQ(name, "LOCK_", 5)) {
+    	if (strnEQ(name, "OCK_", 4)) {
 	    /* We support flock() on systems which don't have it, so
 	       always supply the constants. */
-	    if (strEQ(name, "LOCK_SH"))
+	    name += 4;
+	    if (strEQ(name, "SH"))
 #ifdef LOCK_SH
 		return LOCK_SH;
 #else
 		return 1;
 #endif
-	    if (strEQ(name, "LOCK_EX"))
+	    if (strEQ(name, "EX"))
 #ifdef LOCK_EX
 		return LOCK_EX;
 #else
 		return 2;
 #endif
-    	    if (strEQ(name, "LOCK_NB"))
+    	    if (strEQ(name, "NB"))
 #ifdef LOCK_NB
 		return LOCK_NB;
 #else
 		return 4;
 #endif
-    	    if (strEQ(name, "LOCK_UN"))
+    	    if (strEQ(name, "UN"))
 #ifdef LOCK_UN
     	    	return LOCK_UN;
 #else
@@ -385,188 +387,189 @@
 	  goto not_there;
     	break;
     case 'O':
-	if (strnEQ(name, "O_", 2)) {
-	    if (strEQ(name, "O_ACCMODE"))
+	if (name[0] == '_') {
+	    name++;
+	    if (strEQ(name, "ACCMODE"))
 #ifdef O_ACCMODE
 	        return O_ACCMODE;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "O_APPEND"))
+	    if (strEQ(name, "APPEND"))
 #ifdef O_APPEND
 	        return O_APPEND;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "O_ASYNC"))
+	    if (strEQ(name, "ASYNC"))
 #ifdef O_ASYNC
 	        return O_ASYNC;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "O_BINARY"))
+	    if (strEQ(name, "BINARY"))
 #ifdef O_BINARY
 	        return O_BINARY;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "O_CREAT"))
+	    if (strEQ(name, "CREAT"))
 #ifdef O_CREAT
 	        return O_CREAT;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "O_DEFER"))
+	    if (strEQ(name, "DEFER"))
 #ifdef O_DEFER
 	        return O_DEFER;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "O_DIRECT"))
+	    if (strEQ(name, "DIRECT"))
 #ifdef O_DIRECT
 	        return O_DIRECT;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "O_DIRECTORY"))
+	    if (strEQ(name, "DIRECTORY"))
 #ifdef O_DIRECTORY
 	        return O_DIRECTORY;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "O_DSYNC"))
+	    if (strEQ(name, "DSYNC"))
 #ifdef O_DSYNC
 	        return O_DSYNC;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "O_EXCL"))
+	    if (strEQ(name, "EXCL"))
 #ifdef O_EXCL
 	        return O_EXCL;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "O_EXLOCK"))
+	    if (strEQ(name, "EXLOCK"))
 #ifdef O_EXLOCK
 	        return O_EXLOCK;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "O_LARGEFILE"))
+	    if (strEQ(name, "LARGEFILE"))
 #ifdef O_LARGEFILE
 	        return O_LARGEFILE;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "O_NDELAY"))
+	    if (strEQ(name, "NDELAY"))
 #ifdef O_NDELAY
 	        return O_NDELAY;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "O_NOCTTY"))
+	    if (strEQ(name, "NOCTTY"))
 #ifdef O_NOCTTY
 	        return O_NOCTTY;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "O_NOFOLLOW"))
+	    if (strEQ(name, "NOFOLLOW"))
 #ifdef O_NOFOLLOW
 	        return O_NOFOLLOW;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "O_NOINHERIT"))
+	    if (strEQ(name, "NOINHERIT"))
 #ifdef O_NOINHERIT
 	        return O_NOINHERIT;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "O_NONBLOCK"))
+	    if (strEQ(name, "NONBLOCK"))
 #ifdef O_NONBLOCK
 	        return O_NONBLOCK;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "O_RANDOM"))
+	    if (strEQ(name, "RANDOM"))
 #ifdef O_RANDOM
 	        return O_RANDOM;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "O_RAW"))
+	    if (strEQ(name, "RAW"))
 #ifdef O_RAW
 	        return O_RAW;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "O_RDONLY"))
+	    if (strEQ(name, "RDONLY"))
 #ifdef O_RDONLY
 	        return O_RDONLY;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "O_RDWR"))
+	    if (strEQ(name, "RDWR"))
 #ifdef O_RDWR
 	        return O_RDWR;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "O_RSYNC"))
+	    if (strEQ(name, "RSYNC"))
 #ifdef O_RSYNC
 	        return O_RSYNC;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "O_SEQUENTIAL"))
+	    if (strEQ(name, "SEQUENTIAL"))
 #ifdef O_SEQUENTIAL
 	        return O_SEQUENTIAL;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "O_SHLOCK"))
+	    if (strEQ(name, "SHLOCK"))
 #ifdef O_SHLOCK
 	        return O_SHLOCK;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "O_SYNC"))
+	    if (strEQ(name, "SYNC"))
 #ifdef O_SYNC
 	        return O_SYNC;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "O_TEMPORARY"))
+	    if (strEQ(name, "TEMPORARY"))
 #ifdef O_TEMPORARY
 	        return O_TEMPORARY;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "O_TEXT"))
+	    if (strEQ(name, "TEXT"))
 #ifdef O_TEXT
 	        return O_TEXT;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "O_TRUNC"))
+	    if (strEQ(name, "TRUNC"))
 #ifdef O_TRUNC
 	        return O_TRUNC;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "O_WRONLY"))
+	    if (strEQ(name, "WRONLY"))
 #ifdef O_WRONLY
 	        return O_WRONLY;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "O_ALIAS"))
+	    if (strEQ(name, "ALIAS"))
 #ifdef O_ALIAS
 	        return O_ALIAS;
 #else
 	        goto not_there;
 #endif
-	    if (strEQ(name, "O_RSRC"))
+	    if (strEQ(name, "RSRC"))
 #ifdef O_RSRC
 	        return O_RSRC;
 #else
@@ -576,171 +579,171 @@
 	  goto not_there;
 	break;
     case 'S':
-      switch (name[1]) {
+      switch (*(name++)) {
       case '_':
-	if (strEQ(name, "S_ISUID"))
+	if (strEQ(name, "ISUID"))
 #ifdef S_ISUID
 	  return S_ISUID;
 #else
 	  goto not_there;
 #endif
-	if (strEQ(name, "S_ISGID"))
+	if (strEQ(name, "ISGID"))
 #ifdef S_ISGID
 	  return S_ISGID;
 #else
 	  goto not_there;
 #endif
-	if (strEQ(name, "S_ISVTX"))
+	if (strEQ(name, "ISVTX"))
 #ifdef S_ISVTX
 	  return S_ISVTX;
 #else
 	  goto not_there;
 #endif
-	if (strEQ(name, "S_ISTXT"))
+	if (strEQ(name, "ISTXT"))
 #ifdef S_ISTXT
 	  return S_ISTXT;
 #else
 	  goto not_there;
 #endif
-	if (strEQ(name, "S_IFREG"))
+	if (strEQ(name, "IFREG"))
 #ifdef S_IFREG
 	  return S_IFREG;
 #else
 	  goto not_there;
 #endif
-	if (strEQ(name, "S_IFDIR"))
+	if (strEQ(name, "IFDIR"))
 #ifdef S_IFDIR
 	  return S_IFDIR;
 #else
 	  goto not_there;
 #endif
-	if (strEQ(name, "S_IFLNK"))
+	if (strEQ(name, "IFLNK"))
 #ifdef S_IFLNK
 	  return S_IFLNK;
 #else
 	  goto not_there;
 #endif
-	if (strEQ(name, "S_IFSOCK"))
+	if (strEQ(name, "IFSOCK"))
 #ifdef S_IFSOCK
 	  return S_IFSOCK;
 #else
 	  goto not_there;
 #endif
-	if (strEQ(name, "S_IFBLK"))
+	if (strEQ(name, "IFBLK"))
 #ifdef S_IFBLK
 	  return S_IFBLK;
 #else
 	  goto not_there;
 #endif
-	if (strEQ(name, "S_IFCHR"))
+	if (strEQ(name, "IFCHR"))
 #ifdef S_IFCHR
 	  return S_IFCHR;
 #else
 	  goto not_there;
 #endif
-	if (strEQ(name, "S_IFIFO"))
+	if (strEQ(name, "IFIFO"))
 #ifdef S_IFIFO
 	  return S_IFIFO;
 #else
 	  goto not_there;
 #endif
-	if (strEQ(name, "S_IFWHT"))
+	if (strEQ(name, "IFWHT"))
 #ifdef S_IFWHT
 	  return S_IFWHT;
 #else
 	  goto not_there;
 #endif
-	if (strEQ(name, "S_ENFMT"))
+	if (strEQ(name, "ENFMT"))
 #ifdef S_ENFMT
 	  return S_ENFMT;
 #else
 	  goto not_there;
 #endif
-	if (strEQ(name, "S_IRUSR"))
+	if (strEQ(name, "IRUSR"))
 #ifdef S_IRUSR
 	  return S_IRUSR;
 #else
 	  goto not_there;
 #endif
-	if (strEQ(name, "S_IWUSR"))
+	if (strEQ(name, "IWUSR"))
 #ifdef S_IWUSR
 	  return S_IWUSR;
 #else
 	  goto not_there;
 #endif
-	if (strEQ(name, "S_IXUSR"))
+	if (strEQ(name, "IXUSR"))
 #ifdef S_IXUSR
 	  return S_IXUSR;
 #else
 	  goto not_there;
 #endif
-	if (strEQ(name, "S_IRWXU"))
+	if (strEQ(name, "IRWXU"))
 #ifdef S_IRWXU
 	  return S_IRWXU;
 #else
 	  goto not_there;
 #endif
-	if (strEQ(name, "S_IRGRP"))
+	if (strEQ(name, "IRGRP"))
 #ifdef S_IRGRP
 	  return S_IRGRP;
 #else
 	  goto not_there;
 #endif
-	if (strEQ(name, "S_IWGRP"))
+	if (strEQ(name, "IWGRP"))
 #ifdef S_IWGRP
 	  return S_IWGRP;
 #else
 	  goto not_there;
 #endif
-	if (strEQ(name, "S_IXGRP"))
+	if (strEQ(name, "IXGRP"))
 #ifdef S_IXGRP
 	  return S_IXGRP;
 #else
 	  goto not_there;
 #endif
-	if (strEQ(name, "S_IRWXG"))
+	if (strEQ(name, "IRWXG"))
 #ifdef S_IRWXG
 	  return S_IRWXG;
 #else
 	  goto not_there;
 #endif
-	if (strEQ(name, "S_IROTH"))
+	if (strEQ(name, "IROTH"))
 #ifdef S_IROTH
 	  return S_IROTH;
 #else
 	  goto not_there;
 #endif
-	if (strEQ(name, "S_IWOTH"))
+	if (strEQ(name, "IWOTH"))
 #ifdef S_IWOTH
 	  return S_IWOTH;
 #else
 	  goto not_there;
 #endif
-	if (strEQ(name, "S_IXOTH"))
+	if (strEQ(name, "IXOTH"))
 #ifdef S_IXOTH
 	  return S_IXOTH;
 #else
 	  goto not_there;
 #endif
-	if (strEQ(name, "S_IRWXO"))
+	if (strEQ(name, "IRWXO"))
 #ifdef S_IRWXO
 	  return S_IRWXO;
 #else
 	  goto not_there;
 #endif
-	if (strEQ(name, "S_IREAD"))
+	if (strEQ(name, "IREAD"))
 #ifdef S_IREAD
 	  return S_IREAD;
 #else
 	  goto not_there;
 #endif
-	if (strEQ(name, "S_IWRITE"))
+	if (strEQ(name, "IWRITE"))
 #ifdef S_IWRITE
 	  return S_IWRITE;
 #else
 	  goto not_there;
 #endif
-	if (strEQ(name, "S_IEXEC"))
+	if (strEQ(name, "IEXEC"))
 #ifdef S_IEXEC
 	  return S_IEXEC;
 #else
@@ -748,19 +751,19 @@
 #endif
 	break;
       case 'E':
-	  if (strEQ(name, "SEEK_CUR"))
+	  if (strEQ(name, "EK_CUR"))
 #ifdef SEEK_CUR
 	    return SEEK_CUR;
 #else
 	    return 1;
 #endif
-	if (strEQ(name, "SEEK_END"))
+	if (strEQ(name, "EK_END"))
 #ifdef SEEK_END
 	    return SEEK_END;
 #else
 	    return 2;
 #endif
-	if (strEQ(name, "SEEK_SET"))
+	if (strEQ(name, "EK_SET"))
 #ifdef SEEK_SET
 	    return SEEK_SET;
 #else
@@ -780,8 +783,7 @@
 
 MODULE = Fcntl		PACKAGE = Fcntl
 
-double
-constant(name,arg)
+IV
+constant(name)
 	char *		name
-	int		arg
 
--- ext/Fcntl/Fcntl.pm.orig	Tue Aug  1 03:31:40 2000
+++ ext/Fcntl/Fcntl.pm	Sat Dec 16 20:55:31 2000
@@ -201,7 +201,7 @@
 
 sub AUTOLOAD {
     (my $constname = $AUTOLOAD) =~ s/.*:://;
-    my $val = constant($constname, 0);
+    my $val = constant($constname);
     if ($! != 0) {
 	if ($! =~ /Invalid/ || $!{EINVAL}) {
 	    $AutoLoader::AUTOLOAD = $AUTOLOAD;
--- t/op/goto_xs.t.orig	Tue Aug 29 13:54:13 2000
+++ t/op/goto_xs.t	Sat Dec 16 20:58:16 2000
@@ -35,7 +35,7 @@
 ### First, we check whether Fcntl::constant returns sane answers.
 # Fcntl::constant("LOCK_SH",0) should always succeed.
 
-$value = Fcntl::constant($VALID,0);
+$value = Fcntl::constant($VALID);
 print((!defined $value)
       ? "not ok 1\n# Sanity check broke, remaining tests will fail.\n"
       : "ok 1\n");
@@ -45,20 +45,20 @@
 # test "goto &function_constant"
 sub goto_const { goto &Fcntl::constant; }
 
-$ret = goto_const($VALID,0);
+$ret = goto_const($VALID);
 print(($ret == $value) ? "ok 2\n" : "not ok 2\n# ($ret != $value)\n");
 
 # test "goto &$function_package_and_name"
 $FNAME1 = 'Fcntl::constant';
 sub goto_name1 { goto &$FNAME1; }
 
-$ret = goto_name1($VALID,0);
+$ret = goto_name1($VALID);
 print(($ret == $value) ? "ok 3\n" : "not ok 3\n# ($ret != $value)\n");
 
 # test "goto &$function_package_and_name" again, with dirtier stack
-$ret = goto_name1($VALID,0);
+$ret = goto_name1($VALID);
 print(($ret == $value) ? "ok 4\n" : "not ok 4\n# ($ret != $value)\n");
-$ret = goto_name1($VALID,0);
+$ret = goto_name1($VALID);
 print(($ret == $value) ? "ok 5\n" : "not ok 5\n# ($ret != $value)\n");
 
 # test "goto &$function_name" from local package
@@ -67,14 +67,14 @@
 sub goto_name2 { goto &$FNAME2; }
 package main;
 
-$ret = Fcntl::goto_name2($VALID,0);
+$ret = Fcntl::goto_name2($VALID);
 print(($ret == $value) ? "ok 6\n" : "not ok 6\n# ($ret != $value)\n");
 
 # test "goto &$function_ref"
 $FREF = \&Fcntl::constant;
 sub goto_ref { goto &$FREF; }
 
-$ret = goto_ref($VALID,0);
+$ret = goto_ref($VALID);
 print(($ret == $value) ? "ok 7\n" : "not ok 7\n# ($ret != $value)\n");
 
 ### tests where the args are not on stack but in GvAV(defgv) (ie, @_)
@@ -82,17 +82,17 @@
 # test "goto &function_constant" from a sub called without arglist
 sub call_goto_const { &goto_const; }
 
-$ret = call_goto_const($VALID,0);
+$ret = call_goto_const($VALID);
 print(($ret == $value) ? "ok 8\n" : "not ok 8\n# ($ret != $value)\n");
 
 # test "goto &$function_package_and_name" from a sub called without arglist
 sub call_goto_name1 { &goto_name1; }
 
-$ret = call_goto_name1($VALID,0);
+$ret = call_goto_name1($VALID);
 print(($ret == $value) ? "ok 9\n" : "not ok 9\n# ($ret != $value)\n");
 
 # test "goto &$function_ref" from a sub called without arglist
 sub call_goto_ref { &goto_ref; }
 
-$ret = call_goto_ref($VALID,0);
+$ret = call_goto_ref($VALID);
 print(($ret == $value) ? "ok 10\n" : "not ok 10\n# ($ret != $value)\n");

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About