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
107 # undef MB_CUR_MAX /* XXX: bug in b20.1 */
111 # define mkfifo(a,b) not_here("mkfifo")
112 # define ttyname(a) (char*)not_here("ttyname")
113 # define sigset_t long
116 # define tzname _tzname
119 # define mode_t short
122 # define mode_t short
124 # define tzset() not_here("tzset")
126 # ifndef _POSIX_OPEN_MAX
127 # define _POSIX_OPEN_MAX FOPEN_MAX /* XXX bogus ? */
130 # define sigaction(a,b,c) not_here("sigaction")
131 # define sigpending(a) not_here("sigpending")
132 # define sigprocmask(a,b,c) not_here("sigprocmask")
133 # define sigsuspend(a) not_here("sigsuspend")
134 # define sigemptyset(a) not_here("sigemptyset")
135 # define sigaddset(a,b) not_here("sigaddset")
136 # define sigdelset(a,b) not_here("sigdelset")
137 # define sigfillset(a) not_here("sigfillset")
138 # define sigismember(a,b) not_here("sigismember")
143 # define mkfifo(a,b) not_here("mkfifo")
144 # else /* !( defined OS2 ) */
146 # define mkfifo(path, mode) (mknod((path), (mode) | S_IFIFO, 0))
149 # endif /* !HAS_MKFIFO */
152 # include <sys/times.h>
154 # include <sys/utsname.h>
156 # include <sys/wait.h>
164 typedef long SysRetLong;
165 typedef sigset_t* POSIX__SigSet;
166 typedef HV* POSIX__SigAction;
168 typedef struct termios* POSIX__Termios;
169 #else /* Define termios types to int, and call not_here for the functions.*/
170 #define POSIX__Termios int
174 #define cfgetispeed(x) not_here("cfgetispeed")
175 #define cfgetospeed(x) not_here("cfgetospeed")
176 #define tcdrain(x) not_here("tcdrain")
177 #define tcflush(x,y) not_here("tcflush")
178 #define tcsendbreak(x,y) not_here("tcsendbreak")
179 #define cfsetispeed(x,y) not_here("cfsetispeed")
180 #define cfsetospeed(x,y) not_here("cfsetospeed")
181 #define ctermid(x) (char *) not_here("ctermid")
182 #define tcflow(x,y) not_here("tcflow")
183 #define tcgetattr(x,y) not_here("tcgetattr")
184 #define tcsetattr(x,y,z) not_here("tcsetattr")
187 /* Possibly needed prototypes */
188 char *cuserid (char *);
189 double strtod (const char *, char **);
190 long strtol (const char *, char **, int);
191 unsigned long strtoul (const char *, char **, int);
194 #define cuserid(a) (char *) not_here("cuserid")
198 #define difftime(a,b) not_here("difftime")
201 #ifndef HAS_FPATHCONF
202 #define fpathconf(f,n) (SysRetLong) not_here("fpathconf")
205 #define mktime(a) not_here("mktime")
208 #define nice(a) not_here("nice")
211 #define pathconf(f,n) (SysRetLong) not_here("pathconf")
214 #define sysconf(n) (SysRetLong) not_here("sysconf")
217 #define readlink(a,b,c) not_here("readlink")
220 #define setpgid(a,b) not_here("setpgid")
223 #define setsid() not_here("setsid")
226 #define strcoll(s1,s2) not_here("strcoll")
229 #define strtod(s1,s2) not_here("strtod")
232 #define strtol(s1,s2,b) not_here("strtol")
235 #define strtoul(s1,s2,b) not_here("strtoul")
238 #define strxfrm(s1,s2,n) not_here("strxfrm")
240 #ifndef HAS_TCGETPGRP
241 #define tcgetpgrp(a) not_here("tcgetpgrp")
243 #ifndef HAS_TCSETPGRP
244 #define tcsetpgrp(a,b) not_here("tcsetpgrp")
247 #define times(a) not_here("times")
250 #define uname(a) not_here("uname")
253 #define waitpid(a,b,c) not_here("waitpid")
258 #define mblen(a,b) not_here("mblen")
262 #define mbstowcs(s, pwcs, n) not_here("mbstowcs")
265 #define mbtowc(pwc, s, n) not_here("mbtowc")
268 #define wcstombs(s, pwcs, n) not_here("wcstombs")
271 #define wctomb(s, wchar) not_here("wcstombs")
273 #if !defined(HAS_MBLEN) && !defined(HAS_MBSTOWCS) && !defined(HAS_MBTOWC) && !defined(HAS_WCSTOMBS) && !defined(HAS_WCTOMB)
274 /* If we don't have these functions, then we wouldn't have gotten a typedef
275 for wchar_t, the wide character type. Defining wchar_t allows the
276 functions referencing it to compile. Its actual type is then meaningless,
277 since without the above functions, all sections using it end up calling
278 not_here() and croak. --Kaveh Ghazi (ghazi@noc.rutgers.edu) 9/18/94. */
284 #ifndef HAS_LOCALECONV
285 #define localeconv() not_here("localeconv")
290 extern char *tzname[];
293 #if !defined(WIN32) || (defined(__MINGW32__) && !defined(tzname))
294 char *tzname[] = { "" , "" };
298 /* XXX struct tm on some systems (SunOS4/BSD) contains extra (non POSIX)
299 * fields for which we don't have Configure support yet:
300 * char *tm_zone; -- abbreviation of timezone name
301 * long tm_gmtoff; -- offset from GMT in seconds
302 * To workaround core dumps from the uninitialised tm_zone we get the
303 * system to give us a reasonable struct to copy. This fix means that
304 * strftime uses the tm_zone and tm_gmtoff values returned by
305 * localtime(time()). That should give the desired result most of the
306 * time. But probably not always!
308 * This is a temporary workaround to be removed once Configure
309 * support is added and NETaa14816 is considered in full.
310 * It does not address tzname aspects of NETaa14816.
313 # ifndef STRUCT_TM_HASZONE
314 # define STRUCT_TM_HASZONE
318 #ifdef STRUCT_TM_HASZONE
320 init_tm(struct tm *ptm) /* see mktime, strftime and asctime */
324 Copy(localtime(&now), ptm, 1, struct tm);
328 # define init_tm(ptm)
332 #ifdef HAS_LONG_DOUBLE
333 # if LONG_DOUBLESIZE > DOUBLESIZE
334 # undef HAS_LONG_DOUBLE /* XXX until we figure out how to use them */
338 #ifndef HAS_LONG_DOUBLE
353 croak("POSIX::%s not implemented on this architecture", s);
358 #ifdef HAS_LONG_DOUBLE
363 constant(char *name, int arg)
368 if (strEQ(name, "ARG_MAX"))
376 if (strEQ(name, "BUFSIZ"))
382 if (strEQ(name, "BRKINT"))
388 if (strEQ(name, "B9600"))
394 if (strEQ(name, "B19200"))
400 if (strEQ(name, "B38400"))
406 if (strEQ(name, "B0"))
412 if (strEQ(name, "B110"))
418 if (strEQ(name, "B1200"))
424 if (strEQ(name, "B134"))
430 if (strEQ(name, "B150"))
436 if (strEQ(name, "B1800"))
442 if (strEQ(name, "B200"))
448 if (strEQ(name, "B2400"))
454 if (strEQ(name, "B300"))
460 if (strEQ(name, "B4800"))
466 if (strEQ(name, "B50"))
472 if (strEQ(name, "B600"))
478 if (strEQ(name, "B75"))
486 if (strEQ(name, "CHAR_BIT"))
492 if (strEQ(name, "CHAR_MAX"))
498 if (strEQ(name, "CHAR_MIN"))
504 if (strEQ(name, "CHILD_MAX"))
510 if (strEQ(name, "CLK_TCK"))
516 if (strEQ(name, "CLOCAL"))
522 if (strEQ(name, "CLOCKS_PER_SEC"))
523 #ifdef CLOCKS_PER_SEC
524 return CLOCKS_PER_SEC;
528 if (strEQ(name, "CREAD"))
534 if (strEQ(name, "CS5"))
540 if (strEQ(name, "CS6"))
546 if (strEQ(name, "CS7"))
552 if (strEQ(name, "CS8"))
558 if (strEQ(name, "CSIZE"))
564 if (strEQ(name, "CSTOPB"))
572 if (strEQ(name, "DBL_MAX"))
578 if (strEQ(name, "DBL_MIN"))
584 if (strEQ(name, "DBL_DIG"))
590 if (strEQ(name, "DBL_EPSILON"))
596 if (strEQ(name, "DBL_MANT_DIG"))
602 if (strEQ(name, "DBL_MAX_10_EXP"))
603 #ifdef DBL_MAX_10_EXP
604 return DBL_MAX_10_EXP;
608 if (strEQ(name, "DBL_MAX_EXP"))
614 if (strEQ(name, "DBL_MIN_10_EXP"))
615 #ifdef DBL_MIN_10_EXP
616 return DBL_MIN_10_EXP;
620 if (strEQ(name, "DBL_MIN_EXP"))
630 if (strEQ(name, "EACCES"))
636 if (strEQ(name, "EADDRINUSE"))
642 if (strEQ(name, "EADDRNOTAVAIL"))
644 return EADDRNOTAVAIL;
648 if (strEQ(name, "EAFNOSUPPORT"))
654 if (strEQ(name, "EAGAIN"))
660 if (strEQ(name, "EALREADY"))
668 if (strEQ(name, "EBADF"))
674 if (strEQ(name, "EBUSY"))
682 if (strEQ(name, "ECHILD"))
688 if (strEQ(name, "ECHO"))
694 if (strEQ(name, "ECHOE"))
700 if (strEQ(name, "ECHOK"))
706 if (strEQ(name, "ECHONL"))
712 if (strEQ(name, "ECONNABORTED"))
718 if (strEQ(name, "ECONNREFUSED"))
724 if (strEQ(name, "ECONNRESET"))
732 if (strEQ(name, "EDEADLK"))
738 if (strEQ(name, "EDESTADDRREQ"))
744 if (strEQ(name, "EDOM"))
750 if (strEQ(name, "EDQUOT"))
758 if (strEQ(name, "EEXIST"))
766 if (strEQ(name, "EFAULT"))
772 if (strEQ(name, "EFBIG"))
780 if (strEQ(name, "EHOSTDOWN"))
786 if (strEQ(name, "EHOSTUNREACH"))
794 if (strEQ(name, "EINPROGRESS"))
800 if (strEQ(name, "EINTR"))
806 if (strEQ(name, "EINVAL"))
812 if (strEQ(name, "EIO"))
818 if (strEQ(name, "EISCONN"))
824 if (strEQ(name, "EISDIR"))
832 if (strEQ(name, "ELOOP"))
840 if (strEQ(name, "EMFILE"))
846 if (strEQ(name, "EMLINK"))
852 if (strEQ(name, "EMSGSIZE"))
860 if (strEQ(name, "ENETDOWN"))
866 if (strEQ(name, "ENETRESET"))
872 if (strEQ(name, "ENETUNREACH"))
878 if (strEQ(name, "ENOBUFS"))
884 if (strEQ(name, "ENOEXEC"))
890 if (strEQ(name, "ENOMEM"))
896 if (strEQ(name, "ENOPROTOOPT"))
902 if (strEQ(name, "ENOSPC"))
908 if (strEQ(name, "ENOTBLK"))
914 if (strEQ(name, "ENOTCONN"))
920 if (strEQ(name, "ENOTDIR"))
926 if (strEQ(name, "ENOTEMPTY"))
932 if (strEQ(name, "ENOTSOCK"))
938 if (strEQ(name, "ENOTTY"))
944 if (strEQ(name, "ENFILE"))
950 if (strEQ(name, "ENODEV"))
956 if (strEQ(name, "ENOENT"))
962 if (strEQ(name, "ENOLCK"))
968 if (strEQ(name, "ENOSYS"))
974 if (strEQ(name, "ENXIO"))
980 if (strEQ(name, "ENAMETOOLONG"))
988 if (strEQ(name, "EOF"))
994 if (strEQ(name, "EOPNOTSUPP"))
1002 if (strEQ(name, "EPERM"))
1008 if (strEQ(name, "EPFNOSUPPORT"))
1010 return EPFNOSUPPORT;
1014 if (strEQ(name, "EPIPE"))
1020 if (strEQ(name, "EPROCLIM"))
1026 if (strEQ(name, "EPROTONOSUPPORT"))
1027 #ifdef EPROTONOSUPPORT
1028 return EPROTONOSUPPORT;
1032 if (strEQ(name, "EPROTOTYPE"))
1040 if (strEQ(name, "ERANGE"))
1046 if (strEQ(name, "EREMOTE"))
1052 if (strEQ(name, "ERESTART"))
1058 if (strEQ(name, "EROFS"))
1066 if (strEQ(name, "ESHUTDOWN"))
1072 if (strEQ(name, "ESOCKTNOSUPPORT"))
1073 #ifdef ESOCKTNOSUPPORT
1074 return ESOCKTNOSUPPORT;
1078 if (strEQ(name, "ESPIPE"))
1084 if (strEQ(name, "ESRCH"))
1090 if (strEQ(name, "ESTALE"))
1098 if (strEQ(name, "ETIMEDOUT"))
1104 if (strEQ(name, "ETOOMANYREFS"))
1106 return ETOOMANYREFS;
1110 if (strEQ(name, "ETXTBSY"))
1118 if (strEQ(name, "EUSERS"))
1126 if (strEQ(name, "EWOULDBLOCK"))
1134 if (strEQ(name, "EXIT_FAILURE"))
1136 return EXIT_FAILURE;
1140 if (strEQ(name, "EXIT_SUCCESS"))
1142 return EXIT_SUCCESS;
1146 if (strEQ(name, "EXDEV"))
1154 if (strEQ(name, "E2BIG"))
1162 if (strnEQ(name, "FLT_", 4)) {
1163 if (strEQ(name, "FLT_MAX"))
1169 if (strEQ(name, "FLT_MIN"))
1175 if (strEQ(name, "FLT_ROUNDS"))
1181 if (strEQ(name, "FLT_DIG"))
1187 if (strEQ(name, "FLT_EPSILON"))
1193 if (strEQ(name, "FLT_MANT_DIG"))
1195 return FLT_MANT_DIG;
1199 if (strEQ(name, "FLT_MAX_10_EXP"))
1200 #ifdef FLT_MAX_10_EXP
1201 return FLT_MAX_10_EXP;
1205 if (strEQ(name, "FLT_MAX_EXP"))
1211 if (strEQ(name, "FLT_MIN_10_EXP"))
1212 #ifdef FLT_MIN_10_EXP
1213 return FLT_MIN_10_EXP;
1217 if (strEQ(name, "FLT_MIN_EXP"))
1223 if (strEQ(name, "FLT_RADIX"))
1231 if (strnEQ(name, "F_", 2)) {
1232 if (strEQ(name, "F_DUPFD"))
1238 if (strEQ(name, "F_GETFD"))
1244 if (strEQ(name, "F_GETFL"))
1250 if (strEQ(name, "F_GETLK"))
1256 if (strEQ(name, "F_OK"))
1262 if (strEQ(name, "F_RDLCK"))
1268 if (strEQ(name, "F_SETFD"))
1274 if (strEQ(name, "F_SETFL"))
1280 if (strEQ(name, "F_SETLK"))
1286 if (strEQ(name, "F_SETLKW"))
1292 if (strEQ(name, "F_UNLCK"))
1298 if (strEQ(name, "F_WRLCK"))
1306 if (strEQ(name, "FD_CLOEXEC"))
1312 if (strEQ(name, "FILENAME_MAX"))
1314 return FILENAME_MAX;
1320 if (strEQ(name, "HUGE_VAL"))
1326 if (strEQ(name, "HUPCL"))
1334 if (strEQ(name, "INT_MAX"))
1340 if (strEQ(name, "INT_MIN"))
1346 if (strEQ(name, "ICANON"))
1352 if (strEQ(name, "ICRNL"))
1358 if (strEQ(name, "IEXTEN"))
1364 if (strEQ(name, "IGNBRK"))
1370 if (strEQ(name, "IGNCR"))
1376 if (strEQ(name, "IGNPAR"))
1382 if (strEQ(name, "INLCR"))
1388 if (strEQ(name, "INPCK"))
1394 if (strEQ(name, "ISIG"))
1400 if (strEQ(name, "ISTRIP"))
1406 if (strEQ(name, "IXOFF"))
1412 if (strEQ(name, "IXON"))
1420 if (strnEQ(name, "LC_", 3)) {
1421 if (strEQ(name, "LC_ALL"))
1427 if (strEQ(name, "LC_COLLATE"))
1433 if (strEQ(name, "LC_CTYPE"))
1439 if (strEQ(name, "LC_MONETARY"))
1445 if (strEQ(name, "LC_NUMERIC"))
1451 if (strEQ(name, "LC_TIME"))
1459 if (strnEQ(name, "LDBL_", 5)) {
1460 if (strEQ(name, "LDBL_MAX"))
1466 if (strEQ(name, "LDBL_MIN"))
1472 if (strEQ(name, "LDBL_DIG"))
1478 if (strEQ(name, "LDBL_EPSILON"))
1480 return LDBL_EPSILON;
1484 if (strEQ(name, "LDBL_MANT_DIG"))
1485 #ifdef LDBL_MANT_DIG
1486 return LDBL_MANT_DIG;
1490 if (strEQ(name, "LDBL_MAX_10_EXP"))
1491 #ifdef LDBL_MAX_10_EXP
1492 return LDBL_MAX_10_EXP;
1496 if (strEQ(name, "LDBL_MAX_EXP"))
1498 return LDBL_MAX_EXP;
1502 if (strEQ(name, "LDBL_MIN_10_EXP"))
1503 #ifdef LDBL_MIN_10_EXP
1504 return LDBL_MIN_10_EXP;
1508 if (strEQ(name, "LDBL_MIN_EXP"))
1510 return LDBL_MIN_EXP;
1516 if (strnEQ(name, "L_", 2)) {
1517 if (strEQ(name, "L_ctermid"))
1523 if (strEQ(name, "L_cuserid"))
1529 if (strEQ(name, "L_tmpname"))
1537 if (strEQ(name, "LONG_MAX"))
1543 if (strEQ(name, "LONG_MIN"))
1549 if (strEQ(name, "LINK_MAX"))
1557 if (strEQ(name, "MAX_CANON"))
1563 if (strEQ(name, "MAX_INPUT"))
1569 if (strEQ(name, "MB_CUR_MAX"))
1575 if (strEQ(name, "MB_LEN_MAX"))
1583 if (strEQ(name, "NULL")) return 0;
1584 if (strEQ(name, "NAME_MAX"))
1590 if (strEQ(name, "NCCS"))
1596 if (strEQ(name, "NGROUPS_MAX"))
1602 if (strEQ(name, "NOFLSH"))
1610 if (strnEQ(name, "O_", 2)) {
1611 if (strEQ(name, "O_APPEND"))
1617 if (strEQ(name, "O_CREAT"))
1623 if (strEQ(name, "O_TRUNC"))
1629 if (strEQ(name, "O_RDONLY"))
1635 if (strEQ(name, "O_RDWR"))
1641 if (strEQ(name, "O_WRONLY"))
1647 if (strEQ(name, "O_EXCL"))
1653 if (strEQ(name, "O_NOCTTY"))
1659 if (strEQ(name, "O_NONBLOCK"))
1665 if (strEQ(name, "O_ACCMODE"))
1673 if (strEQ(name, "OPEN_MAX"))
1679 if (strEQ(name, "OPOST"))
1687 if (strEQ(name, "PATH_MAX"))
1693 if (strEQ(name, "PARENB"))
1699 if (strEQ(name, "PARMRK"))
1705 if (strEQ(name, "PARODD"))
1711 if (strEQ(name, "PIPE_BUF"))
1719 if (strEQ(name, "RAND_MAX"))
1725 if (strEQ(name, "R_OK"))
1733 if (strnEQ(name, "SIG", 3)) {
1734 if (name[3] == '_') {
1735 if (strEQ(name, "SIG_BLOCK"))
1742 if (strEQ(name, "SIG_DFL")) return (IV)SIG_DFL;
1745 if (strEQ(name, "SIG_ERR")) return (IV)SIG_ERR;
1748 if (strEQ(name, "SIG_IGN")) return (IV)SIG_IGN;
1750 if (strEQ(name, "SIG_SETMASK"))
1756 if (strEQ(name, "SIG_UNBLOCK"))
1764 if (strEQ(name, "SIGABRT"))
1770 if (strEQ(name, "SIGALRM"))
1776 if (strEQ(name, "SIGCHLD"))
1782 if (strEQ(name, "SIGCONT"))
1788 if (strEQ(name, "SIGFPE"))
1794 if (strEQ(name, "SIGHUP"))
1800 if (strEQ(name, "SIGILL"))
1806 if (strEQ(name, "SIGINT"))
1812 if (strEQ(name, "SIGKILL"))
1818 if (strEQ(name, "SIGPIPE"))
1824 if (strEQ(name, "SIGQUIT"))
1830 if (strEQ(name, "SIGSEGV"))
1836 if (strEQ(name, "SIGSTOP"))
1842 if (strEQ(name, "SIGTERM"))
1848 if (strEQ(name, "SIGTSTP"))
1854 if (strEQ(name, "SIGTTIN"))
1860 if (strEQ(name, "SIGTTOU"))
1866 if (strEQ(name, "SIGUSR1"))
1872 if (strEQ(name, "SIGUSR2"))
1880 if (name[1] == '_') {
1881 if (strEQ(name, "S_ISGID"))
1887 if (strEQ(name, "S_ISUID"))
1893 if (strEQ(name, "S_IRGRP"))
1899 if (strEQ(name, "S_IROTH"))
1905 if (strEQ(name, "S_IRUSR"))
1911 if (strEQ(name, "S_IRWXG"))
1917 if (strEQ(name, "S_IRWXO"))
1923 if (strEQ(name, "S_IRWXU"))
1929 if (strEQ(name, "S_IWGRP"))
1935 if (strEQ(name, "S_IWOTH"))
1941 if (strEQ(name, "S_IWUSR"))
1947 if (strEQ(name, "S_IXGRP"))
1953 if (strEQ(name, "S_IXOTH"))
1959 if (strEQ(name, "S_IXUSR"))
1965 errno = EAGAIN; /* the following aren't constants */
1967 if (strEQ(name, "S_ISBLK")) return S_ISBLK(arg);
1970 if (strEQ(name, "S_ISCHR")) return S_ISCHR(arg);
1973 if (strEQ(name, "S_ISDIR")) return S_ISDIR(arg);
1976 if (strEQ(name, "S_ISFIFO")) return S_ISFIFO(arg);
1979 if (strEQ(name, "S_ISREG")) return S_ISREG(arg);
1983 if (strEQ(name, "SEEK_CUR"))
1989 if (strEQ(name, "SEEK_END"))
1995 if (strEQ(name, "SEEK_SET"))
2001 if (strEQ(name, "STREAM_MAX"))
2007 if (strEQ(name, "SHRT_MAX"))
2013 if (strEQ(name, "SHRT_MIN"))
2019 if (strnEQ(name, "SA_", 3)) {
2020 if (strEQ(name, "SA_NOCLDSTOP"))
2022 return SA_NOCLDSTOP;
2026 if (strEQ(name, "SA_NOCLDWAIT"))
2028 return SA_NOCLDWAIT;
2032 if (strEQ(name, "SA_NODEFER"))
2038 if (strEQ(name, "SA_ONSTACK"))
2044 if (strEQ(name, "SA_RESETHAND"))
2046 return SA_RESETHAND;
2050 if (strEQ(name, "SA_RESTART"))
2056 if (strEQ(name, "SA_SIGINFO"))
2064 if (strEQ(name, "SCHAR_MAX"))
2070 if (strEQ(name, "SCHAR_MIN"))
2076 if (strEQ(name, "SSIZE_MAX"))
2082 if (strEQ(name, "STDIN_FILENO"))
2084 return STDIN_FILENO;
2088 if (strEQ(name, "STDOUT_FILENO"))
2089 #ifdef STDOUT_FILENO
2090 return STDOUT_FILENO;
2094 if (strEQ(name, "STRERR_FILENO"))
2095 #ifdef STRERR_FILENO
2096 return STRERR_FILENO;
2102 if (strEQ(name, "TCIFLUSH"))
2108 if (strEQ(name, "TCIOFF"))
2114 if (strEQ(name, "TCIOFLUSH"))
2120 if (strEQ(name, "TCION"))
2126 if (strEQ(name, "TCOFLUSH"))
2132 if (strEQ(name, "TCOOFF"))
2138 if (strEQ(name, "TCOON"))
2144 if (strEQ(name, "TCSADRAIN"))
2150 if (strEQ(name, "TCSAFLUSH"))
2156 if (strEQ(name, "TCSANOW"))
2162 if (strEQ(name, "TMP_MAX"))
2168 if (strEQ(name, "TOSTOP"))
2174 if (strEQ(name, "TZNAME_MAX"))
2182 if (strEQ(name, "UCHAR_MAX"))
2188 if (strEQ(name, "UINT_MAX"))
2194 if (strEQ(name, "ULONG_MAX"))
2200 if (strEQ(name, "USHRT_MAX"))
2208 if (strEQ(name, "VEOF"))
2214 if (strEQ(name, "VEOL"))
2220 if (strEQ(name, "VERASE"))
2226 if (strEQ(name, "VINTR"))
2232 if (strEQ(name, "VKILL"))
2238 if (strEQ(name, "VMIN"))
2244 if (strEQ(name, "VQUIT"))
2250 if (strEQ(name, "VSTART"))
2256 if (strEQ(name, "VSTOP"))
2262 if (strEQ(name, "VSUSP"))
2268 if (strEQ(name, "VTIME"))
2276 if (strEQ(name, "W_OK"))
2282 if (strEQ(name, "WNOHANG"))
2288 if (strEQ(name, "WUNTRACED"))
2294 errno = EAGAIN; /* the following aren't constants */
2296 if (strEQ(name, "WEXITSTATUS")) return WEXITSTATUS(arg);
2299 if (strEQ(name, "WIFEXITED")) return WIFEXITED(arg);
2302 if (strEQ(name, "WIFSIGNALED")) return WIFSIGNALED(arg);
2305 if (strEQ(name, "WIFSTOPPED")) return WIFSTOPPED(arg);
2308 if (strEQ(name, "WSTOPSIG")) return WSTOPSIG(arg);
2311 if (strEQ(name, "WTERMSIG")) return WTERMSIG(arg);
2315 if (strEQ(name, "X_OK"))
2323 if (strnEQ(name, "_PC_", 4)) {
2324 if (strEQ(name, "_PC_CHOWN_RESTRICTED"))
2325 #if defined(_PC_CHOWN_RESTRICTED) || HINT_SC_EXIST
2326 return _PC_CHOWN_RESTRICTED;
2330 if (strEQ(name, "_PC_LINK_MAX"))
2331 #if defined(_PC_LINK_MAX) || HINT_SC_EXIST
2332 return _PC_LINK_MAX;
2336 if (strEQ(name, "_PC_MAX_CANON"))
2337 #if defined(_PC_MAX_CANON) || HINT_SC_EXIST
2338 return _PC_MAX_CANON;
2342 if (strEQ(name, "_PC_MAX_INPUT"))
2343 #if defined(_PC_MAX_INPUT) || HINT_SC_EXIST
2344 return _PC_MAX_INPUT;
2348 if (strEQ(name, "_PC_NAME_MAX"))
2349 #if defined(_PC_NAME_MAX) || HINT_SC_EXIST
2350 return _PC_NAME_MAX;
2354 if (strEQ(name, "_PC_NO_TRUNC"))
2355 #if defined(_PC_NO_TRUNC) || HINT_SC_EXIST
2356 return _PC_NO_TRUNC;
2360 if (strEQ(name, "_PC_PATH_MAX"))
2361 #if defined(_PC_PATH_MAX) || HINT_SC_EXIST
2362 return _PC_PATH_MAX;
2366 if (strEQ(name, "_PC_PIPE_BUF"))
2367 #if defined(_PC_PIPE_BUF) || HINT_SC_EXIST
2368 return _PC_PIPE_BUF;
2372 if (strEQ(name, "_PC_VDISABLE"))
2373 #if defined(_PC_VDISABLE) || HINT_SC_EXIST
2374 return _PC_VDISABLE;
2380 if (strnEQ(name, "_POSIX_", 7)) {
2381 if (strEQ(name, "_POSIX_ARG_MAX"))
2382 #ifdef _POSIX_ARG_MAX
2383 return _POSIX_ARG_MAX;
2387 if (strEQ(name, "_POSIX_CHILD_MAX"))
2388 #ifdef _POSIX_CHILD_MAX
2389 return _POSIX_CHILD_MAX;
2393 if (strEQ(name, "_POSIX_CHOWN_RESTRICTED"))
2394 #ifdef _POSIX_CHOWN_RESTRICTED
2395 return _POSIX_CHOWN_RESTRICTED;
2399 if (strEQ(name, "_POSIX_JOB_CONTROL"))
2400 #ifdef _POSIX_JOB_CONTROL
2401 return _POSIX_JOB_CONTROL;
2405 if (strEQ(name, "_POSIX_LINK_MAX"))
2406 #ifdef _POSIX_LINK_MAX
2407 return _POSIX_LINK_MAX;
2411 if (strEQ(name, "_POSIX_MAX_CANON"))
2412 #ifdef _POSIX_MAX_CANON
2413 return _POSIX_MAX_CANON;
2417 if (strEQ(name, "_POSIX_MAX_INPUT"))
2418 #ifdef _POSIX_MAX_INPUT
2419 return _POSIX_MAX_INPUT;
2423 if (strEQ(name, "_POSIX_NAME_MAX"))
2424 #ifdef _POSIX_NAME_MAX
2425 return _POSIX_NAME_MAX;
2429 if (strEQ(name, "_POSIX_NGROUPS_MAX"))
2430 #ifdef _POSIX_NGROUPS_MAX
2431 return _POSIX_NGROUPS_MAX;
2435 if (strEQ(name, "_POSIX_NO_TRUNC"))
2436 #ifdef _POSIX_NO_TRUNC
2437 return _POSIX_NO_TRUNC;
2441 if (strEQ(name, "_POSIX_OPEN_MAX"))
2442 #ifdef _POSIX_OPEN_MAX
2443 return _POSIX_OPEN_MAX;
2447 if (strEQ(name, "_POSIX_PATH_MAX"))
2448 #ifdef _POSIX_PATH_MAX
2449 return _POSIX_PATH_MAX;
2453 if (strEQ(name, "_POSIX_PIPE_BUF"))
2454 #ifdef _POSIX_PIPE_BUF
2455 return _POSIX_PIPE_BUF;
2459 if (strEQ(name, "_POSIX_SAVED_IDS"))
2460 #ifdef _POSIX_SAVED_IDS
2461 return _POSIX_SAVED_IDS;
2465 if (strEQ(name, "_POSIX_SSIZE_MAX"))
2466 #ifdef _POSIX_SSIZE_MAX
2467 return _POSIX_SSIZE_MAX;
2471 if (strEQ(name, "_POSIX_STREAM_MAX"))
2472 #ifdef _POSIX_STREAM_MAX
2473 return _POSIX_STREAM_MAX;
2477 if (strEQ(name, "_POSIX_TZNAME_MAX"))
2478 #ifdef _POSIX_TZNAME_MAX
2479 return _POSIX_TZNAME_MAX;
2483 if (strEQ(name, "_POSIX_VDISABLE"))
2484 #ifdef _POSIX_VDISABLE
2485 return _POSIX_VDISABLE;
2489 if (strEQ(name, "_POSIX_VERSION"))
2490 #ifdef _POSIX_VERSION
2491 return _POSIX_VERSION;
2497 if (strnEQ(name, "_SC_", 4)) {
2498 if (strEQ(name, "_SC_ARG_MAX"))
2499 #if defined(_SC_ARG_MAX) || HINT_SC_EXIST
2504 if (strEQ(name, "_SC_CHILD_MAX"))
2505 #if defined(_SC_CHILD_MAX) || HINT_SC_EXIST
2506 return _SC_CHILD_MAX;
2510 if (strEQ(name, "_SC_CLK_TCK"))
2511 #if defined(_SC_CLK_TCK) || HINT_SC_EXIST
2516 if (strEQ(name, "_SC_JOB_CONTROL"))
2517 #if defined(_SC_JOB_CONTROL) || HINT_SC_EXIST
2518 return _SC_JOB_CONTROL;
2522 if (strEQ(name, "_SC_NGROUPS_MAX"))
2523 #if defined(_SC_NGROUPS_MAX) || HINT_SC_EXIST
2524 return _SC_NGROUPS_MAX;
2528 if (strEQ(name, "_SC_OPEN_MAX"))
2529 #if defined(_SC_OPEN_MAX) || HINT_SC_EXIST
2530 return _SC_OPEN_MAX;
2534 if (strEQ(name, "_SC_SAVED_IDS"))
2535 #if defined(_SC_SAVED_IDS) || HINT_SC_EXIST
2536 return _SC_SAVED_IDS;
2540 if (strEQ(name, "_SC_STREAM_MAX"))
2541 #if defined(_SC_STREAM_MAX) || HINT_SC_EXIST
2542 return _SC_STREAM_MAX;
2546 if (strEQ(name, "_SC_TZNAME_MAX"))
2547 #if defined(_SC_TZNAME_MAX) || HINT_SC_EXIST
2548 return _SC_TZNAME_MAX;
2552 if (strEQ(name, "_SC_VERSION"))
2553 #if defined(_SC_VERSION) || HINT_SC_EXIST
2569 MODULE = SigSet PACKAGE = POSIX::SigSet PREFIX = sig
2572 new(packname = "POSIX::SigSet", ...)
2577 New(0, RETVAL, 1, sigset_t);
2578 sigemptyset(RETVAL);
2579 for (i = 1; i < items; i++)
2580 sigaddset(RETVAL, SvIV(ST(i)));
2587 POSIX::SigSet sigset
2592 sigaddset(sigset, sig)
2593 POSIX::SigSet sigset
2597 sigdelset(sigset, sig)
2598 POSIX::SigSet sigset
2603 POSIX::SigSet sigset
2607 POSIX::SigSet sigset
2610 sigismember(sigset, sig)
2611 POSIX::SigSet sigset
2615 MODULE = Termios PACKAGE = POSIX::Termios PREFIX = cf
2618 new(packname = "POSIX::Termios", ...)
2623 New(0, RETVAL, 1, struct termios);
2625 not_here("termios");
2633 DESTROY(termios_ref)
2634 POSIX::Termios termios_ref
2637 Safefree(termios_ref);
2639 not_here("termios");
2643 getattr(termios_ref, fd = 0)
2644 POSIX::Termios termios_ref
2647 RETVAL = tcgetattr(fd, termios_ref);
2652 setattr(termios_ref, fd = 0, optional_actions = 0)
2653 POSIX::Termios termios_ref
2655 int optional_actions
2657 RETVAL = tcsetattr(fd, optional_actions, termios_ref);
2662 cfgetispeed(termios_ref)
2663 POSIX::Termios termios_ref
2666 cfgetospeed(termios_ref)
2667 POSIX::Termios termios_ref
2670 getiflag(termios_ref)
2671 POSIX::Termios termios_ref
2673 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2674 RETVAL = termios_ref->c_iflag;
2676 not_here("getiflag");
2683 getoflag(termios_ref)
2684 POSIX::Termios termios_ref
2686 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2687 RETVAL = termios_ref->c_oflag;
2689 not_here("getoflag");
2696 getcflag(termios_ref)
2697 POSIX::Termios termios_ref
2699 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2700 RETVAL = termios_ref->c_cflag;
2702 not_here("getcflag");
2709 getlflag(termios_ref)
2710 POSIX::Termios termios_ref
2712 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2713 RETVAL = termios_ref->c_lflag;
2715 not_here("getlflag");
2722 getcc(termios_ref, ccix)
2723 POSIX::Termios termios_ref
2726 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2728 croak("Bad getcc subscript");
2729 RETVAL = termios_ref->c_cc[ccix];
2738 cfsetispeed(termios_ref, speed)
2739 POSIX::Termios termios_ref
2743 cfsetospeed(termios_ref, speed)
2744 POSIX::Termios termios_ref
2748 setiflag(termios_ref, iflag)
2749 POSIX::Termios termios_ref
2752 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2753 termios_ref->c_iflag = iflag;
2755 not_here("setiflag");
2759 setoflag(termios_ref, oflag)
2760 POSIX::Termios termios_ref
2763 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2764 termios_ref->c_oflag = oflag;
2766 not_here("setoflag");
2770 setcflag(termios_ref, cflag)
2771 POSIX::Termios termios_ref
2774 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2775 termios_ref->c_cflag = cflag;
2777 not_here("setcflag");
2781 setlflag(termios_ref, lflag)
2782 POSIX::Termios termios_ref
2785 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2786 termios_ref->c_lflag = lflag;
2788 not_here("setlflag");
2792 setcc(termios_ref, ccix, cc)
2793 POSIX::Termios termios_ref
2797 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2799 croak("Bad setcc subscript");
2800 termios_ref->c_cc[ccix] = cc;
2806 MODULE = POSIX PACKAGE = POSIX
2815 unsigned char * charstring
2817 unsigned char *s = charstring;
2818 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2819 for (RETVAL = 1; RETVAL && s < e; s++)
2827 unsigned char * charstring
2829 unsigned char *s = charstring;
2830 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2831 for (RETVAL = 1; RETVAL && s < e; s++)
2839 unsigned char * charstring
2841 unsigned char *s = charstring;
2842 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2843 for (RETVAL = 1; RETVAL && s < e; s++)
2851 unsigned char * charstring
2853 unsigned char *s = charstring;
2854 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2855 for (RETVAL = 1; RETVAL && s < e; s++)
2863 unsigned char * charstring
2865 unsigned char *s = charstring;
2866 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2867 for (RETVAL = 1; RETVAL && s < e; s++)
2875 unsigned char * charstring
2877 unsigned char *s = charstring;
2878 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2879 for (RETVAL = 1; RETVAL && s < e; s++)
2887 unsigned char * charstring
2889 unsigned char *s = charstring;
2890 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2891 for (RETVAL = 1; RETVAL && s < e; s++)
2899 unsigned char * charstring
2901 unsigned char *s = charstring;
2902 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2903 for (RETVAL = 1; RETVAL && s < e; s++)
2911 unsigned char * charstring
2913 unsigned char *s = charstring;
2914 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2915 for (RETVAL = 1; RETVAL && s < e; s++)
2923 unsigned char * charstring
2925 unsigned char *s = charstring;
2926 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2927 for (RETVAL = 1; RETVAL && s < e; s++)
2934 isxdigit(charstring)
2935 unsigned char * charstring
2937 unsigned char *s = charstring;
2938 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2939 for (RETVAL = 1; RETVAL && s < e; s++)
2946 open(filename, flags = O_RDONLY, mode = 0666)
2951 if (flags & (O_APPEND|O_CREAT|O_TRUNC|O_RDWR|O_WRONLY|O_EXCL))
2952 TAINT_PROPER("open");
2953 RETVAL = open(filename, flags, mode);
2961 #ifdef HAS_LOCALECONV
2962 struct lconv *lcbuf;
2964 if (lcbuf = localeconv()) {
2966 if (lcbuf->decimal_point && *lcbuf->decimal_point)
2967 hv_store(RETVAL, "decimal_point", 13,
2968 newSVpv(lcbuf->decimal_point, 0), 0);
2969 if (lcbuf->thousands_sep && *lcbuf->thousands_sep)
2970 hv_store(RETVAL, "thousands_sep", 13,
2971 newSVpv(lcbuf->thousands_sep, 0), 0);
2972 #ifndef NO_LOCALECONV_GROUPING
2973 if (lcbuf->grouping && *lcbuf->grouping)
2974 hv_store(RETVAL, "grouping", 8,
2975 newSVpv(lcbuf->grouping, 0), 0);
2977 if (lcbuf->int_curr_symbol && *lcbuf->int_curr_symbol)
2978 hv_store(RETVAL, "int_curr_symbol", 15,
2979 newSVpv(lcbuf->int_curr_symbol, 0), 0);
2980 if (lcbuf->currency_symbol && *lcbuf->currency_symbol)
2981 hv_store(RETVAL, "currency_symbol", 15,
2982 newSVpv(lcbuf->currency_symbol, 0), 0);
2983 if (lcbuf->mon_decimal_point && *lcbuf->mon_decimal_point)
2984 hv_store(RETVAL, "mon_decimal_point", 17,
2985 newSVpv(lcbuf->mon_decimal_point, 0), 0);
2986 #ifndef NO_LOCALECONV_MON_THOUSANDS_SEP
2987 if (lcbuf->mon_thousands_sep && *lcbuf->mon_thousands_sep)
2988 hv_store(RETVAL, "mon_thousands_sep", 17,
2989 newSVpv(lcbuf->mon_thousands_sep, 0), 0);
2991 #ifndef NO_LOCALECONV_MON_GROUPING
2992 if (lcbuf->mon_grouping && *lcbuf->mon_grouping)
2993 hv_store(RETVAL, "mon_grouping", 12,
2994 newSVpv(lcbuf->mon_grouping, 0), 0);
2996 if (lcbuf->positive_sign && *lcbuf->positive_sign)
2997 hv_store(RETVAL, "positive_sign", 13,
2998 newSVpv(lcbuf->positive_sign, 0), 0);
2999 if (lcbuf->negative_sign && *lcbuf->negative_sign)
3000 hv_store(RETVAL, "negative_sign", 13,
3001 newSVpv(lcbuf->negative_sign, 0), 0);
3003 if (lcbuf->int_frac_digits != CHAR_MAX)
3004 hv_store(RETVAL, "int_frac_digits", 15,
3005 newSViv(lcbuf->int_frac_digits), 0);
3006 if (lcbuf->frac_digits != CHAR_MAX)
3007 hv_store(RETVAL, "frac_digits", 11,
3008 newSViv(lcbuf->frac_digits), 0);
3009 if (lcbuf->p_cs_precedes != CHAR_MAX)
3010 hv_store(RETVAL, "p_cs_precedes", 13,
3011 newSViv(lcbuf->p_cs_precedes), 0);
3012 if (lcbuf->p_sep_by_space != CHAR_MAX)
3013 hv_store(RETVAL, "p_sep_by_space", 14,
3014 newSViv(lcbuf->p_sep_by_space), 0);
3015 if (lcbuf->n_cs_precedes != CHAR_MAX)
3016 hv_store(RETVAL, "n_cs_precedes", 13,
3017 newSViv(lcbuf->n_cs_precedes), 0);
3018 if (lcbuf->n_sep_by_space != CHAR_MAX)
3019 hv_store(RETVAL, "n_sep_by_space", 14,
3020 newSViv(lcbuf->n_sep_by_space), 0);
3021 if (lcbuf->p_sign_posn != CHAR_MAX)
3022 hv_store(RETVAL, "p_sign_posn", 11,
3023 newSViv(lcbuf->p_sign_posn), 0);
3024 if (lcbuf->n_sign_posn != CHAR_MAX)
3025 hv_store(RETVAL, "n_sign_posn", 11,
3026 newSViv(lcbuf->n_sign_posn), 0);
3029 localeconv(); /* A stub to call not_here(). */
3035 setlocale(category, locale = 0)
3039 RETVAL = setlocale(category, locale);
3041 #ifdef USE_LOCALE_CTYPE
3042 if (category == LC_CTYPE
3044 || category == LC_ALL
3050 if (category == LC_ALL)
3051 newctype = setlocale(LC_CTYPE, NULL);
3055 new_ctype(newctype);
3057 #endif /* USE_LOCALE_CTYPE */
3058 #ifdef USE_LOCALE_COLLATE
3059 if (category == LC_COLLATE
3061 || category == LC_ALL
3067 if (category == LC_ALL)
3068 newcoll = setlocale(LC_COLLATE, NULL);
3072 new_collate(newcoll);
3074 #endif /* USE_LOCALE_COLLATE */
3075 #ifdef USE_LOCALE_NUMERIC
3076 if (category == LC_NUMERIC
3078 || category == LC_ALL
3084 if (category == LC_ALL)
3085 newnum = setlocale(LC_NUMERIC, NULL);
3089 new_numeric(newnum);
3091 #endif /* USE_LOCALE_NUMERIC */
3131 /* (We already know stack is long enough.) */
3132 PUSHs(sv_2mortal(newSVnv(frexp(x,&expvar))));
3133 PUSHs(sv_2mortal(newSViv(expvar)));
3149 /* (We already know stack is long enough.) */
3150 PUSHs(sv_2mortal(newSVnv(modf(x,&intvar))));
3151 PUSHs(sv_2mortal(newSVnv(intvar)));
3166 sigaction(sig, action, oldaction = 0)
3168 POSIX::SigAction action
3169 POSIX::SigAction oldaction
3172 RETVAL = not_here("sigaction");
3174 # This code is really grody because we're trying to make the signal
3175 # interface look beautiful, which is hard.
3178 gv_fetchpv("SIG", TRUE, SVt_PVHV);
3181 struct sigaction act;
3182 struct sigaction oact;
3183 POSIX__SigSet sigset;
3185 SV** sigsvp = hv_fetch(GvHVn(PL_siggv),
3187 strlen(PL_sig_name[sig]),
3191 /* Remember old handler name if desired. */
3193 char *hand = SvPVx(*sigsvp, n_a);
3194 svp = hv_fetch(oldaction, "HANDLER", 7, TRUE);
3195 sv_setpv(*svp, *hand ? hand : "DEFAULT");
3199 /* Vector new handler through %SIG. (We always use sighandler
3200 for the C signal handler, which reads %SIG to dispatch.) */
3201 svp = hv_fetch(action, "HANDLER", 7, FALSE);
3203 croak("Can't supply an action without a HANDLER");
3204 sv_setpv(*sigsvp, SvPV(*svp, n_a));
3205 mg_set(*sigsvp); /* handles DEFAULT and IGNORE */
3206 act.sa_handler = PL_sighandlerp;
3208 /* Set up any desired mask. */
3209 svp = hv_fetch(action, "MASK", 4, FALSE);
3210 if (svp && sv_isa(*svp, "POSIX::SigSet")) {
3212 tmp = (unsigned long)SvNV((SV*)SvRV(*svp));
3213 sigset = (sigset_t*) tmp;
3214 act.sa_mask = *sigset;
3217 sigemptyset(& act.sa_mask);
3219 /* Set up any desired flags. */
3220 svp = hv_fetch(action, "FLAGS", 5, FALSE);
3221 act.sa_flags = svp ? SvIV(*svp) : 0;
3224 /* Now work around sigaction oddities */
3225 if (action && oldaction)
3226 RETVAL = sigaction(sig, & act, & oact);
3228 RETVAL = sigaction(sig, & act, (struct sigaction *)0);
3230 RETVAL = sigaction(sig, (struct sigaction *)0, & oact);
3235 /* Get back the mask. */
3236 svp = hv_fetch(oldaction, "MASK", 4, TRUE);
3237 if (sv_isa(*svp, "POSIX::SigSet")) {
3239 tmp = (unsigned long)SvNV((SV*)SvRV(*svp));
3240 sigset = (sigset_t*) tmp;
3243 New(0, sigset, 1, sigset_t);
3244 sv_setptrobj(*svp, sigset, "POSIX::SigSet");
3246 *sigset = oact.sa_mask;
3248 /* Get back the flags. */
3249 svp = hv_fetch(oldaction, "FLAGS", 5, TRUE);
3250 sv_setiv(*svp, oact.sa_flags);
3259 POSIX::SigSet sigset
3262 sigprocmask(how, sigset, oldsigset = 0)
3264 POSIX::SigSet sigset
3265 POSIX::SigSet oldsigset = NO_INIT
3270 else if (sv_derived_from(ST(2), "POSIX::SigSet")) {
3271 IV tmp = SvIV((SV*)SvRV(ST(2)));
3272 oldsigset = (POSIX__SigSet) tmp;
3275 New(0, oldsigset, 1, sigset_t);
3276 sigemptyset(oldsigset);
3277 sv_setref_pv(ST(2), "POSIX::SigSet", (void*)oldsigset);
3281 sigsuspend(signal_mask)
3282 POSIX::SigSet signal_mask
3302 lseek(fd, offset, whence)
3315 if (pipe(fds) != -1) {
3317 PUSHs(sv_2mortal(newSViv(fds[0])));
3318 PUSHs(sv_2mortal(newSViv(fds[1])));
3322 read(fd, buffer, nbytes)
3324 SV *sv_buffer = SvROK(ST(1)) ? SvRV(ST(1)) : ST(1);
3328 char * buffer = sv_grow( sv_buffer, nbytes+1 );
3331 SvCUR(sv_buffer) = RETVAL;
3332 SvPOK_only(sv_buffer);
3333 *SvEND(sv_buffer) = '\0';
3334 SvTAINTED_on(sv_buffer);
3350 tcsetpgrp(fd, pgrp_id)
3359 if (uname(&buf) >= 0) {
3361 PUSHs(sv_2mortal(newSVpv(buf.sysname, 0)));
3362 PUSHs(sv_2mortal(newSVpv(buf.nodename, 0)));
3363 PUSHs(sv_2mortal(newSVpv(buf.release, 0)));
3364 PUSHs(sv_2mortal(newSVpv(buf.version, 0)));
3365 PUSHs(sv_2mortal(newSVpv(buf.machine, 0)));
3368 uname((char *) 0); /* A stub to call not_here(). */
3372 write(fd, buffer, nbytes)
3390 mbstowcs(s, pwcs, n)
3402 wcstombs(s, pwcs, n)
3424 SET_NUMERIC_LOCAL();
3425 num = strtod(str, &unparsed);
3426 PUSHs(sv_2mortal(newSVnv(num)));
3427 if (GIMME == G_ARRAY) {
3430 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3432 PUSHs(&PL_sv_undef);
3436 strtol(str, base = 0)
3443 num = strtol(str, &unparsed, base);
3444 if (num >= IV_MIN && num <= IV_MAX)
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))));
3453 PUSHs(&PL_sv_undef);
3457 strtoul(str, base = 0)
3464 num = strtoul(str, &unparsed, base);
3466 PUSHs(sv_2mortal(newSViv((IV)num)));
3468 PUSHs(sv_2mortal(newSVnv((double)num)));
3469 if (GIMME == G_ARRAY) {
3472 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3474 PUSHs(&PL_sv_undef);
3484 char *p = SvPV(src,srclen);
3486 ST(0) = sv_2mortal(NEWSV(800,srclen));
3487 dstlen = strxfrm(SvPVX(ST(0)), p, (size_t)srclen);
3488 if (dstlen > srclen) {
3490 SvGROW(ST(0), dstlen);
3491 strxfrm(SvPVX(ST(0)), p, (size_t)dstlen);
3494 SvCUR(ST(0)) = dstlen;
3499 mkfifo(filename, mode)
3503 TAINT_PROPER("mkfifo");
3504 RETVAL = mkfifo(filename, mode);
3520 tcflush(fd, queue_selector)
3525 tcsendbreak(fd, duration)
3530 asctime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3543 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3546 mytm.tm_hour = hour;
3547 mytm.tm_mday = mday;
3549 mytm.tm_year = year;
3550 mytm.tm_wday = wday;
3551 mytm.tm_yday = yday;
3552 mytm.tm_isdst = isdst;
3553 RETVAL = asctime(&mytm);
3570 realtime = times( &tms );
3572 PUSHs( sv_2mortal( newSViv( (IV) realtime ) ) );
3573 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_utime ) ) );
3574 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_stime ) ) );
3575 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cutime ) ) );
3576 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cstime ) ) );
3579 difftime(time1, time2)
3584 mktime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3597 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3600 mytm.tm_hour = hour;
3601 mytm.tm_mday = mday;
3603 mytm.tm_year = year;
3604 mytm.tm_wday = wday;
3605 mytm.tm_yday = yday;
3606 mytm.tm_isdst = isdst;
3607 RETVAL = mktime(&mytm);
3613 strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1)
3629 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3632 mytm.tm_hour = hour;
3633 mytm.tm_mday = mday;
3635 mytm.tm_year = year;
3636 mytm.tm_wday = wday;
3637 mytm.tm_yday = yday;
3638 mytm.tm_isdst = isdst;
3639 (void) mktime(&mytm);
3640 len = strftime(tmpbuf, sizeof tmpbuf, fmt, &mytm);
3642 ** The following is needed to handle to the situation where
3643 ** tmpbuf overflows. Basically we want to allocate a buffer
3644 ** and try repeatedly. The reason why it is so complicated
3645 ** is that getting a return value of 0 from strftime can indicate
3646 ** one of the following:
3647 ** 1. buffer overflowed,
3648 ** 2. illegal conversion specifier, or
3649 ** 3. the format string specifies nothing to be returned(not
3650 ** an error). This could be because format is an empty string
3651 ** or it specifies %p that yields an empty string in some locale.
3652 ** If there is a better way to make it portable, go ahead by
3655 if ( ( len > 0 && len < sizeof(tmpbuf) )
3656 || ( len == 0 && strlen(fmt) == 0 ) ) {
3657 ST(0) = sv_2mortal(newSVpv(tmpbuf, len));
3659 /* Possibly buf overflowed - try again with a bigger buf */
3660 int bufsize = strlen(fmt) + sizeof(tmpbuf);
3664 New(0, buf, bufsize, char);
3666 buflen = strftime(buf, bufsize, fmt, &mytm);
3667 if ( buflen > 0 && buflen < bufsize ) break;
3669 Renew(buf, bufsize, char);
3672 ST(0) = sv_2mortal(newSVpvn(buf, buflen));
3675 ST(0) = sv_2mortal(newSVpvn(tmpbuf, len));
3687 PUSHs(sv_2mortal(newSVpvn(tzname[0],strlen(tzname[0]))));
3688 PUSHs(sv_2mortal(newSVpvn(tzname[1],strlen(tzname[1]))));
3691 access(filename, mode)
3709 pathconf(filename, name)