5 #define PERL_NO_GET_CONTEXT
8 #define PERLIO_NOT_STDIO 1
11 #if defined(PERL_OBJECT) || defined(PERL_CAPI) || defined(PERL_IMPLICIT_SYS)
15 # define open PerlLIO_open3
18 #ifdef I_DIRENT /* XXX maybe better to just rely on perl.h? */
41 /* XXX This comment is just to make I_TERMIO and I_SGTTY visible to
42 metaconfig for future extension writers. We don't use them in POSIX.
43 (This is really sneaky :-) --AD
45 #if defined(I_TERMIOS)
53 #include <sys/types.h>
58 #ifdef MACOS_TRADITIONAL
63 #if defined(__VMS) && !defined(__POSIX_SOURCE)
64 # include <libdef.h> /* LIB$_INVARG constant */
65 # include <lib$routines.h> /* prototype for lib$ediv() */
66 # include <starlet.h> /* prototype for sys$gettim() */
67 # if DECC_VERSION < 50000000
68 # define pid_t int /* old versions of DECC miss this in types.h */
72 # define mkfifo(a,b) (not_here("mkfifo"),-1)
73 # define tzset() not_here("tzset")
75 #if ((__VMS_VER >= 70000000) && (__DECC_VER >= 50200000)) || (__CRTL_VER >= 70000000)
76 # define HAS_TZNAME /* shows up in VMS 7.0 or Dec C 5.6 */
78 # endif /* __VMS_VER >= 70000000 or Dec C 5.6 */
80 /* The POSIX notion of ttyname() is better served by getname() under VMS */
81 static char ttnambuf[64];
82 # define ttyname(fd) (isatty(fd) > 0 ? getname(fd,ttnambuf,0) : NULL)
84 /* The non-POSIX CRTL times() has void return type, so we just get the
85 current time directly */
86 clock_t vms_times(struct tms *bufptr) {
89 /* Get wall time and convert to 10 ms intervals to
90 * produce the return value that the POSIX standard expects */
91 # if defined(__DECC) && defined (__ALPHA)
94 _ckvmssts(sys$gettim(&vmstime));
96 retval = vmstime & 0x7fffffff;
98 /* (Older hw or ccs don't have an atomic 64-bit type, so we
99 * juggle 32-bit ints (and a float) to produce a time_t result
100 * with minimal loss of information.) */
101 long int vmstime[2],remainder,divisor = 100000;
102 _ckvmssts(sys$gettim((unsigned long int *)vmstime));
103 vmstime[1] &= 0x7fff; /* prevent overflow in EDIV */
104 _ckvmssts(lib$ediv(&divisor,vmstime,(long int *)&retval,&remainder));
106 /* Fill in the struct tms using the CRTL routine . . .*/
107 times((tbuffer_t *)bufptr);
108 return (clock_t) retval;
110 # define times(t) vms_times(t)
112 #if defined (__CYGWIN__)
113 # define tzname _tzname
117 # define mkfifo(a,b) not_here("mkfifo")
118 # define ttyname(a) (char*)not_here("ttyname")
119 # define sigset_t long
122 # define tzname _tzname
125 # define mode_t short
128 # define mode_t short
130 # define tzset() not_here("tzset")
132 # ifndef _POSIX_OPEN_MAX
133 # define _POSIX_OPEN_MAX FOPEN_MAX /* XXX bogus ? */
136 # define sigaction(a,b,c) not_here("sigaction")
137 # define sigpending(a) not_here("sigpending")
138 # define sigprocmask(a,b,c) not_here("sigprocmask")
139 # define sigsuspend(a) not_here("sigsuspend")
140 # define sigemptyset(a) not_here("sigemptyset")
141 # define sigaddset(a,b) not_here("sigaddset")
142 # define sigdelset(a,b) not_here("sigdelset")
143 # define sigfillset(a) not_here("sigfillset")
144 # define sigismember(a,b) not_here("sigismember")
148 # if defined(OS2) || defined(MACOS_TRADITIONAL)
149 # define mkfifo(a,b) not_here("mkfifo")
150 # else /* !( defined OS2 ) */
152 # define mkfifo(path, mode) (mknod((path), (mode) | S_IFIFO, 0))
155 # endif /* !HAS_MKFIFO */
157 # ifdef MACOS_TRADITIONAL
158 # define ttyname(a) (char*)not_here("ttyname")
159 # define tzset() not_here("tzset")
162 # include <sys/times.h>
164 # include <sys/utsname.h>
166 # include <sys/wait.h>
175 typedef long SysRetLong;
176 typedef sigset_t* POSIX__SigSet;
177 typedef HV* POSIX__SigAction;
179 typedef struct termios* POSIX__Termios;
180 #else /* Define termios types to int, and call not_here for the functions.*/
181 #define POSIX__Termios int
185 #define cfgetispeed(x) not_here("cfgetispeed")
186 #define cfgetospeed(x) not_here("cfgetospeed")
187 #define tcdrain(x) not_here("tcdrain")
188 #define tcflush(x,y) not_here("tcflush")
189 #define tcsendbreak(x,y) not_here("tcsendbreak")
190 #define cfsetispeed(x,y) not_here("cfsetispeed")
191 #define cfsetospeed(x,y) not_here("cfsetospeed")
192 #define ctermid(x) (char *) not_here("ctermid")
193 #define tcflow(x,y) not_here("tcflow")
194 #define tcgetattr(x,y) not_here("tcgetattr")
195 #define tcsetattr(x,y,z) not_here("tcsetattr")
198 /* Possibly needed prototypes */
199 char *cuserid (char *);
200 double strtod (const char *, char **);
201 long strtol (const char *, char **, int);
202 unsigned long strtoul (const char *, char **, int);
205 #define cuserid(a) (char *) not_here("cuserid")
209 #define difftime(a,b) not_here("difftime")
212 #ifndef HAS_FPATHCONF
213 #define fpathconf(f,n) (SysRetLong) not_here("fpathconf")
216 #define mktime(a) not_here("mktime")
219 #define nice(a) not_here("nice")
222 #define pathconf(f,n) (SysRetLong) not_here("pathconf")
225 #define sysconf(n) (SysRetLong) not_here("sysconf")
228 #define readlink(a,b,c) not_here("readlink")
231 #define setpgid(a,b) not_here("setpgid")
234 #define setsid() not_here("setsid")
237 #define strcoll(s1,s2) not_here("strcoll")
240 #define strtod(s1,s2) not_here("strtod")
243 #define strtol(s1,s2,b) not_here("strtol")
246 #define strtoul(s1,s2,b) not_here("strtoul")
249 #define strxfrm(s1,s2,n) not_here("strxfrm")
251 #ifndef HAS_TCGETPGRP
252 #define tcgetpgrp(a) not_here("tcgetpgrp")
254 #ifndef HAS_TCSETPGRP
255 #define tcsetpgrp(a,b) not_here("tcsetpgrp")
258 #define times(a) not_here("times")
261 #define uname(a) not_here("uname")
264 #define waitpid(a,b,c) not_here("waitpid")
269 #define mblen(a,b) not_here("mblen")
273 #define mbstowcs(s, pwcs, n) not_here("mbstowcs")
276 #define mbtowc(pwc, s, n) not_here("mbtowc")
279 #define wcstombs(s, pwcs, n) not_here("wcstombs")
282 #define wctomb(s, wchar) not_here("wcstombs")
284 #if !defined(HAS_MBLEN) && !defined(HAS_MBSTOWCS) && !defined(HAS_MBTOWC) && !defined(HAS_WCSTOMBS) && !defined(HAS_WCTOMB)
285 /* If we don't have these functions, then we wouldn't have gotten a typedef
286 for wchar_t, the wide character type. Defining wchar_t allows the
287 functions referencing it to compile. Its actual type is then meaningless,
288 since without the above functions, all sections using it end up calling
289 not_here() and croak. --Kaveh Ghazi (ghazi@noc.rutgers.edu) 9/18/94. */
295 #ifndef HAS_LOCALECONV
296 #define localeconv() not_here("localeconv")
300 # if !defined(WIN32) && !defined(__CYGWIN__)
301 extern char *tzname[];
304 #if !defined(WIN32) || (defined(__MINGW32__) && !defined(tzname))
305 char *tzname[] = { "" , "" };
309 /* XXX struct tm on some systems (SunOS4/BSD) contains extra (non POSIX)
310 * fields for which we don't have Configure support yet:
311 * char *tm_zone; -- abbreviation of timezone name
312 * long tm_gmtoff; -- offset from GMT in seconds
313 * To workaround core dumps from the uninitialised tm_zone we get the
314 * system to give us a reasonable struct to copy. This fix means that
315 * strftime uses the tm_zone and tm_gmtoff values returned by
316 * localtime(time()). That should give the desired result most of the
317 * time. But probably not always!
319 * This is a temporary workaround to be removed once Configure
320 * support is added and NETaa14816 is considered in full.
321 * It does not address tzname aspects of NETaa14816.
324 # ifndef STRUCT_TM_HASZONE
325 # define STRUCT_TM_HASZONE
329 #ifdef STRUCT_TM_HASZONE
331 init_tm(struct tm *ptm) /* see mktime, strftime and asctime */
335 Copy(localtime(&now), ptm, 1, struct tm);
339 # define init_tm(ptm)
343 * mini_mktime - normalise struct tm values without the localtime()
344 * semantics (and overhead) of mktime().
347 mini_mktime(struct tm *ptm)
351 int month, mday, year, jday;
352 int odd_cent, odd_year;
354 #define DAYS_PER_YEAR 365
355 #define DAYS_PER_QYEAR (4*DAYS_PER_YEAR+1)
356 #define DAYS_PER_CENT (25*DAYS_PER_QYEAR-1)
357 #define DAYS_PER_QCENT (4*DAYS_PER_CENT+1)
358 #define SECS_PER_HOUR (60*60)
359 #define SECS_PER_DAY (24*SECS_PER_HOUR)
360 /* parentheses deliberately absent on these two, otherwise they don't work */
361 #define MONTH_TO_DAYS 153/5
362 #define DAYS_TO_MONTH 5/153
363 /* offset to bias by March (month 4) 1st between month/mday & year finding */
364 #define YEAR_ADJUST (4*MONTH_TO_DAYS+1)
365 /* as used here, the algorithm leaves Sunday as day 1 unless we adjust it */
366 #define WEEKDAY_BIAS 6 /* (1+6)%7 makes Sunday 0 again */
369 * Year/day algorithm notes:
371 * With a suitable offset for numeric value of the month, one can find
372 * an offset into the year by considering months to have 30.6 (153/5) days,
373 * using integer arithmetic (i.e., with truncation). To avoid too much
374 * messing about with leap days, we consider January and February to be
375 * the 13th and 14th month of the previous year. After that transformation,
376 * we need the month index we use to be high by 1 from 'normal human' usage,
377 * so the month index values we use run from 4 through 15.
379 * Given that, and the rules for the Gregorian calendar (leap years are those
380 * divisible by 4 unless also divisible by 100, when they must be divisible
381 * by 400 instead), we can simply calculate the number of days since some
382 * arbitrary 'beginning of time' by futzing with the (adjusted) year number,
383 * the days we derive from our month index, and adding in the day of the
384 * month. The value used here is not adjusted for the actual origin which
385 * it normally would use (1 January A.D. 1), since we're not exposing it.
386 * We're only building the value so we can turn around and get the
387 * normalised values for the year, month, day-of-month, and day-of-year.
389 * For going backward, we need to bias the value we're using so that we find
390 * the right year value. (Basically, we don't want the contribution of
391 * March 1st to the number to apply while deriving the year). Having done
392 * that, we 'count up' the contribution to the year number by accounting for
393 * full quadracenturies (400-year periods) with their extra leap days, plus
394 * the contribution from full centuries (to avoid counting in the lost leap
395 * days), plus the contribution from full quad-years (to count in the normal
396 * leap days), plus the leftover contribution from any non-leap years.
397 * At this point, if we were working with an actual leap day, we'll have 0
398 * days left over. This is also true for March 1st, however. So, we have
399 * to special-case that result, and (earlier) keep track of the 'odd'
400 * century and year contributions. If we got 4 extra centuries in a qcent,
401 * or 4 extra years in a qyear, then it's a leap day and we call it 29 Feb.
402 * Otherwise, we add back in the earlier bias we removed (the 123 from
403 * figuring in March 1st), find the month index (integer division by 30.6),
404 * and the remainder is the day-of-month. We then have to convert back to
405 * 'real' months (including fixing January and February from being 14/15 in
406 * the previous year to being in the proper year). After that, to get
407 * tm_yday, we work with the normalised year and get a new yearday value for
408 * January 1st, which we subtract from the yearday value we had earlier,
409 * representing the date we've re-built. This is done from January 1
410 * because tm_yday is 0-origin.
412 * Since POSIX time routines are only guaranteed to work for times since the
413 * UNIX epoch (00:00:00 1 Jan 1970 UTC), the fact that this algorithm
414 * applies Gregorian calendar rules even to dates before the 16th century
415 * doesn't bother me. Besides, you'd need cultural context for a given
416 * date to know whether it was Julian or Gregorian calendar, and that's
417 * outside the scope for this routine. Since we convert back based on the
418 * same rules we used to build the yearday, you'll only get strange results
419 * for input which needed normalising, or for the 'odd' century years which
420 * were leap years in the Julian calander but not in the Gregorian one.
421 * I can live with that.
423 * This algorithm also fails to handle years before A.D. 1 gracefully, but
424 * that's still outside the scope for POSIX time manipulation, so I don't
428 year = 1900 + ptm->tm_year;
431 /* allow given yday with no month & mday to dominate the result */
432 if (ptm->tm_yday >= 0 && mday <= 0 && month <= 0) {
435 jday = 1 + ptm->tm_yday;
444 yearday = DAYS_PER_YEAR * year + year/4 - year/100 + year/400;
445 yearday += month*MONTH_TO_DAYS + mday + jday;
447 * Note that we don't know when leap-seconds were or will be,
448 * so we have to trust the user if we get something which looks
449 * like a sensible leap-second. Wild values for seconds will
450 * be rationalised, however.
452 if ((unsigned) ptm->tm_sec <= 60) {
459 secs += 60 * ptm->tm_min;
460 secs += SECS_PER_HOUR * ptm->tm_hour;
462 if (secs-(secs/SECS_PER_DAY*SECS_PER_DAY) < 0) {
463 /* got negative remainder, but need positive time */
464 /* back off an extra day to compensate */
465 yearday += (secs/SECS_PER_DAY)-1;
466 secs -= SECS_PER_DAY * (secs/SECS_PER_DAY - 1);
469 yearday += (secs/SECS_PER_DAY);
470 secs -= SECS_PER_DAY * (secs/SECS_PER_DAY);
473 else if (secs >= SECS_PER_DAY) {
474 yearday += (secs/SECS_PER_DAY);
475 secs %= SECS_PER_DAY;
477 ptm->tm_hour = secs/SECS_PER_HOUR;
478 secs %= SECS_PER_HOUR;
479 ptm->tm_min = secs/60;
482 /* done with time of day effects */
484 * The algorithm for yearday has (so far) left it high by 428.
485 * To avoid mistaking a legitimate Feb 29 as Mar 1, we need to
486 * bias it by 123 while trying to figure out what year it
487 * really represents. Even with this tweak, the reverse
488 * translation fails for years before A.D. 0001.
489 * It would still fail for Feb 29, but we catch that one below.
491 jday = yearday; /* save for later fixup vis-a-vis Jan 1 */
492 yearday -= YEAR_ADJUST;
493 year = (yearday / DAYS_PER_QCENT) * 400;
494 yearday %= DAYS_PER_QCENT;
495 odd_cent = yearday / DAYS_PER_CENT;
496 year += odd_cent * 100;
497 yearday %= DAYS_PER_CENT;
498 year += (yearday / DAYS_PER_QYEAR) * 4;
499 yearday %= DAYS_PER_QYEAR;
500 odd_year = yearday / DAYS_PER_YEAR;
502 yearday %= DAYS_PER_YEAR;
503 if (!yearday && (odd_cent==4 || odd_year==4)) { /* catch Feb 29 */
508 yearday += YEAR_ADJUST; /* recover March 1st crock */
509 month = yearday*DAYS_TO_MONTH;
510 yearday -= month*MONTH_TO_DAYS;
511 /* recover other leap-year adjustment */
520 ptm->tm_year = year - 1900;
522 ptm->tm_mday = yearday;
527 ptm->tm_mon = month - 1;
529 /* re-build yearday based on Jan 1 to get tm_yday */
531 yearday = year*DAYS_PER_YEAR + year/4 - year/100 + year/400;
532 yearday += 14*MONTH_TO_DAYS + 1;
533 ptm->tm_yday = jday - yearday;
534 /* fix tm_wday if not overridden by caller */
535 if ((unsigned)ptm->tm_wday > 6)
536 ptm->tm_wday = (jday + WEEKDAY_BIAS) % 7;
539 #ifdef HAS_LONG_DOUBLE
540 # if LONG_DOUBLESIZE > NVSIZE
541 # undef HAS_LONG_DOUBLE /* XXX until we figure out how to use them */
545 #ifndef HAS_LONG_DOUBLE
560 croak("POSIX::%s not implemented on this architecture", s);
566 constant(char *name, int arg)
571 if (strEQ(name, "ARG_MAX"))
579 if (strEQ(name, "BUFSIZ"))
585 if (strEQ(name, "BRKINT"))
591 if (strEQ(name, "B9600"))
597 if (strEQ(name, "B19200"))
603 if (strEQ(name, "B38400"))
609 if (strEQ(name, "B0"))
615 if (strEQ(name, "B110"))
621 if (strEQ(name, "B1200"))
627 if (strEQ(name, "B134"))
633 if (strEQ(name, "B150"))
639 if (strEQ(name, "B1800"))
645 if (strEQ(name, "B200"))
651 if (strEQ(name, "B2400"))
657 if (strEQ(name, "B300"))
663 if (strEQ(name, "B4800"))
669 if (strEQ(name, "B50"))
675 if (strEQ(name, "B600"))
681 if (strEQ(name, "B75"))
689 if (strEQ(name, "CHAR_BIT"))
695 if (strEQ(name, "CHAR_MAX"))
701 if (strEQ(name, "CHAR_MIN"))
707 if (strEQ(name, "CHILD_MAX"))
713 if (strEQ(name, "CLK_TCK"))
719 if (strEQ(name, "CLOCAL"))
725 if (strEQ(name, "CLOCKS_PER_SEC"))
726 #ifdef CLOCKS_PER_SEC
727 return CLOCKS_PER_SEC;
731 if (strEQ(name, "CREAD"))
737 if (strEQ(name, "CS5"))
743 if (strEQ(name, "CS6"))
749 if (strEQ(name, "CS7"))
755 if (strEQ(name, "CS8"))
761 if (strEQ(name, "CSIZE"))
767 if (strEQ(name, "CSTOPB"))
775 if (strEQ(name, "DBL_MAX"))
781 if (strEQ(name, "DBL_MIN"))
787 if (strEQ(name, "DBL_DIG"))
793 if (strEQ(name, "DBL_EPSILON"))
799 if (strEQ(name, "DBL_MANT_DIG"))
805 if (strEQ(name, "DBL_MAX_10_EXP"))
806 #ifdef DBL_MAX_10_EXP
807 return DBL_MAX_10_EXP;
811 if (strEQ(name, "DBL_MAX_EXP"))
817 if (strEQ(name, "DBL_MIN_10_EXP"))
818 #ifdef DBL_MIN_10_EXP
819 return DBL_MIN_10_EXP;
823 if (strEQ(name, "DBL_MIN_EXP"))
833 if (strEQ(name, "EACCES"))
839 if (strEQ(name, "EADDRINUSE"))
845 if (strEQ(name, "EADDRNOTAVAIL"))
847 return EADDRNOTAVAIL;
851 if (strEQ(name, "EAFNOSUPPORT"))
857 if (strEQ(name, "EAGAIN"))
863 if (strEQ(name, "EALREADY"))
871 if (strEQ(name, "EBADF"))
877 if (strEQ(name, "EBUSY"))
885 if (strEQ(name, "ECHILD"))
891 if (strEQ(name, "ECHO"))
897 if (strEQ(name, "ECHOE"))
903 if (strEQ(name, "ECHOK"))
909 if (strEQ(name, "ECHONL"))
915 if (strEQ(name, "ECONNABORTED"))
921 if (strEQ(name, "ECONNREFUSED"))
927 if (strEQ(name, "ECONNRESET"))
935 if (strEQ(name, "EDEADLK"))
941 if (strEQ(name, "EDESTADDRREQ"))
947 if (strEQ(name, "EDOM"))
953 if (strEQ(name, "EDQUOT"))
961 if (strEQ(name, "EEXIST"))
969 if (strEQ(name, "EFAULT"))
975 if (strEQ(name, "EFBIG"))
983 if (strEQ(name, "EHOSTDOWN"))
989 if (strEQ(name, "EHOSTUNREACH"))
997 if (strEQ(name, "EINPROGRESS"))
1003 if (strEQ(name, "EINTR"))
1009 if (strEQ(name, "EINVAL"))
1015 if (strEQ(name, "EIO"))
1021 if (strEQ(name, "EISCONN"))
1027 if (strEQ(name, "EISDIR"))
1035 if (strEQ(name, "ELOOP"))
1043 if (strEQ(name, "EMFILE"))
1049 if (strEQ(name, "EMLINK"))
1055 if (strEQ(name, "EMSGSIZE"))
1063 if (strEQ(name, "ENETDOWN"))
1069 if (strEQ(name, "ENETRESET"))
1075 if (strEQ(name, "ENETUNREACH"))
1081 if (strEQ(name, "ENOBUFS"))
1087 if (strEQ(name, "ENOEXEC"))
1093 if (strEQ(name, "ENOMEM"))
1099 if (strEQ(name, "ENOPROTOOPT"))
1105 if (strEQ(name, "ENOSPC"))
1111 if (strEQ(name, "ENOTBLK"))
1117 if (strEQ(name, "ENOTCONN"))
1123 if (strEQ(name, "ENOTDIR"))
1129 if (strEQ(name, "ENOTEMPTY"))
1135 if (strEQ(name, "ENOTSOCK"))
1141 if (strEQ(name, "ENOTTY"))
1147 if (strEQ(name, "ENFILE"))
1153 if (strEQ(name, "ENODEV"))
1159 if (strEQ(name, "ENOENT"))
1165 if (strEQ(name, "ENOLCK"))
1171 if (strEQ(name, "ENOSYS"))
1177 if (strEQ(name, "ENXIO"))
1183 if (strEQ(name, "ENAMETOOLONG"))
1185 return ENAMETOOLONG;
1191 if (strEQ(name, "EOF"))
1197 if (strEQ(name, "EOPNOTSUPP"))
1205 if (strEQ(name, "EPERM"))
1211 if (strEQ(name, "EPFNOSUPPORT"))
1213 return EPFNOSUPPORT;
1217 if (strEQ(name, "EPIPE"))
1223 if (strEQ(name, "EPROCLIM"))
1229 if (strEQ(name, "EPROTONOSUPPORT"))
1230 #ifdef EPROTONOSUPPORT
1231 return EPROTONOSUPPORT;
1235 if (strEQ(name, "EPROTOTYPE"))
1243 if (strEQ(name, "ERANGE"))
1249 if (strEQ(name, "EREMOTE"))
1255 if (strEQ(name, "ERESTART"))
1261 if (strEQ(name, "EROFS"))
1269 if (strEQ(name, "ESHUTDOWN"))
1275 if (strEQ(name, "ESOCKTNOSUPPORT"))
1276 #ifdef ESOCKTNOSUPPORT
1277 return ESOCKTNOSUPPORT;
1281 if (strEQ(name, "ESPIPE"))
1287 if (strEQ(name, "ESRCH"))
1293 if (strEQ(name, "ESTALE"))
1301 if (strEQ(name, "ETIMEDOUT"))
1307 if (strEQ(name, "ETOOMANYREFS"))
1309 return ETOOMANYREFS;
1313 if (strEQ(name, "ETXTBSY"))
1321 if (strEQ(name, "EUSERS"))
1329 if (strEQ(name, "EWOULDBLOCK"))
1337 if (strEQ(name, "EXIT_FAILURE"))
1339 return EXIT_FAILURE;
1343 if (strEQ(name, "EXIT_SUCCESS"))
1345 return EXIT_SUCCESS;
1349 if (strEQ(name, "EXDEV"))
1357 if (strEQ(name, "E2BIG"))
1365 if (strnEQ(name, "FLT_", 4)) {
1366 if (strEQ(name, "FLT_MAX"))
1372 if (strEQ(name, "FLT_MIN"))
1378 if (strEQ(name, "FLT_ROUNDS"))
1384 if (strEQ(name, "FLT_DIG"))
1390 if (strEQ(name, "FLT_EPSILON"))
1396 if (strEQ(name, "FLT_MANT_DIG"))
1398 return FLT_MANT_DIG;
1402 if (strEQ(name, "FLT_MAX_10_EXP"))
1403 #ifdef FLT_MAX_10_EXP
1404 return FLT_MAX_10_EXP;
1408 if (strEQ(name, "FLT_MAX_EXP"))
1414 if (strEQ(name, "FLT_MIN_10_EXP"))
1415 #ifdef FLT_MIN_10_EXP
1416 return FLT_MIN_10_EXP;
1420 if (strEQ(name, "FLT_MIN_EXP"))
1426 if (strEQ(name, "FLT_RADIX"))
1434 if (strnEQ(name, "F_", 2)) {
1435 if (strEQ(name, "F_DUPFD"))
1441 if (strEQ(name, "F_GETFD"))
1447 if (strEQ(name, "F_GETFL"))
1453 if (strEQ(name, "F_GETLK"))
1459 if (strEQ(name, "F_OK"))
1465 if (strEQ(name, "F_RDLCK"))
1471 if (strEQ(name, "F_SETFD"))
1477 if (strEQ(name, "F_SETFL"))
1483 if (strEQ(name, "F_SETLK"))
1489 if (strEQ(name, "F_SETLKW"))
1495 if (strEQ(name, "F_UNLCK"))
1501 if (strEQ(name, "F_WRLCK"))
1509 if (strEQ(name, "FD_CLOEXEC"))
1515 if (strEQ(name, "FILENAME_MAX"))
1517 return FILENAME_MAX;
1523 if (strEQ(name, "HUGE_VAL"))
1524 #if defined(USE_LONG_DOUBLE) && defined(HUGE_VALL)
1525 /* HUGE_VALL is admittedly non-POSIX but if we are using long doubles
1526 * we might as well use long doubles. --jhi */
1534 if (strEQ(name, "HUPCL"))
1542 if (strEQ(name, "INT_MAX"))
1548 if (strEQ(name, "INT_MIN"))
1554 if (strEQ(name, "ICANON"))
1560 if (strEQ(name, "ICRNL"))
1566 if (strEQ(name, "IEXTEN"))
1572 if (strEQ(name, "IGNBRK"))
1578 if (strEQ(name, "IGNCR"))
1584 if (strEQ(name, "IGNPAR"))
1590 if (strEQ(name, "INLCR"))
1596 if (strEQ(name, "INPCK"))
1602 if (strEQ(name, "ISIG"))
1608 if (strEQ(name, "ISTRIP"))
1614 if (strEQ(name, "IXOFF"))
1620 if (strEQ(name, "IXON"))
1628 if (strnEQ(name, "LC_", 3)) {
1629 if (strEQ(name, "LC_ALL"))
1635 if (strEQ(name, "LC_COLLATE"))
1641 if (strEQ(name, "LC_CTYPE"))
1647 if (strEQ(name, "LC_MONETARY"))
1653 if (strEQ(name, "LC_NUMERIC"))
1659 if (strEQ(name, "LC_TIME"))
1667 if (strnEQ(name, "LDBL_", 5)) {
1668 if (strEQ(name, "LDBL_MAX"))
1674 if (strEQ(name, "LDBL_MIN"))
1680 if (strEQ(name, "LDBL_DIG"))
1686 if (strEQ(name, "LDBL_EPSILON"))
1688 return LDBL_EPSILON;
1692 if (strEQ(name, "LDBL_MANT_DIG"))
1693 #ifdef LDBL_MANT_DIG
1694 return LDBL_MANT_DIG;
1698 if (strEQ(name, "LDBL_MAX_10_EXP"))
1699 #ifdef LDBL_MAX_10_EXP
1700 return LDBL_MAX_10_EXP;
1704 if (strEQ(name, "LDBL_MAX_EXP"))
1706 return LDBL_MAX_EXP;
1710 if (strEQ(name, "LDBL_MIN_10_EXP"))
1711 #ifdef LDBL_MIN_10_EXP
1712 return LDBL_MIN_10_EXP;
1716 if (strEQ(name, "LDBL_MIN_EXP"))
1718 return LDBL_MIN_EXP;
1724 if (strnEQ(name, "L_", 2)) {
1725 if (strEQ(name, "L_ctermid"))
1731 if (strEQ(name, "L_cuserid"))
1737 /* L_tmpnam[e] was a typo--retained for compatibility */
1738 if (strEQ(name, "L_tmpname") || strEQ(name, "L_tmpnam"))
1746 if (strEQ(name, "LONG_MAX"))
1752 if (strEQ(name, "LONG_MIN"))
1758 if (strEQ(name, "LINK_MAX"))
1766 if (strEQ(name, "MAX_CANON"))
1772 if (strEQ(name, "MAX_INPUT"))
1778 if (strEQ(name, "MB_CUR_MAX"))
1784 if (strEQ(name, "MB_LEN_MAX"))
1792 if (strEQ(name, "NULL")) return 0;
1793 if (strEQ(name, "NAME_MAX"))
1799 if (strEQ(name, "NCCS"))
1805 if (strEQ(name, "NGROUPS_MAX"))
1811 if (strEQ(name, "NOFLSH"))
1819 if (strnEQ(name, "O_", 2)) {
1820 if (strEQ(name, "O_APPEND"))
1826 if (strEQ(name, "O_CREAT"))
1832 if (strEQ(name, "O_TRUNC"))
1838 if (strEQ(name, "O_RDONLY"))
1844 if (strEQ(name, "O_RDWR"))
1850 if (strEQ(name, "O_WRONLY"))
1856 if (strEQ(name, "O_EXCL"))
1862 if (strEQ(name, "O_NOCTTY"))
1868 if (strEQ(name, "O_NONBLOCK"))
1874 if (strEQ(name, "O_ACCMODE"))
1882 if (strEQ(name, "OPEN_MAX"))
1888 if (strEQ(name, "OPOST"))
1896 if (strEQ(name, "PATH_MAX"))
1902 if (strEQ(name, "PARENB"))
1908 if (strEQ(name, "PARMRK"))
1914 if (strEQ(name, "PARODD"))
1920 if (strEQ(name, "PIPE_BUF"))
1928 if (strEQ(name, "RAND_MAX"))
1934 if (strEQ(name, "R_OK"))
1942 if (strnEQ(name, "SIG", 3)) {
1943 if (name[3] == '_') {
1944 if (strEQ(name, "SIG_BLOCK"))
1951 if (strEQ(name, "SIG_DFL")) return (IV)SIG_DFL;
1954 if (strEQ(name, "SIG_ERR")) return (IV)SIG_ERR;
1957 if (strEQ(name, "SIG_IGN")) return (IV)SIG_IGN;
1959 if (strEQ(name, "SIG_SETMASK"))
1965 if (strEQ(name, "SIG_UNBLOCK"))
1973 if (strEQ(name, "SIGABRT"))
1979 if (strEQ(name, "SIGALRM"))
1985 if (strEQ(name, "SIGCHLD"))
1991 if (strEQ(name, "SIGCONT"))
1997 if (strEQ(name, "SIGFPE"))
2003 if (strEQ(name, "SIGHUP"))
2009 if (strEQ(name, "SIGILL"))
2015 if (strEQ(name, "SIGINT"))
2021 if (strEQ(name, "SIGKILL"))
2027 if (strEQ(name, "SIGPIPE"))
2033 if (strEQ(name, "SIGQUIT"))
2039 if (strEQ(name, "SIGSEGV"))
2045 if (strEQ(name, "SIGSTOP"))
2051 if (strEQ(name, "SIGTERM"))
2057 if (strEQ(name, "SIGTSTP"))
2063 if (strEQ(name, "SIGTTIN"))
2069 if (strEQ(name, "SIGTTOU"))
2075 if (strEQ(name, "SIGUSR1"))
2081 if (strEQ(name, "SIGUSR2"))
2089 if (name[1] == '_') {
2090 if (strEQ(name, "S_ISGID"))
2096 if (strEQ(name, "S_ISUID"))
2102 if (strEQ(name, "S_IRGRP"))
2108 if (strEQ(name, "S_IROTH"))
2114 if (strEQ(name, "S_IRUSR"))
2120 if (strEQ(name, "S_IRWXG"))
2126 if (strEQ(name, "S_IRWXO"))
2132 if (strEQ(name, "S_IRWXU"))
2138 if (strEQ(name, "S_IWGRP"))
2144 if (strEQ(name, "S_IWOTH"))
2150 if (strEQ(name, "S_IWUSR"))
2156 if (strEQ(name, "S_IXGRP"))
2162 if (strEQ(name, "S_IXOTH"))
2168 if (strEQ(name, "S_IXUSR"))
2174 errno = EAGAIN; /* the following aren't constants */
2176 if (strEQ(name, "S_ISBLK")) return S_ISBLK(arg);
2179 if (strEQ(name, "S_ISCHR")) return S_ISCHR(arg);
2182 if (strEQ(name, "S_ISDIR")) return S_ISDIR(arg);
2185 if (strEQ(name, "S_ISFIFO")) return S_ISFIFO(arg);
2188 if (strEQ(name, "S_ISREG")) return S_ISREG(arg);
2192 if (strEQ(name, "SEEK_CUR"))
2198 if (strEQ(name, "SEEK_END"))
2204 if (strEQ(name, "SEEK_SET"))
2210 if (strEQ(name, "STREAM_MAX"))
2216 if (strEQ(name, "SHRT_MAX"))
2222 if (strEQ(name, "SHRT_MIN"))
2228 if (strnEQ(name, "SA_", 3)) {
2229 if (strEQ(name, "SA_NOCLDSTOP"))
2231 return SA_NOCLDSTOP;
2235 if (strEQ(name, "SA_NOCLDWAIT"))
2237 return SA_NOCLDWAIT;
2241 if (strEQ(name, "SA_NODEFER"))
2247 if (strEQ(name, "SA_ONSTACK"))
2253 if (strEQ(name, "SA_RESETHAND"))
2255 return SA_RESETHAND;
2259 if (strEQ(name, "SA_RESTART"))
2265 if (strEQ(name, "SA_SIGINFO"))
2273 if (strEQ(name, "SCHAR_MAX"))
2279 if (strEQ(name, "SCHAR_MIN"))
2285 if (strEQ(name, "SSIZE_MAX"))
2291 if (strEQ(name, "STDIN_FILENO"))
2293 return STDIN_FILENO;
2297 if (strEQ(name, "STDOUT_FILENO"))
2298 #ifdef STDOUT_FILENO
2299 return STDOUT_FILENO;
2303 if (strEQ(name, "STDERR_FILENO"))
2304 #ifdef STDERR_FILENO
2305 return STDERR_FILENO;
2311 if (strEQ(name, "TCIFLUSH"))
2317 if (strEQ(name, "TCIOFF"))
2323 if (strEQ(name, "TCIOFLUSH"))
2329 if (strEQ(name, "TCION"))
2335 if (strEQ(name, "TCOFLUSH"))
2341 if (strEQ(name, "TCOOFF"))
2347 if (strEQ(name, "TCOON"))
2353 if (strEQ(name, "TCSADRAIN"))
2359 if (strEQ(name, "TCSAFLUSH"))
2365 if (strEQ(name, "TCSANOW"))
2371 if (strEQ(name, "TMP_MAX"))
2377 if (strEQ(name, "TOSTOP"))
2383 if (strEQ(name, "TZNAME_MAX"))
2391 if (strEQ(name, "UCHAR_MAX"))
2397 if (strEQ(name, "UINT_MAX"))
2403 if (strEQ(name, "ULONG_MAX"))
2409 if (strEQ(name, "USHRT_MAX"))
2417 if (strEQ(name, "VEOF"))
2423 if (strEQ(name, "VEOL"))
2429 if (strEQ(name, "VERASE"))
2435 if (strEQ(name, "VINTR"))
2441 if (strEQ(name, "VKILL"))
2447 if (strEQ(name, "VMIN"))
2453 if (strEQ(name, "VQUIT"))
2459 if (strEQ(name, "VSTART"))
2465 if (strEQ(name, "VSTOP"))
2471 if (strEQ(name, "VSUSP"))
2477 if (strEQ(name, "VTIME"))
2485 if (strEQ(name, "W_OK"))
2491 if (strEQ(name, "WNOHANG"))
2497 if (strEQ(name, "WUNTRACED"))
2503 errno = EAGAIN; /* the following aren't constants */
2505 if (strEQ(name, "WEXITSTATUS")) return WEXITSTATUS(arg);
2508 if (strEQ(name, "WIFEXITED")) return WIFEXITED(arg);
2511 if (strEQ(name, "WIFSIGNALED")) return WIFSIGNALED(arg);
2514 if (strEQ(name, "WIFSTOPPED")) return WIFSTOPPED(arg);
2517 if (strEQ(name, "WSTOPSIG")) return WSTOPSIG(arg);
2520 if (strEQ(name, "WTERMSIG")) return WTERMSIG(arg);
2524 if (strEQ(name, "X_OK"))
2532 if (strnEQ(name, "_PC_", 4)) {
2533 if (strEQ(name, "_PC_CHOWN_RESTRICTED"))
2534 #if defined(_PC_CHOWN_RESTRICTED) || HINT_SC_EXIST
2535 return _PC_CHOWN_RESTRICTED;
2539 if (strEQ(name, "_PC_LINK_MAX"))
2540 #if defined(_PC_LINK_MAX) || HINT_SC_EXIST
2541 return _PC_LINK_MAX;
2545 if (strEQ(name, "_PC_MAX_CANON"))
2546 #if defined(_PC_MAX_CANON) || HINT_SC_EXIST
2547 return _PC_MAX_CANON;
2551 if (strEQ(name, "_PC_MAX_INPUT"))
2552 #if defined(_PC_MAX_INPUT) || HINT_SC_EXIST
2553 return _PC_MAX_INPUT;
2557 if (strEQ(name, "_PC_NAME_MAX"))
2558 #if defined(_PC_NAME_MAX) || HINT_SC_EXIST
2559 return _PC_NAME_MAX;
2563 if (strEQ(name, "_PC_NO_TRUNC"))
2564 #if defined(_PC_NO_TRUNC) || HINT_SC_EXIST
2565 return _PC_NO_TRUNC;
2569 if (strEQ(name, "_PC_PATH_MAX"))
2570 #if defined(_PC_PATH_MAX) || HINT_SC_EXIST
2571 return _PC_PATH_MAX;
2575 if (strEQ(name, "_PC_PIPE_BUF"))
2576 #if defined(_PC_PIPE_BUF) || HINT_SC_EXIST
2577 return _PC_PIPE_BUF;
2581 if (strEQ(name, "_PC_VDISABLE"))
2582 #if defined(_PC_VDISABLE) || HINT_SC_EXIST
2583 return _PC_VDISABLE;
2589 if (strnEQ(name, "_POSIX_", 7)) {
2590 if (strEQ(name, "_POSIX_ARG_MAX"))
2591 #ifdef _POSIX_ARG_MAX
2592 return _POSIX_ARG_MAX;
2596 if (strEQ(name, "_POSIX_CHILD_MAX"))
2597 #ifdef _POSIX_CHILD_MAX
2598 return _POSIX_CHILD_MAX;
2602 if (strEQ(name, "_POSIX_CHOWN_RESTRICTED"))
2603 #ifdef _POSIX_CHOWN_RESTRICTED
2604 return _POSIX_CHOWN_RESTRICTED;
2608 if (strEQ(name, "_POSIX_JOB_CONTROL"))
2609 #ifdef _POSIX_JOB_CONTROL
2610 return _POSIX_JOB_CONTROL;
2614 if (strEQ(name, "_POSIX_LINK_MAX"))
2615 #ifdef _POSIX_LINK_MAX
2616 return _POSIX_LINK_MAX;
2620 if (strEQ(name, "_POSIX_MAX_CANON"))
2621 #ifdef _POSIX_MAX_CANON
2622 return _POSIX_MAX_CANON;
2626 if (strEQ(name, "_POSIX_MAX_INPUT"))
2627 #ifdef _POSIX_MAX_INPUT
2628 return _POSIX_MAX_INPUT;
2632 if (strEQ(name, "_POSIX_NAME_MAX"))
2633 #ifdef _POSIX_NAME_MAX
2634 return _POSIX_NAME_MAX;
2638 if (strEQ(name, "_POSIX_NGROUPS_MAX"))
2639 #ifdef _POSIX_NGROUPS_MAX
2640 return _POSIX_NGROUPS_MAX;
2644 if (strEQ(name, "_POSIX_NO_TRUNC"))
2645 #ifdef _POSIX_NO_TRUNC
2646 return _POSIX_NO_TRUNC;
2650 if (strEQ(name, "_POSIX_OPEN_MAX"))
2651 #ifdef _POSIX_OPEN_MAX
2652 return _POSIX_OPEN_MAX;
2656 if (strEQ(name, "_POSIX_PATH_MAX"))
2657 #ifdef _POSIX_PATH_MAX
2658 return _POSIX_PATH_MAX;
2662 if (strEQ(name, "_POSIX_PIPE_BUF"))
2663 #ifdef _POSIX_PIPE_BUF
2664 return _POSIX_PIPE_BUF;
2668 if (strEQ(name, "_POSIX_SAVED_IDS"))
2669 #ifdef _POSIX_SAVED_IDS
2670 return _POSIX_SAVED_IDS;
2674 if (strEQ(name, "_POSIX_SSIZE_MAX"))
2675 #ifdef _POSIX_SSIZE_MAX
2676 return _POSIX_SSIZE_MAX;
2680 if (strEQ(name, "_POSIX_STREAM_MAX"))
2681 #ifdef _POSIX_STREAM_MAX
2682 return _POSIX_STREAM_MAX;
2686 if (strEQ(name, "_POSIX_TZNAME_MAX"))
2687 #ifdef _POSIX_TZNAME_MAX
2688 return _POSIX_TZNAME_MAX;
2692 if (strEQ(name, "_POSIX_VDISABLE"))
2693 #ifdef _POSIX_VDISABLE
2694 return _POSIX_VDISABLE;
2698 if (strEQ(name, "_POSIX_VERSION"))
2699 #ifdef _POSIX_VERSION
2700 return _POSIX_VERSION;
2706 if (strnEQ(name, "_SC_", 4)) {
2707 if (strEQ(name, "_SC_ARG_MAX"))
2708 #if defined(_SC_ARG_MAX) || HINT_SC_EXIST
2713 if (strEQ(name, "_SC_CHILD_MAX"))
2714 #if defined(_SC_CHILD_MAX) || HINT_SC_EXIST
2715 return _SC_CHILD_MAX;
2719 if (strEQ(name, "_SC_CLK_TCK"))
2720 #if defined(_SC_CLK_TCK) || HINT_SC_EXIST
2725 if (strEQ(name, "_SC_JOB_CONTROL"))
2726 #if defined(_SC_JOB_CONTROL) || HINT_SC_EXIST
2727 return _SC_JOB_CONTROL;
2731 if (strEQ(name, "_SC_NGROUPS_MAX"))
2732 #if defined(_SC_NGROUPS_MAX) || HINT_SC_EXIST
2733 return _SC_NGROUPS_MAX;
2737 if (strEQ(name, "_SC_OPEN_MAX"))
2738 #if defined(_SC_OPEN_MAX) || HINT_SC_EXIST
2739 return _SC_OPEN_MAX;
2743 if (strEQ(name, "_SC_SAVED_IDS"))
2744 #if defined(_SC_SAVED_IDS) || HINT_SC_EXIST
2745 return _SC_SAVED_IDS;
2749 if (strEQ(name, "_SC_STREAM_MAX"))
2750 #if defined(_SC_STREAM_MAX) || HINT_SC_EXIST
2751 return _SC_STREAM_MAX;
2755 if (strEQ(name, "_SC_TZNAME_MAX"))
2756 #if defined(_SC_TZNAME_MAX) || HINT_SC_EXIST
2757 return _SC_TZNAME_MAX;
2761 if (strEQ(name, "_SC_VERSION"))
2762 #if defined(_SC_VERSION) || HINT_SC_EXIST
2779 restore_sigmask(sigset_t *ossetp)
2781 /* Fortunately, restoring the signal mask can't fail, because
2782 * there's nothing we can do about it if it does -- we're not
2783 * supposed to return -1 from sigaction unless the disposition
2786 (void)sigprocmask(SIG_SETMASK, ossetp, (sigset_t *)0);
2789 MODULE = SigSet PACKAGE = POSIX::SigSet PREFIX = sig
2792 new(packname = "POSIX::SigSet", ...)
2797 New(0, RETVAL, 1, sigset_t);
2798 sigemptyset(RETVAL);
2799 for (i = 1; i < items; i++)
2800 sigaddset(RETVAL, SvIV(ST(i)));
2807 POSIX::SigSet sigset
2812 sigaddset(sigset, sig)
2813 POSIX::SigSet sigset
2817 sigdelset(sigset, sig)
2818 POSIX::SigSet sigset
2823 POSIX::SigSet sigset
2827 POSIX::SigSet sigset
2830 sigismember(sigset, sig)
2831 POSIX::SigSet sigset
2835 MODULE = Termios PACKAGE = POSIX::Termios PREFIX = cf
2838 new(packname = "POSIX::Termios", ...)
2843 New(0, RETVAL, 1, struct termios);
2845 not_here("termios");
2853 DESTROY(termios_ref)
2854 POSIX::Termios termios_ref
2857 Safefree(termios_ref);
2859 not_here("termios");
2863 getattr(termios_ref, fd = 0)
2864 POSIX::Termios termios_ref
2867 RETVAL = tcgetattr(fd, termios_ref);
2872 setattr(termios_ref, fd = 0, optional_actions = 0)
2873 POSIX::Termios termios_ref
2875 int optional_actions
2877 RETVAL = tcsetattr(fd, optional_actions, termios_ref);
2882 cfgetispeed(termios_ref)
2883 POSIX::Termios termios_ref
2886 cfgetospeed(termios_ref)
2887 POSIX::Termios termios_ref
2890 getiflag(termios_ref)
2891 POSIX::Termios termios_ref
2893 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2894 RETVAL = termios_ref->c_iflag;
2896 not_here("getiflag");
2903 getoflag(termios_ref)
2904 POSIX::Termios termios_ref
2906 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2907 RETVAL = termios_ref->c_oflag;
2909 not_here("getoflag");
2916 getcflag(termios_ref)
2917 POSIX::Termios termios_ref
2919 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2920 RETVAL = termios_ref->c_cflag;
2922 not_here("getcflag");
2929 getlflag(termios_ref)
2930 POSIX::Termios termios_ref
2932 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2933 RETVAL = termios_ref->c_lflag;
2935 not_here("getlflag");
2942 getcc(termios_ref, ccix)
2943 POSIX::Termios termios_ref
2946 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2948 croak("Bad getcc subscript");
2949 RETVAL = termios_ref->c_cc[ccix];
2958 cfsetispeed(termios_ref, speed)
2959 POSIX::Termios termios_ref
2963 cfsetospeed(termios_ref, speed)
2964 POSIX::Termios termios_ref
2968 setiflag(termios_ref, iflag)
2969 POSIX::Termios termios_ref
2972 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2973 termios_ref->c_iflag = iflag;
2975 not_here("setiflag");
2979 setoflag(termios_ref, oflag)
2980 POSIX::Termios termios_ref
2983 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2984 termios_ref->c_oflag = oflag;
2986 not_here("setoflag");
2990 setcflag(termios_ref, cflag)
2991 POSIX::Termios termios_ref
2994 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2995 termios_ref->c_cflag = cflag;
2997 not_here("setcflag");
3001 setlflag(termios_ref, lflag)
3002 POSIX::Termios termios_ref
3005 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
3006 termios_ref->c_lflag = lflag;
3008 not_here("setlflag");
3012 setcc(termios_ref, ccix, cc)
3013 POSIX::Termios termios_ref
3017 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
3019 croak("Bad setcc subscript");
3020 termios_ref->c_cc[ccix] = cc;
3026 MODULE = POSIX PACKAGE = POSIX
3035 unsigned char * charstring
3037 unsigned char *s = charstring;
3038 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3039 for (RETVAL = 1; RETVAL && s < e; s++)
3047 unsigned char * charstring
3049 unsigned char *s = charstring;
3050 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3051 for (RETVAL = 1; RETVAL && s < e; s++)
3059 unsigned char * charstring
3061 unsigned char *s = charstring;
3062 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3063 for (RETVAL = 1; RETVAL && s < e; s++)
3071 unsigned char * charstring
3073 unsigned char *s = charstring;
3074 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3075 for (RETVAL = 1; RETVAL && s < e; s++)
3083 unsigned char * charstring
3085 unsigned char *s = charstring;
3086 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3087 for (RETVAL = 1; RETVAL && s < e; s++)
3095 unsigned char * charstring
3097 unsigned char *s = charstring;
3098 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3099 for (RETVAL = 1; RETVAL && s < e; s++)
3107 unsigned char * charstring
3109 unsigned char *s = charstring;
3110 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3111 for (RETVAL = 1; RETVAL && s < e; s++)
3119 unsigned char * charstring
3121 unsigned char *s = charstring;
3122 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3123 for (RETVAL = 1; RETVAL && s < e; s++)
3131 unsigned char * charstring
3133 unsigned char *s = charstring;
3134 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3135 for (RETVAL = 1; RETVAL && s < e; s++)
3143 unsigned char * charstring
3145 unsigned char *s = charstring;
3146 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3147 for (RETVAL = 1; RETVAL && s < e; s++)
3154 isxdigit(charstring)
3155 unsigned char * charstring
3157 unsigned char *s = charstring;
3158 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3159 for (RETVAL = 1; RETVAL && s < e; s++)
3166 open(filename, flags = O_RDONLY, mode = 0666)
3171 if (flags & (O_APPEND|O_CREAT|O_TRUNC|O_RDWR|O_WRONLY|O_EXCL))
3172 TAINT_PROPER("open");
3173 RETVAL = open(filename, flags, mode);
3181 #ifdef HAS_LOCALECONV
3182 struct lconv *lcbuf;
3184 if ((lcbuf = localeconv())) {
3186 if (lcbuf->decimal_point && *lcbuf->decimal_point)
3187 hv_store(RETVAL, "decimal_point", 13,
3188 newSVpv(lcbuf->decimal_point, 0), 0);
3189 if (lcbuf->thousands_sep && *lcbuf->thousands_sep)
3190 hv_store(RETVAL, "thousands_sep", 13,
3191 newSVpv(lcbuf->thousands_sep, 0), 0);
3192 #ifndef NO_LOCALECONV_GROUPING
3193 if (lcbuf->grouping && *lcbuf->grouping)
3194 hv_store(RETVAL, "grouping", 8,
3195 newSVpv(lcbuf->grouping, 0), 0);
3197 if (lcbuf->int_curr_symbol && *lcbuf->int_curr_symbol)
3198 hv_store(RETVAL, "int_curr_symbol", 15,
3199 newSVpv(lcbuf->int_curr_symbol, 0), 0);
3200 if (lcbuf->currency_symbol && *lcbuf->currency_symbol)
3201 hv_store(RETVAL, "currency_symbol", 15,
3202 newSVpv(lcbuf->currency_symbol, 0), 0);
3203 if (lcbuf->mon_decimal_point && *lcbuf->mon_decimal_point)
3204 hv_store(RETVAL, "mon_decimal_point", 17,
3205 newSVpv(lcbuf->mon_decimal_point, 0), 0);
3206 #ifndef NO_LOCALECONV_MON_THOUSANDS_SEP
3207 if (lcbuf->mon_thousands_sep && *lcbuf->mon_thousands_sep)
3208 hv_store(RETVAL, "mon_thousands_sep", 17,
3209 newSVpv(lcbuf->mon_thousands_sep, 0), 0);
3211 #ifndef NO_LOCALECONV_MON_GROUPING
3212 if (lcbuf->mon_grouping && *lcbuf->mon_grouping)
3213 hv_store(RETVAL, "mon_grouping", 12,
3214 newSVpv(lcbuf->mon_grouping, 0), 0);
3216 if (lcbuf->positive_sign && *lcbuf->positive_sign)
3217 hv_store(RETVAL, "positive_sign", 13,
3218 newSVpv(lcbuf->positive_sign, 0), 0);
3219 if (lcbuf->negative_sign && *lcbuf->negative_sign)
3220 hv_store(RETVAL, "negative_sign", 13,
3221 newSVpv(lcbuf->negative_sign, 0), 0);
3223 if (lcbuf->int_frac_digits != CHAR_MAX)
3224 hv_store(RETVAL, "int_frac_digits", 15,
3225 newSViv(lcbuf->int_frac_digits), 0);
3226 if (lcbuf->frac_digits != CHAR_MAX)
3227 hv_store(RETVAL, "frac_digits", 11,
3228 newSViv(lcbuf->frac_digits), 0);
3229 if (lcbuf->p_cs_precedes != CHAR_MAX)
3230 hv_store(RETVAL, "p_cs_precedes", 13,
3231 newSViv(lcbuf->p_cs_precedes), 0);
3232 if (lcbuf->p_sep_by_space != CHAR_MAX)
3233 hv_store(RETVAL, "p_sep_by_space", 14,
3234 newSViv(lcbuf->p_sep_by_space), 0);
3235 if (lcbuf->n_cs_precedes != CHAR_MAX)
3236 hv_store(RETVAL, "n_cs_precedes", 13,
3237 newSViv(lcbuf->n_cs_precedes), 0);
3238 if (lcbuf->n_sep_by_space != CHAR_MAX)
3239 hv_store(RETVAL, "n_sep_by_space", 14,
3240 newSViv(lcbuf->n_sep_by_space), 0);
3241 if (lcbuf->p_sign_posn != CHAR_MAX)
3242 hv_store(RETVAL, "p_sign_posn", 11,
3243 newSViv(lcbuf->p_sign_posn), 0);
3244 if (lcbuf->n_sign_posn != CHAR_MAX)
3245 hv_store(RETVAL, "n_sign_posn", 11,
3246 newSViv(lcbuf->n_sign_posn), 0);
3249 localeconv(); /* A stub to call not_here(). */
3255 setlocale(category, locale = 0)
3259 RETVAL = setlocale(category, locale);
3261 #ifdef USE_LOCALE_CTYPE
3262 if (category == LC_CTYPE
3264 || category == LC_ALL
3270 if (category == LC_ALL)
3271 newctype = setlocale(LC_CTYPE, NULL);
3275 new_ctype(newctype);
3277 #endif /* USE_LOCALE_CTYPE */
3278 #ifdef USE_LOCALE_COLLATE
3279 if (category == LC_COLLATE
3281 || category == LC_ALL
3287 if (category == LC_ALL)
3288 newcoll = setlocale(LC_COLLATE, NULL);
3292 new_collate(newcoll);
3294 #endif /* USE_LOCALE_COLLATE */
3295 #ifdef USE_LOCALE_NUMERIC
3296 if (category == LC_NUMERIC
3298 || category == LC_ALL
3304 if (category == LC_ALL)
3305 newnum = setlocale(LC_NUMERIC, NULL);
3309 new_numeric(newnum);
3311 #endif /* USE_LOCALE_NUMERIC */
3351 /* (We already know stack is long enough.) */
3352 PUSHs(sv_2mortal(newSVnv(frexp(x,&expvar))));
3353 PUSHs(sv_2mortal(newSViv(expvar)));
3369 /* (We already know stack is long enough.) */
3370 PUSHs(sv_2mortal(newSVnv(Perl_modf(x,&intvar))));
3371 PUSHs(sv_2mortal(newSVnv(intvar)));
3386 sigaction(sig, optaction, oldaction = 0)
3389 POSIX::SigAction oldaction
3392 RETVAL = not_here("sigaction");
3394 # This code is really grody because we're trying to make the signal
3395 # interface look beautiful, which is hard.
3398 POSIX__SigAction action;
3399 GV *siggv = gv_fetchpv("SIG", TRUE, SVt_PVHV);
3400 struct sigaction act;
3401 struct sigaction oact;
3404 POSIX__SigSet sigset;
3406 SV** sigsvp = hv_fetch(GvHVn(siggv),
3408 strlen(PL_sig_name[sig]),
3412 /* Check optaction and set action */
3413 if(SvTRUE(optaction)) {
3414 if(sv_isa(optaction, "POSIX::SigAction"))
3415 action = (HV*)SvRV(optaction);
3417 croak("action is not of type POSIX::SigAction");
3423 /* sigaction() is supposed to look atomic. In particular, any
3424 * signal handler invoked during a sigaction() call should
3425 * see either the old or the new disposition, and not something
3426 * in between. We use sigprocmask() to make it so.
3429 RETVAL=sigprocmask(SIG_BLOCK, &sset, &osset);
3433 /* Restore signal mask no matter how we exit this block. */
3434 SAVEDESTRUCTOR(restore_sigmask, &osset);
3436 RETVAL=-1; /* In case both oldaction and action are 0. */
3438 /* Remember old disposition if desired. */
3440 svp = hv_fetch(oldaction, "HANDLER", 7, TRUE);
3442 croak("Can't supply an oldaction without a HANDLER");
3443 if(SvTRUE(*sigsvp)) { /* TBD: what if "0"? */
3444 sv_setsv(*svp, *sigsvp);
3447 sv_setpv(*svp, "DEFAULT");
3449 RETVAL = sigaction(sig, (struct sigaction *)0, & oact);
3452 /* Get back the mask. */
3453 svp = hv_fetch(oldaction, "MASK", 4, TRUE);
3454 if (sv_isa(*svp, "POSIX::SigSet")) {
3455 IV tmp = SvIV((SV*)SvRV(*svp));
3456 sigset = INT2PTR(sigset_t*, tmp);
3459 New(0, sigset, 1, sigset_t);
3460 sv_setptrobj(*svp, sigset, "POSIX::SigSet");
3462 *sigset = oact.sa_mask;
3464 /* Get back the flags. */
3465 svp = hv_fetch(oldaction, "FLAGS", 5, TRUE);
3466 sv_setiv(*svp, oact.sa_flags);
3470 /* Vector new handler through %SIG. (We always use sighandler
3471 for the C signal handler, which reads %SIG to dispatch.) */
3472 svp = hv_fetch(action, "HANDLER", 7, FALSE);
3474 croak("Can't supply an action without a HANDLER");
3475 sv_setsv(*sigsvp, *svp);
3476 mg_set(*sigsvp); /* handles DEFAULT and IGNORE */
3478 char *s=SvPVX(*svp);
3479 if(strEQ(s,"IGNORE")) {
3480 act.sa_handler = SIG_IGN;
3482 else if(strEQ(s,"DEFAULT")) {
3483 act.sa_handler = SIG_DFL;
3486 act.sa_handler = PL_sighandlerp;
3490 act.sa_handler = PL_sighandlerp;
3493 /* Set up any desired mask. */
3494 svp = hv_fetch(action, "MASK", 4, FALSE);
3495 if (svp && sv_isa(*svp, "POSIX::SigSet")) {
3496 IV tmp = SvIV((SV*)SvRV(*svp));
3497 sigset = INT2PTR(sigset_t*, tmp);
3498 act.sa_mask = *sigset;
3501 sigemptyset(& act.sa_mask);
3503 /* Set up any desired flags. */
3504 svp = hv_fetch(action, "FLAGS", 5, FALSE);
3505 act.sa_flags = svp ? SvIV(*svp) : 0;
3507 /* Don't worry about cleaning up *sigsvp if this fails,
3508 * because that means we tried to disposition a
3509 * nonblockable signal, in which case *sigsvp is
3510 * essentially meaningless anyway.
3512 RETVAL = sigaction(sig, & act, (struct sigaction *)0);
3523 POSIX::SigSet sigset
3526 sigprocmask(how, sigset, oldsigset = 0)
3528 POSIX::SigSet sigset
3529 POSIX::SigSet oldsigset = NO_INIT
3534 else if (sv_derived_from(ST(2), "POSIX::SigSet")) {
3535 IV tmp = SvIV((SV*)SvRV(ST(2)));
3536 oldsigset = INT2PTR(POSIX__SigSet,tmp);
3539 New(0, oldsigset, 1, sigset_t);
3540 sigemptyset(oldsigset);
3541 sv_setref_pv(ST(2), "POSIX::SigSet", (void*)oldsigset);
3545 sigsuspend(signal_mask)
3546 POSIX::SigSet signal_mask
3566 lseek(fd, offset, whence)
3579 if (pipe(fds) != -1) {
3581 PUSHs(sv_2mortal(newSViv(fds[0])));
3582 PUSHs(sv_2mortal(newSViv(fds[1])));
3586 read(fd, buffer, nbytes)
3588 SV *sv_buffer = SvROK(ST(1)) ? SvRV(ST(1)) : ST(1);
3592 char * buffer = sv_grow( sv_buffer, nbytes+1 );
3595 SvCUR(sv_buffer) = RETVAL;
3596 SvPOK_only(sv_buffer);
3597 *SvEND(sv_buffer) = '\0';
3598 SvTAINTED_on(sv_buffer);
3614 tcsetpgrp(fd, pgrp_id)
3623 if (uname(&buf) >= 0) {
3625 PUSHs(sv_2mortal(newSVpv(buf.sysname, 0)));
3626 PUSHs(sv_2mortal(newSVpv(buf.nodename, 0)));
3627 PUSHs(sv_2mortal(newSVpv(buf.release, 0)));
3628 PUSHs(sv_2mortal(newSVpv(buf.version, 0)));
3629 PUSHs(sv_2mortal(newSVpv(buf.machine, 0)));
3632 uname((char *) 0); /* A stub to call not_here(). */
3636 write(fd, buffer, nbytes)
3647 RETVAL = newSVpvn("", 0);
3648 SvGROW(RETVAL, L_tmpnam);
3649 len = strlen(tmpnam(SvPV(RETVAL, i)));
3650 SvCUR_set(RETVAL, len);
3663 mbstowcs(s, pwcs, n)
3675 wcstombs(s, pwcs, n)
3697 SET_NUMERIC_LOCAL();
3698 num = strtod(str, &unparsed);
3699 PUSHs(sv_2mortal(newSVnv(num)));
3700 if (GIMME == G_ARRAY) {
3703 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3705 PUSHs(&PL_sv_undef);
3709 strtol(str, base = 0)
3716 num = strtol(str, &unparsed, base);
3717 #if IVSIZE <= LONGSIZE
3718 if (num < IV_MIN || num > IV_MAX)
3719 PUSHs(sv_2mortal(newSVnv((double)num)));
3722 PUSHs(sv_2mortal(newSViv((IV)num)));
3723 if (GIMME == G_ARRAY) {
3726 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3728 PUSHs(&PL_sv_undef);
3732 strtoul(str, base = 0)
3739 num = strtoul(str, &unparsed, base);
3741 PUSHs(sv_2mortal(newSViv((IV)num)));
3743 PUSHs(sv_2mortal(newSVnv((double)num)));
3744 if (GIMME == G_ARRAY) {
3747 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3749 PUSHs(&PL_sv_undef);
3759 char *p = SvPV(src,srclen);
3761 ST(0) = sv_2mortal(NEWSV(800,srclen));
3762 dstlen = strxfrm(SvPVX(ST(0)), p, (size_t)srclen);
3763 if (dstlen > srclen) {
3765 SvGROW(ST(0), dstlen);
3766 strxfrm(SvPVX(ST(0)), p, (size_t)dstlen);
3769 SvCUR(ST(0)) = dstlen;
3774 mkfifo(filename, mode)
3778 TAINT_PROPER("mkfifo");
3779 RETVAL = mkfifo(filename, mode);
3795 tcflush(fd, queue_selector)
3800 tcsendbreak(fd, duration)
3805 asctime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3818 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3821 mytm.tm_hour = hour;
3822 mytm.tm_mday = mday;
3824 mytm.tm_year = year;
3825 mytm.tm_wday = wday;
3826 mytm.tm_yday = yday;
3827 mytm.tm_isdst = isdst;
3828 RETVAL = asctime(&mytm);
3845 realtime = times( &tms );
3847 PUSHs( sv_2mortal( newSViv( (IV) realtime ) ) );
3848 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_utime ) ) );
3849 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_stime ) ) );
3850 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cutime ) ) );
3851 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cstime ) ) );
3854 difftime(time1, time2)
3859 mktime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3872 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3875 mytm.tm_hour = hour;
3876 mytm.tm_mday = mday;
3878 mytm.tm_year = year;
3879 mytm.tm_wday = wday;
3880 mytm.tm_yday = yday;
3881 mytm.tm_isdst = isdst;
3882 RETVAL = mktime(&mytm);
3887 #XXX: if $xsubpp::WantOptimize is always the default
3888 # sv_setpv(TARG, ...) could be used rather than
3889 # ST(0) = sv_2mortal(newSVpv(...))
3891 strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1)
3907 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3910 mytm.tm_hour = hour;
3911 mytm.tm_mday = mday;
3913 mytm.tm_year = year;
3914 mytm.tm_wday = wday;
3915 mytm.tm_yday = yday;
3916 mytm.tm_isdst = isdst;
3918 len = strftime(tmpbuf, sizeof tmpbuf, fmt, &mytm);
3920 ** The following is needed to handle to the situation where
3921 ** tmpbuf overflows. Basically we want to allocate a buffer
3922 ** and try repeatedly. The reason why it is so complicated
3923 ** is that getting a return value of 0 from strftime can indicate
3924 ** one of the following:
3925 ** 1. buffer overflowed,
3926 ** 2. illegal conversion specifier, or
3927 ** 3. the format string specifies nothing to be returned(not
3928 ** an error). This could be because format is an empty string
3929 ** or it specifies %p that yields an empty string in some locale.
3930 ** If there is a better way to make it portable, go ahead by
3933 if ((len > 0 && len < sizeof(tmpbuf)) || (len == 0 && *fmt == '\0'))
3934 ST(0) = sv_2mortal(newSVpv(tmpbuf, len));
3936 /* Possibly buf overflowed - try again with a bigger buf */
3937 int fmtlen = strlen(fmt);
3938 int bufsize = fmtlen + sizeof(tmpbuf);
3942 New(0, buf, bufsize, char);
3944 buflen = strftime(buf, bufsize, fmt, &mytm);
3945 if (buflen > 0 && buflen < bufsize)
3947 /* heuristic to prevent out-of-memory errors */
3948 if (bufsize > 100*fmtlen) {
3954 Renew(buf, bufsize, char);
3957 ST(0) = sv_2mortal(newSVpvn(buf, buflen));
3961 ST(0) = sv_2mortal(newSVpvn(tmpbuf, len));
3972 PUSHs(sv_2mortal(newSVpvn(tzname[0],strlen(tzname[0]))));
3973 PUSHs(sv_2mortal(newSVpvn(tzname[1],strlen(tzname[1]))));
3976 access(filename, mode)
3994 pathconf(filename, name)