2 #define PERLIO_NOT_STDIO 1
6 #ifdef I_DIRENT /* XXX maybe better to just rely on perl.h? */
29 /* XXX This comment is just to make I_TERMIO and I_SGTTY visible to
30 metaconfig for future extension writers. We don't use them in POSIX.
31 (This is really sneaky :-) --AD
33 #if defined(I_TERMIOS)
42 #include <sys/types.h>
45 #if defined(__VMS) && !defined(__POSIX_SOURCE)
46 # include <file.h> /* == fcntl.h for DECC; no fcntl.h for VAXC */
47 # include <libdef.h> /* LIB$_INVARG constant */
48 # include <lib$routines.h> /* prototype for lib$ediv() */
49 # include <starlet.h> /* prototype for sys$gettim() */
51 # undef mkfifo /* #defined in perl.h */
52 # define mkfifo(a,b) (not_here("mkfifo"),-1)
53 # define tzset() not_here("tzset")
55 /* The default VMS emulation of Unix signals isn't very POSIXish */
57 # define sigpending(a) (not_here("sigpending"),0)
59 /* sigset_t is atomic under VMS, so these routines are easy */
60 int sigemptyset(sigset_t *set) {
61 if (!set) { SETERRNO(EFAULT,SS$_ACCVIO); return -1; }
64 int sigfillset(sigset_t *set) {
66 if (!set) { SETERRNO(EFAULT,SS$_ACCVIO); return -1; }
67 for (i = 0; i < NSIG; i++) *set |= (1 << i);
70 int sigaddset(sigset_t *set, int sig) {
71 if (!set) { SETERRNO(EFAULT,SS$_ACCVIO); return -1; }
72 if (sig > NSIG) { SETERRNO(EINVAL,LIB$_INVARG); return -1; }
73 *set |= (1 << (sig - 1));
76 int sigdelset(sigset_t *set, int sig) {
77 if (!set) { SETERRNO(EFAULT,SS$_ACCVIO); return -1; }
78 if (sig > NSIG) { SETERRNO(EINVAL,LIB$_INVARG); return -1; }
79 *set &= ~(1 << (sig - 1));
82 int sigismember(sigset_t *set, int sig) {
83 if (!set) { SETERRNO(EFAULT,SS$_ACCVIO); return -1; }
84 if (sig > NSIG) { SETERRNO(EINVAL,LIB$_INVARG); return -1; }
85 *set & (1 << (sig - 1));
87 /* The tools for sigprocmask() are there, just not the routine itself */
89 # define SIG_UNBLOCK 1
95 # define SIG_SETMASK 3
97 int sigprocmask(int how, sigset_t *set, sigset_t *oset) {
99 set_errno(EFAULT); set_vaxc_errno(SS$_ACCVIO);
104 *oset = sigsetmask(*set);
107 *oset = sigblock(*set);
111 sigsetmask(*oset & ~*set);
114 set_errno(EINVAL); set_vaxc_errno(LIB$_INVARG);
119 # define sigaction sigvec
120 # define sa_flags sv_onstack
121 # define sa_handler sv_handler
122 # define sa_mask sv_mask
123 # define sigsuspend(set) sigpause(*set)
125 /* The POSIX notion of ttyname() is better served by getname() under VMS */
126 static char ttnambuf[64];
127 # define ttyname(fd) (isatty(fd) > 0 ? getname(fd,ttnambuf,0) : NULL)
129 /* The non-POSIX CRTL times() has void return type, so we just get the
130 current time directly */
131 clock_t vms_times(struct tms *bufptr) {
133 /* Get wall time and convert to 10 ms intervals to
134 * produce the return value that the POSIX standard expects */
135 # if defined(__DECC) && defined (__ALPHA)
138 _ckvmssts(sys$gettim(&vmstime));
140 retval = vmstime & 0x7fffffff;
142 /* (Older hw or ccs don't have an atomic 64-bit type, so we
143 * juggle 32-bit ints (and a float) to produce a time_t result
144 * with minimal loss of information.) */
145 long int vmstime[2],remainder,divisor = 100000;
146 _ckvmssts(sys$gettim((unsigned long int *)vmstime));
147 vmstime[1] &= 0x7fff; /* prevent overflow in EDIV */
148 _ckvmssts(lib$ediv(&divisor,vmstime,(long int *)&retval,&remainder));
150 /* Fill in the struct tms using the CRTL routine . . .*/
151 times((tbuffer_t *)bufptr);
152 return (clock_t) retval;
154 # define times(t) vms_times(t)
158 # include <sys/times.h>
160 # include <sys/utsname.h>
162 # include <sys/wait.h>
169 typedef long SysRetLong;
170 typedef sigset_t* POSIX__SigSet;
171 typedef HV* POSIX__SigAction;
173 typedef struct termios* POSIX__Termios;
174 #else /* Define termios types to int, and call not_here for the functions.*/
175 #define POSIX__Termios int
179 #define cfgetispeed(x) not_here("cfgetispeed")
180 #define cfgetospeed(x) not_here("cfgetospeed")
181 #define tcdrain(x) not_here("tcdrain")
182 #define tcflush(x,y) not_here("tcflush")
183 #define tcsendbreak(x,y) not_here("tcsendbreak")
184 #define cfsetispeed(x,y) not_here("cfsetispeed")
185 #define cfsetospeed(x,y) not_here("cfsetospeed")
186 #define ctermid(x) (char *) not_here("ctermid")
187 #define tcflow(x,y) not_here("tcflow")
188 #define tcgetattr(x,y) not_here("tcgetattr")
189 #define tcsetattr(x,y,z) not_here("tcsetattr")
192 /* Possibly needed prototypes */
193 char *cuserid _((char *));
196 #define cuserid(a) (char *) not_here("cuserid")
200 #define difftime(a,b) not_here("difftime")
203 #ifndef HAS_FPATHCONF
204 #define fpathconf(f,n) (SysRetLong) not_here("fpathconf")
207 #define mktime(a) not_here("mktime")
210 #define nice(a) not_here("nice")
213 #define pathconf(f,n) (SysRetLong) not_here("pathconf")
216 #define sysconf(n) (SysRetLong) not_here("sysconf")
219 #define readlink(a,b,c) not_here("readlink")
222 #define setpgid(a,b) not_here("setpgid")
225 #define setsid() not_here("setsid")
228 #define strcoll(s1,s2) not_here("strcoll")
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")
282 extern char *tzname[];
284 char *tzname[] = { "" , "" };
287 /* XXX struct tm on some systems (SunOS4/BSD) contains extra (non POSIX)
288 * fields for which we don't have Configure support yet:
289 * char *tm_zone; -- abbreviation of timezone name
290 * long tm_gmtoff; -- offset from GMT in seconds
291 * To workaround core dumps from the uninitialised tm_zone we get the
292 * system to give us a reasonable struct to copy. This fix means that
293 * strftime uses the tm_zone and tm_gmtoff values returned by
294 * localtime(time()). That should give the desired result most of the
295 * time. But probably not always!
297 * This is a temporary workaround to be removed once Configure
298 * support is added and NETaa14816 is considered in full.
299 * It does not address tzname aspects of NETaa14816.
301 #ifdef STRUCT_TM_HASZONE
303 init_tm(ptm) /* see mktime, strftime and asctime */
308 Copy(localtime(&now), ptm, 1, struct tm);
312 # define init_tm(ptm)
316 #ifndef HAS_LONG_DOUBLE /* XXX What to do about long doubles? */
332 croak("POSIX::%s not implemented on this architecture", s);
344 if (strEQ(name, "ARG_MAX"))
352 if (strEQ(name, "BUFSIZ"))
358 if (strEQ(name, "BRKINT"))
364 if (strEQ(name, "B9600"))
370 if (strEQ(name, "B19200"))
376 if (strEQ(name, "B38400"))
382 if (strEQ(name, "B0"))
388 if (strEQ(name, "B110"))
394 if (strEQ(name, "B1200"))
400 if (strEQ(name, "B134"))
406 if (strEQ(name, "B150"))
412 if (strEQ(name, "B1800"))
418 if (strEQ(name, "B200"))
424 if (strEQ(name, "B2400"))
430 if (strEQ(name, "B300"))
436 if (strEQ(name, "B4800"))
442 if (strEQ(name, "B50"))
448 if (strEQ(name, "B600"))
454 if (strEQ(name, "B75"))
462 if (strEQ(name, "CHAR_BIT"))
468 if (strEQ(name, "CHAR_MAX"))
474 if (strEQ(name, "CHAR_MIN"))
480 if (strEQ(name, "CHILD_MAX"))
486 if (strEQ(name, "CLK_TCK"))
492 if (strEQ(name, "CLOCAL"))
498 if (strEQ(name, "CLOCKS_PER_SEC"))
499 #ifdef CLOCKS_PER_SEC
500 return CLOCKS_PER_SEC;
504 if (strEQ(name, "CREAD"))
510 if (strEQ(name, "CS5"))
516 if (strEQ(name, "CS6"))
522 if (strEQ(name, "CS7"))
528 if (strEQ(name, "CS8"))
534 if (strEQ(name, "CSIZE"))
540 if (strEQ(name, "CSTOPB"))
548 if (strEQ(name, "DBL_MAX"))
554 if (strEQ(name, "DBL_MIN"))
560 if (strEQ(name, "DBL_DIG"))
566 if (strEQ(name, "DBL_EPSILON"))
572 if (strEQ(name, "DBL_MANT_DIG"))
578 if (strEQ(name, "DBL_MAX_10_EXP"))
579 #ifdef DBL_MAX_10_EXP
580 return DBL_MAX_10_EXP;
584 if (strEQ(name, "DBL_MAX_EXP"))
590 if (strEQ(name, "DBL_MIN_10_EXP"))
591 #ifdef DBL_MIN_10_EXP
592 return DBL_MIN_10_EXP;
596 if (strEQ(name, "DBL_MIN_EXP"))
606 if (strEQ(name, "EACCES"))
612 if (strEQ(name, "EAGAIN"))
620 if (strEQ(name, "EBADF"))
626 if (strEQ(name, "EBUSY"))
634 if (strEQ(name, "ECHILD"))
640 if (strEQ(name, "ECHO"))
646 if (strEQ(name, "ECHOE"))
652 if (strEQ(name, "ECHOK"))
658 if (strEQ(name, "ECHONL"))
666 if (strEQ(name, "EDEADLK"))
672 if (strEQ(name, "EDOM"))
680 if (strEQ(name, "EEXIST"))
688 if (strEQ(name, "EFAULT"))
694 if (strEQ(name, "EFBIG"))
702 if (strEQ(name, "EINTR"))
708 if (strEQ(name, "EINVAL"))
714 if (strEQ(name, "EIO"))
720 if (strEQ(name, "EISDIR"))
728 if (strEQ(name, "EMFILE"))
734 if (strEQ(name, "EMLINK"))
742 if (strEQ(name, "ENOMEM"))
748 if (strEQ(name, "ENOSPC"))
754 if (strEQ(name, "ENOEXEC"))
760 if (strEQ(name, "ENOTTY"))
766 if (strEQ(name, "ENOTDIR"))
772 if (strEQ(name, "ENOTEMPTY"))
778 if (strEQ(name, "ENFILE"))
784 if (strEQ(name, "ENODEV"))
790 if (strEQ(name, "ENOENT"))
796 if (strEQ(name, "ENOLCK"))
802 if (strEQ(name, "ENOSYS"))
808 if (strEQ(name, "ENXIO"))
814 if (strEQ(name, "ENAMETOOLONG"))
822 if (strEQ(name, "EOF"))
830 if (strEQ(name, "EPERM"))
836 if (strEQ(name, "EPIPE"))
844 if (strEQ(name, "ERANGE"))
850 if (strEQ(name, "EROFS"))
858 if (strEQ(name, "ESPIPE"))
864 if (strEQ(name, "ESRCH"))
872 if (strEQ(name, "EXIT_FAILURE"))
878 if (strEQ(name, "EXIT_SUCCESS"))
884 if (strEQ(name, "EXDEV"))
892 if (strEQ(name, "E2BIG"))
900 if (strnEQ(name, "FLT_", 4)) {
901 if (strEQ(name, "FLT_MAX"))
907 if (strEQ(name, "FLT_MIN"))
913 if (strEQ(name, "FLT_ROUNDS"))
919 if (strEQ(name, "FLT_DIG"))
925 if (strEQ(name, "FLT_EPSILON"))
931 if (strEQ(name, "FLT_MANT_DIG"))
937 if (strEQ(name, "FLT_MAX_10_EXP"))
938 #ifdef FLT_MAX_10_EXP
939 return FLT_MAX_10_EXP;
943 if (strEQ(name, "FLT_MAX_EXP"))
949 if (strEQ(name, "FLT_MIN_10_EXP"))
950 #ifdef FLT_MIN_10_EXP
951 return FLT_MIN_10_EXP;
955 if (strEQ(name, "FLT_MIN_EXP"))
961 if (strEQ(name, "FLT_RADIX"))
969 if (strnEQ(name, "F_", 2)) {
970 if (strEQ(name, "F_DUPFD"))
976 if (strEQ(name, "F_GETFD"))
982 if (strEQ(name, "F_GETFL"))
988 if (strEQ(name, "F_GETLK"))
994 if (strEQ(name, "F_OK"))
1000 if (strEQ(name, "F_RDLCK"))
1006 if (strEQ(name, "F_SETFD"))
1012 if (strEQ(name, "F_SETFL"))
1018 if (strEQ(name, "F_SETLK"))
1024 if (strEQ(name, "F_SETLKW"))
1030 if (strEQ(name, "F_UNLCK"))
1036 if (strEQ(name, "F_WRLCK"))
1044 if (strEQ(name, "FD_CLOEXEC"))
1050 if (strEQ(name, "FILENAME_MAX"))
1052 return FILENAME_MAX;
1058 if (strEQ(name, "HUGE_VAL"))
1064 if (strEQ(name, "HUPCL"))
1072 if (strEQ(name, "INT_MAX"))
1078 if (strEQ(name, "INT_MIN"))
1084 if (strEQ(name, "ICANON"))
1090 if (strEQ(name, "ICRNL"))
1096 if (strEQ(name, "IEXTEN"))
1102 if (strEQ(name, "IGNBRK"))
1108 if (strEQ(name, "IGNCR"))
1114 if (strEQ(name, "IGNPAR"))
1120 if (strEQ(name, "INLCR"))
1126 if (strEQ(name, "INPCK"))
1132 if (strEQ(name, "ISIG"))
1138 if (strEQ(name, "ISTRIP"))
1144 if (strEQ(name, "IXOFF"))
1150 if (strEQ(name, "IXON"))
1158 if (strnEQ(name, "LC_", 3)) {
1159 if (strEQ(name, "LC_ALL"))
1165 if (strEQ(name, "LC_COLLATE"))
1171 if (strEQ(name, "LC_CTYPE"))
1177 if (strEQ(name, "LC_MONETARY"))
1183 if (strEQ(name, "LC_NUMERIC"))
1189 if (strEQ(name, "LC_TIME"))
1197 if (strnEQ(name, "LDBL_", 5)) {
1198 if (strEQ(name, "LDBL_MAX"))
1204 if (strEQ(name, "LDBL_MIN"))
1210 if (strEQ(name, "LDBL_DIG"))
1216 if (strEQ(name, "LDBL_EPSILON"))
1218 return LDBL_EPSILON;
1222 if (strEQ(name, "LDBL_MANT_DIG"))
1223 #ifdef LDBL_MANT_DIG
1224 return LDBL_MANT_DIG;
1228 if (strEQ(name, "LDBL_MAX_10_EXP"))
1229 #ifdef LDBL_MAX_10_EXP
1230 return LDBL_MAX_10_EXP;
1234 if (strEQ(name, "LDBL_MAX_EXP"))
1236 return LDBL_MAX_EXP;
1240 if (strEQ(name, "LDBL_MIN_10_EXP"))
1241 #ifdef LDBL_MIN_10_EXP
1242 return LDBL_MIN_10_EXP;
1246 if (strEQ(name, "LDBL_MIN_EXP"))
1248 return LDBL_MIN_EXP;
1254 if (strnEQ(name, "L_", 2)) {
1255 if (strEQ(name, "L_ctermid"))
1261 if (strEQ(name, "L_cuserid"))
1267 if (strEQ(name, "L_tmpname"))
1275 if (strEQ(name, "LONG_MAX"))
1281 if (strEQ(name, "LONG_MIN"))
1287 if (strEQ(name, "LINK_MAX"))
1295 if (strEQ(name, "MAX_CANON"))
1301 if (strEQ(name, "MAX_INPUT"))
1307 if (strEQ(name, "MB_CUR_MAX"))
1313 if (strEQ(name, "MB_LEN_MAX"))
1321 if (strEQ(name, "NULL")) return 0;
1322 if (strEQ(name, "NAME_MAX"))
1328 if (strEQ(name, "NCCS"))
1334 if (strEQ(name, "NGROUPS_MAX"))
1340 if (strEQ(name, "NOFLSH"))
1348 if (strnEQ(name, "O_", 2)) {
1349 if (strEQ(name, "O_APPEND"))
1355 if (strEQ(name, "O_CREAT"))
1361 if (strEQ(name, "O_TRUNC"))
1367 if (strEQ(name, "O_RDONLY"))
1373 if (strEQ(name, "O_RDWR"))
1379 if (strEQ(name, "O_WRONLY"))
1385 if (strEQ(name, "O_EXCL"))
1391 if (strEQ(name, "O_NOCTTY"))
1397 if (strEQ(name, "O_NONBLOCK"))
1403 if (strEQ(name, "O_ACCMODE"))
1411 if (strEQ(name, "OPEN_MAX"))
1417 if (strEQ(name, "OPOST"))
1425 if (strEQ(name, "PATH_MAX"))
1431 if (strEQ(name, "PARENB"))
1437 if (strEQ(name, "PARMRK"))
1443 if (strEQ(name, "PARODD"))
1449 if (strEQ(name, "PIPE_BUF"))
1457 if (strEQ(name, "RAND_MAX"))
1463 if (strEQ(name, "R_OK"))
1471 if (strnEQ(name, "SIG", 3)) {
1472 if (name[3] == '_') {
1473 if (strEQ(name, "SIG_BLOCK"))
1480 if (strEQ(name, "SIG_DFL")) return (int)SIG_DFL;
1483 if (strEQ(name, "SIG_ERR")) return (int)SIG_ERR;
1486 if (strEQ(name, "SIG_IGN")) return (int)SIG_IGN;
1488 if (strEQ(name, "SIG_SETMASK"))
1494 if (strEQ(name, "SIG_UNBLOCK"))
1502 if (strEQ(name, "SIGABRT"))
1508 if (strEQ(name, "SIGALRM"))
1514 if (strEQ(name, "SIGCHLD"))
1520 if (strEQ(name, "SIGCONT"))
1526 if (strEQ(name, "SIGFPE"))
1532 if (strEQ(name, "SIGHUP"))
1538 if (strEQ(name, "SIGILL"))
1544 if (strEQ(name, "SIGINT"))
1550 if (strEQ(name, "SIGKILL"))
1556 if (strEQ(name, "SIGPIPE"))
1562 if (strEQ(name, "SIGQUIT"))
1568 if (strEQ(name, "SIGSEGV"))
1574 if (strEQ(name, "SIGSTOP"))
1580 if (strEQ(name, "SIGTERM"))
1586 if (strEQ(name, "SIGTSTP"))
1592 if (strEQ(name, "SIGTTIN"))
1598 if (strEQ(name, "SIGTTOU"))
1604 if (strEQ(name, "SIGUSR1"))
1610 if (strEQ(name, "SIGUSR2"))
1618 if (name[1] == '_') {
1619 if (strEQ(name, "S_ISGID"))
1625 if (strEQ(name, "S_ISUID"))
1631 if (strEQ(name, "S_IRGRP"))
1637 if (strEQ(name, "S_IROTH"))
1643 if (strEQ(name, "S_IRUSR"))
1649 if (strEQ(name, "S_IRWXG"))
1655 if (strEQ(name, "S_IRWXO"))
1661 if (strEQ(name, "S_IRWXU"))
1667 if (strEQ(name, "S_IWGRP"))
1673 if (strEQ(name, "S_IWOTH"))
1679 if (strEQ(name, "S_IWUSR"))
1685 if (strEQ(name, "S_IXGRP"))
1691 if (strEQ(name, "S_IXOTH"))
1697 if (strEQ(name, "S_IXUSR"))
1703 errno = EAGAIN; /* the following aren't constants */
1705 if (strEQ(name, "S_ISBLK")) return S_ISBLK(arg);
1708 if (strEQ(name, "S_ISCHR")) return S_ISCHR(arg);
1711 if (strEQ(name, "S_ISDIR")) return S_ISDIR(arg);
1714 if (strEQ(name, "S_ISFIFO")) return S_ISFIFO(arg);
1717 if (strEQ(name, "S_ISREG")) return S_ISREG(arg);
1721 if (strEQ(name, "SEEK_CUR"))
1727 if (strEQ(name, "SEEK_END"))
1733 if (strEQ(name, "SEEK_SET"))
1739 if (strEQ(name, "STREAM_MAX"))
1745 if (strEQ(name, "SHRT_MAX"))
1751 if (strEQ(name, "SHRT_MIN"))
1757 if (strEQ(name, "SA_NOCLDSTOP"))
1759 return SA_NOCLDSTOP;
1763 if (strEQ(name, "SCHAR_MAX"))
1769 if (strEQ(name, "SCHAR_MIN"))
1775 if (strEQ(name, "SSIZE_MAX"))
1781 if (strEQ(name, "STDIN_FILENO"))
1783 return STDIN_FILENO;
1787 if (strEQ(name, "STDOUT_FILENO"))
1788 #ifdef STDOUT_FILENO
1789 return STDOUT_FILENO;
1793 if (strEQ(name, "STRERR_FILENO"))
1794 #ifdef STRERR_FILENO
1795 return STRERR_FILENO;
1801 if (strEQ(name, "TCIFLUSH"))
1807 if (strEQ(name, "TCIOFF"))
1813 if (strEQ(name, "TCIOFLUSH"))
1819 if (strEQ(name, "TCION"))
1825 if (strEQ(name, "TCOFLUSH"))
1831 if (strEQ(name, "TCOOFF"))
1837 if (strEQ(name, "TCOON"))
1843 if (strEQ(name, "TCSADRAIN"))
1849 if (strEQ(name, "TCSAFLUSH"))
1855 if (strEQ(name, "TCSANOW"))
1861 if (strEQ(name, "TMP_MAX"))
1867 if (strEQ(name, "TOSTOP"))
1873 if (strEQ(name, "TZNAME_MAX"))
1881 if (strEQ(name, "UCHAR_MAX"))
1887 if (strEQ(name, "UINT_MAX"))
1893 if (strEQ(name, "ULONG_MAX"))
1899 if (strEQ(name, "USHRT_MAX"))
1907 if (strEQ(name, "VEOF"))
1913 if (strEQ(name, "VEOL"))
1919 if (strEQ(name, "VERASE"))
1925 if (strEQ(name, "VINTR"))
1931 if (strEQ(name, "VKILL"))
1937 if (strEQ(name, "VMIN"))
1943 if (strEQ(name, "VQUIT"))
1949 if (strEQ(name, "VSTART"))
1955 if (strEQ(name, "VSTOP"))
1961 if (strEQ(name, "VSUSP"))
1967 if (strEQ(name, "VTIME"))
1975 if (strEQ(name, "W_OK"))
1981 if (strEQ(name, "WNOHANG"))
1987 if (strEQ(name, "WUNTRACED"))
1993 errno = EAGAIN; /* the following aren't constants */
1995 if (strEQ(name, "WEXITSTATUS")) return WEXITSTATUS(arg);
1998 if (strEQ(name, "WIFEXITED")) return WIFEXITED(arg);
2001 if (strEQ(name, "WIFSIGNALED")) return WIFSIGNALED(arg);
2004 if (strEQ(name, "WIFSTOPPED")) return WIFSTOPPED(arg);
2007 if (strEQ(name, "WSTOPSIG")) return WSTOPSIG(arg);
2010 if (strEQ(name, "WTERMSIG")) return WTERMSIG(arg);
2014 if (strEQ(name, "X_OK"))
2022 if (strnEQ(name, "_PC_", 4)) {
2023 if (strEQ(name, "_PC_CHOWN_RESTRICTED"))
2024 #ifdef _PC_CHOWN_RESTRICTED
2025 return _PC_CHOWN_RESTRICTED;
2029 if (strEQ(name, "_PC_LINK_MAX"))
2031 return _PC_LINK_MAX;
2035 if (strEQ(name, "_PC_MAX_CANON"))
2036 #ifdef _PC_MAX_CANON
2037 return _PC_MAX_CANON;
2041 if (strEQ(name, "_PC_MAX_INPUT"))
2042 #ifdef _PC_MAX_INPUT
2043 return _PC_MAX_INPUT;
2047 if (strEQ(name, "_PC_NAME_MAX"))
2049 return _PC_NAME_MAX;
2053 if (strEQ(name, "_PC_NO_TRUNC"))
2055 return _PC_NO_TRUNC;
2059 if (strEQ(name, "_PC_PATH_MAX"))
2061 return _PC_PATH_MAX;
2065 if (strEQ(name, "_PC_PIPE_BUF"))
2067 return _PC_PIPE_BUF;
2071 if (strEQ(name, "_PC_VDISABLE"))
2073 return _PC_VDISABLE;
2079 if (strnEQ(name, "_POSIX_", 7)) {
2080 if (strEQ(name, "_POSIX_ARG_MAX"))
2081 #ifdef _POSIX_ARG_MAX
2082 return _POSIX_ARG_MAX;
2086 if (strEQ(name, "_POSIX_CHILD_MAX"))
2087 #ifdef _POSIX_CHILD_MAX
2088 return _POSIX_CHILD_MAX;
2092 if (strEQ(name, "_POSIX_CHOWN_RESTRICTED"))
2093 #ifdef _POSIX_CHOWN_RESTRICTED
2094 return _POSIX_CHOWN_RESTRICTED;
2098 if (strEQ(name, "_POSIX_JOB_CONTROL"))
2099 #ifdef _POSIX_JOB_CONTROL
2100 return _POSIX_JOB_CONTROL;
2104 if (strEQ(name, "_POSIX_LINK_MAX"))
2105 #ifdef _POSIX_LINK_MAX
2106 return _POSIX_LINK_MAX;
2110 if (strEQ(name, "_POSIX_MAX_CANON"))
2111 #ifdef _POSIX_MAX_CANON
2112 return _POSIX_MAX_CANON;
2116 if (strEQ(name, "_POSIX_MAX_INPUT"))
2117 #ifdef _POSIX_MAX_INPUT
2118 return _POSIX_MAX_INPUT;
2122 if (strEQ(name, "_POSIX_NAME_MAX"))
2123 #ifdef _POSIX_NAME_MAX
2124 return _POSIX_NAME_MAX;
2128 if (strEQ(name, "_POSIX_NGROUPS_MAX"))
2129 #ifdef _POSIX_NGROUPS_MAX
2130 return _POSIX_NGROUPS_MAX;
2134 if (strEQ(name, "_POSIX_NO_TRUNC"))
2135 #ifdef _POSIX_NO_TRUNC
2136 return _POSIX_NO_TRUNC;
2140 if (strEQ(name, "_POSIX_OPEN_MAX"))
2141 #ifdef _POSIX_OPEN_MAX
2142 return _POSIX_OPEN_MAX;
2146 if (strEQ(name, "_POSIX_PATH_MAX"))
2147 #ifdef _POSIX_PATH_MAX
2148 return _POSIX_PATH_MAX;
2152 if (strEQ(name, "_POSIX_PIPE_BUF"))
2153 #ifdef _POSIX_PIPE_BUF
2154 return _POSIX_PIPE_BUF;
2158 if (strEQ(name, "_POSIX_SAVED_IDS"))
2159 #ifdef _POSIX_SAVED_IDS
2160 return _POSIX_SAVED_IDS;
2164 if (strEQ(name, "_POSIX_SSIZE_MAX"))
2165 #ifdef _POSIX_SSIZE_MAX
2166 return _POSIX_SSIZE_MAX;
2170 if (strEQ(name, "_POSIX_STREAM_MAX"))
2171 #ifdef _POSIX_STREAM_MAX
2172 return _POSIX_STREAM_MAX;
2176 if (strEQ(name, "_POSIX_TZNAME_MAX"))
2177 #ifdef _POSIX_TZNAME_MAX
2178 return _POSIX_TZNAME_MAX;
2182 if (strEQ(name, "_POSIX_VDISABLE"))
2183 #ifdef _POSIX_VDISABLE
2184 return _POSIX_VDISABLE;
2188 if (strEQ(name, "_POSIX_VERSION"))
2189 #ifdef _POSIX_VERSION
2190 return _POSIX_VERSION;
2196 if (strnEQ(name, "_SC_", 4)) {
2197 if (strEQ(name, "_SC_ARG_MAX"))
2203 if (strEQ(name, "_SC_CHILD_MAX"))
2204 #ifdef _SC_CHILD_MAX
2205 return _SC_CHILD_MAX;
2209 if (strEQ(name, "_SC_CLK_TCK"))
2215 if (strEQ(name, "_SC_JOB_CONTROL"))
2216 #ifdef _SC_JOB_CONTROL
2217 return _SC_JOB_CONTROL;
2221 if (strEQ(name, "_SC_NGROUPS_MAX"))
2222 #ifdef _SC_NGROUPS_MAX
2223 return _SC_NGROUPS_MAX;
2227 if (strEQ(name, "_SC_OPEN_MAX"))
2229 return _SC_OPEN_MAX;
2233 if (strEQ(name, "_SC_SAVED_IDS"))
2234 #ifdef _SC_SAVED_IDS
2235 return _SC_SAVED_IDS;
2239 if (strEQ(name, "_SC_STREAM_MAX"))
2240 #ifdef _SC_STREAM_MAX
2241 return _SC_STREAM_MAX;
2245 if (strEQ(name, "_SC_TZNAME_MAX"))
2246 #ifdef _SC_TZNAME_MAX
2247 return _SC_TZNAME_MAX;
2251 if (strEQ(name, "_SC_VERSION"))
2268 MODULE = SigSet PACKAGE = POSIX::SigSet PREFIX = sig
2271 new(packname = "POSIX::SigSet", ...)
2276 RETVAL = (sigset_t*)safemalloc(sizeof(sigset_t));
2277 sigemptyset(RETVAL);
2278 for (i = 1; i < items; i++)
2279 sigaddset(RETVAL, SvIV(ST(i)));
2286 POSIX::SigSet sigset
2288 safefree((char *)sigset);
2291 sigaddset(sigset, sig)
2292 POSIX::SigSet sigset
2296 sigdelset(sigset, sig)
2297 POSIX::SigSet sigset
2302 POSIX::SigSet sigset
2306 POSIX::SigSet sigset
2309 sigismember(sigset, sig)
2310 POSIX::SigSet sigset
2314 MODULE = Termios PACKAGE = POSIX::Termios PREFIX = cf
2317 new(packname = "POSIX::Termios", ...)
2322 RETVAL = (struct termios*)safemalloc(sizeof(struct termios));
2324 not_here("termios");
2331 DESTROY(termios_ref)
2332 POSIX::Termios termios_ref
2335 safefree((char *)termios_ref);
2337 not_here("termios");
2341 getattr(termios_ref, fd = 0)
2342 POSIX::Termios termios_ref
2345 RETVAL = tcgetattr(fd, termios_ref);
2350 setattr(termios_ref, fd = 0, optional_actions = 0)
2351 POSIX::Termios termios_ref
2353 int optional_actions
2355 RETVAL = tcsetattr(fd, optional_actions, termios_ref);
2360 cfgetispeed(termios_ref)
2361 POSIX::Termios termios_ref
2364 cfgetospeed(termios_ref)
2365 POSIX::Termios termios_ref
2368 getiflag(termios_ref)
2369 POSIX::Termios termios_ref
2371 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2372 RETVAL = termios_ref->c_iflag;
2374 not_here("getiflag");
2380 getoflag(termios_ref)
2381 POSIX::Termios termios_ref
2383 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2384 RETVAL = termios_ref->c_oflag;
2386 not_here("getoflag");
2392 getcflag(termios_ref)
2393 POSIX::Termios termios_ref
2395 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2396 RETVAL = termios_ref->c_cflag;
2398 not_here("getcflag");
2404 getlflag(termios_ref)
2405 POSIX::Termios termios_ref
2407 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2408 RETVAL = termios_ref->c_lflag;
2410 not_here("getlflag");
2416 getcc(termios_ref, ccix)
2417 POSIX::Termios termios_ref
2420 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2422 croak("Bad getcc subscript");
2423 RETVAL = termios_ref->c_cc[ccix];
2431 cfsetispeed(termios_ref, speed)
2432 POSIX::Termios termios_ref
2436 cfsetospeed(termios_ref, speed)
2437 POSIX::Termios termios_ref
2441 setiflag(termios_ref, iflag)
2442 POSIX::Termios termios_ref
2445 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2446 termios_ref->c_iflag = iflag;
2448 not_here("setiflag");
2452 setoflag(termios_ref, oflag)
2453 POSIX::Termios termios_ref
2456 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2457 termios_ref->c_oflag = oflag;
2459 not_here("setoflag");
2463 setcflag(termios_ref, cflag)
2464 POSIX::Termios termios_ref
2467 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2468 termios_ref->c_cflag = cflag;
2470 not_here("setcflag");
2474 setlflag(termios_ref, lflag)
2475 POSIX::Termios termios_ref
2478 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2479 termios_ref->c_lflag = lflag;
2481 not_here("setlflag");
2485 setcc(termios_ref, ccix, cc)
2486 POSIX::Termios termios_ref
2490 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2492 croak("Bad setcc subscript");
2493 termios_ref->c_cc[ccix] = cc;
2499 MODULE = POSIX PACKAGE = POSIX
2512 for (s = charstring; *s && RETVAL; s++)
2524 for (s = charstring; *s && RETVAL; s++)
2536 for (s = charstring; *s && RETVAL; s++)
2548 for (s = charstring; *s && RETVAL; s++)
2560 for (s = charstring; *s && RETVAL; s++)
2572 for (s = charstring; *s && RETVAL; s++)
2584 for (s = charstring; *s && RETVAL; s++)
2596 for (s = charstring; *s && RETVAL; s++)
2608 for (s = charstring; *s && RETVAL; s++)
2620 for (s = charstring; *s && RETVAL; s++)
2627 isxdigit(charstring)
2632 for (s = charstring; *s && RETVAL; s++)
2639 open(filename, flags = O_RDONLY, mode = 0666)
2644 if (flags & (O_APPEND|O_CREAT|O_TRUNC|O_RDWR|O_WRONLY|O_EXCL))
2645 TAINT_PROPER("open");
2646 RETVAL = open(filename, flags, mode);
2654 #ifdef HAS_LOCALECONV
2655 struct lconv *lcbuf;
2657 if (lcbuf = localeconv()) {
2659 if (lcbuf->decimal_point && *lcbuf->decimal_point)
2660 hv_store(RETVAL, "decimal_point", 13,
2661 newSVpv(lcbuf->decimal_point, 0), 0);
2662 if (lcbuf->thousands_sep && *lcbuf->thousands_sep)
2663 hv_store(RETVAL, "thousands_sep", 13,
2664 newSVpv(lcbuf->thousands_sep, 0), 0);
2665 if (lcbuf->grouping && *lcbuf->grouping)
2666 hv_store(RETVAL, "grouping", 8,
2667 newSVpv(lcbuf->grouping, 0), 0);
2668 if (lcbuf->int_curr_symbol && *lcbuf->int_curr_symbol)
2669 hv_store(RETVAL, "int_curr_symbol", 15,
2670 newSVpv(lcbuf->int_curr_symbol, 0), 0);
2671 if (lcbuf->currency_symbol && *lcbuf->currency_symbol)
2672 hv_store(RETVAL, "currency_symbol", 15,
2673 newSVpv(lcbuf->currency_symbol, 0), 0);
2674 if (lcbuf->mon_decimal_point && *lcbuf->mon_decimal_point)
2675 hv_store(RETVAL, "mon_decimal_point", 17,
2676 newSVpv(lcbuf->mon_decimal_point, 0), 0);
2677 if (lcbuf->mon_thousands_sep && *lcbuf->mon_thousands_sep)
2678 hv_store(RETVAL, "mon_thousands_sep", 17,
2679 newSVpv(lcbuf->mon_thousands_sep, 0), 0);
2680 if (lcbuf->mon_grouping && *lcbuf->mon_grouping)
2681 hv_store(RETVAL, "mon_grouping", 12,
2682 newSVpv(lcbuf->mon_grouping, 0), 0);
2683 if (lcbuf->positive_sign && *lcbuf->positive_sign)
2684 hv_store(RETVAL, "positive_sign", 13,
2685 newSVpv(lcbuf->positive_sign, 0), 0);
2686 if (lcbuf->negative_sign && *lcbuf->negative_sign)
2687 hv_store(RETVAL, "negative_sign", 13,
2688 newSVpv(lcbuf->negative_sign, 0), 0);
2690 if (lcbuf->int_frac_digits != CHAR_MAX)
2691 hv_store(RETVAL, "int_frac_digits", 15,
2692 newSViv(lcbuf->int_frac_digits), 0);
2693 if (lcbuf->frac_digits != CHAR_MAX)
2694 hv_store(RETVAL, "frac_digits", 11,
2695 newSViv(lcbuf->frac_digits), 0);
2696 if (lcbuf->p_cs_precedes != CHAR_MAX)
2697 hv_store(RETVAL, "p_cs_precedes", 13,
2698 newSViv(lcbuf->p_cs_precedes), 0);
2699 if (lcbuf->p_sep_by_space != CHAR_MAX)
2700 hv_store(RETVAL, "p_sep_by_space", 14,
2701 newSViv(lcbuf->p_sep_by_space), 0);
2702 if (lcbuf->n_cs_precedes != CHAR_MAX)
2703 hv_store(RETVAL, "n_cs_precedes", 13,
2704 newSViv(lcbuf->n_cs_precedes), 0);
2705 if (lcbuf->n_sep_by_space != CHAR_MAX)
2706 hv_store(RETVAL, "n_sep_by_space", 14,
2707 newSViv(lcbuf->n_sep_by_space), 0);
2708 if (lcbuf->p_sign_posn != CHAR_MAX)
2709 hv_store(RETVAL, "p_sign_posn", 11,
2710 newSViv(lcbuf->p_sign_posn), 0);
2711 if (lcbuf->n_sign_posn != CHAR_MAX)
2712 hv_store(RETVAL, "n_sign_posn", 11,
2713 newSViv(lcbuf->n_sign_posn), 0);
2716 localeconv(); /* A stub to call not_here(). */
2722 setlocale(category, locale)
2760 /* (We already know stack is long enough.) */
2761 PUSHs(sv_2mortal(newSVnv(frexp(x,&expvar))));
2762 PUSHs(sv_2mortal(newSViv(expvar)));
2778 /* (We already know stack is long enough.) */
2779 PUSHs(sv_2mortal(newSVnv(modf(x,&intvar))));
2780 PUSHs(sv_2mortal(newSVnv(intvar)));
2795 sigaction(sig, action, oldaction = 0)
2797 POSIX::SigAction action
2798 POSIX::SigAction oldaction
2801 # This code is really grody because we're trying to make the signal
2802 # interface look beautiful, which is hard.
2805 gv_fetchpv("SIG", TRUE, SVt_PVHV);
2808 struct sigaction act;
2809 struct sigaction oact;
2810 POSIX__SigSet sigset;
2812 SV** sigsvp = hv_fetch(GvHVn(siggv),
2814 strlen(sig_name[sig]),
2817 /* Remember old handler name if desired. */
2819 char *hand = SvPVx(*sigsvp, na);
2820 svp = hv_fetch(oldaction, "HANDLER", 7, TRUE);
2821 sv_setpv(*svp, *hand ? hand : "DEFAULT");
2825 /* Vector new handler through %SIG. (We always use sighandler
2826 for the C signal handler, which reads %SIG to dispatch.) */
2827 svp = hv_fetch(action, "HANDLER", 7, FALSE);
2829 croak("Can't supply an action without a HANDLER");
2830 sv_setpv(*sigsvp, SvPV(*svp, na));
2831 mg_set(*sigsvp); /* handles DEFAULT and IGNORE */
2832 act.sa_handler = sighandler;
2834 /* Set up any desired mask. */
2835 svp = hv_fetch(action, "MASK", 4, FALSE);
2836 if (svp && sv_isa(*svp, "POSIX::SigSet")) {
2838 tmp = (unsigned long)SvNV((SV*)SvRV(*svp));
2839 sigset = (sigset_t*) tmp;
2840 act.sa_mask = *sigset;
2843 sigemptyset(& act.sa_mask);
2845 /* Set up any desired flags. */
2846 svp = hv_fetch(action, "FLAGS", 5, FALSE);
2847 act.sa_flags = svp ? SvIV(*svp) : 0;
2850 /* Now work around sigaction oddities */
2851 if (action && oldaction)
2852 RETVAL = sigaction(sig, & act, & oact);
2854 RETVAL = sigaction(sig, & act, (struct sigaction *)0);
2856 RETVAL = sigaction(sig, (struct sigaction *)0, & oact);
2861 /* Get back the mask. */
2862 svp = hv_fetch(oldaction, "MASK", 4, TRUE);
2863 if (sv_isa(*svp, "POSIX::SigSet")) {
2865 tmp = (unsigned long)SvNV((SV*)SvRV(*svp));
2866 sigset = (sigset_t*) tmp;
2869 sigset = (sigset_t*)safemalloc(sizeof(sigset_t));
2870 sv_setptrobj(*svp, sigset, "POSIX::SigSet");
2872 *sigset = oact.sa_mask;
2874 /* Get back the flags. */
2875 svp = hv_fetch(oldaction, "FLAGS", 5, TRUE);
2876 sv_setiv(*svp, oact.sa_flags);
2884 POSIX::SigSet sigset
2887 sigprocmask(how, sigset, oldsigset = 0)
2889 POSIX::SigSet sigset
2890 POSIX::SigSet oldsigset
2893 sigsuspend(signal_mask)
2894 POSIX::SigSet signal_mask
2914 lseek(fd, offset, whence)
2927 if (pipe(fds) != -1) {
2929 PUSHs(sv_2mortal(newSViv(fds[0])));
2930 PUSHs(sv_2mortal(newSViv(fds[1])));
2934 read(fd, buffer, nbytes)
2936 SV *sv_buffer = SvROK(ST(1)) ? SvRV(ST(1)) : ST(1);
2940 char * buffer = sv_grow( sv_buffer, nbytes+1 );
2943 SvCUR(sv_buffer) = RETVAL;
2944 SvPOK_only(sv_buffer);
2945 *SvEND(sv_buffer) = '\0';
2947 sv_magic(sv_buffer, 0, 't', 0, 0);
2963 tcsetpgrp(fd, pgrp_id)
2972 if (uname(&buf) >= 0) {
2974 PUSHs(sv_2mortal(newSVpv(buf.sysname, 0)));
2975 PUSHs(sv_2mortal(newSVpv(buf.nodename, 0)));
2976 PUSHs(sv_2mortal(newSVpv(buf.release, 0)));
2977 PUSHs(sv_2mortal(newSVpv(buf.version, 0)));
2978 PUSHs(sv_2mortal(newSVpv(buf.machine, 0)));
2981 uname((char *) 0); /* A stub to call not_here(). */
2985 write(fd, buffer, nbytes)
3003 mbstowcs(s, pwcs, n)
3015 wcstombs(s, pwcs, n)
3037 char *p = SvPV(src,srclen);
3039 ST(0) = sv_2mortal(NEWSV(800,srclen));
3040 dstlen = strxfrm(SvPVX(ST(0)), p, (size_t)srclen);
3041 if (dstlen > srclen) {
3043 SvGROW(ST(0), dstlen);
3044 strxfrm(SvPVX(ST(0)), p, (size_t)dstlen);
3047 SvCUR(ST(0)) = dstlen;
3052 mkfifo(filename, mode)
3056 TAINT_PROPER("mkfifo");
3057 RETVAL = mkfifo(filename, mode);
3073 tcflush(fd, queue_selector)
3078 tcsendbreak(fd, duration)
3083 asctime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3096 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3099 mytm.tm_hour = hour;
3100 mytm.tm_mday = mday;
3102 mytm.tm_year = year;
3103 mytm.tm_wday = wday;
3104 mytm.tm_yday = yday;
3105 mytm.tm_isdst = isdst;
3106 RETVAL = asctime(&mytm);
3123 realtime = times( &tms );
3125 PUSHs( sv_2mortal( newSVnv( realtime ) ) );
3126 PUSHs( sv_2mortal( newSVnv( tms.tms_utime ) ) );
3127 PUSHs( sv_2mortal( newSVnv( tms.tms_stime ) ) );
3128 PUSHs( sv_2mortal( newSVnv( tms.tms_cutime ) ) );
3129 PUSHs( sv_2mortal( newSVnv( tms.tms_cstime ) ) );
3132 difftime(time1, time2)
3137 mktime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3150 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3153 mytm.tm_hour = hour;
3154 mytm.tm_mday = mday;
3156 mytm.tm_year = year;
3157 mytm.tm_wday = wday;
3158 mytm.tm_yday = yday;
3159 mytm.tm_isdst = isdst;
3160 RETVAL = mktime(&mytm);
3166 strftime(fmt, sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3182 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3185 mytm.tm_hour = hour;
3186 mytm.tm_mday = mday;
3188 mytm.tm_year = year;
3189 mytm.tm_wday = wday;
3190 mytm.tm_yday = yday;
3191 mytm.tm_isdst = isdst;
3192 len = strftime(tmpbuf, sizeof tmpbuf, fmt, &mytm);
3193 ST(0) = sv_2mortal(newSVpv(tmpbuf, len));
3203 PUSHs(sv_2mortal(newSVpv(tzname[0],strlen(tzname[0]))));
3204 PUSHs(sv_2mortal(newSVpv(tzname[1],strlen(tzname[1]))));
3207 access(filename, mode)
3225 pathconf(filename, name)