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 #if defined(__VMS) && !defined(__POSIX_SOURCE)
68 # include <libdef.h> /* LIB$_INVARG constant */
69 # include <lib$routines.h> /* prototype for lib$ediv() */
70 # include <starlet.h> /* prototype for sys$gettim() */
71 # if DECC_VERSION < 50000000
72 # define pid_t int /* old versions of DECC miss this in types.h */
76 # define mkfifo(a,b) (not_here("mkfifo"),-1)
77 # define tzset() not_here("tzset")
79 #if ((__VMS_VER >= 70000000) && (__DECC_VER >= 50200000)) || (__CRTL_VER >= 70000000)
80 # define HAS_TZNAME /* shows up in VMS 7.0 or Dec C 5.6 */
82 # endif /* __VMS_VER >= 70000000 or Dec C 5.6 */
84 /* The POSIX notion of ttyname() is better served by getname() under VMS */
85 static char ttnambuf[64];
86 # define ttyname(fd) (isatty(fd) > 0 ? getname(fd,ttnambuf,0) : NULL)
88 /* The non-POSIX CRTL times() has void return type, so we just get the
89 current time directly */
90 clock_t vms_times(struct tms *bufptr) {
93 /* Get wall time and convert to 10 ms intervals to
94 * produce the return value that the POSIX standard expects */
95 # if defined(__DECC) && defined (__ALPHA)
98 _ckvmssts(sys$gettim(&vmstime));
100 retval = vmstime & 0x7fffffff;
102 /* (Older hw or ccs don't have an atomic 64-bit type, so we
103 * juggle 32-bit ints (and a float) to produce a time_t result
104 * with minimal loss of information.) */
105 long int vmstime[2],remainder,divisor = 100000;
106 _ckvmssts(sys$gettim((unsigned long int *)vmstime));
107 vmstime[1] &= 0x7fff; /* prevent overflow in EDIV */
108 _ckvmssts(lib$ediv(&divisor,vmstime,(long int *)&retval,&remainder));
110 /* Fill in the struct tms using the CRTL routine . . .*/
111 times((tbuffer_t *)bufptr);
112 return (clock_t) retval;
114 # define times(t) vms_times(t)
116 #if defined (__CYGWIN__)
117 # define tzname _tzname
121 # define mkfifo(a,b) not_here("mkfifo")
122 # define ttyname(a) (char*)not_here("ttyname")
123 # define sigset_t long
126 # define tzname _tzname
129 # define mode_t short
132 # define mode_t short
134 # define tzset() not_here("tzset")
136 # ifndef _POSIX_OPEN_MAX
137 # define _POSIX_OPEN_MAX FOPEN_MAX /* XXX bogus ? */
140 # define sigaction(a,b,c) not_here("sigaction")
141 # define sigpending(a) not_here("sigpending")
142 # define sigprocmask(a,b,c) not_here("sigprocmask")
143 # define sigsuspend(a) not_here("sigsuspend")
144 # define sigemptyset(a) not_here("sigemptyset")
145 # define sigaddset(a,b) not_here("sigaddset")
146 # define sigdelset(a,b) not_here("sigdelset")
147 # define sigfillset(a) not_here("sigfillset")
148 # define sigismember(a,b) not_here("sigismember")
152 # if defined(OS2) || defined(MACOS_TRADITIONAL)
153 # define mkfifo(a,b) not_here("mkfifo")
154 # else /* !( defined OS2 ) */
156 # define mkfifo(path, mode) (mknod((path), (mode) | S_IFIFO, 0))
159 # endif /* !HAS_MKFIFO */
161 # ifdef MACOS_TRADITIONAL
162 # define ttyname(a) (char*)not_here("ttyname")
163 # define tzset() not_here("tzset")
166 # include <sys/times.h>
168 # include <sys/utsname.h>
170 # include <sys/wait.h>
179 typedef long SysRetLong;
180 typedef sigset_t* POSIX__SigSet;
181 typedef HV* POSIX__SigAction;
183 typedef struct termios* POSIX__Termios;
184 #else /* Define termios types to int, and call not_here for the functions.*/
185 #define POSIX__Termios int
189 #define cfgetispeed(x) not_here("cfgetispeed")
190 #define cfgetospeed(x) not_here("cfgetospeed")
191 #define tcdrain(x) not_here("tcdrain")
192 #define tcflush(x,y) not_here("tcflush")
193 #define tcsendbreak(x,y) not_here("tcsendbreak")
194 #define cfsetispeed(x,y) not_here("cfsetispeed")
195 #define cfsetospeed(x,y) not_here("cfsetospeed")
196 #define ctermid(x) (char *) not_here("ctermid")
197 #define tcflow(x,y) not_here("tcflow")
198 #define tcgetattr(x,y) not_here("tcgetattr")
199 #define tcsetattr(x,y,z) not_here("tcsetattr")
202 /* Possibly needed prototypes */
203 char *cuserid (char *);
204 double strtod (const char *, char **);
205 long strtol (const char *, char **, int);
206 unsigned long strtoul (const char *, char **, int);
209 #define cuserid(a) (char *) not_here("cuserid")
213 #define difftime(a,b) not_here("difftime")
216 #ifndef HAS_FPATHCONF
217 #define fpathconf(f,n) (SysRetLong) not_here("fpathconf")
220 #define mktime(a) not_here("mktime")
223 #define nice(a) not_here("nice")
226 #define pathconf(f,n) (SysRetLong) not_here("pathconf")
229 #define sysconf(n) (SysRetLong) not_here("sysconf")
232 #define readlink(a,b,c) not_here("readlink")
235 #define setpgid(a,b) not_here("setpgid")
238 #define setsid() not_here("setsid")
241 #define strcoll(s1,s2) not_here("strcoll")
244 #define strtod(s1,s2) not_here("strtod")
247 #define strtol(s1,s2,b) not_here("strtol")
250 #define strtoul(s1,s2,b) not_here("strtoul")
253 #define strxfrm(s1,s2,n) not_here("strxfrm")
255 #ifndef HAS_TCGETPGRP
256 #define tcgetpgrp(a) not_here("tcgetpgrp")
258 #ifndef HAS_TCSETPGRP
259 #define tcsetpgrp(a,b) not_here("tcsetpgrp")
262 #define times(a) not_here("times")
265 #define uname(a) not_here("uname")
268 #define waitpid(a,b,c) not_here("waitpid")
273 #define mblen(a,b) not_here("mblen")
277 #define mbstowcs(s, pwcs, n) not_here("mbstowcs")
280 #define mbtowc(pwc, s, n) not_here("mbtowc")
283 #define wcstombs(s, pwcs, n) not_here("wcstombs")
286 #define wctomb(s, wchar) not_here("wcstombs")
288 #if !defined(HAS_MBLEN) && !defined(HAS_MBSTOWCS) && !defined(HAS_MBTOWC) && !defined(HAS_WCSTOMBS) && !defined(HAS_WCTOMB)
289 /* If we don't have these functions, then we wouldn't have gotten a typedef
290 for wchar_t, the wide character type. Defining wchar_t allows the
291 functions referencing it to compile. Its actual type is then meaningless,
292 since without the above functions, all sections using it end up calling
293 not_here() and croak. --Kaveh Ghazi (ghazi@noc.rutgers.edu) 9/18/94. */
299 #ifndef HAS_LOCALECONV
300 #define localeconv() not_here("localeconv")
303 #ifdef HAS_LONG_DOUBLE
304 # if LONG_DOUBLESIZE > NVSIZE
305 # undef HAS_LONG_DOUBLE /* XXX until we figure out how to use them */
309 #ifndef HAS_LONG_DOUBLE
324 croak("POSIX::%s not implemented on this architecture", s);
330 constant(char *name, int arg)
335 if (strEQ(name, "ARG_MAX"))
343 if (strEQ(name, "BUFSIZ"))
349 if (strEQ(name, "BRKINT"))
355 if (strEQ(name, "B9600"))
361 if (strEQ(name, "B19200"))
367 if (strEQ(name, "B38400"))
373 if (strEQ(name, "B0"))
379 if (strEQ(name, "B110"))
385 if (strEQ(name, "B1200"))
391 if (strEQ(name, "B134"))
397 if (strEQ(name, "B150"))
403 if (strEQ(name, "B1800"))
409 if (strEQ(name, "B200"))
415 if (strEQ(name, "B2400"))
421 if (strEQ(name, "B300"))
427 if (strEQ(name, "B4800"))
433 if (strEQ(name, "B50"))
439 if (strEQ(name, "B600"))
445 if (strEQ(name, "B75"))
453 if (strEQ(name, "CHAR_BIT"))
459 if (strEQ(name, "CHAR_MAX"))
465 if (strEQ(name, "CHAR_MIN"))
471 if (strEQ(name, "CHILD_MAX"))
477 if (strEQ(name, "CLK_TCK"))
483 if (strEQ(name, "CLOCAL"))
489 if (strEQ(name, "CLOCKS_PER_SEC"))
490 #ifdef CLOCKS_PER_SEC
491 return CLOCKS_PER_SEC;
495 if (strEQ(name, "CREAD"))
501 if (strEQ(name, "CS5"))
507 if (strEQ(name, "CS6"))
513 if (strEQ(name, "CS7"))
519 if (strEQ(name, "CS8"))
525 if (strEQ(name, "CSIZE"))
531 if (strEQ(name, "CSTOPB"))
539 if (strEQ(name, "DBL_MAX"))
545 if (strEQ(name, "DBL_MIN"))
551 if (strEQ(name, "DBL_DIG"))
557 if (strEQ(name, "DBL_EPSILON"))
563 if (strEQ(name, "DBL_MANT_DIG"))
569 if (strEQ(name, "DBL_MAX_10_EXP"))
570 #ifdef DBL_MAX_10_EXP
571 return DBL_MAX_10_EXP;
575 if (strEQ(name, "DBL_MAX_EXP"))
581 if (strEQ(name, "DBL_MIN_10_EXP"))
582 #ifdef DBL_MIN_10_EXP
583 return DBL_MIN_10_EXP;
587 if (strEQ(name, "DBL_MIN_EXP"))
597 if (strEQ(name, "EACCES"))
603 if (strEQ(name, "EADDRINUSE"))
609 if (strEQ(name, "EADDRNOTAVAIL"))
611 return EADDRNOTAVAIL;
615 if (strEQ(name, "EAFNOSUPPORT"))
621 if (strEQ(name, "EAGAIN"))
627 if (strEQ(name, "EALREADY"))
635 if (strEQ(name, "EBADF"))
641 if (strEQ(name, "EBUSY"))
649 if (strEQ(name, "ECHILD"))
655 if (strEQ(name, "ECHO"))
661 if (strEQ(name, "ECHOE"))
667 if (strEQ(name, "ECHOK"))
673 if (strEQ(name, "ECHONL"))
679 if (strEQ(name, "ECONNABORTED"))
685 if (strEQ(name, "ECONNREFUSED"))
691 if (strEQ(name, "ECONNRESET"))
699 if (strEQ(name, "EDEADLK"))
705 if (strEQ(name, "EDESTADDRREQ"))
711 if (strEQ(name, "EDOM"))
717 if (strEQ(name, "EDQUOT"))
725 if (strEQ(name, "EEXIST"))
733 if (strEQ(name, "EFAULT"))
739 if (strEQ(name, "EFBIG"))
747 if (strEQ(name, "EHOSTDOWN"))
753 if (strEQ(name, "EHOSTUNREACH"))
761 if (strEQ(name, "EINPROGRESS"))
767 if (strEQ(name, "EINTR"))
773 if (strEQ(name, "EINVAL"))
779 if (strEQ(name, "EIO"))
785 if (strEQ(name, "EISCONN"))
791 if (strEQ(name, "EISDIR"))
799 if (strEQ(name, "ELOOP"))
807 if (strEQ(name, "EMFILE"))
813 if (strEQ(name, "EMLINK"))
819 if (strEQ(name, "EMSGSIZE"))
827 if (strEQ(name, "ENETDOWN"))
833 if (strEQ(name, "ENETRESET"))
839 if (strEQ(name, "ENETUNREACH"))
845 if (strEQ(name, "ENOBUFS"))
851 if (strEQ(name, "ENOEXEC"))
857 if (strEQ(name, "ENOMEM"))
863 if (strEQ(name, "ENOPROTOOPT"))
869 if (strEQ(name, "ENOSPC"))
875 if (strEQ(name, "ENOTBLK"))
881 if (strEQ(name, "ENOTCONN"))
887 if (strEQ(name, "ENOTDIR"))
893 if (strEQ(name, "ENOTEMPTY"))
899 if (strEQ(name, "ENOTSOCK"))
905 if (strEQ(name, "ENOTTY"))
911 if (strEQ(name, "ENFILE"))
917 if (strEQ(name, "ENODEV"))
923 if (strEQ(name, "ENOENT"))
929 if (strEQ(name, "ENOLCK"))
935 if (strEQ(name, "ENOSYS"))
941 if (strEQ(name, "ENXIO"))
947 if (strEQ(name, "ENAMETOOLONG"))
955 if (strEQ(name, "EOF"))
961 if (strEQ(name, "EOPNOTSUPP"))
969 if (strEQ(name, "EPERM"))
975 if (strEQ(name, "EPFNOSUPPORT"))
981 if (strEQ(name, "EPIPE"))
987 if (strEQ(name, "EPROCLIM"))
993 if (strEQ(name, "EPROTONOSUPPORT"))
994 #ifdef EPROTONOSUPPORT
995 return EPROTONOSUPPORT;
999 if (strEQ(name, "EPROTOTYPE"))
1007 if (strEQ(name, "ERANGE"))
1013 if (strEQ(name, "EREMOTE"))
1019 if (strEQ(name, "ERESTART"))
1025 if (strEQ(name, "EROFS"))
1033 if (strEQ(name, "ESHUTDOWN"))
1039 if (strEQ(name, "ESOCKTNOSUPPORT"))
1040 #ifdef ESOCKTNOSUPPORT
1041 return ESOCKTNOSUPPORT;
1045 if (strEQ(name, "ESPIPE"))
1051 if (strEQ(name, "ESRCH"))
1057 if (strEQ(name, "ESTALE"))
1065 if (strEQ(name, "ETIMEDOUT"))
1071 if (strEQ(name, "ETOOMANYREFS"))
1073 return ETOOMANYREFS;
1077 if (strEQ(name, "ETXTBSY"))
1085 if (strEQ(name, "EUSERS"))
1093 if (strEQ(name, "EWOULDBLOCK"))
1101 if (strEQ(name, "EXIT_FAILURE"))
1103 return EXIT_FAILURE;
1107 if (strEQ(name, "EXIT_SUCCESS"))
1109 return EXIT_SUCCESS;
1113 if (strEQ(name, "EXDEV"))
1121 if (strEQ(name, "E2BIG"))
1129 if (strnEQ(name, "FLT_", 4)) {
1130 if (strEQ(name, "FLT_MAX"))
1136 if (strEQ(name, "FLT_MIN"))
1142 if (strEQ(name, "FLT_ROUNDS"))
1148 if (strEQ(name, "FLT_DIG"))
1154 if (strEQ(name, "FLT_EPSILON"))
1160 if (strEQ(name, "FLT_MANT_DIG"))
1162 return FLT_MANT_DIG;
1166 if (strEQ(name, "FLT_MAX_10_EXP"))
1167 #ifdef FLT_MAX_10_EXP
1168 return FLT_MAX_10_EXP;
1172 if (strEQ(name, "FLT_MAX_EXP"))
1178 if (strEQ(name, "FLT_MIN_10_EXP"))
1179 #ifdef FLT_MIN_10_EXP
1180 return FLT_MIN_10_EXP;
1184 if (strEQ(name, "FLT_MIN_EXP"))
1190 if (strEQ(name, "FLT_RADIX"))
1198 if (strnEQ(name, "F_", 2)) {
1199 if (strEQ(name, "F_DUPFD"))
1205 if (strEQ(name, "F_GETFD"))
1211 if (strEQ(name, "F_GETFL"))
1217 if (strEQ(name, "F_GETLK"))
1223 if (strEQ(name, "F_OK"))
1229 if (strEQ(name, "F_RDLCK"))
1235 if (strEQ(name, "F_SETFD"))
1241 if (strEQ(name, "F_SETFL"))
1247 if (strEQ(name, "F_SETLK"))
1253 if (strEQ(name, "F_SETLKW"))
1259 if (strEQ(name, "F_UNLCK"))
1265 if (strEQ(name, "F_WRLCK"))
1273 if (strEQ(name, "FD_CLOEXEC"))
1279 if (strEQ(name, "FILENAME_MAX"))
1281 return FILENAME_MAX;
1287 if (strEQ(name, "HUGE_VAL"))
1288 #if defined(USE_LONG_DOUBLE) && defined(HUGE_VALL)
1289 /* HUGE_VALL is admittedly non-POSIX but if we are using long doubles
1290 * we might as well use long doubles. --jhi */
1298 if (strEQ(name, "HUPCL"))
1306 if (strEQ(name, "INT_MAX"))
1312 if (strEQ(name, "INT_MIN"))
1318 if (strEQ(name, "ICANON"))
1324 if (strEQ(name, "ICRNL"))
1330 if (strEQ(name, "IEXTEN"))
1336 if (strEQ(name, "IGNBRK"))
1342 if (strEQ(name, "IGNCR"))
1348 if (strEQ(name, "IGNPAR"))
1354 if (strEQ(name, "INLCR"))
1360 if (strEQ(name, "INPCK"))
1366 if (strEQ(name, "ISIG"))
1372 if (strEQ(name, "ISTRIP"))
1378 if (strEQ(name, "IXOFF"))
1384 if (strEQ(name, "IXON"))
1392 if (strnEQ(name, "LC_", 3)) {
1393 if (strEQ(name, "LC_ALL"))
1399 if (strEQ(name, "LC_COLLATE"))
1405 if (strEQ(name, "LC_CTYPE"))
1411 if (strEQ(name, "LC_MONETARY"))
1417 if (strEQ(name, "LC_NUMERIC"))
1423 if (strEQ(name, "LC_TIME"))
1431 if (strnEQ(name, "LDBL_", 5)) {
1432 if (strEQ(name, "LDBL_MAX"))
1438 if (strEQ(name, "LDBL_MIN"))
1444 if (strEQ(name, "LDBL_DIG"))
1450 if (strEQ(name, "LDBL_EPSILON"))
1452 return LDBL_EPSILON;
1456 if (strEQ(name, "LDBL_MANT_DIG"))
1457 #ifdef LDBL_MANT_DIG
1458 return LDBL_MANT_DIG;
1462 if (strEQ(name, "LDBL_MAX_10_EXP"))
1463 #ifdef LDBL_MAX_10_EXP
1464 return LDBL_MAX_10_EXP;
1468 if (strEQ(name, "LDBL_MAX_EXP"))
1470 return LDBL_MAX_EXP;
1474 if (strEQ(name, "LDBL_MIN_10_EXP"))
1475 #ifdef LDBL_MIN_10_EXP
1476 return LDBL_MIN_10_EXP;
1480 if (strEQ(name, "LDBL_MIN_EXP"))
1482 return LDBL_MIN_EXP;
1488 if (strnEQ(name, "L_", 2)) {
1489 if (strEQ(name, "L_ctermid"))
1495 if (strEQ(name, "L_cuserid"))
1501 /* L_tmpnam[e] was a typo--retained for compatibility */
1502 if (strEQ(name, "L_tmpname") || strEQ(name, "L_tmpnam"))
1510 if (strEQ(name, "LONG_MAX"))
1516 if (strEQ(name, "LONG_MIN"))
1522 if (strEQ(name, "LINK_MAX"))
1530 if (strEQ(name, "MAX_CANON"))
1536 if (strEQ(name, "MAX_INPUT"))
1542 if (strEQ(name, "MB_CUR_MAX"))
1548 if (strEQ(name, "MB_LEN_MAX"))
1556 if (strEQ(name, "NULL")) return 0;
1557 if (strEQ(name, "NAME_MAX"))
1563 if (strEQ(name, "NCCS"))
1569 if (strEQ(name, "NGROUPS_MAX"))
1575 if (strEQ(name, "NOFLSH"))
1583 if (strnEQ(name, "O_", 2)) {
1584 if (strEQ(name, "O_APPEND"))
1590 if (strEQ(name, "O_CREAT"))
1596 if (strEQ(name, "O_TRUNC"))
1602 if (strEQ(name, "O_RDONLY"))
1608 if (strEQ(name, "O_RDWR"))
1614 if (strEQ(name, "O_WRONLY"))
1620 if (strEQ(name, "O_EXCL"))
1626 if (strEQ(name, "O_NOCTTY"))
1632 if (strEQ(name, "O_NONBLOCK"))
1638 if (strEQ(name, "O_ACCMODE"))
1646 if (strEQ(name, "OPEN_MAX"))
1652 if (strEQ(name, "OPOST"))
1660 if (strEQ(name, "PATH_MAX"))
1666 if (strEQ(name, "PARENB"))
1672 if (strEQ(name, "PARMRK"))
1678 if (strEQ(name, "PARODD"))
1684 if (strEQ(name, "PIPE_BUF"))
1692 if (strEQ(name, "RAND_MAX"))
1698 if (strEQ(name, "R_OK"))
1706 if (strnEQ(name, "SIG", 3)) {
1707 if (name[3] == '_') {
1708 if (strEQ(name, "SIG_BLOCK"))
1715 if (strEQ(name, "SIG_DFL")) return (IV)SIG_DFL;
1718 if (strEQ(name, "SIG_ERR")) return (IV)SIG_ERR;
1721 if (strEQ(name, "SIG_IGN")) return (IV)SIG_IGN;
1723 if (strEQ(name, "SIG_SETMASK"))
1729 if (strEQ(name, "SIG_UNBLOCK"))
1737 if (strEQ(name, "SIGABRT"))
1743 if (strEQ(name, "SIGALRM"))
1749 if (strEQ(name, "SIGCHLD"))
1755 if (strEQ(name, "SIGCONT"))
1761 if (strEQ(name, "SIGFPE"))
1767 if (strEQ(name, "SIGHUP"))
1773 if (strEQ(name, "SIGILL"))
1779 if (strEQ(name, "SIGINT"))
1785 if (strEQ(name, "SIGKILL"))
1791 if (strEQ(name, "SIGPIPE"))
1797 if (strEQ(name, "SIGQUIT"))
1803 if (strEQ(name, "SIGSEGV"))
1809 if (strEQ(name, "SIGSTOP"))
1815 if (strEQ(name, "SIGTERM"))
1821 if (strEQ(name, "SIGTSTP"))
1827 if (strEQ(name, "SIGTTIN"))
1833 if (strEQ(name, "SIGTTOU"))
1839 if (strEQ(name, "SIGUSR1"))
1845 if (strEQ(name, "SIGUSR2"))
1853 if (name[1] == '_') {
1854 if (strEQ(name, "S_ISGID"))
1860 if (strEQ(name, "S_ISUID"))
1866 if (strEQ(name, "S_IRGRP"))
1872 if (strEQ(name, "S_IROTH"))
1878 if (strEQ(name, "S_IRUSR"))
1884 if (strEQ(name, "S_IRWXG"))
1890 if (strEQ(name, "S_IRWXO"))
1896 if (strEQ(name, "S_IRWXU"))
1902 if (strEQ(name, "S_IWGRP"))
1908 if (strEQ(name, "S_IWOTH"))
1914 if (strEQ(name, "S_IWUSR"))
1920 if (strEQ(name, "S_IXGRP"))
1926 if (strEQ(name, "S_IXOTH"))
1932 if (strEQ(name, "S_IXUSR"))
1938 errno = EAGAIN; /* the following aren't constants */
1940 if (strEQ(name, "S_ISBLK")) return S_ISBLK(arg);
1943 if (strEQ(name, "S_ISCHR")) return S_ISCHR(arg);
1946 if (strEQ(name, "S_ISDIR")) return S_ISDIR(arg);
1949 if (strEQ(name, "S_ISFIFO")) return S_ISFIFO(arg);
1952 if (strEQ(name, "S_ISREG")) return S_ISREG(arg);
1956 if (strEQ(name, "SEEK_CUR"))
1962 if (strEQ(name, "SEEK_END"))
1968 if (strEQ(name, "SEEK_SET"))
1974 if (strEQ(name, "STREAM_MAX"))
1980 if (strEQ(name, "SHRT_MAX"))
1986 if (strEQ(name, "SHRT_MIN"))
1992 if (strnEQ(name, "SA_", 3)) {
1993 if (strEQ(name, "SA_NOCLDSTOP"))
1995 return SA_NOCLDSTOP;
1999 if (strEQ(name, "SA_NOCLDWAIT"))
2001 return SA_NOCLDWAIT;
2005 if (strEQ(name, "SA_NODEFER"))
2011 if (strEQ(name, "SA_ONSTACK"))
2017 if (strEQ(name, "SA_RESETHAND"))
2019 return SA_RESETHAND;
2023 if (strEQ(name, "SA_RESTART"))
2029 if (strEQ(name, "SA_SIGINFO"))
2037 if (strEQ(name, "SCHAR_MAX"))
2043 if (strEQ(name, "SCHAR_MIN"))
2049 if (strEQ(name, "SSIZE_MAX"))
2055 if (strEQ(name, "STDIN_FILENO"))
2057 return STDIN_FILENO;
2061 if (strEQ(name, "STDOUT_FILENO"))
2062 #ifdef STDOUT_FILENO
2063 return STDOUT_FILENO;
2067 if (strEQ(name, "STDERR_FILENO"))
2068 #ifdef STDERR_FILENO
2069 return STDERR_FILENO;
2075 if (strEQ(name, "TCIFLUSH"))
2081 if (strEQ(name, "TCIOFF"))
2087 if (strEQ(name, "TCIOFLUSH"))
2093 if (strEQ(name, "TCION"))
2099 if (strEQ(name, "TCOFLUSH"))
2105 if (strEQ(name, "TCOOFF"))
2111 if (strEQ(name, "TCOON"))
2117 if (strEQ(name, "TCSADRAIN"))
2123 if (strEQ(name, "TCSAFLUSH"))
2129 if (strEQ(name, "TCSANOW"))
2135 if (strEQ(name, "TMP_MAX"))
2141 if (strEQ(name, "TOSTOP"))
2147 if (strEQ(name, "TZNAME_MAX"))
2155 if (strEQ(name, "UCHAR_MAX"))
2161 if (strEQ(name, "UINT_MAX"))
2167 if (strEQ(name, "ULONG_MAX"))
2173 if (strEQ(name, "USHRT_MAX"))
2181 if (strEQ(name, "VEOF"))
2187 if (strEQ(name, "VEOL"))
2193 if (strEQ(name, "VERASE"))
2199 if (strEQ(name, "VINTR"))
2205 if (strEQ(name, "VKILL"))
2211 if (strEQ(name, "VMIN"))
2217 if (strEQ(name, "VQUIT"))
2223 if (strEQ(name, "VSTART"))
2229 if (strEQ(name, "VSTOP"))
2235 if (strEQ(name, "VSUSP"))
2241 if (strEQ(name, "VTIME"))
2249 if (strEQ(name, "W_OK"))
2255 if (strEQ(name, "WNOHANG"))
2261 if (strEQ(name, "WUNTRACED"))
2267 errno = EAGAIN; /* the following aren't constants */
2269 if (strEQ(name, "WEXITSTATUS")) return WEXITSTATUS(arg);
2272 if (strEQ(name, "WIFEXITED")) return WIFEXITED(arg);
2275 if (strEQ(name, "WIFSIGNALED")) return WIFSIGNALED(arg);
2278 if (strEQ(name, "WIFSTOPPED")) return WIFSTOPPED(arg);
2281 if (strEQ(name, "WSTOPSIG")) return WSTOPSIG(arg);
2284 if (strEQ(name, "WTERMSIG")) return WTERMSIG(arg);
2288 if (strEQ(name, "X_OK"))
2296 if (strnEQ(name, "_PC_", 4)) {
2297 if (strEQ(name, "_PC_CHOWN_RESTRICTED"))
2298 #if defined(_PC_CHOWN_RESTRICTED) || HINT_SC_EXIST
2299 return _PC_CHOWN_RESTRICTED;
2303 if (strEQ(name, "_PC_LINK_MAX"))
2304 #if defined(_PC_LINK_MAX) || HINT_SC_EXIST
2305 return _PC_LINK_MAX;
2309 if (strEQ(name, "_PC_MAX_CANON"))
2310 #if defined(_PC_MAX_CANON) || HINT_SC_EXIST
2311 return _PC_MAX_CANON;
2315 if (strEQ(name, "_PC_MAX_INPUT"))
2316 #if defined(_PC_MAX_INPUT) || HINT_SC_EXIST
2317 return _PC_MAX_INPUT;
2321 if (strEQ(name, "_PC_NAME_MAX"))
2322 #if defined(_PC_NAME_MAX) || HINT_SC_EXIST
2323 return _PC_NAME_MAX;
2327 if (strEQ(name, "_PC_NO_TRUNC"))
2328 #if defined(_PC_NO_TRUNC) || HINT_SC_EXIST
2329 return _PC_NO_TRUNC;
2333 if (strEQ(name, "_PC_PATH_MAX"))
2334 #if defined(_PC_PATH_MAX) || HINT_SC_EXIST
2335 return _PC_PATH_MAX;
2339 if (strEQ(name, "_PC_PIPE_BUF"))
2340 #if defined(_PC_PIPE_BUF) || HINT_SC_EXIST
2341 return _PC_PIPE_BUF;
2345 if (strEQ(name, "_PC_VDISABLE"))
2346 #if defined(_PC_VDISABLE) || HINT_SC_EXIST
2347 return _PC_VDISABLE;
2353 if (strnEQ(name, "_POSIX_", 7)) {
2354 if (strEQ(name, "_POSIX_ARG_MAX"))
2355 #ifdef _POSIX_ARG_MAX
2356 return _POSIX_ARG_MAX;
2360 if (strEQ(name, "_POSIX_CHILD_MAX"))
2361 #ifdef _POSIX_CHILD_MAX
2362 return _POSIX_CHILD_MAX;
2366 if (strEQ(name, "_POSIX_CHOWN_RESTRICTED"))
2367 #ifdef _POSIX_CHOWN_RESTRICTED
2368 return _POSIX_CHOWN_RESTRICTED;
2372 if (strEQ(name, "_POSIX_JOB_CONTROL"))
2373 #ifdef _POSIX_JOB_CONTROL
2374 return _POSIX_JOB_CONTROL;
2378 if (strEQ(name, "_POSIX_LINK_MAX"))
2379 #ifdef _POSIX_LINK_MAX
2380 return _POSIX_LINK_MAX;
2384 if (strEQ(name, "_POSIX_MAX_CANON"))
2385 #ifdef _POSIX_MAX_CANON
2386 return _POSIX_MAX_CANON;
2390 if (strEQ(name, "_POSIX_MAX_INPUT"))
2391 #ifdef _POSIX_MAX_INPUT
2392 return _POSIX_MAX_INPUT;
2396 if (strEQ(name, "_POSIX_NAME_MAX"))
2397 #ifdef _POSIX_NAME_MAX
2398 return _POSIX_NAME_MAX;
2402 if (strEQ(name, "_POSIX_NGROUPS_MAX"))
2403 #ifdef _POSIX_NGROUPS_MAX
2404 return _POSIX_NGROUPS_MAX;
2408 if (strEQ(name, "_POSIX_NO_TRUNC"))
2409 #ifdef _POSIX_NO_TRUNC
2410 return _POSIX_NO_TRUNC;
2414 if (strEQ(name, "_POSIX_OPEN_MAX"))
2415 #ifdef _POSIX_OPEN_MAX
2416 return _POSIX_OPEN_MAX;
2420 if (strEQ(name, "_POSIX_PATH_MAX"))
2421 #ifdef _POSIX_PATH_MAX
2422 return _POSIX_PATH_MAX;
2426 if (strEQ(name, "_POSIX_PIPE_BUF"))
2427 #ifdef _POSIX_PIPE_BUF
2428 return _POSIX_PIPE_BUF;
2432 if (strEQ(name, "_POSIX_SAVED_IDS"))
2433 #ifdef _POSIX_SAVED_IDS
2434 return _POSIX_SAVED_IDS;
2438 if (strEQ(name, "_POSIX_SSIZE_MAX"))
2439 #ifdef _POSIX_SSIZE_MAX
2440 return _POSIX_SSIZE_MAX;
2444 if (strEQ(name, "_POSIX_STREAM_MAX"))
2445 #ifdef _POSIX_STREAM_MAX
2446 return _POSIX_STREAM_MAX;
2450 if (strEQ(name, "_POSIX_TZNAME_MAX"))
2451 #ifdef _POSIX_TZNAME_MAX
2452 return _POSIX_TZNAME_MAX;
2456 if (strEQ(name, "_POSIX_VDISABLE"))
2457 #ifdef _POSIX_VDISABLE
2458 return _POSIX_VDISABLE;
2462 if (strEQ(name, "_POSIX_VERSION"))
2463 #ifdef _POSIX_VERSION
2464 return _POSIX_VERSION;
2470 if (strnEQ(name, "_SC_", 4)) {
2471 if (strEQ(name, "_SC_ARG_MAX"))
2472 #if defined(_SC_ARG_MAX) || HINT_SC_EXIST
2477 if (strEQ(name, "_SC_CHILD_MAX"))
2478 #if defined(_SC_CHILD_MAX) || HINT_SC_EXIST
2479 return _SC_CHILD_MAX;
2483 if (strEQ(name, "_SC_CLK_TCK"))
2484 #if defined(_SC_CLK_TCK) || HINT_SC_EXIST
2489 if (strEQ(name, "_SC_JOB_CONTROL"))
2490 #if defined(_SC_JOB_CONTROL) || HINT_SC_EXIST
2491 return _SC_JOB_CONTROL;
2495 if (strEQ(name, "_SC_NGROUPS_MAX"))
2496 #if defined(_SC_NGROUPS_MAX) || HINT_SC_EXIST
2497 return _SC_NGROUPS_MAX;
2501 if (strEQ(name, "_SC_OPEN_MAX"))
2502 #if defined(_SC_OPEN_MAX) || HINT_SC_EXIST
2503 return _SC_OPEN_MAX;
2507 if (strEQ(name, "_SC_SAVED_IDS"))
2508 #if defined(_SC_SAVED_IDS) || HINT_SC_EXIST
2509 return _SC_SAVED_IDS;
2513 if (strEQ(name, "_SC_STREAM_MAX"))
2514 #if defined(_SC_STREAM_MAX) || HINT_SC_EXIST
2515 return _SC_STREAM_MAX;
2519 if (strEQ(name, "_SC_TZNAME_MAX"))
2520 #if defined(_SC_TZNAME_MAX) || HINT_SC_EXIST
2521 return _SC_TZNAME_MAX;
2525 if (strEQ(name, "_SC_VERSION"))
2526 #if defined(_SC_VERSION) || HINT_SC_EXIST
2543 restore_sigmask(sigset_t *ossetp)
2545 /* Fortunately, restoring the signal mask can't fail, because
2546 * there's nothing we can do about it if it does -- we're not
2547 * supposed to return -1 from sigaction unless the disposition
2550 (void)sigprocmask(SIG_SETMASK, ossetp, (sigset_t *)0);
2553 MODULE = SigSet PACKAGE = POSIX::SigSet PREFIX = sig
2556 new(packname = "POSIX::SigSet", ...)
2561 New(0, RETVAL, 1, sigset_t);
2562 sigemptyset(RETVAL);
2563 for (i = 1; i < items; i++)
2564 sigaddset(RETVAL, SvIV(ST(i)));
2571 POSIX::SigSet sigset
2576 sigaddset(sigset, sig)
2577 POSIX::SigSet sigset
2581 sigdelset(sigset, sig)
2582 POSIX::SigSet sigset
2587 POSIX::SigSet sigset
2591 POSIX::SigSet sigset
2594 sigismember(sigset, sig)
2595 POSIX::SigSet sigset
2599 MODULE = Termios PACKAGE = POSIX::Termios PREFIX = cf
2602 new(packname = "POSIX::Termios", ...)
2607 New(0, RETVAL, 1, struct termios);
2609 not_here("termios");
2617 DESTROY(termios_ref)
2618 POSIX::Termios termios_ref
2621 Safefree(termios_ref);
2623 not_here("termios");
2627 getattr(termios_ref, fd = 0)
2628 POSIX::Termios termios_ref
2631 RETVAL = tcgetattr(fd, termios_ref);
2636 setattr(termios_ref, fd = 0, optional_actions = 0)
2637 POSIX::Termios termios_ref
2639 int optional_actions
2641 RETVAL = tcsetattr(fd, optional_actions, termios_ref);
2646 cfgetispeed(termios_ref)
2647 POSIX::Termios termios_ref
2650 cfgetospeed(termios_ref)
2651 POSIX::Termios termios_ref
2654 getiflag(termios_ref)
2655 POSIX::Termios termios_ref
2657 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2658 RETVAL = termios_ref->c_iflag;
2660 not_here("getiflag");
2667 getoflag(termios_ref)
2668 POSIX::Termios termios_ref
2670 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2671 RETVAL = termios_ref->c_oflag;
2673 not_here("getoflag");
2680 getcflag(termios_ref)
2681 POSIX::Termios termios_ref
2683 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2684 RETVAL = termios_ref->c_cflag;
2686 not_here("getcflag");
2693 getlflag(termios_ref)
2694 POSIX::Termios termios_ref
2696 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2697 RETVAL = termios_ref->c_lflag;
2699 not_here("getlflag");
2706 getcc(termios_ref, ccix)
2707 POSIX::Termios termios_ref
2710 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2712 croak("Bad getcc subscript");
2713 RETVAL = termios_ref->c_cc[ccix];
2722 cfsetispeed(termios_ref, speed)
2723 POSIX::Termios termios_ref
2727 cfsetospeed(termios_ref, speed)
2728 POSIX::Termios termios_ref
2732 setiflag(termios_ref, iflag)
2733 POSIX::Termios termios_ref
2736 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2737 termios_ref->c_iflag = iflag;
2739 not_here("setiflag");
2743 setoflag(termios_ref, oflag)
2744 POSIX::Termios termios_ref
2747 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2748 termios_ref->c_oflag = oflag;
2750 not_here("setoflag");
2754 setcflag(termios_ref, cflag)
2755 POSIX::Termios termios_ref
2758 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2759 termios_ref->c_cflag = cflag;
2761 not_here("setcflag");
2765 setlflag(termios_ref, lflag)
2766 POSIX::Termios termios_ref
2769 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2770 termios_ref->c_lflag = lflag;
2772 not_here("setlflag");
2776 setcc(termios_ref, ccix, cc)
2777 POSIX::Termios termios_ref
2781 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2783 croak("Bad setcc subscript");
2784 termios_ref->c_cc[ccix] = cc;
2790 MODULE = POSIX PACKAGE = POSIX
2799 unsigned char * charstring
2801 unsigned char *s = charstring;
2802 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2803 for (RETVAL = 1; RETVAL && s < e; s++)
2811 unsigned char * charstring
2813 unsigned char *s = charstring;
2814 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2815 for (RETVAL = 1; RETVAL && s < e; s++)
2823 unsigned char * charstring
2825 unsigned char *s = charstring;
2826 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2827 for (RETVAL = 1; RETVAL && s < e; s++)
2835 unsigned char * charstring
2837 unsigned char *s = charstring;
2838 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2839 for (RETVAL = 1; RETVAL && s < e; s++)
2847 unsigned char * charstring
2849 unsigned char *s = charstring;
2850 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2851 for (RETVAL = 1; RETVAL && s < e; s++)
2859 unsigned char * charstring
2861 unsigned char *s = charstring;
2862 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2863 for (RETVAL = 1; RETVAL && s < e; s++)
2871 unsigned char * charstring
2873 unsigned char *s = charstring;
2874 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2875 for (RETVAL = 1; RETVAL && s < e; s++)
2883 unsigned char * charstring
2885 unsigned char *s = charstring;
2886 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2887 for (RETVAL = 1; RETVAL && s < e; s++)
2895 unsigned char * charstring
2897 unsigned char *s = charstring;
2898 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2899 for (RETVAL = 1; RETVAL && s < e; s++)
2907 unsigned char * charstring
2909 unsigned char *s = charstring;
2910 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2911 for (RETVAL = 1; RETVAL && s < e; s++)
2918 isxdigit(charstring)
2919 unsigned char * charstring
2921 unsigned char *s = charstring;
2922 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2923 for (RETVAL = 1; RETVAL && s < e; s++)
2930 open(filename, flags = O_RDONLY, mode = 0666)
2935 if (flags & (O_APPEND|O_CREAT|O_TRUNC|O_RDWR|O_WRONLY|O_EXCL))
2936 TAINT_PROPER("open");
2937 RETVAL = open(filename, flags, mode);
2945 #ifdef HAS_LOCALECONV
2946 struct lconv *lcbuf;
2948 if ((lcbuf = localeconv())) {
2950 if (lcbuf->decimal_point && *lcbuf->decimal_point)
2951 hv_store(RETVAL, "decimal_point", 13,
2952 newSVpv(lcbuf->decimal_point, 0), 0);
2953 if (lcbuf->thousands_sep && *lcbuf->thousands_sep)
2954 hv_store(RETVAL, "thousands_sep", 13,
2955 newSVpv(lcbuf->thousands_sep, 0), 0);
2956 #ifndef NO_LOCALECONV_GROUPING
2957 if (lcbuf->grouping && *lcbuf->grouping)
2958 hv_store(RETVAL, "grouping", 8,
2959 newSVpv(lcbuf->grouping, 0), 0);
2961 if (lcbuf->int_curr_symbol && *lcbuf->int_curr_symbol)
2962 hv_store(RETVAL, "int_curr_symbol", 15,
2963 newSVpv(lcbuf->int_curr_symbol, 0), 0);
2964 if (lcbuf->currency_symbol && *lcbuf->currency_symbol)
2965 hv_store(RETVAL, "currency_symbol", 15,
2966 newSVpv(lcbuf->currency_symbol, 0), 0);
2967 if (lcbuf->mon_decimal_point && *lcbuf->mon_decimal_point)
2968 hv_store(RETVAL, "mon_decimal_point", 17,
2969 newSVpv(lcbuf->mon_decimal_point, 0), 0);
2970 #ifndef NO_LOCALECONV_MON_THOUSANDS_SEP
2971 if (lcbuf->mon_thousands_sep && *lcbuf->mon_thousands_sep)
2972 hv_store(RETVAL, "mon_thousands_sep", 17,
2973 newSVpv(lcbuf->mon_thousands_sep, 0), 0);
2975 #ifndef NO_LOCALECONV_MON_GROUPING
2976 if (lcbuf->mon_grouping && *lcbuf->mon_grouping)
2977 hv_store(RETVAL, "mon_grouping", 12,
2978 newSVpv(lcbuf->mon_grouping, 0), 0);
2980 if (lcbuf->positive_sign && *lcbuf->positive_sign)
2981 hv_store(RETVAL, "positive_sign", 13,
2982 newSVpv(lcbuf->positive_sign, 0), 0);
2983 if (lcbuf->negative_sign && *lcbuf->negative_sign)
2984 hv_store(RETVAL, "negative_sign", 13,
2985 newSVpv(lcbuf->negative_sign, 0), 0);
2987 if (lcbuf->int_frac_digits != CHAR_MAX)
2988 hv_store(RETVAL, "int_frac_digits", 15,
2989 newSViv(lcbuf->int_frac_digits), 0);
2990 if (lcbuf->frac_digits != CHAR_MAX)
2991 hv_store(RETVAL, "frac_digits", 11,
2992 newSViv(lcbuf->frac_digits), 0);
2993 if (lcbuf->p_cs_precedes != CHAR_MAX)
2994 hv_store(RETVAL, "p_cs_precedes", 13,
2995 newSViv(lcbuf->p_cs_precedes), 0);
2996 if (lcbuf->p_sep_by_space != CHAR_MAX)
2997 hv_store(RETVAL, "p_sep_by_space", 14,
2998 newSViv(lcbuf->p_sep_by_space), 0);
2999 if (lcbuf->n_cs_precedes != CHAR_MAX)
3000 hv_store(RETVAL, "n_cs_precedes", 13,
3001 newSViv(lcbuf->n_cs_precedes), 0);
3002 if (lcbuf->n_sep_by_space != CHAR_MAX)
3003 hv_store(RETVAL, "n_sep_by_space", 14,
3004 newSViv(lcbuf->n_sep_by_space), 0);
3005 if (lcbuf->p_sign_posn != CHAR_MAX)
3006 hv_store(RETVAL, "p_sign_posn", 11,
3007 newSViv(lcbuf->p_sign_posn), 0);
3008 if (lcbuf->n_sign_posn != CHAR_MAX)
3009 hv_store(RETVAL, "n_sign_posn", 11,
3010 newSViv(lcbuf->n_sign_posn), 0);
3013 localeconv(); /* A stub to call not_here(). */
3019 setlocale(category, locale = 0)
3023 RETVAL = setlocale(category, locale);
3025 #ifdef USE_LOCALE_CTYPE
3026 if (category == LC_CTYPE
3028 || category == LC_ALL
3034 if (category == LC_ALL)
3035 newctype = setlocale(LC_CTYPE, NULL);
3039 new_ctype(newctype);
3041 #endif /* USE_LOCALE_CTYPE */
3042 #ifdef USE_LOCALE_COLLATE
3043 if (category == LC_COLLATE
3045 || category == LC_ALL
3051 if (category == LC_ALL)
3052 newcoll = setlocale(LC_COLLATE, NULL);
3056 new_collate(newcoll);
3058 #endif /* USE_LOCALE_COLLATE */
3059 #ifdef USE_LOCALE_NUMERIC
3060 if (category == LC_NUMERIC
3062 || category == LC_ALL
3068 if (category == LC_ALL)
3069 newnum = setlocale(LC_NUMERIC, NULL);
3073 new_numeric(newnum);
3075 #endif /* USE_LOCALE_NUMERIC */
3115 /* (We already know stack is long enough.) */
3116 PUSHs(sv_2mortal(newSVnv(frexp(x,&expvar))));
3117 PUSHs(sv_2mortal(newSViv(expvar)));
3133 /* (We already know stack is long enough.) */
3134 PUSHs(sv_2mortal(newSVnv(Perl_modf(x,&intvar))));
3135 PUSHs(sv_2mortal(newSVnv(intvar)));
3150 sigaction(sig, optaction, oldaction = 0)
3153 POSIX::SigAction oldaction
3156 RETVAL = not_here("sigaction");
3158 # This code is really grody because we're trying to make the signal
3159 # interface look beautiful, which is hard.
3162 POSIX__SigAction action;
3163 GV *siggv = gv_fetchpv("SIG", TRUE, SVt_PVHV);
3164 struct sigaction act;
3165 struct sigaction oact;
3168 POSIX__SigSet sigset;
3170 SV** sigsvp = hv_fetch(GvHVn(siggv),
3172 strlen(PL_sig_name[sig]),
3176 /* Check optaction and set action */
3177 if(SvTRUE(optaction)) {
3178 if(sv_isa(optaction, "POSIX::SigAction"))
3179 action = (HV*)SvRV(optaction);
3181 croak("action is not of type POSIX::SigAction");
3187 /* sigaction() is supposed to look atomic. In particular, any
3188 * signal handler invoked during a sigaction() call should
3189 * see either the old or the new disposition, and not something
3190 * in between. We use sigprocmask() to make it so.
3193 RETVAL=sigprocmask(SIG_BLOCK, &sset, &osset);
3197 /* Restore signal mask no matter how we exit this block. */
3198 SAVEDESTRUCTOR(restore_sigmask, &osset);
3200 RETVAL=-1; /* In case both oldaction and action are 0. */
3202 /* Remember old disposition if desired. */
3204 svp = hv_fetch(oldaction, "HANDLER", 7, TRUE);
3206 croak("Can't supply an oldaction without a HANDLER");
3207 if(SvTRUE(*sigsvp)) { /* TBD: what if "0"? */
3208 sv_setsv(*svp, *sigsvp);
3211 sv_setpv(*svp, "DEFAULT");
3213 RETVAL = sigaction(sig, (struct sigaction *)0, & oact);
3216 /* Get back the mask. */
3217 svp = hv_fetch(oldaction, "MASK", 4, TRUE);
3218 if (sv_isa(*svp, "POSIX::SigSet")) {
3219 IV tmp = SvIV((SV*)SvRV(*svp));
3220 sigset = INT2PTR(sigset_t*, tmp);
3223 New(0, sigset, 1, sigset_t);
3224 sv_setptrobj(*svp, sigset, "POSIX::SigSet");
3226 *sigset = oact.sa_mask;
3228 /* Get back the flags. */
3229 svp = hv_fetch(oldaction, "FLAGS", 5, TRUE);
3230 sv_setiv(*svp, oact.sa_flags);
3234 /* Vector new handler through %SIG. (We always use sighandler
3235 for the C signal handler, which reads %SIG to dispatch.) */
3236 svp = hv_fetch(action, "HANDLER", 7, FALSE);
3238 croak("Can't supply an action without a HANDLER");
3239 sv_setsv(*sigsvp, *svp);
3240 mg_set(*sigsvp); /* handles DEFAULT and IGNORE */
3242 char *s=SvPVX(*svp);
3243 if(strEQ(s,"IGNORE")) {
3244 act.sa_handler = SIG_IGN;
3246 else if(strEQ(s,"DEFAULT")) {
3247 act.sa_handler = SIG_DFL;
3250 act.sa_handler = PL_sighandlerp;
3254 act.sa_handler = PL_sighandlerp;
3257 /* Set up any desired mask. */
3258 svp = hv_fetch(action, "MASK", 4, FALSE);
3259 if (svp && sv_isa(*svp, "POSIX::SigSet")) {
3260 IV tmp = SvIV((SV*)SvRV(*svp));
3261 sigset = INT2PTR(sigset_t*, tmp);
3262 act.sa_mask = *sigset;
3265 sigemptyset(& act.sa_mask);
3267 /* Set up any desired flags. */
3268 svp = hv_fetch(action, "FLAGS", 5, FALSE);
3269 act.sa_flags = svp ? SvIV(*svp) : 0;
3271 /* Don't worry about cleaning up *sigsvp if this fails,
3272 * because that means we tried to disposition a
3273 * nonblockable signal, in which case *sigsvp is
3274 * essentially meaningless anyway.
3276 RETVAL = sigaction(sig, & act, (struct sigaction *)0);
3287 POSIX::SigSet sigset
3290 sigprocmask(how, sigset, oldsigset = 0)
3292 POSIX::SigSet sigset
3293 POSIX::SigSet oldsigset = NO_INIT
3298 else if (sv_derived_from(ST(2), "POSIX::SigSet")) {
3299 IV tmp = SvIV((SV*)SvRV(ST(2)));
3300 oldsigset = INT2PTR(POSIX__SigSet,tmp);
3303 New(0, oldsigset, 1, sigset_t);
3304 sigemptyset(oldsigset);
3305 sv_setref_pv(ST(2), "POSIX::SigSet", (void*)oldsigset);
3309 sigsuspend(signal_mask)
3310 POSIX::SigSet signal_mask
3330 lseek(fd, offset, whence)
3343 if (pipe(fds) != -1) {
3345 PUSHs(sv_2mortal(newSViv(fds[0])));
3346 PUSHs(sv_2mortal(newSViv(fds[1])));
3350 read(fd, buffer, nbytes)
3352 SV *sv_buffer = SvROK(ST(1)) ? SvRV(ST(1)) : ST(1);
3356 char * buffer = sv_grow( sv_buffer, nbytes+1 );
3359 SvCUR(sv_buffer) = RETVAL;
3360 SvPOK_only(sv_buffer);
3361 *SvEND(sv_buffer) = '\0';
3362 SvTAINTED_on(sv_buffer);
3378 tcsetpgrp(fd, pgrp_id)
3387 if (uname(&buf) >= 0) {
3389 PUSHs(sv_2mortal(newSVpv(buf.sysname, 0)));
3390 PUSHs(sv_2mortal(newSVpv(buf.nodename, 0)));
3391 PUSHs(sv_2mortal(newSVpv(buf.release, 0)));
3392 PUSHs(sv_2mortal(newSVpv(buf.version, 0)));
3393 PUSHs(sv_2mortal(newSVpv(buf.machine, 0)));
3396 uname((char *) 0); /* A stub to call not_here(). */
3400 write(fd, buffer, nbytes)
3411 RETVAL = newSVpvn("", 0);
3412 SvGROW(RETVAL, L_tmpnam);
3413 len = strlen(tmpnam(SvPV(RETVAL, i)));
3414 SvCUR_set(RETVAL, len);
3427 mbstowcs(s, pwcs, n)
3439 wcstombs(s, pwcs, n)
3461 SET_NUMERIC_LOCAL();
3462 num = strtod(str, &unparsed);
3463 PUSHs(sv_2mortal(newSVnv(num)));
3464 if (GIMME == G_ARRAY) {
3467 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3469 PUSHs(&PL_sv_undef);
3473 strtol(str, base = 0)
3480 num = strtol(str, &unparsed, base);
3481 #if IVSIZE <= LONGSIZE
3482 if (num < IV_MIN || num > IV_MAX)
3483 PUSHs(sv_2mortal(newSVnv((double)num)));
3486 PUSHs(sv_2mortal(newSViv((IV)num)));
3487 if (GIMME == G_ARRAY) {
3490 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3492 PUSHs(&PL_sv_undef);
3496 strtoul(str, base = 0)
3503 num = strtoul(str, &unparsed, base);
3505 PUSHs(sv_2mortal(newSViv((IV)num)));
3507 PUSHs(sv_2mortal(newSVnv((double)num)));
3508 if (GIMME == G_ARRAY) {
3511 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3513 PUSHs(&PL_sv_undef);
3523 char *p = SvPV(src,srclen);
3525 ST(0) = sv_2mortal(NEWSV(800,srclen));
3526 dstlen = strxfrm(SvPVX(ST(0)), p, (size_t)srclen);
3527 if (dstlen > srclen) {
3529 SvGROW(ST(0), dstlen);
3530 strxfrm(SvPVX(ST(0)), p, (size_t)dstlen);
3533 SvCUR(ST(0)) = dstlen;
3538 mkfifo(filename, mode)
3542 TAINT_PROPER("mkfifo");
3543 RETVAL = mkfifo(filename, mode);
3559 tcflush(fd, queue_selector)
3564 tcsendbreak(fd, duration)
3569 asctime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3582 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3585 mytm.tm_hour = hour;
3586 mytm.tm_mday = mday;
3588 mytm.tm_year = year;
3589 mytm.tm_wday = wday;
3590 mytm.tm_yday = yday;
3591 mytm.tm_isdst = isdst;
3592 RETVAL = asctime(&mytm);
3609 realtime = times( &tms );
3611 PUSHs( sv_2mortal( newSViv( (IV) realtime ) ) );
3612 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_utime ) ) );
3613 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_stime ) ) );
3614 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cutime ) ) );
3615 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cstime ) ) );
3618 difftime(time1, time2)
3623 mktime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3636 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3639 mytm.tm_hour = hour;
3640 mytm.tm_mday = mday;
3642 mytm.tm_year = year;
3643 mytm.tm_wday = wday;
3644 mytm.tm_yday = yday;
3645 mytm.tm_isdst = isdst;
3646 RETVAL = mktime(&mytm);
3651 #XXX: if $xsubpp::WantOptimize is always the default
3652 # sv_setpv(TARG, ...) could be used rather than
3653 # ST(0) = sv_2mortal(newSVpv(...))
3655 strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1)
3668 char *buf = my_strftime(fmt, sec, min, hour, mday, mon, year, wday, yday, isdst);
3669 ST(0) = sv_2mortal(newSVpv(buf, 0));
3680 PUSHs(sv_2mortal(newSVpvn(tzname[0],strlen(tzname[0]))));
3681 PUSHs(sv_2mortal(newSVpvn(tzname[1],strlen(tzname[1]))));
3684 access(filename, mode)
3702 pathconf(filename, name)
3733 New(0, buf, buflen, char);
3734 /* Many getcwd()s know how to automatically allocate memory
3735 * for the directory if the buffer argument is NULL but...
3736 * (1) we cannot assume all getcwd()s do that
3737 * (2) this may interfere with Perl's malloc
3738 * So let's not. --jhi */
3739 while ((getcwd(buf, buflen) == NULL) && errno == ERANGE) {
3741 if (buflen > MAXPATHLEN) {
3746 Renew(buf, buflen, char);
3749 PUSHs(sv_2mortal(newSVpv(buf, 0)));
3753 PUSHs(&PL_sv_undef);
3755 require_pv("Cwd.pm");
3756 /* Module require may have grown the stack */
3760 XSRETURN(call_pv("Cwd::cwd", GIMME_V));