5 #define PERLIO_NOT_STDIO 1
8 #ifdef PERL_OBJECT /* XXX _very_ temporary hacks */
11 # define open PerlLIO_open3
13 # define TAINT_PROPER(a)
16 #ifdef I_DIRENT /* XXX maybe better to just rely on perl.h? */
39 /* XXX This comment is just to make I_TERMIO and I_SGTTY visible to
40 metaconfig for future extension writers. We don't use them in POSIX.
41 (This is really sneaky :-) --AD
43 #if defined(I_TERMIOS)
51 #include <sys/types.h>
58 #if defined(__VMS) && !defined(__POSIX_SOURCE)
59 # include <libdef.h> /* LIB$_INVARG constant */
60 # include <lib$routines.h> /* prototype for lib$ediv() */
61 # include <starlet.h> /* prototype for sys$gettim() */
62 # if DECC_VERSION < 50000000
63 # define pid_t int /* old versions of DECC miss this in types.h */
67 # define mkfifo(a,b) (not_here("mkfifo"),-1)
68 # define tzset() not_here("tzset")
70 #if ((__VMS_VER >= 70000000) && (__DECC_VER >= 50200000)) || (__CRTL_VER >= 70000000)
71 # define HAS_TZNAME /* shows up in VMS 7.0 or Dec C 5.6 */
73 # endif /* __VMS_VER >= 70000000 or Dec C 5.6 */
75 /* The POSIX notion of ttyname() is better served by getname() under VMS */
76 static char ttnambuf[64];
77 # define ttyname(fd) (isatty(fd) > 0 ? getname(fd,ttnambuf,0) : NULL)
79 /* The non-POSIX CRTL times() has void return type, so we just get the
80 current time directly */
81 clock_t vms_times(struct tms *bufptr) {
83 /* Get wall time and convert to 10 ms intervals to
84 * produce the return value that the POSIX standard expects */
85 # if defined(__DECC) && defined (__ALPHA)
88 _ckvmssts(sys$gettim(&vmstime));
90 retval = vmstime & 0x7fffffff;
92 /* (Older hw or ccs don't have an atomic 64-bit type, so we
93 * juggle 32-bit ints (and a float) to produce a time_t result
94 * with minimal loss of information.) */
95 long int vmstime[2],remainder,divisor = 100000;
96 _ckvmssts(sys$gettim((unsigned long int *)vmstime));
97 vmstime[1] &= 0x7fff; /* prevent overflow in EDIV */
98 _ckvmssts(lib$ediv(&divisor,vmstime,(long int *)&retval,&remainder));
100 /* Fill in the struct tms using the CRTL routine . . .*/
101 times((tbuffer_t *)bufptr);
102 return (clock_t) retval;
104 # define times(t) vms_times(t)
108 # define mkfifo(a,b) not_here("mkfifo")
109 # define ttyname(a) (char*)not_here("ttyname")
110 # define sigset_t long
113 # define tzname _tzname
116 # define mode_t short
119 # define mode_t short
121 # define tzset() not_here("tzset")
123 # ifndef _POSIX_OPEN_MAX
124 # define _POSIX_OPEN_MAX FOPEN_MAX /* XXX bogus ? */
127 # define sigaction(a,b,c) not_here("sigaction")
128 # define sigpending(a) not_here("sigpending")
129 # define sigprocmask(a,b,c) not_here("sigprocmask")
130 # define sigsuspend(a) not_here("sigsuspend")
131 # define sigemptyset(a) not_here("sigemptyset")
132 # define sigaddset(a,b) not_here("sigaddset")
133 # define sigdelset(a,b) not_here("sigdelset")
134 # define sigfillset(a) not_here("sigfillset")
135 # define sigismember(a,b) not_here("sigismember")
140 # define mkfifo(path, mode) (mknod((path), (mode) | S_IFIFO, 0))
142 # endif /* !HAS_MKFIFO */
145 # include <sys/times.h>
147 # include <sys/utsname.h>
149 # include <sys/wait.h>
157 typedef long SysRetLong;
158 typedef sigset_t* POSIX__SigSet;
159 typedef HV* POSIX__SigAction;
161 typedef struct termios* POSIX__Termios;
162 #else /* Define termios types to int, and call not_here for the functions.*/
163 #define POSIX__Termios int
167 #define cfgetispeed(x) not_here("cfgetispeed")
168 #define cfgetospeed(x) not_here("cfgetospeed")
169 #define tcdrain(x) not_here("tcdrain")
170 #define tcflush(x,y) not_here("tcflush")
171 #define tcsendbreak(x,y) not_here("tcsendbreak")
172 #define cfsetispeed(x,y) not_here("cfsetispeed")
173 #define cfsetospeed(x,y) not_here("cfsetospeed")
174 #define ctermid(x) (char *) not_here("ctermid")
175 #define tcflow(x,y) not_here("tcflow")
176 #define tcgetattr(x,y) not_here("tcgetattr")
177 #define tcsetattr(x,y,z) not_here("tcsetattr")
180 /* Possibly needed prototypes */
181 char *cuserid _((char *));
182 double strtod _((const char *, char **));
183 long strtol _((const char *, char **, int));
184 unsigned long strtoul _((const char *, char **, int));
187 #define cuserid(a) (char *) not_here("cuserid")
191 #define difftime(a,b) not_here("difftime")
194 #ifndef HAS_FPATHCONF
195 #define fpathconf(f,n) (SysRetLong) not_here("fpathconf")
198 #define mktime(a) not_here("mktime")
201 #define nice(a) not_here("nice")
204 #define pathconf(f,n) (SysRetLong) not_here("pathconf")
207 #define sysconf(n) (SysRetLong) not_here("sysconf")
210 #define readlink(a,b,c) not_here("readlink")
213 #define setpgid(a,b) not_here("setpgid")
216 #define setsid() not_here("setsid")
219 #define strcoll(s1,s2) not_here("strcoll")
222 #define strtod(s1,s2) not_here("strtod")
225 #define strtol(s1,s2,b) not_here("strtol")
228 #define strtoul(s1,s2,b) not_here("strtoul")
231 #define strxfrm(s1,s2,n) not_here("strxfrm")
233 #ifndef HAS_TCGETPGRP
234 #define tcgetpgrp(a) not_here("tcgetpgrp")
236 #ifndef HAS_TCSETPGRP
237 #define tcsetpgrp(a,b) not_here("tcsetpgrp")
240 #define times(a) not_here("times")
243 #define uname(a) not_here("uname")
246 #define waitpid(a,b,c) not_here("waitpid")
251 #define mblen(a,b) not_here("mblen")
255 #define mbstowcs(s, pwcs, n) not_here("mbstowcs")
258 #define mbtowc(pwc, s, n) not_here("mbtowc")
261 #define wcstombs(s, pwcs, n) not_here("wcstombs")
264 #define wctomb(s, wchar) not_here("wcstombs")
266 #if !defined(HAS_MBLEN) && !defined(HAS_MBSTOWCS) && !defined(HAS_MBTOWC) && !defined(HAS_WCSTOMBS) && !defined(HAS_WCTOMB)
267 /* If we don't have these functions, then we wouldn't have gotten a typedef
268 for wchar_t, the wide character type. Defining wchar_t allows the
269 functions referencing it to compile. Its actual type is then meaningless,
270 since without the above functions, all sections using it end up calling
271 not_here() and croak. --Kaveh Ghazi (ghazi@noc.rutgers.edu) 9/18/94. */
277 #ifndef HAS_LOCALECONV
278 #define localeconv() not_here("localeconv")
283 extern char *tzname[];
286 #if !defined(WIN32) || (defined(__MINGW32__) && !defined(tzname))
287 char *tzname[] = { "" , "" };
291 /* XXX struct tm on some systems (SunOS4/BSD) contains extra (non POSIX)
292 * fields for which we don't have Configure support yet:
293 * char *tm_zone; -- abbreviation of timezone name
294 * long tm_gmtoff; -- offset from GMT in seconds
295 * To workaround core dumps from the uninitialised tm_zone we get the
296 * system to give us a reasonable struct to copy. This fix means that
297 * strftime uses the tm_zone and tm_gmtoff values returned by
298 * localtime(time()). That should give the desired result most of the
299 * time. But probably not always!
301 * This is a temporary workaround to be removed once Configure
302 * support is added and NETaa14816 is considered in full.
303 * It does not address tzname aspects of NETaa14816.
306 # ifndef STRUCT_TM_HASZONE
307 # define STRUCT_TM_HAS_ZONE
311 #ifdef STRUCT_TM_HASZONE
313 init_tm(ptm) /* see mktime, strftime and asctime */
318 Copy(localtime(&now), ptm, 1, struct tm);
322 # define init_tm(ptm)
326 #ifdef HAS_LONG_DOUBLE
327 # if LONG_DOUBLESIZE > DOUBLESIZE
328 # undef HAS_LONG_DOUBLE /* XXX until we figure out how to use them */
332 #ifndef HAS_LONG_DOUBLE
347 croak("POSIX::%s not implemented on this architecture", s);
352 #ifdef HAS_LONG_DOUBLE
357 constant(char *name, int arg)
362 if (strEQ(name, "ARG_MAX"))
370 if (strEQ(name, "BUFSIZ"))
376 if (strEQ(name, "BRKINT"))
382 if (strEQ(name, "B9600"))
388 if (strEQ(name, "B19200"))
394 if (strEQ(name, "B38400"))
400 if (strEQ(name, "B0"))
406 if (strEQ(name, "B110"))
412 if (strEQ(name, "B1200"))
418 if (strEQ(name, "B134"))
424 if (strEQ(name, "B150"))
430 if (strEQ(name, "B1800"))
436 if (strEQ(name, "B200"))
442 if (strEQ(name, "B2400"))
448 if (strEQ(name, "B300"))
454 if (strEQ(name, "B4800"))
460 if (strEQ(name, "B50"))
466 if (strEQ(name, "B600"))
472 if (strEQ(name, "B75"))
480 if (strEQ(name, "CHAR_BIT"))
486 if (strEQ(name, "CHAR_MAX"))
492 if (strEQ(name, "CHAR_MIN"))
498 if (strEQ(name, "CHILD_MAX"))
504 if (strEQ(name, "CLK_TCK"))
510 if (strEQ(name, "CLOCAL"))
516 if (strEQ(name, "CLOCKS_PER_SEC"))
517 #ifdef CLOCKS_PER_SEC
518 return CLOCKS_PER_SEC;
522 if (strEQ(name, "CREAD"))
528 if (strEQ(name, "CS5"))
534 if (strEQ(name, "CS6"))
540 if (strEQ(name, "CS7"))
546 if (strEQ(name, "CS8"))
552 if (strEQ(name, "CSIZE"))
558 if (strEQ(name, "CSTOPB"))
566 if (strEQ(name, "DBL_MAX"))
572 if (strEQ(name, "DBL_MIN"))
578 if (strEQ(name, "DBL_DIG"))
584 if (strEQ(name, "DBL_EPSILON"))
590 if (strEQ(name, "DBL_MANT_DIG"))
596 if (strEQ(name, "DBL_MAX_10_EXP"))
597 #ifdef DBL_MAX_10_EXP
598 return DBL_MAX_10_EXP;
602 if (strEQ(name, "DBL_MAX_EXP"))
608 if (strEQ(name, "DBL_MIN_10_EXP"))
609 #ifdef DBL_MIN_10_EXP
610 return DBL_MIN_10_EXP;
614 if (strEQ(name, "DBL_MIN_EXP"))
624 if (strEQ(name, "EACCES"))
630 if (strEQ(name, "EADDRINUSE"))
636 if (strEQ(name, "EADDRNOTAVAIL"))
638 return EADDRNOTAVAIL;
642 if (strEQ(name, "EAFNOSUPPORT"))
648 if (strEQ(name, "EAGAIN"))
654 if (strEQ(name, "EALREADY"))
662 if (strEQ(name, "EBADF"))
668 if (strEQ(name, "EBUSY"))
676 if (strEQ(name, "ECHILD"))
682 if (strEQ(name, "ECHO"))
688 if (strEQ(name, "ECHOE"))
694 if (strEQ(name, "ECHOK"))
700 if (strEQ(name, "ECHONL"))
706 if (strEQ(name, "ECONNABORTED"))
712 if (strEQ(name, "ECONNREFUSED"))
718 if (strEQ(name, "ECONNRESET"))
726 if (strEQ(name, "EDEADLK"))
732 if (strEQ(name, "EDESTADDRREQ"))
738 if (strEQ(name, "EDOM"))
744 if (strEQ(name, "EDQUOT"))
752 if (strEQ(name, "EEXIST"))
760 if (strEQ(name, "EFAULT"))
766 if (strEQ(name, "EFBIG"))
774 if (strEQ(name, "EHOSTDOWN"))
780 if (strEQ(name, "EHOSTUNREACH"))
788 if (strEQ(name, "EINPROGRESS"))
794 if (strEQ(name, "EINTR"))
800 if (strEQ(name, "EINVAL"))
806 if (strEQ(name, "EIO"))
812 if (strEQ(name, "EISCONN"))
818 if (strEQ(name, "EISDIR"))
824 if (strEQ(name, "ELOOP"))
832 if (strEQ(name, "EMFILE"))
838 if (strEQ(name, "EMLINK"))
844 if (strEQ(name, "EMSGSIZE"))
852 if (strEQ(name, "ENETDOWN"))
858 if (strEQ(name, "ENETRESET"))
864 if (strEQ(name, "ENETUNREACH"))
870 if (strEQ(name, "ENOBUFS"))
876 if (strEQ(name, "ENOEXEC"))
882 if (strEQ(name, "ENOMEM"))
888 if (strEQ(name, "ENOPROTOOPT"))
894 if (strEQ(name, "ENOSPC"))
900 if (strEQ(name, "ENOTBLK"))
906 if (strEQ(name, "ENOTCONN"))
912 if (strEQ(name, "ENOTDIR"))
918 if (strEQ(name, "ENOTEMPTY"))
924 if (strEQ(name, "ENOTSOCK"))
930 if (strEQ(name, "ENOTTY"))
936 if (strEQ(name, "ENFILE"))
942 if (strEQ(name, "ENODEV"))
948 if (strEQ(name, "ENOENT"))
954 if (strEQ(name, "ENOLCK"))
960 if (strEQ(name, "ENOSYS"))
966 if (strEQ(name, "ENXIO"))
972 if (strEQ(name, "ENAMETOOLONG"))
980 if (strEQ(name, "EOF"))
986 if (strEQ(name, "EOPNOTSUPP"))
994 if (strEQ(name, "EPERM"))
1000 if (strEQ(name, "EPFNOSUPPORT"))
1002 return EPFNOSUPPORT;
1006 if (strEQ(name, "EPIPE"))
1012 if (strEQ(name, "EPROCLIM"))
1018 if (strEQ(name, "EPROTONOSUPPORT"))
1019 #ifdef EPROTONOSUPPORT
1020 return EPROTONOSUPPORT;
1024 if (strEQ(name, "EPROTOTYPE"))
1032 if (strEQ(name, "ERANGE"))
1038 if (strEQ(name, "EREMOTE"))
1044 if (strEQ(name, "ERESTART"))
1050 if (strEQ(name, "EROFS"))
1058 if (strEQ(name, "ESHUTDOWN"))
1064 if (strEQ(name, "ESOCKTNOSUPPORT"))
1065 #ifdef ESOCKTNOSUPPORT
1066 return ESOCKTNOSUPPORT;
1070 if (strEQ(name, "ESPIPE"))
1076 if (strEQ(name, "ESRCH"))
1082 if (strEQ(name, "ESTALE"))
1090 if (strEQ(name, "ETIMEDOUT"))
1096 if (strEQ(name, "ETOOMANYREFS"))
1098 return ETOOMANYREFS;
1102 if (strEQ(name, "ETXTBSY"))
1110 if (strEQ(name, "EUSERS"))
1118 if (strEQ(name, "EWOULDBLOCK"))
1126 if (strEQ(name, "EXIT_FAILURE"))
1128 return EXIT_FAILURE;
1132 if (strEQ(name, "EXIT_SUCCESS"))
1134 return EXIT_SUCCESS;
1138 if (strEQ(name, "EXDEV"))
1146 if (strEQ(name, "E2BIG"))
1154 if (strnEQ(name, "FLT_", 4)) {
1155 if (strEQ(name, "FLT_MAX"))
1161 if (strEQ(name, "FLT_MIN"))
1167 if (strEQ(name, "FLT_ROUNDS"))
1173 if (strEQ(name, "FLT_DIG"))
1179 if (strEQ(name, "FLT_EPSILON"))
1185 if (strEQ(name, "FLT_MANT_DIG"))
1187 return FLT_MANT_DIG;
1191 if (strEQ(name, "FLT_MAX_10_EXP"))
1192 #ifdef FLT_MAX_10_EXP
1193 return FLT_MAX_10_EXP;
1197 if (strEQ(name, "FLT_MAX_EXP"))
1203 if (strEQ(name, "FLT_MIN_10_EXP"))
1204 #ifdef FLT_MIN_10_EXP
1205 return FLT_MIN_10_EXP;
1209 if (strEQ(name, "FLT_MIN_EXP"))
1215 if (strEQ(name, "FLT_RADIX"))
1223 if (strnEQ(name, "F_", 2)) {
1224 if (strEQ(name, "F_DUPFD"))
1230 if (strEQ(name, "F_GETFD"))
1236 if (strEQ(name, "F_GETFL"))
1242 if (strEQ(name, "F_GETLK"))
1248 if (strEQ(name, "F_OK"))
1254 if (strEQ(name, "F_RDLCK"))
1260 if (strEQ(name, "F_SETFD"))
1266 if (strEQ(name, "F_SETFL"))
1272 if (strEQ(name, "F_SETLK"))
1278 if (strEQ(name, "F_SETLKW"))
1284 if (strEQ(name, "F_UNLCK"))
1290 if (strEQ(name, "F_WRLCK"))
1298 if (strEQ(name, "FD_CLOEXEC"))
1304 if (strEQ(name, "FILENAME_MAX"))
1306 return FILENAME_MAX;
1312 if (strEQ(name, "HUGE_VAL"))
1318 if (strEQ(name, "HUPCL"))
1326 if (strEQ(name, "INT_MAX"))
1332 if (strEQ(name, "INT_MIN"))
1338 if (strEQ(name, "ICANON"))
1344 if (strEQ(name, "ICRNL"))
1350 if (strEQ(name, "IEXTEN"))
1356 if (strEQ(name, "IGNBRK"))
1362 if (strEQ(name, "IGNCR"))
1368 if (strEQ(name, "IGNPAR"))
1374 if (strEQ(name, "INLCR"))
1380 if (strEQ(name, "INPCK"))
1386 if (strEQ(name, "ISIG"))
1392 if (strEQ(name, "ISTRIP"))
1398 if (strEQ(name, "IXOFF"))
1404 if (strEQ(name, "IXON"))
1412 if (strnEQ(name, "LC_", 3)) {
1413 if (strEQ(name, "LC_ALL"))
1419 if (strEQ(name, "LC_COLLATE"))
1425 if (strEQ(name, "LC_CTYPE"))
1431 if (strEQ(name, "LC_MONETARY"))
1437 if (strEQ(name, "LC_NUMERIC"))
1443 if (strEQ(name, "LC_TIME"))
1451 if (strnEQ(name, "LDBL_", 5)) {
1452 if (strEQ(name, "LDBL_MAX"))
1458 if (strEQ(name, "LDBL_MIN"))
1464 if (strEQ(name, "LDBL_DIG"))
1470 if (strEQ(name, "LDBL_EPSILON"))
1472 return LDBL_EPSILON;
1476 if (strEQ(name, "LDBL_MANT_DIG"))
1477 #ifdef LDBL_MANT_DIG
1478 return LDBL_MANT_DIG;
1482 if (strEQ(name, "LDBL_MAX_10_EXP"))
1483 #ifdef LDBL_MAX_10_EXP
1484 return LDBL_MAX_10_EXP;
1488 if (strEQ(name, "LDBL_MAX_EXP"))
1490 return LDBL_MAX_EXP;
1494 if (strEQ(name, "LDBL_MIN_10_EXP"))
1495 #ifdef LDBL_MIN_10_EXP
1496 return LDBL_MIN_10_EXP;
1500 if (strEQ(name, "LDBL_MIN_EXP"))
1502 return LDBL_MIN_EXP;
1508 if (strnEQ(name, "L_", 2)) {
1509 if (strEQ(name, "L_ctermid"))
1515 if (strEQ(name, "L_cuserid"))
1521 if (strEQ(name, "L_tmpname"))
1529 if (strEQ(name, "LONG_MAX"))
1535 if (strEQ(name, "LONG_MIN"))
1541 if (strEQ(name, "LINK_MAX"))
1549 if (strEQ(name, "MAX_CANON"))
1555 if (strEQ(name, "MAX_INPUT"))
1561 if (strEQ(name, "MB_CUR_MAX"))
1567 if (strEQ(name, "MB_LEN_MAX"))
1575 if (strEQ(name, "NULL")) return 0;
1576 if (strEQ(name, "NAME_MAX"))
1582 if (strEQ(name, "NCCS"))
1588 if (strEQ(name, "NGROUPS_MAX"))
1594 if (strEQ(name, "NOFLSH"))
1602 if (strnEQ(name, "O_", 2)) {
1603 if (strEQ(name, "O_APPEND"))
1609 if (strEQ(name, "O_CREAT"))
1615 if (strEQ(name, "O_TRUNC"))
1621 if (strEQ(name, "O_RDONLY"))
1627 if (strEQ(name, "O_RDWR"))
1633 if (strEQ(name, "O_WRONLY"))
1639 if (strEQ(name, "O_EXCL"))
1645 if (strEQ(name, "O_NOCTTY"))
1651 if (strEQ(name, "O_NONBLOCK"))
1657 if (strEQ(name, "O_ACCMODE"))
1665 if (strEQ(name, "OPEN_MAX"))
1671 if (strEQ(name, "OPOST"))
1679 if (strEQ(name, "PATH_MAX"))
1685 if (strEQ(name, "PARENB"))
1691 if (strEQ(name, "PARMRK"))
1697 if (strEQ(name, "PARODD"))
1703 if (strEQ(name, "PIPE_BUF"))
1711 if (strEQ(name, "RAND_MAX"))
1717 if (strEQ(name, "R_OK"))
1725 if (strnEQ(name, "SIG", 3)) {
1726 if (name[3] == '_') {
1727 if (strEQ(name, "SIG_BLOCK"))
1734 if (strEQ(name, "SIG_DFL")) return (IV)SIG_DFL;
1737 if (strEQ(name, "SIG_ERR")) return (IV)SIG_ERR;
1740 if (strEQ(name, "SIG_IGN")) return (IV)SIG_IGN;
1742 if (strEQ(name, "SIG_SETMASK"))
1748 if (strEQ(name, "SIG_UNBLOCK"))
1756 if (strEQ(name, "SIGABRT"))
1762 if (strEQ(name, "SIGALRM"))
1768 if (strEQ(name, "SIGCHLD"))
1774 if (strEQ(name, "SIGCONT"))
1780 if (strEQ(name, "SIGFPE"))
1786 if (strEQ(name, "SIGHUP"))
1792 if (strEQ(name, "SIGILL"))
1798 if (strEQ(name, "SIGINT"))
1804 if (strEQ(name, "SIGKILL"))
1810 if (strEQ(name, "SIGPIPE"))
1816 if (strEQ(name, "SIGQUIT"))
1822 if (strEQ(name, "SIGSEGV"))
1828 if (strEQ(name, "SIGSTOP"))
1834 if (strEQ(name, "SIGTERM"))
1840 if (strEQ(name, "SIGTSTP"))
1846 if (strEQ(name, "SIGTTIN"))
1852 if (strEQ(name, "SIGTTOU"))
1858 if (strEQ(name, "SIGUSR1"))
1864 if (strEQ(name, "SIGUSR2"))
1872 if (name[1] == '_') {
1873 if (strEQ(name, "S_ISGID"))
1879 if (strEQ(name, "S_ISUID"))
1885 if (strEQ(name, "S_IRGRP"))
1891 if (strEQ(name, "S_IROTH"))
1897 if (strEQ(name, "S_IRUSR"))
1903 if (strEQ(name, "S_IRWXG"))
1909 if (strEQ(name, "S_IRWXO"))
1915 if (strEQ(name, "S_IRWXU"))
1921 if (strEQ(name, "S_IWGRP"))
1927 if (strEQ(name, "S_IWOTH"))
1933 if (strEQ(name, "S_IWUSR"))
1939 if (strEQ(name, "S_IXGRP"))
1945 if (strEQ(name, "S_IXOTH"))
1951 if (strEQ(name, "S_IXUSR"))
1957 errno = EAGAIN; /* the following aren't constants */
1959 if (strEQ(name, "S_ISBLK")) return S_ISBLK(arg);
1962 if (strEQ(name, "S_ISCHR")) return S_ISCHR(arg);
1965 if (strEQ(name, "S_ISDIR")) return S_ISDIR(arg);
1968 if (strEQ(name, "S_ISFIFO")) return S_ISFIFO(arg);
1971 if (strEQ(name, "S_ISREG")) return S_ISREG(arg);
1975 if (strEQ(name, "SEEK_CUR"))
1981 if (strEQ(name, "SEEK_END"))
1987 if (strEQ(name, "SEEK_SET"))
1993 if (strEQ(name, "STREAM_MAX"))
1999 if (strEQ(name, "SHRT_MAX"))
2005 if (strEQ(name, "SHRT_MIN"))
2011 if (strnEQ(name, "SA_", 3)) {
2012 if (strEQ(name, "SA_NOCLDSTOP"))
2014 return SA_NOCLDSTOP;
2018 if (strEQ(name, "SA_NOCLDWAIT"))
2020 return SA_NOCLDWAIT;
2024 if (strEQ(name, "SA_NODEFER"))
2030 if (strEQ(name, "SA_ONSTACK"))
2036 if (strEQ(name, "SA_RESETHAND"))
2038 return SA_RESETHAND;
2042 if (strEQ(name, "SA_RESTART"))
2048 if (strEQ(name, "SA_SIGINFO"))
2056 if (strEQ(name, "SCHAR_MAX"))
2062 if (strEQ(name, "SCHAR_MIN"))
2068 if (strEQ(name, "SSIZE_MAX"))
2074 if (strEQ(name, "STDIN_FILENO"))
2076 return STDIN_FILENO;
2080 if (strEQ(name, "STDOUT_FILENO"))
2081 #ifdef STDOUT_FILENO
2082 return STDOUT_FILENO;
2086 if (strEQ(name, "STRERR_FILENO"))
2087 #ifdef STRERR_FILENO
2088 return STRERR_FILENO;
2094 if (strEQ(name, "TCIFLUSH"))
2100 if (strEQ(name, "TCIOFF"))
2106 if (strEQ(name, "TCIOFLUSH"))
2112 if (strEQ(name, "TCION"))
2118 if (strEQ(name, "TCOFLUSH"))
2124 if (strEQ(name, "TCOOFF"))
2130 if (strEQ(name, "TCOON"))
2136 if (strEQ(name, "TCSADRAIN"))
2142 if (strEQ(name, "TCSAFLUSH"))
2148 if (strEQ(name, "TCSANOW"))
2154 if (strEQ(name, "TMP_MAX"))
2160 if (strEQ(name, "TOSTOP"))
2166 if (strEQ(name, "TZNAME_MAX"))
2174 if (strEQ(name, "UCHAR_MAX"))
2180 if (strEQ(name, "UINT_MAX"))
2186 if (strEQ(name, "ULONG_MAX"))
2192 if (strEQ(name, "USHRT_MAX"))
2200 if (strEQ(name, "VEOF"))
2206 if (strEQ(name, "VEOL"))
2212 if (strEQ(name, "VERASE"))
2218 if (strEQ(name, "VINTR"))
2224 if (strEQ(name, "VKILL"))
2230 if (strEQ(name, "VMIN"))
2236 if (strEQ(name, "VQUIT"))
2242 if (strEQ(name, "VSTART"))
2248 if (strEQ(name, "VSTOP"))
2254 if (strEQ(name, "VSUSP"))
2260 if (strEQ(name, "VTIME"))
2268 if (strEQ(name, "W_OK"))
2274 if (strEQ(name, "WNOHANG"))
2280 if (strEQ(name, "WUNTRACED"))
2286 errno = EAGAIN; /* the following aren't constants */
2288 if (strEQ(name, "WEXITSTATUS")) return WEXITSTATUS(arg);
2291 if (strEQ(name, "WIFEXITED")) return WIFEXITED(arg);
2294 if (strEQ(name, "WIFSIGNALED")) return WIFSIGNALED(arg);
2297 if (strEQ(name, "WIFSTOPPED")) return WIFSTOPPED(arg);
2300 if (strEQ(name, "WSTOPSIG")) return WSTOPSIG(arg);
2303 if (strEQ(name, "WTERMSIG")) return WTERMSIG(arg);
2307 if (strEQ(name, "X_OK"))
2315 if (strnEQ(name, "_PC_", 4)) {
2316 if (strEQ(name, "_PC_CHOWN_RESTRICTED"))
2317 #if defined(_PC_CHOWN_RESTRICTED) || HINT_SC_EXIST
2318 return _PC_CHOWN_RESTRICTED;
2322 if (strEQ(name, "_PC_LINK_MAX"))
2323 #if defined(_PC_LINK_MAX) || HINT_SC_EXIST
2324 return _PC_LINK_MAX;
2328 if (strEQ(name, "_PC_MAX_CANON"))
2329 #if defined(_PC_MAX_CANON) || HINT_SC_EXIST
2330 return _PC_MAX_CANON;
2334 if (strEQ(name, "_PC_MAX_INPUT"))
2335 #if defined(_PC_MAX_INPUT) || HINT_SC_EXIST
2336 return _PC_MAX_INPUT;
2340 if (strEQ(name, "_PC_NAME_MAX"))
2341 #if defined(_PC_NAME_MAX) || HINT_SC_EXIST
2342 return _PC_NAME_MAX;
2346 if (strEQ(name, "_PC_NO_TRUNC"))
2347 #if defined(_PC_NO_TRUNC) || HINT_SC_EXIST
2348 return _PC_NO_TRUNC;
2352 if (strEQ(name, "_PC_PATH_MAX"))
2353 #if defined(_PC_PATH_MAX) || HINT_SC_EXIST
2354 return _PC_PATH_MAX;
2358 if (strEQ(name, "_PC_PIPE_BUF"))
2359 #if defined(_PC_PIPE_BUF) || HINT_SC_EXIST
2360 return _PC_PIPE_BUF;
2364 if (strEQ(name, "_PC_VDISABLE"))
2365 #if defined(_PC_VDISABLE) || HINT_SC_EXIST
2366 return _PC_VDISABLE;
2372 if (strnEQ(name, "_POSIX_", 7)) {
2373 if (strEQ(name, "_POSIX_ARG_MAX"))
2374 #ifdef _POSIX_ARG_MAX
2375 return _POSIX_ARG_MAX;
2379 if (strEQ(name, "_POSIX_CHILD_MAX"))
2380 #ifdef _POSIX_CHILD_MAX
2381 return _POSIX_CHILD_MAX;
2385 if (strEQ(name, "_POSIX_CHOWN_RESTRICTED"))
2386 #ifdef _POSIX_CHOWN_RESTRICTED
2387 return _POSIX_CHOWN_RESTRICTED;
2391 if (strEQ(name, "_POSIX_JOB_CONTROL"))
2392 #ifdef _POSIX_JOB_CONTROL
2393 return _POSIX_JOB_CONTROL;
2397 if (strEQ(name, "_POSIX_LINK_MAX"))
2398 #ifdef _POSIX_LINK_MAX
2399 return _POSIX_LINK_MAX;
2403 if (strEQ(name, "_POSIX_MAX_CANON"))
2404 #ifdef _POSIX_MAX_CANON
2405 return _POSIX_MAX_CANON;
2409 if (strEQ(name, "_POSIX_MAX_INPUT"))
2410 #ifdef _POSIX_MAX_INPUT
2411 return _POSIX_MAX_INPUT;
2415 if (strEQ(name, "_POSIX_NAME_MAX"))
2416 #ifdef _POSIX_NAME_MAX
2417 return _POSIX_NAME_MAX;
2421 if (strEQ(name, "_POSIX_NGROUPS_MAX"))
2422 #ifdef _POSIX_NGROUPS_MAX
2423 return _POSIX_NGROUPS_MAX;
2427 if (strEQ(name, "_POSIX_NO_TRUNC"))
2428 #ifdef _POSIX_NO_TRUNC
2429 return _POSIX_NO_TRUNC;
2433 if (strEQ(name, "_POSIX_OPEN_MAX"))
2434 #ifdef _POSIX_OPEN_MAX
2435 return _POSIX_OPEN_MAX;
2439 if (strEQ(name, "_POSIX_PATH_MAX"))
2440 #ifdef _POSIX_PATH_MAX
2441 return _POSIX_PATH_MAX;
2445 if (strEQ(name, "_POSIX_PIPE_BUF"))
2446 #ifdef _POSIX_PIPE_BUF
2447 return _POSIX_PIPE_BUF;
2451 if (strEQ(name, "_POSIX_SAVED_IDS"))
2452 #ifdef _POSIX_SAVED_IDS
2453 return _POSIX_SAVED_IDS;
2457 if (strEQ(name, "_POSIX_SSIZE_MAX"))
2458 #ifdef _POSIX_SSIZE_MAX
2459 return _POSIX_SSIZE_MAX;
2463 if (strEQ(name, "_POSIX_STREAM_MAX"))
2464 #ifdef _POSIX_STREAM_MAX
2465 return _POSIX_STREAM_MAX;
2469 if (strEQ(name, "_POSIX_TZNAME_MAX"))
2470 #ifdef _POSIX_TZNAME_MAX
2471 return _POSIX_TZNAME_MAX;
2475 if (strEQ(name, "_POSIX_VDISABLE"))
2476 #ifdef _POSIX_VDISABLE
2477 return _POSIX_VDISABLE;
2481 if (strEQ(name, "_POSIX_VERSION"))
2482 #ifdef _POSIX_VERSION
2483 return _POSIX_VERSION;
2489 if (strnEQ(name, "_SC_", 4)) {
2490 if (strEQ(name, "_SC_ARG_MAX"))
2491 #if defined(_SC_ARG_MAX) || HINT_SC_EXIST
2496 if (strEQ(name, "_SC_CHILD_MAX"))
2497 #if defined(_SC_CHILD_MAX) || HINT_SC_EXIST
2498 return _SC_CHILD_MAX;
2502 if (strEQ(name, "_SC_CLK_TCK"))
2503 #if defined(_SC_CLK_TCK) || HINT_SC_EXIST
2508 if (strEQ(name, "_SC_JOB_CONTROL"))
2509 #if defined(_SC_JOB_CONTROL) || HINT_SC_EXIST
2510 return _SC_JOB_CONTROL;
2514 if (strEQ(name, "_SC_NGROUPS_MAX"))
2515 #if defined(_SC_NGROUPS_MAX) || HINT_SC_EXIST
2516 return _SC_NGROUPS_MAX;
2520 if (strEQ(name, "_SC_OPEN_MAX"))
2521 #if defined(_SC_OPEN_MAX) || HINT_SC_EXIST
2522 return _SC_OPEN_MAX;
2526 if (strEQ(name, "_SC_SAVED_IDS"))
2527 #if defined(_SC_SAVED_IDS) || HINT_SC_EXIST
2528 return _SC_SAVED_IDS;
2532 if (strEQ(name, "_SC_STREAM_MAX"))
2533 #if defined(_SC_STREAM_MAX) || HINT_SC_EXIST
2534 return _SC_STREAM_MAX;
2538 if (strEQ(name, "_SC_TZNAME_MAX"))
2539 #if defined(_SC_TZNAME_MAX) || HINT_SC_EXIST
2540 return _SC_TZNAME_MAX;
2544 if (strEQ(name, "_SC_VERSION"))
2545 #if defined(_SC_VERSION) || HINT_SC_EXIST
2561 MODULE = SigSet PACKAGE = POSIX::SigSet PREFIX = sig
2564 new(packname = "POSIX::SigSet", ...)
2569 RETVAL = (sigset_t*)safemalloc(sizeof(sigset_t));
2570 sigemptyset(RETVAL);
2571 for (i = 1; i < items; i++)
2572 sigaddset(RETVAL, SvIV(ST(i)));
2579 POSIX::SigSet sigset
2581 safefree((char *)sigset);
2584 sigaddset(sigset, sig)
2585 POSIX::SigSet sigset
2589 sigdelset(sigset, sig)
2590 POSIX::SigSet sigset
2595 POSIX::SigSet sigset
2599 POSIX::SigSet sigset
2602 sigismember(sigset, sig)
2603 POSIX::SigSet sigset
2607 MODULE = Termios PACKAGE = POSIX::Termios PREFIX = cf
2610 new(packname = "POSIX::Termios", ...)
2615 RETVAL = (struct termios*)safemalloc(sizeof(struct termios));
2617 not_here("termios");
2625 DESTROY(termios_ref)
2626 POSIX::Termios termios_ref
2629 safefree((char *)termios_ref);
2631 not_here("termios");
2635 getattr(termios_ref, fd = 0)
2636 POSIX::Termios termios_ref
2639 RETVAL = tcgetattr(fd, termios_ref);
2644 setattr(termios_ref, fd = 0, optional_actions = 0)
2645 POSIX::Termios termios_ref
2647 int optional_actions
2649 RETVAL = tcsetattr(fd, optional_actions, termios_ref);
2654 cfgetispeed(termios_ref)
2655 POSIX::Termios termios_ref
2658 cfgetospeed(termios_ref)
2659 POSIX::Termios termios_ref
2662 getiflag(termios_ref)
2663 POSIX::Termios termios_ref
2665 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2666 RETVAL = termios_ref->c_iflag;
2668 not_here("getiflag");
2675 getoflag(termios_ref)
2676 POSIX::Termios termios_ref
2678 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2679 RETVAL = termios_ref->c_oflag;
2681 not_here("getoflag");
2688 getcflag(termios_ref)
2689 POSIX::Termios termios_ref
2691 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2692 RETVAL = termios_ref->c_cflag;
2694 not_here("getcflag");
2701 getlflag(termios_ref)
2702 POSIX::Termios termios_ref
2704 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2705 RETVAL = termios_ref->c_lflag;
2707 not_here("getlflag");
2714 getcc(termios_ref, ccix)
2715 POSIX::Termios termios_ref
2718 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2720 croak("Bad getcc subscript");
2721 RETVAL = termios_ref->c_cc[ccix];
2730 cfsetispeed(termios_ref, speed)
2731 POSIX::Termios termios_ref
2735 cfsetospeed(termios_ref, speed)
2736 POSIX::Termios termios_ref
2740 setiflag(termios_ref, iflag)
2741 POSIX::Termios termios_ref
2744 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2745 termios_ref->c_iflag = iflag;
2747 not_here("setiflag");
2751 setoflag(termios_ref, oflag)
2752 POSIX::Termios termios_ref
2755 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2756 termios_ref->c_oflag = oflag;
2758 not_here("setoflag");
2762 setcflag(termios_ref, cflag)
2763 POSIX::Termios termios_ref
2766 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2767 termios_ref->c_cflag = cflag;
2769 not_here("setcflag");
2773 setlflag(termios_ref, lflag)
2774 POSIX::Termios termios_ref
2777 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2778 termios_ref->c_lflag = lflag;
2780 not_here("setlflag");
2784 setcc(termios_ref, ccix, cc)
2785 POSIX::Termios termios_ref
2789 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2791 croak("Bad setcc subscript");
2792 termios_ref->c_cc[ccix] = cc;
2798 MODULE = POSIX PACKAGE = POSIX
2807 unsigned char * charstring
2809 unsigned char *s = charstring;
2810 unsigned char *e = s + na; /* "na" set by typemap side effect */
2811 for (RETVAL = 1; RETVAL && s < e; s++)
2819 unsigned char * charstring
2821 unsigned char *s = charstring;
2822 unsigned char *e = s + na; /* "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 + na; /* "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 + na; /* "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 + na; /* "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 + na; /* "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 + na; /* "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 + na; /* "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 + na; /* "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 + na; /* "na" set by typemap side effect */
2919 for (RETVAL = 1; RETVAL && s < e; s++)
2926 isxdigit(charstring)
2927 unsigned char * charstring
2929 unsigned char *s = charstring;
2930 unsigned char *e = s + na; /* "na" set by typemap side effect */
2931 for (RETVAL = 1; RETVAL && s < e; s++)
2938 open(filename, flags = O_RDONLY, mode = 0666)
2943 if (flags & (O_APPEND|O_CREAT|O_TRUNC|O_RDWR|O_WRONLY|O_EXCL))
2944 TAINT_PROPER("open");
2945 RETVAL = open(filename, flags, mode);
2953 #ifdef HAS_LOCALECONV
2954 struct lconv *lcbuf;
2956 SET_NUMERIC_LOCAL();
2957 if (lcbuf = localeconv()) {
2959 if (lcbuf->decimal_point && *lcbuf->decimal_point)
2960 hv_store(RETVAL, "decimal_point", 13,
2961 newSVpv(lcbuf->decimal_point, 0), 0);
2962 if (lcbuf->thousands_sep && *lcbuf->thousands_sep)
2963 hv_store(RETVAL, "thousands_sep", 13,
2964 newSVpv(lcbuf->thousands_sep, 0), 0);
2965 #ifndef NO_LOCALECONV_GROUPING
2966 if (lcbuf->grouping && *lcbuf->grouping)
2967 hv_store(RETVAL, "grouping", 8,
2968 newSVpv(lcbuf->grouping, 0), 0);
2970 if (lcbuf->int_curr_symbol && *lcbuf->int_curr_symbol)
2971 hv_store(RETVAL, "int_curr_symbol", 15,
2972 newSVpv(lcbuf->int_curr_symbol, 0), 0);
2973 if (lcbuf->currency_symbol && *lcbuf->currency_symbol)
2974 hv_store(RETVAL, "currency_symbol", 15,
2975 newSVpv(lcbuf->currency_symbol, 0), 0);
2976 if (lcbuf->mon_decimal_point && *lcbuf->mon_decimal_point)
2977 hv_store(RETVAL, "mon_decimal_point", 17,
2978 newSVpv(lcbuf->mon_decimal_point, 0), 0);
2979 #ifndef NO_LOCALECONV_MON_THOUSANDS_SEP
2980 if (lcbuf->mon_thousands_sep && *lcbuf->mon_thousands_sep)
2981 hv_store(RETVAL, "mon_thousands_sep", 17,
2982 newSVpv(lcbuf->mon_thousands_sep, 0), 0);
2984 #ifndef NO_LOCALECONV_MON_GROUPING
2985 if (lcbuf->mon_grouping && *lcbuf->mon_grouping)
2986 hv_store(RETVAL, "mon_grouping", 12,
2987 newSVpv(lcbuf->mon_grouping, 0), 0);
2989 if (lcbuf->positive_sign && *lcbuf->positive_sign)
2990 hv_store(RETVAL, "positive_sign", 13,
2991 newSVpv(lcbuf->positive_sign, 0), 0);
2992 if (lcbuf->negative_sign && *lcbuf->negative_sign)
2993 hv_store(RETVAL, "negative_sign", 13,
2994 newSVpv(lcbuf->negative_sign, 0), 0);
2996 if (lcbuf->int_frac_digits != CHAR_MAX)
2997 hv_store(RETVAL, "int_frac_digits", 15,
2998 newSViv(lcbuf->int_frac_digits), 0);
2999 if (lcbuf->frac_digits != CHAR_MAX)
3000 hv_store(RETVAL, "frac_digits", 11,
3001 newSViv(lcbuf->frac_digits), 0);
3002 if (lcbuf->p_cs_precedes != CHAR_MAX)
3003 hv_store(RETVAL, "p_cs_precedes", 13,
3004 newSViv(lcbuf->p_cs_precedes), 0);
3005 if (lcbuf->p_sep_by_space != CHAR_MAX)
3006 hv_store(RETVAL, "p_sep_by_space", 14,
3007 newSViv(lcbuf->p_sep_by_space), 0);
3008 if (lcbuf->n_cs_precedes != CHAR_MAX)
3009 hv_store(RETVAL, "n_cs_precedes", 13,
3010 newSViv(lcbuf->n_cs_precedes), 0);
3011 if (lcbuf->n_sep_by_space != CHAR_MAX)
3012 hv_store(RETVAL, "n_sep_by_space", 14,
3013 newSViv(lcbuf->n_sep_by_space), 0);
3014 if (lcbuf->p_sign_posn != CHAR_MAX)
3015 hv_store(RETVAL, "p_sign_posn", 11,
3016 newSViv(lcbuf->p_sign_posn), 0);
3017 if (lcbuf->n_sign_posn != CHAR_MAX)
3018 hv_store(RETVAL, "n_sign_posn", 11,
3019 newSViv(lcbuf->n_sign_posn), 0);
3022 localeconv(); /* A stub to call not_here(). */
3028 setlocale(category, locale = 0)
3032 RETVAL = setlocale(category, locale);
3034 #ifdef USE_LOCALE_CTYPE
3035 if (category == LC_CTYPE
3037 || category == LC_ALL
3043 if (category == LC_ALL)
3044 newctype = setlocale(LC_CTYPE, NULL);
3048 perl_new_ctype(newctype);
3050 #endif /* USE_LOCALE_CTYPE */
3051 #ifdef USE_LOCALE_COLLATE
3052 if (category == LC_COLLATE
3054 || category == LC_ALL
3060 if (category == LC_ALL)
3061 newcoll = setlocale(LC_COLLATE, NULL);
3065 perl_new_collate(newcoll);
3067 #endif /* USE_LOCALE_COLLATE */
3068 #ifdef USE_LOCALE_NUMERIC
3069 if (category == LC_NUMERIC
3071 || category == LC_ALL
3077 if (category == LC_ALL)
3078 newnum = setlocale(LC_NUMERIC, NULL);
3082 perl_new_numeric(newnum);
3084 #endif /* USE_LOCALE_NUMERIC */
3124 /* (We already know stack is long enough.) */
3125 PUSHs(sv_2mortal(newSVnv(frexp(x,&expvar))));
3126 PUSHs(sv_2mortal(newSViv(expvar)));
3142 /* (We already know stack is long enough.) */
3143 PUSHs(sv_2mortal(newSVnv(modf(x,&intvar))));
3144 PUSHs(sv_2mortal(newSVnv(intvar)));
3159 sigaction(sig, action, oldaction = 0)
3161 POSIX::SigAction action
3162 POSIX::SigAction oldaction
3165 RETVAL = not_here("sigaction");
3167 # This code is really grody because we're trying to make the signal
3168 # interface look beautiful, which is hard.
3171 gv_fetchpv("SIG", TRUE, SVt_PVHV);
3174 struct sigaction act;
3175 struct sigaction oact;
3176 POSIX__SigSet sigset;
3178 SV** sigsvp = hv_fetch(GvHVn(siggv),
3180 strlen(sig_name[sig]),
3183 /* Remember old handler name if desired. */
3185 char *hand = SvPVx(*sigsvp, na);
3186 svp = hv_fetch(oldaction, "HANDLER", 7, TRUE);
3187 sv_setpv(*svp, *hand ? hand : "DEFAULT");
3191 /* Vector new handler through %SIG. (We always use sighandler
3192 for the C signal handler, which reads %SIG to dispatch.) */
3193 svp = hv_fetch(action, "HANDLER", 7, FALSE);
3195 croak("Can't supply an action without a HANDLER");
3196 sv_setpv(*sigsvp, SvPV(*svp, na));
3197 mg_set(*sigsvp); /* handles DEFAULT and IGNORE */
3198 act.sa_handler = sighandler;
3200 /* Set up any desired mask. */
3201 svp = hv_fetch(action, "MASK", 4, FALSE);
3202 if (svp && sv_isa(*svp, "POSIX::SigSet")) {
3204 tmp = (unsigned long)SvNV((SV*)SvRV(*svp));
3205 sigset = (sigset_t*) tmp;
3206 act.sa_mask = *sigset;
3209 sigemptyset(& act.sa_mask);
3211 /* Set up any desired flags. */
3212 svp = hv_fetch(action, "FLAGS", 5, FALSE);
3213 act.sa_flags = svp ? SvIV(*svp) : 0;
3216 /* Now work around sigaction oddities */
3217 if (action && oldaction)
3218 RETVAL = sigaction(sig, & act, & oact);
3220 RETVAL = sigaction(sig, & act, (struct sigaction *)0);
3222 RETVAL = sigaction(sig, (struct sigaction *)0, & oact);
3227 /* Get back the mask. */
3228 svp = hv_fetch(oldaction, "MASK", 4, TRUE);
3229 if (sv_isa(*svp, "POSIX::SigSet")) {
3231 tmp = (unsigned long)SvNV((SV*)SvRV(*svp));
3232 sigset = (sigset_t*) tmp;
3235 sigset = (sigset_t*)safemalloc(sizeof(sigset_t));
3236 sv_setptrobj(*svp, sigset, "POSIX::SigSet");
3238 *sigset = oact.sa_mask;
3240 /* Get back the flags. */
3241 svp = hv_fetch(oldaction, "FLAGS", 5, TRUE);
3242 sv_setiv(*svp, oact.sa_flags);
3251 POSIX::SigSet sigset
3254 sigprocmask(how, sigset, oldsigset = 0)
3256 POSIX::SigSet sigset
3257 POSIX::SigSet oldsigset
3260 sigsuspend(signal_mask)
3261 POSIX::SigSet signal_mask
3281 lseek(fd, offset, whence)
3294 if (pipe(fds) != -1) {
3296 PUSHs(sv_2mortal(newSViv(fds[0])));
3297 PUSHs(sv_2mortal(newSViv(fds[1])));
3301 read(fd, buffer, nbytes)
3303 SV *sv_buffer = SvROK(ST(1)) ? SvRV(ST(1)) : ST(1);
3307 char * buffer = sv_grow( sv_buffer, nbytes+1 );
3310 SvCUR(sv_buffer) = RETVAL;
3311 SvPOK_only(sv_buffer);
3312 *SvEND(sv_buffer) = '\0';
3313 SvTAINTED_on(sv_buffer);
3329 tcsetpgrp(fd, pgrp_id)
3338 if (uname(&buf) >= 0) {
3340 PUSHs(sv_2mortal(newSVpv(buf.sysname, 0)));
3341 PUSHs(sv_2mortal(newSVpv(buf.nodename, 0)));
3342 PUSHs(sv_2mortal(newSVpv(buf.release, 0)));
3343 PUSHs(sv_2mortal(newSVpv(buf.version, 0)));
3344 PUSHs(sv_2mortal(newSVpv(buf.machine, 0)));
3347 uname((char *) 0); /* A stub to call not_here(). */
3351 write(fd, buffer, nbytes)
3369 mbstowcs(s, pwcs, n)
3381 wcstombs(s, pwcs, n)
3403 SET_NUMERIC_LOCAL();
3404 num = strtod(str, &unparsed);
3405 PUSHs(sv_2mortal(newSVnv(num)));
3406 if (GIMME == G_ARRAY) {
3409 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3415 strtol(str, base = 0)
3422 num = strtol(str, &unparsed, base);
3423 if (num >= IV_MIN && num <= IV_MAX)
3424 PUSHs(sv_2mortal(newSViv((IV)num)));
3426 PUSHs(sv_2mortal(newSVnv((double)num)));
3427 if (GIMME == G_ARRAY) {
3430 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3436 strtoul(str, base = 0)
3443 num = strtoul(str, &unparsed, base);
3445 PUSHs(sv_2mortal(newSViv((IV)num)));
3447 PUSHs(sv_2mortal(newSVnv((double)num)));
3448 if (GIMME == G_ARRAY) {
3451 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3463 char *p = SvPV(src,srclen);
3465 ST(0) = sv_2mortal(NEWSV(800,srclen));
3466 dstlen = strxfrm(SvPVX(ST(0)), p, (size_t)srclen);
3467 if (dstlen > srclen) {
3469 SvGROW(ST(0), dstlen);
3470 strxfrm(SvPVX(ST(0)), p, (size_t)dstlen);
3473 SvCUR(ST(0)) = dstlen;
3478 mkfifo(filename, mode)
3482 TAINT_PROPER("mkfifo");
3483 RETVAL = mkfifo(filename, mode);
3499 tcflush(fd, queue_selector)
3504 tcsendbreak(fd, duration)
3509 asctime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3522 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3525 mytm.tm_hour = hour;
3526 mytm.tm_mday = mday;
3528 mytm.tm_year = year;
3529 mytm.tm_wday = wday;
3530 mytm.tm_yday = yday;
3531 mytm.tm_isdst = isdst;
3532 RETVAL = asctime(&mytm);
3549 realtime = times( &tms );
3551 PUSHs( sv_2mortal( newSViv( (IV) realtime ) ) );
3552 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_utime ) ) );
3553 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_stime ) ) );
3554 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cutime ) ) );
3555 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cstime ) ) );
3558 difftime(time1, time2)
3563 mktime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3576 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3579 mytm.tm_hour = hour;
3580 mytm.tm_mday = mday;
3582 mytm.tm_year = year;
3583 mytm.tm_wday = wday;
3584 mytm.tm_yday = yday;
3585 mytm.tm_isdst = isdst;
3586 RETVAL = mktime(&mytm);
3592 strftime(fmt, sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3608 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3611 mytm.tm_hour = hour;
3612 mytm.tm_mday = mday;
3614 mytm.tm_year = year;
3615 mytm.tm_wday = wday;
3616 mytm.tm_yday = yday;
3617 mytm.tm_isdst = isdst;
3618 len = strftime(tmpbuf, sizeof tmpbuf, fmt, &mytm);
3619 ST(0) = sv_2mortal(newSVpv(tmpbuf, len));
3629 PUSHs(sv_2mortal(newSVpv(tzname[0],strlen(tzname[0]))));
3630 PUSHs(sv_2mortal(newSVpv(tzname[1],strlen(tzname[1]))));
3633 access(filename, mode)
3651 pathconf(filename, name)