5 #define PERL_NO_GET_CONTEXT
8 #define PERLIO_NOT_STDIO 1
11 #if defined(PERL_OBJECT) || defined(PERL_CAPI) || defined(PERL_IMPLICIT_SYS)
15 # define open PerlLIO_open3
18 #ifdef I_DIRENT /* XXX maybe better to just rely on perl.h? */
45 /* XXX This comment is just to make I_TERMIO and I_SGTTY visible to
46 metaconfig for future extension writers. We don't use them in POSIX.
47 (This is really sneaky :-) --AD
49 #if defined(I_TERMIOS)
57 #include <sys/types.h>
62 #ifdef MACOS_TRADITIONAL
67 /* Mac OSX does not include a definition of tzname in a .h file */
68 #if defined (HAS_TZNAME) && defined(__APPLE__) && defined(__MACH__)
69 extern char *tzname[2];
72 #if defined(__VMS) && !defined(__POSIX_SOURCE)
73 # include <libdef.h> /* LIB$_INVARG constant */
74 # include <lib$routines.h> /* prototype for lib$ediv() */
75 # include <starlet.h> /* prototype for sys$gettim() */
76 # if DECC_VERSION < 50000000
77 # define pid_t int /* old versions of DECC miss this in types.h */
81 # define mkfifo(a,b) (not_here("mkfifo"),-1)
82 # define tzset() not_here("tzset")
84 #if ((__VMS_VER >= 70000000) && (__DECC_VER >= 50200000)) || (__CRTL_VER >= 70000000)
85 # define HAS_TZNAME /* shows up in VMS 7.0 or Dec C 5.6 */
87 # endif /* __VMS_VER >= 70000000 or Dec C 5.6 */
89 /* The POSIX notion of ttyname() is better served by getname() under VMS */
90 static char ttnambuf[64];
91 # define ttyname(fd) (isatty(fd) > 0 ? getname(fd,ttnambuf,0) : NULL)
93 /* The non-POSIX CRTL times() has void return type, so we just get the
94 current time directly */
95 clock_t vms_times(struct tms *bufptr) {
98 /* Get wall time and convert to 10 ms intervals to
99 * produce the return value that the POSIX standard expects */
100 # if defined(__DECC) && defined (__ALPHA)
103 _ckvmssts(sys$gettim(&vmstime));
105 retval = vmstime & 0x7fffffff;
107 /* (Older hw or ccs don't have an atomic 64-bit type, so we
108 * juggle 32-bit ints (and a float) to produce a time_t result
109 * with minimal loss of information.) */
110 long int vmstime[2],remainder,divisor = 100000;
111 _ckvmssts(sys$gettim((unsigned long int *)vmstime));
112 vmstime[1] &= 0x7fff; /* prevent overflow in EDIV */
113 _ckvmssts(lib$ediv(&divisor,vmstime,(long int *)&retval,&remainder));
115 /* Fill in the struct tms using the CRTL routine . . .*/
116 times((tbuffer_t *)bufptr);
117 return (clock_t) retval;
119 # define times(t) vms_times(t)
121 #if defined (__CYGWIN__)
122 # define tzname _tzname
126 # define mkfifo(a,b) not_here("mkfifo")
127 # define ttyname(a) (char*)not_here("ttyname")
128 # define sigset_t long
131 # define tzname _tzname
134 # define mode_t short
137 # define mode_t short
139 # define tzset() not_here("tzset")
141 # ifndef _POSIX_OPEN_MAX
142 # define _POSIX_OPEN_MAX FOPEN_MAX /* XXX bogus ? */
145 # define sigaction(a,b,c) not_here("sigaction")
146 # define sigpending(a) not_here("sigpending")
147 # define sigprocmask(a,b,c) not_here("sigprocmask")
148 # define sigsuspend(a) not_here("sigsuspend")
149 # define sigemptyset(a) not_here("sigemptyset")
150 # define sigaddset(a,b) not_here("sigaddset")
151 # define sigdelset(a,b) not_here("sigdelset")
152 # define sigfillset(a) not_here("sigfillset")
153 # define sigismember(a,b) not_here("sigismember")
157 # if defined(OS2) || defined(MACOS_TRADITIONAL)
158 # define mkfifo(a,b) not_here("mkfifo")
159 # else /* !( defined OS2 ) */
161 # define mkfifo(path, mode) (mknod((path), (mode) | S_IFIFO, 0))
164 # endif /* !HAS_MKFIFO */
166 # ifdef MACOS_TRADITIONAL
167 # define ttyname(a) (char*)not_here("ttyname")
168 # define tzset() not_here("tzset")
171 # include <sys/times.h>
173 # include <sys/utsname.h>
175 # include <sys/wait.h>
184 typedef long SysRetLong;
185 typedef sigset_t* POSIX__SigSet;
186 typedef HV* POSIX__SigAction;
188 typedef struct termios* POSIX__Termios;
189 #else /* Define termios types to int, and call not_here for the functions.*/
190 #define POSIX__Termios int
194 #define cfgetispeed(x) not_here("cfgetispeed")
195 #define cfgetospeed(x) not_here("cfgetospeed")
196 #define tcdrain(x) not_here("tcdrain")
197 #define tcflush(x,y) not_here("tcflush")
198 #define tcsendbreak(x,y) not_here("tcsendbreak")
199 #define cfsetispeed(x,y) not_here("cfsetispeed")
200 #define cfsetospeed(x,y) not_here("cfsetospeed")
201 #define ctermid(x) (char *) not_here("ctermid")
202 #define tcflow(x,y) not_here("tcflow")
203 #define tcgetattr(x,y) not_here("tcgetattr")
204 #define tcsetattr(x,y,z) not_here("tcsetattr")
207 /* Possibly needed prototypes */
208 char *cuserid (char *);
209 double strtod (const char *, char **);
210 long strtol (const char *, char **, int);
211 unsigned long strtoul (const char *, char **, int);
214 #define cuserid(a) (char *) not_here("cuserid")
218 #define difftime(a,b) not_here("difftime")
221 #ifndef HAS_FPATHCONF
222 #define fpathconf(f,n) (SysRetLong) not_here("fpathconf")
225 #define mktime(a) not_here("mktime")
228 #define nice(a) not_here("nice")
231 #define pathconf(f,n) (SysRetLong) not_here("pathconf")
234 #define sysconf(n) (SysRetLong) not_here("sysconf")
237 #define readlink(a,b,c) not_here("readlink")
240 #define setpgid(a,b) not_here("setpgid")
243 #define setsid() not_here("setsid")
246 #define strcoll(s1,s2) not_here("strcoll")
249 #define strtod(s1,s2) not_here("strtod")
252 #define strtol(s1,s2,b) not_here("strtol")
255 #define strtoul(s1,s2,b) not_here("strtoul")
258 #define strxfrm(s1,s2,n) not_here("strxfrm")
260 #ifndef HAS_TCGETPGRP
261 #define tcgetpgrp(a) not_here("tcgetpgrp")
263 #ifndef HAS_TCSETPGRP
264 #define tcsetpgrp(a,b) not_here("tcsetpgrp")
267 #define times(a) not_here("times")
270 #define uname(a) not_here("uname")
273 #define waitpid(a,b,c) not_here("waitpid")
278 #define mblen(a,b) not_here("mblen")
282 #define mbstowcs(s, pwcs, n) not_here("mbstowcs")
285 #define mbtowc(pwc, s, n) not_here("mbtowc")
288 #define wcstombs(s, pwcs, n) not_here("wcstombs")
291 #define wctomb(s, wchar) not_here("wcstombs")
293 #if !defined(HAS_MBLEN) && !defined(HAS_MBSTOWCS) && !defined(HAS_MBTOWC) && !defined(HAS_WCSTOMBS) && !defined(HAS_WCTOMB)
294 /* If we don't have these functions, then we wouldn't have gotten a typedef
295 for wchar_t, the wide character type. Defining wchar_t allows the
296 functions referencing it to compile. Its actual type is then meaningless,
297 since without the above functions, all sections using it end up calling
298 not_here() and croak. --Kaveh Ghazi (ghazi@noc.rutgers.edu) 9/18/94. */
304 #ifndef HAS_LOCALECONV
305 #define localeconv() not_here("localeconv")
308 #ifdef HAS_LONG_DOUBLE
309 # if LONG_DOUBLESIZE > NVSIZE
310 # undef HAS_LONG_DOUBLE /* XXX until we figure out how to use them */
314 #ifndef HAS_LONG_DOUBLE
329 croak("POSIX::%s not implemented on this architecture", s);
335 constant(char *name, int arg)
340 if (strEQ(name, "ARG_MAX"))
348 if (strEQ(name, "BUFSIZ"))
354 if (strEQ(name, "BRKINT"))
360 if (strEQ(name, "B9600"))
366 if (strEQ(name, "B19200"))
372 if (strEQ(name, "B38400"))
378 if (strEQ(name, "B0"))
384 if (strEQ(name, "B110"))
390 if (strEQ(name, "B1200"))
396 if (strEQ(name, "B134"))
402 if (strEQ(name, "B150"))
408 if (strEQ(name, "B1800"))
414 if (strEQ(name, "B200"))
420 if (strEQ(name, "B2400"))
426 if (strEQ(name, "B300"))
432 if (strEQ(name, "B4800"))
438 if (strEQ(name, "B50"))
444 if (strEQ(name, "B600"))
450 if (strEQ(name, "B75"))
458 if (strEQ(name, "CHAR_BIT"))
464 if (strEQ(name, "CHAR_MAX"))
470 if (strEQ(name, "CHAR_MIN"))
476 if (strEQ(name, "CHILD_MAX"))
482 if (strEQ(name, "CLK_TCK"))
488 if (strEQ(name, "CLOCAL"))
494 if (strEQ(name, "CLOCKS_PER_SEC"))
495 #ifdef CLOCKS_PER_SEC
496 return CLOCKS_PER_SEC;
500 if (strEQ(name, "CREAD"))
506 if (strEQ(name, "CS5"))
512 if (strEQ(name, "CS6"))
518 if (strEQ(name, "CS7"))
524 if (strEQ(name, "CS8"))
530 if (strEQ(name, "CSIZE"))
536 if (strEQ(name, "CSTOPB"))
544 if (strEQ(name, "DBL_MAX"))
550 if (strEQ(name, "DBL_MIN"))
556 if (strEQ(name, "DBL_DIG"))
562 if (strEQ(name, "DBL_EPSILON"))
568 if (strEQ(name, "DBL_MANT_DIG"))
574 if (strEQ(name, "DBL_MAX_10_EXP"))
575 #ifdef DBL_MAX_10_EXP
576 return DBL_MAX_10_EXP;
580 if (strEQ(name, "DBL_MAX_EXP"))
586 if (strEQ(name, "DBL_MIN_10_EXP"))
587 #ifdef DBL_MIN_10_EXP
588 return DBL_MIN_10_EXP;
592 if (strEQ(name, "DBL_MIN_EXP"))
602 if (strEQ(name, "EACCES"))
608 if (strEQ(name, "EADDRINUSE"))
614 if (strEQ(name, "EADDRNOTAVAIL"))
616 return EADDRNOTAVAIL;
620 if (strEQ(name, "EAFNOSUPPORT"))
626 if (strEQ(name, "EAGAIN"))
632 if (strEQ(name, "EALREADY"))
640 if (strEQ(name, "EBADF"))
646 if (strEQ(name, "EBUSY"))
654 if (strEQ(name, "ECHILD"))
660 if (strEQ(name, "ECHO"))
666 if (strEQ(name, "ECHOE"))
672 if (strEQ(name, "ECHOK"))
678 if (strEQ(name, "ECHONL"))
684 if (strEQ(name, "ECONNABORTED"))
690 if (strEQ(name, "ECONNREFUSED"))
696 if (strEQ(name, "ECONNRESET"))
704 if (strEQ(name, "EDEADLK"))
710 if (strEQ(name, "EDESTADDRREQ"))
716 if (strEQ(name, "EDOM"))
722 if (strEQ(name, "EDQUOT"))
730 if (strEQ(name, "EEXIST"))
738 if (strEQ(name, "EFAULT"))
744 if (strEQ(name, "EFBIG"))
752 if (strEQ(name, "EHOSTDOWN"))
758 if (strEQ(name, "EHOSTUNREACH"))
766 if (strEQ(name, "EINPROGRESS"))
772 if (strEQ(name, "EINTR"))
778 if (strEQ(name, "EINVAL"))
784 if (strEQ(name, "EIO"))
790 if (strEQ(name, "EISCONN"))
796 if (strEQ(name, "EISDIR"))
804 if (strEQ(name, "ELOOP"))
812 if (strEQ(name, "EMFILE"))
818 if (strEQ(name, "EMLINK"))
824 if (strEQ(name, "EMSGSIZE"))
832 if (strEQ(name, "ENETDOWN"))
838 if (strEQ(name, "ENETRESET"))
844 if (strEQ(name, "ENETUNREACH"))
850 if (strEQ(name, "ENOBUFS"))
856 if (strEQ(name, "ENOEXEC"))
862 if (strEQ(name, "ENOMEM"))
868 if (strEQ(name, "ENOPROTOOPT"))
874 if (strEQ(name, "ENOSPC"))
880 if (strEQ(name, "ENOTBLK"))
886 if (strEQ(name, "ENOTCONN"))
892 if (strEQ(name, "ENOTDIR"))
898 if (strEQ(name, "ENOTEMPTY"))
904 if (strEQ(name, "ENOTSOCK"))
910 if (strEQ(name, "ENOTTY"))
916 if (strEQ(name, "ENFILE"))
922 if (strEQ(name, "ENODEV"))
928 if (strEQ(name, "ENOENT"))
934 if (strEQ(name, "ENOLCK"))
940 if (strEQ(name, "ENOSYS"))
946 if (strEQ(name, "ENXIO"))
952 if (strEQ(name, "ENAMETOOLONG"))
960 if (strEQ(name, "EOF"))
966 if (strEQ(name, "EOPNOTSUPP"))
974 if (strEQ(name, "EPERM"))
980 if (strEQ(name, "EPFNOSUPPORT"))
986 if (strEQ(name, "EPIPE"))
992 if (strEQ(name, "EPROCLIM"))
998 if (strEQ(name, "EPROTONOSUPPORT"))
999 #ifdef EPROTONOSUPPORT
1000 return EPROTONOSUPPORT;
1004 if (strEQ(name, "EPROTOTYPE"))
1012 if (strEQ(name, "ERANGE"))
1018 if (strEQ(name, "EREMOTE"))
1024 if (strEQ(name, "ERESTART"))
1030 if (strEQ(name, "EROFS"))
1038 if (strEQ(name, "ESHUTDOWN"))
1044 if (strEQ(name, "ESOCKTNOSUPPORT"))
1045 #ifdef ESOCKTNOSUPPORT
1046 return ESOCKTNOSUPPORT;
1050 if (strEQ(name, "ESPIPE"))
1056 if (strEQ(name, "ESRCH"))
1062 if (strEQ(name, "ESTALE"))
1070 if (strEQ(name, "ETIMEDOUT"))
1076 if (strEQ(name, "ETOOMANYREFS"))
1078 return ETOOMANYREFS;
1082 if (strEQ(name, "ETXTBSY"))
1090 if (strEQ(name, "EUSERS"))
1098 if (strEQ(name, "EWOULDBLOCK"))
1106 if (strEQ(name, "EXIT_FAILURE"))
1108 return EXIT_FAILURE;
1112 if (strEQ(name, "EXIT_SUCCESS"))
1114 return EXIT_SUCCESS;
1118 if (strEQ(name, "EXDEV"))
1126 if (strEQ(name, "E2BIG"))
1134 if (strnEQ(name, "FLT_", 4)) {
1135 if (strEQ(name, "FLT_MAX"))
1141 if (strEQ(name, "FLT_MIN"))
1147 if (strEQ(name, "FLT_ROUNDS"))
1153 if (strEQ(name, "FLT_DIG"))
1159 if (strEQ(name, "FLT_EPSILON"))
1165 if (strEQ(name, "FLT_MANT_DIG"))
1167 return FLT_MANT_DIG;
1171 if (strEQ(name, "FLT_MAX_10_EXP"))
1172 #ifdef FLT_MAX_10_EXP
1173 return FLT_MAX_10_EXP;
1177 if (strEQ(name, "FLT_MAX_EXP"))
1183 if (strEQ(name, "FLT_MIN_10_EXP"))
1184 #ifdef FLT_MIN_10_EXP
1185 return FLT_MIN_10_EXP;
1189 if (strEQ(name, "FLT_MIN_EXP"))
1195 if (strEQ(name, "FLT_RADIX"))
1203 if (strnEQ(name, "F_", 2)) {
1204 if (strEQ(name, "F_DUPFD"))
1210 if (strEQ(name, "F_GETFD"))
1216 if (strEQ(name, "F_GETFL"))
1222 if (strEQ(name, "F_GETLK"))
1228 if (strEQ(name, "F_OK"))
1234 if (strEQ(name, "F_RDLCK"))
1240 if (strEQ(name, "F_SETFD"))
1246 if (strEQ(name, "F_SETFL"))
1252 if (strEQ(name, "F_SETLK"))
1258 if (strEQ(name, "F_SETLKW"))
1264 if (strEQ(name, "F_UNLCK"))
1270 if (strEQ(name, "F_WRLCK"))
1278 if (strEQ(name, "FD_CLOEXEC"))
1284 if (strEQ(name, "FILENAME_MAX"))
1286 return FILENAME_MAX;
1292 if (strEQ(name, "HUGE_VAL"))
1293 #if defined(USE_LONG_DOUBLE) && defined(HUGE_VALL)
1294 /* HUGE_VALL is admittedly non-POSIX but if we are using long doubles
1295 * we might as well use long doubles. --jhi */
1303 if (strEQ(name, "HUPCL"))
1311 if (strEQ(name, "INT_MAX"))
1317 if (strEQ(name, "INT_MIN"))
1323 if (strEQ(name, "ICANON"))
1329 if (strEQ(name, "ICRNL"))
1335 if (strEQ(name, "IEXTEN"))
1341 if (strEQ(name, "IGNBRK"))
1347 if (strEQ(name, "IGNCR"))
1353 if (strEQ(name, "IGNPAR"))
1359 if (strEQ(name, "INLCR"))
1365 if (strEQ(name, "INPCK"))
1371 if (strEQ(name, "ISIG"))
1377 if (strEQ(name, "ISTRIP"))
1383 if (strEQ(name, "IXOFF"))
1389 if (strEQ(name, "IXON"))
1397 if (strnEQ(name, "LC_", 3)) {
1398 if (strEQ(name, "LC_ALL"))
1404 if (strEQ(name, "LC_COLLATE"))
1410 if (strEQ(name, "LC_CTYPE"))
1416 if (strEQ(name, "LC_MONETARY"))
1422 if (strEQ(name, "LC_NUMERIC"))
1428 if (strEQ(name, "LC_TIME"))
1436 if (strnEQ(name, "LDBL_", 5)) {
1437 if (strEQ(name, "LDBL_MAX"))
1443 if (strEQ(name, "LDBL_MIN"))
1449 if (strEQ(name, "LDBL_DIG"))
1455 if (strEQ(name, "LDBL_EPSILON"))
1457 return LDBL_EPSILON;
1461 if (strEQ(name, "LDBL_MANT_DIG"))
1462 #ifdef LDBL_MANT_DIG
1463 return LDBL_MANT_DIG;
1467 if (strEQ(name, "LDBL_MAX_10_EXP"))
1468 #ifdef LDBL_MAX_10_EXP
1469 return LDBL_MAX_10_EXP;
1473 if (strEQ(name, "LDBL_MAX_EXP"))
1475 return LDBL_MAX_EXP;
1479 if (strEQ(name, "LDBL_MIN_10_EXP"))
1480 #ifdef LDBL_MIN_10_EXP
1481 return LDBL_MIN_10_EXP;
1485 if (strEQ(name, "LDBL_MIN_EXP"))
1487 return LDBL_MIN_EXP;
1493 if (strnEQ(name, "L_", 2)) {
1494 if (strEQ(name, "L_ctermid"))
1500 if (strEQ(name, "L_cuserid"))
1506 /* L_tmpnam[e] was a typo--retained for compatibility */
1507 if (strEQ(name, "L_tmpname") || strEQ(name, "L_tmpnam"))
1515 if (strEQ(name, "LONG_MAX"))
1521 if (strEQ(name, "LONG_MIN"))
1527 if (strEQ(name, "LINK_MAX"))
1535 if (strEQ(name, "MAX_CANON"))
1541 if (strEQ(name, "MAX_INPUT"))
1547 if (strEQ(name, "MB_CUR_MAX"))
1553 if (strEQ(name, "MB_LEN_MAX"))
1561 if (strEQ(name, "NULL")) return 0;
1562 if (strEQ(name, "NAME_MAX"))
1568 if (strEQ(name, "NCCS"))
1574 if (strEQ(name, "NGROUPS_MAX"))
1580 if (strEQ(name, "NOFLSH"))
1588 if (strnEQ(name, "O_", 2)) {
1589 if (strEQ(name, "O_APPEND"))
1595 if (strEQ(name, "O_CREAT"))
1601 if (strEQ(name, "O_TRUNC"))
1607 if (strEQ(name, "O_RDONLY"))
1613 if (strEQ(name, "O_RDWR"))
1619 if (strEQ(name, "O_WRONLY"))
1625 if (strEQ(name, "O_EXCL"))
1631 if (strEQ(name, "O_NOCTTY"))
1637 if (strEQ(name, "O_NONBLOCK"))
1643 if (strEQ(name, "O_ACCMODE"))
1651 if (strEQ(name, "OPEN_MAX"))
1657 if (strEQ(name, "OPOST"))
1665 if (strEQ(name, "PATH_MAX"))
1671 if (strEQ(name, "PARENB"))
1677 if (strEQ(name, "PARMRK"))
1683 if (strEQ(name, "PARODD"))
1689 if (strEQ(name, "PIPE_BUF"))
1697 if (strEQ(name, "RAND_MAX"))
1703 if (strEQ(name, "R_OK"))
1711 if (strnEQ(name, "SIG", 3)) {
1712 if (name[3] == '_') {
1713 if (strEQ(name, "SIG_BLOCK"))
1720 if (strEQ(name, "SIG_DFL")) return (IV)SIG_DFL;
1723 if (strEQ(name, "SIG_ERR")) return (IV)SIG_ERR;
1726 if (strEQ(name, "SIG_IGN")) return (IV)SIG_IGN;
1728 if (strEQ(name, "SIG_SETMASK"))
1734 if (strEQ(name, "SIG_UNBLOCK"))
1742 if (strEQ(name, "SIGABRT"))
1748 if (strEQ(name, "SIGALRM"))
1754 if (strEQ(name, "SIGCHLD"))
1760 if (strEQ(name, "SIGCONT"))
1766 if (strEQ(name, "SIGFPE"))
1772 if (strEQ(name, "SIGHUP"))
1778 if (strEQ(name, "SIGILL"))
1784 if (strEQ(name, "SIGINT"))
1790 if (strEQ(name, "SIGKILL"))
1796 if (strEQ(name, "SIGPIPE"))
1802 if (strEQ(name, "SIGQUIT"))
1808 if (strEQ(name, "SIGSEGV"))
1814 if (strEQ(name, "SIGSTOP"))
1820 if (strEQ(name, "SIGTERM"))
1826 if (strEQ(name, "SIGTSTP"))
1832 if (strEQ(name, "SIGTTIN"))
1838 if (strEQ(name, "SIGTTOU"))
1844 if (strEQ(name, "SIGUSR1"))
1850 if (strEQ(name, "SIGUSR2"))
1858 if (name[1] == '_') {
1859 if (strEQ(name, "S_ISGID"))
1865 if (strEQ(name, "S_ISUID"))
1871 if (strEQ(name, "S_IRGRP"))
1877 if (strEQ(name, "S_IROTH"))
1883 if (strEQ(name, "S_IRUSR"))
1889 if (strEQ(name, "S_IRWXG"))
1895 if (strEQ(name, "S_IRWXO"))
1901 if (strEQ(name, "S_IRWXU"))
1907 if (strEQ(name, "S_IWGRP"))
1913 if (strEQ(name, "S_IWOTH"))
1919 if (strEQ(name, "S_IWUSR"))
1925 if (strEQ(name, "S_IXGRP"))
1931 if (strEQ(name, "S_IXOTH"))
1937 if (strEQ(name, "S_IXUSR"))
1943 errno = EAGAIN; /* the following aren't constants */
1945 if (strEQ(name, "S_ISBLK")) return S_ISBLK(arg);
1948 if (strEQ(name, "S_ISCHR")) return S_ISCHR(arg);
1951 if (strEQ(name, "S_ISDIR")) return S_ISDIR(arg);
1954 if (strEQ(name, "S_ISFIFO")) return S_ISFIFO(arg);
1957 if (strEQ(name, "S_ISREG")) return S_ISREG(arg);
1961 if (strEQ(name, "SEEK_CUR"))
1967 if (strEQ(name, "SEEK_END"))
1973 if (strEQ(name, "SEEK_SET"))
1979 if (strEQ(name, "STREAM_MAX"))
1985 if (strEQ(name, "SHRT_MAX"))
1991 if (strEQ(name, "SHRT_MIN"))
1997 if (strnEQ(name, "SA_", 3)) {
1998 if (strEQ(name, "SA_NOCLDSTOP"))
2000 return SA_NOCLDSTOP;
2004 if (strEQ(name, "SA_NOCLDWAIT"))
2006 return SA_NOCLDWAIT;
2010 if (strEQ(name, "SA_NODEFER"))
2016 if (strEQ(name, "SA_ONSTACK"))
2022 if (strEQ(name, "SA_RESETHAND"))
2024 return SA_RESETHAND;
2028 if (strEQ(name, "SA_RESTART"))
2034 if (strEQ(name, "SA_SIGINFO"))
2042 if (strEQ(name, "SCHAR_MAX"))
2048 if (strEQ(name, "SCHAR_MIN"))
2054 if (strEQ(name, "SSIZE_MAX"))
2060 if (strEQ(name, "STDIN_FILENO"))
2062 return STDIN_FILENO;
2066 if (strEQ(name, "STDOUT_FILENO"))
2067 #ifdef STDOUT_FILENO
2068 return STDOUT_FILENO;
2072 if (strEQ(name, "STDERR_FILENO"))
2073 #ifdef STDERR_FILENO
2074 return STDERR_FILENO;
2080 if (strEQ(name, "TCIFLUSH"))
2086 if (strEQ(name, "TCIOFF"))
2092 if (strEQ(name, "TCIOFLUSH"))
2098 if (strEQ(name, "TCION"))
2104 if (strEQ(name, "TCOFLUSH"))
2110 if (strEQ(name, "TCOOFF"))
2116 if (strEQ(name, "TCOON"))
2122 if (strEQ(name, "TCSADRAIN"))
2128 if (strEQ(name, "TCSAFLUSH"))
2134 if (strEQ(name, "TCSANOW"))
2140 if (strEQ(name, "TMP_MAX"))
2146 if (strEQ(name, "TOSTOP"))
2152 if (strEQ(name, "TZNAME_MAX"))
2160 if (strEQ(name, "UCHAR_MAX"))
2166 if (strEQ(name, "UINT_MAX"))
2172 if (strEQ(name, "ULONG_MAX"))
2178 if (strEQ(name, "USHRT_MAX"))
2186 if (strEQ(name, "VEOF"))
2192 if (strEQ(name, "VEOL"))
2198 if (strEQ(name, "VERASE"))
2204 if (strEQ(name, "VINTR"))
2210 if (strEQ(name, "VKILL"))
2216 if (strEQ(name, "VMIN"))
2222 if (strEQ(name, "VQUIT"))
2228 if (strEQ(name, "VSTART"))
2234 if (strEQ(name, "VSTOP"))
2240 if (strEQ(name, "VSUSP"))
2246 if (strEQ(name, "VTIME"))
2254 if (strEQ(name, "W_OK"))
2260 if (strEQ(name, "WNOHANG"))
2266 if (strEQ(name, "WUNTRACED"))
2272 errno = EAGAIN; /* the following aren't constants */
2274 if (strEQ(name, "WEXITSTATUS")) return WEXITSTATUS(arg);
2277 if (strEQ(name, "WIFEXITED")) return WIFEXITED(arg);
2280 if (strEQ(name, "WIFSIGNALED")) return WIFSIGNALED(arg);
2283 if (strEQ(name, "WIFSTOPPED")) return WIFSTOPPED(arg);
2286 if (strEQ(name, "WSTOPSIG")) return WSTOPSIG(arg);
2289 if (strEQ(name, "WTERMSIG")) return WTERMSIG(arg);
2293 if (strEQ(name, "X_OK"))
2301 if (strnEQ(name, "_PC_", 4)) {
2302 if (strEQ(name, "_PC_CHOWN_RESTRICTED"))
2303 #if defined(_PC_CHOWN_RESTRICTED) || HINT_SC_EXIST
2304 return _PC_CHOWN_RESTRICTED;
2308 if (strEQ(name, "_PC_LINK_MAX"))
2309 #if defined(_PC_LINK_MAX) || HINT_SC_EXIST
2310 return _PC_LINK_MAX;
2314 if (strEQ(name, "_PC_MAX_CANON"))
2315 #if defined(_PC_MAX_CANON) || HINT_SC_EXIST
2316 return _PC_MAX_CANON;
2320 if (strEQ(name, "_PC_MAX_INPUT"))
2321 #if defined(_PC_MAX_INPUT) || HINT_SC_EXIST
2322 return _PC_MAX_INPUT;
2326 if (strEQ(name, "_PC_NAME_MAX"))
2327 #if defined(_PC_NAME_MAX) || HINT_SC_EXIST
2328 return _PC_NAME_MAX;
2332 if (strEQ(name, "_PC_NO_TRUNC"))
2333 #if defined(_PC_NO_TRUNC) || HINT_SC_EXIST
2334 return _PC_NO_TRUNC;
2338 if (strEQ(name, "_PC_PATH_MAX"))
2339 #if defined(_PC_PATH_MAX) || HINT_SC_EXIST
2340 return _PC_PATH_MAX;
2344 if (strEQ(name, "_PC_PIPE_BUF"))
2345 #if defined(_PC_PIPE_BUF) || HINT_SC_EXIST
2346 return _PC_PIPE_BUF;
2350 if (strEQ(name, "_PC_VDISABLE"))
2351 #if defined(_PC_VDISABLE) || HINT_SC_EXIST
2352 return _PC_VDISABLE;
2358 if (strnEQ(name, "_POSIX_", 7)) {
2359 if (strEQ(name, "_POSIX_ARG_MAX"))
2360 #ifdef _POSIX_ARG_MAX
2361 return _POSIX_ARG_MAX;
2365 if (strEQ(name, "_POSIX_CHILD_MAX"))
2366 #ifdef _POSIX_CHILD_MAX
2367 return _POSIX_CHILD_MAX;
2371 if (strEQ(name, "_POSIX_CHOWN_RESTRICTED"))
2372 #ifdef _POSIX_CHOWN_RESTRICTED
2373 return _POSIX_CHOWN_RESTRICTED;
2377 if (strEQ(name, "_POSIX_JOB_CONTROL"))
2378 #ifdef _POSIX_JOB_CONTROL
2379 return _POSIX_JOB_CONTROL;
2383 if (strEQ(name, "_POSIX_LINK_MAX"))
2384 #ifdef _POSIX_LINK_MAX
2385 return _POSIX_LINK_MAX;
2389 if (strEQ(name, "_POSIX_MAX_CANON"))
2390 #ifdef _POSIX_MAX_CANON
2391 return _POSIX_MAX_CANON;
2395 if (strEQ(name, "_POSIX_MAX_INPUT"))
2396 #ifdef _POSIX_MAX_INPUT
2397 return _POSIX_MAX_INPUT;
2401 if (strEQ(name, "_POSIX_NAME_MAX"))
2402 #ifdef _POSIX_NAME_MAX
2403 return _POSIX_NAME_MAX;
2407 if (strEQ(name, "_POSIX_NGROUPS_MAX"))
2408 #ifdef _POSIX_NGROUPS_MAX
2409 return _POSIX_NGROUPS_MAX;
2413 if (strEQ(name, "_POSIX_NO_TRUNC"))
2414 #ifdef _POSIX_NO_TRUNC
2415 return _POSIX_NO_TRUNC;
2419 if (strEQ(name, "_POSIX_OPEN_MAX"))
2420 #ifdef _POSIX_OPEN_MAX
2421 return _POSIX_OPEN_MAX;
2425 if (strEQ(name, "_POSIX_PATH_MAX"))
2426 #ifdef _POSIX_PATH_MAX
2427 return _POSIX_PATH_MAX;
2431 if (strEQ(name, "_POSIX_PIPE_BUF"))
2432 #ifdef _POSIX_PIPE_BUF
2433 return _POSIX_PIPE_BUF;
2437 if (strEQ(name, "_POSIX_SAVED_IDS"))
2438 #ifdef _POSIX_SAVED_IDS
2439 return _POSIX_SAVED_IDS;
2443 if (strEQ(name, "_POSIX_SSIZE_MAX"))
2444 #ifdef _POSIX_SSIZE_MAX
2445 return _POSIX_SSIZE_MAX;
2449 if (strEQ(name, "_POSIX_STREAM_MAX"))
2450 #ifdef _POSIX_STREAM_MAX
2451 return _POSIX_STREAM_MAX;
2455 if (strEQ(name, "_POSIX_TZNAME_MAX"))
2456 #ifdef _POSIX_TZNAME_MAX
2457 return _POSIX_TZNAME_MAX;
2461 if (strEQ(name, "_POSIX_VDISABLE"))
2462 #ifdef _POSIX_VDISABLE
2463 return _POSIX_VDISABLE;
2467 if (strEQ(name, "_POSIX_VERSION"))
2468 #ifdef _POSIX_VERSION
2469 return _POSIX_VERSION;
2475 if (strnEQ(name, "_SC_", 4)) {
2476 if (strEQ(name, "_SC_ARG_MAX"))
2477 #if defined(_SC_ARG_MAX) || HINT_SC_EXIST
2482 if (strEQ(name, "_SC_CHILD_MAX"))
2483 #if defined(_SC_CHILD_MAX) || HINT_SC_EXIST
2484 return _SC_CHILD_MAX;
2488 if (strEQ(name, "_SC_CLK_TCK"))
2489 #if defined(_SC_CLK_TCK) || HINT_SC_EXIST
2494 if (strEQ(name, "_SC_JOB_CONTROL"))
2495 #if defined(_SC_JOB_CONTROL) || HINT_SC_EXIST
2496 return _SC_JOB_CONTROL;
2500 if (strEQ(name, "_SC_NGROUPS_MAX"))
2501 #if defined(_SC_NGROUPS_MAX) || HINT_SC_EXIST
2502 return _SC_NGROUPS_MAX;
2506 if (strEQ(name, "_SC_OPEN_MAX"))
2507 #if defined(_SC_OPEN_MAX) || HINT_SC_EXIST
2508 return _SC_OPEN_MAX;
2512 if (strEQ(name, "_SC_SAVED_IDS"))
2513 #if defined(_SC_SAVED_IDS) || HINT_SC_EXIST
2514 return _SC_SAVED_IDS;
2518 if (strEQ(name, "_SC_STREAM_MAX"))
2519 #if defined(_SC_STREAM_MAX) || HINT_SC_EXIST
2520 return _SC_STREAM_MAX;
2524 if (strEQ(name, "_SC_TZNAME_MAX"))
2525 #if defined(_SC_TZNAME_MAX) || HINT_SC_EXIST
2526 return _SC_TZNAME_MAX;
2530 if (strEQ(name, "_SC_VERSION"))
2531 #if defined(_SC_VERSION) || HINT_SC_EXIST
2548 restore_sigmask(sigset_t *ossetp)
2550 /* Fortunately, restoring the signal mask can't fail, because
2551 * there's nothing we can do about it if it does -- we're not
2552 * supposed to return -1 from sigaction unless the disposition
2555 (void)sigprocmask(SIG_SETMASK, ossetp, (sigset_t *)0);
2558 MODULE = SigSet PACKAGE = POSIX::SigSet PREFIX = sig
2561 new(packname = "POSIX::SigSet", ...)
2566 New(0, RETVAL, 1, sigset_t);
2567 sigemptyset(RETVAL);
2568 for (i = 1; i < items; i++)
2569 sigaddset(RETVAL, SvIV(ST(i)));
2576 POSIX::SigSet sigset
2581 sigaddset(sigset, sig)
2582 POSIX::SigSet sigset
2586 sigdelset(sigset, sig)
2587 POSIX::SigSet sigset
2592 POSIX::SigSet sigset
2596 POSIX::SigSet sigset
2599 sigismember(sigset, sig)
2600 POSIX::SigSet sigset
2604 MODULE = Termios PACKAGE = POSIX::Termios PREFIX = cf
2607 new(packname = "POSIX::Termios", ...)
2612 New(0, RETVAL, 1, struct termios);
2614 not_here("termios");
2622 DESTROY(termios_ref)
2623 POSIX::Termios termios_ref
2626 Safefree(termios_ref);
2628 not_here("termios");
2632 getattr(termios_ref, fd = 0)
2633 POSIX::Termios termios_ref
2636 RETVAL = tcgetattr(fd, termios_ref);
2641 setattr(termios_ref, fd = 0, optional_actions = 0)
2642 POSIX::Termios termios_ref
2644 int optional_actions
2646 RETVAL = tcsetattr(fd, optional_actions, termios_ref);
2651 cfgetispeed(termios_ref)
2652 POSIX::Termios termios_ref
2655 cfgetospeed(termios_ref)
2656 POSIX::Termios termios_ref
2659 getiflag(termios_ref)
2660 POSIX::Termios termios_ref
2662 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2663 RETVAL = termios_ref->c_iflag;
2665 not_here("getiflag");
2672 getoflag(termios_ref)
2673 POSIX::Termios termios_ref
2675 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2676 RETVAL = termios_ref->c_oflag;
2678 not_here("getoflag");
2685 getcflag(termios_ref)
2686 POSIX::Termios termios_ref
2688 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2689 RETVAL = termios_ref->c_cflag;
2691 not_here("getcflag");
2698 getlflag(termios_ref)
2699 POSIX::Termios termios_ref
2701 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2702 RETVAL = termios_ref->c_lflag;
2704 not_here("getlflag");
2711 getcc(termios_ref, ccix)
2712 POSIX::Termios termios_ref
2715 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2717 croak("Bad getcc subscript");
2718 RETVAL = termios_ref->c_cc[ccix];
2727 cfsetispeed(termios_ref, speed)
2728 POSIX::Termios termios_ref
2732 cfsetospeed(termios_ref, speed)
2733 POSIX::Termios termios_ref
2737 setiflag(termios_ref, iflag)
2738 POSIX::Termios termios_ref
2741 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2742 termios_ref->c_iflag = iflag;
2744 not_here("setiflag");
2748 setoflag(termios_ref, oflag)
2749 POSIX::Termios termios_ref
2752 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2753 termios_ref->c_oflag = oflag;
2755 not_here("setoflag");
2759 setcflag(termios_ref, cflag)
2760 POSIX::Termios termios_ref
2763 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2764 termios_ref->c_cflag = cflag;
2766 not_here("setcflag");
2770 setlflag(termios_ref, lflag)
2771 POSIX::Termios termios_ref
2774 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2775 termios_ref->c_lflag = lflag;
2777 not_here("setlflag");
2781 setcc(termios_ref, ccix, cc)
2782 POSIX::Termios termios_ref
2786 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2788 croak("Bad setcc subscript");
2789 termios_ref->c_cc[ccix] = cc;
2795 MODULE = POSIX PACKAGE = POSIX
2804 unsigned char * charstring
2806 unsigned char *s = charstring;
2807 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2808 for (RETVAL = 1; RETVAL && s < e; s++)
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++)
2923 isxdigit(charstring)
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 open(filename, flags = O_RDONLY, mode = 0666)
2940 if (flags & (O_APPEND|O_CREAT|O_TRUNC|O_RDWR|O_WRONLY|O_EXCL))
2941 TAINT_PROPER("open");
2942 RETVAL = open(filename, flags, mode);
2950 #ifdef HAS_LOCALECONV
2951 struct lconv *lcbuf;
2953 if ((lcbuf = localeconv())) {
2955 if (lcbuf->decimal_point && *lcbuf->decimal_point)
2956 hv_store(RETVAL, "decimal_point", 13,
2957 newSVpv(lcbuf->decimal_point, 0), 0);
2958 if (lcbuf->thousands_sep && *lcbuf->thousands_sep)
2959 hv_store(RETVAL, "thousands_sep", 13,
2960 newSVpv(lcbuf->thousands_sep, 0), 0);
2961 #ifndef NO_LOCALECONV_GROUPING
2962 if (lcbuf->grouping && *lcbuf->grouping)
2963 hv_store(RETVAL, "grouping", 8,
2964 newSVpv(lcbuf->grouping, 0), 0);
2966 if (lcbuf->int_curr_symbol && *lcbuf->int_curr_symbol)
2967 hv_store(RETVAL, "int_curr_symbol", 15,
2968 newSVpv(lcbuf->int_curr_symbol, 0), 0);
2969 if (lcbuf->currency_symbol && *lcbuf->currency_symbol)
2970 hv_store(RETVAL, "currency_symbol", 15,
2971 newSVpv(lcbuf->currency_symbol, 0), 0);
2972 if (lcbuf->mon_decimal_point && *lcbuf->mon_decimal_point)
2973 hv_store(RETVAL, "mon_decimal_point", 17,
2974 newSVpv(lcbuf->mon_decimal_point, 0), 0);
2975 #ifndef NO_LOCALECONV_MON_THOUSANDS_SEP
2976 if (lcbuf->mon_thousands_sep && *lcbuf->mon_thousands_sep)
2977 hv_store(RETVAL, "mon_thousands_sep", 17,
2978 newSVpv(lcbuf->mon_thousands_sep, 0), 0);
2980 #ifndef NO_LOCALECONV_MON_GROUPING
2981 if (lcbuf->mon_grouping && *lcbuf->mon_grouping)
2982 hv_store(RETVAL, "mon_grouping", 12,
2983 newSVpv(lcbuf->mon_grouping, 0), 0);
2985 if (lcbuf->positive_sign && *lcbuf->positive_sign)
2986 hv_store(RETVAL, "positive_sign", 13,
2987 newSVpv(lcbuf->positive_sign, 0), 0);
2988 if (lcbuf->negative_sign && *lcbuf->negative_sign)
2989 hv_store(RETVAL, "negative_sign", 13,
2990 newSVpv(lcbuf->negative_sign, 0), 0);
2992 if (lcbuf->int_frac_digits != CHAR_MAX)
2993 hv_store(RETVAL, "int_frac_digits", 15,
2994 newSViv(lcbuf->int_frac_digits), 0);
2995 if (lcbuf->frac_digits != CHAR_MAX)
2996 hv_store(RETVAL, "frac_digits", 11,
2997 newSViv(lcbuf->frac_digits), 0);
2998 if (lcbuf->p_cs_precedes != CHAR_MAX)
2999 hv_store(RETVAL, "p_cs_precedes", 13,
3000 newSViv(lcbuf->p_cs_precedes), 0);
3001 if (lcbuf->p_sep_by_space != CHAR_MAX)
3002 hv_store(RETVAL, "p_sep_by_space", 14,
3003 newSViv(lcbuf->p_sep_by_space), 0);
3004 if (lcbuf->n_cs_precedes != CHAR_MAX)
3005 hv_store(RETVAL, "n_cs_precedes", 13,
3006 newSViv(lcbuf->n_cs_precedes), 0);
3007 if (lcbuf->n_sep_by_space != CHAR_MAX)
3008 hv_store(RETVAL, "n_sep_by_space", 14,
3009 newSViv(lcbuf->n_sep_by_space), 0);
3010 if (lcbuf->p_sign_posn != CHAR_MAX)
3011 hv_store(RETVAL, "p_sign_posn", 11,
3012 newSViv(lcbuf->p_sign_posn), 0);
3013 if (lcbuf->n_sign_posn != CHAR_MAX)
3014 hv_store(RETVAL, "n_sign_posn", 11,
3015 newSViv(lcbuf->n_sign_posn), 0);
3018 localeconv(); /* A stub to call not_here(). */
3024 setlocale(category, locale = 0)
3028 RETVAL = setlocale(category, locale);
3030 #ifdef USE_LOCALE_CTYPE
3031 if (category == LC_CTYPE
3033 || category == LC_ALL
3039 if (category == LC_ALL)
3040 newctype = setlocale(LC_CTYPE, NULL);
3044 new_ctype(newctype);
3046 #endif /* USE_LOCALE_CTYPE */
3047 #ifdef USE_LOCALE_COLLATE
3048 if (category == LC_COLLATE
3050 || category == LC_ALL
3056 if (category == LC_ALL)
3057 newcoll = setlocale(LC_COLLATE, NULL);
3061 new_collate(newcoll);
3063 #endif /* USE_LOCALE_COLLATE */
3064 #ifdef USE_LOCALE_NUMERIC
3065 if (category == LC_NUMERIC
3067 || category == LC_ALL
3073 if (category == LC_ALL)
3074 newnum = setlocale(LC_NUMERIC, NULL);
3078 new_numeric(newnum);
3080 #endif /* USE_LOCALE_NUMERIC */
3120 /* (We already know stack is long enough.) */
3121 PUSHs(sv_2mortal(newSVnv(frexp(x,&expvar))));
3122 PUSHs(sv_2mortal(newSViv(expvar)));
3138 /* (We already know stack is long enough.) */
3139 PUSHs(sv_2mortal(newSVnv(Perl_modf(x,&intvar))));
3140 PUSHs(sv_2mortal(newSVnv(intvar)));
3155 sigaction(sig, optaction, oldaction = 0)
3158 POSIX::SigAction oldaction
3161 RETVAL = not_here("sigaction");
3163 # This code is really grody because we're trying to make the signal
3164 # interface look beautiful, which is hard.
3167 POSIX__SigAction action;
3168 GV *siggv = gv_fetchpv("SIG", TRUE, SVt_PVHV);
3169 struct sigaction act;
3170 struct sigaction oact;
3173 POSIX__SigSet sigset;
3175 SV** sigsvp = hv_fetch(GvHVn(siggv),
3177 strlen(PL_sig_name[sig]),
3181 /* Check optaction and set action */
3182 if(SvTRUE(optaction)) {
3183 if(sv_isa(optaction, "POSIX::SigAction"))
3184 action = (HV*)SvRV(optaction);
3186 croak("action is not of type POSIX::SigAction");
3192 /* sigaction() is supposed to look atomic. In particular, any
3193 * signal handler invoked during a sigaction() call should
3194 * see either the old or the new disposition, and not something
3195 * in between. We use sigprocmask() to make it so.
3198 RETVAL=sigprocmask(SIG_BLOCK, &sset, &osset);
3202 /* Restore signal mask no matter how we exit this block. */
3203 SAVEDESTRUCTOR(restore_sigmask, &osset);
3205 RETVAL=-1; /* In case both oldaction and action are 0. */
3207 /* Remember old disposition if desired. */
3209 svp = hv_fetch(oldaction, "HANDLER", 7, TRUE);
3211 croak("Can't supply an oldaction without a HANDLER");
3212 if(SvTRUE(*sigsvp)) { /* TBD: what if "0"? */
3213 sv_setsv(*svp, *sigsvp);
3216 sv_setpv(*svp, "DEFAULT");
3218 RETVAL = sigaction(sig, (struct sigaction *)0, & oact);
3221 /* Get back the mask. */
3222 svp = hv_fetch(oldaction, "MASK", 4, TRUE);
3223 if (sv_isa(*svp, "POSIX::SigSet")) {
3224 IV tmp = SvIV((SV*)SvRV(*svp));
3225 sigset = INT2PTR(sigset_t*, tmp);
3228 New(0, sigset, 1, sigset_t);
3229 sv_setptrobj(*svp, sigset, "POSIX::SigSet");
3231 *sigset = oact.sa_mask;
3233 /* Get back the flags. */
3234 svp = hv_fetch(oldaction, "FLAGS", 5, TRUE);
3235 sv_setiv(*svp, oact.sa_flags);
3239 /* Vector new handler through %SIG. (We always use sighandler
3240 for the C signal handler, which reads %SIG to dispatch.) */
3241 svp = hv_fetch(action, "HANDLER", 7, FALSE);
3243 croak("Can't supply an action without a HANDLER");
3244 sv_setsv(*sigsvp, *svp);
3245 mg_set(*sigsvp); /* handles DEFAULT and IGNORE */
3247 char *s=SvPVX(*svp);
3248 if(strEQ(s,"IGNORE")) {
3249 act.sa_handler = SIG_IGN;
3251 else if(strEQ(s,"DEFAULT")) {
3252 act.sa_handler = SIG_DFL;
3255 act.sa_handler = PL_sighandlerp;
3259 act.sa_handler = PL_sighandlerp;
3262 /* Set up any desired mask. */
3263 svp = hv_fetch(action, "MASK", 4, FALSE);
3264 if (svp && sv_isa(*svp, "POSIX::SigSet")) {
3265 IV tmp = SvIV((SV*)SvRV(*svp));
3266 sigset = INT2PTR(sigset_t*, tmp);
3267 act.sa_mask = *sigset;
3270 sigemptyset(& act.sa_mask);
3272 /* Set up any desired flags. */
3273 svp = hv_fetch(action, "FLAGS", 5, FALSE);
3274 act.sa_flags = svp ? SvIV(*svp) : 0;
3276 /* Don't worry about cleaning up *sigsvp if this fails,
3277 * because that means we tried to disposition a
3278 * nonblockable signal, in which case *sigsvp is
3279 * essentially meaningless anyway.
3281 RETVAL = sigaction(sig, & act, (struct sigaction *)0);
3292 POSIX::SigSet sigset
3295 sigprocmask(how, sigset, oldsigset = 0)
3297 POSIX::SigSet sigset
3298 POSIX::SigSet oldsigset = NO_INIT
3303 else if (sv_derived_from(ST(2), "POSIX::SigSet")) {
3304 IV tmp = SvIV((SV*)SvRV(ST(2)));
3305 oldsigset = INT2PTR(POSIX__SigSet,tmp);
3308 New(0, oldsigset, 1, sigset_t);
3309 sigemptyset(oldsigset);
3310 sv_setref_pv(ST(2), "POSIX::SigSet", (void*)oldsigset);
3314 sigsuspend(signal_mask)
3315 POSIX::SigSet signal_mask
3335 lseek(fd, offset, whence)
3348 if (pipe(fds) != -1) {
3350 PUSHs(sv_2mortal(newSViv(fds[0])));
3351 PUSHs(sv_2mortal(newSViv(fds[1])));
3355 read(fd, buffer, nbytes)
3357 SV *sv_buffer = SvROK(ST(1)) ? SvRV(ST(1)) : ST(1);
3361 char * buffer = sv_grow( sv_buffer, nbytes+1 );
3364 SvCUR(sv_buffer) = RETVAL;
3365 SvPOK_only(sv_buffer);
3366 *SvEND(sv_buffer) = '\0';
3367 SvTAINTED_on(sv_buffer);
3383 tcsetpgrp(fd, pgrp_id)
3392 if (uname(&buf) >= 0) {
3394 PUSHs(sv_2mortal(newSVpv(buf.sysname, 0)));
3395 PUSHs(sv_2mortal(newSVpv(buf.nodename, 0)));
3396 PUSHs(sv_2mortal(newSVpv(buf.release, 0)));
3397 PUSHs(sv_2mortal(newSVpv(buf.version, 0)));
3398 PUSHs(sv_2mortal(newSVpv(buf.machine, 0)));
3401 uname((char *) 0); /* A stub to call not_here(). */
3405 write(fd, buffer, nbytes)
3416 RETVAL = newSVpvn("", 0);
3417 SvGROW(RETVAL, L_tmpnam);
3418 len = strlen(tmpnam(SvPV(RETVAL, i)));
3419 SvCUR_set(RETVAL, len);
3432 mbstowcs(s, pwcs, n)
3444 wcstombs(s, pwcs, n)
3466 SET_NUMERIC_LOCAL();
3467 num = strtod(str, &unparsed);
3468 PUSHs(sv_2mortal(newSVnv(num)));
3469 if (GIMME == G_ARRAY) {
3472 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3474 PUSHs(&PL_sv_undef);
3478 strtol(str, base = 0)
3485 num = strtol(str, &unparsed, base);
3486 #if IVSIZE <= LONGSIZE
3487 if (num < IV_MIN || num > IV_MAX)
3488 PUSHs(sv_2mortal(newSVnv((double)num)));
3491 PUSHs(sv_2mortal(newSViv((IV)num)));
3492 if (GIMME == G_ARRAY) {
3495 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3497 PUSHs(&PL_sv_undef);
3501 strtoul(str, base = 0)
3508 num = strtoul(str, &unparsed, base);
3510 PUSHs(sv_2mortal(newSViv((IV)num)));
3512 PUSHs(sv_2mortal(newSVnv((double)num)));
3513 if (GIMME == G_ARRAY) {
3516 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3518 PUSHs(&PL_sv_undef);
3528 char *p = SvPV(src,srclen);
3530 ST(0) = sv_2mortal(NEWSV(800,srclen));
3531 dstlen = strxfrm(SvPVX(ST(0)), p, (size_t)srclen);
3532 if (dstlen > srclen) {
3534 SvGROW(ST(0), dstlen);
3535 strxfrm(SvPVX(ST(0)), p, (size_t)dstlen);
3538 SvCUR(ST(0)) = dstlen;
3543 mkfifo(filename, mode)
3547 TAINT_PROPER("mkfifo");
3548 RETVAL = mkfifo(filename, mode);
3564 tcflush(fd, queue_selector)
3569 tcsendbreak(fd, duration)
3574 asctime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3587 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3590 mytm.tm_hour = hour;
3591 mytm.tm_mday = mday;
3593 mytm.tm_year = year;
3594 mytm.tm_wday = wday;
3595 mytm.tm_yday = yday;
3596 mytm.tm_isdst = isdst;
3597 RETVAL = asctime(&mytm);
3614 realtime = times( &tms );
3616 PUSHs( sv_2mortal( newSViv( (IV) realtime ) ) );
3617 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_utime ) ) );
3618 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_stime ) ) );
3619 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cutime ) ) );
3620 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cstime ) ) );
3623 difftime(time1, time2)
3628 mktime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3641 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3644 mytm.tm_hour = hour;
3645 mytm.tm_mday = mday;
3647 mytm.tm_year = year;
3648 mytm.tm_wday = wday;
3649 mytm.tm_yday = yday;
3650 mytm.tm_isdst = isdst;
3651 RETVAL = mktime(&mytm);
3656 #XXX: if $xsubpp::WantOptimize is always the default
3657 # sv_setpv(TARG, ...) could be used rather than
3658 # ST(0) = sv_2mortal(newSVpv(...))
3660 strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1)
3673 char *buf = my_strftime(fmt, sec, min, hour, mday, mon, year, wday, yday, isdst);
3675 ST(0) = sv_2mortal(newSVpv(buf, 0));
3687 PUSHs(sv_2mortal(newSVpvn(tzname[0],strlen(tzname[0]))));
3688 PUSHs(sv_2mortal(newSVpvn(tzname[1],strlen(tzname[1]))));
3691 access(filename, mode)
3709 pathconf(filename, name)
3740 New(0, buf, buflen, char);
3741 /* Many getcwd()s know how to automatically allocate memory
3742 * for the directory if the buffer argument is NULL but...
3743 * (1) we cannot assume all getcwd()s do that
3744 * (2) this may interfere with Perl's malloc
3745 * So let's not. --jhi */
3746 while ((getcwd(buf, buflen) == NULL) && errno == ERANGE) {
3748 if (buflen > MAXPATHLEN) {
3753 Renew(buf, buflen, char);
3756 PUSHs(sv_2mortal(newSVpv(buf, 0)));
3760 PUSHs(&PL_sv_undef);
3762 require_pv("Cwd.pm");
3763 /* Module require may have grown the stack */
3767 XSRETURN(call_pv("Cwd::cwd", GIMME_V));