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)
105 #if defined (CYGWIN32)
106 # define tzname _tzname
110 # define mkfifo(a,b) not_here("mkfifo")
111 # define ttyname(a) (char*)not_here("ttyname")
112 # define sigset_t long
115 # define tzname _tzname
118 # define mode_t short
121 # define mode_t short
123 # define tzset() not_here("tzset")
125 # ifndef _POSIX_OPEN_MAX
126 # define _POSIX_OPEN_MAX FOPEN_MAX /* XXX bogus ? */
129 # define sigaction(a,b,c) not_here("sigaction")
130 # define sigpending(a) not_here("sigpending")
131 # define sigprocmask(a,b,c) not_here("sigprocmask")
132 # define sigsuspend(a) not_here("sigsuspend")
133 # define sigemptyset(a) not_here("sigemptyset")
134 # define sigaddset(a,b) not_here("sigaddset")
135 # define sigdelset(a,b) not_here("sigdelset")
136 # define sigfillset(a) not_here("sigfillset")
137 # define sigismember(a,b) not_here("sigismember")
142 # define mkfifo(a,b) not_here("mkfifo")
143 # else /* !( defined OS2 ) */
145 # define mkfifo(path, mode) (mknod((path), (mode) | S_IFIFO, 0))
148 # endif /* !HAS_MKFIFO */
151 # include <sys/times.h>
153 # include <sys/utsname.h>
155 # include <sys/wait.h>
163 typedef long SysRetLong;
164 typedef sigset_t* POSIX__SigSet;
165 typedef HV* POSIX__SigAction;
167 typedef struct termios* POSIX__Termios;
168 #else /* Define termios types to int, and call not_here for the functions.*/
169 #define POSIX__Termios int
173 #define cfgetispeed(x) not_here("cfgetispeed")
174 #define cfgetospeed(x) not_here("cfgetospeed")
175 #define tcdrain(x) not_here("tcdrain")
176 #define tcflush(x,y) not_here("tcflush")
177 #define tcsendbreak(x,y) not_here("tcsendbreak")
178 #define cfsetispeed(x,y) not_here("cfsetispeed")
179 #define cfsetospeed(x,y) not_here("cfsetospeed")
180 #define ctermid(x) (char *) not_here("ctermid")
181 #define tcflow(x,y) not_here("tcflow")
182 #define tcgetattr(x,y) not_here("tcgetattr")
183 #define tcsetattr(x,y,z) not_here("tcsetattr")
186 /* Possibly needed prototypes */
187 char *cuserid (char *);
188 double strtod (const char *, char **);
189 long strtol (const char *, char **, int);
190 unsigned long strtoul (const char *, char **, int);
193 #define cuserid(a) (char *) not_here("cuserid")
197 #define difftime(a,b) not_here("difftime")
200 #ifndef HAS_FPATHCONF
201 #define fpathconf(f,n) (SysRetLong) not_here("fpathconf")
204 #define mktime(a) not_here("mktime")
207 #define nice(a) not_here("nice")
210 #define pathconf(f,n) (SysRetLong) not_here("pathconf")
213 #define sysconf(n) (SysRetLong) not_here("sysconf")
216 #define readlink(a,b,c) not_here("readlink")
219 #define setpgid(a,b) not_here("setpgid")
222 #define setsid() not_here("setsid")
225 #define strcoll(s1,s2) not_here("strcoll")
228 #define strtod(s1,s2) not_here("strtod")
231 #define strtol(s1,s2,b) not_here("strtol")
234 #define strtoul(s1,s2,b) not_here("strtoul")
237 #define strxfrm(s1,s2,n) not_here("strxfrm")
239 #ifndef HAS_TCGETPGRP
240 #define tcgetpgrp(a) not_here("tcgetpgrp")
242 #ifndef HAS_TCSETPGRP
243 #define tcsetpgrp(a,b) not_here("tcsetpgrp")
246 #define times(a) not_here("times")
249 #define uname(a) not_here("uname")
252 #define waitpid(a,b,c) not_here("waitpid")
257 #define mblen(a,b) not_here("mblen")
261 #define mbstowcs(s, pwcs, n) not_here("mbstowcs")
264 #define mbtowc(pwc, s, n) not_here("mbtowc")
267 #define wcstombs(s, pwcs, n) not_here("wcstombs")
270 #define wctomb(s, wchar) not_here("wcstombs")
272 #if !defined(HAS_MBLEN) && !defined(HAS_MBSTOWCS) && !defined(HAS_MBTOWC) && !defined(HAS_WCSTOMBS) && !defined(HAS_WCTOMB)
273 /* If we don't have these functions, then we wouldn't have gotten a typedef
274 for wchar_t, the wide character type. Defining wchar_t allows the
275 functions referencing it to compile. Its actual type is then meaningless,
276 since without the above functions, all sections using it end up calling
277 not_here() and croak. --Kaveh Ghazi (ghazi@noc.rutgers.edu) 9/18/94. */
283 #ifndef HAS_LOCALECONV
284 #define localeconv() not_here("localeconv")
289 extern char *tzname[];
292 #if !defined(WIN32) || (defined(__MINGW32__) && !defined(tzname))
293 char *tzname[] = { "" , "" };
297 /* XXX struct tm on some systems (SunOS4/BSD) contains extra (non POSIX)
298 * fields for which we don't have Configure support yet:
299 * char *tm_zone; -- abbreviation of timezone name
300 * long tm_gmtoff; -- offset from GMT in seconds
301 * To workaround core dumps from the uninitialised tm_zone we get the
302 * system to give us a reasonable struct to copy. This fix means that
303 * strftime uses the tm_zone and tm_gmtoff values returned by
304 * localtime(time()). That should give the desired result most of the
305 * time. But probably not always!
307 * This is a temporary workaround to be removed once Configure
308 * support is added and NETaa14816 is considered in full.
309 * It does not address tzname aspects of NETaa14816.
312 # ifndef STRUCT_TM_HASZONE
313 # define STRUCT_TM_HASZONE
317 #ifdef STRUCT_TM_HASZONE
319 init_tm(struct tm *ptm) /* see mktime, strftime and asctime */
323 Copy(localtime(&now), ptm, 1, struct tm);
327 # define init_tm(ptm)
331 #ifdef HAS_LONG_DOUBLE
332 # if LONG_DOUBLESIZE > DOUBLESIZE
333 # undef HAS_LONG_DOUBLE /* XXX until we figure out how to use them */
337 #ifndef HAS_LONG_DOUBLE
352 croak("POSIX::%s not implemented on this architecture", s);
357 #ifdef HAS_LONG_DOUBLE
362 constant(char *name, int arg)
367 if (strEQ(name, "ARG_MAX"))
375 if (strEQ(name, "BUFSIZ"))
381 if (strEQ(name, "BRKINT"))
387 if (strEQ(name, "B9600"))
393 if (strEQ(name, "B19200"))
399 if (strEQ(name, "B38400"))
405 if (strEQ(name, "B0"))
411 if (strEQ(name, "B110"))
417 if (strEQ(name, "B1200"))
423 if (strEQ(name, "B134"))
429 if (strEQ(name, "B150"))
435 if (strEQ(name, "B1800"))
441 if (strEQ(name, "B200"))
447 if (strEQ(name, "B2400"))
453 if (strEQ(name, "B300"))
459 if (strEQ(name, "B4800"))
465 if (strEQ(name, "B50"))
471 if (strEQ(name, "B600"))
477 if (strEQ(name, "B75"))
485 if (strEQ(name, "CHAR_BIT"))
491 if (strEQ(name, "CHAR_MAX"))
497 if (strEQ(name, "CHAR_MIN"))
503 if (strEQ(name, "CHILD_MAX"))
509 if (strEQ(name, "CLK_TCK"))
515 if (strEQ(name, "CLOCAL"))
521 if (strEQ(name, "CLOCKS_PER_SEC"))
522 #ifdef CLOCKS_PER_SEC
523 return CLOCKS_PER_SEC;
527 if (strEQ(name, "CREAD"))
533 if (strEQ(name, "CS5"))
539 if (strEQ(name, "CS6"))
545 if (strEQ(name, "CS7"))
551 if (strEQ(name, "CS8"))
557 if (strEQ(name, "CSIZE"))
563 if (strEQ(name, "CSTOPB"))
571 if (strEQ(name, "DBL_MAX"))
577 if (strEQ(name, "DBL_MIN"))
583 if (strEQ(name, "DBL_DIG"))
589 if (strEQ(name, "DBL_EPSILON"))
595 if (strEQ(name, "DBL_MANT_DIG"))
601 if (strEQ(name, "DBL_MAX_10_EXP"))
602 #ifdef DBL_MAX_10_EXP
603 return DBL_MAX_10_EXP;
607 if (strEQ(name, "DBL_MAX_EXP"))
613 if (strEQ(name, "DBL_MIN_10_EXP"))
614 #ifdef DBL_MIN_10_EXP
615 return DBL_MIN_10_EXP;
619 if (strEQ(name, "DBL_MIN_EXP"))
629 if (strEQ(name, "EACCES"))
635 if (strEQ(name, "EADDRINUSE"))
641 if (strEQ(name, "EADDRNOTAVAIL"))
643 return EADDRNOTAVAIL;
647 if (strEQ(name, "EAFNOSUPPORT"))
653 if (strEQ(name, "EAGAIN"))
659 if (strEQ(name, "EALREADY"))
667 if (strEQ(name, "EBADF"))
673 if (strEQ(name, "EBUSY"))
681 if (strEQ(name, "ECHILD"))
687 if (strEQ(name, "ECHO"))
693 if (strEQ(name, "ECHOE"))
699 if (strEQ(name, "ECHOK"))
705 if (strEQ(name, "ECHONL"))
711 if (strEQ(name, "ECONNABORTED"))
717 if (strEQ(name, "ECONNREFUSED"))
723 if (strEQ(name, "ECONNRESET"))
731 if (strEQ(name, "EDEADLK"))
737 if (strEQ(name, "EDESTADDRREQ"))
743 if (strEQ(name, "EDOM"))
749 if (strEQ(name, "EDQUOT"))
757 if (strEQ(name, "EEXIST"))
765 if (strEQ(name, "EFAULT"))
771 if (strEQ(name, "EFBIG"))
779 if (strEQ(name, "EHOSTDOWN"))
785 if (strEQ(name, "EHOSTUNREACH"))
793 if (strEQ(name, "EINPROGRESS"))
799 if (strEQ(name, "EINTR"))
805 if (strEQ(name, "EINVAL"))
811 if (strEQ(name, "EIO"))
817 if (strEQ(name, "EISCONN"))
823 if (strEQ(name, "EISDIR"))
831 if (strEQ(name, "ELOOP"))
839 if (strEQ(name, "EMFILE"))
845 if (strEQ(name, "EMLINK"))
851 if (strEQ(name, "EMSGSIZE"))
859 if (strEQ(name, "ENETDOWN"))
865 if (strEQ(name, "ENETRESET"))
871 if (strEQ(name, "ENETUNREACH"))
877 if (strEQ(name, "ENOBUFS"))
883 if (strEQ(name, "ENOEXEC"))
889 if (strEQ(name, "ENOMEM"))
895 if (strEQ(name, "ENOPROTOOPT"))
901 if (strEQ(name, "ENOSPC"))
907 if (strEQ(name, "ENOTBLK"))
913 if (strEQ(name, "ENOTCONN"))
919 if (strEQ(name, "ENOTDIR"))
925 if (strEQ(name, "ENOTEMPTY"))
931 if (strEQ(name, "ENOTSOCK"))
937 if (strEQ(name, "ENOTTY"))
943 if (strEQ(name, "ENFILE"))
949 if (strEQ(name, "ENODEV"))
955 if (strEQ(name, "ENOENT"))
961 if (strEQ(name, "ENOLCK"))
967 if (strEQ(name, "ENOSYS"))
973 if (strEQ(name, "ENXIO"))
979 if (strEQ(name, "ENAMETOOLONG"))
987 if (strEQ(name, "EOF"))
993 if (strEQ(name, "EOPNOTSUPP"))
1001 if (strEQ(name, "EPERM"))
1007 if (strEQ(name, "EPFNOSUPPORT"))
1009 return EPFNOSUPPORT;
1013 if (strEQ(name, "EPIPE"))
1019 if (strEQ(name, "EPROCLIM"))
1025 if (strEQ(name, "EPROTONOSUPPORT"))
1026 #ifdef EPROTONOSUPPORT
1027 return EPROTONOSUPPORT;
1031 if (strEQ(name, "EPROTOTYPE"))
1039 if (strEQ(name, "ERANGE"))
1045 if (strEQ(name, "EREMOTE"))
1051 if (strEQ(name, "ERESTART"))
1057 if (strEQ(name, "EROFS"))
1065 if (strEQ(name, "ESHUTDOWN"))
1071 if (strEQ(name, "ESOCKTNOSUPPORT"))
1072 #ifdef ESOCKTNOSUPPORT
1073 return ESOCKTNOSUPPORT;
1077 if (strEQ(name, "ESPIPE"))
1083 if (strEQ(name, "ESRCH"))
1089 if (strEQ(name, "ESTALE"))
1097 if (strEQ(name, "ETIMEDOUT"))
1103 if (strEQ(name, "ETOOMANYREFS"))
1105 return ETOOMANYREFS;
1109 if (strEQ(name, "ETXTBSY"))
1117 if (strEQ(name, "EUSERS"))
1125 if (strEQ(name, "EWOULDBLOCK"))
1133 if (strEQ(name, "EXIT_FAILURE"))
1135 return EXIT_FAILURE;
1139 if (strEQ(name, "EXIT_SUCCESS"))
1141 return EXIT_SUCCESS;
1145 if (strEQ(name, "EXDEV"))
1153 if (strEQ(name, "E2BIG"))
1161 if (strnEQ(name, "FLT_", 4)) {
1162 if (strEQ(name, "FLT_MAX"))
1168 if (strEQ(name, "FLT_MIN"))
1174 if (strEQ(name, "FLT_ROUNDS"))
1180 if (strEQ(name, "FLT_DIG"))
1186 if (strEQ(name, "FLT_EPSILON"))
1192 if (strEQ(name, "FLT_MANT_DIG"))
1194 return FLT_MANT_DIG;
1198 if (strEQ(name, "FLT_MAX_10_EXP"))
1199 #ifdef FLT_MAX_10_EXP
1200 return FLT_MAX_10_EXP;
1204 if (strEQ(name, "FLT_MAX_EXP"))
1210 if (strEQ(name, "FLT_MIN_10_EXP"))
1211 #ifdef FLT_MIN_10_EXP
1212 return FLT_MIN_10_EXP;
1216 if (strEQ(name, "FLT_MIN_EXP"))
1222 if (strEQ(name, "FLT_RADIX"))
1230 if (strnEQ(name, "F_", 2)) {
1231 if (strEQ(name, "F_DUPFD"))
1237 if (strEQ(name, "F_GETFD"))
1243 if (strEQ(name, "F_GETFL"))
1249 if (strEQ(name, "F_GETLK"))
1255 if (strEQ(name, "F_OK"))
1261 if (strEQ(name, "F_RDLCK"))
1267 if (strEQ(name, "F_SETFD"))
1273 if (strEQ(name, "F_SETFL"))
1279 if (strEQ(name, "F_SETLK"))
1285 if (strEQ(name, "F_SETLKW"))
1291 if (strEQ(name, "F_UNLCK"))
1297 if (strEQ(name, "F_WRLCK"))
1305 if (strEQ(name, "FD_CLOEXEC"))
1311 if (strEQ(name, "FILENAME_MAX"))
1313 return FILENAME_MAX;
1319 if (strEQ(name, "HUGE_VAL"))
1325 if (strEQ(name, "HUPCL"))
1333 if (strEQ(name, "INT_MAX"))
1339 if (strEQ(name, "INT_MIN"))
1345 if (strEQ(name, "ICANON"))
1351 if (strEQ(name, "ICRNL"))
1357 if (strEQ(name, "IEXTEN"))
1363 if (strEQ(name, "IGNBRK"))
1369 if (strEQ(name, "IGNCR"))
1375 if (strEQ(name, "IGNPAR"))
1381 if (strEQ(name, "INLCR"))
1387 if (strEQ(name, "INPCK"))
1393 if (strEQ(name, "ISIG"))
1399 if (strEQ(name, "ISTRIP"))
1405 if (strEQ(name, "IXOFF"))
1411 if (strEQ(name, "IXON"))
1419 if (strnEQ(name, "LC_", 3)) {
1420 if (strEQ(name, "LC_ALL"))
1426 if (strEQ(name, "LC_COLLATE"))
1432 if (strEQ(name, "LC_CTYPE"))
1438 if (strEQ(name, "LC_MONETARY"))
1444 if (strEQ(name, "LC_NUMERIC"))
1450 if (strEQ(name, "LC_TIME"))
1458 if (strnEQ(name, "LDBL_", 5)) {
1459 if (strEQ(name, "LDBL_MAX"))
1465 if (strEQ(name, "LDBL_MIN"))
1471 if (strEQ(name, "LDBL_DIG"))
1477 if (strEQ(name, "LDBL_EPSILON"))
1479 return LDBL_EPSILON;
1483 if (strEQ(name, "LDBL_MANT_DIG"))
1484 #ifdef LDBL_MANT_DIG
1485 return LDBL_MANT_DIG;
1489 if (strEQ(name, "LDBL_MAX_10_EXP"))
1490 #ifdef LDBL_MAX_10_EXP
1491 return LDBL_MAX_10_EXP;
1495 if (strEQ(name, "LDBL_MAX_EXP"))
1497 return LDBL_MAX_EXP;
1501 if (strEQ(name, "LDBL_MIN_10_EXP"))
1502 #ifdef LDBL_MIN_10_EXP
1503 return LDBL_MIN_10_EXP;
1507 if (strEQ(name, "LDBL_MIN_EXP"))
1509 return LDBL_MIN_EXP;
1515 if (strnEQ(name, "L_", 2)) {
1516 if (strEQ(name, "L_ctermid"))
1522 if (strEQ(name, "L_cuserid"))
1528 if (strEQ(name, "L_tmpname"))
1536 if (strEQ(name, "LONG_MAX"))
1542 if (strEQ(name, "LONG_MIN"))
1548 if (strEQ(name, "LINK_MAX"))
1556 if (strEQ(name, "MAX_CANON"))
1562 if (strEQ(name, "MAX_INPUT"))
1568 if (strEQ(name, "MB_CUR_MAX"))
1574 if (strEQ(name, "MB_LEN_MAX"))
1582 if (strEQ(name, "NULL")) return 0;
1583 if (strEQ(name, "NAME_MAX"))
1589 if (strEQ(name, "NCCS"))
1595 if (strEQ(name, "NGROUPS_MAX"))
1601 if (strEQ(name, "NOFLSH"))
1609 if (strnEQ(name, "O_", 2)) {
1610 if (strEQ(name, "O_APPEND"))
1616 if (strEQ(name, "O_CREAT"))
1622 if (strEQ(name, "O_TRUNC"))
1628 if (strEQ(name, "O_RDONLY"))
1634 if (strEQ(name, "O_RDWR"))
1640 if (strEQ(name, "O_WRONLY"))
1646 if (strEQ(name, "O_EXCL"))
1652 if (strEQ(name, "O_NOCTTY"))
1658 if (strEQ(name, "O_NONBLOCK"))
1664 if (strEQ(name, "O_ACCMODE"))
1672 if (strEQ(name, "OPEN_MAX"))
1678 if (strEQ(name, "OPOST"))
1686 if (strEQ(name, "PATH_MAX"))
1692 if (strEQ(name, "PARENB"))
1698 if (strEQ(name, "PARMRK"))
1704 if (strEQ(name, "PARODD"))
1710 if (strEQ(name, "PIPE_BUF"))
1718 if (strEQ(name, "RAND_MAX"))
1724 if (strEQ(name, "R_OK"))
1732 if (strnEQ(name, "SIG", 3)) {
1733 if (name[3] == '_') {
1734 if (strEQ(name, "SIG_BLOCK"))
1741 if (strEQ(name, "SIG_DFL")) return (IV)SIG_DFL;
1744 if (strEQ(name, "SIG_ERR")) return (IV)SIG_ERR;
1747 if (strEQ(name, "SIG_IGN")) return (IV)SIG_IGN;
1749 if (strEQ(name, "SIG_SETMASK"))
1755 if (strEQ(name, "SIG_UNBLOCK"))
1763 if (strEQ(name, "SIGABRT"))
1769 if (strEQ(name, "SIGALRM"))
1775 if (strEQ(name, "SIGCHLD"))
1781 if (strEQ(name, "SIGCONT"))
1787 if (strEQ(name, "SIGFPE"))
1793 if (strEQ(name, "SIGHUP"))
1799 if (strEQ(name, "SIGILL"))
1805 if (strEQ(name, "SIGINT"))
1811 if (strEQ(name, "SIGKILL"))
1817 if (strEQ(name, "SIGPIPE"))
1823 if (strEQ(name, "SIGQUIT"))
1829 if (strEQ(name, "SIGSEGV"))
1835 if (strEQ(name, "SIGSTOP"))
1841 if (strEQ(name, "SIGTERM"))
1847 if (strEQ(name, "SIGTSTP"))
1853 if (strEQ(name, "SIGTTIN"))
1859 if (strEQ(name, "SIGTTOU"))
1865 if (strEQ(name, "SIGUSR1"))
1871 if (strEQ(name, "SIGUSR2"))
1879 if (name[1] == '_') {
1880 if (strEQ(name, "S_ISGID"))
1886 if (strEQ(name, "S_ISUID"))
1892 if (strEQ(name, "S_IRGRP"))
1898 if (strEQ(name, "S_IROTH"))
1904 if (strEQ(name, "S_IRUSR"))
1910 if (strEQ(name, "S_IRWXG"))
1916 if (strEQ(name, "S_IRWXO"))
1922 if (strEQ(name, "S_IRWXU"))
1928 if (strEQ(name, "S_IWGRP"))
1934 if (strEQ(name, "S_IWOTH"))
1940 if (strEQ(name, "S_IWUSR"))
1946 if (strEQ(name, "S_IXGRP"))
1952 if (strEQ(name, "S_IXOTH"))
1958 if (strEQ(name, "S_IXUSR"))
1964 errno = EAGAIN; /* the following aren't constants */
1966 if (strEQ(name, "S_ISBLK")) return S_ISBLK(arg);
1969 if (strEQ(name, "S_ISCHR")) return S_ISCHR(arg);
1972 if (strEQ(name, "S_ISDIR")) return S_ISDIR(arg);
1975 if (strEQ(name, "S_ISFIFO")) return S_ISFIFO(arg);
1978 if (strEQ(name, "S_ISREG")) return S_ISREG(arg);
1982 if (strEQ(name, "SEEK_CUR"))
1988 if (strEQ(name, "SEEK_END"))
1994 if (strEQ(name, "SEEK_SET"))
2000 if (strEQ(name, "STREAM_MAX"))
2006 if (strEQ(name, "SHRT_MAX"))
2012 if (strEQ(name, "SHRT_MIN"))
2018 if (strnEQ(name, "SA_", 3)) {
2019 if (strEQ(name, "SA_NOCLDSTOP"))
2021 return SA_NOCLDSTOP;
2025 if (strEQ(name, "SA_NOCLDWAIT"))
2027 return SA_NOCLDWAIT;
2031 if (strEQ(name, "SA_NODEFER"))
2037 if (strEQ(name, "SA_ONSTACK"))
2043 if (strEQ(name, "SA_RESETHAND"))
2045 return SA_RESETHAND;
2049 if (strEQ(name, "SA_RESTART"))
2055 if (strEQ(name, "SA_SIGINFO"))
2063 if (strEQ(name, "SCHAR_MAX"))
2069 if (strEQ(name, "SCHAR_MIN"))
2075 if (strEQ(name, "SSIZE_MAX"))
2081 if (strEQ(name, "STDIN_FILENO"))
2083 return STDIN_FILENO;
2087 if (strEQ(name, "STDOUT_FILENO"))
2088 #ifdef STDOUT_FILENO
2089 return STDOUT_FILENO;
2093 if (strEQ(name, "STRERR_FILENO"))
2094 #ifdef STRERR_FILENO
2095 return STRERR_FILENO;
2101 if (strEQ(name, "TCIFLUSH"))
2107 if (strEQ(name, "TCIOFF"))
2113 if (strEQ(name, "TCIOFLUSH"))
2119 if (strEQ(name, "TCION"))
2125 if (strEQ(name, "TCOFLUSH"))
2131 if (strEQ(name, "TCOOFF"))
2137 if (strEQ(name, "TCOON"))
2143 if (strEQ(name, "TCSADRAIN"))
2149 if (strEQ(name, "TCSAFLUSH"))
2155 if (strEQ(name, "TCSANOW"))
2161 if (strEQ(name, "TMP_MAX"))
2167 if (strEQ(name, "TOSTOP"))
2173 if (strEQ(name, "TZNAME_MAX"))
2181 if (strEQ(name, "UCHAR_MAX"))
2187 if (strEQ(name, "UINT_MAX"))
2193 if (strEQ(name, "ULONG_MAX"))
2199 if (strEQ(name, "USHRT_MAX"))
2207 if (strEQ(name, "VEOF"))
2213 if (strEQ(name, "VEOL"))
2219 if (strEQ(name, "VERASE"))
2225 if (strEQ(name, "VINTR"))
2231 if (strEQ(name, "VKILL"))
2237 if (strEQ(name, "VMIN"))
2243 if (strEQ(name, "VQUIT"))
2249 if (strEQ(name, "VSTART"))
2255 if (strEQ(name, "VSTOP"))
2261 if (strEQ(name, "VSUSP"))
2267 if (strEQ(name, "VTIME"))
2275 if (strEQ(name, "W_OK"))
2281 if (strEQ(name, "WNOHANG"))
2287 if (strEQ(name, "WUNTRACED"))
2293 errno = EAGAIN; /* the following aren't constants */
2295 if (strEQ(name, "WEXITSTATUS")) return WEXITSTATUS(arg);
2298 if (strEQ(name, "WIFEXITED")) return WIFEXITED(arg);
2301 if (strEQ(name, "WIFSIGNALED")) return WIFSIGNALED(arg);
2304 if (strEQ(name, "WIFSTOPPED")) return WIFSTOPPED(arg);
2307 if (strEQ(name, "WSTOPSIG")) return WSTOPSIG(arg);
2310 if (strEQ(name, "WTERMSIG")) return WTERMSIG(arg);
2314 if (strEQ(name, "X_OK"))
2322 if (strnEQ(name, "_PC_", 4)) {
2323 if (strEQ(name, "_PC_CHOWN_RESTRICTED"))
2324 #if defined(_PC_CHOWN_RESTRICTED) || HINT_SC_EXIST
2325 return _PC_CHOWN_RESTRICTED;
2329 if (strEQ(name, "_PC_LINK_MAX"))
2330 #if defined(_PC_LINK_MAX) || HINT_SC_EXIST
2331 return _PC_LINK_MAX;
2335 if (strEQ(name, "_PC_MAX_CANON"))
2336 #if defined(_PC_MAX_CANON) || HINT_SC_EXIST
2337 return _PC_MAX_CANON;
2341 if (strEQ(name, "_PC_MAX_INPUT"))
2342 #if defined(_PC_MAX_INPUT) || HINT_SC_EXIST
2343 return _PC_MAX_INPUT;
2347 if (strEQ(name, "_PC_NAME_MAX"))
2348 #if defined(_PC_NAME_MAX) || HINT_SC_EXIST
2349 return _PC_NAME_MAX;
2353 if (strEQ(name, "_PC_NO_TRUNC"))
2354 #if defined(_PC_NO_TRUNC) || HINT_SC_EXIST
2355 return _PC_NO_TRUNC;
2359 if (strEQ(name, "_PC_PATH_MAX"))
2360 #if defined(_PC_PATH_MAX) || HINT_SC_EXIST
2361 return _PC_PATH_MAX;
2365 if (strEQ(name, "_PC_PIPE_BUF"))
2366 #if defined(_PC_PIPE_BUF) || HINT_SC_EXIST
2367 return _PC_PIPE_BUF;
2371 if (strEQ(name, "_PC_VDISABLE"))
2372 #if defined(_PC_VDISABLE) || HINT_SC_EXIST
2373 return _PC_VDISABLE;
2379 if (strnEQ(name, "_POSIX_", 7)) {
2380 if (strEQ(name, "_POSIX_ARG_MAX"))
2381 #ifdef _POSIX_ARG_MAX
2382 return _POSIX_ARG_MAX;
2386 if (strEQ(name, "_POSIX_CHILD_MAX"))
2387 #ifdef _POSIX_CHILD_MAX
2388 return _POSIX_CHILD_MAX;
2392 if (strEQ(name, "_POSIX_CHOWN_RESTRICTED"))
2393 #ifdef _POSIX_CHOWN_RESTRICTED
2394 return _POSIX_CHOWN_RESTRICTED;
2398 if (strEQ(name, "_POSIX_JOB_CONTROL"))
2399 #ifdef _POSIX_JOB_CONTROL
2400 return _POSIX_JOB_CONTROL;
2404 if (strEQ(name, "_POSIX_LINK_MAX"))
2405 #ifdef _POSIX_LINK_MAX
2406 return _POSIX_LINK_MAX;
2410 if (strEQ(name, "_POSIX_MAX_CANON"))
2411 #ifdef _POSIX_MAX_CANON
2412 return _POSIX_MAX_CANON;
2416 if (strEQ(name, "_POSIX_MAX_INPUT"))
2417 #ifdef _POSIX_MAX_INPUT
2418 return _POSIX_MAX_INPUT;
2422 if (strEQ(name, "_POSIX_NAME_MAX"))
2423 #ifdef _POSIX_NAME_MAX
2424 return _POSIX_NAME_MAX;
2428 if (strEQ(name, "_POSIX_NGROUPS_MAX"))
2429 #ifdef _POSIX_NGROUPS_MAX
2430 return _POSIX_NGROUPS_MAX;
2434 if (strEQ(name, "_POSIX_NO_TRUNC"))
2435 #ifdef _POSIX_NO_TRUNC
2436 return _POSIX_NO_TRUNC;
2440 if (strEQ(name, "_POSIX_OPEN_MAX"))
2441 #ifdef _POSIX_OPEN_MAX
2442 return _POSIX_OPEN_MAX;
2446 if (strEQ(name, "_POSIX_PATH_MAX"))
2447 #ifdef _POSIX_PATH_MAX
2448 return _POSIX_PATH_MAX;
2452 if (strEQ(name, "_POSIX_PIPE_BUF"))
2453 #ifdef _POSIX_PIPE_BUF
2454 return _POSIX_PIPE_BUF;
2458 if (strEQ(name, "_POSIX_SAVED_IDS"))
2459 #ifdef _POSIX_SAVED_IDS
2460 return _POSIX_SAVED_IDS;
2464 if (strEQ(name, "_POSIX_SSIZE_MAX"))
2465 #ifdef _POSIX_SSIZE_MAX
2466 return _POSIX_SSIZE_MAX;
2470 if (strEQ(name, "_POSIX_STREAM_MAX"))
2471 #ifdef _POSIX_STREAM_MAX
2472 return _POSIX_STREAM_MAX;
2476 if (strEQ(name, "_POSIX_TZNAME_MAX"))
2477 #ifdef _POSIX_TZNAME_MAX
2478 return _POSIX_TZNAME_MAX;
2482 if (strEQ(name, "_POSIX_VDISABLE"))
2483 #ifdef _POSIX_VDISABLE
2484 return _POSIX_VDISABLE;
2488 if (strEQ(name, "_POSIX_VERSION"))
2489 #ifdef _POSIX_VERSION
2490 return _POSIX_VERSION;
2496 if (strnEQ(name, "_SC_", 4)) {
2497 if (strEQ(name, "_SC_ARG_MAX"))
2498 #if defined(_SC_ARG_MAX) || HINT_SC_EXIST
2503 if (strEQ(name, "_SC_CHILD_MAX"))
2504 #if defined(_SC_CHILD_MAX) || HINT_SC_EXIST
2505 return _SC_CHILD_MAX;
2509 if (strEQ(name, "_SC_CLK_TCK"))
2510 #if defined(_SC_CLK_TCK) || HINT_SC_EXIST
2515 if (strEQ(name, "_SC_JOB_CONTROL"))
2516 #if defined(_SC_JOB_CONTROL) || HINT_SC_EXIST
2517 return _SC_JOB_CONTROL;
2521 if (strEQ(name, "_SC_NGROUPS_MAX"))
2522 #if defined(_SC_NGROUPS_MAX) || HINT_SC_EXIST
2523 return _SC_NGROUPS_MAX;
2527 if (strEQ(name, "_SC_OPEN_MAX"))
2528 #if defined(_SC_OPEN_MAX) || HINT_SC_EXIST
2529 return _SC_OPEN_MAX;
2533 if (strEQ(name, "_SC_SAVED_IDS"))
2534 #if defined(_SC_SAVED_IDS) || HINT_SC_EXIST
2535 return _SC_SAVED_IDS;
2539 if (strEQ(name, "_SC_STREAM_MAX"))
2540 #if defined(_SC_STREAM_MAX) || HINT_SC_EXIST
2541 return _SC_STREAM_MAX;
2545 if (strEQ(name, "_SC_TZNAME_MAX"))
2546 #if defined(_SC_TZNAME_MAX) || HINT_SC_EXIST
2547 return _SC_TZNAME_MAX;
2551 if (strEQ(name, "_SC_VERSION"))
2552 #if defined(_SC_VERSION) || HINT_SC_EXIST
2568 MODULE = SigSet PACKAGE = POSIX::SigSet PREFIX = sig
2571 new(packname = "POSIX::SigSet", ...)
2576 New(0, RETVAL, 1, sigset_t);
2577 sigemptyset(RETVAL);
2578 for (i = 1; i < items; i++)
2579 sigaddset(RETVAL, SvIV(ST(i)));
2586 POSIX::SigSet sigset
2591 sigaddset(sigset, sig)
2592 POSIX::SigSet sigset
2596 sigdelset(sigset, sig)
2597 POSIX::SigSet sigset
2602 POSIX::SigSet sigset
2606 POSIX::SigSet sigset
2609 sigismember(sigset, sig)
2610 POSIX::SigSet sigset
2614 MODULE = Termios PACKAGE = POSIX::Termios PREFIX = cf
2617 new(packname = "POSIX::Termios", ...)
2622 New(0, RETVAL, 1, struct termios);
2624 not_here("termios");
2632 DESTROY(termios_ref)
2633 POSIX::Termios termios_ref
2636 Safefree(termios_ref);
2638 not_here("termios");
2642 getattr(termios_ref, fd = 0)
2643 POSIX::Termios termios_ref
2646 RETVAL = tcgetattr(fd, termios_ref);
2651 setattr(termios_ref, fd = 0, optional_actions = 0)
2652 POSIX::Termios termios_ref
2654 int optional_actions
2656 RETVAL = tcsetattr(fd, optional_actions, termios_ref);
2661 cfgetispeed(termios_ref)
2662 POSIX::Termios termios_ref
2665 cfgetospeed(termios_ref)
2666 POSIX::Termios termios_ref
2669 getiflag(termios_ref)
2670 POSIX::Termios termios_ref
2672 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2673 RETVAL = termios_ref->c_iflag;
2675 not_here("getiflag");
2682 getoflag(termios_ref)
2683 POSIX::Termios termios_ref
2685 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2686 RETVAL = termios_ref->c_oflag;
2688 not_here("getoflag");
2695 getcflag(termios_ref)
2696 POSIX::Termios termios_ref
2698 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2699 RETVAL = termios_ref->c_cflag;
2701 not_here("getcflag");
2708 getlflag(termios_ref)
2709 POSIX::Termios termios_ref
2711 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2712 RETVAL = termios_ref->c_lflag;
2714 not_here("getlflag");
2721 getcc(termios_ref, ccix)
2722 POSIX::Termios termios_ref
2725 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2727 croak("Bad getcc subscript");
2728 RETVAL = termios_ref->c_cc[ccix];
2737 cfsetispeed(termios_ref, speed)
2738 POSIX::Termios termios_ref
2742 cfsetospeed(termios_ref, speed)
2743 POSIX::Termios termios_ref
2747 setiflag(termios_ref, iflag)
2748 POSIX::Termios termios_ref
2751 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2752 termios_ref->c_iflag = iflag;
2754 not_here("setiflag");
2758 setoflag(termios_ref, oflag)
2759 POSIX::Termios termios_ref
2762 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2763 termios_ref->c_oflag = oflag;
2765 not_here("setoflag");
2769 setcflag(termios_ref, cflag)
2770 POSIX::Termios termios_ref
2773 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2774 termios_ref->c_cflag = cflag;
2776 not_here("setcflag");
2780 setlflag(termios_ref, lflag)
2781 POSIX::Termios termios_ref
2784 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2785 termios_ref->c_lflag = lflag;
2787 not_here("setlflag");
2791 setcc(termios_ref, ccix, cc)
2792 POSIX::Termios termios_ref
2796 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2798 croak("Bad setcc subscript");
2799 termios_ref->c_cc[ccix] = cc;
2805 MODULE = POSIX PACKAGE = POSIX
2814 unsigned char * charstring
2816 unsigned char *s = charstring;
2817 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2818 for (RETVAL = 1; RETVAL && s < e; s++)
2826 unsigned char * charstring
2828 unsigned char *s = charstring;
2829 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2830 for (RETVAL = 1; RETVAL && s < e; s++)
2838 unsigned char * charstring
2840 unsigned char *s = charstring;
2841 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2842 for (RETVAL = 1; RETVAL && s < e; s++)
2850 unsigned char * charstring
2852 unsigned char *s = charstring;
2853 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2854 for (RETVAL = 1; RETVAL && s < e; s++)
2862 unsigned char * charstring
2864 unsigned char *s = charstring;
2865 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2866 for (RETVAL = 1; RETVAL && s < e; s++)
2874 unsigned char * charstring
2876 unsigned char *s = charstring;
2877 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2878 for (RETVAL = 1; RETVAL && s < e; s++)
2886 unsigned char * charstring
2888 unsigned char *s = charstring;
2889 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2890 for (RETVAL = 1; RETVAL && s < e; s++)
2898 unsigned char * charstring
2900 unsigned char *s = charstring;
2901 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2902 for (RETVAL = 1; RETVAL && s < e; s++)
2910 unsigned char * charstring
2912 unsigned char *s = charstring;
2913 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2914 for (RETVAL = 1; RETVAL && s < e; s++)
2922 unsigned char * charstring
2924 unsigned char *s = charstring;
2925 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2926 for (RETVAL = 1; RETVAL && s < e; s++)
2933 isxdigit(charstring)
2934 unsigned char * charstring
2936 unsigned char *s = charstring;
2937 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2938 for (RETVAL = 1; RETVAL && s < e; s++)
2945 open(filename, flags = O_RDONLY, mode = 0666)
2950 if (flags & (O_APPEND|O_CREAT|O_TRUNC|O_RDWR|O_WRONLY|O_EXCL))
2951 TAINT_PROPER("open");
2952 RETVAL = open(filename, flags, mode);
2960 #ifdef HAS_LOCALECONV
2961 struct lconv *lcbuf;
2963 if (lcbuf = localeconv()) {
2965 if (lcbuf->decimal_point && *lcbuf->decimal_point)
2966 hv_store(RETVAL, "decimal_point", 13,
2967 newSVpv(lcbuf->decimal_point, 0), 0);
2968 if (lcbuf->thousands_sep && *lcbuf->thousands_sep)
2969 hv_store(RETVAL, "thousands_sep", 13,
2970 newSVpv(lcbuf->thousands_sep, 0), 0);
2971 #ifndef NO_LOCALECONV_GROUPING
2972 if (lcbuf->grouping && *lcbuf->grouping)
2973 hv_store(RETVAL, "grouping", 8,
2974 newSVpv(lcbuf->grouping, 0), 0);
2976 if (lcbuf->int_curr_symbol && *lcbuf->int_curr_symbol)
2977 hv_store(RETVAL, "int_curr_symbol", 15,
2978 newSVpv(lcbuf->int_curr_symbol, 0), 0);
2979 if (lcbuf->currency_symbol && *lcbuf->currency_symbol)
2980 hv_store(RETVAL, "currency_symbol", 15,
2981 newSVpv(lcbuf->currency_symbol, 0), 0);
2982 if (lcbuf->mon_decimal_point && *lcbuf->mon_decimal_point)
2983 hv_store(RETVAL, "mon_decimal_point", 17,
2984 newSVpv(lcbuf->mon_decimal_point, 0), 0);
2985 #ifndef NO_LOCALECONV_MON_THOUSANDS_SEP
2986 if (lcbuf->mon_thousands_sep && *lcbuf->mon_thousands_sep)
2987 hv_store(RETVAL, "mon_thousands_sep", 17,
2988 newSVpv(lcbuf->mon_thousands_sep, 0), 0);
2990 #ifndef NO_LOCALECONV_MON_GROUPING
2991 if (lcbuf->mon_grouping && *lcbuf->mon_grouping)
2992 hv_store(RETVAL, "mon_grouping", 12,
2993 newSVpv(lcbuf->mon_grouping, 0), 0);
2995 if (lcbuf->positive_sign && *lcbuf->positive_sign)
2996 hv_store(RETVAL, "positive_sign", 13,
2997 newSVpv(lcbuf->positive_sign, 0), 0);
2998 if (lcbuf->negative_sign && *lcbuf->negative_sign)
2999 hv_store(RETVAL, "negative_sign", 13,
3000 newSVpv(lcbuf->negative_sign, 0), 0);
3002 if (lcbuf->int_frac_digits != CHAR_MAX)
3003 hv_store(RETVAL, "int_frac_digits", 15,
3004 newSViv(lcbuf->int_frac_digits), 0);
3005 if (lcbuf->frac_digits != CHAR_MAX)
3006 hv_store(RETVAL, "frac_digits", 11,
3007 newSViv(lcbuf->frac_digits), 0);
3008 if (lcbuf->p_cs_precedes != CHAR_MAX)
3009 hv_store(RETVAL, "p_cs_precedes", 13,
3010 newSViv(lcbuf->p_cs_precedes), 0);
3011 if (lcbuf->p_sep_by_space != CHAR_MAX)
3012 hv_store(RETVAL, "p_sep_by_space", 14,
3013 newSViv(lcbuf->p_sep_by_space), 0);
3014 if (lcbuf->n_cs_precedes != CHAR_MAX)
3015 hv_store(RETVAL, "n_cs_precedes", 13,
3016 newSViv(lcbuf->n_cs_precedes), 0);
3017 if (lcbuf->n_sep_by_space != CHAR_MAX)
3018 hv_store(RETVAL, "n_sep_by_space", 14,
3019 newSViv(lcbuf->n_sep_by_space), 0);
3020 if (lcbuf->p_sign_posn != CHAR_MAX)
3021 hv_store(RETVAL, "p_sign_posn", 11,
3022 newSViv(lcbuf->p_sign_posn), 0);
3023 if (lcbuf->n_sign_posn != CHAR_MAX)
3024 hv_store(RETVAL, "n_sign_posn", 11,
3025 newSViv(lcbuf->n_sign_posn), 0);
3028 localeconv(); /* A stub to call not_here(). */
3034 setlocale(category, locale = 0)
3038 RETVAL = setlocale(category, locale);
3040 #ifdef USE_LOCALE_CTYPE
3041 if (category == LC_CTYPE
3043 || category == LC_ALL
3049 if (category == LC_ALL)
3050 newctype = setlocale(LC_CTYPE, NULL);
3054 new_ctype(newctype);
3056 #endif /* USE_LOCALE_CTYPE */
3057 #ifdef USE_LOCALE_COLLATE
3058 if (category == LC_COLLATE
3060 || category == LC_ALL
3066 if (category == LC_ALL)
3067 newcoll = setlocale(LC_COLLATE, NULL);
3071 new_collate(newcoll);
3073 #endif /* USE_LOCALE_COLLATE */
3074 #ifdef USE_LOCALE_NUMERIC
3075 if (category == LC_NUMERIC
3077 || category == LC_ALL
3083 if (category == LC_ALL)
3084 newnum = setlocale(LC_NUMERIC, NULL);
3088 new_numeric(newnum);
3090 #endif /* USE_LOCALE_NUMERIC */
3130 /* (We already know stack is long enough.) */
3131 PUSHs(sv_2mortal(newSVnv(frexp(x,&expvar))));
3132 PUSHs(sv_2mortal(newSViv(expvar)));
3148 /* (We already know stack is long enough.) */
3149 PUSHs(sv_2mortal(newSVnv(modf(x,&intvar))));
3150 PUSHs(sv_2mortal(newSVnv(intvar)));
3165 sigaction(sig, action, oldaction = 0)
3167 POSIX::SigAction action
3168 POSIX::SigAction oldaction
3171 RETVAL = not_here("sigaction");
3173 # This code is really grody because we're trying to make the signal
3174 # interface look beautiful, which is hard.
3177 gv_fetchpv("SIG", TRUE, SVt_PVHV);
3180 struct sigaction act;
3181 struct sigaction oact;
3182 POSIX__SigSet sigset;
3184 SV** sigsvp = hv_fetch(GvHVn(PL_siggv),
3186 strlen(PL_sig_name[sig]),
3190 /* Remember old handler name if desired. */
3192 char *hand = SvPVx(*sigsvp, n_a);
3193 svp = hv_fetch(oldaction, "HANDLER", 7, TRUE);
3194 sv_setpv(*svp, *hand ? hand : "DEFAULT");
3198 /* Vector new handler through %SIG. (We always use sighandler
3199 for the C signal handler, which reads %SIG to dispatch.) */
3200 svp = hv_fetch(action, "HANDLER", 7, FALSE);
3202 croak("Can't supply an action without a HANDLER");
3203 sv_setpv(*sigsvp, SvPV(*svp, n_a));
3204 mg_set(*sigsvp); /* handles DEFAULT and IGNORE */
3205 act.sa_handler = PL_sighandlerp;
3207 /* Set up any desired mask. */
3208 svp = hv_fetch(action, "MASK", 4, FALSE);
3209 if (svp && sv_isa(*svp, "POSIX::SigSet")) {
3211 tmp = (unsigned long)SvNV((SV*)SvRV(*svp));
3212 sigset = (sigset_t*) tmp;
3213 act.sa_mask = *sigset;
3216 sigemptyset(& act.sa_mask);
3218 /* Set up any desired flags. */
3219 svp = hv_fetch(action, "FLAGS", 5, FALSE);
3220 act.sa_flags = svp ? SvIV(*svp) : 0;
3223 /* Now work around sigaction oddities */
3224 if (action && oldaction)
3225 RETVAL = sigaction(sig, & act, & oact);
3227 RETVAL = sigaction(sig, & act, (struct sigaction *)0);
3229 RETVAL = sigaction(sig, (struct sigaction *)0, & oact);
3234 /* Get back the mask. */
3235 svp = hv_fetch(oldaction, "MASK", 4, TRUE);
3236 if (sv_isa(*svp, "POSIX::SigSet")) {
3238 tmp = (unsigned long)SvNV((SV*)SvRV(*svp));
3239 sigset = (sigset_t*) tmp;
3242 New(0, sigset, 1, sigset_t);
3243 sv_setptrobj(*svp, sigset, "POSIX::SigSet");
3245 *sigset = oact.sa_mask;
3247 /* Get back the flags. */
3248 svp = hv_fetch(oldaction, "FLAGS", 5, TRUE);
3249 sv_setiv(*svp, oact.sa_flags);
3258 POSIX::SigSet sigset
3261 sigprocmask(how, sigset, oldsigset = 0)
3263 POSIX::SigSet sigset
3264 POSIX::SigSet oldsigset = NO_INIT
3269 else if (sv_derived_from(ST(2), "POSIX::SigSet")) {
3270 IV tmp = SvIV((SV*)SvRV(ST(2)));
3271 oldsigset = (POSIX__SigSet) tmp;
3274 New(0, oldsigset, 1, sigset_t);
3275 sigemptyset(oldsigset);
3276 sv_setref_pv(ST(2), "POSIX::SigSet", (void*)oldsigset);
3280 sigsuspend(signal_mask)
3281 POSIX::SigSet signal_mask
3301 lseek(fd, offset, whence)
3314 if (pipe(fds) != -1) {
3316 PUSHs(sv_2mortal(newSViv(fds[0])));
3317 PUSHs(sv_2mortal(newSViv(fds[1])));
3321 read(fd, buffer, nbytes)
3323 SV *sv_buffer = SvROK(ST(1)) ? SvRV(ST(1)) : ST(1);
3327 char * buffer = sv_grow( sv_buffer, nbytes+1 );
3330 SvCUR(sv_buffer) = RETVAL;
3331 SvPOK_only(sv_buffer);
3332 *SvEND(sv_buffer) = '\0';
3333 SvTAINTED_on(sv_buffer);
3349 tcsetpgrp(fd, pgrp_id)
3358 if (uname(&buf) >= 0) {
3360 PUSHs(sv_2mortal(newSVpv(buf.sysname, 0)));
3361 PUSHs(sv_2mortal(newSVpv(buf.nodename, 0)));
3362 PUSHs(sv_2mortal(newSVpv(buf.release, 0)));
3363 PUSHs(sv_2mortal(newSVpv(buf.version, 0)));
3364 PUSHs(sv_2mortal(newSVpv(buf.machine, 0)));
3367 uname((char *) 0); /* A stub to call not_here(). */
3371 write(fd, buffer, nbytes)
3389 mbstowcs(s, pwcs, n)
3401 wcstombs(s, pwcs, n)
3423 SET_NUMERIC_LOCAL();
3424 num = strtod(str, &unparsed);
3425 PUSHs(sv_2mortal(newSVnv(num)));
3426 if (GIMME == G_ARRAY) {
3429 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3431 PUSHs(&PL_sv_undef);
3435 strtol(str, base = 0)
3442 num = strtol(str, &unparsed, base);
3443 if (num >= IV_MIN && num <= IV_MAX)
3444 PUSHs(sv_2mortal(newSViv((IV)num)));
3446 PUSHs(sv_2mortal(newSVnv((double)num)));
3447 if (GIMME == G_ARRAY) {
3450 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3452 PUSHs(&PL_sv_undef);
3456 strtoul(str, base = 0)
3463 num = strtoul(str, &unparsed, base);
3465 PUSHs(sv_2mortal(newSViv((IV)num)));
3467 PUSHs(sv_2mortal(newSVnv((double)num)));
3468 if (GIMME == G_ARRAY) {
3471 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3473 PUSHs(&PL_sv_undef);
3483 char *p = SvPV(src,srclen);
3485 ST(0) = sv_2mortal(NEWSV(800,srclen));
3486 dstlen = strxfrm(SvPVX(ST(0)), p, (size_t)srclen);
3487 if (dstlen > srclen) {
3489 SvGROW(ST(0), dstlen);
3490 strxfrm(SvPVX(ST(0)), p, (size_t)dstlen);
3493 SvCUR(ST(0)) = dstlen;
3498 mkfifo(filename, mode)
3502 TAINT_PROPER("mkfifo");
3503 RETVAL = mkfifo(filename, mode);
3519 tcflush(fd, queue_selector)
3524 tcsendbreak(fd, duration)
3529 asctime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3542 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3545 mytm.tm_hour = hour;
3546 mytm.tm_mday = mday;
3548 mytm.tm_year = year;
3549 mytm.tm_wday = wday;
3550 mytm.tm_yday = yday;
3551 mytm.tm_isdst = isdst;
3552 RETVAL = asctime(&mytm);
3569 realtime = times( &tms );
3571 PUSHs( sv_2mortal( newSViv( (IV) realtime ) ) );
3572 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_utime ) ) );
3573 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_stime ) ) );
3574 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cutime ) ) );
3575 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cstime ) ) );
3578 difftime(time1, time2)
3583 mktime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3596 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3599 mytm.tm_hour = hour;
3600 mytm.tm_mday = mday;
3602 mytm.tm_year = year;
3603 mytm.tm_wday = wday;
3604 mytm.tm_yday = yday;
3605 mytm.tm_isdst = isdst;
3606 RETVAL = mktime(&mytm);
3612 strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1)
3628 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3631 mytm.tm_hour = hour;
3632 mytm.tm_mday = mday;
3634 mytm.tm_year = year;
3635 mytm.tm_wday = wday;
3636 mytm.tm_yday = yday;
3637 mytm.tm_isdst = isdst;
3638 (void) mktime(&mytm);
3639 len = strftime(tmpbuf, sizeof tmpbuf, fmt, &mytm);
3641 ** The following is needed to handle to the situation where
3642 ** tmpbuf overflows. Basically we want to allocate a buffer
3643 ** and try repeatedly. The reason why it is so complicated
3644 ** is that getting a return value of 0 from strftime can indicate
3645 ** one of the following:
3646 ** 1. buffer overflowed,
3647 ** 2. illegal conversion specifier, or
3648 ** 3. the format string specifies nothing to be returned(not
3649 ** an error). This could be because format is an empty string
3650 ** or it specifies %p that yields an empty string in some locale.
3651 ** If there is a better way to make it portable, go ahead by
3654 if ( ( len > 0 && len < sizeof(tmpbuf) )
3655 || ( len == 0 && strlen(fmt) == 0 ) ) {
3656 ST(0) = sv_2mortal(newSVpv(tmpbuf, len));
3658 /* Possibly buf overflowed - try again with a bigger buf */
3659 int bufsize = strlen(fmt) + sizeof(tmpbuf);
3663 New(0, buf, bufsize, char);
3665 buflen = strftime(buf, bufsize, fmt, &mytm);
3666 if ( buflen > 0 && buflen < bufsize ) break;
3668 Renew(buf, bufsize, char);
3671 ST(0) = sv_2mortal(newSVpvn(buf, buflen));
3674 ST(0) = sv_2mortal(newSVpvn(tmpbuf, len));
3686 PUSHs(sv_2mortal(newSVpvn(tzname[0],strlen(tzname[0]))));
3687 PUSHs(sv_2mortal(newSVpvn(tzname[1],strlen(tzname[1]))));
3690 access(filename, mode)
3708 pathconf(filename, name)