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
2553 restore_sigmask(sigset_t *ossetp)
2555 /* Fortunately, restoring the signal mask can't fail, because
2556 * there's nothing we can do about it if it does -- we're not
2557 * supposed to return -1 from sigaction unless the disposition
2560 (void)sigprocmask(SIG_SETMASK, ossetp, (sigset_t *)0);
2563 MODULE = SigSet PACKAGE = POSIX::SigSet PREFIX = sig
2566 new(packname = "POSIX::SigSet", ...)
2571 New(0, RETVAL, 1, sigset_t);
2572 sigemptyset(RETVAL);
2573 for (i = 1; i < items; i++)
2574 sigaddset(RETVAL, SvIV(ST(i)));
2581 POSIX::SigSet sigset
2586 sigaddset(sigset, sig)
2587 POSIX::SigSet sigset
2591 sigdelset(sigset, sig)
2592 POSIX::SigSet sigset
2597 POSIX::SigSet sigset
2601 POSIX::SigSet sigset
2604 sigismember(sigset, sig)
2605 POSIX::SigSet sigset
2609 MODULE = Termios PACKAGE = POSIX::Termios PREFIX = cf
2612 new(packname = "POSIX::Termios", ...)
2617 New(0, RETVAL, 1, struct termios);
2619 not_here("termios");
2627 DESTROY(termios_ref)
2628 POSIX::Termios termios_ref
2631 Safefree(termios_ref);
2633 not_here("termios");
2637 getattr(termios_ref, fd = 0)
2638 POSIX::Termios termios_ref
2641 RETVAL = tcgetattr(fd, termios_ref);
2646 setattr(termios_ref, fd = 0, optional_actions = 0)
2647 POSIX::Termios termios_ref
2649 int optional_actions
2651 RETVAL = tcsetattr(fd, optional_actions, termios_ref);
2656 cfgetispeed(termios_ref)
2657 POSIX::Termios termios_ref
2660 cfgetospeed(termios_ref)
2661 POSIX::Termios termios_ref
2664 getiflag(termios_ref)
2665 POSIX::Termios termios_ref
2667 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2668 RETVAL = termios_ref->c_iflag;
2670 not_here("getiflag");
2677 getoflag(termios_ref)
2678 POSIX::Termios termios_ref
2680 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2681 RETVAL = termios_ref->c_oflag;
2683 not_here("getoflag");
2690 getcflag(termios_ref)
2691 POSIX::Termios termios_ref
2693 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2694 RETVAL = termios_ref->c_cflag;
2696 not_here("getcflag");
2703 getlflag(termios_ref)
2704 POSIX::Termios termios_ref
2706 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2707 RETVAL = termios_ref->c_lflag;
2709 not_here("getlflag");
2716 getcc(termios_ref, ccix)
2717 POSIX::Termios termios_ref
2720 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2722 croak("Bad getcc subscript");
2723 RETVAL = termios_ref->c_cc[ccix];
2732 cfsetispeed(termios_ref, speed)
2733 POSIX::Termios termios_ref
2737 cfsetospeed(termios_ref, speed)
2738 POSIX::Termios termios_ref
2742 setiflag(termios_ref, iflag)
2743 POSIX::Termios termios_ref
2746 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2747 termios_ref->c_iflag = iflag;
2749 not_here("setiflag");
2753 setoflag(termios_ref, oflag)
2754 POSIX::Termios termios_ref
2757 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2758 termios_ref->c_oflag = oflag;
2760 not_here("setoflag");
2764 setcflag(termios_ref, cflag)
2765 POSIX::Termios termios_ref
2768 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2769 termios_ref->c_cflag = cflag;
2771 not_here("setcflag");
2775 setlflag(termios_ref, lflag)
2776 POSIX::Termios termios_ref
2779 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2780 termios_ref->c_lflag = lflag;
2782 not_here("setlflag");
2786 setcc(termios_ref, ccix, cc)
2787 POSIX::Termios termios_ref
2791 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2793 croak("Bad setcc subscript");
2794 termios_ref->c_cc[ccix] = cc;
2800 MODULE = POSIX PACKAGE = POSIX
2809 unsigned char * charstring
2811 unsigned char *s = charstring;
2812 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2813 for (RETVAL = 1; RETVAL && s < e; s++)
2821 unsigned char * charstring
2823 unsigned char *s = charstring;
2824 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2825 for (RETVAL = 1; RETVAL && s < e; s++)
2833 unsigned char * charstring
2835 unsigned char *s = charstring;
2836 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2837 for (RETVAL = 1; RETVAL && s < e; s++)
2845 unsigned char * charstring
2847 unsigned char *s = charstring;
2848 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2849 for (RETVAL = 1; RETVAL && s < e; s++)
2857 unsigned char * charstring
2859 unsigned char *s = charstring;
2860 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2861 for (RETVAL = 1; RETVAL && s < e; s++)
2869 unsigned char * charstring
2871 unsigned char *s = charstring;
2872 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2873 for (RETVAL = 1; RETVAL && s < e; s++)
2881 unsigned char * charstring
2883 unsigned char *s = charstring;
2884 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2885 for (RETVAL = 1; RETVAL && s < e; s++)
2893 unsigned char * charstring
2895 unsigned char *s = charstring;
2896 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2897 for (RETVAL = 1; RETVAL && s < e; s++)
2905 unsigned char * charstring
2907 unsigned char *s = charstring;
2908 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2909 for (RETVAL = 1; RETVAL && s < e; s++)
2917 unsigned char * charstring
2919 unsigned char *s = charstring;
2920 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2921 for (RETVAL = 1; RETVAL && s < e; s++)
2928 isxdigit(charstring)
2929 unsigned char * charstring
2931 unsigned char *s = charstring;
2932 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
2933 for (RETVAL = 1; RETVAL && s < e; s++)
2940 open(filename, flags = O_RDONLY, mode = 0666)
2945 if (flags & (O_APPEND|O_CREAT|O_TRUNC|O_RDWR|O_WRONLY|O_EXCL))
2946 TAINT_PROPER("open");
2947 RETVAL = open(filename, flags, mode);
2955 #ifdef HAS_LOCALECONV
2956 struct lconv *lcbuf;
2958 if ((lcbuf = localeconv())) {
2960 if (lcbuf->decimal_point && *lcbuf->decimal_point)
2961 hv_store(RETVAL, "decimal_point", 13,
2962 newSVpv(lcbuf->decimal_point, 0), 0);
2963 if (lcbuf->thousands_sep && *lcbuf->thousands_sep)
2964 hv_store(RETVAL, "thousands_sep", 13,
2965 newSVpv(lcbuf->thousands_sep, 0), 0);
2966 #ifndef NO_LOCALECONV_GROUPING
2967 if (lcbuf->grouping && *lcbuf->grouping)
2968 hv_store(RETVAL, "grouping", 8,
2969 newSVpv(lcbuf->grouping, 0), 0);
2971 if (lcbuf->int_curr_symbol && *lcbuf->int_curr_symbol)
2972 hv_store(RETVAL, "int_curr_symbol", 15,
2973 newSVpv(lcbuf->int_curr_symbol, 0), 0);
2974 if (lcbuf->currency_symbol && *lcbuf->currency_symbol)
2975 hv_store(RETVAL, "currency_symbol", 15,
2976 newSVpv(lcbuf->currency_symbol, 0), 0);
2977 if (lcbuf->mon_decimal_point && *lcbuf->mon_decimal_point)
2978 hv_store(RETVAL, "mon_decimal_point", 17,
2979 newSVpv(lcbuf->mon_decimal_point, 0), 0);
2980 #ifndef NO_LOCALECONV_MON_THOUSANDS_SEP
2981 if (lcbuf->mon_thousands_sep && *lcbuf->mon_thousands_sep)
2982 hv_store(RETVAL, "mon_thousands_sep", 17,
2983 newSVpv(lcbuf->mon_thousands_sep, 0), 0);
2985 #ifndef NO_LOCALECONV_MON_GROUPING
2986 if (lcbuf->mon_grouping && *lcbuf->mon_grouping)
2987 hv_store(RETVAL, "mon_grouping", 12,
2988 newSVpv(lcbuf->mon_grouping, 0), 0);
2990 if (lcbuf->positive_sign && *lcbuf->positive_sign)
2991 hv_store(RETVAL, "positive_sign", 13,
2992 newSVpv(lcbuf->positive_sign, 0), 0);
2993 if (lcbuf->negative_sign && *lcbuf->negative_sign)
2994 hv_store(RETVAL, "negative_sign", 13,
2995 newSVpv(lcbuf->negative_sign, 0), 0);
2997 if (lcbuf->int_frac_digits != CHAR_MAX)
2998 hv_store(RETVAL, "int_frac_digits", 15,
2999 newSViv(lcbuf->int_frac_digits), 0);
3000 if (lcbuf->frac_digits != CHAR_MAX)
3001 hv_store(RETVAL, "frac_digits", 11,
3002 newSViv(lcbuf->frac_digits), 0);
3003 if (lcbuf->p_cs_precedes != CHAR_MAX)
3004 hv_store(RETVAL, "p_cs_precedes", 13,
3005 newSViv(lcbuf->p_cs_precedes), 0);
3006 if (lcbuf->p_sep_by_space != CHAR_MAX)
3007 hv_store(RETVAL, "p_sep_by_space", 14,
3008 newSViv(lcbuf->p_sep_by_space), 0);
3009 if (lcbuf->n_cs_precedes != CHAR_MAX)
3010 hv_store(RETVAL, "n_cs_precedes", 13,
3011 newSViv(lcbuf->n_cs_precedes), 0);
3012 if (lcbuf->n_sep_by_space != CHAR_MAX)
3013 hv_store(RETVAL, "n_sep_by_space", 14,
3014 newSViv(lcbuf->n_sep_by_space), 0);
3015 if (lcbuf->p_sign_posn != CHAR_MAX)
3016 hv_store(RETVAL, "p_sign_posn", 11,
3017 newSViv(lcbuf->p_sign_posn), 0);
3018 if (lcbuf->n_sign_posn != CHAR_MAX)
3019 hv_store(RETVAL, "n_sign_posn", 11,
3020 newSViv(lcbuf->n_sign_posn), 0);
3023 localeconv(); /* A stub to call not_here(). */
3029 setlocale(category, locale = 0)
3033 RETVAL = setlocale(category, locale);
3035 #ifdef USE_LOCALE_CTYPE
3036 if (category == LC_CTYPE
3038 || category == LC_ALL
3044 if (category == LC_ALL)
3045 newctype = setlocale(LC_CTYPE, NULL);
3049 new_ctype(newctype);
3051 #endif /* USE_LOCALE_CTYPE */
3052 #ifdef USE_LOCALE_COLLATE
3053 if (category == LC_COLLATE
3055 || category == LC_ALL
3061 if (category == LC_ALL)
3062 newcoll = setlocale(LC_COLLATE, NULL);
3066 new_collate(newcoll);
3068 #endif /* USE_LOCALE_COLLATE */
3069 #ifdef USE_LOCALE_NUMERIC
3070 if (category == LC_NUMERIC
3072 || category == LC_ALL
3078 if (category == LC_ALL)
3079 newnum = setlocale(LC_NUMERIC, NULL);
3083 new_numeric(newnum);
3085 #endif /* USE_LOCALE_NUMERIC */
3125 /* (We already know stack is long enough.) */
3126 PUSHs(sv_2mortal(newSVnv(frexp(x,&expvar))));
3127 PUSHs(sv_2mortal(newSViv(expvar)));
3143 /* (We already know stack is long enough.) */
3144 PUSHs(sv_2mortal(newSVnv(Perl_modf(x,&intvar))));
3145 PUSHs(sv_2mortal(newSVnv(intvar)));
3160 sigaction(sig, optaction, oldaction = 0)
3163 POSIX::SigAction oldaction
3166 RETVAL = not_here("sigaction");
3168 # This code is really grody because we're trying to make the signal
3169 # interface look beautiful, which is hard.
3172 POSIX__SigAction action;
3173 GV *siggv = gv_fetchpv("SIG", TRUE, SVt_PVHV);
3174 struct sigaction act;
3175 struct sigaction oact;
3178 POSIX__SigSet sigset;
3180 SV** sigsvp = hv_fetch(GvHVn(siggv),
3182 strlen(PL_sig_name[sig]),
3186 /* Check optaction and set action */
3187 if(SvTRUE(optaction)) {
3188 if(sv_isa(optaction, "POSIX::SigAction"))
3189 action = (HV*)SvRV(optaction);
3191 croak("action is not of type POSIX::SigAction");
3197 /* sigaction() is supposed to look atomic. In particular, any
3198 * signal handler invoked during a sigaction() call should
3199 * see either the old or the new disposition, and not something
3200 * in between. We use sigprocmask() to make it so.
3203 RETVAL=sigprocmask(SIG_BLOCK, &sset, &osset);
3207 /* Restore signal mask no matter how we exit this block. */
3208 SAVEDESTRUCTOR(restore_sigmask, &osset);
3210 RETVAL=-1; /* In case both oldaction and action are 0. */
3212 /* Remember old disposition if desired. */
3214 svp = hv_fetch(oldaction, "HANDLER", 7, TRUE);
3216 croak("Can't supply an oldaction without a HANDLER");
3217 if(SvTRUE(*sigsvp)) { /* TBD: what if "0"? */
3218 sv_setsv(*svp, *sigsvp);
3221 sv_setpv(*svp, "DEFAULT");
3223 RETVAL = sigaction(sig, (struct sigaction *)0, & oact);
3226 /* Get back the mask. */
3227 svp = hv_fetch(oldaction, "MASK", 4, TRUE);
3228 if (sv_isa(*svp, "POSIX::SigSet")) {
3229 IV tmp = SvIV((SV*)SvRV(*svp));
3230 sigset = INT2PTR(sigset_t*, tmp);
3233 New(0, sigset, 1, sigset_t);
3234 sv_setptrobj(*svp, sigset, "POSIX::SigSet");
3236 *sigset = oact.sa_mask;
3238 /* Get back the flags. */
3239 svp = hv_fetch(oldaction, "FLAGS", 5, TRUE);
3240 sv_setiv(*svp, oact.sa_flags);
3244 /* Vector new handler through %SIG. (We always use sighandler
3245 for the C signal handler, which reads %SIG to dispatch.) */
3246 svp = hv_fetch(action, "HANDLER", 7, FALSE);
3248 croak("Can't supply an action without a HANDLER");
3249 sv_setsv(*sigsvp, *svp);
3250 mg_set(*sigsvp); /* handles DEFAULT and IGNORE */
3252 char *s=SvPVX(*svp);
3253 if(strEQ(s,"IGNORE")) {
3254 act.sa_handler = SIG_IGN;
3256 else if(strEQ(s,"DEFAULT")) {
3257 act.sa_handler = SIG_DFL;
3260 act.sa_handler = PL_sighandlerp;
3264 act.sa_handler = PL_sighandlerp;
3267 /* Set up any desired mask. */
3268 svp = hv_fetch(action, "MASK", 4, FALSE);
3269 if (svp && sv_isa(*svp, "POSIX::SigSet")) {
3270 IV tmp = SvIV((SV*)SvRV(*svp));
3271 sigset = INT2PTR(sigset_t*, tmp);
3272 act.sa_mask = *sigset;
3275 sigemptyset(& act.sa_mask);
3277 /* Set up any desired flags. */
3278 svp = hv_fetch(action, "FLAGS", 5, FALSE);
3279 act.sa_flags = svp ? SvIV(*svp) : 0;
3281 /* Don't worry about cleaning up *sigsvp if this fails,
3282 * because that means we tried to disposition a
3283 * nonblockable signal, in which case *sigsvp is
3284 * essentially meaningless anyway.
3286 RETVAL = sigaction(sig, & act, (struct sigaction *)0);
3297 POSIX::SigSet sigset
3300 sigprocmask(how, sigset, oldsigset = 0)
3302 POSIX::SigSet sigset
3303 POSIX::SigSet oldsigset = NO_INIT
3308 else if (sv_derived_from(ST(2), "POSIX::SigSet")) {
3309 IV tmp = SvIV((SV*)SvRV(ST(2)));
3310 oldsigset = INT2PTR(POSIX__SigSet,tmp);
3313 New(0, oldsigset, 1, sigset_t);
3314 sigemptyset(oldsigset);
3315 sv_setref_pv(ST(2), "POSIX::SigSet", (void*)oldsigset);
3319 sigsuspend(signal_mask)
3320 POSIX::SigSet signal_mask
3340 lseek(fd, offset, whence)
3353 if (pipe(fds) != -1) {
3355 PUSHs(sv_2mortal(newSViv(fds[0])));
3356 PUSHs(sv_2mortal(newSViv(fds[1])));
3360 read(fd, buffer, nbytes)
3362 SV *sv_buffer = SvROK(ST(1)) ? SvRV(ST(1)) : ST(1);
3366 char * buffer = sv_grow( sv_buffer, nbytes+1 );
3369 SvCUR(sv_buffer) = RETVAL;
3370 SvPOK_only(sv_buffer);
3371 *SvEND(sv_buffer) = '\0';
3372 SvTAINTED_on(sv_buffer);
3388 tcsetpgrp(fd, pgrp_id)
3397 if (uname(&buf) >= 0) {
3399 PUSHs(sv_2mortal(newSVpv(buf.sysname, 0)));
3400 PUSHs(sv_2mortal(newSVpv(buf.nodename, 0)));
3401 PUSHs(sv_2mortal(newSVpv(buf.release, 0)));
3402 PUSHs(sv_2mortal(newSVpv(buf.version, 0)));
3403 PUSHs(sv_2mortal(newSVpv(buf.machine, 0)));
3406 uname((char *) 0); /* A stub to call not_here(). */
3410 write(fd, buffer, nbytes)
3421 RETVAL = newSVpvn("", 0);
3422 SvGROW(RETVAL, L_tmpnam);
3423 len = strlen(tmpnam(SvPV(RETVAL, i)));
3424 SvCUR_set(RETVAL, len);
3437 mbstowcs(s, pwcs, n)
3449 wcstombs(s, pwcs, n)
3471 SET_NUMERIC_LOCAL();
3472 num = strtod(str, &unparsed);
3473 PUSHs(sv_2mortal(newSVnv(num)));
3474 if (GIMME == G_ARRAY) {
3477 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3479 PUSHs(&PL_sv_undef);
3483 strtol(str, base = 0)
3490 num = strtol(str, &unparsed, base);
3491 #if IVSIZE <= LONGSIZE
3492 if (num < IV_MIN || num > IV_MAX)
3493 PUSHs(sv_2mortal(newSVnv((double)num)));
3496 PUSHs(sv_2mortal(newSViv((IV)num)));
3497 if (GIMME == G_ARRAY) {
3500 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3502 PUSHs(&PL_sv_undef);
3506 strtoul(str, base = 0)
3513 num = strtoul(str, &unparsed, base);
3515 PUSHs(sv_2mortal(newSViv((IV)num)));
3517 PUSHs(sv_2mortal(newSVnv((double)num)));
3518 if (GIMME == G_ARRAY) {
3521 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3523 PUSHs(&PL_sv_undef);
3533 char *p = SvPV(src,srclen);
3535 ST(0) = sv_2mortal(NEWSV(800,srclen));
3536 dstlen = strxfrm(SvPVX(ST(0)), p, (size_t)srclen);
3537 if (dstlen > srclen) {
3539 SvGROW(ST(0), dstlen);
3540 strxfrm(SvPVX(ST(0)), p, (size_t)dstlen);
3543 SvCUR(ST(0)) = dstlen;
3548 mkfifo(filename, mode)
3552 TAINT_PROPER("mkfifo");
3553 RETVAL = mkfifo(filename, mode);
3569 tcflush(fd, queue_selector)
3574 tcsendbreak(fd, duration)
3579 asctime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3592 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3595 mytm.tm_hour = hour;
3596 mytm.tm_mday = mday;
3598 mytm.tm_year = year;
3599 mytm.tm_wday = wday;
3600 mytm.tm_yday = yday;
3601 mytm.tm_isdst = isdst;
3602 RETVAL = asctime(&mytm);
3619 realtime = times( &tms );
3621 PUSHs( sv_2mortal( newSViv( (IV) realtime ) ) );
3622 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_utime ) ) );
3623 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_stime ) ) );
3624 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cutime ) ) );
3625 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cstime ) ) );
3628 difftime(time1, time2)
3633 mktime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3646 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3649 mytm.tm_hour = hour;
3650 mytm.tm_mday = mday;
3652 mytm.tm_year = year;
3653 mytm.tm_wday = wday;
3654 mytm.tm_yday = yday;
3655 mytm.tm_isdst = isdst;
3656 RETVAL = mktime(&mytm);
3661 #XXX: if $xsubpp::WantOptimize is always the default
3662 # sv_setpv(TARG, ...) could be used rather than
3663 # ST(0) = sv_2mortal(newSVpv(...))
3665 strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1)
3678 char *buf = my_strftime(fmt, sec, min, hour, mday, mon, year, wday, yday, isdst);
3680 ST(0) = sv_2mortal(newSVpv(buf, 0));
3692 PUSHs(sv_2mortal(newSVpvn(tzname[0],strlen(tzname[0]))));
3693 PUSHs(sv_2mortal(newSVpvn(tzname[1],strlen(tzname[1]))));
3696 access(filename, mode)
3714 pathconf(filename, name)
3745 New(0, buf, buflen, char);
3746 /* Many getcwd()s know how to automatically allocate memory
3747 * for the directory if the buffer argument is NULL but...
3748 * (1) we cannot assume all getcwd()s do that
3749 * (2) this may interfere with Perl's malloc
3750 * So let's not. --jhi */
3751 while ((getcwd(buf, buflen) == NULL) && errno == ERANGE) {
3753 if (buflen > MAXPATHLEN) {
3758 Renew(buf, buflen, char);
3761 PUSHs(sv_2mortal(newSVpv(buf, 0)));
3765 PUSHs(&PL_sv_undef);
3767 require_pv("Cwd.pm");
3768 /* Module require may have grown the stack */
3772 XSRETURN(call_pv("Cwd::cwd", GIMME_V));