5 #define PERLIO_NOT_STDIO 1
8 #ifdef PERL_OBJECT /* XXX _very_ temporary hacks */
12 # define open PerlLIO_open3
15 #ifdef I_DIRENT /* XXX maybe better to just rely on perl.h? */
38 /* XXX This comment is just to make I_TERMIO and I_SGTTY visible to
39 metaconfig for future extension writers. We don't use them in POSIX.
40 (This is really sneaky :-) --AD
42 #if defined(I_TERMIOS)
50 #include <sys/types.h>
57 #if defined(__VMS) && !defined(__POSIX_SOURCE)
58 # include <libdef.h> /* LIB$_INVARG constant */
59 # include <lib$routines.h> /* prototype for lib$ediv() */
60 # include <starlet.h> /* prototype for sys$gettim() */
61 # if DECC_VERSION < 50000000
62 # define pid_t int /* old versions of DECC miss this in types.h */
66 # define mkfifo(a,b) (not_here("mkfifo"),-1)
67 # define tzset() not_here("tzset")
69 #if ((__VMS_VER >= 70000000) && (__DECC_VER >= 50200000)) || (__CRTL_VER >= 70000000)
70 # define HAS_TZNAME /* shows up in VMS 7.0 or Dec C 5.6 */
72 # endif /* __VMS_VER >= 70000000 or Dec C 5.6 */
74 /* The POSIX notion of ttyname() is better served by getname() under VMS */
75 static char ttnambuf[64];
76 # define ttyname(fd) (isatty(fd) > 0 ? getname(fd,ttnambuf,0) : NULL)
78 /* The non-POSIX CRTL times() has void return type, so we just get the
79 current time directly */
80 clock_t vms_times(struct tms *PL_bufptr) {
82 /* Get wall time and convert to 10 ms intervals to
83 * produce the return value that the POSIX standard expects */
84 # if defined(__DECC) && defined (__ALPHA)
87 _ckvmssts(sys$gettim(&vmstime));
89 retval = vmstime & 0x7fffffff;
91 /* (Older hw or ccs don't have an atomic 64-bit type, so we
92 * juggle 32-bit ints (and a float) to produce a time_t result
93 * with minimal loss of information.) */
94 long int vmstime[2],remainder,divisor = 100000;
95 _ckvmssts(sys$gettim((unsigned long int *)vmstime));
96 vmstime[1] &= 0x7fff; /* prevent overflow in EDIV */
97 _ckvmssts(lib$ediv(&divisor,vmstime,(long int *)&retval,&remainder));
99 /* Fill in the struct tms using the CRTL routine . . .*/
100 times((tbuffer_t *)PL_bufptr);
101 return (clock_t) retval;
103 # define times(t) vms_times(t)
107 # define mkfifo(a,b) not_here("mkfifo")
108 # define ttyname(a) (char*)not_here("ttyname")
109 # define sigset_t long
112 # define tzname _tzname
115 # define mode_t short
118 # define mode_t short
120 # define tzset() not_here("tzset")
122 # ifndef _POSIX_OPEN_MAX
123 # define _POSIX_OPEN_MAX FOPEN_MAX /* XXX bogus ? */
126 # define sigaction(a,b,c) not_here("sigaction")
127 # define sigpending(a) not_here("sigpending")
128 # define sigprocmask(a,b,c) not_here("sigprocmask")
129 # define sigsuspend(a) not_here("sigsuspend")
130 # define sigemptyset(a) not_here("sigemptyset")
131 # define sigaddset(a,b) not_here("sigaddset")
132 # define sigdelset(a,b) not_here("sigdelset")
133 # define sigfillset(a) not_here("sigfillset")
134 # define sigismember(a,b) not_here("sigismember")
139 # define mkfifo(path, mode) (mknod((path), (mode) | S_IFIFO, 0))
141 # endif /* !HAS_MKFIFO */
144 # include <sys/times.h>
146 # include <sys/utsname.h>
148 # include <sys/wait.h>
156 typedef long SysRetLong;
157 typedef sigset_t* POSIX__SigSet;
158 typedef HV* POSIX__SigAction;
160 typedef struct termios* POSIX__Termios;
161 #else /* Define termios types to int, and call not_here for the functions.*/
162 #define POSIX__Termios int
166 #define cfgetispeed(x) not_here("cfgetispeed")
167 #define cfgetospeed(x) not_here("cfgetospeed")
168 #define tcdrain(x) not_here("tcdrain")
169 #define tcflush(x,y) not_here("tcflush")
170 #define tcsendbreak(x,y) not_here("tcsendbreak")
171 #define cfsetispeed(x,y) not_here("cfsetispeed")
172 #define cfsetospeed(x,y) not_here("cfsetospeed")
173 #define ctermid(x) (char *) not_here("ctermid")
174 #define tcflow(x,y) not_here("tcflow")
175 #define tcgetattr(x,y) not_here("tcgetattr")
176 #define tcsetattr(x,y,z) not_here("tcsetattr")
179 /* Possibly needed prototypes */
180 char *cuserid _((char *));
181 double strtod _((const char *, char **));
182 long strtol _((const char *, char **, int));
183 unsigned long strtoul _((const char *, char **, int));
186 #define cuserid(a) (char *) not_here("cuserid")
190 #define difftime(a,b) not_here("difftime")
193 #ifndef HAS_FPATHCONF
194 #define fpathconf(f,n) (SysRetLong) not_here("fpathconf")
197 #define mktime(a) not_here("mktime")
200 #define nice(a) not_here("nice")
203 #define pathconf(f,n) (SysRetLong) not_here("pathconf")
206 #define sysconf(n) (SysRetLong) not_here("sysconf")
209 #define readlink(a,b,c) not_here("readlink")
212 #define setpgid(a,b) not_here("setpgid")
215 #define setsid() not_here("setsid")
218 #define strcoll(s1,s2) not_here("strcoll")
221 #define strtod(s1,s2) not_here("strtod")
224 #define strtol(s1,s2,b) not_here("strtol")
227 #define strtoul(s1,s2,b) not_here("strtoul")
230 #define strxfrm(s1,s2,n) not_here("strxfrm")
232 #ifndef HAS_TCGETPGRP
233 #define tcgetpgrp(a) not_here("tcgetpgrp")
235 #ifndef HAS_TCSETPGRP
236 #define tcsetpgrp(a,b) not_here("tcsetpgrp")
239 #define times(a) not_here("times")
242 #define uname(a) not_here("uname")
245 #define waitpid(a,b,c) not_here("waitpid")
250 #define mblen(a,b) not_here("mblen")
254 #define mbstowcs(s, pwcs, n) not_here("mbstowcs")
257 #define mbtowc(pwc, s, n) not_here("mbtowc")
260 #define wcstombs(s, pwcs, n) not_here("wcstombs")
263 #define wctomb(s, wchar) not_here("wcstombs")
265 #if !defined(HAS_MBLEN) && !defined(HAS_MBSTOWCS) && !defined(HAS_MBTOWC) && !defined(HAS_WCSTOMBS) && !defined(HAS_WCTOMB)
266 /* If we don't have these functions, then we wouldn't have gotten a typedef
267 for wchar_t, the wide character type. Defining wchar_t allows the
268 functions referencing it to compile. Its actual type is then meaningless,
269 since without the above functions, all sections using it end up calling
270 not_here() and croak. --Kaveh Ghazi (ghazi@noc.rutgers.edu) 9/18/94. */
276 #ifndef HAS_LOCALECONV
277 #define localeconv() not_here("localeconv")
282 extern char *tzname[];
285 #if !defined(WIN32) || (defined(__MINGW32__) && !defined(tzname))
286 char *tzname[] = { "" , "" };
290 /* XXX struct tm on some systems (SunOS4/BSD) contains extra (non POSIX)
291 * fields for which we don't have Configure support yet:
292 * char *tm_zone; -- abbreviation of timezone name
293 * long tm_gmtoff; -- offset from GMT in seconds
294 * To workaround core dumps from the uninitialised tm_zone we get the
295 * system to give us a reasonable struct to copy. This fix means that
296 * strftime uses the tm_zone and tm_gmtoff values returned by
297 * localtime(time()). That should give the desired result most of the
298 * time. But probably not always!
300 * This is a temporary workaround to be removed once Configure
301 * support is added and NETaa14816 is considered in full.
302 * It does not address tzname aspects of NETaa14816.
305 # ifndef STRUCT_TM_HASZONE
306 # define STRUCT_TM_HAS_ZONE
310 #ifdef STRUCT_TM_HASZONE
312 init_tm(ptm) /* see mktime, strftime and asctime */
317 Copy(localtime(&now), ptm, 1, struct tm);
321 # define init_tm(ptm)
325 #ifdef HAS_LONG_DOUBLE
326 # if LONG_DOUBLESIZE > DOUBLESIZE
327 # undef HAS_LONG_DOUBLE /* XXX until we figure out how to use them */
331 #ifndef HAS_LONG_DOUBLE
346 croak("POSIX::%s not implemented on this architecture", s);
351 #ifdef HAS_LONG_DOUBLE
356 constant(char *name, int arg)
361 if (strEQ(name, "ARG_MAX"))
369 if (strEQ(name, "BUFSIZ"))
375 if (strEQ(name, "BRKINT"))
381 if (strEQ(name, "B9600"))
387 if (strEQ(name, "B19200"))
393 if (strEQ(name, "B38400"))
399 if (strEQ(name, "B0"))
405 if (strEQ(name, "B110"))
411 if (strEQ(name, "B1200"))
417 if (strEQ(name, "B134"))
423 if (strEQ(name, "B150"))
429 if (strEQ(name, "B1800"))
435 if (strEQ(name, "B200"))
441 if (strEQ(name, "B2400"))
447 if (strEQ(name, "B300"))
453 if (strEQ(name, "B4800"))
459 if (strEQ(name, "B50"))
465 if (strEQ(name, "B600"))
471 if (strEQ(name, "B75"))
479 if (strEQ(name, "CHAR_BIT"))
485 if (strEQ(name, "CHAR_MAX"))
491 if (strEQ(name, "CHAR_MIN"))
497 if (strEQ(name, "CHILD_MAX"))
503 if (strEQ(name, "CLK_TCK"))
509 if (strEQ(name, "CLOCAL"))
515 if (strEQ(name, "CLOCKS_PER_SEC"))
516 #ifdef CLOCKS_PER_SEC
517 return CLOCKS_PER_SEC;
521 if (strEQ(name, "CREAD"))
527 if (strEQ(name, "CS5"))
533 if (strEQ(name, "CS6"))
539 if (strEQ(name, "CS7"))
545 if (strEQ(name, "CS8"))
551 if (strEQ(name, "CSIZE"))
557 if (strEQ(name, "CSTOPB"))
565 if (strEQ(name, "DBL_MAX"))
571 if (strEQ(name, "DBL_MIN"))
577 if (strEQ(name, "DBL_DIG"))
583 if (strEQ(name, "DBL_EPSILON"))
589 if (strEQ(name, "DBL_MANT_DIG"))
595 if (strEQ(name, "DBL_MAX_10_EXP"))
596 #ifdef DBL_MAX_10_EXP
597 return DBL_MAX_10_EXP;
601 if (strEQ(name, "DBL_MAX_EXP"))
607 if (strEQ(name, "DBL_MIN_10_EXP"))
608 #ifdef DBL_MIN_10_EXP
609 return DBL_MIN_10_EXP;
613 if (strEQ(name, "DBL_MIN_EXP"))
623 if (strEQ(name, "EACCES"))
629 if (strEQ(name, "EADDRINUSE"))
635 if (strEQ(name, "EADDRNOTAVAIL"))
637 return EADDRNOTAVAIL;
641 if (strEQ(name, "EAFNOSUPPORT"))
647 if (strEQ(name, "EAGAIN"))
653 if (strEQ(name, "EALREADY"))
661 if (strEQ(name, "EBADF"))
667 if (strEQ(name, "EBUSY"))
675 if (strEQ(name, "ECHILD"))
681 if (strEQ(name, "ECHO"))
687 if (strEQ(name, "ECHOE"))
693 if (strEQ(name, "ECHOK"))
699 if (strEQ(name, "ECHONL"))
705 if (strEQ(name, "ECONNABORTED"))
711 if (strEQ(name, "ECONNREFUSED"))
717 if (strEQ(name, "ECONNRESET"))
725 if (strEQ(name, "EDEADLK"))
731 if (strEQ(name, "EDESTADDRREQ"))
737 if (strEQ(name, "EDOM"))
743 if (strEQ(name, "EDQUOT"))
751 if (strEQ(name, "EEXIST"))
759 if (strEQ(name, "EFAULT"))
765 if (strEQ(name, "EFBIG"))
773 if (strEQ(name, "EHOSTDOWN"))
779 if (strEQ(name, "EHOSTUNREACH"))
787 if (strEQ(name, "EINPROGRESS"))
793 if (strEQ(name, "EINTR"))
799 if (strEQ(name, "EINVAL"))
805 if (strEQ(name, "EIO"))
811 if (strEQ(name, "EISCONN"))
817 if (strEQ(name, "EISDIR"))
825 if (strEQ(name, "ELOOP"))
833 if (strEQ(name, "EMFILE"))
839 if (strEQ(name, "EMLINK"))
845 if (strEQ(name, "EMSGSIZE"))
853 if (strEQ(name, "ENETDOWN"))
859 if (strEQ(name, "ENETRESET"))
865 if (strEQ(name, "ENETUNREACH"))
871 if (strEQ(name, "ENOBUFS"))
877 if (strEQ(name, "ENOEXEC"))
883 if (strEQ(name, "ENOMEM"))
889 if (strEQ(name, "ENOPROTOOPT"))
895 if (strEQ(name, "ENOSPC"))
901 if (strEQ(name, "ENOTBLK"))
907 if (strEQ(name, "ENOTCONN"))
913 if (strEQ(name, "ENOTDIR"))
919 if (strEQ(name, "ENOTEMPTY"))
925 if (strEQ(name, "ENOTSOCK"))
931 if (strEQ(name, "ENOTTY"))
937 if (strEQ(name, "ENFILE"))
943 if (strEQ(name, "ENODEV"))
949 if (strEQ(name, "ENOENT"))
955 if (strEQ(name, "ENOLCK"))
961 if (strEQ(name, "ENOSYS"))
967 if (strEQ(name, "ENXIO"))
973 if (strEQ(name, "ENAMETOOLONG"))
981 if (strEQ(name, "EOF"))
987 if (strEQ(name, "EOPNOTSUPP"))
995 if (strEQ(name, "EPERM"))
1001 if (strEQ(name, "EPFNOSUPPORT"))
1003 return EPFNOSUPPORT;
1007 if (strEQ(name, "EPIPE"))
1013 if (strEQ(name, "EPROCLIM"))
1019 if (strEQ(name, "EPROTONOSUPPORT"))
1020 #ifdef EPROTONOSUPPORT
1021 return EPROTONOSUPPORT;
1025 if (strEQ(name, "EPROTOTYPE"))
1033 if (strEQ(name, "ERANGE"))
1039 if (strEQ(name, "EREMOTE"))
1045 if (strEQ(name, "ERESTART"))
1051 if (strEQ(name, "EROFS"))
1059 if (strEQ(name, "ESHUTDOWN"))
1065 if (strEQ(name, "ESOCKTNOSUPPORT"))
1066 #ifdef ESOCKTNOSUPPORT
1067 return ESOCKTNOSUPPORT;
1071 if (strEQ(name, "ESPIPE"))
1077 if (strEQ(name, "ESRCH"))
1083 if (strEQ(name, "ESTALE"))
1091 if (strEQ(name, "ETIMEDOUT"))
1097 if (strEQ(name, "ETOOMANYREFS"))
1099 return ETOOMANYREFS;
1103 if (strEQ(name, "ETXTBSY"))
1111 if (strEQ(name, "EUSERS"))
1119 if (strEQ(name, "EWOULDBLOCK"))
1127 if (strEQ(name, "EXIT_FAILURE"))
1129 return EXIT_FAILURE;
1133 if (strEQ(name, "EXIT_SUCCESS"))
1135 return EXIT_SUCCESS;
1139 if (strEQ(name, "EXDEV"))
1147 if (strEQ(name, "E2BIG"))
1155 if (strnEQ(name, "FLT_", 4)) {
1156 if (strEQ(name, "FLT_MAX"))
1162 if (strEQ(name, "FLT_MIN"))
1168 if (strEQ(name, "FLT_ROUNDS"))
1174 if (strEQ(name, "FLT_DIG"))
1180 if (strEQ(name, "FLT_EPSILON"))
1186 if (strEQ(name, "FLT_MANT_DIG"))
1188 return FLT_MANT_DIG;
1192 if (strEQ(name, "FLT_MAX_10_EXP"))
1193 #ifdef FLT_MAX_10_EXP
1194 return FLT_MAX_10_EXP;
1198 if (strEQ(name, "FLT_MAX_EXP"))
1204 if (strEQ(name, "FLT_MIN_10_EXP"))
1205 #ifdef FLT_MIN_10_EXP
1206 return FLT_MIN_10_EXP;
1210 if (strEQ(name, "FLT_MIN_EXP"))
1216 if (strEQ(name, "FLT_RADIX"))
1224 if (strnEQ(name, "F_", 2)) {
1225 if (strEQ(name, "F_DUPFD"))
1231 if (strEQ(name, "F_GETFD"))
1237 if (strEQ(name, "F_GETFL"))
1243 if (strEQ(name, "F_GETLK"))
1249 if (strEQ(name, "F_OK"))
1255 if (strEQ(name, "F_RDLCK"))
1261 if (strEQ(name, "F_SETFD"))
1267 if (strEQ(name, "F_SETFL"))
1273 if (strEQ(name, "F_SETLK"))
1279 if (strEQ(name, "F_SETLKW"))
1285 if (strEQ(name, "F_UNLCK"))
1291 if (strEQ(name, "F_WRLCK"))
1299 if (strEQ(name, "FD_CLOEXEC"))
1305 if (strEQ(name, "FILENAME_MAX"))
1307 return FILENAME_MAX;
1313 if (strEQ(name, "HUGE_VAL"))
1319 if (strEQ(name, "HUPCL"))
1327 if (strEQ(name, "INT_MAX"))
1333 if (strEQ(name, "INT_MIN"))
1339 if (strEQ(name, "ICANON"))
1345 if (strEQ(name, "ICRNL"))
1351 if (strEQ(name, "IEXTEN"))
1357 if (strEQ(name, "IGNBRK"))
1363 if (strEQ(name, "IGNCR"))
1369 if (strEQ(name, "IGNPAR"))
1375 if (strEQ(name, "INLCR"))
1381 if (strEQ(name, "INPCK"))
1387 if (strEQ(name, "ISIG"))
1393 if (strEQ(name, "ISTRIP"))
1399 if (strEQ(name, "IXOFF"))
1405 if (strEQ(name, "IXON"))
1413 if (strnEQ(name, "LC_", 3)) {
1414 if (strEQ(name, "LC_ALL"))
1420 if (strEQ(name, "LC_COLLATE"))
1426 if (strEQ(name, "LC_CTYPE"))
1432 if (strEQ(name, "LC_MONETARY"))
1438 if (strEQ(name, "LC_NUMERIC"))
1444 if (strEQ(name, "LC_TIME"))
1452 if (strnEQ(name, "LDBL_", 5)) {
1453 if (strEQ(name, "LDBL_MAX"))
1459 if (strEQ(name, "LDBL_MIN"))
1465 if (strEQ(name, "LDBL_DIG"))
1471 if (strEQ(name, "LDBL_EPSILON"))
1473 return LDBL_EPSILON;
1477 if (strEQ(name, "LDBL_MANT_DIG"))
1478 #ifdef LDBL_MANT_DIG
1479 return LDBL_MANT_DIG;
1483 if (strEQ(name, "LDBL_MAX_10_EXP"))
1484 #ifdef LDBL_MAX_10_EXP
1485 return LDBL_MAX_10_EXP;
1489 if (strEQ(name, "LDBL_MAX_EXP"))
1491 return LDBL_MAX_EXP;
1495 if (strEQ(name, "LDBL_MIN_10_EXP"))
1496 #ifdef LDBL_MIN_10_EXP
1497 return LDBL_MIN_10_EXP;
1501 if (strEQ(name, "LDBL_MIN_EXP"))
1503 return LDBL_MIN_EXP;
1509 if (strnEQ(name, "L_", 2)) {
1510 if (strEQ(name, "L_ctermid"))
1516 if (strEQ(name, "L_cuserid"))
1522 if (strEQ(name, "L_tmpname"))
1530 if (strEQ(name, "LONG_MAX"))
1536 if (strEQ(name, "LONG_MIN"))
1542 if (strEQ(name, "LINK_MAX"))
1550 if (strEQ(name, "MAX_CANON"))
1556 if (strEQ(name, "MAX_INPUT"))
1562 if (strEQ(name, "MB_CUR_MAX"))
1568 if (strEQ(name, "MB_LEN_MAX"))
1576 if (strEQ(name, "NULL")) return 0;
1577 if (strEQ(name, "NAME_MAX"))
1583 if (strEQ(name, "NCCS"))
1589 if (strEQ(name, "NGROUPS_MAX"))
1595 if (strEQ(name, "NOFLSH"))
1603 if (strnEQ(name, "O_", 2)) {
1604 if (strEQ(name, "O_APPEND"))
1610 if (strEQ(name, "O_CREAT"))
1616 if (strEQ(name, "O_TRUNC"))
1622 if (strEQ(name, "O_RDONLY"))
1628 if (strEQ(name, "O_RDWR"))
1634 if (strEQ(name, "O_WRONLY"))
1640 if (strEQ(name, "O_EXCL"))
1646 if (strEQ(name, "O_NOCTTY"))
1652 if (strEQ(name, "O_NONBLOCK"))
1658 if (strEQ(name, "O_ACCMODE"))
1666 if (strEQ(name, "OPEN_MAX"))
1672 if (strEQ(name, "OPOST"))
1680 if (strEQ(name, "PATH_MAX"))
1686 if (strEQ(name, "PARENB"))
1692 if (strEQ(name, "PARMRK"))
1698 if (strEQ(name, "PARODD"))
1704 if (strEQ(name, "PIPE_BUF"))
1712 if (strEQ(name, "RAND_MAX"))
1718 if (strEQ(name, "R_OK"))
1726 if (strnEQ(name, "SIG", 3)) {
1727 if (name[3] == '_') {
1728 if (strEQ(name, "SIG_BLOCK"))
1735 if (strEQ(name, "SIG_DFL")) return (IV)SIG_DFL;
1738 if (strEQ(name, "SIG_ERR")) return (IV)SIG_ERR;
1741 if (strEQ(name, "SIG_IGN")) return (IV)SIG_IGN;
1743 if (strEQ(name, "SIG_SETMASK"))
1749 if (strEQ(name, "SIG_UNBLOCK"))
1757 if (strEQ(name, "SIGABRT"))
1763 if (strEQ(name, "SIGALRM"))
1769 if (strEQ(name, "SIGCHLD"))
1775 if (strEQ(name, "SIGCONT"))
1781 if (strEQ(name, "SIGFPE"))
1787 if (strEQ(name, "SIGHUP"))
1793 if (strEQ(name, "SIGILL"))
1799 if (strEQ(name, "SIGINT"))
1805 if (strEQ(name, "SIGKILL"))
1811 if (strEQ(name, "SIGPIPE"))
1817 if (strEQ(name, "SIGQUIT"))
1823 if (strEQ(name, "SIGSEGV"))
1829 if (strEQ(name, "SIGSTOP"))
1835 if (strEQ(name, "SIGTERM"))
1841 if (strEQ(name, "SIGTSTP"))
1847 if (strEQ(name, "SIGTTIN"))
1853 if (strEQ(name, "SIGTTOU"))
1859 if (strEQ(name, "SIGUSR1"))
1865 if (strEQ(name, "SIGUSR2"))
1873 if (name[1] == '_') {
1874 if (strEQ(name, "S_ISGID"))
1880 if (strEQ(name, "S_ISUID"))
1886 if (strEQ(name, "S_IRGRP"))
1892 if (strEQ(name, "S_IROTH"))
1898 if (strEQ(name, "S_IRUSR"))
1904 if (strEQ(name, "S_IRWXG"))
1910 if (strEQ(name, "S_IRWXO"))
1916 if (strEQ(name, "S_IRWXU"))
1922 if (strEQ(name, "S_IWGRP"))
1928 if (strEQ(name, "S_IWOTH"))
1934 if (strEQ(name, "S_IWUSR"))
1940 if (strEQ(name, "S_IXGRP"))
1946 if (strEQ(name, "S_IXOTH"))
1952 if (strEQ(name, "S_IXUSR"))
1958 errno = EAGAIN; /* the following aren't constants */
1960 if (strEQ(name, "S_ISBLK")) return S_ISBLK(arg);
1963 if (strEQ(name, "S_ISCHR")) return S_ISCHR(arg);
1966 if (strEQ(name, "S_ISDIR")) return S_ISDIR(arg);
1969 if (strEQ(name, "S_ISFIFO")) return S_ISFIFO(arg);
1972 if (strEQ(name, "S_ISREG")) return S_ISREG(arg);
1976 if (strEQ(name, "SEEK_CUR"))
1982 if (strEQ(name, "SEEK_END"))
1988 if (strEQ(name, "SEEK_SET"))
1994 if (strEQ(name, "STREAM_MAX"))
2000 if (strEQ(name, "SHRT_MAX"))
2006 if (strEQ(name, "SHRT_MIN"))
2012 if (strnEQ(name, "SA_", 3)) {
2013 if (strEQ(name, "SA_NOCLDSTOP"))
2015 return SA_NOCLDSTOP;
2019 if (strEQ(name, "SA_NOCLDWAIT"))
2021 return SA_NOCLDWAIT;
2025 if (strEQ(name, "SA_NODEFER"))
2031 if (strEQ(name, "SA_ONSTACK"))
2037 if (strEQ(name, "SA_RESETHAND"))
2039 return SA_RESETHAND;
2043 if (strEQ(name, "SA_RESTART"))
2049 if (strEQ(name, "SA_SIGINFO"))
2057 if (strEQ(name, "SCHAR_MAX"))
2063 if (strEQ(name, "SCHAR_MIN"))
2069 if (strEQ(name, "SSIZE_MAX"))
2075 if (strEQ(name, "STDIN_FILENO"))
2077 return STDIN_FILENO;
2081 if (strEQ(name, "STDOUT_FILENO"))
2082 #ifdef STDOUT_FILENO
2083 return STDOUT_FILENO;
2087 if (strEQ(name, "STRERR_FILENO"))
2088 #ifdef STRERR_FILENO
2089 return STRERR_FILENO;
2095 if (strEQ(name, "TCIFLUSH"))
2101 if (strEQ(name, "TCIOFF"))
2107 if (strEQ(name, "TCIOFLUSH"))
2113 if (strEQ(name, "TCION"))
2119 if (strEQ(name, "TCOFLUSH"))
2125 if (strEQ(name, "TCOOFF"))
2131 if (strEQ(name, "TCOON"))
2137 if (strEQ(name, "TCSADRAIN"))
2143 if (strEQ(name, "TCSAFLUSH"))
2149 if (strEQ(name, "TCSANOW"))
2155 if (strEQ(name, "TMP_MAX"))
2161 if (strEQ(name, "TOSTOP"))
2167 if (strEQ(name, "TZNAME_MAX"))
2175 if (strEQ(name, "UCHAR_MAX"))
2181 if (strEQ(name, "UINT_MAX"))
2187 if (strEQ(name, "ULONG_MAX"))
2193 if (strEQ(name, "USHRT_MAX"))
2201 if (strEQ(name, "VEOF"))
2207 if (strEQ(name, "VEOL"))
2213 if (strEQ(name, "VERASE"))
2219 if (strEQ(name, "VINTR"))
2225 if (strEQ(name, "VKILL"))
2231 if (strEQ(name, "VMIN"))
2237 if (strEQ(name, "VQUIT"))
2243 if (strEQ(name, "VSTART"))
2249 if (strEQ(name, "VSTOP"))
2255 if (strEQ(name, "VSUSP"))
2261 if (strEQ(name, "VTIME"))
2269 if (strEQ(name, "W_OK"))
2275 if (strEQ(name, "WNOHANG"))
2281 if (strEQ(name, "WUNTRACED"))
2287 errno = EAGAIN; /* the following aren't constants */
2289 if (strEQ(name, "WEXITSTATUS")) return WEXITSTATUS(arg);
2292 if (strEQ(name, "WIFEXITED")) return WIFEXITED(arg);
2295 if (strEQ(name, "WIFSIGNALED")) return WIFSIGNALED(arg);
2298 if (strEQ(name, "WIFSTOPPED")) return WIFSTOPPED(arg);
2301 if (strEQ(name, "WSTOPSIG")) return WSTOPSIG(arg);
2304 if (strEQ(name, "WTERMSIG")) return WTERMSIG(arg);
2308 if (strEQ(name, "X_OK"))
2316 if (strnEQ(name, "_PC_", 4)) {
2317 if (strEQ(name, "_PC_CHOWN_RESTRICTED"))
2318 #if defined(_PC_CHOWN_RESTRICTED) || HINT_SC_EXIST
2319 return _PC_CHOWN_RESTRICTED;
2323 if (strEQ(name, "_PC_LINK_MAX"))
2324 #if defined(_PC_LINK_MAX) || HINT_SC_EXIST
2325 return _PC_LINK_MAX;
2329 if (strEQ(name, "_PC_MAX_CANON"))
2330 #if defined(_PC_MAX_CANON) || HINT_SC_EXIST
2331 return _PC_MAX_CANON;
2335 if (strEQ(name, "_PC_MAX_INPUT"))
2336 #if defined(_PC_MAX_INPUT) || HINT_SC_EXIST
2337 return _PC_MAX_INPUT;
2341 if (strEQ(name, "_PC_NAME_MAX"))
2342 #if defined(_PC_NAME_MAX) || HINT_SC_EXIST
2343 return _PC_NAME_MAX;
2347 if (strEQ(name, "_PC_NO_TRUNC"))
2348 #if defined(_PC_NO_TRUNC) || HINT_SC_EXIST
2349 return _PC_NO_TRUNC;
2353 if (strEQ(name, "_PC_PATH_MAX"))
2354 #if defined(_PC_PATH_MAX) || HINT_SC_EXIST
2355 return _PC_PATH_MAX;
2359 if (strEQ(name, "_PC_PIPE_BUF"))
2360 #if defined(_PC_PIPE_BUF) || HINT_SC_EXIST
2361 return _PC_PIPE_BUF;
2365 if (strEQ(name, "_PC_VDISABLE"))
2366 #if defined(_PC_VDISABLE) || HINT_SC_EXIST
2367 return _PC_VDISABLE;
2373 if (strnEQ(name, "_POSIX_", 7)) {
2374 if (strEQ(name, "_POSIX_ARG_MAX"))
2375 #ifdef _POSIX_ARG_MAX
2376 return _POSIX_ARG_MAX;
2380 if (strEQ(name, "_POSIX_CHILD_MAX"))
2381 #ifdef _POSIX_CHILD_MAX
2382 return _POSIX_CHILD_MAX;
2386 if (strEQ(name, "_POSIX_CHOWN_RESTRICTED"))
2387 #ifdef _POSIX_CHOWN_RESTRICTED
2388 return _POSIX_CHOWN_RESTRICTED;
2392 if (strEQ(name, "_POSIX_JOB_CONTROL"))
2393 #ifdef _POSIX_JOB_CONTROL
2394 return _POSIX_JOB_CONTROL;
2398 if (strEQ(name, "_POSIX_LINK_MAX"))
2399 #ifdef _POSIX_LINK_MAX
2400 return _POSIX_LINK_MAX;
2404 if (strEQ(name, "_POSIX_MAX_CANON"))
2405 #ifdef _POSIX_MAX_CANON
2406 return _POSIX_MAX_CANON;
2410 if (strEQ(name, "_POSIX_MAX_INPUT"))
2411 #ifdef _POSIX_MAX_INPUT
2412 return _POSIX_MAX_INPUT;
2416 if (strEQ(name, "_POSIX_NAME_MAX"))
2417 #ifdef _POSIX_NAME_MAX
2418 return _POSIX_NAME_MAX;
2422 if (strEQ(name, "_POSIX_NGROUPS_MAX"))
2423 #ifdef _POSIX_NGROUPS_MAX
2424 return _POSIX_NGROUPS_MAX;
2428 if (strEQ(name, "_POSIX_NO_TRUNC"))
2429 #ifdef _POSIX_NO_TRUNC
2430 return _POSIX_NO_TRUNC;
2434 if (strEQ(name, "_POSIX_OPEN_MAX"))
2435 #ifdef _POSIX_OPEN_MAX
2436 return _POSIX_OPEN_MAX;
2440 if (strEQ(name, "_POSIX_PATH_MAX"))
2441 #ifdef _POSIX_PATH_MAX
2442 return _POSIX_PATH_MAX;
2446 if (strEQ(name, "_POSIX_PIPE_BUF"))
2447 #ifdef _POSIX_PIPE_BUF
2448 return _POSIX_PIPE_BUF;
2452 if (strEQ(name, "_POSIX_SAVED_IDS"))
2453 #ifdef _POSIX_SAVED_IDS
2454 return _POSIX_SAVED_IDS;
2458 if (strEQ(name, "_POSIX_SSIZE_MAX"))
2459 #ifdef _POSIX_SSIZE_MAX
2460 return _POSIX_SSIZE_MAX;
2464 if (strEQ(name, "_POSIX_STREAM_MAX"))
2465 #ifdef _POSIX_STREAM_MAX
2466 return _POSIX_STREAM_MAX;
2470 if (strEQ(name, "_POSIX_TZNAME_MAX"))
2471 #ifdef _POSIX_TZNAME_MAX
2472 return _POSIX_TZNAME_MAX;
2476 if (strEQ(name, "_POSIX_VDISABLE"))
2477 #ifdef _POSIX_VDISABLE
2478 return _POSIX_VDISABLE;
2482 if (strEQ(name, "_POSIX_VERSION"))
2483 #ifdef _POSIX_VERSION
2484 return _POSIX_VERSION;
2490 if (strnEQ(name, "_SC_", 4)) {
2491 if (strEQ(name, "_SC_ARG_MAX"))
2492 #if defined(_SC_ARG_MAX) || HINT_SC_EXIST
2497 if (strEQ(name, "_SC_CHILD_MAX"))
2498 #if defined(_SC_CHILD_MAX) || HINT_SC_EXIST
2499 return _SC_CHILD_MAX;
2503 if (strEQ(name, "_SC_CLK_TCK"))
2504 #if defined(_SC_CLK_TCK) || HINT_SC_EXIST
2509 if (strEQ(name, "_SC_JOB_CONTROL"))
2510 #if defined(_SC_JOB_CONTROL) || HINT_SC_EXIST
2511 return _SC_JOB_CONTROL;
2515 if (strEQ(name, "_SC_NGROUPS_MAX"))
2516 #if defined(_SC_NGROUPS_MAX) || HINT_SC_EXIST
2517 return _SC_NGROUPS_MAX;
2521 if (strEQ(name, "_SC_OPEN_MAX"))
2522 #if defined(_SC_OPEN_MAX) || HINT_SC_EXIST
2523 return _SC_OPEN_MAX;
2527 if (strEQ(name, "_SC_SAVED_IDS"))
2528 #if defined(_SC_SAVED_IDS) || HINT_SC_EXIST
2529 return _SC_SAVED_IDS;
2533 if (strEQ(name, "_SC_STREAM_MAX"))
2534 #if defined(_SC_STREAM_MAX) || HINT_SC_EXIST
2535 return _SC_STREAM_MAX;
2539 if (strEQ(name, "_SC_TZNAME_MAX"))
2540 #if defined(_SC_TZNAME_MAX) || HINT_SC_EXIST
2541 return _SC_TZNAME_MAX;
2545 if (strEQ(name, "_SC_VERSION"))
2546 #if defined(_SC_VERSION) || HINT_SC_EXIST
2562 MODULE = SigSet PACKAGE = POSIX::SigSet PREFIX = sig
2565 new(packname = "POSIX::SigSet", ...)
2570 New(0, RETVAL, 1, sigset_t);
2571 sigemptyset(RETVAL);
2572 for (i = 1; i < items; i++)
2573 sigaddset(RETVAL, SvIV(ST(i)));
2580 POSIX::SigSet sigset
2585 sigaddset(sigset, sig)
2586 POSIX::SigSet sigset
2590 sigdelset(sigset, sig)
2591 POSIX::SigSet sigset
2596 POSIX::SigSet sigset
2600 POSIX::SigSet sigset
2603 sigismember(sigset, sig)
2604 POSIX::SigSet sigset
2608 MODULE = Termios PACKAGE = POSIX::Termios PREFIX = cf
2611 new(packname = "POSIX::Termios", ...)
2616 New(0, RETVAL, 1, struct termios);
2618 not_here("termios");
2626 DESTROY(termios_ref)
2627 POSIX::Termios termios_ref
2630 Safefree(termios_ref);
2632 not_here("termios");
2636 getattr(termios_ref, fd = 0)
2637 POSIX::Termios termios_ref
2640 RETVAL = tcgetattr(fd, termios_ref);
2645 setattr(termios_ref, fd = 0, optional_actions = 0)
2646 POSIX::Termios termios_ref
2648 int optional_actions
2650 RETVAL = tcsetattr(fd, optional_actions, termios_ref);
2655 cfgetispeed(termios_ref)
2656 POSIX::Termios termios_ref
2659 cfgetospeed(termios_ref)
2660 POSIX::Termios termios_ref
2663 getiflag(termios_ref)
2664 POSIX::Termios termios_ref
2666 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2667 RETVAL = termios_ref->c_iflag;
2669 not_here("getiflag");
2676 getoflag(termios_ref)
2677 POSIX::Termios termios_ref
2679 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2680 RETVAL = termios_ref->c_oflag;
2682 not_here("getoflag");
2689 getcflag(termios_ref)
2690 POSIX::Termios termios_ref
2692 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2693 RETVAL = termios_ref->c_cflag;
2695 not_here("getcflag");
2702 getlflag(termios_ref)
2703 POSIX::Termios termios_ref
2705 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2706 RETVAL = termios_ref->c_lflag;
2708 not_here("getlflag");
2715 getcc(termios_ref, ccix)
2716 POSIX::Termios termios_ref
2719 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2721 croak("Bad getcc subscript");
2722 RETVAL = termios_ref->c_cc[ccix];
2731 cfsetispeed(termios_ref, speed)
2732 POSIX::Termios termios_ref
2736 cfsetospeed(termios_ref, speed)
2737 POSIX::Termios termios_ref
2741 setiflag(termios_ref, iflag)
2742 POSIX::Termios termios_ref
2745 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2746 termios_ref->c_iflag = iflag;
2748 not_here("setiflag");
2752 setoflag(termios_ref, oflag)
2753 POSIX::Termios termios_ref
2756 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2757 termios_ref->c_oflag = oflag;
2759 not_here("setoflag");
2763 setcflag(termios_ref, cflag)
2764 POSIX::Termios termios_ref
2767 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2768 termios_ref->c_cflag = cflag;
2770 not_here("setcflag");
2774 setlflag(termios_ref, lflag)
2775 POSIX::Termios termios_ref
2778 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2779 termios_ref->c_lflag = lflag;
2781 not_here("setlflag");
2785 setcc(termios_ref, ccix, cc)
2786 POSIX::Termios termios_ref
2790 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2792 croak("Bad setcc subscript");
2793 termios_ref->c_cc[ccix] = cc;
2799 MODULE = POSIX PACKAGE = POSIX
2808 unsigned char * charstring
2810 unsigned char *s = charstring;
2811 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2812 for (RETVAL = 1; RETVAL && s < e; s++)
2820 unsigned char * charstring
2822 unsigned char *s = charstring;
2823 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2824 for (RETVAL = 1; RETVAL && s < e; s++)
2832 unsigned char * charstring
2834 unsigned char *s = charstring;
2835 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2836 for (RETVAL = 1; RETVAL && s < e; s++)
2844 unsigned char * charstring
2846 unsigned char *s = charstring;
2847 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2848 for (RETVAL = 1; RETVAL && s < e; s++)
2856 unsigned char * charstring
2858 unsigned char *s = charstring;
2859 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2860 for (RETVAL = 1; RETVAL && s < e; s++)
2868 unsigned char * charstring
2870 unsigned char *s = charstring;
2871 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2872 for (RETVAL = 1; RETVAL && s < e; s++)
2880 unsigned char * charstring
2882 unsigned char *s = charstring;
2883 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2884 for (RETVAL = 1; RETVAL && s < e; s++)
2892 unsigned char * charstring
2894 unsigned char *s = charstring;
2895 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2896 for (RETVAL = 1; RETVAL && s < e; s++)
2904 unsigned char * charstring
2906 unsigned char *s = charstring;
2907 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2908 for (RETVAL = 1; RETVAL && s < e; s++)
2916 unsigned char * charstring
2918 unsigned char *s = charstring;
2919 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2920 for (RETVAL = 1; RETVAL && s < e; s++)
2927 isxdigit(charstring)
2928 unsigned char * charstring
2930 unsigned char *s = charstring;
2931 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2932 for (RETVAL = 1; RETVAL && s < e; s++)
2939 open(filename, flags = O_RDONLY, mode = 0666)
2944 if (flags & (O_APPEND|O_CREAT|O_TRUNC|O_RDWR|O_WRONLY|O_EXCL))
2945 TAINT_PROPER("open");
2946 RETVAL = open(filename, flags, mode);
2954 #ifdef HAS_LOCALECONV
2955 struct lconv *lcbuf;
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(PL_siggv),
3180 strlen(PL_sig_name[sig]),
3184 /* Remember old handler name if desired. */
3186 char *hand = SvPVx(*sigsvp, n_a);
3187 svp = hv_fetch(oldaction, "HANDLER", 7, TRUE);
3188 sv_setpv(*svp, *hand ? hand : "DEFAULT");
3192 /* Vector new handler through %SIG. (We always use sighandler
3193 for the C signal handler, which reads %SIG to dispatch.) */
3194 svp = hv_fetch(action, "HANDLER", 7, FALSE);
3196 croak("Can't supply an action without a HANDLER");
3197 sv_setpv(*sigsvp, SvPV(*svp, n_a));
3198 mg_set(*sigsvp); /* handles DEFAULT and IGNORE */
3199 act.sa_handler = sighandler;
3201 /* Set up any desired mask. */
3202 svp = hv_fetch(action, "MASK", 4, FALSE);
3203 if (svp && sv_isa(*svp, "POSIX::SigSet")) {
3205 tmp = (unsigned long)SvNV((SV*)SvRV(*svp));
3206 sigset = (sigset_t*) tmp;
3207 act.sa_mask = *sigset;
3210 sigemptyset(& act.sa_mask);
3212 /* Set up any desired flags. */
3213 svp = hv_fetch(action, "FLAGS", 5, FALSE);
3214 act.sa_flags = svp ? SvIV(*svp) : 0;
3217 /* Now work around sigaction oddities */
3218 if (action && oldaction)
3219 RETVAL = sigaction(sig, & act, & oact);
3221 RETVAL = sigaction(sig, & act, (struct sigaction *)0);
3223 RETVAL = sigaction(sig, (struct sigaction *)0, & oact);
3228 /* Get back the mask. */
3229 svp = hv_fetch(oldaction, "MASK", 4, TRUE);
3230 if (sv_isa(*svp, "POSIX::SigSet")) {
3232 tmp = (unsigned long)SvNV((SV*)SvRV(*svp));
3233 sigset = (sigset_t*) tmp;
3236 New(0, sigset, 1, sigset_t);
3237 sv_setptrobj(*svp, sigset, "POSIX::SigSet");
3239 *sigset = oact.sa_mask;
3241 /* Get back the flags. */
3242 svp = hv_fetch(oldaction, "FLAGS", 5, TRUE);
3243 sv_setiv(*svp, oact.sa_flags);
3252 POSIX::SigSet sigset
3255 sigprocmask(how, sigset, oldsigset = 0)
3257 POSIX::SigSet sigset
3258 POSIX::SigSet oldsigset = NO_INIT
3263 else if (sv_derived_from(ST(2), "POSIX::SigSet")) {
3264 IV tmp = SvIV((SV*)SvRV(ST(2)));
3265 oldsigset = (POSIX__SigSet) tmp;
3268 New(0, oldsigset, 1, sigset_t);
3269 sigemptyset(oldsigset);
3270 sv_setref_pv(ST(2), "POSIX::SigSet", (void*)oldsigset);
3274 sigsuspend(signal_mask)
3275 POSIX::SigSet signal_mask
3295 lseek(fd, offset, whence)
3308 if (pipe(fds) != -1) {
3310 PUSHs(sv_2mortal(newSViv(fds[0])));
3311 PUSHs(sv_2mortal(newSViv(fds[1])));
3315 read(fd, buffer, nbytes)
3317 SV *sv_buffer = SvROK(ST(1)) ? SvRV(ST(1)) : ST(1);
3321 char * buffer = sv_grow( sv_buffer, nbytes+1 );
3324 SvCUR(sv_buffer) = RETVAL;
3325 SvPOK_only(sv_buffer);
3326 *SvEND(sv_buffer) = '\0';
3327 SvTAINTED_on(sv_buffer);
3343 tcsetpgrp(fd, pgrp_id)
3352 if (uname(&buf) >= 0) {
3354 PUSHs(sv_2mortal(newSVpv(buf.sysname, 0)));
3355 PUSHs(sv_2mortal(newSVpv(buf.nodename, 0)));
3356 PUSHs(sv_2mortal(newSVpv(buf.release, 0)));
3357 PUSHs(sv_2mortal(newSVpv(buf.version, 0)));
3358 PUSHs(sv_2mortal(newSVpv(buf.machine, 0)));
3361 uname((char *) 0); /* A stub to call not_here(). */
3365 write(fd, buffer, nbytes)
3383 mbstowcs(s, pwcs, n)
3395 wcstombs(s, pwcs, n)
3417 SET_NUMERIC_LOCAL();
3418 num = strtod(str, &unparsed);
3419 PUSHs(sv_2mortal(newSVnv(num)));
3420 if (GIMME == G_ARRAY) {
3423 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3425 PUSHs(&PL_sv_undef);
3429 strtol(str, base = 0)
3436 num = strtol(str, &unparsed, base);
3437 if (num >= IV_MIN && num <= IV_MAX)
3438 PUSHs(sv_2mortal(newSViv((IV)num)));
3440 PUSHs(sv_2mortal(newSVnv((double)num)));
3441 if (GIMME == G_ARRAY) {
3444 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3446 PUSHs(&PL_sv_undef);
3450 strtoul(str, base = 0)
3457 num = strtoul(str, &unparsed, base);
3459 PUSHs(sv_2mortal(newSViv((IV)num)));
3461 PUSHs(sv_2mortal(newSVnv((double)num)));
3462 if (GIMME == G_ARRAY) {
3465 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3467 PUSHs(&PL_sv_undef);
3477 char *p = SvPV(src,srclen);
3479 ST(0) = sv_2mortal(NEWSV(800,srclen));
3480 dstlen = strxfrm(SvPVX(ST(0)), p, (size_t)srclen);
3481 if (dstlen > srclen) {
3483 SvGROW(ST(0), dstlen);
3484 strxfrm(SvPVX(ST(0)), p, (size_t)dstlen);
3487 SvCUR(ST(0)) = dstlen;
3492 mkfifo(filename, mode)
3496 TAINT_PROPER("mkfifo");
3497 RETVAL = mkfifo(filename, mode);
3513 tcflush(fd, queue_selector)
3518 tcsendbreak(fd, duration)
3523 asctime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3536 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3539 mytm.tm_hour = hour;
3540 mytm.tm_mday = mday;
3542 mytm.tm_year = year;
3543 mytm.tm_wday = wday;
3544 mytm.tm_yday = yday;
3545 mytm.tm_isdst = isdst;
3546 RETVAL = asctime(&mytm);
3563 realtime = times( &tms );
3565 PUSHs( sv_2mortal( newSViv( (IV) realtime ) ) );
3566 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_utime ) ) );
3567 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_stime ) ) );
3568 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cutime ) ) );
3569 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cstime ) ) );
3572 difftime(time1, time2)
3577 mktime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3590 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3593 mytm.tm_hour = hour;
3594 mytm.tm_mday = mday;
3596 mytm.tm_year = year;
3597 mytm.tm_wday = wday;
3598 mytm.tm_yday = yday;
3599 mytm.tm_isdst = isdst;
3600 RETVAL = mktime(&mytm);
3606 strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1)
3622 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3625 mytm.tm_hour = hour;
3626 mytm.tm_mday = mday;
3628 mytm.tm_year = year;
3629 mytm.tm_wday = wday;
3630 mytm.tm_yday = yday;
3631 mytm.tm_isdst = isdst;
3632 (void) mktime(&mytm);
3633 len = strftime(tmpbuf, sizeof tmpbuf, fmt, &mytm);
3635 ** The following is needed to handle to the situation where
3636 ** tmpbuf overflows. Basically we want to allocate a buffer
3637 ** and try repeatedly. The reason why it is so complicated
3638 ** is that getting a return value of 0 from strftime can indicate
3639 ** one of the following:
3640 ** 1. buffer overflowed,
3641 ** 2. illegal conversion specifier, or
3642 ** 3. the format string specifies nothing to be returned(not
3643 ** an error). This could be because format is an empty string
3644 ** or it specifies %p that yields an empty string in some locale.
3645 ** If there is a better way to make it portable, go ahead by
3648 if ( ( len > 0 && len < sizeof(tmpbuf) )
3649 || ( len == 0 && strlen(fmt) == 0 ) ) {
3650 ST(0) = sv_2mortal(newSVpv(tmpbuf, len));
3652 /* Possibly buf overflowed - try again with a bigger buf */
3653 int bufsize = strlen(fmt) + sizeof(tmpbuf);
3657 New(0, buf, bufsize, char);
3659 buflen = strftime(buf, bufsize, fmt, &mytm);
3660 if ( buflen > 0 && buflen < bufsize ) break;
3662 Renew(buf, bufsize, char);
3665 ST(0) = sv_2mortal(newSVpvn(buf, buflen));
3668 ST(0) = sv_2mortal(newSVpvn(tmpbuf, len));
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)