5 #define PERLIO_NOT_STDIO 1
8 #ifdef PERL_OBJECT /* XXX _very_ temporary hacks */
12 # define open PerlLIO_open3
15 #ifdef I_DIRENT /* XXX maybe better to just rely on perl.h? */
38 /* XXX This comment is just to make I_TERMIO and I_SGTTY visible to
39 metaconfig for future extension writers. We don't use them in POSIX.
40 (This is really sneaky :-) --AD
42 #if defined(I_TERMIOS)
50 #include <sys/types.h>
57 #if defined(__VMS) && !defined(__POSIX_SOURCE)
58 # include <libdef.h> /* LIB$_INVARG constant */
59 # include <lib$routines.h> /* prototype for lib$ediv() */
60 # include <starlet.h> /* prototype for sys$gettim() */
61 # if DECC_VERSION < 50000000
62 # define pid_t int /* old versions of DECC miss this in types.h */
66 # define mkfifo(a,b) (not_here("mkfifo"),-1)
67 # define tzset() not_here("tzset")
69 #if ((__VMS_VER >= 70000000) && (__DECC_VER >= 50200000)) || (__CRTL_VER >= 70000000)
70 # define HAS_TZNAME /* shows up in VMS 7.0 or Dec C 5.6 */
72 # endif /* __VMS_VER >= 70000000 or Dec C 5.6 */
74 /* The POSIX notion of ttyname() is better served by getname() under VMS */
75 static char ttnambuf[64];
76 # define ttyname(fd) (isatty(fd) > 0 ? getname(fd,ttnambuf,0) : NULL)
78 /* The non-POSIX CRTL times() has void return type, so we just get the
79 current time directly */
80 clock_t vms_times(struct tms *PL_bufptr) {
82 /* Get wall time and convert to 10 ms intervals to
83 * produce the return value that the POSIX standard expects */
84 # if defined(__DECC) && defined (__ALPHA)
87 _ckvmssts(sys$gettim(&vmstime));
89 retval = vmstime & 0x7fffffff;
91 /* (Older hw or ccs don't have an atomic 64-bit type, so we
92 * juggle 32-bit ints (and a float) to produce a time_t result
93 * with minimal loss of information.) */
94 long int vmstime[2],remainder,divisor = 100000;
95 _ckvmssts(sys$gettim((unsigned long int *)vmstime));
96 vmstime[1] &= 0x7fff; /* prevent overflow in EDIV */
97 _ckvmssts(lib$ediv(&divisor,vmstime,(long int *)&retval,&remainder));
99 /* Fill in the struct tms using the CRTL routine . . .*/
100 times((tbuffer_t *)PL_bufptr);
101 return (clock_t) retval;
103 # define times(t) vms_times(t)
105 #if defined (CYGWIN32)
106 # define tzname _tzname
107 # undef MB_CUR_MAX /* XXX: bug in b20.1 */
111 # define mkfifo(a,b) not_here("mkfifo")
112 # define ttyname(a) (char*)not_here("ttyname")
113 # define sigset_t long
116 # define tzname _tzname
119 # define mode_t short
122 # define mode_t short
124 # define tzset() not_here("tzset")
126 # ifndef _POSIX_OPEN_MAX
127 # define _POSIX_OPEN_MAX FOPEN_MAX /* XXX bogus ? */
130 # define sigaction(a,b,c) not_here("sigaction")
131 # define sigpending(a) not_here("sigpending")
132 # define sigprocmask(a,b,c) not_here("sigprocmask")
133 # define sigsuspend(a) not_here("sigsuspend")
134 # define sigemptyset(a) not_here("sigemptyset")
135 # define sigaddset(a,b) not_here("sigaddset")
136 # define sigdelset(a,b) not_here("sigdelset")
137 # define sigfillset(a) not_here("sigfillset")
138 # define sigismember(a,b) not_here("sigismember")
143 # define mkfifo(a,b) not_here("mkfifo")
144 # else /* !( defined OS2 ) */
146 # define mkfifo(path, mode) (mknod((path), (mode) | S_IFIFO, 0))
149 # endif /* !HAS_MKFIFO */
152 # include <sys/times.h>
154 # include <sys/utsname.h>
156 # include <sys/wait.h>
164 typedef long SysRetLong;
165 typedef sigset_t* POSIX__SigSet;
166 typedef HV* POSIX__SigAction;
168 typedef struct termios* POSIX__Termios;
169 #else /* Define termios types to int, and call not_here for the functions.*/
170 #define POSIX__Termios int
174 #define cfgetispeed(x) not_here("cfgetispeed")
175 #define cfgetospeed(x) not_here("cfgetospeed")
176 #define tcdrain(x) not_here("tcdrain")
177 #define tcflush(x,y) not_here("tcflush")
178 #define tcsendbreak(x,y) not_here("tcsendbreak")
179 #define cfsetispeed(x,y) not_here("cfsetispeed")
180 #define cfsetospeed(x,y) not_here("cfsetospeed")
181 #define ctermid(x) (char *) not_here("ctermid")
182 #define tcflow(x,y) not_here("tcflow")
183 #define tcgetattr(x,y) not_here("tcgetattr")
184 #define tcsetattr(x,y,z) not_here("tcsetattr")
187 /* Possibly needed prototypes */
188 char *cuserid (char *);
189 double strtod (const char *, char **);
190 long strtol (const char *, char **, int);
191 unsigned long strtoul (const char *, char **, int);
194 #define cuserid(a) (char *) not_here("cuserid")
198 #define difftime(a,b) not_here("difftime")
201 #ifndef HAS_FPATHCONF
202 #define fpathconf(f,n) (SysRetLong) not_here("fpathconf")
205 #define mktime(a) not_here("mktime")
208 #define nice(a) not_here("nice")
211 #define pathconf(f,n) (SysRetLong) not_here("pathconf")
214 #define sysconf(n) (SysRetLong) not_here("sysconf")
217 #define readlink(a,b,c) not_here("readlink")
220 #define setpgid(a,b) not_here("setpgid")
223 #define setsid() not_here("setsid")
226 #define strcoll(s1,s2) not_here("strcoll")
229 #define strtod(s1,s2) not_here("strtod")
232 #define strtol(s1,s2,b) not_here("strtol")
235 #define strtoul(s1,s2,b) not_here("strtoul")
238 #define strxfrm(s1,s2,n) not_here("strxfrm")
240 #ifndef HAS_TCGETPGRP
241 #define tcgetpgrp(a) not_here("tcgetpgrp")
243 #ifndef HAS_TCSETPGRP
244 #define tcsetpgrp(a,b) not_here("tcsetpgrp")
247 #define times(a) not_here("times")
250 #define uname(a) not_here("uname")
253 #define waitpid(a,b,c) not_here("waitpid")
258 #define mblen(a,b) not_here("mblen")
262 #define mbstowcs(s, pwcs, n) not_here("mbstowcs")
265 #define mbtowc(pwc, s, n) not_here("mbtowc")
268 #define wcstombs(s, pwcs, n) not_here("wcstombs")
271 #define wctomb(s, wchar) not_here("wcstombs")
273 #if !defined(HAS_MBLEN) && !defined(HAS_MBSTOWCS) && !defined(HAS_MBTOWC) && !defined(HAS_WCSTOMBS) && !defined(HAS_WCTOMB)
274 /* If we don't have these functions, then we wouldn't have gotten a typedef
275 for wchar_t, the wide character type. Defining wchar_t allows the
276 functions referencing it to compile. Its actual type is then meaningless,
277 since without the above functions, all sections using it end up calling
278 not_here() and croak. --Kaveh Ghazi (ghazi@noc.rutgers.edu) 9/18/94. */
284 #ifndef HAS_LOCALECONV
285 #define localeconv() not_here("localeconv")
290 extern char *tzname[];
293 #if !defined(WIN32) || (defined(__MINGW32__) && !defined(tzname))
294 char *tzname[] = { "" , "" };
298 /* XXX struct tm on some systems (SunOS4/BSD) contains extra (non POSIX)
299 * fields for which we don't have Configure support yet:
300 * char *tm_zone; -- abbreviation of timezone name
301 * long tm_gmtoff; -- offset from GMT in seconds
302 * To workaround core dumps from the uninitialised tm_zone we get the
303 * system to give us a reasonable struct to copy. This fix means that
304 * strftime uses the tm_zone and tm_gmtoff values returned by
305 * localtime(time()). That should give the desired result most of the
306 * time. But probably not always!
308 * This is a temporary workaround to be removed once Configure
309 * support is added and NETaa14816 is considered in full.
310 * It does not address tzname aspects of NETaa14816.
313 # ifndef STRUCT_TM_HASZONE
314 # define STRUCT_TM_HASZONE
318 #ifdef STRUCT_TM_HASZONE
320 init_tm(struct tm *ptm) /* see mktime, strftime and asctime */
324 Copy(localtime(&now), ptm, 1, struct tm);
328 # define init_tm(ptm)
332 #ifdef HAS_LONG_DOUBLE
333 # if LONG_DOUBLESIZE > DOUBLESIZE
334 # undef HAS_LONG_DOUBLE /* XXX until we figure out how to use them */
338 #ifndef HAS_LONG_DOUBLE
353 croak("POSIX::%s not implemented on this architecture", s);
358 #ifdef HAS_LONG_DOUBLE
363 constant(char *name, int arg)
368 if (strEQ(name, "ARG_MAX"))
376 if (strEQ(name, "BUFSIZ"))
382 if (strEQ(name, "BRKINT"))
388 if (strEQ(name, "B9600"))
394 if (strEQ(name, "B19200"))
400 if (strEQ(name, "B38400"))
406 if (strEQ(name, "B0"))
412 if (strEQ(name, "B110"))
418 if (strEQ(name, "B1200"))
424 if (strEQ(name, "B134"))
430 if (strEQ(name, "B150"))
436 if (strEQ(name, "B1800"))
442 if (strEQ(name, "B200"))
448 if (strEQ(name, "B2400"))
454 if (strEQ(name, "B300"))
460 if (strEQ(name, "B4800"))
466 if (strEQ(name, "B50"))
472 if (strEQ(name, "B600"))
478 if (strEQ(name, "B75"))
486 if (strEQ(name, "CHAR_BIT"))
492 if (strEQ(name, "CHAR_MAX"))
498 if (strEQ(name, "CHAR_MIN"))
504 if (strEQ(name, "CHILD_MAX"))
510 if (strEQ(name, "CLK_TCK"))
516 if (strEQ(name, "CLOCAL"))
522 if (strEQ(name, "CLOCKS_PER_SEC"))
523 #ifdef CLOCKS_PER_SEC
524 return CLOCKS_PER_SEC;
528 if (strEQ(name, "CREAD"))
534 if (strEQ(name, "CS5"))
540 if (strEQ(name, "CS6"))
546 if (strEQ(name, "CS7"))
552 if (strEQ(name, "CS8"))
558 if (strEQ(name, "CSIZE"))
564 if (strEQ(name, "CSTOPB"))
572 if (strEQ(name, "DBL_MAX"))
578 if (strEQ(name, "DBL_MIN"))
584 if (strEQ(name, "DBL_DIG"))
590 if (strEQ(name, "DBL_EPSILON"))
596 if (strEQ(name, "DBL_MANT_DIG"))
602 if (strEQ(name, "DBL_MAX_10_EXP"))
603 #ifdef DBL_MAX_10_EXP
604 return DBL_MAX_10_EXP;
608 if (strEQ(name, "DBL_MAX_EXP"))
614 if (strEQ(name, "DBL_MIN_10_EXP"))
615 #ifdef DBL_MIN_10_EXP
616 return DBL_MIN_10_EXP;
620 if (strEQ(name, "DBL_MIN_EXP"))
630 if (strEQ(name, "EACCES"))
636 if (strEQ(name, "EADDRINUSE"))
642 if (strEQ(name, "EADDRNOTAVAIL"))
644 return EADDRNOTAVAIL;
648 if (strEQ(name, "EAFNOSUPPORT"))
654 if (strEQ(name, "EAGAIN"))
660 if (strEQ(name, "EALREADY"))
668 if (strEQ(name, "EBADF"))
674 if (strEQ(name, "EBUSY"))
682 if (strEQ(name, "ECHILD"))
688 if (strEQ(name, "ECHO"))
694 if (strEQ(name, "ECHOE"))
700 if (strEQ(name, "ECHOK"))
706 if (strEQ(name, "ECHONL"))
712 if (strEQ(name, "ECONNABORTED"))
718 if (strEQ(name, "ECONNREFUSED"))
724 if (strEQ(name, "ECONNRESET"))
732 if (strEQ(name, "EDEADLK"))
738 if (strEQ(name, "EDESTADDRREQ"))
744 if (strEQ(name, "EDOM"))
750 if (strEQ(name, "EDQUOT"))
758 if (strEQ(name, "EEXIST"))
766 if (strEQ(name, "EFAULT"))
772 if (strEQ(name, "EFBIG"))
780 if (strEQ(name, "EHOSTDOWN"))
786 if (strEQ(name, "EHOSTUNREACH"))
794 if (strEQ(name, "EINPROGRESS"))
800 if (strEQ(name, "EINTR"))
806 if (strEQ(name, "EINVAL"))
812 if (strEQ(name, "EIO"))
818 if (strEQ(name, "EISCONN"))
824 if (strEQ(name, "EISDIR"))
832 if (strEQ(name, "ELOOP"))
840 if (strEQ(name, "EMFILE"))
846 if (strEQ(name, "EMLINK"))
852 if (strEQ(name, "EMSGSIZE"))
860 if (strEQ(name, "ENETDOWN"))
866 if (strEQ(name, "ENETRESET"))
872 if (strEQ(name, "ENETUNREACH"))
878 if (strEQ(name, "ENOBUFS"))
884 if (strEQ(name, "ENOEXEC"))
890 if (strEQ(name, "ENOMEM"))
896 if (strEQ(name, "ENOPROTOOPT"))
902 if (strEQ(name, "ENOSPC"))
908 if (strEQ(name, "ENOTBLK"))
914 if (strEQ(name, "ENOTCONN"))
920 if (strEQ(name, "ENOTDIR"))
926 if (strEQ(name, "ENOTEMPTY"))
932 if (strEQ(name, "ENOTSOCK"))
938 if (strEQ(name, "ENOTTY"))
944 if (strEQ(name, "ENFILE"))
950 if (strEQ(name, "ENODEV"))
956 if (strEQ(name, "ENOENT"))
962 if (strEQ(name, "ENOLCK"))
968 if (strEQ(name, "ENOSYS"))
974 if (strEQ(name, "ENXIO"))
980 if (strEQ(name, "ENAMETOOLONG"))
988 if (strEQ(name, "EOF"))
994 if (strEQ(name, "EOPNOTSUPP"))
1002 if (strEQ(name, "EPERM"))
1008 if (strEQ(name, "EPFNOSUPPORT"))
1010 return EPFNOSUPPORT;
1014 if (strEQ(name, "EPIPE"))
1020 if (strEQ(name, "EPROCLIM"))
1026 if (strEQ(name, "EPROTONOSUPPORT"))
1027 #ifdef EPROTONOSUPPORT
1028 return EPROTONOSUPPORT;
1032 if (strEQ(name, "EPROTOTYPE"))
1040 if (strEQ(name, "ERANGE"))
1046 if (strEQ(name, "EREMOTE"))
1052 if (strEQ(name, "ERESTART"))
1058 if (strEQ(name, "EROFS"))
1066 if (strEQ(name, "ESHUTDOWN"))
1072 if (strEQ(name, "ESOCKTNOSUPPORT"))
1073 #ifdef ESOCKTNOSUPPORT
1074 return ESOCKTNOSUPPORT;
1078 if (strEQ(name, "ESPIPE"))
1084 if (strEQ(name, "ESRCH"))
1090 if (strEQ(name, "ESTALE"))
1098 if (strEQ(name, "ETIMEDOUT"))
1104 if (strEQ(name, "ETOOMANYREFS"))
1106 return ETOOMANYREFS;
1110 if (strEQ(name, "ETXTBSY"))
1118 if (strEQ(name, "EUSERS"))
1126 if (strEQ(name, "EWOULDBLOCK"))
1134 if (strEQ(name, "EXIT_FAILURE"))
1136 return EXIT_FAILURE;
1140 if (strEQ(name, "EXIT_SUCCESS"))
1142 return EXIT_SUCCESS;
1146 if (strEQ(name, "EXDEV"))
1154 if (strEQ(name, "E2BIG"))
1162 if (strnEQ(name, "FLT_", 4)) {
1163 if (strEQ(name, "FLT_MAX"))
1169 if (strEQ(name, "FLT_MIN"))
1175 if (strEQ(name, "FLT_ROUNDS"))
1181 if (strEQ(name, "FLT_DIG"))
1187 if (strEQ(name, "FLT_EPSILON"))
1193 if (strEQ(name, "FLT_MANT_DIG"))
1195 return FLT_MANT_DIG;
1199 if (strEQ(name, "FLT_MAX_10_EXP"))
1200 #ifdef FLT_MAX_10_EXP
1201 return FLT_MAX_10_EXP;
1205 if (strEQ(name, "FLT_MAX_EXP"))
1211 if (strEQ(name, "FLT_MIN_10_EXP"))
1212 #ifdef FLT_MIN_10_EXP
1213 return FLT_MIN_10_EXP;
1217 if (strEQ(name, "FLT_MIN_EXP"))
1223 if (strEQ(name, "FLT_RADIX"))
1231 if (strnEQ(name, "F_", 2)) {
1232 if (strEQ(name, "F_DUPFD"))
1238 if (strEQ(name, "F_GETFD"))
1244 if (strEQ(name, "F_GETFL"))
1250 if (strEQ(name, "F_GETLK"))
1256 if (strEQ(name, "F_OK"))
1262 if (strEQ(name, "F_RDLCK"))
1268 if (strEQ(name, "F_SETFD"))
1274 if (strEQ(name, "F_SETFL"))
1280 if (strEQ(name, "F_SETLK"))
1286 if (strEQ(name, "F_SETLKW"))
1292 if (strEQ(name, "F_UNLCK"))
1298 if (strEQ(name, "F_WRLCK"))
1306 if (strEQ(name, "FD_CLOEXEC"))
1312 if (strEQ(name, "FILENAME_MAX"))
1314 return FILENAME_MAX;
1320 if (strEQ(name, "HUGE_VAL"))
1326 if (strEQ(name, "HUPCL"))
1334 if (strEQ(name, "INT_MAX"))
1340 if (strEQ(name, "INT_MIN"))
1346 if (strEQ(name, "ICANON"))
1352 if (strEQ(name, "ICRNL"))
1358 if (strEQ(name, "IEXTEN"))
1364 if (strEQ(name, "IGNBRK"))
1370 if (strEQ(name, "IGNCR"))
1376 if (strEQ(name, "IGNPAR"))
1382 if (strEQ(name, "INLCR"))
1388 if (strEQ(name, "INPCK"))
1394 if (strEQ(name, "ISIG"))
1400 if (strEQ(name, "ISTRIP"))
1406 if (strEQ(name, "IXOFF"))
1412 if (strEQ(name, "IXON"))
1420 if (strnEQ(name, "LC_", 3)) {
1421 if (strEQ(name, "LC_ALL"))
1427 if (strEQ(name, "LC_COLLATE"))
1433 if (strEQ(name, "LC_CTYPE"))
1439 if (strEQ(name, "LC_MONETARY"))
1445 if (strEQ(name, "LC_NUMERIC"))
1451 if (strEQ(name, "LC_TIME"))
1459 if (strnEQ(name, "LDBL_", 5)) {
1460 if (strEQ(name, "LDBL_MAX"))
1466 if (strEQ(name, "LDBL_MIN"))
1472 if (strEQ(name, "LDBL_DIG"))
1478 if (strEQ(name, "LDBL_EPSILON"))
1480 return LDBL_EPSILON;
1484 if (strEQ(name, "LDBL_MANT_DIG"))
1485 #ifdef LDBL_MANT_DIG
1486 return LDBL_MANT_DIG;
1490 if (strEQ(name, "LDBL_MAX_10_EXP"))
1491 #ifdef LDBL_MAX_10_EXP
1492 return LDBL_MAX_10_EXP;
1496 if (strEQ(name, "LDBL_MAX_EXP"))
1498 return LDBL_MAX_EXP;
1502 if (strEQ(name, "LDBL_MIN_10_EXP"))
1503 #ifdef LDBL_MIN_10_EXP
1504 return LDBL_MIN_10_EXP;
1508 if (strEQ(name, "LDBL_MIN_EXP"))
1510 return LDBL_MIN_EXP;
1516 if (strnEQ(name, "L_", 2)) {
1517 if (strEQ(name, "L_ctermid"))
1523 if (strEQ(name, "L_cuserid"))
1529 /* L_tmpnam[e] was a typo--retained for compatibility */
1530 if (strEQ(name, "L_tmpname") || strEQ(name, "L_tmpnam"))
1538 if (strEQ(name, "LONG_MAX"))
1544 if (strEQ(name, "LONG_MIN"))
1550 if (strEQ(name, "LINK_MAX"))
1558 if (strEQ(name, "MAX_CANON"))
1564 if (strEQ(name, "MAX_INPUT"))
1570 if (strEQ(name, "MB_CUR_MAX"))
1576 if (strEQ(name, "MB_LEN_MAX"))
1584 if (strEQ(name, "NULL")) return 0;
1585 if (strEQ(name, "NAME_MAX"))
1591 if (strEQ(name, "NCCS"))
1597 if (strEQ(name, "NGROUPS_MAX"))
1603 if (strEQ(name, "NOFLSH"))
1611 if (strnEQ(name, "O_", 2)) {
1612 if (strEQ(name, "O_APPEND"))
1618 if (strEQ(name, "O_CREAT"))
1624 if (strEQ(name, "O_TRUNC"))
1630 if (strEQ(name, "O_RDONLY"))
1636 if (strEQ(name, "O_RDWR"))
1642 if (strEQ(name, "O_WRONLY"))
1648 if (strEQ(name, "O_EXCL"))
1654 if (strEQ(name, "O_NOCTTY"))
1660 if (strEQ(name, "O_NONBLOCK"))
1666 if (strEQ(name, "O_ACCMODE"))
1674 if (strEQ(name, "OPEN_MAX"))
1680 if (strEQ(name, "OPOST"))
1688 if (strEQ(name, "PATH_MAX"))
1694 if (strEQ(name, "PARENB"))
1700 if (strEQ(name, "PARMRK"))
1706 if (strEQ(name, "PARODD"))
1712 if (strEQ(name, "PIPE_BUF"))
1720 if (strEQ(name, "RAND_MAX"))
1726 if (strEQ(name, "R_OK"))
1734 if (strnEQ(name, "SIG", 3)) {
1735 if (name[3] == '_') {
1736 if (strEQ(name, "SIG_BLOCK"))
1743 if (strEQ(name, "SIG_DFL")) return (IV)SIG_DFL;
1746 if (strEQ(name, "SIG_ERR")) return (IV)SIG_ERR;
1749 if (strEQ(name, "SIG_IGN")) return (IV)SIG_IGN;
1751 if (strEQ(name, "SIG_SETMASK"))
1757 if (strEQ(name, "SIG_UNBLOCK"))
1765 if (strEQ(name, "SIGABRT"))
1771 if (strEQ(name, "SIGALRM"))
1777 if (strEQ(name, "SIGCHLD"))
1783 if (strEQ(name, "SIGCONT"))
1789 if (strEQ(name, "SIGFPE"))
1795 if (strEQ(name, "SIGHUP"))
1801 if (strEQ(name, "SIGILL"))
1807 if (strEQ(name, "SIGINT"))
1813 if (strEQ(name, "SIGKILL"))
1819 if (strEQ(name, "SIGPIPE"))
1825 if (strEQ(name, "SIGQUIT"))
1831 if (strEQ(name, "SIGSEGV"))
1837 if (strEQ(name, "SIGSTOP"))
1843 if (strEQ(name, "SIGTERM"))
1849 if (strEQ(name, "SIGTSTP"))
1855 if (strEQ(name, "SIGTTIN"))
1861 if (strEQ(name, "SIGTTOU"))
1867 if (strEQ(name, "SIGUSR1"))
1873 if (strEQ(name, "SIGUSR2"))
1881 if (name[1] == '_') {
1882 if (strEQ(name, "S_ISGID"))
1888 if (strEQ(name, "S_ISUID"))
1894 if (strEQ(name, "S_IRGRP"))
1900 if (strEQ(name, "S_IROTH"))
1906 if (strEQ(name, "S_IRUSR"))
1912 if (strEQ(name, "S_IRWXG"))
1918 if (strEQ(name, "S_IRWXO"))
1924 if (strEQ(name, "S_IRWXU"))
1930 if (strEQ(name, "S_IWGRP"))
1936 if (strEQ(name, "S_IWOTH"))
1942 if (strEQ(name, "S_IWUSR"))
1948 if (strEQ(name, "S_IXGRP"))
1954 if (strEQ(name, "S_IXOTH"))
1960 if (strEQ(name, "S_IXUSR"))
1966 errno = EAGAIN; /* the following aren't constants */
1968 if (strEQ(name, "S_ISBLK")) return S_ISBLK(arg);
1971 if (strEQ(name, "S_ISCHR")) return S_ISCHR(arg);
1974 if (strEQ(name, "S_ISDIR")) return S_ISDIR(arg);
1977 if (strEQ(name, "S_ISFIFO")) return S_ISFIFO(arg);
1980 if (strEQ(name, "S_ISREG")) return S_ISREG(arg);
1984 if (strEQ(name, "SEEK_CUR"))
1990 if (strEQ(name, "SEEK_END"))
1996 if (strEQ(name, "SEEK_SET"))
2002 if (strEQ(name, "STREAM_MAX"))
2008 if (strEQ(name, "SHRT_MAX"))
2014 if (strEQ(name, "SHRT_MIN"))
2020 if (strnEQ(name, "SA_", 3)) {
2021 if (strEQ(name, "SA_NOCLDSTOP"))
2023 return SA_NOCLDSTOP;
2027 if (strEQ(name, "SA_NOCLDWAIT"))
2029 return SA_NOCLDWAIT;
2033 if (strEQ(name, "SA_NODEFER"))
2039 if (strEQ(name, "SA_ONSTACK"))
2045 if (strEQ(name, "SA_RESETHAND"))
2047 return SA_RESETHAND;
2051 if (strEQ(name, "SA_RESTART"))
2057 if (strEQ(name, "SA_SIGINFO"))
2065 if (strEQ(name, "SCHAR_MAX"))
2071 if (strEQ(name, "SCHAR_MIN"))
2077 if (strEQ(name, "SSIZE_MAX"))
2083 if (strEQ(name, "STDIN_FILENO"))
2085 return STDIN_FILENO;
2089 if (strEQ(name, "STDOUT_FILENO"))
2090 #ifdef STDOUT_FILENO
2091 return STDOUT_FILENO;
2095 if (strEQ(name, "STRERR_FILENO"))
2096 #ifdef STRERR_FILENO
2097 return STRERR_FILENO;
2103 if (strEQ(name, "TCIFLUSH"))
2109 if (strEQ(name, "TCIOFF"))
2115 if (strEQ(name, "TCIOFLUSH"))
2121 if (strEQ(name, "TCION"))
2127 if (strEQ(name, "TCOFLUSH"))
2133 if (strEQ(name, "TCOOFF"))
2139 if (strEQ(name, "TCOON"))
2145 if (strEQ(name, "TCSADRAIN"))
2151 if (strEQ(name, "TCSAFLUSH"))
2157 if (strEQ(name, "TCSANOW"))
2163 if (strEQ(name, "TMP_MAX"))
2169 if (strEQ(name, "TOSTOP"))
2175 if (strEQ(name, "TZNAME_MAX"))
2183 if (strEQ(name, "UCHAR_MAX"))
2189 if (strEQ(name, "UINT_MAX"))
2195 if (strEQ(name, "ULONG_MAX"))
2201 if (strEQ(name, "USHRT_MAX"))
2209 if (strEQ(name, "VEOF"))
2215 if (strEQ(name, "VEOL"))
2221 if (strEQ(name, "VERASE"))
2227 if (strEQ(name, "VINTR"))
2233 if (strEQ(name, "VKILL"))
2239 if (strEQ(name, "VMIN"))
2245 if (strEQ(name, "VQUIT"))
2251 if (strEQ(name, "VSTART"))
2257 if (strEQ(name, "VSTOP"))
2263 if (strEQ(name, "VSUSP"))
2269 if (strEQ(name, "VTIME"))
2277 if (strEQ(name, "W_OK"))
2283 if (strEQ(name, "WNOHANG"))
2289 if (strEQ(name, "WUNTRACED"))
2295 errno = EAGAIN; /* the following aren't constants */
2297 if (strEQ(name, "WEXITSTATUS")) return WEXITSTATUS(arg);
2300 if (strEQ(name, "WIFEXITED")) return WIFEXITED(arg);
2303 if (strEQ(name, "WIFSIGNALED")) return WIFSIGNALED(arg);
2306 if (strEQ(name, "WIFSTOPPED")) return WIFSTOPPED(arg);
2309 if (strEQ(name, "WSTOPSIG")) return WSTOPSIG(arg);
2312 if (strEQ(name, "WTERMSIG")) return WTERMSIG(arg);
2316 if (strEQ(name, "X_OK"))
2324 if (strnEQ(name, "_PC_", 4)) {
2325 if (strEQ(name, "_PC_CHOWN_RESTRICTED"))
2326 #if defined(_PC_CHOWN_RESTRICTED) || HINT_SC_EXIST
2327 return _PC_CHOWN_RESTRICTED;
2331 if (strEQ(name, "_PC_LINK_MAX"))
2332 #if defined(_PC_LINK_MAX) || HINT_SC_EXIST
2333 return _PC_LINK_MAX;
2337 if (strEQ(name, "_PC_MAX_CANON"))
2338 #if defined(_PC_MAX_CANON) || HINT_SC_EXIST
2339 return _PC_MAX_CANON;
2343 if (strEQ(name, "_PC_MAX_INPUT"))
2344 #if defined(_PC_MAX_INPUT) || HINT_SC_EXIST
2345 return _PC_MAX_INPUT;
2349 if (strEQ(name, "_PC_NAME_MAX"))
2350 #if defined(_PC_NAME_MAX) || HINT_SC_EXIST
2351 return _PC_NAME_MAX;
2355 if (strEQ(name, "_PC_NO_TRUNC"))
2356 #if defined(_PC_NO_TRUNC) || HINT_SC_EXIST
2357 return _PC_NO_TRUNC;
2361 if (strEQ(name, "_PC_PATH_MAX"))
2362 #if defined(_PC_PATH_MAX) || HINT_SC_EXIST
2363 return _PC_PATH_MAX;
2367 if (strEQ(name, "_PC_PIPE_BUF"))
2368 #if defined(_PC_PIPE_BUF) || HINT_SC_EXIST
2369 return _PC_PIPE_BUF;
2373 if (strEQ(name, "_PC_VDISABLE"))
2374 #if defined(_PC_VDISABLE) || HINT_SC_EXIST
2375 return _PC_VDISABLE;
2381 if (strnEQ(name, "_POSIX_", 7)) {
2382 if (strEQ(name, "_POSIX_ARG_MAX"))
2383 #ifdef _POSIX_ARG_MAX
2384 return _POSIX_ARG_MAX;
2388 if (strEQ(name, "_POSIX_CHILD_MAX"))
2389 #ifdef _POSIX_CHILD_MAX
2390 return _POSIX_CHILD_MAX;
2394 if (strEQ(name, "_POSIX_CHOWN_RESTRICTED"))
2395 #ifdef _POSIX_CHOWN_RESTRICTED
2396 return _POSIX_CHOWN_RESTRICTED;
2400 if (strEQ(name, "_POSIX_JOB_CONTROL"))
2401 #ifdef _POSIX_JOB_CONTROL
2402 return _POSIX_JOB_CONTROL;
2406 if (strEQ(name, "_POSIX_LINK_MAX"))
2407 #ifdef _POSIX_LINK_MAX
2408 return _POSIX_LINK_MAX;
2412 if (strEQ(name, "_POSIX_MAX_CANON"))
2413 #ifdef _POSIX_MAX_CANON
2414 return _POSIX_MAX_CANON;
2418 if (strEQ(name, "_POSIX_MAX_INPUT"))
2419 #ifdef _POSIX_MAX_INPUT
2420 return _POSIX_MAX_INPUT;
2424 if (strEQ(name, "_POSIX_NAME_MAX"))
2425 #ifdef _POSIX_NAME_MAX
2426 return _POSIX_NAME_MAX;
2430 if (strEQ(name, "_POSIX_NGROUPS_MAX"))
2431 #ifdef _POSIX_NGROUPS_MAX
2432 return _POSIX_NGROUPS_MAX;
2436 if (strEQ(name, "_POSIX_NO_TRUNC"))
2437 #ifdef _POSIX_NO_TRUNC
2438 return _POSIX_NO_TRUNC;
2442 if (strEQ(name, "_POSIX_OPEN_MAX"))
2443 #ifdef _POSIX_OPEN_MAX
2444 return _POSIX_OPEN_MAX;
2448 if (strEQ(name, "_POSIX_PATH_MAX"))
2449 #ifdef _POSIX_PATH_MAX
2450 return _POSIX_PATH_MAX;
2454 if (strEQ(name, "_POSIX_PIPE_BUF"))
2455 #ifdef _POSIX_PIPE_BUF
2456 return _POSIX_PIPE_BUF;
2460 if (strEQ(name, "_POSIX_SAVED_IDS"))
2461 #ifdef _POSIX_SAVED_IDS
2462 return _POSIX_SAVED_IDS;
2466 if (strEQ(name, "_POSIX_SSIZE_MAX"))
2467 #ifdef _POSIX_SSIZE_MAX
2468 return _POSIX_SSIZE_MAX;
2472 if (strEQ(name, "_POSIX_STREAM_MAX"))
2473 #ifdef _POSIX_STREAM_MAX
2474 return _POSIX_STREAM_MAX;
2478 if (strEQ(name, "_POSIX_TZNAME_MAX"))
2479 #ifdef _POSIX_TZNAME_MAX
2480 return _POSIX_TZNAME_MAX;
2484 if (strEQ(name, "_POSIX_VDISABLE"))
2485 #ifdef _POSIX_VDISABLE
2486 return _POSIX_VDISABLE;
2490 if (strEQ(name, "_POSIX_VERSION"))
2491 #ifdef _POSIX_VERSION
2492 return _POSIX_VERSION;
2498 if (strnEQ(name, "_SC_", 4)) {
2499 if (strEQ(name, "_SC_ARG_MAX"))
2500 #if defined(_SC_ARG_MAX) || HINT_SC_EXIST
2505 if (strEQ(name, "_SC_CHILD_MAX"))
2506 #if defined(_SC_CHILD_MAX) || HINT_SC_EXIST
2507 return _SC_CHILD_MAX;
2511 if (strEQ(name, "_SC_CLK_TCK"))
2512 #if defined(_SC_CLK_TCK) || HINT_SC_EXIST
2517 if (strEQ(name, "_SC_JOB_CONTROL"))
2518 #if defined(_SC_JOB_CONTROL) || HINT_SC_EXIST
2519 return _SC_JOB_CONTROL;
2523 if (strEQ(name, "_SC_NGROUPS_MAX"))
2524 #if defined(_SC_NGROUPS_MAX) || HINT_SC_EXIST
2525 return _SC_NGROUPS_MAX;
2529 if (strEQ(name, "_SC_OPEN_MAX"))
2530 #if defined(_SC_OPEN_MAX) || HINT_SC_EXIST
2531 return _SC_OPEN_MAX;
2535 if (strEQ(name, "_SC_SAVED_IDS"))
2536 #if defined(_SC_SAVED_IDS) || HINT_SC_EXIST
2537 return _SC_SAVED_IDS;
2541 if (strEQ(name, "_SC_STREAM_MAX"))
2542 #if defined(_SC_STREAM_MAX) || HINT_SC_EXIST
2543 return _SC_STREAM_MAX;
2547 if (strEQ(name, "_SC_TZNAME_MAX"))
2548 #if defined(_SC_TZNAME_MAX) || HINT_SC_EXIST
2549 return _SC_TZNAME_MAX;
2553 if (strEQ(name, "_SC_VERSION"))
2554 #if defined(_SC_VERSION) || HINT_SC_EXIST
2570 MODULE = SigSet PACKAGE = POSIX::SigSet PREFIX = sig
2573 new(packname = "POSIX::SigSet", ...)
2578 New(0, RETVAL, 1, sigset_t);
2579 sigemptyset(RETVAL);
2580 for (i = 1; i < items; i++)
2581 sigaddset(RETVAL, SvIV(ST(i)));
2588 POSIX::SigSet sigset
2593 sigaddset(sigset, sig)
2594 POSIX::SigSet sigset
2598 sigdelset(sigset, sig)
2599 POSIX::SigSet sigset
2604 POSIX::SigSet sigset
2608 POSIX::SigSet sigset
2611 sigismember(sigset, sig)
2612 POSIX::SigSet sigset
2616 MODULE = Termios PACKAGE = POSIX::Termios PREFIX = cf
2619 new(packname = "POSIX::Termios", ...)
2624 New(0, RETVAL, 1, struct termios);
2626 not_here("termios");
2634 DESTROY(termios_ref)
2635 POSIX::Termios termios_ref
2638 Safefree(termios_ref);
2640 not_here("termios");
2644 getattr(termios_ref, fd = 0)
2645 POSIX::Termios termios_ref
2648 RETVAL = tcgetattr(fd, termios_ref);
2653 setattr(termios_ref, fd = 0, optional_actions = 0)
2654 POSIX::Termios termios_ref
2656 int optional_actions
2658 RETVAL = tcsetattr(fd, optional_actions, termios_ref);
2663 cfgetispeed(termios_ref)
2664 POSIX::Termios termios_ref
2667 cfgetospeed(termios_ref)
2668 POSIX::Termios termios_ref
2671 getiflag(termios_ref)
2672 POSIX::Termios termios_ref
2674 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2675 RETVAL = termios_ref->c_iflag;
2677 not_here("getiflag");
2684 getoflag(termios_ref)
2685 POSIX::Termios termios_ref
2687 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2688 RETVAL = termios_ref->c_oflag;
2690 not_here("getoflag");
2697 getcflag(termios_ref)
2698 POSIX::Termios termios_ref
2700 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2701 RETVAL = termios_ref->c_cflag;
2703 not_here("getcflag");
2710 getlflag(termios_ref)
2711 POSIX::Termios termios_ref
2713 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2714 RETVAL = termios_ref->c_lflag;
2716 not_here("getlflag");
2723 getcc(termios_ref, ccix)
2724 POSIX::Termios termios_ref
2727 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2729 croak("Bad getcc subscript");
2730 RETVAL = termios_ref->c_cc[ccix];
2739 cfsetispeed(termios_ref, speed)
2740 POSIX::Termios termios_ref
2744 cfsetospeed(termios_ref, speed)
2745 POSIX::Termios termios_ref
2749 setiflag(termios_ref, iflag)
2750 POSIX::Termios termios_ref
2753 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2754 termios_ref->c_iflag = iflag;
2756 not_here("setiflag");
2760 setoflag(termios_ref, oflag)
2761 POSIX::Termios termios_ref
2764 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2765 termios_ref->c_oflag = oflag;
2767 not_here("setoflag");
2771 setcflag(termios_ref, cflag)
2772 POSIX::Termios termios_ref
2775 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2776 termios_ref->c_cflag = cflag;
2778 not_here("setcflag");
2782 setlflag(termios_ref, lflag)
2783 POSIX::Termios termios_ref
2786 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2787 termios_ref->c_lflag = lflag;
2789 not_here("setlflag");
2793 setcc(termios_ref, ccix, cc)
2794 POSIX::Termios termios_ref
2798 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2800 croak("Bad setcc subscript");
2801 termios_ref->c_cc[ccix] = cc;
2807 MODULE = POSIX PACKAGE = POSIX
2816 unsigned char * charstring
2818 unsigned char *s = charstring;
2819 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2820 for (RETVAL = 1; RETVAL && s < e; s++)
2828 unsigned char * charstring
2830 unsigned char *s = charstring;
2831 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2832 for (RETVAL = 1; RETVAL && s < e; s++)
2840 unsigned char * charstring
2842 unsigned char *s = charstring;
2843 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2844 for (RETVAL = 1; RETVAL && s < e; s++)
2852 unsigned char * charstring
2854 unsigned char *s = charstring;
2855 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2856 for (RETVAL = 1; RETVAL && s < e; s++)
2864 unsigned char * charstring
2866 unsigned char *s = charstring;
2867 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2868 for (RETVAL = 1; RETVAL && s < e; s++)
2876 unsigned char * charstring
2878 unsigned char *s = charstring;
2879 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2880 for (RETVAL = 1; RETVAL && s < e; s++)
2888 unsigned char * charstring
2890 unsigned char *s = charstring;
2891 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2892 for (RETVAL = 1; RETVAL && s < e; s++)
2900 unsigned char * charstring
2902 unsigned char *s = charstring;
2903 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2904 for (RETVAL = 1; RETVAL && s < e; s++)
2912 unsigned char * charstring
2914 unsigned char *s = charstring;
2915 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2916 for (RETVAL = 1; RETVAL && s < e; s++)
2924 unsigned char * charstring
2926 unsigned char *s = charstring;
2927 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2928 for (RETVAL = 1; RETVAL && s < e; s++)
2935 isxdigit(charstring)
2936 unsigned char * charstring
2938 unsigned char *s = charstring;
2939 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2940 for (RETVAL = 1; RETVAL && s < e; s++)
2947 open(filename, flags = O_RDONLY, mode = 0666)
2952 if (flags & (O_APPEND|O_CREAT|O_TRUNC|O_RDWR|O_WRONLY|O_EXCL))
2953 TAINT_PROPER("open");
2954 RETVAL = open(filename, flags, mode);
2962 #ifdef HAS_LOCALECONV
2963 struct lconv *lcbuf;
2965 if (lcbuf = localeconv()) {
2967 if (lcbuf->decimal_point && *lcbuf->decimal_point)
2968 hv_store(RETVAL, "decimal_point", 13,
2969 newSVpv(lcbuf->decimal_point, 0), 0);
2970 if (lcbuf->thousands_sep && *lcbuf->thousands_sep)
2971 hv_store(RETVAL, "thousands_sep", 13,
2972 newSVpv(lcbuf->thousands_sep, 0), 0);
2973 #ifndef NO_LOCALECONV_GROUPING
2974 if (lcbuf->grouping && *lcbuf->grouping)
2975 hv_store(RETVAL, "grouping", 8,
2976 newSVpv(lcbuf->grouping, 0), 0);
2978 if (lcbuf->int_curr_symbol && *lcbuf->int_curr_symbol)
2979 hv_store(RETVAL, "int_curr_symbol", 15,
2980 newSVpv(lcbuf->int_curr_symbol, 0), 0);
2981 if (lcbuf->currency_symbol && *lcbuf->currency_symbol)
2982 hv_store(RETVAL, "currency_symbol", 15,
2983 newSVpv(lcbuf->currency_symbol, 0), 0);
2984 if (lcbuf->mon_decimal_point && *lcbuf->mon_decimal_point)
2985 hv_store(RETVAL, "mon_decimal_point", 17,
2986 newSVpv(lcbuf->mon_decimal_point, 0), 0);
2987 #ifndef NO_LOCALECONV_MON_THOUSANDS_SEP
2988 if (lcbuf->mon_thousands_sep && *lcbuf->mon_thousands_sep)
2989 hv_store(RETVAL, "mon_thousands_sep", 17,
2990 newSVpv(lcbuf->mon_thousands_sep, 0), 0);
2992 #ifndef NO_LOCALECONV_MON_GROUPING
2993 if (lcbuf->mon_grouping && *lcbuf->mon_grouping)
2994 hv_store(RETVAL, "mon_grouping", 12,
2995 newSVpv(lcbuf->mon_grouping, 0), 0);
2997 if (lcbuf->positive_sign && *lcbuf->positive_sign)
2998 hv_store(RETVAL, "positive_sign", 13,
2999 newSVpv(lcbuf->positive_sign, 0), 0);
3000 if (lcbuf->negative_sign && *lcbuf->negative_sign)
3001 hv_store(RETVAL, "negative_sign", 13,
3002 newSVpv(lcbuf->negative_sign, 0), 0);
3004 if (lcbuf->int_frac_digits != CHAR_MAX)
3005 hv_store(RETVAL, "int_frac_digits", 15,
3006 newSViv(lcbuf->int_frac_digits), 0);
3007 if (lcbuf->frac_digits != CHAR_MAX)
3008 hv_store(RETVAL, "frac_digits", 11,
3009 newSViv(lcbuf->frac_digits), 0);
3010 if (lcbuf->p_cs_precedes != CHAR_MAX)
3011 hv_store(RETVAL, "p_cs_precedes", 13,
3012 newSViv(lcbuf->p_cs_precedes), 0);
3013 if (lcbuf->p_sep_by_space != CHAR_MAX)
3014 hv_store(RETVAL, "p_sep_by_space", 14,
3015 newSViv(lcbuf->p_sep_by_space), 0);
3016 if (lcbuf->n_cs_precedes != CHAR_MAX)
3017 hv_store(RETVAL, "n_cs_precedes", 13,
3018 newSViv(lcbuf->n_cs_precedes), 0);
3019 if (lcbuf->n_sep_by_space != CHAR_MAX)
3020 hv_store(RETVAL, "n_sep_by_space", 14,
3021 newSViv(lcbuf->n_sep_by_space), 0);
3022 if (lcbuf->p_sign_posn != CHAR_MAX)
3023 hv_store(RETVAL, "p_sign_posn", 11,
3024 newSViv(lcbuf->p_sign_posn), 0);
3025 if (lcbuf->n_sign_posn != CHAR_MAX)
3026 hv_store(RETVAL, "n_sign_posn", 11,
3027 newSViv(lcbuf->n_sign_posn), 0);
3030 localeconv(); /* A stub to call not_here(). */
3036 setlocale(category, locale = 0)
3040 RETVAL = setlocale(category, locale);
3042 #ifdef USE_LOCALE_CTYPE
3043 if (category == LC_CTYPE
3045 || category == LC_ALL
3051 if (category == LC_ALL)
3052 newctype = setlocale(LC_CTYPE, NULL);
3056 new_ctype(newctype);
3058 #endif /* USE_LOCALE_CTYPE */
3059 #ifdef USE_LOCALE_COLLATE
3060 if (category == LC_COLLATE
3062 || category == LC_ALL
3068 if (category == LC_ALL)
3069 newcoll = setlocale(LC_COLLATE, NULL);
3073 new_collate(newcoll);
3075 #endif /* USE_LOCALE_COLLATE */
3076 #ifdef USE_LOCALE_NUMERIC
3077 if (category == LC_NUMERIC
3079 || category == LC_ALL
3085 if (category == LC_ALL)
3086 newnum = setlocale(LC_NUMERIC, NULL);
3090 new_numeric(newnum);
3092 #endif /* USE_LOCALE_NUMERIC */
3132 /* (We already know stack is long enough.) */
3133 PUSHs(sv_2mortal(newSVnv(frexp(x,&expvar))));
3134 PUSHs(sv_2mortal(newSViv(expvar)));
3150 /* (We already know stack is long enough.) */
3151 PUSHs(sv_2mortal(newSVnv(modf(x,&intvar))));
3152 PUSHs(sv_2mortal(newSVnv(intvar)));
3167 sigaction(sig, action, oldaction = 0)
3169 POSIX::SigAction action
3170 POSIX::SigAction oldaction
3173 RETVAL = not_here("sigaction");
3175 # This code is really grody because we're trying to make the signal
3176 # interface look beautiful, which is hard.
3179 gv_fetchpv("SIG", TRUE, SVt_PVHV);
3182 struct sigaction act;
3183 struct sigaction oact;
3184 POSIX__SigSet sigset;
3186 SV** sigsvp = hv_fetch(GvHVn(PL_siggv),
3188 strlen(PL_sig_name[sig]),
3192 /* Remember old handler name if desired. */
3194 char *hand = SvPVx(*sigsvp, n_a);
3195 svp = hv_fetch(oldaction, "HANDLER", 7, TRUE);
3196 sv_setpv(*svp, *hand ? hand : "DEFAULT");
3200 /* Vector new handler through %SIG. (We always use sighandler
3201 for the C signal handler, which reads %SIG to dispatch.) */
3202 svp = hv_fetch(action, "HANDLER", 7, FALSE);
3204 croak("Can't supply an action without a HANDLER");
3205 sv_setpv(*sigsvp, SvPV(*svp, n_a));
3206 mg_set(*sigsvp); /* handles DEFAULT and IGNORE */
3207 act.sa_handler = PL_sighandlerp;
3209 /* Set up any desired mask. */
3210 svp = hv_fetch(action, "MASK", 4, FALSE);
3211 if (svp && sv_isa(*svp, "POSIX::SigSet")) {
3213 tmp = (unsigned long)SvNV((SV*)SvRV(*svp));
3214 sigset = (sigset_t*) tmp;
3215 act.sa_mask = *sigset;
3218 sigemptyset(& act.sa_mask);
3220 /* Set up any desired flags. */
3221 svp = hv_fetch(action, "FLAGS", 5, FALSE);
3222 act.sa_flags = svp ? SvIV(*svp) : 0;
3225 /* Now work around sigaction oddities */
3226 if (action && oldaction)
3227 RETVAL = sigaction(sig, & act, & oact);
3229 RETVAL = sigaction(sig, & act, (struct sigaction *)0);
3231 RETVAL = sigaction(sig, (struct sigaction *)0, & oact);
3236 /* Get back the mask. */
3237 svp = hv_fetch(oldaction, "MASK", 4, TRUE);
3238 if (sv_isa(*svp, "POSIX::SigSet")) {
3240 tmp = (unsigned long)SvNV((SV*)SvRV(*svp));
3241 sigset = (sigset_t*) tmp;
3244 New(0, sigset, 1, sigset_t);
3245 sv_setptrobj(*svp, sigset, "POSIX::SigSet");
3247 *sigset = oact.sa_mask;
3249 /* Get back the flags. */
3250 svp = hv_fetch(oldaction, "FLAGS", 5, TRUE);
3251 sv_setiv(*svp, oact.sa_flags);
3260 POSIX::SigSet sigset
3263 sigprocmask(how, sigset, oldsigset = 0)
3265 POSIX::SigSet sigset
3266 POSIX::SigSet oldsigset = NO_INIT
3271 else if (sv_derived_from(ST(2), "POSIX::SigSet")) {
3272 IV tmp = SvIV((SV*)SvRV(ST(2)));
3273 oldsigset = (POSIX__SigSet) tmp;
3276 New(0, oldsigset, 1, sigset_t);
3277 sigemptyset(oldsigset);
3278 sv_setref_pv(ST(2), "POSIX::SigSet", (void*)oldsigset);
3282 sigsuspend(signal_mask)
3283 POSIX::SigSet signal_mask
3303 lseek(fd, offset, whence)
3316 if (pipe(fds) != -1) {
3318 PUSHs(sv_2mortal(newSViv(fds[0])));
3319 PUSHs(sv_2mortal(newSViv(fds[1])));
3323 read(fd, buffer, nbytes)
3325 SV *sv_buffer = SvROK(ST(1)) ? SvRV(ST(1)) : ST(1);
3329 char * buffer = sv_grow( sv_buffer, nbytes+1 );
3332 SvCUR(sv_buffer) = RETVAL;
3333 SvPOK_only(sv_buffer);
3334 *SvEND(sv_buffer) = '\0';
3335 SvTAINTED_on(sv_buffer);
3351 tcsetpgrp(fd, pgrp_id)
3360 if (uname(&buf) >= 0) {
3362 PUSHs(sv_2mortal(newSVpv(buf.sysname, 0)));
3363 PUSHs(sv_2mortal(newSVpv(buf.nodename, 0)));
3364 PUSHs(sv_2mortal(newSVpv(buf.release, 0)));
3365 PUSHs(sv_2mortal(newSVpv(buf.version, 0)));
3366 PUSHs(sv_2mortal(newSVpv(buf.machine, 0)));
3369 uname((char *) 0); /* A stub to call not_here(). */
3373 write(fd, buffer, nbytes)
3384 RETVAL = newSVpvn("", 0);
3385 SvGROW(RETVAL, L_tmpnam);
3386 len = strlen(tmpnam(SvPV(RETVAL, i)));
3387 SvCUR_set(RETVAL, len);
3400 mbstowcs(s, pwcs, n)
3412 wcstombs(s, pwcs, n)
3434 SET_NUMERIC_LOCAL();
3435 num = strtod(str, &unparsed);
3436 PUSHs(sv_2mortal(newSVnv(num)));
3437 if (GIMME == G_ARRAY) {
3440 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3442 PUSHs(&PL_sv_undef);
3446 strtol(str, base = 0)
3453 num = strtol(str, &unparsed, base);
3454 if (num >= IV_MIN && num <= IV_MAX)
3455 PUSHs(sv_2mortal(newSViv((IV)num)));
3457 PUSHs(sv_2mortal(newSVnv((double)num)));
3458 if (GIMME == G_ARRAY) {
3461 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3463 PUSHs(&PL_sv_undef);
3467 strtoul(str, base = 0)
3474 num = strtoul(str, &unparsed, base);
3476 PUSHs(sv_2mortal(newSViv((IV)num)));
3478 PUSHs(sv_2mortal(newSVnv((double)num)));
3479 if (GIMME == G_ARRAY) {
3482 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3484 PUSHs(&PL_sv_undef);
3494 char *p = SvPV(src,srclen);
3496 ST(0) = sv_2mortal(NEWSV(800,srclen));
3497 dstlen = strxfrm(SvPVX(ST(0)), p, (size_t)srclen);
3498 if (dstlen > srclen) {
3500 SvGROW(ST(0), dstlen);
3501 strxfrm(SvPVX(ST(0)), p, (size_t)dstlen);
3504 SvCUR(ST(0)) = dstlen;
3509 mkfifo(filename, mode)
3513 TAINT_PROPER("mkfifo");
3514 RETVAL = mkfifo(filename, mode);
3530 tcflush(fd, queue_selector)
3535 tcsendbreak(fd, duration)
3540 asctime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3553 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3556 mytm.tm_hour = hour;
3557 mytm.tm_mday = mday;
3559 mytm.tm_year = year;
3560 mytm.tm_wday = wday;
3561 mytm.tm_yday = yday;
3562 mytm.tm_isdst = isdst;
3563 RETVAL = asctime(&mytm);
3580 realtime = times( &tms );
3582 PUSHs( sv_2mortal( newSViv( (IV) realtime ) ) );
3583 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_utime ) ) );
3584 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_stime ) ) );
3585 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cutime ) ) );
3586 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cstime ) ) );
3589 difftime(time1, time2)
3594 mktime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3607 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3610 mytm.tm_hour = hour;
3611 mytm.tm_mday = mday;
3613 mytm.tm_year = year;
3614 mytm.tm_wday = wday;
3615 mytm.tm_yday = yday;
3616 mytm.tm_isdst = isdst;
3617 RETVAL = mktime(&mytm);
3623 strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1)
3639 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3642 mytm.tm_hour = hour;
3643 mytm.tm_mday = mday;
3645 mytm.tm_year = year;
3646 mytm.tm_wday = wday;
3647 mytm.tm_yday = yday;
3648 mytm.tm_isdst = isdst;
3649 (void) mktime(&mytm);
3650 len = strftime(tmpbuf, sizeof tmpbuf, fmt, &mytm);
3652 ** The following is needed to handle to the situation where
3653 ** tmpbuf overflows. Basically we want to allocate a buffer
3654 ** and try repeatedly. The reason why it is so complicated
3655 ** is that getting a return value of 0 from strftime can indicate
3656 ** one of the following:
3657 ** 1. buffer overflowed,
3658 ** 2. illegal conversion specifier, or
3659 ** 3. the format string specifies nothing to be returned(not
3660 ** an error). This could be because format is an empty string
3661 ** or it specifies %p that yields an empty string in some locale.
3662 ** If there is a better way to make it portable, go ahead by
3665 if ( ( len > 0 && len < sizeof(tmpbuf) )
3666 || ( len == 0 && strlen(fmt) == 0 ) ) {
3667 ST(0) = sv_2mortal(newSVpv(tmpbuf, len));
3669 /* Possibly buf overflowed - try again with a bigger buf */
3670 int bufsize = strlen(fmt) + sizeof(tmpbuf);
3674 New(0, buf, bufsize, char);
3676 buflen = strftime(buf, bufsize, fmt, &mytm);
3677 if ( buflen > 0 && buflen < bufsize ) break;
3679 Renew(buf, bufsize, char);
3682 ST(0) = sv_2mortal(newSVpvn(buf, buflen));
3685 ST(0) = sv_2mortal(newSVpvn(tmpbuf, len));
3697 PUSHs(sv_2mortal(newSVpvn(tzname[0],strlen(tzname[0]))));
3698 PUSHs(sv_2mortal(newSVpvn(tzname[1],strlen(tzname[1]))));
3701 access(filename, mode)
3719 pathconf(filename, name)