5 #define PERL_NO_GET_CONTEXT
8 #define PERLIO_NOT_STDIO 1
11 #if defined(PERL_OBJECT) || defined(PERL_CAPI) || defined(PERL_IMPLICIT_SYS)
15 # define open PerlLIO_open3
18 #ifdef I_DIRENT /* XXX maybe better to just rely on perl.h? */
45 /* XXX This comment is just to make I_TERMIO and I_SGTTY visible to
46 metaconfig for future extension writers. We don't use them in POSIX.
47 (This is really sneaky :-) --AD
49 #if defined(I_TERMIOS)
57 #include <sys/types.h>
62 #ifdef MACOS_TRADITIONAL
68 # if !defined(WIN32) && !defined(__CYGWIN__)
69 extern char *tzname[];
72 #if !defined(WIN32) || (defined(__MINGW32__) && !defined(tzname))
73 char *tzname[] = { "" , "" };
77 #if defined(__VMS) && !defined(__POSIX_SOURCE)
78 # include <libdef.h> /* LIB$_INVARG constant */
79 # include <lib$routines.h> /* prototype for lib$ediv() */
80 # include <starlet.h> /* prototype for sys$gettim() */
81 # if DECC_VERSION < 50000000
82 # define pid_t int /* old versions of DECC miss this in types.h */
86 # define mkfifo(a,b) (not_here("mkfifo"),-1)
87 # define tzset() not_here("tzset")
89 #if ((__VMS_VER >= 70000000) && (__DECC_VER >= 50200000)) || (__CRTL_VER >= 70000000)
90 # define HAS_TZNAME /* shows up in VMS 7.0 or Dec C 5.6 */
92 # endif /* __VMS_VER >= 70000000 or Dec C 5.6 */
94 /* The POSIX notion of ttyname() is better served by getname() under VMS */
95 static char ttnambuf[64];
96 # define ttyname(fd) (isatty(fd) > 0 ? getname(fd,ttnambuf,0) : NULL)
98 /* The non-POSIX CRTL times() has void return type, so we just get the
99 current time directly */
100 clock_t vms_times(struct tms *bufptr) {
103 /* Get wall time and convert to 10 ms intervals to
104 * produce the return value that the POSIX standard expects */
105 # if defined(__DECC) && defined (__ALPHA)
108 _ckvmssts(sys$gettim(&vmstime));
110 retval = vmstime & 0x7fffffff;
112 /* (Older hw or ccs don't have an atomic 64-bit type, so we
113 * juggle 32-bit ints (and a float) to produce a time_t result
114 * with minimal loss of information.) */
115 long int vmstime[2],remainder,divisor = 100000;
116 _ckvmssts(sys$gettim((unsigned long int *)vmstime));
117 vmstime[1] &= 0x7fff; /* prevent overflow in EDIV */
118 _ckvmssts(lib$ediv(&divisor,vmstime,(long int *)&retval,&remainder));
120 /* Fill in the struct tms using the CRTL routine . . .*/
121 times((tbuffer_t *)bufptr);
122 return (clock_t) retval;
124 # define times(t) vms_times(t)
126 #if defined (__CYGWIN__)
127 # define tzname _tzname
131 # define mkfifo(a,b) not_here("mkfifo")
132 # define ttyname(a) (char*)not_here("ttyname")
133 # define sigset_t long
136 # define tzname _tzname
139 # define mode_t short
142 # define mode_t short
144 # define tzset() not_here("tzset")
146 # ifndef _POSIX_OPEN_MAX
147 # define _POSIX_OPEN_MAX FOPEN_MAX /* XXX bogus ? */
150 # define sigaction(a,b,c) not_here("sigaction")
151 # define sigpending(a) not_here("sigpending")
152 # define sigprocmask(a,b,c) not_here("sigprocmask")
153 # define sigsuspend(a) not_here("sigsuspend")
154 # define sigemptyset(a) not_here("sigemptyset")
155 # define sigaddset(a,b) not_here("sigaddset")
156 # define sigdelset(a,b) not_here("sigdelset")
157 # define sigfillset(a) not_here("sigfillset")
158 # define sigismember(a,b) not_here("sigismember")
162 # if defined(OS2) || defined(MACOS_TRADITIONAL)
163 # define mkfifo(a,b) not_here("mkfifo")
164 # else /* !( defined OS2 ) */
166 # define mkfifo(path, mode) (mknod((path), (mode) | S_IFIFO, 0))
169 # endif /* !HAS_MKFIFO */
171 # ifdef MACOS_TRADITIONAL
172 # define ttyname(a) (char*)not_here("ttyname")
173 # define tzset() not_here("tzset")
176 # include <sys/times.h>
178 # include <sys/utsname.h>
180 # include <sys/wait.h>
189 typedef long SysRetLong;
190 typedef sigset_t* POSIX__SigSet;
191 typedef HV* POSIX__SigAction;
193 typedef struct termios* POSIX__Termios;
194 #else /* Define termios types to int, and call not_here for the functions.*/
195 #define POSIX__Termios int
199 #define cfgetispeed(x) not_here("cfgetispeed")
200 #define cfgetospeed(x) not_here("cfgetospeed")
201 #define tcdrain(x) not_here("tcdrain")
202 #define tcflush(x,y) not_here("tcflush")
203 #define tcsendbreak(x,y) not_here("tcsendbreak")
204 #define cfsetispeed(x,y) not_here("cfsetispeed")
205 #define cfsetospeed(x,y) not_here("cfsetospeed")
206 #define ctermid(x) (char *) not_here("ctermid")
207 #define tcflow(x,y) not_here("tcflow")
208 #define tcgetattr(x,y) not_here("tcgetattr")
209 #define tcsetattr(x,y,z) not_here("tcsetattr")
212 /* Possibly needed prototypes */
213 char *cuserid (char *);
214 double strtod (const char *, char **);
215 long strtol (const char *, char **, int);
216 unsigned long strtoul (const char *, char **, int);
219 #define cuserid(a) (char *) not_here("cuserid")
223 #define difftime(a,b) not_here("difftime")
226 #ifndef HAS_FPATHCONF
227 #define fpathconf(f,n) (SysRetLong) not_here("fpathconf")
230 #define mktime(a) not_here("mktime")
233 #define nice(a) not_here("nice")
236 #define pathconf(f,n) (SysRetLong) not_here("pathconf")
239 #define sysconf(n) (SysRetLong) not_here("sysconf")
242 #define readlink(a,b,c) not_here("readlink")
245 #define setpgid(a,b) not_here("setpgid")
248 #define setsid() not_here("setsid")
251 #define strcoll(s1,s2) not_here("strcoll")
254 #define strtod(s1,s2) not_here("strtod")
257 #define strtol(s1,s2,b) not_here("strtol")
260 #define strtoul(s1,s2,b) not_here("strtoul")
263 #define strxfrm(s1,s2,n) not_here("strxfrm")
265 #ifndef HAS_TCGETPGRP
266 #define tcgetpgrp(a) not_here("tcgetpgrp")
268 #ifndef HAS_TCSETPGRP
269 #define tcsetpgrp(a,b) not_here("tcsetpgrp")
272 #define times(a) not_here("times")
275 #define uname(a) not_here("uname")
278 #define waitpid(a,b,c) not_here("waitpid")
283 #define mblen(a,b) not_here("mblen")
287 #define mbstowcs(s, pwcs, n) not_here("mbstowcs")
290 #define mbtowc(pwc, s, n) not_here("mbtowc")
293 #define wcstombs(s, pwcs, n) not_here("wcstombs")
296 #define wctomb(s, wchar) not_here("wcstombs")
298 #if !defined(HAS_MBLEN) && !defined(HAS_MBSTOWCS) && !defined(HAS_MBTOWC) && !defined(HAS_WCSTOMBS) && !defined(HAS_WCTOMB)
299 /* If we don't have these functions, then we wouldn't have gotten a typedef
300 for wchar_t, the wide character type. Defining wchar_t allows the
301 functions referencing it to compile. Its actual type is then meaningless,
302 since without the above functions, all sections using it end up calling
303 not_here() and croak. --Kaveh Ghazi (ghazi@noc.rutgers.edu) 9/18/94. */
309 #ifndef HAS_LOCALECONV
310 #define localeconv() not_here("localeconv")
313 #ifdef HAS_LONG_DOUBLE
314 # if LONG_DOUBLESIZE > NVSIZE
315 # undef HAS_LONG_DOUBLE /* XXX until we figure out how to use them */
319 #ifndef HAS_LONG_DOUBLE
334 croak("POSIX::%s not implemented on this architecture", s);
340 constant(char *name, int arg)
345 if (strEQ(name, "ARG_MAX"))
353 if (strEQ(name, "BUFSIZ"))
359 if (strEQ(name, "BRKINT"))
365 if (strEQ(name, "B9600"))
371 if (strEQ(name, "B19200"))
377 if (strEQ(name, "B38400"))
383 if (strEQ(name, "B0"))
389 if (strEQ(name, "B110"))
395 if (strEQ(name, "B1200"))
401 if (strEQ(name, "B134"))
407 if (strEQ(name, "B150"))
413 if (strEQ(name, "B1800"))
419 if (strEQ(name, "B200"))
425 if (strEQ(name, "B2400"))
431 if (strEQ(name, "B300"))
437 if (strEQ(name, "B4800"))
443 if (strEQ(name, "B50"))
449 if (strEQ(name, "B600"))
455 if (strEQ(name, "B75"))
463 if (strEQ(name, "CHAR_BIT"))
469 if (strEQ(name, "CHAR_MAX"))
475 if (strEQ(name, "CHAR_MIN"))
481 if (strEQ(name, "CHILD_MAX"))
487 if (strEQ(name, "CLK_TCK"))
493 if (strEQ(name, "CLOCAL"))
499 if (strEQ(name, "CLOCKS_PER_SEC"))
500 #ifdef CLOCKS_PER_SEC
501 return CLOCKS_PER_SEC;
505 if (strEQ(name, "CREAD"))
511 if (strEQ(name, "CS5"))
517 if (strEQ(name, "CS6"))
523 if (strEQ(name, "CS7"))
529 if (strEQ(name, "CS8"))
535 if (strEQ(name, "CSIZE"))
541 if (strEQ(name, "CSTOPB"))
549 if (strEQ(name, "DBL_MAX"))
555 if (strEQ(name, "DBL_MIN"))
561 if (strEQ(name, "DBL_DIG"))
567 if (strEQ(name, "DBL_EPSILON"))
573 if (strEQ(name, "DBL_MANT_DIG"))
579 if (strEQ(name, "DBL_MAX_10_EXP"))
580 #ifdef DBL_MAX_10_EXP
581 return DBL_MAX_10_EXP;
585 if (strEQ(name, "DBL_MAX_EXP"))
591 if (strEQ(name, "DBL_MIN_10_EXP"))
592 #ifdef DBL_MIN_10_EXP
593 return DBL_MIN_10_EXP;
597 if (strEQ(name, "DBL_MIN_EXP"))
607 if (strEQ(name, "EACCES"))
613 if (strEQ(name, "EADDRINUSE"))
619 if (strEQ(name, "EADDRNOTAVAIL"))
621 return EADDRNOTAVAIL;
625 if (strEQ(name, "EAFNOSUPPORT"))
631 if (strEQ(name, "EAGAIN"))
637 if (strEQ(name, "EALREADY"))
645 if (strEQ(name, "EBADF"))
651 if (strEQ(name, "EBUSY"))
659 if (strEQ(name, "ECHILD"))
665 if (strEQ(name, "ECHO"))
671 if (strEQ(name, "ECHOE"))
677 if (strEQ(name, "ECHOK"))
683 if (strEQ(name, "ECHONL"))
689 if (strEQ(name, "ECONNABORTED"))
695 if (strEQ(name, "ECONNREFUSED"))
701 if (strEQ(name, "ECONNRESET"))
709 if (strEQ(name, "EDEADLK"))
715 if (strEQ(name, "EDESTADDRREQ"))
721 if (strEQ(name, "EDOM"))
727 if (strEQ(name, "EDQUOT"))
735 if (strEQ(name, "EEXIST"))
743 if (strEQ(name, "EFAULT"))
749 if (strEQ(name, "EFBIG"))
757 if (strEQ(name, "EHOSTDOWN"))
763 if (strEQ(name, "EHOSTUNREACH"))
771 if (strEQ(name, "EINPROGRESS"))
777 if (strEQ(name, "EINTR"))
783 if (strEQ(name, "EINVAL"))
789 if (strEQ(name, "EIO"))
795 if (strEQ(name, "EISCONN"))
801 if (strEQ(name, "EISDIR"))
809 if (strEQ(name, "ELOOP"))
817 if (strEQ(name, "EMFILE"))
823 if (strEQ(name, "EMLINK"))
829 if (strEQ(name, "EMSGSIZE"))
837 if (strEQ(name, "ENETDOWN"))
843 if (strEQ(name, "ENETRESET"))
849 if (strEQ(name, "ENETUNREACH"))
855 if (strEQ(name, "ENOBUFS"))
861 if (strEQ(name, "ENOEXEC"))
867 if (strEQ(name, "ENOMEM"))
873 if (strEQ(name, "ENOPROTOOPT"))
879 if (strEQ(name, "ENOSPC"))
885 if (strEQ(name, "ENOTBLK"))
891 if (strEQ(name, "ENOTCONN"))
897 if (strEQ(name, "ENOTDIR"))
903 if (strEQ(name, "ENOTEMPTY"))
909 if (strEQ(name, "ENOTSOCK"))
915 if (strEQ(name, "ENOTTY"))
921 if (strEQ(name, "ENFILE"))
927 if (strEQ(name, "ENODEV"))
933 if (strEQ(name, "ENOENT"))
939 if (strEQ(name, "ENOLCK"))
945 if (strEQ(name, "ENOSYS"))
951 if (strEQ(name, "ENXIO"))
957 if (strEQ(name, "ENAMETOOLONG"))
965 if (strEQ(name, "EOF"))
971 if (strEQ(name, "EOPNOTSUPP"))
979 if (strEQ(name, "EPERM"))
985 if (strEQ(name, "EPFNOSUPPORT"))
991 if (strEQ(name, "EPIPE"))
997 if (strEQ(name, "EPROCLIM"))
1003 if (strEQ(name, "EPROTONOSUPPORT"))
1004 #ifdef EPROTONOSUPPORT
1005 return EPROTONOSUPPORT;
1009 if (strEQ(name, "EPROTOTYPE"))
1017 if (strEQ(name, "ERANGE"))
1023 if (strEQ(name, "EREMOTE"))
1029 if (strEQ(name, "ERESTART"))
1035 if (strEQ(name, "EROFS"))
1043 if (strEQ(name, "ESHUTDOWN"))
1049 if (strEQ(name, "ESOCKTNOSUPPORT"))
1050 #ifdef ESOCKTNOSUPPORT
1051 return ESOCKTNOSUPPORT;
1055 if (strEQ(name, "ESPIPE"))
1061 if (strEQ(name, "ESRCH"))
1067 if (strEQ(name, "ESTALE"))
1075 if (strEQ(name, "ETIMEDOUT"))
1081 if (strEQ(name, "ETOOMANYREFS"))
1083 return ETOOMANYREFS;
1087 if (strEQ(name, "ETXTBSY"))
1095 if (strEQ(name, "EUSERS"))
1103 if (strEQ(name, "EWOULDBLOCK"))
1111 if (strEQ(name, "EXIT_FAILURE"))
1113 return EXIT_FAILURE;
1117 if (strEQ(name, "EXIT_SUCCESS"))
1119 return EXIT_SUCCESS;
1123 if (strEQ(name, "EXDEV"))
1131 if (strEQ(name, "E2BIG"))
1139 if (strnEQ(name, "FLT_", 4)) {
1140 if (strEQ(name, "FLT_MAX"))
1146 if (strEQ(name, "FLT_MIN"))
1152 if (strEQ(name, "FLT_ROUNDS"))
1158 if (strEQ(name, "FLT_DIG"))
1164 if (strEQ(name, "FLT_EPSILON"))
1170 if (strEQ(name, "FLT_MANT_DIG"))
1172 return FLT_MANT_DIG;
1176 if (strEQ(name, "FLT_MAX_10_EXP"))
1177 #ifdef FLT_MAX_10_EXP
1178 return FLT_MAX_10_EXP;
1182 if (strEQ(name, "FLT_MAX_EXP"))
1188 if (strEQ(name, "FLT_MIN_10_EXP"))
1189 #ifdef FLT_MIN_10_EXP
1190 return FLT_MIN_10_EXP;
1194 if (strEQ(name, "FLT_MIN_EXP"))
1200 if (strEQ(name, "FLT_RADIX"))
1208 if (strnEQ(name, "F_", 2)) {
1209 if (strEQ(name, "F_DUPFD"))
1215 if (strEQ(name, "F_GETFD"))
1221 if (strEQ(name, "F_GETFL"))
1227 if (strEQ(name, "F_GETLK"))
1233 if (strEQ(name, "F_OK"))
1239 if (strEQ(name, "F_RDLCK"))
1245 if (strEQ(name, "F_SETFD"))
1251 if (strEQ(name, "F_SETFL"))
1257 if (strEQ(name, "F_SETLK"))
1263 if (strEQ(name, "F_SETLKW"))
1269 if (strEQ(name, "F_UNLCK"))
1275 if (strEQ(name, "F_WRLCK"))
1283 if (strEQ(name, "FD_CLOEXEC"))
1289 if (strEQ(name, "FILENAME_MAX"))
1291 return FILENAME_MAX;
1297 if (strEQ(name, "HUGE_VAL"))
1298 #if defined(USE_LONG_DOUBLE) && defined(HUGE_VALL)
1299 /* HUGE_VALL is admittedly non-POSIX but if we are using long doubles
1300 * we might as well use long doubles. --jhi */
1308 if (strEQ(name, "HUPCL"))
1316 if (strEQ(name, "INT_MAX"))
1322 if (strEQ(name, "INT_MIN"))
1328 if (strEQ(name, "ICANON"))
1334 if (strEQ(name, "ICRNL"))
1340 if (strEQ(name, "IEXTEN"))
1346 if (strEQ(name, "IGNBRK"))
1352 if (strEQ(name, "IGNCR"))
1358 if (strEQ(name, "IGNPAR"))
1364 if (strEQ(name, "INLCR"))
1370 if (strEQ(name, "INPCK"))
1376 if (strEQ(name, "ISIG"))
1382 if (strEQ(name, "ISTRIP"))
1388 if (strEQ(name, "IXOFF"))
1394 if (strEQ(name, "IXON"))
1402 if (strnEQ(name, "LC_", 3)) {
1403 if (strEQ(name, "LC_ALL"))
1409 if (strEQ(name, "LC_COLLATE"))
1415 if (strEQ(name, "LC_CTYPE"))
1421 if (strEQ(name, "LC_MONETARY"))
1427 if (strEQ(name, "LC_NUMERIC"))
1433 if (strEQ(name, "LC_TIME"))
1441 if (strnEQ(name, "LDBL_", 5)) {
1442 if (strEQ(name, "LDBL_MAX"))
1448 if (strEQ(name, "LDBL_MIN"))
1454 if (strEQ(name, "LDBL_DIG"))
1460 if (strEQ(name, "LDBL_EPSILON"))
1462 return LDBL_EPSILON;
1466 if (strEQ(name, "LDBL_MANT_DIG"))
1467 #ifdef LDBL_MANT_DIG
1468 return LDBL_MANT_DIG;
1472 if (strEQ(name, "LDBL_MAX_10_EXP"))
1473 #ifdef LDBL_MAX_10_EXP
1474 return LDBL_MAX_10_EXP;
1478 if (strEQ(name, "LDBL_MAX_EXP"))
1480 return LDBL_MAX_EXP;
1484 if (strEQ(name, "LDBL_MIN_10_EXP"))
1485 #ifdef LDBL_MIN_10_EXP
1486 return LDBL_MIN_10_EXP;
1490 if (strEQ(name, "LDBL_MIN_EXP"))
1492 return LDBL_MIN_EXP;
1498 if (strnEQ(name, "L_", 2)) {
1499 if (strEQ(name, "L_ctermid"))
1505 if (strEQ(name, "L_cuserid"))
1511 /* L_tmpnam[e] was a typo--retained for compatibility */
1512 if (strEQ(name, "L_tmpname") || strEQ(name, "L_tmpnam"))
1520 if (strEQ(name, "LONG_MAX"))
1526 if (strEQ(name, "LONG_MIN"))
1532 if (strEQ(name, "LINK_MAX"))
1540 if (strEQ(name, "MAX_CANON"))
1546 if (strEQ(name, "MAX_INPUT"))
1552 if (strEQ(name, "MB_CUR_MAX"))
1558 if (strEQ(name, "MB_LEN_MAX"))
1566 if (strEQ(name, "NULL")) return 0;
1567 if (strEQ(name, "NAME_MAX"))
1573 if (strEQ(name, "NCCS"))
1579 if (strEQ(name, "NGROUPS_MAX"))
1585 if (strEQ(name, "NOFLSH"))
1593 if (strnEQ(name, "O_", 2)) {
1594 if (strEQ(name, "O_APPEND"))
1600 if (strEQ(name, "O_CREAT"))
1606 if (strEQ(name, "O_TRUNC"))
1612 if (strEQ(name, "O_RDONLY"))
1618 if (strEQ(name, "O_RDWR"))
1624 if (strEQ(name, "O_WRONLY"))
1630 if (strEQ(name, "O_EXCL"))
1636 if (strEQ(name, "O_NOCTTY"))
1642 if (strEQ(name, "O_NONBLOCK"))
1648 if (strEQ(name, "O_ACCMODE"))
1656 if (strEQ(name, "OPEN_MAX"))
1662 if (strEQ(name, "OPOST"))
1670 if (strEQ(name, "PATH_MAX"))
1676 if (strEQ(name, "PARENB"))
1682 if (strEQ(name, "PARMRK"))
1688 if (strEQ(name, "PARODD"))
1694 if (strEQ(name, "PIPE_BUF"))
1702 if (strEQ(name, "RAND_MAX"))
1708 if (strEQ(name, "R_OK"))
1716 if (strnEQ(name, "SIG", 3)) {
1717 if (name[3] == '_') {
1718 if (strEQ(name, "SIG_BLOCK"))
1725 if (strEQ(name, "SIG_DFL")) return (IV)SIG_DFL;
1728 if (strEQ(name, "SIG_ERR")) return (IV)SIG_ERR;
1731 if (strEQ(name, "SIG_IGN")) return (IV)SIG_IGN;
1733 if (strEQ(name, "SIG_SETMASK"))
1739 if (strEQ(name, "SIG_UNBLOCK"))
1747 if (strEQ(name, "SIGABRT"))
1753 if (strEQ(name, "SIGALRM"))
1759 if (strEQ(name, "SIGCHLD"))
1765 if (strEQ(name, "SIGCONT"))
1771 if (strEQ(name, "SIGFPE"))
1777 if (strEQ(name, "SIGHUP"))
1783 if (strEQ(name, "SIGILL"))
1789 if (strEQ(name, "SIGINT"))
1795 if (strEQ(name, "SIGKILL"))
1801 if (strEQ(name, "SIGPIPE"))
1807 if (strEQ(name, "SIGQUIT"))
1813 if (strEQ(name, "SIGSEGV"))
1819 if (strEQ(name, "SIGSTOP"))
1825 if (strEQ(name, "SIGTERM"))
1831 if (strEQ(name, "SIGTSTP"))
1837 if (strEQ(name, "SIGTTIN"))
1843 if (strEQ(name, "SIGTTOU"))
1849 if (strEQ(name, "SIGUSR1"))
1855 if (strEQ(name, "SIGUSR2"))
1863 if (name[1] == '_') {
1864 if (strEQ(name, "S_ISGID"))
1870 if (strEQ(name, "S_ISUID"))
1876 if (strEQ(name, "S_IRGRP"))
1882 if (strEQ(name, "S_IROTH"))
1888 if (strEQ(name, "S_IRUSR"))
1894 if (strEQ(name, "S_IRWXG"))
1900 if (strEQ(name, "S_IRWXO"))
1906 if (strEQ(name, "S_IRWXU"))
1912 if (strEQ(name, "S_IWGRP"))
1918 if (strEQ(name, "S_IWOTH"))
1924 if (strEQ(name, "S_IWUSR"))
1930 if (strEQ(name, "S_IXGRP"))
1936 if (strEQ(name, "S_IXOTH"))
1942 if (strEQ(name, "S_IXUSR"))
1948 errno = EAGAIN; /* the following aren't constants */
1950 if (strEQ(name, "S_ISBLK")) return S_ISBLK(arg);
1953 if (strEQ(name, "S_ISCHR")) return S_ISCHR(arg);
1956 if (strEQ(name, "S_ISDIR")) return S_ISDIR(arg);
1959 if (strEQ(name, "S_ISFIFO")) return S_ISFIFO(arg);
1962 if (strEQ(name, "S_ISREG")) return S_ISREG(arg);
1966 if (strEQ(name, "SEEK_CUR"))
1972 if (strEQ(name, "SEEK_END"))
1978 if (strEQ(name, "SEEK_SET"))
1984 if (strEQ(name, "STREAM_MAX"))
1990 if (strEQ(name, "SHRT_MAX"))
1996 if (strEQ(name, "SHRT_MIN"))
2002 if (strnEQ(name, "SA_", 3)) {
2003 if (strEQ(name, "SA_NOCLDSTOP"))
2005 return SA_NOCLDSTOP;
2009 if (strEQ(name, "SA_NOCLDWAIT"))
2011 return SA_NOCLDWAIT;
2015 if (strEQ(name, "SA_NODEFER"))
2021 if (strEQ(name, "SA_ONSTACK"))
2027 if (strEQ(name, "SA_RESETHAND"))
2029 return SA_RESETHAND;
2033 if (strEQ(name, "SA_RESTART"))
2039 if (strEQ(name, "SA_SIGINFO"))
2047 if (strEQ(name, "SCHAR_MAX"))
2053 if (strEQ(name, "SCHAR_MIN"))
2059 if (strEQ(name, "SSIZE_MAX"))
2065 if (strEQ(name, "STDIN_FILENO"))
2067 return STDIN_FILENO;
2071 if (strEQ(name, "STDOUT_FILENO"))
2072 #ifdef STDOUT_FILENO
2073 return STDOUT_FILENO;
2077 if (strEQ(name, "STDERR_FILENO"))
2078 #ifdef STDERR_FILENO
2079 return STDERR_FILENO;
2085 if (strEQ(name, "TCIFLUSH"))
2091 if (strEQ(name, "TCIOFF"))
2097 if (strEQ(name, "TCIOFLUSH"))
2103 if (strEQ(name, "TCION"))
2109 if (strEQ(name, "TCOFLUSH"))
2115 if (strEQ(name, "TCOOFF"))
2121 if (strEQ(name, "TCOON"))
2127 if (strEQ(name, "TCSADRAIN"))
2133 if (strEQ(name, "TCSAFLUSH"))
2139 if (strEQ(name, "TCSANOW"))
2145 if (strEQ(name, "TMP_MAX"))
2151 if (strEQ(name, "TOSTOP"))
2157 if (strEQ(name, "TZNAME_MAX"))
2165 if (strEQ(name, "UCHAR_MAX"))
2171 if (strEQ(name, "UINT_MAX"))
2177 if (strEQ(name, "ULONG_MAX"))
2183 if (strEQ(name, "USHRT_MAX"))
2191 if (strEQ(name, "VEOF"))
2197 if (strEQ(name, "VEOL"))
2203 if (strEQ(name, "VERASE"))
2209 if (strEQ(name, "VINTR"))
2215 if (strEQ(name, "VKILL"))
2221 if (strEQ(name, "VMIN"))
2227 if (strEQ(name, "VQUIT"))
2233 if (strEQ(name, "VSTART"))
2239 if (strEQ(name, "VSTOP"))
2245 if (strEQ(name, "VSUSP"))
2251 if (strEQ(name, "VTIME"))
2259 if (strEQ(name, "W_OK"))
2265 if (strEQ(name, "WNOHANG"))
2271 if (strEQ(name, "WUNTRACED"))
2277 errno = EAGAIN; /* the following aren't constants */
2279 if (strEQ(name, "WEXITSTATUS")) return WEXITSTATUS(arg);
2282 if (strEQ(name, "WIFEXITED")) return WIFEXITED(arg);
2285 if (strEQ(name, "WIFSIGNALED")) return WIFSIGNALED(arg);
2288 if (strEQ(name, "WIFSTOPPED")) return WIFSTOPPED(arg);
2291 if (strEQ(name, "WSTOPSIG")) return WSTOPSIG(arg);
2294 if (strEQ(name, "WTERMSIG")) return WTERMSIG(arg);
2298 if (strEQ(name, "X_OK"))
2306 if (strnEQ(name, "_PC_", 4)) {
2307 if (strEQ(name, "_PC_CHOWN_RESTRICTED"))
2308 #if defined(_PC_CHOWN_RESTRICTED) || HINT_SC_EXIST
2309 return _PC_CHOWN_RESTRICTED;
2313 if (strEQ(name, "_PC_LINK_MAX"))
2314 #if defined(_PC_LINK_MAX) || HINT_SC_EXIST
2315 return _PC_LINK_MAX;
2319 if (strEQ(name, "_PC_MAX_CANON"))
2320 #if defined(_PC_MAX_CANON) || HINT_SC_EXIST
2321 return _PC_MAX_CANON;
2325 if (strEQ(name, "_PC_MAX_INPUT"))
2326 #if defined(_PC_MAX_INPUT) || HINT_SC_EXIST
2327 return _PC_MAX_INPUT;
2331 if (strEQ(name, "_PC_NAME_MAX"))
2332 #if defined(_PC_NAME_MAX) || HINT_SC_EXIST
2333 return _PC_NAME_MAX;
2337 if (strEQ(name, "_PC_NO_TRUNC"))
2338 #if defined(_PC_NO_TRUNC) || HINT_SC_EXIST
2339 return _PC_NO_TRUNC;
2343 if (strEQ(name, "_PC_PATH_MAX"))
2344 #if defined(_PC_PATH_MAX) || HINT_SC_EXIST
2345 return _PC_PATH_MAX;
2349 if (strEQ(name, "_PC_PIPE_BUF"))
2350 #if defined(_PC_PIPE_BUF) || HINT_SC_EXIST
2351 return _PC_PIPE_BUF;
2355 if (strEQ(name, "_PC_VDISABLE"))
2356 #if defined(_PC_VDISABLE) || HINT_SC_EXIST
2357 return _PC_VDISABLE;
2363 if (strnEQ(name, "_POSIX_", 7)) {
2364 if (strEQ(name, "_POSIX_ARG_MAX"))
2365 #ifdef _POSIX_ARG_MAX
2366 return _POSIX_ARG_MAX;
2370 if (strEQ(name, "_POSIX_CHILD_MAX"))
2371 #ifdef _POSIX_CHILD_MAX
2372 return _POSIX_CHILD_MAX;
2376 if (strEQ(name, "_POSIX_CHOWN_RESTRICTED"))
2377 #ifdef _POSIX_CHOWN_RESTRICTED
2378 return _POSIX_CHOWN_RESTRICTED;
2382 if (strEQ(name, "_POSIX_JOB_CONTROL"))
2383 #ifdef _POSIX_JOB_CONTROL
2384 return _POSIX_JOB_CONTROL;
2388 if (strEQ(name, "_POSIX_LINK_MAX"))
2389 #ifdef _POSIX_LINK_MAX
2390 return _POSIX_LINK_MAX;
2394 if (strEQ(name, "_POSIX_MAX_CANON"))
2395 #ifdef _POSIX_MAX_CANON
2396 return _POSIX_MAX_CANON;
2400 if (strEQ(name, "_POSIX_MAX_INPUT"))
2401 #ifdef _POSIX_MAX_INPUT
2402 return _POSIX_MAX_INPUT;
2406 if (strEQ(name, "_POSIX_NAME_MAX"))
2407 #ifdef _POSIX_NAME_MAX
2408 return _POSIX_NAME_MAX;
2412 if (strEQ(name, "_POSIX_NGROUPS_MAX"))
2413 #ifdef _POSIX_NGROUPS_MAX
2414 return _POSIX_NGROUPS_MAX;
2418 if (strEQ(name, "_POSIX_NO_TRUNC"))
2419 #ifdef _POSIX_NO_TRUNC
2420 return _POSIX_NO_TRUNC;
2424 if (strEQ(name, "_POSIX_OPEN_MAX"))
2425 #ifdef _POSIX_OPEN_MAX
2426 return _POSIX_OPEN_MAX;
2430 if (strEQ(name, "_POSIX_PATH_MAX"))
2431 #ifdef _POSIX_PATH_MAX
2432 return _POSIX_PATH_MAX;
2436 if (strEQ(name, "_POSIX_PIPE_BUF"))
2437 #ifdef _POSIX_PIPE_BUF
2438 return _POSIX_PIPE_BUF;
2442 if (strEQ(name, "_POSIX_SAVED_IDS"))
2443 #ifdef _POSIX_SAVED_IDS
2444 return _POSIX_SAVED_IDS;
2448 if (strEQ(name, "_POSIX_SSIZE_MAX"))
2449 #ifdef _POSIX_SSIZE_MAX
2450 return _POSIX_SSIZE_MAX;
2454 if (strEQ(name, "_POSIX_STREAM_MAX"))
2455 #ifdef _POSIX_STREAM_MAX
2456 return _POSIX_STREAM_MAX;
2460 if (strEQ(name, "_POSIX_TZNAME_MAX"))
2461 #ifdef _POSIX_TZNAME_MAX
2462 return _POSIX_TZNAME_MAX;
2466 if (strEQ(name, "_POSIX_VDISABLE"))
2467 #ifdef _POSIX_VDISABLE
2468 return _POSIX_VDISABLE;
2472 if (strEQ(name, "_POSIX_VERSION"))
2473 #ifdef _POSIX_VERSION
2474 return _POSIX_VERSION;
2480 if (strnEQ(name, "_SC_", 4)) {
2481 if (strEQ(name, "_SC_ARG_MAX"))
2482 #if defined(_SC_ARG_MAX) || HINT_SC_EXIST
2487 if (strEQ(name, "_SC_CHILD_MAX"))
2488 #if defined(_SC_CHILD_MAX) || HINT_SC_EXIST
2489 return _SC_CHILD_MAX;
2493 if (strEQ(name, "_SC_CLK_TCK"))
2494 #if defined(_SC_CLK_TCK) || HINT_SC_EXIST
2499 if (strEQ(name, "_SC_JOB_CONTROL"))
2500 #if defined(_SC_JOB_CONTROL) || HINT_SC_EXIST
2501 return _SC_JOB_CONTROL;
2505 if (strEQ(name, "_SC_NGROUPS_MAX"))
2506 #if defined(_SC_NGROUPS_MAX) || HINT_SC_EXIST
2507 return _SC_NGROUPS_MAX;
2511 if (strEQ(name, "_SC_OPEN_MAX"))
2512 #if defined(_SC_OPEN_MAX) || HINT_SC_EXIST
2513 return _SC_OPEN_MAX;
2517 if (strEQ(name, "_SC_SAVED_IDS"))
2518 #if defined(_SC_SAVED_IDS) || HINT_SC_EXIST
2519 return _SC_SAVED_IDS;
2523 if (strEQ(name, "_SC_STREAM_MAX"))
2524 #if defined(_SC_STREAM_MAX) || HINT_SC_EXIST
2525 return _SC_STREAM_MAX;
2529 if (strEQ(name, "_SC_TZNAME_MAX"))
2530 #if defined(_SC_TZNAME_MAX) || HINT_SC_EXIST
2531 return _SC_TZNAME_MAX;
2535 if (strEQ(name, "_SC_VERSION"))
2536 #if defined(_SC_VERSION) || HINT_SC_EXIST
2548 not_here(""); /* -Wall */
2557 restore_sigmask(sigset_t *ossetp)
2559 /* Fortunately, restoring the signal mask can't fail, because
2560 * there's nothing we can do about it if it does -- we're not
2561 * supposed to return -1 from sigaction unless the disposition
2564 (void)sigprocmask(SIG_SETMASK, ossetp, (sigset_t *)0);
2567 MODULE = SigSet PACKAGE = POSIX::SigSet PREFIX = sig
2570 new(packname = "POSIX::SigSet", ...)
2575 New(0, RETVAL, 1, sigset_t);
2576 sigemptyset(RETVAL);
2577 for (i = 1; i < items; i++)
2578 sigaddset(RETVAL, SvIV(ST(i)));
2585 POSIX::SigSet sigset
2590 sigaddset(sigset, sig)
2591 POSIX::SigSet sigset
2595 sigdelset(sigset, sig)
2596 POSIX::SigSet sigset
2601 POSIX::SigSet sigset
2605 POSIX::SigSet sigset
2608 sigismember(sigset, sig)
2609 POSIX::SigSet sigset
2613 MODULE = Termios PACKAGE = POSIX::Termios PREFIX = cf
2616 new(packname = "POSIX::Termios", ...)
2621 New(0, RETVAL, 1, struct termios);
2623 not_here("termios");
2631 DESTROY(termios_ref)
2632 POSIX::Termios termios_ref
2635 Safefree(termios_ref);
2637 not_here("termios");
2641 getattr(termios_ref, fd = 0)
2642 POSIX::Termios termios_ref
2645 RETVAL = tcgetattr(fd, termios_ref);
2650 setattr(termios_ref, fd = 0, optional_actions = 0)
2651 POSIX::Termios termios_ref
2653 int optional_actions
2655 RETVAL = tcsetattr(fd, optional_actions, termios_ref);
2660 cfgetispeed(termios_ref)
2661 POSIX::Termios termios_ref
2664 cfgetospeed(termios_ref)
2665 POSIX::Termios termios_ref
2668 getiflag(termios_ref)
2669 POSIX::Termios termios_ref
2671 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2672 RETVAL = termios_ref->c_iflag;
2674 not_here("getiflag");
2681 getoflag(termios_ref)
2682 POSIX::Termios termios_ref
2684 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2685 RETVAL = termios_ref->c_oflag;
2687 not_here("getoflag");
2694 getcflag(termios_ref)
2695 POSIX::Termios termios_ref
2697 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2698 RETVAL = termios_ref->c_cflag;
2700 not_here("getcflag");
2707 getlflag(termios_ref)
2708 POSIX::Termios termios_ref
2710 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2711 RETVAL = termios_ref->c_lflag;
2713 not_here("getlflag");
2720 getcc(termios_ref, ccix)
2721 POSIX::Termios termios_ref
2724 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2726 croak("Bad getcc subscript");
2727 RETVAL = termios_ref->c_cc[ccix];
2736 cfsetispeed(termios_ref, speed)
2737 POSIX::Termios termios_ref
2741 cfsetospeed(termios_ref, speed)
2742 POSIX::Termios termios_ref
2746 setiflag(termios_ref, iflag)
2747 POSIX::Termios termios_ref
2750 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2751 termios_ref->c_iflag = iflag;
2753 not_here("setiflag");
2757 setoflag(termios_ref, oflag)
2758 POSIX::Termios termios_ref
2761 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2762 termios_ref->c_oflag = oflag;
2764 not_here("setoflag");
2768 setcflag(termios_ref, cflag)
2769 POSIX::Termios termios_ref
2772 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2773 termios_ref->c_cflag = cflag;
2775 not_here("setcflag");
2779 setlflag(termios_ref, lflag)
2780 POSIX::Termios termios_ref
2783 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2784 termios_ref->c_lflag = lflag;
2786 not_here("setlflag");
2790 setcc(termios_ref, ccix, cc)
2791 POSIX::Termios termios_ref
2795 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2797 croak("Bad setcc subscript");
2798 termios_ref->c_cc[ccix] = cc;
2804 MODULE = POSIX PACKAGE = POSIX
2813 unsigned char * charstring
2815 unsigned char *s = charstring;
2816 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2817 for (RETVAL = 1; RETVAL && s < e; s++)
2825 unsigned char * charstring
2827 unsigned char *s = charstring;
2828 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2829 for (RETVAL = 1; RETVAL && s < e; s++)
2837 unsigned char * charstring
2839 unsigned char *s = charstring;
2840 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2841 for (RETVAL = 1; RETVAL && s < e; s++)
2849 unsigned char * charstring
2851 unsigned char *s = charstring;
2852 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2853 for (RETVAL = 1; RETVAL && s < e; s++)
2861 unsigned char * charstring
2863 unsigned char *s = charstring;
2864 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2865 for (RETVAL = 1; RETVAL && s < e; s++)
2873 unsigned char * charstring
2875 unsigned char *s = charstring;
2876 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2877 for (RETVAL = 1; RETVAL && s < e; s++)
2885 unsigned char * charstring
2887 unsigned char *s = charstring;
2888 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2889 for (RETVAL = 1; RETVAL && s < e; s++)
2897 unsigned char * charstring
2899 unsigned char *s = charstring;
2900 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2901 for (RETVAL = 1; RETVAL && s < e; s++)
2909 unsigned char * charstring
2911 unsigned char *s = charstring;
2912 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2913 for (RETVAL = 1; RETVAL && s < e; s++)
2921 unsigned char * charstring
2923 unsigned char *s = charstring;
2924 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2925 for (RETVAL = 1; RETVAL && s < e; s++)
2932 isxdigit(charstring)
2933 unsigned char * charstring
2935 unsigned char *s = charstring;
2936 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2937 for (RETVAL = 1; RETVAL && s < e; s++)
2944 open(filename, flags = O_RDONLY, mode = 0666)
2949 if (flags & (O_APPEND|O_CREAT|O_TRUNC|O_RDWR|O_WRONLY|O_EXCL))
2950 TAINT_PROPER("open");
2951 RETVAL = open(filename, flags, mode);
2959 #ifdef HAS_LOCALECONV
2960 struct lconv *lcbuf;
2962 if ((lcbuf = localeconv())) {
2964 if (lcbuf->decimal_point && *lcbuf->decimal_point)
2965 hv_store(RETVAL, "decimal_point", 13,
2966 newSVpv(lcbuf->decimal_point, 0), 0);
2967 if (lcbuf->thousands_sep && *lcbuf->thousands_sep)
2968 hv_store(RETVAL, "thousands_sep", 13,
2969 newSVpv(lcbuf->thousands_sep, 0), 0);
2970 #ifndef NO_LOCALECONV_GROUPING
2971 if (lcbuf->grouping && *lcbuf->grouping)
2972 hv_store(RETVAL, "grouping", 8,
2973 newSVpv(lcbuf->grouping, 0), 0);
2975 if (lcbuf->int_curr_symbol && *lcbuf->int_curr_symbol)
2976 hv_store(RETVAL, "int_curr_symbol", 15,
2977 newSVpv(lcbuf->int_curr_symbol, 0), 0);
2978 if (lcbuf->currency_symbol && *lcbuf->currency_symbol)
2979 hv_store(RETVAL, "currency_symbol", 15,
2980 newSVpv(lcbuf->currency_symbol, 0), 0);
2981 if (lcbuf->mon_decimal_point && *lcbuf->mon_decimal_point)
2982 hv_store(RETVAL, "mon_decimal_point", 17,
2983 newSVpv(lcbuf->mon_decimal_point, 0), 0);
2984 #ifndef NO_LOCALECONV_MON_THOUSANDS_SEP
2985 if (lcbuf->mon_thousands_sep && *lcbuf->mon_thousands_sep)
2986 hv_store(RETVAL, "mon_thousands_sep", 17,
2987 newSVpv(lcbuf->mon_thousands_sep, 0), 0);
2989 #ifndef NO_LOCALECONV_MON_GROUPING
2990 if (lcbuf->mon_grouping && *lcbuf->mon_grouping)
2991 hv_store(RETVAL, "mon_grouping", 12,
2992 newSVpv(lcbuf->mon_grouping, 0), 0);
2994 if (lcbuf->positive_sign && *lcbuf->positive_sign)
2995 hv_store(RETVAL, "positive_sign", 13,
2996 newSVpv(lcbuf->positive_sign, 0), 0);
2997 if (lcbuf->negative_sign && *lcbuf->negative_sign)
2998 hv_store(RETVAL, "negative_sign", 13,
2999 newSVpv(lcbuf->negative_sign, 0), 0);
3001 if (lcbuf->int_frac_digits != CHAR_MAX)
3002 hv_store(RETVAL, "int_frac_digits", 15,
3003 newSViv(lcbuf->int_frac_digits), 0);
3004 if (lcbuf->frac_digits != CHAR_MAX)
3005 hv_store(RETVAL, "frac_digits", 11,
3006 newSViv(lcbuf->frac_digits), 0);
3007 if (lcbuf->p_cs_precedes != CHAR_MAX)
3008 hv_store(RETVAL, "p_cs_precedes", 13,
3009 newSViv(lcbuf->p_cs_precedes), 0);
3010 if (lcbuf->p_sep_by_space != CHAR_MAX)
3011 hv_store(RETVAL, "p_sep_by_space", 14,
3012 newSViv(lcbuf->p_sep_by_space), 0);
3013 if (lcbuf->n_cs_precedes != CHAR_MAX)
3014 hv_store(RETVAL, "n_cs_precedes", 13,
3015 newSViv(lcbuf->n_cs_precedes), 0);
3016 if (lcbuf->n_sep_by_space != CHAR_MAX)
3017 hv_store(RETVAL, "n_sep_by_space", 14,
3018 newSViv(lcbuf->n_sep_by_space), 0);
3019 if (lcbuf->p_sign_posn != CHAR_MAX)
3020 hv_store(RETVAL, "p_sign_posn", 11,
3021 newSViv(lcbuf->p_sign_posn), 0);
3022 if (lcbuf->n_sign_posn != CHAR_MAX)
3023 hv_store(RETVAL, "n_sign_posn", 11,
3024 newSViv(lcbuf->n_sign_posn), 0);
3027 localeconv(); /* A stub to call not_here(). */
3033 setlocale(category, locale = 0)
3037 RETVAL = setlocale(category, locale);
3039 #ifdef USE_LOCALE_CTYPE
3040 if (category == LC_CTYPE
3042 || category == LC_ALL
3048 if (category == LC_ALL)
3049 newctype = setlocale(LC_CTYPE, NULL);
3053 new_ctype(newctype);
3055 #endif /* USE_LOCALE_CTYPE */
3056 #ifdef USE_LOCALE_COLLATE
3057 if (category == LC_COLLATE
3059 || category == LC_ALL
3065 if (category == LC_ALL)
3066 newcoll = setlocale(LC_COLLATE, NULL);
3070 new_collate(newcoll);
3072 #endif /* USE_LOCALE_COLLATE */
3073 #ifdef USE_LOCALE_NUMERIC
3074 if (category == LC_NUMERIC
3076 || category == LC_ALL
3082 if (category == LC_ALL)
3083 newnum = setlocale(LC_NUMERIC, NULL);
3087 new_numeric(newnum);
3089 #endif /* USE_LOCALE_NUMERIC */
3129 /* (We already know stack is long enough.) */
3130 PUSHs(sv_2mortal(newSVnv(frexp(x,&expvar))));
3131 PUSHs(sv_2mortal(newSViv(expvar)));
3147 /* (We already know stack is long enough.) */
3148 PUSHs(sv_2mortal(newSVnv(Perl_modf(x,&intvar))));
3149 PUSHs(sv_2mortal(newSVnv(intvar)));
3164 sigaction(sig, optaction, oldaction = 0)
3167 POSIX::SigAction oldaction
3170 RETVAL = not_here("sigaction");
3172 # This code is really grody because we're trying to make the signal
3173 # interface look beautiful, which is hard.
3176 POSIX__SigAction action;
3177 GV *siggv = gv_fetchpv("SIG", TRUE, SVt_PVHV);
3178 struct sigaction act;
3179 struct sigaction oact;
3182 POSIX__SigSet sigset;
3184 SV** sigsvp = hv_fetch(GvHVn(siggv),
3186 strlen(PL_sig_name[sig]),
3189 /* Check optaction and set action */
3190 if(SvTRUE(optaction)) {
3191 if(sv_isa(optaction, "POSIX::SigAction"))
3192 action = (HV*)SvRV(optaction);
3194 croak("action is not of type POSIX::SigAction");
3200 /* sigaction() is supposed to look atomic. In particular, any
3201 * signal handler invoked during a sigaction() call should
3202 * see either the old or the new disposition, and not something
3203 * in between. We use sigprocmask() to make it so.
3206 RETVAL=sigprocmask(SIG_BLOCK, &sset, &osset);
3210 /* Restore signal mask no matter how we exit this block. */
3211 SAVEDESTRUCTOR(restore_sigmask, &osset);
3213 RETVAL=-1; /* In case both oldaction and action are 0. */
3215 /* Remember old disposition if desired. */
3217 svp = hv_fetch(oldaction, "HANDLER", 7, TRUE);
3219 croak("Can't supply an oldaction without a HANDLER");
3220 if(SvTRUE(*sigsvp)) { /* TBD: what if "0"? */
3221 sv_setsv(*svp, *sigsvp);
3224 sv_setpv(*svp, "DEFAULT");
3226 RETVAL = sigaction(sig, (struct sigaction *)0, & oact);
3229 /* Get back the mask. */
3230 svp = hv_fetch(oldaction, "MASK", 4, TRUE);
3231 if (sv_isa(*svp, "POSIX::SigSet")) {
3232 IV tmp = SvIV((SV*)SvRV(*svp));
3233 sigset = INT2PTR(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);
3247 /* Vector new handler through %SIG. (We always use sighandler
3248 for the C signal handler, which reads %SIG to dispatch.) */
3249 svp = hv_fetch(action, "HANDLER", 7, FALSE);
3251 croak("Can't supply an action without a HANDLER");
3252 sv_setsv(*sigsvp, *svp);
3253 mg_set(*sigsvp); /* handles DEFAULT and IGNORE */
3255 char *s=SvPVX(*svp);
3256 if(strEQ(s,"IGNORE")) {
3257 act.sa_handler = SIG_IGN;
3259 else if(strEQ(s,"DEFAULT")) {
3260 act.sa_handler = SIG_DFL;
3263 act.sa_handler = PL_sighandlerp;
3267 act.sa_handler = PL_sighandlerp;
3270 /* Set up any desired mask. */
3271 svp = hv_fetch(action, "MASK", 4, FALSE);
3272 if (svp && sv_isa(*svp, "POSIX::SigSet")) {
3273 IV tmp = SvIV((SV*)SvRV(*svp));
3274 sigset = INT2PTR(sigset_t*, tmp);
3275 act.sa_mask = *sigset;
3278 sigemptyset(& act.sa_mask);
3280 /* Set up any desired flags. */
3281 svp = hv_fetch(action, "FLAGS", 5, FALSE);
3282 act.sa_flags = svp ? SvIV(*svp) : 0;
3284 /* Don't worry about cleaning up *sigsvp if this fails,
3285 * because that means we tried to disposition a
3286 * nonblockable signal, in which case *sigsvp is
3287 * essentially meaningless anyway.
3289 RETVAL = sigaction(sig, & act, (struct sigaction *)0);
3300 POSIX::SigSet sigset
3303 sigprocmask(how, sigset, oldsigset = 0)
3305 POSIX::SigSet sigset
3306 POSIX::SigSet oldsigset = NO_INIT
3311 else if (sv_derived_from(ST(2), "POSIX::SigSet")) {
3312 IV tmp = SvIV((SV*)SvRV(ST(2)));
3313 oldsigset = INT2PTR(POSIX__SigSet,tmp);
3316 New(0, oldsigset, 1, sigset_t);
3317 sigemptyset(oldsigset);
3318 sv_setref_pv(ST(2), "POSIX::SigSet", (void*)oldsigset);
3322 sigsuspend(signal_mask)
3323 POSIX::SigSet signal_mask
3343 lseek(fd, offset, whence)
3356 if (pipe(fds) != -1) {
3358 PUSHs(sv_2mortal(newSViv(fds[0])));
3359 PUSHs(sv_2mortal(newSViv(fds[1])));
3363 read(fd, buffer, nbytes)
3365 SV *sv_buffer = SvROK(ST(1)) ? SvRV(ST(1)) : ST(1);
3369 char * buffer = sv_grow( sv_buffer, nbytes+1 );
3372 SvCUR(sv_buffer) = RETVAL;
3373 SvPOK_only(sv_buffer);
3374 *SvEND(sv_buffer) = '\0';
3375 SvTAINTED_on(sv_buffer);
3391 tcsetpgrp(fd, pgrp_id)
3400 if (uname(&buf) >= 0) {
3402 PUSHs(sv_2mortal(newSVpv(buf.sysname, 0)));
3403 PUSHs(sv_2mortal(newSVpv(buf.nodename, 0)));
3404 PUSHs(sv_2mortal(newSVpv(buf.release, 0)));
3405 PUSHs(sv_2mortal(newSVpv(buf.version, 0)));
3406 PUSHs(sv_2mortal(newSVpv(buf.machine, 0)));
3409 uname((char *) 0); /* A stub to call not_here(). */
3413 write(fd, buffer, nbytes)
3424 RETVAL = newSVpvn("", 0);
3425 SvGROW(RETVAL, L_tmpnam);
3426 len = strlen(tmpnam(SvPV(RETVAL, i)));
3427 SvCUR_set(RETVAL, len);
3440 mbstowcs(s, pwcs, n)
3452 wcstombs(s, pwcs, n)
3474 SET_NUMERIC_LOCAL();
3475 num = strtod(str, &unparsed);
3476 PUSHs(sv_2mortal(newSVnv(num)));
3477 if (GIMME == G_ARRAY) {
3480 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3482 PUSHs(&PL_sv_undef);
3486 strtol(str, base = 0)
3493 num = strtol(str, &unparsed, base);
3494 #if IVSIZE <= LONGSIZE
3495 if (num < IV_MIN || num > IV_MAX)
3496 PUSHs(sv_2mortal(newSVnv((double)num)));
3499 PUSHs(sv_2mortal(newSViv((IV)num)));
3500 if (GIMME == G_ARRAY) {
3503 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3505 PUSHs(&PL_sv_undef);
3509 strtoul(str, base = 0)
3516 num = strtoul(str, &unparsed, base);
3518 PUSHs(sv_2mortal(newSViv((IV)num)));
3520 PUSHs(sv_2mortal(newSVnv((double)num)));
3521 if (GIMME == G_ARRAY) {
3524 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3526 PUSHs(&PL_sv_undef);
3536 char *p = SvPV(src,srclen);
3538 ST(0) = sv_2mortal(NEWSV(800,srclen));
3539 dstlen = strxfrm(SvPVX(ST(0)), p, (size_t)srclen);
3540 if (dstlen > srclen) {
3542 SvGROW(ST(0), dstlen);
3543 strxfrm(SvPVX(ST(0)), p, (size_t)dstlen);
3546 SvCUR(ST(0)) = dstlen;
3551 mkfifo(filename, mode)
3555 TAINT_PROPER("mkfifo");
3556 RETVAL = mkfifo(filename, mode);
3572 tcflush(fd, queue_selector)
3577 tcsendbreak(fd, duration)
3582 asctime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3595 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3598 mytm.tm_hour = hour;
3599 mytm.tm_mday = mday;
3601 mytm.tm_year = year;
3602 mytm.tm_wday = wday;
3603 mytm.tm_yday = yday;
3604 mytm.tm_isdst = isdst;
3605 RETVAL = asctime(&mytm);
3622 realtime = times( &tms );
3624 PUSHs( sv_2mortal( newSViv( (IV) realtime ) ) );
3625 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_utime ) ) );
3626 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_stime ) ) );
3627 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cutime ) ) );
3628 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cstime ) ) );
3631 difftime(time1, time2)
3636 mktime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3649 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3652 mytm.tm_hour = hour;
3653 mytm.tm_mday = mday;
3655 mytm.tm_year = year;
3656 mytm.tm_wday = wday;
3657 mytm.tm_yday = yday;
3658 mytm.tm_isdst = isdst;
3659 RETVAL = mktime(&mytm);
3664 #XXX: if $xsubpp::WantOptimize is always the default
3665 # sv_setpv(TARG, ...) could be used rather than
3666 # ST(0) = sv_2mortal(newSVpv(...))
3668 strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1)
3681 char *buf = my_strftime(fmt, sec, min, hour, mday, mon, year, wday, yday, isdst);
3683 ST(0) = sv_2mortal(newSVpv(buf, 0));
3695 PUSHs(sv_2mortal(newSVpvn(tzname[0],strlen(tzname[0]))));
3696 PUSHs(sv_2mortal(newSVpvn(tzname[1],strlen(tzname[1]))));
3699 access(filename, mode)
3717 pathconf(filename, name)
3740 #XXX: use sv_getcwd()
3748 New(0, buf, buflen, char);
3749 /* Many getcwd()s know how to automatically allocate memory
3750 * for the directory if the buffer argument is NULL but...
3751 * (1) we cannot assume all getcwd()s do that
3752 * (2) this may interfere with Perl's malloc
3753 * So let's not. --jhi */
3754 while ((getcwd(buf, buflen) == NULL) && errno == ERANGE) {
3756 if (buflen > MAXPATHLEN) {
3761 Renew(buf, buflen, char);
3764 PUSHs(sv_2mortal(newSVpv(buf, 0)));
3768 PUSHs(&PL_sv_undef);
3770 require_pv("Cwd.pm");
3771 /* Module require may have grown the stack */
3775 XSRETURN(call_pv("Cwd::cwd", GIMME_V));