5 #define PERL_NO_GET_CONTEXT
8 #define PERLIO_NOT_STDIO 1
11 #if defined(PERL_OBJECT) || defined(PERL_CAPI) || defined(PERL_IMPLICIT_SYS)
15 # define open PerlLIO_open3
18 #ifdef I_DIRENT /* XXX maybe better to just rely on perl.h? */
41 /* XXX This comment is just to make I_TERMIO and I_SGTTY visible to
42 metaconfig for future extension writers. We don't use them in POSIX.
43 (This is really sneaky :-) --AD
45 #if defined(I_TERMIOS)
53 #include <sys/types.h>
58 #ifdef MACOS_TRADITIONAL
63 #if defined(__VMS) && !defined(__POSIX_SOURCE)
64 # include <libdef.h> /* LIB$_INVARG constant */
65 # include <lib$routines.h> /* prototype for lib$ediv() */
66 # include <starlet.h> /* prototype for sys$gettim() */
67 # if DECC_VERSION < 50000000
68 # define pid_t int /* old versions of DECC miss this in types.h */
72 # define mkfifo(a,b) (not_here("mkfifo"),-1)
73 # define tzset() not_here("tzset")
75 #if ((__VMS_VER >= 70000000) && (__DECC_VER >= 50200000)) || (__CRTL_VER >= 70000000)
76 # define HAS_TZNAME /* shows up in VMS 7.0 or Dec C 5.6 */
78 # endif /* __VMS_VER >= 70000000 or Dec C 5.6 */
80 /* The POSIX notion of ttyname() is better served by getname() under VMS */
81 static char ttnambuf[64];
82 # define ttyname(fd) (isatty(fd) > 0 ? getname(fd,ttnambuf,0) : NULL)
84 /* The non-POSIX CRTL times() has void return type, so we just get the
85 current time directly */
86 clock_t vms_times(struct tms *bufptr) {
89 /* Get wall time and convert to 10 ms intervals to
90 * produce the return value that the POSIX standard expects */
91 # if defined(__DECC) && defined (__ALPHA)
94 _ckvmssts(sys$gettim(&vmstime));
96 retval = vmstime & 0x7fffffff;
98 /* (Older hw or ccs don't have an atomic 64-bit type, so we
99 * juggle 32-bit ints (and a float) to produce a time_t result
100 * with minimal loss of information.) */
101 long int vmstime[2],remainder,divisor = 100000;
102 _ckvmssts(sys$gettim((unsigned long int *)vmstime));
103 vmstime[1] &= 0x7fff; /* prevent overflow in EDIV */
104 _ckvmssts(lib$ediv(&divisor,vmstime,(long int *)&retval,&remainder));
106 /* Fill in the struct tms using the CRTL routine . . .*/
107 times((tbuffer_t *)bufptr);
108 return (clock_t) retval;
110 # define times(t) vms_times(t)
112 #if defined (__CYGWIN__)
113 # define tzname _tzname
117 # define mkfifo(a,b) not_here("mkfifo")
118 # define ttyname(a) (char*)not_here("ttyname")
119 # define sigset_t long
122 # define tzname _tzname
125 # define mode_t short
128 # define mode_t short
130 # define tzset() not_here("tzset")
132 # ifndef _POSIX_OPEN_MAX
133 # define _POSIX_OPEN_MAX FOPEN_MAX /* XXX bogus ? */
136 # define sigaction(a,b,c) not_here("sigaction")
137 # define sigpending(a) not_here("sigpending")
138 # define sigprocmask(a,b,c) not_here("sigprocmask")
139 # define sigsuspend(a) not_here("sigsuspend")
140 # define sigemptyset(a) not_here("sigemptyset")
141 # define sigaddset(a,b) not_here("sigaddset")
142 # define sigdelset(a,b) not_here("sigdelset")
143 # define sigfillset(a) not_here("sigfillset")
144 # define sigismember(a,b) not_here("sigismember")
148 # if defined(OS2) || defined(MACOS_TRADITIONAL)
149 # define mkfifo(a,b) not_here("mkfifo")
150 # else /* !( defined OS2 ) */
152 # define mkfifo(path, mode) (mknod((path), (mode) | S_IFIFO, 0))
155 # endif /* !HAS_MKFIFO */
157 # ifdef MACOS_TRADITIONAL
158 struct tms { time_t tms_utime, tms_stime, tms_cutime, tms_cstime; };
159 # define times(a) not_here("times")
160 # define ttyname(a) (char*)not_here("ttyname")
161 # define tzset() not_here("tzset")
164 # include <sys/times.h>
166 # include <sys/utsname.h>
168 # include <sys/wait.h>
177 typedef long SysRetLong;
178 typedef sigset_t* POSIX__SigSet;
179 typedef HV* POSIX__SigAction;
181 typedef struct termios* POSIX__Termios;
182 #else /* Define termios types to int, and call not_here for the functions.*/
183 #define POSIX__Termios int
187 #define cfgetispeed(x) not_here("cfgetispeed")
188 #define cfgetospeed(x) not_here("cfgetospeed")
189 #define tcdrain(x) not_here("tcdrain")
190 #define tcflush(x,y) not_here("tcflush")
191 #define tcsendbreak(x,y) not_here("tcsendbreak")
192 #define cfsetispeed(x,y) not_here("cfsetispeed")
193 #define cfsetospeed(x,y) not_here("cfsetospeed")
194 #define ctermid(x) (char *) not_here("ctermid")
195 #define tcflow(x,y) not_here("tcflow")
196 #define tcgetattr(x,y) not_here("tcgetattr")
197 #define tcsetattr(x,y,z) not_here("tcsetattr")
200 /* Possibly needed prototypes */
201 char *cuserid (char *);
202 double strtod (const char *, char **);
203 long strtol (const char *, char **, int);
204 unsigned long strtoul (const char *, char **, int);
207 #define cuserid(a) (char *) not_here("cuserid")
211 #define difftime(a,b) not_here("difftime")
214 #ifndef HAS_FPATHCONF
215 #define fpathconf(f,n) (SysRetLong) not_here("fpathconf")
218 #define mktime(a) not_here("mktime")
221 #define nice(a) not_here("nice")
224 #define pathconf(f,n) (SysRetLong) not_here("pathconf")
227 #define sysconf(n) (SysRetLong) not_here("sysconf")
230 #define readlink(a,b,c) not_here("readlink")
233 #define setpgid(a,b) not_here("setpgid")
236 #define setsid() not_here("setsid")
239 #define strcoll(s1,s2) not_here("strcoll")
242 #define strtod(s1,s2) not_here("strtod")
245 #define strtol(s1,s2,b) not_here("strtol")
248 #define strtoul(s1,s2,b) not_here("strtoul")
251 #define strxfrm(s1,s2,n) not_here("strxfrm")
253 #ifndef HAS_TCGETPGRP
254 #define tcgetpgrp(a) not_here("tcgetpgrp")
256 #ifndef HAS_TCSETPGRP
257 #define tcsetpgrp(a,b) not_here("tcsetpgrp")
260 #define times(a) not_here("times")
263 #define uname(a) not_here("uname")
266 #define waitpid(a,b,c) not_here("waitpid")
271 #define mblen(a,b) not_here("mblen")
275 #define mbstowcs(s, pwcs, n) not_here("mbstowcs")
278 #define mbtowc(pwc, s, n) not_here("mbtowc")
281 #define wcstombs(s, pwcs, n) not_here("wcstombs")
284 #define wctomb(s, wchar) not_here("wcstombs")
286 #if !defined(HAS_MBLEN) && !defined(HAS_MBSTOWCS) && !defined(HAS_MBTOWC) && !defined(HAS_WCSTOMBS) && !defined(HAS_WCTOMB)
287 /* If we don't have these functions, then we wouldn't have gotten a typedef
288 for wchar_t, the wide character type. Defining wchar_t allows the
289 functions referencing it to compile. Its actual type is then meaningless,
290 since without the above functions, all sections using it end up calling
291 not_here() and croak. --Kaveh Ghazi (ghazi@noc.rutgers.edu) 9/18/94. */
297 #ifndef HAS_LOCALECONV
298 #define localeconv() not_here("localeconv")
302 # if !defined(WIN32) && !defined(__CYGWIN__)
303 extern char *tzname[];
306 #if !defined(WIN32) || (defined(__MINGW32__) && !defined(tzname))
307 char *tzname[] = { "" , "" };
311 /* XXX struct tm on some systems (SunOS4/BSD) contains extra (non POSIX)
312 * fields for which we don't have Configure support yet:
313 * char *tm_zone; -- abbreviation of timezone name
314 * long tm_gmtoff; -- offset from GMT in seconds
315 * To workaround core dumps from the uninitialised tm_zone we get the
316 * system to give us a reasonable struct to copy. This fix means that
317 * strftime uses the tm_zone and tm_gmtoff values returned by
318 * localtime(time()). That should give the desired result most of the
319 * time. But probably not always!
321 * This is a temporary workaround to be removed once Configure
322 * support is added and NETaa14816 is considered in full.
323 * It does not address tzname aspects of NETaa14816.
326 # ifndef STRUCT_TM_HASZONE
327 # define STRUCT_TM_HASZONE
331 #ifdef STRUCT_TM_HASZONE
333 init_tm(struct tm *ptm) /* see mktime, strftime and asctime */
337 Copy(localtime(&now), ptm, 1, struct tm);
341 # define init_tm(ptm)
345 * mini_mktime - normalise struct tm values without the localtime()
346 * semantics (and overhead) of mktime().
349 mini_mktime(struct tm *ptm)
353 int month, mday, year, jday;
354 int odd_cent, odd_year;
356 #define DAYS_PER_YEAR 365
357 #define DAYS_PER_QYEAR (4*DAYS_PER_YEAR+1)
358 #define DAYS_PER_CENT (25*DAYS_PER_QYEAR-1)
359 #define DAYS_PER_QCENT (4*DAYS_PER_CENT+1)
360 #define SECS_PER_HOUR (60*60)
361 #define SECS_PER_DAY (24*SECS_PER_HOUR)
362 /* parentheses deliberately absent on these two, otherwise they don't work */
363 #define MONTH_TO_DAYS 153/5
364 #define DAYS_TO_MONTH 5/153
365 /* offset to bias by March (month 4) 1st between month/mday & year finding */
366 #define YEAR_ADJUST (4*MONTH_TO_DAYS+1)
367 /* as used here, the algorithm leaves Sunday as day 1 unless we adjust it */
368 #define WEEKDAY_BIAS 6 /* (1+6)%7 makes Sunday 0 again */
371 * Year/day algorithm notes:
373 * With a suitable offset for numeric value of the month, one can find
374 * an offset into the year by considering months to have 30.6 (153/5) days,
375 * using integer arithmetic (i.e., with truncation). To avoid too much
376 * messing about with leap days, we consider January and February to be
377 * the 13th and 14th month of the previous year. After that transformation,
378 * we need the month index we use to be high by 1 from 'normal human' usage,
379 * so the month index values we use run from 4 through 15.
381 * Given that, and the rules for the Gregorian calendar (leap years are those
382 * divisible by 4 unless also divisible by 100, when they must be divisible
383 * by 400 instead), we can simply calculate the number of days since some
384 * arbitrary 'beginning of time' by futzing with the (adjusted) year number,
385 * the days we derive from our month index, and adding in the day of the
386 * month. The value used here is not adjusted for the actual origin which
387 * it normally would use (1 January A.D. 1), since we're not exposing it.
388 * We're only building the value so we can turn around and get the
389 * normalised values for the year, month, day-of-month, and day-of-year.
391 * For going backward, we need to bias the value we're using so that we find
392 * the right year value. (Basically, we don't want the contribution of
393 * March 1st to the number to apply while deriving the year). Having done
394 * that, we 'count up' the contribution to the year number by accounting for
395 * full quadracenturies (400-year periods) with their extra leap days, plus
396 * the contribution from full centuries (to avoid counting in the lost leap
397 * days), plus the contribution from full quad-years (to count in the normal
398 * leap days), plus the leftover contribution from any non-leap years.
399 * At this point, if we were working with an actual leap day, we'll have 0
400 * days left over. This is also true for March 1st, however. So, we have
401 * to special-case that result, and (earlier) keep track of the 'odd'
402 * century and year contributions. If we got 4 extra centuries in a qcent,
403 * or 4 extra years in a qyear, then it's a leap day and we call it 29 Feb.
404 * Otherwise, we add back in the earlier bias we removed (the 123 from
405 * figuring in March 1st), find the month index (integer division by 30.6),
406 * and the remainder is the day-of-month. We then have to convert back to
407 * 'real' months (including fixing January and February from being 14/15 in
408 * the previous year to being in the proper year). After that, to get
409 * tm_yday, we work with the normalised year and get a new yearday value for
410 * January 1st, which we subtract from the yearday value we had earlier,
411 * representing the date we've re-built. This is done from January 1
412 * because tm_yday is 0-origin.
414 * Since POSIX time routines are only guaranteed to work for times since the
415 * UNIX epoch (00:00:00 1 Jan 1970 UTC), the fact that this algorithm
416 * applies Gregorian calendar rules even to dates before the 16th century
417 * doesn't bother me. Besides, you'd need cultural context for a given
418 * date to know whether it was Julian or Gregorian calendar, and that's
419 * outside the scope for this routine. Since we convert back based on the
420 * same rules we used to build the yearday, you'll only get strange results
421 * for input which needed normalising, or for the 'odd' century years which
422 * were leap years in the Julian calander but not in the Gregorian one.
423 * I can live with that.
425 * This algorithm also fails to handle years before A.D. 1 gracefully, but
426 * that's still outside the scope for POSIX time manipulation, so I don't
430 year = 1900 + ptm->tm_year;
433 /* allow given yday with no month & mday to dominate the result */
434 if (ptm->tm_yday >= 0 && mday <= 0 && month <= 0) {
437 jday = 1 + ptm->tm_yday;
446 yearday = DAYS_PER_YEAR * year + year/4 - year/100 + year/400;
447 yearday += month*MONTH_TO_DAYS + mday + jday;
449 * Note that we don't know when leap-seconds were or will be,
450 * so we have to trust the user if we get something which looks
451 * like a sensible leap-second. Wild values for seconds will
452 * be rationalised, however.
454 if ((unsigned) ptm->tm_sec <= 60) {
461 secs += 60 * ptm->tm_min;
462 secs += SECS_PER_HOUR * ptm->tm_hour;
464 if (secs-(secs/SECS_PER_DAY*SECS_PER_DAY) < 0) {
465 /* got negative remainder, but need positive time */
466 /* back off an extra day to compensate */
467 yearday += (secs/SECS_PER_DAY)-1;
468 secs -= SECS_PER_DAY * (secs/SECS_PER_DAY - 1);
471 yearday += (secs/SECS_PER_DAY);
472 secs -= SECS_PER_DAY * (secs/SECS_PER_DAY);
475 else if (secs >= SECS_PER_DAY) {
476 yearday += (secs/SECS_PER_DAY);
477 secs %= SECS_PER_DAY;
479 ptm->tm_hour = secs/SECS_PER_HOUR;
480 secs %= SECS_PER_HOUR;
481 ptm->tm_min = secs/60;
484 /* done with time of day effects */
486 * The algorithm for yearday has (so far) left it high by 428.
487 * To avoid mistaking a legitimate Feb 29 as Mar 1, we need to
488 * bias it by 123 while trying to figure out what year it
489 * really represents. Even with this tweak, the reverse
490 * translation fails for years before A.D. 0001.
491 * It would still fail for Feb 29, but we catch that one below.
493 jday = yearday; /* save for later fixup vis-a-vis Jan 1 */
494 yearday -= YEAR_ADJUST;
495 year = (yearday / DAYS_PER_QCENT) * 400;
496 yearday %= DAYS_PER_QCENT;
497 odd_cent = yearday / DAYS_PER_CENT;
498 year += odd_cent * 100;
499 yearday %= DAYS_PER_CENT;
500 year += (yearday / DAYS_PER_QYEAR) * 4;
501 yearday %= DAYS_PER_QYEAR;
502 odd_year = yearday / DAYS_PER_YEAR;
504 yearday %= DAYS_PER_YEAR;
505 if (!yearday && (odd_cent==4 || odd_year==4)) { /* catch Feb 29 */
510 yearday += YEAR_ADJUST; /* recover March 1st crock */
511 month = yearday*DAYS_TO_MONTH;
512 yearday -= month*MONTH_TO_DAYS;
513 /* recover other leap-year adjustment */
522 ptm->tm_year = year - 1900;
524 ptm->tm_mday = yearday;
529 ptm->tm_mon = month - 1;
531 /* re-build yearday based on Jan 1 to get tm_yday */
533 yearday = year*DAYS_PER_YEAR + year/4 - year/100 + year/400;
534 yearday += 14*MONTH_TO_DAYS + 1;
535 ptm->tm_yday = jday - yearday;
536 /* fix tm_wday if not overridden by caller */
537 if ((unsigned)ptm->tm_wday > 6)
538 ptm->tm_wday = (jday + WEEKDAY_BIAS) % 7;
541 #ifdef HAS_LONG_DOUBLE
542 # if LONG_DOUBLESIZE > DOUBLESIZE
543 # undef HAS_LONG_DOUBLE /* XXX until we figure out how to use them */
547 #ifndef HAS_LONG_DOUBLE
562 croak("POSIX::%s not implemented on this architecture", s);
567 #if defined(HAS_LONG_DOUBLE) && (LONG_DOUBLESIZE > DOUBLESIZE)
572 constant(char *name, int arg)
577 if (strEQ(name, "ARG_MAX"))
585 if (strEQ(name, "BUFSIZ"))
591 if (strEQ(name, "BRKINT"))
597 if (strEQ(name, "B9600"))
603 if (strEQ(name, "B19200"))
609 if (strEQ(name, "B38400"))
615 if (strEQ(name, "B0"))
621 if (strEQ(name, "B110"))
627 if (strEQ(name, "B1200"))
633 if (strEQ(name, "B134"))
639 if (strEQ(name, "B150"))
645 if (strEQ(name, "B1800"))
651 if (strEQ(name, "B200"))
657 if (strEQ(name, "B2400"))
663 if (strEQ(name, "B300"))
669 if (strEQ(name, "B4800"))
675 if (strEQ(name, "B50"))
681 if (strEQ(name, "B600"))
687 if (strEQ(name, "B75"))
695 if (strEQ(name, "CHAR_BIT"))
701 if (strEQ(name, "CHAR_MAX"))
707 if (strEQ(name, "CHAR_MIN"))
713 if (strEQ(name, "CHILD_MAX"))
719 if (strEQ(name, "CLK_TCK"))
725 if (strEQ(name, "CLOCAL"))
731 if (strEQ(name, "CLOCKS_PER_SEC"))
732 #ifdef CLOCKS_PER_SEC
733 return CLOCKS_PER_SEC;
737 if (strEQ(name, "CREAD"))
743 if (strEQ(name, "CS5"))
749 if (strEQ(name, "CS6"))
755 if (strEQ(name, "CS7"))
761 if (strEQ(name, "CS8"))
767 if (strEQ(name, "CSIZE"))
773 if (strEQ(name, "CSTOPB"))
781 if (strEQ(name, "DBL_MAX"))
787 if (strEQ(name, "DBL_MIN"))
793 if (strEQ(name, "DBL_DIG"))
799 if (strEQ(name, "DBL_EPSILON"))
805 if (strEQ(name, "DBL_MANT_DIG"))
811 if (strEQ(name, "DBL_MAX_10_EXP"))
812 #ifdef DBL_MAX_10_EXP
813 return DBL_MAX_10_EXP;
817 if (strEQ(name, "DBL_MAX_EXP"))
823 if (strEQ(name, "DBL_MIN_10_EXP"))
824 #ifdef DBL_MIN_10_EXP
825 return DBL_MIN_10_EXP;
829 if (strEQ(name, "DBL_MIN_EXP"))
839 if (strEQ(name, "EACCES"))
845 if (strEQ(name, "EADDRINUSE"))
851 if (strEQ(name, "EADDRNOTAVAIL"))
853 return EADDRNOTAVAIL;
857 if (strEQ(name, "EAFNOSUPPORT"))
863 if (strEQ(name, "EAGAIN"))
869 if (strEQ(name, "EALREADY"))
877 if (strEQ(name, "EBADF"))
883 if (strEQ(name, "EBUSY"))
891 if (strEQ(name, "ECHILD"))
897 if (strEQ(name, "ECHO"))
903 if (strEQ(name, "ECHOE"))
909 if (strEQ(name, "ECHOK"))
915 if (strEQ(name, "ECHONL"))
921 if (strEQ(name, "ECONNABORTED"))
927 if (strEQ(name, "ECONNREFUSED"))
933 if (strEQ(name, "ECONNRESET"))
941 if (strEQ(name, "EDEADLK"))
947 if (strEQ(name, "EDESTADDRREQ"))
953 if (strEQ(name, "EDOM"))
959 if (strEQ(name, "EDQUOT"))
967 if (strEQ(name, "EEXIST"))
975 if (strEQ(name, "EFAULT"))
981 if (strEQ(name, "EFBIG"))
989 if (strEQ(name, "EHOSTDOWN"))
995 if (strEQ(name, "EHOSTUNREACH"))
1003 if (strEQ(name, "EINPROGRESS"))
1009 if (strEQ(name, "EINTR"))
1015 if (strEQ(name, "EINVAL"))
1021 if (strEQ(name, "EIO"))
1027 if (strEQ(name, "EISCONN"))
1033 if (strEQ(name, "EISDIR"))
1041 if (strEQ(name, "ELOOP"))
1049 if (strEQ(name, "EMFILE"))
1055 if (strEQ(name, "EMLINK"))
1061 if (strEQ(name, "EMSGSIZE"))
1069 if (strEQ(name, "ENETDOWN"))
1075 if (strEQ(name, "ENETRESET"))
1081 if (strEQ(name, "ENETUNREACH"))
1087 if (strEQ(name, "ENOBUFS"))
1093 if (strEQ(name, "ENOEXEC"))
1099 if (strEQ(name, "ENOMEM"))
1105 if (strEQ(name, "ENOPROTOOPT"))
1111 if (strEQ(name, "ENOSPC"))
1117 if (strEQ(name, "ENOTBLK"))
1123 if (strEQ(name, "ENOTCONN"))
1129 if (strEQ(name, "ENOTDIR"))
1135 if (strEQ(name, "ENOTEMPTY"))
1141 if (strEQ(name, "ENOTSOCK"))
1147 if (strEQ(name, "ENOTTY"))
1153 if (strEQ(name, "ENFILE"))
1159 if (strEQ(name, "ENODEV"))
1165 if (strEQ(name, "ENOENT"))
1171 if (strEQ(name, "ENOLCK"))
1177 if (strEQ(name, "ENOSYS"))
1183 if (strEQ(name, "ENXIO"))
1189 if (strEQ(name, "ENAMETOOLONG"))
1191 return ENAMETOOLONG;
1197 if (strEQ(name, "EOF"))
1203 if (strEQ(name, "EOPNOTSUPP"))
1211 if (strEQ(name, "EPERM"))
1217 if (strEQ(name, "EPFNOSUPPORT"))
1219 return EPFNOSUPPORT;
1223 if (strEQ(name, "EPIPE"))
1229 if (strEQ(name, "EPROCLIM"))
1235 if (strEQ(name, "EPROTONOSUPPORT"))
1236 #ifdef EPROTONOSUPPORT
1237 return EPROTONOSUPPORT;
1241 if (strEQ(name, "EPROTOTYPE"))
1249 if (strEQ(name, "ERANGE"))
1255 if (strEQ(name, "EREMOTE"))
1261 if (strEQ(name, "ERESTART"))
1267 if (strEQ(name, "EROFS"))
1275 if (strEQ(name, "ESHUTDOWN"))
1281 if (strEQ(name, "ESOCKTNOSUPPORT"))
1282 #ifdef ESOCKTNOSUPPORT
1283 return ESOCKTNOSUPPORT;
1287 if (strEQ(name, "ESPIPE"))
1293 if (strEQ(name, "ESRCH"))
1299 if (strEQ(name, "ESTALE"))
1307 if (strEQ(name, "ETIMEDOUT"))
1313 if (strEQ(name, "ETOOMANYREFS"))
1315 return ETOOMANYREFS;
1319 if (strEQ(name, "ETXTBSY"))
1327 if (strEQ(name, "EUSERS"))
1335 if (strEQ(name, "EWOULDBLOCK"))
1343 if (strEQ(name, "EXIT_FAILURE"))
1345 return EXIT_FAILURE;
1349 if (strEQ(name, "EXIT_SUCCESS"))
1351 return EXIT_SUCCESS;
1355 if (strEQ(name, "EXDEV"))
1363 if (strEQ(name, "E2BIG"))
1371 if (strnEQ(name, "FLT_", 4)) {
1372 if (strEQ(name, "FLT_MAX"))
1378 if (strEQ(name, "FLT_MIN"))
1384 if (strEQ(name, "FLT_ROUNDS"))
1390 if (strEQ(name, "FLT_DIG"))
1396 if (strEQ(name, "FLT_EPSILON"))
1402 if (strEQ(name, "FLT_MANT_DIG"))
1404 return FLT_MANT_DIG;
1408 if (strEQ(name, "FLT_MAX_10_EXP"))
1409 #ifdef FLT_MAX_10_EXP
1410 return FLT_MAX_10_EXP;
1414 if (strEQ(name, "FLT_MAX_EXP"))
1420 if (strEQ(name, "FLT_MIN_10_EXP"))
1421 #ifdef FLT_MIN_10_EXP
1422 return FLT_MIN_10_EXP;
1426 if (strEQ(name, "FLT_MIN_EXP"))
1432 if (strEQ(name, "FLT_RADIX"))
1440 if (strnEQ(name, "F_", 2)) {
1441 if (strEQ(name, "F_DUPFD"))
1447 if (strEQ(name, "F_GETFD"))
1453 if (strEQ(name, "F_GETFL"))
1459 if (strEQ(name, "F_GETLK"))
1465 if (strEQ(name, "F_OK"))
1471 if (strEQ(name, "F_RDLCK"))
1477 if (strEQ(name, "F_SETFD"))
1483 if (strEQ(name, "F_SETFL"))
1489 if (strEQ(name, "F_SETLK"))
1495 if (strEQ(name, "F_SETLKW"))
1501 if (strEQ(name, "F_UNLCK"))
1507 if (strEQ(name, "F_WRLCK"))
1515 if (strEQ(name, "FD_CLOEXEC"))
1521 if (strEQ(name, "FILENAME_MAX"))
1523 return FILENAME_MAX;
1529 if (strEQ(name, "HUGE_VAL"))
1530 #if defined(USE_LONG_DOUBLE) && defined(HUGE_VALL)
1531 /* HUGE_VALL is admittedly non-POSIX but if are using long doubles
1532 * we might as well use long doubles. --jhi */
1540 if (strEQ(name, "HUPCL"))
1548 if (strEQ(name, "INT_MAX"))
1554 if (strEQ(name, "INT_MIN"))
1560 if (strEQ(name, "ICANON"))
1566 if (strEQ(name, "ICRNL"))
1572 if (strEQ(name, "IEXTEN"))
1578 if (strEQ(name, "IGNBRK"))
1584 if (strEQ(name, "IGNCR"))
1590 if (strEQ(name, "IGNPAR"))
1596 if (strEQ(name, "INLCR"))
1602 if (strEQ(name, "INPCK"))
1608 if (strEQ(name, "ISIG"))
1614 if (strEQ(name, "ISTRIP"))
1620 if (strEQ(name, "IXOFF"))
1626 if (strEQ(name, "IXON"))
1634 if (strnEQ(name, "LC_", 3)) {
1635 if (strEQ(name, "LC_ALL"))
1641 if (strEQ(name, "LC_COLLATE"))
1647 if (strEQ(name, "LC_CTYPE"))
1653 if (strEQ(name, "LC_MONETARY"))
1659 if (strEQ(name, "LC_NUMERIC"))
1665 if (strEQ(name, "LC_TIME"))
1673 if (strnEQ(name, "LDBL_", 5)) {
1674 if (strEQ(name, "LDBL_MAX"))
1680 if (strEQ(name, "LDBL_MIN"))
1686 if (strEQ(name, "LDBL_DIG"))
1692 if (strEQ(name, "LDBL_EPSILON"))
1694 return LDBL_EPSILON;
1698 if (strEQ(name, "LDBL_MANT_DIG"))
1699 #ifdef LDBL_MANT_DIG
1700 return LDBL_MANT_DIG;
1704 if (strEQ(name, "LDBL_MAX_10_EXP"))
1705 #ifdef LDBL_MAX_10_EXP
1706 return LDBL_MAX_10_EXP;
1710 if (strEQ(name, "LDBL_MAX_EXP"))
1712 return LDBL_MAX_EXP;
1716 if (strEQ(name, "LDBL_MIN_10_EXP"))
1717 #ifdef LDBL_MIN_10_EXP
1718 return LDBL_MIN_10_EXP;
1722 if (strEQ(name, "LDBL_MIN_EXP"))
1724 return LDBL_MIN_EXP;
1730 if (strnEQ(name, "L_", 2)) {
1731 if (strEQ(name, "L_ctermid"))
1737 if (strEQ(name, "L_cuserid"))
1743 /* L_tmpnam[e] was a typo--retained for compatibility */
1744 if (strEQ(name, "L_tmpname") || strEQ(name, "L_tmpnam"))
1752 if (strEQ(name, "LONG_MAX"))
1758 if (strEQ(name, "LONG_MIN"))
1764 if (strEQ(name, "LINK_MAX"))
1772 if (strEQ(name, "MAX_CANON"))
1778 if (strEQ(name, "MAX_INPUT"))
1784 if (strEQ(name, "MB_CUR_MAX"))
1790 if (strEQ(name, "MB_LEN_MAX"))
1798 if (strEQ(name, "NULL")) return 0;
1799 if (strEQ(name, "NAME_MAX"))
1805 if (strEQ(name, "NCCS"))
1811 if (strEQ(name, "NGROUPS_MAX"))
1817 if (strEQ(name, "NOFLSH"))
1825 if (strnEQ(name, "O_", 2)) {
1826 if (strEQ(name, "O_APPEND"))
1832 if (strEQ(name, "O_CREAT"))
1838 if (strEQ(name, "O_TRUNC"))
1844 if (strEQ(name, "O_RDONLY"))
1850 if (strEQ(name, "O_RDWR"))
1856 if (strEQ(name, "O_WRONLY"))
1862 if (strEQ(name, "O_EXCL"))
1868 if (strEQ(name, "O_NOCTTY"))
1874 if (strEQ(name, "O_NONBLOCK"))
1880 if (strEQ(name, "O_ACCMODE"))
1888 if (strEQ(name, "OPEN_MAX"))
1894 if (strEQ(name, "OPOST"))
1902 if (strEQ(name, "PATH_MAX"))
1908 if (strEQ(name, "PARENB"))
1914 if (strEQ(name, "PARMRK"))
1920 if (strEQ(name, "PARODD"))
1926 if (strEQ(name, "PIPE_BUF"))
1934 if (strEQ(name, "RAND_MAX"))
1940 if (strEQ(name, "R_OK"))
1948 if (strnEQ(name, "SIG", 3)) {
1949 if (name[3] == '_') {
1950 if (strEQ(name, "SIG_BLOCK"))
1957 if (strEQ(name, "SIG_DFL")) return (IV)SIG_DFL;
1960 if (strEQ(name, "SIG_ERR")) return (IV)SIG_ERR;
1963 if (strEQ(name, "SIG_IGN")) return (IV)SIG_IGN;
1965 if (strEQ(name, "SIG_SETMASK"))
1971 if (strEQ(name, "SIG_UNBLOCK"))
1979 if (strEQ(name, "SIGABRT"))
1985 if (strEQ(name, "SIGALRM"))
1991 if (strEQ(name, "SIGCHLD"))
1997 if (strEQ(name, "SIGCONT"))
2003 if (strEQ(name, "SIGFPE"))
2009 if (strEQ(name, "SIGHUP"))
2015 if (strEQ(name, "SIGILL"))
2021 if (strEQ(name, "SIGINT"))
2027 if (strEQ(name, "SIGKILL"))
2033 if (strEQ(name, "SIGPIPE"))
2039 if (strEQ(name, "SIGQUIT"))
2045 if (strEQ(name, "SIGSEGV"))
2051 if (strEQ(name, "SIGSTOP"))
2057 if (strEQ(name, "SIGTERM"))
2063 if (strEQ(name, "SIGTSTP"))
2069 if (strEQ(name, "SIGTTIN"))
2075 if (strEQ(name, "SIGTTOU"))
2081 if (strEQ(name, "SIGUSR1"))
2087 if (strEQ(name, "SIGUSR2"))
2095 if (name[1] == '_') {
2096 if (strEQ(name, "S_ISGID"))
2102 if (strEQ(name, "S_ISUID"))
2108 if (strEQ(name, "S_IRGRP"))
2114 if (strEQ(name, "S_IROTH"))
2120 if (strEQ(name, "S_IRUSR"))
2126 if (strEQ(name, "S_IRWXG"))
2132 if (strEQ(name, "S_IRWXO"))
2138 if (strEQ(name, "S_IRWXU"))
2144 if (strEQ(name, "S_IWGRP"))
2150 if (strEQ(name, "S_IWOTH"))
2156 if (strEQ(name, "S_IWUSR"))
2162 if (strEQ(name, "S_IXGRP"))
2168 if (strEQ(name, "S_IXOTH"))
2174 if (strEQ(name, "S_IXUSR"))
2180 errno = EAGAIN; /* the following aren't constants */
2182 if (strEQ(name, "S_ISBLK")) return S_ISBLK(arg);
2185 if (strEQ(name, "S_ISCHR")) return S_ISCHR(arg);
2188 if (strEQ(name, "S_ISDIR")) return S_ISDIR(arg);
2191 if (strEQ(name, "S_ISFIFO")) return S_ISFIFO(arg);
2194 if (strEQ(name, "S_ISREG")) return S_ISREG(arg);
2198 if (strEQ(name, "SEEK_CUR"))
2204 if (strEQ(name, "SEEK_END"))
2210 if (strEQ(name, "SEEK_SET"))
2216 if (strEQ(name, "STREAM_MAX"))
2222 if (strEQ(name, "SHRT_MAX"))
2228 if (strEQ(name, "SHRT_MIN"))
2234 if (strnEQ(name, "SA_", 3)) {
2235 if (strEQ(name, "SA_NOCLDSTOP"))
2237 return SA_NOCLDSTOP;
2241 if (strEQ(name, "SA_NOCLDWAIT"))
2243 return SA_NOCLDWAIT;
2247 if (strEQ(name, "SA_NODEFER"))
2253 if (strEQ(name, "SA_ONSTACK"))
2259 if (strEQ(name, "SA_RESETHAND"))
2261 return SA_RESETHAND;
2265 if (strEQ(name, "SA_RESTART"))
2271 if (strEQ(name, "SA_SIGINFO"))
2279 if (strEQ(name, "SCHAR_MAX"))
2285 if (strEQ(name, "SCHAR_MIN"))
2291 if (strEQ(name, "SSIZE_MAX"))
2297 if (strEQ(name, "STDIN_FILENO"))
2299 return STDIN_FILENO;
2303 if (strEQ(name, "STDOUT_FILENO"))
2304 #ifdef STDOUT_FILENO
2305 return STDOUT_FILENO;
2309 if (strEQ(name, "STDERR_FILENO"))
2310 #ifdef STDERR_FILENO
2311 return STDERR_FILENO;
2317 if (strEQ(name, "TCIFLUSH"))
2323 if (strEQ(name, "TCIOFF"))
2329 if (strEQ(name, "TCIOFLUSH"))
2335 if (strEQ(name, "TCION"))
2341 if (strEQ(name, "TCOFLUSH"))
2347 if (strEQ(name, "TCOOFF"))
2353 if (strEQ(name, "TCOON"))
2359 if (strEQ(name, "TCSADRAIN"))
2365 if (strEQ(name, "TCSAFLUSH"))
2371 if (strEQ(name, "TCSANOW"))
2377 if (strEQ(name, "TMP_MAX"))
2383 if (strEQ(name, "TOSTOP"))
2389 if (strEQ(name, "TZNAME_MAX"))
2397 if (strEQ(name, "UCHAR_MAX"))
2403 if (strEQ(name, "UINT_MAX"))
2409 if (strEQ(name, "ULONG_MAX"))
2415 if (strEQ(name, "USHRT_MAX"))
2423 if (strEQ(name, "VEOF"))
2429 if (strEQ(name, "VEOL"))
2435 if (strEQ(name, "VERASE"))
2441 if (strEQ(name, "VINTR"))
2447 if (strEQ(name, "VKILL"))
2453 if (strEQ(name, "VMIN"))
2459 if (strEQ(name, "VQUIT"))
2465 if (strEQ(name, "VSTART"))
2471 if (strEQ(name, "VSTOP"))
2477 if (strEQ(name, "VSUSP"))
2483 if (strEQ(name, "VTIME"))
2491 if (strEQ(name, "W_OK"))
2497 if (strEQ(name, "WNOHANG"))
2503 if (strEQ(name, "WUNTRACED"))
2509 errno = EAGAIN; /* the following aren't constants */
2511 if (strEQ(name, "WEXITSTATUS")) return WEXITSTATUS(arg);
2514 if (strEQ(name, "WIFEXITED")) return WIFEXITED(arg);
2517 if (strEQ(name, "WIFSIGNALED")) return WIFSIGNALED(arg);
2520 if (strEQ(name, "WIFSTOPPED")) return WIFSTOPPED(arg);
2523 if (strEQ(name, "WSTOPSIG")) return WSTOPSIG(arg);
2526 if (strEQ(name, "WTERMSIG")) return WTERMSIG(arg);
2530 if (strEQ(name, "X_OK"))
2538 if (strnEQ(name, "_PC_", 4)) {
2539 if (strEQ(name, "_PC_CHOWN_RESTRICTED"))
2540 #if defined(_PC_CHOWN_RESTRICTED) || HINT_SC_EXIST
2541 return _PC_CHOWN_RESTRICTED;
2545 if (strEQ(name, "_PC_LINK_MAX"))
2546 #if defined(_PC_LINK_MAX) || HINT_SC_EXIST
2547 return _PC_LINK_MAX;
2551 if (strEQ(name, "_PC_MAX_CANON"))
2552 #if defined(_PC_MAX_CANON) || HINT_SC_EXIST
2553 return _PC_MAX_CANON;
2557 if (strEQ(name, "_PC_MAX_INPUT"))
2558 #if defined(_PC_MAX_INPUT) || HINT_SC_EXIST
2559 return _PC_MAX_INPUT;
2563 if (strEQ(name, "_PC_NAME_MAX"))
2564 #if defined(_PC_NAME_MAX) || HINT_SC_EXIST
2565 return _PC_NAME_MAX;
2569 if (strEQ(name, "_PC_NO_TRUNC"))
2570 #if defined(_PC_NO_TRUNC) || HINT_SC_EXIST
2571 return _PC_NO_TRUNC;
2575 if (strEQ(name, "_PC_PATH_MAX"))
2576 #if defined(_PC_PATH_MAX) || HINT_SC_EXIST
2577 return _PC_PATH_MAX;
2581 if (strEQ(name, "_PC_PIPE_BUF"))
2582 #if defined(_PC_PIPE_BUF) || HINT_SC_EXIST
2583 return _PC_PIPE_BUF;
2587 if (strEQ(name, "_PC_VDISABLE"))
2588 #if defined(_PC_VDISABLE) || HINT_SC_EXIST
2589 return _PC_VDISABLE;
2595 if (strnEQ(name, "_POSIX_", 7)) {
2596 if (strEQ(name, "_POSIX_ARG_MAX"))
2597 #ifdef _POSIX_ARG_MAX
2598 return _POSIX_ARG_MAX;
2602 if (strEQ(name, "_POSIX_CHILD_MAX"))
2603 #ifdef _POSIX_CHILD_MAX
2604 return _POSIX_CHILD_MAX;
2608 if (strEQ(name, "_POSIX_CHOWN_RESTRICTED"))
2609 #ifdef _POSIX_CHOWN_RESTRICTED
2610 return _POSIX_CHOWN_RESTRICTED;
2614 if (strEQ(name, "_POSIX_JOB_CONTROL"))
2615 #ifdef _POSIX_JOB_CONTROL
2616 return _POSIX_JOB_CONTROL;
2620 if (strEQ(name, "_POSIX_LINK_MAX"))
2621 #ifdef _POSIX_LINK_MAX
2622 return _POSIX_LINK_MAX;
2626 if (strEQ(name, "_POSIX_MAX_CANON"))
2627 #ifdef _POSIX_MAX_CANON
2628 return _POSIX_MAX_CANON;
2632 if (strEQ(name, "_POSIX_MAX_INPUT"))
2633 #ifdef _POSIX_MAX_INPUT
2634 return _POSIX_MAX_INPUT;
2638 if (strEQ(name, "_POSIX_NAME_MAX"))
2639 #ifdef _POSIX_NAME_MAX
2640 return _POSIX_NAME_MAX;
2644 if (strEQ(name, "_POSIX_NGROUPS_MAX"))
2645 #ifdef _POSIX_NGROUPS_MAX
2646 return _POSIX_NGROUPS_MAX;
2650 if (strEQ(name, "_POSIX_NO_TRUNC"))
2651 #ifdef _POSIX_NO_TRUNC
2652 return _POSIX_NO_TRUNC;
2656 if (strEQ(name, "_POSIX_OPEN_MAX"))
2657 #ifdef _POSIX_OPEN_MAX
2658 return _POSIX_OPEN_MAX;
2662 if (strEQ(name, "_POSIX_PATH_MAX"))
2663 #ifdef _POSIX_PATH_MAX
2664 return _POSIX_PATH_MAX;
2668 if (strEQ(name, "_POSIX_PIPE_BUF"))
2669 #ifdef _POSIX_PIPE_BUF
2670 return _POSIX_PIPE_BUF;
2674 if (strEQ(name, "_POSIX_SAVED_IDS"))
2675 #ifdef _POSIX_SAVED_IDS
2676 return _POSIX_SAVED_IDS;
2680 if (strEQ(name, "_POSIX_SSIZE_MAX"))
2681 #ifdef _POSIX_SSIZE_MAX
2682 return _POSIX_SSIZE_MAX;
2686 if (strEQ(name, "_POSIX_STREAM_MAX"))
2687 #ifdef _POSIX_STREAM_MAX
2688 return _POSIX_STREAM_MAX;
2692 if (strEQ(name, "_POSIX_TZNAME_MAX"))
2693 #ifdef _POSIX_TZNAME_MAX
2694 return _POSIX_TZNAME_MAX;
2698 if (strEQ(name, "_POSIX_VDISABLE"))
2699 #ifdef _POSIX_VDISABLE
2700 return _POSIX_VDISABLE;
2704 if (strEQ(name, "_POSIX_VERSION"))
2705 #ifdef _POSIX_VERSION
2706 return _POSIX_VERSION;
2712 if (strnEQ(name, "_SC_", 4)) {
2713 if (strEQ(name, "_SC_ARG_MAX"))
2714 #if defined(_SC_ARG_MAX) || HINT_SC_EXIST
2719 if (strEQ(name, "_SC_CHILD_MAX"))
2720 #if defined(_SC_CHILD_MAX) || HINT_SC_EXIST
2721 return _SC_CHILD_MAX;
2725 if (strEQ(name, "_SC_CLK_TCK"))
2726 #if defined(_SC_CLK_TCK) || HINT_SC_EXIST
2731 if (strEQ(name, "_SC_JOB_CONTROL"))
2732 #if defined(_SC_JOB_CONTROL) || HINT_SC_EXIST
2733 return _SC_JOB_CONTROL;
2737 if (strEQ(name, "_SC_NGROUPS_MAX"))
2738 #if defined(_SC_NGROUPS_MAX) || HINT_SC_EXIST
2739 return _SC_NGROUPS_MAX;
2743 if (strEQ(name, "_SC_OPEN_MAX"))
2744 #if defined(_SC_OPEN_MAX) || HINT_SC_EXIST
2745 return _SC_OPEN_MAX;
2749 if (strEQ(name, "_SC_SAVED_IDS"))
2750 #if defined(_SC_SAVED_IDS) || HINT_SC_EXIST
2751 return _SC_SAVED_IDS;
2755 if (strEQ(name, "_SC_STREAM_MAX"))
2756 #if defined(_SC_STREAM_MAX) || HINT_SC_EXIST
2757 return _SC_STREAM_MAX;
2761 if (strEQ(name, "_SC_TZNAME_MAX"))
2762 #if defined(_SC_TZNAME_MAX) || HINT_SC_EXIST
2763 return _SC_TZNAME_MAX;
2767 if (strEQ(name, "_SC_VERSION"))
2768 #if defined(_SC_VERSION) || HINT_SC_EXIST
2784 MODULE = SigSet PACKAGE = POSIX::SigSet PREFIX = sig
2787 new(packname = "POSIX::SigSet", ...)
2792 New(0, RETVAL, 1, sigset_t);
2793 sigemptyset(RETVAL);
2794 for (i = 1; i < items; i++)
2795 sigaddset(RETVAL, SvIV(ST(i)));
2802 POSIX::SigSet sigset
2807 sigaddset(sigset, sig)
2808 POSIX::SigSet sigset
2812 sigdelset(sigset, sig)
2813 POSIX::SigSet sigset
2818 POSIX::SigSet sigset
2822 POSIX::SigSet sigset
2825 sigismember(sigset, sig)
2826 POSIX::SigSet sigset
2830 MODULE = Termios PACKAGE = POSIX::Termios PREFIX = cf
2833 new(packname = "POSIX::Termios", ...)
2838 New(0, RETVAL, 1, struct termios);
2840 not_here("termios");
2848 DESTROY(termios_ref)
2849 POSIX::Termios termios_ref
2852 Safefree(termios_ref);
2854 not_here("termios");
2858 getattr(termios_ref, fd = 0)
2859 POSIX::Termios termios_ref
2862 RETVAL = tcgetattr(fd, termios_ref);
2867 setattr(termios_ref, fd = 0, optional_actions = 0)
2868 POSIX::Termios termios_ref
2870 int optional_actions
2872 RETVAL = tcsetattr(fd, optional_actions, termios_ref);
2877 cfgetispeed(termios_ref)
2878 POSIX::Termios termios_ref
2881 cfgetospeed(termios_ref)
2882 POSIX::Termios termios_ref
2885 getiflag(termios_ref)
2886 POSIX::Termios termios_ref
2888 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2889 RETVAL = termios_ref->c_iflag;
2891 not_here("getiflag");
2898 getoflag(termios_ref)
2899 POSIX::Termios termios_ref
2901 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2902 RETVAL = termios_ref->c_oflag;
2904 not_here("getoflag");
2911 getcflag(termios_ref)
2912 POSIX::Termios termios_ref
2914 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2915 RETVAL = termios_ref->c_cflag;
2917 not_here("getcflag");
2924 getlflag(termios_ref)
2925 POSIX::Termios termios_ref
2927 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2928 RETVAL = termios_ref->c_lflag;
2930 not_here("getlflag");
2937 getcc(termios_ref, ccix)
2938 POSIX::Termios termios_ref
2941 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2943 croak("Bad getcc subscript");
2944 RETVAL = termios_ref->c_cc[ccix];
2953 cfsetispeed(termios_ref, speed)
2954 POSIX::Termios termios_ref
2958 cfsetospeed(termios_ref, speed)
2959 POSIX::Termios termios_ref
2963 setiflag(termios_ref, iflag)
2964 POSIX::Termios termios_ref
2967 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2968 termios_ref->c_iflag = iflag;
2970 not_here("setiflag");
2974 setoflag(termios_ref, oflag)
2975 POSIX::Termios termios_ref
2978 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2979 termios_ref->c_oflag = oflag;
2981 not_here("setoflag");
2985 setcflag(termios_ref, cflag)
2986 POSIX::Termios termios_ref
2989 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2990 termios_ref->c_cflag = cflag;
2992 not_here("setcflag");
2996 setlflag(termios_ref, lflag)
2997 POSIX::Termios termios_ref
3000 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
3001 termios_ref->c_lflag = lflag;
3003 not_here("setlflag");
3007 setcc(termios_ref, ccix, cc)
3008 POSIX::Termios termios_ref
3012 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
3014 croak("Bad setcc subscript");
3015 termios_ref->c_cc[ccix] = cc;
3021 MODULE = POSIX PACKAGE = POSIX
3030 unsigned char * charstring
3032 unsigned char *s = charstring;
3033 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3034 for (RETVAL = 1; RETVAL && s < e; s++)
3042 unsigned char * charstring
3044 unsigned char *s = charstring;
3045 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3046 for (RETVAL = 1; RETVAL && s < e; s++)
3054 unsigned char * charstring
3056 unsigned char *s = charstring;
3057 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3058 for (RETVAL = 1; RETVAL && s < e; s++)
3066 unsigned char * charstring
3068 unsigned char *s = charstring;
3069 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3070 for (RETVAL = 1; RETVAL && s < e; s++)
3078 unsigned char * charstring
3080 unsigned char *s = charstring;
3081 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3082 for (RETVAL = 1; RETVAL && s < e; s++)
3090 unsigned char * charstring
3092 unsigned char *s = charstring;
3093 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3094 for (RETVAL = 1; RETVAL && s < e; s++)
3102 unsigned char * charstring
3104 unsigned char *s = charstring;
3105 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3106 for (RETVAL = 1; RETVAL && s < e; s++)
3114 unsigned char * charstring
3116 unsigned char *s = charstring;
3117 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3118 for (RETVAL = 1; RETVAL && s < e; s++)
3126 unsigned char * charstring
3128 unsigned char *s = charstring;
3129 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3130 for (RETVAL = 1; RETVAL && s < e; s++)
3138 unsigned char * charstring
3140 unsigned char *s = charstring;
3141 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3142 for (RETVAL = 1; RETVAL && s < e; s++)
3149 isxdigit(charstring)
3150 unsigned char * charstring
3152 unsigned char *s = charstring;
3153 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3154 for (RETVAL = 1; RETVAL && s < e; s++)
3161 open(filename, flags = O_RDONLY, mode = 0666)
3166 if (flags & (O_APPEND|O_CREAT|O_TRUNC|O_RDWR|O_WRONLY|O_EXCL))
3167 TAINT_PROPER("open");
3168 RETVAL = open(filename, flags, mode);
3176 #ifdef HAS_LOCALECONV
3177 struct lconv *lcbuf;
3179 if (lcbuf = localeconv()) {
3181 if (lcbuf->decimal_point && *lcbuf->decimal_point)
3182 hv_store(RETVAL, "decimal_point", 13,
3183 newSVpv(lcbuf->decimal_point, 0), 0);
3184 if (lcbuf->thousands_sep && *lcbuf->thousands_sep)
3185 hv_store(RETVAL, "thousands_sep", 13,
3186 newSVpv(lcbuf->thousands_sep, 0), 0);
3187 #ifndef NO_LOCALECONV_GROUPING
3188 if (lcbuf->grouping && *lcbuf->grouping)
3189 hv_store(RETVAL, "grouping", 8,
3190 newSVpv(lcbuf->grouping, 0), 0);
3192 if (lcbuf->int_curr_symbol && *lcbuf->int_curr_symbol)
3193 hv_store(RETVAL, "int_curr_symbol", 15,
3194 newSVpv(lcbuf->int_curr_symbol, 0), 0);
3195 if (lcbuf->currency_symbol && *lcbuf->currency_symbol)
3196 hv_store(RETVAL, "currency_symbol", 15,
3197 newSVpv(lcbuf->currency_symbol, 0), 0);
3198 if (lcbuf->mon_decimal_point && *lcbuf->mon_decimal_point)
3199 hv_store(RETVAL, "mon_decimal_point", 17,
3200 newSVpv(lcbuf->mon_decimal_point, 0), 0);
3201 #ifndef NO_LOCALECONV_MON_THOUSANDS_SEP
3202 if (lcbuf->mon_thousands_sep && *lcbuf->mon_thousands_sep)
3203 hv_store(RETVAL, "mon_thousands_sep", 17,
3204 newSVpv(lcbuf->mon_thousands_sep, 0), 0);
3206 #ifndef NO_LOCALECONV_MON_GROUPING
3207 if (lcbuf->mon_grouping && *lcbuf->mon_grouping)
3208 hv_store(RETVAL, "mon_grouping", 12,
3209 newSVpv(lcbuf->mon_grouping, 0), 0);
3211 if (lcbuf->positive_sign && *lcbuf->positive_sign)
3212 hv_store(RETVAL, "positive_sign", 13,
3213 newSVpv(lcbuf->positive_sign, 0), 0);
3214 if (lcbuf->negative_sign && *lcbuf->negative_sign)
3215 hv_store(RETVAL, "negative_sign", 13,
3216 newSVpv(lcbuf->negative_sign, 0), 0);
3218 if (lcbuf->int_frac_digits != CHAR_MAX)
3219 hv_store(RETVAL, "int_frac_digits", 15,
3220 newSViv(lcbuf->int_frac_digits), 0);
3221 if (lcbuf->frac_digits != CHAR_MAX)
3222 hv_store(RETVAL, "frac_digits", 11,
3223 newSViv(lcbuf->frac_digits), 0);
3224 if (lcbuf->p_cs_precedes != CHAR_MAX)
3225 hv_store(RETVAL, "p_cs_precedes", 13,
3226 newSViv(lcbuf->p_cs_precedes), 0);
3227 if (lcbuf->p_sep_by_space != CHAR_MAX)
3228 hv_store(RETVAL, "p_sep_by_space", 14,
3229 newSViv(lcbuf->p_sep_by_space), 0);
3230 if (lcbuf->n_cs_precedes != CHAR_MAX)
3231 hv_store(RETVAL, "n_cs_precedes", 13,
3232 newSViv(lcbuf->n_cs_precedes), 0);
3233 if (lcbuf->n_sep_by_space != CHAR_MAX)
3234 hv_store(RETVAL, "n_sep_by_space", 14,
3235 newSViv(lcbuf->n_sep_by_space), 0);
3236 if (lcbuf->p_sign_posn != CHAR_MAX)
3237 hv_store(RETVAL, "p_sign_posn", 11,
3238 newSViv(lcbuf->p_sign_posn), 0);
3239 if (lcbuf->n_sign_posn != CHAR_MAX)
3240 hv_store(RETVAL, "n_sign_posn", 11,
3241 newSViv(lcbuf->n_sign_posn), 0);
3244 localeconv(); /* A stub to call not_here(). */
3250 setlocale(category, locale = 0)
3254 RETVAL = setlocale(category, locale);
3256 #ifdef USE_LOCALE_CTYPE
3257 if (category == LC_CTYPE
3259 || category == LC_ALL
3265 if (category == LC_ALL)
3266 newctype = setlocale(LC_CTYPE, NULL);
3270 new_ctype(newctype);
3272 #endif /* USE_LOCALE_CTYPE */
3273 #ifdef USE_LOCALE_COLLATE
3274 if (category == LC_COLLATE
3276 || category == LC_ALL
3282 if (category == LC_ALL)
3283 newcoll = setlocale(LC_COLLATE, NULL);
3287 new_collate(newcoll);
3289 #endif /* USE_LOCALE_COLLATE */
3290 #ifdef USE_LOCALE_NUMERIC
3291 if (category == LC_NUMERIC
3293 || category == LC_ALL
3299 if (category == LC_ALL)
3300 newnum = setlocale(LC_NUMERIC, NULL);
3304 new_numeric(newnum);
3306 #endif /* USE_LOCALE_NUMERIC */
3346 /* (We already know stack is long enough.) */
3347 PUSHs(sv_2mortal(newSVnv(frexp(x,&expvar))));
3348 PUSHs(sv_2mortal(newSViv(expvar)));
3364 /* (We already know stack is long enough.) */
3365 PUSHs(sv_2mortal(newSVnv(Perl_modf(x,&intvar))));
3366 PUSHs(sv_2mortal(newSVnv(intvar)));
3381 sigaction(sig, action, oldaction = 0)
3383 POSIX::SigAction action
3384 POSIX::SigAction oldaction
3387 RETVAL = not_here("sigaction");
3389 # This code is really grody because we're trying to make the signal
3390 # interface look beautiful, which is hard.
3393 GV *siggv = gv_fetchpv("SIG", TRUE, SVt_PVHV);
3394 struct sigaction act;
3395 struct sigaction oact;
3396 POSIX__SigSet sigset;
3398 SV** sigsvp = hv_fetch(GvHVn(siggv),
3400 strlen(PL_sig_name[sig]),
3404 /* Remember old handler name if desired. */
3406 char *hand = SvPVx(*sigsvp, n_a);
3407 svp = hv_fetch(oldaction, "HANDLER", 7, TRUE);
3408 sv_setpv(*svp, *hand ? hand : "DEFAULT");
3412 /* Vector new handler through %SIG. (We always use sighandler
3413 for the C signal handler, which reads %SIG to dispatch.) */
3414 svp = hv_fetch(action, "HANDLER", 7, FALSE);
3416 croak("Can't supply an action without a HANDLER");
3417 sv_setpv(*sigsvp, SvPV(*svp, n_a));
3418 mg_set(*sigsvp); /* handles DEFAULT and IGNORE */
3419 act.sa_handler = PL_sighandlerp;
3421 /* Set up any desired mask. */
3422 svp = hv_fetch(action, "MASK", 4, FALSE);
3423 if (svp && sv_isa(*svp, "POSIX::SigSet")) {
3425 tmp = (unsigned long)SvNV((SV*)SvRV(*svp));
3426 sigset = (sigset_t*) tmp;
3427 act.sa_mask = *sigset;
3430 sigemptyset(& act.sa_mask);
3432 /* Set up any desired flags. */
3433 svp = hv_fetch(action, "FLAGS", 5, FALSE);
3434 act.sa_flags = svp ? SvIV(*svp) : 0;
3437 /* Now work around sigaction oddities */
3438 if (action && oldaction)
3439 RETVAL = sigaction(sig, & act, & oact);
3441 RETVAL = sigaction(sig, & act, (struct sigaction *)0);
3443 RETVAL = sigaction(sig, (struct sigaction *)0, & oact);
3448 /* Get back the mask. */
3449 svp = hv_fetch(oldaction, "MASK", 4, TRUE);
3450 if (sv_isa(*svp, "POSIX::SigSet")) {
3452 tmp = (unsigned long)SvNV((SV*)SvRV(*svp));
3453 sigset = (sigset_t*) tmp;
3456 New(0, sigset, 1, sigset_t);
3457 sv_setptrobj(*svp, sigset, "POSIX::SigSet");
3459 *sigset = oact.sa_mask;
3461 /* Get back the flags. */
3462 svp = hv_fetch(oldaction, "FLAGS", 5, TRUE);
3463 sv_setiv(*svp, oact.sa_flags);
3472 POSIX::SigSet sigset
3475 sigprocmask(how, sigset, oldsigset = 0)
3477 POSIX::SigSet sigset
3478 POSIX::SigSet oldsigset = NO_INIT
3483 else if (sv_derived_from(ST(2), "POSIX::SigSet")) {
3484 IV tmp = SvIV((SV*)SvRV(ST(2)));
3485 oldsigset = INT2PTR(POSIX__SigSet,tmp);
3488 New(0, oldsigset, 1, sigset_t);
3489 sigemptyset(oldsigset);
3490 sv_setref_pv(ST(2), "POSIX::SigSet", (void*)oldsigset);
3494 sigsuspend(signal_mask)
3495 POSIX::SigSet signal_mask
3515 lseek(fd, offset, whence)
3528 if (pipe(fds) != -1) {
3530 PUSHs(sv_2mortal(newSViv(fds[0])));
3531 PUSHs(sv_2mortal(newSViv(fds[1])));
3535 read(fd, buffer, nbytes)
3537 SV *sv_buffer = SvROK(ST(1)) ? SvRV(ST(1)) : ST(1);
3541 char * buffer = sv_grow( sv_buffer, nbytes+1 );
3544 SvCUR(sv_buffer) = RETVAL;
3545 SvPOK_only(sv_buffer);
3546 *SvEND(sv_buffer) = '\0';
3547 SvTAINTED_on(sv_buffer);
3563 tcsetpgrp(fd, pgrp_id)
3572 if (uname(&buf) >= 0) {
3574 PUSHs(sv_2mortal(newSVpv(buf.sysname, 0)));
3575 PUSHs(sv_2mortal(newSVpv(buf.nodename, 0)));
3576 PUSHs(sv_2mortal(newSVpv(buf.release, 0)));
3577 PUSHs(sv_2mortal(newSVpv(buf.version, 0)));
3578 PUSHs(sv_2mortal(newSVpv(buf.machine, 0)));
3581 uname((char *) 0); /* A stub to call not_here(). */
3585 write(fd, buffer, nbytes)
3596 RETVAL = newSVpvn("", 0);
3597 SvGROW(RETVAL, L_tmpnam);
3598 len = strlen(tmpnam(SvPV(RETVAL, i)));
3599 SvCUR_set(RETVAL, len);
3612 mbstowcs(s, pwcs, n)
3624 wcstombs(s, pwcs, n)
3646 SET_NUMERIC_LOCAL();
3647 num = strtod(str, &unparsed);
3648 PUSHs(sv_2mortal(newSVnv(num)));
3649 if (GIMME == G_ARRAY) {
3652 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3654 PUSHs(&PL_sv_undef);
3658 strtol(str, base = 0)
3665 num = strtol(str, &unparsed, base);
3666 #if IVSIZE <= LONGSIZE
3667 if (num < IV_MIN || num > IV_MAX)
3668 PUSHs(sv_2mortal(newSVnv((double)num)));
3671 PUSHs(sv_2mortal(newSViv((IV)num)));
3672 if (GIMME == G_ARRAY) {
3675 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3677 PUSHs(&PL_sv_undef);
3681 strtoul(str, base = 0)
3688 num = strtoul(str, &unparsed, base);
3690 PUSHs(sv_2mortal(newSViv((IV)num)));
3692 PUSHs(sv_2mortal(newSVnv((double)num)));
3693 if (GIMME == G_ARRAY) {
3696 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3698 PUSHs(&PL_sv_undef);
3708 char *p = SvPV(src,srclen);
3710 ST(0) = sv_2mortal(NEWSV(800,srclen));
3711 dstlen = strxfrm(SvPVX(ST(0)), p, (size_t)srclen);
3712 if (dstlen > srclen) {
3714 SvGROW(ST(0), dstlen);
3715 strxfrm(SvPVX(ST(0)), p, (size_t)dstlen);
3718 SvCUR(ST(0)) = dstlen;
3723 mkfifo(filename, mode)
3727 TAINT_PROPER("mkfifo");
3728 RETVAL = mkfifo(filename, mode);
3744 tcflush(fd, queue_selector)
3749 tcsendbreak(fd, duration)
3754 asctime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3767 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3770 mytm.tm_hour = hour;
3771 mytm.tm_mday = mday;
3773 mytm.tm_year = year;
3774 mytm.tm_wday = wday;
3775 mytm.tm_yday = yday;
3776 mytm.tm_isdst = isdst;
3777 RETVAL = asctime(&mytm);
3794 realtime = times( &tms );
3796 PUSHs( sv_2mortal( newSViv( (IV) realtime ) ) );
3797 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_utime ) ) );
3798 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_stime ) ) );
3799 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cutime ) ) );
3800 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cstime ) ) );
3803 difftime(time1, time2)
3808 mktime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3821 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3824 mytm.tm_hour = hour;
3825 mytm.tm_mday = mday;
3827 mytm.tm_year = year;
3828 mytm.tm_wday = wday;
3829 mytm.tm_yday = yday;
3830 mytm.tm_isdst = isdst;
3831 RETVAL = mktime(&mytm);
3837 strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1)
3853 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3856 mytm.tm_hour = hour;
3857 mytm.tm_mday = mday;
3859 mytm.tm_year = year;
3860 mytm.tm_wday = wday;
3861 mytm.tm_yday = yday;
3862 mytm.tm_isdst = isdst;
3864 len = strftime(tmpbuf, sizeof tmpbuf, fmt, &mytm);
3866 ** The following is needed to handle to the situation where
3867 ** tmpbuf overflows. Basically we want to allocate a buffer
3868 ** and try repeatedly. The reason why it is so complicated
3869 ** is that getting a return value of 0 from strftime can indicate
3870 ** one of the following:
3871 ** 1. buffer overflowed,
3872 ** 2. illegal conversion specifier, or
3873 ** 3. the format string specifies nothing to be returned(not
3874 ** an error). This could be because format is an empty string
3875 ** or it specifies %p that yields an empty string in some locale.
3876 ** If there is a better way to make it portable, go ahead by
3879 if ((len > 0 && len < sizeof(tmpbuf)) || (len == 0 && *fmt == '\0'))
3880 ST(0) = sv_2mortal(newSVpv(tmpbuf, len));
3882 /* Possibly buf overflowed - try again with a bigger buf */
3883 int fmtlen = strlen(fmt);
3884 int bufsize = fmtlen + sizeof(tmpbuf);
3888 New(0, buf, bufsize, char);
3890 buflen = strftime(buf, bufsize, fmt, &mytm);
3891 if (buflen > 0 && buflen < bufsize)
3893 /* heuristic to prevent out-of-memory errors */
3894 if (bufsize > 100*fmtlen) {
3900 Renew(buf, bufsize, char);
3903 ST(0) = sv_2mortal(newSVpvn(buf, buflen));
3907 ST(0) = sv_2mortal(newSVpvn(tmpbuf, len));
3918 PUSHs(sv_2mortal(newSVpvn(tzname[0],strlen(tzname[0]))));
3919 PUSHs(sv_2mortal(newSVpvn(tzname[1],strlen(tzname[1]))));
3922 access(filename, mode)
3940 pathconf(filename, name)