From: Jarkko Hietaniemi Date: Fri, 6 Aug 1999 11:59:11 +0000 (+0000) Subject: More Fcntl constants. (This process really needs X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ac88732c4568487a2aa5fbad75ba393744f616ba;p=p5sagit%2Fp5-mst-13.2.git More Fcntl constants. (This process really needs to be automated, at least partly, see the Errno extension.) Now also the SEEK_ constants are available via the Fcntl. Yes, this is redundant (IO::Seekable and POSIX supply them already), but now Fcntl is a one-stop shopping mall for all your file-related constants. p4raw-id: //depot/cfgperl@3929 --- diff --git a/ext/Fcntl/Fcntl.pm b/ext/Fcntl/Fcntl.pm index 0f70840..699ee4a 100644 --- a/ext/Fcntl/Fcntl.pm +++ b/ext/Fcntl/Fcntl.pm @@ -53,15 +53,28 @@ $VERSION = "1.03"; @EXPORT = qw( FD_CLOEXEC + F_ALLOCSP + F_ALLOCSP64 + F_COMPAT + F_DUP2FD F_DUPFD F_EXLCK + F_FREESP + F_FREESP64 + F_FSYNC + F_FSYNC64 F_GETFD F_GETFL F_GETLK F_GETLK64 F_GETOWN + F_NODNY F_POSIX + F_RDACC + F_RDDNY F_RDLCK + F_RWACC + F_RWDNY F_SETFD F_SETFL F_SETLK @@ -69,8 +82,12 @@ $VERSION = "1.03"; F_SETLKW F_SETLKW64 F_SETOWN + F_SHARE F_SHLCK F_UNLCK + F_UNSHARE + F_WRACC + F_WRDNY F_WRLCK O_ACCMODE O_APPEND @@ -93,6 +110,9 @@ $VERSION = "1.03"; O_TEXT O_TRUNC O_WRONLY + SEEK_SET + SEEK_CUR + SEEK_END ); # Other items we are prepared to export if requested @@ -101,9 +121,12 @@ $VERSION = "1.03"; FASYNC FCREAT FDEFER + FDSYNC FEXCL + FLARGEFILE FNDELAY FNONBLOCK + FRSYNC FSYNC FTRUNC LOCK_EX @@ -114,8 +137,8 @@ $VERSION = "1.03"; # Named groups of exports %EXPORT_TAGS = ( 'flock' => [qw(LOCK_SH LOCK_EX LOCK_NB LOCK_UN)], - 'Fcompat' => [qw(FAPPEND FASYNC FCREAT FDEFER FEXCL - FNDELAY FNONBLOCK FSYNC FTRUNC)], + 'Fcompat' => [qw(FAPPEND FASYNC FCREAT FDEFER FDSYNC FEXCL FLARGEFILE + FNDELAY FNONBLOCK FRSYNC FSYNC FTRUNC)], ); sub AUTOLOAD { diff --git a/ext/Fcntl/Fcntl.xs b/ext/Fcntl/Fcntl.xs index bc16cc9..0dab7f1 100644 --- a/ext/Fcntl/Fcntl.xs +++ b/ext/Fcntl/Fcntl.xs @@ -15,6 +15,10 @@ #endif #endif +#ifdef I_UNISTD +#include +#endif + /* This comment is a kludge to get metaconfig to see the symbols VAL_O_NONBLOCK VAL_EAGAIN @@ -43,6 +47,30 @@ constant(char *name, int arg) switch (*name) { case 'F': if (strnEQ(name, "F_", 2)) { + if (strEQ(name, "F_ALLOCSP")) +#ifdef F_ALLOCSP + return F_ALLOCSP; +#else + goto not_there; +#endif + if (strEQ(name, "F_ALLOCSP64")) +#ifdef F_ALLOCSP64 + return F_ALLOCSP64; +#else + goto not_there; +#endif + if (strEQ(name, "F_COMPAT")) +#ifdef F_COMPAT + return F_COMPAT; +#else + goto not_there; +#endif + if (strEQ(name, "F_DUP2FD")) +#ifdef F_DUP2FD + return F_DUP2FD; +#else + goto not_there; +#endif if (strEQ(name, "F_DUPFD")) #ifdef F_DUPFD return F_DUPFD; @@ -55,6 +83,30 @@ constant(char *name, int arg) #else goto not_there; #endif + if (strEQ(name, "F_FREESP")) +#ifdef F_FREESP + return F_FREESP; +#else + goto not_there; +#endif + if (strEQ(name, "F_FREESP64")) +#ifdef F_FREESP64 + return F_FREESP64; +#else + goto not_there; +#endif + if (strEQ(name, "F_FSYNC")) +#ifdef F_FSYNC + return F_FSYNC; +#else + goto not_there; +#endif + if (strEQ(name, "F_FSYNC64")) +#ifdef F_FSYNC64 + return F_FSYNC64; +#else + goto not_there; +#endif if (strEQ(name, "F_GETFD")) #ifdef F_GETFD return F_GETFD; @@ -85,18 +137,48 @@ constant(char *name, int arg) #else goto not_there; #endif + if (strEQ(name, "F_NODNY")) +#ifdef F_NODNY + return F_NODNY; +#else + goto not_there; +#endif if (strEQ(name, "F_POSIX")) #ifdef F_POSIX return F_POSIX; #else goto not_there; #endif + if (strEQ(name, "F_RDACC")) +#ifdef F_RDACC + return F_RDACC; +#else + goto not_there; +#endif + if (strEQ(name, "F_RDDNY")) +#ifdef F_RDDNY + return F_RDDNY; +#else + goto not_there; +#endif if (strEQ(name, "F_RDLCK")) #ifdef F_RDLCK return F_RDLCK; #else goto not_there; #endif + if (strEQ(name, "F_RWACC")) +#ifdef F_RWACC + return F_RWACC; +#else + goto not_there; +#endif + if (strEQ(name, "F_RWDNY")) +#ifdef F_RWDNY + return F_RWDNY; +#else + goto not_there; +#endif if (strEQ(name, "F_SETFD")) #ifdef F_SETFD return F_SETFD; @@ -139,6 +221,12 @@ constant(char *name, int arg) #else goto not_there; #endif + if (strEQ(name, "F_SHARE")) +#ifdef F_SHARE + return F_SHARE; +#else + goto not_there; +#endif if (strEQ(name, "F_SHLCK")) #ifdef F_SHLCK return F_SHLCK; @@ -151,6 +239,24 @@ constant(char *name, int arg) #else goto not_there; #endif + if (strEQ(name, "F_UNSHARE")) +#ifdef F_UNSHARE + return F_UNSHARE; +#else + goto not_there; +#endif + if (strEQ(name, "F_WRACC")) +#ifdef F_WRACC + return F_WRACC; +#else + goto not_there; +#endif + if (strEQ(name, "F_WRDNY")) +#ifdef F_WRDNY + return F_WRDNY; +#else + goto not_there; +#endif if (strEQ(name, "F_WRLCK")) #ifdef F_WRLCK return F_WRLCK; @@ -190,12 +296,24 @@ constant(char *name, int arg) #else goto not_there; #endif + if (strEQ(name, "FDSYNC")) +#ifdef FDSYNC + return FDSYNC; +#else + goto not_there; +#endif if (strEQ(name, "FEXCL")) #ifdef FEXCL return FEXCL; #else goto not_there; #endif + if (strEQ(name, "FLARGEFILE")) +#ifdef FLARGEFILE + return FLARGEFILE; +#else + goto not_there; +#endif if (strEQ(name, "FNDELAY")) #ifdef FNDELAY return FNDELAY; @@ -208,6 +326,12 @@ constant(char *name, int arg) #else goto not_there; #endif + if (strEQ(name, "FRSYNC")) +#ifdef FRSYNC + return FRSYNC; +#else + goto not_there; +#endif if (strEQ(name, "FSYNC")) #ifdef FSYNC return FSYNC; @@ -383,6 +507,26 @@ constant(char *name, int arg) } else goto not_there; break; + case 'S': + if (strEQ(name, "SEEK_CUR")) +#ifdef SEEK_CUR + return SEEK_CUR; +#else + goto not_there; +#endif + if (strEQ(name, "SEEK_END")) +#ifdef SEEK_END + return SEEK_END; +#else + goto not_there; +#endif + if (strEQ(name, "SEEK_SET")) +#ifdef SEEK_SET + return SEEK_SET; +#else + goto not_there; +#endif + break; } errno = EINVAL; return 0; diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index aa55e3e..3e10038 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -3496,10 +3496,12 @@ See L for more details on unary operators and the comma operator. Sets FILEHANDLE's position, just like the C call of C. FILEHANDLE may be an expression whose value gives the name of the filehandle. The values for WHENCE are C<0> to set the new position to -POSITION, C<1> to set it to the current position plus POSITION, and C<2> to -set it to EOF plus POSITION (typically negative). For WHENCE you may -use the constants C, C, and C from either the -C or the POSIX module. Returns C<1> upon success, C<0> otherwise. +POSITION, C<1> to set it to the current position plus POSITION, and +C<2> to set it to EOF plus POSITION (typically negative). For WHENCE +you may use the constants C, C, and C +(start of the file, current position, end of the file) from any of the +modules Fcntl, C, or POSIX. Returns C<1> upon success, +C<0> otherwise. If you want to position file for C or C, don't use C--buffering makes its effect on the file's system position @@ -4481,13 +4483,14 @@ for a return value for 0 to decide whether you're done. Sets FILEHANDLE's system position using the system call lseek(2). It bypasses stdio, so mixing this with reads (other than C), -C, C, C, C, or C may cause -confusion. FILEHANDLE may be an expression whose value gives the name -of the filehandle. The values for WHENCE are C<0> to set the new -position to POSITION, C<1> to set the it to the current position plus -POSITION, and C<2> to set it to EOF plus POSITION (typically negative). -For WHENCE, you may use the constants C, C, and -C from either the C or the POSIX module. +C, C, C, C, or C may cause confusion. +FILEHANDLE may be an expression whose value gives the name of the +filehandle. The values for WHENCE are C<0> to set the new position to +POSITION, C<1> to set the it to the current position plus POSITION, +and C<2> to set it to EOF plus POSITION (typically negative). For +WHENCE, you may also use the constants C, C, and +C (start of the file, current position, end of the file) +from any of the modules Fcntl, C, or POSIX. Returns the new position, or the undefined value on failure. A position of zero is returned as the string C<"0 but true">; thus C returns