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>
60 #if defined(__VMS) && !defined(__POSIX_SOURCE)
61 # include <libdef.h> /* LIB$_INVARG constant */
62 # include <lib$routines.h> /* prototype for lib$ediv() */
63 # include <starlet.h> /* prototype for sys$gettim() */
64 # if DECC_VERSION < 50000000
65 # define pid_t int /* old versions of DECC miss this in types.h */
69 # define mkfifo(a,b) (not_here("mkfifo"),-1)
70 # define tzset() not_here("tzset")
72 #if ((__VMS_VER >= 70000000) && (__DECC_VER >= 50200000)) || (__CRTL_VER >= 70000000)
73 # define HAS_TZNAME /* shows up in VMS 7.0 or Dec C 5.6 */
75 # endif /* __VMS_VER >= 70000000 or Dec C 5.6 */
77 /* The POSIX notion of ttyname() is better served by getname() under VMS */
78 static char ttnambuf[64];
79 # define ttyname(fd) (isatty(fd) > 0 ? getname(fd,ttnambuf,0) : NULL)
81 /* The non-POSIX CRTL times() has void return type, so we just get the
82 current time directly */
83 clock_t vms_times(struct tms *PL_bufptr) {
86 /* Get wall time and convert to 10 ms intervals to
87 * produce the return value that the POSIX standard expects */
88 # if defined(__DECC) && defined (__ALPHA)
91 _ckvmssts(sys$gettim(&vmstime));
93 retval = vmstime & 0x7fffffff;
95 /* (Older hw or ccs don't have an atomic 64-bit type, so we
96 * juggle 32-bit ints (and a float) to produce a time_t result
97 * with minimal loss of information.) */
98 long int vmstime[2],remainder,divisor = 100000;
99 _ckvmssts(sys$gettim((unsigned long int *)vmstime));
100 vmstime[1] &= 0x7fff; /* prevent overflow in EDIV */
101 _ckvmssts(lib$ediv(&divisor,vmstime,(long int *)&retval,&remainder));
103 /* Fill in the struct tms using the CRTL routine . . .*/
104 times((tbuffer_t *)PL_bufptr);
105 return (clock_t) retval;
107 # define times(t) vms_times(t)
109 #if defined (__CYGWIN__)
110 # define tzname _tzname
114 # define mkfifo(a,b) not_here("mkfifo")
115 # define ttyname(a) (char*)not_here("ttyname")
116 # define sigset_t long
119 # define tzname _tzname
122 # define mode_t short
125 # define mode_t short
127 # define tzset() not_here("tzset")
129 # ifndef _POSIX_OPEN_MAX
130 # define _POSIX_OPEN_MAX FOPEN_MAX /* XXX bogus ? */
133 # define sigaction(a,b,c) not_here("sigaction")
134 # define sigpending(a) not_here("sigpending")
135 # define sigprocmask(a,b,c) not_here("sigprocmask")
136 # define sigsuspend(a) not_here("sigsuspend")
137 # define sigemptyset(a) not_here("sigemptyset")
138 # define sigaddset(a,b) not_here("sigaddset")
139 # define sigdelset(a,b) not_here("sigdelset")
140 # define sigfillset(a) not_here("sigfillset")
141 # define sigismember(a,b) not_here("sigismember")
146 # define mkfifo(a,b) not_here("mkfifo")
147 # else /* !( defined OS2 ) */
149 # define mkfifo(path, mode) (mknod((path), (mode) | S_IFIFO, 0))
152 # endif /* !HAS_MKFIFO */
155 # include <sys/times.h>
157 # include <sys/utsname.h>
159 # include <sys/wait.h>
167 typedef long SysRetLong;
168 typedef sigset_t* POSIX__SigSet;
169 typedef HV* POSIX__SigAction;
171 typedef struct termios* POSIX__Termios;
172 #else /* Define termios types to int, and call not_here for the functions.*/
173 #define POSIX__Termios int
177 #define cfgetispeed(x) not_here("cfgetispeed")
178 #define cfgetospeed(x) not_here("cfgetospeed")
179 #define tcdrain(x) not_here("tcdrain")
180 #define tcflush(x,y) not_here("tcflush")
181 #define tcsendbreak(x,y) not_here("tcsendbreak")
182 #define cfsetispeed(x,y) not_here("cfsetispeed")
183 #define cfsetospeed(x,y) not_here("cfsetospeed")
184 #define ctermid(x) (char *) not_here("ctermid")
185 #define tcflow(x,y) not_here("tcflow")
186 #define tcgetattr(x,y) not_here("tcgetattr")
187 #define tcsetattr(x,y,z) not_here("tcsetattr")
190 /* Possibly needed prototypes */
191 char *cuserid (char *);
192 double strtod (const char *, char **);
193 long strtol (const char *, char **, int);
194 unsigned long strtoul (const char *, char **, int);
197 #define cuserid(a) (char *) not_here("cuserid")
201 #define difftime(a,b) not_here("difftime")
204 #ifndef HAS_FPATHCONF
205 #define fpathconf(f,n) (SysRetLong) not_here("fpathconf")
208 #define mktime(a) not_here("mktime")
211 #define nice(a) not_here("nice")
214 #define pathconf(f,n) (SysRetLong) not_here("pathconf")
217 #define sysconf(n) (SysRetLong) not_here("sysconf")
220 #define readlink(a,b,c) not_here("readlink")
223 #define setpgid(a,b) not_here("setpgid")
226 #define setsid() not_here("setsid")
229 #define strcoll(s1,s2) not_here("strcoll")
232 #define strtod(s1,s2) not_here("strtod")
235 #define strtol(s1,s2,b) not_here("strtol")
238 #define strtoul(s1,s2,b) not_here("strtoul")
241 #define strxfrm(s1,s2,n) not_here("strxfrm")
243 #ifndef HAS_TCGETPGRP
244 #define tcgetpgrp(a) not_here("tcgetpgrp")
246 #ifndef HAS_TCSETPGRP
247 #define tcsetpgrp(a,b) not_here("tcsetpgrp")
250 #define times(a) not_here("times")
253 #define uname(a) not_here("uname")
256 #define waitpid(a,b,c) not_here("waitpid")
261 #define mblen(a,b) not_here("mblen")
265 #define mbstowcs(s, pwcs, n) not_here("mbstowcs")
268 #define mbtowc(pwc, s, n) not_here("mbtowc")
271 #define wcstombs(s, pwcs, n) not_here("wcstombs")
274 #define wctomb(s, wchar) not_here("wcstombs")
276 #if !defined(HAS_MBLEN) && !defined(HAS_MBSTOWCS) && !defined(HAS_MBTOWC) && !defined(HAS_WCSTOMBS) && !defined(HAS_WCTOMB)
277 /* If we don't have these functions, then we wouldn't have gotten a typedef
278 for wchar_t, the wide character type. Defining wchar_t allows the
279 functions referencing it to compile. Its actual type is then meaningless,
280 since without the above functions, all sections using it end up calling
281 not_here() and croak. --Kaveh Ghazi (ghazi@noc.rutgers.edu) 9/18/94. */
287 #ifndef HAS_LOCALECONV
288 #define localeconv() not_here("localeconv")
292 # if !defined(WIN32) && !defined(__CYGWIN__)
293 extern char *tzname[];
296 #if !defined(WIN32) || (defined(__MINGW32__) && !defined(tzname))
297 char *tzname[] = { "" , "" };
301 /* XXX struct tm on some systems (SunOS4/BSD) contains extra (non POSIX)
302 * fields for which we don't have Configure support yet:
303 * char *tm_zone; -- abbreviation of timezone name
304 * long tm_gmtoff; -- offset from GMT in seconds
305 * To workaround core dumps from the uninitialised tm_zone we get the
306 * system to give us a reasonable struct to copy. This fix means that
307 * strftime uses the tm_zone and tm_gmtoff values returned by
308 * localtime(time()). That should give the desired result most of the
309 * time. But probably not always!
311 * This is a temporary workaround to be removed once Configure
312 * support is added and NETaa14816 is considered in full.
313 * It does not address tzname aspects of NETaa14816.
316 # ifndef STRUCT_TM_HASZONE
317 # define STRUCT_TM_HASZONE
321 #ifdef STRUCT_TM_HASZONE
323 init_tm(struct tm *ptm) /* see mktime, strftime and asctime */
327 Copy(localtime(&now), ptm, 1, struct tm);
331 # define init_tm(ptm)
335 * mini_mktime - normalise struct tm values without the localtime()
336 * semantics (and overhead) of mktime().
339 mini_mktime(struct tm *ptm)
343 int month, mday, year, jday;
344 int odd_cent, odd_year;
346 #define DAYS_PER_YEAR 365
347 #define DAYS_PER_QYEAR (4*DAYS_PER_YEAR+1)
348 #define DAYS_PER_CENT (25*DAYS_PER_QYEAR-1)
349 #define DAYS_PER_QCENT (4*DAYS_PER_CENT+1)
350 #define SECS_PER_HOUR (60*60)
351 #define SECS_PER_DAY (24*SECS_PER_HOUR)
352 /* parentheses deliberately absent on these two, otherwise they don't work */
353 #define MONTH_TO_DAYS 153/5
354 #define DAYS_TO_MONTH 5/153
355 /* offset to bias by March (month 4) 1st between month/mday & year finding */
356 #define YEAR_ADJUST (4*MONTH_TO_DAYS+1)
357 /* as used here, the algorithm leaves Sunday as day 1 unless we adjust it */
358 #define WEEKDAY_BIAS 6 /* (1+6)%7 makes Sunday 0 again */
361 * Year/day algorithm notes:
363 * With a suitable offset for numeric value of the month, one can find
364 * an offset into the year by considering months to have 30.6 (153/5) days,
365 * using integer arithmetic (i.e., with truncation). To avoid too much
366 * messing about with leap days, we consider January and February to be
367 * the 13th and 14th month of the previous year. After that transformation,
368 * we need the month index we use to be high by 1 from 'normal human' usage,
369 * so the month index values we use run from 4 through 15.
371 * Given that, and the rules for the Gregorian calendar (leap years are those
372 * divisible by 4 unless also divisible by 100, when they must be divisible
373 * by 400 instead), we can simply calculate the number of days since some
374 * arbitrary 'beginning of time' by futzing with the (adjusted) year number,
375 * the days we derive from our month index, and adding in the day of the
376 * month. The value used here is not adjusted for the actual origin which
377 * it normally would use (1 January A.D. 1), since we're not exposing it.
378 * We're only building the value so we can turn around and get the
379 * normalised values for the year, month, day-of-month, and day-of-year.
381 * For going backward, we need to bias the value we're using so that we find
382 * the right year value. (Basically, we don't want the contribution of
383 * March 1st to the number to apply while deriving the year). Having done
384 * that, we 'count up' the contribution to the year number by accounting for
385 * full quadracenturies (400-year periods) with their extra leap days, plus
386 * the contribution from full centuries (to avoid counting in the lost leap
387 * days), plus the contribution from full quad-years (to count in the normal
388 * leap days), plus the leftover contribution from any non-leap years.
389 * At this point, if we were working with an actual leap day, we'll have 0
390 * days left over. This is also true for March 1st, however. So, we have
391 * to special-case that result, and (earlier) keep track of the 'odd'
392 * century and year contributions. If we got 4 extra centuries in a qcent,
393 * or 4 extra years in a qyear, then it's a leap day and we call it 29 Feb.
394 * Otherwise, we add back in the earlier bias we removed (the 123 from
395 * figuring in March 1st), find the month index (integer division by 30.6),
396 * and the remainder is the day-of-month. We then have to convert back to
397 * 'real' months (including fixing January and February from being 14/15 in
398 * the previous year to being in the proper year). After that, to get
399 * tm_yday, we work with the normalised year and get a new yearday value for
400 * January 1st, which we subtract from the yearday value we had earlier,
401 * representing the date we've re-built. This is done from January 1
402 * because tm_yday is 0-origin.
404 * Since POSIX time routines are only guaranteed to work for times since the
405 * UNIX epoch (00:00:00 1 Jan 1970 UTC), the fact that this algorithm
406 * applies Gregorian calendar rules even to dates before the 16th century
407 * doesn't bother me. Besides, you'd need cultural context for a given
408 * date to know whether it was Julian or Gregorian calendar, and that's
409 * outside the scope for this routine. Since we convert back based on the
410 * same rules we used to build the yearday, you'll only get strange results
411 * for input which needed normalising, or for the 'odd' century years which
412 * were leap years in the Julian calander but not in the Gregorian one.
413 * I can live with that.
415 * This algorithm also fails to handle years before A.D. 1 gracefully, but
416 * that's still outside the scope for POSIX time manipulation, so I don't
420 year = 1900 + ptm->tm_year;
423 /* allow given yday with no month & mday to dominate the result */
424 if (ptm->tm_yday >= 0 && mday <= 0 && month <= 0) {
427 jday = 1 + ptm->tm_yday;
436 yearday = DAYS_PER_YEAR * year + year/4 - year/100 + year/400;
437 yearday += month*MONTH_TO_DAYS + mday + jday;
439 * Note that we don't know when leap-seconds were or will be,
440 * so we have to trust the user if we get something which looks
441 * like a sensible leap-second. Wild values for seconds will
442 * be rationalised, however.
444 if ((unsigned) ptm->tm_sec <= 60) {
451 secs += 60 * ptm->tm_min;
452 secs += SECS_PER_HOUR * ptm->tm_hour;
454 if (secs-(secs/SECS_PER_DAY*SECS_PER_DAY) < 0) {
455 /* got negative remainder, but need positive time */
456 /* back off an extra day to compensate */
457 yearday += (secs/SECS_PER_DAY)-1;
458 secs -= SECS_PER_DAY * (secs/SECS_PER_DAY - 1);
461 yearday += (secs/SECS_PER_DAY);
462 secs -= SECS_PER_DAY * (secs/SECS_PER_DAY);
465 else if (secs >= SECS_PER_DAY) {
466 yearday += (secs/SECS_PER_DAY);
467 secs %= SECS_PER_DAY;
469 ptm->tm_hour = secs/SECS_PER_HOUR;
470 secs %= SECS_PER_HOUR;
471 ptm->tm_min = secs/60;
474 /* done with time of day effects */
476 * The algorithm for yearday has (so far) left it high by 428.
477 * To avoid mistaking a legitimate Feb 29 as Mar 1, we need to
478 * bias it by 123 while trying to figure out what year it
479 * really represents. Even with this tweak, the reverse
480 * translation fails for years before A.D. 0001.
481 * It would still fail for Feb 29, but we catch that one below.
483 jday = yearday; /* save for later fixup vis-a-vis Jan 1 */
484 yearday -= YEAR_ADJUST;
485 year = (yearday / DAYS_PER_QCENT) * 400;
486 yearday %= DAYS_PER_QCENT;
487 odd_cent = yearday / DAYS_PER_CENT;
488 year += odd_cent * 100;
489 yearday %= DAYS_PER_CENT;
490 year += (yearday / DAYS_PER_QYEAR) * 4;
491 yearday %= DAYS_PER_QYEAR;
492 odd_year = yearday / DAYS_PER_YEAR;
494 yearday %= DAYS_PER_YEAR;
495 if (!yearday && (odd_cent==4 || odd_year==4)) { /* catch Feb 29 */
500 yearday += YEAR_ADJUST; /* recover March 1st crock */
501 month = yearday*DAYS_TO_MONTH;
502 yearday -= month*MONTH_TO_DAYS;
503 /* recover other leap-year adjustment */
512 ptm->tm_year = year - 1900;
514 ptm->tm_mday = yearday;
519 ptm->tm_mon = month - 1;
521 /* re-build yearday based on Jan 1 to get tm_yday */
523 yearday = year*DAYS_PER_YEAR + year/4 - year/100 + year/400;
524 yearday += 14*MONTH_TO_DAYS + 1;
525 ptm->tm_yday = jday - yearday;
526 /* fix tm_wday if not overridden by caller */
527 if ((unsigned)ptm->tm_wday > 6)
528 ptm->tm_wday = (jday + WEEKDAY_BIAS) % 7;
531 #ifdef HAS_LONG_DOUBLE
532 # if LONG_DOUBLESIZE > DOUBLESIZE
533 # undef HAS_LONG_DOUBLE /* XXX until we figure out how to use them */
537 #ifndef HAS_LONG_DOUBLE
552 croak("POSIX::%s not implemented on this architecture", s);
557 #if defined(HAS_LONG_DOUBLE) && (LONG_DOUBLESIZE > DOUBLESIZE)
562 constant(char *name, int arg)
567 if (strEQ(name, "ARG_MAX"))
575 if (strEQ(name, "BUFSIZ"))
581 if (strEQ(name, "BRKINT"))
587 if (strEQ(name, "B9600"))
593 if (strEQ(name, "B19200"))
599 if (strEQ(name, "B38400"))
605 if (strEQ(name, "B0"))
611 if (strEQ(name, "B110"))
617 if (strEQ(name, "B1200"))
623 if (strEQ(name, "B134"))
629 if (strEQ(name, "B150"))
635 if (strEQ(name, "B1800"))
641 if (strEQ(name, "B200"))
647 if (strEQ(name, "B2400"))
653 if (strEQ(name, "B300"))
659 if (strEQ(name, "B4800"))
665 if (strEQ(name, "B50"))
671 if (strEQ(name, "B600"))
677 if (strEQ(name, "B75"))
685 if (strEQ(name, "CHAR_BIT"))
691 if (strEQ(name, "CHAR_MAX"))
697 if (strEQ(name, "CHAR_MIN"))
703 if (strEQ(name, "CHILD_MAX"))
709 if (strEQ(name, "CLK_TCK"))
715 if (strEQ(name, "CLOCAL"))
721 if (strEQ(name, "CLOCKS_PER_SEC"))
722 #ifdef CLOCKS_PER_SEC
723 return CLOCKS_PER_SEC;
727 if (strEQ(name, "CREAD"))
733 if (strEQ(name, "CS5"))
739 if (strEQ(name, "CS6"))
745 if (strEQ(name, "CS7"))
751 if (strEQ(name, "CS8"))
757 if (strEQ(name, "CSIZE"))
763 if (strEQ(name, "CSTOPB"))
771 if (strEQ(name, "DBL_MAX"))
777 if (strEQ(name, "DBL_MIN"))
783 if (strEQ(name, "DBL_DIG"))
789 if (strEQ(name, "DBL_EPSILON"))
795 if (strEQ(name, "DBL_MANT_DIG"))
801 if (strEQ(name, "DBL_MAX_10_EXP"))
802 #ifdef DBL_MAX_10_EXP
803 return DBL_MAX_10_EXP;
807 if (strEQ(name, "DBL_MAX_EXP"))
813 if (strEQ(name, "DBL_MIN_10_EXP"))
814 #ifdef DBL_MIN_10_EXP
815 return DBL_MIN_10_EXP;
819 if (strEQ(name, "DBL_MIN_EXP"))
829 if (strEQ(name, "EACCES"))
835 if (strEQ(name, "EADDRINUSE"))
841 if (strEQ(name, "EADDRNOTAVAIL"))
843 return EADDRNOTAVAIL;
847 if (strEQ(name, "EAFNOSUPPORT"))
853 if (strEQ(name, "EAGAIN"))
859 if (strEQ(name, "EALREADY"))
867 if (strEQ(name, "EBADF"))
873 if (strEQ(name, "EBUSY"))
881 if (strEQ(name, "ECHILD"))
887 if (strEQ(name, "ECHO"))
893 if (strEQ(name, "ECHOE"))
899 if (strEQ(name, "ECHOK"))
905 if (strEQ(name, "ECHONL"))
911 if (strEQ(name, "ECONNABORTED"))
917 if (strEQ(name, "ECONNREFUSED"))
923 if (strEQ(name, "ECONNRESET"))
931 if (strEQ(name, "EDEADLK"))
937 if (strEQ(name, "EDESTADDRREQ"))
943 if (strEQ(name, "EDOM"))
949 if (strEQ(name, "EDQUOT"))
957 if (strEQ(name, "EEXIST"))
965 if (strEQ(name, "EFAULT"))
971 if (strEQ(name, "EFBIG"))
979 if (strEQ(name, "EHOSTDOWN"))
985 if (strEQ(name, "EHOSTUNREACH"))
993 if (strEQ(name, "EINPROGRESS"))
999 if (strEQ(name, "EINTR"))
1005 if (strEQ(name, "EINVAL"))
1011 if (strEQ(name, "EIO"))
1017 if (strEQ(name, "EISCONN"))
1023 if (strEQ(name, "EISDIR"))
1031 if (strEQ(name, "ELOOP"))
1039 if (strEQ(name, "EMFILE"))
1045 if (strEQ(name, "EMLINK"))
1051 if (strEQ(name, "EMSGSIZE"))
1059 if (strEQ(name, "ENETDOWN"))
1065 if (strEQ(name, "ENETRESET"))
1071 if (strEQ(name, "ENETUNREACH"))
1077 if (strEQ(name, "ENOBUFS"))
1083 if (strEQ(name, "ENOEXEC"))
1089 if (strEQ(name, "ENOMEM"))
1095 if (strEQ(name, "ENOPROTOOPT"))
1101 if (strEQ(name, "ENOSPC"))
1107 if (strEQ(name, "ENOTBLK"))
1113 if (strEQ(name, "ENOTCONN"))
1119 if (strEQ(name, "ENOTDIR"))
1125 if (strEQ(name, "ENOTEMPTY"))
1131 if (strEQ(name, "ENOTSOCK"))
1137 if (strEQ(name, "ENOTTY"))
1143 if (strEQ(name, "ENFILE"))
1149 if (strEQ(name, "ENODEV"))
1155 if (strEQ(name, "ENOENT"))
1161 if (strEQ(name, "ENOLCK"))
1167 if (strEQ(name, "ENOSYS"))
1173 if (strEQ(name, "ENXIO"))
1179 if (strEQ(name, "ENAMETOOLONG"))
1181 return ENAMETOOLONG;
1187 if (strEQ(name, "EOF"))
1193 if (strEQ(name, "EOPNOTSUPP"))
1201 if (strEQ(name, "EPERM"))
1207 if (strEQ(name, "EPFNOSUPPORT"))
1209 return EPFNOSUPPORT;
1213 if (strEQ(name, "EPIPE"))
1219 if (strEQ(name, "EPROCLIM"))
1225 if (strEQ(name, "EPROTONOSUPPORT"))
1226 #ifdef EPROTONOSUPPORT
1227 return EPROTONOSUPPORT;
1231 if (strEQ(name, "EPROTOTYPE"))
1239 if (strEQ(name, "ERANGE"))
1245 if (strEQ(name, "EREMOTE"))
1251 if (strEQ(name, "ERESTART"))
1257 if (strEQ(name, "EROFS"))
1265 if (strEQ(name, "ESHUTDOWN"))
1271 if (strEQ(name, "ESOCKTNOSUPPORT"))
1272 #ifdef ESOCKTNOSUPPORT
1273 return ESOCKTNOSUPPORT;
1277 if (strEQ(name, "ESPIPE"))
1283 if (strEQ(name, "ESRCH"))
1289 if (strEQ(name, "ESTALE"))
1297 if (strEQ(name, "ETIMEDOUT"))
1303 if (strEQ(name, "ETOOMANYREFS"))
1305 return ETOOMANYREFS;
1309 if (strEQ(name, "ETXTBSY"))
1317 if (strEQ(name, "EUSERS"))
1325 if (strEQ(name, "EWOULDBLOCK"))
1333 if (strEQ(name, "EXIT_FAILURE"))
1335 return EXIT_FAILURE;
1339 if (strEQ(name, "EXIT_SUCCESS"))
1341 return EXIT_SUCCESS;
1345 if (strEQ(name, "EXDEV"))
1353 if (strEQ(name, "E2BIG"))
1361 if (strnEQ(name, "FLT_", 4)) {
1362 if (strEQ(name, "FLT_MAX"))
1368 if (strEQ(name, "FLT_MIN"))
1374 if (strEQ(name, "FLT_ROUNDS"))
1380 if (strEQ(name, "FLT_DIG"))
1386 if (strEQ(name, "FLT_EPSILON"))
1392 if (strEQ(name, "FLT_MANT_DIG"))
1394 return FLT_MANT_DIG;
1398 if (strEQ(name, "FLT_MAX_10_EXP"))
1399 #ifdef FLT_MAX_10_EXP
1400 return FLT_MAX_10_EXP;
1404 if (strEQ(name, "FLT_MAX_EXP"))
1410 if (strEQ(name, "FLT_MIN_10_EXP"))
1411 #ifdef FLT_MIN_10_EXP
1412 return FLT_MIN_10_EXP;
1416 if (strEQ(name, "FLT_MIN_EXP"))
1422 if (strEQ(name, "FLT_RADIX"))
1430 if (strnEQ(name, "F_", 2)) {
1431 if (strEQ(name, "F_DUPFD"))
1437 if (strEQ(name, "F_GETFD"))
1443 if (strEQ(name, "F_GETFL"))
1449 if (strEQ(name, "F_GETLK"))
1455 if (strEQ(name, "F_OK"))
1461 if (strEQ(name, "F_RDLCK"))
1467 if (strEQ(name, "F_SETFD"))
1473 if (strEQ(name, "F_SETFL"))
1479 if (strEQ(name, "F_SETLK"))
1485 if (strEQ(name, "F_SETLKW"))
1491 if (strEQ(name, "F_UNLCK"))
1497 if (strEQ(name, "F_WRLCK"))
1505 if (strEQ(name, "FD_CLOEXEC"))
1511 if (strEQ(name, "FILENAME_MAX"))
1513 return FILENAME_MAX;
1519 if (strEQ(name, "HUGE_VAL"))
1525 if (strEQ(name, "HUPCL"))
1533 if (strEQ(name, "INT_MAX"))
1539 if (strEQ(name, "INT_MIN"))
1545 if (strEQ(name, "ICANON"))
1551 if (strEQ(name, "ICRNL"))
1557 if (strEQ(name, "IEXTEN"))
1563 if (strEQ(name, "IGNBRK"))
1569 if (strEQ(name, "IGNCR"))
1575 if (strEQ(name, "IGNPAR"))
1581 if (strEQ(name, "INLCR"))
1587 if (strEQ(name, "INPCK"))
1593 if (strEQ(name, "ISIG"))
1599 if (strEQ(name, "ISTRIP"))
1605 if (strEQ(name, "IXOFF"))
1611 if (strEQ(name, "IXON"))
1619 if (strnEQ(name, "LC_", 3)) {
1620 if (strEQ(name, "LC_ALL"))
1626 if (strEQ(name, "LC_COLLATE"))
1632 if (strEQ(name, "LC_CTYPE"))
1638 if (strEQ(name, "LC_MONETARY"))
1644 if (strEQ(name, "LC_NUMERIC"))
1650 if (strEQ(name, "LC_TIME"))
1658 if (strnEQ(name, "LDBL_", 5)) {
1659 if (strEQ(name, "LDBL_MAX"))
1665 if (strEQ(name, "LDBL_MIN"))
1671 if (strEQ(name, "LDBL_DIG"))
1677 if (strEQ(name, "LDBL_EPSILON"))
1679 return LDBL_EPSILON;
1683 if (strEQ(name, "LDBL_MANT_DIG"))
1684 #ifdef LDBL_MANT_DIG
1685 return LDBL_MANT_DIG;
1689 if (strEQ(name, "LDBL_MAX_10_EXP"))
1690 #ifdef LDBL_MAX_10_EXP
1691 return LDBL_MAX_10_EXP;
1695 if (strEQ(name, "LDBL_MAX_EXP"))
1697 return LDBL_MAX_EXP;
1701 if (strEQ(name, "LDBL_MIN_10_EXP"))
1702 #ifdef LDBL_MIN_10_EXP
1703 return LDBL_MIN_10_EXP;
1707 if (strEQ(name, "LDBL_MIN_EXP"))
1709 return LDBL_MIN_EXP;
1715 if (strnEQ(name, "L_", 2)) {
1716 if (strEQ(name, "L_ctermid"))
1722 if (strEQ(name, "L_cuserid"))
1728 /* L_tmpnam[e] was a typo--retained for compatibility */
1729 if (strEQ(name, "L_tmpname") || strEQ(name, "L_tmpnam"))
1737 if (strEQ(name, "LONG_MAX"))
1743 if (strEQ(name, "LONG_MIN"))
1749 if (strEQ(name, "LINK_MAX"))
1757 if (strEQ(name, "MAX_CANON"))
1763 if (strEQ(name, "MAX_INPUT"))
1769 if (strEQ(name, "MB_CUR_MAX"))
1775 if (strEQ(name, "MB_LEN_MAX"))
1783 if (strEQ(name, "NULL")) return 0;
1784 if (strEQ(name, "NAME_MAX"))
1790 if (strEQ(name, "NCCS"))
1796 if (strEQ(name, "NGROUPS_MAX"))
1802 if (strEQ(name, "NOFLSH"))
1810 if (strnEQ(name, "O_", 2)) {
1811 if (strEQ(name, "O_APPEND"))
1817 if (strEQ(name, "O_CREAT"))
1823 if (strEQ(name, "O_TRUNC"))
1829 if (strEQ(name, "O_RDONLY"))
1835 if (strEQ(name, "O_RDWR"))
1841 if (strEQ(name, "O_WRONLY"))
1847 if (strEQ(name, "O_EXCL"))
1853 if (strEQ(name, "O_NOCTTY"))
1859 if (strEQ(name, "O_NONBLOCK"))
1865 if (strEQ(name, "O_ACCMODE"))
1873 if (strEQ(name, "OPEN_MAX"))
1879 if (strEQ(name, "OPOST"))
1887 if (strEQ(name, "PATH_MAX"))
1893 if (strEQ(name, "PARENB"))
1899 if (strEQ(name, "PARMRK"))
1905 if (strEQ(name, "PARODD"))
1911 if (strEQ(name, "PIPE_BUF"))
1919 if (strEQ(name, "RAND_MAX"))
1925 if (strEQ(name, "R_OK"))
1933 if (strnEQ(name, "SIG", 3)) {
1934 if (name[3] == '_') {
1935 if (strEQ(name, "SIG_BLOCK"))
1942 if (strEQ(name, "SIG_DFL")) return (IV)SIG_DFL;
1945 if (strEQ(name, "SIG_ERR")) return (IV)SIG_ERR;
1948 if (strEQ(name, "SIG_IGN")) return (IV)SIG_IGN;
1950 if (strEQ(name, "SIG_SETMASK"))
1956 if (strEQ(name, "SIG_UNBLOCK"))
1964 if (strEQ(name, "SIGABRT"))
1970 if (strEQ(name, "SIGALRM"))
1976 if (strEQ(name, "SIGCHLD"))
1982 if (strEQ(name, "SIGCONT"))
1988 if (strEQ(name, "SIGFPE"))
1994 if (strEQ(name, "SIGHUP"))
2000 if (strEQ(name, "SIGILL"))
2006 if (strEQ(name, "SIGINT"))
2012 if (strEQ(name, "SIGKILL"))
2018 if (strEQ(name, "SIGPIPE"))
2024 if (strEQ(name, "SIGQUIT"))
2030 if (strEQ(name, "SIGSEGV"))
2036 if (strEQ(name, "SIGSTOP"))
2042 if (strEQ(name, "SIGTERM"))
2048 if (strEQ(name, "SIGTSTP"))
2054 if (strEQ(name, "SIGTTIN"))
2060 if (strEQ(name, "SIGTTOU"))
2066 if (strEQ(name, "SIGUSR1"))
2072 if (strEQ(name, "SIGUSR2"))
2080 if (name[1] == '_') {
2081 if (strEQ(name, "S_ISGID"))
2087 if (strEQ(name, "S_ISUID"))
2093 if (strEQ(name, "S_IRGRP"))
2099 if (strEQ(name, "S_IROTH"))
2105 if (strEQ(name, "S_IRUSR"))
2111 if (strEQ(name, "S_IRWXG"))
2117 if (strEQ(name, "S_IRWXO"))
2123 if (strEQ(name, "S_IRWXU"))
2129 if (strEQ(name, "S_IWGRP"))
2135 if (strEQ(name, "S_IWOTH"))
2141 if (strEQ(name, "S_IWUSR"))
2147 if (strEQ(name, "S_IXGRP"))
2153 if (strEQ(name, "S_IXOTH"))
2159 if (strEQ(name, "S_IXUSR"))
2165 errno = EAGAIN; /* the following aren't constants */
2167 if (strEQ(name, "S_ISBLK")) return S_ISBLK(arg);
2170 if (strEQ(name, "S_ISCHR")) return S_ISCHR(arg);
2173 if (strEQ(name, "S_ISDIR")) return S_ISDIR(arg);
2176 if (strEQ(name, "S_ISFIFO")) return S_ISFIFO(arg);
2179 if (strEQ(name, "S_ISREG")) return S_ISREG(arg);
2183 if (strEQ(name, "SEEK_CUR"))
2189 if (strEQ(name, "SEEK_END"))
2195 if (strEQ(name, "SEEK_SET"))
2201 if (strEQ(name, "STREAM_MAX"))
2207 if (strEQ(name, "SHRT_MAX"))
2213 if (strEQ(name, "SHRT_MIN"))
2219 if (strnEQ(name, "SA_", 3)) {
2220 if (strEQ(name, "SA_NOCLDSTOP"))
2222 return SA_NOCLDSTOP;
2226 if (strEQ(name, "SA_NOCLDWAIT"))
2228 return SA_NOCLDWAIT;
2232 if (strEQ(name, "SA_NODEFER"))
2238 if (strEQ(name, "SA_ONSTACK"))
2244 if (strEQ(name, "SA_RESETHAND"))
2246 return SA_RESETHAND;
2250 if (strEQ(name, "SA_RESTART"))
2256 if (strEQ(name, "SA_SIGINFO"))
2264 if (strEQ(name, "SCHAR_MAX"))
2270 if (strEQ(name, "SCHAR_MIN"))
2276 if (strEQ(name, "SSIZE_MAX"))
2282 if (strEQ(name, "STDIN_FILENO"))
2284 return STDIN_FILENO;
2288 if (strEQ(name, "STDOUT_FILENO"))
2289 #ifdef STDOUT_FILENO
2290 return STDOUT_FILENO;
2294 if (strEQ(name, "STRERR_FILENO"))
2295 #ifdef STRERR_FILENO
2296 return STRERR_FILENO;
2302 if (strEQ(name, "TCIFLUSH"))
2308 if (strEQ(name, "TCIOFF"))
2314 if (strEQ(name, "TCIOFLUSH"))
2320 if (strEQ(name, "TCION"))
2326 if (strEQ(name, "TCOFLUSH"))
2332 if (strEQ(name, "TCOOFF"))
2338 if (strEQ(name, "TCOON"))
2344 if (strEQ(name, "TCSADRAIN"))
2350 if (strEQ(name, "TCSAFLUSH"))
2356 if (strEQ(name, "TCSANOW"))
2362 if (strEQ(name, "TMP_MAX"))
2368 if (strEQ(name, "TOSTOP"))
2374 if (strEQ(name, "TZNAME_MAX"))
2382 if (strEQ(name, "UCHAR_MAX"))
2388 if (strEQ(name, "UINT_MAX"))
2394 if (strEQ(name, "ULONG_MAX"))
2400 if (strEQ(name, "USHRT_MAX"))
2408 if (strEQ(name, "VEOF"))
2414 if (strEQ(name, "VEOL"))
2420 if (strEQ(name, "VERASE"))
2426 if (strEQ(name, "VINTR"))
2432 if (strEQ(name, "VKILL"))
2438 if (strEQ(name, "VMIN"))
2444 if (strEQ(name, "VQUIT"))
2450 if (strEQ(name, "VSTART"))
2456 if (strEQ(name, "VSTOP"))
2462 if (strEQ(name, "VSUSP"))
2468 if (strEQ(name, "VTIME"))
2476 if (strEQ(name, "W_OK"))
2482 if (strEQ(name, "WNOHANG"))
2488 if (strEQ(name, "WUNTRACED"))
2494 errno = EAGAIN; /* the following aren't constants */
2496 if (strEQ(name, "WEXITSTATUS")) return WEXITSTATUS(arg);
2499 if (strEQ(name, "WIFEXITED")) return WIFEXITED(arg);
2502 if (strEQ(name, "WIFSIGNALED")) return WIFSIGNALED(arg);
2505 if (strEQ(name, "WIFSTOPPED")) return WIFSTOPPED(arg);
2508 if (strEQ(name, "WSTOPSIG")) return WSTOPSIG(arg);
2511 if (strEQ(name, "WTERMSIG")) return WTERMSIG(arg);
2515 if (strEQ(name, "X_OK"))
2523 if (strnEQ(name, "_PC_", 4)) {
2524 if (strEQ(name, "_PC_CHOWN_RESTRICTED"))
2525 #if defined(_PC_CHOWN_RESTRICTED) || HINT_SC_EXIST
2526 return _PC_CHOWN_RESTRICTED;
2530 if (strEQ(name, "_PC_LINK_MAX"))
2531 #if defined(_PC_LINK_MAX) || HINT_SC_EXIST
2532 return _PC_LINK_MAX;
2536 if (strEQ(name, "_PC_MAX_CANON"))
2537 #if defined(_PC_MAX_CANON) || HINT_SC_EXIST
2538 return _PC_MAX_CANON;
2542 if (strEQ(name, "_PC_MAX_INPUT"))
2543 #if defined(_PC_MAX_INPUT) || HINT_SC_EXIST
2544 return _PC_MAX_INPUT;
2548 if (strEQ(name, "_PC_NAME_MAX"))
2549 #if defined(_PC_NAME_MAX) || HINT_SC_EXIST
2550 return _PC_NAME_MAX;
2554 if (strEQ(name, "_PC_NO_TRUNC"))
2555 #if defined(_PC_NO_TRUNC) || HINT_SC_EXIST
2556 return _PC_NO_TRUNC;
2560 if (strEQ(name, "_PC_PATH_MAX"))
2561 #if defined(_PC_PATH_MAX) || HINT_SC_EXIST
2562 return _PC_PATH_MAX;
2566 if (strEQ(name, "_PC_PIPE_BUF"))
2567 #if defined(_PC_PIPE_BUF) || HINT_SC_EXIST
2568 return _PC_PIPE_BUF;
2572 if (strEQ(name, "_PC_VDISABLE"))
2573 #if defined(_PC_VDISABLE) || HINT_SC_EXIST
2574 return _PC_VDISABLE;
2580 if (strnEQ(name, "_POSIX_", 7)) {
2581 if (strEQ(name, "_POSIX_ARG_MAX"))
2582 #ifdef _POSIX_ARG_MAX
2583 return _POSIX_ARG_MAX;
2587 if (strEQ(name, "_POSIX_CHILD_MAX"))
2588 #ifdef _POSIX_CHILD_MAX
2589 return _POSIX_CHILD_MAX;
2593 if (strEQ(name, "_POSIX_CHOWN_RESTRICTED"))
2594 #ifdef _POSIX_CHOWN_RESTRICTED
2595 return _POSIX_CHOWN_RESTRICTED;
2599 if (strEQ(name, "_POSIX_JOB_CONTROL"))
2600 #ifdef _POSIX_JOB_CONTROL
2601 return _POSIX_JOB_CONTROL;
2605 if (strEQ(name, "_POSIX_LINK_MAX"))
2606 #ifdef _POSIX_LINK_MAX
2607 return _POSIX_LINK_MAX;
2611 if (strEQ(name, "_POSIX_MAX_CANON"))
2612 #ifdef _POSIX_MAX_CANON
2613 return _POSIX_MAX_CANON;
2617 if (strEQ(name, "_POSIX_MAX_INPUT"))
2618 #ifdef _POSIX_MAX_INPUT
2619 return _POSIX_MAX_INPUT;
2623 if (strEQ(name, "_POSIX_NAME_MAX"))
2624 #ifdef _POSIX_NAME_MAX
2625 return _POSIX_NAME_MAX;
2629 if (strEQ(name, "_POSIX_NGROUPS_MAX"))
2630 #ifdef _POSIX_NGROUPS_MAX
2631 return _POSIX_NGROUPS_MAX;
2635 if (strEQ(name, "_POSIX_NO_TRUNC"))
2636 #ifdef _POSIX_NO_TRUNC
2637 return _POSIX_NO_TRUNC;
2641 if (strEQ(name, "_POSIX_OPEN_MAX"))
2642 #ifdef _POSIX_OPEN_MAX
2643 return _POSIX_OPEN_MAX;
2647 if (strEQ(name, "_POSIX_PATH_MAX"))
2648 #ifdef _POSIX_PATH_MAX
2649 return _POSIX_PATH_MAX;
2653 if (strEQ(name, "_POSIX_PIPE_BUF"))
2654 #ifdef _POSIX_PIPE_BUF
2655 return _POSIX_PIPE_BUF;
2659 if (strEQ(name, "_POSIX_SAVED_IDS"))
2660 #ifdef _POSIX_SAVED_IDS
2661 return _POSIX_SAVED_IDS;
2665 if (strEQ(name, "_POSIX_SSIZE_MAX"))
2666 #ifdef _POSIX_SSIZE_MAX
2667 return _POSIX_SSIZE_MAX;
2671 if (strEQ(name, "_POSIX_STREAM_MAX"))
2672 #ifdef _POSIX_STREAM_MAX
2673 return _POSIX_STREAM_MAX;
2677 if (strEQ(name, "_POSIX_TZNAME_MAX"))
2678 #ifdef _POSIX_TZNAME_MAX
2679 return _POSIX_TZNAME_MAX;
2683 if (strEQ(name, "_POSIX_VDISABLE"))
2684 #ifdef _POSIX_VDISABLE
2685 return _POSIX_VDISABLE;
2689 if (strEQ(name, "_POSIX_VERSION"))
2690 #ifdef _POSIX_VERSION
2691 return _POSIX_VERSION;
2697 if (strnEQ(name, "_SC_", 4)) {
2698 if (strEQ(name, "_SC_ARG_MAX"))
2699 #if defined(_SC_ARG_MAX) || HINT_SC_EXIST
2704 if (strEQ(name, "_SC_CHILD_MAX"))
2705 #if defined(_SC_CHILD_MAX) || HINT_SC_EXIST
2706 return _SC_CHILD_MAX;
2710 if (strEQ(name, "_SC_CLK_TCK"))
2711 #if defined(_SC_CLK_TCK) || HINT_SC_EXIST
2716 if (strEQ(name, "_SC_JOB_CONTROL"))
2717 #if defined(_SC_JOB_CONTROL) || HINT_SC_EXIST
2718 return _SC_JOB_CONTROL;
2722 if (strEQ(name, "_SC_NGROUPS_MAX"))
2723 #if defined(_SC_NGROUPS_MAX) || HINT_SC_EXIST
2724 return _SC_NGROUPS_MAX;
2728 if (strEQ(name, "_SC_OPEN_MAX"))
2729 #if defined(_SC_OPEN_MAX) || HINT_SC_EXIST
2730 return _SC_OPEN_MAX;
2734 if (strEQ(name, "_SC_SAVED_IDS"))
2735 #if defined(_SC_SAVED_IDS) || HINT_SC_EXIST
2736 return _SC_SAVED_IDS;
2740 if (strEQ(name, "_SC_STREAM_MAX"))
2741 #if defined(_SC_STREAM_MAX) || HINT_SC_EXIST
2742 return _SC_STREAM_MAX;
2746 if (strEQ(name, "_SC_TZNAME_MAX"))
2747 #if defined(_SC_TZNAME_MAX) || HINT_SC_EXIST
2748 return _SC_TZNAME_MAX;
2752 if (strEQ(name, "_SC_VERSION"))
2753 #if defined(_SC_VERSION) || HINT_SC_EXIST
2769 MODULE = SigSet PACKAGE = POSIX::SigSet PREFIX = sig
2772 new(packname = "POSIX::SigSet", ...)
2777 New(0, RETVAL, 1, sigset_t);
2778 sigemptyset(RETVAL);
2779 for (i = 1; i < items; i++)
2780 sigaddset(RETVAL, SvIV(ST(i)));
2787 POSIX::SigSet sigset
2792 sigaddset(sigset, sig)
2793 POSIX::SigSet sigset
2797 sigdelset(sigset, sig)
2798 POSIX::SigSet sigset
2803 POSIX::SigSet sigset
2807 POSIX::SigSet sigset
2810 sigismember(sigset, sig)
2811 POSIX::SigSet sigset
2815 MODULE = Termios PACKAGE = POSIX::Termios PREFIX = cf
2818 new(packname = "POSIX::Termios", ...)
2823 New(0, RETVAL, 1, struct termios);
2825 not_here("termios");
2833 DESTROY(termios_ref)
2834 POSIX::Termios termios_ref
2837 Safefree(termios_ref);
2839 not_here("termios");
2843 getattr(termios_ref, fd = 0)
2844 POSIX::Termios termios_ref
2847 RETVAL = tcgetattr(fd, termios_ref);
2852 setattr(termios_ref, fd = 0, optional_actions = 0)
2853 POSIX::Termios termios_ref
2855 int optional_actions
2857 RETVAL = tcsetattr(fd, optional_actions, termios_ref);
2862 cfgetispeed(termios_ref)
2863 POSIX::Termios termios_ref
2866 cfgetospeed(termios_ref)
2867 POSIX::Termios termios_ref
2870 getiflag(termios_ref)
2871 POSIX::Termios termios_ref
2873 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2874 RETVAL = termios_ref->c_iflag;
2876 not_here("getiflag");
2883 getoflag(termios_ref)
2884 POSIX::Termios termios_ref
2886 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2887 RETVAL = termios_ref->c_oflag;
2889 not_here("getoflag");
2896 getcflag(termios_ref)
2897 POSIX::Termios termios_ref
2899 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2900 RETVAL = termios_ref->c_cflag;
2902 not_here("getcflag");
2909 getlflag(termios_ref)
2910 POSIX::Termios termios_ref
2912 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2913 RETVAL = termios_ref->c_lflag;
2915 not_here("getlflag");
2922 getcc(termios_ref, ccix)
2923 POSIX::Termios termios_ref
2926 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2928 croak("Bad getcc subscript");
2929 RETVAL = termios_ref->c_cc[ccix];
2938 cfsetispeed(termios_ref, speed)
2939 POSIX::Termios termios_ref
2943 cfsetospeed(termios_ref, speed)
2944 POSIX::Termios termios_ref
2948 setiflag(termios_ref, iflag)
2949 POSIX::Termios termios_ref
2952 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2953 termios_ref->c_iflag = iflag;
2955 not_here("setiflag");
2959 setoflag(termios_ref, oflag)
2960 POSIX::Termios termios_ref
2963 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2964 termios_ref->c_oflag = oflag;
2966 not_here("setoflag");
2970 setcflag(termios_ref, cflag)
2971 POSIX::Termios termios_ref
2974 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2975 termios_ref->c_cflag = cflag;
2977 not_here("setcflag");
2981 setlflag(termios_ref, lflag)
2982 POSIX::Termios termios_ref
2985 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2986 termios_ref->c_lflag = lflag;
2988 not_here("setlflag");
2992 setcc(termios_ref, ccix, cc)
2993 POSIX::Termios termios_ref
2997 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2999 croak("Bad setcc subscript");
3000 termios_ref->c_cc[ccix] = cc;
3006 MODULE = POSIX PACKAGE = POSIX
3015 unsigned char * charstring
3017 unsigned char *s = charstring;
3018 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3019 for (RETVAL = 1; RETVAL && s < e; s++)
3027 unsigned char * charstring
3029 unsigned char *s = charstring;
3030 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3031 for (RETVAL = 1; RETVAL && s < e; s++)
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++)
3134 isxdigit(charstring)
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++)
3146 open(filename, flags = O_RDONLY, mode = 0666)
3151 if (flags & (O_APPEND|O_CREAT|O_TRUNC|O_RDWR|O_WRONLY|O_EXCL))
3152 TAINT_PROPER("open");
3153 RETVAL = open(filename, flags, mode);
3161 #ifdef HAS_LOCALECONV
3162 struct lconv *lcbuf;
3164 if (lcbuf = localeconv()) {
3166 if (lcbuf->decimal_point && *lcbuf->decimal_point)
3167 hv_store(RETVAL, "decimal_point", 13,
3168 newSVpv(lcbuf->decimal_point, 0), 0);
3169 if (lcbuf->thousands_sep && *lcbuf->thousands_sep)
3170 hv_store(RETVAL, "thousands_sep", 13,
3171 newSVpv(lcbuf->thousands_sep, 0), 0);
3172 #ifndef NO_LOCALECONV_GROUPING
3173 if (lcbuf->grouping && *lcbuf->grouping)
3174 hv_store(RETVAL, "grouping", 8,
3175 newSVpv(lcbuf->grouping, 0), 0);
3177 if (lcbuf->int_curr_symbol && *lcbuf->int_curr_symbol)
3178 hv_store(RETVAL, "int_curr_symbol", 15,
3179 newSVpv(lcbuf->int_curr_symbol, 0), 0);
3180 if (lcbuf->currency_symbol && *lcbuf->currency_symbol)
3181 hv_store(RETVAL, "currency_symbol", 15,
3182 newSVpv(lcbuf->currency_symbol, 0), 0);
3183 if (lcbuf->mon_decimal_point && *lcbuf->mon_decimal_point)
3184 hv_store(RETVAL, "mon_decimal_point", 17,
3185 newSVpv(lcbuf->mon_decimal_point, 0), 0);
3186 #ifndef NO_LOCALECONV_MON_THOUSANDS_SEP
3187 if (lcbuf->mon_thousands_sep && *lcbuf->mon_thousands_sep)
3188 hv_store(RETVAL, "mon_thousands_sep", 17,
3189 newSVpv(lcbuf->mon_thousands_sep, 0), 0);
3191 #ifndef NO_LOCALECONV_MON_GROUPING
3192 if (lcbuf->mon_grouping && *lcbuf->mon_grouping)
3193 hv_store(RETVAL, "mon_grouping", 12,
3194 newSVpv(lcbuf->mon_grouping, 0), 0);
3196 if (lcbuf->positive_sign && *lcbuf->positive_sign)
3197 hv_store(RETVAL, "positive_sign", 13,
3198 newSVpv(lcbuf->positive_sign, 0), 0);
3199 if (lcbuf->negative_sign && *lcbuf->negative_sign)
3200 hv_store(RETVAL, "negative_sign", 13,
3201 newSVpv(lcbuf->negative_sign, 0), 0);
3203 if (lcbuf->int_frac_digits != CHAR_MAX)
3204 hv_store(RETVAL, "int_frac_digits", 15,
3205 newSViv(lcbuf->int_frac_digits), 0);
3206 if (lcbuf->frac_digits != CHAR_MAX)
3207 hv_store(RETVAL, "frac_digits", 11,
3208 newSViv(lcbuf->frac_digits), 0);
3209 if (lcbuf->p_cs_precedes != CHAR_MAX)
3210 hv_store(RETVAL, "p_cs_precedes", 13,
3211 newSViv(lcbuf->p_cs_precedes), 0);
3212 if (lcbuf->p_sep_by_space != CHAR_MAX)
3213 hv_store(RETVAL, "p_sep_by_space", 14,
3214 newSViv(lcbuf->p_sep_by_space), 0);
3215 if (lcbuf->n_cs_precedes != CHAR_MAX)
3216 hv_store(RETVAL, "n_cs_precedes", 13,
3217 newSViv(lcbuf->n_cs_precedes), 0);
3218 if (lcbuf->n_sep_by_space != CHAR_MAX)
3219 hv_store(RETVAL, "n_sep_by_space", 14,
3220 newSViv(lcbuf->n_sep_by_space), 0);
3221 if (lcbuf->p_sign_posn != CHAR_MAX)
3222 hv_store(RETVAL, "p_sign_posn", 11,
3223 newSViv(lcbuf->p_sign_posn), 0);
3224 if (lcbuf->n_sign_posn != CHAR_MAX)
3225 hv_store(RETVAL, "n_sign_posn", 11,
3226 newSViv(lcbuf->n_sign_posn), 0);
3229 localeconv(); /* A stub to call not_here(). */
3235 setlocale(category, locale = 0)
3239 RETVAL = setlocale(category, locale);
3241 #ifdef USE_LOCALE_CTYPE
3242 if (category == LC_CTYPE
3244 || category == LC_ALL
3250 if (category == LC_ALL)
3251 newctype = setlocale(LC_CTYPE, NULL);
3255 new_ctype(newctype);
3257 #endif /* USE_LOCALE_CTYPE */
3258 #ifdef USE_LOCALE_COLLATE
3259 if (category == LC_COLLATE
3261 || category == LC_ALL
3267 if (category == LC_ALL)
3268 newcoll = setlocale(LC_COLLATE, NULL);
3272 new_collate(newcoll);
3274 #endif /* USE_LOCALE_COLLATE */
3275 #ifdef USE_LOCALE_NUMERIC
3276 if (category == LC_NUMERIC
3278 || category == LC_ALL
3284 if (category == LC_ALL)
3285 newnum = setlocale(LC_NUMERIC, NULL);
3289 new_numeric(newnum);
3291 #endif /* USE_LOCALE_NUMERIC */
3331 /* (We already know stack is long enough.) */
3332 PUSHs(sv_2mortal(newSVnv(frexp(x,&expvar))));
3333 PUSHs(sv_2mortal(newSViv(expvar)));
3349 /* (We already know stack is long enough.) */
3350 PUSHs(sv_2mortal(newSVnv(modf(x,&intvar))));
3351 PUSHs(sv_2mortal(newSVnv(intvar)));
3366 sigaction(sig, action, oldaction = 0)
3368 POSIX::SigAction action
3369 POSIX::SigAction oldaction
3372 RETVAL = not_here("sigaction");
3374 # This code is really grody because we're trying to make the signal
3375 # interface look beautiful, which is hard.
3378 GV *siggv = gv_fetchpv("SIG", TRUE, SVt_PVHV);
3379 struct sigaction act;
3380 struct sigaction oact;
3381 POSIX__SigSet sigset;
3383 SV** sigsvp = hv_fetch(GvHVn(siggv),
3385 strlen(PL_sig_name[sig]),
3389 /* Remember old handler name if desired. */
3391 char *hand = SvPVx(*sigsvp, n_a);
3392 svp = hv_fetch(oldaction, "HANDLER", 7, TRUE);
3393 sv_setpv(*svp, *hand ? hand : "DEFAULT");
3397 /* Vector new handler through %SIG. (We always use sighandler
3398 for the C signal handler, which reads %SIG to dispatch.) */
3399 svp = hv_fetch(action, "HANDLER", 7, FALSE);
3401 croak("Can't supply an action without a HANDLER");
3402 sv_setpv(*sigsvp, SvPV(*svp, n_a));
3403 mg_set(*sigsvp); /* handles DEFAULT and IGNORE */
3404 act.sa_handler = PL_sighandlerp;
3406 /* Set up any desired mask. */
3407 svp = hv_fetch(action, "MASK", 4, FALSE);
3408 if (svp && sv_isa(*svp, "POSIX::SigSet")) {
3410 tmp = (unsigned long)SvNV((SV*)SvRV(*svp));
3411 sigset = (sigset_t*) tmp;
3412 act.sa_mask = *sigset;
3415 sigemptyset(& act.sa_mask);
3417 /* Set up any desired flags. */
3418 svp = hv_fetch(action, "FLAGS", 5, FALSE);
3419 act.sa_flags = svp ? SvIV(*svp) : 0;
3422 /* Now work around sigaction oddities */
3423 if (action && oldaction)
3424 RETVAL = sigaction(sig, & act, & oact);
3426 RETVAL = sigaction(sig, & act, (struct sigaction *)0);
3428 RETVAL = sigaction(sig, (struct sigaction *)0, & oact);
3433 /* Get back the mask. */
3434 svp = hv_fetch(oldaction, "MASK", 4, TRUE);
3435 if (sv_isa(*svp, "POSIX::SigSet")) {
3437 tmp = (unsigned long)SvNV((SV*)SvRV(*svp));
3438 sigset = (sigset_t*) tmp;
3441 New(0, sigset, 1, sigset_t);
3442 sv_setptrobj(*svp, sigset, "POSIX::SigSet");
3444 *sigset = oact.sa_mask;
3446 /* Get back the flags. */
3447 svp = hv_fetch(oldaction, "FLAGS", 5, TRUE);
3448 sv_setiv(*svp, oact.sa_flags);
3457 POSIX::SigSet sigset
3460 sigprocmask(how, sigset, oldsigset = 0)
3462 POSIX::SigSet sigset
3463 POSIX::SigSet oldsigset = NO_INIT
3468 else if (sv_derived_from(ST(2), "POSIX::SigSet")) {
3469 IV tmp = SvIV((SV*)SvRV(ST(2)));
3470 oldsigset = INT2PTR(POSIX__SigSet,tmp);
3473 New(0, oldsigset, 1, sigset_t);
3474 sigemptyset(oldsigset);
3475 sv_setref_pv(ST(2), "POSIX::SigSet", (void*)oldsigset);
3479 sigsuspend(signal_mask)
3480 POSIX::SigSet signal_mask
3500 lseek(fd, offset, whence)
3513 if (pipe(fds) != -1) {
3515 PUSHs(sv_2mortal(newSViv(fds[0])));
3516 PUSHs(sv_2mortal(newSViv(fds[1])));
3520 read(fd, buffer, nbytes)
3522 SV *sv_buffer = SvROK(ST(1)) ? SvRV(ST(1)) : ST(1);
3526 char * buffer = sv_grow( sv_buffer, nbytes+1 );
3529 SvCUR(sv_buffer) = RETVAL;
3530 SvPOK_only(sv_buffer);
3531 *SvEND(sv_buffer) = '\0';
3532 SvTAINTED_on(sv_buffer);
3548 tcsetpgrp(fd, pgrp_id)
3557 if (uname(&buf) >= 0) {
3559 PUSHs(sv_2mortal(newSVpv(buf.sysname, 0)));
3560 PUSHs(sv_2mortal(newSVpv(buf.nodename, 0)));
3561 PUSHs(sv_2mortal(newSVpv(buf.release, 0)));
3562 PUSHs(sv_2mortal(newSVpv(buf.version, 0)));
3563 PUSHs(sv_2mortal(newSVpv(buf.machine, 0)));
3566 uname((char *) 0); /* A stub to call not_here(). */
3570 write(fd, buffer, nbytes)
3581 RETVAL = newSVpvn("", 0);
3582 SvGROW(RETVAL, L_tmpnam);
3583 len = strlen(tmpnam(SvPV(RETVAL, i)));
3584 SvCUR_set(RETVAL, len);
3597 mbstowcs(s, pwcs, n)
3609 wcstombs(s, pwcs, n)
3631 SET_NUMERIC_LOCAL();
3632 num = strtod(str, &unparsed);
3633 PUSHs(sv_2mortal(newSVnv(num)));
3634 if (GIMME == G_ARRAY) {
3637 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3639 PUSHs(&PL_sv_undef);
3643 strtol(str, base = 0)
3650 num = strtol(str, &unparsed, base);
3651 #if IVSIZE <= LONGSIZE
3652 if (num < IV_MIN || num > IV_MAX)
3653 PUSHs(sv_2mortal(newSVnv((double)num)));
3656 PUSHs(sv_2mortal(newSViv((IV)num)));
3657 if (GIMME == G_ARRAY) {
3660 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3662 PUSHs(&PL_sv_undef);
3666 strtoul(str, base = 0)
3673 num = strtoul(str, &unparsed, base);
3675 PUSHs(sv_2mortal(newSViv((IV)num)));
3677 PUSHs(sv_2mortal(newSVnv((double)num)));
3678 if (GIMME == G_ARRAY) {
3681 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3683 PUSHs(&PL_sv_undef);
3693 char *p = SvPV(src,srclen);
3695 ST(0) = sv_2mortal(NEWSV(800,srclen));
3696 dstlen = strxfrm(SvPVX(ST(0)), p, (size_t)srclen);
3697 if (dstlen > srclen) {
3699 SvGROW(ST(0), dstlen);
3700 strxfrm(SvPVX(ST(0)), p, (size_t)dstlen);
3703 SvCUR(ST(0)) = dstlen;
3708 mkfifo(filename, mode)
3712 TAINT_PROPER("mkfifo");
3713 RETVAL = mkfifo(filename, mode);
3729 tcflush(fd, queue_selector)
3734 tcsendbreak(fd, duration)
3739 asctime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3752 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3755 mytm.tm_hour = hour;
3756 mytm.tm_mday = mday;
3758 mytm.tm_year = year;
3759 mytm.tm_wday = wday;
3760 mytm.tm_yday = yday;
3761 mytm.tm_isdst = isdst;
3762 RETVAL = asctime(&mytm);
3779 realtime = times( &tms );
3781 PUSHs( sv_2mortal( newSViv( (IV) realtime ) ) );
3782 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_utime ) ) );
3783 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_stime ) ) );
3784 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cutime ) ) );
3785 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cstime ) ) );
3788 difftime(time1, time2)
3793 mktime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3806 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3809 mytm.tm_hour = hour;
3810 mytm.tm_mday = mday;
3812 mytm.tm_year = year;
3813 mytm.tm_wday = wday;
3814 mytm.tm_yday = yday;
3815 mytm.tm_isdst = isdst;
3816 RETVAL = mktime(&mytm);
3822 strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1)
3838 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3841 mytm.tm_hour = hour;
3842 mytm.tm_mday = mday;
3844 mytm.tm_year = year;
3845 mytm.tm_wday = wday;
3846 mytm.tm_yday = yday;
3847 mytm.tm_isdst = isdst;
3849 len = strftime(tmpbuf, sizeof tmpbuf, fmt, &mytm);
3851 ** The following is needed to handle to the situation where
3852 ** tmpbuf overflows. Basically we want to allocate a buffer
3853 ** and try repeatedly. The reason why it is so complicated
3854 ** is that getting a return value of 0 from strftime can indicate
3855 ** one of the following:
3856 ** 1. buffer overflowed,
3857 ** 2. illegal conversion specifier, or
3858 ** 3. the format string specifies nothing to be returned(not
3859 ** an error). This could be because format is an empty string
3860 ** or it specifies %p that yields an empty string in some locale.
3861 ** If there is a better way to make it portable, go ahead by
3864 if ((len > 0 && len < sizeof(tmpbuf)) || (len == 0 && *fmt == '\0'))
3865 ST(0) = sv_2mortal(newSVpv(tmpbuf, len));
3867 /* Possibly buf overflowed - try again with a bigger buf */
3868 int fmtlen = strlen(fmt);
3869 int bufsize = fmtlen + sizeof(tmpbuf);
3873 New(0, buf, bufsize, char);
3875 buflen = strftime(buf, bufsize, fmt, &mytm);
3876 if (buflen > 0 && buflen < bufsize)
3878 /* heuristic to prevent out-of-memory errors */
3879 if (bufsize > 100*fmtlen) {
3885 Renew(buf, bufsize, char);
3888 ST(0) = sv_2mortal(newSVpvn(buf, buflen));
3892 ST(0) = sv_2mortal(newSVpvn(tmpbuf, len));
3903 PUSHs(sv_2mortal(newSVpvn(tzname[0],strlen(tzname[0]))));
3904 PUSHs(sv_2mortal(newSVpvn(tzname[1],strlen(tzname[1]))));
3907 access(filename, mode)
3925 pathconf(filename, name)