5 #define PERL_NO_GET_CONTEXT
8 #define PERLIO_NOT_STDIO 1
11 #if defined(PERL_OBJECT) || defined(PERL_CAPI) || defined(PERL_IMPLICIT_SYS)
15 # define open PerlLIO_open3
18 #ifdef I_DIRENT /* XXX maybe better to just rely on perl.h? */
45 /* XXX This comment is just to make I_TERMIO and I_SGTTY visible to
46 metaconfig for future extension writers. We don't use them in POSIX.
47 (This is really sneaky :-) --AD
49 #if defined(I_TERMIOS)
57 #include <sys/types.h>
62 #ifdef MACOS_TRADITIONAL
67 #if defined(__VMS) && !defined(__POSIX_SOURCE)
68 # include <libdef.h> /* LIB$_INVARG constant */
69 # include <lib$routines.h> /* prototype for lib$ediv() */
70 # include <starlet.h> /* prototype for sys$gettim() */
71 # if DECC_VERSION < 50000000
72 # define pid_t int /* old versions of DECC miss this in types.h */
76 # define mkfifo(a,b) (not_here("mkfifo"),-1)
77 # define tzset() not_here("tzset")
79 #if ((__VMS_VER >= 70000000) && (__DECC_VER >= 50200000)) || (__CRTL_VER >= 70000000)
80 # define HAS_TZNAME /* shows up in VMS 7.0 or Dec C 5.6 */
82 # endif /* __VMS_VER >= 70000000 or Dec C 5.6 */
84 /* The POSIX notion of ttyname() is better served by getname() under VMS */
85 static char ttnambuf[64];
86 # define ttyname(fd) (isatty(fd) > 0 ? getname(fd,ttnambuf,0) : NULL)
88 /* The non-POSIX CRTL times() has void return type, so we just get the
89 current time directly */
90 clock_t vms_times(struct tms *bufptr) {
93 /* Get wall time and convert to 10 ms intervals to
94 * produce the return value that the POSIX standard expects */
95 # if defined(__DECC) && defined (__ALPHA)
98 _ckvmssts(sys$gettim(&vmstime));
100 retval = vmstime & 0x7fffffff;
102 /* (Older hw or ccs don't have an atomic 64-bit type, so we
103 * juggle 32-bit ints (and a float) to produce a time_t result
104 * with minimal loss of information.) */
105 long int vmstime[2],remainder,divisor = 100000;
106 _ckvmssts(sys$gettim((unsigned long int *)vmstime));
107 vmstime[1] &= 0x7fff; /* prevent overflow in EDIV */
108 _ckvmssts(lib$ediv(&divisor,vmstime,(long int *)&retval,&remainder));
110 /* Fill in the struct tms using the CRTL routine . . .*/
111 times((tbuffer_t *)bufptr);
112 return (clock_t) retval;
114 # define times(t) vms_times(t)
116 #if defined (__CYGWIN__)
117 # define tzname _tzname
121 # define mkfifo(a,b) not_here("mkfifo")
122 # define ttyname(a) (char*)not_here("ttyname")
123 # define sigset_t long
126 # define tzname _tzname
129 # define mode_t short
132 # define mode_t short
134 # define tzset() not_here("tzset")
136 # ifndef _POSIX_OPEN_MAX
137 # define _POSIX_OPEN_MAX FOPEN_MAX /* XXX bogus ? */
140 # define sigaction(a,b,c) not_here("sigaction")
141 # define sigpending(a) not_here("sigpending")
142 # define sigprocmask(a,b,c) not_here("sigprocmask")
143 # define sigsuspend(a) not_here("sigsuspend")
144 # define sigemptyset(a) not_here("sigemptyset")
145 # define sigaddset(a,b) not_here("sigaddset")
146 # define sigdelset(a,b) not_here("sigdelset")
147 # define sigfillset(a) not_here("sigfillset")
148 # define sigismember(a,b) not_here("sigismember")
152 # if defined(OS2) || defined(MACOS_TRADITIONAL)
153 # define mkfifo(a,b) not_here("mkfifo")
154 # else /* !( defined OS2 ) */
156 # define mkfifo(path, mode) (mknod((path), (mode) | S_IFIFO, 0))
159 # endif /* !HAS_MKFIFO */
161 # ifdef MACOS_TRADITIONAL
162 # define ttyname(a) (char*)not_here("ttyname")
163 # define tzset() not_here("tzset")
166 # include <sys/times.h>
168 # include <sys/utsname.h>
170 # include <sys/wait.h>
179 typedef long SysRetLong;
180 typedef sigset_t* POSIX__SigSet;
181 typedef HV* POSIX__SigAction;
183 typedef struct termios* POSIX__Termios;
184 #else /* Define termios types to int, and call not_here for the functions.*/
185 #define POSIX__Termios int
189 #define cfgetispeed(x) not_here("cfgetispeed")
190 #define cfgetospeed(x) not_here("cfgetospeed")
191 #define tcdrain(x) not_here("tcdrain")
192 #define tcflush(x,y) not_here("tcflush")
193 #define tcsendbreak(x,y) not_here("tcsendbreak")
194 #define cfsetispeed(x,y) not_here("cfsetispeed")
195 #define cfsetospeed(x,y) not_here("cfsetospeed")
196 #define ctermid(x) (char *) not_here("ctermid")
197 #define tcflow(x,y) not_here("tcflow")
198 #define tcgetattr(x,y) not_here("tcgetattr")
199 #define tcsetattr(x,y,z) not_here("tcsetattr")
202 /* Possibly needed prototypes */
203 char *cuserid (char *);
204 double strtod (const char *, char **);
205 long strtol (const char *, char **, int);
206 unsigned long strtoul (const char *, char **, int);
209 #define cuserid(a) (char *) not_here("cuserid")
213 #define difftime(a,b) not_here("difftime")
216 #ifndef HAS_FPATHCONF
217 #define fpathconf(f,n) (SysRetLong) not_here("fpathconf")
220 #define mktime(a) not_here("mktime")
223 #define nice(a) not_here("nice")
226 #define pathconf(f,n) (SysRetLong) not_here("pathconf")
229 #define sysconf(n) (SysRetLong) not_here("sysconf")
232 #define readlink(a,b,c) not_here("readlink")
235 #define setpgid(a,b) not_here("setpgid")
238 #define setsid() not_here("setsid")
241 #define strcoll(s1,s2) not_here("strcoll")
244 #define strtod(s1,s2) not_here("strtod")
247 #define strtol(s1,s2,b) not_here("strtol")
250 #define strtoul(s1,s2,b) not_here("strtoul")
253 #define strxfrm(s1,s2,n) not_here("strxfrm")
255 #ifndef HAS_TCGETPGRP
256 #define tcgetpgrp(a) not_here("tcgetpgrp")
258 #ifndef HAS_TCSETPGRP
259 #define tcsetpgrp(a,b) not_here("tcsetpgrp")
262 #define times(a) not_here("times")
265 #define uname(a) not_here("uname")
268 #define waitpid(a,b,c) not_here("waitpid")
273 #define mblen(a,b) not_here("mblen")
277 #define mbstowcs(s, pwcs, n) not_here("mbstowcs")
280 #define mbtowc(pwc, s, n) not_here("mbtowc")
283 #define wcstombs(s, pwcs, n) not_here("wcstombs")
286 #define wctomb(s, wchar) not_here("wcstombs")
288 #if !defined(HAS_MBLEN) && !defined(HAS_MBSTOWCS) && !defined(HAS_MBTOWC) && !defined(HAS_WCSTOMBS) && !defined(HAS_WCTOMB)
289 /* If we don't have these functions, then we wouldn't have gotten a typedef
290 for wchar_t, the wide character type. Defining wchar_t allows the
291 functions referencing it to compile. Its actual type is then meaningless,
292 since without the above functions, all sections using it end up calling
293 not_here() and croak. --Kaveh Ghazi (ghazi@noc.rutgers.edu) 9/18/94. */
299 #ifndef HAS_LOCALECONV
300 #define localeconv() not_here("localeconv")
304 # if !defined(WIN32) && !defined(__CYGWIN__)
305 extern char *tzname[];
308 #if !defined(WIN32) || (defined(__MINGW32__) && !defined(tzname))
309 char *tzname[] = { "" , "" };
313 /* XXX struct tm on some systems (SunOS4/BSD) contains extra (non POSIX)
314 * fields for which we don't have Configure support yet:
315 * char *tm_zone; -- abbreviation of timezone name
316 * long tm_gmtoff; -- offset from GMT in seconds
317 * To workaround core dumps from the uninitialised tm_zone we get the
318 * system to give us a reasonable struct to copy. This fix means that
319 * strftime uses the tm_zone and tm_gmtoff values returned by
320 * localtime(time()). That should give the desired result most of the
321 * time. But probably not always!
323 * This is a temporary workaround to be removed once Configure
324 * support is added and NETaa14816 is considered in full.
325 * It does not address tzname aspects of NETaa14816.
328 # ifndef STRUCT_TM_HASZONE
329 # define STRUCT_TM_HASZONE
333 #ifdef STRUCT_TM_HASZONE
335 init_tm(struct tm *ptm) /* see mktime, strftime and asctime */
339 Copy(localtime(&now), ptm, 1, struct tm);
343 # define init_tm(ptm)
347 * mini_mktime - normalise struct tm values without the localtime()
348 * semantics (and overhead) of mktime().
351 mini_mktime(struct tm *ptm)
355 int month, mday, year, jday;
356 int odd_cent, odd_year;
358 #define DAYS_PER_YEAR 365
359 #define DAYS_PER_QYEAR (4*DAYS_PER_YEAR+1)
360 #define DAYS_PER_CENT (25*DAYS_PER_QYEAR-1)
361 #define DAYS_PER_QCENT (4*DAYS_PER_CENT+1)
362 #define SECS_PER_HOUR (60*60)
363 #define SECS_PER_DAY (24*SECS_PER_HOUR)
364 /* parentheses deliberately absent on these two, otherwise they don't work */
365 #define MONTH_TO_DAYS 153/5
366 #define DAYS_TO_MONTH 5/153
367 /* offset to bias by March (month 4) 1st between month/mday & year finding */
368 #define YEAR_ADJUST (4*MONTH_TO_DAYS+1)
369 /* as used here, the algorithm leaves Sunday as day 1 unless we adjust it */
370 #define WEEKDAY_BIAS 6 /* (1+6)%7 makes Sunday 0 again */
373 * Year/day algorithm notes:
375 * With a suitable offset for numeric value of the month, one can find
376 * an offset into the year by considering months to have 30.6 (153/5) days,
377 * using integer arithmetic (i.e., with truncation). To avoid too much
378 * messing about with leap days, we consider January and February to be
379 * the 13th and 14th month of the previous year. After that transformation,
380 * we need the month index we use to be high by 1 from 'normal human' usage,
381 * so the month index values we use run from 4 through 15.
383 * Given that, and the rules for the Gregorian calendar (leap years are those
384 * divisible by 4 unless also divisible by 100, when they must be divisible
385 * by 400 instead), we can simply calculate the number of days since some
386 * arbitrary 'beginning of time' by futzing with the (adjusted) year number,
387 * the days we derive from our month index, and adding in the day of the
388 * month. The value used here is not adjusted for the actual origin which
389 * it normally would use (1 January A.D. 1), since we're not exposing it.
390 * We're only building the value so we can turn around and get the
391 * normalised values for the year, month, day-of-month, and day-of-year.
393 * For going backward, we need to bias the value we're using so that we find
394 * the right year value. (Basically, we don't want the contribution of
395 * March 1st to the number to apply while deriving the year). Having done
396 * that, we 'count up' the contribution to the year number by accounting for
397 * full quadracenturies (400-year periods) with their extra leap days, plus
398 * the contribution from full centuries (to avoid counting in the lost leap
399 * days), plus the contribution from full quad-years (to count in the normal
400 * leap days), plus the leftover contribution from any non-leap years.
401 * At this point, if we were working with an actual leap day, we'll have 0
402 * days left over. This is also true for March 1st, however. So, we have
403 * to special-case that result, and (earlier) keep track of the 'odd'
404 * century and year contributions. If we got 4 extra centuries in a qcent,
405 * or 4 extra years in a qyear, then it's a leap day and we call it 29 Feb.
406 * Otherwise, we add back in the earlier bias we removed (the 123 from
407 * figuring in March 1st), find the month index (integer division by 30.6),
408 * and the remainder is the day-of-month. We then have to convert back to
409 * 'real' months (including fixing January and February from being 14/15 in
410 * the previous year to being in the proper year). After that, to get
411 * tm_yday, we work with the normalised year and get a new yearday value for
412 * January 1st, which we subtract from the yearday value we had earlier,
413 * representing the date we've re-built. This is done from January 1
414 * because tm_yday is 0-origin.
416 * Since POSIX time routines are only guaranteed to work for times since the
417 * UNIX epoch (00:00:00 1 Jan 1970 UTC), the fact that this algorithm
418 * applies Gregorian calendar rules even to dates before the 16th century
419 * doesn't bother me. Besides, you'd need cultural context for a given
420 * date to know whether it was Julian or Gregorian calendar, and that's
421 * outside the scope for this routine. Since we convert back based on the
422 * same rules we used to build the yearday, you'll only get strange results
423 * for input which needed normalising, or for the 'odd' century years which
424 * were leap years in the Julian calander but not in the Gregorian one.
425 * I can live with that.
427 * This algorithm also fails to handle years before A.D. 1 gracefully, but
428 * that's still outside the scope for POSIX time manipulation, so I don't
432 year = 1900 + ptm->tm_year;
435 /* allow given yday with no month & mday to dominate the result */
436 if (ptm->tm_yday >= 0 && mday <= 0 && month <= 0) {
439 jday = 1 + ptm->tm_yday;
448 yearday = DAYS_PER_YEAR * year + year/4 - year/100 + year/400;
449 yearday += month*MONTH_TO_DAYS + mday + jday;
451 * Note that we don't know when leap-seconds were or will be,
452 * so we have to trust the user if we get something which looks
453 * like a sensible leap-second. Wild values for seconds will
454 * be rationalised, however.
456 if ((unsigned) ptm->tm_sec <= 60) {
463 secs += 60 * ptm->tm_min;
464 secs += SECS_PER_HOUR * ptm->tm_hour;
466 if (secs-(secs/SECS_PER_DAY*SECS_PER_DAY) < 0) {
467 /* got negative remainder, but need positive time */
468 /* back off an extra day to compensate */
469 yearday += (secs/SECS_PER_DAY)-1;
470 secs -= SECS_PER_DAY * (secs/SECS_PER_DAY - 1);
473 yearday += (secs/SECS_PER_DAY);
474 secs -= SECS_PER_DAY * (secs/SECS_PER_DAY);
477 else if (secs >= SECS_PER_DAY) {
478 yearday += (secs/SECS_PER_DAY);
479 secs %= SECS_PER_DAY;
481 ptm->tm_hour = secs/SECS_PER_HOUR;
482 secs %= SECS_PER_HOUR;
483 ptm->tm_min = secs/60;
486 /* done with time of day effects */
488 * The algorithm for yearday has (so far) left it high by 428.
489 * To avoid mistaking a legitimate Feb 29 as Mar 1, we need to
490 * bias it by 123 while trying to figure out what year it
491 * really represents. Even with this tweak, the reverse
492 * translation fails for years before A.D. 0001.
493 * It would still fail for Feb 29, but we catch that one below.
495 jday = yearday; /* save for later fixup vis-a-vis Jan 1 */
496 yearday -= YEAR_ADJUST;
497 year = (yearday / DAYS_PER_QCENT) * 400;
498 yearday %= DAYS_PER_QCENT;
499 odd_cent = yearday / DAYS_PER_CENT;
500 year += odd_cent * 100;
501 yearday %= DAYS_PER_CENT;
502 year += (yearday / DAYS_PER_QYEAR) * 4;
503 yearday %= DAYS_PER_QYEAR;
504 odd_year = yearday / DAYS_PER_YEAR;
506 yearday %= DAYS_PER_YEAR;
507 if (!yearday && (odd_cent==4 || odd_year==4)) { /* catch Feb 29 */
512 yearday += YEAR_ADJUST; /* recover March 1st crock */
513 month = yearday*DAYS_TO_MONTH;
514 yearday -= month*MONTH_TO_DAYS;
515 /* recover other leap-year adjustment */
524 ptm->tm_year = year - 1900;
526 ptm->tm_mday = yearday;
531 ptm->tm_mon = month - 1;
533 /* re-build yearday based on Jan 1 to get tm_yday */
535 yearday = year*DAYS_PER_YEAR + year/4 - year/100 + year/400;
536 yearday += 14*MONTH_TO_DAYS + 1;
537 ptm->tm_yday = jday - yearday;
538 /* fix tm_wday if not overridden by caller */
539 if ((unsigned)ptm->tm_wday > 6)
540 ptm->tm_wday = (jday + WEEKDAY_BIAS) % 7;
543 #ifdef HAS_LONG_DOUBLE
544 # if LONG_DOUBLESIZE > NVSIZE
545 # undef HAS_LONG_DOUBLE /* XXX until we figure out how to use them */
549 #ifndef HAS_LONG_DOUBLE
564 croak("POSIX::%s not implemented on this architecture", s);
570 constant(char *name, int arg)
575 if (strEQ(name, "ARG_MAX"))
583 if (strEQ(name, "BUFSIZ"))
589 if (strEQ(name, "BRKINT"))
595 if (strEQ(name, "B9600"))
601 if (strEQ(name, "B19200"))
607 if (strEQ(name, "B38400"))
613 if (strEQ(name, "B0"))
619 if (strEQ(name, "B110"))
625 if (strEQ(name, "B1200"))
631 if (strEQ(name, "B134"))
637 if (strEQ(name, "B150"))
643 if (strEQ(name, "B1800"))
649 if (strEQ(name, "B200"))
655 if (strEQ(name, "B2400"))
661 if (strEQ(name, "B300"))
667 if (strEQ(name, "B4800"))
673 if (strEQ(name, "B50"))
679 if (strEQ(name, "B600"))
685 if (strEQ(name, "B75"))
693 if (strEQ(name, "CHAR_BIT"))
699 if (strEQ(name, "CHAR_MAX"))
705 if (strEQ(name, "CHAR_MIN"))
711 if (strEQ(name, "CHILD_MAX"))
717 if (strEQ(name, "CLK_TCK"))
723 if (strEQ(name, "CLOCAL"))
729 if (strEQ(name, "CLOCKS_PER_SEC"))
730 #ifdef CLOCKS_PER_SEC
731 return CLOCKS_PER_SEC;
735 if (strEQ(name, "CREAD"))
741 if (strEQ(name, "CS5"))
747 if (strEQ(name, "CS6"))
753 if (strEQ(name, "CS7"))
759 if (strEQ(name, "CS8"))
765 if (strEQ(name, "CSIZE"))
771 if (strEQ(name, "CSTOPB"))
779 if (strEQ(name, "DBL_MAX"))
785 if (strEQ(name, "DBL_MIN"))
791 if (strEQ(name, "DBL_DIG"))
797 if (strEQ(name, "DBL_EPSILON"))
803 if (strEQ(name, "DBL_MANT_DIG"))
809 if (strEQ(name, "DBL_MAX_10_EXP"))
810 #ifdef DBL_MAX_10_EXP
811 return DBL_MAX_10_EXP;
815 if (strEQ(name, "DBL_MAX_EXP"))
821 if (strEQ(name, "DBL_MIN_10_EXP"))
822 #ifdef DBL_MIN_10_EXP
823 return DBL_MIN_10_EXP;
827 if (strEQ(name, "DBL_MIN_EXP"))
837 if (strEQ(name, "EACCES"))
843 if (strEQ(name, "EADDRINUSE"))
849 if (strEQ(name, "EADDRNOTAVAIL"))
851 return EADDRNOTAVAIL;
855 if (strEQ(name, "EAFNOSUPPORT"))
861 if (strEQ(name, "EAGAIN"))
867 if (strEQ(name, "EALREADY"))
875 if (strEQ(name, "EBADF"))
881 if (strEQ(name, "EBUSY"))
889 if (strEQ(name, "ECHILD"))
895 if (strEQ(name, "ECHO"))
901 if (strEQ(name, "ECHOE"))
907 if (strEQ(name, "ECHOK"))
913 if (strEQ(name, "ECHONL"))
919 if (strEQ(name, "ECONNABORTED"))
925 if (strEQ(name, "ECONNREFUSED"))
931 if (strEQ(name, "ECONNRESET"))
939 if (strEQ(name, "EDEADLK"))
945 if (strEQ(name, "EDESTADDRREQ"))
951 if (strEQ(name, "EDOM"))
957 if (strEQ(name, "EDQUOT"))
965 if (strEQ(name, "EEXIST"))
973 if (strEQ(name, "EFAULT"))
979 if (strEQ(name, "EFBIG"))
987 if (strEQ(name, "EHOSTDOWN"))
993 if (strEQ(name, "EHOSTUNREACH"))
1001 if (strEQ(name, "EINPROGRESS"))
1007 if (strEQ(name, "EINTR"))
1013 if (strEQ(name, "EINVAL"))
1019 if (strEQ(name, "EIO"))
1025 if (strEQ(name, "EISCONN"))
1031 if (strEQ(name, "EISDIR"))
1039 if (strEQ(name, "ELOOP"))
1047 if (strEQ(name, "EMFILE"))
1053 if (strEQ(name, "EMLINK"))
1059 if (strEQ(name, "EMSGSIZE"))
1067 if (strEQ(name, "ENETDOWN"))
1073 if (strEQ(name, "ENETRESET"))
1079 if (strEQ(name, "ENETUNREACH"))
1085 if (strEQ(name, "ENOBUFS"))
1091 if (strEQ(name, "ENOEXEC"))
1097 if (strEQ(name, "ENOMEM"))
1103 if (strEQ(name, "ENOPROTOOPT"))
1109 if (strEQ(name, "ENOSPC"))
1115 if (strEQ(name, "ENOTBLK"))
1121 if (strEQ(name, "ENOTCONN"))
1127 if (strEQ(name, "ENOTDIR"))
1133 if (strEQ(name, "ENOTEMPTY"))
1139 if (strEQ(name, "ENOTSOCK"))
1145 if (strEQ(name, "ENOTTY"))
1151 if (strEQ(name, "ENFILE"))
1157 if (strEQ(name, "ENODEV"))
1163 if (strEQ(name, "ENOENT"))
1169 if (strEQ(name, "ENOLCK"))
1175 if (strEQ(name, "ENOSYS"))
1181 if (strEQ(name, "ENXIO"))
1187 if (strEQ(name, "ENAMETOOLONG"))
1189 return ENAMETOOLONG;
1195 if (strEQ(name, "EOF"))
1201 if (strEQ(name, "EOPNOTSUPP"))
1209 if (strEQ(name, "EPERM"))
1215 if (strEQ(name, "EPFNOSUPPORT"))
1217 return EPFNOSUPPORT;
1221 if (strEQ(name, "EPIPE"))
1227 if (strEQ(name, "EPROCLIM"))
1233 if (strEQ(name, "EPROTONOSUPPORT"))
1234 #ifdef EPROTONOSUPPORT
1235 return EPROTONOSUPPORT;
1239 if (strEQ(name, "EPROTOTYPE"))
1247 if (strEQ(name, "ERANGE"))
1253 if (strEQ(name, "EREMOTE"))
1259 if (strEQ(name, "ERESTART"))
1265 if (strEQ(name, "EROFS"))
1273 if (strEQ(name, "ESHUTDOWN"))
1279 if (strEQ(name, "ESOCKTNOSUPPORT"))
1280 #ifdef ESOCKTNOSUPPORT
1281 return ESOCKTNOSUPPORT;
1285 if (strEQ(name, "ESPIPE"))
1291 if (strEQ(name, "ESRCH"))
1297 if (strEQ(name, "ESTALE"))
1305 if (strEQ(name, "ETIMEDOUT"))
1311 if (strEQ(name, "ETOOMANYREFS"))
1313 return ETOOMANYREFS;
1317 if (strEQ(name, "ETXTBSY"))
1325 if (strEQ(name, "EUSERS"))
1333 if (strEQ(name, "EWOULDBLOCK"))
1341 if (strEQ(name, "EXIT_FAILURE"))
1343 return EXIT_FAILURE;
1347 if (strEQ(name, "EXIT_SUCCESS"))
1349 return EXIT_SUCCESS;
1353 if (strEQ(name, "EXDEV"))
1361 if (strEQ(name, "E2BIG"))
1369 if (strnEQ(name, "FLT_", 4)) {
1370 if (strEQ(name, "FLT_MAX"))
1376 if (strEQ(name, "FLT_MIN"))
1382 if (strEQ(name, "FLT_ROUNDS"))
1388 if (strEQ(name, "FLT_DIG"))
1394 if (strEQ(name, "FLT_EPSILON"))
1400 if (strEQ(name, "FLT_MANT_DIG"))
1402 return FLT_MANT_DIG;
1406 if (strEQ(name, "FLT_MAX_10_EXP"))
1407 #ifdef FLT_MAX_10_EXP
1408 return FLT_MAX_10_EXP;
1412 if (strEQ(name, "FLT_MAX_EXP"))
1418 if (strEQ(name, "FLT_MIN_10_EXP"))
1419 #ifdef FLT_MIN_10_EXP
1420 return FLT_MIN_10_EXP;
1424 if (strEQ(name, "FLT_MIN_EXP"))
1430 if (strEQ(name, "FLT_RADIX"))
1438 if (strnEQ(name, "F_", 2)) {
1439 if (strEQ(name, "F_DUPFD"))
1445 if (strEQ(name, "F_GETFD"))
1451 if (strEQ(name, "F_GETFL"))
1457 if (strEQ(name, "F_GETLK"))
1463 if (strEQ(name, "F_OK"))
1469 if (strEQ(name, "F_RDLCK"))
1475 if (strEQ(name, "F_SETFD"))
1481 if (strEQ(name, "F_SETFL"))
1487 if (strEQ(name, "F_SETLK"))
1493 if (strEQ(name, "F_SETLKW"))
1499 if (strEQ(name, "F_UNLCK"))
1505 if (strEQ(name, "F_WRLCK"))
1513 if (strEQ(name, "FD_CLOEXEC"))
1519 if (strEQ(name, "FILENAME_MAX"))
1521 return FILENAME_MAX;
1527 if (strEQ(name, "HUGE_VAL"))
1528 #if defined(USE_LONG_DOUBLE) && defined(HUGE_VALL)
1529 /* HUGE_VALL is admittedly non-POSIX but if we are using long doubles
1530 * we might as well use long doubles. --jhi */
1538 if (strEQ(name, "HUPCL"))
1546 if (strEQ(name, "INT_MAX"))
1552 if (strEQ(name, "INT_MIN"))
1558 if (strEQ(name, "ICANON"))
1564 if (strEQ(name, "ICRNL"))
1570 if (strEQ(name, "IEXTEN"))
1576 if (strEQ(name, "IGNBRK"))
1582 if (strEQ(name, "IGNCR"))
1588 if (strEQ(name, "IGNPAR"))
1594 if (strEQ(name, "INLCR"))
1600 if (strEQ(name, "INPCK"))
1606 if (strEQ(name, "ISIG"))
1612 if (strEQ(name, "ISTRIP"))
1618 if (strEQ(name, "IXOFF"))
1624 if (strEQ(name, "IXON"))
1632 if (strnEQ(name, "LC_", 3)) {
1633 if (strEQ(name, "LC_ALL"))
1639 if (strEQ(name, "LC_COLLATE"))
1645 if (strEQ(name, "LC_CTYPE"))
1651 if (strEQ(name, "LC_MONETARY"))
1657 if (strEQ(name, "LC_NUMERIC"))
1663 if (strEQ(name, "LC_TIME"))
1671 if (strnEQ(name, "LDBL_", 5)) {
1672 if (strEQ(name, "LDBL_MAX"))
1678 if (strEQ(name, "LDBL_MIN"))
1684 if (strEQ(name, "LDBL_DIG"))
1690 if (strEQ(name, "LDBL_EPSILON"))
1692 return LDBL_EPSILON;
1696 if (strEQ(name, "LDBL_MANT_DIG"))
1697 #ifdef LDBL_MANT_DIG
1698 return LDBL_MANT_DIG;
1702 if (strEQ(name, "LDBL_MAX_10_EXP"))
1703 #ifdef LDBL_MAX_10_EXP
1704 return LDBL_MAX_10_EXP;
1708 if (strEQ(name, "LDBL_MAX_EXP"))
1710 return LDBL_MAX_EXP;
1714 if (strEQ(name, "LDBL_MIN_10_EXP"))
1715 #ifdef LDBL_MIN_10_EXP
1716 return LDBL_MIN_10_EXP;
1720 if (strEQ(name, "LDBL_MIN_EXP"))
1722 return LDBL_MIN_EXP;
1728 if (strnEQ(name, "L_", 2)) {
1729 if (strEQ(name, "L_ctermid"))
1735 if (strEQ(name, "L_cuserid"))
1741 /* L_tmpnam[e] was a typo--retained for compatibility */
1742 if (strEQ(name, "L_tmpname") || strEQ(name, "L_tmpnam"))
1750 if (strEQ(name, "LONG_MAX"))
1756 if (strEQ(name, "LONG_MIN"))
1762 if (strEQ(name, "LINK_MAX"))
1770 if (strEQ(name, "MAX_CANON"))
1776 if (strEQ(name, "MAX_INPUT"))
1782 if (strEQ(name, "MB_CUR_MAX"))
1788 if (strEQ(name, "MB_LEN_MAX"))
1796 if (strEQ(name, "NULL")) return 0;
1797 if (strEQ(name, "NAME_MAX"))
1803 if (strEQ(name, "NCCS"))
1809 if (strEQ(name, "NGROUPS_MAX"))
1815 if (strEQ(name, "NOFLSH"))
1823 if (strnEQ(name, "O_", 2)) {
1824 if (strEQ(name, "O_APPEND"))
1830 if (strEQ(name, "O_CREAT"))
1836 if (strEQ(name, "O_TRUNC"))
1842 if (strEQ(name, "O_RDONLY"))
1848 if (strEQ(name, "O_RDWR"))
1854 if (strEQ(name, "O_WRONLY"))
1860 if (strEQ(name, "O_EXCL"))
1866 if (strEQ(name, "O_NOCTTY"))
1872 if (strEQ(name, "O_NONBLOCK"))
1878 if (strEQ(name, "O_ACCMODE"))
1886 if (strEQ(name, "OPEN_MAX"))
1892 if (strEQ(name, "OPOST"))
1900 if (strEQ(name, "PATH_MAX"))
1906 if (strEQ(name, "PARENB"))
1912 if (strEQ(name, "PARMRK"))
1918 if (strEQ(name, "PARODD"))
1924 if (strEQ(name, "PIPE_BUF"))
1932 if (strEQ(name, "RAND_MAX"))
1938 if (strEQ(name, "R_OK"))
1946 if (strnEQ(name, "SIG", 3)) {
1947 if (name[3] == '_') {
1948 if (strEQ(name, "SIG_BLOCK"))
1955 if (strEQ(name, "SIG_DFL")) return (IV)SIG_DFL;
1958 if (strEQ(name, "SIG_ERR")) return (IV)SIG_ERR;
1961 if (strEQ(name, "SIG_IGN")) return (IV)SIG_IGN;
1963 if (strEQ(name, "SIG_SETMASK"))
1969 if (strEQ(name, "SIG_UNBLOCK"))
1977 if (strEQ(name, "SIGABRT"))
1983 if (strEQ(name, "SIGALRM"))
1989 if (strEQ(name, "SIGCHLD"))
1995 if (strEQ(name, "SIGCONT"))
2001 if (strEQ(name, "SIGFPE"))
2007 if (strEQ(name, "SIGHUP"))
2013 if (strEQ(name, "SIGILL"))
2019 if (strEQ(name, "SIGINT"))
2025 if (strEQ(name, "SIGKILL"))
2031 if (strEQ(name, "SIGPIPE"))
2037 if (strEQ(name, "SIGQUIT"))
2043 if (strEQ(name, "SIGSEGV"))
2049 if (strEQ(name, "SIGSTOP"))
2055 if (strEQ(name, "SIGTERM"))
2061 if (strEQ(name, "SIGTSTP"))
2067 if (strEQ(name, "SIGTTIN"))
2073 if (strEQ(name, "SIGTTOU"))
2079 if (strEQ(name, "SIGUSR1"))
2085 if (strEQ(name, "SIGUSR2"))
2093 if (name[1] == '_') {
2094 if (strEQ(name, "S_ISGID"))
2100 if (strEQ(name, "S_ISUID"))
2106 if (strEQ(name, "S_IRGRP"))
2112 if (strEQ(name, "S_IROTH"))
2118 if (strEQ(name, "S_IRUSR"))
2124 if (strEQ(name, "S_IRWXG"))
2130 if (strEQ(name, "S_IRWXO"))
2136 if (strEQ(name, "S_IRWXU"))
2142 if (strEQ(name, "S_IWGRP"))
2148 if (strEQ(name, "S_IWOTH"))
2154 if (strEQ(name, "S_IWUSR"))
2160 if (strEQ(name, "S_IXGRP"))
2166 if (strEQ(name, "S_IXOTH"))
2172 if (strEQ(name, "S_IXUSR"))
2178 errno = EAGAIN; /* the following aren't constants */
2180 if (strEQ(name, "S_ISBLK")) return S_ISBLK(arg);
2183 if (strEQ(name, "S_ISCHR")) return S_ISCHR(arg);
2186 if (strEQ(name, "S_ISDIR")) return S_ISDIR(arg);
2189 if (strEQ(name, "S_ISFIFO")) return S_ISFIFO(arg);
2192 if (strEQ(name, "S_ISREG")) return S_ISREG(arg);
2196 if (strEQ(name, "SEEK_CUR"))
2202 if (strEQ(name, "SEEK_END"))
2208 if (strEQ(name, "SEEK_SET"))
2214 if (strEQ(name, "STREAM_MAX"))
2220 if (strEQ(name, "SHRT_MAX"))
2226 if (strEQ(name, "SHRT_MIN"))
2232 if (strnEQ(name, "SA_", 3)) {
2233 if (strEQ(name, "SA_NOCLDSTOP"))
2235 return SA_NOCLDSTOP;
2239 if (strEQ(name, "SA_NOCLDWAIT"))
2241 return SA_NOCLDWAIT;
2245 if (strEQ(name, "SA_NODEFER"))
2251 if (strEQ(name, "SA_ONSTACK"))
2257 if (strEQ(name, "SA_RESETHAND"))
2259 return SA_RESETHAND;
2263 if (strEQ(name, "SA_RESTART"))
2269 if (strEQ(name, "SA_SIGINFO"))
2277 if (strEQ(name, "SCHAR_MAX"))
2283 if (strEQ(name, "SCHAR_MIN"))
2289 if (strEQ(name, "SSIZE_MAX"))
2295 if (strEQ(name, "STDIN_FILENO"))
2297 return STDIN_FILENO;
2301 if (strEQ(name, "STDOUT_FILENO"))
2302 #ifdef STDOUT_FILENO
2303 return STDOUT_FILENO;
2307 if (strEQ(name, "STDERR_FILENO"))
2308 #ifdef STDERR_FILENO
2309 return STDERR_FILENO;
2315 if (strEQ(name, "TCIFLUSH"))
2321 if (strEQ(name, "TCIOFF"))
2327 if (strEQ(name, "TCIOFLUSH"))
2333 if (strEQ(name, "TCION"))
2339 if (strEQ(name, "TCOFLUSH"))
2345 if (strEQ(name, "TCOOFF"))
2351 if (strEQ(name, "TCOON"))
2357 if (strEQ(name, "TCSADRAIN"))
2363 if (strEQ(name, "TCSAFLUSH"))
2369 if (strEQ(name, "TCSANOW"))
2375 if (strEQ(name, "TMP_MAX"))
2381 if (strEQ(name, "TOSTOP"))
2387 if (strEQ(name, "TZNAME_MAX"))
2395 if (strEQ(name, "UCHAR_MAX"))
2401 if (strEQ(name, "UINT_MAX"))
2407 if (strEQ(name, "ULONG_MAX"))
2413 if (strEQ(name, "USHRT_MAX"))
2421 if (strEQ(name, "VEOF"))
2427 if (strEQ(name, "VEOL"))
2433 if (strEQ(name, "VERASE"))
2439 if (strEQ(name, "VINTR"))
2445 if (strEQ(name, "VKILL"))
2451 if (strEQ(name, "VMIN"))
2457 if (strEQ(name, "VQUIT"))
2463 if (strEQ(name, "VSTART"))
2469 if (strEQ(name, "VSTOP"))
2475 if (strEQ(name, "VSUSP"))
2481 if (strEQ(name, "VTIME"))
2489 if (strEQ(name, "W_OK"))
2495 if (strEQ(name, "WNOHANG"))
2501 if (strEQ(name, "WUNTRACED"))
2507 errno = EAGAIN; /* the following aren't constants */
2509 if (strEQ(name, "WEXITSTATUS")) return WEXITSTATUS(arg);
2512 if (strEQ(name, "WIFEXITED")) return WIFEXITED(arg);
2515 if (strEQ(name, "WIFSIGNALED")) return WIFSIGNALED(arg);
2518 if (strEQ(name, "WIFSTOPPED")) return WIFSTOPPED(arg);
2521 if (strEQ(name, "WSTOPSIG")) return WSTOPSIG(arg);
2524 if (strEQ(name, "WTERMSIG")) return WTERMSIG(arg);
2528 if (strEQ(name, "X_OK"))
2536 if (strnEQ(name, "_PC_", 4)) {
2537 if (strEQ(name, "_PC_CHOWN_RESTRICTED"))
2538 #if defined(_PC_CHOWN_RESTRICTED) || HINT_SC_EXIST
2539 return _PC_CHOWN_RESTRICTED;
2543 if (strEQ(name, "_PC_LINK_MAX"))
2544 #if defined(_PC_LINK_MAX) || HINT_SC_EXIST
2545 return _PC_LINK_MAX;
2549 if (strEQ(name, "_PC_MAX_CANON"))
2550 #if defined(_PC_MAX_CANON) || HINT_SC_EXIST
2551 return _PC_MAX_CANON;
2555 if (strEQ(name, "_PC_MAX_INPUT"))
2556 #if defined(_PC_MAX_INPUT) || HINT_SC_EXIST
2557 return _PC_MAX_INPUT;
2561 if (strEQ(name, "_PC_NAME_MAX"))
2562 #if defined(_PC_NAME_MAX) || HINT_SC_EXIST
2563 return _PC_NAME_MAX;
2567 if (strEQ(name, "_PC_NO_TRUNC"))
2568 #if defined(_PC_NO_TRUNC) || HINT_SC_EXIST
2569 return _PC_NO_TRUNC;
2573 if (strEQ(name, "_PC_PATH_MAX"))
2574 #if defined(_PC_PATH_MAX) || HINT_SC_EXIST
2575 return _PC_PATH_MAX;
2579 if (strEQ(name, "_PC_PIPE_BUF"))
2580 #if defined(_PC_PIPE_BUF) || HINT_SC_EXIST
2581 return _PC_PIPE_BUF;
2585 if (strEQ(name, "_PC_VDISABLE"))
2586 #if defined(_PC_VDISABLE) || HINT_SC_EXIST
2587 return _PC_VDISABLE;
2593 if (strnEQ(name, "_POSIX_", 7)) {
2594 if (strEQ(name, "_POSIX_ARG_MAX"))
2595 #ifdef _POSIX_ARG_MAX
2596 return _POSIX_ARG_MAX;
2600 if (strEQ(name, "_POSIX_CHILD_MAX"))
2601 #ifdef _POSIX_CHILD_MAX
2602 return _POSIX_CHILD_MAX;
2606 if (strEQ(name, "_POSIX_CHOWN_RESTRICTED"))
2607 #ifdef _POSIX_CHOWN_RESTRICTED
2608 return _POSIX_CHOWN_RESTRICTED;
2612 if (strEQ(name, "_POSIX_JOB_CONTROL"))
2613 #ifdef _POSIX_JOB_CONTROL
2614 return _POSIX_JOB_CONTROL;
2618 if (strEQ(name, "_POSIX_LINK_MAX"))
2619 #ifdef _POSIX_LINK_MAX
2620 return _POSIX_LINK_MAX;
2624 if (strEQ(name, "_POSIX_MAX_CANON"))
2625 #ifdef _POSIX_MAX_CANON
2626 return _POSIX_MAX_CANON;
2630 if (strEQ(name, "_POSIX_MAX_INPUT"))
2631 #ifdef _POSIX_MAX_INPUT
2632 return _POSIX_MAX_INPUT;
2636 if (strEQ(name, "_POSIX_NAME_MAX"))
2637 #ifdef _POSIX_NAME_MAX
2638 return _POSIX_NAME_MAX;
2642 if (strEQ(name, "_POSIX_NGROUPS_MAX"))
2643 #ifdef _POSIX_NGROUPS_MAX
2644 return _POSIX_NGROUPS_MAX;
2648 if (strEQ(name, "_POSIX_NO_TRUNC"))
2649 #ifdef _POSIX_NO_TRUNC
2650 return _POSIX_NO_TRUNC;
2654 if (strEQ(name, "_POSIX_OPEN_MAX"))
2655 #ifdef _POSIX_OPEN_MAX
2656 return _POSIX_OPEN_MAX;
2660 if (strEQ(name, "_POSIX_PATH_MAX"))
2661 #ifdef _POSIX_PATH_MAX
2662 return _POSIX_PATH_MAX;
2666 if (strEQ(name, "_POSIX_PIPE_BUF"))
2667 #ifdef _POSIX_PIPE_BUF
2668 return _POSIX_PIPE_BUF;
2672 if (strEQ(name, "_POSIX_SAVED_IDS"))
2673 #ifdef _POSIX_SAVED_IDS
2674 return _POSIX_SAVED_IDS;
2678 if (strEQ(name, "_POSIX_SSIZE_MAX"))
2679 #ifdef _POSIX_SSIZE_MAX
2680 return _POSIX_SSIZE_MAX;
2684 if (strEQ(name, "_POSIX_STREAM_MAX"))
2685 #ifdef _POSIX_STREAM_MAX
2686 return _POSIX_STREAM_MAX;
2690 if (strEQ(name, "_POSIX_TZNAME_MAX"))
2691 #ifdef _POSIX_TZNAME_MAX
2692 return _POSIX_TZNAME_MAX;
2696 if (strEQ(name, "_POSIX_VDISABLE"))
2697 #ifdef _POSIX_VDISABLE
2698 return _POSIX_VDISABLE;
2702 if (strEQ(name, "_POSIX_VERSION"))
2703 #ifdef _POSIX_VERSION
2704 return _POSIX_VERSION;
2710 if (strnEQ(name, "_SC_", 4)) {
2711 if (strEQ(name, "_SC_ARG_MAX"))
2712 #if defined(_SC_ARG_MAX) || HINT_SC_EXIST
2717 if (strEQ(name, "_SC_CHILD_MAX"))
2718 #if defined(_SC_CHILD_MAX) || HINT_SC_EXIST
2719 return _SC_CHILD_MAX;
2723 if (strEQ(name, "_SC_CLK_TCK"))
2724 #if defined(_SC_CLK_TCK) || HINT_SC_EXIST
2729 if (strEQ(name, "_SC_JOB_CONTROL"))
2730 #if defined(_SC_JOB_CONTROL) || HINT_SC_EXIST
2731 return _SC_JOB_CONTROL;
2735 if (strEQ(name, "_SC_NGROUPS_MAX"))
2736 #if defined(_SC_NGROUPS_MAX) || HINT_SC_EXIST
2737 return _SC_NGROUPS_MAX;
2741 if (strEQ(name, "_SC_OPEN_MAX"))
2742 #if defined(_SC_OPEN_MAX) || HINT_SC_EXIST
2743 return _SC_OPEN_MAX;
2747 if (strEQ(name, "_SC_SAVED_IDS"))
2748 #if defined(_SC_SAVED_IDS) || HINT_SC_EXIST
2749 return _SC_SAVED_IDS;
2753 if (strEQ(name, "_SC_STREAM_MAX"))
2754 #if defined(_SC_STREAM_MAX) || HINT_SC_EXIST
2755 return _SC_STREAM_MAX;
2759 if (strEQ(name, "_SC_TZNAME_MAX"))
2760 #if defined(_SC_TZNAME_MAX) || HINT_SC_EXIST
2761 return _SC_TZNAME_MAX;
2765 if (strEQ(name, "_SC_VERSION"))
2766 #if defined(_SC_VERSION) || HINT_SC_EXIST
2783 restore_sigmask(sigset_t *ossetp)
2785 /* Fortunately, restoring the signal mask can't fail, because
2786 * there's nothing we can do about it if it does -- we're not
2787 * supposed to return -1 from sigaction unless the disposition
2790 (void)sigprocmask(SIG_SETMASK, ossetp, (sigset_t *)0);
2793 MODULE = SigSet PACKAGE = POSIX::SigSet PREFIX = sig
2796 new(packname = "POSIX::SigSet", ...)
2801 New(0, RETVAL, 1, sigset_t);
2802 sigemptyset(RETVAL);
2803 for (i = 1; i < items; i++)
2804 sigaddset(RETVAL, SvIV(ST(i)));
2811 POSIX::SigSet sigset
2816 sigaddset(sigset, sig)
2817 POSIX::SigSet sigset
2821 sigdelset(sigset, sig)
2822 POSIX::SigSet sigset
2827 POSIX::SigSet sigset
2831 POSIX::SigSet sigset
2834 sigismember(sigset, sig)
2835 POSIX::SigSet sigset
2839 MODULE = Termios PACKAGE = POSIX::Termios PREFIX = cf
2842 new(packname = "POSIX::Termios", ...)
2847 New(0, RETVAL, 1, struct termios);
2849 not_here("termios");
2857 DESTROY(termios_ref)
2858 POSIX::Termios termios_ref
2861 Safefree(termios_ref);
2863 not_here("termios");
2867 getattr(termios_ref, fd = 0)
2868 POSIX::Termios termios_ref
2871 RETVAL = tcgetattr(fd, termios_ref);
2876 setattr(termios_ref, fd = 0, optional_actions = 0)
2877 POSIX::Termios termios_ref
2879 int optional_actions
2881 RETVAL = tcsetattr(fd, optional_actions, termios_ref);
2886 cfgetispeed(termios_ref)
2887 POSIX::Termios termios_ref
2890 cfgetospeed(termios_ref)
2891 POSIX::Termios termios_ref
2894 getiflag(termios_ref)
2895 POSIX::Termios termios_ref
2897 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2898 RETVAL = termios_ref->c_iflag;
2900 not_here("getiflag");
2907 getoflag(termios_ref)
2908 POSIX::Termios termios_ref
2910 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2911 RETVAL = termios_ref->c_oflag;
2913 not_here("getoflag");
2920 getcflag(termios_ref)
2921 POSIX::Termios termios_ref
2923 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2924 RETVAL = termios_ref->c_cflag;
2926 not_here("getcflag");
2933 getlflag(termios_ref)
2934 POSIX::Termios termios_ref
2936 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2937 RETVAL = termios_ref->c_lflag;
2939 not_here("getlflag");
2946 getcc(termios_ref, ccix)
2947 POSIX::Termios termios_ref
2950 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2952 croak("Bad getcc subscript");
2953 RETVAL = termios_ref->c_cc[ccix];
2962 cfsetispeed(termios_ref, speed)
2963 POSIX::Termios termios_ref
2967 cfsetospeed(termios_ref, speed)
2968 POSIX::Termios termios_ref
2972 setiflag(termios_ref, iflag)
2973 POSIX::Termios termios_ref
2976 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2977 termios_ref->c_iflag = iflag;
2979 not_here("setiflag");
2983 setoflag(termios_ref, oflag)
2984 POSIX::Termios termios_ref
2987 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2988 termios_ref->c_oflag = oflag;
2990 not_here("setoflag");
2994 setcflag(termios_ref, cflag)
2995 POSIX::Termios termios_ref
2998 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2999 termios_ref->c_cflag = cflag;
3001 not_here("setcflag");
3005 setlflag(termios_ref, lflag)
3006 POSIX::Termios termios_ref
3009 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
3010 termios_ref->c_lflag = lflag;
3012 not_here("setlflag");
3016 setcc(termios_ref, ccix, cc)
3017 POSIX::Termios termios_ref
3021 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
3023 croak("Bad setcc subscript");
3024 termios_ref->c_cc[ccix] = cc;
3030 MODULE = POSIX PACKAGE = POSIX
3039 unsigned char * charstring
3041 unsigned char *s = charstring;
3042 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3043 for (RETVAL = 1; RETVAL && s < e; s++)
3051 unsigned char * charstring
3053 unsigned char *s = charstring;
3054 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3055 for (RETVAL = 1; RETVAL && s < e; s++)
3063 unsigned char * charstring
3065 unsigned char *s = charstring;
3066 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3067 for (RETVAL = 1; RETVAL && s < e; s++)
3075 unsigned char * charstring
3077 unsigned char *s = charstring;
3078 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3079 for (RETVAL = 1; RETVAL && s < e; s++)
3087 unsigned char * charstring
3089 unsigned char *s = charstring;
3090 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3091 for (RETVAL = 1; RETVAL && s < e; s++)
3099 unsigned char * charstring
3101 unsigned char *s = charstring;
3102 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3103 for (RETVAL = 1; RETVAL && s < e; s++)
3111 unsigned char * charstring
3113 unsigned char *s = charstring;
3114 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3115 for (RETVAL = 1; RETVAL && s < e; s++)
3123 unsigned char * charstring
3125 unsigned char *s = charstring;
3126 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3127 for (RETVAL = 1; RETVAL && s < e; s++)
3135 unsigned char * charstring
3137 unsigned char *s = charstring;
3138 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3139 for (RETVAL = 1; RETVAL && s < e; s++)
3147 unsigned char * charstring
3149 unsigned char *s = charstring;
3150 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3151 for (RETVAL = 1; RETVAL && s < e; s++)
3158 isxdigit(charstring)
3159 unsigned char * charstring
3161 unsigned char *s = charstring;
3162 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3163 for (RETVAL = 1; RETVAL && s < e; s++)
3170 open(filename, flags = O_RDONLY, mode = 0666)
3175 if (flags & (O_APPEND|O_CREAT|O_TRUNC|O_RDWR|O_WRONLY|O_EXCL))
3176 TAINT_PROPER("open");
3177 RETVAL = open(filename, flags, mode);
3185 #ifdef HAS_LOCALECONV
3186 struct lconv *lcbuf;
3188 if ((lcbuf = localeconv())) {
3190 if (lcbuf->decimal_point && *lcbuf->decimal_point)
3191 hv_store(RETVAL, "decimal_point", 13,
3192 newSVpv(lcbuf->decimal_point, 0), 0);
3193 if (lcbuf->thousands_sep && *lcbuf->thousands_sep)
3194 hv_store(RETVAL, "thousands_sep", 13,
3195 newSVpv(lcbuf->thousands_sep, 0), 0);
3196 #ifndef NO_LOCALECONV_GROUPING
3197 if (lcbuf->grouping && *lcbuf->grouping)
3198 hv_store(RETVAL, "grouping", 8,
3199 newSVpv(lcbuf->grouping, 0), 0);
3201 if (lcbuf->int_curr_symbol && *lcbuf->int_curr_symbol)
3202 hv_store(RETVAL, "int_curr_symbol", 15,
3203 newSVpv(lcbuf->int_curr_symbol, 0), 0);
3204 if (lcbuf->currency_symbol && *lcbuf->currency_symbol)
3205 hv_store(RETVAL, "currency_symbol", 15,
3206 newSVpv(lcbuf->currency_symbol, 0), 0);
3207 if (lcbuf->mon_decimal_point && *lcbuf->mon_decimal_point)
3208 hv_store(RETVAL, "mon_decimal_point", 17,
3209 newSVpv(lcbuf->mon_decimal_point, 0), 0);
3210 #ifndef NO_LOCALECONV_MON_THOUSANDS_SEP
3211 if (lcbuf->mon_thousands_sep && *lcbuf->mon_thousands_sep)
3212 hv_store(RETVAL, "mon_thousands_sep", 17,
3213 newSVpv(lcbuf->mon_thousands_sep, 0), 0);
3215 #ifndef NO_LOCALECONV_MON_GROUPING
3216 if (lcbuf->mon_grouping && *lcbuf->mon_grouping)
3217 hv_store(RETVAL, "mon_grouping", 12,
3218 newSVpv(lcbuf->mon_grouping, 0), 0);
3220 if (lcbuf->positive_sign && *lcbuf->positive_sign)
3221 hv_store(RETVAL, "positive_sign", 13,
3222 newSVpv(lcbuf->positive_sign, 0), 0);
3223 if (lcbuf->negative_sign && *lcbuf->negative_sign)
3224 hv_store(RETVAL, "negative_sign", 13,
3225 newSVpv(lcbuf->negative_sign, 0), 0);
3227 if (lcbuf->int_frac_digits != CHAR_MAX)
3228 hv_store(RETVAL, "int_frac_digits", 15,
3229 newSViv(lcbuf->int_frac_digits), 0);
3230 if (lcbuf->frac_digits != CHAR_MAX)
3231 hv_store(RETVAL, "frac_digits", 11,
3232 newSViv(lcbuf->frac_digits), 0);
3233 if (lcbuf->p_cs_precedes != CHAR_MAX)
3234 hv_store(RETVAL, "p_cs_precedes", 13,
3235 newSViv(lcbuf->p_cs_precedes), 0);
3236 if (lcbuf->p_sep_by_space != CHAR_MAX)
3237 hv_store(RETVAL, "p_sep_by_space", 14,
3238 newSViv(lcbuf->p_sep_by_space), 0);
3239 if (lcbuf->n_cs_precedes != CHAR_MAX)
3240 hv_store(RETVAL, "n_cs_precedes", 13,
3241 newSViv(lcbuf->n_cs_precedes), 0);
3242 if (lcbuf->n_sep_by_space != CHAR_MAX)
3243 hv_store(RETVAL, "n_sep_by_space", 14,
3244 newSViv(lcbuf->n_sep_by_space), 0);
3245 if (lcbuf->p_sign_posn != CHAR_MAX)
3246 hv_store(RETVAL, "p_sign_posn", 11,
3247 newSViv(lcbuf->p_sign_posn), 0);
3248 if (lcbuf->n_sign_posn != CHAR_MAX)
3249 hv_store(RETVAL, "n_sign_posn", 11,
3250 newSViv(lcbuf->n_sign_posn), 0);
3253 localeconv(); /* A stub to call not_here(). */
3259 setlocale(category, locale = 0)
3263 RETVAL = setlocale(category, locale);
3265 #ifdef USE_LOCALE_CTYPE
3266 if (category == LC_CTYPE
3268 || category == LC_ALL
3274 if (category == LC_ALL)
3275 newctype = setlocale(LC_CTYPE, NULL);
3279 new_ctype(newctype);
3281 #endif /* USE_LOCALE_CTYPE */
3282 #ifdef USE_LOCALE_COLLATE
3283 if (category == LC_COLLATE
3285 || category == LC_ALL
3291 if (category == LC_ALL)
3292 newcoll = setlocale(LC_COLLATE, NULL);
3296 new_collate(newcoll);
3298 #endif /* USE_LOCALE_COLLATE */
3299 #ifdef USE_LOCALE_NUMERIC
3300 if (category == LC_NUMERIC
3302 || category == LC_ALL
3308 if (category == LC_ALL)
3309 newnum = setlocale(LC_NUMERIC, NULL);
3313 new_numeric(newnum);
3315 #endif /* USE_LOCALE_NUMERIC */
3355 /* (We already know stack is long enough.) */
3356 PUSHs(sv_2mortal(newSVnv(frexp(x,&expvar))));
3357 PUSHs(sv_2mortal(newSViv(expvar)));
3373 /* (We already know stack is long enough.) */
3374 PUSHs(sv_2mortal(newSVnv(Perl_modf(x,&intvar))));
3375 PUSHs(sv_2mortal(newSVnv(intvar)));
3390 sigaction(sig, optaction, oldaction = 0)
3393 POSIX::SigAction oldaction
3396 RETVAL = not_here("sigaction");
3398 # This code is really grody because we're trying to make the signal
3399 # interface look beautiful, which is hard.
3402 POSIX__SigAction action;
3403 GV *siggv = gv_fetchpv("SIG", TRUE, SVt_PVHV);
3404 struct sigaction act;
3405 struct sigaction oact;
3408 POSIX__SigSet sigset;
3410 SV** sigsvp = hv_fetch(GvHVn(siggv),
3412 strlen(PL_sig_name[sig]),
3416 /* Check optaction and set action */
3417 if(SvTRUE(optaction)) {
3418 if(sv_isa(optaction, "POSIX::SigAction"))
3419 action = (HV*)SvRV(optaction);
3421 croak("action is not of type POSIX::SigAction");
3427 /* sigaction() is supposed to look atomic. In particular, any
3428 * signal handler invoked during a sigaction() call should
3429 * see either the old or the new disposition, and not something
3430 * in between. We use sigprocmask() to make it so.
3433 RETVAL=sigprocmask(SIG_BLOCK, &sset, &osset);
3437 /* Restore signal mask no matter how we exit this block. */
3438 SAVEDESTRUCTOR(restore_sigmask, &osset);
3440 RETVAL=-1; /* In case both oldaction and action are 0. */
3442 /* Remember old disposition if desired. */
3444 svp = hv_fetch(oldaction, "HANDLER", 7, TRUE);
3446 croak("Can't supply an oldaction without a HANDLER");
3447 if(SvTRUE(*sigsvp)) { /* TBD: what if "0"? */
3448 sv_setsv(*svp, *sigsvp);
3451 sv_setpv(*svp, "DEFAULT");
3453 RETVAL = sigaction(sig, (struct sigaction *)0, & oact);
3456 /* Get back the mask. */
3457 svp = hv_fetch(oldaction, "MASK", 4, TRUE);
3458 if (sv_isa(*svp, "POSIX::SigSet")) {
3459 IV tmp = SvIV((SV*)SvRV(*svp));
3460 sigset = INT2PTR(sigset_t*, tmp);
3463 New(0, sigset, 1, sigset_t);
3464 sv_setptrobj(*svp, sigset, "POSIX::SigSet");
3466 *sigset = oact.sa_mask;
3468 /* Get back the flags. */
3469 svp = hv_fetch(oldaction, "FLAGS", 5, TRUE);
3470 sv_setiv(*svp, oact.sa_flags);
3474 /* Vector new handler through %SIG. (We always use sighandler
3475 for the C signal handler, which reads %SIG to dispatch.) */
3476 svp = hv_fetch(action, "HANDLER", 7, FALSE);
3478 croak("Can't supply an action without a HANDLER");
3479 sv_setsv(*sigsvp, *svp);
3480 mg_set(*sigsvp); /* handles DEFAULT and IGNORE */
3482 char *s=SvPVX(*svp);
3483 if(strEQ(s,"IGNORE")) {
3484 act.sa_handler = SIG_IGN;
3486 else if(strEQ(s,"DEFAULT")) {
3487 act.sa_handler = SIG_DFL;
3490 act.sa_handler = PL_sighandlerp;
3494 act.sa_handler = PL_sighandlerp;
3497 /* Set up any desired mask. */
3498 svp = hv_fetch(action, "MASK", 4, FALSE);
3499 if (svp && sv_isa(*svp, "POSIX::SigSet")) {
3500 IV tmp = SvIV((SV*)SvRV(*svp));
3501 sigset = INT2PTR(sigset_t*, tmp);
3502 act.sa_mask = *sigset;
3505 sigemptyset(& act.sa_mask);
3507 /* Set up any desired flags. */
3508 svp = hv_fetch(action, "FLAGS", 5, FALSE);
3509 act.sa_flags = svp ? SvIV(*svp) : 0;
3511 /* Don't worry about cleaning up *sigsvp if this fails,
3512 * because that means we tried to disposition a
3513 * nonblockable signal, in which case *sigsvp is
3514 * essentially meaningless anyway.
3516 RETVAL = sigaction(sig, & act, (struct sigaction *)0);
3527 POSIX::SigSet sigset
3530 sigprocmask(how, sigset, oldsigset = 0)
3532 POSIX::SigSet sigset
3533 POSIX::SigSet oldsigset = NO_INIT
3538 else if (sv_derived_from(ST(2), "POSIX::SigSet")) {
3539 IV tmp = SvIV((SV*)SvRV(ST(2)));
3540 oldsigset = INT2PTR(POSIX__SigSet,tmp);
3543 New(0, oldsigset, 1, sigset_t);
3544 sigemptyset(oldsigset);
3545 sv_setref_pv(ST(2), "POSIX::SigSet", (void*)oldsigset);
3549 sigsuspend(signal_mask)
3550 POSIX::SigSet signal_mask
3570 lseek(fd, offset, whence)
3583 if (pipe(fds) != -1) {
3585 PUSHs(sv_2mortal(newSViv(fds[0])));
3586 PUSHs(sv_2mortal(newSViv(fds[1])));
3590 read(fd, buffer, nbytes)
3592 SV *sv_buffer = SvROK(ST(1)) ? SvRV(ST(1)) : ST(1);
3596 char * buffer = sv_grow( sv_buffer, nbytes+1 );
3599 SvCUR(sv_buffer) = RETVAL;
3600 SvPOK_only(sv_buffer);
3601 *SvEND(sv_buffer) = '\0';
3602 SvTAINTED_on(sv_buffer);
3618 tcsetpgrp(fd, pgrp_id)
3627 if (uname(&buf) >= 0) {
3629 PUSHs(sv_2mortal(newSVpv(buf.sysname, 0)));
3630 PUSHs(sv_2mortal(newSVpv(buf.nodename, 0)));
3631 PUSHs(sv_2mortal(newSVpv(buf.release, 0)));
3632 PUSHs(sv_2mortal(newSVpv(buf.version, 0)));
3633 PUSHs(sv_2mortal(newSVpv(buf.machine, 0)));
3636 uname((char *) 0); /* A stub to call not_here(). */
3640 write(fd, buffer, nbytes)
3651 RETVAL = newSVpvn("", 0);
3652 SvGROW(RETVAL, L_tmpnam);
3653 len = strlen(tmpnam(SvPV(RETVAL, i)));
3654 SvCUR_set(RETVAL, len);
3667 mbstowcs(s, pwcs, n)
3679 wcstombs(s, pwcs, n)
3701 SET_NUMERIC_LOCAL();
3702 num = strtod(str, &unparsed);
3703 PUSHs(sv_2mortal(newSVnv(num)));
3704 if (GIMME == G_ARRAY) {
3707 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3709 PUSHs(&PL_sv_undef);
3713 strtol(str, base = 0)
3720 num = strtol(str, &unparsed, base);
3721 #if IVSIZE <= LONGSIZE
3722 if (num < IV_MIN || num > IV_MAX)
3723 PUSHs(sv_2mortal(newSVnv((double)num)));
3726 PUSHs(sv_2mortal(newSViv((IV)num)));
3727 if (GIMME == G_ARRAY) {
3730 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3732 PUSHs(&PL_sv_undef);
3736 strtoul(str, base = 0)
3743 num = strtoul(str, &unparsed, base);
3745 PUSHs(sv_2mortal(newSViv((IV)num)));
3747 PUSHs(sv_2mortal(newSVnv((double)num)));
3748 if (GIMME == G_ARRAY) {
3751 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3753 PUSHs(&PL_sv_undef);
3763 char *p = SvPV(src,srclen);
3765 ST(0) = sv_2mortal(NEWSV(800,srclen));
3766 dstlen = strxfrm(SvPVX(ST(0)), p, (size_t)srclen);
3767 if (dstlen > srclen) {
3769 SvGROW(ST(0), dstlen);
3770 strxfrm(SvPVX(ST(0)), p, (size_t)dstlen);
3773 SvCUR(ST(0)) = dstlen;
3778 mkfifo(filename, mode)
3782 TAINT_PROPER("mkfifo");
3783 RETVAL = mkfifo(filename, mode);
3799 tcflush(fd, queue_selector)
3804 tcsendbreak(fd, duration)
3809 asctime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3822 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3825 mytm.tm_hour = hour;
3826 mytm.tm_mday = mday;
3828 mytm.tm_year = year;
3829 mytm.tm_wday = wday;
3830 mytm.tm_yday = yday;
3831 mytm.tm_isdst = isdst;
3832 RETVAL = asctime(&mytm);
3849 realtime = times( &tms );
3851 PUSHs( sv_2mortal( newSViv( (IV) realtime ) ) );
3852 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_utime ) ) );
3853 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_stime ) ) );
3854 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cutime ) ) );
3855 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cstime ) ) );
3858 difftime(time1, time2)
3863 mktime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3876 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3879 mytm.tm_hour = hour;
3880 mytm.tm_mday = mday;
3882 mytm.tm_year = year;
3883 mytm.tm_wday = wday;
3884 mytm.tm_yday = yday;
3885 mytm.tm_isdst = isdst;
3886 RETVAL = mktime(&mytm);
3891 #XXX: if $xsubpp::WantOptimize is always the default
3892 # sv_setpv(TARG, ...) could be used rather than
3893 # ST(0) = sv_2mortal(newSVpv(...))
3895 strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1)
3911 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3914 mytm.tm_hour = hour;
3915 mytm.tm_mday = mday;
3917 mytm.tm_year = year;
3918 mytm.tm_wday = wday;
3919 mytm.tm_yday = yday;
3920 mytm.tm_isdst = isdst;
3922 len = strftime(tmpbuf, sizeof tmpbuf, fmt, &mytm);
3924 ** The following is needed to handle to the situation where
3925 ** tmpbuf overflows. Basically we want to allocate a buffer
3926 ** and try repeatedly. The reason why it is so complicated
3927 ** is that getting a return value of 0 from strftime can indicate
3928 ** one of the following:
3929 ** 1. buffer overflowed,
3930 ** 2. illegal conversion specifier, or
3931 ** 3. the format string specifies nothing to be returned(not
3932 ** an error). This could be because format is an empty string
3933 ** or it specifies %p that yields an empty string in some locale.
3934 ** If there is a better way to make it portable, go ahead by
3937 if ((len > 0 && len < sizeof(tmpbuf)) || (len == 0 && *fmt == '\0'))
3938 ST(0) = sv_2mortal(newSVpv(tmpbuf, len));
3940 /* Possibly buf overflowed - try again with a bigger buf */
3941 int fmtlen = strlen(fmt);
3942 int bufsize = fmtlen + sizeof(tmpbuf);
3946 New(0, buf, bufsize, char);
3948 buflen = strftime(buf, bufsize, fmt, &mytm);
3949 if (buflen > 0 && buflen < bufsize)
3951 /* heuristic to prevent out-of-memory errors */
3952 if (bufsize > 100*fmtlen) {
3958 Renew(buf, bufsize, char);
3961 ST(0) = sv_2mortal(newSVpvn(buf, buflen));
3965 ST(0) = sv_2mortal(newSVpvn(tmpbuf, len));
3976 PUSHs(sv_2mortal(newSVpvn(tzname[0],strlen(tzname[0]))));
3977 PUSHs(sv_2mortal(newSVpvn(tzname[1],strlen(tzname[1]))));
3980 access(filename, mode)
3998 pathconf(filename, name)
4029 New(0, buf, buflen, char);
4030 /* Many getcwd()s know how to automatically allocate memory
4031 * for the directory if the buffer argument is NULL but...
4032 * (1) we cannot assume all getcwd()s do that
4033 * (2) this may interfere with Perl's malloc
4034 * So let's not. --jhi */
4035 while ((getcwd(buf, buflen) == NULL) && errno == ERANGE) {
4037 if (buflen > MAXPATHLEN) {
4042 Renew(buf, buflen, char);
4045 PUSHs(sv_2mortal(newSVpv(buf, 0)));
4049 PUSHs(&PL_sv_undef);
4051 require_pv("Cwd.pm");
4052 /* Module require may have grown the stack */
4056 XSRETURN(call_pv("Cwd::cwd", GIMME_V));