6 #define PERLIO_NOT_STDIO 1
9 #ifdef PERL_OBJECT /* XXX _very_ temporary hacks */
13 # define open PerlLIO_open3
16 #ifdef I_DIRENT /* XXX maybe better to just rely on perl.h? */
39 /* XXX This comment is just to make I_TERMIO and I_SGTTY visible to
40 metaconfig for future extension writers. We don't use them in POSIX.
41 (This is really sneaky :-) --AD
43 #if defined(I_TERMIOS)
51 #include <sys/types.h>
58 #if defined(__VMS) && !defined(__POSIX_SOURCE)
59 # include <libdef.h> /* LIB$_INVARG constant */
60 # include <lib$routines.h> /* prototype for lib$ediv() */
61 # include <starlet.h> /* prototype for sys$gettim() */
62 # if DECC_VERSION < 50000000
63 # define pid_t int /* old versions of DECC miss this in types.h */
67 # define mkfifo(a,b) (not_here("mkfifo"),-1)
68 # define tzset() not_here("tzset")
70 #if ((__VMS_VER >= 70000000) && (__DECC_VER >= 50200000)) || (__CRTL_VER >= 70000000)
71 # define HAS_TZNAME /* shows up in VMS 7.0 or Dec C 5.6 */
73 # endif /* __VMS_VER >= 70000000 or Dec C 5.6 */
75 /* The POSIX notion of ttyname() is better served by getname() under VMS */
76 static char ttnambuf[64];
77 # define ttyname(fd) (isatty(fd) > 0 ? getname(fd,ttnambuf,0) : NULL)
79 /* The non-POSIX CRTL times() has void return type, so we just get the
80 current time directly */
81 clock_t vms_times(struct tms *PL_bufptr) {
83 /* Get wall time and convert to 10 ms intervals to
84 * produce the return value that the POSIX standard expects */
85 # if defined(__DECC) && defined (__ALPHA)
88 _ckvmssts(sys$gettim(&vmstime));
90 retval = vmstime & 0x7fffffff;
92 /* (Older hw or ccs don't have an atomic 64-bit type, so we
93 * juggle 32-bit ints (and a float) to produce a time_t result
94 * with minimal loss of information.) */
95 long int vmstime[2],remainder,divisor = 100000;
96 _ckvmssts(sys$gettim((unsigned long int *)vmstime));
97 vmstime[1] &= 0x7fff; /* prevent overflow in EDIV */
98 _ckvmssts(lib$ediv(&divisor,vmstime,(long int *)&retval,&remainder));
100 /* Fill in the struct tms using the CRTL routine . . .*/
101 times((tbuffer_t *)PL_bufptr);
102 return (clock_t) retval;
104 # define times(t) vms_times(t)
108 # define mkfifo(a,b) not_here("mkfifo")
109 # define ttyname(a) (char*)not_here("ttyname")
110 # define sigset_t long
113 # define tzname _tzname
116 # define mode_t short
119 # define mode_t short
121 # define tzset() not_here("tzset")
123 # ifndef _POSIX_OPEN_MAX
124 # define _POSIX_OPEN_MAX FOPEN_MAX /* XXX bogus ? */
127 # define sigaction(a,b,c) not_here("sigaction")
128 # define sigpending(a) not_here("sigpending")
129 # define sigprocmask(a,b,c) not_here("sigprocmask")
130 # define sigsuspend(a) not_here("sigsuspend")
131 # define sigemptyset(a) not_here("sigemptyset")
132 # define sigaddset(a,b) not_here("sigaddset")
133 # define sigdelset(a,b) not_here("sigdelset")
134 # define sigfillset(a) not_here("sigfillset")
135 # define sigismember(a,b) not_here("sigismember")
140 # define mkfifo(path, mode) (mknod((path), (mode) | S_IFIFO, 0))
142 # endif /* !HAS_MKFIFO */
145 # include <sys/times.h>
147 # include <sys/utsname.h>
149 # include <sys/wait.h>
157 typedef long SysRetLong;
158 typedef sigset_t* POSIX__SigSet;
159 typedef HV* POSIX__SigAction;
161 typedef struct termios* POSIX__Termios;
162 #else /* Define termios types to int, and call not_here for the functions.*/
163 #define POSIX__Termios int
167 #define cfgetispeed(x) not_here("cfgetispeed")
168 #define cfgetospeed(x) not_here("cfgetospeed")
169 #define tcdrain(x) not_here("tcdrain")
170 #define tcflush(x,y) not_here("tcflush")
171 #define tcsendbreak(x,y) not_here("tcsendbreak")
172 #define cfsetispeed(x,y) not_here("cfsetispeed")
173 #define cfsetospeed(x,y) not_here("cfsetospeed")
174 #define ctermid(x) (char *) not_here("ctermid")
175 #define tcflow(x,y) not_here("tcflow")
176 #define tcgetattr(x,y) not_here("tcgetattr")
177 #define tcsetattr(x,y,z) not_here("tcsetattr")
180 /* Possibly needed prototypes */
181 char *cuserid _((char *));
182 double strtod _((const char *, char **));
183 long strtol _((const char *, char **, int));
184 unsigned long strtoul _((const char *, char **, int));
187 #define cuserid(a) (char *) not_here("cuserid")
191 #define difftime(a,b) not_here("difftime")
194 #ifndef HAS_FPATHCONF
195 #define fpathconf(f,n) (SysRetLong) not_here("fpathconf")
198 #define mktime(a) not_here("mktime")
201 #define nice(a) not_here("nice")
204 #define pathconf(f,n) (SysRetLong) not_here("pathconf")
207 #define sysconf(n) (SysRetLong) not_here("sysconf")
210 #define readlink(a,b,c) not_here("readlink")
213 #define setpgid(a,b) not_here("setpgid")
216 #define setsid() not_here("setsid")
219 #define strcoll(s1,s2) not_here("strcoll")
222 #define strtod(s1,s2) not_here("strtod")
225 #define strtol(s1,s2,b) not_here("strtol")
228 #define strtoul(s1,s2,b) not_here("strtoul")
231 #define strxfrm(s1,s2,n) not_here("strxfrm")
233 #ifndef HAS_TCGETPGRP
234 #define tcgetpgrp(a) not_here("tcgetpgrp")
236 #ifndef HAS_TCSETPGRP
237 #define tcsetpgrp(a,b) not_here("tcsetpgrp")
240 #define times(a) not_here("times")
243 #define uname(a) not_here("uname")
246 #define waitpid(a,b,c) not_here("waitpid")
251 #define mblen(a,b) not_here("mblen")
255 #define mbstowcs(s, pwcs, n) not_here("mbstowcs")
258 #define mbtowc(pwc, s, n) not_here("mbtowc")
261 #define wcstombs(s, pwcs, n) not_here("wcstombs")
264 #define wctomb(s, wchar) not_here("wcstombs")
266 #if !defined(HAS_MBLEN) && !defined(HAS_MBSTOWCS) && !defined(HAS_MBTOWC) && !defined(HAS_WCSTOMBS) && !defined(HAS_WCTOMB)
267 /* If we don't have these functions, then we wouldn't have gotten a typedef
268 for wchar_t, the wide character type. Defining wchar_t allows the
269 functions referencing it to compile. Its actual type is then meaningless,
270 since without the above functions, all sections using it end up calling
271 not_here() and croak. --Kaveh Ghazi (ghazi@noc.rutgers.edu) 9/18/94. */
277 #ifndef HAS_LOCALECONV
278 #define localeconv() not_here("localeconv")
283 extern char *tzname[];
286 #if !defined(WIN32) || (defined(__MINGW32__) && !defined(tzname))
287 char *tzname[] = { "" , "" };
291 /* XXX struct tm on some systems (SunOS4/BSD) contains extra (non POSIX)
292 * fields for which we don't have Configure support yet:
293 * char *tm_zone; -- abbreviation of timezone name
294 * long tm_gmtoff; -- offset from GMT in seconds
295 * To workaround core dumps from the uninitialised tm_zone we get the
296 * system to give us a reasonable struct to copy. This fix means that
297 * strftime uses the tm_zone and tm_gmtoff values returned by
298 * localtime(time()). That should give the desired result most of the
299 * time. But probably not always!
301 * This is a temporary workaround to be removed once Configure
302 * support is added and NETaa14816 is considered in full.
303 * It does not address tzname aspects of NETaa14816.
306 # ifndef STRUCT_TM_HASZONE
307 # define STRUCT_TM_HAS_ZONE
311 #ifdef STRUCT_TM_HASZONE
313 init_tm(ptm) /* see mktime, strftime and asctime */
318 Copy(localtime(&now), ptm, 1, struct tm);
322 # define init_tm(ptm)
326 #ifdef HAS_LONG_DOUBLE
327 # if LONG_DOUBLESIZE > DOUBLESIZE
328 # undef HAS_LONG_DOUBLE /* XXX until we figure out how to use them */
332 #ifndef HAS_LONG_DOUBLE
347 croak("POSIX::%s not implemented on this architecture", s);
352 #ifdef HAS_LONG_DOUBLE
357 constant(char *name, int arg)
362 if (strEQ(name, "ARG_MAX"))
370 if (strEQ(name, "BUFSIZ"))
376 if (strEQ(name, "BRKINT"))
382 if (strEQ(name, "B9600"))
388 if (strEQ(name, "B19200"))
394 if (strEQ(name, "B38400"))
400 if (strEQ(name, "B0"))
406 if (strEQ(name, "B110"))
412 if (strEQ(name, "B1200"))
418 if (strEQ(name, "B134"))
424 if (strEQ(name, "B150"))
430 if (strEQ(name, "B1800"))
436 if (strEQ(name, "B200"))
442 if (strEQ(name, "B2400"))
448 if (strEQ(name, "B300"))
454 if (strEQ(name, "B4800"))
460 if (strEQ(name, "B50"))
466 if (strEQ(name, "B600"))
472 if (strEQ(name, "B75"))
480 if (strEQ(name, "CHAR_BIT"))
486 if (strEQ(name, "CHAR_MAX"))
492 if (strEQ(name, "CHAR_MIN"))
498 if (strEQ(name, "CHILD_MAX"))
504 if (strEQ(name, "CLK_TCK"))
510 if (strEQ(name, "CLOCAL"))
516 if (strEQ(name, "CLOCKS_PER_SEC"))
517 #ifdef CLOCKS_PER_SEC
518 return CLOCKS_PER_SEC;
522 if (strEQ(name, "CREAD"))
528 if (strEQ(name, "CS5"))
534 if (strEQ(name, "CS6"))
540 if (strEQ(name, "CS7"))
546 if (strEQ(name, "CS8"))
552 if (strEQ(name, "CSIZE"))
558 if (strEQ(name, "CSTOPB"))
566 if (strEQ(name, "DBL_MAX"))
572 if (strEQ(name, "DBL_MIN"))
578 if (strEQ(name, "DBL_DIG"))
584 if (strEQ(name, "DBL_EPSILON"))
590 if (strEQ(name, "DBL_MANT_DIG"))
596 if (strEQ(name, "DBL_MAX_10_EXP"))
597 #ifdef DBL_MAX_10_EXP
598 return DBL_MAX_10_EXP;
602 if (strEQ(name, "DBL_MAX_EXP"))
608 if (strEQ(name, "DBL_MIN_10_EXP"))
609 #ifdef DBL_MIN_10_EXP
610 return DBL_MIN_10_EXP;
614 if (strEQ(name, "DBL_MIN_EXP"))
624 if (strEQ(name, "EACCES"))
630 if (strEQ(name, "EADDRINUSE"))
636 if (strEQ(name, "EADDRNOTAVAIL"))
638 return EADDRNOTAVAIL;
642 if (strEQ(name, "EAFNOSUPPORT"))
648 if (strEQ(name, "EAGAIN"))
654 if (strEQ(name, "EALREADY"))
662 if (strEQ(name, "EBADF"))
668 if (strEQ(name, "EBUSY"))
676 if (strEQ(name, "ECHILD"))
682 if (strEQ(name, "ECHO"))
688 if (strEQ(name, "ECHOE"))
694 if (strEQ(name, "ECHOK"))
700 if (strEQ(name, "ECHONL"))
706 if (strEQ(name, "ECONNABORTED"))
712 if (strEQ(name, "ECONNREFUSED"))
718 if (strEQ(name, "ECONNRESET"))
726 if (strEQ(name, "EDEADLK"))
732 if (strEQ(name, "EDESTADDRREQ"))
738 if (strEQ(name, "EDOM"))
744 if (strEQ(name, "EDQUOT"))
752 if (strEQ(name, "EEXIST"))
760 if (strEQ(name, "EFAULT"))
766 if (strEQ(name, "EFBIG"))
774 if (strEQ(name, "EHOSTDOWN"))
780 if (strEQ(name, "EHOSTUNREACH"))
788 if (strEQ(name, "EINPROGRESS"))
794 if (strEQ(name, "EINTR"))
800 if (strEQ(name, "EINVAL"))
806 if (strEQ(name, "EIO"))
812 if (strEQ(name, "EISCONN"))
818 if (strEQ(name, "EISDIR"))
826 if (strEQ(name, "ELOOP"))
834 if (strEQ(name, "EMFILE"))
840 if (strEQ(name, "EMLINK"))
846 if (strEQ(name, "EMSGSIZE"))
854 if (strEQ(name, "ENETDOWN"))
860 if (strEQ(name, "ENETRESET"))
866 if (strEQ(name, "ENETUNREACH"))
872 if (strEQ(name, "ENOBUFS"))
878 if (strEQ(name, "ENOEXEC"))
884 if (strEQ(name, "ENOMEM"))
890 if (strEQ(name, "ENOPROTOOPT"))
896 if (strEQ(name, "ENOSPC"))
902 if (strEQ(name, "ENOTBLK"))
908 if (strEQ(name, "ENOTCONN"))
914 if (strEQ(name, "ENOTDIR"))
920 if (strEQ(name, "ENOTEMPTY"))
926 if (strEQ(name, "ENOTSOCK"))
932 if (strEQ(name, "ENOTTY"))
938 if (strEQ(name, "ENFILE"))
944 if (strEQ(name, "ENODEV"))
950 if (strEQ(name, "ENOENT"))
956 if (strEQ(name, "ENOLCK"))
962 if (strEQ(name, "ENOSYS"))
968 if (strEQ(name, "ENXIO"))
974 if (strEQ(name, "ENAMETOOLONG"))
982 if (strEQ(name, "EOF"))
988 if (strEQ(name, "EOPNOTSUPP"))
996 if (strEQ(name, "EPERM"))
1002 if (strEQ(name, "EPFNOSUPPORT"))
1004 return EPFNOSUPPORT;
1008 if (strEQ(name, "EPIPE"))
1014 if (strEQ(name, "EPROCLIM"))
1020 if (strEQ(name, "EPROTONOSUPPORT"))
1021 #ifdef EPROTONOSUPPORT
1022 return EPROTONOSUPPORT;
1026 if (strEQ(name, "EPROTOTYPE"))
1034 if (strEQ(name, "ERANGE"))
1040 if (strEQ(name, "EREMOTE"))
1046 if (strEQ(name, "ERESTART"))
1052 if (strEQ(name, "EROFS"))
1060 if (strEQ(name, "ESHUTDOWN"))
1066 if (strEQ(name, "ESOCKTNOSUPPORT"))
1067 #ifdef ESOCKTNOSUPPORT
1068 return ESOCKTNOSUPPORT;
1072 if (strEQ(name, "ESPIPE"))
1078 if (strEQ(name, "ESRCH"))
1084 if (strEQ(name, "ESTALE"))
1092 if (strEQ(name, "ETIMEDOUT"))
1098 if (strEQ(name, "ETOOMANYREFS"))
1100 return ETOOMANYREFS;
1104 if (strEQ(name, "ETXTBSY"))
1112 if (strEQ(name, "EUSERS"))
1120 if (strEQ(name, "EWOULDBLOCK"))
1128 if (strEQ(name, "EXIT_FAILURE"))
1130 return EXIT_FAILURE;
1134 if (strEQ(name, "EXIT_SUCCESS"))
1136 return EXIT_SUCCESS;
1140 if (strEQ(name, "EXDEV"))
1148 if (strEQ(name, "E2BIG"))
1156 if (strnEQ(name, "FLT_", 4)) {
1157 if (strEQ(name, "FLT_MAX"))
1163 if (strEQ(name, "FLT_MIN"))
1169 if (strEQ(name, "FLT_ROUNDS"))
1175 if (strEQ(name, "FLT_DIG"))
1181 if (strEQ(name, "FLT_EPSILON"))
1187 if (strEQ(name, "FLT_MANT_DIG"))
1189 return FLT_MANT_DIG;
1193 if (strEQ(name, "FLT_MAX_10_EXP"))
1194 #ifdef FLT_MAX_10_EXP
1195 return FLT_MAX_10_EXP;
1199 if (strEQ(name, "FLT_MAX_EXP"))
1205 if (strEQ(name, "FLT_MIN_10_EXP"))
1206 #ifdef FLT_MIN_10_EXP
1207 return FLT_MIN_10_EXP;
1211 if (strEQ(name, "FLT_MIN_EXP"))
1217 if (strEQ(name, "FLT_RADIX"))
1225 if (strnEQ(name, "F_", 2)) {
1226 if (strEQ(name, "F_DUPFD"))
1232 if (strEQ(name, "F_GETFD"))
1238 if (strEQ(name, "F_GETFL"))
1244 if (strEQ(name, "F_GETLK"))
1250 if (strEQ(name, "F_OK"))
1256 if (strEQ(name, "F_RDLCK"))
1262 if (strEQ(name, "F_SETFD"))
1268 if (strEQ(name, "F_SETFL"))
1274 if (strEQ(name, "F_SETLK"))
1280 if (strEQ(name, "F_SETLKW"))
1286 if (strEQ(name, "F_UNLCK"))
1292 if (strEQ(name, "F_WRLCK"))
1300 if (strEQ(name, "FD_CLOEXEC"))
1306 if (strEQ(name, "FILENAME_MAX"))
1308 return FILENAME_MAX;
1314 if (strEQ(name, "HUGE_VAL"))
1320 if (strEQ(name, "HUPCL"))
1328 if (strEQ(name, "INT_MAX"))
1334 if (strEQ(name, "INT_MIN"))
1340 if (strEQ(name, "ICANON"))
1346 if (strEQ(name, "ICRNL"))
1352 if (strEQ(name, "IEXTEN"))
1358 if (strEQ(name, "IGNBRK"))
1364 if (strEQ(name, "IGNCR"))
1370 if (strEQ(name, "IGNPAR"))
1376 if (strEQ(name, "INLCR"))
1382 if (strEQ(name, "INPCK"))
1388 if (strEQ(name, "ISIG"))
1394 if (strEQ(name, "ISTRIP"))
1400 if (strEQ(name, "IXOFF"))
1406 if (strEQ(name, "IXON"))
1414 if (strnEQ(name, "LC_", 3)) {
1415 if (strEQ(name, "LC_ALL"))
1421 if (strEQ(name, "LC_COLLATE"))
1427 if (strEQ(name, "LC_CTYPE"))
1433 if (strEQ(name, "LC_MONETARY"))
1439 if (strEQ(name, "LC_NUMERIC"))
1445 if (strEQ(name, "LC_TIME"))
1453 if (strnEQ(name, "LDBL_", 5)) {
1454 if (strEQ(name, "LDBL_MAX"))
1460 if (strEQ(name, "LDBL_MIN"))
1466 if (strEQ(name, "LDBL_DIG"))
1472 if (strEQ(name, "LDBL_EPSILON"))
1474 return LDBL_EPSILON;
1478 if (strEQ(name, "LDBL_MANT_DIG"))
1479 #ifdef LDBL_MANT_DIG
1480 return LDBL_MANT_DIG;
1484 if (strEQ(name, "LDBL_MAX_10_EXP"))
1485 #ifdef LDBL_MAX_10_EXP
1486 return LDBL_MAX_10_EXP;
1490 if (strEQ(name, "LDBL_MAX_EXP"))
1492 return LDBL_MAX_EXP;
1496 if (strEQ(name, "LDBL_MIN_10_EXP"))
1497 #ifdef LDBL_MIN_10_EXP
1498 return LDBL_MIN_10_EXP;
1502 if (strEQ(name, "LDBL_MIN_EXP"))
1504 return LDBL_MIN_EXP;
1510 if (strnEQ(name, "L_", 2)) {
1511 if (strEQ(name, "L_ctermid"))
1517 if (strEQ(name, "L_cuserid"))
1523 if (strEQ(name, "L_tmpname"))
1531 if (strEQ(name, "LONG_MAX"))
1537 if (strEQ(name, "LONG_MIN"))
1543 if (strEQ(name, "LINK_MAX"))
1551 if (strEQ(name, "MAX_CANON"))
1557 if (strEQ(name, "MAX_INPUT"))
1563 if (strEQ(name, "MB_CUR_MAX"))
1569 if (strEQ(name, "MB_LEN_MAX"))
1577 if (strEQ(name, "NULL")) return 0;
1578 if (strEQ(name, "NAME_MAX"))
1584 if (strEQ(name, "NCCS"))
1590 if (strEQ(name, "NGROUPS_MAX"))
1596 if (strEQ(name, "NOFLSH"))
1604 if (strnEQ(name, "O_", 2)) {
1605 if (strEQ(name, "O_APPEND"))
1611 if (strEQ(name, "O_CREAT"))
1617 if (strEQ(name, "O_TRUNC"))
1623 if (strEQ(name, "O_RDONLY"))
1629 if (strEQ(name, "O_RDWR"))
1635 if (strEQ(name, "O_WRONLY"))
1641 if (strEQ(name, "O_EXCL"))
1647 if (strEQ(name, "O_NOCTTY"))
1653 if (strEQ(name, "O_NONBLOCK"))
1659 if (strEQ(name, "O_ACCMODE"))
1667 if (strEQ(name, "OPEN_MAX"))
1673 if (strEQ(name, "OPOST"))
1681 if (strEQ(name, "PATH_MAX"))
1687 if (strEQ(name, "PARENB"))
1693 if (strEQ(name, "PARMRK"))
1699 if (strEQ(name, "PARODD"))
1705 if (strEQ(name, "PIPE_BUF"))
1713 if (strEQ(name, "RAND_MAX"))
1719 if (strEQ(name, "R_OK"))
1727 if (strnEQ(name, "SIG", 3)) {
1728 if (name[3] == '_') {
1729 if (strEQ(name, "SIG_BLOCK"))
1736 if (strEQ(name, "SIG_DFL")) return (IV)SIG_DFL;
1739 if (strEQ(name, "SIG_ERR")) return (IV)SIG_ERR;
1742 if (strEQ(name, "SIG_IGN")) return (IV)SIG_IGN;
1744 if (strEQ(name, "SIG_SETMASK"))
1750 if (strEQ(name, "SIG_UNBLOCK"))
1758 if (strEQ(name, "SIGABRT"))
1764 if (strEQ(name, "SIGALRM"))
1770 if (strEQ(name, "SIGCHLD"))
1776 if (strEQ(name, "SIGCONT"))
1782 if (strEQ(name, "SIGFPE"))
1788 if (strEQ(name, "SIGHUP"))
1794 if (strEQ(name, "SIGILL"))
1800 if (strEQ(name, "SIGINT"))
1806 if (strEQ(name, "SIGKILL"))
1812 if (strEQ(name, "SIGPIPE"))
1818 if (strEQ(name, "SIGQUIT"))
1824 if (strEQ(name, "SIGSEGV"))
1830 if (strEQ(name, "SIGSTOP"))
1836 if (strEQ(name, "SIGTERM"))
1842 if (strEQ(name, "SIGTSTP"))
1848 if (strEQ(name, "SIGTTIN"))
1854 if (strEQ(name, "SIGTTOU"))
1860 if (strEQ(name, "SIGUSR1"))
1866 if (strEQ(name, "SIGUSR2"))
1874 if (name[1] == '_') {
1875 if (strEQ(name, "S_ISGID"))
1881 if (strEQ(name, "S_ISUID"))
1887 if (strEQ(name, "S_IRGRP"))
1893 if (strEQ(name, "S_IROTH"))
1899 if (strEQ(name, "S_IRUSR"))
1905 if (strEQ(name, "S_IRWXG"))
1911 if (strEQ(name, "S_IRWXO"))
1917 if (strEQ(name, "S_IRWXU"))
1923 if (strEQ(name, "S_IWGRP"))
1929 if (strEQ(name, "S_IWOTH"))
1935 if (strEQ(name, "S_IWUSR"))
1941 if (strEQ(name, "S_IXGRP"))
1947 if (strEQ(name, "S_IXOTH"))
1953 if (strEQ(name, "S_IXUSR"))
1959 errno = EAGAIN; /* the following aren't constants */
1961 if (strEQ(name, "S_ISBLK")) return S_ISBLK(arg);
1964 if (strEQ(name, "S_ISCHR")) return S_ISCHR(arg);
1967 if (strEQ(name, "S_ISDIR")) return S_ISDIR(arg);
1970 if (strEQ(name, "S_ISFIFO")) return S_ISFIFO(arg);
1973 if (strEQ(name, "S_ISREG")) return S_ISREG(arg);
1977 if (strEQ(name, "SEEK_CUR"))
1983 if (strEQ(name, "SEEK_END"))
1989 if (strEQ(name, "SEEK_SET"))
1995 if (strEQ(name, "STREAM_MAX"))
2001 if (strEQ(name, "SHRT_MAX"))
2007 if (strEQ(name, "SHRT_MIN"))
2013 if (strnEQ(name, "SA_", 3)) {
2014 if (strEQ(name, "SA_NOCLDSTOP"))
2016 return SA_NOCLDSTOP;
2020 if (strEQ(name, "SA_NOCLDWAIT"))
2022 return SA_NOCLDWAIT;
2026 if (strEQ(name, "SA_NODEFER"))
2032 if (strEQ(name, "SA_ONSTACK"))
2038 if (strEQ(name, "SA_RESETHAND"))
2040 return SA_RESETHAND;
2044 if (strEQ(name, "SA_RESTART"))
2050 if (strEQ(name, "SA_SIGINFO"))
2058 if (strEQ(name, "SCHAR_MAX"))
2064 if (strEQ(name, "SCHAR_MIN"))
2070 if (strEQ(name, "SSIZE_MAX"))
2076 if (strEQ(name, "STDIN_FILENO"))
2078 return STDIN_FILENO;
2082 if (strEQ(name, "STDOUT_FILENO"))
2083 #ifdef STDOUT_FILENO
2084 return STDOUT_FILENO;
2088 if (strEQ(name, "STRERR_FILENO"))
2089 #ifdef STRERR_FILENO
2090 return STRERR_FILENO;
2096 if (strEQ(name, "TCIFLUSH"))
2102 if (strEQ(name, "TCIOFF"))
2108 if (strEQ(name, "TCIOFLUSH"))
2114 if (strEQ(name, "TCION"))
2120 if (strEQ(name, "TCOFLUSH"))
2126 if (strEQ(name, "TCOOFF"))
2132 if (strEQ(name, "TCOON"))
2138 if (strEQ(name, "TCSADRAIN"))
2144 if (strEQ(name, "TCSAFLUSH"))
2150 if (strEQ(name, "TCSANOW"))
2156 if (strEQ(name, "TMP_MAX"))
2162 if (strEQ(name, "TOSTOP"))
2168 if (strEQ(name, "TZNAME_MAX"))
2176 if (strEQ(name, "UCHAR_MAX"))
2182 if (strEQ(name, "UINT_MAX"))
2188 if (strEQ(name, "ULONG_MAX"))
2194 if (strEQ(name, "USHRT_MAX"))
2202 if (strEQ(name, "VEOF"))
2208 if (strEQ(name, "VEOL"))
2214 if (strEQ(name, "VERASE"))
2220 if (strEQ(name, "VINTR"))
2226 if (strEQ(name, "VKILL"))
2232 if (strEQ(name, "VMIN"))
2238 if (strEQ(name, "VQUIT"))
2244 if (strEQ(name, "VSTART"))
2250 if (strEQ(name, "VSTOP"))
2256 if (strEQ(name, "VSUSP"))
2262 if (strEQ(name, "VTIME"))
2270 if (strEQ(name, "W_OK"))
2276 if (strEQ(name, "WNOHANG"))
2282 if (strEQ(name, "WUNTRACED"))
2288 errno = EAGAIN; /* the following aren't constants */
2290 if (strEQ(name, "WEXITSTATUS")) return WEXITSTATUS(arg);
2293 if (strEQ(name, "WIFEXITED")) return WIFEXITED(arg);
2296 if (strEQ(name, "WIFSIGNALED")) return WIFSIGNALED(arg);
2299 if (strEQ(name, "WIFSTOPPED")) return WIFSTOPPED(arg);
2302 if (strEQ(name, "WSTOPSIG")) return WSTOPSIG(arg);
2305 if (strEQ(name, "WTERMSIG")) return WTERMSIG(arg);
2309 if (strEQ(name, "X_OK"))
2317 if (strnEQ(name, "_PC_", 4)) {
2318 if (strEQ(name, "_PC_CHOWN_RESTRICTED"))
2319 #if defined(_PC_CHOWN_RESTRICTED) || HINT_SC_EXIST
2320 return _PC_CHOWN_RESTRICTED;
2324 if (strEQ(name, "_PC_LINK_MAX"))
2325 #if defined(_PC_LINK_MAX) || HINT_SC_EXIST
2326 return _PC_LINK_MAX;
2330 if (strEQ(name, "_PC_MAX_CANON"))
2331 #if defined(_PC_MAX_CANON) || HINT_SC_EXIST
2332 return _PC_MAX_CANON;
2336 if (strEQ(name, "_PC_MAX_INPUT"))
2337 #if defined(_PC_MAX_INPUT) || HINT_SC_EXIST
2338 return _PC_MAX_INPUT;
2342 if (strEQ(name, "_PC_NAME_MAX"))
2343 #if defined(_PC_NAME_MAX) || HINT_SC_EXIST
2344 return _PC_NAME_MAX;
2348 if (strEQ(name, "_PC_NO_TRUNC"))
2349 #if defined(_PC_NO_TRUNC) || HINT_SC_EXIST
2350 return _PC_NO_TRUNC;
2354 if (strEQ(name, "_PC_PATH_MAX"))
2355 #if defined(_PC_PATH_MAX) || HINT_SC_EXIST
2356 return _PC_PATH_MAX;
2360 if (strEQ(name, "_PC_PIPE_BUF"))
2361 #if defined(_PC_PIPE_BUF) || HINT_SC_EXIST
2362 return _PC_PIPE_BUF;
2366 if (strEQ(name, "_PC_VDISABLE"))
2367 #if defined(_PC_VDISABLE) || HINT_SC_EXIST
2368 return _PC_VDISABLE;
2374 if (strnEQ(name, "_POSIX_", 7)) {
2375 if (strEQ(name, "_POSIX_ARG_MAX"))
2376 #ifdef _POSIX_ARG_MAX
2377 return _POSIX_ARG_MAX;
2381 if (strEQ(name, "_POSIX_CHILD_MAX"))
2382 #ifdef _POSIX_CHILD_MAX
2383 return _POSIX_CHILD_MAX;
2387 if (strEQ(name, "_POSIX_CHOWN_RESTRICTED"))
2388 #ifdef _POSIX_CHOWN_RESTRICTED
2389 return _POSIX_CHOWN_RESTRICTED;
2393 if (strEQ(name, "_POSIX_JOB_CONTROL"))
2394 #ifdef _POSIX_JOB_CONTROL
2395 return _POSIX_JOB_CONTROL;
2399 if (strEQ(name, "_POSIX_LINK_MAX"))
2400 #ifdef _POSIX_LINK_MAX
2401 return _POSIX_LINK_MAX;
2405 if (strEQ(name, "_POSIX_MAX_CANON"))
2406 #ifdef _POSIX_MAX_CANON
2407 return _POSIX_MAX_CANON;
2411 if (strEQ(name, "_POSIX_MAX_INPUT"))
2412 #ifdef _POSIX_MAX_INPUT
2413 return _POSIX_MAX_INPUT;
2417 if (strEQ(name, "_POSIX_NAME_MAX"))
2418 #ifdef _POSIX_NAME_MAX
2419 return _POSIX_NAME_MAX;
2423 if (strEQ(name, "_POSIX_NGROUPS_MAX"))
2424 #ifdef _POSIX_NGROUPS_MAX
2425 return _POSIX_NGROUPS_MAX;
2429 if (strEQ(name, "_POSIX_NO_TRUNC"))
2430 #ifdef _POSIX_NO_TRUNC
2431 return _POSIX_NO_TRUNC;
2435 if (strEQ(name, "_POSIX_OPEN_MAX"))
2436 #ifdef _POSIX_OPEN_MAX
2437 return _POSIX_OPEN_MAX;
2441 if (strEQ(name, "_POSIX_PATH_MAX"))
2442 #ifdef _POSIX_PATH_MAX
2443 return _POSIX_PATH_MAX;
2447 if (strEQ(name, "_POSIX_PIPE_BUF"))
2448 #ifdef _POSIX_PIPE_BUF
2449 return _POSIX_PIPE_BUF;
2453 if (strEQ(name, "_POSIX_SAVED_IDS"))
2454 #ifdef _POSIX_SAVED_IDS
2455 return _POSIX_SAVED_IDS;
2459 if (strEQ(name, "_POSIX_SSIZE_MAX"))
2460 #ifdef _POSIX_SSIZE_MAX
2461 return _POSIX_SSIZE_MAX;
2465 if (strEQ(name, "_POSIX_STREAM_MAX"))
2466 #ifdef _POSIX_STREAM_MAX
2467 return _POSIX_STREAM_MAX;
2471 if (strEQ(name, "_POSIX_TZNAME_MAX"))
2472 #ifdef _POSIX_TZNAME_MAX
2473 return _POSIX_TZNAME_MAX;
2477 if (strEQ(name, "_POSIX_VDISABLE"))
2478 #ifdef _POSIX_VDISABLE
2479 return _POSIX_VDISABLE;
2483 if (strEQ(name, "_POSIX_VERSION"))
2484 #ifdef _POSIX_VERSION
2485 return _POSIX_VERSION;
2491 if (strnEQ(name, "_SC_", 4)) {
2492 if (strEQ(name, "_SC_ARG_MAX"))
2493 #if defined(_SC_ARG_MAX) || HINT_SC_EXIST
2498 if (strEQ(name, "_SC_CHILD_MAX"))
2499 #if defined(_SC_CHILD_MAX) || HINT_SC_EXIST
2500 return _SC_CHILD_MAX;
2504 if (strEQ(name, "_SC_CLK_TCK"))
2505 #if defined(_SC_CLK_TCK) || HINT_SC_EXIST
2510 if (strEQ(name, "_SC_JOB_CONTROL"))
2511 #if defined(_SC_JOB_CONTROL) || HINT_SC_EXIST
2512 return _SC_JOB_CONTROL;
2516 if (strEQ(name, "_SC_NGROUPS_MAX"))
2517 #if defined(_SC_NGROUPS_MAX) || HINT_SC_EXIST
2518 return _SC_NGROUPS_MAX;
2522 if (strEQ(name, "_SC_OPEN_MAX"))
2523 #if defined(_SC_OPEN_MAX) || HINT_SC_EXIST
2524 return _SC_OPEN_MAX;
2528 if (strEQ(name, "_SC_SAVED_IDS"))
2529 #if defined(_SC_SAVED_IDS) || HINT_SC_EXIST
2530 return _SC_SAVED_IDS;
2534 if (strEQ(name, "_SC_STREAM_MAX"))
2535 #if defined(_SC_STREAM_MAX) || HINT_SC_EXIST
2536 return _SC_STREAM_MAX;
2540 if (strEQ(name, "_SC_TZNAME_MAX"))
2541 #if defined(_SC_TZNAME_MAX) || HINT_SC_EXIST
2542 return _SC_TZNAME_MAX;
2546 if (strEQ(name, "_SC_VERSION"))
2547 #if defined(_SC_VERSION) || HINT_SC_EXIST
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 perl_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 perl_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 perl_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(modf(x,&intvar))));
3145 PUSHs(sv_2mortal(newSVnv(intvar)));
3160 sigaction(sig, action, oldaction = 0)
3162 POSIX::SigAction action
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 gv_fetchpv("SIG", TRUE, SVt_PVHV);
3175 struct sigaction act;
3176 struct sigaction oact;
3177 POSIX__SigSet sigset;
3179 SV** sigsvp = hv_fetch(GvHVn(PL_siggv),
3181 strlen(sig_name[sig]),
3185 /* Remember old handler name if desired. */
3187 char *hand = SvPVx(*sigsvp, n_a);
3188 svp = hv_fetch(oldaction, "HANDLER", 7, TRUE);
3189 sv_setpv(*svp, *hand ? hand : "DEFAULT");
3193 /* Vector new handler through %SIG. (We always use sighandler
3194 for the C signal handler, which reads %SIG to dispatch.) */
3195 svp = hv_fetch(action, "HANDLER", 7, FALSE);
3197 croak("Can't supply an action without a HANDLER");
3198 sv_setpv(*sigsvp, SvPV(*svp, n_a));
3199 mg_set(*sigsvp); /* handles DEFAULT and IGNORE */
3200 act.sa_handler = sighandler;
3202 /* Set up any desired mask. */
3203 svp = hv_fetch(action, "MASK", 4, FALSE);
3204 if (svp && sv_isa(*svp, "POSIX::SigSet")) {
3206 tmp = (unsigned long)SvNV((SV*)SvRV(*svp));
3207 sigset = (sigset_t*) tmp;
3208 act.sa_mask = *sigset;
3211 sigemptyset(& act.sa_mask);
3213 /* Set up any desired flags. */
3214 svp = hv_fetch(action, "FLAGS", 5, FALSE);
3215 act.sa_flags = svp ? SvIV(*svp) : 0;
3218 /* Now work around sigaction oddities */
3219 if (action && oldaction)
3220 RETVAL = sigaction(sig, & act, & oact);
3222 RETVAL = sigaction(sig, & act, (struct sigaction *)0);
3224 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")) {
3233 tmp = (unsigned long)SvNV((SV*)SvRV(*svp));
3234 sigset = (sigset_t*) tmp;
3237 New(0, sigset, 1, sigset_t);
3238 sv_setptrobj(*svp, sigset, "POSIX::SigSet");
3240 *sigset = oact.sa_mask;
3242 /* Get back the flags. */
3243 svp = hv_fetch(oldaction, "FLAGS", 5, TRUE);
3244 sv_setiv(*svp, oact.sa_flags);
3253 POSIX::SigSet sigset
3256 sigprocmask(how, sigset, oldsigset = 0)
3258 POSIX::SigSet sigset
3259 POSIX::SigSet oldsigset = NO_INIT
3264 else if (sv_derived_from(ST(2), "POSIX::SigSet")) {
3265 IV tmp = SvIV((SV*)SvRV(ST(2)));
3266 oldsigset = (POSIX__SigSet) tmp;
3269 New(0, oldsigset, 1, sigset_t);
3270 sigemptyset(oldsigset);
3271 sv_setref_pv(ST(2), "POSIX::SigSet", (void*)oldsigset);
3275 sigsuspend(signal_mask)
3276 POSIX::SigSet signal_mask
3296 lseek(fd, offset, whence)
3309 if (pipe(fds) != -1) {
3311 PUSHs(sv_2mortal(newSViv(fds[0])));
3312 PUSHs(sv_2mortal(newSViv(fds[1])));
3316 read(fd, buffer, nbytes)
3318 SV *sv_buffer = SvROK(ST(1)) ? SvRV(ST(1)) : ST(1);
3322 char * buffer = sv_grow( sv_buffer, nbytes+1 );
3325 SvCUR(sv_buffer) = RETVAL;
3326 SvPOK_only(sv_buffer);
3327 *SvEND(sv_buffer) = '\0';
3328 SvTAINTED_on(sv_buffer);
3344 tcsetpgrp(fd, pgrp_id)
3353 if (uname(&buf) >= 0) {
3355 PUSHs(sv_2mortal(newSVpv(buf.sysname, 0)));
3356 PUSHs(sv_2mortal(newSVpv(buf.nodename, 0)));
3357 PUSHs(sv_2mortal(newSVpv(buf.release, 0)));
3358 PUSHs(sv_2mortal(newSVpv(buf.version, 0)));
3359 PUSHs(sv_2mortal(newSVpv(buf.machine, 0)));
3362 uname((char *) 0); /* A stub to call not_here(). */
3366 write(fd, buffer, nbytes)
3384 mbstowcs(s, pwcs, n)
3396 wcstombs(s, pwcs, n)
3418 SET_NUMERIC_LOCAL();
3419 num = strtod(str, &unparsed);
3420 PUSHs(sv_2mortal(newSVnv(num)));
3421 if (GIMME == G_ARRAY) {
3424 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3426 PUSHs(&PL_sv_undef);
3430 strtol(str, base = 0)
3437 num = strtol(str, &unparsed, base);
3438 if (num >= IV_MIN && num <= IV_MAX)
3439 PUSHs(sv_2mortal(newSViv((IV)num)));
3441 PUSHs(sv_2mortal(newSVnv((double)num)));
3442 if (GIMME == G_ARRAY) {
3445 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3447 PUSHs(&PL_sv_undef);
3451 strtoul(str, base = 0)
3458 num = strtoul(str, &unparsed, base);
3460 PUSHs(sv_2mortal(newSViv((IV)num)));
3462 PUSHs(sv_2mortal(newSVnv((double)num)));
3463 if (GIMME == G_ARRAY) {
3466 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3468 PUSHs(&PL_sv_undef);
3478 char *p = SvPV(src,srclen);
3480 ST(0) = sv_2mortal(NEWSV(800,srclen));
3481 dstlen = strxfrm(SvPVX(ST(0)), p, (size_t)srclen);
3482 if (dstlen > srclen) {
3484 SvGROW(ST(0), dstlen);
3485 strxfrm(SvPVX(ST(0)), p, (size_t)dstlen);
3488 SvCUR(ST(0)) = dstlen;
3493 mkfifo(filename, mode)
3497 TAINT_PROPER("mkfifo");
3498 RETVAL = mkfifo(filename, mode);
3514 tcflush(fd, queue_selector)
3519 tcsendbreak(fd, duration)
3524 asctime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3537 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3540 mytm.tm_hour = hour;
3541 mytm.tm_mday = mday;
3543 mytm.tm_year = year;
3544 mytm.tm_wday = wday;
3545 mytm.tm_yday = yday;
3546 mytm.tm_isdst = isdst;
3547 RETVAL = asctime(&mytm);
3564 realtime = times( &tms );
3566 PUSHs( sv_2mortal( newSViv( (IV) realtime ) ) );
3567 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_utime ) ) );
3568 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_stime ) ) );
3569 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cutime ) ) );
3570 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cstime ) ) );
3573 difftime(time1, time2)
3578 mktime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3591 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3594 mytm.tm_hour = hour;
3595 mytm.tm_mday = mday;
3597 mytm.tm_year = year;
3598 mytm.tm_wday = wday;
3599 mytm.tm_yday = yday;
3600 mytm.tm_isdst = isdst;
3601 RETVAL = mktime(&mytm);
3607 strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1)
3624 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3628 mytm.tm_hour = hour;
3629 mytm.tm_mday = mday;
3631 mytm.tm_year = year;
3632 mytm.tm_wday = wday;
3633 mytm.tm_yday = yday;
3634 mytm.tm_isdst = isdst;
3637 mytm.tm_zone = "???";
3639 (void) mktime(&mytm);
3641 len = strftime(tmpbuf, sizeof tmpbuf, fmt, &mytm);
3643 ** The following is needed to handle to the situation where
3644 ** tmpbuf overflows. Basically we want to allocate a buffer
3645 ** and try repeatedly. The reason why it is so complicated
3646 ** is that getting a return value of 0 from strftime can indicate
3647 ** one of the following:
3648 ** 1. buffer overflowed,
3649 ** 2. illegal conversion specifier, or
3650 ** 3. the format string specifies nothing to be returned(not
3651 ** an error). This could be because format is an empty string
3652 ** or it specifies %p that yields an empty string in some locale.
3653 ** If there is a better way to make it portable, go ahead by
3656 if ( ( len > 0 && len < sizeof(tmpbuf) )
3657 || ( len == 0 && strlen(fmt) == 0 ) ) {
3658 ST(0) = sv_2mortal(newSVpv(tmpbuf, len));
3660 /* Possibly buf overflowed - try again with a bigger buf */
3661 int bufsize = strlen(fmt) + sizeof(tmpbuf);
3665 New(0, buf, bufsize, char);
3667 buflen = strftime(buf, bufsize, fmt, &mytm);
3668 if ( buflen > 0 && buflen < bufsize ) break;
3670 Renew(buf, bufsize, char);
3673 ST(0) = sv_2mortal(newSVpv(buf, buflen));
3676 ST(0) = sv_2mortal(newSVpv(tmpbuf, len));
3688 PUSHs(sv_2mortal(newSVpv(tzname[0],strlen(tzname[0]))));
3689 PUSHs(sv_2mortal(newSVpv(tzname[1],strlen(tzname[1]))));
3692 access(filename, mode)
3710 pathconf(filename, name)