5 #ifdef I_DIRENT /* XXX maybe better to just rely on perl.h? */
28 /* XXX This comment is just to make I_TERMIO and I_SGTTY visible to
29 metaconfig for future extension writers. We don't use them in POSIX.
30 (This is really sneaky :-) --AD
32 #if defined(I_TERMIOS)
41 #include <sys/types.h>
44 #if defined(__VMS) && !defined(__POSIX_SOURCE)
45 # include <file.h> /* == fcntl.h for DECC; no fcntl.h for VAXC */
46 # include <libdef.h> /* LIB$_INVARG constant */
47 # include <lib$routines.h> /* prototype for lib$ediv() */
48 # include <starlet.h> /* prototype for sys$gettim() */
50 # undef mkfifo /* #defined in perl.h */
51 # define mkfifo(a,b) (not_here("mkfifo"),-1)
52 # define tzset() not_here("tzset")
54 /* The default VMS emulation of Unix signals isn't very POSIXish */
56 # define sigpending(a) (not_here("sigpending"),0)
58 /* sigset_t is atomic under VMS, so these routines are easy */
59 int sigemptyset(sigset_t *set) {
60 if (!set) { SETERRNO(EFAULT,SS$_ACCVIO); return -1; }
63 int sigfillset(sigset_t *set) {
65 if (!set) { SETERRNO(EFAULT,SS$_ACCVIO); return -1; }
66 for (i = 0; i < NSIG; i++) *set |= (1 << i);
69 int sigaddset(sigset_t *set, int sig) {
70 if (!set) { SETERRNO(EFAULT,SS$_ACCVIO); return -1; }
71 if (sig > NSIG) { SETERRNO(EINVAL,LIB$_INVARG); return -1; }
72 *set |= (1 << (sig - 1));
75 int sigdelset(sigset_t *set, int sig) {
76 if (!set) { SETERRNO(EFAULT,SS$_ACCVIO); return -1; }
77 if (sig > NSIG) { SETERRNO(EINVAL,LIB$_INVARG); return -1; }
78 *set &= ~(1 << (sig - 1));
81 int sigismember(sigset_t *set, int sig) {
82 if (!set) { SETERRNO(EFAULT,SS$_ACCVIO); return -1; }
83 if (sig > NSIG) { SETERRNO(EINVAL,LIB$_INVARG); return -1; }
84 *set & (1 << (sig - 1));
86 /* The tools for sigprocmask() are there, just not the routine itself */
88 # define SIG_UNBLOCK 1
94 # define SIG_SETMASK 3
96 int sigprocmask(int how, sigset_t *set, sigset_t *oset) {
98 set_errno(EFAULT); set_vaxc_errno(SS$_ACCVIO);
103 *oset = sigsetmask(*set);
106 *oset = sigblock(*set);
110 sigsetmask(*oset & ~*set);
113 set_errno(EINVAL); set_vaxc_errno(LIB$_INVARG);
118 # define sigaction sigvec
119 # define sa_flags sv_onstack
120 # define sa_handler sv_handler
121 # define sa_mask sv_mask
122 # define sigsuspend(set) sigpause(*set)
124 /* The POSIX notion of ttyname() is better served by getname() under VMS */
125 static char ttnambuf[64];
126 # define ttyname(fd) (isatty(fd) > 0 ? getname(fd,ttnambuf,0) : NULL)
128 /* The non-POSIX CRTL times() has void return type, so we just get the
129 current time directly */
130 clock_t vms_times(struct tms *bufptr) {
132 /* Get wall time and convert to 10 ms intervals to
133 * produce the return value that the POSIX standard expects */
134 # if defined(__DECC) && defined (__ALPHA)
137 _ckvmssts(sys$gettim(&vmstime));
139 retval = vmstime & 0x7fffffff;
141 /* (Older hw or ccs don't have an atomic 64-bit type, so we
142 * juggle 32-bit ints (and a float) to produce a time_t result
143 * with minimal loss of information.) */
144 long int vmstime[2],remainder,divisor = 100000;
145 _ckvmssts(sys$gettim((unsigned long int *)vmstime));
146 vmstime[1] &= 0x7fff; /* prevent overflow in EDIV */
147 _ckvmssts(lib$ediv(&divisor,vmstime,(long int *)&retval,&remainder));
149 /* Fill in the struct tms using the CRTL routine . . .*/
150 times((tbuffer_t *)bufptr);
151 return (clock_t) retval;
153 # define times(t) vms_times(t)
157 # include <sys/times.h>
159 # include <sys/utsname.h>
161 # include <sys/wait.h>
168 typedef long SysRetLong;
169 typedef sigset_t* POSIX__SigSet;
170 typedef HV* POSIX__SigAction;
172 typedef struct termios* POSIX__Termios;
173 #else /* Define termios types to int, and call not_here for the functions.*/
174 #define POSIX__Termios int
178 #define cfgetispeed(x) not_here("cfgetispeed")
179 #define cfgetospeed(x) not_here("cfgetospeed")
180 #define tcdrain(x) not_here("tcdrain")
181 #define tcflush(x,y) not_here("tcflush")
182 #define tcsendbreak(x,y) not_here("tcsendbreak")
183 #define cfsetispeed(x,y) not_here("cfsetispeed")
184 #define cfsetospeed(x,y) not_here("cfsetospeed")
185 #define ctermid(x) (char *) not_here("ctermid")
186 #define tcflow(x,y) not_here("tcflow")
187 #define tcgetattr(x,y) not_here("tcgetattr")
188 #define tcsetattr(x,y,z) not_here("tcsetattr")
191 /* Possibly needed prototypes */
192 char *cuserid _((char *));
195 #define cuserid(a) (char *) not_here("cuserid")
199 #define difftime(a,b) not_here("difftime")
202 #ifndef HAS_FPATHCONF
203 #define fpathconf(f,n) (SysRetLong) not_here("fpathconf")
206 #define mktime(a) not_here("mktime")
209 #define nice(a) not_here("nice")
212 #define pathconf(f,n) (SysRetLong) not_here("pathconf")
215 #define sysconf(n) (SysRetLong) not_here("sysconf")
218 #define readlink(a,b,c) not_here("readlink")
221 #define setpgid(a,b) not_here("setpgid")
224 #define setsid() not_here("setsid")
227 #define strcoll(s1,s2) not_here("strcoll")
230 #define strxfrm(s1,s2,n) not_here("strxfrm")
232 #ifndef HAS_TCGETPGRP
233 #define tcgetpgrp(a) not_here("tcgetpgrp")
235 #ifndef HAS_TCSETPGRP
236 #define tcsetpgrp(a,b) not_here("tcsetpgrp")
239 #define times(a) not_here("times")
242 #define uname(a) not_here("uname")
245 #define waitpid(a,b,c) not_here("waitpid")
249 #define fgetpos(a,b) not_here("fgetpos")
252 #define fsetpos(a,b) not_here("fsetpos")
257 #define mblen(a,b) not_here("mblen")
261 #define mbstowcs(s, pwcs, n) not_here("mbstowcs")
264 #define mbtowc(pwc, s, n) not_here("mbtowc")
267 #define wcstombs(s, pwcs, n) not_here("wcstombs")
270 #define wctomb(s, wchar) not_here("wcstombs")
272 #if !defined(HAS_MBLEN) && !defined(HAS_MBSTOWCS) && !defined(HAS_MBTOWC) && !defined(HAS_WCSTOMBS) && !defined(HAS_WCTOMB)
273 /* If we don't have these functions, then we wouldn't have gotten a typedef
274 for wchar_t, the wide character type. Defining wchar_t allows the
275 functions referencing it to compile. Its actual type is then meaningless,
276 since without the above functions, all sections using it end up calling
277 not_here() and croak. --Kaveh Ghazi (ghazi@noc.rutgers.edu) 9/18/94. */
283 #ifndef HAS_LOCALECONV
284 #define localeconv() not_here("localeconv")
288 extern char *tzname[];
290 char *tzname[] = { "" , "" };
293 /* XXX struct tm on some systems (SunOS4/BSD) contains extra (non POSIX)
294 * fields for which we don't have Configure support yet:
295 * char *tm_zone; -- abbreviation of timezone name
296 * long tm_gmtoff; -- offset from GMT in seconds
297 * To workaround core dumps from the uninitialised tm_zone we get the
298 * system to give us a reasonable struct to copy. This fix means that
299 * strftime uses the tm_zone and tm_gmtoff values returned by
300 * localtime(time()). That should give the desired result most of the
301 * time. But probably not always!
303 * This is a temporary workaround to be removed once Configure
304 * support is added and NETaa14816 is considered in full.
305 * It does not address tzname aspects of NETaa14816.
307 #ifdef STRUCT_TM_HASZONE
309 init_tm(ptm) /* see mktime, strftime and asctime */
314 Copy(localtime(&now), ptm, 1, struct tm);
318 # define init_tm(ptm)
322 #ifndef HAS_LONG_DOUBLE /* XXX What to do about long doubles? */
338 croak("POSIX::%s not implemented on this architecture", s);
350 if (strEQ(name, "ARG_MAX"))
358 if (strEQ(name, "BUFSIZ"))
364 if (strEQ(name, "BRKINT"))
370 if (strEQ(name, "B9600"))
376 if (strEQ(name, "B19200"))
382 if (strEQ(name, "B38400"))
388 if (strEQ(name, "B0"))
394 if (strEQ(name, "B110"))
400 if (strEQ(name, "B1200"))
406 if (strEQ(name, "B134"))
412 if (strEQ(name, "B150"))
418 if (strEQ(name, "B1800"))
424 if (strEQ(name, "B200"))
430 if (strEQ(name, "B2400"))
436 if (strEQ(name, "B300"))
442 if (strEQ(name, "B4800"))
448 if (strEQ(name, "B50"))
454 if (strEQ(name, "B600"))
460 if (strEQ(name, "B75"))
468 if (strEQ(name, "CHAR_BIT"))
474 if (strEQ(name, "CHAR_MAX"))
480 if (strEQ(name, "CHAR_MIN"))
486 if (strEQ(name, "CHILD_MAX"))
492 if (strEQ(name, "CLK_TCK"))
498 if (strEQ(name, "CLOCAL"))
504 if (strEQ(name, "CLOCKS_PER_SEC"))
505 #ifdef CLOCKS_PER_SEC
506 return CLOCKS_PER_SEC;
510 if (strEQ(name, "CREAD"))
516 if (strEQ(name, "CS5"))
522 if (strEQ(name, "CS6"))
528 if (strEQ(name, "CS7"))
534 if (strEQ(name, "CS8"))
540 if (strEQ(name, "CSIZE"))
546 if (strEQ(name, "CSTOPB"))
554 if (strEQ(name, "DBL_MAX"))
560 if (strEQ(name, "DBL_MIN"))
566 if (strEQ(name, "DBL_DIG"))
572 if (strEQ(name, "DBL_EPSILON"))
578 if (strEQ(name, "DBL_MANT_DIG"))
584 if (strEQ(name, "DBL_MAX_10_EXP"))
585 #ifdef DBL_MAX_10_EXP
586 return DBL_MAX_10_EXP;
590 if (strEQ(name, "DBL_MAX_EXP"))
596 if (strEQ(name, "DBL_MIN_10_EXP"))
597 #ifdef DBL_MIN_10_EXP
598 return DBL_MIN_10_EXP;
602 if (strEQ(name, "DBL_MIN_EXP"))
612 if (strEQ(name, "EACCES"))
618 if (strEQ(name, "EAGAIN"))
626 if (strEQ(name, "EBADF"))
632 if (strEQ(name, "EBUSY"))
640 if (strEQ(name, "ECHILD"))
646 if (strEQ(name, "ECHO"))
652 if (strEQ(name, "ECHOE"))
658 if (strEQ(name, "ECHOK"))
664 if (strEQ(name, "ECHONL"))
672 if (strEQ(name, "EDEADLK"))
678 if (strEQ(name, "EDOM"))
686 if (strEQ(name, "EEXIST"))
694 if (strEQ(name, "EFAULT"))
700 if (strEQ(name, "EFBIG"))
708 if (strEQ(name, "EINTR"))
714 if (strEQ(name, "EINVAL"))
720 if (strEQ(name, "EIO"))
726 if (strEQ(name, "EISDIR"))
734 if (strEQ(name, "EMFILE"))
740 if (strEQ(name, "EMLINK"))
748 if (strEQ(name, "ENOMEM"))
754 if (strEQ(name, "ENOSPC"))
760 if (strEQ(name, "ENOEXEC"))
766 if (strEQ(name, "ENOTTY"))
772 if (strEQ(name, "ENOTDIR"))
778 if (strEQ(name, "ENOTEMPTY"))
784 if (strEQ(name, "ENFILE"))
790 if (strEQ(name, "ENODEV"))
796 if (strEQ(name, "ENOENT"))
802 if (strEQ(name, "ENOLCK"))
808 if (strEQ(name, "ENOSYS"))
814 if (strEQ(name, "ENXIO"))
820 if (strEQ(name, "ENAMETOOLONG"))
828 if (strEQ(name, "EOF"))
836 if (strEQ(name, "EPERM"))
842 if (strEQ(name, "EPIPE"))
850 if (strEQ(name, "ERANGE"))
856 if (strEQ(name, "EROFS"))
864 if (strEQ(name, "ESPIPE"))
870 if (strEQ(name, "ESRCH"))
878 if (strEQ(name, "EXIT_FAILURE"))
884 if (strEQ(name, "EXIT_SUCCESS"))
890 if (strEQ(name, "EXDEV"))
898 if (strEQ(name, "E2BIG"))
906 if (strnEQ(name, "FLT_", 4)) {
907 if (strEQ(name, "FLT_MAX"))
913 if (strEQ(name, "FLT_MIN"))
919 if (strEQ(name, "FLT_ROUNDS"))
925 if (strEQ(name, "FLT_DIG"))
931 if (strEQ(name, "FLT_EPSILON"))
937 if (strEQ(name, "FLT_MANT_DIG"))
943 if (strEQ(name, "FLT_MAX_10_EXP"))
944 #ifdef FLT_MAX_10_EXP
945 return FLT_MAX_10_EXP;
949 if (strEQ(name, "FLT_MAX_EXP"))
955 if (strEQ(name, "FLT_MIN_10_EXP"))
956 #ifdef FLT_MIN_10_EXP
957 return FLT_MIN_10_EXP;
961 if (strEQ(name, "FLT_MIN_EXP"))
967 if (strEQ(name, "FLT_RADIX"))
975 if (strnEQ(name, "F_", 2)) {
976 if (strEQ(name, "F_DUPFD"))
982 if (strEQ(name, "F_GETFD"))
988 if (strEQ(name, "F_GETFL"))
994 if (strEQ(name, "F_GETLK"))
1000 if (strEQ(name, "F_OK"))
1006 if (strEQ(name, "F_RDLCK"))
1012 if (strEQ(name, "F_SETFD"))
1018 if (strEQ(name, "F_SETFL"))
1024 if (strEQ(name, "F_SETLK"))
1030 if (strEQ(name, "F_SETLKW"))
1036 if (strEQ(name, "F_UNLCK"))
1042 if (strEQ(name, "F_WRLCK"))
1050 if (strEQ(name, "FD_CLOEXEC"))
1056 if (strEQ(name, "FILENAME_MAX"))
1058 return FILENAME_MAX;
1064 if (strEQ(name, "HUGE_VAL"))
1070 if (strEQ(name, "HUPCL"))
1078 if (strEQ(name, "INT_MAX"))
1084 if (strEQ(name, "INT_MIN"))
1090 if (strEQ(name, "ICANON"))
1096 if (strEQ(name, "ICRNL"))
1102 if (strEQ(name, "IEXTEN"))
1108 if (strEQ(name, "IGNBRK"))
1114 if (strEQ(name, "IGNCR"))
1120 if (strEQ(name, "IGNPAR"))
1126 if (strEQ(name, "INLCR"))
1132 if (strEQ(name, "INPCK"))
1138 if (strEQ(name, "ISIG"))
1144 if (strEQ(name, "ISTRIP"))
1150 if (strEQ(name, "IXOFF"))
1156 if (strEQ(name, "IXON"))
1164 if (strnEQ(name, "LC_", 3)) {
1165 if (strEQ(name, "LC_ALL"))
1171 if (strEQ(name, "LC_COLLATE"))
1177 if (strEQ(name, "LC_CTYPE"))
1183 if (strEQ(name, "LC_MONETARY"))
1189 if (strEQ(name, "LC_NUMERIC"))
1195 if (strEQ(name, "LC_TIME"))
1203 if (strnEQ(name, "LDBL_", 5)) {
1204 if (strEQ(name, "LDBL_MAX"))
1210 if (strEQ(name, "LDBL_MIN"))
1216 if (strEQ(name, "LDBL_DIG"))
1222 if (strEQ(name, "LDBL_EPSILON"))
1224 return LDBL_EPSILON;
1228 if (strEQ(name, "LDBL_MANT_DIG"))
1229 #ifdef LDBL_MANT_DIG
1230 return LDBL_MANT_DIG;
1234 if (strEQ(name, "LDBL_MAX_10_EXP"))
1235 #ifdef LDBL_MAX_10_EXP
1236 return LDBL_MAX_10_EXP;
1240 if (strEQ(name, "LDBL_MAX_EXP"))
1242 return LDBL_MAX_EXP;
1246 if (strEQ(name, "LDBL_MIN_10_EXP"))
1247 #ifdef LDBL_MIN_10_EXP
1248 return LDBL_MIN_10_EXP;
1252 if (strEQ(name, "LDBL_MIN_EXP"))
1254 return LDBL_MIN_EXP;
1260 if (strnEQ(name, "L_", 2)) {
1261 if (strEQ(name, "L_ctermid"))
1267 if (strEQ(name, "L_cuserid"))
1273 if (strEQ(name, "L_tmpname"))
1281 if (strEQ(name, "LONG_MAX"))
1287 if (strEQ(name, "LONG_MIN"))
1293 if (strEQ(name, "LINK_MAX"))
1301 if (strEQ(name, "MAX_CANON"))
1307 if (strEQ(name, "MAX_INPUT"))
1313 if (strEQ(name, "MB_CUR_MAX"))
1319 if (strEQ(name, "MB_LEN_MAX"))
1327 if (strEQ(name, "NULL")) return 0;
1328 if (strEQ(name, "NAME_MAX"))
1334 if (strEQ(name, "NCCS"))
1340 if (strEQ(name, "NGROUPS_MAX"))
1346 if (strEQ(name, "NOFLSH"))
1354 if (strnEQ(name, "O_", 2)) {
1355 if (strEQ(name, "O_APPEND"))
1361 if (strEQ(name, "O_CREAT"))
1367 if (strEQ(name, "O_TRUNC"))
1373 if (strEQ(name, "O_RDONLY"))
1379 if (strEQ(name, "O_RDWR"))
1385 if (strEQ(name, "O_WRONLY"))
1391 if (strEQ(name, "O_EXCL"))
1397 if (strEQ(name, "O_NOCTTY"))
1403 if (strEQ(name, "O_NONBLOCK"))
1409 if (strEQ(name, "O_ACCMODE"))
1417 if (strEQ(name, "OPEN_MAX"))
1423 if (strEQ(name, "OPOST"))
1431 if (strEQ(name, "PATH_MAX"))
1437 if (strEQ(name, "PARENB"))
1443 if (strEQ(name, "PARMRK"))
1449 if (strEQ(name, "PARODD"))
1455 if (strEQ(name, "PIPE_BUF"))
1463 if (strEQ(name, "RAND_MAX"))
1469 if (strEQ(name, "R_OK"))
1477 if (strnEQ(name, "SIG", 3)) {
1478 if (name[3] == '_') {
1479 if (strEQ(name, "SIG_BLOCK"))
1486 if (strEQ(name, "SIG_DFL")) return (int)SIG_DFL;
1489 if (strEQ(name, "SIG_ERR")) return (int)SIG_ERR;
1492 if (strEQ(name, "SIG_IGN")) return (int)SIG_IGN;
1494 if (strEQ(name, "SIG_SETMASK"))
1500 if (strEQ(name, "SIG_UNBLOCK"))
1508 if (strEQ(name, "SIGABRT"))
1514 if (strEQ(name, "SIGALRM"))
1520 if (strEQ(name, "SIGCHLD"))
1526 if (strEQ(name, "SIGCONT"))
1532 if (strEQ(name, "SIGFPE"))
1538 if (strEQ(name, "SIGHUP"))
1544 if (strEQ(name, "SIGILL"))
1550 if (strEQ(name, "SIGINT"))
1556 if (strEQ(name, "SIGKILL"))
1562 if (strEQ(name, "SIGPIPE"))
1568 if (strEQ(name, "SIGQUIT"))
1574 if (strEQ(name, "SIGSEGV"))
1580 if (strEQ(name, "SIGSTOP"))
1586 if (strEQ(name, "SIGTERM"))
1592 if (strEQ(name, "SIGTSTP"))
1598 if (strEQ(name, "SIGTTIN"))
1604 if (strEQ(name, "SIGTTOU"))
1610 if (strEQ(name, "SIGUSR1"))
1616 if (strEQ(name, "SIGUSR2"))
1624 if (name[1] == '_') {
1625 if (strEQ(name, "S_ISGID"))
1631 if (strEQ(name, "S_ISUID"))
1637 if (strEQ(name, "S_IRGRP"))
1643 if (strEQ(name, "S_IROTH"))
1649 if (strEQ(name, "S_IRUSR"))
1655 if (strEQ(name, "S_IRWXG"))
1661 if (strEQ(name, "S_IRWXO"))
1667 if (strEQ(name, "S_IRWXU"))
1673 if (strEQ(name, "S_IWGRP"))
1679 if (strEQ(name, "S_IWOTH"))
1685 if (strEQ(name, "S_IWUSR"))
1691 if (strEQ(name, "S_IXGRP"))
1697 if (strEQ(name, "S_IXOTH"))
1703 if (strEQ(name, "S_IXUSR"))
1709 errno = EAGAIN; /* the following aren't constants */
1711 if (strEQ(name, "S_ISBLK")) return S_ISBLK(arg);
1714 if (strEQ(name, "S_ISCHR")) return S_ISCHR(arg);
1717 if (strEQ(name, "S_ISDIR")) return S_ISDIR(arg);
1720 if (strEQ(name, "S_ISFIFO")) return S_ISFIFO(arg);
1723 if (strEQ(name, "S_ISREG")) return S_ISREG(arg);
1727 if (strEQ(name, "SEEK_CUR"))
1733 if (strEQ(name, "SEEK_END"))
1739 if (strEQ(name, "SEEK_SET"))
1745 if (strEQ(name, "STREAM_MAX"))
1751 if (strEQ(name, "SHRT_MAX"))
1757 if (strEQ(name, "SHRT_MIN"))
1763 if (strEQ(name, "SA_NOCLDSTOP"))
1765 return SA_NOCLDSTOP;
1769 if (strEQ(name, "SCHAR_MAX"))
1775 if (strEQ(name, "SCHAR_MIN"))
1781 if (strEQ(name, "SSIZE_MAX"))
1787 if (strEQ(name, "STDIN_FILENO"))
1789 return STDIN_FILENO;
1793 if (strEQ(name, "STDOUT_FILENO"))
1794 #ifdef STDOUT_FILENO
1795 return STDOUT_FILENO;
1799 if (strEQ(name, "STRERR_FILENO"))
1800 #ifdef STRERR_FILENO
1801 return STRERR_FILENO;
1807 if (strEQ(name, "TCIFLUSH"))
1813 if (strEQ(name, "TCIOFF"))
1819 if (strEQ(name, "TCIOFLUSH"))
1825 if (strEQ(name, "TCION"))
1831 if (strEQ(name, "TCOFLUSH"))
1837 if (strEQ(name, "TCOOFF"))
1843 if (strEQ(name, "TCOON"))
1849 if (strEQ(name, "TCSADRAIN"))
1855 if (strEQ(name, "TCSAFLUSH"))
1861 if (strEQ(name, "TCSANOW"))
1867 if (strEQ(name, "TMP_MAX"))
1873 if (strEQ(name, "TOSTOP"))
1879 if (strEQ(name, "TZNAME_MAX"))
1887 if (strEQ(name, "UCHAR_MAX"))
1893 if (strEQ(name, "UINT_MAX"))
1899 if (strEQ(name, "ULONG_MAX"))
1905 if (strEQ(name, "USHRT_MAX"))
1913 if (strEQ(name, "VEOF"))
1919 if (strEQ(name, "VEOL"))
1925 if (strEQ(name, "VERASE"))
1931 if (strEQ(name, "VINTR"))
1937 if (strEQ(name, "VKILL"))
1943 if (strEQ(name, "VMIN"))
1949 if (strEQ(name, "VQUIT"))
1955 if (strEQ(name, "VSTART"))
1961 if (strEQ(name, "VSTOP"))
1967 if (strEQ(name, "VSUSP"))
1973 if (strEQ(name, "VTIME"))
1981 if (strEQ(name, "W_OK"))
1987 if (strEQ(name, "WNOHANG"))
1993 if (strEQ(name, "WUNTRACED"))
1999 errno = EAGAIN; /* the following aren't constants */
2001 if (strEQ(name, "WEXITSTATUS")) return WEXITSTATUS(arg);
2004 if (strEQ(name, "WIFEXITED")) return WIFEXITED(arg);
2007 if (strEQ(name, "WIFSIGNALED")) return WIFSIGNALED(arg);
2010 if (strEQ(name, "WIFSTOPPED")) return WIFSTOPPED(arg);
2013 if (strEQ(name, "WSTOPSIG")) return WSTOPSIG(arg);
2016 if (strEQ(name, "WTERMSIG")) return WTERMSIG(arg);
2020 if (strEQ(name, "X_OK"))
2028 if (strnEQ(name, "_PC_", 4)) {
2029 if (strEQ(name, "_PC_CHOWN_RESTRICTED"))
2030 #ifdef _PC_CHOWN_RESTRICTED
2031 return _PC_CHOWN_RESTRICTED;
2035 if (strEQ(name, "_PC_LINK_MAX"))
2037 return _PC_LINK_MAX;
2041 if (strEQ(name, "_PC_MAX_CANON"))
2042 #ifdef _PC_MAX_CANON
2043 return _PC_MAX_CANON;
2047 if (strEQ(name, "_PC_MAX_INPUT"))
2048 #ifdef _PC_MAX_INPUT
2049 return _PC_MAX_INPUT;
2053 if (strEQ(name, "_PC_NAME_MAX"))
2055 return _PC_NAME_MAX;
2059 if (strEQ(name, "_PC_NO_TRUNC"))
2061 return _PC_NO_TRUNC;
2065 if (strEQ(name, "_PC_PATH_MAX"))
2067 return _PC_PATH_MAX;
2071 if (strEQ(name, "_PC_PIPE_BUF"))
2073 return _PC_PIPE_BUF;
2077 if (strEQ(name, "_PC_VDISABLE"))
2079 return _PC_VDISABLE;
2085 if (strnEQ(name, "_POSIX_", 7)) {
2086 if (strEQ(name, "_POSIX_ARG_MAX"))
2087 #ifdef _POSIX_ARG_MAX
2088 return _POSIX_ARG_MAX;
2092 if (strEQ(name, "_POSIX_CHILD_MAX"))
2093 #ifdef _POSIX_CHILD_MAX
2094 return _POSIX_CHILD_MAX;
2098 if (strEQ(name, "_POSIX_CHOWN_RESTRICTED"))
2099 #ifdef _POSIX_CHOWN_RESTRICTED
2100 return _POSIX_CHOWN_RESTRICTED;
2104 if (strEQ(name, "_POSIX_JOB_CONTROL"))
2105 #ifdef _POSIX_JOB_CONTROL
2106 return _POSIX_JOB_CONTROL;
2110 if (strEQ(name, "_POSIX_LINK_MAX"))
2111 #ifdef _POSIX_LINK_MAX
2112 return _POSIX_LINK_MAX;
2116 if (strEQ(name, "_POSIX_MAX_CANON"))
2117 #ifdef _POSIX_MAX_CANON
2118 return _POSIX_MAX_CANON;
2122 if (strEQ(name, "_POSIX_MAX_INPUT"))
2123 #ifdef _POSIX_MAX_INPUT
2124 return _POSIX_MAX_INPUT;
2128 if (strEQ(name, "_POSIX_NAME_MAX"))
2129 #ifdef _POSIX_NAME_MAX
2130 return _POSIX_NAME_MAX;
2134 if (strEQ(name, "_POSIX_NGROUPS_MAX"))
2135 #ifdef _POSIX_NGROUPS_MAX
2136 return _POSIX_NGROUPS_MAX;
2140 if (strEQ(name, "_POSIX_NO_TRUNC"))
2141 #ifdef _POSIX_NO_TRUNC
2142 return _POSIX_NO_TRUNC;
2146 if (strEQ(name, "_POSIX_OPEN_MAX"))
2147 #ifdef _POSIX_OPEN_MAX
2148 return _POSIX_OPEN_MAX;
2152 if (strEQ(name, "_POSIX_PATH_MAX"))
2153 #ifdef _POSIX_PATH_MAX
2154 return _POSIX_PATH_MAX;
2158 if (strEQ(name, "_POSIX_PIPE_BUF"))
2159 #ifdef _POSIX_PIPE_BUF
2160 return _POSIX_PIPE_BUF;
2164 if (strEQ(name, "_POSIX_SAVED_IDS"))
2165 #ifdef _POSIX_SAVED_IDS
2166 return _POSIX_SAVED_IDS;
2170 if (strEQ(name, "_POSIX_SSIZE_MAX"))
2171 #ifdef _POSIX_SSIZE_MAX
2172 return _POSIX_SSIZE_MAX;
2176 if (strEQ(name, "_POSIX_STREAM_MAX"))
2177 #ifdef _POSIX_STREAM_MAX
2178 return _POSIX_STREAM_MAX;
2182 if (strEQ(name, "_POSIX_TZNAME_MAX"))
2183 #ifdef _POSIX_TZNAME_MAX
2184 return _POSIX_TZNAME_MAX;
2188 if (strEQ(name, "_POSIX_VDISABLE"))
2189 #ifdef _POSIX_VDISABLE
2190 return _POSIX_VDISABLE;
2194 if (strEQ(name, "_POSIX_VERSION"))
2195 #ifdef _POSIX_VERSION
2196 return _POSIX_VERSION;
2202 if (strnEQ(name, "_SC_", 4)) {
2203 if (strEQ(name, "_SC_ARG_MAX"))
2209 if (strEQ(name, "_SC_CHILD_MAX"))
2210 #ifdef _SC_CHILD_MAX
2211 return _SC_CHILD_MAX;
2215 if (strEQ(name, "_SC_CLK_TCK"))
2221 if (strEQ(name, "_SC_JOB_CONTROL"))
2222 #ifdef _SC_JOB_CONTROL
2223 return _SC_JOB_CONTROL;
2227 if (strEQ(name, "_SC_NGROUPS_MAX"))
2228 #ifdef _SC_NGROUPS_MAX
2229 return _SC_NGROUPS_MAX;
2233 if (strEQ(name, "_SC_OPEN_MAX"))
2235 return _SC_OPEN_MAX;
2239 if (strEQ(name, "_SC_SAVED_IDS"))
2240 #ifdef _SC_SAVED_IDS
2241 return _SC_SAVED_IDS;
2245 if (strEQ(name, "_SC_STREAM_MAX"))
2246 #ifdef _SC_STREAM_MAX
2247 return _SC_STREAM_MAX;
2251 if (strEQ(name, "_SC_TZNAME_MAX"))
2252 #ifdef _SC_TZNAME_MAX
2253 return _SC_TZNAME_MAX;
2257 if (strEQ(name, "_SC_VERSION"))
2274 MODULE = SigSet PACKAGE = POSIX::SigSet PREFIX = sig
2277 new(packname = "POSIX::SigSet", ...)
2282 RETVAL = (sigset_t*)safemalloc(sizeof(sigset_t));
2283 sigemptyset(RETVAL);
2284 for (i = 1; i < items; i++)
2285 sigaddset(RETVAL, SvIV(ST(i)));
2292 POSIX::SigSet sigset
2294 safefree((char *)sigset);
2297 sigaddset(sigset, sig)
2298 POSIX::SigSet sigset
2302 sigdelset(sigset, sig)
2303 POSIX::SigSet sigset
2308 POSIX::SigSet sigset
2312 POSIX::SigSet sigset
2315 sigismember(sigset, sig)
2316 POSIX::SigSet sigset
2320 MODULE = Termios PACKAGE = POSIX::Termios PREFIX = cf
2323 new(packname = "POSIX::Termios", ...)
2328 RETVAL = (struct termios*)safemalloc(sizeof(struct termios));
2330 not_here("termios");
2337 DESTROY(termios_ref)
2338 POSIX::Termios termios_ref
2341 safefree((char *)termios_ref);
2343 not_here("termios");
2347 getattr(termios_ref, fd = 0)
2348 POSIX::Termios termios_ref
2351 RETVAL = tcgetattr(fd, termios_ref);
2356 setattr(termios_ref, fd = 0, optional_actions = 0)
2357 POSIX::Termios termios_ref
2359 int optional_actions
2361 RETVAL = tcsetattr(fd, optional_actions, termios_ref);
2366 cfgetispeed(termios_ref)
2367 POSIX::Termios termios_ref
2370 cfgetospeed(termios_ref)
2371 POSIX::Termios termios_ref
2374 getiflag(termios_ref)
2375 POSIX::Termios termios_ref
2377 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2378 RETVAL = termios_ref->c_iflag;
2380 not_here("getiflag");
2386 getoflag(termios_ref)
2387 POSIX::Termios termios_ref
2389 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2390 RETVAL = termios_ref->c_oflag;
2392 not_here("getoflag");
2398 getcflag(termios_ref)
2399 POSIX::Termios termios_ref
2401 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2402 RETVAL = termios_ref->c_cflag;
2404 not_here("getcflag");
2410 getlflag(termios_ref)
2411 POSIX::Termios termios_ref
2413 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2414 RETVAL = termios_ref->c_lflag;
2416 not_here("getlflag");
2422 getcc(termios_ref, ccix)
2423 POSIX::Termios termios_ref
2426 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2428 croak("Bad getcc subscript");
2429 RETVAL = termios_ref->c_cc[ccix];
2437 cfsetispeed(termios_ref, speed)
2438 POSIX::Termios termios_ref
2442 cfsetospeed(termios_ref, speed)
2443 POSIX::Termios termios_ref
2447 setiflag(termios_ref, iflag)
2448 POSIX::Termios termios_ref
2451 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2452 termios_ref->c_iflag = iflag;
2454 not_here("setiflag");
2458 setoflag(termios_ref, oflag)
2459 POSIX::Termios termios_ref
2462 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2463 termios_ref->c_oflag = oflag;
2465 not_here("setoflag");
2469 setcflag(termios_ref, cflag)
2470 POSIX::Termios termios_ref
2473 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2474 termios_ref->c_cflag = cflag;
2476 not_here("setcflag");
2480 setlflag(termios_ref, lflag)
2481 POSIX::Termios termios_ref
2484 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2485 termios_ref->c_lflag = lflag;
2487 not_here("setlflag");
2491 setcc(termios_ref, ccix, cc)
2492 POSIX::Termios termios_ref
2496 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2498 croak("Bad setcc subscript");
2499 termios_ref->c_cc[ccix] = cc;
2505 MODULE = POSIX PACKAGE = POSIX
2518 for (s = charstring; *s && RETVAL; s++)
2530 for (s = charstring; *s && RETVAL; s++)
2542 for (s = charstring; *s && RETVAL; s++)
2554 for (s = charstring; *s && RETVAL; s++)
2566 for (s = charstring; *s && RETVAL; s++)
2578 for (s = charstring; *s && RETVAL; s++)
2590 for (s = charstring; *s && RETVAL; s++)
2602 for (s = charstring; *s && RETVAL; s++)
2614 for (s = charstring; *s && RETVAL; s++)
2626 for (s = charstring; *s && RETVAL; s++)
2633 isxdigit(charstring)
2638 for (s = charstring; *s && RETVAL; s++)
2645 open(filename, flags = O_RDONLY, mode = 0666)
2650 if (flags & (O_APPEND|O_CREAT|O_TRUNC|O_RDWR|O_WRONLY|O_EXCL))
2651 TAINT_PROPER("open");
2652 RETVAL = open(filename, flags, mode);
2660 #ifdef HAS_LOCALECONV
2661 struct lconv *lcbuf;
2663 if (lcbuf = localeconv()) {
2665 if (lcbuf->decimal_point && *lcbuf->decimal_point)
2666 hv_store(RETVAL, "decimal_point", 13,
2667 newSVpv(lcbuf->decimal_point, 0), 0);
2668 if (lcbuf->thousands_sep && *lcbuf->thousands_sep)
2669 hv_store(RETVAL, "thousands_sep", 13,
2670 newSVpv(lcbuf->thousands_sep, 0), 0);
2671 if (lcbuf->grouping && *lcbuf->grouping)
2672 hv_store(RETVAL, "grouping", 8,
2673 newSVpv(lcbuf->grouping, 0), 0);
2674 if (lcbuf->int_curr_symbol && *lcbuf->int_curr_symbol)
2675 hv_store(RETVAL, "int_curr_symbol", 15,
2676 newSVpv(lcbuf->int_curr_symbol, 0), 0);
2677 if (lcbuf->currency_symbol && *lcbuf->currency_symbol)
2678 hv_store(RETVAL, "currency_symbol", 15,
2679 newSVpv(lcbuf->currency_symbol, 0), 0);
2680 if (lcbuf->mon_decimal_point && *lcbuf->mon_decimal_point)
2681 hv_store(RETVAL, "mon_decimal_point", 17,
2682 newSVpv(lcbuf->mon_decimal_point, 0), 0);
2683 if (lcbuf->mon_thousands_sep && *lcbuf->mon_thousands_sep)
2684 hv_store(RETVAL, "mon_thousands_sep", 17,
2685 newSVpv(lcbuf->mon_thousands_sep, 0), 0);
2686 if (lcbuf->mon_grouping && *lcbuf->mon_grouping)
2687 hv_store(RETVAL, "mon_grouping", 12,
2688 newSVpv(lcbuf->mon_grouping, 0), 0);
2689 if (lcbuf->positive_sign && *lcbuf->positive_sign)
2690 hv_store(RETVAL, "positive_sign", 13,
2691 newSVpv(lcbuf->positive_sign, 0), 0);
2692 if (lcbuf->negative_sign && *lcbuf->negative_sign)
2693 hv_store(RETVAL, "negative_sign", 13,
2694 newSVpv(lcbuf->negative_sign, 0), 0);
2696 if (lcbuf->int_frac_digits != CHAR_MAX)
2697 hv_store(RETVAL, "int_frac_digits", 15,
2698 newSViv(lcbuf->int_frac_digits), 0);
2699 if (lcbuf->frac_digits != CHAR_MAX)
2700 hv_store(RETVAL, "frac_digits", 11,
2701 newSViv(lcbuf->frac_digits), 0);
2702 if (lcbuf->p_cs_precedes != CHAR_MAX)
2703 hv_store(RETVAL, "p_cs_precedes", 13,
2704 newSViv(lcbuf->p_cs_precedes), 0);
2705 if (lcbuf->p_sep_by_space != CHAR_MAX)
2706 hv_store(RETVAL, "p_sep_by_space", 14,
2707 newSViv(lcbuf->p_sep_by_space), 0);
2708 if (lcbuf->n_cs_precedes != CHAR_MAX)
2709 hv_store(RETVAL, "n_cs_precedes", 13,
2710 newSViv(lcbuf->n_cs_precedes), 0);
2711 if (lcbuf->n_sep_by_space != CHAR_MAX)
2712 hv_store(RETVAL, "n_sep_by_space", 14,
2713 newSViv(lcbuf->n_sep_by_space), 0);
2714 if (lcbuf->p_sign_posn != CHAR_MAX)
2715 hv_store(RETVAL, "p_sign_posn", 11,
2716 newSViv(lcbuf->p_sign_posn), 0);
2717 if (lcbuf->n_sign_posn != CHAR_MAX)
2718 hv_store(RETVAL, "n_sign_posn", 11,
2719 newSViv(lcbuf->n_sign_posn), 0);
2722 localeconv(); /* A stub to call not_here(). */
2728 setlocale(category, locale)
2766 /* (We already know stack is long enough.) */
2767 PUSHs(sv_2mortal(newSVnv(frexp(x,&expvar))));
2768 PUSHs(sv_2mortal(newSViv(expvar)));
2784 /* (We already know stack is long enough.) */
2785 PUSHs(sv_2mortal(newSVnv(modf(x,&intvar))));
2786 PUSHs(sv_2mortal(newSVnv(intvar)));
2801 sigaction(sig, action, oldaction = 0)
2803 POSIX::SigAction action
2804 POSIX::SigAction oldaction
2807 # This code is really grody because we're trying to make the signal
2808 # interface look beautiful, which is hard.
2811 gv_fetchpv("SIG", TRUE, SVt_PVHV);
2814 struct sigaction act;
2815 struct sigaction oact;
2816 POSIX__SigSet sigset;
2818 SV** sigsvp = hv_fetch(GvHVn(siggv),
2820 strlen(sig_name[sig]),
2823 /* Remember old handler name if desired. */
2825 char *hand = SvPVx(*sigsvp, na);
2826 svp = hv_fetch(oldaction, "HANDLER", 7, TRUE);
2827 sv_setpv(*svp, *hand ? hand : "DEFAULT");
2831 /* Vector new handler through %SIG. (We always use sighandler
2832 for the C signal handler, which reads %SIG to dispatch.) */
2833 svp = hv_fetch(action, "HANDLER", 7, FALSE);
2835 croak("Can't supply an action without a HANDLER");
2836 sv_setpv(*sigsvp, SvPV(*svp, na));
2837 mg_set(*sigsvp); /* handles DEFAULT and IGNORE */
2838 act.sa_handler = sighandler;
2840 /* Set up any desired mask. */
2841 svp = hv_fetch(action, "MASK", 4, FALSE);
2842 if (svp && sv_isa(*svp, "POSIX::SigSet")) {
2844 tmp = (unsigned long)SvNV((SV*)SvRV(*svp));
2845 sigset = (sigset_t*) tmp;
2846 act.sa_mask = *sigset;
2849 sigemptyset(& act.sa_mask);
2851 /* Set up any desired flags. */
2852 svp = hv_fetch(action, "FLAGS", 5, FALSE);
2853 act.sa_flags = svp ? SvIV(*svp) : 0;
2856 /* Now work around sigaction oddities */
2857 if (action && oldaction)
2858 RETVAL = sigaction(sig, & act, & oact);
2860 RETVAL = sigaction(sig, & act, (struct sigaction *)0);
2862 RETVAL = sigaction(sig, (struct sigaction *)0, & oact);
2867 /* Get back the mask. */
2868 svp = hv_fetch(oldaction, "MASK", 4, TRUE);
2869 if (sv_isa(*svp, "POSIX::SigSet")) {
2871 tmp = (unsigned long)SvNV((SV*)SvRV(*svp));
2872 sigset = (sigset_t*) tmp;
2875 sigset = (sigset_t*)safemalloc(sizeof(sigset_t));
2876 sv_setptrobj(*svp, sigset, "POSIX::SigSet");
2878 *sigset = oact.sa_mask;
2880 /* Get back the flags. */
2881 svp = hv_fetch(oldaction, "FLAGS", 5, TRUE);
2882 sv_setiv(*svp, oact.sa_flags);
2890 POSIX::SigSet sigset
2893 sigprocmask(how, sigset, oldsigset = 0)
2895 POSIX::SigSet sigset
2896 POSIX::SigSet oldsigset
2899 sigsuspend(signal_mask)
2900 POSIX::SigSet signal_mask
2920 lseek(fd, offset, whence)
2933 if (pipe(fds) != -1) {
2935 PUSHs(sv_2mortal(newSViv(fds[0])));
2936 PUSHs(sv_2mortal(newSViv(fds[1])));
2940 read(fd, buffer, nbytes)
2942 SV *sv_buffer = SvROK(ST(1)) ? SvRV(ST(1)) : ST(1);
2946 char * buffer = sv_grow( sv_buffer, nbytes+1 );
2949 SvCUR(sv_buffer) = RETVAL;
2950 SvPOK_only(sv_buffer);
2951 *SvEND(sv_buffer) = '\0';
2953 sv_magic(sv_buffer, 0, 't', 0, 0);
2969 tcsetpgrp(fd, pgrp_id)
2978 if (uname(&buf) >= 0) {
2980 PUSHs(sv_2mortal(newSVpv(buf.sysname, 0)));
2981 PUSHs(sv_2mortal(newSVpv(buf.nodename, 0)));
2982 PUSHs(sv_2mortal(newSVpv(buf.release, 0)));
2983 PUSHs(sv_2mortal(newSVpv(buf.version, 0)));
2984 PUSHs(sv_2mortal(newSVpv(buf.machine, 0)));
2987 uname((char *) 0); /* A stub to call not_here(). */
2991 write(fd, buffer, nbytes)
3009 mbstowcs(s, pwcs, n)
3021 wcstombs(s, pwcs, n)
3043 char *p = SvPV(src,srclen);
3045 ST(0) = sv_2mortal(NEWSV(800,srclen));
3046 dstlen = strxfrm(SvPVX(ST(0)), p, (size_t)srclen);
3047 if (dstlen > srclen) {
3049 SvGROW(ST(0), dstlen);
3050 strxfrm(SvPVX(ST(0)), p, (size_t)dstlen);
3053 SvCUR(ST(0)) = dstlen;
3058 mkfifo(filename, mode)
3062 TAINT_PROPER("mkfifo");
3063 RETVAL = mkfifo(filename, mode);
3079 tcflush(fd, queue_selector)
3084 tcsendbreak(fd, duration)
3089 asctime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3102 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3105 mytm.tm_hour = hour;
3106 mytm.tm_mday = mday;
3108 mytm.tm_year = year;
3109 mytm.tm_wday = wday;
3110 mytm.tm_yday = yday;
3111 mytm.tm_isdst = isdst;
3112 RETVAL = asctime(&mytm);
3129 realtime = times( &tms );
3131 PUSHs( sv_2mortal( newSVnv( realtime ) ) );
3132 PUSHs( sv_2mortal( newSVnv( tms.tms_utime ) ) );
3133 PUSHs( sv_2mortal( newSVnv( tms.tms_stime ) ) );
3134 PUSHs( sv_2mortal( newSVnv( tms.tms_cutime ) ) );
3135 PUSHs( sv_2mortal( newSVnv( tms.tms_cstime ) ) );
3138 difftime(time1, time2)
3143 mktime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3156 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3159 mytm.tm_hour = hour;
3160 mytm.tm_mday = mday;
3162 mytm.tm_year = year;
3163 mytm.tm_wday = wday;
3164 mytm.tm_yday = yday;
3165 mytm.tm_isdst = isdst;
3166 RETVAL = mktime(&mytm);
3172 strftime(fmt, sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3188 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3191 mytm.tm_hour = hour;
3192 mytm.tm_mday = mday;
3194 mytm.tm_year = year;
3195 mytm.tm_wday = wday;
3196 mytm.tm_yday = yday;
3197 mytm.tm_isdst = isdst;
3198 len = strftime(tmpbuf, sizeof tmpbuf, fmt, &mytm);
3199 ST(0) = sv_2mortal(newSVpv(tmpbuf, len));
3209 PUSHs(sv_2mortal(newSVpv(tzname[0],strlen(tzname[0]))));
3210 PUSHs(sv_2mortal(newSVpv(tzname[1],strlen(tzname[1]))));
3213 access(filename, mode)
3231 pathconf(filename, name)