This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix type mismatches in x2p's safe{alloc,realloc,free}.
[perl5.git] / ext / POSIX / POSIX.xs
CommitLineData
463ee0b2 1#include "EXTERN.h"
760ac839 2#define PERLIO_NOT_STDIO 1
463ee0b2
LW
3#include "perl.h"
4#include "XSUB.h"
2304df62 5#include <ctype.h>
a0d0e21e 6#ifdef I_DIRENT /* XXX maybe better to just rely on perl.h? */
2304df62 7#include <dirent.h>
a0d0e21e 8#endif
2304df62 9#include <errno.h>
2304df62
AD
10#ifdef I_FLOAT
11#include <float.h>
12#endif
a0d0e21e 13#ifdef I_LIMITS
2304df62 14#include <limits.h>
a0d0e21e 15#endif
2304df62
AD
16#include <locale.h>
17#include <math.h>
85e6fe83 18#ifdef I_PWD
2304df62 19#include <pwd.h>
85e6fe83 20#endif
2304df62
AD
21#include <setjmp.h>
22#include <signal.h>
23#ifdef I_STDARG
24#include <stdarg.h>
25#endif
26#ifdef I_STDDEF
27#include <stddef.h>
28#endif
a0d0e21e
LW
29/* XXX This comment is just to make I_TERMIO and I_SGTTY visible to
30 metaconfig for future extension writers. We don't use them in POSIX.
31 (This is really sneaky :-) --AD
32*/
33#if defined(I_TERMIOS)
34#include <termios.h>
35#endif
2304df62 36#include <stdio.h>
a0d0e21e 37#ifdef I_STDLIB
2304df62 38#include <stdlib.h>
a0d0e21e 39#endif
2304df62
AD
40#include <string.h>
41#include <sys/stat.h>
2304df62 42#include <sys/types.h>
2304df62
AD
43#include <time.h>
44#include <unistd.h>
6c418a22
PP
45#if defined(__VMS) && !defined(__POSIX_SOURCE)
46# include <file.h> /* == fcntl.h for DECC; no fcntl.h for VAXC */
47# include <libdef.h> /* LIB$_INVARG constant */
48# include <lib$routines.h> /* prototype for lib$ediv() */
49# include <starlet.h> /* prototype for sys$gettim() */
50
51# undef mkfifo /* #defined in perl.h */
52# define mkfifo(a,b) (not_here("mkfifo"),-1)
53# define tzset() not_here("tzset")
54
55 /* The default VMS emulation of Unix signals isn't very POSIXish */
56 typedef int sigset_t;
57# define sigpending(a) (not_here("sigpending"),0)
58
59 /* sigset_t is atomic under VMS, so these routines are easy */
60 int sigemptyset(sigset_t *set) {
61 if (!set) { SETERRNO(EFAULT,SS$_ACCVIO); return -1; }
62 *set = 0; return 0;
63 }
64 int sigfillset(sigset_t *set) {
65 int i;
66 if (!set) { SETERRNO(EFAULT,SS$_ACCVIO); return -1; }
67 for (i = 0; i < NSIG; i++) *set |= (1 << i);
68 return 0;
69 }
70 int sigaddset(sigset_t *set, int sig) {
71 if (!set) { SETERRNO(EFAULT,SS$_ACCVIO); return -1; }
72 if (sig > NSIG) { SETERRNO(EINVAL,LIB$_INVARG); return -1; }
73 *set |= (1 << (sig - 1));
74 return 0;
75 }
76 int sigdelset(sigset_t *set, int sig) {
77 if (!set) { SETERRNO(EFAULT,SS$_ACCVIO); return -1; }
78 if (sig > NSIG) { SETERRNO(EINVAL,LIB$_INVARG); return -1; }
79 *set &= ~(1 << (sig - 1));
80 return 0;
81 }
82 int sigismember(sigset_t *set, int sig) {
83 if (!set) { SETERRNO(EFAULT,SS$_ACCVIO); return -1; }
84 if (sig > NSIG) { SETERRNO(EINVAL,LIB$_INVARG); return -1; }
85 *set & (1 << (sig - 1));
86 }
87 /* The tools for sigprocmask() are there, just not the routine itself */
88# ifndef SIG_UNBLOCK
89# define SIG_UNBLOCK 1
90# endif
91# ifndef SIG_BLOCK
92# define SIG_BLOCK 2
93# endif
94# ifndef SIG_SETMASK
95# define SIG_SETMASK 3
96# endif
97 int sigprocmask(int how, sigset_t *set, sigset_t *oset) {
98 if (!set || !oset) {
99 set_errno(EFAULT); set_vaxc_errno(SS$_ACCVIO);
100 return -1;
101 }
102 switch (how) {
103 case SIG_SETMASK:
104 *oset = sigsetmask(*set);
105 break;
106 case SIG_BLOCK:
107 *oset = sigblock(*set);
108 break;
109 case SIG_UNBLOCK:
110 *oset = sigblock(0);
111 sigsetmask(*oset & ~*set);
112 break;
113 default:
114 set_errno(EINVAL); set_vaxc_errno(LIB$_INVARG);
115 return -1;
116 }
117 return 0;
118 }
119# define sigaction sigvec
120# define sa_flags sv_onstack
121# define sa_handler sv_handler
122# define sa_mask sv_mask
123# define sigsuspend(set) sigpause(*set)
124
125 /* The POSIX notion of ttyname() is better served by getname() under VMS */
126 static char ttnambuf[64];
127# define ttyname(fd) (isatty(fd) > 0 ? getname(fd,ttnambuf,0) : NULL)
128
129 /* The non-POSIX CRTL times() has void return type, so we just get the
130 current time directly */
131 clock_t vms_times(struct tms *bufptr) {
132 clock_t retval;
133 /* Get wall time and convert to 10 ms intervals to
134 * produce the return value that the POSIX standard expects */
135# if defined(__DECC) && defined (__ALPHA)
136# include <ints.h>
137 uint64 vmstime;
138 _ckvmssts(sys$gettim(&vmstime));
139 vmstime /= 100000;
140 retval = vmstime & 0x7fffffff;
141# else
142 /* (Older hw or ccs don't have an atomic 64-bit type, so we
143 * juggle 32-bit ints (and a float) to produce a time_t result
144 * with minimal loss of information.) */
145 long int vmstime[2],remainder,divisor = 100000;
146 _ckvmssts(sys$gettim((unsigned long int *)vmstime));
147 vmstime[1] &= 0x7fff; /* prevent overflow in EDIV */
148 _ckvmssts(lib$ediv(&divisor,vmstime,(long int *)&retval,&remainder));
149# endif
150 /* Fill in the struct tms using the CRTL routine . . .*/
151 times((tbuffer_t *)bufptr);
152 return (clock_t) retval;
153 }
154# define times(t) vms_times(t)
155#else
156# include <fcntl.h>
157# include <grp.h>
158# include <sys/times.h>
159# ifdef HAS_UNAME
160# include <sys/utsname.h>
161# endif
162# include <sys/wait.h>
163# ifdef I_UTIME
164# include <utime.h>
165# endif
a0d0e21e 166#endif
2304df62
AD
167
168typedef int SysRet;
a0d0e21e 169typedef long SysRetLong;
2304df62
AD
170typedef sigset_t* POSIX__SigSet;
171typedef HV* POSIX__SigAction;
a0d0e21e
LW
172#ifdef I_TERMIOS
173typedef struct termios* POSIX__Termios;
174#else /* Define termios types to int, and call not_here for the functions.*/
175#define POSIX__Termios int
176#define speed_t int
177#define tcflag_t int
178#define cc_t int
179#define cfgetispeed(x) not_here("cfgetispeed")
180#define cfgetospeed(x) not_here("cfgetospeed")
181#define tcdrain(x) not_here("tcdrain")
182#define tcflush(x,y) not_here("tcflush")
183#define tcsendbreak(x,y) not_here("tcsendbreak")
184#define cfsetispeed(x,y) not_here("cfsetispeed")
185#define cfsetospeed(x,y) not_here("cfsetospeed")
186#define ctermid(x) (char *) not_here("ctermid")
187#define tcflow(x,y) not_here("tcflow")
188#define tcgetattr(x,y) not_here("tcgetattr")
189#define tcsetattr(x,y,z) not_here("tcsetattr")
190#endif
191
192/* Possibly needed prototypes */
193char *cuserid _((char *));
a89d8a78
DH
194double strtod _((const char *, char **));
195long strtol _((const char *, char **, int));
196unsigned long strtoul _((const char *, char **, int));
a0d0e21e
LW
197
198#ifndef HAS_CUSERID
199#define cuserid(a) (char *) not_here("cuserid")
200#endif
201#ifndef HAS_DIFFTIME
202#ifndef difftime
203#define difftime(a,b) not_here("difftime")
204#endif
205#endif
206#ifndef HAS_FPATHCONF
207#define fpathconf(f,n) (SysRetLong) not_here("fpathconf")
208#endif
209#ifndef HAS_MKTIME
210#define mktime(a) not_here("mktime")
8990e307
LW
211#endif
212#ifndef HAS_NICE
213#define nice(a) not_here("nice")
214#endif
a0d0e21e
LW
215#ifndef HAS_PATHCONF
216#define pathconf(f,n) (SysRetLong) not_here("pathconf")
217#endif
218#ifndef HAS_SYSCONF
219#define sysconf(n) (SysRetLong) not_here("sysconf")
220#endif
8990e307
LW
221#ifndef HAS_READLINK
222#define readlink(a,b,c) not_here("readlink")
223#endif
224#ifndef HAS_SETPGID
225#define setpgid(a,b) not_here("setpgid")
226#endif
8990e307
LW
227#ifndef HAS_SETSID
228#define setsid() not_here("setsid")
229#endif
a0d0e21e
LW
230#ifndef HAS_STRCOLL
231#define strcoll(s1,s2) not_here("strcoll")
232#endif
a89d8a78
DH
233#ifndef HAS_STRTOD
234#define strtod(s1,s2) not_here("strtod")
235#endif
236#ifndef HAS_STRTOL
237#define strtol(s1,s2,b) not_here("strtol")
238#endif
239#ifndef HAS_STRTOUL
240#define strtoul(s1,s2,b) not_here("strtoul")
241#endif
a0d0e21e
LW
242#ifndef HAS_STRXFRM
243#define strxfrm(s1,s2,n) not_here("strxfrm")
8990e307
LW
244#endif
245#ifndef HAS_TCGETPGRP
246#define tcgetpgrp(a) not_here("tcgetpgrp")
247#endif
248#ifndef HAS_TCSETPGRP
249#define tcsetpgrp(a,b) not_here("tcsetpgrp")
250#endif
251#ifndef HAS_TIMES
252#define times(a) not_here("times")
253#endif
254#ifndef HAS_UNAME
255#define uname(a) not_here("uname")
256#endif
257#ifndef HAS_WAITPID
258#define waitpid(a,b,c) not_here("waitpid")
259#endif
260
a0d0e21e
LW
261#ifndef HAS_MBLEN
262#ifndef mblen
263#define mblen(a,b) not_here("mblen")
264#endif
265#endif
266#ifndef HAS_MBSTOWCS
267#define mbstowcs(s, pwcs, n) not_here("mbstowcs")
268#endif
269#ifndef HAS_MBTOWC
270#define mbtowc(pwc, s, n) not_here("mbtowc")
271#endif
272#ifndef HAS_WCSTOMBS
273#define wcstombs(s, pwcs, n) not_here("wcstombs")
274#endif
275#ifndef HAS_WCTOMB
276#define wctomb(s, wchar) not_here("wcstombs")
277#endif
278#if !defined(HAS_MBLEN) && !defined(HAS_MBSTOWCS) && !defined(HAS_MBTOWC) && !defined(HAS_WCSTOMBS) && !defined(HAS_WCTOMB)
279/* If we don't have these functions, then we wouldn't have gotten a typedef
280 for wchar_t, the wide character type. Defining wchar_t allows the
281 functions referencing it to compile. Its actual type is then meaningless,
282 since without the above functions, all sections using it end up calling
283 not_here() and croak. --Kaveh Ghazi (ghazi@noc.rutgers.edu) 9/18/94. */
284#ifndef wchar_t
285#define wchar_t char
286#endif
287#endif
288
289#ifndef HAS_LOCALECONV
290#define localeconv() not_here("localeconv")
291#endif
292
293#ifdef HAS_TZNAME
294extern char *tzname[];
295#else
296char *tzname[] = { "" , "" };
297#endif
298
7747499c
TB
299/* XXX struct tm on some systems (SunOS4/BSD) contains extra (non POSIX)
300 * fields for which we don't have Configure support yet:
301 * char *tm_zone; -- abbreviation of timezone name
302 * long tm_gmtoff; -- offset from GMT in seconds
303 * To workaround core dumps from the uninitialised tm_zone we get the
304 * system to give us a reasonable struct to copy. This fix means that
305 * strftime uses the tm_zone and tm_gmtoff values returned by
306 * localtime(time()). That should give the desired result most of the
307 * time. But probably not always!
308 *
309 * This is a temporary workaround to be removed once Configure
310 * support is added and NETaa14816 is considered in full.
311 * It does not address tzname aspects of NETaa14816.
312 */
313#ifdef STRUCT_TM_HASZONE
314static void
315init_tm(ptm) /* see mktime, strftime and asctime */
316 struct tm *ptm;
317{
318 Time_t now;
319 (void)time(&now);
320 Copy(localtime(&now), ptm, 1, struct tm);
321}
322
323#else
324# define init_tm(ptm)
325#endif
326
327
a0d0e21e
LW
328#ifndef HAS_LONG_DOUBLE /* XXX What to do about long doubles? */
329#ifdef LDBL_MAX
330#undef LDBL_MAX
331#endif
332#ifdef LDBL_MIN
333#undef LDBL_MIN
334#endif
335#ifdef LDBL_EPSILON
336#undef LDBL_EPSILON
337#endif
338#endif
339
8990e307
LW
340static int
341not_here(s)
342char *s;
343{
344 croak("POSIX::%s not implemented on this architecture", s);
345 return -1;
346}
463ee0b2 347
a0d0e21e
LW
348static double
349constant(name, arg)
2304df62
AD
350char *name;
351int arg;
352{
353 errno = 0;
354 switch (*name) {
355 case 'A':
356 if (strEQ(name, "ARG_MAX"))
357#ifdef ARG_MAX
358 return ARG_MAX;
359#else
360 goto not_there;
361#endif
362 break;
363 case 'B':
364 if (strEQ(name, "BUFSIZ"))
365#ifdef BUFSIZ
366 return BUFSIZ;
367#else
368 goto not_there;
369#endif
370 if (strEQ(name, "BRKINT"))
371#ifdef BRKINT
372 return BRKINT;
373#else
374 goto not_there;
375#endif
376 if (strEQ(name, "B9600"))
377#ifdef B9600
378 return B9600;
379#else
380 goto not_there;
381#endif
382 if (strEQ(name, "B19200"))
383#ifdef B19200
384 return B19200;
385#else
386 goto not_there;
387#endif
388 if (strEQ(name, "B38400"))
389#ifdef B38400
390 return B38400;
391#else
392 goto not_there;
393#endif
394 if (strEQ(name, "B0"))
395#ifdef B0
396 return B0;
397#else
398 goto not_there;
399#endif
400 if (strEQ(name, "B110"))
401#ifdef B110
402 return B110;
403#else
404 goto not_there;
405#endif
406 if (strEQ(name, "B1200"))
407#ifdef B1200
408 return B1200;
409#else
410 goto not_there;
411#endif
412 if (strEQ(name, "B134"))
413#ifdef B134
414 return B134;
415#else
416 goto not_there;
417#endif
418 if (strEQ(name, "B150"))
419#ifdef B150
420 return B150;
421#else
422 goto not_there;
423#endif
424 if (strEQ(name, "B1800"))
425#ifdef B1800
426 return B1800;
427#else
428 goto not_there;
429#endif
430 if (strEQ(name, "B200"))
431#ifdef B200
432 return B200;
433#else
434 goto not_there;
435#endif
436 if (strEQ(name, "B2400"))
437#ifdef B2400
438 return B2400;
439#else
440 goto not_there;
441#endif
442 if (strEQ(name, "B300"))
443#ifdef B300
444 return B300;
445#else
446 goto not_there;
447#endif
448 if (strEQ(name, "B4800"))
449#ifdef B4800
450 return B4800;
451#else
452 goto not_there;
453#endif
454 if (strEQ(name, "B50"))
455#ifdef B50
456 return B50;
457#else
458 goto not_there;
459#endif
460 if (strEQ(name, "B600"))
461#ifdef B600
462 return B600;
463#else
464 goto not_there;
465#endif
466 if (strEQ(name, "B75"))
467#ifdef B75
468 return B75;
469#else
470 goto not_there;
471#endif
472 break;
473 case 'C':
474 if (strEQ(name, "CHAR_BIT"))
475#ifdef CHAR_BIT
476 return CHAR_BIT;
477#else
478 goto not_there;
479#endif
480 if (strEQ(name, "CHAR_MAX"))
481#ifdef CHAR_MAX
482 return CHAR_MAX;
483#else
484 goto not_there;
485#endif
486 if (strEQ(name, "CHAR_MIN"))
487#ifdef CHAR_MIN
488 return CHAR_MIN;
489#else
490 goto not_there;
491#endif
492 if (strEQ(name, "CHILD_MAX"))
493#ifdef CHILD_MAX
494 return CHILD_MAX;
495#else
496 goto not_there;
497#endif
498 if (strEQ(name, "CLK_TCK"))
499#ifdef CLK_TCK
500 return CLK_TCK;
501#else
502 goto not_there;
503#endif
504 if (strEQ(name, "CLOCAL"))
505#ifdef CLOCAL
506 return CLOCAL;
507#else
508 goto not_there;
509#endif
510 if (strEQ(name, "CLOCKS_PER_SEC"))
511#ifdef CLOCKS_PER_SEC
512 return CLOCKS_PER_SEC;
513#else
514 goto not_there;
515#endif
516 if (strEQ(name, "CREAD"))
517#ifdef CREAD
518 return CREAD;
519#else
520 goto not_there;
521#endif
522 if (strEQ(name, "CS5"))
523#ifdef CS5
524 return CS5;
525#else
526 goto not_there;
527#endif
528 if (strEQ(name, "CS6"))
529#ifdef CS6
530 return CS6;
531#else
532 goto not_there;
533#endif
534 if (strEQ(name, "CS7"))
535#ifdef CS7
536 return CS7;
537#else
538 goto not_there;
539#endif
540 if (strEQ(name, "CS8"))
541#ifdef CS8
542 return CS8;
543#else
544 goto not_there;
545#endif
546 if (strEQ(name, "CSIZE"))
547#ifdef CSIZE
548 return CSIZE;
549#else
550 goto not_there;
551#endif
552 if (strEQ(name, "CSTOPB"))
553#ifdef CSTOPB
554 return CSTOPB;
555#else
556 goto not_there;
557#endif
558 break;
559 case 'D':
560 if (strEQ(name, "DBL_MAX"))
561#ifdef DBL_MAX
562 return DBL_MAX;
563#else
564 goto not_there;
565#endif
566 if (strEQ(name, "DBL_MIN"))
567#ifdef DBL_MIN
568 return DBL_MIN;
569#else
570 goto not_there;
571#endif
572 if (strEQ(name, "DBL_DIG"))
573#ifdef DBL_DIG
574 return DBL_DIG;
575#else
576 goto not_there;
577#endif
578 if (strEQ(name, "DBL_EPSILON"))
579#ifdef DBL_EPSILON
580 return DBL_EPSILON;
581#else
582 goto not_there;
583#endif
584 if (strEQ(name, "DBL_MANT_DIG"))
585#ifdef DBL_MANT_DIG
586 return DBL_MANT_DIG;
587#else
588 goto not_there;
589#endif
590 if (strEQ(name, "DBL_MAX_10_EXP"))
591#ifdef DBL_MAX_10_EXP
592 return DBL_MAX_10_EXP;
593#else
594 goto not_there;
595#endif
596 if (strEQ(name, "DBL_MAX_EXP"))
597#ifdef DBL_MAX_EXP
598 return DBL_MAX_EXP;
599#else
600 goto not_there;
601#endif
602 if (strEQ(name, "DBL_MIN_10_EXP"))
603#ifdef DBL_MIN_10_EXP
604 return DBL_MIN_10_EXP;
605#else
606 goto not_there;
607#endif
608 if (strEQ(name, "DBL_MIN_EXP"))
609#ifdef DBL_MIN_EXP
610 return DBL_MIN_EXP;
611#else
612 goto not_there;
613#endif
614 break;
615 case 'E':
616 switch (name[1]) {
617 case 'A':
618 if (strEQ(name, "EACCES"))
619#ifdef EACCES
620 return EACCES;
621#else
622 goto not_there;
623#endif
624 if (strEQ(name, "EAGAIN"))
625#ifdef EAGAIN
626 return EAGAIN;
627#else
628 goto not_there;
629#endif
630 break;
631 case 'B':
632 if (strEQ(name, "EBADF"))
633#ifdef EBADF
634 return EBADF;
635#else
636 goto not_there;
637#endif
638 if (strEQ(name, "EBUSY"))
639#ifdef EBUSY
640 return EBUSY;
641#else
642 goto not_there;
643#endif
644 break;
645 case 'C':
646 if (strEQ(name, "ECHILD"))
647#ifdef ECHILD
648 return ECHILD;
649#else
650 goto not_there;
651#endif
652 if (strEQ(name, "ECHO"))
653#ifdef ECHO
654 return ECHO;
655#else
656 goto not_there;
657#endif
658 if (strEQ(name, "ECHOE"))
659#ifdef ECHOE
660 return ECHOE;
661#else
662 goto not_there;
663#endif
664 if (strEQ(name, "ECHOK"))
665#ifdef ECHOK
666 return ECHOK;
667#else
668 goto not_there;
669#endif
670 if (strEQ(name, "ECHONL"))
671#ifdef ECHONL
672 return ECHONL;
673#else
674 goto not_there;
675#endif
676 break;
677 case 'D':
678 if (strEQ(name, "EDEADLK"))
679#ifdef EDEADLK
680 return EDEADLK;
681#else
682 goto not_there;
683#endif
684 if (strEQ(name, "EDOM"))
685#ifdef EDOM
686 return EDOM;
687#else
688 goto not_there;
689#endif
690 break;
691 case 'E':
692 if (strEQ(name, "EEXIST"))
693#ifdef EEXIST
694 return EEXIST;
695#else
696 goto not_there;
697#endif
698 break;
699 case 'F':
700 if (strEQ(name, "EFAULT"))
701#ifdef EFAULT
702 return EFAULT;
703#else
704 goto not_there;
705#endif
706 if (strEQ(name, "EFBIG"))
707#ifdef EFBIG
708 return EFBIG;
709#else
710 goto not_there;
711#endif
712 break;
713 case 'I':
714 if (strEQ(name, "EINTR"))
715#ifdef EINTR
716 return EINTR;
717#else
718 goto not_there;
719#endif
720 if (strEQ(name, "EINVAL"))
721#ifdef EINVAL
722 return EINVAL;
723#else
724 goto not_there;
725#endif
726 if (strEQ(name, "EIO"))
727#ifdef EIO
728 return EIO;
729#else
730 goto not_there;
731#endif
732 if (strEQ(name, "EISDIR"))
733#ifdef EISDIR
734 return EISDIR;
735#else
736 goto not_there;
737#endif
738 break;
739 case 'M':
740 if (strEQ(name, "EMFILE"))
741#ifdef EMFILE
742 return EMFILE;
743#else
744 goto not_there;
745#endif
746 if (strEQ(name, "EMLINK"))
747#ifdef EMLINK
748 return EMLINK;
749#else
750 goto not_there;
751#endif
752 break;
753 case 'N':
754 if (strEQ(name, "ENOMEM"))
755#ifdef ENOMEM
756 return ENOMEM;
757#else
758 goto not_there;
759#endif
760 if (strEQ(name, "ENOSPC"))
761#ifdef ENOSPC
762 return ENOSPC;
763#else
764 goto not_there;
765#endif
766 if (strEQ(name, "ENOEXEC"))
767#ifdef ENOEXEC
768 return ENOEXEC;
769#else
770 goto not_there;
771#endif
772 if (strEQ(name, "ENOTTY"))
773#ifdef ENOTTY
774 return ENOTTY;
775#else
776 goto not_there;
777#endif
778 if (strEQ(name, "ENOTDIR"))
779#ifdef ENOTDIR
780 return ENOTDIR;
781#else
782 goto not_there;
783#endif
784 if (strEQ(name, "ENOTEMPTY"))
785#ifdef ENOTEMPTY
786 return ENOTEMPTY;
787#else
788 goto not_there;
789#endif
790 if (strEQ(name, "ENFILE"))
791#ifdef ENFILE
792 return ENFILE;
793#else
794 goto not_there;
795#endif
796 if (strEQ(name, "ENODEV"))
797#ifdef ENODEV
798 return ENODEV;
799#else
800 goto not_there;
801#endif
802 if (strEQ(name, "ENOENT"))
803#ifdef ENOENT
804 return ENOENT;
805#else
806 goto not_there;
807#endif
808 if (strEQ(name, "ENOLCK"))
809#ifdef ENOLCK
810 return ENOLCK;
811#else
812 goto not_there;
813#endif
814 if (strEQ(name, "ENOSYS"))
815#ifdef ENOSYS
816 return ENOSYS;
817#else
818 goto not_there;
819#endif
820 if (strEQ(name, "ENXIO"))
821#ifdef ENXIO
822 return ENXIO;
823#else
824 goto not_there;
825#endif
826 if (strEQ(name, "ENAMETOOLONG"))
827#ifdef ENAMETOOLONG
828 return ENAMETOOLONG;
829#else
830 goto not_there;
831#endif
832 break;
833 case 'O':
834 if (strEQ(name, "EOF"))
835#ifdef EOF
836 return EOF;
837#else
838 goto not_there;
839#endif
840 break;
841 case 'P':
842 if (strEQ(name, "EPERM"))
843#ifdef EPERM
844 return EPERM;
845#else
846 goto not_there;
847#endif
848 if (strEQ(name, "EPIPE"))
849#ifdef EPIPE
850 return EPIPE;
851#else
852 goto not_there;
853#endif
854 break;
855 case 'R':
856 if (strEQ(name, "ERANGE"))
857#ifdef ERANGE
858 return ERANGE;
859#else
860 goto not_there;
861#endif
862 if (strEQ(name, "EROFS"))
863#ifdef EROFS
864 return EROFS;
865#else
866 goto not_there;
867#endif
868 break;
869 case 'S':
870 if (strEQ(name, "ESPIPE"))
871#ifdef ESPIPE
872 return ESPIPE;
873#else
874 goto not_there;
875#endif
876 if (strEQ(name, "ESRCH"))
877#ifdef ESRCH
878 return ESRCH;
879#else
880 goto not_there;
881#endif
882 break;
883 case 'X':
884 if (strEQ(name, "EXIT_FAILURE"))
885#ifdef EXIT_FAILURE
886 return EXIT_FAILURE;
887#else
888 return 1;
889#endif
890 if (strEQ(name, "EXIT_SUCCESS"))
891#ifdef EXIT_SUCCESS
892 return EXIT_SUCCESS;
893#else
894 return 0;
895#endif
896 if (strEQ(name, "EXDEV"))
897#ifdef EXDEV
898 return EXDEV;
899#else
900 goto not_there;
901#endif
902 break;
903 }
904 if (strEQ(name, "E2BIG"))
905#ifdef E2BIG
906 return E2BIG;
907#else
908 goto not_there;
909#endif
910 break;
911 case 'F':
912 if (strnEQ(name, "FLT_", 4)) {
913 if (strEQ(name, "FLT_MAX"))
914#ifdef FLT_MAX
915 return FLT_MAX;
916#else
917 goto not_there;
918#endif
919 if (strEQ(name, "FLT_MIN"))
920#ifdef FLT_MIN
921 return FLT_MIN;
922#else
923 goto not_there;
924#endif
925 if (strEQ(name, "FLT_ROUNDS"))
926#ifdef FLT_ROUNDS
927 return FLT_ROUNDS;
928#else
929 goto not_there;
930#endif
931 if (strEQ(name, "FLT_DIG"))
932#ifdef FLT_DIG
933 return FLT_DIG;
934#else
935 goto not_there;
936#endif
937 if (strEQ(name, "FLT_EPSILON"))
938#ifdef FLT_EPSILON
939 return FLT_EPSILON;
940#else
941 goto not_there;
942#endif
943 if (strEQ(name, "FLT_MANT_DIG"))
944#ifdef FLT_MANT_DIG
945 return FLT_MANT_DIG;
946#else
947 goto not_there;
948#endif
949 if (strEQ(name, "FLT_MAX_10_EXP"))
950#ifdef FLT_MAX_10_EXP
951 return FLT_MAX_10_EXP;
952#else
953 goto not_there;
954#endif
955 if (strEQ(name, "FLT_MAX_EXP"))
956#ifdef FLT_MAX_EXP
957 return FLT_MAX_EXP;
958#else
959 goto not_there;
960#endif
961 if (strEQ(name, "FLT_MIN_10_EXP"))
962#ifdef FLT_MIN_10_EXP
963 return FLT_MIN_10_EXP;
964#else
965 goto not_there;
966#endif
967 if (strEQ(name, "FLT_MIN_EXP"))
968#ifdef FLT_MIN_EXP
969 return FLT_MIN_EXP;
970#else
971 goto not_there;
972#endif
973 if (strEQ(name, "FLT_RADIX"))
974#ifdef FLT_RADIX
975 return FLT_RADIX;
976#else
977 goto not_there;
978#endif
979 break;
980 }
981 if (strnEQ(name, "F_", 2)) {
982 if (strEQ(name, "F_DUPFD"))
983#ifdef F_DUPFD
984 return F_DUPFD;
985#else
986 goto not_there;
987#endif
988 if (strEQ(name, "F_GETFD"))
989#ifdef F_GETFD
990 return F_GETFD;
991#else
992 goto not_there;
993#endif
994 if (strEQ(name, "F_GETFL"))
995#ifdef F_GETFL
996 return F_GETFL;
997#else
998 goto not_there;
999#endif
1000 if (strEQ(name, "F_GETLK"))
1001#ifdef F_GETLK
1002 return F_GETLK;
1003#else
1004 goto not_there;
1005#endif
1006 if (strEQ(name, "F_OK"))
1007#ifdef F_OK
1008 return F_OK;
1009#else
1010 goto not_there;
1011#endif
1012 if (strEQ(name, "F_RDLCK"))
1013#ifdef F_RDLCK
1014 return F_RDLCK;
1015#else
1016 goto not_there;
1017#endif
1018 if (strEQ(name, "F_SETFD"))
1019#ifdef F_SETFD
1020 return F_SETFD;
1021#else
1022 goto not_there;
1023#endif
1024 if (strEQ(name, "F_SETFL"))
1025#ifdef F_SETFL
1026 return F_SETFL;
1027#else
1028 goto not_there;
1029#endif
1030 if (strEQ(name, "F_SETLK"))
1031#ifdef F_SETLK
1032 return F_SETLK;
1033#else
1034 goto not_there;
1035#endif
1036 if (strEQ(name, "F_SETLKW"))
1037#ifdef F_SETLKW
1038 return F_SETLKW;
1039#else
1040 goto not_there;
1041#endif
1042 if (strEQ(name, "F_UNLCK"))
1043#ifdef F_UNLCK
1044 return F_UNLCK;
1045#else
1046 goto not_there;
1047#endif
1048 if (strEQ(name, "F_WRLCK"))
1049#ifdef F_WRLCK
1050 return F_WRLCK;
1051#else
1052 goto not_there;
1053#endif
1054 break;
1055 }
40000a8c
AD
1056 if (strEQ(name, "FD_CLOEXEC"))
1057#ifdef FD_CLOEXEC
1058 return FD_CLOEXEC;
1059#else
1060 goto not_there;
1061#endif
2304df62
AD
1062 if (strEQ(name, "FILENAME_MAX"))
1063#ifdef FILENAME_MAX
1064 return FILENAME_MAX;
1065#else
1066 goto not_there;
1067#endif
1068 break;
1069 case 'H':
1070 if (strEQ(name, "HUGE_VAL"))
1071#ifdef HUGE_VAL
1072 return HUGE_VAL;
1073#else
1074 goto not_there;
1075#endif
1076 if (strEQ(name, "HUPCL"))
1077#ifdef HUPCL
1078 return HUPCL;
1079#else
1080 goto not_there;
1081#endif
1082 break;
1083 case 'I':
1084 if (strEQ(name, "INT_MAX"))
1085#ifdef INT_MAX
1086 return INT_MAX;
1087#else
1088 goto not_there;
1089#endif
1090 if (strEQ(name, "INT_MIN"))
1091#ifdef INT_MIN
1092 return INT_MIN;
1093#else
1094 goto not_there;
1095#endif
1096 if (strEQ(name, "ICANON"))
1097#ifdef ICANON
1098 return ICANON;
1099#else
1100 goto not_there;
1101#endif
1102 if (strEQ(name, "ICRNL"))
1103#ifdef ICRNL
1104 return ICRNL;
1105#else
1106 goto not_there;
1107#endif
1108 if (strEQ(name, "IEXTEN"))
1109#ifdef IEXTEN
1110 return IEXTEN;
1111#else
1112 goto not_there;
1113#endif
1114 if (strEQ(name, "IGNBRK"))
1115#ifdef IGNBRK
1116 return IGNBRK;
1117#else
1118 goto not_there;
1119#endif
1120 if (strEQ(name, "IGNCR"))
1121#ifdef IGNCR
1122 return IGNCR;
1123#else
1124 goto not_there;
1125#endif
1126 if (strEQ(name, "IGNPAR"))
1127#ifdef IGNPAR
1128 return IGNPAR;
1129#else
1130 goto not_there;
1131#endif
1132 if (strEQ(name, "INLCR"))
1133#ifdef INLCR
1134 return INLCR;
1135#else
1136 goto not_there;
1137#endif
1138 if (strEQ(name, "INPCK"))
1139#ifdef INPCK
1140 return INPCK;
1141#else
1142 goto not_there;
1143#endif
1144 if (strEQ(name, "ISIG"))
1145#ifdef ISIG
1146 return ISIG;
1147#else
1148 goto not_there;
1149#endif
1150 if (strEQ(name, "ISTRIP"))
1151#ifdef ISTRIP
1152 return ISTRIP;
1153#else
1154 goto not_there;
1155#endif
1156 if (strEQ(name, "IXOFF"))
1157#ifdef IXOFF
1158 return IXOFF;
1159#else
1160 goto not_there;
1161#endif
1162 if (strEQ(name, "IXON"))
1163#ifdef IXON
1164 return IXON;
1165#else
1166 goto not_there;
1167#endif
1168 break;
1169 case 'L':
1170 if (strnEQ(name, "LC_", 3)) {
1171 if (strEQ(name, "LC_ALL"))
1172#ifdef LC_ALL
1173 return LC_ALL;
1174#else
1175 goto not_there;
1176#endif
1177 if (strEQ(name, "LC_COLLATE"))
1178#ifdef LC_COLLATE
1179 return LC_COLLATE;
1180#else
1181 goto not_there;
1182#endif
1183 if (strEQ(name, "LC_CTYPE"))
1184#ifdef LC_CTYPE
1185 return LC_CTYPE;
1186#else
1187 goto not_there;
1188#endif
1189 if (strEQ(name, "LC_MONETARY"))
1190#ifdef LC_MONETARY
1191 return LC_MONETARY;
1192#else
1193 goto not_there;
1194#endif
1195 if (strEQ(name, "LC_NUMERIC"))
1196#ifdef LC_NUMERIC
1197 return LC_NUMERIC;
1198#else
1199 goto not_there;
1200#endif
1201 if (strEQ(name, "LC_TIME"))
1202#ifdef LC_TIME
1203 return LC_TIME;
1204#else
1205 goto not_there;
1206#endif
1207 break;
1208 }
1209 if (strnEQ(name, "LDBL_", 5)) {
1210 if (strEQ(name, "LDBL_MAX"))
1211#ifdef LDBL_MAX
1212 return LDBL_MAX;
1213#else
1214 goto not_there;
1215#endif
1216 if (strEQ(name, "LDBL_MIN"))
1217#ifdef LDBL_MIN
1218 return LDBL_MIN;
1219#else
1220 goto not_there;
1221#endif
1222 if (strEQ(name, "LDBL_DIG"))
1223#ifdef LDBL_DIG
1224 return LDBL_DIG;
1225#else
1226 goto not_there;
1227#endif
1228 if (strEQ(name, "LDBL_EPSILON"))
1229#ifdef LDBL_EPSILON
1230 return LDBL_EPSILON;
1231#else
1232 goto not_there;
1233#endif
1234 if (strEQ(name, "LDBL_MANT_DIG"))
1235#ifdef LDBL_MANT_DIG
1236 return LDBL_MANT_DIG;
1237#else
1238 goto not_there;
1239#endif
1240 if (strEQ(name, "LDBL_MAX_10_EXP"))
1241#ifdef LDBL_MAX_10_EXP
1242 return LDBL_MAX_10_EXP;
1243#else
1244 goto not_there;
1245#endif
1246 if (strEQ(name, "LDBL_MAX_EXP"))
1247#ifdef LDBL_MAX_EXP
1248 return LDBL_MAX_EXP;
1249#else
1250 goto not_there;
1251#endif
1252 if (strEQ(name, "LDBL_MIN_10_EXP"))
1253#ifdef LDBL_MIN_10_EXP
1254 return LDBL_MIN_10_EXP;
1255#else
1256 goto not_there;
1257#endif
1258 if (strEQ(name, "LDBL_MIN_EXP"))
1259#ifdef LDBL_MIN_EXP
1260 return LDBL_MIN_EXP;
1261#else
1262 goto not_there;
1263#endif
1264 break;
1265 }
1266 if (strnEQ(name, "L_", 2)) {
1267 if (strEQ(name, "L_ctermid"))
1268#ifdef L_ctermid
1269 return L_ctermid;
1270#else
1271 goto not_there;
1272#endif
1273 if (strEQ(name, "L_cuserid"))
1274#ifdef L_cuserid
1275 return L_cuserid;
1276#else
1277 goto not_there;
1278#endif
1279 if (strEQ(name, "L_tmpname"))
1280#ifdef L_tmpname
1281 return L_tmpname;
1282#else
1283 goto not_there;
1284#endif
1285 break;
1286 }
1287 if (strEQ(name, "LONG_MAX"))
1288#ifdef LONG_MAX
1289 return LONG_MAX;
1290#else
1291 goto not_there;
1292#endif
1293 if (strEQ(name, "LONG_MIN"))
1294#ifdef LONG_MIN
1295 return LONG_MIN;
1296#else
1297 goto not_there;
1298#endif
1299 if (strEQ(name, "LINK_MAX"))
1300#ifdef LINK_MAX
1301 return LINK_MAX;
1302#else
1303 goto not_there;
1304#endif
1305 break;
1306 case 'M':
1307 if (strEQ(name, "MAX_CANON"))
1308#ifdef MAX_CANON
1309 return MAX_CANON;
1310#else
1311 goto not_there;
1312#endif
1313 if (strEQ(name, "MAX_INPUT"))
1314#ifdef MAX_INPUT
1315 return MAX_INPUT;
1316#else
1317 goto not_there;
1318#endif
1319 if (strEQ(name, "MB_CUR_MAX"))
1320#ifdef MB_CUR_MAX
1321 return MB_CUR_MAX;
1322#else
1323 goto not_there;
1324#endif
1325 if (strEQ(name, "MB_LEN_MAX"))
1326#ifdef MB_LEN_MAX
1327 return MB_LEN_MAX;
1328#else
1329 goto not_there;
1330#endif
1331 break;
1332 case 'N':
a0d0e21e 1333 if (strEQ(name, "NULL")) return 0;
2304df62
AD
1334 if (strEQ(name, "NAME_MAX"))
1335#ifdef NAME_MAX
1336 return NAME_MAX;
1337#else
1338 goto not_there;
1339#endif
1340 if (strEQ(name, "NCCS"))
1341#ifdef NCCS
1342 return NCCS;
1343#else
1344 goto not_there;
1345#endif
1346 if (strEQ(name, "NGROUPS_MAX"))
1347#ifdef NGROUPS_MAX
1348 return NGROUPS_MAX;
1349#else
1350 goto not_there;
1351#endif
1352 if (strEQ(name, "NOFLSH"))
1353#ifdef NOFLSH
1354 return NOFLSH;
1355#else
1356 goto not_there;
1357#endif
1358 break;
1359 case 'O':
1360 if (strnEQ(name, "O_", 2)) {
1361 if (strEQ(name, "O_APPEND"))
1362#ifdef O_APPEND
1363 return O_APPEND;
1364#else
1365 goto not_there;
1366#endif
1367 if (strEQ(name, "O_CREAT"))
1368#ifdef O_CREAT
1369 return O_CREAT;
1370#else
1371 goto not_there;
1372#endif
1373 if (strEQ(name, "O_TRUNC"))
1374#ifdef O_TRUNC
1375 return O_TRUNC;
1376#else
1377 goto not_there;
1378#endif
1379 if (strEQ(name, "O_RDONLY"))
1380#ifdef O_RDONLY
1381 return O_RDONLY;
1382#else
1383 goto not_there;
1384#endif
1385 if (strEQ(name, "O_RDWR"))
1386#ifdef O_RDWR
1387 return O_RDWR;
1388#else
1389 goto not_there;
1390#endif
1391 if (strEQ(name, "O_WRONLY"))
1392#ifdef O_WRONLY
1393 return O_WRONLY;
1394#else
1395 goto not_there;
1396#endif
1397 if (strEQ(name, "O_EXCL"))
1398#ifdef O_EXCL
1399 return O_EXCL;
1400#else
1401 goto not_there;
1402#endif
1403 if (strEQ(name, "O_NOCTTY"))
1404#ifdef O_NOCTTY
1405 return O_NOCTTY;
1406#else
1407 goto not_there;
1408#endif
1409 if (strEQ(name, "O_NONBLOCK"))
1410#ifdef O_NONBLOCK
1411 return O_NONBLOCK;
1412#else
1413 goto not_there;
1414#endif
1415 if (strEQ(name, "O_ACCMODE"))
1416#ifdef O_ACCMODE
1417 return O_ACCMODE;
1418#else
1419 goto not_there;
1420#endif
1421 break;
1422 }
1423 if (strEQ(name, "OPEN_MAX"))
1424#ifdef OPEN_MAX
1425 return OPEN_MAX;
1426#else
1427 goto not_there;
1428#endif
1429 if (strEQ(name, "OPOST"))
1430#ifdef OPOST
1431 return OPOST;
1432#else
1433 goto not_there;
1434#endif
1435 break;
1436 case 'P':
1437 if (strEQ(name, "PATH_MAX"))
1438#ifdef PATH_MAX
1439 return PATH_MAX;
1440#else
1441 goto not_there;
1442#endif
1443 if (strEQ(name, "PARENB"))
1444#ifdef PARENB
1445 return PARENB;
1446#else
1447 goto not_there;
1448#endif
1449 if (strEQ(name, "PARMRK"))
1450#ifdef PARMRK
1451 return PARMRK;
1452#else
1453 goto not_there;
1454#endif
1455 if (strEQ(name, "PARODD"))
1456#ifdef PARODD
1457 return PARODD;
1458#else
1459 goto not_there;
1460#endif
1461 if (strEQ(name, "PIPE_BUF"))
1462#ifdef PIPE_BUF
1463 return PIPE_BUF;
1464#else
1465 goto not_there;
1466#endif
1467 break;
1468 case 'R':
1469 if (strEQ(name, "RAND_MAX"))
1470#ifdef RAND_MAX
1471 return RAND_MAX;
1472#else
1473 goto not_there;
1474#endif
1475 if (strEQ(name, "R_OK"))
1476#ifdef R_OK
1477 return R_OK;
1478#else
1479 goto not_there;
1480#endif
1481 break;
1482 case 'S':
1483 if (strnEQ(name, "SIG", 3)) {
1484 if (name[3] == '_') {
1485 if (strEQ(name, "SIG_BLOCK"))
1486#ifdef SIG_BLOCK
1487 return SIG_BLOCK;
1488#else
1489 goto not_there;
1490#endif
1491#ifdef SIG_DFL
1492 if (strEQ(name, "SIG_DFL")) return (int)SIG_DFL;
1493#endif
1494#ifdef SIG_ERR
1495 if (strEQ(name, "SIG_ERR")) return (int)SIG_ERR;
1496#endif
1497#ifdef SIG_IGN
1498 if (strEQ(name, "SIG_IGN")) return (int)SIG_IGN;
1499#endif
1500 if (strEQ(name, "SIG_SETMASK"))
1501#ifdef SIG_SETMASK
1502 return SIG_SETMASK;
1503#else
1504 goto not_there;
1505#endif
1506 if (strEQ(name, "SIG_UNBLOCK"))
1507#ifdef SIG_UNBLOCK
1508 return SIG_UNBLOCK;
1509#else
1510 goto not_there;
1511#endif
1512 break;
1513 }
1514 if (strEQ(name, "SIGABRT"))
1515#ifdef SIGABRT
1516 return SIGABRT;
1517#else
1518 goto not_there;
1519#endif
1520 if (strEQ(name, "SIGALRM"))
1521#ifdef SIGALRM
1522 return SIGALRM;
1523#else
1524 goto not_there;
1525#endif
1526 if (strEQ(name, "SIGCHLD"))
1527#ifdef SIGCHLD
1528 return SIGCHLD;
1529#else
1530 goto not_there;
1531#endif
1532 if (strEQ(name, "SIGCONT"))
1533#ifdef SIGCONT
1534 return SIGCONT;
1535#else
1536 goto not_there;
1537#endif
1538 if (strEQ(name, "SIGFPE"))
1539#ifdef SIGFPE
1540 return SIGFPE;
1541#else
1542 goto not_there;
1543#endif
1544 if (strEQ(name, "SIGHUP"))
1545#ifdef SIGHUP
1546 return SIGHUP;
1547#else
1548 goto not_there;
1549#endif
1550 if (strEQ(name, "SIGILL"))
1551#ifdef SIGILL
1552 return SIGILL;
1553#else
1554 goto not_there;
1555#endif
1556 if (strEQ(name, "SIGINT"))
1557#ifdef SIGINT
1558 return SIGINT;
1559#else
1560 goto not_there;
1561#endif
1562 if (strEQ(name, "SIGKILL"))
1563#ifdef SIGKILL
1564 return SIGKILL;
1565#else
1566 goto not_there;
1567#endif
1568 if (strEQ(name, "SIGPIPE"))
1569#ifdef SIGPIPE
1570 return SIGPIPE;
1571#else
1572 goto not_there;
1573#endif
1574 if (strEQ(name, "SIGQUIT"))
1575#ifdef SIGQUIT
1576 return SIGQUIT;
1577#else
1578 goto not_there;
1579#endif
1580 if (strEQ(name, "SIGSEGV"))
1581#ifdef SIGSEGV
1582 return SIGSEGV;
1583#else
1584 goto not_there;
1585#endif
1586 if (strEQ(name, "SIGSTOP"))
1587#ifdef SIGSTOP
1588 return SIGSTOP;
1589#else
1590 goto not_there;
1591#endif
1592 if (strEQ(name, "SIGTERM"))
1593#ifdef SIGTERM
1594 return SIGTERM;
1595#else
1596 goto not_there;
1597#endif
1598 if (strEQ(name, "SIGTSTP"))
1599#ifdef SIGTSTP
1600 return SIGTSTP;
1601#else
1602 goto not_there;
1603#endif
1604 if (strEQ(name, "SIGTTIN"))
1605#ifdef SIGTTIN
1606 return SIGTTIN;
1607#else
1608 goto not_there;
1609#endif
1610 if (strEQ(name, "SIGTTOU"))
1611#ifdef SIGTTOU
1612 return SIGTTOU;
1613#else
1614 goto not_there;
1615#endif
1616 if (strEQ(name, "SIGUSR1"))
1617#ifdef SIGUSR1
1618 return SIGUSR1;
1619#else
1620 goto not_there;
1621#endif
1622 if (strEQ(name, "SIGUSR2"))
1623#ifdef SIGUSR2
1624 return SIGUSR2;
1625#else
1626 goto not_there;
1627#endif
1628 break;
1629 }
1630 if (name[1] == '_') {
2304df62
AD
1631 if (strEQ(name, "S_ISGID"))
1632#ifdef S_ISGID
1633 return S_ISGID;
1634#else
1635 goto not_there;
1636#endif
1637 if (strEQ(name, "S_ISUID"))
1638#ifdef S_ISUID
1639 return S_ISUID;
1640#else
1641 goto not_there;
1642#endif
1643 if (strEQ(name, "S_IRGRP"))
1644#ifdef S_IRGRP
1645 return S_IRGRP;
1646#else
1647 goto not_there;
1648#endif
1649 if (strEQ(name, "S_IROTH"))
1650#ifdef S_IROTH
1651 return S_IROTH;
1652#else
1653 goto not_there;
1654#endif
1655 if (strEQ(name, "S_IRUSR"))
1656#ifdef S_IRUSR
1657 return S_IRUSR;
1658#else
1659 goto not_there;
1660#endif
1661 if (strEQ(name, "S_IRWXG"))
1662#ifdef S_IRWXG
1663 return S_IRWXG;
1664#else
1665 goto not_there;
1666#endif
1667 if (strEQ(name, "S_IRWXO"))
1668#ifdef S_IRWXO
1669 return S_IRWXO;
1670#else
1671 goto not_there;
1672#endif
1673 if (strEQ(name, "S_IRWXU"))
1674#ifdef S_IRWXU
1675 return S_IRWXU;
1676#else
1677 goto not_there;
1678#endif
1679 if (strEQ(name, "S_IWGRP"))
1680#ifdef S_IWGRP
1681 return S_IWGRP;
1682#else
1683 goto not_there;
1684#endif
1685 if (strEQ(name, "S_IWOTH"))
1686#ifdef S_IWOTH
1687 return S_IWOTH;
1688#else
1689 goto not_there;
1690#endif
1691 if (strEQ(name, "S_IWUSR"))
1692#ifdef S_IWUSR
1693 return S_IWUSR;
1694#else
1695 goto not_there;
1696#endif
1697 if (strEQ(name, "S_IXGRP"))
1698#ifdef S_IXGRP
1699 return S_IXGRP;
1700#else
1701 goto not_there;
1702#endif
1703 if (strEQ(name, "S_IXOTH"))
1704#ifdef S_IXOTH
1705 return S_IXOTH;
1706#else
1707 goto not_there;
1708#endif
1709 if (strEQ(name, "S_IXUSR"))
1710#ifdef S_IXUSR
1711 return S_IXUSR;
1712#else
1713 goto not_there;
1714#endif
4633a7c4
LW
1715 errno = EAGAIN; /* the following aren't constants */
1716#ifdef S_ISBLK
1717 if (strEQ(name, "S_ISBLK")) return S_ISBLK(arg);
1718#endif
1719#ifdef S_ISCHR
1720 if (strEQ(name, "S_ISCHR")) return S_ISCHR(arg);
1721#endif
1722#ifdef S_ISDIR
1723 if (strEQ(name, "S_ISDIR")) return S_ISDIR(arg);
1724#endif
1725#ifdef S_ISFIFO
1726 if (strEQ(name, "S_ISFIFO")) return S_ISFIFO(arg);
1727#endif
1728#ifdef S_ISREG
1729 if (strEQ(name, "S_ISREG")) return S_ISREG(arg);
1730#endif
2304df62
AD
1731 break;
1732 }
1733 if (strEQ(name, "SEEK_CUR"))
1734#ifdef SEEK_CUR
1735 return SEEK_CUR;
1736#else
1737 goto not_there;
1738#endif
1739 if (strEQ(name, "SEEK_END"))
1740#ifdef SEEK_END
1741 return SEEK_END;
1742#else
1743 goto not_there;
1744#endif
1745 if (strEQ(name, "SEEK_SET"))
1746#ifdef SEEK_SET
1747 return SEEK_SET;
1748#else
1749 goto not_there;
1750#endif
1751 if (strEQ(name, "STREAM_MAX"))
1752#ifdef STREAM_MAX
1753 return STREAM_MAX;
1754#else
1755 goto not_there;
1756#endif
1757 if (strEQ(name, "SHRT_MAX"))
1758#ifdef SHRT_MAX
1759 return SHRT_MAX;
1760#else
1761 goto not_there;
1762#endif
1763 if (strEQ(name, "SHRT_MIN"))
1764#ifdef SHRT_MIN
1765 return SHRT_MIN;
1766#else
1767 goto not_there;
1768#endif
1769 if (strEQ(name, "SA_NOCLDSTOP"))
1770#ifdef SA_NOCLDSTOP
1771 return SA_NOCLDSTOP;
1772#else
1773 goto not_there;
1774#endif
1775 if (strEQ(name, "SCHAR_MAX"))
1776#ifdef SCHAR_MAX
1777 return SCHAR_MAX;
1778#else
1779 goto not_there;
1780#endif
1781 if (strEQ(name, "SCHAR_MIN"))
1782#ifdef SCHAR_MIN
1783 return SCHAR_MIN;
1784#else
1785 goto not_there;
1786#endif
1787 if (strEQ(name, "SSIZE_MAX"))
1788#ifdef SSIZE_MAX
1789 return SSIZE_MAX;
1790#else
1791 goto not_there;
1792#endif
1793 if (strEQ(name, "STDIN_FILENO"))
1794#ifdef STDIN_FILENO
1795 return STDIN_FILENO;
1796#else
1797 goto not_there;
1798#endif
1799 if (strEQ(name, "STDOUT_FILENO"))
1800#ifdef STDOUT_FILENO
1801 return STDOUT_FILENO;
1802#else
1803 goto not_there;
1804#endif
1805 if (strEQ(name, "STRERR_FILENO"))
1806#ifdef STRERR_FILENO
1807 return STRERR_FILENO;
1808#else
1809 goto not_there;
1810#endif
1811 break;
1812 case 'T':
1813 if (strEQ(name, "TCIFLUSH"))
1814#ifdef TCIFLUSH
1815 return TCIFLUSH;
1816#else
1817 goto not_there;
1818#endif
1819 if (strEQ(name, "TCIOFF"))
1820#ifdef TCIOFF
1821 return TCIOFF;
1822#else
1823 goto not_there;
1824#endif
1825 if (strEQ(name, "TCIOFLUSH"))
1826#ifdef TCIOFLUSH
1827 return TCIOFLUSH;
1828#else
1829 goto not_there;
1830#endif
1831 if (strEQ(name, "TCION"))
1832#ifdef TCION
1833 return TCION;
1834#else
1835 goto not_there;
1836#endif
1837 if (strEQ(name, "TCOFLUSH"))
1838#ifdef TCOFLUSH
1839 return TCOFLUSH;
1840#else
1841 goto not_there;
1842#endif
1843 if (strEQ(name, "TCOOFF"))
1844#ifdef TCOOFF
1845 return TCOOFF;
1846#else
1847 goto not_there;
1848#endif
1849 if (strEQ(name, "TCOON"))
1850#ifdef TCOON
1851 return TCOON;
1852#else
1853 goto not_there;
1854#endif
1855 if (strEQ(name, "TCSADRAIN"))
1856#ifdef TCSADRAIN
1857 return TCSADRAIN;
1858#else
1859 goto not_there;
1860#endif
1861 if (strEQ(name, "TCSAFLUSH"))
1862#ifdef TCSAFLUSH
1863 return TCSAFLUSH;
1864#else
1865 goto not_there;
1866#endif
1867 if (strEQ(name, "TCSANOW"))
1868#ifdef TCSANOW
1869 return TCSANOW;
1870#else
1871 goto not_there;
1872#endif
1873 if (strEQ(name, "TMP_MAX"))
1874#ifdef TMP_MAX
1875 return TMP_MAX;
1876#else
1877 goto not_there;
1878#endif
1879 if (strEQ(name, "TOSTOP"))
1880#ifdef TOSTOP
1881 return TOSTOP;
1882#else
1883 goto not_there;
1884#endif
1885 if (strEQ(name, "TZNAME_MAX"))
1886#ifdef TZNAME_MAX
1887 return TZNAME_MAX;
1888#else
1889 goto not_there;
1890#endif
1891 break;
1892 case 'U':
1893 if (strEQ(name, "UCHAR_MAX"))
1894#ifdef UCHAR_MAX
1895 return UCHAR_MAX;
1896#else
1897 goto not_there;
1898#endif
1899 if (strEQ(name, "UINT_MAX"))
1900#ifdef UINT_MAX
1901 return UINT_MAX;
1902#else
1903 goto not_there;
1904#endif
1905 if (strEQ(name, "ULONG_MAX"))
1906#ifdef ULONG_MAX
1907 return ULONG_MAX;
1908#else
1909 goto not_there;
1910#endif
1911 if (strEQ(name, "USHRT_MAX"))
1912#ifdef USHRT_MAX
1913 return USHRT_MAX;
1914#else
1915 goto not_there;
1916#endif
1917 break;
1918 case 'V':
1919 if (strEQ(name, "VEOF"))
1920#ifdef VEOF
1921 return VEOF;
1922#else
1923 goto not_there;
1924#endif
1925 if (strEQ(name, "VEOL"))
1926#ifdef VEOL
1927 return VEOL;
1928#else
1929 goto not_there;
1930#endif
1931 if (strEQ(name, "VERASE"))
1932#ifdef VERASE
1933 return VERASE;
1934#else
1935 goto not_there;
1936#endif
1937 if (strEQ(name, "VINTR"))
1938#ifdef VINTR
1939 return VINTR;
1940#else
1941 goto not_there;
1942#endif
1943 if (strEQ(name, "VKILL"))
1944#ifdef VKILL
1945 return VKILL;
1946#else
1947 goto not_there;
1948#endif
1949 if (strEQ(name, "VMIN"))
1950#ifdef VMIN
1951 return VMIN;
1952#else
1953 goto not_there;
1954#endif
1955 if (strEQ(name, "VQUIT"))
1956#ifdef VQUIT
1957 return VQUIT;
1958#else
1959 goto not_there;
1960#endif
1961 if (strEQ(name, "VSTART"))
1962#ifdef VSTART
1963 return VSTART;
1964#else
1965 goto not_there;
1966#endif
1967 if (strEQ(name, "VSTOP"))
1968#ifdef VSTOP
1969 return VSTOP;
1970#else
1971 goto not_there;
1972#endif
1973 if (strEQ(name, "VSUSP"))
1974#ifdef VSUSP
1975 return VSUSP;
1976#else
1977 goto not_there;
1978#endif
1979 if (strEQ(name, "VTIME"))
1980#ifdef VTIME
1981 return VTIME;
1982#else
1983 goto not_there;
1984#endif
1985 break;
1986 case 'W':
1987 if (strEQ(name, "W_OK"))
1988#ifdef W_OK
1989 return W_OK;
1990#else
1991 goto not_there;
1992#endif
4633a7c4
LW
1993 if (strEQ(name, "WNOHANG"))
1994#ifdef WNOHANG
1995 return WNOHANG;
1996#else
1997 goto not_there;
1998#endif
1999 if (strEQ(name, "WUNTRACED"))
2000#ifdef WUNTRACED
2001 return WUNTRACED;
2002#else
2003 goto not_there;
2004#endif
2005 errno = EAGAIN; /* the following aren't constants */
2304df62
AD
2006#ifdef WEXITSTATUS
2007 if (strEQ(name, "WEXITSTATUS")) return WEXITSTATUS(arg);
2008#endif
2009#ifdef WIFEXITED
2010 if (strEQ(name, "WIFEXITED")) return WIFEXITED(arg);
2011#endif
2012#ifdef WIFSIGNALED
2013 if (strEQ(name, "WIFSIGNALED")) return WIFSIGNALED(arg);
2014#endif
2015#ifdef WIFSTOPPED
2016 if (strEQ(name, "WIFSTOPPED")) return WIFSTOPPED(arg);
2017#endif
2304df62
AD
2018#ifdef WSTOPSIG
2019 if (strEQ(name, "WSTOPSIG")) return WSTOPSIG(arg);
2020#endif
2021#ifdef WTERMSIG
2022 if (strEQ(name, "WTERMSIG")) return WTERMSIG(arg);
2023#endif
2304df62
AD
2024 break;
2025 case 'X':
2026 if (strEQ(name, "X_OK"))
2027#ifdef X_OK
2028 return X_OK;
2029#else
2030 goto not_there;
2031#endif
2032 break;
2033 case '_':
2034 if (strnEQ(name, "_PC_", 4)) {
2035 if (strEQ(name, "_PC_CHOWN_RESTRICTED"))
2036#ifdef _PC_CHOWN_RESTRICTED
2037 return _PC_CHOWN_RESTRICTED;
2038#else
2039 goto not_there;
2040#endif
2041 if (strEQ(name, "_PC_LINK_MAX"))
2042#ifdef _PC_LINK_MAX
2043 return _PC_LINK_MAX;
2044#else
2045 goto not_there;
2046#endif
2047 if (strEQ(name, "_PC_MAX_CANON"))
2048#ifdef _PC_MAX_CANON
2049 return _PC_MAX_CANON;
2050#else
2051 goto not_there;
2052#endif
2053 if (strEQ(name, "_PC_MAX_INPUT"))
2054#ifdef _PC_MAX_INPUT
2055 return _PC_MAX_INPUT;
2056#else
2057 goto not_there;
2058#endif
2059 if (strEQ(name, "_PC_NAME_MAX"))
2060#ifdef _PC_NAME_MAX
2061 return _PC_NAME_MAX;
2062#else
2063 goto not_there;
2064#endif
2065 if (strEQ(name, "_PC_NO_TRUNC"))
2066#ifdef _PC_NO_TRUNC
2067 return _PC_NO_TRUNC;
2068#else
2069 goto not_there;
2070#endif
2071 if (strEQ(name, "_PC_PATH_MAX"))
2072#ifdef _PC_PATH_MAX
2073 return _PC_PATH_MAX;
2074#else
2075 goto not_there;
2076#endif
2077 if (strEQ(name, "_PC_PIPE_BUF"))
2078#ifdef _PC_PIPE_BUF
2079 return _PC_PIPE_BUF;
2080#else
2081 goto not_there;
2082#endif
2083 if (strEQ(name, "_PC_VDISABLE"))
2084#ifdef _PC_VDISABLE
2085 return _PC_VDISABLE;
2086#else
2087 goto not_there;
2088#endif
2089 break;
2090 }
2091 if (strnEQ(name, "_POSIX_", 7)) {
2092 if (strEQ(name, "_POSIX_ARG_MAX"))
2093#ifdef _POSIX_ARG_MAX
2094 return _POSIX_ARG_MAX;
2095#else
2096 return 0;
2097#endif
2098 if (strEQ(name, "_POSIX_CHILD_MAX"))
2099#ifdef _POSIX_CHILD_MAX
2100 return _POSIX_CHILD_MAX;
2101#else
2102 return 0;
2103#endif
2104 if (strEQ(name, "_POSIX_CHOWN_RESTRICTED"))
2105#ifdef _POSIX_CHOWN_RESTRICTED
2106 return _POSIX_CHOWN_RESTRICTED;
2107#else
2108 return 0;
2109#endif
2110 if (strEQ(name, "_POSIX_JOB_CONTROL"))
2111#ifdef _POSIX_JOB_CONTROL
2112 return _POSIX_JOB_CONTROL;
2113#else
2114 return 0;
2115#endif
2116 if (strEQ(name, "_POSIX_LINK_MAX"))
2117#ifdef _POSIX_LINK_MAX
2118 return _POSIX_LINK_MAX;
2119#else
2120 return 0;
2121#endif
2122 if (strEQ(name, "_POSIX_MAX_CANON"))
2123#ifdef _POSIX_MAX_CANON
2124 return _POSIX_MAX_CANON;
2125#else
2126 return 0;
2127#endif
2128 if (strEQ(name, "_POSIX_MAX_INPUT"))
2129#ifdef _POSIX_MAX_INPUT
2130 return _POSIX_MAX_INPUT;
2131#else
2132 return 0;
2133#endif
2134 if (strEQ(name, "_POSIX_NAME_MAX"))
2135#ifdef _POSIX_NAME_MAX
2136 return _POSIX_NAME_MAX;
2137#else
2138 return 0;
2139#endif
2140 if (strEQ(name, "_POSIX_NGROUPS_MAX"))
2141#ifdef _POSIX_NGROUPS_MAX
2142 return _POSIX_NGROUPS_MAX;
2143#else
2144 return 0;
2145#endif
2146 if (strEQ(name, "_POSIX_NO_TRUNC"))
2147#ifdef _POSIX_NO_TRUNC
2148 return _POSIX_NO_TRUNC;
2149#else
2150 return 0;
2151#endif
2152 if (strEQ(name, "_POSIX_OPEN_MAX"))
2153#ifdef _POSIX_OPEN_MAX
2154 return _POSIX_OPEN_MAX;
2155#else
2156 return 0;
2157#endif
2158 if (strEQ(name, "_POSIX_PATH_MAX"))
2159#ifdef _POSIX_PATH_MAX
2160 return _POSIX_PATH_MAX;
2161#else
2162 return 0;
2163#endif
2164 if (strEQ(name, "_POSIX_PIPE_BUF"))
2165#ifdef _POSIX_PIPE_BUF
2166 return _POSIX_PIPE_BUF;
2167#else
2168 return 0;
2169#endif
2170 if (strEQ(name, "_POSIX_SAVED_IDS"))
2171#ifdef _POSIX_SAVED_IDS
2172 return _POSIX_SAVED_IDS;
2173#else
2174 return 0;
2175#endif
2176 if (strEQ(name, "_POSIX_SSIZE_MAX"))
2177#ifdef _POSIX_SSIZE_MAX
2178 return _POSIX_SSIZE_MAX;
2179#else
2180 return 0;
2181#endif
2182 if (strEQ(name, "_POSIX_STREAM_MAX"))
2183#ifdef _POSIX_STREAM_MAX
2184 return _POSIX_STREAM_MAX;
2185#else
2186 return 0;
2187#endif
2188 if (strEQ(name, "_POSIX_TZNAME_MAX"))
2189#ifdef _POSIX_TZNAME_MAX
2190 return _POSIX_TZNAME_MAX;
2191#else
2192 return 0;
2193#endif
2194 if (strEQ(name, "_POSIX_VDISABLE"))
2195#ifdef _POSIX_VDISABLE
2196 return _POSIX_VDISABLE;
2197#else
2198 return 0;
2199#endif
2200 if (strEQ(name, "_POSIX_VERSION"))
2201#ifdef _POSIX_VERSION
2202 return _POSIX_VERSION;
2203#else
2204 return 0;
2205#endif
2206 break;
2207 }
2208 if (strnEQ(name, "_SC_", 4)) {
2209 if (strEQ(name, "_SC_ARG_MAX"))
2210#ifdef _SC_ARG_MAX
2211 return _SC_ARG_MAX;
2212#else
2213 goto not_there;
2214#endif
2215 if (strEQ(name, "_SC_CHILD_MAX"))
2216#ifdef _SC_CHILD_MAX
2217 return _SC_CHILD_MAX;
2218#else
2219 goto not_there;
2220#endif
2221 if (strEQ(name, "_SC_CLK_TCK"))
2222#ifdef _SC_CLK_TCK
2223 return _SC_CLK_TCK;
2224#else
2225 goto not_there;
2226#endif
2227 if (strEQ(name, "_SC_JOB_CONTROL"))
2228#ifdef _SC_JOB_CONTROL
2229 return _SC_JOB_CONTROL;
2230#else
2231 goto not_there;
2232#endif
2233 if (strEQ(name, "_SC_NGROUPS_MAX"))
2234#ifdef _SC_NGROUPS_MAX
2235 return _SC_NGROUPS_MAX;
2236#else
2237 goto not_there;
2238#endif
2239 if (strEQ(name, "_SC_OPEN_MAX"))
2240#ifdef _SC_OPEN_MAX
2241 return _SC_OPEN_MAX;
2242#else
2243 goto not_there;
2244#endif
2245 if (strEQ(name, "_SC_SAVED_IDS"))
2246#ifdef _SC_SAVED_IDS
2247 return _SC_SAVED_IDS;
2248#else
2249 goto not_there;
2250#endif
2251 if (strEQ(name, "_SC_STREAM_MAX"))
2252#ifdef _SC_STREAM_MAX
2253 return _SC_STREAM_MAX;
2254#else
2255 goto not_there;
2256#endif
2257 if (strEQ(name, "_SC_TZNAME_MAX"))
2258#ifdef _SC_TZNAME_MAX
2259 return _SC_TZNAME_MAX;
2260#else
2261 goto not_there;
2262#endif
2263 if (strEQ(name, "_SC_VERSION"))
2264#ifdef _SC_VERSION
2265 return _SC_VERSION;
2266#else
2267 goto not_there;
2268#endif
2269 break;
2270 }
2304df62
AD
2271 }
2272 errno = EINVAL;
2273 return 0;
2274
2275not_there:
2276 errno = ENOENT;
2277 return 0;
2278}
2279
2280MODULE = SigSet PACKAGE = POSIX::SigSet PREFIX = sig
2281
2282POSIX::SigSet
2283new(packname = "POSIX::SigSet", ...)
2284 char * packname
2285 CODE:
2286 {
2287 int i;
2288 RETVAL = (sigset_t*)safemalloc(sizeof(sigset_t));
2289 sigemptyset(RETVAL);
a0d0e21e 2290 for (i = 1; i < items; i++)
2304df62
AD
2291 sigaddset(RETVAL, SvIV(ST(i)));
2292 }
2293 OUTPUT:
2294 RETVAL
463ee0b2 2295
8990e307 2296void
2304df62
AD
2297DESTROY(sigset)
2298 POSIX::SigSet sigset
2299 CODE:
a0d0e21e 2300 safefree((char *)sigset);
2304df62
AD
2301
2302SysRet
2303sigaddset(sigset, sig)
2304 POSIX::SigSet sigset
2305 int sig
2306
2307SysRet
2308sigdelset(sigset, sig)
2309 POSIX::SigSet sigset
2310 int sig
2311
2312SysRet
2313sigemptyset(sigset)
2314 POSIX::SigSet sigset
2315
2316SysRet
2317sigfillset(sigset)
2318 POSIX::SigSet sigset
2319
2320int
2321sigismember(sigset, sig)
2322 POSIX::SigSet sigset
2323 int sig
2324
2325
a0d0e21e
LW
2326MODULE = Termios PACKAGE = POSIX::Termios PREFIX = cf
2327
2328POSIX::Termios
2329new(packname = "POSIX::Termios", ...)
2330 char * packname
2331 CODE:
2332 {
2333#ifdef I_TERMIOS
2334 RETVAL = (struct termios*)safemalloc(sizeof(struct termios));
2335#else
2336 not_here("termios");
2337#endif
2338 }
2339 OUTPUT:
2340 RETVAL
2341
2342void
2343DESTROY(termios_ref)
2344 POSIX::Termios termios_ref
2345 CODE:
2346#ifdef I_TERMIOS
2347 safefree((char *)termios_ref);
2348#else
2349 not_here("termios");
2350#endif
2351
2352SysRet
2353getattr(termios_ref, fd = 0)
2354 POSIX::Termios termios_ref
2355 int fd
2356 CODE:
2357 RETVAL = tcgetattr(fd, termios_ref);
2358 OUTPUT:
2359 RETVAL
2360
2361SysRet
2362setattr(termios_ref, fd = 0, optional_actions = 0)
2363 POSIX::Termios termios_ref
2364 int fd
2365 int optional_actions
2366 CODE:
2367 RETVAL = tcsetattr(fd, optional_actions, termios_ref);
2368 OUTPUT:
2369 RETVAL
2370
2371speed_t
2372cfgetispeed(termios_ref)
2373 POSIX::Termios termios_ref
2374
2375speed_t
2376cfgetospeed(termios_ref)
2377 POSIX::Termios termios_ref
2378
2379tcflag_t
2380getiflag(termios_ref)
2381 POSIX::Termios termios_ref
2382 CODE:
2383#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2384 RETVAL = termios_ref->c_iflag;
2385#else
2386 not_here("getiflag");
2387#endif
2388 OUTPUT:
2389 RETVAL
2390
2391tcflag_t
2392getoflag(termios_ref)
2393 POSIX::Termios termios_ref
2394 CODE:
2395#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2396 RETVAL = termios_ref->c_oflag;
2397#else
2398 not_here("getoflag");
2399#endif
2400 OUTPUT:
2401 RETVAL
2402
2403tcflag_t
2404getcflag(termios_ref)
2405 POSIX::Termios termios_ref
2406 CODE:
2407#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2408 RETVAL = termios_ref->c_cflag;
2409#else
2410 not_here("getcflag");
2411#endif
2412 OUTPUT:
2413 RETVAL
2414
2415tcflag_t
2416getlflag(termios_ref)
2417 POSIX::Termios termios_ref
2418 CODE:
2419#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2420 RETVAL = termios_ref->c_lflag;
2421#else
2422 not_here("getlflag");
2423#endif
2424 OUTPUT:
2425 RETVAL
2426
2427cc_t
2428getcc(termios_ref, ccix)
2429 POSIX::Termios termios_ref
2430 int ccix
2431 CODE:
2432#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2433 if (ccix >= NCCS)
2434 croak("Bad getcc subscript");
2435 RETVAL = termios_ref->c_cc[ccix];
2436#else
2437 not_here("getcc");
2438#endif
2439 OUTPUT:
2440 RETVAL
2441
2442SysRet
2443cfsetispeed(termios_ref, speed)
2444 POSIX::Termios termios_ref
2445 speed_t speed
2446
2447SysRet
2448cfsetospeed(termios_ref, speed)
2449 POSIX::Termios termios_ref
2450 speed_t speed
2451
2452void
2453setiflag(termios_ref, iflag)
2454 POSIX::Termios termios_ref
2455 tcflag_t iflag
2456 CODE:
2457#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2458 termios_ref->c_iflag = iflag;
2459#else
2460 not_here("setiflag");
2461#endif
2462
2463void
2464setoflag(termios_ref, oflag)
2465 POSIX::Termios termios_ref
2466 tcflag_t oflag
2467 CODE:
2468#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2469 termios_ref->c_oflag = oflag;
2470#else
2471 not_here("setoflag");
2472#endif
2473
2474void
2475setcflag(termios_ref, cflag)
2476 POSIX::Termios termios_ref
2477 tcflag_t cflag
2478 CODE:
2479#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2480 termios_ref->c_cflag = cflag;
2481#else
2482 not_here("setcflag");
2483#endif
2484
2485void
2486setlflag(termios_ref, lflag)
2487 POSIX::Termios termios_ref
2488 tcflag_t lflag
2489 CODE:
2490#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2491 termios_ref->c_lflag = lflag;
2492#else
2493 not_here("setlflag");
2494#endif
2495
2496void
2497setcc(termios_ref, ccix, cc)
2498 POSIX::Termios termios_ref
2499 int ccix
2500 cc_t cc
2501 CODE:
2502#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2503 if (ccix >= NCCS)
2504 croak("Bad setcc subscript");
2505 termios_ref->c_cc[ccix] = cc;
2506#else
2507 not_here("setcc");
2508#endif
2509
2510
a0d0e21e
LW
2511MODULE = POSIX PACKAGE = POSIX
2512
2513double
2304df62
AD
2514constant(name,arg)
2515 char * name
2516 int arg
2517
2518int
2519isalnum(charstring)
2520 char * charstring
2521 CODE:
2522 char *s;
2523 RETVAL = 1;
85e6fe83 2524 for (s = charstring; *s && RETVAL; s++)
2304df62
AD
2525 if (!isalnum(*s))
2526 RETVAL = 0;
2527 OUTPUT:
2528 RETVAL
2529
2530int
2531isalpha(charstring)
2532 char * charstring
2533 CODE:
2534 char *s;
2535 RETVAL = 1;
85e6fe83 2536 for (s = charstring; *s && RETVAL; s++)
2304df62
AD
2537 if (!isalpha(*s))
2538 RETVAL = 0;
2539 OUTPUT:
2540 RETVAL
2541
2542int
2543iscntrl(charstring)
2544 char * charstring
2545 CODE:
2546 char *s;
2547 RETVAL = 1;
85e6fe83 2548 for (s = charstring; *s && RETVAL; s++)
2304df62
AD
2549 if (!iscntrl(*s))
2550 RETVAL = 0;
2551 OUTPUT:
2552 RETVAL
2553
2554int
2555isdigit(charstring)
2556 char * charstring
2557 CODE:
2558 char *s;
2559 RETVAL = 1;
85e6fe83 2560 for (s = charstring; *s && RETVAL; s++)
2304df62
AD
2561 if (!isdigit(*s))
2562 RETVAL = 0;
2563 OUTPUT:
2564 RETVAL
2565
2566int
2567isgraph(charstring)
2568 char * charstring
2569 CODE:
2570 char *s;
2571 RETVAL = 1;
85e6fe83 2572 for (s = charstring; *s && RETVAL; s++)
2304df62
AD
2573 if (!isgraph(*s))
2574 RETVAL = 0;
2575 OUTPUT:
2576 RETVAL
2577
2578int
2579islower(charstring)
2580 char * charstring
2581 CODE:
2582 char *s;
2583 RETVAL = 1;
85e6fe83 2584 for (s = charstring; *s && RETVAL; s++)
2304df62
AD
2585 if (!islower(*s))
2586 RETVAL = 0;
2587 OUTPUT:
2588 RETVAL
2589
2590int
2591isprint(charstring)
2592 char * charstring
2593 CODE:
2594 char *s;
2595 RETVAL = 1;
85e6fe83 2596 for (s = charstring; *s && RETVAL; s++)
2304df62
AD
2597 if (!isprint(*s))
2598 RETVAL = 0;
2599 OUTPUT:
2600 RETVAL
2601
2602int
2603ispunct(charstring)
2604 char * charstring
2605 CODE:
2606 char *s;
2607 RETVAL = 1;
85e6fe83 2608 for (s = charstring; *s && RETVAL; s++)
2304df62
AD
2609 if (!ispunct(*s))
2610 RETVAL = 0;
2611 OUTPUT:
2612 RETVAL
2613
2614int
2615isspace(charstring)
2616 char * charstring
2617 CODE:
2618 char *s;
2619 RETVAL = 1;
85e6fe83 2620 for (s = charstring; *s && RETVAL; s++)
2304df62
AD
2621 if (!isspace(*s))
2622 RETVAL = 0;
2623 OUTPUT:
2624 RETVAL
8990e307
LW
2625
2626int
2304df62
AD
2627isupper(charstring)
2628 char * charstring
2629 CODE:
2630 char *s;
2631 RETVAL = 1;
85e6fe83 2632 for (s = charstring; *s && RETVAL; s++)
2304df62
AD
2633 if (!isupper(*s))
2634 RETVAL = 0;
2635 OUTPUT:
2636 RETVAL
8990e307
LW
2637
2638int
2304df62
AD
2639isxdigit(charstring)
2640 char * charstring
2641 CODE:
2642 char *s;
2643 RETVAL = 1;
85e6fe83 2644 for (s = charstring; *s && RETVAL; s++)
2304df62
AD
2645 if (!isxdigit(*s))
2646 RETVAL = 0;
2647 OUTPUT:
2648 RETVAL
2649
2650SysRet
2651open(filename, flags = O_RDONLY, mode = 0666)
2652 char * filename
2653 int flags
a0d0e21e 2654 Mode_t mode
748a9306
LW
2655 CODE:
2656 if (flags & (O_APPEND|O_CREAT|O_TRUNC|O_RDWR|O_WRONLY|O_EXCL))
2657 TAINT_PROPER("open");
2658 RETVAL = open(filename, flags, mode);
2659 OUTPUT:
2660 RETVAL
2661
2304df62
AD
2662
2663HV *
2664localeconv()
2665 CODE:
a0d0e21e 2666#ifdef HAS_LOCALECONV
2304df62
AD
2667 struct lconv *lcbuf;
2668 RETVAL = newHV();
2669 if (lcbuf = localeconv()) {
2670 /* the strings */
2671 if (lcbuf->decimal_point && *lcbuf->decimal_point)
2672 hv_store(RETVAL, "decimal_point", 13,
2673 newSVpv(lcbuf->decimal_point, 0), 0);
2674 if (lcbuf->thousands_sep && *lcbuf->thousands_sep)
2675 hv_store(RETVAL, "thousands_sep", 13,
2676 newSVpv(lcbuf->thousands_sep, 0), 0);
2677 if (lcbuf->grouping && *lcbuf->grouping)
2678 hv_store(RETVAL, "grouping", 8,
2679 newSVpv(lcbuf->grouping, 0), 0);
2680 if (lcbuf->int_curr_symbol && *lcbuf->int_curr_symbol)
2681 hv_store(RETVAL, "int_curr_symbol", 15,
2682 newSVpv(lcbuf->int_curr_symbol, 0), 0);
2683 if (lcbuf->currency_symbol && *lcbuf->currency_symbol)
2684 hv_store(RETVAL, "currency_symbol", 15,
2685 newSVpv(lcbuf->currency_symbol, 0), 0);
2686 if (lcbuf->mon_decimal_point && *lcbuf->mon_decimal_point)
2687 hv_store(RETVAL, "mon_decimal_point", 17,
2688 newSVpv(lcbuf->mon_decimal_point, 0), 0);
2689 if (lcbuf->mon_thousands_sep && *lcbuf->mon_thousands_sep)
2690 hv_store(RETVAL, "mon_thousands_sep", 17,
2691 newSVpv(lcbuf->mon_thousands_sep, 0), 0);
2692 if (lcbuf->mon_grouping && *lcbuf->mon_grouping)
2693 hv_store(RETVAL, "mon_grouping", 12,
2694 newSVpv(lcbuf->mon_grouping, 0), 0);
2695 if (lcbuf->positive_sign && *lcbuf->positive_sign)
2696 hv_store(RETVAL, "positive_sign", 13,
2697 newSVpv(lcbuf->positive_sign, 0), 0);
2698 if (lcbuf->negative_sign && *lcbuf->negative_sign)
2699 hv_store(RETVAL, "negative_sign", 13,
2700 newSVpv(lcbuf->negative_sign, 0), 0);
2701 /* the integers */
2702 if (lcbuf->int_frac_digits != CHAR_MAX)
2703 hv_store(RETVAL, "int_frac_digits", 15,
2704 newSViv(lcbuf->int_frac_digits), 0);
2705 if (lcbuf->frac_digits != CHAR_MAX)
2706 hv_store(RETVAL, "frac_digits", 11,
2707 newSViv(lcbuf->frac_digits), 0);
2708 if (lcbuf->p_cs_precedes != CHAR_MAX)
2709 hv_store(RETVAL, "p_cs_precedes", 13,
2710 newSViv(lcbuf->p_cs_precedes), 0);
2711 if (lcbuf->p_sep_by_space != CHAR_MAX)
2712 hv_store(RETVAL, "p_sep_by_space", 14,
2713 newSViv(lcbuf->p_sep_by_space), 0);
2714 if (lcbuf->n_cs_precedes != CHAR_MAX)
2715 hv_store(RETVAL, "n_cs_precedes", 13,
2716 newSViv(lcbuf->n_cs_precedes), 0);
2717 if (lcbuf->n_sep_by_space != CHAR_MAX)
2718 hv_store(RETVAL, "n_sep_by_space", 14,
2719 newSViv(lcbuf->n_sep_by_space), 0);
2720 if (lcbuf->p_sign_posn != CHAR_MAX)
2721 hv_store(RETVAL, "p_sign_posn", 11,
2722 newSViv(lcbuf->p_sign_posn), 0);
2723 if (lcbuf->n_sign_posn != CHAR_MAX)
2724 hv_store(RETVAL, "n_sign_posn", 11,
2725 newSViv(lcbuf->n_sign_posn), 0);
2726 }
a0d0e21e
LW
2727#else
2728 localeconv(); /* A stub to call not_here(). */
2729#endif
2304df62
AD
2730 OUTPUT:
2731 RETVAL
2732
2733char *
c28ee57b 2734setlocale(category, locale = 0)
2304df62
AD
2735 int category
2736 char * locale
c28ee57b
JH
2737 CODE:
2738 RETVAL = setlocale(category, locale);
2739 if (RETVAL)
2740 perl_init_fold();
2741 OUTPUT:
2742 RETVAL
2743
2304df62
AD
2744
2745double
2746acos(x)
2747 double x
2748
2749double
2750asin(x)
2751 double x
2752
2753double
2754atan(x)
2755 double x
2756
2757double
2758ceil(x)
2759 double x
2760
2761double
2762cosh(x)
2763 double x
2764
2765double
2766floor(x)
2767 double x
2768
2769double
2770fmod(x,y)
2771 double x
2772 double y
2773
2774void
2775frexp(x)
2776 double x
2777 PPCODE:
2778 int expvar;
2304df62
AD
2779 /* (We already know stack is long enough.) */
2780 PUSHs(sv_2mortal(newSVnv(frexp(x,&expvar))));
2781 PUSHs(sv_2mortal(newSViv(expvar)));
2782
2783double
2784ldexp(x,exp)
2785 double x
2786 int exp
2787
2788double
2789log10(x)
2790 double x
2791
2792void
2793modf(x)
2794 double x
2795 PPCODE:
2796 double intvar;
2304df62
AD
2797 /* (We already know stack is long enough.) */
2798 PUSHs(sv_2mortal(newSVnv(modf(x,&intvar))));
2799 PUSHs(sv_2mortal(newSVnv(intvar)));
2800
2801double
2802sinh(x)
2803 double x
2804
2805double
3b35bae3
AD
2806tan(x)
2807 double x
2808
2809double
2304df62
AD
2810tanh(x)
2811 double x
2812
2813SysRet
2814sigaction(sig, action, oldaction = 0)
2815 int sig
2816 POSIX::SigAction action
2817 POSIX::SigAction oldaction
2818 CODE:
2819
2820# This code is really grody because we're trying to make the signal
2821# interface look beautiful, which is hard.
2822
2823 if (!siggv)
85e6fe83 2824 gv_fetchpv("SIG", TRUE, SVt_PVHV);
2304df62
AD
2825
2826 {
2827 struct sigaction act;
2828 struct sigaction oact;
2829 POSIX__SigSet sigset;
2830 SV** svp;
2831 SV** sigsvp = hv_fetch(GvHVn(siggv),
4633a7c4
LW
2832 sig_name[sig],
2833 strlen(sig_name[sig]),
2304df62
AD
2834 TRUE);
2835
2836 /* Remember old handler name if desired. */
2837 if (oldaction) {
2838 char *hand = SvPVx(*sigsvp, na);
2839 svp = hv_fetch(oldaction, "HANDLER", 7, TRUE);
2840 sv_setpv(*svp, *hand ? hand : "DEFAULT");
2841 }
2842
2843 if (action) {
2844 /* Vector new handler through %SIG. (We always use sighandler
2845 for the C signal handler, which reads %SIG to dispatch.) */
2846 svp = hv_fetch(action, "HANDLER", 7, FALSE);
2847 if (!svp)
2848 croak("Can't supply an action without a HANDLER");
2849 sv_setpv(*sigsvp, SvPV(*svp, na));
2850 mg_set(*sigsvp); /* handles DEFAULT and IGNORE */
2851 act.sa_handler = sighandler;
2852
2853 /* Set up any desired mask. */
2854 svp = hv_fetch(action, "MASK", 4, FALSE);
2855 if (svp && sv_isa(*svp, "POSIX::SigSet")) {
a0d0e21e
LW
2856 unsigned long tmp;
2857 tmp = (unsigned long)SvNV((SV*)SvRV(*svp));
2858 sigset = (sigset_t*) tmp;
2304df62
AD
2859 act.sa_mask = *sigset;
2860 }
2861 else
85e6fe83 2862 sigemptyset(& act.sa_mask);
2304df62
AD
2863
2864 /* Set up any desired flags. */
2865 svp = hv_fetch(action, "FLAGS", 5, FALSE);
2866 act.sa_flags = svp ? SvIV(*svp) : 0;
2867 }
2868
2869 /* Now work around sigaction oddities */
2870 if (action && oldaction)
85e6fe83 2871 RETVAL = sigaction(sig, & act, & oact);
2304df62 2872 else if (action)
6c418a22 2873 RETVAL = sigaction(sig, & act, (struct sigaction *)0);
2304df62 2874 else if (oldaction)
6c418a22 2875 RETVAL = sigaction(sig, (struct sigaction *)0, & oact);
a0d0e21e
LW
2876 else
2877 RETVAL = -1;
2304df62
AD
2878
2879 if (oldaction) {
2880 /* Get back the mask. */
2881 svp = hv_fetch(oldaction, "MASK", 4, TRUE);
a0d0e21e
LW
2882 if (sv_isa(*svp, "POSIX::SigSet")) {
2883 unsigned long tmp;
2884 tmp = (unsigned long)SvNV((SV*)SvRV(*svp));
2885 sigset = (sigset_t*) tmp;
2886 }
2304df62
AD
2887 else {
2888 sigset = (sigset_t*)safemalloc(sizeof(sigset_t));
2889 sv_setptrobj(*svp, sigset, "POSIX::SigSet");
2890 }
2891 *sigset = oact.sa_mask;
2892
2893 /* Get back the flags. */
2894 svp = hv_fetch(oldaction, "FLAGS", 5, TRUE);
2895 sv_setiv(*svp, oact.sa_flags);
2896 }
2897 }
2898 OUTPUT:
2899 RETVAL
2900
2901SysRet
2902sigpending(sigset)
2903 POSIX::SigSet sigset
2904
2905SysRet
2906sigprocmask(how, sigset, oldsigset = 0)
2907 int how
2908 POSIX::SigSet sigset
2909 POSIX::SigSet oldsigset
2910
2911SysRet
2912sigsuspend(signal_mask)
2913 POSIX::SigSet signal_mask
2914
2304df62
AD
2915void
2916_exit(status)
2917 int status
8990e307 2918
85e6fe83 2919SysRet
8990e307
LW
2920close(fd)
2921 int fd
2922
85e6fe83 2923SysRet
8990e307
LW
2924dup(fd)
2925 int fd
2926
85e6fe83 2927SysRet
8990e307
LW
2928dup2(fd1, fd2)
2929 int fd1
2930 int fd2
2931
94b6baf5 2932SysRetLong
a0d0e21e 2933lseek(fd, offset, whence)
85e6fe83
LW
2934 int fd
2935 Off_t offset
2936 int whence
8990e307 2937
85e6fe83 2938SysRet
8990e307
LW
2939nice(incr)
2940 int incr
2941
2942int
8990e307 2943pipe()
85e6fe83
LW
2944 PPCODE:
2945 int fds[2];
85e6fe83
LW
2946 if (pipe(fds) != -1) {
2947 EXTEND(sp,2);
2948 PUSHs(sv_2mortal(newSViv(fds[0])));
2949 PUSHs(sv_2mortal(newSViv(fds[1])));
2950 }
8990e307 2951
85e6fe83 2952SysRet
a0d0e21e 2953read(fd, buffer, nbytes)
7747499c
TB
2954 PREINIT:
2955 SV *sv_buffer = SvROK(ST(1)) ? SvRV(ST(1)) : ST(1);
2956 INPUT:
2957 int fd
2958 size_t nbytes
2959 char * buffer = sv_grow( sv_buffer, nbytes+1 );
a0d0e21e 2960 CLEANUP:
7747499c
TB
2961 if (RETVAL >= 0) {
2962 SvCUR(sv_buffer) = RETVAL;
2963 SvPOK_only(sv_buffer);
2964 *SvEND(sv_buffer) = '\0';
2965 if (tainting)
2966 sv_magic(sv_buffer, 0, 't', 0, 0);
2967 }
8990e307 2968
85e6fe83 2969SysRet
8990e307
LW
2970setpgid(pid, pgid)
2971 pid_t pid
2972 pid_t pgid
2973
8990e307
LW
2974pid_t
2975setsid()
2976
8990e307
LW
2977pid_t
2978tcgetpgrp(fd)
2979 int fd
2980
85e6fe83 2981SysRet
8990e307
LW
2982tcsetpgrp(fd, pgrp_id)
2983 int fd
2984 pid_t pgrp_id
2985
2986int
8990e307 2987uname()
2304df62 2988 PPCODE:
a0d0e21e 2989#ifdef HAS_UNAME
85e6fe83 2990 struct utsname buf;
85e6fe83 2991 if (uname(&buf) >= 0) {
8990e307 2992 EXTEND(sp, 5);
85e6fe83
LW
2993 PUSHs(sv_2mortal(newSVpv(buf.sysname, 0)));
2994 PUSHs(sv_2mortal(newSVpv(buf.nodename, 0)));
2995 PUSHs(sv_2mortal(newSVpv(buf.release, 0)));
2996 PUSHs(sv_2mortal(newSVpv(buf.version, 0)));
2997 PUSHs(sv_2mortal(newSVpv(buf.machine, 0)));
8990e307 2998 }
a0d0e21e
LW
2999#else
3000 uname((char *) 0); /* A stub to call not_here(). */
3001#endif
8990e307 3002
85e6fe83 3003SysRet
a0d0e21e
LW
3004write(fd, buffer, nbytes)
3005 int fd
3006 char * buffer
3007 size_t nbytes
3008
3009char *
3010tmpnam(s = 0)
3011 char * s = 0;
3012
3013void
3014abort()
3015
3016int
3017mblen(s, n)
3018 char * s
3019 size_t n
3020
3021size_t
3022mbstowcs(s, pwcs, n)
3023 wchar_t * s
3024 char * pwcs
3025 size_t n
3026
3027int
3028mbtowc(pwc, s, n)
3029 wchar_t * pwc
3030 char * s
3031 size_t n
3032
3033int
3034wcstombs(s, pwcs, n)
3035 char * s
3036 wchar_t * pwcs
3037 size_t n
3038
3039int
3040wctomb(s, wchar)
3041 char * s
3042 wchar_t wchar
3043
3044int
3045strcoll(s1, s2)
3046 char * s1
3047 char * s2
3048
a89d8a78
DH
3049void
3050strtod(str)
3051 char * str
3052 PREINIT:
3053 double num;
3054 char *unparsed;
3055 PPCODE:
3056 num = strtod(str, &unparsed);
3057 PUSHs(sv_2mortal(newSVnv(num)));
3058 if (GIMME == G_ARRAY) {
3059 EXTEND(sp, 1);
3060 if (unparsed)
3061 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3062 else
3063 PUSHs(&sv_undef);
3064 }
3065
3066void
3067strtol(str, base = 0)
3068 char * str
3069 int base
3070 PREINIT:
3071 long num;
3072 char *unparsed;
3073 PPCODE:
3074 num = strtol(str, &unparsed, base);
3075 if (num >= IV_MIN && num <= IV_MAX)
3076 PUSHs(sv_2mortal(newSViv((IV)num)));
3077 else
3078 PUSHs(sv_2mortal(newSVnv((double)num)));
3079 if (GIMME == G_ARRAY) {
3080 EXTEND(sp, 1);
3081 if (unparsed)
3082 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3083 else
3084 PUSHs(&sv_undef);
3085 }
3086
3087void
3088strtoul(str, base = 0)
3089 char * str
3090 int base
3091 PREINIT:
3092 unsigned long num;
3093 char *unparsed;
3094 PPCODE:
3095 num = strtoul(str, &unparsed, base);
3096 if (num <= IV_MAX)
3097 PUSHs(sv_2mortal(newSViv((IV)num)));
3098 else
3099 PUSHs(sv_2mortal(newSVnv((double)num)));
3100 if (GIMME == G_ARRAY) {
3101 EXTEND(sp, 1);
3102 if (unparsed)
3103 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
3104 else
3105 PUSHs(&sv_undef);
3106 }
3107
a0d0e21e
LW
3108SV *
3109strxfrm(src)
3110 SV * src
85e6fe83 3111 CODE:
a0d0e21e
LW
3112 {
3113 STRLEN srclen;
3114 STRLEN dstlen;
3115 char *p = SvPV(src,srclen);
3116 srclen++;
748a9306 3117 ST(0) = sv_2mortal(NEWSV(800,srclen));
a0d0e21e
LW
3118 dstlen = strxfrm(SvPVX(ST(0)), p, (size_t)srclen);
3119 if (dstlen > srclen) {
3120 dstlen++;
3121 SvGROW(ST(0), dstlen);
3122 strxfrm(SvPVX(ST(0)), p, (size_t)dstlen);
3123 dstlen--;
3124 }
3125 SvCUR(ST(0)) = dstlen;
3126 SvPOK_only(ST(0));
3127 }
3128
3129SysRet
3130mkfifo(filename, mode)
3131 char * filename
3132 Mode_t mode
748a9306
LW
3133 CODE:
3134 TAINT_PROPER("mkfifo");
3135 RETVAL = mkfifo(filename, mode);
3136 OUTPUT:
3137 RETVAL
a0d0e21e
LW
3138
3139SysRet
3140tcdrain(fd)
3141 int fd
3142
3143
3144SysRet
3145tcflow(fd, action)
3146 int fd
3147 int action
3148
3149
3150SysRet
3151tcflush(fd, queue_selector)
3152 int fd
3153 int queue_selector
3154
3155SysRet
3156tcsendbreak(fd, duration)
3157 int fd
3158 int duration
3159
3160char *
3161asctime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3162 int sec
3163 int min
3164 int hour
3165 int mday
3166 int mon
3167 int year
3168 int wday
3169 int yday
3170 int isdst
3171 CODE:
3172 {
3173 struct tm mytm;
7747499c 3174 init_tm(&mytm); /* XXX workaround - see init_tm() above */
a0d0e21e
LW
3175 mytm.tm_sec = sec;
3176 mytm.tm_min = min;
3177 mytm.tm_hour = hour;
3178 mytm.tm_mday = mday;
3179 mytm.tm_mon = mon;
3180 mytm.tm_year = year;
3181 mytm.tm_wday = wday;
3182 mytm.tm_yday = yday;
3183 mytm.tm_isdst = isdst;
3184 RETVAL = asctime(&mytm);
3185 }
3186 OUTPUT:
3187 RETVAL
3188
3189long
3190clock()
3191
3192char *
3193ctime(time)
748a9306 3194 Time_t &time
8990e307 3195
37120919
AD
3196void
3197times()
3198 PPCODE:
3199 struct tms tms;
3200 clock_t realtime;
3201 realtime = times( &tms );
3202 EXTEND(sp,5);
3203 PUSHs( sv_2mortal( newSVnv( realtime ) ) );
3204 PUSHs( sv_2mortal( newSVnv( tms.tms_utime ) ) );
3205 PUSHs( sv_2mortal( newSVnv( tms.tms_stime ) ) );
3206 PUSHs( sv_2mortal( newSVnv( tms.tms_cutime ) ) );
3207 PUSHs( sv_2mortal( newSVnv( tms.tms_cstime ) ) );
3208
a0d0e21e
LW
3209double
3210difftime(time1, time2)
3211 Time_t time1
3212 Time_t time2
3213
3214SysRetLong
3215mktime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3216 int sec
3217 int min
3218 int hour
3219 int mday
3220 int mon
3221 int year
3222 int wday
3223 int yday
3224 int isdst
3225 CODE:
3226 {
3227 struct tm mytm;
7747499c 3228 init_tm(&mytm); /* XXX workaround - see init_tm() above */
a0d0e21e
LW
3229 mytm.tm_sec = sec;
3230 mytm.tm_min = min;
3231 mytm.tm_hour = hour;
3232 mytm.tm_mday = mday;
3233 mytm.tm_mon = mon;
3234 mytm.tm_year = year;
3235 mytm.tm_wday = wday;
3236 mytm.tm_yday = yday;
3237 mytm.tm_isdst = isdst;
3238 RETVAL = mktime(&mytm);
3239 }
85e6fe83
LW
3240 OUTPUT:
3241 RETVAL
a0d0e21e
LW
3242
3243char *
3244strftime(fmt, sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3245 char * fmt
3246 int sec
3247 int min
3248 int hour
3249 int mday
3250 int mon
3251 int year
3252 int wday
3253 int yday
3254 int isdst
3255 CODE:
3256 {
3257 char tmpbuf[128];
3258 struct tm mytm;
3259 int len;
7747499c 3260 init_tm(&mytm); /* XXX workaround - see init_tm() above */
a0d0e21e
LW
3261 mytm.tm_sec = sec;
3262 mytm.tm_min = min;
3263 mytm.tm_hour = hour;
3264 mytm.tm_mday = mday;
3265 mytm.tm_mon = mon;
3266 mytm.tm_year = year;
3267 mytm.tm_wday = wday;
3268 mytm.tm_yday = yday;
3269 mytm.tm_isdst = isdst;
3270 len = strftime(tmpbuf, sizeof tmpbuf, fmt, &mytm);
3271 ST(0) = sv_2mortal(newSVpv(tmpbuf, len));
3272 }
3273
3274void
3275tzset()
3276
3277void
3278tzname()
3279 PPCODE:
3280 EXTEND(sp,2);
3281 PUSHs(sv_2mortal(newSVpv(tzname[0],strlen(tzname[0]))));
3282 PUSHs(sv_2mortal(newSVpv(tzname[1],strlen(tzname[1]))));
3283
3284SysRet
3285access(filename, mode)
3286 char * filename
3287 Mode_t mode
3288
3289char *
3290ctermid(s = 0)
3291 char * s = 0;
3292
3293char *
3294cuserid(s = 0)
3295 char * s = 0;
3296
3297SysRetLong
3298fpathconf(fd, name)
3299 int fd
3300 int name
3301
3302SysRetLong
3303pathconf(filename, name)
3304 char * filename
3305 int name
3306
3307SysRet
3308pause()
3309
3310SysRetLong
3311sysconf(name)
3312 int name
3313
3314char *
3315ttyname(fd)
3316 int fd