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) {
85 /* Get wall time and convert to 10 ms intervals to
86 * produce the return value that the POSIX standard expects */
87 # if defined(__DECC) && defined (__ALPHA)
90 _ckvmssts(sys$gettim(&vmstime));
92 retval = vmstime & 0x7fffffff;
94 /* (Older hw or ccs don't have an atomic 64-bit type, so we
95 * juggle 32-bit ints (and a float) to produce a time_t result
96 * with minimal loss of information.) */
97 long int vmstime[2],remainder,divisor = 100000;
98 _ckvmssts(sys$gettim((unsigned long int *)vmstime));
99 vmstime[1] &= 0x7fff; /* prevent overflow in EDIV */
100 _ckvmssts(lib$ediv(&divisor,vmstime,(long int *)&retval,&remainder));
102 /* Fill in the struct tms using the CRTL routine . . .*/
103 times((tbuffer_t *)PL_bufptr);
104 return (clock_t) retval;
106 # define times(t) vms_times(t)
109 # define tzname _tzname
110 # undef MB_CUR_MAX /* XXX: bug in b20.1 */
114 # define mkfifo(a,b) not_here("mkfifo")
115 # define ttyname(a) (char*)not_here("ttyname")
116 # define sigset_t long
119 # define tzname _tzname
122 # define mode_t short
125 # define mode_t short
127 # define tzset() not_here("tzset")
129 # ifndef _POSIX_OPEN_MAX
130 # define _POSIX_OPEN_MAX FOPEN_MAX /* XXX bogus ? */
133 # define sigaction(a,b,c) not_here("sigaction")
134 # define sigpending(a) not_here("sigpending")
135 # define sigprocmask(a,b,c) not_here("sigprocmask")
136 # define sigsuspend(a) not_here("sigsuspend")
137 # define sigemptyset(a) not_here("sigemptyset")
138 # define sigaddset(a,b) not_here("sigaddset")
139 # define sigdelset(a,b) not_here("sigdelset")
140 # define sigfillset(a) not_here("sigfillset")
141 # define sigismember(a,b) not_here("sigismember")
146 # define mkfifo(a,b) not_here("mkfifo")
147 # else /* !( defined OS2 ) */
149 # define mkfifo(path, mode) (mknod((path), (mode) | S_IFIFO, 0))
152 # endif /* !HAS_MKFIFO */
155 # include <sys/times.h>
157 # include <sys/utsname.h>
159 # include <sys/wait.h>
167 typedef long SysRetLong;
168 typedef sigset_t* POSIX__SigSet;
169 typedef HV* POSIX__SigAction;
171 typedef struct termios* POSIX__Termios;
172 #else /* Define termios types to int, and call not_here for the functions.*/
173 #define POSIX__Termios int
177 #define cfgetispeed(x) not_here("cfgetispeed")
178 #define cfgetospeed(x) not_here("cfgetospeed")
179 #define tcdrain(x) not_here("tcdrain")
180 #define tcflush(x,y) not_here("tcflush")
181 #define tcsendbreak(x,y) not_here("tcsendbreak")
182 #define cfsetispeed(x,y) not_here("cfsetispeed")
183 #define cfsetospeed(x,y) not_here("cfsetospeed")
184 #define ctermid(x) (char *) not_here("ctermid")
185 #define tcflow(x,y) not_here("tcflow")
186 #define tcgetattr(x,y) not_here("tcgetattr")
187 #define tcsetattr(x,y,z) not_here("tcsetattr")
190 /* Possibly needed prototypes */
191 char *cuserid (char *);
192 double strtod (const char *, char **);
193 long strtol (const char *, char **, int);
194 unsigned long strtoul (const char *, char **, int);
197 #define cuserid(a) (char *) not_here("cuserid")
201 #define difftime(a,b) not_here("difftime")
204 #ifndef HAS_FPATHCONF
205 #define fpathconf(f,n) (SysRetLong) not_here("fpathconf")
208 #define mktime(a) not_here("mktime")
211 #define nice(a) not_here("nice")
214 #define pathconf(f,n) (SysRetLong) not_here("pathconf")
217 #define sysconf(n) (SysRetLong) not_here("sysconf")
220 #define readlink(a,b,c) not_here("readlink")
223 #define setpgid(a,b) not_here("setpgid")
226 #define setsid() not_here("setsid")
229 #define strcoll(s1,s2) not_here("strcoll")
232 #define strtod(s1,s2) not_here("strtod")
235 #define strtol(s1,s2,b) not_here("strtol")
238 #define strtoul(s1,s2,b) not_here("strtoul")
241 #define strxfrm(s1,s2,n) not_here("strxfrm")
243 #ifndef HAS_TCGETPGRP
244 #define tcgetpgrp(a) not_here("tcgetpgrp")
246 #ifndef HAS_TCSETPGRP
247 #define tcsetpgrp(a,b) not_here("tcsetpgrp")
250 #define times(a) not_here("times")
253 #define uname(a) not_here("uname")
256 #define waitpid(a,b,c) not_here("waitpid")
261 #define mblen(a,b) not_here("mblen")
265 #define mbstowcs(s, pwcs, n) not_here("mbstowcs")
268 #define mbtowc(pwc, s, n) not_here("mbtowc")
271 #define wcstombs(s, pwcs, n) not_here("wcstombs")
274 #define wctomb(s, wchar) not_here("wcstombs")
276 #if !defined(HAS_MBLEN) && !defined(HAS_MBSTOWCS) && !defined(HAS_MBTOWC) && !defined(HAS_WCSTOMBS) && !defined(HAS_WCTOMB)
277 /* If we don't have these functions, then we wouldn't have gotten a typedef
278 for wchar_t, the wide character type. Defining wchar_t allows the
279 functions referencing it to compile. Its actual type is then meaningless,
280 since without the above functions, all sections using it end up calling
281 not_here() and croak. --Kaveh Ghazi (ghazi@noc.rutgers.edu) 9/18/94. */
287 #ifndef HAS_LOCALECONV
288 #define localeconv() not_here("localeconv")
293 extern char *tzname[];
296 #if !defined(WIN32) || (defined(__MINGW32__) && !defined(tzname))
297 char *tzname[] = { "" , "" };
301 /* XXX struct tm on some systems (SunOS4/BSD) contains extra (non POSIX)
302 * fields for which we don't have Configure support yet:
303 * char *tm_zone; -- abbreviation of timezone name
304 * long tm_gmtoff; -- offset from GMT in seconds
305 * To workaround core dumps from the uninitialised tm_zone we get the
306 * system to give us a reasonable struct to copy. This fix means that
307 * strftime uses the tm_zone and tm_gmtoff values returned by
308 * localtime(time()). That should give the desired result most of the
309 * time. But probably not always!
311 * This is a temporary workaround to be removed once Configure
312 * support is added and NETaa14816 is considered in full.
313 * It does not address tzname aspects of NETaa14816.
316 # ifndef STRUCT_TM_HASZONE
317 # define STRUCT_TM_HASZONE
321 #ifdef STRUCT_TM_HASZONE
323 init_tm(struct tm *ptm) /* see mktime, strftime and asctime */
327 Copy(localtime(&now), ptm, 1, struct tm);
331 # define init_tm(ptm)
335 #ifdef HAS_LONG_DOUBLE
336 # if LONG_DOUBLESIZE > DOUBLESIZE
337 # undef HAS_LONG_DOUBLE /* XXX until we figure out how to use them */
341 #ifndef HAS_LONG_DOUBLE
356 croak("POSIX::%s not implemented on this architecture", s);
361 #if defined(HAS_LONG_DOUBLE) && (LONG_DOUBLESIZE > DOUBLESIZE)
366 constant(char *name, int arg)
371 if (strEQ(name, "ARG_MAX"))
379 if (strEQ(name, "BUFSIZ"))
385 if (strEQ(name, "BRKINT"))
391 if (strEQ(name, "B9600"))
397 if (strEQ(name, "B19200"))
403 if (strEQ(name, "B38400"))
409 if (strEQ(name, "B0"))
415 if (strEQ(name, "B110"))
421 if (strEQ(name, "B1200"))
427 if (strEQ(name, "B134"))
433 if (strEQ(name, "B150"))
439 if (strEQ(name, "B1800"))
445 if (strEQ(name, "B200"))
451 if (strEQ(name, "B2400"))
457 if (strEQ(name, "B300"))
463 if (strEQ(name, "B4800"))
469 if (strEQ(name, "B50"))
475 if (strEQ(name, "B600"))
481 if (strEQ(name, "B75"))
489 if (strEQ(name, "CHAR_BIT"))
495 if (strEQ(name, "CHAR_MAX"))
501 if (strEQ(name, "CHAR_MIN"))
507 if (strEQ(name, "CHILD_MAX"))
513 if (strEQ(name, "CLK_TCK"))
519 if (strEQ(name, "CLOCAL"))
525 if (strEQ(name, "CLOCKS_PER_SEC"))
526 #ifdef CLOCKS_PER_SEC
527 return CLOCKS_PER_SEC;
531 if (strEQ(name, "CREAD"))
537 if (strEQ(name, "CS5"))
543 if (strEQ(name, "CS6"))
549 if (strEQ(name, "CS7"))
555 if (strEQ(name, "CS8"))
561 if (strEQ(name, "CSIZE"))
567 if (strEQ(name, "CSTOPB"))
575 if (strEQ(name, "DBL_MAX"))
581 if (strEQ(name, "DBL_MIN"))
587 if (strEQ(name, "DBL_DIG"))
593 if (strEQ(name, "DBL_EPSILON"))
599 if (strEQ(name, "DBL_MANT_DIG"))
605 if (strEQ(name, "DBL_MAX_10_EXP"))
606 #ifdef DBL_MAX_10_EXP
607 return DBL_MAX_10_EXP;
611 if (strEQ(name, "DBL_MAX_EXP"))
617 if (strEQ(name, "DBL_MIN_10_EXP"))
618 #ifdef DBL_MIN_10_EXP
619 return DBL_MIN_10_EXP;
623 if (strEQ(name, "DBL_MIN_EXP"))
633 if (strEQ(name, "EACCES"))
639 if (strEQ(name, "EADDRINUSE"))
645 if (strEQ(name, "EADDRNOTAVAIL"))
647 return EADDRNOTAVAIL;
651 if (strEQ(name, "EAFNOSUPPORT"))
657 if (strEQ(name, "EAGAIN"))
663 if (strEQ(name, "EALREADY"))
671 if (strEQ(name, "EBADF"))
677 if (strEQ(name, "EBUSY"))
685 if (strEQ(name, "ECHILD"))
691 if (strEQ(name, "ECHO"))
697 if (strEQ(name, "ECHOE"))
703 if (strEQ(name, "ECHOK"))
709 if (strEQ(name, "ECHONL"))
715 if (strEQ(name, "ECONNABORTED"))
721 if (strEQ(name, "ECONNREFUSED"))
727 if (strEQ(name, "ECONNRESET"))
735 if (strEQ(name, "EDEADLK"))
741 if (strEQ(name, "EDESTADDRREQ"))
747 if (strEQ(name, "EDOM"))
753 if (strEQ(name, "EDQUOT"))
761 if (strEQ(name, "EEXIST"))
769 if (strEQ(name, "EFAULT"))
775 if (strEQ(name, "EFBIG"))
783 if (strEQ(name, "EHOSTDOWN"))
789 if (strEQ(name, "EHOSTUNREACH"))
797 if (strEQ(name, "EINPROGRESS"))
803 if (strEQ(name, "EINTR"))
809 if (strEQ(name, "EINVAL"))
815 if (strEQ(name, "EIO"))
821 if (strEQ(name, "EISCONN"))
827 if (strEQ(name, "EISDIR"))
835 if (strEQ(name, "ELOOP"))
843 if (strEQ(name, "EMFILE"))
849 if (strEQ(name, "EMLINK"))
855 if (strEQ(name, "EMSGSIZE"))
863 if (strEQ(name, "ENETDOWN"))
869 if (strEQ(name, "ENETRESET"))
875 if (strEQ(name, "ENETUNREACH"))
881 if (strEQ(name, "ENOBUFS"))
887 if (strEQ(name, "ENOEXEC"))
893 if (strEQ(name, "ENOMEM"))
899 if (strEQ(name, "ENOPROTOOPT"))
905 if (strEQ(name, "ENOSPC"))
911 if (strEQ(name, "ENOTBLK"))
917 if (strEQ(name, "ENOTCONN"))
923 if (strEQ(name, "ENOTDIR"))
929 if (strEQ(name, "ENOTEMPTY"))
935 if (strEQ(name, "ENOTSOCK"))
941 if (strEQ(name, "ENOTTY"))
947 if (strEQ(name, "ENFILE"))
953 if (strEQ(name, "ENODEV"))
959 if (strEQ(name, "ENOENT"))
965 if (strEQ(name, "ENOLCK"))
971 if (strEQ(name, "ENOSYS"))
977 if (strEQ(name, "ENXIO"))
983 if (strEQ(name, "ENAMETOOLONG"))
991 if (strEQ(name, "EOF"))
997 if (strEQ(name, "EOPNOTSUPP"))
1005 if (strEQ(name, "EPERM"))
1011 if (strEQ(name, "EPFNOSUPPORT"))
1013 return EPFNOSUPPORT;
1017 if (strEQ(name, "EPIPE"))
1023 if (strEQ(name, "EPROCLIM"))
1029 if (strEQ(name, "EPROTONOSUPPORT"))
1030 #ifdef EPROTONOSUPPORT
1031 return EPROTONOSUPPORT;
1035 if (strEQ(name, "EPROTOTYPE"))
1043 if (strEQ(name, "ERANGE"))
1049 if (strEQ(name, "EREMOTE"))
1055 if (strEQ(name, "ERESTART"))
1061 if (strEQ(name, "EROFS"))
1069 if (strEQ(name, "ESHUTDOWN"))
1075 if (strEQ(name, "ESOCKTNOSUPPORT"))
1076 #ifdef ESOCKTNOSUPPORT
1077 return ESOCKTNOSUPPORT;
1081 if (strEQ(name, "ESPIPE"))
1087 if (strEQ(name, "ESRCH"))
1093 if (strEQ(name, "ESTALE"))
1101 if (strEQ(name, "ETIMEDOUT"))
1107 if (strEQ(name, "ETOOMANYREFS"))
1109 return ETOOMANYREFS;
1113 if (strEQ(name, "ETXTBSY"))
1121 if (strEQ(name, "EUSERS"))
1129 if (strEQ(name, "EWOULDBLOCK"))
1137 if (strEQ(name, "EXIT_FAILURE"))
1139 return EXIT_FAILURE;
1143 if (strEQ(name, "EXIT_SUCCESS"))
1145 return EXIT_SUCCESS;
1149 if (strEQ(name, "EXDEV"))
1157 if (strEQ(name, "E2BIG"))
1165 if (strnEQ(name, "FLT_", 4)) {
1166 if (strEQ(name, "FLT_MAX"))
1172 if (strEQ(name, "FLT_MIN"))
1178 if (strEQ(name, "FLT_ROUNDS"))
1184 if (strEQ(name, "FLT_DIG"))
1190 if (strEQ(name, "FLT_EPSILON"))
1196 if (strEQ(name, "FLT_MANT_DIG"))
1198 return FLT_MANT_DIG;
1202 if (strEQ(name, "FLT_MAX_10_EXP"))
1203 #ifdef FLT_MAX_10_EXP
1204 return FLT_MAX_10_EXP;
1208 if (strEQ(name, "FLT_MAX_EXP"))
1214 if (strEQ(name, "FLT_MIN_10_EXP"))
1215 #ifdef FLT_MIN_10_EXP
1216 return FLT_MIN_10_EXP;
1220 if (strEQ(name, "FLT_MIN_EXP"))
1226 if (strEQ(name, "FLT_RADIX"))
1234 if (strnEQ(name, "F_", 2)) {
1235 if (strEQ(name, "F_DUPFD"))
1241 if (strEQ(name, "F_GETFD"))
1247 if (strEQ(name, "F_GETFL"))
1253 if (strEQ(name, "F_GETLK"))
1259 if (strEQ(name, "F_OK"))
1265 if (strEQ(name, "F_RDLCK"))
1271 if (strEQ(name, "F_SETFD"))
1277 if (strEQ(name, "F_SETFL"))
1283 if (strEQ(name, "F_SETLK"))
1289 if (strEQ(name, "F_SETLKW"))
1295 if (strEQ(name, "F_UNLCK"))
1301 if (strEQ(name, "F_WRLCK"))
1309 if (strEQ(name, "FD_CLOEXEC"))
1315 if (strEQ(name, "FILENAME_MAX"))
1317 return FILENAME_MAX;
1323 if (strEQ(name, "HUGE_VAL"))
1329 if (strEQ(name, "HUPCL"))
1337 if (strEQ(name, "INT_MAX"))
1343 if (strEQ(name, "INT_MIN"))
1349 if (strEQ(name, "ICANON"))
1355 if (strEQ(name, "ICRNL"))
1361 if (strEQ(name, "IEXTEN"))
1367 if (strEQ(name, "IGNBRK"))
1373 if (strEQ(name, "IGNCR"))
1379 if (strEQ(name, "IGNPAR"))
1385 if (strEQ(name, "INLCR"))
1391 if (strEQ(name, "INPCK"))
1397 if (strEQ(name, "ISIG"))
1403 if (strEQ(name, "ISTRIP"))
1409 if (strEQ(name, "IXOFF"))
1415 if (strEQ(name, "IXON"))
1423 if (strnEQ(name, "LC_", 3)) {
1424 if (strEQ(name, "LC_ALL"))
1430 if (strEQ(name, "LC_COLLATE"))
1436 if (strEQ(name, "LC_CTYPE"))
1442 if (strEQ(name, "LC_MONETARY"))
1448 if (strEQ(name, "LC_NUMERIC"))
1454 if (strEQ(name, "LC_TIME"))
1462 if (strnEQ(name, "LDBL_", 5)) {
1463 if (strEQ(name, "LDBL_MAX"))
1469 if (strEQ(name, "LDBL_MIN"))
1475 if (strEQ(name, "LDBL_DIG"))
1481 if (strEQ(name, "LDBL_EPSILON"))
1483 return LDBL_EPSILON;
1487 if (strEQ(name, "LDBL_MANT_DIG"))
1488 #ifdef LDBL_MANT_DIG
1489 return LDBL_MANT_DIG;
1493 if (strEQ(name, "LDBL_MAX_10_EXP"))
1494 #ifdef LDBL_MAX_10_EXP
1495 return LDBL_MAX_10_EXP;
1499 if (strEQ(name, "LDBL_MAX_EXP"))
1501 return LDBL_MAX_EXP;
1505 if (strEQ(name, "LDBL_MIN_10_EXP"))
1506 #ifdef LDBL_MIN_10_EXP
1507 return LDBL_MIN_10_EXP;
1511 if (strEQ(name, "LDBL_MIN_EXP"))
1513 return LDBL_MIN_EXP;
1519 if (strnEQ(name, "L_", 2)) {
1520 if (strEQ(name, "L_ctermid"))
1526 if (strEQ(name, "L_cuserid"))
1532 /* L_tmpnam[e] was a typo--retained for compatibility */
1533 if (strEQ(name, "L_tmpname") || strEQ(name, "L_tmpnam"))
1541 if (strEQ(name, "LONG_MAX"))
1547 if (strEQ(name, "LONG_MIN"))
1553 if (strEQ(name, "LINK_MAX"))
1561 if (strEQ(name, "MAX_CANON"))
1567 if (strEQ(name, "MAX_INPUT"))
1573 if (strEQ(name, "MB_CUR_MAX"))
1579 if (strEQ(name, "MB_LEN_MAX"))
1587 if (strEQ(name, "NULL")) return 0;
1588 if (strEQ(name, "NAME_MAX"))
1594 if (strEQ(name, "NCCS"))
1600 if (strEQ(name, "NGROUPS_MAX"))
1606 if (strEQ(name, "NOFLSH"))
1614 if (strnEQ(name, "O_", 2)) {
1615 if (strEQ(name, "O_APPEND"))
1621 if (strEQ(name, "O_CREAT"))
1627 if (strEQ(name, "O_TRUNC"))
1633 if (strEQ(name, "O_RDONLY"))
1639 if (strEQ(name, "O_RDWR"))
1645 if (strEQ(name, "O_WRONLY"))
1651 if (strEQ(name, "O_EXCL"))
1657 if (strEQ(name, "O_NOCTTY"))
1663 if (strEQ(name, "O_NONBLOCK"))
1669 if (strEQ(name, "O_ACCMODE"))
1677 if (strEQ(name, "OPEN_MAX"))
1683 if (strEQ(name, "OPOST"))
1691 if (strEQ(name, "PATH_MAX"))
1697 if (strEQ(name, "PARENB"))
1703 if (strEQ(name, "PARMRK"))
1709 if (strEQ(name, "PARODD"))
1715 if (strEQ(name, "PIPE_BUF"))
1723 if (strEQ(name, "RAND_MAX"))
1729 if (strEQ(name, "R_OK"))
1737 if (strnEQ(name, "SIG", 3)) {
1738 if (name[3] == '_') {
1739 if (strEQ(name, "SIG_BLOCK"))
1746 if (strEQ(name, "SIG_DFL")) return (IV)SIG_DFL;
1749 if (strEQ(name, "SIG_ERR")) return (IV)SIG_ERR;
1752 if (strEQ(name, "SIG_IGN")) return (IV)SIG_IGN;
1754 if (strEQ(name, "SIG_SETMASK"))
1760 if (strEQ(name, "SIG_UNBLOCK"))
1768 if (strEQ(name, "SIGABRT"))
1774 if (strEQ(name, "SIGALRM"))
1780 if (strEQ(name, "SIGCHLD"))
1786 if (strEQ(name, "SIGCONT"))
1792 if (strEQ(name, "SIGFPE"))
1798 if (strEQ(name, "SIGHUP"))
1804 if (strEQ(name, "SIGILL"))
1810 if (strEQ(name, "SIGINT"))
1816 if (strEQ(name, "SIGKILL"))
1822 if (strEQ(name, "SIGPIPE"))
1828 if (strEQ(name, "SIGQUIT"))
1834 if (strEQ(name, "SIGSEGV"))
1840 if (strEQ(name, "SIGSTOP"))
1846 if (strEQ(name, "SIGTERM"))
1852 if (strEQ(name, "SIGTSTP"))
1858 if (strEQ(name, "SIGTTIN"))
1864 if (strEQ(name, "SIGTTOU"))
1870 if (strEQ(name, "SIGUSR1"))
1876 if (strEQ(name, "SIGUSR2"))
1884 if (name[1] == '_') {
1885 if (strEQ(name, "S_ISGID"))
1891 if (strEQ(name, "S_ISUID"))
1897 if (strEQ(name, "S_IRGRP"))
1903 if (strEQ(name, "S_IROTH"))
1909 if (strEQ(name, "S_IRUSR"))
1915 if (strEQ(name, "S_IRWXG"))
1921 if (strEQ(name, "S_IRWXO"))
1927 if (strEQ(name, "S_IRWXU"))
1933 if (strEQ(name, "S_IWGRP"))
1939 if (strEQ(name, "S_IWOTH"))
1945 if (strEQ(name, "S_IWUSR"))
1951 if (strEQ(name, "S_IXGRP"))
1957 if (strEQ(name, "S_IXOTH"))
1963 if (strEQ(name, "S_IXUSR"))
1969 errno = EAGAIN; /* the following aren't constants */
1971 if (strEQ(name, "S_ISBLK")) return S_ISBLK(arg);
1974 if (strEQ(name, "S_ISCHR")) return S_ISCHR(arg);
1977 if (strEQ(name, "S_ISDIR")) return S_ISDIR(arg);
1980 if (strEQ(name, "S_ISFIFO")) return S_ISFIFO(arg);
1983 if (strEQ(name, "S_ISREG")) return S_ISREG(arg);
1987 if (strEQ(name, "SEEK_CUR"))
1993 if (strEQ(name, "SEEK_END"))
1999 if (strEQ(name, "SEEK_SET"))
2005 if (strEQ(name, "STREAM_MAX"))
2011 if (strEQ(name, "SHRT_MAX"))
2017 if (strEQ(name, "SHRT_MIN"))
2023 if (strnEQ(name, "SA_", 3)) {
2024 if (strEQ(name, "SA_NOCLDSTOP"))
2026 return SA_NOCLDSTOP;
2030 if (strEQ(name, "SA_NOCLDWAIT"))
2032 return SA_NOCLDWAIT;
2036 if (strEQ(name, "SA_NODEFER"))
2042 if (strEQ(name, "SA_ONSTACK"))
2048 if (strEQ(name, "SA_RESETHAND"))
2050 return SA_RESETHAND;
2054 if (strEQ(name, "SA_RESTART"))
2060 if (strEQ(name, "SA_SIGINFO"))
2068 if (strEQ(name, "SCHAR_MAX"))
2074 if (strEQ(name, "SCHAR_MIN"))
2080 if (strEQ(name, "SSIZE_MAX"))
2086 if (strEQ(name, "STDIN_FILENO"))
2088 return STDIN_FILENO;
2092 if (strEQ(name, "STDOUT_FILENO"))
2093 #ifdef STDOUT_FILENO
2094 return STDOUT_FILENO;
2098 if (strEQ(name, "STRERR_FILENO"))
2099 #ifdef STRERR_FILENO
2100 return STRERR_FILENO;
2106 if (strEQ(name, "TCIFLUSH"))
2112 if (strEQ(name, "TCIOFF"))
2118 if (strEQ(name, "TCIOFLUSH"))
2124 if (strEQ(name, "TCION"))
2130 if (strEQ(name, "TCOFLUSH"))
2136 if (strEQ(name, "TCOOFF"))
2142 if (strEQ(name, "TCOON"))
2148 if (strEQ(name, "TCSADRAIN"))
2154 if (strEQ(name, "TCSAFLUSH"))
2160 if (strEQ(name, "TCSANOW"))
2166 if (strEQ(name, "TMP_MAX"))
2172 if (strEQ(name, "TOSTOP"))
2178 if (strEQ(name, "TZNAME_MAX"))
2186 if (strEQ(name, "UCHAR_MAX"))
2192 if (strEQ(name, "UINT_MAX"))
2198 if (strEQ(name, "ULONG_MAX"))
2204 if (strEQ(name, "USHRT_MAX"))
2212 if (strEQ(name, "VEOF"))
2218 if (strEQ(name, "VEOL"))
2224 if (strEQ(name, "VERASE"))
2230 if (strEQ(name, "VINTR"))
2236 if (strEQ(name, "VKILL"))
2242 if (strEQ(name, "VMIN"))
2248 if (strEQ(name, "VQUIT"))
2254 if (strEQ(name, "VSTART"))
2260 if (strEQ(name, "VSTOP"))
2266 if (strEQ(name, "VSUSP"))
2272 if (strEQ(name, "VTIME"))
2280 if (strEQ(name, "W_OK"))
2286 if (strEQ(name, "WNOHANG"))
2292 if (strEQ(name, "WUNTRACED"))
2298 errno = EAGAIN; /* the following aren't constants */
2300 if (strEQ(name, "WEXITSTATUS")) return WEXITSTATUS(arg);
2303 if (strEQ(name, "WIFEXITED")) return WIFEXITED(arg);
2306 if (strEQ(name, "WIFSIGNALED")) return WIFSIGNALED(arg);
2309 if (strEQ(name, "WIFSTOPPED")) return WIFSTOPPED(arg);
2312 if (strEQ(name, "WSTOPSIG")) return WSTOPSIG(arg);
2315 if (strEQ(name, "WTERMSIG")) return WTERMSIG(arg);
2319 if (strEQ(name, "X_OK"))
2327 if (strnEQ(name, "_PC_", 4)) {
2328 if (strEQ(name, "_PC_CHOWN_RESTRICTED"))
2329 #if defined(_PC_CHOWN_RESTRICTED) || HINT_SC_EXIST
2330 return _PC_CHOWN_RESTRICTED;
2334 if (strEQ(name, "_PC_LINK_MAX"))
2335 #if defined(_PC_LINK_MAX) || HINT_SC_EXIST
2336 return _PC_LINK_MAX;
2340 if (strEQ(name, "_PC_MAX_CANON"))
2341 #if defined(_PC_MAX_CANON) || HINT_SC_EXIST
2342 return _PC_MAX_CANON;
2346 if (strEQ(name, "_PC_MAX_INPUT"))
2347 #if defined(_PC_MAX_INPUT) || HINT_SC_EXIST
2348 return _PC_MAX_INPUT;
2352 if (strEQ(name, "_PC_NAME_MAX"))
2353 #if defined(_PC_NAME_MAX) || HINT_SC_EXIST
2354 return _PC_NAME_MAX;
2358 if (strEQ(name, "_PC_NO_TRUNC"))
2359 #if defined(_PC_NO_TRUNC) || HINT_SC_EXIST
2360 return _PC_NO_TRUNC;
2364 if (strEQ(name, "_PC_PATH_MAX"))
2365 #if defined(_PC_PATH_MAX) || HINT_SC_EXIST
2366 return _PC_PATH_MAX;
2370 if (strEQ(name, "_PC_PIPE_BUF"))
2371 #if defined(_PC_PIPE_BUF) || HINT_SC_EXIST
2372 return _PC_PIPE_BUF;
2376 if (strEQ(name, "_PC_VDISABLE"))
2377 #if defined(_PC_VDISABLE) || HINT_SC_EXIST
2378 return _PC_VDISABLE;
2384 if (strnEQ(name, "_POSIX_", 7)) {
2385 if (strEQ(name, "_POSIX_ARG_MAX"))
2386 #ifdef _POSIX_ARG_MAX
2387 return _POSIX_ARG_MAX;
2391 if (strEQ(name, "_POSIX_CHILD_MAX"))
2392 #ifdef _POSIX_CHILD_MAX
2393 return _POSIX_CHILD_MAX;
2397 if (strEQ(name, "_POSIX_CHOWN_RESTRICTED"))
2398 #ifdef _POSIX_CHOWN_RESTRICTED
2399 return _POSIX_CHOWN_RESTRICTED;
2403 if (strEQ(name, "_POSIX_JOB_CONTROL"))
2404 #ifdef _POSIX_JOB_CONTROL
2405 return _POSIX_JOB_CONTROL;
2409 if (strEQ(name, "_POSIX_LINK_MAX"))
2410 #ifdef _POSIX_LINK_MAX
2411 return _POSIX_LINK_MAX;
2415 if (strEQ(name, "_POSIX_MAX_CANON"))
2416 #ifdef _POSIX_MAX_CANON
2417 return _POSIX_MAX_CANON;
2421 if (strEQ(name, "_POSIX_MAX_INPUT"))
2422 #ifdef _POSIX_MAX_INPUT
2423 return _POSIX_MAX_INPUT;
2427 if (strEQ(name, "_POSIX_NAME_MAX"))
2428 #ifdef _POSIX_NAME_MAX
2429 return _POSIX_NAME_MAX;
2433 if (strEQ(name, "_POSIX_NGROUPS_MAX"))
2434 #ifdef _POSIX_NGROUPS_MAX
2435 return _POSIX_NGROUPS_MAX;
2439 if (strEQ(name, "_POSIX_NO_TRUNC"))
2440 #ifdef _POSIX_NO_TRUNC
2441 return _POSIX_NO_TRUNC;
2445 if (strEQ(name, "_POSIX_OPEN_MAX"))
2446 #ifdef _POSIX_OPEN_MAX
2447 return _POSIX_OPEN_MAX;
2451 if (strEQ(name, "_POSIX_PATH_MAX"))
2452 #ifdef _POSIX_PATH_MAX
2453 return _POSIX_PATH_MAX;
2457 if (strEQ(name, "_POSIX_PIPE_BUF"))
2458 #ifdef _POSIX_PIPE_BUF
2459 return _POSIX_PIPE_BUF;
2463 if (strEQ(name, "_POSIX_SAVED_IDS"))
2464 #ifdef _POSIX_SAVED_IDS
2465 return _POSIX_SAVED_IDS;
2469 if (strEQ(name, "_POSIX_SSIZE_MAX"))
2470 #ifdef _POSIX_SSIZE_MAX
2471 return _POSIX_SSIZE_MAX;
2475 if (strEQ(name, "_POSIX_STREAM_MAX"))
2476 #ifdef _POSIX_STREAM_MAX
2477 return _POSIX_STREAM_MAX;
2481 if (strEQ(name, "_POSIX_TZNAME_MAX"))
2482 #ifdef _POSIX_TZNAME_MAX
2483 return _POSIX_TZNAME_MAX;
2487 if (strEQ(name, "_POSIX_VDISABLE"))
2488 #ifdef _POSIX_VDISABLE
2489 return _POSIX_VDISABLE;
2493 if (strEQ(name, "_POSIX_VERSION"))
2494 #ifdef _POSIX_VERSION
2495 return _POSIX_VERSION;
2501 if (strnEQ(name, "_SC_", 4)) {
2502 if (strEQ(name, "_SC_ARG_MAX"))
2503 #if defined(_SC_ARG_MAX) || HINT_SC_EXIST
2508 if (strEQ(name, "_SC_CHILD_MAX"))
2509 #if defined(_SC_CHILD_MAX) || HINT_SC_EXIST
2510 return _SC_CHILD_MAX;
2514 if (strEQ(name, "_SC_CLK_TCK"))
2515 #if defined(_SC_CLK_TCK) || HINT_SC_EXIST
2520 if (strEQ(name, "_SC_JOB_CONTROL"))
2521 #if defined(_SC_JOB_CONTROL) || HINT_SC_EXIST
2522 return _SC_JOB_CONTROL;
2526 if (strEQ(name, "_SC_NGROUPS_MAX"))
2527 #if defined(_SC_NGROUPS_MAX) || HINT_SC_EXIST
2528 return _SC_NGROUPS_MAX;
2532 if (strEQ(name, "_SC_OPEN_MAX"))
2533 #if defined(_SC_OPEN_MAX) || HINT_SC_EXIST
2534 return _SC_OPEN_MAX;
2538 if (strEQ(name, "_SC_SAVED_IDS"))
2539 #if defined(_SC_SAVED_IDS) || HINT_SC_EXIST
2540 return _SC_SAVED_IDS;
2544 if (strEQ(name, "_SC_STREAM_MAX"))
2545 #if defined(_SC_STREAM_MAX) || HINT_SC_EXIST
2546 return _SC_STREAM_MAX;
2550 if (strEQ(name, "_SC_TZNAME_MAX"))
2551 #if defined(_SC_TZNAME_MAX) || HINT_SC_EXIST
2552 return _SC_TZNAME_MAX;
2556 if (strEQ(name, "_SC_VERSION"))
2557 #if defined(_SC_VERSION) || HINT_SC_EXIST
2573 MODULE = SigSet PACKAGE = POSIX::SigSet PREFIX = sig
2576 new(packname = "POSIX::SigSet", ...)
2581 New(0, RETVAL, 1, sigset_t);
2582 sigemptyset(RETVAL);
2583 for (i = 1; i < items; i++)
2584 sigaddset(RETVAL, SvIV(ST(i)));
2591 POSIX::SigSet sigset
2596 sigaddset(sigset, sig)
2597 POSIX::SigSet sigset
2601 sigdelset(sigset, sig)
2602 POSIX::SigSet sigset
2607 POSIX::SigSet sigset
2611 POSIX::SigSet sigset
2614 sigismember(sigset, sig)
2615 POSIX::SigSet sigset
2619 MODULE = Termios PACKAGE = POSIX::Termios PREFIX = cf
2622 new(packname = "POSIX::Termios", ...)
2627 New(0, RETVAL, 1, struct termios);
2629 not_here("termios");
2637 DESTROY(termios_ref)
2638 POSIX::Termios termios_ref
2641 Safefree(termios_ref);
2643 not_here("termios");
2647 getattr(termios_ref, fd = 0)
2648 POSIX::Termios termios_ref
2651 RETVAL = tcgetattr(fd, termios_ref);
2656 setattr(termios_ref, fd = 0, optional_actions = 0)
2657 POSIX::Termios termios_ref
2659 int optional_actions
2661 RETVAL = tcsetattr(fd, optional_actions, termios_ref);
2666 cfgetispeed(termios_ref)
2667 POSIX::Termios termios_ref
2670 cfgetospeed(termios_ref)
2671 POSIX::Termios termios_ref
2674 getiflag(termios_ref)
2675 POSIX::Termios termios_ref
2677 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2678 RETVAL = termios_ref->c_iflag;
2680 not_here("getiflag");
2687 getoflag(termios_ref)
2688 POSIX::Termios termios_ref
2690 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2691 RETVAL = termios_ref->c_oflag;
2693 not_here("getoflag");
2700 getcflag(termios_ref)
2701 POSIX::Termios termios_ref
2703 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2704 RETVAL = termios_ref->c_cflag;
2706 not_here("getcflag");
2713 getlflag(termios_ref)
2714 POSIX::Termios termios_ref
2716 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2717 RETVAL = termios_ref->c_lflag;
2719 not_here("getlflag");
2726 getcc(termios_ref, ccix)
2727 POSIX::Termios termios_ref
2730 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2732 croak("Bad getcc subscript");
2733 RETVAL = termios_ref->c_cc[ccix];
2742 cfsetispeed(termios_ref, speed)
2743 POSIX::Termios termios_ref
2747 cfsetospeed(termios_ref, speed)
2748 POSIX::Termios termios_ref
2752 setiflag(termios_ref, iflag)
2753 POSIX::Termios termios_ref
2756 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2757 termios_ref->c_iflag = iflag;
2759 not_here("setiflag");
2763 setoflag(termios_ref, oflag)
2764 POSIX::Termios termios_ref
2767 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2768 termios_ref->c_oflag = oflag;
2770 not_here("setoflag");
2774 setcflag(termios_ref, cflag)
2775 POSIX::Termios termios_ref
2778 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2779 termios_ref->c_cflag = cflag;
2781 not_here("setcflag");
2785 setlflag(termios_ref, lflag)
2786 POSIX::Termios termios_ref
2789 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2790 termios_ref->c_lflag = lflag;
2792 not_here("setlflag");
2796 setcc(termios_ref, ccix, cc)
2797 POSIX::Termios termios_ref
2801 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2803 croak("Bad setcc subscript");
2804 termios_ref->c_cc[ccix] = cc;
2810 MODULE = POSIX PACKAGE = POSIX
2819 unsigned char * charstring
2821 unsigned char *s = charstring;
2822 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2823 for (RETVAL = 1; RETVAL && s < e; s++)
2831 unsigned char * charstring
2833 unsigned char *s = charstring;
2834 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2835 for (RETVAL = 1; RETVAL && s < e; s++)
2843 unsigned char * charstring
2845 unsigned char *s = charstring;
2846 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2847 for (RETVAL = 1; RETVAL && s < e; s++)
2855 unsigned char * charstring
2857 unsigned char *s = charstring;
2858 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2859 for (RETVAL = 1; RETVAL && s < e; s++)
2867 unsigned char * charstring
2869 unsigned char *s = charstring;
2870 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2871 for (RETVAL = 1; RETVAL && s < e; s++)
2879 unsigned char * charstring
2881 unsigned char *s = charstring;
2882 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2883 for (RETVAL = 1; RETVAL && s < e; s++)
2891 unsigned char * charstring
2893 unsigned char *s = charstring;
2894 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2895 for (RETVAL = 1; RETVAL && s < e; s++)
2903 unsigned char * charstring
2905 unsigned char *s = charstring;
2906 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2907 for (RETVAL = 1; RETVAL && s < e; s++)
2915 unsigned char * charstring
2917 unsigned char *s = charstring;
2918 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2919 for (RETVAL = 1; RETVAL && s < e; s++)
2927 unsigned char * charstring
2929 unsigned char *s = charstring;
2930 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2931 for (RETVAL = 1; RETVAL && s < e; s++)
2938 isxdigit(charstring)
2939 unsigned char * charstring
2941 unsigned char *s = charstring;
2942 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2943 for (RETVAL = 1; RETVAL && s < e; s++)
2950 open(filename, flags = O_RDONLY, mode = 0666)
2955 if (flags & (O_APPEND|O_CREAT|O_TRUNC|O_RDWR|O_WRONLY|O_EXCL))
2956 TAINT_PROPER("open");
2957 RETVAL = open(filename, flags, mode);
2965 #ifdef HAS_LOCALECONV
2966 struct lconv *lcbuf;
2968 if (lcbuf = localeconv()) {
2970 if (lcbuf->decimal_point && *lcbuf->decimal_point)
2971 hv_store(RETVAL, "decimal_point", 13,
2972 newSVpv(lcbuf->decimal_point, 0), 0);
2973 if (lcbuf->thousands_sep && *lcbuf->thousands_sep)
2974 hv_store(RETVAL, "thousands_sep", 13,
2975 newSVpv(lcbuf->thousands_sep, 0), 0);
2976 #ifndef NO_LOCALECONV_GROUPING
2977 if (lcbuf->grouping && *lcbuf->grouping)
2978 hv_store(RETVAL, "grouping", 8,
2979 newSVpv(lcbuf->grouping, 0), 0);
2981 if (lcbuf->int_curr_symbol && *lcbuf->int_curr_symbol)
2982 hv_store(RETVAL, "int_curr_symbol", 15,
2983 newSVpv(lcbuf->int_curr_symbol, 0), 0);
2984 if (lcbuf->currency_symbol && *lcbuf->currency_symbol)
2985 hv_store(RETVAL, "currency_symbol", 15,
2986 newSVpv(lcbuf->currency_symbol, 0), 0);
2987 if (lcbuf->mon_decimal_point && *lcbuf->mon_decimal_point)
2988 hv_store(RETVAL, "mon_decimal_point", 17,
2989 newSVpv(lcbuf->mon_decimal_point, 0), 0);
2990 #ifndef NO_LOCALECONV_MON_THOUSANDS_SEP
2991 if (lcbuf->mon_thousands_sep && *lcbuf->mon_thousands_sep)
2992 hv_store(RETVAL, "mon_thousands_sep", 17,
2993 newSVpv(lcbuf->mon_thousands_sep, 0), 0);
2995 #ifndef NO_LOCALECONV_MON_GROUPING
2996 if (lcbuf->mon_grouping && *lcbuf->mon_grouping)
2997 hv_store(RETVAL, "mon_grouping", 12,
2998 newSVpv(lcbuf->mon_grouping, 0), 0);
3000 if (lcbuf->positive_sign && *lcbuf->positive_sign)
3001 hv_store(RETVAL, "positive_sign", 13,
3002 newSVpv(lcbuf->positive_sign, 0), 0);
3003 if (lcbuf->negative_sign && *lcbuf->negative_sign)
3004 hv_store(RETVAL, "negative_sign", 13,
3005 newSVpv(lcbuf->negative_sign, 0), 0);
3007 if (lcbuf->int_frac_digits != CHAR_MAX)
3008 hv_store(RETVAL, "int_frac_digits", 15,
3009 newSViv(lcbuf->int_frac_digits), 0);
3010 if (lcbuf->frac_digits != CHAR_MAX)
3011 hv_store(RETVAL, "frac_digits", 11,
3012 newSViv(lcbuf->frac_digits), 0);
3013 if (lcbuf->p_cs_precedes != CHAR_MAX)
3014 hv_store(RETVAL, "p_cs_precedes", 13,
3015 newSViv(lcbuf->p_cs_precedes), 0);
3016 if (lcbuf->p_sep_by_space != CHAR_MAX)
3017 hv_store(RETVAL, "p_sep_by_space", 14,
3018 newSViv(lcbuf->p_sep_by_space), 0);
3019 if (lcbuf->n_cs_precedes != CHAR_MAX)
3020 hv_store(RETVAL, "n_cs_precedes", 13,
3021 newSViv(lcbuf->n_cs_precedes), 0);
3022 if (lcbuf->n_sep_by_space != CHAR_MAX)
3023 hv_store(RETVAL, "n_sep_by_space", 14,
3024 newSViv(lcbuf->n_sep_by_space), 0);
3025 if (lcbuf->p_sign_posn != CHAR_MAX)
3026 hv_store(RETVAL, "p_sign_posn", 11,
3027 newSViv(lcbuf->p_sign_posn), 0);
3028 if (lcbuf->n_sign_posn != CHAR_MAX)
3029 hv_store(RETVAL, "n_sign_posn", 11,
3030 newSViv(lcbuf->n_sign_posn), 0);
3033 localeconv(); /* A stub to call not_here(). */
3039 setlocale(category, locale = 0)
3043 RETVAL = setlocale(category, locale);
3045 #ifdef USE_LOCALE_CTYPE
3046 if (category == LC_CTYPE
3048 || category == LC_ALL
3054 if (category == LC_ALL)
3055 newctype = setlocale(LC_CTYPE, NULL);
3059 new_ctype(newctype);
3061 #endif /* USE_LOCALE_CTYPE */
3062 #ifdef USE_LOCALE_COLLATE
3063 if (category == LC_COLLATE
3065 || category == LC_ALL
3071 if (category == LC_ALL)
3072 newcoll = setlocale(LC_COLLATE, NULL);
3076 new_collate(newcoll);
3078 #endif /* USE_LOCALE_COLLATE */
3079 #ifdef USE_LOCALE_NUMERIC
3080 if (category == LC_NUMERIC
3082 || category == LC_ALL
3088 if (category == LC_ALL)
3089 newnum = setlocale(LC_NUMERIC, NULL);
3093 new_numeric(newnum);
3095 #endif /* USE_LOCALE_NUMERIC */
3135 /* (We already know stack is long enough.) */
3136 PUSHs(sv_2mortal(newSVnv(frexp(x,&expvar))));
3137 PUSHs(sv_2mortal(newSViv(expvar)));
3153 /* (We already know stack is long enough.) */
3154 PUSHs(sv_2mortal(newSVnv(modf(x,&intvar))));
3155 PUSHs(sv_2mortal(newSVnv(intvar)));
3170 sigaction(sig, action, oldaction = 0)
3172 POSIX::SigAction action
3173 POSIX::SigAction oldaction
3176 RETVAL = not_here("sigaction");
3178 # This code is really grody because we're trying to make the signal
3179 # interface look beautiful, which is hard.
3182 gv_fetchpv("SIG", TRUE, SVt_PVHV);
3185 struct sigaction act;
3186 struct sigaction oact;
3187 POSIX__SigSet sigset;
3189 SV** sigsvp = hv_fetch(GvHVn(PL_siggv),
3191 strlen(PL_sig_name[sig]),
3195 /* Remember old handler name if desired. */
3197 char *hand = SvPVx(*sigsvp, n_a);
3198 svp = hv_fetch(oldaction, "HANDLER", 7, TRUE);
3199 sv_setpv(*svp, *hand ? hand : "DEFAULT");
3203 /* Vector new handler through %SIG. (We always use sighandler
3204 for the C signal handler, which reads %SIG to dispatch.) */
3205 svp = hv_fetch(action, "HANDLER", 7, FALSE);
3207 croak("Can't supply an action without a HANDLER");
3208 sv_setpv(*sigsvp, SvPV(*svp, n_a));
3209 mg_set(*sigsvp); /* handles DEFAULT and IGNORE */
3210 act.sa_handler = PL_sighandlerp;
3212 /* Set up any desired mask. */
3213 svp = hv_fetch(action, "MASK", 4, FALSE);
3214 if (svp && sv_isa(*svp, "POSIX::SigSet")) {
3216 tmp = (unsigned long)SvNV((SV*)SvRV(*svp));
3217 sigset = (sigset_t*) tmp;
3218 act.sa_mask = *sigset;
3221 sigemptyset(& act.sa_mask);
3223 /* Set up any desired flags. */
3224 svp = hv_fetch(action, "FLAGS", 5, FALSE);
3225 act.sa_flags = svp ? SvIV(*svp) : 0;
3228 /* Now work around sigaction oddities */
3229 if (action && oldaction)
3230 RETVAL = sigaction(sig, & act, & oact);
3232 RETVAL = sigaction(sig, & act, (struct sigaction *)0);
3234 RETVAL = sigaction(sig, (struct sigaction *)0, & oact);
3239 /* Get back the mask. */
3240 svp = hv_fetch(oldaction, "MASK", 4, TRUE);
3241 if (sv_isa(*svp, "POSIX::SigSet")) {
3243 tmp = (unsigned long)SvNV((SV*)SvRV(*svp));
3244 sigset = (sigset_t*) tmp;
3247 New(0, sigset, 1, sigset_t);
3248 sv_setptrobj(*svp, sigset, "POSIX::SigSet");
3250 *sigset = oact.sa_mask;
3252 /* Get back the flags. */
3253 svp = hv_fetch(oldaction, "FLAGS", 5, TRUE);
3254 sv_setiv(*svp, oact.sa_flags);
3263 POSIX::SigSet sigset
3266 sigprocmask(how, sigset, oldsigset = 0)
3268 POSIX::SigSet sigset
3269 POSIX::SigSet oldsigset = NO_INIT
3274 else if (sv_derived_from(ST(2), "POSIX::SigSet")) {
3275 IV tmp = SvIV((SV*)SvRV(ST(2)));
3276 oldsigset = (POSIX__SigSet) tmp;
3279 New(0, oldsigset, 1, sigset_t);
3280 sigemptyset(oldsigset);
3281 sv_setref_pv(ST(2), "POSIX::SigSet", (void*)oldsigset);
3285 sigsuspend(signal_mask)
3286 POSIX::SigSet signal_mask
3306 lseek(fd, offset, whence)
3319 if (pipe(fds) != -1) {
3321 PUSHs(sv_2mortal(newSViv(fds[0])));
3322 PUSHs(sv_2mortal(newSViv(fds[1])));
3326 read(fd, buffer, nbytes)
3328 SV *sv_buffer = SvROK(ST(1)) ? SvRV(ST(1)) : ST(1);
3332 char * buffer = sv_grow( sv_buffer, nbytes+1 );
3335 SvCUR(sv_buffer) = RETVAL;
3336 SvPOK_only(sv_buffer);
3337 *SvEND(sv_buffer) = '\0';
3338 SvTAINTED_on(sv_buffer);
3354 tcsetpgrp(fd, pgrp_id)
3363 if (uname(&buf) >= 0) {
3365 PUSHs(sv_2mortal(newSVpv(buf.sysname, 0)));
3366 PUSHs(sv_2mortal(newSVpv(buf.nodename, 0)));
3367 PUSHs(sv_2mortal(newSVpv(buf.release, 0)));
3368 PUSHs(sv_2mortal(newSVpv(buf.version, 0)));
3369 PUSHs(sv_2mortal(newSVpv(buf.machine, 0)));
3372 uname((char *) 0); /* A stub to call not_here(). */
3376 write(fd, buffer, nbytes)
3387 RETVAL = newSVpvn("", 0);
3388 SvGROW(RETVAL, L_tmpnam);
3389 len = strlen(tmpnam(SvPV(RETVAL, i)));
3390 SvCUR_set(RETVAL, len);
3403 mbstowcs(s, pwcs, n)
3415 wcstombs(s, pwcs, n)
3437 SET_NUMERIC_LOCAL();
3438 num = strtod(str, &unparsed);
3439 PUSHs(sv_2mortal(newSVnv(num)));
3440 if (GIMME == G_ARRAY) {
3443 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3445 PUSHs(&PL_sv_undef);
3449 strtol(str, base = 0)
3456 num = strtol(str, &unparsed, base);
3457 if (num >= IV_MIN && num <= IV_MAX)
3458 PUSHs(sv_2mortal(newSViv((IV)num)));
3460 PUSHs(sv_2mortal(newSVnv((double)num)));
3461 if (GIMME == G_ARRAY) {
3464 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3466 PUSHs(&PL_sv_undef);
3470 strtoul(str, base = 0)
3477 num = strtoul(str, &unparsed, base);
3479 PUSHs(sv_2mortal(newSViv((IV)num)));
3481 PUSHs(sv_2mortal(newSVnv((double)num)));
3482 if (GIMME == G_ARRAY) {
3485 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3487 PUSHs(&PL_sv_undef);
3497 char *p = SvPV(src,srclen);
3499 ST(0) = sv_2mortal(NEWSV(800,srclen));
3500 dstlen = strxfrm(SvPVX(ST(0)), p, (size_t)srclen);
3501 if (dstlen > srclen) {
3503 SvGROW(ST(0), dstlen);
3504 strxfrm(SvPVX(ST(0)), p, (size_t)dstlen);
3507 SvCUR(ST(0)) = dstlen;
3512 mkfifo(filename, mode)
3516 TAINT_PROPER("mkfifo");
3517 RETVAL = mkfifo(filename, mode);
3533 tcflush(fd, queue_selector)
3538 tcsendbreak(fd, duration)
3543 asctime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3556 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3559 mytm.tm_hour = hour;
3560 mytm.tm_mday = mday;
3562 mytm.tm_year = year;
3563 mytm.tm_wday = wday;
3564 mytm.tm_yday = yday;
3565 mytm.tm_isdst = isdst;
3566 RETVAL = asctime(&mytm);
3583 realtime = times( &tms );
3585 PUSHs( sv_2mortal( newSViv( (IV) realtime ) ) );
3586 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_utime ) ) );
3587 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_stime ) ) );
3588 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cutime ) ) );
3589 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cstime ) ) );
3592 difftime(time1, time2)
3597 mktime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3610 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3613 mytm.tm_hour = hour;
3614 mytm.tm_mday = mday;
3616 mytm.tm_year = year;
3617 mytm.tm_wday = wday;
3618 mytm.tm_yday = yday;
3619 mytm.tm_isdst = isdst;
3620 RETVAL = mktime(&mytm);
3626 strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1)
3642 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3645 mytm.tm_hour = hour;
3646 mytm.tm_mday = mday;
3648 mytm.tm_year = year;
3649 mytm.tm_wday = wday;
3650 mytm.tm_yday = yday;
3651 mytm.tm_isdst = isdst;
3652 (void) mktime(&mytm);
3653 len = strftime(tmpbuf, sizeof tmpbuf, fmt, &mytm);
3655 ** The following is needed to handle to the situation where
3656 ** tmpbuf overflows. Basically we want to allocate a buffer
3657 ** and try repeatedly. The reason why it is so complicated
3658 ** is that getting a return value of 0 from strftime can indicate
3659 ** one of the following:
3660 ** 1. buffer overflowed,
3661 ** 2. illegal conversion specifier, or
3662 ** 3. the format string specifies nothing to be returned(not
3663 ** an error). This could be because format is an empty string
3664 ** or it specifies %p that yields an empty string in some locale.
3665 ** If there is a better way to make it portable, go ahead by
3668 if ( ( len > 0 && len < sizeof(tmpbuf) )
3669 || ( len == 0 && strlen(fmt) == 0 ) ) {
3670 ST(0) = sv_2mortal(newSVpv(tmpbuf, len));
3672 /* Possibly buf overflowed - try again with a bigger buf */
3673 int bufsize = strlen(fmt) + sizeof(tmpbuf);
3677 New(0, buf, bufsize, char);
3679 buflen = strftime(buf, bufsize, fmt, &mytm);
3680 if ( buflen > 0 && buflen < bufsize ) break;
3682 Renew(buf, bufsize, char);
3685 ST(0) = sv_2mortal(newSVpvn(buf, buflen));
3688 ST(0) = sv_2mortal(newSVpvn(tmpbuf, len));
3700 PUSHs(sv_2mortal(newSVpvn(tzname[0],strlen(tzname[0]))));
3701 PUSHs(sv_2mortal(newSVpvn(tzname[1],strlen(tzname[1]))));
3704 access(filename, mode)
3722 pathconf(filename, name)