5 #define PERL_NO_GET_CONTEXT
8 #define PERLIO_NOT_STDIO 1
11 #if defined(PERL_OBJECT) || defined(PERL_CAPI)
15 # define open PerlLIO_open3
18 #ifdef I_DIRENT /* XXX maybe better to just rely on perl.h? */
41 /* XXX This comment is just to make I_TERMIO and I_SGTTY visible to
42 metaconfig for future extension writers. We don't use them in POSIX.
43 (This is really sneaky :-) --AD
45 #if defined(I_TERMIOS)
53 #include <sys/types.h>
60 #if defined(__VMS) && !defined(__POSIX_SOURCE)
61 # include <libdef.h> /* LIB$_INVARG constant */
62 # include <lib$routines.h> /* prototype for lib$ediv() */
63 # include <starlet.h> /* prototype for sys$gettim() */
64 # if DECC_VERSION < 50000000
65 # define pid_t int /* old versions of DECC miss this in types.h */
69 # define mkfifo(a,b) (not_here("mkfifo"),-1)
70 # define tzset() not_here("tzset")
72 #if ((__VMS_VER >= 70000000) && (__DECC_VER >= 50200000)) || (__CRTL_VER >= 70000000)
73 # define HAS_TZNAME /* shows up in VMS 7.0 or Dec C 5.6 */
75 # endif /* __VMS_VER >= 70000000 or Dec C 5.6 */
77 /* The POSIX notion of ttyname() is better served by getname() under VMS */
78 static char ttnambuf[64];
79 # define ttyname(fd) (isatty(fd) > 0 ? getname(fd,ttnambuf,0) : NULL)
81 /* The non-POSIX CRTL times() has void return type, so we just get the
82 current time directly */
83 clock_t vms_times(struct tms *PL_bufptr) {
86 /* Get wall time and convert to 10 ms intervals to
87 * produce the return value that the POSIX standard expects */
88 # if defined(__DECC) && defined (__ALPHA)
91 _ckvmssts(sys$gettim(&vmstime));
93 retval = vmstime & 0x7fffffff;
95 /* (Older hw or ccs don't have an atomic 64-bit type, so we
96 * juggle 32-bit ints (and a float) to produce a time_t result
97 * with minimal loss of information.) */
98 long int vmstime[2],remainder,divisor = 100000;
99 _ckvmssts(sys$gettim((unsigned long int *)vmstime));
100 vmstime[1] &= 0x7fff; /* prevent overflow in EDIV */
101 _ckvmssts(lib$ediv(&divisor,vmstime,(long int *)&retval,&remainder));
103 /* Fill in the struct tms using the CRTL routine . . .*/
104 times((tbuffer_t *)PL_bufptr);
105 return (clock_t) retval;
107 # define times(t) vms_times(t)
110 # define tzname _tzname
111 # undef MB_CUR_MAX /* XXX: bug in b20.1 */
115 # define mkfifo(a,b) not_here("mkfifo")
116 # define ttyname(a) (char*)not_here("ttyname")
117 # define sigset_t long
120 # define tzname _tzname
123 # define mode_t short
126 # define mode_t short
128 # define tzset() not_here("tzset")
130 # ifndef _POSIX_OPEN_MAX
131 # define _POSIX_OPEN_MAX FOPEN_MAX /* XXX bogus ? */
134 # define sigaction(a,b,c) not_here("sigaction")
135 # define sigpending(a) not_here("sigpending")
136 # define sigprocmask(a,b,c) not_here("sigprocmask")
137 # define sigsuspend(a) not_here("sigsuspend")
138 # define sigemptyset(a) not_here("sigemptyset")
139 # define sigaddset(a,b) not_here("sigaddset")
140 # define sigdelset(a,b) not_here("sigdelset")
141 # define sigfillset(a) not_here("sigfillset")
142 # define sigismember(a,b) not_here("sigismember")
147 # define mkfifo(a,b) not_here("mkfifo")
148 # else /* !( defined OS2 ) */
150 # define mkfifo(path, mode) (mknod((path), (mode) | S_IFIFO, 0))
153 # endif /* !HAS_MKFIFO */
156 # include <sys/times.h>
158 # include <sys/utsname.h>
160 # include <sys/wait.h>
168 typedef long SysRetLong;
169 typedef sigset_t* POSIX__SigSet;
170 typedef HV* POSIX__SigAction;
172 typedef struct termios* POSIX__Termios;
173 #else /* Define termios types to int, and call not_here for the functions.*/
174 #define POSIX__Termios int
178 #define cfgetispeed(x) not_here("cfgetispeed")
179 #define cfgetospeed(x) not_here("cfgetospeed")
180 #define tcdrain(x) not_here("tcdrain")
181 #define tcflush(x,y) not_here("tcflush")
182 #define tcsendbreak(x,y) not_here("tcsendbreak")
183 #define cfsetispeed(x,y) not_here("cfsetispeed")
184 #define cfsetospeed(x,y) not_here("cfsetospeed")
185 #define ctermid(x) (char *) not_here("ctermid")
186 #define tcflow(x,y) not_here("tcflow")
187 #define tcgetattr(x,y) not_here("tcgetattr")
188 #define tcsetattr(x,y,z) not_here("tcsetattr")
191 /* Possibly needed prototypes */
192 char *cuserid (char *);
193 double strtod (const char *, char **);
194 long strtol (const char *, char **, int);
195 unsigned long strtoul (const char *, char **, int);
198 #define cuserid(a) (char *) not_here("cuserid")
202 #define difftime(a,b) not_here("difftime")
205 #ifndef HAS_FPATHCONF
206 #define fpathconf(f,n) (SysRetLong) not_here("fpathconf")
209 #define mktime(a) not_here("mktime")
212 #define nice(a) not_here("nice")
215 #define pathconf(f,n) (SysRetLong) not_here("pathconf")
218 #define sysconf(n) (SysRetLong) not_here("sysconf")
221 #define readlink(a,b,c) not_here("readlink")
224 #define setpgid(a,b) not_here("setpgid")
227 #define setsid() not_here("setsid")
230 #define strcoll(s1,s2) not_here("strcoll")
233 #define strtod(s1,s2) not_here("strtod")
236 #define strtol(s1,s2,b) not_here("strtol")
239 #define strtoul(s1,s2,b) not_here("strtoul")
242 #define strxfrm(s1,s2,n) not_here("strxfrm")
244 #ifndef HAS_TCGETPGRP
245 #define tcgetpgrp(a) not_here("tcgetpgrp")
247 #ifndef HAS_TCSETPGRP
248 #define tcsetpgrp(a,b) not_here("tcsetpgrp")
251 #define times(a) not_here("times")
254 #define uname(a) not_here("uname")
257 #define waitpid(a,b,c) not_here("waitpid")
262 #define mblen(a,b) not_here("mblen")
266 #define mbstowcs(s, pwcs, n) not_here("mbstowcs")
269 #define mbtowc(pwc, s, n) not_here("mbtowc")
272 #define wcstombs(s, pwcs, n) not_here("wcstombs")
275 #define wctomb(s, wchar) not_here("wcstombs")
277 #if !defined(HAS_MBLEN) && !defined(HAS_MBSTOWCS) && !defined(HAS_MBTOWC) && !defined(HAS_WCSTOMBS) && !defined(HAS_WCTOMB)
278 /* If we don't have these functions, then we wouldn't have gotten a typedef
279 for wchar_t, the wide character type. Defining wchar_t allows the
280 functions referencing it to compile. Its actual type is then meaningless,
281 since without the above functions, all sections using it end up calling
282 not_here() and croak. --Kaveh Ghazi (ghazi@noc.rutgers.edu) 9/18/94. */
288 #ifndef HAS_LOCALECONV
289 #define localeconv() not_here("localeconv")
294 extern char *tzname[];
297 #if !defined(WIN32) || (defined(__MINGW32__) && !defined(tzname))
298 char *tzname[] = { "" , "" };
302 /* XXX struct tm on some systems (SunOS4/BSD) contains extra (non POSIX)
303 * fields for which we don't have Configure support yet:
304 * char *tm_zone; -- abbreviation of timezone name
305 * long tm_gmtoff; -- offset from GMT in seconds
306 * To workaround core dumps from the uninitialised tm_zone we get the
307 * system to give us a reasonable struct to copy. This fix means that
308 * strftime uses the tm_zone and tm_gmtoff values returned by
309 * localtime(time()). That should give the desired result most of the
310 * time. But probably not always!
312 * This is a temporary workaround to be removed once Configure
313 * support is added and NETaa14816 is considered in full.
314 * It does not address tzname aspects of NETaa14816.
317 # ifndef STRUCT_TM_HASZONE
318 # define STRUCT_TM_HASZONE
322 #ifdef STRUCT_TM_HASZONE
324 init_tm(struct tm *ptm) /* see mktime, strftime and asctime */
328 Copy(localtime(&now), ptm, 1, struct tm);
332 # define init_tm(ptm)
336 #ifdef HAS_LONG_DOUBLE
337 # if LONG_DOUBLESIZE > DOUBLESIZE
338 # undef HAS_LONG_DOUBLE /* XXX until we figure out how to use them */
342 #ifndef HAS_LONG_DOUBLE
357 croak("POSIX::%s not implemented on this architecture", s);
362 #if defined(HAS_LONG_DOUBLE) && (LONG_DOUBLESIZE > DOUBLESIZE)
367 constant(char *name, int arg)
372 if (strEQ(name, "ARG_MAX"))
380 if (strEQ(name, "BUFSIZ"))
386 if (strEQ(name, "BRKINT"))
392 if (strEQ(name, "B9600"))
398 if (strEQ(name, "B19200"))
404 if (strEQ(name, "B38400"))
410 if (strEQ(name, "B0"))
416 if (strEQ(name, "B110"))
422 if (strEQ(name, "B1200"))
428 if (strEQ(name, "B134"))
434 if (strEQ(name, "B150"))
440 if (strEQ(name, "B1800"))
446 if (strEQ(name, "B200"))
452 if (strEQ(name, "B2400"))
458 if (strEQ(name, "B300"))
464 if (strEQ(name, "B4800"))
470 if (strEQ(name, "B50"))
476 if (strEQ(name, "B600"))
482 if (strEQ(name, "B75"))
490 if (strEQ(name, "CHAR_BIT"))
496 if (strEQ(name, "CHAR_MAX"))
502 if (strEQ(name, "CHAR_MIN"))
508 if (strEQ(name, "CHILD_MAX"))
514 if (strEQ(name, "CLK_TCK"))
520 if (strEQ(name, "CLOCAL"))
526 if (strEQ(name, "CLOCKS_PER_SEC"))
527 #ifdef CLOCKS_PER_SEC
528 return CLOCKS_PER_SEC;
532 if (strEQ(name, "CREAD"))
538 if (strEQ(name, "CS5"))
544 if (strEQ(name, "CS6"))
550 if (strEQ(name, "CS7"))
556 if (strEQ(name, "CS8"))
562 if (strEQ(name, "CSIZE"))
568 if (strEQ(name, "CSTOPB"))
576 if (strEQ(name, "DBL_MAX"))
582 if (strEQ(name, "DBL_MIN"))
588 if (strEQ(name, "DBL_DIG"))
594 if (strEQ(name, "DBL_EPSILON"))
600 if (strEQ(name, "DBL_MANT_DIG"))
606 if (strEQ(name, "DBL_MAX_10_EXP"))
607 #ifdef DBL_MAX_10_EXP
608 return DBL_MAX_10_EXP;
612 if (strEQ(name, "DBL_MAX_EXP"))
618 if (strEQ(name, "DBL_MIN_10_EXP"))
619 #ifdef DBL_MIN_10_EXP
620 return DBL_MIN_10_EXP;
624 if (strEQ(name, "DBL_MIN_EXP"))
634 if (strEQ(name, "EACCES"))
640 if (strEQ(name, "EADDRINUSE"))
646 if (strEQ(name, "EADDRNOTAVAIL"))
648 return EADDRNOTAVAIL;
652 if (strEQ(name, "EAFNOSUPPORT"))
658 if (strEQ(name, "EAGAIN"))
664 if (strEQ(name, "EALREADY"))
672 if (strEQ(name, "EBADF"))
678 if (strEQ(name, "EBUSY"))
686 if (strEQ(name, "ECHILD"))
692 if (strEQ(name, "ECHO"))
698 if (strEQ(name, "ECHOE"))
704 if (strEQ(name, "ECHOK"))
710 if (strEQ(name, "ECHONL"))
716 if (strEQ(name, "ECONNABORTED"))
722 if (strEQ(name, "ECONNREFUSED"))
728 if (strEQ(name, "ECONNRESET"))
736 if (strEQ(name, "EDEADLK"))
742 if (strEQ(name, "EDESTADDRREQ"))
748 if (strEQ(name, "EDOM"))
754 if (strEQ(name, "EDQUOT"))
762 if (strEQ(name, "EEXIST"))
770 if (strEQ(name, "EFAULT"))
776 if (strEQ(name, "EFBIG"))
784 if (strEQ(name, "EHOSTDOWN"))
790 if (strEQ(name, "EHOSTUNREACH"))
798 if (strEQ(name, "EINPROGRESS"))
804 if (strEQ(name, "EINTR"))
810 if (strEQ(name, "EINVAL"))
816 if (strEQ(name, "EIO"))
822 if (strEQ(name, "EISCONN"))
828 if (strEQ(name, "EISDIR"))
836 if (strEQ(name, "ELOOP"))
844 if (strEQ(name, "EMFILE"))
850 if (strEQ(name, "EMLINK"))
856 if (strEQ(name, "EMSGSIZE"))
864 if (strEQ(name, "ENETDOWN"))
870 if (strEQ(name, "ENETRESET"))
876 if (strEQ(name, "ENETUNREACH"))
882 if (strEQ(name, "ENOBUFS"))
888 if (strEQ(name, "ENOEXEC"))
894 if (strEQ(name, "ENOMEM"))
900 if (strEQ(name, "ENOPROTOOPT"))
906 if (strEQ(name, "ENOSPC"))
912 if (strEQ(name, "ENOTBLK"))
918 if (strEQ(name, "ENOTCONN"))
924 if (strEQ(name, "ENOTDIR"))
930 if (strEQ(name, "ENOTEMPTY"))
936 if (strEQ(name, "ENOTSOCK"))
942 if (strEQ(name, "ENOTTY"))
948 if (strEQ(name, "ENFILE"))
954 if (strEQ(name, "ENODEV"))
960 if (strEQ(name, "ENOENT"))
966 if (strEQ(name, "ENOLCK"))
972 if (strEQ(name, "ENOSYS"))
978 if (strEQ(name, "ENXIO"))
984 if (strEQ(name, "ENAMETOOLONG"))
992 if (strEQ(name, "EOF"))
998 if (strEQ(name, "EOPNOTSUPP"))
1006 if (strEQ(name, "EPERM"))
1012 if (strEQ(name, "EPFNOSUPPORT"))
1014 return EPFNOSUPPORT;
1018 if (strEQ(name, "EPIPE"))
1024 if (strEQ(name, "EPROCLIM"))
1030 if (strEQ(name, "EPROTONOSUPPORT"))
1031 #ifdef EPROTONOSUPPORT
1032 return EPROTONOSUPPORT;
1036 if (strEQ(name, "EPROTOTYPE"))
1044 if (strEQ(name, "ERANGE"))
1050 if (strEQ(name, "EREMOTE"))
1056 if (strEQ(name, "ERESTART"))
1062 if (strEQ(name, "EROFS"))
1070 if (strEQ(name, "ESHUTDOWN"))
1076 if (strEQ(name, "ESOCKTNOSUPPORT"))
1077 #ifdef ESOCKTNOSUPPORT
1078 return ESOCKTNOSUPPORT;
1082 if (strEQ(name, "ESPIPE"))
1088 if (strEQ(name, "ESRCH"))
1094 if (strEQ(name, "ESTALE"))
1102 if (strEQ(name, "ETIMEDOUT"))
1108 if (strEQ(name, "ETOOMANYREFS"))
1110 return ETOOMANYREFS;
1114 if (strEQ(name, "ETXTBSY"))
1122 if (strEQ(name, "EUSERS"))
1130 if (strEQ(name, "EWOULDBLOCK"))
1138 if (strEQ(name, "EXIT_FAILURE"))
1140 return EXIT_FAILURE;
1144 if (strEQ(name, "EXIT_SUCCESS"))
1146 return EXIT_SUCCESS;
1150 if (strEQ(name, "EXDEV"))
1158 if (strEQ(name, "E2BIG"))
1166 if (strnEQ(name, "FLT_", 4)) {
1167 if (strEQ(name, "FLT_MAX"))
1173 if (strEQ(name, "FLT_MIN"))
1179 if (strEQ(name, "FLT_ROUNDS"))
1185 if (strEQ(name, "FLT_DIG"))
1191 if (strEQ(name, "FLT_EPSILON"))
1197 if (strEQ(name, "FLT_MANT_DIG"))
1199 return FLT_MANT_DIG;
1203 if (strEQ(name, "FLT_MAX_10_EXP"))
1204 #ifdef FLT_MAX_10_EXP
1205 return FLT_MAX_10_EXP;
1209 if (strEQ(name, "FLT_MAX_EXP"))
1215 if (strEQ(name, "FLT_MIN_10_EXP"))
1216 #ifdef FLT_MIN_10_EXP
1217 return FLT_MIN_10_EXP;
1221 if (strEQ(name, "FLT_MIN_EXP"))
1227 if (strEQ(name, "FLT_RADIX"))
1235 if (strnEQ(name, "F_", 2)) {
1236 if (strEQ(name, "F_DUPFD"))
1242 if (strEQ(name, "F_GETFD"))
1248 if (strEQ(name, "F_GETFL"))
1254 if (strEQ(name, "F_GETLK"))
1260 if (strEQ(name, "F_OK"))
1266 if (strEQ(name, "F_RDLCK"))
1272 if (strEQ(name, "F_SETFD"))
1278 if (strEQ(name, "F_SETFL"))
1284 if (strEQ(name, "F_SETLK"))
1290 if (strEQ(name, "F_SETLKW"))
1296 if (strEQ(name, "F_UNLCK"))
1302 if (strEQ(name, "F_WRLCK"))
1310 if (strEQ(name, "FD_CLOEXEC"))
1316 if (strEQ(name, "FILENAME_MAX"))
1318 return FILENAME_MAX;
1324 if (strEQ(name, "HUGE_VAL"))
1330 if (strEQ(name, "HUPCL"))
1338 if (strEQ(name, "INT_MAX"))
1344 if (strEQ(name, "INT_MIN"))
1350 if (strEQ(name, "ICANON"))
1356 if (strEQ(name, "ICRNL"))
1362 if (strEQ(name, "IEXTEN"))
1368 if (strEQ(name, "IGNBRK"))
1374 if (strEQ(name, "IGNCR"))
1380 if (strEQ(name, "IGNPAR"))
1386 if (strEQ(name, "INLCR"))
1392 if (strEQ(name, "INPCK"))
1398 if (strEQ(name, "ISIG"))
1404 if (strEQ(name, "ISTRIP"))
1410 if (strEQ(name, "IXOFF"))
1416 if (strEQ(name, "IXON"))
1424 if (strnEQ(name, "LC_", 3)) {
1425 if (strEQ(name, "LC_ALL"))
1431 if (strEQ(name, "LC_COLLATE"))
1437 if (strEQ(name, "LC_CTYPE"))
1443 if (strEQ(name, "LC_MONETARY"))
1449 if (strEQ(name, "LC_NUMERIC"))
1455 if (strEQ(name, "LC_TIME"))
1463 if (strnEQ(name, "LDBL_", 5)) {
1464 if (strEQ(name, "LDBL_MAX"))
1470 if (strEQ(name, "LDBL_MIN"))
1476 if (strEQ(name, "LDBL_DIG"))
1482 if (strEQ(name, "LDBL_EPSILON"))
1484 return LDBL_EPSILON;
1488 if (strEQ(name, "LDBL_MANT_DIG"))
1489 #ifdef LDBL_MANT_DIG
1490 return LDBL_MANT_DIG;
1494 if (strEQ(name, "LDBL_MAX_10_EXP"))
1495 #ifdef LDBL_MAX_10_EXP
1496 return LDBL_MAX_10_EXP;
1500 if (strEQ(name, "LDBL_MAX_EXP"))
1502 return LDBL_MAX_EXP;
1506 if (strEQ(name, "LDBL_MIN_10_EXP"))
1507 #ifdef LDBL_MIN_10_EXP
1508 return LDBL_MIN_10_EXP;
1512 if (strEQ(name, "LDBL_MIN_EXP"))
1514 return LDBL_MIN_EXP;
1520 if (strnEQ(name, "L_", 2)) {
1521 if (strEQ(name, "L_ctermid"))
1527 if (strEQ(name, "L_cuserid"))
1533 /* L_tmpnam[e] was a typo--retained for compatibility */
1534 if (strEQ(name, "L_tmpname") || strEQ(name, "L_tmpnam"))
1542 if (strEQ(name, "LONG_MAX"))
1548 if (strEQ(name, "LONG_MIN"))
1554 if (strEQ(name, "LINK_MAX"))
1562 if (strEQ(name, "MAX_CANON"))
1568 if (strEQ(name, "MAX_INPUT"))
1574 if (strEQ(name, "MB_CUR_MAX"))
1580 if (strEQ(name, "MB_LEN_MAX"))
1588 if (strEQ(name, "NULL")) return 0;
1589 if (strEQ(name, "NAME_MAX"))
1595 if (strEQ(name, "NCCS"))
1601 if (strEQ(name, "NGROUPS_MAX"))
1607 if (strEQ(name, "NOFLSH"))
1615 if (strnEQ(name, "O_", 2)) {
1616 if (strEQ(name, "O_APPEND"))
1622 if (strEQ(name, "O_CREAT"))
1628 if (strEQ(name, "O_TRUNC"))
1634 if (strEQ(name, "O_RDONLY"))
1640 if (strEQ(name, "O_RDWR"))
1646 if (strEQ(name, "O_WRONLY"))
1652 if (strEQ(name, "O_EXCL"))
1658 if (strEQ(name, "O_NOCTTY"))
1664 if (strEQ(name, "O_NONBLOCK"))
1670 if (strEQ(name, "O_ACCMODE"))
1678 if (strEQ(name, "OPEN_MAX"))
1684 if (strEQ(name, "OPOST"))
1692 if (strEQ(name, "PATH_MAX"))
1698 if (strEQ(name, "PARENB"))
1704 if (strEQ(name, "PARMRK"))
1710 if (strEQ(name, "PARODD"))
1716 if (strEQ(name, "PIPE_BUF"))
1724 if (strEQ(name, "RAND_MAX"))
1730 if (strEQ(name, "R_OK"))
1738 if (strnEQ(name, "SIG", 3)) {
1739 if (name[3] == '_') {
1740 if (strEQ(name, "SIG_BLOCK"))
1747 if (strEQ(name, "SIG_DFL")) return (IV)SIG_DFL;
1750 if (strEQ(name, "SIG_ERR")) return (IV)SIG_ERR;
1753 if (strEQ(name, "SIG_IGN")) return (IV)SIG_IGN;
1755 if (strEQ(name, "SIG_SETMASK"))
1761 if (strEQ(name, "SIG_UNBLOCK"))
1769 if (strEQ(name, "SIGABRT"))
1775 if (strEQ(name, "SIGALRM"))
1781 if (strEQ(name, "SIGCHLD"))
1787 if (strEQ(name, "SIGCONT"))
1793 if (strEQ(name, "SIGFPE"))
1799 if (strEQ(name, "SIGHUP"))
1805 if (strEQ(name, "SIGILL"))
1811 if (strEQ(name, "SIGINT"))
1817 if (strEQ(name, "SIGKILL"))
1823 if (strEQ(name, "SIGPIPE"))
1829 if (strEQ(name, "SIGQUIT"))
1835 if (strEQ(name, "SIGSEGV"))
1841 if (strEQ(name, "SIGSTOP"))
1847 if (strEQ(name, "SIGTERM"))
1853 if (strEQ(name, "SIGTSTP"))
1859 if (strEQ(name, "SIGTTIN"))
1865 if (strEQ(name, "SIGTTOU"))
1871 if (strEQ(name, "SIGUSR1"))
1877 if (strEQ(name, "SIGUSR2"))
1885 if (name[1] == '_') {
1886 if (strEQ(name, "S_ISGID"))
1892 if (strEQ(name, "S_ISUID"))
1898 if (strEQ(name, "S_IRGRP"))
1904 if (strEQ(name, "S_IROTH"))
1910 if (strEQ(name, "S_IRUSR"))
1916 if (strEQ(name, "S_IRWXG"))
1922 if (strEQ(name, "S_IRWXO"))
1928 if (strEQ(name, "S_IRWXU"))
1934 if (strEQ(name, "S_IWGRP"))
1940 if (strEQ(name, "S_IWOTH"))
1946 if (strEQ(name, "S_IWUSR"))
1952 if (strEQ(name, "S_IXGRP"))
1958 if (strEQ(name, "S_IXOTH"))
1964 if (strEQ(name, "S_IXUSR"))
1970 errno = EAGAIN; /* the following aren't constants */
1972 if (strEQ(name, "S_ISBLK")) return S_ISBLK(arg);
1975 if (strEQ(name, "S_ISCHR")) return S_ISCHR(arg);
1978 if (strEQ(name, "S_ISDIR")) return S_ISDIR(arg);
1981 if (strEQ(name, "S_ISFIFO")) return S_ISFIFO(arg);
1984 if (strEQ(name, "S_ISREG")) return S_ISREG(arg);
1988 if (strEQ(name, "SEEK_CUR"))
1994 if (strEQ(name, "SEEK_END"))
2000 if (strEQ(name, "SEEK_SET"))
2006 if (strEQ(name, "STREAM_MAX"))
2012 if (strEQ(name, "SHRT_MAX"))
2018 if (strEQ(name, "SHRT_MIN"))
2024 if (strnEQ(name, "SA_", 3)) {
2025 if (strEQ(name, "SA_NOCLDSTOP"))
2027 return SA_NOCLDSTOP;
2031 if (strEQ(name, "SA_NOCLDWAIT"))
2033 return SA_NOCLDWAIT;
2037 if (strEQ(name, "SA_NODEFER"))
2043 if (strEQ(name, "SA_ONSTACK"))
2049 if (strEQ(name, "SA_RESETHAND"))
2051 return SA_RESETHAND;
2055 if (strEQ(name, "SA_RESTART"))
2061 if (strEQ(name, "SA_SIGINFO"))
2069 if (strEQ(name, "SCHAR_MAX"))
2075 if (strEQ(name, "SCHAR_MIN"))
2081 if (strEQ(name, "SSIZE_MAX"))
2087 if (strEQ(name, "STDIN_FILENO"))
2089 return STDIN_FILENO;
2093 if (strEQ(name, "STDOUT_FILENO"))
2094 #ifdef STDOUT_FILENO
2095 return STDOUT_FILENO;
2099 if (strEQ(name, "STRERR_FILENO"))
2100 #ifdef STRERR_FILENO
2101 return STRERR_FILENO;
2107 if (strEQ(name, "TCIFLUSH"))
2113 if (strEQ(name, "TCIOFF"))
2119 if (strEQ(name, "TCIOFLUSH"))
2125 if (strEQ(name, "TCION"))
2131 if (strEQ(name, "TCOFLUSH"))
2137 if (strEQ(name, "TCOOFF"))
2143 if (strEQ(name, "TCOON"))
2149 if (strEQ(name, "TCSADRAIN"))
2155 if (strEQ(name, "TCSAFLUSH"))
2161 if (strEQ(name, "TCSANOW"))
2167 if (strEQ(name, "TMP_MAX"))
2173 if (strEQ(name, "TOSTOP"))
2179 if (strEQ(name, "TZNAME_MAX"))
2187 if (strEQ(name, "UCHAR_MAX"))
2193 if (strEQ(name, "UINT_MAX"))
2199 if (strEQ(name, "ULONG_MAX"))
2205 if (strEQ(name, "USHRT_MAX"))
2213 if (strEQ(name, "VEOF"))
2219 if (strEQ(name, "VEOL"))
2225 if (strEQ(name, "VERASE"))
2231 if (strEQ(name, "VINTR"))
2237 if (strEQ(name, "VKILL"))
2243 if (strEQ(name, "VMIN"))
2249 if (strEQ(name, "VQUIT"))
2255 if (strEQ(name, "VSTART"))
2261 if (strEQ(name, "VSTOP"))
2267 if (strEQ(name, "VSUSP"))
2273 if (strEQ(name, "VTIME"))
2281 if (strEQ(name, "W_OK"))
2287 if (strEQ(name, "WNOHANG"))
2293 if (strEQ(name, "WUNTRACED"))
2299 errno = EAGAIN; /* the following aren't constants */
2301 if (strEQ(name, "WEXITSTATUS")) return WEXITSTATUS(arg);
2304 if (strEQ(name, "WIFEXITED")) return WIFEXITED(arg);
2307 if (strEQ(name, "WIFSIGNALED")) return WIFSIGNALED(arg);
2310 if (strEQ(name, "WIFSTOPPED")) return WIFSTOPPED(arg);
2313 if (strEQ(name, "WSTOPSIG")) return WSTOPSIG(arg);
2316 if (strEQ(name, "WTERMSIG")) return WTERMSIG(arg);
2320 if (strEQ(name, "X_OK"))
2328 if (strnEQ(name, "_PC_", 4)) {
2329 if (strEQ(name, "_PC_CHOWN_RESTRICTED"))
2330 #if defined(_PC_CHOWN_RESTRICTED) || HINT_SC_EXIST
2331 return _PC_CHOWN_RESTRICTED;
2335 if (strEQ(name, "_PC_LINK_MAX"))
2336 #if defined(_PC_LINK_MAX) || HINT_SC_EXIST
2337 return _PC_LINK_MAX;
2341 if (strEQ(name, "_PC_MAX_CANON"))
2342 #if defined(_PC_MAX_CANON) || HINT_SC_EXIST
2343 return _PC_MAX_CANON;
2347 if (strEQ(name, "_PC_MAX_INPUT"))
2348 #if defined(_PC_MAX_INPUT) || HINT_SC_EXIST
2349 return _PC_MAX_INPUT;
2353 if (strEQ(name, "_PC_NAME_MAX"))
2354 #if defined(_PC_NAME_MAX) || HINT_SC_EXIST
2355 return _PC_NAME_MAX;
2359 if (strEQ(name, "_PC_NO_TRUNC"))
2360 #if defined(_PC_NO_TRUNC) || HINT_SC_EXIST
2361 return _PC_NO_TRUNC;
2365 if (strEQ(name, "_PC_PATH_MAX"))
2366 #if defined(_PC_PATH_MAX) || HINT_SC_EXIST
2367 return _PC_PATH_MAX;
2371 if (strEQ(name, "_PC_PIPE_BUF"))
2372 #if defined(_PC_PIPE_BUF) || HINT_SC_EXIST
2373 return _PC_PIPE_BUF;
2377 if (strEQ(name, "_PC_VDISABLE"))
2378 #if defined(_PC_VDISABLE) || HINT_SC_EXIST
2379 return _PC_VDISABLE;
2385 if (strnEQ(name, "_POSIX_", 7)) {
2386 if (strEQ(name, "_POSIX_ARG_MAX"))
2387 #ifdef _POSIX_ARG_MAX
2388 return _POSIX_ARG_MAX;
2392 if (strEQ(name, "_POSIX_CHILD_MAX"))
2393 #ifdef _POSIX_CHILD_MAX
2394 return _POSIX_CHILD_MAX;
2398 if (strEQ(name, "_POSIX_CHOWN_RESTRICTED"))
2399 #ifdef _POSIX_CHOWN_RESTRICTED
2400 return _POSIX_CHOWN_RESTRICTED;
2404 if (strEQ(name, "_POSIX_JOB_CONTROL"))
2405 #ifdef _POSIX_JOB_CONTROL
2406 return _POSIX_JOB_CONTROL;
2410 if (strEQ(name, "_POSIX_LINK_MAX"))
2411 #ifdef _POSIX_LINK_MAX
2412 return _POSIX_LINK_MAX;
2416 if (strEQ(name, "_POSIX_MAX_CANON"))
2417 #ifdef _POSIX_MAX_CANON
2418 return _POSIX_MAX_CANON;
2422 if (strEQ(name, "_POSIX_MAX_INPUT"))
2423 #ifdef _POSIX_MAX_INPUT
2424 return _POSIX_MAX_INPUT;
2428 if (strEQ(name, "_POSIX_NAME_MAX"))
2429 #ifdef _POSIX_NAME_MAX
2430 return _POSIX_NAME_MAX;
2434 if (strEQ(name, "_POSIX_NGROUPS_MAX"))
2435 #ifdef _POSIX_NGROUPS_MAX
2436 return _POSIX_NGROUPS_MAX;
2440 if (strEQ(name, "_POSIX_NO_TRUNC"))
2441 #ifdef _POSIX_NO_TRUNC
2442 return _POSIX_NO_TRUNC;
2446 if (strEQ(name, "_POSIX_OPEN_MAX"))
2447 #ifdef _POSIX_OPEN_MAX
2448 return _POSIX_OPEN_MAX;
2452 if (strEQ(name, "_POSIX_PATH_MAX"))
2453 #ifdef _POSIX_PATH_MAX
2454 return _POSIX_PATH_MAX;
2458 if (strEQ(name, "_POSIX_PIPE_BUF"))
2459 #ifdef _POSIX_PIPE_BUF
2460 return _POSIX_PIPE_BUF;
2464 if (strEQ(name, "_POSIX_SAVED_IDS"))
2465 #ifdef _POSIX_SAVED_IDS
2466 return _POSIX_SAVED_IDS;
2470 if (strEQ(name, "_POSIX_SSIZE_MAX"))
2471 #ifdef _POSIX_SSIZE_MAX
2472 return _POSIX_SSIZE_MAX;
2476 if (strEQ(name, "_POSIX_STREAM_MAX"))
2477 #ifdef _POSIX_STREAM_MAX
2478 return _POSIX_STREAM_MAX;
2482 if (strEQ(name, "_POSIX_TZNAME_MAX"))
2483 #ifdef _POSIX_TZNAME_MAX
2484 return _POSIX_TZNAME_MAX;
2488 if (strEQ(name, "_POSIX_VDISABLE"))
2489 #ifdef _POSIX_VDISABLE
2490 return _POSIX_VDISABLE;
2494 if (strEQ(name, "_POSIX_VERSION"))
2495 #ifdef _POSIX_VERSION
2496 return _POSIX_VERSION;
2502 if (strnEQ(name, "_SC_", 4)) {
2503 if (strEQ(name, "_SC_ARG_MAX"))
2504 #if defined(_SC_ARG_MAX) || HINT_SC_EXIST
2509 if (strEQ(name, "_SC_CHILD_MAX"))
2510 #if defined(_SC_CHILD_MAX) || HINT_SC_EXIST
2511 return _SC_CHILD_MAX;
2515 if (strEQ(name, "_SC_CLK_TCK"))
2516 #if defined(_SC_CLK_TCK) || HINT_SC_EXIST
2521 if (strEQ(name, "_SC_JOB_CONTROL"))
2522 #if defined(_SC_JOB_CONTROL) || HINT_SC_EXIST
2523 return _SC_JOB_CONTROL;
2527 if (strEQ(name, "_SC_NGROUPS_MAX"))
2528 #if defined(_SC_NGROUPS_MAX) || HINT_SC_EXIST
2529 return _SC_NGROUPS_MAX;
2533 if (strEQ(name, "_SC_OPEN_MAX"))
2534 #if defined(_SC_OPEN_MAX) || HINT_SC_EXIST
2535 return _SC_OPEN_MAX;
2539 if (strEQ(name, "_SC_SAVED_IDS"))
2540 #if defined(_SC_SAVED_IDS) || HINT_SC_EXIST
2541 return _SC_SAVED_IDS;
2545 if (strEQ(name, "_SC_STREAM_MAX"))
2546 #if defined(_SC_STREAM_MAX) || HINT_SC_EXIST
2547 return _SC_STREAM_MAX;
2551 if (strEQ(name, "_SC_TZNAME_MAX"))
2552 #if defined(_SC_TZNAME_MAX) || HINT_SC_EXIST
2553 return _SC_TZNAME_MAX;
2557 if (strEQ(name, "_SC_VERSION"))
2558 #if defined(_SC_VERSION) || HINT_SC_EXIST
2574 MODULE = SigSet PACKAGE = POSIX::SigSet PREFIX = sig
2577 new(packname = "POSIX::SigSet", ...)
2582 New(0, RETVAL, 1, sigset_t);
2583 sigemptyset(RETVAL);
2584 for (i = 1; i < items; i++)
2585 sigaddset(RETVAL, SvIV(ST(i)));
2592 POSIX::SigSet sigset
2597 sigaddset(sigset, sig)
2598 POSIX::SigSet sigset
2602 sigdelset(sigset, sig)
2603 POSIX::SigSet sigset
2608 POSIX::SigSet sigset
2612 POSIX::SigSet sigset
2615 sigismember(sigset, sig)
2616 POSIX::SigSet sigset
2620 MODULE = Termios PACKAGE = POSIX::Termios PREFIX = cf
2623 new(packname = "POSIX::Termios", ...)
2628 New(0, RETVAL, 1, struct termios);
2630 not_here("termios");
2638 DESTROY(termios_ref)
2639 POSIX::Termios termios_ref
2642 Safefree(termios_ref);
2644 not_here("termios");
2648 getattr(termios_ref, fd = 0)
2649 POSIX::Termios termios_ref
2652 RETVAL = tcgetattr(fd, termios_ref);
2657 setattr(termios_ref, fd = 0, optional_actions = 0)
2658 POSIX::Termios termios_ref
2660 int optional_actions
2662 RETVAL = tcsetattr(fd, optional_actions, termios_ref);
2667 cfgetispeed(termios_ref)
2668 POSIX::Termios termios_ref
2671 cfgetospeed(termios_ref)
2672 POSIX::Termios termios_ref
2675 getiflag(termios_ref)
2676 POSIX::Termios termios_ref
2678 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2679 RETVAL = termios_ref->c_iflag;
2681 not_here("getiflag");
2688 getoflag(termios_ref)
2689 POSIX::Termios termios_ref
2691 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2692 RETVAL = termios_ref->c_oflag;
2694 not_here("getoflag");
2701 getcflag(termios_ref)
2702 POSIX::Termios termios_ref
2704 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2705 RETVAL = termios_ref->c_cflag;
2707 not_here("getcflag");
2714 getlflag(termios_ref)
2715 POSIX::Termios termios_ref
2717 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2718 RETVAL = termios_ref->c_lflag;
2720 not_here("getlflag");
2727 getcc(termios_ref, ccix)
2728 POSIX::Termios termios_ref
2731 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2733 croak("Bad getcc subscript");
2734 RETVAL = termios_ref->c_cc[ccix];
2743 cfsetispeed(termios_ref, speed)
2744 POSIX::Termios termios_ref
2748 cfsetospeed(termios_ref, speed)
2749 POSIX::Termios termios_ref
2753 setiflag(termios_ref, iflag)
2754 POSIX::Termios termios_ref
2757 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2758 termios_ref->c_iflag = iflag;
2760 not_here("setiflag");
2764 setoflag(termios_ref, oflag)
2765 POSIX::Termios termios_ref
2768 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2769 termios_ref->c_oflag = oflag;
2771 not_here("setoflag");
2775 setcflag(termios_ref, cflag)
2776 POSIX::Termios termios_ref
2779 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2780 termios_ref->c_cflag = cflag;
2782 not_here("setcflag");
2786 setlflag(termios_ref, lflag)
2787 POSIX::Termios termios_ref
2790 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2791 termios_ref->c_lflag = lflag;
2793 not_here("setlflag");
2797 setcc(termios_ref, ccix, cc)
2798 POSIX::Termios termios_ref
2802 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2804 croak("Bad setcc subscript");
2805 termios_ref->c_cc[ccix] = cc;
2811 MODULE = POSIX PACKAGE = POSIX
2820 unsigned char * charstring
2822 unsigned char *s = charstring;
2823 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2824 for (RETVAL = 1; RETVAL && s < e; s++)
2832 unsigned char * charstring
2834 unsigned char *s = charstring;
2835 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2836 for (RETVAL = 1; RETVAL && s < e; s++)
2844 unsigned char * charstring
2846 unsigned char *s = charstring;
2847 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2848 for (RETVAL = 1; RETVAL && s < e; s++)
2856 unsigned char * charstring
2858 unsigned char *s = charstring;
2859 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2860 for (RETVAL = 1; RETVAL && s < e; s++)
2868 unsigned char * charstring
2870 unsigned char *s = charstring;
2871 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2872 for (RETVAL = 1; RETVAL && s < e; s++)
2880 unsigned char * charstring
2882 unsigned char *s = charstring;
2883 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2884 for (RETVAL = 1; RETVAL && s < e; s++)
2892 unsigned char * charstring
2894 unsigned char *s = charstring;
2895 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2896 for (RETVAL = 1; RETVAL && s < e; s++)
2904 unsigned char * charstring
2906 unsigned char *s = charstring;
2907 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2908 for (RETVAL = 1; RETVAL && s < e; s++)
2916 unsigned char * charstring
2918 unsigned char *s = charstring;
2919 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2920 for (RETVAL = 1; RETVAL && s < e; s++)
2928 unsigned char * charstring
2930 unsigned char *s = charstring;
2931 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2932 for (RETVAL = 1; RETVAL && s < e; s++)
2939 isxdigit(charstring)
2940 unsigned char * charstring
2942 unsigned char *s = charstring;
2943 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2944 for (RETVAL = 1; RETVAL && s < e; s++)
2951 open(filename, flags = O_RDONLY, mode = 0666)
2956 if (flags & (O_APPEND|O_CREAT|O_TRUNC|O_RDWR|O_WRONLY|O_EXCL))
2957 TAINT_PROPER("open");
2958 RETVAL = open(filename, flags, mode);
2966 #ifdef HAS_LOCALECONV
2967 struct lconv *lcbuf;
2969 if (lcbuf = localeconv()) {
2971 if (lcbuf->decimal_point && *lcbuf->decimal_point)
2972 hv_store(RETVAL, "decimal_point", 13,
2973 newSVpv(lcbuf->decimal_point, 0), 0);
2974 if (lcbuf->thousands_sep && *lcbuf->thousands_sep)
2975 hv_store(RETVAL, "thousands_sep", 13,
2976 newSVpv(lcbuf->thousands_sep, 0), 0);
2977 #ifndef NO_LOCALECONV_GROUPING
2978 if (lcbuf->grouping && *lcbuf->grouping)
2979 hv_store(RETVAL, "grouping", 8,
2980 newSVpv(lcbuf->grouping, 0), 0);
2982 if (lcbuf->int_curr_symbol && *lcbuf->int_curr_symbol)
2983 hv_store(RETVAL, "int_curr_symbol", 15,
2984 newSVpv(lcbuf->int_curr_symbol, 0), 0);
2985 if (lcbuf->currency_symbol && *lcbuf->currency_symbol)
2986 hv_store(RETVAL, "currency_symbol", 15,
2987 newSVpv(lcbuf->currency_symbol, 0), 0);
2988 if (lcbuf->mon_decimal_point && *lcbuf->mon_decimal_point)
2989 hv_store(RETVAL, "mon_decimal_point", 17,
2990 newSVpv(lcbuf->mon_decimal_point, 0), 0);
2991 #ifndef NO_LOCALECONV_MON_THOUSANDS_SEP
2992 if (lcbuf->mon_thousands_sep && *lcbuf->mon_thousands_sep)
2993 hv_store(RETVAL, "mon_thousands_sep", 17,
2994 newSVpv(lcbuf->mon_thousands_sep, 0), 0);
2996 #ifndef NO_LOCALECONV_MON_GROUPING
2997 if (lcbuf->mon_grouping && *lcbuf->mon_grouping)
2998 hv_store(RETVAL, "mon_grouping", 12,
2999 newSVpv(lcbuf->mon_grouping, 0), 0);
3001 if (lcbuf->positive_sign && *lcbuf->positive_sign)
3002 hv_store(RETVAL, "positive_sign", 13,
3003 newSVpv(lcbuf->positive_sign, 0), 0);
3004 if (lcbuf->negative_sign && *lcbuf->negative_sign)
3005 hv_store(RETVAL, "negative_sign", 13,
3006 newSVpv(lcbuf->negative_sign, 0), 0);
3008 if (lcbuf->int_frac_digits != CHAR_MAX)
3009 hv_store(RETVAL, "int_frac_digits", 15,
3010 newSViv(lcbuf->int_frac_digits), 0);
3011 if (lcbuf->frac_digits != CHAR_MAX)
3012 hv_store(RETVAL, "frac_digits", 11,
3013 newSViv(lcbuf->frac_digits), 0);
3014 if (lcbuf->p_cs_precedes != CHAR_MAX)
3015 hv_store(RETVAL, "p_cs_precedes", 13,
3016 newSViv(lcbuf->p_cs_precedes), 0);
3017 if (lcbuf->p_sep_by_space != CHAR_MAX)
3018 hv_store(RETVAL, "p_sep_by_space", 14,
3019 newSViv(lcbuf->p_sep_by_space), 0);
3020 if (lcbuf->n_cs_precedes != CHAR_MAX)
3021 hv_store(RETVAL, "n_cs_precedes", 13,
3022 newSViv(lcbuf->n_cs_precedes), 0);
3023 if (lcbuf->n_sep_by_space != CHAR_MAX)
3024 hv_store(RETVAL, "n_sep_by_space", 14,
3025 newSViv(lcbuf->n_sep_by_space), 0);
3026 if (lcbuf->p_sign_posn != CHAR_MAX)
3027 hv_store(RETVAL, "p_sign_posn", 11,
3028 newSViv(lcbuf->p_sign_posn), 0);
3029 if (lcbuf->n_sign_posn != CHAR_MAX)
3030 hv_store(RETVAL, "n_sign_posn", 11,
3031 newSViv(lcbuf->n_sign_posn), 0);
3034 localeconv(); /* A stub to call not_here(). */
3040 setlocale(category, locale = 0)
3044 RETVAL = setlocale(category, locale);
3046 #ifdef USE_LOCALE_CTYPE
3047 if (category == LC_CTYPE
3049 || category == LC_ALL
3055 if (category == LC_ALL)
3056 newctype = setlocale(LC_CTYPE, NULL);
3060 new_ctype(newctype);
3062 #endif /* USE_LOCALE_CTYPE */
3063 #ifdef USE_LOCALE_COLLATE
3064 if (category == LC_COLLATE
3066 || category == LC_ALL
3072 if (category == LC_ALL)
3073 newcoll = setlocale(LC_COLLATE, NULL);
3077 new_collate(newcoll);
3079 #endif /* USE_LOCALE_COLLATE */
3080 #ifdef USE_LOCALE_NUMERIC
3081 if (category == LC_NUMERIC
3083 || category == LC_ALL
3089 if (category == LC_ALL)
3090 newnum = setlocale(LC_NUMERIC, NULL);
3094 new_numeric(newnum);
3096 #endif /* USE_LOCALE_NUMERIC */
3136 /* (We already know stack is long enough.) */
3137 PUSHs(sv_2mortal(newSVnv(frexp(x,&expvar))));
3138 PUSHs(sv_2mortal(newSViv(expvar)));
3154 /* (We already know stack is long enough.) */
3155 PUSHs(sv_2mortal(newSVnv(modf(x,&intvar))));
3156 PUSHs(sv_2mortal(newSVnv(intvar)));
3171 sigaction(sig, action, oldaction = 0)
3173 POSIX::SigAction action
3174 POSIX::SigAction oldaction
3177 RETVAL = not_here("sigaction");
3179 # This code is really grody because we're trying to make the signal
3180 # interface look beautiful, which is hard.
3183 gv_fetchpv("SIG", TRUE, SVt_PVHV);
3186 struct sigaction act;
3187 struct sigaction oact;
3188 POSIX__SigSet sigset;
3190 SV** sigsvp = hv_fetch(GvHVn(PL_siggv),
3192 strlen(PL_sig_name[sig]),
3196 /* Remember old handler name if desired. */
3198 char *hand = SvPVx(*sigsvp, n_a);
3199 svp = hv_fetch(oldaction, "HANDLER", 7, TRUE);
3200 sv_setpv(*svp, *hand ? hand : "DEFAULT");
3204 /* Vector new handler through %SIG. (We always use sighandler
3205 for the C signal handler, which reads %SIG to dispatch.) */
3206 svp = hv_fetch(action, "HANDLER", 7, FALSE);
3208 croak("Can't supply an action without a HANDLER");
3209 sv_setpv(*sigsvp, SvPV(*svp, n_a));
3210 mg_set(*sigsvp); /* handles DEFAULT and IGNORE */
3211 act.sa_handler = PL_sighandlerp;
3213 /* Set up any desired mask. */
3214 svp = hv_fetch(action, "MASK", 4, FALSE);
3215 if (svp && sv_isa(*svp, "POSIX::SigSet")) {
3217 tmp = (unsigned long)SvNV((SV*)SvRV(*svp));
3218 sigset = (sigset_t*) tmp;
3219 act.sa_mask = *sigset;
3222 sigemptyset(& act.sa_mask);
3224 /* Set up any desired flags. */
3225 svp = hv_fetch(action, "FLAGS", 5, FALSE);
3226 act.sa_flags = svp ? SvIV(*svp) : 0;
3229 /* Now work around sigaction oddities */
3230 if (action && oldaction)
3231 RETVAL = sigaction(sig, & act, & oact);
3233 RETVAL = sigaction(sig, & act, (struct sigaction *)0);
3235 RETVAL = sigaction(sig, (struct sigaction *)0, & oact);
3240 /* Get back the mask. */
3241 svp = hv_fetch(oldaction, "MASK", 4, TRUE);
3242 if (sv_isa(*svp, "POSIX::SigSet")) {
3244 tmp = (unsigned long)SvNV((SV*)SvRV(*svp));
3245 sigset = (sigset_t*) tmp;
3248 New(0, sigset, 1, sigset_t);
3249 sv_setptrobj(*svp, sigset, "POSIX::SigSet");
3251 *sigset = oact.sa_mask;
3253 /* Get back the flags. */
3254 svp = hv_fetch(oldaction, "FLAGS", 5, TRUE);
3255 sv_setiv(*svp, oact.sa_flags);
3264 POSIX::SigSet sigset
3267 sigprocmask(how, sigset, oldsigset = 0)
3269 POSIX::SigSet sigset
3270 POSIX::SigSet oldsigset = NO_INIT
3275 else if (sv_derived_from(ST(2), "POSIX::SigSet")) {
3276 IV tmp = SvIV((SV*)SvRV(ST(2)));
3277 oldsigset = INT2PTR(POSIX__SigSet,tmp);
3280 New(0, oldsigset, 1, sigset_t);
3281 sigemptyset(oldsigset);
3282 sv_setref_pv(ST(2), "POSIX::SigSet", (void*)oldsigset);
3286 sigsuspend(signal_mask)
3287 POSIX::SigSet signal_mask
3307 lseek(fd, offset, whence)
3320 if (pipe(fds) != -1) {
3322 PUSHs(sv_2mortal(newSViv(fds[0])));
3323 PUSHs(sv_2mortal(newSViv(fds[1])));
3327 read(fd, buffer, nbytes)
3329 SV *sv_buffer = SvROK(ST(1)) ? SvRV(ST(1)) : ST(1);
3333 char * buffer = sv_grow( sv_buffer, nbytes+1 );
3336 SvCUR(sv_buffer) = RETVAL;
3337 SvPOK_only(sv_buffer);
3338 *SvEND(sv_buffer) = '\0';
3339 SvTAINTED_on(sv_buffer);
3355 tcsetpgrp(fd, pgrp_id)
3364 if (uname(&buf) >= 0) {
3366 PUSHs(sv_2mortal(newSVpv(buf.sysname, 0)));
3367 PUSHs(sv_2mortal(newSVpv(buf.nodename, 0)));
3368 PUSHs(sv_2mortal(newSVpv(buf.release, 0)));
3369 PUSHs(sv_2mortal(newSVpv(buf.version, 0)));
3370 PUSHs(sv_2mortal(newSVpv(buf.machine, 0)));
3373 uname((char *) 0); /* A stub to call not_here(). */
3377 write(fd, buffer, nbytes)
3388 RETVAL = newSVpvn("", 0);
3389 SvGROW(RETVAL, L_tmpnam);
3390 len = strlen(tmpnam(SvPV(RETVAL, i)));
3391 SvCUR_set(RETVAL, len);
3404 mbstowcs(s, pwcs, n)
3416 wcstombs(s, pwcs, n)
3438 SET_NUMERIC_LOCAL();
3439 num = strtod(str, &unparsed);
3440 PUSHs(sv_2mortal(newSVnv(num)));
3441 if (GIMME == G_ARRAY) {
3444 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3446 PUSHs(&PL_sv_undef);
3450 strtol(str, base = 0)
3457 num = strtol(str, &unparsed, base);
3458 #if IVSIZE <= LONGSIZE
3459 if (num < IV_MIN || num > IV_MAX)
3460 PUSHs(sv_2mortal(newSVnv((double)num)));
3463 PUSHs(sv_2mortal(newSViv((IV)num)));
3464 if (GIMME == G_ARRAY) {
3467 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3469 PUSHs(&PL_sv_undef);
3473 strtoul(str, base = 0)
3480 num = strtoul(str, &unparsed, base);
3482 PUSHs(sv_2mortal(newSViv((IV)num)));
3484 PUSHs(sv_2mortal(newSVnv((double)num)));
3485 if (GIMME == G_ARRAY) {
3488 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3490 PUSHs(&PL_sv_undef);
3500 char *p = SvPV(src,srclen);
3502 ST(0) = sv_2mortal(NEWSV(800,srclen));
3503 dstlen = strxfrm(SvPVX(ST(0)), p, (size_t)srclen);
3504 if (dstlen > srclen) {
3506 SvGROW(ST(0), dstlen);
3507 strxfrm(SvPVX(ST(0)), p, (size_t)dstlen);
3510 SvCUR(ST(0)) = dstlen;
3515 mkfifo(filename, mode)
3519 TAINT_PROPER("mkfifo");
3520 RETVAL = mkfifo(filename, mode);
3536 tcflush(fd, queue_selector)
3541 tcsendbreak(fd, duration)
3546 asctime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3559 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3562 mytm.tm_hour = hour;
3563 mytm.tm_mday = mday;
3565 mytm.tm_year = year;
3566 mytm.tm_wday = wday;
3567 mytm.tm_yday = yday;
3568 mytm.tm_isdst = isdst;
3569 RETVAL = asctime(&mytm);
3586 realtime = times( &tms );
3588 PUSHs( sv_2mortal( newSViv( (IV) realtime ) ) );
3589 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_utime ) ) );
3590 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_stime ) ) );
3591 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cutime ) ) );
3592 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cstime ) ) );
3595 difftime(time1, time2)
3600 mktime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3613 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3616 mytm.tm_hour = hour;
3617 mytm.tm_mday = mday;
3619 mytm.tm_year = year;
3620 mytm.tm_wday = wday;
3621 mytm.tm_yday = yday;
3622 mytm.tm_isdst = isdst;
3623 RETVAL = mktime(&mytm);
3629 strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1)
3645 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3648 mytm.tm_hour = hour;
3649 mytm.tm_mday = mday;
3651 mytm.tm_year = year;
3652 mytm.tm_wday = wday;
3653 mytm.tm_yday = yday;
3654 mytm.tm_isdst = isdst;
3655 (void) mktime(&mytm);
3656 len = strftime(tmpbuf, sizeof tmpbuf, fmt, &mytm);
3658 ** The following is needed to handle to the situation where
3659 ** tmpbuf overflows. Basically we want to allocate a buffer
3660 ** and try repeatedly. The reason why it is so complicated
3661 ** is that getting a return value of 0 from strftime can indicate
3662 ** one of the following:
3663 ** 1. buffer overflowed,
3664 ** 2. illegal conversion specifier, or
3665 ** 3. the format string specifies nothing to be returned(not
3666 ** an error). This could be because format is an empty string
3667 ** or it specifies %p that yields an empty string in some locale.
3668 ** If there is a better way to make it portable, go ahead by
3671 if ( ( len > 0 && len < sizeof(tmpbuf) )
3672 || ( len == 0 && strlen(fmt) == 0 ) ) {
3673 ST(0) = sv_2mortal(newSVpv(tmpbuf, len));
3675 /* Possibly buf overflowed - try again with a bigger buf */
3676 int bufsize = strlen(fmt) + sizeof(tmpbuf);
3680 New(0, buf, bufsize, char);
3682 buflen = strftime(buf, bufsize, fmt, &mytm);
3683 if ( buflen > 0 && buflen < bufsize ) break;
3685 Renew(buf, bufsize, char);
3688 ST(0) = sv_2mortal(newSVpvn(buf, buflen));
3691 ST(0) = sv_2mortal(newSVpvn(tmpbuf, len));
3703 PUSHs(sv_2mortal(newSVpvn(tzname[0],strlen(tzname[0]))));
3704 PUSHs(sv_2mortal(newSVpvn(tzname[1],strlen(tzname[1]))));
3707 access(filename, mode)
3725 pathconf(filename, name)