POSIX.xs revision 7c478bd95313f5f23a4c958a745db2134aa03244
#ifdef WIN32
#define _POSIX_
#endif
#define PERL_NO_GET_CONTEXT
#include "EXTERN.h"
#define PERLIO_NOT_STDIO 1
#include "perl.h"
#include "XSUB.h"
# define open PerlLIO_open3
#endif
#include <ctype.h>
#include <dirent.h>
#endif
#include <errno.h>
#ifdef I_FLOAT
#include <float.h>
#endif
#ifdef I_LIMITS
#include <limits.h>
#endif
#include <locale.h>
#include <math.h>
#ifdef I_PWD
#include <pwd.h>
#endif
#include <setjmp.h>
#include <signal.h>
#include <stdarg.h>
#ifdef I_STDDEF
#include <stddef.h>
#endif
/* XXX This comment is just to make I_TERMIO and I_SGTTY visible to
metaconfig for future extension writers. We don't use them in POSIX.
(This is really sneaky :-) --AD
*/
#if defined(I_TERMIOS)
#include <termios.h>
#endif
#ifdef I_STDLIB
#include <stdlib.h>
#endif
#include <string.h>
#include <time.h>
#ifdef I_UNISTD
#include <unistd.h>
#endif
#ifdef MACOS_TRADITIONAL
#endif
#include <fcntl.h>
#if defined(__VMS) && !defined(__POSIX_SOURCE)
# include <libdef.h> /* LIB$_INVARG constant */
# include <starlet.h> /* prototype for sys$gettim() */
# if DECC_VERSION < 50000000
# endif
# define HAS_TZNAME /* shows up in VMS 7.0 or Dec C 5.6 */
# include <utsname.h>
# endif /* __VMS_VER >= 70000000 or Dec C 5.6 */
/* The POSIX notion of ttyname() is better served by getname() under VMS */
static char ttnambuf[64];
/* The non-POSIX CRTL times() has void return type, so we just get the
current time directly */
dTHX;
/* Get wall time and convert to 10 ms intervals to
* produce the return value that the POSIX standard expects */
# include <ints.h>
vmstime /= 100000;
# else
/* (Older hw or ccs don't have an atomic 64-bit type, so we
* juggle 32-bit ints (and a float) to produce a time_t result
* with minimal loss of information.) */
# endif
/* Fill in the struct tms using the CRTL routine . . .*/
}
#else
#if defined (__CYGWIN__)
#endif
#if defined (WIN32)
# define sigset_t long
# define pid_t long
# ifdef __BORLANDC__
# endif
# ifdef _MSC_VER
# define mode_t short
# endif
# ifdef __MINGW32__
# define mode_t short
# ifndef tzset
# endif
# ifndef _POSIX_OPEN_MAX
# endif
# endif
#else
# ifndef HAS_MKFIFO
# if defined(OS2) || defined(MACOS_TRADITIONAL)
# else /* !( defined OS2 ) */
# ifndef mkfifo
# endif
# endif
# endif /* !HAS_MKFIFO */
# ifdef MACOS_TRADITIONAL
# else
# include <grp.h>
# ifdef HAS_UNAME
# endif
# endif
# ifdef I_UTIME
# include <utime.h>
# endif
#endif /* WIN32 */
#endif /* __VMS */
typedef int SysRet;
typedef long SysRetLong;
typedef sigset_t* POSIX__SigSet;
typedef HV* POSIX__SigAction;
#ifdef I_TERMIOS
typedef struct termios* POSIX__Termios;
#else /* Define termios types to int, and call not_here for the functions.*/
#define POSIX__Termios int
#define speed_t int
#define tcflag_t int
#define cc_t int
#endif
/* Possibly needed prototypes */
char *cuserid (char *);
double strtod (const char *, char **);
long strtol (const char *, char **, int);
unsigned long strtoul (const char *, char **, int);
#ifndef HAS_CUSERID
#endif
#ifndef HAS_DIFFTIME
#ifndef difftime
#endif
#endif
#ifndef HAS_FPATHCONF
#endif
#ifndef HAS_MKTIME
#endif
#ifndef HAS_NICE
#endif
#ifndef HAS_PATHCONF
#endif
#ifndef HAS_SYSCONF
#endif
#ifndef HAS_READLINK
#endif
#ifndef HAS_SETPGID
#endif
#ifndef HAS_SETSID
#endif
#ifndef HAS_STRCOLL
#endif
#ifndef HAS_STRTOD
#endif
#ifndef HAS_STRTOL
#endif
#ifndef HAS_STRTOUL
#endif
#ifndef HAS_STRXFRM
#endif
#ifndef HAS_TCGETPGRP
#endif
#ifndef HAS_TCSETPGRP
#endif
#ifndef HAS_TIMES
#endif
#ifndef HAS_UNAME
#endif
#ifndef HAS_WAITPID
#endif
#ifndef HAS_MBLEN
#ifndef mblen
#endif
#endif
#ifndef HAS_MBSTOWCS
#endif
#ifndef HAS_MBTOWC
#endif
#ifndef HAS_WCSTOMBS
#endif
#ifndef HAS_WCTOMB
#endif
#if !defined(HAS_MBLEN) && !defined(HAS_MBSTOWCS) && !defined(HAS_MBTOWC) && !defined(HAS_WCSTOMBS) && !defined(HAS_WCTOMB)
/* If we don't have these functions, then we wouldn't have gotten a typedef
for wchar_t, the wide character type. Defining wchar_t allows the
functions referencing it to compile. Its actual type is then meaningless,
since without the above functions, all sections using it end up calling
not_here() and croak. --Kaveh Ghazi (ghazi@noc.rutgers.edu) 9/18/94. */
#ifndef wchar_t
#define wchar_t char
#endif
#endif
#ifndef HAS_LOCALECONV
#endif
#ifdef HAS_TZNAME
# if !defined(WIN32) && !defined(__CYGWIN__)
extern char *tzname[];
# endif
#else
#endif
#endif
* fields for which we don't have Configure support yet:
* char *tm_zone; -- abbreviation of timezone name
* long tm_gmtoff; -- offset from GMT in seconds
* To workaround core dumps from the uninitialised tm_zone we get the
* system to give us a reasonable struct to copy. This fix means that
* strftime uses the tm_zone and tm_gmtoff values returned by
* localtime(time()). That should give the desired result most of the
* time. But probably not always!
*
* This is a temporary workaround to be removed once Configure
* support is added and NETaa14816 is considered in full.
* It does not address tzname aspects of NETaa14816.
*/
#ifdef HAS_GNULIBC
# ifndef STRUCT_TM_HASZONE
# define STRUCT_TM_HASZONE
# endif
#endif
#ifdef STRUCT_TM_HASZONE
static void
{
}
#else
#endif
/*
* mini_mktime - normalise struct tm values without the localtime()
* semantics (and overhead) of mktime().
*/
static void
{
int yearday;
int secs;
#define DAYS_PER_YEAR 365
/* parentheses deliberately absent on these two, otherwise they don't work */
/* as used here, the algorithm leaves Sunday as day 1 unless we adjust it */
/*
*
* With a suitable offset for numeric value of the month, one can find
* an offset into the year by considering months to have 30.6 (153/5) days,
* using integer arithmetic (i.e., with truncation). To avoid too much
* messing about with leap days, we consider January and February to be
* the 13th and 14th month of the previous year. After that transformation,
* we need the month index we use to be high by 1 from 'normal human' usage,
* so the month index values we use run from 4 through 15.
*
* Given that, and the rules for the Gregorian calendar (leap years are those
* divisible by 4 unless also divisible by 100, when they must be divisible
* by 400 instead), we can simply calculate the number of days since some
* arbitrary 'beginning of time' by futzing with the (adjusted) year number,
* the days we derive from our month index, and adding in the day of the
* month. The value used here is not adjusted for the actual origin which
* it normally would use (1 January A.D. 1), since we're not exposing it.
* We're only building the value so we can turn around and get the
* normalised values for the year, month, day-of-month, and day-of-year.
*
* For going backward, we need to bias the value we're using so that we find
* the right year value. (Basically, we don't want the contribution of
* March 1st to the number to apply while deriving the year). Having done
* that, we 'count up' the contribution to the year number by accounting for
* full quadracenturies (400-year periods) with their extra leap days, plus
* the contribution from full centuries (to avoid counting in the lost leap
* days), plus the contribution from full quad-years (to count in the normal
* leap days), plus the leftover contribution from any non-leap years.
* At this point, if we were working with an actual leap day, we'll have 0
* days left over. This is also true for March 1st, however. So, we have
* to special-case that result, and (earlier) keep track of the 'odd'
* century and year contributions. If we got 4 extra centuries in a qcent,
* or 4 extra years in a qyear, then it's a leap day and we call it 29 Feb.
* Otherwise, we add back in the earlier bias we removed (the 123 from
* figuring in March 1st), find the month index (integer division by 30.6),
* and the remainder is the day-of-month. We then have to convert back to
* 'real' months (including fixing January and February from being 14/15 in
* the previous year to being in the proper year). After that, to get
* tm_yday, we work with the normalised year and get a new yearday value for
* January 1st, which we subtract from the yearday value we had earlier,
* representing the date we've re-built. This is done from January 1
* because tm_yday is 0-origin.
*
* Since POSIX time routines are only guaranteed to work for times since the
* UNIX epoch (00:00:00 1 Jan 1970 UTC), the fact that this algorithm
* applies Gregorian calendar rules even to dates before the 16th century
* doesn't bother me. Besides, you'd need cultural context for a given
* date to know whether it was Julian or Gregorian calendar, and that's
* outside the scope for this routine. Since we convert back based on the
* same rules we used to build the yearday, you'll only get strange results
* for input which needed normalising, or for the 'odd' century years which
* were leap years in the Julian calander but not in the Gregorian one.
* I can live with that.
*
* This algorithm also fails to handle years before A.D. 1 gracefully, but
* that's still outside the scope for POSIX time manipulation, so I don't
* care.
*/
/* allow given yday with no month & mday to dominate the result */
month = 0;
mday = 0;
}
else {
jday = 0;
}
if (month >= 2)
month+=2;
else
/*
* Note that we don't know when leap-seconds were or will be,
* so we have to trust the user if we get something which looks
* like a sensible leap-second. Wild values for seconds will
* be rationalised, however.
*/
secs = 0;
}
else {
}
if (secs < 0) {
/* got negative remainder, but need positive time */
/* back off an extra day to compensate */
}
else {
}
}
else if (secs >= SECS_PER_DAY) {
secs %= SECS_PER_DAY;
}
secs %= SECS_PER_HOUR;
secs %= 60;
/* done with time of day effects */
/*
* The algorithm for yearday has (so far) left it high by 428.
* To avoid mistaking a legitimate Feb 29 as Mar 1, we need to
* bias it by 123 while trying to figure out what year it
* really represents. Even with this tweak, the reverse
* translation fails for years before A.D. 0001.
* It would still fail for Feb 29, but we catch that one below.
*/
yearday -= YEAR_ADJUST;
yearday %= DAYS_PER_CENT;
yearday %= DAYS_PER_YEAR;
month = 1;
yearday = 29;
}
else {
/* recover other leap-year adjustment */
if (month > 13) {
month-=14;
year++;
}
else {
month-=2;
}
}
if (yearday) {
}
else {
}
/* re-build yearday based on Jan 1 to get tm_yday */
year--;
/* fix tm_wday if not overridden by caller */
}
#ifdef HAS_LONG_DOUBLE
# if LONG_DOUBLESIZE > NVSIZE
# endif
#endif
#ifndef HAS_LONG_DOUBLE
#ifdef LDBL_MAX
#endif
#ifdef LDBL_MIN
#endif
#ifdef LDBL_EPSILON
#endif
#endif
static int
not_here(char *s)
{
croak("POSIX::%s not implemented on this architecture", s);
return -1;
}
static
{
errno = 0;
switch (*name) {
case 'A':
#ifdef ARG_MAX
return ARG_MAX;
#else
goto not_there;
#endif
break;
case 'B':
#ifdef BUFSIZ
return BUFSIZ;
#else
goto not_there;
#endif
#ifdef BRKINT
return BRKINT;
#else
goto not_there;
#endif
#ifdef B9600
return B9600;
#else
goto not_there;
#endif
#ifdef B19200
return B19200;
#else
goto not_there;
#endif
#ifdef B38400
return B38400;
#else
goto not_there;
#endif
#ifdef B0
return B0;
#else
goto not_there;
#endif
#ifdef B110
return B110;
#else
goto not_there;
#endif
#ifdef B1200
return B1200;
#else
goto not_there;
#endif
#ifdef B134
return B134;
#else
goto not_there;
#endif
#ifdef B150
return B150;
#else
goto not_there;
#endif
#ifdef B1800
return B1800;
#else
goto not_there;
#endif
#ifdef B200
return B200;
#else
goto not_there;
#endif
#ifdef B2400
return B2400;
#else
goto not_there;
#endif
#ifdef B300
return B300;
#else
goto not_there;
#endif
#ifdef B4800
return B4800;
#else
goto not_there;
#endif
#ifdef B50
return B50;
#else
goto not_there;
#endif
#ifdef B600
return B600;
#else
goto not_there;
#endif
#ifdef B75
return B75;
#else
goto not_there;
#endif
break;
case 'C':
#ifdef CHAR_BIT
return CHAR_BIT;
#else
goto not_there;
#endif
#ifdef CHAR_MAX
return CHAR_MAX;
#else
goto not_there;
#endif
#ifdef CHAR_MIN
return CHAR_MIN;
#else
goto not_there;
#endif
#ifdef CHILD_MAX
return CHILD_MAX;
#else
goto not_there;
#endif
#ifdef CLK_TCK
return CLK_TCK;
#else
goto not_there;
#endif
#ifdef CLOCAL
return CLOCAL;
#else
goto not_there;
#endif
#ifdef CLOCKS_PER_SEC
return CLOCKS_PER_SEC;
#else
goto not_there;
#endif
#ifdef CREAD
return CREAD;
#else
goto not_there;
#endif
#ifdef CS5
return CS5;
#else
goto not_there;
#endif
#ifdef CS6
return CS6;
#else
goto not_there;
#endif
#ifdef CS7
return CS7;
#else
goto not_there;
#endif
#ifdef CS8
return CS8;
#else
goto not_there;
#endif
#ifdef CSIZE
return CSIZE;
#else
goto not_there;
#endif
#ifdef CSTOPB
return CSTOPB;
#else
goto not_there;
#endif
break;
case 'D':
#ifdef DBL_MAX
return DBL_MAX;
#else
goto not_there;
#endif
#ifdef DBL_MIN
return DBL_MIN;
#else
goto not_there;
#endif
#ifdef DBL_DIG
return DBL_DIG;
#else
goto not_there;
#endif
#ifdef DBL_EPSILON
return DBL_EPSILON;
#else
goto not_there;
#endif
#ifdef DBL_MANT_DIG
return DBL_MANT_DIG;
#else
goto not_there;
#endif
#ifdef DBL_MAX_10_EXP
return DBL_MAX_10_EXP;
#else
goto not_there;
#endif
#ifdef DBL_MAX_EXP
return DBL_MAX_EXP;
#else
goto not_there;
#endif
#ifdef DBL_MIN_10_EXP
return DBL_MIN_10_EXP;
#else
goto not_there;
#endif
#ifdef DBL_MIN_EXP
return DBL_MIN_EXP;
#else
goto not_there;
#endif
break;
case 'E':
switch (name[1]) {
case 'A':
#ifdef EACCES
return EACCES;
#else
goto not_there;
#endif
#ifdef EADDRINUSE
return EADDRINUSE;
#else
goto not_there;
#endif
#ifdef EADDRNOTAVAIL
return EADDRNOTAVAIL;
#else
goto not_there;
#endif
#ifdef EAFNOSUPPORT
return EAFNOSUPPORT;
#else
goto not_there;
#endif
#ifdef EAGAIN
return EAGAIN;
#else
goto not_there;
#endif
#ifdef EALREADY
return EALREADY;
#else
goto not_there;
#endif
break;
case 'B':
#ifdef EBADF
return EBADF;
#else
goto not_there;
#endif
#ifdef EBUSY
return EBUSY;
#else
goto not_there;
#endif
break;
case 'C':
#ifdef ECHILD
return ECHILD;
#else
goto not_there;
#endif
#ifdef ECHO
return ECHO;
#else
goto not_there;
#endif
#ifdef ECHOE
return ECHOE;
#else
goto not_there;
#endif
#ifdef ECHOK
return ECHOK;
#else
goto not_there;
#endif
#ifdef ECHONL
return ECHONL;
#else
goto not_there;
#endif
#ifdef ECONNABORTED
return ECONNABORTED;
#else
goto not_there;
#endif
#ifdef ECONNREFUSED
return ECONNREFUSED;
#else
goto not_there;
#endif
#ifdef ECONNRESET
return ECONNRESET;
#else
goto not_there;
#endif
break;
case 'D':
#ifdef EDEADLK
return EDEADLK;
#else
goto not_there;
#endif
#ifdef EDESTADDRREQ
return EDESTADDRREQ;
#else
goto not_there;
#endif
#ifdef EDOM
return EDOM;
#else
goto not_there;
#endif
#ifdef EDQUOT
return EDQUOT;
#else
goto not_there;
#endif
break;
case 'E':
#ifdef EEXIST
return EEXIST;
#else
goto not_there;
#endif
break;
case 'F':
#ifdef EFAULT
return EFAULT;
#else
goto not_there;
#endif
#ifdef EFBIG
return EFBIG;
#else
goto not_there;
#endif
break;
case 'H':
#ifdef EHOSTDOWN
return EHOSTDOWN;
#else
goto not_there;
#endif
#ifdef EHOSTUNREACH
return EHOSTUNREACH;
#else
goto not_there;
#endif
break;
case 'I':
#ifdef EINPROGRESS
return EINPROGRESS;
#else
goto not_there;
#endif
#ifdef EINTR
return EINTR;
#else
goto not_there;
#endif
#ifdef EINVAL
return EINVAL;
#else
goto not_there;
#endif
#ifdef EIO
return EIO;
#else
goto not_there;
#endif
#ifdef EISCONN
return EISCONN;
#else
goto not_there;
#endif
#ifdef EISDIR
return EISDIR;
#else
goto not_there;
#endif
break;
case 'L':
#ifdef ELOOP
return ELOOP;
#else
goto not_there;
#endif
break;
case 'M':
#ifdef EMFILE
return EMFILE;
#else
goto not_there;
#endif
#ifdef EMLINK
return EMLINK;
#else
goto not_there;
#endif
#ifdef EMSGSIZE
return EMSGSIZE;
#else
goto not_there;
#endif
break;
case 'N':
#ifdef ENETDOWN
return ENETDOWN;
#else
goto not_there;
#endif
#ifdef ENETRESET
return ENETRESET;
#else
goto not_there;
#endif
#ifdef ENETUNREACH
return ENETUNREACH;
#else
goto not_there;
#endif
#ifdef ENOBUFS
return ENOBUFS;
#else
goto not_there;
#endif
#ifdef ENOEXEC
return ENOEXEC;
#else
goto not_there;
#endif
#ifdef ENOMEM
return ENOMEM;
#else
goto not_there;
#endif
#ifdef ENOPROTOOPT
return ENOPROTOOPT;
#else
goto not_there;
#endif
#ifdef ENOSPC
return ENOSPC;
#else
goto not_there;
#endif
#ifdef ENOTBLK
return ENOTBLK;
#else
goto not_there;
#endif
#ifdef ENOTCONN
return ENOTCONN;
#else
goto not_there;
#endif
#ifdef ENOTDIR
return ENOTDIR;
#else
goto not_there;
#endif
#ifdef ENOTEMPTY
return ENOTEMPTY;
#else
goto not_there;
#endif
#ifdef ENOTSOCK
return ENOTSOCK;
#else
goto not_there;
#endif
#ifdef ENOTTY
return ENOTTY;
#else
goto not_there;
#endif
#ifdef ENFILE
return ENFILE;
#else
goto not_there;
#endif
#ifdef ENODEV
return ENODEV;
#else
goto not_there;
#endif
#ifdef ENOENT
return ENOENT;
#else
goto not_there;
#endif
#ifdef ENOLCK
return ENOLCK;
#else
goto not_there;
#endif
#ifdef ENOSYS
return ENOSYS;
#else
goto not_there;
#endif
#ifdef ENXIO
return ENXIO;
#else
goto not_there;
#endif
#ifdef ENAMETOOLONG
return ENAMETOOLONG;
#else
goto not_there;
#endif
break;
case 'O':
#ifdef EOF
return EOF;
#else
goto not_there;
#endif
#ifdef EOPNOTSUPP
return EOPNOTSUPP;
#else
goto not_there;
#endif
break;
case 'P':
#ifdef EPERM
return EPERM;
#else
goto not_there;
#endif
#ifdef EPFNOSUPPORT
return EPFNOSUPPORT;
#else
goto not_there;
#endif
#ifdef EPIPE
return EPIPE;
#else
goto not_there;
#endif
#ifdef EPROCLIM
return EPROCLIM;
#else
goto not_there;
#endif
#ifdef EPROTONOSUPPORT
return EPROTONOSUPPORT;
#else
goto not_there;
#endif
#ifdef EPROTOTYPE
return EPROTOTYPE;
#else
goto not_there;
#endif
break;
case 'R':
#ifdef ERANGE
return ERANGE;
#else
goto not_there;
#endif
#ifdef EREMOTE
return EREMOTE;
#else
goto not_there;
#endif
#ifdef ERESTART
return ERESTART;
#else
goto not_there;
#endif
#ifdef EROFS
return EROFS;
#else
goto not_there;
#endif
break;
case 'S':
#ifdef ESHUTDOWN
return ESHUTDOWN;
#else
goto not_there;
#endif
#ifdef ESOCKTNOSUPPORT
return ESOCKTNOSUPPORT;
#else
goto not_there;
#endif
#ifdef ESPIPE
return ESPIPE;
#else
goto not_there;
#endif
#ifdef ESRCH
return ESRCH;
#else
goto not_there;
#endif
#ifdef ESTALE
return ESTALE;
#else
goto not_there;
#endif
break;
case 'T':
#ifdef ETIMEDOUT
return ETIMEDOUT;
#else
goto not_there;
#endif
#ifdef ETOOMANYREFS
return ETOOMANYREFS;
#else
goto not_there;
#endif
#ifdef ETXTBSY
return ETXTBSY;
#else
goto not_there;
#endif
break;
case 'U':
#ifdef EUSERS
return EUSERS;
#else
goto not_there;
#endif
break;
case 'W':
#ifdef EWOULDBLOCK
return EWOULDBLOCK;
#else
goto not_there;
#endif
break;
case 'X':
#ifdef EXIT_FAILURE
return EXIT_FAILURE;
#else
return 1;
#endif
#ifdef EXIT_SUCCESS
return EXIT_SUCCESS;
#else
return 0;
#endif
#ifdef EXDEV
return EXDEV;
#else
goto not_there;
#endif
break;
}
#ifdef E2BIG
return E2BIG;
#else
goto not_there;
#endif
break;
case 'F':
#ifdef FLT_MAX
return FLT_MAX;
#else
goto not_there;
#endif
#ifdef FLT_MIN
return FLT_MIN;
#else
goto not_there;
#endif
#ifdef FLT_ROUNDS
return FLT_ROUNDS;
#else
goto not_there;
#endif
#ifdef FLT_DIG
return FLT_DIG;
#else
goto not_there;
#endif
#ifdef FLT_EPSILON
return FLT_EPSILON;
#else
goto not_there;
#endif
#ifdef FLT_MANT_DIG
return FLT_MANT_DIG;
#else
goto not_there;
#endif
#ifdef FLT_MAX_10_EXP
return FLT_MAX_10_EXP;
#else
goto not_there;
#endif
#ifdef FLT_MAX_EXP
return FLT_MAX_EXP;
#else
goto not_there;
#endif
#ifdef FLT_MIN_10_EXP
return FLT_MIN_10_EXP;
#else
goto not_there;
#endif
#ifdef FLT_MIN_EXP
return FLT_MIN_EXP;
#else
goto not_there;
#endif
#ifdef FLT_RADIX
return FLT_RADIX;
#else
goto not_there;
#endif
break;
}
#ifdef F_DUPFD
return F_DUPFD;
#else
goto not_there;
#endif
#ifdef F_GETFD
return F_GETFD;
#else
goto not_there;
#endif
#ifdef F_GETFL
return F_GETFL;
#else
goto not_there;
#endif
#ifdef F_GETLK
return F_GETLK;
#else
goto not_there;
#endif
#ifdef F_OK
return F_OK;
#else
goto not_there;
#endif
#ifdef F_RDLCK
return F_RDLCK;
#else
goto not_there;
#endif
#ifdef F_SETFD
return F_SETFD;
#else
goto not_there;
#endif
#ifdef F_SETFL
return F_SETFL;
#else
goto not_there;
#endif
#ifdef F_SETLK
return F_SETLK;
#else
goto not_there;
#endif
#ifdef F_SETLKW
return F_SETLKW;
#else
goto not_there;
#endif
#ifdef F_UNLCK
return F_UNLCK;
#else
goto not_there;
#endif
#ifdef F_WRLCK
return F_WRLCK;
#else
goto not_there;
#endif
break;
}
#ifdef FD_CLOEXEC
return FD_CLOEXEC;
#else
goto not_there;
#endif
#ifdef FILENAME_MAX
return FILENAME_MAX;
#else
goto not_there;
#endif
break;
case 'H':
#if defined(USE_LONG_DOUBLE) && defined(HUGE_VALL)
/* HUGE_VALL is admittedly non-POSIX but if we are using long doubles
* we might as well use long doubles. --jhi */
return HUGE_VALL;
#endif
#ifdef HUGE_VAL
return HUGE_VAL;
#else
goto not_there;
#endif
#ifdef HUPCL
return HUPCL;
#else
goto not_there;
#endif
break;
case 'I':
#ifdef INT_MAX
return INT_MAX;
#else
goto not_there;
#endif
#ifdef INT_MIN
return INT_MIN;
#else
goto not_there;
#endif
#ifdef ICANON
return ICANON;
#else
goto not_there;
#endif
#ifdef ICRNL
return ICRNL;
#else
goto not_there;
#endif
#ifdef IEXTEN
return IEXTEN;
#else
goto not_there;
#endif
#ifdef IGNBRK
return IGNBRK;
#else
goto not_there;
#endif
#ifdef IGNCR
return IGNCR;
#else
goto not_there;
#endif
#ifdef IGNPAR
return IGNPAR;
#else
goto not_there;
#endif
#ifdef INLCR
return INLCR;
#else
goto not_there;
#endif
#ifdef INPCK
return INPCK;
#else
goto not_there;
#endif
#ifdef ISIG
return ISIG;
#else
goto not_there;
#endif
#ifdef ISTRIP
return ISTRIP;
#else
goto not_there;
#endif
#ifdef IXOFF
return IXOFF;
#else
goto not_there;
#endif
#ifdef IXON
return IXON;
#else
goto not_there;
#endif
break;
case 'L':
#ifdef LC_ALL
return LC_ALL;
#else
goto not_there;
#endif
#ifdef LC_COLLATE
return LC_COLLATE;
#else
goto not_there;
#endif
#ifdef LC_CTYPE
return LC_CTYPE;
#else
goto not_there;
#endif
#ifdef LC_MESSAGES
return LC_MESSAGES;
#else
goto not_there;
#endif
#ifdef LC_MONETARY
return LC_MONETARY;
#else
goto not_there;
#endif
#ifdef LC_NUMERIC
return LC_NUMERIC;
#else
goto not_there;
#endif
#ifdef LC_TIME
return LC_TIME;
#else
goto not_there;
#endif
break;
}
#ifdef LDBL_MAX
return LDBL_MAX;
#else
goto not_there;
#endif
#ifdef LDBL_MIN
return LDBL_MIN;
#else
goto not_there;
#endif
#ifdef LDBL_DIG
return LDBL_DIG;
#else
goto not_there;
#endif
#ifdef LDBL_EPSILON
return LDBL_EPSILON;
#else
goto not_there;
#endif
#ifdef LDBL_MANT_DIG
return LDBL_MANT_DIG;
#else
goto not_there;
#endif
#ifdef LDBL_MAX_10_EXP
return LDBL_MAX_10_EXP;
#else
goto not_there;
#endif
#ifdef LDBL_MAX_EXP
return LDBL_MAX_EXP;
#else
goto not_there;
#endif
#ifdef LDBL_MIN_10_EXP
return LDBL_MIN_10_EXP;
#else
goto not_there;
#endif
#ifdef LDBL_MIN_EXP
return LDBL_MIN_EXP;
#else
goto not_there;
#endif
break;
}
#ifdef L_ctermid
return L_ctermid;
#else
goto not_there;
#endif
#ifdef L_cuserid
return L_cuserid;
#else
goto not_there;
#endif
/* L_tmpnam[e] was a typo--retained for compatibility */
#ifdef L_tmpnam
return L_tmpnam;
#else
goto not_there;
#endif
break;
}
#ifdef LONG_MAX
return LONG_MAX;
#else
goto not_there;
#endif
#ifdef LONG_MIN
return LONG_MIN;
#else
goto not_there;
#endif
#ifdef LINK_MAX
return LINK_MAX;
#else
goto not_there;
#endif
break;
case 'M':
#ifdef MAX_CANON
return MAX_CANON;
#else
goto not_there;
#endif
#ifdef MAX_INPUT
return MAX_INPUT;
#else
goto not_there;
#endif
#ifdef MB_CUR_MAX
return MB_CUR_MAX;
#else
goto not_there;
#endif
#ifdef MB_LEN_MAX
return MB_LEN_MAX;
#else
goto not_there;
#endif
break;
case 'N':
#ifdef NAME_MAX
return NAME_MAX;
#else
goto not_there;
#endif
#ifdef NCCS
return NCCS;
#else
goto not_there;
#endif
#ifdef NGROUPS_MAX
return NGROUPS_MAX;
#else
goto not_there;
#endif
#ifdef NOFLSH
return NOFLSH;
#else
goto not_there;
#endif
break;
case 'O':
#ifdef O_APPEND
return O_APPEND;
#else
goto not_there;
#endif
#ifdef O_CREAT
return O_CREAT;
#else
goto not_there;
#endif
#ifdef O_TRUNC
return O_TRUNC;
#else
goto not_there;
#endif
#ifdef O_RDONLY
return O_RDONLY;
#else
goto not_there;
#endif
#ifdef O_RDWR
return O_RDWR;
#else
goto not_there;
#endif
#ifdef O_WRONLY
return O_WRONLY;
#else
goto not_there;
#endif
#ifdef O_EXCL
return O_EXCL;
#else
goto not_there;
#endif
#ifdef O_NOCTTY
return O_NOCTTY;
#else
goto not_there;
#endif
#ifdef O_NONBLOCK
return O_NONBLOCK;
#else
goto not_there;
#endif
#ifdef O_ACCMODE
return O_ACCMODE;
#else
goto not_there;
#endif
break;
}
#ifdef OPEN_MAX
return OPEN_MAX;
#else
goto not_there;
#endif
#ifdef OPOST
return OPOST;
#else
goto not_there;
#endif
break;
case 'P':
#ifdef PATH_MAX
return PATH_MAX;
#else
goto not_there;
#endif
#ifdef PARENB
return PARENB;
#else
goto not_there;
#endif
#ifdef PARMRK
return PARMRK;
#else
goto not_there;
#endif
#ifdef PARODD
return PARODD;
#else
goto not_there;
#endif
#ifdef PIPE_BUF
return PIPE_BUF;
#else
goto not_there;
#endif
break;
case 'R':
#ifdef RAND_MAX
return RAND_MAX;
#else
goto not_there;
#endif
#ifdef R_OK
return R_OK;
#else
goto not_there;
#endif
break;
case 'S':
#ifdef SIG_BLOCK
return SIG_BLOCK;
#else
goto not_there;
#endif
#ifdef SIG_DFL
#endif
#ifdef SIG_ERR
#endif
#ifdef SIG_IGN
#endif
#ifdef SIG_SETMASK
return SIG_SETMASK;
#else
goto not_there;
#endif
#ifdef SIG_UNBLOCK
return SIG_UNBLOCK;
#else
goto not_there;
#endif
break;
}
#ifdef SIGABRT
return SIGABRT;
#else
goto not_there;
#endif
#ifdef SIGALRM
return SIGALRM;
#else
goto not_there;
#endif
#ifdef SIGCHLD
return SIGCHLD;
#else
goto not_there;
#endif
#ifdef SIGCONT
return SIGCONT;
#else
goto not_there;
#endif
#ifdef SIGFPE
return SIGFPE;
#else
goto not_there;
#endif
#ifdef SIGHUP
return SIGHUP;
#else
goto not_there;
#endif
#ifdef SIGILL
return SIGILL;
#else
goto not_there;
#endif
#ifdef SIGINT
return SIGINT;
#else
goto not_there;
#endif
#ifdef SIGKILL
return SIGKILL;
#else
goto not_there;
#endif
#ifdef SIGPIPE
return SIGPIPE;
#else
goto not_there;
#endif
#ifdef SIGQUIT
return SIGQUIT;
#else
goto not_there;
#endif
#ifdef SIGSEGV
return SIGSEGV;
#else
goto not_there;
#endif
#ifdef SIGSTOP
return SIGSTOP;
#else
goto not_there;
#endif
#ifdef SIGTERM
return SIGTERM;
#else
goto not_there;
#endif
#ifdef SIGTSTP
return SIGTSTP;
#else
goto not_there;
#endif
#ifdef SIGTTIN
return SIGTTIN;
#else
goto not_there;
#endif
#ifdef SIGTTOU
return SIGTTOU;
#else
goto not_there;
#endif
#ifdef SIGUSR1
return SIGUSR1;
#else
goto not_there;
#endif
#ifdef SIGUSR2
return SIGUSR2;
#else
goto not_there;
#endif
break;
}
#ifdef S_ISGID
return S_ISGID;
#else
goto not_there;
#endif
#ifdef S_ISUID
return S_ISUID;
#else
goto not_there;
#endif
#ifdef S_IRGRP
return S_IRGRP;
#else
goto not_there;
#endif
#ifdef S_IROTH
return S_IROTH;
#else
goto not_there;
#endif
#ifdef S_IRUSR
return S_IRUSR;
#else
goto not_there;
#endif
#ifdef S_IRWXG
return S_IRWXG;
#else
goto not_there;
#endif
#ifdef S_IRWXO
return S_IRWXO;
#else
goto not_there;
#endif
#ifdef S_IRWXU
return S_IRWXU;
#else
goto not_there;
#endif
#ifdef S_IWGRP
return S_IWGRP;
#else
goto not_there;
#endif
#ifdef S_IWOTH
return S_IWOTH;
#else
goto not_there;
#endif
#ifdef S_IWUSR
return S_IWUSR;
#else
goto not_there;
#endif
#ifdef S_IXGRP
return S_IXGRP;
#else
goto not_there;
#endif
#ifdef S_IXOTH
return S_IXOTH;
#else
goto not_there;
#endif
#ifdef S_IXUSR
return S_IXUSR;
#else
goto not_there;
#endif
#ifdef S_ISBLK
#endif
#ifdef S_ISCHR
#endif
#ifdef S_ISDIR
#endif
#ifdef S_ISFIFO
#endif
#ifdef S_ISREG
#endif
break;
}
#ifdef SEEK_CUR
return SEEK_CUR;
#else
goto not_there;
#endif
#ifdef SEEK_END
return SEEK_END;
#else
goto not_there;
#endif
#ifdef SEEK_SET
return SEEK_SET;
#else
goto not_there;
#endif
#ifdef STREAM_MAX
return STREAM_MAX;
#else
goto not_there;
#endif
#ifdef SHRT_MAX
return SHRT_MAX;
#else
goto not_there;
#endif
#ifdef SHRT_MIN
return SHRT_MIN;
#else
goto not_there;
#endif
#ifdef SA_NOCLDSTOP
return SA_NOCLDSTOP;
#else
goto not_there;
#endif
#ifdef SA_NOCLDWAIT
return SA_NOCLDWAIT;
#else
goto not_there;
#endif
#ifdef SA_NODEFER
return SA_NODEFER;
#else
goto not_there;
#endif
#ifdef SA_ONSTACK
return SA_ONSTACK;
#else
goto not_there;
#endif
#ifdef SA_RESETHAND
return SA_RESETHAND;
#else
goto not_there;
#endif
#ifdef SA_RESTART
return SA_RESTART;
#else
goto not_there;
#endif
#ifdef SA_SIGINFO
return SA_SIGINFO;
#else
goto not_there;
#endif
break;
}
#ifdef SCHAR_MAX
return SCHAR_MAX;
#else
goto not_there;
#endif
#ifdef SCHAR_MIN
return SCHAR_MIN;
#else
goto not_there;
#endif
#ifdef SSIZE_MAX
return SSIZE_MAX;
#else
goto not_there;
#endif
#ifdef STDIN_FILENO
return STDIN_FILENO;
#else
goto not_there;
#endif
#ifdef STDOUT_FILENO
return STDOUT_FILENO;
#else
goto not_there;
#endif
#ifdef STDERR_FILENO
return STDERR_FILENO;
#else
goto not_there;
#endif
break;
case 'T':
#ifdef TCIFLUSH
return TCIFLUSH;
#else
goto not_there;
#endif
#ifdef TCIOFF
return TCIOFF;
#else
goto not_there;
#endif
#ifdef TCIOFLUSH
return TCIOFLUSH;
#else
goto not_there;
#endif
#ifdef TCION
return TCION;
#else
goto not_there;
#endif
#ifdef TCOFLUSH
return TCOFLUSH;
#else
goto not_there;
#endif
#ifdef TCOOFF
return TCOOFF;
#else
goto not_there;
#endif
#ifdef TCOON
return TCOON;
#else
goto not_there;
#endif
#ifdef TCSADRAIN
return TCSADRAIN;
#else
goto not_there;
#endif
#ifdef TCSAFLUSH
return TCSAFLUSH;
#else
goto not_there;
#endif
#ifdef TCSANOW
return TCSANOW;
#else
goto not_there;
#endif
#ifdef TMP_MAX
return TMP_MAX;
#else
goto not_there;
#endif
#ifdef TOSTOP
return TOSTOP;
#else
goto not_there;
#endif
#ifdef TZNAME_MAX
return TZNAME_MAX;
#else
goto not_there;
#endif
break;
case 'U':
#ifdef UCHAR_MAX
return UCHAR_MAX;
#else
goto not_there;
#endif
#ifdef UINT_MAX
return UINT_MAX;
#else
goto not_there;
#endif
#ifdef ULONG_MAX
return ULONG_MAX;
#else
goto not_there;
#endif
#ifdef USHRT_MAX
return USHRT_MAX;
#else
goto not_there;
#endif
break;
case 'V':
#ifdef VEOF
return VEOF;
#else
goto not_there;
#endif
#ifdef VEOL
return VEOL;
#else
goto not_there;
#endif
#ifdef VERASE
return VERASE;
#else
goto not_there;
#endif
#ifdef VINTR
return VINTR;
#else
goto not_there;
#endif
#ifdef VKILL
return VKILL;
#else
goto not_there;
#endif
#ifdef VMIN
return VMIN;
#else
goto not_there;
#endif
#ifdef VQUIT
return VQUIT;
#else
goto not_there;
#endif
#ifdef VSTART
return VSTART;
#else
goto not_there;
#endif
#ifdef VSTOP
return VSTOP;
#else
goto not_there;
#endif
#ifdef VSUSP
return VSUSP;
#else
goto not_there;
#endif
#ifdef VTIME
return VTIME;
#else
goto not_there;
#endif
break;
case 'W':
#ifdef W_OK
return W_OK;
#else
goto not_there;
#endif
#ifdef WNOHANG
return WNOHANG;
#else
goto not_there;
#endif
#ifdef WUNTRACED
return WUNTRACED;
#else
goto not_there;
#endif
#ifdef WEXITSTATUS
#endif
#ifdef WIFEXITED
#endif
#ifdef WIFSIGNALED
#endif
#ifdef WIFSTOPPED
#endif
#ifdef WSTOPSIG
#endif
#ifdef WTERMSIG
#endif
break;
case 'X':
#ifdef X_OK
return X_OK;
#else
goto not_there;
#endif
break;
case '_':
#if defined(_PC_CHOWN_RESTRICTED) || HINT_SC_EXIST
return _PC_CHOWN_RESTRICTED;
#else
goto not_there;
#endif
#if defined(_PC_LINK_MAX) || HINT_SC_EXIST
return _PC_LINK_MAX;
#else
goto not_there;
#endif
#if defined(_PC_MAX_CANON) || HINT_SC_EXIST
return _PC_MAX_CANON;
#else
goto not_there;
#endif
#if defined(_PC_MAX_INPUT) || HINT_SC_EXIST
return _PC_MAX_INPUT;
#else
goto not_there;
#endif
#if defined(_PC_NAME_MAX) || HINT_SC_EXIST
return _PC_NAME_MAX;
#else
goto not_there;
#endif
#if defined(_PC_NO_TRUNC) || HINT_SC_EXIST
return _PC_NO_TRUNC;
#else
goto not_there;
#endif
#if defined(_PC_PATH_MAX) || HINT_SC_EXIST
return _PC_PATH_MAX;
#else
goto not_there;
#endif
#if defined(_PC_PIPE_BUF) || HINT_SC_EXIST
return _PC_PIPE_BUF;
#else
goto not_there;
#endif
#if defined(_PC_VDISABLE) || HINT_SC_EXIST
return _PC_VDISABLE;
#else
goto not_there;
#endif
break;
}
#ifdef _POSIX_ARG_MAX
return _POSIX_ARG_MAX;
#else
return 0;
#endif
#ifdef _POSIX_CHILD_MAX
return _POSIX_CHILD_MAX;
#else
return 0;
#endif
#ifdef _POSIX_CHOWN_RESTRICTED
return _POSIX_CHOWN_RESTRICTED;
#else
return 0;
#endif
#ifdef _POSIX_JOB_CONTROL
return _POSIX_JOB_CONTROL;
#else
return 0;
#endif
#ifdef _POSIX_LINK_MAX
return _POSIX_LINK_MAX;
#else
return 0;
#endif
#ifdef _POSIX_MAX_CANON
return _POSIX_MAX_CANON;
#else
return 0;
#endif
#ifdef _POSIX_MAX_INPUT
return _POSIX_MAX_INPUT;
#else
return 0;
#endif
#ifdef _POSIX_NAME_MAX
return _POSIX_NAME_MAX;
#else
return 0;
#endif
#ifdef _POSIX_NGROUPS_MAX
return _POSIX_NGROUPS_MAX;
#else
return 0;
#endif
#ifdef _POSIX_NO_TRUNC
return _POSIX_NO_TRUNC;
#else
return 0;
#endif
#ifdef _POSIX_OPEN_MAX
return _POSIX_OPEN_MAX;
#else
return 0;
#endif
#ifdef _POSIX_PATH_MAX
return _POSIX_PATH_MAX;
#else
return 0;
#endif
#ifdef _POSIX_PIPE_BUF
return _POSIX_PIPE_BUF;
#else
return 0;
#endif
#ifdef _POSIX_SAVED_IDS
return _POSIX_SAVED_IDS;
#else
return 0;
#endif
#ifdef _POSIX_SSIZE_MAX
return _POSIX_SSIZE_MAX;
#else
return 0;
#endif
#ifdef _POSIX_STREAM_MAX
return _POSIX_STREAM_MAX;
#else
return 0;
#endif
#ifdef _POSIX_TZNAME_MAX
return _POSIX_TZNAME_MAX;
#else
return 0;
#endif
#ifdef _POSIX_VDISABLE
return _POSIX_VDISABLE;
#else
return 0;
#endif
#ifdef _POSIX_VERSION
return _POSIX_VERSION;
#else
return 0;
#endif
break;
}
#if defined(_SC_ARG_MAX) || HINT_SC_EXIST
return _SC_ARG_MAX;
#else
goto not_there;
#endif
#if defined(_SC_CHILD_MAX) || HINT_SC_EXIST
return _SC_CHILD_MAX;
#else
goto not_there;
#endif
#if defined(_SC_CLK_TCK) || HINT_SC_EXIST
return _SC_CLK_TCK;
#else
goto not_there;
#endif
#if defined(_SC_JOB_CONTROL) || HINT_SC_EXIST
return _SC_JOB_CONTROL;
#else
goto not_there;
#endif
#if defined(_SC_NGROUPS_MAX) || HINT_SC_EXIST
return _SC_NGROUPS_MAX;
#else
goto not_there;
#endif
#if defined(_SC_OPEN_MAX) || HINT_SC_EXIST
return _SC_OPEN_MAX;
#else
goto not_there;
#endif
#if defined(_SC_SAVED_IDS) || HINT_SC_EXIST
return _SC_SAVED_IDS;
#else
goto not_there;
#endif
#if defined(_SC_STREAM_MAX) || HINT_SC_EXIST
return _SC_STREAM_MAX;
#else
goto not_there;
#endif
#if defined(_SC_TZNAME_MAX) || HINT_SC_EXIST
return _SC_TZNAME_MAX;
#else
goto not_there;
#endif
#if defined(_SC_VERSION) || HINT_SC_EXIST
return _SC_VERSION;
#else
goto not_there;
#endif
break;
}
}
return 0;
return 0;
}
char * packname
CODE:
{
int i;
for (i = 1; i < items; i++)
}
void
CODE:
int sig
int sig
int
int sig
char * packname
CODE:
{
#ifdef I_TERMIOS
#else
not_here("termios");
RETVAL = 0;
#endif
}
void
CODE:
#ifdef I_TERMIOS
#else
not_here("termios");
#endif
int fd
CODE:
int fd
int optional_actions
CODE:
CODE:
#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
#else
not_here("getiflag");
RETVAL = 0;
#endif
CODE:
#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
#else
not_here("getoflag");
RETVAL = 0;
#endif
CODE:
#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
#else
not_here("getcflag");
RETVAL = 0;
#endif
CODE:
#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
#else
not_here("getlflag");
RETVAL = 0;
#endif
int ccix
CODE:
#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
croak("Bad getcc subscript");
#else
not_here("getcc");
RETVAL = 0;
#endif
void
CODE:
#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
#else
not_here("setiflag");
#endif
void
CODE:
#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
#else
not_here("setoflag");
#endif
void
CODE:
#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
#else
not_here("setcflag");
#endif
void
CODE:
#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
#else
not_here("setlflag");
#endif
void
int ccix
CODE:
#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
croak("Bad setcc subscript");
#else
not_here("setcc");
#endif
char * name
int arg
int
unsigned char * charstring
CODE:
unsigned char *s = charstring;
unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
if (!isalnum(*s))
RETVAL = 0;
int
unsigned char * charstring
CODE:
unsigned char *s = charstring;
unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
if (!isalpha(*s))
RETVAL = 0;
int
unsigned char * charstring
CODE:
unsigned char *s = charstring;
unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
if (!iscntrl(*s))
RETVAL = 0;
int
unsigned char * charstring
CODE:
unsigned char *s = charstring;
unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
if (!isdigit(*s))
RETVAL = 0;
int
unsigned char * charstring
CODE:
unsigned char *s = charstring;
unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
if (!isgraph(*s))
RETVAL = 0;
int
unsigned char * charstring
CODE:
unsigned char *s = charstring;
unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
if (!islower(*s))
RETVAL = 0;
int
unsigned char * charstring
CODE:
unsigned char *s = charstring;
unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
if (!isprint(*s))
RETVAL = 0;
int
unsigned char * charstring
CODE:
unsigned char *s = charstring;
unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
if (!ispunct(*s))
RETVAL = 0;
int
unsigned char * charstring
CODE:
unsigned char *s = charstring;
unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
if (!isspace(*s))
RETVAL = 0;
int
unsigned char * charstring
CODE:
unsigned char *s = charstring;
unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
if (!isupper(*s))
RETVAL = 0;
int
unsigned char * charstring
CODE:
unsigned char *s = charstring;
unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
if (!isxdigit(*s))
RETVAL = 0;
char * filename
int flags
CODE:
TAINT_PROPER("open");
HV *
CODE:
#ifdef HAS_LOCALECONV
if ((lcbuf = localeconv())) {
/* the strings */
#ifndef NO_LOCALECONV_GROUPING
#endif
#ifndef NO_LOCALECONV_MON_THOUSANDS_SEP
#endif
#ifndef NO_LOCALECONV_MON_GROUPING
#endif
/* the integers */
}
#else
localeconv(); /* A stub to call not_here(). */
#endif
char *
int category
char * locale
CODE:
if (RETVAL) {
#ifdef USE_LOCALE_CTYPE
#ifdef LC_ALL
#endif
)
{
char *newctype;
#ifdef LC_ALL
else
#endif
}
#endif /* USE_LOCALE_CTYPE */
#ifdef USE_LOCALE_COLLATE
if (category == LC_COLLATE
#ifdef LC_ALL
#endif
)
{
char *newcoll;
#ifdef LC_ALL
else
#endif
}
#endif /* USE_LOCALE_COLLATE */
#ifdef USE_LOCALE_NUMERIC
if (category == LC_NUMERIC
#ifdef LC_ALL
#endif
)
{
char *newnum;
#ifdef LC_ALL
else
#endif
}
#endif /* USE_LOCALE_NUMERIC */
}
acos(x)
NV x
asin(x)
NV x
atan(x)
NV x
ceil(x)
NV x
cosh(x)
NV x
floor(x)
NV x
fmod(x,y)
NV x
NV y
void
frexp(x)
NV x
int expvar;
/* (We already know stack is long enough.) */
NV x
int exp
log10(x)
NV x
void
modf(x)
NV x
/* (We already know stack is long enough.) */
sinh(x)
NV x
tan(x)
NV x
tanh(x)
NV x
int sig
CODE:
#ifdef WIN32
#else
# interface look beautiful, which is hard.
{
GV *siggv = gv_fetchpv("SIG", TRUE, SVt_PVHV);
struct sigaction act;
struct sigaction oact;
POSIX__SigSet sigset;
SV** svp;
SV** sigsvp = hv_fetch(GvHVn(siggv),
PL_sig_name[sig],
strlen(PL_sig_name[sig]),
TRUE);
STRLEN n_a;
/* Remember old handler name if desired. */
if (oldaction) {
char *hand = SvPVx(*sigsvp, n_a);
svp = hv_fetch(oldaction, "HANDLER", 7, TRUE);
sv_setpv(*svp, *hand ? hand : "DEFAULT");
}
if (action) {
/* Vector new handler through %SIG. (We always use sighandler
for the C signal handler, which reads %SIG to dispatch.) */
svp = hv_fetch(action, "HANDLER", 7, FALSE);
if (!svp)
sv_setpv(*sigsvp, SvPV(*svp, n_a));
mg_set(*sigsvp); /* handles DEFAULT and IGNORE */
act.sa_handler = PL_sighandlerp;
/* Set up any desired mask. */
IV tmp = SvIV((SV*)SvRV(*svp));
sigset = INT2PTR(sigset_t*, tmp);
act.sa_mask = *sigset;
}
else
sigemptyset(& act.sa_mask);
/* Set up any desired flags. */
act.sa_flags = svp ? SvIV(*svp) : 0;
}
/* Now work around sigaction oddities */
if (action && oldaction)
RETVAL = sigaction(sig, & act, & oact);
else if (action)
RETVAL = sigaction(sig, & act, (struct sigaction *)0);
else if (oldaction)
RETVAL = sigaction(sig, (struct sigaction *)0, & oact);
else
RETVAL = -1;
if (oldaction) {
/* Get back the mask. */
IV tmp = SvIV((SV*)SvRV(*svp));
sigset = INT2PTR(sigset_t*, tmp);
}
else {
New(0, sigset, 1, sigset_t);
}
*sigset = oact.sa_mask;
/* Get back the flags. */
sv_setiv(*svp, oact.sa_flags);
}
}
#endif
OUTPUT:
RETVAL
SysRet
sigpending(sigset)
POSIX::SigSet sigset
SysRet
sigprocmask(how, sigset, oldsigset = 0)
int how
POSIX::SigSet sigset
POSIX::SigSet oldsigset = NO_INIT
INIT:
if ( items < 3 ) {
oldsigset = 0;
}
IV tmp = SvIV((SV*)SvRV(ST(2)));
oldsigset = INT2PTR(POSIX__SigSet,tmp);
}
else {
New(0, oldsigset, 1, sigset_t);
sigemptyset(oldsigset);
}
SysRet
sigsuspend(signal_mask)
POSIX::SigSet signal_mask
void
_exit(status)
int status
SysRet
close(fd)
int fd
SysRet
dup(fd)
int fd
SysRet
dup2(fd1, fd2)
int fd1
int fd2
SysRetLong
lseek(fd, offset, whence)
int fd
Off_t offset
int whence
SysRet
nice(incr)
int incr
void
pipe()
PPCODE:
int fds[2];
if (pipe(fds) != -1) {
EXTEND(SP,2);
PUSHs(sv_2mortal(newSViv(fds[0])));
PUSHs(sv_2mortal(newSViv(fds[1])));
}
SysRet
read(fd, buffer, nbytes)
PREINIT:
SV *sv_buffer = SvROK(ST(1)) ? SvRV(ST(1)) : ST(1);
INPUT:
int fd
size_t nbytes
char * buffer = sv_grow( sv_buffer, nbytes+1 );
CLEANUP:
if (RETVAL >= 0) {
SvCUR(sv_buffer) = RETVAL;
SvPOK_only(sv_buffer);
*SvEND(sv_buffer) = '\0';
SvTAINTED_on(sv_buffer);
}
SysRet
setpgid(pid, pgid)
pid_t pid
pid_t pgid
pid_t
setsid()
pid_t
tcgetpgrp(fd)
int fd
SysRet
tcsetpgrp(fd, pgrp_id)
int fd
pid_t pgrp_id
void
uname()
PPCODE:
#ifdef HAS_UNAME
struct utsname buf;
if (uname(&buf) >= 0) {
EXTEND(SP, 5);
PUSHs(sv_2mortal(newSVpv(buf.sysname, 0)));
PUSHs(sv_2mortal(newSVpv(buf.nodename, 0)));
PUSHs(sv_2mortal(newSVpv(buf.release, 0)));
PUSHs(sv_2mortal(newSVpv(buf.version, 0)));
PUSHs(sv_2mortal(newSVpv(buf.machine, 0)));
}
#else
uname((char *) 0); /* A stub to call not_here(). */
#endif
SysRet
write(fd, buffer, nbytes)
int fd
char * buffer
size_t nbytes
SV *
tmpnam()
PREINIT:
STRLEN i;
int len;
CODE:
RETVAL = newSVpvn("", 0);
SvGROW(RETVAL, L_tmpnam);
len = strlen(tmpnam(SvPV(RETVAL, i)));
SvCUR_set(RETVAL, len);
OUTPUT:
RETVAL
void
abort()
int
mblen(s, n)
char * s
size_t n
size_t
mbstowcs(s, pwcs, n)
wchar_t * s
char * pwcs
size_t n
int
mbtowc(pwc, s, n)
wchar_t * pwc
char * s
size_t n
int
wcstombs(s, pwcs, n)
char * s
wchar_t * pwcs
size_t n
int
wctomb(s, wchar)
char * s
wchar_t wchar
int
strcoll(s1, s2)
char * s1
char * s2
void
strtod(str)
char * str
PREINIT:
double num;
char *unparsed;
PPCODE:
SET_NUMERIC_LOCAL();
num = strtod(str, &unparsed);
PUSHs(sv_2mortal(newSVnv(num)));
if (GIMME == G_ARRAY) {
EXTEND(SP, 1);
if (unparsed)
PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
else
PUSHs(&PL_sv_undef);
}
void
strtol(str, base = 0)
char * str
int base
PREINIT:
long num;
char *unparsed;
PPCODE:
num = strtol(str, &unparsed, base);
#if IVSIZE <= LONGSIZE
if (num < IV_MIN || num > IV_MAX)
PUSHs(sv_2mortal(newSVnv((double)num)));
else
#endif
PUSHs(sv_2mortal(newSViv((IV)num)));
if (GIMME == G_ARRAY) {
EXTEND(SP, 1);
if (unparsed)
PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
else
PUSHs(&PL_sv_undef);
}
void
strtoul(str, base = 0)
char * str
int base
PREINIT:
unsigned long num;
char *unparsed;
PPCODE:
num = strtoul(str, &unparsed, base);
if (num <= IV_MAX)
PUSHs(sv_2mortal(newSViv((IV)num)));
else
PUSHs(sv_2mortal(newSVnv((double)num)));
if (GIMME == G_ARRAY) {
EXTEND(SP, 1);
if (unparsed)
PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
else
PUSHs(&PL_sv_undef);
}
void
strxfrm(src)
SV * src
CODE:
{
STRLEN srclen;
STRLEN dstlen;
char *p = SvPV(src,srclen);
srclen++;
ST(0) = sv_2mortal(NEWSV(800,srclen));
dstlen = strxfrm(SvPVX(ST(0)), p, (size_t)srclen);
if (dstlen > srclen) {
dstlen++;
SvGROW(ST(0), dstlen);
strxfrm(SvPVX(ST(0)), p, (size_t)dstlen);
dstlen--;
}
SvCUR(ST(0)) = dstlen;
SvPOK_only(ST(0));
}
SysRet
mkfifo(filename, mode)
char * filename
Mode_t mode
CODE:
RETVAL = mkfifo(filename, mode);
OUTPUT:
RETVAL
SysRet
tcdrain(fd)
int fd
SysRet
tcflow(fd, action)
int fd
int action
SysRet
tcflush(fd, queue_selector)
int fd
int queue_selector
SysRet
tcsendbreak(fd, duration)
int fd
int duration
char *
asctime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
int sec
int min
int hour
int mday
int mon
int year
int wday
int yday
int isdst
CODE:
{
struct tm mytm;
init_tm(&mytm); /* XXX workaround - see init_tm() above */
mytm.tm_sec = sec;
mytm.tm_min = min;
mytm.tm_hour = hour;
mytm.tm_mday = mday;
mytm.tm_mon = mon;
mytm.tm_year = year;
mytm.tm_wday = wday;
mytm.tm_yday = yday;
mytm.tm_isdst = isdst;
RETVAL = asctime(&mytm);
}
OUTPUT:
RETVAL
long
clock()
char *
ctime(time)
Time_t &time
void
times()
PPCODE:
struct tms tms;
clock_t realtime;
realtime = times( &tms );
EXTEND(SP,5);
PUSHs( sv_2mortal( newSViv( (IV) realtime ) ) );
PUSHs( sv_2mortal( newSViv( (IV) tms.tms_utime ) ) );
PUSHs( sv_2mortal( newSViv( (IV) tms.tms_stime ) ) );
PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cutime ) ) );
PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cstime ) ) );
double
difftime(time1, time2)
Time_t time1
Time_t time2
SysRetLong
mktime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
int sec
int min
int hour
int mday
int mon
int year
int wday
int yday
int isdst
CODE:
{
struct tm mytm;
init_tm(&mytm); /* XXX workaround - see init_tm() above */
mytm.tm_sec = sec;
mytm.tm_min = min;
mytm.tm_hour = hour;
mytm.tm_mday = mday;
mytm.tm_mon = mon;
mytm.tm_year = year;
mytm.tm_wday = wday;
mytm.tm_yday = yday;
mytm.tm_isdst = isdst;
RETVAL = mktime(&mytm);
}
OUTPUT:
RETVAL
#XXX: if $xsubpp::WantOptimize is always the default
# sv_setpv(TARG, ...) could be used rather than
# ST(0) = sv_2mortal(newSVpv(...))
void
strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1)
char * fmt
int sec
int min
int hour
int mday
int mon
int year
int wday
int yday
int isdst
CODE:
{
char tmpbuf[128];
struct tm mytm;
int len;
init_tm(&mytm); /* XXX workaround - see init_tm() above */
mytm.tm_sec = sec;
mytm.tm_min = min;
mytm.tm_hour = hour;
mytm.tm_mday = mday;
mytm.tm_mon = mon;
mytm.tm_year = year;
mytm.tm_wday = wday;
mytm.tm_yday = yday;
mytm.tm_isdst = isdst;
mini_mktime(&mytm);
len = strftime(tmpbuf, sizeof tmpbuf, fmt, &mytm);
/*
** The following is needed to handle to the situation where
** tmpbuf overflows. Basically we want to allocate a buffer
** and try repeatedly. The reason why it is so complicated
** is that getting a return value of 0 from strftime can indicate
** one of the following:
** 1. buffer overflowed,
** 2. illegal conversion specifier, or
** 3. the format string specifies nothing to be returned(not
** an error). This could be because format is an empty string
** or it specifies %p that yields an empty string in some locale.
** If there is a better way to make it portable, go ahead by
** all means.
*/
if ((len > 0 && len < sizeof(tmpbuf)) || (len == 0 && *fmt == '\0'))
ST(0) = sv_2mortal(newSVpv(tmpbuf, len));
else {
/* Possibly buf overflowed - try again with a bigger buf */
int fmtlen = strlen(fmt);
int bufsize = fmtlen + sizeof(tmpbuf);
char* buf;
int buflen;
New(0, buf, bufsize, char);
while (buf) {
buflen = strftime(buf, bufsize, fmt, &mytm);
if (buflen > 0 && buflen < bufsize)
break;
/* heuristic to prevent out-of-memory errors */
if (bufsize > 100*fmtlen) {
Safefree(buf);
buf = NULL;
break;
}
bufsize *= 2;
Renew(buf, bufsize, char);
}
if (buf) {
ST(0) = sv_2mortal(newSVpvn(buf, buflen));
Safefree(buf);
}
else
ST(0) = sv_2mortal(newSVpvn(tmpbuf, len));
}
}
void
tzset()
void
tzname()
PPCODE:
EXTEND(SP,2);
PUSHs(sv_2mortal(newSVpvn(tzname[0],strlen(tzname[0]))));
PUSHs(sv_2mortal(newSVpvn(tzname[1],strlen(tzname[1]))));
SysRet
access(filename, mode)
char * filename
Mode_t mode
char *
ctermid(s = 0)
char * s = 0;
char *
cuserid(s = 0)
char * s = 0;
SysRetLong
fpathconf(fd, name)
int fd
int name
SysRetLong
pathconf(filename, name)
char * filename
int name
SysRet
pause()
SysRetLong
sysconf(name)
int name
char *
ttyname(fd)
int fd