5 #define PERL_NO_GET_CONTEXT
8 #define PERLIO_NOT_STDIO 1
11 #if defined(PERL_OBJECT) || defined(PERL_CAPI)
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)
110 # define tzname _tzname
111 # undef MB_CUR_MAX /* XXX: bug in b20.1 */
115 # define mkfifo(a,b) not_here("mkfifo")
116 # define ttyname(a) (char*)not_here("ttyname")
117 # define sigset_t long
120 # define tzname _tzname
123 # define mode_t short
126 # define mode_t short
128 # define tzset() not_here("tzset")
130 # ifndef _POSIX_OPEN_MAX
131 # define _POSIX_OPEN_MAX FOPEN_MAX /* XXX bogus ? */
134 # define sigaction(a,b,c) not_here("sigaction")
135 # define sigpending(a) not_here("sigpending")
136 # define sigprocmask(a,b,c) not_here("sigprocmask")
137 # define sigsuspend(a) not_here("sigsuspend")
138 # define sigemptyset(a) not_here("sigemptyset")
139 # define sigaddset(a,b) not_here("sigaddset")
140 # define sigdelset(a,b) not_here("sigdelset")
141 # define sigfillset(a) not_here("sigfillset")
142 # define sigismember(a,b) not_here("sigismember")
147 # define mkfifo(a,b) not_here("mkfifo")
148 # else /* !( defined OS2 ) */
150 # define mkfifo(path, mode) (mknod((path), (mode) | S_IFIFO, 0))
153 # endif /* !HAS_MKFIFO */
156 # include <sys/times.h>
158 # include <sys/utsname.h>
160 # include <sys/wait.h>
168 typedef long SysRetLong;
169 typedef sigset_t* POSIX__SigSet;
170 typedef HV* POSIX__SigAction;
172 typedef struct termios* POSIX__Termios;
173 #else /* Define termios types to int, and call not_here for the functions.*/
174 #define POSIX__Termios int
178 #define cfgetispeed(x) not_here("cfgetispeed")
179 #define cfgetospeed(x) not_here("cfgetospeed")
180 #define tcdrain(x) not_here("tcdrain")
181 #define tcflush(x,y) not_here("tcflush")
182 #define tcsendbreak(x,y) not_here("tcsendbreak")
183 #define cfsetispeed(x,y) not_here("cfsetispeed")
184 #define cfsetospeed(x,y) not_here("cfsetospeed")
185 #define ctermid(x) (char *) not_here("ctermid")
186 #define tcflow(x,y) not_here("tcflow")
187 #define tcgetattr(x,y) not_here("tcgetattr")
188 #define tcsetattr(x,y,z) not_here("tcsetattr")
191 /* Possibly needed prototypes */
192 char *cuserid (char *);
193 double strtod (const char *, char **);
194 long strtol (const char *, char **, int);
195 unsigned long strtoul (const char *, char **, int);
198 #define cuserid(a) (char *) not_here("cuserid")
202 #define difftime(a,b) not_here("difftime")
205 #ifndef HAS_FPATHCONF
206 #define fpathconf(f,n) (SysRetLong) not_here("fpathconf")
209 #define mktime(a) not_here("mktime")
212 #define nice(a) not_here("nice")
215 #define pathconf(f,n) (SysRetLong) not_here("pathconf")
218 #define sysconf(n) (SysRetLong) not_here("sysconf")
221 #define readlink(a,b,c) not_here("readlink")
224 #define setpgid(a,b) not_here("setpgid")
227 #define setsid() not_here("setsid")
230 #define strcoll(s1,s2) not_here("strcoll")
233 #define strtod(s1,s2) not_here("strtod")
236 #define strtol(s1,s2,b) not_here("strtol")
239 #define strtoul(s1,s2,b) not_here("strtoul")
242 #define strxfrm(s1,s2,n) not_here("strxfrm")
244 #ifndef HAS_TCGETPGRP
245 #define tcgetpgrp(a) not_here("tcgetpgrp")
247 #ifndef HAS_TCSETPGRP
248 #define tcsetpgrp(a,b) not_here("tcsetpgrp")
251 #define times(a) not_here("times")
254 #define uname(a) not_here("uname")
257 #define waitpid(a,b,c) not_here("waitpid")
262 #define mblen(a,b) not_here("mblen")
266 #define mbstowcs(s, pwcs, n) not_here("mbstowcs")
269 #define mbtowc(pwc, s, n) not_here("mbtowc")
272 #define wcstombs(s, pwcs, n) not_here("wcstombs")
275 #define wctomb(s, wchar) not_here("wcstombs")
277 #if !defined(HAS_MBLEN) && !defined(HAS_MBSTOWCS) && !defined(HAS_MBTOWC) && !defined(HAS_WCSTOMBS) && !defined(HAS_WCTOMB)
278 /* If we don't have these functions, then we wouldn't have gotten a typedef
279 for wchar_t, the wide character type. Defining wchar_t allows the
280 functions referencing it to compile. Its actual type is then meaningless,
281 since without the above functions, all sections using it end up calling
282 not_here() and croak. --Kaveh Ghazi (ghazi@noc.rutgers.edu) 9/18/94. */
288 #ifndef HAS_LOCALECONV
289 #define localeconv() not_here("localeconv")
294 extern char *tzname[];
297 #if !defined(WIN32) || (defined(__MINGW32__) && !defined(tzname))
298 char *tzname[] = { "" , "" };
302 /* XXX struct tm on some systems (SunOS4/BSD) contains extra (non POSIX)
303 * fields for which we don't have Configure support yet:
304 * char *tm_zone; -- abbreviation of timezone name
305 * long tm_gmtoff; -- offset from GMT in seconds
306 * To workaround core dumps from the uninitialised tm_zone we get the
307 * system to give us a reasonable struct to copy. This fix means that
308 * strftime uses the tm_zone and tm_gmtoff values returned by
309 * localtime(time()). That should give the desired result most of the
310 * time. But probably not always!
312 * This is a temporary workaround to be removed once Configure
313 * support is added and NETaa14816 is considered in full.
314 * It does not address tzname aspects of NETaa14816.
317 # ifndef STRUCT_TM_HASZONE
318 # define STRUCT_TM_HASZONE
322 #ifdef STRUCT_TM_HASZONE
324 init_tm(struct tm *ptm) /* see mktime, strftime and asctime */
328 Copy(localtime(&now), ptm, 1, struct tm);
332 # define init_tm(ptm)
336 * mini_mktime - normalise struct tm values without the localtime()
337 * semantics (and overhead) of mktime().
340 mini_mktime(struct tm *ptm)
344 int month, mday, year, jday;
345 int odd_cent, odd_year;
347 #define DAYS_PER_YEAR 365
348 #define DAYS_PER_QYEAR (4*DAYS_PER_YEAR+1)
349 #define DAYS_PER_CENT (25*DAYS_PER_QYEAR-1)
350 #define DAYS_PER_QCENT (4*DAYS_PER_CENT+1)
351 #define SECS_PER_HOUR (60*60)
352 #define SECS_PER_DAY (24*SECS_PER_HOUR)
353 /* parentheses deliberately absent on these two, otherwise they don't work */
354 #define MONTH_TO_DAYS 153/5
355 #define DAYS_TO_MONTH 5/153
356 /* offset to bias by March (month 4) 1st between month/mday & year finding */
357 #define YEAR_ADJUST (4*MONTH_TO_DAYS+1)
358 /* as used here, the algorithm leaves Sunday as day 1 unless we adjust it */
359 #define WEEKDAY_BIAS 6 /* (1+6)%7 makes Sunday 0 again */
362 * Year/day algorithm notes:
364 * With a suitable offset for numeric value of the month, one can find
365 * an offset into the year by considering months to have 30.6 (153/5) days,
366 * using integer arithmetic (i.e., with truncation). To avoid too much
367 * messing about with leap days, we consider January and February to be
368 * the 13th and 14th month of the previous year. After that transformation,
369 * we need the month index we use to be high by 1 from 'normal human' usage,
370 * so the month index values we use run from 4 through 15.
372 * Given that, and the rules for the Gregorian calendar (leap years are those
373 * divisible by 4 unless also divisible by 100, when they must be divisible
374 * by 400 instead), we can simply calculate the number of days since some
375 * arbitrary 'beginning of time' by futzing with the (adjusted) year number,
376 * the days we derive from our month index, and adding in the day of the
377 * month. The value used here is not adjusted for the actual origin which
378 * it normally would use (1 January A.D. 1), since we're not exposing it.
379 * We're only building the value so we can turn around and get the
380 * normalised values for the year, month, day-of-month, and day-of-year.
382 * For going backward, we need to bias the value we're using so that we find
383 * the right year value. (Basically, we don't want the contribution of
384 * March 1st to the number to apply while deriving the year). Having done
385 * that, we 'count up' the contribution to the year number by accounting for
386 * full quadracenturies (400-year periods) with their extra leap days, plus
387 * the contribution from full centuries (to avoid counting in the lost leap
388 * days), plus the contribution from full quad-years (to count in the normal
389 * leap days), plus the leftover contribution from any non-leap years.
390 * At this point, if we were working with an actual leap day, we'll have 0
391 * days left over. This is also true for March 1st, however. So, we have
392 * to special-case that result, and (earlier) keep track of the 'odd'
393 * century and year contributions. If we got 4 extra centuries in a qcent,
394 * or 4 extra years in a qyear, then it's a leap day and we call it 29 Feb.
395 * Otherwise, we add back in the earlier bias we removed (the 123 from
396 * figuring in March 1st), find the month index (integer division by 30.6),
397 * and the remainder is the day-of-month. We then have to convert back to
398 * 'real' months (including fixing January and February from being 14/15 in
399 * the previous year to being in the proper year). After that, to get
400 * tm_yday, we work with the normalised year and get a new yearday value for
401 * January 1st, which we subtract from the yearday value we had earlier,
402 * representing the date we've re-built. This is done from January 1
403 * because tm_yday is 0-origin.
405 * Since POSIX time routines are only guaranteed to work for times since the
406 * UNIX epoch (00:00:00 1 Jan 1970 UTC), the fact that this algorithm
407 * applies Gregorian calendar rules even to dates before the 16th century
408 * doesn't bother me. Besides, you'd need cultural context for a given
409 * date to know whether it was Julian or Gregorian calendar, and that's
410 * outside the scope for this routine. Since we convert back based on the
411 * same rules we used to build the yearday, you'll only get strange results
412 * for input which needed normalising, or for the 'odd' century years which
413 * were leap years in the Julian calander but not in the Gregorian one.
414 * I can live with that.
416 * This algorithm also fails to handle years before A.D. 1 gracefully, but
417 * that's still outside the scope for POSIX time manipulation, so I don't
421 year = 1900 + ptm->tm_year;
424 /* allow given yday with no month & mday to dominate the result */
425 if (ptm->tm_yday >= 0 && mday <= 0 && month <= 0) {
428 jday = 1 + ptm->tm_yday;
437 yearday = DAYS_PER_YEAR * year + year/4 - year/100 + year/400;
438 yearday += month*MONTH_TO_DAYS + mday + jday;
440 * Note that we don't know when leap-seconds were or will be,
441 * so we have to trust the user if we get something which looks
442 * like a sensible leap-second. Wild values for seconds will
443 * be rationalised, however.
445 if ((unsigned) ptm->tm_sec <= 60) {
452 secs += 60 * ptm->tm_min;
453 secs += SECS_PER_HOUR * ptm->tm_hour;
455 if (secs-(secs/SECS_PER_DAY*SECS_PER_DAY) < 0) {
456 /* got negative remainder, but need positive time */
457 /* back off an extra day to compensate */
458 yearday += (secs/SECS_PER_DAY)-1;
459 secs -= SECS_PER_DAY * (secs/SECS_PER_DAY - 1);
462 yearday += (secs/SECS_PER_DAY);
463 secs -= SECS_PER_DAY * (secs/SECS_PER_DAY);
466 else if (secs >= SECS_PER_DAY) {
467 yearday += (secs/SECS_PER_DAY);
468 secs %= SECS_PER_DAY;
470 ptm->tm_hour = secs/SECS_PER_HOUR;
471 secs %= SECS_PER_HOUR;
472 ptm->tm_min = secs/60;
475 /* done with time of day effects */
477 * The algorithm for yearday has (so far) left it high by 428.
478 * To avoid mistaking a legitimate Feb 29 as Mar 1, we need to
479 * bias it by 123 while trying to figure out what year it
480 * really represents. Even with this tweak, the reverse
481 * translation fails for years before A.D. 0001.
482 * It would still fail for Feb 29, but we catch that one below.
484 jday = yearday; /* save for later fixup vis-a-vis Jan 1 */
485 yearday -= YEAR_ADJUST;
486 year = (yearday / DAYS_PER_QCENT) * 400;
487 yearday %= DAYS_PER_QCENT;
488 odd_cent = yearday / DAYS_PER_CENT;
489 year += odd_cent * 100;
490 yearday %= DAYS_PER_CENT;
491 year += (yearday / DAYS_PER_QYEAR) * 4;
492 yearday %= DAYS_PER_QYEAR;
493 odd_year = yearday / DAYS_PER_YEAR;
495 yearday %= DAYS_PER_YEAR;
496 if (!yearday && (odd_cent==4 || odd_year==4)) { /* catch Feb 29 */
501 yearday += YEAR_ADJUST; /* recover March 1st crock */
502 month = yearday*DAYS_TO_MONTH;
503 yearday -= month*MONTH_TO_DAYS;
504 /* recover other leap-year adjustment */
513 ptm->tm_year = year - 1900;
515 ptm->tm_mday = yearday;
516 /* re-build yearday based on Jan 1 to get tm_yday */
518 yearday = year*DAYS_PER_YEAR + year/4 - year/100 + year/400;
519 yearday += 14*MONTH_TO_DAYS + 1;
520 ptm->tm_yday = jday - yearday;
521 /* fix tm_wday if not overridden by caller */
522 if ((unsigned)ptm->tm_wday > 6)
523 ptm->tm_wday = (jday + WEEKDAY_BIAS) % 7;
526 #ifdef HAS_LONG_DOUBLE
527 # if LONG_DOUBLESIZE > DOUBLESIZE
528 # undef HAS_LONG_DOUBLE /* XXX until we figure out how to use them */
532 #ifndef HAS_LONG_DOUBLE
547 croak("POSIX::%s not implemented on this architecture", s);
552 #if defined(HAS_LONG_DOUBLE) && (LONG_DOUBLESIZE > DOUBLESIZE)
557 constant(char *name, int arg)
562 if (strEQ(name, "ARG_MAX"))
570 if (strEQ(name, "BUFSIZ"))
576 if (strEQ(name, "BRKINT"))
582 if (strEQ(name, "B9600"))
588 if (strEQ(name, "B19200"))
594 if (strEQ(name, "B38400"))
600 if (strEQ(name, "B0"))
606 if (strEQ(name, "B110"))
612 if (strEQ(name, "B1200"))
618 if (strEQ(name, "B134"))
624 if (strEQ(name, "B150"))
630 if (strEQ(name, "B1800"))
636 if (strEQ(name, "B200"))
642 if (strEQ(name, "B2400"))
648 if (strEQ(name, "B300"))
654 if (strEQ(name, "B4800"))
660 if (strEQ(name, "B50"))
666 if (strEQ(name, "B600"))
672 if (strEQ(name, "B75"))
680 if (strEQ(name, "CHAR_BIT"))
686 if (strEQ(name, "CHAR_MAX"))
692 if (strEQ(name, "CHAR_MIN"))
698 if (strEQ(name, "CHILD_MAX"))
704 if (strEQ(name, "CLK_TCK"))
710 if (strEQ(name, "CLOCAL"))
716 if (strEQ(name, "CLOCKS_PER_SEC"))
717 #ifdef CLOCKS_PER_SEC
718 return CLOCKS_PER_SEC;
722 if (strEQ(name, "CREAD"))
728 if (strEQ(name, "CS5"))
734 if (strEQ(name, "CS6"))
740 if (strEQ(name, "CS7"))
746 if (strEQ(name, "CS8"))
752 if (strEQ(name, "CSIZE"))
758 if (strEQ(name, "CSTOPB"))
766 if (strEQ(name, "DBL_MAX"))
772 if (strEQ(name, "DBL_MIN"))
778 if (strEQ(name, "DBL_DIG"))
784 if (strEQ(name, "DBL_EPSILON"))
790 if (strEQ(name, "DBL_MANT_DIG"))
796 if (strEQ(name, "DBL_MAX_10_EXP"))
797 #ifdef DBL_MAX_10_EXP
798 return DBL_MAX_10_EXP;
802 if (strEQ(name, "DBL_MAX_EXP"))
808 if (strEQ(name, "DBL_MIN_10_EXP"))
809 #ifdef DBL_MIN_10_EXP
810 return DBL_MIN_10_EXP;
814 if (strEQ(name, "DBL_MIN_EXP"))
824 if (strEQ(name, "EACCES"))
830 if (strEQ(name, "EADDRINUSE"))
836 if (strEQ(name, "EADDRNOTAVAIL"))
838 return EADDRNOTAVAIL;
842 if (strEQ(name, "EAFNOSUPPORT"))
848 if (strEQ(name, "EAGAIN"))
854 if (strEQ(name, "EALREADY"))
862 if (strEQ(name, "EBADF"))
868 if (strEQ(name, "EBUSY"))
876 if (strEQ(name, "ECHILD"))
882 if (strEQ(name, "ECHO"))
888 if (strEQ(name, "ECHOE"))
894 if (strEQ(name, "ECHOK"))
900 if (strEQ(name, "ECHONL"))
906 if (strEQ(name, "ECONNABORTED"))
912 if (strEQ(name, "ECONNREFUSED"))
918 if (strEQ(name, "ECONNRESET"))
926 if (strEQ(name, "EDEADLK"))
932 if (strEQ(name, "EDESTADDRREQ"))
938 if (strEQ(name, "EDOM"))
944 if (strEQ(name, "EDQUOT"))
952 if (strEQ(name, "EEXIST"))
960 if (strEQ(name, "EFAULT"))
966 if (strEQ(name, "EFBIG"))
974 if (strEQ(name, "EHOSTDOWN"))
980 if (strEQ(name, "EHOSTUNREACH"))
988 if (strEQ(name, "EINPROGRESS"))
994 if (strEQ(name, "EINTR"))
1000 if (strEQ(name, "EINVAL"))
1006 if (strEQ(name, "EIO"))
1012 if (strEQ(name, "EISCONN"))
1018 if (strEQ(name, "EISDIR"))
1026 if (strEQ(name, "ELOOP"))
1034 if (strEQ(name, "EMFILE"))
1040 if (strEQ(name, "EMLINK"))
1046 if (strEQ(name, "EMSGSIZE"))
1054 if (strEQ(name, "ENETDOWN"))
1060 if (strEQ(name, "ENETRESET"))
1066 if (strEQ(name, "ENETUNREACH"))
1072 if (strEQ(name, "ENOBUFS"))
1078 if (strEQ(name, "ENOEXEC"))
1084 if (strEQ(name, "ENOMEM"))
1090 if (strEQ(name, "ENOPROTOOPT"))
1096 if (strEQ(name, "ENOSPC"))
1102 if (strEQ(name, "ENOTBLK"))
1108 if (strEQ(name, "ENOTCONN"))
1114 if (strEQ(name, "ENOTDIR"))
1120 if (strEQ(name, "ENOTEMPTY"))
1126 if (strEQ(name, "ENOTSOCK"))
1132 if (strEQ(name, "ENOTTY"))
1138 if (strEQ(name, "ENFILE"))
1144 if (strEQ(name, "ENODEV"))
1150 if (strEQ(name, "ENOENT"))
1156 if (strEQ(name, "ENOLCK"))
1162 if (strEQ(name, "ENOSYS"))
1168 if (strEQ(name, "ENXIO"))
1174 if (strEQ(name, "ENAMETOOLONG"))
1176 return ENAMETOOLONG;
1182 if (strEQ(name, "EOF"))
1188 if (strEQ(name, "EOPNOTSUPP"))
1196 if (strEQ(name, "EPERM"))
1202 if (strEQ(name, "EPFNOSUPPORT"))
1204 return EPFNOSUPPORT;
1208 if (strEQ(name, "EPIPE"))
1214 if (strEQ(name, "EPROCLIM"))
1220 if (strEQ(name, "EPROTONOSUPPORT"))
1221 #ifdef EPROTONOSUPPORT
1222 return EPROTONOSUPPORT;
1226 if (strEQ(name, "EPROTOTYPE"))
1234 if (strEQ(name, "ERANGE"))
1240 if (strEQ(name, "EREMOTE"))
1246 if (strEQ(name, "ERESTART"))
1252 if (strEQ(name, "EROFS"))
1260 if (strEQ(name, "ESHUTDOWN"))
1266 if (strEQ(name, "ESOCKTNOSUPPORT"))
1267 #ifdef ESOCKTNOSUPPORT
1268 return ESOCKTNOSUPPORT;
1272 if (strEQ(name, "ESPIPE"))
1278 if (strEQ(name, "ESRCH"))
1284 if (strEQ(name, "ESTALE"))
1292 if (strEQ(name, "ETIMEDOUT"))
1298 if (strEQ(name, "ETOOMANYREFS"))
1300 return ETOOMANYREFS;
1304 if (strEQ(name, "ETXTBSY"))
1312 if (strEQ(name, "EUSERS"))
1320 if (strEQ(name, "EWOULDBLOCK"))
1328 if (strEQ(name, "EXIT_FAILURE"))
1330 return EXIT_FAILURE;
1334 if (strEQ(name, "EXIT_SUCCESS"))
1336 return EXIT_SUCCESS;
1340 if (strEQ(name, "EXDEV"))
1348 if (strEQ(name, "E2BIG"))
1356 if (strnEQ(name, "FLT_", 4)) {
1357 if (strEQ(name, "FLT_MAX"))
1363 if (strEQ(name, "FLT_MIN"))
1369 if (strEQ(name, "FLT_ROUNDS"))
1375 if (strEQ(name, "FLT_DIG"))
1381 if (strEQ(name, "FLT_EPSILON"))
1387 if (strEQ(name, "FLT_MANT_DIG"))
1389 return FLT_MANT_DIG;
1393 if (strEQ(name, "FLT_MAX_10_EXP"))
1394 #ifdef FLT_MAX_10_EXP
1395 return FLT_MAX_10_EXP;
1399 if (strEQ(name, "FLT_MAX_EXP"))
1405 if (strEQ(name, "FLT_MIN_10_EXP"))
1406 #ifdef FLT_MIN_10_EXP
1407 return FLT_MIN_10_EXP;
1411 if (strEQ(name, "FLT_MIN_EXP"))
1417 if (strEQ(name, "FLT_RADIX"))
1425 if (strnEQ(name, "F_", 2)) {
1426 if (strEQ(name, "F_DUPFD"))
1432 if (strEQ(name, "F_GETFD"))
1438 if (strEQ(name, "F_GETFL"))
1444 if (strEQ(name, "F_GETLK"))
1450 if (strEQ(name, "F_OK"))
1456 if (strEQ(name, "F_RDLCK"))
1462 if (strEQ(name, "F_SETFD"))
1468 if (strEQ(name, "F_SETFL"))
1474 if (strEQ(name, "F_SETLK"))
1480 if (strEQ(name, "F_SETLKW"))
1486 if (strEQ(name, "F_UNLCK"))
1492 if (strEQ(name, "F_WRLCK"))
1500 if (strEQ(name, "FD_CLOEXEC"))
1506 if (strEQ(name, "FILENAME_MAX"))
1508 return FILENAME_MAX;
1514 if (strEQ(name, "HUGE_VAL"))
1520 if (strEQ(name, "HUPCL"))
1528 if (strEQ(name, "INT_MAX"))
1534 if (strEQ(name, "INT_MIN"))
1540 if (strEQ(name, "ICANON"))
1546 if (strEQ(name, "ICRNL"))
1552 if (strEQ(name, "IEXTEN"))
1558 if (strEQ(name, "IGNBRK"))
1564 if (strEQ(name, "IGNCR"))
1570 if (strEQ(name, "IGNPAR"))
1576 if (strEQ(name, "INLCR"))
1582 if (strEQ(name, "INPCK"))
1588 if (strEQ(name, "ISIG"))
1594 if (strEQ(name, "ISTRIP"))
1600 if (strEQ(name, "IXOFF"))
1606 if (strEQ(name, "IXON"))
1614 if (strnEQ(name, "LC_", 3)) {
1615 if (strEQ(name, "LC_ALL"))
1621 if (strEQ(name, "LC_COLLATE"))
1627 if (strEQ(name, "LC_CTYPE"))
1633 if (strEQ(name, "LC_MONETARY"))
1639 if (strEQ(name, "LC_NUMERIC"))
1645 if (strEQ(name, "LC_TIME"))
1653 if (strnEQ(name, "LDBL_", 5)) {
1654 if (strEQ(name, "LDBL_MAX"))
1660 if (strEQ(name, "LDBL_MIN"))
1666 if (strEQ(name, "LDBL_DIG"))
1672 if (strEQ(name, "LDBL_EPSILON"))
1674 return LDBL_EPSILON;
1678 if (strEQ(name, "LDBL_MANT_DIG"))
1679 #ifdef LDBL_MANT_DIG
1680 return LDBL_MANT_DIG;
1684 if (strEQ(name, "LDBL_MAX_10_EXP"))
1685 #ifdef LDBL_MAX_10_EXP
1686 return LDBL_MAX_10_EXP;
1690 if (strEQ(name, "LDBL_MAX_EXP"))
1692 return LDBL_MAX_EXP;
1696 if (strEQ(name, "LDBL_MIN_10_EXP"))
1697 #ifdef LDBL_MIN_10_EXP
1698 return LDBL_MIN_10_EXP;
1702 if (strEQ(name, "LDBL_MIN_EXP"))
1704 return LDBL_MIN_EXP;
1710 if (strnEQ(name, "L_", 2)) {
1711 if (strEQ(name, "L_ctermid"))
1717 if (strEQ(name, "L_cuserid"))
1723 /* L_tmpnam[e] was a typo--retained for compatibility */
1724 if (strEQ(name, "L_tmpname") || strEQ(name, "L_tmpnam"))
1732 if (strEQ(name, "LONG_MAX"))
1738 if (strEQ(name, "LONG_MIN"))
1744 if (strEQ(name, "LINK_MAX"))
1752 if (strEQ(name, "MAX_CANON"))
1758 if (strEQ(name, "MAX_INPUT"))
1764 if (strEQ(name, "MB_CUR_MAX"))
1770 if (strEQ(name, "MB_LEN_MAX"))
1778 if (strEQ(name, "NULL")) return 0;
1779 if (strEQ(name, "NAME_MAX"))
1785 if (strEQ(name, "NCCS"))
1791 if (strEQ(name, "NGROUPS_MAX"))
1797 if (strEQ(name, "NOFLSH"))
1805 if (strnEQ(name, "O_", 2)) {
1806 if (strEQ(name, "O_APPEND"))
1812 if (strEQ(name, "O_CREAT"))
1818 if (strEQ(name, "O_TRUNC"))
1824 if (strEQ(name, "O_RDONLY"))
1830 if (strEQ(name, "O_RDWR"))
1836 if (strEQ(name, "O_WRONLY"))
1842 if (strEQ(name, "O_EXCL"))
1848 if (strEQ(name, "O_NOCTTY"))
1854 if (strEQ(name, "O_NONBLOCK"))
1860 if (strEQ(name, "O_ACCMODE"))
1868 if (strEQ(name, "OPEN_MAX"))
1874 if (strEQ(name, "OPOST"))
1882 if (strEQ(name, "PATH_MAX"))
1888 if (strEQ(name, "PARENB"))
1894 if (strEQ(name, "PARMRK"))
1900 if (strEQ(name, "PARODD"))
1906 if (strEQ(name, "PIPE_BUF"))
1914 if (strEQ(name, "RAND_MAX"))
1920 if (strEQ(name, "R_OK"))
1928 if (strnEQ(name, "SIG", 3)) {
1929 if (name[3] == '_') {
1930 if (strEQ(name, "SIG_BLOCK"))
1937 if (strEQ(name, "SIG_DFL")) return (IV)SIG_DFL;
1940 if (strEQ(name, "SIG_ERR")) return (IV)SIG_ERR;
1943 if (strEQ(name, "SIG_IGN")) return (IV)SIG_IGN;
1945 if (strEQ(name, "SIG_SETMASK"))
1951 if (strEQ(name, "SIG_UNBLOCK"))
1959 if (strEQ(name, "SIGABRT"))
1965 if (strEQ(name, "SIGALRM"))
1971 if (strEQ(name, "SIGCHLD"))
1977 if (strEQ(name, "SIGCONT"))
1983 if (strEQ(name, "SIGFPE"))
1989 if (strEQ(name, "SIGHUP"))
1995 if (strEQ(name, "SIGILL"))
2001 if (strEQ(name, "SIGINT"))
2007 if (strEQ(name, "SIGKILL"))
2013 if (strEQ(name, "SIGPIPE"))
2019 if (strEQ(name, "SIGQUIT"))
2025 if (strEQ(name, "SIGSEGV"))
2031 if (strEQ(name, "SIGSTOP"))
2037 if (strEQ(name, "SIGTERM"))
2043 if (strEQ(name, "SIGTSTP"))
2049 if (strEQ(name, "SIGTTIN"))
2055 if (strEQ(name, "SIGTTOU"))
2061 if (strEQ(name, "SIGUSR1"))
2067 if (strEQ(name, "SIGUSR2"))
2075 if (name[1] == '_') {
2076 if (strEQ(name, "S_ISGID"))
2082 if (strEQ(name, "S_ISUID"))
2088 if (strEQ(name, "S_IRGRP"))
2094 if (strEQ(name, "S_IROTH"))
2100 if (strEQ(name, "S_IRUSR"))
2106 if (strEQ(name, "S_IRWXG"))
2112 if (strEQ(name, "S_IRWXO"))
2118 if (strEQ(name, "S_IRWXU"))
2124 if (strEQ(name, "S_IWGRP"))
2130 if (strEQ(name, "S_IWOTH"))
2136 if (strEQ(name, "S_IWUSR"))
2142 if (strEQ(name, "S_IXGRP"))
2148 if (strEQ(name, "S_IXOTH"))
2154 if (strEQ(name, "S_IXUSR"))
2160 errno = EAGAIN; /* the following aren't constants */
2162 if (strEQ(name, "S_ISBLK")) return S_ISBLK(arg);
2165 if (strEQ(name, "S_ISCHR")) return S_ISCHR(arg);
2168 if (strEQ(name, "S_ISDIR")) return S_ISDIR(arg);
2171 if (strEQ(name, "S_ISFIFO")) return S_ISFIFO(arg);
2174 if (strEQ(name, "S_ISREG")) return S_ISREG(arg);
2178 if (strEQ(name, "SEEK_CUR"))
2184 if (strEQ(name, "SEEK_END"))
2190 if (strEQ(name, "SEEK_SET"))
2196 if (strEQ(name, "STREAM_MAX"))
2202 if (strEQ(name, "SHRT_MAX"))
2208 if (strEQ(name, "SHRT_MIN"))
2214 if (strnEQ(name, "SA_", 3)) {
2215 if (strEQ(name, "SA_NOCLDSTOP"))
2217 return SA_NOCLDSTOP;
2221 if (strEQ(name, "SA_NOCLDWAIT"))
2223 return SA_NOCLDWAIT;
2227 if (strEQ(name, "SA_NODEFER"))
2233 if (strEQ(name, "SA_ONSTACK"))
2239 if (strEQ(name, "SA_RESETHAND"))
2241 return SA_RESETHAND;
2245 if (strEQ(name, "SA_RESTART"))
2251 if (strEQ(name, "SA_SIGINFO"))
2259 if (strEQ(name, "SCHAR_MAX"))
2265 if (strEQ(name, "SCHAR_MIN"))
2271 if (strEQ(name, "SSIZE_MAX"))
2277 if (strEQ(name, "STDIN_FILENO"))
2279 return STDIN_FILENO;
2283 if (strEQ(name, "STDOUT_FILENO"))
2284 #ifdef STDOUT_FILENO
2285 return STDOUT_FILENO;
2289 if (strEQ(name, "STRERR_FILENO"))
2290 #ifdef STRERR_FILENO
2291 return STRERR_FILENO;
2297 if (strEQ(name, "TCIFLUSH"))
2303 if (strEQ(name, "TCIOFF"))
2309 if (strEQ(name, "TCIOFLUSH"))
2315 if (strEQ(name, "TCION"))
2321 if (strEQ(name, "TCOFLUSH"))
2327 if (strEQ(name, "TCOOFF"))
2333 if (strEQ(name, "TCOON"))
2339 if (strEQ(name, "TCSADRAIN"))
2345 if (strEQ(name, "TCSAFLUSH"))
2351 if (strEQ(name, "TCSANOW"))
2357 if (strEQ(name, "TMP_MAX"))
2363 if (strEQ(name, "TOSTOP"))
2369 if (strEQ(name, "TZNAME_MAX"))
2377 if (strEQ(name, "UCHAR_MAX"))
2383 if (strEQ(name, "UINT_MAX"))
2389 if (strEQ(name, "ULONG_MAX"))
2395 if (strEQ(name, "USHRT_MAX"))
2403 if (strEQ(name, "VEOF"))
2409 if (strEQ(name, "VEOL"))
2415 if (strEQ(name, "VERASE"))
2421 if (strEQ(name, "VINTR"))
2427 if (strEQ(name, "VKILL"))
2433 if (strEQ(name, "VMIN"))
2439 if (strEQ(name, "VQUIT"))
2445 if (strEQ(name, "VSTART"))
2451 if (strEQ(name, "VSTOP"))
2457 if (strEQ(name, "VSUSP"))
2463 if (strEQ(name, "VTIME"))
2471 if (strEQ(name, "W_OK"))
2477 if (strEQ(name, "WNOHANG"))
2483 if (strEQ(name, "WUNTRACED"))
2489 errno = EAGAIN; /* the following aren't constants */
2491 if (strEQ(name, "WEXITSTATUS")) return WEXITSTATUS(arg);
2494 if (strEQ(name, "WIFEXITED")) return WIFEXITED(arg);
2497 if (strEQ(name, "WIFSIGNALED")) return WIFSIGNALED(arg);
2500 if (strEQ(name, "WIFSTOPPED")) return WIFSTOPPED(arg);
2503 if (strEQ(name, "WSTOPSIG")) return WSTOPSIG(arg);
2506 if (strEQ(name, "WTERMSIG")) return WTERMSIG(arg);
2510 if (strEQ(name, "X_OK"))
2518 if (strnEQ(name, "_PC_", 4)) {
2519 if (strEQ(name, "_PC_CHOWN_RESTRICTED"))
2520 #if defined(_PC_CHOWN_RESTRICTED) || HINT_SC_EXIST
2521 return _PC_CHOWN_RESTRICTED;
2525 if (strEQ(name, "_PC_LINK_MAX"))
2526 #if defined(_PC_LINK_MAX) || HINT_SC_EXIST
2527 return _PC_LINK_MAX;
2531 if (strEQ(name, "_PC_MAX_CANON"))
2532 #if defined(_PC_MAX_CANON) || HINT_SC_EXIST
2533 return _PC_MAX_CANON;
2537 if (strEQ(name, "_PC_MAX_INPUT"))
2538 #if defined(_PC_MAX_INPUT) || HINT_SC_EXIST
2539 return _PC_MAX_INPUT;
2543 if (strEQ(name, "_PC_NAME_MAX"))
2544 #if defined(_PC_NAME_MAX) || HINT_SC_EXIST
2545 return _PC_NAME_MAX;
2549 if (strEQ(name, "_PC_NO_TRUNC"))
2550 #if defined(_PC_NO_TRUNC) || HINT_SC_EXIST
2551 return _PC_NO_TRUNC;
2555 if (strEQ(name, "_PC_PATH_MAX"))
2556 #if defined(_PC_PATH_MAX) || HINT_SC_EXIST
2557 return _PC_PATH_MAX;
2561 if (strEQ(name, "_PC_PIPE_BUF"))
2562 #if defined(_PC_PIPE_BUF) || HINT_SC_EXIST
2563 return _PC_PIPE_BUF;
2567 if (strEQ(name, "_PC_VDISABLE"))
2568 #if defined(_PC_VDISABLE) || HINT_SC_EXIST
2569 return _PC_VDISABLE;
2575 if (strnEQ(name, "_POSIX_", 7)) {
2576 if (strEQ(name, "_POSIX_ARG_MAX"))
2577 #ifdef _POSIX_ARG_MAX
2578 return _POSIX_ARG_MAX;
2582 if (strEQ(name, "_POSIX_CHILD_MAX"))
2583 #ifdef _POSIX_CHILD_MAX
2584 return _POSIX_CHILD_MAX;
2588 if (strEQ(name, "_POSIX_CHOWN_RESTRICTED"))
2589 #ifdef _POSIX_CHOWN_RESTRICTED
2590 return _POSIX_CHOWN_RESTRICTED;
2594 if (strEQ(name, "_POSIX_JOB_CONTROL"))
2595 #ifdef _POSIX_JOB_CONTROL
2596 return _POSIX_JOB_CONTROL;
2600 if (strEQ(name, "_POSIX_LINK_MAX"))
2601 #ifdef _POSIX_LINK_MAX
2602 return _POSIX_LINK_MAX;
2606 if (strEQ(name, "_POSIX_MAX_CANON"))
2607 #ifdef _POSIX_MAX_CANON
2608 return _POSIX_MAX_CANON;
2612 if (strEQ(name, "_POSIX_MAX_INPUT"))
2613 #ifdef _POSIX_MAX_INPUT
2614 return _POSIX_MAX_INPUT;
2618 if (strEQ(name, "_POSIX_NAME_MAX"))
2619 #ifdef _POSIX_NAME_MAX
2620 return _POSIX_NAME_MAX;
2624 if (strEQ(name, "_POSIX_NGROUPS_MAX"))
2625 #ifdef _POSIX_NGROUPS_MAX
2626 return _POSIX_NGROUPS_MAX;
2630 if (strEQ(name, "_POSIX_NO_TRUNC"))
2631 #ifdef _POSIX_NO_TRUNC
2632 return _POSIX_NO_TRUNC;
2636 if (strEQ(name, "_POSIX_OPEN_MAX"))
2637 #ifdef _POSIX_OPEN_MAX
2638 return _POSIX_OPEN_MAX;
2642 if (strEQ(name, "_POSIX_PATH_MAX"))
2643 #ifdef _POSIX_PATH_MAX
2644 return _POSIX_PATH_MAX;
2648 if (strEQ(name, "_POSIX_PIPE_BUF"))
2649 #ifdef _POSIX_PIPE_BUF
2650 return _POSIX_PIPE_BUF;
2654 if (strEQ(name, "_POSIX_SAVED_IDS"))
2655 #ifdef _POSIX_SAVED_IDS
2656 return _POSIX_SAVED_IDS;
2660 if (strEQ(name, "_POSIX_SSIZE_MAX"))
2661 #ifdef _POSIX_SSIZE_MAX
2662 return _POSIX_SSIZE_MAX;
2666 if (strEQ(name, "_POSIX_STREAM_MAX"))
2667 #ifdef _POSIX_STREAM_MAX
2668 return _POSIX_STREAM_MAX;
2672 if (strEQ(name, "_POSIX_TZNAME_MAX"))
2673 #ifdef _POSIX_TZNAME_MAX
2674 return _POSIX_TZNAME_MAX;
2678 if (strEQ(name, "_POSIX_VDISABLE"))
2679 #ifdef _POSIX_VDISABLE
2680 return _POSIX_VDISABLE;
2684 if (strEQ(name, "_POSIX_VERSION"))
2685 #ifdef _POSIX_VERSION
2686 return _POSIX_VERSION;
2692 if (strnEQ(name, "_SC_", 4)) {
2693 if (strEQ(name, "_SC_ARG_MAX"))
2694 #if defined(_SC_ARG_MAX) || HINT_SC_EXIST
2699 if (strEQ(name, "_SC_CHILD_MAX"))
2700 #if defined(_SC_CHILD_MAX) || HINT_SC_EXIST
2701 return _SC_CHILD_MAX;
2705 if (strEQ(name, "_SC_CLK_TCK"))
2706 #if defined(_SC_CLK_TCK) || HINT_SC_EXIST
2711 if (strEQ(name, "_SC_JOB_CONTROL"))
2712 #if defined(_SC_JOB_CONTROL) || HINT_SC_EXIST
2713 return _SC_JOB_CONTROL;
2717 if (strEQ(name, "_SC_NGROUPS_MAX"))
2718 #if defined(_SC_NGROUPS_MAX) || HINT_SC_EXIST
2719 return _SC_NGROUPS_MAX;
2723 if (strEQ(name, "_SC_OPEN_MAX"))
2724 #if defined(_SC_OPEN_MAX) || HINT_SC_EXIST
2725 return _SC_OPEN_MAX;
2729 if (strEQ(name, "_SC_SAVED_IDS"))
2730 #if defined(_SC_SAVED_IDS) || HINT_SC_EXIST
2731 return _SC_SAVED_IDS;
2735 if (strEQ(name, "_SC_STREAM_MAX"))
2736 #if defined(_SC_STREAM_MAX) || HINT_SC_EXIST
2737 return _SC_STREAM_MAX;
2741 if (strEQ(name, "_SC_TZNAME_MAX"))
2742 #if defined(_SC_TZNAME_MAX) || HINT_SC_EXIST
2743 return _SC_TZNAME_MAX;
2747 if (strEQ(name, "_SC_VERSION"))
2748 #if defined(_SC_VERSION) || HINT_SC_EXIST
2764 MODULE = SigSet PACKAGE = POSIX::SigSet PREFIX = sig
2767 new(packname = "POSIX::SigSet", ...)
2772 New(0, RETVAL, 1, sigset_t);
2773 sigemptyset(RETVAL);
2774 for (i = 1; i < items; i++)
2775 sigaddset(RETVAL, SvIV(ST(i)));
2782 POSIX::SigSet sigset
2787 sigaddset(sigset, sig)
2788 POSIX::SigSet sigset
2792 sigdelset(sigset, sig)
2793 POSIX::SigSet sigset
2798 POSIX::SigSet sigset
2802 POSIX::SigSet sigset
2805 sigismember(sigset, sig)
2806 POSIX::SigSet sigset
2810 MODULE = Termios PACKAGE = POSIX::Termios PREFIX = cf
2813 new(packname = "POSIX::Termios", ...)
2818 New(0, RETVAL, 1, struct termios);
2820 not_here("termios");
2828 DESTROY(termios_ref)
2829 POSIX::Termios termios_ref
2832 Safefree(termios_ref);
2834 not_here("termios");
2838 getattr(termios_ref, fd = 0)
2839 POSIX::Termios termios_ref
2842 RETVAL = tcgetattr(fd, termios_ref);
2847 setattr(termios_ref, fd = 0, optional_actions = 0)
2848 POSIX::Termios termios_ref
2850 int optional_actions
2852 RETVAL = tcsetattr(fd, optional_actions, termios_ref);
2857 cfgetispeed(termios_ref)
2858 POSIX::Termios termios_ref
2861 cfgetospeed(termios_ref)
2862 POSIX::Termios termios_ref
2865 getiflag(termios_ref)
2866 POSIX::Termios termios_ref
2868 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2869 RETVAL = termios_ref->c_iflag;
2871 not_here("getiflag");
2878 getoflag(termios_ref)
2879 POSIX::Termios termios_ref
2881 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2882 RETVAL = termios_ref->c_oflag;
2884 not_here("getoflag");
2891 getcflag(termios_ref)
2892 POSIX::Termios termios_ref
2894 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2895 RETVAL = termios_ref->c_cflag;
2897 not_here("getcflag");
2904 getlflag(termios_ref)
2905 POSIX::Termios termios_ref
2907 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2908 RETVAL = termios_ref->c_lflag;
2910 not_here("getlflag");
2917 getcc(termios_ref, ccix)
2918 POSIX::Termios termios_ref
2921 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2923 croak("Bad getcc subscript");
2924 RETVAL = termios_ref->c_cc[ccix];
2933 cfsetispeed(termios_ref, speed)
2934 POSIX::Termios termios_ref
2938 cfsetospeed(termios_ref, speed)
2939 POSIX::Termios termios_ref
2943 setiflag(termios_ref, iflag)
2944 POSIX::Termios termios_ref
2947 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2948 termios_ref->c_iflag = iflag;
2950 not_here("setiflag");
2954 setoflag(termios_ref, oflag)
2955 POSIX::Termios termios_ref
2958 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2959 termios_ref->c_oflag = oflag;
2961 not_here("setoflag");
2965 setcflag(termios_ref, cflag)
2966 POSIX::Termios termios_ref
2969 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2970 termios_ref->c_cflag = cflag;
2972 not_here("setcflag");
2976 setlflag(termios_ref, lflag)
2977 POSIX::Termios termios_ref
2980 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2981 termios_ref->c_lflag = lflag;
2983 not_here("setlflag");
2987 setcc(termios_ref, ccix, cc)
2988 POSIX::Termios termios_ref
2992 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2994 croak("Bad setcc subscript");
2995 termios_ref->c_cc[ccix] = cc;
3001 MODULE = POSIX PACKAGE = POSIX
3010 unsigned char * charstring
3012 unsigned char *s = charstring;
3013 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3014 for (RETVAL = 1; RETVAL && s < e; s++)
3022 unsigned char * charstring
3024 unsigned char *s = charstring;
3025 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3026 for (RETVAL = 1; RETVAL && s < e; s++)
3034 unsigned char * charstring
3036 unsigned char *s = charstring;
3037 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3038 for (RETVAL = 1; RETVAL && s < e; s++)
3046 unsigned char * charstring
3048 unsigned char *s = charstring;
3049 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3050 for (RETVAL = 1; RETVAL && s < e; s++)
3058 unsigned char * charstring
3060 unsigned char *s = charstring;
3061 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3062 for (RETVAL = 1; RETVAL && s < e; s++)
3070 unsigned char * charstring
3072 unsigned char *s = charstring;
3073 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3074 for (RETVAL = 1; RETVAL && s < e; s++)
3082 unsigned char * charstring
3084 unsigned char *s = charstring;
3085 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3086 for (RETVAL = 1; RETVAL && s < e; s++)
3094 unsigned char * charstring
3096 unsigned char *s = charstring;
3097 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3098 for (RETVAL = 1; RETVAL && s < e; s++)
3106 unsigned char * charstring
3108 unsigned char *s = charstring;
3109 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3110 for (RETVAL = 1; RETVAL && s < e; s++)
3118 unsigned char * charstring
3120 unsigned char *s = charstring;
3121 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3122 for (RETVAL = 1; RETVAL && s < e; s++)
3129 isxdigit(charstring)
3130 unsigned char * charstring
3132 unsigned char *s = charstring;
3133 unsigned char *e = s + PL_na; /* "PL_na" set by typemap side effect */
3134 for (RETVAL = 1; RETVAL && s < e; s++)
3141 open(filename, flags = O_RDONLY, mode = 0666)
3146 if (flags & (O_APPEND|O_CREAT|O_TRUNC|O_RDWR|O_WRONLY|O_EXCL))
3147 TAINT_PROPER("open");
3148 RETVAL = open(filename, flags, mode);
3156 #ifdef HAS_LOCALECONV
3157 struct lconv *lcbuf;
3159 if (lcbuf = localeconv()) {
3161 if (lcbuf->decimal_point && *lcbuf->decimal_point)
3162 hv_store(RETVAL, "decimal_point", 13,
3163 newSVpv(lcbuf->decimal_point, 0), 0);
3164 if (lcbuf->thousands_sep && *lcbuf->thousands_sep)
3165 hv_store(RETVAL, "thousands_sep", 13,
3166 newSVpv(lcbuf->thousands_sep, 0), 0);
3167 #ifndef NO_LOCALECONV_GROUPING
3168 if (lcbuf->grouping && *lcbuf->grouping)
3169 hv_store(RETVAL, "grouping", 8,
3170 newSVpv(lcbuf->grouping, 0), 0);
3172 if (lcbuf->int_curr_symbol && *lcbuf->int_curr_symbol)
3173 hv_store(RETVAL, "int_curr_symbol", 15,
3174 newSVpv(lcbuf->int_curr_symbol, 0), 0);
3175 if (lcbuf->currency_symbol && *lcbuf->currency_symbol)
3176 hv_store(RETVAL, "currency_symbol", 15,
3177 newSVpv(lcbuf->currency_symbol, 0), 0);
3178 if (lcbuf->mon_decimal_point && *lcbuf->mon_decimal_point)
3179 hv_store(RETVAL, "mon_decimal_point", 17,
3180 newSVpv(lcbuf->mon_decimal_point, 0), 0);
3181 #ifndef NO_LOCALECONV_MON_THOUSANDS_SEP
3182 if (lcbuf->mon_thousands_sep && *lcbuf->mon_thousands_sep)
3183 hv_store(RETVAL, "mon_thousands_sep", 17,
3184 newSVpv(lcbuf->mon_thousands_sep, 0), 0);
3186 #ifndef NO_LOCALECONV_MON_GROUPING
3187 if (lcbuf->mon_grouping && *lcbuf->mon_grouping)
3188 hv_store(RETVAL, "mon_grouping", 12,
3189 newSVpv(lcbuf->mon_grouping, 0), 0);
3191 if (lcbuf->positive_sign && *lcbuf->positive_sign)
3192 hv_store(RETVAL, "positive_sign", 13,
3193 newSVpv(lcbuf->positive_sign, 0), 0);
3194 if (lcbuf->negative_sign && *lcbuf->negative_sign)
3195 hv_store(RETVAL, "negative_sign", 13,
3196 newSVpv(lcbuf->negative_sign, 0), 0);
3198 if (lcbuf->int_frac_digits != CHAR_MAX)
3199 hv_store(RETVAL, "int_frac_digits", 15,
3200 newSViv(lcbuf->int_frac_digits), 0);
3201 if (lcbuf->frac_digits != CHAR_MAX)
3202 hv_store(RETVAL, "frac_digits", 11,
3203 newSViv(lcbuf->frac_digits), 0);
3204 if (lcbuf->p_cs_precedes != CHAR_MAX)
3205 hv_store(RETVAL, "p_cs_precedes", 13,
3206 newSViv(lcbuf->p_cs_precedes), 0);
3207 if (lcbuf->p_sep_by_space != CHAR_MAX)
3208 hv_store(RETVAL, "p_sep_by_space", 14,
3209 newSViv(lcbuf->p_sep_by_space), 0);
3210 if (lcbuf->n_cs_precedes != CHAR_MAX)
3211 hv_store(RETVAL, "n_cs_precedes", 13,
3212 newSViv(lcbuf->n_cs_precedes), 0);
3213 if (lcbuf->n_sep_by_space != CHAR_MAX)
3214 hv_store(RETVAL, "n_sep_by_space", 14,
3215 newSViv(lcbuf->n_sep_by_space), 0);
3216 if (lcbuf->p_sign_posn != CHAR_MAX)
3217 hv_store(RETVAL, "p_sign_posn", 11,
3218 newSViv(lcbuf->p_sign_posn), 0);
3219 if (lcbuf->n_sign_posn != CHAR_MAX)
3220 hv_store(RETVAL, "n_sign_posn", 11,
3221 newSViv(lcbuf->n_sign_posn), 0);
3224 localeconv(); /* A stub to call not_here(). */
3230 setlocale(category, locale = 0)
3234 RETVAL = setlocale(category, locale);
3236 #ifdef USE_LOCALE_CTYPE
3237 if (category == LC_CTYPE
3239 || category == LC_ALL
3245 if (category == LC_ALL)
3246 newctype = setlocale(LC_CTYPE, NULL);
3250 new_ctype(newctype);
3252 #endif /* USE_LOCALE_CTYPE */
3253 #ifdef USE_LOCALE_COLLATE
3254 if (category == LC_COLLATE
3256 || category == LC_ALL
3262 if (category == LC_ALL)
3263 newcoll = setlocale(LC_COLLATE, NULL);
3267 new_collate(newcoll);
3269 #endif /* USE_LOCALE_COLLATE */
3270 #ifdef USE_LOCALE_NUMERIC
3271 if (category == LC_NUMERIC
3273 || category == LC_ALL
3279 if (category == LC_ALL)
3280 newnum = setlocale(LC_NUMERIC, NULL);
3284 new_numeric(newnum);
3286 #endif /* USE_LOCALE_NUMERIC */
3326 /* (We already know stack is long enough.) */
3327 PUSHs(sv_2mortal(newSVnv(frexp(x,&expvar))));
3328 PUSHs(sv_2mortal(newSViv(expvar)));
3344 /* (We already know stack is long enough.) */
3345 PUSHs(sv_2mortal(newSVnv(modf(x,&intvar))));
3346 PUSHs(sv_2mortal(newSVnv(intvar)));
3361 sigaction(sig, action, oldaction = 0)
3363 POSIX::SigAction action
3364 POSIX::SigAction oldaction
3367 RETVAL = not_here("sigaction");
3369 # This code is really grody because we're trying to make the signal
3370 # interface look beautiful, which is hard.
3373 gv_fetchpv("SIG", TRUE, SVt_PVHV);
3376 struct sigaction act;
3377 struct sigaction oact;
3378 POSIX__SigSet sigset;
3380 SV** sigsvp = hv_fetch(GvHVn(PL_siggv),
3382 strlen(PL_sig_name[sig]),
3386 /* Remember old handler name if desired. */
3388 char *hand = SvPVx(*sigsvp, n_a);
3389 svp = hv_fetch(oldaction, "HANDLER", 7, TRUE);
3390 sv_setpv(*svp, *hand ? hand : "DEFAULT");
3394 /* Vector new handler through %SIG. (We always use sighandler
3395 for the C signal handler, which reads %SIG to dispatch.) */
3396 svp = hv_fetch(action, "HANDLER", 7, FALSE);
3398 croak("Can't supply an action without a HANDLER");
3399 sv_setpv(*sigsvp, SvPV(*svp, n_a));
3400 mg_set(*sigsvp); /* handles DEFAULT and IGNORE */
3401 act.sa_handler = PL_sighandlerp;
3403 /* Set up any desired mask. */
3404 svp = hv_fetch(action, "MASK", 4, FALSE);
3405 if (svp && sv_isa(*svp, "POSIX::SigSet")) {
3407 tmp = (unsigned long)SvNV((SV*)SvRV(*svp));
3408 sigset = (sigset_t*) tmp;
3409 act.sa_mask = *sigset;
3412 sigemptyset(& act.sa_mask);
3414 /* Set up any desired flags. */
3415 svp = hv_fetch(action, "FLAGS", 5, FALSE);
3416 act.sa_flags = svp ? SvIV(*svp) : 0;
3419 /* Now work around sigaction oddities */
3420 if (action && oldaction)
3421 RETVAL = sigaction(sig, & act, & oact);
3423 RETVAL = sigaction(sig, & act, (struct sigaction *)0);
3425 RETVAL = sigaction(sig, (struct sigaction *)0, & oact);
3430 /* Get back the mask. */
3431 svp = hv_fetch(oldaction, "MASK", 4, TRUE);
3432 if (sv_isa(*svp, "POSIX::SigSet")) {
3434 tmp = (unsigned long)SvNV((SV*)SvRV(*svp));
3435 sigset = (sigset_t*) tmp;
3438 New(0, sigset, 1, sigset_t);
3439 sv_setptrobj(*svp, sigset, "POSIX::SigSet");
3441 *sigset = oact.sa_mask;
3443 /* Get back the flags. */
3444 svp = hv_fetch(oldaction, "FLAGS", 5, TRUE);
3445 sv_setiv(*svp, oact.sa_flags);
3454 POSIX::SigSet sigset
3457 sigprocmask(how, sigset, oldsigset = 0)
3459 POSIX::SigSet sigset
3460 POSIX::SigSet oldsigset = NO_INIT
3465 else if (sv_derived_from(ST(2), "POSIX::SigSet")) {
3466 IV tmp = SvIV((SV*)SvRV(ST(2)));
3467 oldsigset = INT2PTR(POSIX__SigSet,tmp);
3470 New(0, oldsigset, 1, sigset_t);
3471 sigemptyset(oldsigset);
3472 sv_setref_pv(ST(2), "POSIX::SigSet", (void*)oldsigset);
3476 sigsuspend(signal_mask)
3477 POSIX::SigSet signal_mask
3497 lseek(fd, offset, whence)
3510 if (pipe(fds) != -1) {
3512 PUSHs(sv_2mortal(newSViv(fds[0])));
3513 PUSHs(sv_2mortal(newSViv(fds[1])));
3517 read(fd, buffer, nbytes)
3519 SV *sv_buffer = SvROK(ST(1)) ? SvRV(ST(1)) : ST(1);
3523 char * buffer = sv_grow( sv_buffer, nbytes+1 );
3526 SvCUR(sv_buffer) = RETVAL;
3527 SvPOK_only(sv_buffer);
3528 *SvEND(sv_buffer) = '\0';
3529 SvTAINTED_on(sv_buffer);
3545 tcsetpgrp(fd, pgrp_id)
3554 if (uname(&buf) >= 0) {
3556 PUSHs(sv_2mortal(newSVpv(buf.sysname, 0)));
3557 PUSHs(sv_2mortal(newSVpv(buf.nodename, 0)));
3558 PUSHs(sv_2mortal(newSVpv(buf.release, 0)));
3559 PUSHs(sv_2mortal(newSVpv(buf.version, 0)));
3560 PUSHs(sv_2mortal(newSVpv(buf.machine, 0)));
3563 uname((char *) 0); /* A stub to call not_here(). */
3567 write(fd, buffer, nbytes)
3578 RETVAL = newSVpvn("", 0);
3579 SvGROW(RETVAL, L_tmpnam);
3580 len = strlen(tmpnam(SvPV(RETVAL, i)));
3581 SvCUR_set(RETVAL, len);
3594 mbstowcs(s, pwcs, n)
3606 wcstombs(s, pwcs, n)
3628 SET_NUMERIC_LOCAL();
3629 num = strtod(str, &unparsed);
3630 PUSHs(sv_2mortal(newSVnv(num)));
3631 if (GIMME == G_ARRAY) {
3634 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3636 PUSHs(&PL_sv_undef);
3640 strtol(str, base = 0)
3647 num = strtol(str, &unparsed, base);
3648 #if IVSIZE <= LONGSIZE
3649 if (num < IV_MIN || num > IV_MAX)
3650 PUSHs(sv_2mortal(newSVnv((double)num)));
3653 PUSHs(sv_2mortal(newSViv((IV)num)));
3654 if (GIMME == G_ARRAY) {
3657 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3659 PUSHs(&PL_sv_undef);
3663 strtoul(str, base = 0)
3670 num = strtoul(str, &unparsed, base);
3672 PUSHs(sv_2mortal(newSViv((IV)num)));
3674 PUSHs(sv_2mortal(newSVnv((double)num)));
3675 if (GIMME == G_ARRAY) {
3678 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3680 PUSHs(&PL_sv_undef);
3690 char *p = SvPV(src,srclen);
3692 ST(0) = sv_2mortal(NEWSV(800,srclen));
3693 dstlen = strxfrm(SvPVX(ST(0)), p, (size_t)srclen);
3694 if (dstlen > srclen) {
3696 SvGROW(ST(0), dstlen);
3697 strxfrm(SvPVX(ST(0)), p, (size_t)dstlen);
3700 SvCUR(ST(0)) = dstlen;
3705 mkfifo(filename, mode)
3709 TAINT_PROPER("mkfifo");
3710 RETVAL = mkfifo(filename, mode);
3726 tcflush(fd, queue_selector)
3731 tcsendbreak(fd, duration)
3736 asctime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3749 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3752 mytm.tm_hour = hour;
3753 mytm.tm_mday = mday;
3755 mytm.tm_year = year;
3756 mytm.tm_wday = wday;
3757 mytm.tm_yday = yday;
3758 mytm.tm_isdst = isdst;
3759 RETVAL = asctime(&mytm);
3776 realtime = times( &tms );
3778 PUSHs( sv_2mortal( newSViv( (IV) realtime ) ) );
3779 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_utime ) ) );
3780 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_stime ) ) );
3781 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cutime ) ) );
3782 PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cstime ) ) );
3785 difftime(time1, time2)
3790 mktime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3803 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3806 mytm.tm_hour = hour;
3807 mytm.tm_mday = mday;
3809 mytm.tm_year = year;
3810 mytm.tm_wday = wday;
3811 mytm.tm_yday = yday;
3812 mytm.tm_isdst = isdst;
3813 RETVAL = mktime(&mytm);
3819 strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1)
3835 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3838 mytm.tm_hour = hour;
3839 mytm.tm_mday = mday;
3841 mytm.tm_year = year;
3842 mytm.tm_wday = wday;
3843 mytm.tm_yday = yday;
3844 mytm.tm_isdst = isdst;
3846 len = strftime(tmpbuf, sizeof tmpbuf, fmt, &mytm);
3848 ** The following is needed to handle to the situation where
3849 ** tmpbuf overflows. Basically we want to allocate a buffer
3850 ** and try repeatedly. The reason why it is so complicated
3851 ** is that getting a return value of 0 from strftime can indicate
3852 ** one of the following:
3853 ** 1. buffer overflowed,
3854 ** 2. illegal conversion specifier, or
3855 ** 3. the format string specifies nothing to be returned(not
3856 ** an error). This could be because format is an empty string
3857 ** or it specifies %p that yields an empty string in some locale.
3858 ** If there is a better way to make it portable, go ahead by
3861 if ( ( len > 0 && len < sizeof(tmpbuf) )
3862 || ( len == 0 && strlen(fmt) == 0 ) ) {
3863 ST(0) = sv_2mortal(newSVpv(tmpbuf, len));
3865 /* Possibly buf overflowed - try again with a bigger buf */
3866 int bufsize = strlen(fmt) + sizeof(tmpbuf);
3870 New(0, buf, bufsize, char);
3872 buflen = strftime(buf, bufsize, fmt, &mytm);
3873 if ( buflen > 0 && buflen < bufsize ) break;
3875 Renew(buf, bufsize, char);
3878 ST(0) = sv_2mortal(newSVpvn(buf, buflen));
3881 ST(0) = sv_2mortal(newSVpvn(tmpbuf, len));
3893 PUSHs(sv_2mortal(newSVpvn(tzname[0],strlen(tzname[0]))));
3894 PUSHs(sv_2mortal(newSVpvn(tzname[1],strlen(tzname[1]))));
3897 access(filename, mode)
3915 pathconf(filename, name)