Raw integrate on mainline - MULTIPLICITY issues with Socket.xs
[p5sagit/p5-mst-13.2.git] / ext / POSIX / POSIX.xs
1 #ifdef WIN32
2 #define _POSIX_
3 #endif
4
5 #define PERL_NO_GET_CONTEXT
6
7 #include "EXTERN.h"
8 #define PERLIO_NOT_STDIO 1
9 #include "perl.h"
10 #include "XSUB.h"
11 #if defined(PERL_OBJECT) || defined(PERL_CAPI) || defined(PERL_IMPLICIT_SYS)
12 #  undef signal
13 #  undef open
14 #  undef setmode
15 #  define open PerlLIO_open3
16 #endif
17 #include <ctype.h>
18 #ifdef I_DIRENT    /* XXX maybe better to just rely on perl.h? */
19 #include <dirent.h>
20 #endif
21 #include <errno.h>
22 #ifdef I_FLOAT
23 #include <float.h>
24 #endif
25 #ifdef I_LIMITS
26 #include <limits.h>
27 #endif
28 #include <locale.h>
29 #include <math.h>
30 #ifdef I_PWD
31 #include <pwd.h>
32 #endif
33 #include <setjmp.h>
34 #include <signal.h>
35 #include <stdarg.h>
36
37 #ifdef I_STDDEF
38 #include <stddef.h>
39 #endif
40
41 #ifdef I_UNISTD
42 #include <unistd.h>
43 #endif
44
45 /* XXX This comment is just to make I_TERMIO and I_SGTTY visible to 
46    metaconfig for future extension writers.  We don't use them in POSIX.
47    (This is really sneaky :-)  --AD
48 */
49 #if defined(I_TERMIOS)
50 #include <termios.h>
51 #endif
52 #ifdef I_STDLIB
53 #include <stdlib.h>
54 #endif
55 #include <string.h>
56 #include <sys/stat.h>
57 #include <sys/types.h>
58 #include <time.h>
59 #ifdef I_UNISTD
60 #include <unistd.h>
61 #endif
62 #ifdef MACOS_TRADITIONAL
63 #undef fdopen
64 #endif
65 #include <fcntl.h>
66
67 #ifdef HAS_TZNAME
68 #  if !defined(WIN32) && !defined(__CYGWIN__)
69 extern char *tzname[];
70 #  endif
71 #else
72 #if !defined(WIN32) || (defined(__MINGW32__) && !defined(tzname))
73 char *tzname[] = { "" , "" };
74 #endif
75 #endif
76
77 #if defined(__VMS) && !defined(__POSIX_SOURCE)
78 #  include <libdef.h>       /* LIB$_INVARG constant */
79 #  include <lib$routines.h> /* prototype for lib$ediv() */
80 #  include <starlet.h>      /* prototype for sys$gettim() */
81 #  if DECC_VERSION < 50000000
82 #    define pid_t int       /* old versions of DECC miss this in types.h */
83 #  endif
84
85 #  undef mkfifo
86 #  define mkfifo(a,b) (not_here("mkfifo"),-1)
87 #  define tzset() not_here("tzset")
88
89 #if ((__VMS_VER >= 70000000) && (__DECC_VER >= 50200000)) || (__CRTL_VER >= 70000000)
90 #    define HAS_TZNAME  /* shows up in VMS 7.0 or Dec C 5.6 */
91 #    include <utsname.h>
92 #  endif /* __VMS_VER >= 70000000 or Dec C 5.6 */
93
94    /* The POSIX notion of ttyname() is better served by getname() under VMS */
95    static char ttnambuf[64];
96 #  define ttyname(fd) (isatty(fd) > 0 ? getname(fd,ttnambuf,0) : NULL)
97
98    /* The non-POSIX CRTL times() has void return type, so we just get the
99       current time directly */
100    clock_t vms_times(struct tms *bufptr) {
101         dTHX;
102         clock_t retval;
103         /* Get wall time and convert to 10 ms intervals to
104          * produce the return value that the POSIX standard expects */
105 #  if defined(__DECC) && defined (__ALPHA)
106 #    include <ints.h>
107         uint64 vmstime;
108         _ckvmssts(sys$gettim(&vmstime));
109         vmstime /= 100000;
110         retval = vmstime & 0x7fffffff;
111 #  else
112         /* (Older hw or ccs don't have an atomic 64-bit type, so we
113          * juggle 32-bit ints (and a float) to produce a time_t result
114          * with minimal loss of information.) */
115         long int vmstime[2],remainder,divisor = 100000;
116         _ckvmssts(sys$gettim((unsigned long int *)vmstime));
117         vmstime[1] &= 0x7fff;  /* prevent overflow in EDIV */
118         _ckvmssts(lib$ediv(&divisor,vmstime,(long int *)&retval,&remainder));
119 #  endif
120         /* Fill in the struct tms using the CRTL routine . . .*/
121         times((tbuffer_t *)bufptr);
122         return (clock_t) retval;
123    }
124 #  define times(t) vms_times(t)
125 #else
126 #if defined (__CYGWIN__)
127 #    define tzname _tzname
128 #endif
129 #if defined (WIN32)
130 #  undef mkfifo
131 #  define mkfifo(a,b) not_here("mkfifo")
132 #  define ttyname(a) (char*)not_here("ttyname")
133 #  define sigset_t long
134 #  define pid_t long
135 #  ifdef __BORLANDC__
136 #    define tzname _tzname
137 #  endif
138 #  ifdef _MSC_VER
139 #    define mode_t short
140 #  endif
141 #  ifdef __MINGW32__
142 #    define mode_t short
143 #    ifndef tzset
144 #      define tzset()           not_here("tzset")
145 #    endif
146 #    ifndef _POSIX_OPEN_MAX
147 #      define _POSIX_OPEN_MAX   FOPEN_MAX       /* XXX bogus ? */
148 #    endif
149 #  endif
150 #  define sigaction(a,b,c)      not_here("sigaction")
151 #  define sigpending(a)         not_here("sigpending")
152 #  define sigprocmask(a,b,c)    not_here("sigprocmask")
153 #  define sigsuspend(a)         not_here("sigsuspend")
154 #  define sigemptyset(a)        not_here("sigemptyset")
155 #  define sigaddset(a,b)        not_here("sigaddset")
156 #  define sigdelset(a,b)        not_here("sigdelset")
157 #  define sigfillset(a)         not_here("sigfillset")
158 #  define sigismember(a,b)      not_here("sigismember")
159 #else
160
161 #  ifndef HAS_MKFIFO
162 #    if defined(OS2) || defined(MACOS_TRADITIONAL)
163 #      define mkfifo(a,b) not_here("mkfifo")
164 #    else       /* !( defined OS2 ) */ 
165 #      ifndef mkfifo
166 #        define mkfifo(path, mode) (mknod((path), (mode) | S_IFIFO, 0))
167 #      endif
168 #    endif
169 #  endif /* !HAS_MKFIFO */
170
171 #  ifdef MACOS_TRADITIONAL
172 #    define ttyname(a) (char*)not_here("ttyname")
173 #    define tzset() not_here("tzset")
174 #  else
175 #    include <grp.h>
176 #    include <sys/times.h>
177 #    ifdef HAS_UNAME
178 #      include <sys/utsname.h>
179 #    endif
180 #    include <sys/wait.h>
181 #  endif
182 #  ifdef I_UTIME
183 #    include <utime.h>
184 #  endif
185 #endif /* WIN32 */
186 #endif /* __VMS */
187
188 typedef int SysRet;
189 typedef long SysRetLong;
190 typedef sigset_t* POSIX__SigSet;
191 typedef HV* POSIX__SigAction;
192 #ifdef I_TERMIOS
193 typedef struct termios* POSIX__Termios;
194 #else /* Define termios types to int, and call not_here for the functions.*/
195 #define POSIX__Termios int
196 #define speed_t int
197 #define tcflag_t int
198 #define cc_t int
199 #define cfgetispeed(x) not_here("cfgetispeed")
200 #define cfgetospeed(x) not_here("cfgetospeed")
201 #define tcdrain(x) not_here("tcdrain")
202 #define tcflush(x,y) not_here("tcflush")
203 #define tcsendbreak(x,y) not_here("tcsendbreak")
204 #define cfsetispeed(x,y) not_here("cfsetispeed")
205 #define cfsetospeed(x,y) not_here("cfsetospeed")
206 #define ctermid(x) (char *) not_here("ctermid")
207 #define tcflow(x,y) not_here("tcflow")
208 #define tcgetattr(x,y) not_here("tcgetattr")
209 #define tcsetattr(x,y,z) not_here("tcsetattr")
210 #endif
211
212 /* Possibly needed prototypes */
213 char *cuserid (char *);
214 double strtod (const char *, char **);
215 long strtol (const char *, char **, int);
216 unsigned long strtoul (const char *, char **, int);
217
218 #ifndef HAS_CUSERID
219 #define cuserid(a) (char *) not_here("cuserid")
220 #endif
221 #ifndef HAS_DIFFTIME
222 #ifndef difftime
223 #define difftime(a,b) not_here("difftime")
224 #endif
225 #endif
226 #ifndef HAS_FPATHCONF
227 #define fpathconf(f,n)  (SysRetLong) not_here("fpathconf")
228 #endif
229 #ifndef HAS_MKTIME
230 #define mktime(a) not_here("mktime")
231 #endif
232 #ifndef HAS_NICE
233 #define nice(a) not_here("nice")
234 #endif
235 #ifndef HAS_PATHCONF
236 #define pathconf(f,n)   (SysRetLong) not_here("pathconf")
237 #endif
238 #ifndef HAS_SYSCONF
239 #define sysconf(n)      (SysRetLong) not_here("sysconf")
240 #endif
241 #ifndef HAS_READLINK
242 #define readlink(a,b,c) not_here("readlink")
243 #endif
244 #ifndef HAS_SETPGID
245 #define setpgid(a,b) not_here("setpgid")
246 #endif
247 #ifndef HAS_SETSID
248 #define setsid() not_here("setsid")
249 #endif
250 #ifndef HAS_STRCOLL
251 #define strcoll(s1,s2) not_here("strcoll")
252 #endif
253 #ifndef HAS_STRTOD
254 #define strtod(s1,s2) not_here("strtod")
255 #endif
256 #ifndef HAS_STRTOL
257 #define strtol(s1,s2,b) not_here("strtol")
258 #endif
259 #ifndef HAS_STRTOUL
260 #define strtoul(s1,s2,b) not_here("strtoul")
261 #endif
262 #ifndef HAS_STRXFRM
263 #define strxfrm(s1,s2,n) not_here("strxfrm")
264 #endif
265 #ifndef HAS_TCGETPGRP
266 #define tcgetpgrp(a) not_here("tcgetpgrp")
267 #endif
268 #ifndef HAS_TCSETPGRP
269 #define tcsetpgrp(a,b) not_here("tcsetpgrp")
270 #endif
271 #ifndef HAS_TIMES
272 #define times(a) not_here("times")
273 #endif
274 #ifndef HAS_UNAME
275 #define uname(a) not_here("uname")
276 #endif
277 #ifndef HAS_WAITPID
278 #define waitpid(a,b,c) not_here("waitpid")
279 #endif
280
281 #ifndef HAS_MBLEN
282 #ifndef mblen
283 #define mblen(a,b) not_here("mblen")
284 #endif
285 #endif
286 #ifndef HAS_MBSTOWCS
287 #define mbstowcs(s, pwcs, n) not_here("mbstowcs")
288 #endif
289 #ifndef HAS_MBTOWC
290 #define mbtowc(pwc, s, n) not_here("mbtowc")
291 #endif
292 #ifndef HAS_WCSTOMBS
293 #define wcstombs(s, pwcs, n) not_here("wcstombs")
294 #endif
295 #ifndef HAS_WCTOMB
296 #define wctomb(s, wchar) not_here("wcstombs")
297 #endif
298 #if !defined(HAS_MBLEN) && !defined(HAS_MBSTOWCS) && !defined(HAS_MBTOWC) && !defined(HAS_WCSTOMBS) && !defined(HAS_WCTOMB)
299 /* If we don't have these functions, then we wouldn't have gotten a typedef
300    for wchar_t, the wide character type.  Defining wchar_t allows the
301    functions referencing it to compile.  Its actual type is then meaningless,
302    since without the above functions, all sections using it end up calling
303    not_here() and croak.  --Kaveh Ghazi (ghazi@noc.rutgers.edu) 9/18/94. */
304 #ifndef wchar_t
305 #define wchar_t char
306 #endif
307 #endif
308
309 #ifndef HAS_LOCALECONV
310 #define localeconv() not_here("localeconv")
311 #endif
312
313 #ifdef HAS_LONG_DOUBLE
314 #  if LONG_DOUBLESIZE > NVSIZE
315 #    undef HAS_LONG_DOUBLE  /* XXX until we figure out how to use them */
316 #  endif
317 #endif
318
319 #ifndef HAS_LONG_DOUBLE
320 #ifdef LDBL_MAX
321 #undef LDBL_MAX
322 #endif
323 #ifdef LDBL_MIN
324 #undef LDBL_MIN
325 #endif
326 #ifdef LDBL_EPSILON
327 #undef LDBL_EPSILON
328 #endif
329 #endif
330
331 static int
332 not_here(char *s)
333 {
334     croak("POSIX::%s not implemented on this architecture", s);
335     return -1;
336 }
337
338 #define PERL_constant_NOTFOUND  1
339 #define PERL_constant_NOTDEF    2
340 #define PERL_constant_ISIV      3
341 #define PERL_constant_ISNO      4
342 #define PERL_constant_ISNV      5
343 #define PERL_constant_ISPV      6
344 #define PERL_constant_ISPVN     7
345 #define PERL_constant_ISUNDEF   8
346 #define PERL_constant_ISUV      9
347 #define PERL_constant_ISYES     10
348
349 /* These were implemented in the old "constant" subroutine. They are actually
350    macros that take an integer argument and return an integer result.  */
351 static int
352 int_macro_int (const char *name, STRLEN len, IV *arg_result) {
353   /* Initially switch on the length of the name.  */
354   /* This code has been edited from a "constant" function generated by:
355
356 use ExtUtils::Constant qw (constant_types C_constant XS_constant);
357
358 my $types = {map {($_, 1)} qw(IV)};
359 my @names = (qw(S_ISBLK S_ISCHR S_ISDIR S_ISFIFO S_ISREG WEXITSTATUS WIFEXITED
360                WIFSIGNALED WIFSTOPPED WSTOPSIG WTERMSIG));
361
362 print constant_types(); # macro defs
363 foreach (C_constant ("POSIX", 'int_macro_int', 'IV', $types, undef, 5, @names) ) {
364     print $_, "\n"; # C constant subs
365 }
366 print "#### XS Section:\n";
367 print XS_constant ("POSIX", $types);
368 __END__
369    */
370
371   switch (len) {
372   case 7:
373     /* Names all of length 7.  */
374     /* S_ISBLK S_ISCHR S_ISDIR S_ISREG */
375     /* Offset 5 gives the best switch position.  */
376     switch (name[5]) {
377     case 'E':
378       if (memEQ(name, "S_ISREG", 7)) {
379       /*                    ^       */
380 #ifdef S_ISREG
381         *arg_result = S_ISREG(*arg_result);
382         return PERL_constant_ISIV;
383 #else
384         return PERL_constant_NOTDEF;
385 #endif
386       }
387       break;
388     case 'H':
389       if (memEQ(name, "S_ISCHR", 7)) {
390       /*                    ^       */
391 #ifdef S_ISCHR
392         *arg_result = S_ISCHR(*arg_result);
393         return PERL_constant_ISIV;
394 #else
395         return PERL_constant_NOTDEF;
396 #endif
397       }
398       break;
399     case 'I':
400       if (memEQ(name, "S_ISDIR", 7)) {
401       /*                    ^       */
402 #ifdef S_ISDIR
403         *arg_result = S_ISDIR(*arg_result);
404         return PERL_constant_ISIV;
405 #else
406         return PERL_constant_NOTDEF;
407 #endif
408       }
409       break;
410     case 'L':
411       if (memEQ(name, "S_ISBLK", 7)) {
412       /*                    ^       */
413 #ifdef S_ISBLK
414         *arg_result = S_ISBLK(*arg_result);
415         return PERL_constant_ISIV;
416 #else
417         return PERL_constant_NOTDEF;
418 #endif
419       }
420       break;
421     }
422     break;
423   case 8:
424     /* Names all of length 8.  */
425     /* S_ISFIFO WSTOPSIG WTERMSIG */
426     /* Offset 3 gives the best switch position.  */
427     switch (name[3]) {
428     case 'O':
429       if (memEQ(name, "WSTOPSIG", 8)) {
430       /*                  ^          */
431 #ifdef WSTOPSIG
432         *arg_result = WSTOPSIG(*arg_result);
433         return PERL_constant_ISIV;
434 #else
435         return PERL_constant_NOTDEF;
436 #endif
437       }
438       break;
439     case 'R':
440       if (memEQ(name, "WTERMSIG", 8)) {
441       /*                  ^          */
442 #ifdef WTERMSIG
443         *arg_result = WTERMSIG(*arg_result);
444         return PERL_constant_ISIV;
445 #else
446         return PERL_constant_NOTDEF;
447 #endif
448       }
449       break;
450     case 'S':
451       if (memEQ(name, "S_ISFIFO", 8)) {
452       /*                  ^          */
453 #ifdef S_ISFIFO
454         *arg_result = S_ISFIFO(*arg_result);
455         return PERL_constant_ISIV;
456 #else
457         return PERL_constant_NOTDEF;
458 #endif
459       }
460       break;
461     }
462     break;
463   case 9:
464     if (memEQ(name, "WIFEXITED", 9)) {
465 #ifdef WIFEXITED
466       *arg_result = WIFEXITED(*arg_result);
467       return PERL_constant_ISIV;
468 #else
469       return PERL_constant_NOTDEF;
470 #endif
471     }
472     break;
473   case 10:
474     if (memEQ(name, "WIFSTOPPED", 10)) {
475 #ifdef WIFSTOPPED
476       *arg_result = WIFSTOPPED(*arg_result);
477       return PERL_constant_ISIV;
478 #else
479       return PERL_constant_NOTDEF;
480 #endif
481     }
482     break;
483   case 11:
484     /* Names all of length 11.  */
485     /* WEXITSTATUS WIFSIGNALED */
486     /* Offset 1 gives the best switch position.  */
487     switch (name[1]) {
488     case 'E':
489       if (memEQ(name, "WEXITSTATUS", 11)) {
490       /*                ^                */
491 #ifdef WEXITSTATUS
492         *arg_result = WEXITSTATUS(*arg_result);
493         return PERL_constant_ISIV;
494 #else
495         return PERL_constant_NOTDEF;
496 #endif
497       }
498       break;
499     case 'I':
500       if (memEQ(name, "WIFSIGNALED", 11)) {
501       /*                ^                */
502 #ifdef WIFSIGNALED
503         *arg_result = WIFSIGNALED(*arg_result);
504         return PERL_constant_ISIV;
505 #else
506         return PERL_constant_NOTDEF;
507 #endif
508       }
509       break;
510     }
511     break;
512   }
513   return PERL_constant_NOTFOUND;
514 }
515
516 static int
517 constant_3 (const char *name, IV *iv_return, NV *nv_return) {
518   /* When generated this function returned values for the list of names given
519      here.  However, subsequent manual editing may have added or removed some.
520      B50 B75 CS5 CS6 CS7 CS8 EIO EOF */
521   /* Offset 2 gives the best switch position.  */
522   switch (name[2]) {
523   case '0':
524     if (memEQ(name, "B50", 3)) {
525     /*                 ^      */
526 #ifdef B50
527       *iv_return = B50;
528       return PERL_constant_ISIV;
529 #else
530       return PERL_constant_NOTDEF;
531 #endif
532     }
533     break;
534   case '5':
535     if (memEQ(name, "B75", 3)) {
536     /*                 ^      */
537 #ifdef B75
538       *iv_return = B75;
539       return PERL_constant_ISIV;
540 #else
541       return PERL_constant_NOTDEF;
542 #endif
543     }
544     if (memEQ(name, "CS5", 3)) {
545     /*                 ^      */
546 #ifdef CS5
547       *iv_return = CS5;
548       return PERL_constant_ISIV;
549 #else
550       return PERL_constant_NOTDEF;
551 #endif
552     }
553     break;
554   case '6':
555     if (memEQ(name, "CS6", 3)) {
556     /*                 ^      */
557 #ifdef CS6
558       *iv_return = CS6;
559       return PERL_constant_ISIV;
560 #else
561       return PERL_constant_NOTDEF;
562 #endif
563     }
564     break;
565   case '7':
566     if (memEQ(name, "CS7", 3)) {
567     /*                 ^      */
568 #ifdef CS7
569       *iv_return = CS7;
570       return PERL_constant_ISIV;
571 #else
572       return PERL_constant_NOTDEF;
573 #endif
574     }
575     break;
576   case '8':
577     if (memEQ(name, "CS8", 3)) {
578     /*                 ^      */
579 #ifdef CS8
580       *iv_return = CS8;
581       return PERL_constant_ISIV;
582 #else
583       return PERL_constant_NOTDEF;
584 #endif
585     }
586     break;
587   case 'F':
588     if (memEQ(name, "EOF", 3)) {
589     /*                 ^      */
590 #ifdef EOF
591       *iv_return = EOF;
592       return PERL_constant_ISIV;
593 #else
594       return PERL_constant_NOTDEF;
595 #endif
596     }
597     break;
598   case 'O':
599     if (memEQ(name, "EIO", 3)) {
600     /*                 ^      */
601 #ifdef EIO
602       *iv_return = EIO;
603       return PERL_constant_ISIV;
604 #else
605       return PERL_constant_NOTDEF;
606 #endif
607     }
608     break;
609   }
610   return PERL_constant_NOTFOUND;
611 }
612
613 static int
614 constant_4 (const char *name, IV *iv_return, NV *nv_return) {
615   /* When generated this function returned values for the list of names given
616      here.  However, subsequent manual editing may have added or removed some.
617      B110 B134 B150 B200 B300 B600 ECHO EDOM F_OK ISIG IXON NCCS NULL R_OK VEOF
618      VEOL VMIN W_OK X_OK */
619   /* Offset 1 gives the best switch position.  */
620   switch (name[1]) {
621   case '1':
622     if (memEQ(name, "B110", 4)) {
623     /*                ^        */
624 #ifdef B110
625       *iv_return = B110;
626       return PERL_constant_ISIV;
627 #else
628       return PERL_constant_NOTDEF;
629 #endif
630     }
631     if (memEQ(name, "B134", 4)) {
632     /*                ^        */
633 #ifdef B134
634       *iv_return = B134;
635       return PERL_constant_ISIV;
636 #else
637       return PERL_constant_NOTDEF;
638 #endif
639     }
640     if (memEQ(name, "B150", 4)) {
641     /*                ^        */
642 #ifdef B150
643       *iv_return = B150;
644       return PERL_constant_ISIV;
645 #else
646       return PERL_constant_NOTDEF;
647 #endif
648     }
649     break;
650   case '2':
651     if (memEQ(name, "B200", 4)) {
652     /*                ^        */
653 #ifdef B200
654       *iv_return = B200;
655       return PERL_constant_ISIV;
656 #else
657       return PERL_constant_NOTDEF;
658 #endif
659     }
660     break;
661   case '3':
662     if (memEQ(name, "B300", 4)) {
663     /*                ^        */
664 #ifdef B300
665       *iv_return = B300;
666       return PERL_constant_ISIV;
667 #else
668       return PERL_constant_NOTDEF;
669 #endif
670     }
671     break;
672   case '6':
673     if (memEQ(name, "B600", 4)) {
674     /*                ^        */
675 #ifdef B600
676       *iv_return = B600;
677       return PERL_constant_ISIV;
678 #else
679       return PERL_constant_NOTDEF;
680 #endif
681     }
682     break;
683   case 'C':
684     if (memEQ(name, "ECHO", 4)) {
685     /*                ^        */
686 #ifdef ECHO
687       *iv_return = ECHO;
688       return PERL_constant_ISIV;
689 #else
690       return PERL_constant_NOTDEF;
691 #endif
692     }
693     if (memEQ(name, "NCCS", 4)) {
694     /*                ^        */
695 #ifdef NCCS
696       *iv_return = NCCS;
697       return PERL_constant_ISIV;
698 #else
699       return PERL_constant_NOTDEF;
700 #endif
701     }
702     break;
703   case 'D':
704     if (memEQ(name, "EDOM", 4)) {
705     /*                ^        */
706 #ifdef EDOM
707       *iv_return = EDOM;
708       return PERL_constant_ISIV;
709 #else
710       return PERL_constant_NOTDEF;
711 #endif
712     }
713     break;
714   case 'E':
715     if (memEQ(name, "VEOF", 4)) {
716     /*                ^        */
717 #ifdef VEOF
718       *iv_return = VEOF;
719       return PERL_constant_ISIV;
720 #else
721       return PERL_constant_NOTDEF;
722 #endif
723     }
724     if (memEQ(name, "VEOL", 4)) {
725     /*                ^        */
726 #ifdef VEOL
727       *iv_return = VEOL;
728       return PERL_constant_ISIV;
729 #else
730       return PERL_constant_NOTDEF;
731 #endif
732     }
733     break;
734   case 'M':
735     if (memEQ(name, "VMIN", 4)) {
736     /*                ^        */
737 #ifdef VMIN
738       *iv_return = VMIN;
739       return PERL_constant_ISIV;
740 #else
741       return PERL_constant_NOTDEF;
742 #endif
743     }
744     break;
745   case 'S':
746     if (memEQ(name, "ISIG", 4)) {
747     /*                ^        */
748 #ifdef ISIG
749       *iv_return = ISIG;
750       return PERL_constant_ISIV;
751 #else
752       return PERL_constant_NOTDEF;
753 #endif
754     }
755     break;
756   case 'U':
757     if (memEQ(name, "NULL", 4)) {
758     /*                ^        */
759 #ifdef NULL
760       *iv_return = 0;
761       return PERL_constant_ISIV;
762 #else
763       return PERL_constant_NOTDEF;
764 #endif
765     }
766     break;
767   case 'X':
768     if (memEQ(name, "IXON", 4)) {
769     /*                ^        */
770 #ifdef IXON
771       *iv_return = IXON;
772       return PERL_constant_ISIV;
773 #else
774       return PERL_constant_NOTDEF;
775 #endif
776     }
777     break;
778   case '_':
779     if (memEQ(name, "F_OK", 4)) {
780     /*                ^        */
781 #ifdef F_OK
782       *iv_return = F_OK;
783       return PERL_constant_ISIV;
784 #else
785       return PERL_constant_NOTDEF;
786 #endif
787     }
788     if (memEQ(name, "R_OK", 4)) {
789     /*                ^        */
790 #ifdef R_OK
791       *iv_return = R_OK;
792       return PERL_constant_ISIV;
793 #else
794       return PERL_constant_NOTDEF;
795 #endif
796     }
797     if (memEQ(name, "W_OK", 4)) {
798     /*                ^        */
799 #ifdef W_OK
800       *iv_return = W_OK;
801       return PERL_constant_ISIV;
802 #else
803       return PERL_constant_NOTDEF;
804 #endif
805     }
806     if (memEQ(name, "X_OK", 4)) {
807     /*                ^        */
808 #ifdef X_OK
809       *iv_return = X_OK;
810       return PERL_constant_ISIV;
811 #else
812       return PERL_constant_NOTDEF;
813 #endif
814     }
815     break;
816   }
817   return PERL_constant_NOTFOUND;
818 }
819
820 static int
821 constant_5 (const char *name, IV *iv_return, NV *nv_return) {
822   /* When generated this function returned values for the list of names given
823      here.  However, subsequent manual editing may have added or removed some.
824      B1200 B1800 B2400 B4800 B9600 CREAD CSIZE E2BIG EBADF EBUSY ECHOE ECHOK
825      EFBIG EINTR ELOOP ENXIO EPERM EPIPE EROFS ESRCH EXDEV HUPCL ICRNL IGNCR
826      INLCR INPCK IXOFF OPOST TCION TCOON VINTR VKILL VQUIT VSTOP VSUSP VTIME */
827   /* Offset 1 gives the best switch position.  */
828   switch (name[1]) {
829   case '1':
830     if (memEQ(name, "B1200", 5)) {
831     /*                ^         */
832 #ifdef B1200
833       *iv_return = B1200;
834       return PERL_constant_ISIV;
835 #else
836       return PERL_constant_NOTDEF;
837 #endif
838     }
839     if (memEQ(name, "B1800", 5)) {
840     /*                ^         */
841 #ifdef B1800
842       *iv_return = B1800;
843       return PERL_constant_ISIV;
844 #else
845       return PERL_constant_NOTDEF;
846 #endif
847     }
848     break;
849   case '2':
850     if (memEQ(name, "B2400", 5)) {
851     /*                ^         */
852 #ifdef B2400
853       *iv_return = B2400;
854       return PERL_constant_ISIV;
855 #else
856       return PERL_constant_NOTDEF;
857 #endif
858     }
859     if (memEQ(name, "E2BIG", 5)) {
860     /*                ^         */
861 #ifdef E2BIG
862       *iv_return = E2BIG;
863       return PERL_constant_ISIV;
864 #else
865       return PERL_constant_NOTDEF;
866 #endif
867     }
868     break;
869   case '4':
870     if (memEQ(name, "B4800", 5)) {
871     /*                ^         */
872 #ifdef B4800
873       *iv_return = B4800;
874       return PERL_constant_ISIV;
875 #else
876       return PERL_constant_NOTDEF;
877 #endif
878     }
879     break;
880   case '9':
881     if (memEQ(name, "B9600", 5)) {
882     /*                ^         */
883 #ifdef B9600
884       *iv_return = B9600;
885       return PERL_constant_ISIV;
886 #else
887       return PERL_constant_NOTDEF;
888 #endif
889     }
890     break;
891   case 'B':
892     if (memEQ(name, "EBADF", 5)) {
893     /*                ^         */
894 #ifdef EBADF
895       *iv_return = EBADF;
896       return PERL_constant_ISIV;
897 #else
898       return PERL_constant_NOTDEF;
899 #endif
900     }
901     if (memEQ(name, "EBUSY", 5)) {
902     /*                ^         */
903 #ifdef EBUSY
904       *iv_return = EBUSY;
905       return PERL_constant_ISIV;
906 #else
907       return PERL_constant_NOTDEF;
908 #endif
909     }
910     break;
911   case 'C':
912     if (memEQ(name, "ECHOE", 5)) {
913     /*                ^         */
914 #ifdef ECHOE
915       *iv_return = ECHOE;
916       return PERL_constant_ISIV;
917 #else
918       return PERL_constant_NOTDEF;
919 #endif
920     }
921     if (memEQ(name, "ECHOK", 5)) {
922     /*                ^         */
923 #ifdef ECHOK
924       *iv_return = ECHOK;
925       return PERL_constant_ISIV;
926 #else
927       return PERL_constant_NOTDEF;
928 #endif
929     }
930     if (memEQ(name, "ICRNL", 5)) {
931     /*                ^         */
932 #ifdef ICRNL
933       *iv_return = ICRNL;
934       return PERL_constant_ISIV;
935 #else
936       return PERL_constant_NOTDEF;
937 #endif
938     }
939     if (memEQ(name, "TCION", 5)) {
940     /*                ^         */
941 #ifdef TCION
942       *iv_return = TCION;
943       return PERL_constant_ISIV;
944 #else
945       return PERL_constant_NOTDEF;
946 #endif
947     }
948     if (memEQ(name, "TCOON", 5)) {
949     /*                ^         */
950 #ifdef TCOON
951       *iv_return = TCOON;
952       return PERL_constant_ISIV;
953 #else
954       return PERL_constant_NOTDEF;
955 #endif
956     }
957     break;
958   case 'F':
959     if (memEQ(name, "EFBIG", 5)) {
960     /*                ^         */
961 #ifdef EFBIG
962       *iv_return = EFBIG;
963       return PERL_constant_ISIV;
964 #else
965       return PERL_constant_NOTDEF;
966 #endif
967     }
968     break;
969   case 'G':
970     if (memEQ(name, "IGNCR", 5)) {
971     /*                ^         */
972 #ifdef IGNCR
973       *iv_return = IGNCR;
974       return PERL_constant_ISIV;
975 #else
976       return PERL_constant_NOTDEF;
977 #endif
978     }
979     break;
980   case 'I':
981     if (memEQ(name, "EINTR", 5)) {
982     /*                ^         */
983 #ifdef EINTR
984       *iv_return = EINTR;
985       return PERL_constant_ISIV;
986 #else
987       return PERL_constant_NOTDEF;
988 #endif
989     }
990     if (memEQ(name, "VINTR", 5)) {
991     /*                ^         */
992 #ifdef VINTR
993       *iv_return = VINTR;
994       return PERL_constant_ISIV;
995 #else
996       return PERL_constant_NOTDEF;
997 #endif
998     }
999     break;
1000   case 'K':
1001     if (memEQ(name, "VKILL", 5)) {
1002     /*                ^         */
1003 #ifdef VKILL
1004       *iv_return = VKILL;
1005       return PERL_constant_ISIV;
1006 #else
1007       return PERL_constant_NOTDEF;
1008 #endif
1009     }
1010     break;
1011   case 'L':
1012     if (memEQ(name, "ELOOP", 5)) {
1013     /*                ^         */
1014 #ifdef ELOOP
1015       *iv_return = ELOOP;
1016       return PERL_constant_ISIV;
1017 #else
1018       return PERL_constant_NOTDEF;
1019 #endif
1020     }
1021     break;
1022   case 'N':
1023     if (memEQ(name, "ENXIO", 5)) {
1024     /*                ^         */
1025 #ifdef ENXIO
1026       *iv_return = ENXIO;
1027       return PERL_constant_ISIV;
1028 #else
1029       return PERL_constant_NOTDEF;
1030 #endif
1031     }
1032     if (memEQ(name, "INLCR", 5)) {
1033     /*                ^         */
1034 #ifdef INLCR
1035       *iv_return = INLCR;
1036       return PERL_constant_ISIV;
1037 #else
1038       return PERL_constant_NOTDEF;
1039 #endif
1040     }
1041     if (memEQ(name, "INPCK", 5)) {
1042     /*                ^         */
1043 #ifdef INPCK
1044       *iv_return = INPCK;
1045       return PERL_constant_ISIV;
1046 #else
1047       return PERL_constant_NOTDEF;
1048 #endif
1049     }
1050     break;
1051   case 'P':
1052     if (memEQ(name, "EPERM", 5)) {
1053     /*                ^         */
1054 #ifdef EPERM
1055       *iv_return = EPERM;
1056       return PERL_constant_ISIV;
1057 #else
1058       return PERL_constant_NOTDEF;
1059 #endif
1060     }
1061     if (memEQ(name, "EPIPE", 5)) {
1062     /*                ^         */
1063 #ifdef EPIPE
1064       *iv_return = EPIPE;
1065       return PERL_constant_ISIV;
1066 #else
1067       return PERL_constant_NOTDEF;
1068 #endif
1069     }
1070     if (memEQ(name, "OPOST", 5)) {
1071     /*                ^         */
1072 #ifdef OPOST
1073       *iv_return = OPOST;
1074       return PERL_constant_ISIV;
1075 #else
1076       return PERL_constant_NOTDEF;
1077 #endif
1078     }
1079     break;
1080   case 'Q':
1081     if (memEQ(name, "VQUIT", 5)) {
1082     /*                ^         */
1083 #ifdef VQUIT
1084       *iv_return = VQUIT;
1085       return PERL_constant_ISIV;
1086 #else
1087       return PERL_constant_NOTDEF;
1088 #endif
1089     }
1090     break;
1091   case 'R':
1092     if (memEQ(name, "CREAD", 5)) {
1093     /*                ^         */
1094 #ifdef CREAD
1095       *iv_return = CREAD;
1096       return PERL_constant_ISIV;
1097 #else
1098       return PERL_constant_NOTDEF;
1099 #endif
1100     }
1101     if (memEQ(name, "EROFS", 5)) {
1102     /*                ^         */
1103 #ifdef EROFS
1104       *iv_return = EROFS;
1105       return PERL_constant_ISIV;
1106 #else
1107       return PERL_constant_NOTDEF;
1108 #endif
1109     }
1110     break;
1111   case 'S':
1112     if (memEQ(name, "CSIZE", 5)) {
1113     /*                ^         */
1114 #ifdef CSIZE
1115       *iv_return = CSIZE;
1116       return PERL_constant_ISIV;
1117 #else
1118       return PERL_constant_NOTDEF;
1119 #endif
1120     }
1121     if (memEQ(name, "ESRCH", 5)) {
1122     /*                ^         */
1123 #ifdef ESRCH
1124       *iv_return = ESRCH;
1125       return PERL_constant_ISIV;
1126 #else
1127       return PERL_constant_NOTDEF;
1128 #endif
1129     }
1130     if (memEQ(name, "VSTOP", 5)) {
1131     /*                ^         */
1132 #ifdef VSTOP
1133       *iv_return = VSTOP;
1134       return PERL_constant_ISIV;
1135 #else
1136       return PERL_constant_NOTDEF;
1137 #endif
1138     }
1139     if (memEQ(name, "VSUSP", 5)) {
1140     /*                ^         */
1141 #ifdef VSUSP
1142       *iv_return = VSUSP;
1143       return PERL_constant_ISIV;
1144 #else
1145       return PERL_constant_NOTDEF;
1146 #endif
1147     }
1148     break;
1149   case 'T':
1150     if (memEQ(name, "VTIME", 5)) {
1151     /*                ^         */
1152 #ifdef VTIME
1153       *iv_return = VTIME;
1154       return PERL_constant_ISIV;
1155 #else
1156       return PERL_constant_NOTDEF;
1157 #endif
1158     }
1159     break;
1160   case 'U':
1161     if (memEQ(name, "HUPCL", 5)) {
1162     /*                ^         */
1163 #ifdef HUPCL
1164       *iv_return = HUPCL;
1165       return PERL_constant_ISIV;
1166 #else
1167       return PERL_constant_NOTDEF;
1168 #endif
1169     }
1170     break;
1171   case 'X':
1172     if (memEQ(name, "EXDEV", 5)) {
1173     /*                ^         */
1174 #ifdef EXDEV
1175       *iv_return = EXDEV;
1176       return PERL_constant_ISIV;
1177 #else
1178       return PERL_constant_NOTDEF;
1179 #endif
1180     }
1181     if (memEQ(name, "IXOFF", 5)) {
1182     /*                ^         */
1183 #ifdef IXOFF
1184       *iv_return = IXOFF;
1185       return PERL_constant_ISIV;
1186 #else
1187       return PERL_constant_NOTDEF;
1188 #endif
1189     }
1190     break;
1191   }
1192   return PERL_constant_NOTFOUND;
1193 }
1194
1195 static int
1196 constant_6 (const char *name, IV *iv_return, NV *nv_return) {
1197   /* When generated this function returned values for the list of names given
1198      here.  However, subsequent manual editing may have added or removed some.
1199      B19200 B38400 BRKINT BUFSIZ CLOCAL CSTOPB EACCES EAGAIN ECHILD ECHONL
1200      EDQUOT EEXIST EFAULT EINVAL EISDIR EMFILE EMLINK ENFILE ENODEV ENOENT
1201      ENOLCK ENOMEM ENOSPC ENOSYS ENOTTY ERANGE ESPIPE ESTALE EUSERS ICANON
1202      IEXTEN IGNBRK IGNPAR ISTRIP LC_ALL NOFLSH O_EXCL O_RDWR PARENB PARMRK
1203      PARODD SIGFPE SIGHUP SIGILL SIGINT TCIOFF TCOOFF TOSTOP VERASE VSTART */
1204   /* Offset 3 gives the best switch position.  */
1205   switch (name[3]) {
1206   case '2':
1207     if (memEQ(name, "B19200", 6)) {
1208     /*                  ^        */
1209 #ifdef B19200
1210       *iv_return = B19200;
1211       return PERL_constant_ISIV;
1212 #else
1213       return PERL_constant_NOTDEF;
1214 #endif
1215     }
1216     break;
1217   case '4':
1218     if (memEQ(name, "B38400", 6)) {
1219     /*                  ^        */
1220 #ifdef B38400
1221       *iv_return = B38400;
1222       return PERL_constant_ISIV;
1223 #else
1224       return PERL_constant_NOTDEF;
1225 #endif
1226     }
1227     break;
1228   case 'A':
1229     if (memEQ(name, "EAGAIN", 6)) {
1230     /*                  ^        */
1231 #ifdef EAGAIN
1232       *iv_return = EAGAIN;
1233       return PERL_constant_ISIV;
1234 #else
1235       return PERL_constant_NOTDEF;
1236 #endif
1237     }
1238     if (memEQ(name, "ESTALE", 6)) {
1239     /*                  ^        */
1240 #ifdef ESTALE
1241       *iv_return = ESTALE;
1242       return PERL_constant_ISIV;
1243 #else
1244       return PERL_constant_NOTDEF;
1245 #endif
1246     }
1247     if (memEQ(name, "LC_ALL", 6)) {
1248     /*                  ^        */
1249 #ifdef LC_ALL
1250       *iv_return = LC_ALL;
1251       return PERL_constant_ISIV;
1252 #else
1253       return PERL_constant_NOTDEF;
1254 #endif
1255     }
1256     if (memEQ(name, "VERASE", 6)) {
1257     /*                  ^        */
1258 #ifdef VERASE
1259       *iv_return = VERASE;
1260       return PERL_constant_ISIV;
1261 #else
1262       return PERL_constant_NOTDEF;
1263 #endif
1264     }
1265     if (memEQ(name, "VSTART", 6)) {
1266     /*                  ^        */
1267 #ifdef VSTART
1268       *iv_return = VSTART;
1269       return PERL_constant_ISIV;
1270 #else
1271       return PERL_constant_NOTDEF;
1272 #endif
1273     }
1274     break;
1275   case 'B':
1276     if (memEQ(name, "IGNBRK", 6)) {
1277     /*                  ^        */
1278 #ifdef IGNBRK
1279       *iv_return = IGNBRK;
1280       return PERL_constant_ISIV;
1281 #else
1282       return PERL_constant_NOTDEF;
1283 #endif
1284     }
1285     break;
1286   case 'C':
1287     if (memEQ(name, "CLOCAL", 6)) {
1288     /*                  ^        */
1289 #ifdef CLOCAL
1290       *iv_return = CLOCAL;
1291       return PERL_constant_ISIV;
1292 #else
1293       return PERL_constant_NOTDEF;
1294 #endif
1295     }
1296     if (memEQ(name, "EACCES", 6)) {
1297     /*                  ^        */
1298 #ifdef EACCES
1299       *iv_return = EACCES;
1300       return PERL_constant_ISIV;
1301 #else
1302       return PERL_constant_NOTDEF;
1303 #endif
1304     }
1305     break;
1306   case 'D':
1307     if (memEQ(name, "EISDIR", 6)) {
1308     /*                  ^        */
1309 #ifdef EISDIR
1310       *iv_return = EISDIR;
1311       return PERL_constant_ISIV;
1312 #else
1313       return PERL_constant_NOTDEF;
1314 #endif
1315     }
1316     if (memEQ(name, "ENODEV", 6)) {
1317     /*                  ^        */
1318 #ifdef ENODEV
1319       *iv_return = ENODEV;
1320       return PERL_constant_ISIV;
1321 #else
1322       return PERL_constant_NOTDEF;
1323 #endif
1324     }
1325     if (memEQ(name, "O_RDWR", 6)) {
1326     /*                  ^        */
1327 #ifdef O_RDWR
1328       *iv_return = O_RDWR;
1329       return PERL_constant_ISIV;
1330 #else
1331       return PERL_constant_NOTDEF;
1332 #endif
1333     }
1334     break;
1335   case 'E':
1336     if (memEQ(name, "ENOENT", 6)) {
1337     /*                  ^        */
1338 #ifdef ENOENT
1339       *iv_return = ENOENT;
1340       return PERL_constant_ISIV;
1341 #else
1342       return PERL_constant_NOTDEF;
1343 #endif
1344     }
1345     if (memEQ(name, "EUSERS", 6)) {
1346     /*                  ^        */
1347 #ifdef EUSERS
1348       *iv_return = EUSERS;
1349       return PERL_constant_ISIV;
1350 #else
1351       return PERL_constant_NOTDEF;
1352 #endif
1353     }
1354     if (memEQ(name, "PARENB", 6)) {
1355     /*                  ^        */
1356 #ifdef PARENB
1357       *iv_return = PARENB;
1358       return PERL_constant_ISIV;
1359 #else
1360       return PERL_constant_NOTDEF;
1361 #endif
1362     }
1363     break;
1364   case 'F':
1365     if (memEQ(name, "SIGFPE", 6)) {
1366     /*                  ^        */
1367 #ifdef SIGFPE
1368       *iv_return = SIGFPE;
1369       return PERL_constant_ISIV;
1370 #else
1371       return PERL_constant_NOTDEF;
1372 #endif
1373     }
1374     break;
1375   case 'H':
1376     if (memEQ(name, "SIGHUP", 6)) {
1377     /*                  ^        */
1378 #ifdef SIGHUP
1379       *iv_return = SIGHUP;
1380       return PERL_constant_ISIV;
1381 #else
1382       return PERL_constant_NOTDEF;
1383 #endif
1384     }
1385     break;
1386   case 'I':
1387     if (memEQ(name, "BRKINT", 6)) {
1388     /*                  ^        */
1389 #ifdef BRKINT
1390       *iv_return = BRKINT;
1391       return PERL_constant_ISIV;
1392 #else
1393       return PERL_constant_NOTDEF;
1394 #endif
1395     }
1396     if (memEQ(name, "ECHILD", 6)) {
1397     /*                  ^        */
1398 #ifdef ECHILD
1399       *iv_return = ECHILD;
1400       return PERL_constant_ISIV;
1401 #else
1402       return PERL_constant_NOTDEF;
1403 #endif
1404     }
1405     if (memEQ(name, "EEXIST", 6)) {
1406     /*                  ^        */
1407 #ifdef EEXIST
1408       *iv_return = EEXIST;
1409       return PERL_constant_ISIV;
1410 #else
1411       return PERL_constant_NOTDEF;
1412 #endif
1413     }
1414     if (memEQ(name, "EMFILE", 6)) {
1415     /*                  ^        */
1416 #ifdef EMFILE
1417       *iv_return = EMFILE;
1418       return PERL_constant_ISIV;
1419 #else
1420       return PERL_constant_NOTDEF;
1421 #endif
1422     }
1423     if (memEQ(name, "EMLINK", 6)) {
1424     /*                  ^        */
1425 #ifdef EMLINK
1426       *iv_return = EMLINK;
1427       return PERL_constant_ISIV;
1428 #else
1429       return PERL_constant_NOTDEF;
1430 #endif
1431     }
1432     if (memEQ(name, "ENFILE", 6)) {
1433     /*                  ^        */
1434 #ifdef ENFILE
1435       *iv_return = ENFILE;
1436       return PERL_constant_ISIV;
1437 #else
1438       return PERL_constant_NOTDEF;
1439 #endif
1440     }
1441     if (memEQ(name, "ESPIPE", 6)) {
1442     /*                  ^        */
1443 #ifdef ESPIPE
1444       *iv_return = ESPIPE;
1445       return PERL_constant_ISIV;
1446 #else
1447       return PERL_constant_NOTDEF;
1448 #endif
1449     }
1450     if (memEQ(name, "SIGILL", 6)) {
1451     /*                  ^        */
1452 #ifdef SIGILL
1453       *iv_return = SIGILL;
1454       return PERL_constant_ISIV;
1455 #else
1456       return PERL_constant_NOTDEF;
1457 #endif
1458     }
1459     if (memEQ(name, "SIGINT", 6)) {
1460     /*                  ^        */
1461 #ifdef SIGINT
1462       *iv_return = SIGINT;
1463       return PERL_constant_ISIV;
1464 #else
1465       return PERL_constant_NOTDEF;
1466 #endif
1467     }
1468     break;
1469   case 'L':
1470     if (memEQ(name, "ENOLCK", 6)) {
1471     /*                  ^        */
1472 #ifdef ENOLCK
1473       *iv_return = ENOLCK;
1474       return PERL_constant_ISIV;
1475 #else
1476       return PERL_constant_NOTDEF;
1477 #endif
1478     }
1479     if (memEQ(name, "NOFLSH", 6)) {
1480     /*                  ^        */
1481 #ifdef NOFLSH
1482       *iv_return = NOFLSH;
1483       return PERL_constant_ISIV;
1484 #else
1485       return PERL_constant_NOTDEF;
1486 #endif
1487     }
1488     break;
1489   case 'M':
1490     if (memEQ(name, "ENOMEM", 6)) {
1491     /*                  ^        */
1492 #ifdef ENOMEM
1493       *iv_return = ENOMEM;
1494       return PERL_constant_ISIV;
1495 #else
1496       return PERL_constant_NOTDEF;
1497 #endif
1498     }
1499     if (memEQ(name, "PARMRK", 6)) {
1500     /*                  ^        */
1501 #ifdef PARMRK
1502       *iv_return = PARMRK;
1503       return PERL_constant_ISIV;
1504 #else
1505       return PERL_constant_NOTDEF;
1506 #endif
1507     }
1508     break;
1509   case 'N':
1510     if (memEQ(name, "ERANGE", 6)) {
1511     /*                  ^        */
1512 #ifdef ERANGE
1513       *iv_return = ERANGE;
1514       return PERL_constant_ISIV;
1515 #else
1516       return PERL_constant_NOTDEF;
1517 #endif
1518     }
1519     if (memEQ(name, "ICANON", 6)) {
1520     /*                  ^        */
1521 #ifdef ICANON
1522       *iv_return = ICANON;
1523       return PERL_constant_ISIV;
1524 #else
1525       return PERL_constant_NOTDEF;
1526 #endif
1527     }
1528     break;
1529   case 'O':
1530     if (memEQ(name, "CSTOPB", 6)) {
1531     /*                  ^        */
1532 #ifdef CSTOPB
1533       *iv_return = CSTOPB;
1534       return PERL_constant_ISIV;
1535 #else
1536       return PERL_constant_NOTDEF;
1537 #endif
1538     }
1539     if (memEQ(name, "ECHONL", 6)) {
1540     /*                  ^        */
1541 #ifdef ECHONL
1542       *iv_return = ECHONL;
1543       return PERL_constant_ISIV;
1544 #else
1545       return PERL_constant_NOTDEF;
1546 #endif
1547     }
1548     if (memEQ(name, "PARODD", 6)) {
1549     /*                  ^        */
1550 #ifdef PARODD
1551       *iv_return = PARODD;
1552       return PERL_constant_ISIV;
1553 #else
1554       return PERL_constant_NOTDEF;
1555 #endif
1556     }
1557     if (memEQ(name, "TCIOFF", 6)) {
1558     /*                  ^        */
1559 #ifdef TCIOFF
1560       *iv_return = TCIOFF;
1561       return PERL_constant_ISIV;
1562 #else
1563       return PERL_constant_NOTDEF;
1564 #endif
1565     }
1566     if (memEQ(name, "TCOOFF", 6)) {
1567     /*                  ^        */
1568 #ifdef TCOOFF
1569       *iv_return = TCOOFF;
1570       return PERL_constant_ISIV;
1571 #else
1572       return PERL_constant_NOTDEF;
1573 #endif
1574     }
1575     break;
1576   case 'P':
1577     if (memEQ(name, "IGNPAR", 6)) {
1578     /*                  ^        */
1579 #ifdef IGNPAR
1580       *iv_return = IGNPAR;
1581       return PERL_constant_ISIV;
1582 #else
1583       return PERL_constant_NOTDEF;
1584 #endif
1585     }
1586     break;
1587   case 'R':
1588     if (memEQ(name, "ISTRIP", 6)) {
1589     /*                  ^        */
1590 #ifdef ISTRIP
1591       *iv_return = ISTRIP;
1592       return PERL_constant_ISIV;
1593 #else
1594       return PERL_constant_NOTDEF;
1595 #endif
1596     }
1597     break;
1598   case 'S':
1599     if (memEQ(name, "BUFSIZ", 6)) {
1600     /*                  ^        */
1601 #ifdef BUFSIZ
1602       *iv_return = BUFSIZ;
1603       return PERL_constant_ISIV;
1604 #else
1605       return PERL_constant_NOTDEF;
1606 #endif
1607     }
1608     if (memEQ(name, "ENOSPC", 6)) {
1609     /*                  ^        */
1610 #ifdef ENOSPC
1611       *iv_return = ENOSPC;
1612       return PERL_constant_ISIV;
1613 #else
1614       return PERL_constant_NOTDEF;
1615 #endif
1616     }
1617     if (memEQ(name, "ENOSYS", 6)) {
1618     /*                  ^        */
1619 #ifdef ENOSYS
1620       *iv_return = ENOSYS;
1621       return PERL_constant_ISIV;
1622 #else
1623       return PERL_constant_NOTDEF;
1624 #endif
1625     }
1626     break;
1627   case 'T':
1628     if (memEQ(name, "ENOTTY", 6)) {
1629     /*                  ^        */
1630 #ifdef ENOTTY
1631       *iv_return = ENOTTY;
1632       return PERL_constant_ISIV;
1633 #else
1634       return PERL_constant_NOTDEF;
1635 #endif
1636     }
1637     if (memEQ(name, "IEXTEN", 6)) {
1638     /*                  ^        */
1639 #ifdef IEXTEN
1640       *iv_return = IEXTEN;
1641       return PERL_constant_ISIV;
1642 #else
1643       return PERL_constant_NOTDEF;
1644 #endif
1645     }
1646     if (memEQ(name, "TOSTOP", 6)) {
1647     /*                  ^        */
1648 #ifdef TOSTOP
1649       *iv_return = TOSTOP;
1650       return PERL_constant_ISIV;
1651 #else
1652       return PERL_constant_NOTDEF;
1653 #endif
1654     }
1655     break;
1656   case 'U':
1657     if (memEQ(name, "EDQUOT", 6)) {
1658     /*                  ^        */
1659 #ifdef EDQUOT
1660       *iv_return = EDQUOT;
1661       return PERL_constant_ISIV;
1662 #else
1663       return PERL_constant_NOTDEF;
1664 #endif
1665     }
1666     if (memEQ(name, "EFAULT", 6)) {
1667     /*                  ^        */
1668 #ifdef EFAULT
1669       *iv_return = EFAULT;
1670       return PERL_constant_ISIV;
1671 #else
1672       return PERL_constant_NOTDEF;
1673 #endif
1674     }
1675     break;
1676   case 'V':
1677     if (memEQ(name, "EINVAL", 6)) {
1678     /*                  ^        */
1679 #ifdef EINVAL
1680       *iv_return = EINVAL;
1681       return PERL_constant_ISIV;
1682 #else
1683       return PERL_constant_NOTDEF;
1684 #endif
1685     }
1686     break;
1687   case 'X':
1688     if (memEQ(name, "O_EXCL", 6)) {
1689     /*                  ^        */
1690 #ifdef O_EXCL
1691       *iv_return = O_EXCL;
1692       return PERL_constant_ISIV;
1693 #else
1694       return PERL_constant_NOTDEF;
1695 #endif
1696     }
1697     break;
1698   }
1699   return PERL_constant_NOTFOUND;
1700 }
1701
1702 static int
1703 constant_7 (const char *name, IV *iv_return, NV *nv_return) {
1704   /* When generated this function returned values for the list of names given
1705      here.  However, subsequent manual editing may have added or removed some.
1706      ARG_MAX CLK_TCK DBL_DIG DBL_MAX DBL_MIN EDEADLK EISCONN ENOBUFS ENOEXEC
1707      ENOTBLK ENOTDIR EREMOTE ETXTBSY FLT_DIG FLT_MAX FLT_MIN F_DUPFD F_GETFD
1708      F_GETFL F_GETLK F_RDLCK F_SETFD F_SETFL F_SETLK F_UNLCK F_WRLCK INT_MAX
1709      INT_MIN LC_TIME O_CREAT O_TRUNC SIGABRT SIGALRM SIGCHLD SIGCONT SIGKILL
1710      SIGPIPE SIGQUIT SIGSEGV SIGSTOP SIGTERM SIGTSTP SIGTTIN SIGTTOU SIGUSR1
1711      SIGUSR2 SIG_DFL SIG_ERR SIG_IGN S_IRGRP S_IROTH S_IRUSR S_IRWXG S_IRWXO
1712      S_IRWXU S_ISGID S_ISUID S_IWGRP S_IWOTH S_IWUSR S_IXGRP S_IXOTH S_IXUSR
1713      TCSANOW TMP_MAX WNOHANG */
1714   /* Offset 6 gives the best switch position.  */
1715   switch (name[6]) {
1716   case '1':
1717     if (memEQ(name, "SIGUSR1", 7)) {
1718     /*                     ^      */
1719 #ifdef SIGUSR1
1720       *iv_return = SIGUSR1;
1721       return PERL_constant_ISIV;
1722 #else
1723       return PERL_constant_NOTDEF;
1724 #endif
1725     }
1726     break;
1727   case '2':
1728     if (memEQ(name, "SIGUSR2", 7)) {
1729     /*                     ^      */
1730 #ifdef SIGUSR2
1731       *iv_return = SIGUSR2;
1732       return PERL_constant_ISIV;
1733 #else
1734       return PERL_constant_NOTDEF;
1735 #endif
1736     }
1737     break;
1738   case 'C':
1739     if (memEQ(name, "ENOEXEC", 7)) {
1740     /*                     ^      */
1741 #ifdef ENOEXEC
1742       *iv_return = ENOEXEC;
1743       return PERL_constant_ISIV;
1744 #else
1745       return PERL_constant_NOTDEF;
1746 #endif
1747     }
1748     if (memEQ(name, "O_TRUNC", 7)) {
1749     /*                     ^      */
1750 #ifdef O_TRUNC
1751       *iv_return = O_TRUNC;
1752       return PERL_constant_ISIV;
1753 #else
1754       return PERL_constant_NOTDEF;
1755 #endif
1756     }
1757     break;
1758   case 'D':
1759     if (memEQ(name, "F_DUPFD", 7)) {
1760     /*                     ^      */
1761 #ifdef F_DUPFD
1762       *iv_return = F_DUPFD;
1763       return PERL_constant_ISIV;
1764 #else
1765       return PERL_constant_NOTDEF;
1766 #endif
1767     }
1768     if (memEQ(name, "F_GETFD", 7)) {
1769     /*                     ^      */
1770 #ifdef F_GETFD
1771       *iv_return = F_GETFD;
1772       return PERL_constant_ISIV;
1773 #else
1774       return PERL_constant_NOTDEF;
1775 #endif
1776     }
1777     if (memEQ(name, "F_SETFD", 7)) {
1778     /*                     ^      */
1779 #ifdef F_SETFD
1780       *iv_return = F_SETFD;
1781       return PERL_constant_ISIV;
1782 #else
1783       return PERL_constant_NOTDEF;
1784 #endif
1785     }
1786     if (memEQ(name, "SIGCHLD", 7)) {
1787     /*                     ^      */
1788 #ifdef SIGCHLD
1789       *iv_return = SIGCHLD;
1790       return PERL_constant_ISIV;
1791 #else
1792       return PERL_constant_NOTDEF;
1793 #endif
1794     }
1795     if (memEQ(name, "S_ISGID", 7)) {
1796     /*                     ^      */
1797 #ifdef S_ISGID
1798       *iv_return = S_ISGID;
1799       return PERL_constant_ISIV;
1800 #else
1801       return PERL_constant_NOTDEF;
1802 #endif
1803     }
1804     if (memEQ(name, "S_ISUID", 7)) {
1805     /*                     ^      */
1806 #ifdef S_ISUID
1807       *iv_return = S_ISUID;
1808       return PERL_constant_ISIV;
1809 #else
1810       return PERL_constant_NOTDEF;
1811 #endif
1812     }
1813     break;
1814   case 'E':
1815     if (memEQ(name, "EREMOTE", 7)) {
1816     /*                     ^      */
1817 #ifdef EREMOTE
1818       *iv_return = EREMOTE;
1819       return PERL_constant_ISIV;
1820 #else
1821       return PERL_constant_NOTDEF;
1822 #endif
1823     }
1824     if (memEQ(name, "LC_TIME", 7)) {
1825     /*                     ^      */
1826 #ifdef LC_TIME
1827       *iv_return = LC_TIME;
1828       return PERL_constant_ISIV;
1829 #else
1830       return PERL_constant_NOTDEF;
1831 #endif
1832     }
1833     if (memEQ(name, "SIGPIPE", 7)) {
1834     /*                     ^      */
1835 #ifdef SIGPIPE
1836       *iv_return = SIGPIPE;
1837       return PERL_constant_ISIV;
1838 #else
1839       return PERL_constant_NOTDEF;
1840 #endif
1841     }
1842     break;
1843   case 'G':
1844     if (memEQ(name, "DBL_DIG", 7)) {
1845     /*                     ^      */
1846 #ifdef DBL_DIG
1847       *nv_return = DBL_DIG;
1848       return PERL_constant_ISNV;
1849 #else
1850       return PERL_constant_NOTDEF;
1851 #endif
1852     }
1853     if (memEQ(name, "FLT_DIG", 7)) {
1854     /*                     ^      */
1855 #ifdef FLT_DIG
1856       *nv_return = FLT_DIG;
1857       return PERL_constant_ISNV;
1858 #else
1859       return PERL_constant_NOTDEF;
1860 #endif
1861     }
1862     if (memEQ(name, "S_IRWXG", 7)) {
1863     /*                     ^      */
1864 #ifdef S_IRWXG
1865       *iv_return = S_IRWXG;
1866       return PERL_constant_ISIV;
1867 #else
1868       return PERL_constant_NOTDEF;
1869 #endif
1870     }
1871     if (memEQ(name, "WNOHANG", 7)) {
1872     /*                     ^      */
1873 #ifdef WNOHANG
1874       *iv_return = WNOHANG;
1875       return PERL_constant_ISIV;
1876 #else
1877       return PERL_constant_NOTDEF;
1878 #endif
1879     }
1880     break;
1881   case 'H':
1882     if (memEQ(name, "S_IROTH", 7)) {
1883     /*                     ^      */
1884 #ifdef S_IROTH
1885       *iv_return = S_IROTH;
1886       return PERL_constant_ISIV;
1887 #else
1888       return PERL_constant_NOTDEF;
1889 #endif
1890     }
1891     if (memEQ(name, "S_IWOTH", 7)) {
1892     /*                     ^      */
1893 #ifdef S_IWOTH
1894       *iv_return = S_IWOTH;
1895       return PERL_constant_ISIV;
1896 #else
1897       return PERL_constant_NOTDEF;
1898 #endif
1899     }
1900     if (memEQ(name, "S_IXOTH", 7)) {
1901     /*                     ^      */
1902 #ifdef S_IXOTH
1903       *iv_return = S_IXOTH;
1904       return PERL_constant_ISIV;
1905 #else
1906       return PERL_constant_NOTDEF;
1907 #endif
1908     }
1909     break;
1910   case 'K':
1911     if (memEQ(name, "CLK_TCK", 7)) {
1912     /*                     ^      */
1913 #ifdef CLK_TCK
1914       *iv_return = CLK_TCK;
1915       return PERL_constant_ISIV;
1916 #else
1917       return PERL_constant_NOTDEF;
1918 #endif
1919     }
1920     if (memEQ(name, "EDEADLK", 7)) {
1921     /*                     ^      */
1922 #ifdef EDEADLK
1923       *iv_return = EDEADLK;
1924       return PERL_constant_ISIV;
1925 #else
1926       return PERL_constant_NOTDEF;
1927 #endif
1928     }
1929     if (memEQ(name, "ENOTBLK", 7)) {
1930     /*                     ^      */
1931 #ifdef ENOTBLK
1932       *iv_return = ENOTBLK;
1933       return PERL_constant_ISIV;
1934 #else
1935       return PERL_constant_NOTDEF;
1936 #endif
1937     }
1938     if (memEQ(name, "F_GETLK", 7)) {
1939     /*                     ^      */
1940 #ifdef F_GETLK
1941       *iv_return = F_GETLK;
1942       return PERL_constant_ISIV;
1943 #else
1944       return PERL_constant_NOTDEF;
1945 #endif
1946     }
1947     if (memEQ(name, "F_RDLCK", 7)) {
1948     /*                     ^      */
1949 #ifdef F_RDLCK
1950       *iv_return = F_RDLCK;
1951       return PERL_constant_ISIV;
1952 #else
1953       return PERL_constant_NOTDEF;
1954 #endif
1955     }
1956     if (memEQ(name, "F_SETLK", 7)) {
1957     /*                     ^      */
1958 #ifdef F_SETLK
1959       *iv_return = F_SETLK;
1960       return PERL_constant_ISIV;
1961 #else
1962       return PERL_constant_NOTDEF;
1963 #endif
1964     }
1965     if (memEQ(name, "F_UNLCK", 7)) {
1966     /*                     ^      */
1967 #ifdef F_UNLCK
1968       *iv_return = F_UNLCK;
1969       return PERL_constant_ISIV;
1970 #else
1971       return PERL_constant_NOTDEF;
1972 #endif
1973     }
1974     if (memEQ(name, "F_WRLCK", 7)) {
1975     /*                     ^      */
1976 #ifdef F_WRLCK
1977       *iv_return = F_WRLCK;
1978       return PERL_constant_ISIV;
1979 #else
1980       return PERL_constant_NOTDEF;
1981 #endif
1982     }
1983     break;
1984   case 'L':
1985     if (memEQ(name, "F_GETFL", 7)) {
1986     /*                     ^      */
1987 #ifdef F_GETFL
1988       *iv_return = F_GETFL;
1989       return PERL_constant_ISIV;
1990 #else
1991       return PERL_constant_NOTDEF;
1992 #endif
1993     }
1994     if (memEQ(name, "F_SETFL", 7)) {
1995     /*                     ^      */
1996 #ifdef F_SETFL
1997       *iv_return = F_SETFL;
1998       return PERL_constant_ISIV;
1999 #else
2000       return PERL_constant_NOTDEF;
2001 #endif
2002     }
2003     if (memEQ(name, "SIGKILL", 7)) {
2004     /*                     ^      */
2005 #ifdef SIGKILL
2006       *iv_return = SIGKILL;
2007       return PERL_constant_ISIV;
2008 #else
2009       return PERL_constant_NOTDEF;
2010 #endif
2011     }
2012     if (memEQ(name, "SIG_DFL", 7)) {
2013     /*                     ^      */
2014 #ifdef SIG_DFL
2015       *iv_return = (IV)SIG_DFL;
2016       return PERL_constant_ISIV;
2017 #else
2018       return PERL_constant_NOTDEF;
2019 #endif
2020     }
2021     break;
2022   case 'M':
2023     if (memEQ(name, "SIGALRM", 7)) {
2024     /*                     ^      */
2025 #ifdef SIGALRM
2026       *iv_return = SIGALRM;
2027       return PERL_constant_ISIV;
2028 #else
2029       return PERL_constant_NOTDEF;
2030 #endif
2031     }
2032     if (memEQ(name, "SIGTERM", 7)) {
2033     /*                     ^      */
2034 #ifdef SIGTERM
2035       *iv_return = SIGTERM;
2036       return PERL_constant_ISIV;
2037 #else
2038       return PERL_constant_NOTDEF;
2039 #endif
2040     }
2041     break;
2042   case 'N':
2043     if (memEQ(name, "DBL_MIN", 7)) {
2044     /*                     ^      */
2045 #ifdef DBL_MIN
2046       *nv_return = DBL_MIN;
2047       return PERL_constant_ISNV;
2048 #else
2049       return PERL_constant_NOTDEF;
2050 #endif
2051     }
2052     if (memEQ(name, "EISCONN", 7)) {
2053     /*                     ^      */
2054 #ifdef EISCONN
2055       *iv_return = EISCONN;
2056       return PERL_constant_ISIV;
2057 #else
2058       return PERL_constant_NOTDEF;
2059 #endif
2060     }
2061     if (memEQ(name, "FLT_MIN", 7)) {
2062     /*                     ^      */
2063 #ifdef FLT_MIN
2064       *nv_return = FLT_MIN;
2065       return PERL_constant_ISNV;
2066 #else
2067       return PERL_constant_NOTDEF;
2068 #endif
2069     }
2070     if (memEQ(name, "INT_MIN", 7)) {
2071     /*                     ^      */
2072 #ifdef INT_MIN
2073       *iv_return = INT_MIN;
2074       return PERL_constant_ISIV;
2075 #else
2076       return PERL_constant_NOTDEF;
2077 #endif
2078     }
2079     if (memEQ(name, "SIGTTIN", 7)) {
2080     /*                     ^      */
2081 #ifdef SIGTTIN
2082       *iv_return = SIGTTIN;
2083       return PERL_constant_ISIV;
2084 #else
2085       return PERL_constant_NOTDEF;
2086 #endif
2087     }
2088     if (memEQ(name, "SIG_IGN", 7)) {
2089     /*                     ^      */
2090 #ifdef SIG_IGN
2091       *iv_return = (IV)SIG_IGN;
2092       return PERL_constant_ISIV;
2093 #else
2094       return PERL_constant_NOTDEF;
2095 #endif
2096     }
2097     break;
2098   case 'O':
2099     if (memEQ(name, "S_IRWXO", 7)) {
2100     /*                     ^      */
2101 #ifdef S_IRWXO
2102       *iv_return = S_IRWXO;
2103       return PERL_constant_ISIV;
2104 #else
2105       return PERL_constant_NOTDEF;
2106 #endif
2107     }
2108     break;
2109   case 'P':
2110     if (memEQ(name, "SIGSTOP", 7)) {
2111     /*                     ^      */
2112 #ifdef SIGSTOP
2113       *iv_return = SIGSTOP;
2114       return PERL_constant_ISIV;
2115 #else
2116       return PERL_constant_NOTDEF;
2117 #endif
2118     }
2119     if (memEQ(name, "SIGTSTP", 7)) {
2120     /*                     ^      */
2121 #ifdef SIGTSTP
2122       *iv_return = SIGTSTP;
2123       return PERL_constant_ISIV;
2124 #else
2125       return PERL_constant_NOTDEF;
2126 #endif
2127     }
2128     if (memEQ(name, "S_IRGRP", 7)) {
2129     /*                     ^      */
2130 #ifdef S_IRGRP
2131       *iv_return = S_IRGRP;
2132       return PERL_constant_ISIV;
2133 #else
2134       return PERL_constant_NOTDEF;
2135 #endif
2136     }
2137     if (memEQ(name, "S_IWGRP", 7)) {
2138     /*                     ^      */
2139 #ifdef S_IWGRP
2140       *iv_return = S_IWGRP;
2141       return PERL_constant_ISIV;
2142 #else
2143       return PERL_constant_NOTDEF;
2144 #endif
2145     }
2146     if (memEQ(name, "S_IXGRP", 7)) {
2147     /*                     ^      */
2148 #ifdef S_IXGRP
2149       *iv_return = S_IXGRP;
2150       return PERL_constant_ISIV;
2151 #else
2152       return PERL_constant_NOTDEF;
2153 #endif
2154     }
2155     break;
2156   case 'R':
2157     if (memEQ(name, "ENOTDIR", 7)) {
2158     /*                     ^      */
2159 #ifdef ENOTDIR
2160       *iv_return = ENOTDIR;
2161       return PERL_constant_ISIV;
2162 #else
2163       return PERL_constant_NOTDEF;
2164 #endif
2165     }
2166     if (memEQ(name, "SIG_ERR", 7)) {
2167     /*                     ^      */
2168 #ifdef SIG_ERR
2169       *iv_return = (IV)SIG_ERR;
2170       return PERL_constant_ISIV;
2171 #else
2172       return PERL_constant_NOTDEF;
2173 #endif
2174     }
2175     if (memEQ(name, "S_IRUSR", 7)) {
2176     /*                     ^      */
2177 #ifdef S_IRUSR
2178       *iv_return = S_IRUSR;
2179       return PERL_constant_ISIV;
2180 #else
2181       return PERL_constant_NOTDEF;
2182 #endif
2183     }
2184     if (memEQ(name, "S_IWUSR", 7)) {
2185     /*                     ^      */
2186 #ifdef S_IWUSR
2187       *iv_return = S_IWUSR;
2188       return PERL_constant_ISIV;
2189 #else
2190       return PERL_constant_NOTDEF;
2191 #endif
2192     }
2193     if (memEQ(name, "S_IXUSR", 7)) {
2194     /*                     ^      */
2195 #ifdef S_IXUSR
2196       *iv_return = S_IXUSR;
2197       return PERL_constant_ISIV;
2198 #else
2199       return PERL_constant_NOTDEF;
2200 #endif
2201     }
2202     break;
2203   case 'S':
2204     if (memEQ(name, "ENOBUFS", 7)) {
2205     /*                     ^      */
2206 #ifdef ENOBUFS
2207       *iv_return = ENOBUFS;
2208       return PERL_constant_ISIV;
2209 #else
2210       return PERL_constant_NOTDEF;
2211 #endif
2212     }
2213     break;
2214   case 'T':
2215     if (memEQ(name, "O_CREAT", 7)) {
2216     /*                     ^      */
2217 #ifdef O_CREAT
2218       *iv_return = O_CREAT;
2219       return PERL_constant_ISIV;
2220 #else
2221       return PERL_constant_NOTDEF;
2222 #endif
2223     }
2224     if (memEQ(name, "SIGABRT", 7)) {
2225     /*                     ^      */
2226 #ifdef SIGABRT
2227       *iv_return = SIGABRT;
2228       return PERL_constant_ISIV;
2229 #else
2230       return PERL_constant_NOTDEF;
2231 #endif
2232     }
2233     if (memEQ(name, "SIGCONT", 7)) {
2234     /*                     ^      */
2235 #ifdef SIGCONT
2236       *iv_return = SIGCONT;
2237       return PERL_constant_ISIV;
2238 #else
2239       return PERL_constant_NOTDEF;
2240 #endif
2241     }
2242     if (memEQ(name, "SIGQUIT", 7)) {
2243     /*                     ^      */
2244 #ifdef SIGQUIT
2245       *iv_return = SIGQUIT;
2246       return PERL_constant_ISIV;
2247 #else
2248       return PERL_constant_NOTDEF;
2249 #endif
2250     }
2251     break;
2252   case 'U':
2253     if (memEQ(name, "SIGTTOU", 7)) {
2254     /*                     ^      */
2255 #ifdef SIGTTOU
2256       *iv_return = SIGTTOU;
2257       return PERL_constant_ISIV;
2258 #else
2259       return PERL_constant_NOTDEF;
2260 #endif
2261     }
2262     if (memEQ(name, "S_IRWXU", 7)) {
2263     /*                     ^      */
2264 #ifdef S_IRWXU
2265       *iv_return = S_IRWXU;
2266       return PERL_constant_ISIV;
2267 #else
2268       return PERL_constant_NOTDEF;
2269 #endif
2270     }
2271     break;
2272   case 'V':
2273     if (memEQ(name, "SIGSEGV", 7)) {
2274     /*                     ^      */
2275 #ifdef SIGSEGV
2276       *iv_return = SIGSEGV;
2277       return PERL_constant_ISIV;
2278 #else
2279       return PERL_constant_NOTDEF;
2280 #endif
2281     }
2282     break;
2283   case 'W':
2284     if (memEQ(name, "TCSANOW", 7)) {
2285     /*                     ^      */
2286 #ifdef TCSANOW
2287       *iv_return = TCSANOW;
2288       return PERL_constant_ISIV;
2289 #else
2290       return PERL_constant_NOTDEF;
2291 #endif
2292     }
2293     break;
2294   case 'X':
2295     if (memEQ(name, "ARG_MAX", 7)) {
2296     /*                     ^      */
2297 #ifdef ARG_MAX
2298       *iv_return = ARG_MAX;
2299       return PERL_constant_ISIV;
2300 #else
2301       return PERL_constant_NOTDEF;
2302 #endif
2303     }
2304     if (memEQ(name, "DBL_MAX", 7)) {
2305     /*                     ^      */
2306 #ifdef DBL_MAX
2307       *nv_return = DBL_MAX;
2308       return PERL_constant_ISNV;
2309 #else
2310       return PERL_constant_NOTDEF;
2311 #endif
2312     }
2313     if (memEQ(name, "FLT_MAX", 7)) {
2314     /*                     ^      */
2315 #ifdef FLT_MAX
2316       *nv_return = FLT_MAX;
2317       return PERL_constant_ISNV;
2318 #else
2319       return PERL_constant_NOTDEF;
2320 #endif
2321     }
2322     if (memEQ(name, "INT_MAX", 7)) {
2323     /*                     ^      */
2324 #ifdef INT_MAX
2325       *iv_return = INT_MAX;
2326       return PERL_constant_ISIV;
2327 #else
2328       return PERL_constant_NOTDEF;
2329 #endif
2330     }
2331     if (memEQ(name, "TMP_MAX", 7)) {
2332     /*                     ^      */
2333 #ifdef TMP_MAX
2334       *iv_return = TMP_MAX;
2335       return PERL_constant_ISIV;
2336 #else
2337       return PERL_constant_NOTDEF;
2338 #endif
2339     }
2340     break;
2341   case 'Y':
2342     if (memEQ(name, "ETXTBSY", 7)) {
2343     /*                     ^      */
2344 #ifdef ETXTBSY
2345       *iv_return = ETXTBSY;
2346       return PERL_constant_ISIV;
2347 #else
2348       return PERL_constant_NOTDEF;
2349 #endif
2350     }
2351     break;
2352   }
2353   return PERL_constant_NOTFOUND;
2354 }
2355
2356 static int
2357 constant_8 (const char *name, IV *iv_return, NV *nv_return) {
2358   /* When generated this function returned values for the list of names given
2359      here.  However, subsequent manual editing may have added or removed some.
2360      CHAR_BIT CHAR_MAX CHAR_MIN EALREADY EMSGSIZE ENETDOWN ENOTCONN ENOTSOCK
2361      EPROCLIM ERESTART F_SETLKW HUGE_VAL LC_CTYPE LDBL_DIG LDBL_MAX LDBL_MIN
2362      LINK_MAX LONG_MAX LONG_MIN L_tmpnam NAME_MAX OPEN_MAX O_APPEND O_NOCTTY
2363      O_RDONLY O_WRONLY PATH_MAX PIPE_BUF RAND_MAX SEEK_CUR SEEK_END SEEK_SET
2364      SHRT_MAX SHRT_MIN TCIFLUSH TCOFLUSH UINT_MAX */
2365   /* Offset 2 gives the best switch position.  */
2366   switch (name[2]) {
2367   case 'A':
2368     if (memEQ(name, "CHAR_BIT", 8)) {
2369     /*                 ^           */
2370 #ifdef CHAR_BIT
2371       *iv_return = CHAR_BIT;
2372       return PERL_constant_ISIV;
2373 #else
2374       return PERL_constant_NOTDEF;
2375 #endif
2376     }
2377     if (memEQ(name, "CHAR_MAX", 8)) {
2378     /*                 ^           */
2379 #ifdef CHAR_MAX
2380       *iv_return = CHAR_MAX;
2381       return PERL_constant_ISIV;
2382 #else
2383       return PERL_constant_NOTDEF;
2384 #endif
2385     }
2386     if (memEQ(name, "CHAR_MIN", 8)) {
2387     /*                 ^           */
2388 #ifdef CHAR_MIN
2389       *iv_return = CHAR_MIN;
2390       return PERL_constant_ISIV;
2391 #else
2392       return PERL_constant_NOTDEF;
2393 #endif
2394     }
2395     if (memEQ(name, "O_APPEND", 8)) {
2396     /*                 ^           */
2397 #ifdef O_APPEND
2398       *iv_return = O_APPEND;
2399       return PERL_constant_ISIV;
2400 #else
2401       return PERL_constant_NOTDEF;
2402 #endif
2403     }
2404     break;
2405   case 'B':
2406     if (memEQ(name, "LDBL_DIG", 8)) {
2407     /*                 ^           */
2408 #ifdef LDBL_DIG
2409       *nv_return = LDBL_DIG;
2410       return PERL_constant_ISNV;
2411 #else
2412       return PERL_constant_NOTDEF;
2413 #endif
2414     }
2415     if (memEQ(name, "LDBL_MAX", 8)) {
2416     /*                 ^           */
2417 #ifdef LDBL_MAX
2418       *nv_return = LDBL_MAX;
2419       return PERL_constant_ISNV;
2420 #else
2421       return PERL_constant_NOTDEF;
2422 #endif
2423     }
2424     if (memEQ(name, "LDBL_MIN", 8)) {
2425     /*                 ^           */
2426 #ifdef LDBL_MIN
2427       *nv_return = LDBL_MIN;
2428       return PERL_constant_ISNV;
2429 #else
2430       return PERL_constant_NOTDEF;
2431 #endif
2432     }
2433     break;
2434   case 'E':
2435     if (memEQ(name, "ENETDOWN", 8)) {
2436     /*                 ^           */
2437 #ifdef ENETDOWN
2438       *iv_return = ENETDOWN;
2439       return PERL_constant_ISIV;
2440 #else
2441       return PERL_constant_NOTDEF;
2442 #endif
2443     }
2444     if (memEQ(name, "ERESTART", 8)) {
2445     /*                 ^           */
2446 #ifdef ERESTART
2447       *iv_return = ERESTART;
2448       return PERL_constant_ISIV;
2449 #else
2450       return PERL_constant_NOTDEF;
2451 #endif
2452     }
2453     if (memEQ(name, "OPEN_MAX", 8)) {
2454     /*                 ^           */
2455 #ifdef OPEN_MAX
2456       *iv_return = OPEN_MAX;
2457       return PERL_constant_ISIV;
2458 #else
2459       return PERL_constant_NOTDEF;
2460 #endif
2461     }
2462     if (memEQ(name, "SEEK_CUR", 8)) {
2463     /*                 ^           */
2464 #ifdef SEEK_CUR
2465       *iv_return = SEEK_CUR;
2466       return PERL_constant_ISIV;
2467 #else
2468       return PERL_constant_NOTDEF;
2469 #endif
2470     }
2471     if (memEQ(name, "SEEK_END", 8)) {
2472     /*                 ^           */
2473 #ifdef SEEK_END
2474       *iv_return = SEEK_END;
2475       return PERL_constant_ISIV;
2476 #else
2477       return PERL_constant_NOTDEF;
2478 #endif
2479     }
2480     if (memEQ(name, "SEEK_SET", 8)) {
2481     /*                 ^           */
2482 #ifdef SEEK_SET
2483       *iv_return = SEEK_SET;
2484       return PERL_constant_ISIV;
2485 #else
2486       return PERL_constant_NOTDEF;
2487 #endif
2488     }
2489     break;
2490   case 'G':
2491     if (memEQ(name, "HUGE_VAL", 8)) {
2492     /*                 ^           */
2493 #if (defined(USE_LONG_DOUBLE) && defined(HUGE_VALL)) || defined(HUGE_VAL)
2494         /* HUGE_VALL is admittedly non-POSIX but if we are using long doubles
2495          * we might as well use long doubles. --jhi */
2496       *nv_return = 
2497 #if defined(USE_LONG_DOUBLE) && defined(HUGE_VALL)
2498                    HUGE_VALL
2499 #else
2500                    HUGE_VAL
2501 #endif
2502                            ;
2503       return PERL_constant_ISNV;
2504 #else
2505       return PERL_constant_NOTDEF;
2506 #endif
2507     }
2508     break;
2509   case 'I':
2510     if (memEQ(name, "TCIFLUSH", 8)) {
2511     /*                 ^           */
2512 #ifdef TCIFLUSH
2513       *iv_return = TCIFLUSH;
2514       return PERL_constant_ISIV;
2515 #else
2516       return PERL_constant_NOTDEF;
2517 #endif
2518     }
2519     break;
2520   case 'L':
2521     if (memEQ(name, "EALREADY", 8)) {
2522     /*                 ^           */
2523 #ifdef EALREADY
2524       *iv_return = EALREADY;
2525       return PERL_constant_ISIV;
2526 #else
2527       return PERL_constant_NOTDEF;
2528 #endif
2529     }
2530     break;
2531   case 'M':
2532     if (memEQ(name, "NAME_MAX", 8)) {
2533     /*                 ^           */
2534 #ifdef NAME_MAX
2535       *iv_return = NAME_MAX;
2536       return PERL_constant_ISIV;
2537 #else
2538       return PERL_constant_NOTDEF;
2539 #endif
2540     }
2541     break;
2542   case 'N':
2543     if (memEQ(name, "LINK_MAX", 8)) {
2544     /*                 ^           */
2545 #ifdef LINK_MAX
2546       *iv_return = LINK_MAX;
2547       return PERL_constant_ISIV;
2548 #else
2549       return PERL_constant_NOTDEF;
2550 #endif
2551     }
2552     if (memEQ(name, "LONG_MAX", 8)) {
2553     /*                 ^           */
2554 #ifdef LONG_MAX
2555       *iv_return = LONG_MAX;
2556       return PERL_constant_ISIV;
2557 #else
2558       return PERL_constant_NOTDEF;
2559 #endif
2560     }
2561     if (memEQ(name, "LONG_MIN", 8)) {
2562     /*                 ^           */
2563 #ifdef LONG_MIN
2564       *iv_return = LONG_MIN;
2565       return PERL_constant_ISIV;
2566 #else
2567       return PERL_constant_NOTDEF;
2568 #endif
2569     }
2570     if (memEQ(name, "O_NOCTTY", 8)) {
2571     /*                 ^           */
2572 #ifdef O_NOCTTY
2573       *iv_return = O_NOCTTY;
2574       return PERL_constant_ISIV;
2575 #else
2576       return PERL_constant_NOTDEF;
2577 #endif
2578     }
2579     if (memEQ(name, "RAND_MAX", 8)) {
2580     /*                 ^           */
2581 #ifdef RAND_MAX
2582       *iv_return = RAND_MAX;
2583       return PERL_constant_ISIV;
2584 #else
2585       return PERL_constant_NOTDEF;
2586 #endif
2587     }
2588     if (memEQ(name, "UINT_MAX", 8)) {
2589     /*                 ^           */
2590 #ifdef UINT_MAX
2591       *iv_return = (IV) UINT_MAX;
2592       return PERL_constant_ISUV;
2593 #else
2594       return PERL_constant_NOTDEF;
2595 #endif
2596     }
2597     break;
2598   case 'O':
2599     if (memEQ(name, "ENOTCONN", 8)) {
2600     /*                 ^           */
2601 #ifdef ENOTCONN
2602       *iv_return = ENOTCONN;
2603       return PERL_constant_ISIV;
2604 #else
2605       return PERL_constant_NOTDEF;
2606 #endif
2607     }
2608     if (memEQ(name, "ENOTSOCK", 8)) {
2609     /*                 ^           */
2610 #ifdef ENOTSOCK
2611       *iv_return = ENOTSOCK;
2612       return PERL_constant_ISIV;
2613 #else
2614       return PERL_constant_NOTDEF;
2615 #endif
2616     }
2617     if (memEQ(name, "TCOFLUSH", 8)) {
2618     /*                 ^           */
2619 #ifdef TCOFLUSH
2620       *iv_return = TCOFLUSH;
2621       return PERL_constant_ISIV;
2622 #else
2623       return PERL_constant_NOTDEF;
2624 #endif
2625     }
2626     break;
2627   case 'P':
2628     if (memEQ(name, "PIPE_BUF", 8)) {
2629     /*                 ^           */
2630 #ifdef PIPE_BUF
2631       *iv_return = PIPE_BUF;
2632       return PERL_constant_ISIV;
2633 #else
2634       return PERL_constant_NOTDEF;
2635 #endif
2636     }
2637     break;
2638   case 'R':
2639     if (memEQ(name, "EPROCLIM", 8)) {
2640     /*                 ^           */
2641 #ifdef EPROCLIM
2642       *iv_return = EPROCLIM;
2643       return PERL_constant_ISIV;
2644 #else
2645       return PERL_constant_NOTDEF;
2646 #endif
2647     }
2648     if (memEQ(name, "O_RDONLY", 8)) {
2649     /*                 ^           */
2650 #ifdef O_RDONLY
2651       *iv_return = O_RDONLY;
2652       return PERL_constant_ISIV;
2653 #else
2654       return PERL_constant_NOTDEF;
2655 #endif
2656     }
2657     if (memEQ(name, "SHRT_MAX", 8)) {
2658     /*                 ^           */
2659 #ifdef SHRT_MAX
2660       *iv_return = SHRT_MAX;
2661       return PERL_constant_ISIV;
2662 #else
2663       return PERL_constant_NOTDEF;
2664 #endif
2665     }
2666     if (memEQ(name, "SHRT_MIN", 8)) {
2667     /*                 ^           */
2668 #ifdef SHRT_MIN
2669       *iv_return = SHRT_MIN;
2670       return PERL_constant_ISIV;
2671 #else
2672       return PERL_constant_NOTDEF;
2673 #endif
2674     }
2675     break;
2676   case 'S':
2677     if (memEQ(name, "EMSGSIZE", 8)) {
2678     /*                 ^           */
2679 #ifdef EMSGSIZE
2680       *iv_return = EMSGSIZE;
2681       return PERL_constant_ISIV;
2682 #else
2683       return PERL_constant_NOTDEF;
2684 #endif
2685     }
2686     if (memEQ(name, "F_SETLKW", 8)) {
2687     /*                 ^           */
2688 #ifdef F_SETLKW
2689       *iv_return = F_SETLKW;
2690       return PERL_constant_ISIV;
2691 #else
2692       return PERL_constant_NOTDEF;
2693 #endif
2694     }
2695     break;
2696   case 'T':
2697     if (memEQ(name, "PATH_MAX", 8)) {
2698     /*                 ^           */
2699 #ifdef PATH_MAX
2700       *iv_return = PATH_MAX;
2701       return PERL_constant_ISIV;
2702 #else
2703       return PERL_constant_NOTDEF;
2704 #endif
2705     }
2706     break;
2707   case 'W':
2708     if (memEQ(name, "O_WRONLY", 8)) {
2709     /*                 ^           */
2710 #ifdef O_WRONLY
2711       *iv_return = O_WRONLY;
2712       return PERL_constant_ISIV;
2713 #else
2714       return PERL_constant_NOTDEF;
2715 #endif
2716     }
2717     break;
2718   case '_':
2719     if (memEQ(name, "LC_CTYPE", 8)) {
2720     /*                 ^           */
2721 #ifdef LC_CTYPE
2722       *iv_return = LC_CTYPE;
2723       return PERL_constant_ISIV;
2724 #else
2725       return PERL_constant_NOTDEF;
2726 #endif
2727     }
2728     break;
2729   case 't':
2730     if (memEQ(name, "L_tmpnam", 8)) {
2731     /*                 ^           */
2732 #ifdef L_tmpnam
2733       *iv_return = L_tmpnam;
2734       return PERL_constant_ISIV;
2735 #else
2736       return PERL_constant_NOTDEF;
2737 #endif
2738     }
2739     break;
2740   }
2741   return PERL_constant_NOTFOUND;
2742 }
2743
2744 static int
2745 constant_9 (const char *name, IV *iv_return, NV *nv_return) {
2746   /* When generated this function returned values for the list of names given
2747      here.  However, subsequent manual editing may have added or removed some.
2748      CHILD_MAX EHOSTDOWN ENETRESET ENOTEMPTY ESHUTDOWN ETIMEDOUT FLT_RADIX
2749      L_ctermid L_cuserid L_tmpname MAX_CANON MAX_INPUT O_ACCMODE SCHAR_MAX
2750      SCHAR_MIN SIG_BLOCK SSIZE_MAX TCIOFLUSH TCSADRAIN TCSAFLUSH UCHAR_MAX
2751      ULONG_MAX USHRT_MAX WUNTRACED */
2752   /* Offset 3 gives the best switch position.  */
2753   switch (name[3]) {
2754   case 'A':
2755     if (memEQ(name, "SCHAR_MAX", 9)) {
2756     /*                  ^           */
2757 #ifdef SCHAR_MAX
2758       *iv_return = SCHAR_MAX;
2759       return PERL_constant_ISIV;
2760 #else
2761       return PERL_constant_NOTDEF;
2762 #endif
2763     }
2764     if (memEQ(name, "SCHAR_MIN", 9)) {
2765     /*                  ^           */
2766 #ifdef SCHAR_MIN
2767       *iv_return = SCHAR_MIN;
2768       return PERL_constant_ISIV;
2769 #else
2770       return PERL_constant_NOTDEF;
2771 #endif
2772     }
2773     if (memEQ(name, "TCSADRAIN", 9)) {
2774     /*                  ^           */
2775 #ifdef TCSADRAIN
2776       *iv_return = TCSADRAIN;
2777       return PERL_constant_ISIV;
2778 #else
2779       return PERL_constant_NOTDEF;
2780 #endif
2781     }
2782     if (memEQ(name, "TCSAFLUSH", 9)) {
2783     /*                  ^           */
2784 #ifdef TCSAFLUSH
2785       *iv_return = TCSAFLUSH;
2786       return PERL_constant_ISIV;
2787 #else
2788       return PERL_constant_NOTDEF;
2789 #endif
2790     }
2791     if (memEQ(name, "UCHAR_MAX", 9)) {
2792     /*                  ^           */
2793 #ifdef UCHAR_MAX
2794       *iv_return = (IV) UCHAR_MAX;
2795       return PERL_constant_ISUV;
2796 #else
2797       return PERL_constant_NOTDEF;
2798 #endif
2799     }
2800     break;
2801   case 'C':
2802     if (memEQ(name, "O_ACCMODE", 9)) {
2803     /*                  ^           */
2804 #ifdef O_ACCMODE
2805       *iv_return = O_ACCMODE;
2806       return PERL_constant_ISIV;
2807 #else
2808       return PERL_constant_NOTDEF;
2809 #endif
2810     }
2811     break;
2812   case 'L':
2813     if (memEQ(name, "CHILD_MAX", 9)) {
2814     /*                  ^           */
2815 #ifdef CHILD_MAX
2816       *iv_return = CHILD_MAX;
2817       return PERL_constant_ISIV;
2818 #else
2819       return PERL_constant_NOTDEF;
2820 #endif
2821     }
2822     break;
2823   case 'M':
2824     if (memEQ(name, "ETIMEDOUT", 9)) {
2825     /*                  ^           */
2826 #ifdef ETIMEDOUT
2827       *iv_return = ETIMEDOUT;
2828       return PERL_constant_ISIV;
2829 #else
2830       return PERL_constant_NOTDEF;
2831 #endif
2832     }
2833     break;
2834   case 'N':
2835     if (memEQ(name, "ULONG_MAX", 9)) {
2836     /*                  ^           */
2837 #ifdef ULONG_MAX
2838       *iv_return = (IV) ULONG_MAX;
2839       return PERL_constant_ISUV;
2840 #else
2841       return PERL_constant_NOTDEF;
2842 #endif
2843     }
2844     break;
2845   case 'O':
2846     if (memEQ(name, "TCIOFLUSH", 9)) {
2847     /*                  ^           */
2848 #ifdef TCIOFLUSH
2849       *iv_return = TCIOFLUSH;
2850       return PERL_constant_ISIV;
2851 #else
2852       return PERL_constant_NOTDEF;
2853 #endif
2854     }
2855     break;
2856   case 'R':
2857     if (memEQ(name, "USHRT_MAX", 9)) {
2858     /*                  ^           */
2859 #ifdef USHRT_MAX
2860       *iv_return = (IV) USHRT_MAX;
2861       return PERL_constant_ISUV;
2862 #else
2863       return PERL_constant_NOTDEF;
2864 #endif
2865     }
2866     break;
2867   case 'S':
2868     if (memEQ(name, "EHOSTDOWN", 9)) {
2869     /*                  ^           */
2870 #ifdef EHOSTDOWN
2871       *iv_return = EHOSTDOWN;
2872       return PERL_constant_ISIV;
2873 #else
2874       return PERL_constant_NOTDEF;
2875 #endif
2876     }
2877     break;
2878   case 'T':
2879     if (memEQ(name, "ENETRESET", 9)) {
2880     /*                  ^           */
2881 #ifdef ENETRESET
2882       *iv_return = ENETRESET;
2883       return PERL_constant_ISIV;
2884 #else
2885       return PERL_constant_NOTDEF;
2886 #endif
2887     }
2888     if (memEQ(name, "ENOTEMPTY", 9)) {
2889     /*                  ^           */
2890 #ifdef ENOTEMPTY
2891       *iv_return = ENOTEMPTY;
2892       return PERL_constant_ISIV;
2893 #else
2894       return PERL_constant_NOTDEF;
2895 #endif
2896     }
2897     if (memEQ(name, "WUNTRACED", 9)) {
2898     /*                  ^           */
2899 #ifdef WUNTRACED
2900       *iv_return = WUNTRACED;
2901       return PERL_constant_ISIV;
2902 #else
2903       return PERL_constant_NOTDEF;
2904 #endif
2905     }
2906     break;
2907   case 'U':
2908     if (memEQ(name, "ESHUTDOWN", 9)) {
2909     /*                  ^           */
2910 #ifdef ESHUTDOWN
2911       *iv_return = ESHUTDOWN;
2912       return PERL_constant_ISIV;
2913 #else
2914       return PERL_constant_NOTDEF;
2915 #endif
2916     }
2917     break;
2918   case 'Z':
2919     if (memEQ(name, "SSIZE_MAX", 9)) {
2920     /*                  ^           */
2921 #ifdef SSIZE_MAX
2922       *iv_return = SSIZE_MAX;
2923       return PERL_constant_ISIV;
2924 #else
2925       return PERL_constant_NOTDEF;
2926 #endif
2927     }
2928     break;
2929   case '_':
2930     if (memEQ(name, "FLT_RADIX", 9)) {
2931     /*                  ^           */
2932 #ifdef FLT_RADIX
2933       *nv_return = FLT_RADIX;
2934       return PERL_constant_ISNV;
2935 #else
2936       return PERL_constant_NOTDEF;
2937 #endif
2938     }
2939     if (memEQ(name, "MAX_CANON", 9)) {
2940     /*                  ^           */
2941 #ifdef MAX_CANON
2942       *iv_return = MAX_CANON;
2943       return PERL_constant_ISIV;
2944 #else
2945       return PERL_constant_NOTDEF;
2946 #endif
2947     }
2948     if (memEQ(name, "MAX_INPUT", 9)) {
2949     /*                  ^           */
2950 #ifdef MAX_INPUT
2951       *iv_return = MAX_INPUT;
2952       return PERL_constant_ISIV;
2953 #else
2954       return PERL_constant_NOTDEF;
2955 #endif
2956     }
2957     if (memEQ(name, "SIG_BLOCK", 9)) {
2958     /*                  ^           */
2959 #ifdef SIG_BLOCK
2960       *iv_return = SIG_BLOCK;
2961       return PERL_constant_ISIV;
2962 #else
2963       return PERL_constant_NOTDEF;
2964 #endif
2965     }
2966     break;
2967   case 'm':
2968     if (memEQ(name, "L_tmpname", 9)) {
2969     /*                  ^           */
2970 #ifdef L_tmpname
2971       *iv_return = L_tmpnam;
2972       return PERL_constant_ISIV;
2973 #else
2974       return PERL_constant_NOTDEF;
2975 #endif
2976     }
2977     break;
2978   case 't':
2979     if (memEQ(name, "L_ctermid", 9)) {
2980     /*                  ^           */
2981 #ifdef L_ctermid
2982       *iv_return = L_ctermid;
2983       return PERL_constant_ISIV;
2984 #else
2985       return PERL_constant_NOTDEF;
2986 #endif
2987     }
2988     break;
2989   case 'u':
2990     if (memEQ(name, "L_cuserid", 9)) {
2991     /*                  ^           */
2992 #ifdef L_cuserid
2993       *iv_return = L_cuserid;
2994       return PERL_constant_ISIV;
2995 #else
2996       return PERL_constant_NOTDEF;
2997 #endif
2998     }
2999     break;
3000   }
3001   return PERL_constant_NOTFOUND;
3002 }
3003
3004 static int
3005 constant_10 (const char *name, IV *iv_return, NV *nv_return) {
3006   /* When generated this function returned values for the list of names given
3007      here.  However, subsequent manual editing may have added or removed some.
3008      EADDRINUSE ECONNRESET EOPNOTSUPP EPROTOTYPE FD_CLOEXEC FLT_ROUNDS
3009      LC_COLLATE LC_NUMERIC MB_CUR_MAX MB_LEN_MAX O_NONBLOCK SA_NODEFER
3010      SA_ONSTACK SA_RESTART SA_SIGINFO STREAM_MAX TZNAME_MAX */
3011   /* Offset 5 gives the best switch position.  */
3012   switch (name[5]) {
3013   case 'B':
3014     if (memEQ(name, "O_NONBLOCK", 10)) {
3015     /*                    ^           */
3016 #ifdef O_NONBLOCK
3017       *iv_return = O_NONBLOCK;
3018       return PERL_constant_ISIV;
3019 #else
3020       return PERL_constant_NOTDEF;
3021 #endif
3022     }
3023     break;
3024   case 'D':
3025     if (memEQ(name, "SA_NODEFER", 10)) {
3026     /*                    ^           */
3027 #ifdef SA_NODEFER
3028       *iv_return = (IV) SA_NODEFER;
3029       return PERL_constant_ISUV;
3030 #else
3031       return PERL_constant_NOTDEF;
3032 #endif
3033     }
3034     break;
3035   case 'E':
3036     if (memEQ(name, "TZNAME_MAX", 10)) {
3037     /*                    ^           */
3038 #ifdef TZNAME_MAX
3039       *iv_return = TZNAME_MAX;
3040       return PERL_constant_ISIV;
3041 #else
3042       return PERL_constant_NOTDEF;
3043 #endif
3044     }
3045     break;
3046   case 'G':
3047     if (memEQ(name, "SA_SIGINFO", 10)) {
3048     /*                    ^           */
3049 #ifdef SA_SIGINFO
3050       *iv_return = (IV) SA_SIGINFO;
3051       return PERL_constant_ISUV;
3052 #else
3053       return PERL_constant_NOTDEF;
3054 #endif
3055     }
3056     break;
3057   case 'I':
3058     if (memEQ(name, "EADDRINUSE", 10)) {
3059     /*                    ^           */
3060 #ifdef EADDRINUSE
3061       *iv_return = EADDRINUSE;
3062       return PERL_constant_ISIV;
3063 #else
3064       return PERL_constant_NOTDEF;
3065 #endif
3066     }
3067     break;
3068   case 'L':
3069     if (memEQ(name, "LC_COLLATE", 10)) {
3070     /*                    ^           */
3071 #ifdef LC_COLLATE
3072       *iv_return = LC_COLLATE;
3073       return PERL_constant_ISIV;
3074 #else
3075       return PERL_constant_NOTDEF;
3076 #endif
3077     }
3078     break;
3079   case 'M':
3080     if (memEQ(name, "LC_NUMERIC", 10)) {
3081     /*                    ^           */
3082 #ifdef LC_NUMERIC
3083       *iv_return = LC_NUMERIC;
3084       return PERL_constant_ISIV;
3085 #else
3086       return PERL_constant_NOTDEF;
3087 #endif
3088     }
3089     if (memEQ(name, "STREAM_MAX", 10)) {
3090     /*                    ^           */
3091 #ifdef STREAM_MAX
3092       *iv_return = STREAM_MAX;
3093       return PERL_constant_ISIV;
3094 #else
3095       return PERL_constant_NOTDEF;
3096 #endif
3097     }
3098     break;
3099   case 'N':
3100     if (memEQ(name, "MB_LEN_MAX", 10)) {
3101     /*                    ^           */
3102 #ifdef MB_LEN_MAX
3103       *iv_return = MB_LEN_MAX;
3104       return PERL_constant_ISIV;
3105 #else
3106       return PERL_constant_NOTDEF;
3107 #endif
3108     }
3109     break;
3110   case 'O':
3111     if (memEQ(name, "EPROTOTYPE", 10)) {
3112     /*                    ^           */
3113 #ifdef EPROTOTYPE
3114       *iv_return = EPROTOTYPE;
3115       return PERL_constant_ISIV;
3116 #else
3117       return PERL_constant_NOTDEF;
3118 #endif
3119     }
3120     if (memEQ(name, "FD_CLOEXEC", 10)) {
3121     /*                    ^           */
3122 #ifdef FD_CLOEXEC
3123       *iv_return = FD_CLOEXEC;
3124       return PERL_constant_ISIV;
3125 #else
3126       return PERL_constant_NOTDEF;
3127 #endif
3128     }
3129     if (memEQ(name, "FLT_ROUNDS", 10)) {
3130     /*                    ^           */
3131 #ifdef FLT_ROUNDS
3132       *nv_return = FLT_ROUNDS;
3133       return PERL_constant_ISNV;
3134 #else
3135       return PERL_constant_NOTDEF;
3136 #endif
3137     }
3138     break;
3139   case 'R':
3140     if (memEQ(name, "ECONNRESET", 10)) {
3141     /*                    ^           */
3142 #ifdef ECONNRESET
3143       *iv_return = ECONNRESET;
3144       return PERL_constant_ISIV;
3145 #else
3146       return PERL_constant_NOTDEF;
3147 #endif
3148     }
3149     if (memEQ(name, "MB_CUR_MAX", 10)) {
3150     /*                    ^           */
3151 #ifdef MB_CUR_MAX
3152       *iv_return = MB_CUR_MAX;
3153       return PERL_constant_ISIV;
3154 #else
3155       return PERL_constant_NOTDEF;
3156 #endif
3157     }
3158     break;
3159   case 'S':
3160     if (memEQ(name, "SA_ONSTACK", 10)) {
3161     /*                    ^           */
3162 #ifdef SA_ONSTACK
3163       *iv_return = (IV) SA_ONSTACK;
3164       return PERL_constant_ISUV;
3165 #else
3166       return PERL_constant_NOTDEF;
3167 #endif
3168     }
3169     if (memEQ(name, "SA_RESTART", 10)) {
3170     /*                    ^           */
3171 #ifdef SA_RESTART
3172       *iv_return = (IV) SA_RESTART;
3173       return PERL_constant_ISUV;
3174 #else
3175       return PERL_constant_NOTDEF;
3176 #endif
3177     }
3178     break;
3179   case 'T':
3180     if (memEQ(name, "EOPNOTSUPP", 10)) {
3181     /*                    ^           */
3182 #ifdef EOPNOTSUPP
3183       *iv_return = EOPNOTSUPP;
3184       return PERL_constant_ISIV;
3185 #else
3186       return PERL_constant_NOTDEF;
3187 #endif
3188     }
3189     break;
3190   }
3191   return PERL_constant_NOTFOUND;
3192 }
3193
3194 static int
3195 constant_11 (const char *name, IV *iv_return, NV *nv_return) {
3196   /* When generated this function returned values for the list of names given
3197      here.  However, subsequent manual editing may have added or removed some.
3198      DBL_EPSILON DBL_MAX_EXP DBL_MIN_EXP EINPROGRESS ENETUNREACH ENOPROTOOPT
3199      EWOULDBLOCK FLT_EPSILON FLT_MAX_EXP FLT_MIN_EXP LC_MESSAGES LC_MONETARY
3200      NGROUPS_MAX SIG_SETMASK SIG_UNBLOCK _SC_ARG_MAX _SC_CLK_TCK _SC_VERSION */
3201   /* Offset 5 gives the best switch position.  */
3202   switch (name[5]) {
3203   case 'A':
3204     if (memEQ(name, "DBL_MAX_EXP", 11)) {
3205     /*                    ^            */
3206 #ifdef DBL_MAX_EXP
3207       *nv_return = DBL_MAX_EXP;
3208       return PERL_constant_ISNV;
3209 #else
3210       return PERL_constant_NOTDEF;
3211 #endif
3212     }
3213     if (memEQ(name, "FLT_MAX_EXP", 11)) {
3214     /*                    ^            */
3215 #ifdef FLT_MAX_EXP
3216       *nv_return = FLT_MAX_EXP;
3217       return PERL_constant_ISNV;
3218 #else
3219       return PERL_constant_NOTDEF;
3220 #endif
3221     }
3222     break;
3223   case 'D':
3224     if (memEQ(name, "EWOULDBLOCK", 11)) {
3225     /*                    ^            */
3226 #ifdef EWOULDBLOCK
3227       *iv_return = EWOULDBLOCK;
3228       return PERL_constant_ISIV;
3229 #else
3230       return PERL_constant_NOTDEF;
3231 #endif
3232     }
3233     break;
3234   case 'E':
3235     if (memEQ(name, "SIG_SETMASK", 11)) {
3236     /*                    ^            */
3237 #ifdef SIG_SETMASK
3238       *iv_return = SIG_SETMASK;
3239       return PERL_constant_ISIV;
3240 #else
3241       return PERL_constant_NOTDEF;
3242 #endif
3243     }
3244     if (memEQ(name, "_SC_VERSION", 11)) {
3245     /*                    ^            */
3246 #ifdef _SC_VERSION
3247       *iv_return = _SC_VERSION;
3248       return PERL_constant_ISIV;
3249 #else
3250       return PERL_constant_NOTDEF;
3251 #endif
3252     }
3253     break;
3254   case 'I':
3255     if (memEQ(name, "DBL_MIN_EXP", 11)) {
3256     /*                    ^            */
3257 #ifdef DBL_MIN_EXP
3258       *nv_return = DBL_MIN_EXP;
3259       return PERL_constant_ISNV;
3260 #else
3261       return PERL_constant_NOTDEF;
3262 #endif
3263     }
3264     if (memEQ(name, "FLT_MIN_EXP", 11)) {
3265     /*                    ^            */
3266 #ifdef FLT_MIN_EXP
3267       *nv_return = FLT_MIN_EXP;
3268       return PERL_constant_ISNV;
3269 #else
3270       return PERL_constant_NOTDEF;
3271 #endif
3272     }
3273     break;
3274   case 'L':
3275     if (memEQ(name, "_SC_CLK_TCK", 11)) {
3276     /*                    ^            */
3277 #ifdef _SC_CLK_TCK
3278       *iv_return = _SC_CLK_TCK;
3279       return PERL_constant_ISIV;
3280 #else
3281       return PERL_constant_NOTDEF;
3282 #endif
3283     }
3284     break;
3285   case 'N':
3286     if (memEQ(name, "ENETUNREACH", 11)) {
3287     /*                    ^            */
3288 #ifdef ENETUNREACH
3289       *iv_return = ENETUNREACH;
3290       return PERL_constant_ISIV;
3291 #else
3292       return PERL_constant_NOTDEF;
3293 #endif
3294     }
3295     if (memEQ(name, "LC_MONETARY", 11)) {
3296     /*                    ^            */
3297 #ifdef LC_MONETARY
3298       *iv_return = LC_MONETARY;
3299       return PERL_constant_ISIV;
3300 #else
3301       return PERL_constant_NOTDEF;
3302 #endif
3303     }
3304     if (memEQ(name, "SIG_UNBLOCK", 11)) {
3305     /*                    ^            */
3306 #ifdef SIG_UNBLOCK
3307       *iv_return = SIG_UNBLOCK;
3308       return PERL_constant_ISIV;
3309 #else
3310       return PERL_constant_NOTDEF;
3311 #endif
3312     }
3313     break;
3314   case 'O':
3315     if (memEQ(name, "EINPROGRESS", 11)) {
3316     /*                    ^            */
3317 #ifdef EINPROGRESS
3318       *iv_return = EINPROGRESS;
3319       return PERL_constant_ISIV;
3320 #else
3321       return PERL_constant_NOTDEF;
3322 #endif
3323     }
3324     if (memEQ(name, "ENOPROTOOPT", 11)) {
3325     /*                    ^            */
3326 #ifdef ENOPROTOOPT
3327       *iv_return = ENOPROTOOPT;
3328       return PERL_constant_ISIV;
3329 #else
3330       return PERL_constant_NOTDEF;
3331 #endif
3332     }
3333     break;
3334   case 'P':
3335     if (memEQ(name, "DBL_EPSILON", 11)) {
3336     /*                    ^            */
3337 #ifdef DBL_EPSILON
3338       *nv_return = DBL_EPSILON;
3339       return PERL_constant_ISNV;
3340 #else
3341       return PERL_constant_NOTDEF;
3342 #endif
3343     }
3344     if (memEQ(name, "FLT_EPSILON", 11)) {
3345     /*                    ^            */
3346 #ifdef FLT_EPSILON
3347       *nv_return = FLT_EPSILON;
3348       return PERL_constant_ISNV;
3349 #else
3350       return PERL_constant_NOTDEF;
3351 #endif
3352     }
3353     if (memEQ(name, "NGROUPS_MAX", 11)) {
3354     /*                    ^            */
3355 #ifdef NGROUPS_MAX
3356       *iv_return = NGROUPS_MAX;
3357       return PERL_constant_ISIV;
3358 #else
3359       return PERL_constant_NOTDEF;
3360 #endif
3361     }
3362     break;
3363   case 'R':
3364     if (memEQ(name, "_SC_ARG_MAX", 11)) {
3365     /*                    ^            */
3366 #ifdef _SC_ARG_MAX
3367       *iv_return = _SC_ARG_MAX;
3368       return PERL_constant_ISIV;
3369 #else
3370       return PERL_constant_NOTDEF;
3371 #endif
3372     }
3373     break;
3374   case 'S':
3375     if (memEQ(name, "LC_MESSAGES", 11)) {
3376     /*                    ^            */
3377 #ifdef LC_MESSAGES
3378       *iv_return = LC_MESSAGES;
3379       return PERL_constant_ISIV;
3380 #else
3381       return PERL_constant_NOTDEF;
3382 #endif
3383     }
3384     break;
3385   }
3386   return PERL_constant_NOTFOUND;
3387 }
3388
3389 static int
3390 constant_12 (const char *name, IV *iv_return, NV *nv_return) {
3391   /* When generated this function returned values for the list of names given
3392      here.  However, subsequent manual editing may have added or removed some.
3393      DBL_MANT_DIG EAFNOSUPPORT ECONNABORTED ECONNREFUSED EDESTADDRREQ
3394      EHOSTUNREACH ENAMETOOLONG EPFNOSUPPORT ETOOMANYREFS EXIT_FAILURE
3395      EXIT_SUCCESS FILENAME_MAX FLT_MANT_DIG LDBL_EPSILON LDBL_MAX_EXP
3396      LDBL_MIN_EXP SA_NOCLDSTOP SA_NOCLDWAIT SA_RESETHAND STDIN_FILENO
3397      _PC_LINK_MAX _PC_NAME_MAX _PC_NO_TRUNC _PC_PATH_MAX _PC_PIPE_BUF
3398      _PC_VDISABLE _SC_OPEN_MAX */
3399   /* Offset 7 gives the best switch position.  */
3400   switch (name[7]) {
3401   case 'C':
3402     if (memEQ(name, "EXIT_SUCCESS", 12)) {
3403     /*                      ^           */
3404 #ifdef EXIT_SUCCESS
3405       *iv_return = EXIT_SUCCESS;
3406       return PERL_constant_ISIV;
3407 #else
3408       *iv_return = 0;
3409       return PERL_constant_ISIV;
3410 #endif
3411     }
3412     break;
3413   case 'D':
3414     if (memEQ(name, "EDESTADDRREQ", 12)) {
3415     /*                      ^           */
3416 #ifdef EDESTADDRREQ
3417       *iv_return = EDESTADDRREQ;
3418       return PERL_constant_ISIV;
3419 #else
3420       return PERL_constant_NOTDEF;
3421 #endif
3422     }
3423     if (memEQ(name, "SA_NOCLDSTOP", 12)) {
3424     /*                      ^           */
3425 #ifdef SA_NOCLDSTOP
3426       *iv_return = (IV) SA_NOCLDSTOP;
3427       return PERL_constant_ISUV;
3428 #else
3429       return PERL_constant_NOTDEF;
3430 #endif
3431     }
3432     if (memEQ(name, "SA_NOCLDWAIT", 12)) {
3433     /*                      ^           */
3434 #ifdef SA_NOCLDWAIT
3435       *iv_return = (IV) SA_NOCLDWAIT;
3436       return PERL_constant_ISUV;
3437 #else
3438       return PERL_constant_NOTDEF;
3439 #endif
3440     }
3441     break;
3442   case 'E':
3443     if (memEQ(name, "FILENAME_MAX", 12)) {
3444     /*                      ^           */
3445 #ifdef FILENAME_MAX
3446       *iv_return = FILENAME_MAX;
3447       return PERL_constant_ISIV;
3448 #else
3449       return PERL_constant_NOTDEF;
3450 #endif
3451     }
3452     if (memEQ(name, "_PC_NAME_MAX", 12)) {
3453     /*                      ^           */
3454 #ifdef _PC_NAME_MAX
3455       *iv_return = _PC_NAME_MAX;
3456       return PERL_constant_ISIV;
3457 #else
3458       return PERL_constant_NOTDEF;
3459 #endif
3460     }
3461     if (memEQ(name, "_PC_PIPE_BUF", 12)) {
3462     /*                      ^           */
3463 #ifdef _PC_PIPE_BUF
3464       *iv_return = _PC_PIPE_BUF;
3465       return PERL_constant_ISIV;
3466 #else
3467       return PERL_constant_NOTDEF;
3468 #endif
3469     }
3470     break;
3471   case 'F':
3472     if (memEQ(name, "ECONNREFUSED", 12)) {
3473     /*                      ^           */
3474 #ifdef ECONNREFUSED
3475       *iv_return = ECONNREFUSED;
3476       return PERL_constant_ISIV;
3477 #else
3478       return PERL_constant_NOTDEF;
3479 #endif
3480     }
3481     break;
3482   case 'H':
3483     if (memEQ(name, "_PC_PATH_MAX", 12)) {
3484     /*                      ^           */
3485 #ifdef _PC_PATH_MAX
3486       *iv_return = _PC_PATH_MAX;
3487       return PERL_constant_ISIV;
3488 #else
3489       return PERL_constant_NOTDEF;
3490 #endif
3491     }
3492     break;
3493   case 'I':
3494     if (memEQ(name, "EXIT_FAILURE", 12)) {
3495     /*                      ^           */
3496 #ifdef EXIT_FAILURE
3497       *iv_return = EXIT_FAILURE;
3498       return PERL_constant_ISIV;
3499 #else
3500       *iv_return = 1;
3501       return PERL_constant_ISIV;
3502 #endif
3503     }
3504     if (memEQ(name, "STDIN_FILENO", 12)) {
3505     /*                      ^           */
3506 #ifdef STDIN_FILENO
3507       *iv_return = STDIN_FILENO;
3508       return PERL_constant_ISIV;
3509 #else
3510       return PERL_constant_NOTDEF;
3511 #endif
3512     }
3513     break;
3514   case 'K':
3515     if (memEQ(name, "_PC_LINK_MAX", 12)) {
3516     /*                      ^           */
3517 #ifdef _PC_LINK_MAX
3518       *iv_return = _PC_LINK_MAX;
3519       return PERL_constant_ISIV;
3520 #else
3521       return PERL_constant_NOTDEF;
3522 #endif
3523     }
3524     break;
3525   case 'N':
3526     if (memEQ(name, "LDBL_MIN_EXP", 12)) {
3527     /*                      ^           */
3528 #ifdef LDBL_MIN_EXP
3529       *nv_return = LDBL_MIN_EXP;
3530       return PERL_constant_ISNV;
3531 #else
3532       return PERL_constant_NOTDEF;
3533 #endif
3534     }
3535     if (memEQ(name, "_SC_OPEN_MAX", 12)) {
3536     /*                      ^           */
3537 #ifdef _SC_OPEN_MAX
3538       *iv_return = _SC_OPEN_MAX;
3539       return PERL_constant_ISIV;
3540 #else
3541       return PERL_constant_NOTDEF;
3542 #endif
3543     }
3544     break;
3545   case 'O':
3546     if (memEQ(name, "ECONNABORTED", 12)) {
3547     /*                      ^           */
3548 #ifdef ECONNABORTED
3549       *iv_return = ECONNABORTED;
3550       return PERL_constant_ISIV;
3551 #else
3552       return PERL_constant_NOTDEF;
3553 #endif
3554     }
3555     if (memEQ(name, "ENAMETOOLONG", 12)) {
3556     /*                      ^           */
3557 #ifdef ENAMETOOLONG
3558       *iv_return = ENAMETOOLONG;
3559       return PERL_constant_ISIV;
3560 #else
3561       return PERL_constant_NOTDEF;
3562 #endif
3563     }
3564     break;
3565   case 'P':
3566     if (memEQ(name, "EAFNOSUPPORT", 12)) {
3567     /*                      ^           */
3568 #ifdef EAFNOSUPPORT
3569       *iv_return = EAFNOSUPPORT;
3570       return PERL_constant_ISIV;
3571 #else
3572       return PERL_constant_NOTDEF;
3573 #endif
3574     }
3575     if (memEQ(name, "EPFNOSUPPORT", 12)) {
3576     /*                      ^           */
3577 #ifdef EPFNOSUPPORT
3578       *iv_return = EPFNOSUPPORT;
3579       return PERL_constant_ISIV;
3580 #else
3581       return PERL_constant_NOTDEF;
3582 #endif
3583     }
3584     break;
3585   case 'R':
3586     if (memEQ(name, "EHOSTUNREACH", 12)) {
3587     /*                      ^           */
3588 #ifdef EHOSTUNREACH
3589       *iv_return = EHOSTUNREACH;
3590       return PERL_constant_ISIV;
3591 #else
3592       return PERL_constant_NOTDEF;
3593 #endif
3594     }
3595     break;
3596   case 'S':
3597     if (memEQ(name, "LDBL_EPSILON", 12)) {
3598     /*                      ^           */
3599 #ifdef LDBL_EPSILON
3600       *nv_return = LDBL_EPSILON;
3601       return PERL_constant_ISNV;
3602 #else
3603       return PERL_constant_NOTDEF;
3604 #endif
3605     }
3606     if (memEQ(name, "_PC_VDISABLE", 12)) {
3607     /*                      ^           */
3608 #ifdef _PC_VDISABLE
3609       *iv_return = _PC_VDISABLE;
3610       return PERL_constant_ISIV;
3611 #else
3612       return PERL_constant_NOTDEF;
3613 #endif
3614     }
3615     break;
3616   case 'T':
3617     if (memEQ(name, "DBL_MANT_DIG", 12)) {
3618     /*                      ^           */
3619 #ifdef DBL_MANT_DIG
3620       *nv_return = DBL_MANT_DIG;
3621       return PERL_constant_ISNV;
3622 #else
3623       return PERL_constant_NOTDEF;
3624 #endif
3625     }
3626     if (memEQ(name, "FLT_MANT_DIG", 12)) {
3627     /*                      ^           */
3628 #ifdef FLT_MANT_DIG
3629       *nv_return = FLT_MANT_DIG;
3630       return PERL_constant_ISNV;
3631 #else
3632       return PERL_constant_NOTDEF;
3633 #endif
3634     }
3635     if (memEQ(name, "SA_RESETHAND", 12)) {
3636     /*                      ^           */
3637 #ifdef SA_RESETHAND
3638       *iv_return = (IV) SA_RESETHAND;
3639       return PERL_constant_ISUV;
3640 #else
3641       return PERL_constant_NOTDEF;
3642 #endif
3643     }
3644     if (memEQ(name, "_PC_NO_TRUNC", 12)) {
3645     /*                      ^           */
3646 #ifdef _PC_NO_TRUNC
3647       *iv_return = _PC_NO_TRUNC;
3648       return PERL_constant_ISIV;
3649 #else
3650       return PERL_constant_NOTDEF;
3651 #endif
3652     }
3653     break;
3654   case 'X':
3655     if (memEQ(name, "LDBL_MAX_EXP", 12)) {
3656     /*                      ^           */
3657 #ifdef LDBL_MAX_EXP
3658       *nv_return = LDBL_MAX_EXP;
3659       return PERL_constant_ISNV;
3660 #else
3661       return PERL_constant_NOTDEF;
3662 #endif
3663     }
3664     break;
3665   case 'Y':
3666     if (memEQ(name, "ETOOMANYREFS", 12)) {
3667     /*                      ^           */
3668 #ifdef ETOOMANYREFS
3669       *iv_return = ETOOMANYREFS;
3670       return PERL_constant_ISIV;
3671 #else
3672       return PERL_constant_NOTDEF;
3673 #endif
3674     }
3675     break;
3676   }
3677   return PERL_constant_NOTFOUND;
3678 }
3679
3680 static int
3681 constant_13 (const char *name, IV *iv_return, NV *nv_return) {
3682   /* When generated this function returned values for the list of names given
3683      here.  However, subsequent manual editing may have added or removed some.
3684      EADDRNOTAVAIL LDBL_MANT_DIG STDERR_FILENO STDOUT_FILENO _PC_MAX_CANON
3685      _PC_MAX_INPUT _SC_CHILD_MAX _SC_SAVED_IDS */
3686   /* Offset 10 gives the best switch position.  */
3687   switch (name[10]) {
3688   case 'A':
3689     if (memEQ(name, "EADDRNOTAVAIL", 13)) {
3690     /*                         ^         */
3691 #ifdef EADDRNOTAVAIL
3692       *iv_return = EADDRNOTAVAIL;
3693       return PERL_constant_ISIV;
3694 #else
3695       return PERL_constant_NOTDEF;
3696 #endif
3697     }
3698     break;
3699   case 'D':
3700     if (memEQ(name, "LDBL_MANT_DIG", 13)) {
3701     /*                         ^         */
3702 #ifdef LDBL_MANT_DIG
3703       *nv_return = LDBL_MANT_DIG;
3704       return PERL_constant_ISNV;
3705 #else
3706       return PERL_constant_NOTDEF;
3707 #endif
3708     }
3709     break;
3710   case 'E':
3711     if (memEQ(name, "STDERR_FILENO", 13)) {
3712     /*                         ^         */
3713 #ifdef STDERR_FILENO
3714       *iv_return = STDERR_FILENO;
3715       return PERL_constant_ISIV;
3716 #else
3717       return PERL_constant_NOTDEF;
3718 #endif
3719     }
3720     if (memEQ(name, "STDOUT_FILENO", 13)) {
3721     /*                         ^         */
3722 #ifdef STDOUT_FILENO
3723       *iv_return = STDOUT_FILENO;
3724       return PERL_constant_ISIV;
3725 #else
3726       return PERL_constant_NOTDEF;
3727 #endif
3728     }
3729     break;
3730   case 'I':
3731     if (memEQ(name, "_SC_SAVED_IDS", 13)) {
3732     /*                         ^         */
3733 #ifdef _SC_SAVED_IDS
3734       *iv_return = _SC_SAVED_IDS;
3735       return PERL_constant_ISIV;
3736 #else
3737       return PERL_constant_NOTDEF;
3738 #endif
3739     }
3740     break;
3741   case 'M':
3742     if (memEQ(name, "_SC_CHILD_MAX", 13)) {
3743     /*                         ^         */
3744 #ifdef _SC_CHILD_MAX
3745       *iv_return = _SC_CHILD_MAX;
3746       return PERL_constant_ISIV;
3747 #else
3748       return PERL_constant_NOTDEF;
3749 #endif
3750     }
3751     break;
3752   case 'N':
3753     if (memEQ(name, "_PC_MAX_CANON", 13)) {
3754     /*                         ^         */
3755 #ifdef _PC_MAX_CANON
3756       *iv_return = _PC_MAX_CANON;
3757       return PERL_constant_ISIV;
3758 #else
3759       return PERL_constant_NOTDEF;
3760 #endif
3761     }
3762     break;
3763   case 'P':
3764     if (memEQ(name, "_PC_MAX_INPUT", 13)) {
3765     /*                         ^         */
3766 #ifdef _PC_MAX_INPUT
3767       *iv_return = _PC_MAX_INPUT;
3768       return PERL_constant_ISIV;
3769 #else
3770       return PERL_constant_NOTDEF;
3771 #endif
3772     }
3773     break;
3774   }
3775   return PERL_constant_NOTFOUND;
3776 }
3777
3778 static int
3779 constant_14 (const char *name, IV *iv_return, NV *nv_return) {
3780   /* When generated this function returned values for the list of names given
3781      here.  However, subsequent manual editing may have added or removed some.
3782      CLOCKS_PER_SEC DBL_MAX_10_EXP DBL_MIN_10_EXP FLT_MAX_10_EXP FLT_MIN_10_EXP
3783      _POSIX_ARG_MAX _POSIX_VERSION _SC_STREAM_MAX _SC_TZNAME_MAX */
3784   /* Offset 5 gives the best switch position.  */
3785   switch (name[5]) {
3786   case 'A':
3787     if (memEQ(name, "DBL_MAX_10_EXP", 14)) {
3788     /*                    ^               */
3789 #ifdef DBL_MAX_10_EXP
3790       *nv_return = DBL_MAX_10_EXP;
3791       return PERL_constant_ISNV;
3792 #else
3793       return PERL_constant_NOTDEF;
3794 #endif
3795     }
3796     if (memEQ(name, "FLT_MAX_10_EXP", 14)) {
3797     /*                    ^               */
3798 #ifdef FLT_MAX_10_EXP
3799       *nv_return = FLT_MAX_10_EXP;
3800       return PERL_constant_ISNV;
3801 #else
3802       return PERL_constant_NOTDEF;
3803 #endif
3804     }
3805     break;
3806   case 'I':
3807     if (memEQ(name, "DBL_MIN_10_EXP", 14)) {
3808     /*                    ^               */
3809 #ifdef DBL_MIN_10_EXP
3810       *nv_return = DBL_MIN_10_EXP;
3811       return PERL_constant_ISNV;
3812 #else
3813       return PERL_constant_NOTDEF;
3814 #endif
3815     }
3816     if (memEQ(name, "FLT_MIN_10_EXP", 14)) {
3817     /*                    ^               */
3818 #ifdef FLT_MIN_10_EXP
3819       *nv_return = FLT_MIN_10_EXP;
3820       return PERL_constant_ISNV;
3821 #else
3822       return PERL_constant_NOTDEF;
3823 #endif
3824     }
3825     break;
3826   case 'S':
3827     if (memEQ(name, "CLOCKS_PER_SEC", 14)) {
3828     /*                    ^               */
3829 #ifdef CLOCKS_PER_SEC
3830       *iv_return = CLOCKS_PER_SEC;
3831       return PERL_constant_ISIV;
3832 #else
3833       return PERL_constant_NOTDEF;
3834 #endif
3835     }
3836     break;
3837   case 'T':
3838     if (memEQ(name, "_SC_STREAM_MAX", 14)) {
3839     /*                    ^               */
3840 #ifdef _SC_STREAM_MAX
3841       *iv_return = _SC_STREAM_MAX;
3842       return PERL_constant_ISIV;
3843 #else
3844       return PERL_constant_NOTDEF;
3845 #endif
3846     }
3847     break;
3848   case 'X':
3849     if (memEQ(name, "_POSIX_ARG_MAX", 14)) {
3850     /*                    ^               */
3851 #ifdef _POSIX_ARG_MAX
3852       *iv_return = _POSIX_ARG_MAX;
3853       return PERL_constant_ISIV;
3854 #else
3855       *iv_return = 0;
3856       return PERL_constant_ISIV;
3857 #endif
3858     }
3859     if (memEQ(name, "_POSIX_VERSION", 14)) {
3860     /*                    ^               */
3861 #ifdef _POSIX_VERSION
3862       *iv_return = _POSIX_VERSION;
3863       return PERL_constant_ISIV;
3864 #else
3865       *iv_return = 0;
3866       return PERL_constant_ISIV;
3867 #endif
3868     }
3869     break;
3870   case 'Z':
3871     if (memEQ(name, "_SC_TZNAME_MAX", 14)) {
3872     /*                    ^               */
3873 #ifdef _SC_TZNAME_MAX
3874       *iv_return = _SC_TZNAME_MAX;
3875       return PERL_constant_ISIV;
3876 #else
3877       return PERL_constant_NOTDEF;
3878 #endif
3879     }
3880     break;
3881   }
3882   return PERL_constant_NOTFOUND;
3883 }
3884
3885 static int
3886 constant_15 (const char *name, IV *iv_return, NV *nv_return) {
3887   /* When generated this function returned values for the list of names given
3888      here.  However, subsequent manual editing may have added or removed some.
3889      EPROTONOSUPPORT ESOCKTNOSUPPORT LDBL_MAX_10_EXP LDBL_MIN_10_EXP
3890      _POSIX_LINK_MAX _POSIX_NAME_MAX _POSIX_NO_TRUNC _POSIX_OPEN_MAX
3891      _POSIX_PATH_MAX _POSIX_PIPE_BUF _POSIX_VDISABLE _SC_JOB_CONTROL
3892      _SC_NGROUPS_MAX */
3893   /* Offset 9 gives the best switch position.  */
3894   switch (name[9]) {
3895   case '1':
3896     if (memEQ(name, "LDBL_MAX_10_EXP", 15)) {
3897     /*                        ^            */
3898 #ifdef LDBL_MAX_10_EXP
3899       *nv_return = LDBL_MAX_10_EXP;
3900       return PERL_constant_ISNV;
3901 #else
3902       return PERL_constant_NOTDEF;
3903 #endif
3904     }
3905     if (memEQ(name, "LDBL_MIN_10_EXP", 15)) {
3906     /*                        ^            */
3907 #ifdef LDBL_MIN_10_EXP
3908       *nv_return = LDBL_MIN_10_EXP;
3909       return PERL_constant_ISNV;
3910 #else
3911       return PERL_constant_NOTDEF;
3912 #endif
3913     }
3914     break;
3915   case 'E':
3916     if (memEQ(name, "_POSIX_OPEN_MAX", 15)) {
3917     /*                        ^            */
3918 #ifdef _POSIX_OPEN_MAX
3919       *iv_return = _POSIX_OPEN_MAX;
3920       return PERL_constant_ISIV;
3921 #else
3922       *iv_return = 0;
3923       return PERL_constant_ISIV;
3924 #endif
3925     }
3926     break;
3927   case 'I':
3928     if (memEQ(name, "_POSIX_VDISABLE", 15)) {
3929     /*                        ^            */
3930 #ifdef _POSIX_VDISABLE
3931       *iv_return = _POSIX_VDISABLE;
3932       return PERL_constant_ISIV;
3933 #else
3934       *iv_return = 0;
3935       return PERL_constant_ISIV;
3936 #endif
3937     }
3938     break;
3939   case 'M':
3940     if (memEQ(name, "_POSIX_NAME_MAX", 15)) {
3941     /*                        ^            */
3942 #ifdef _POSIX_NAME_MAX
3943       *iv_return = _POSIX_NAME_MAX;
3944       return PERL_constant_ISIV;
3945 #else
3946       *iv_return = 0;
3947       return PERL_constant_ISIV;
3948 #endif
3949     }
3950     break;
3951   case 'N':
3952     if (memEQ(name, "_POSIX_LINK_MAX", 15)) {
3953     /*                        ^            */
3954 #ifdef _POSIX_LINK_MAX
3955       *iv_return = _POSIX_LINK_MAX;
3956       return PERL_constant_ISIV;
3957 #else
3958       *iv_return = 0;
3959       return PERL_constant_ISIV;
3960 #endif
3961     }
3962     break;
3963   case 'O':
3964     if (memEQ(name, "_SC_JOB_CONTROL", 15)) {
3965     /*                        ^            */
3966 #ifdef _SC_JOB_CONTROL
3967       *iv_return = _SC_JOB_CONTROL;
3968       return PERL_constant_ISIV;
3969 #else
3970       return PERL_constant_NOTDEF;
3971 #endif
3972     }
3973     break;
3974   case 'P':
3975     if (memEQ(name, "_POSIX_PIPE_BUF", 15)) {
3976     /*                        ^            */
3977 #ifdef _POSIX_PIPE_BUF
3978       *iv_return = _POSIX_PIPE_BUF;
3979       return PERL_constant_ISIV;
3980 #else
3981       *iv_return = 0;
3982       return PERL_constant_ISIV;
3983 #endif
3984     }
3985     if (memEQ(name, "_SC_NGROUPS_MAX", 15)) {
3986     /*                        ^            */
3987 #ifdef _SC_NGROUPS_MAX
3988       *iv_return = _SC_NGROUPS_MAX;
3989       return PERL_constant_ISIV;
3990 #else
3991       return PERL_constant_NOTDEF;
3992 #endif
3993     }
3994     break;
3995   case 'T':
3996     if (memEQ(name, "_POSIX_PATH_MAX", 15)) {
3997     /*                        ^            */
3998 #ifdef _POSIX_PATH_MAX
3999       *iv_return = _POSIX_PATH_MAX;
4000       return PERL_constant_ISIV;
4001 #else
4002       *iv_return = 0;
4003       return PERL_constant_ISIV;
4004 #endif
4005     }
4006     break;
4007   case 'U':
4008     if (memEQ(name, "EPROTONOSUPPORT", 15)) {
4009     /*                        ^            */
4010 #ifdef EPROTONOSUPPORT
4011       *iv_return = EPROTONOSUPPORT;
4012       return PERL_constant_ISIV;
4013 #else
4014       return PERL_constant_NOTDEF;
4015 #endif
4016     }
4017     if (memEQ(name, "ESOCKTNOSUPPORT", 15)) {
4018     /*                        ^            */
4019 #ifdef ESOCKTNOSUPPORT
4020       *iv_return = ESOCKTNOSUPPORT;
4021       return PERL_constant_ISIV;
4022 #else
4023       return PERL_constant_NOTDEF;
4024 #endif
4025     }
4026     break;
4027   case '_':
4028     if (memEQ(name, "_POSIX_NO_TRUNC", 15)) {
4029     /*                        ^            */
4030 #ifdef _POSIX_NO_TRUNC
4031       *iv_return = _POSIX_NO_TRUNC;
4032       return PERL_constant_ISIV;
4033 #else
4034       *iv_return = 0;
4035       return PERL_constant_ISIV;
4036 #endif
4037     }
4038     break;
4039   }
4040   return PERL_constant_NOTFOUND;
4041 }
4042
4043 static int
4044 constant_16 (const char *name, IV *iv_return, NV *nv_return) {
4045   /* When generated this function returned values for the list of names given
4046      here.  However, subsequent manual editing may have added or removed some.
4047      _POSIX_CHILD_MAX _POSIX_MAX_CANON _POSIX_MAX_INPUT _POSIX_SAVED_IDS
4048      _POSIX_SSIZE_MAX */
4049   /* Offset 11 gives the best switch position.  */
4050   switch (name[11]) {
4051   case 'C':
4052     if (memEQ(name, "_POSIX_MAX_CANON", 16)) {
4053     /*                          ^           */
4054 #ifdef _POSIX_MAX_CANON
4055       *iv_return = _POSIX_MAX_CANON;
4056       return PERL_constant_ISIV;
4057 #else
4058       *iv_return = 0;
4059       return PERL_constant_ISIV;
4060 #endif
4061     }
4062     break;
4063   case 'D':
4064     if (memEQ(name, "_POSIX_CHILD_MAX", 16)) {
4065     /*                          ^           */
4066 #ifdef _POSIX_CHILD_MAX
4067       *iv_return = _POSIX_CHILD_MAX;
4068       return PERL_constant_ISIV;
4069 #else
4070       *iv_return = 0;
4071       return PERL_constant_ISIV;
4072 #endif
4073     }
4074     if (memEQ(name, "_POSIX_SAVED_IDS", 16)) {
4075     /*                          ^           */
4076 #ifdef _POSIX_SAVED_IDS
4077       *iv_return = 1;
4078       return PERL_constant_ISIV;
4079 #else
4080       *iv_return = 0;
4081       return PERL_constant_ISIV;
4082 #endif
4083     }
4084     break;
4085   case 'E':
4086     if (memEQ(name, "_POSIX_SSIZE_MAX", 16)) {
4087     /*                          ^           */
4088 #ifdef _POSIX_SSIZE_MAX
4089       *iv_return = _POSIX_SSIZE_MAX;
4090       return PERL_constant_ISIV;
4091 #else
4092       *iv_return = 0;
4093       return PERL_constant_ISIV;
4094 #endif
4095     }
4096     break;
4097   case 'I':
4098     if (memEQ(name, "_POSIX_MAX_INPUT", 16)) {
4099     /*                          ^           */
4100 #ifdef _POSIX_MAX_INPUT
4101       *iv_return = _POSIX_MAX_INPUT;
4102       return PERL_constant_ISIV;
4103 #else
4104       *iv_return = 0;
4105       return PERL_constant_ISIV;
4106 #endif
4107     }
4108     break;
4109   }
4110   return PERL_constant_NOTFOUND;
4111 }
4112
4113 static int
4114 constant (const char *name, STRLEN len, IV *iv_return, NV *nv_return) {
4115   /* Initially switch on the length of the name.  */
4116   /* When generated this function returned values for the list of names given
4117      in this section of perl code.  Rather than manually editing these functions
4118      to add or remove constants, which would result in this comment and section
4119      of code becoming inaccurate, we recommend that you edit this section of
4120      code, and use it to regenerate a new set of constant functions which you
4121      then use to replace the originals.
4122
4123      Regenerate these constant functions by feeding this entire source file to
4124      perl -x
4125
4126 #!../../perl -w
4127 use ExtUtils::Constant qw (constant_types C_constant XS_constant);
4128
4129 my $types = {map {($_, 1)} qw(IV NV UV)};
4130 my @names = (qw(ARG_MAX B0 B110 B1200 B134 B150 B1800 B19200 B200 B2400 B300
4131                B38400 B4800 B50 B600 B75 B9600 BRKINT BUFSIZ CHAR_BIT CHAR_MAX
4132                CHAR_MIN CHILD_MAX CLK_TCK CLOCAL CLOCKS_PER_SEC CREAD CS5 CS6
4133                CS7 CS8 CSIZE CSTOPB E2BIG EACCES EADDRINUSE EADDRNOTAVAIL
4134                EAFNOSUPPORT EAGAIN EALREADY EBADF EBUSY ECHILD ECHO ECHOE ECHOK
4135                ECHONL ECONNABORTED ECONNREFUSED ECONNRESET EDEADLK EDESTADDRREQ
4136                EDOM EDQUOT EEXIST EFAULT EFBIG EHOSTDOWN EHOSTUNREACH
4137                EINPROGRESS EINTR EINVAL EIO EISCONN EISDIR ELOOP EMFILE EMLINK
4138                EMSGSIZE ENAMETOOLONG ENETDOWN ENETRESET ENETUNREACH ENFILE
4139                ENOBUFS ENODEV ENOENT ENOEXEC ENOLCK ENOMEM ENOPROTOOPT ENOSPC
4140                ENOSYS ENOTBLK ENOTCONN ENOTDIR ENOTEMPTY ENOTSOCK ENOTTY ENXIO
4141                EOF EOPNOTSUPP EPERM EPFNOSUPPORT EPIPE EPROCLIM EPROTONOSUPPORT
4142                EPROTOTYPE ERANGE EREMOTE ERESTART EROFS ESHUTDOWN
4143                ESOCKTNOSUPPORT ESPIPE ESRCH ESTALE ETIMEDOUT ETOOMANYREFS
4144                ETXTBSY EUSERS EWOULDBLOCK EXDEV FD_CLOEXEC FILENAME_MAX F_DUPFD
4145                F_GETFD F_GETFL F_GETLK F_OK F_RDLCK F_SETFD F_SETFL F_SETLK
4146                F_SETLKW F_UNLCK F_WRLCK HUPCL ICANON ICRNL IEXTEN IGNBRK IGNCR
4147                IGNPAR INLCR INPCK INT_MAX INT_MIN ISIG ISTRIP IXOFF IXON LC_ALL
4148                LC_COLLATE LC_CTYPE LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME
4149                LINK_MAX LONG_MAX LONG_MIN L_ctermid L_cuserid L_tmpnam
4150                MAX_CANON MAX_INPUT MB_CUR_MAX MB_LEN_MAX NAME_MAX NCCS
4151                NGROUPS_MAX NOFLSH OPEN_MAX OPOST O_ACCMODE O_APPEND O_CREAT
4152                O_EXCL O_NOCTTY O_NONBLOCK O_RDONLY O_RDWR O_TRUNC O_WRONLY
4153                PARENB PARMRK PARODD PATH_MAX PIPE_BUF RAND_MAX R_OK SCHAR_MAX
4154                SCHAR_MIN SEEK_CUR SEEK_END SEEK_SET SHRT_MAX SHRT_MIN SIGABRT
4155                SIGALRM SIGCHLD SIGCONT SIGFPE SIGHUP SIGILL SIGINT SIGKILL
4156                SIGPIPE SIGQUIT SIGSEGV SIGSTOP SIGTERM SIGTSTP SIGTTIN SIGTTOU
4157                SIGUSR1 SIGUSR2 SIG_BLOCK SIG_SETMASK SIG_UNBLOCK SSIZE_MAX
4158                STDERR_FILENO STDIN_FILENO STDOUT_FILENO STREAM_MAX S_IRGRP
4159                S_IROTH S_IRUSR S_IRWXG S_IRWXO S_IRWXU S_ISGID S_ISUID S_IWGRP
4160                S_IWOTH S_IWUSR S_IXGRP S_IXOTH S_IXUSR TCIFLUSH TCIOFF
4161                TCIOFLUSH TCION TCOFLUSH TCOOFF TCOON TCSADRAIN TCSAFLUSH
4162                TCSANOW TMP_MAX TOSTOP TZNAME_MAX VEOF VEOL VERASE VINTR VKILL
4163                VMIN VQUIT VSTART VSTOP VSUSP VTIME WNOHANG WUNTRACED W_OK X_OK
4164                _PC_CHOWN_RESTRICTED _PC_LINK_MAX _PC_MAX_CANON _PC_MAX_INPUT
4165                _PC_NAME_MAX _PC_NO_TRUNC _PC_PATH_MAX _PC_PIPE_BUF _PC_VDISABLE
4166                _SC_ARG_MAX _SC_CHILD_MAX _SC_CLK_TCK _SC_JOB_CONTROL
4167                _SC_NGROUPS_MAX _SC_OPEN_MAX _SC_SAVED_IDS _SC_STREAM_MAX
4168                _SC_TZNAME_MAX _SC_VERSION),
4169             {name=>"DBL_DIG", type=>"NV"},
4170             {name=>"DBL_EPSILON", type=>"NV"},
4171             {name=>"DBL_MANT_DIG", type=>"NV"},
4172             {name=>"DBL_MAX", type=>"NV"},
4173             {name=>"DBL_MAX_10_EXP", type=>"NV"},
4174             {name=>"DBL_MAX_EXP", type=>"NV"},
4175             {name=>"DBL_MIN", type=>"NV"},
4176             {name=>"DBL_MIN_10_EXP", type=>"NV"},
4177             {name=>"DBL_MIN_EXP", type=>"NV"},
4178             {name=>"EXIT_FAILURE", type=>"IV", default=>["IV", "1"]},
4179             {name=>"EXIT_SUCCESS", type=>"IV", default=>["IV", "0"]},
4180             {name=>"FLT_DIG", type=>"NV"},
4181             {name=>"FLT_EPSILON", type=>"NV"},
4182             {name=>"FLT_MANT_DIG", type=>"NV"},
4183             {name=>"FLT_MAX", type=>"NV"},
4184             {name=>"FLT_MAX_10_EXP", type=>"NV"},
4185             {name=>"FLT_MAX_EXP", type=>"NV"},
4186             {name=>"FLT_MIN", type=>"NV"},
4187             {name=>"FLT_MIN_10_EXP", type=>"NV"},
4188             {name=>"FLT_MIN_EXP", type=>"NV"},
4189             {name=>"FLT_RADIX", type=>"NV"},
4190             {name=>"FLT_ROUNDS", type=>"NV"},
4191             {name=>"HUGE_VAL", type=>"NV", macro=>["#if (defined(USE_LONG_DOUBLE) && defined(HUGE_VALL)) || defined(HUGE_VAL)\n\t/" . "* HUGE_VALL is admittedly non-POSIX but if we are using long doubles\n\t * we might as well use long doubles. --jhi *" . "/\n", "#endif\n"], value=>"\n#if defined(USE_LONG_DOUBLE) && defined(HUGE_VALL)\n                   HUGE_VALL\n#else\n                   HUGE_VAL\n#endif\n                           "},
4192             {name=>"LDBL_DIG", type=>"NV"},
4193             {name=>"LDBL_EPSILON", type=>"NV"},
4194             {name=>"LDBL_MANT_DIG", type=>"NV"},
4195             {name=>"LDBL_MAX", type=>"NV"},
4196             {name=>"LDBL_MAX_10_EXP", type=>"NV"},
4197             {name=>"LDBL_MAX_EXP", type=>"NV"},
4198             {name=>"LDBL_MIN", type=>"NV"},
4199             {name=>"LDBL_MIN_10_EXP", type=>"NV"},
4200             {name=>"LDBL_MIN_EXP", type=>"NV"},
4201             {name=>"L_tmpname", type=>"IV", value=>"L_tmpnam"},
4202             {name=>"NULL", type=>"IV", value=>"0"},
4203             {name=>"SA_NOCLDSTOP", type=>"UV"},
4204             {name=>"SA_NOCLDWAIT", type=>"UV"},
4205             {name=>"SA_NODEFER", type=>"UV"},
4206             {name=>"SA_ONSTACK", type=>"UV"},
4207             {name=>"SA_RESETHAND", type=>"UV"},
4208             {name=>"SA_RESTART", type=>"UV"},
4209             {name=>"SA_SIGINFO", type=>"UV"},
4210             {name=>"SIG_DFL", type=>"IV", value=>"(IV)SIG_DFL"},
4211             {name=>"SIG_ERR", type=>"IV", value=>"(IV)SIG_ERR"},
4212             {name=>"SIG_IGN", type=>"IV", value=>"(IV)SIG_IGN"},
4213             {name=>"UCHAR_MAX", type=>"UV"},
4214             {name=>"UINT_MAX", type=>"UV"},
4215             {name=>"ULONG_MAX", type=>"UV"},
4216             {name=>"USHRT_MAX", type=>"UV"},
4217             {name=>"_POSIX_ARG_MAX", type=>"IV", default=>["IV", "0"]},
4218             {name=>"_POSIX_CHILD_MAX", type=>"IV", default=>["IV", "0"]},
4219             {name=>"_POSIX_CHOWN_RESTRICTED", type=>"IV", default=>["IV", "0"]},
4220             {name=>"_POSIX_JOB_CONTROL", type=>"IV", value=>"1", default=>["IV", "0"]},
4221             {name=>"_POSIX_LINK_MAX", type=>"IV", default=>["IV", "0"]},
4222             {name=>"_POSIX_MAX_CANON", type=>"IV", default=>["IV", "0"]},
4223             {name=>"_POSIX_MAX_INPUT", type=>"IV", default=>["IV", "0"]},
4224             {name=>"_POSIX_NAME_MAX", type=>"IV", default=>["IV", "0"]},
4225             {name=>"_POSIX_NGROUPS_MAX", type=>"IV", default=>["IV", "0"]},
4226             {name=>"_POSIX_NO_TRUNC", type=>"IV", default=>["IV", "0"]},
4227             {name=>"_POSIX_OPEN_MAX", type=>"IV", default=>["IV", "0"]},
4228             {name=>"_POSIX_PATH_MAX", type=>"IV", default=>["IV", "0"]},
4229             {name=>"_POSIX_PIPE_BUF", type=>"IV", default=>["IV", "0"]},
4230             {name=>"_POSIX_SAVED_IDS", type=>"IV", value=>"1", default=>["IV", "0"]},
4231             {name=>"_POSIX_SSIZE_MAX", type=>"IV", default=>["IV", "0"]},
4232             {name=>"_POSIX_STREAM_MAX", type=>"IV", default=>["IV", "0"]},
4233             {name=>"_POSIX_TZNAME_MAX", type=>"IV", default=>["IV", "0"]},
4234             {name=>"_POSIX_VDISABLE", type=>"IV", default=>["IV", "0"]},
4235             {name=>"_POSIX_VERSION", type=>"IV", default=>["IV", "0"]});
4236
4237 print constant_types(); # macro defs
4238 foreach (C_constant ("POSIX", 'constant', 'IV', $types, undef, 3, @names) ) {
4239     print $_, "\n"; # C constant subs
4240 }
4241 print "#### XS Section:\n";
4242 print XS_constant ("POSIX", $types);
4243 __END__
4244    */
4245
4246   switch (len) {
4247   case 2:
4248     if (memEQ(name, "B0", 2)) {
4249 #ifdef B0
4250       *iv_return = B0;
4251       return PERL_constant_ISIV;
4252 #else
4253       return PERL_constant_NOTDEF;
4254 #endif
4255     }
4256     break;
4257   case 3:
4258     return constant_3 (name, iv_return, nv_return);
4259     break;
4260   case 4:
4261     return constant_4 (name, iv_return, nv_return);
4262     break;
4263   case 5:
4264     return constant_5 (name, iv_return, nv_return);
4265     break;
4266   case 6:
4267     return constant_6 (name, iv_return, nv_return);
4268     break;
4269   case 7:
4270     return constant_7 (name, iv_return, nv_return);
4271     break;
4272   case 8:
4273     return constant_8 (name, iv_return, nv_return);
4274     break;
4275   case 9:
4276     return constant_9 (name, iv_return, nv_return);
4277     break;
4278   case 10:
4279     return constant_10 (name, iv_return, nv_return);
4280     break;
4281   case 11:
4282     return constant_11 (name, iv_return, nv_return);
4283     break;
4284   case 12:
4285     return constant_12 (name, iv_return, nv_return);
4286     break;
4287   case 13:
4288     return constant_13 (name, iv_return, nv_return);
4289     break;
4290   case 14:
4291     return constant_14 (name, iv_return, nv_return);
4292     break;
4293   case 15:
4294     return constant_15 (name, iv_return, nv_return);
4295     break;
4296   case 16:
4297     return constant_16 (name, iv_return, nv_return);
4298     break;
4299   case 17:
4300     /* Names all of length 17.  */
4301     /* _POSIX_STREAM_MAX _POSIX_TZNAME_MAX */
4302     /* Offset 7 gives the best switch position.  */
4303     switch (name[7]) {
4304     case 'S':
4305       if (memEQ(name, "_POSIX_STREAM_MAX", 17)) {
4306       /*                      ^                */
4307 #ifdef _POSIX_STREAM_MAX
4308         *iv_return = _POSIX_STREAM_MAX;
4309         return PERL_constant_ISIV;
4310 #else
4311         *iv_return = 0;
4312         return PERL_constant_ISIV;
4313 #endif
4314       }
4315       break;
4316     case 'T':
4317       if (memEQ(name, "_POSIX_TZNAME_MAX", 17)) {
4318       /*                      ^                */
4319 #ifdef _POSIX_TZNAME_MAX
4320         *iv_return = _POSIX_TZNAME_MAX;
4321         return PERL_constant_ISIV;
4322 #else
4323         *iv_return = 0;
4324         return PERL_constant_ISIV;
4325 #endif
4326       }
4327       break;
4328     }
4329     break;
4330   case 18:
4331     /* Names all of length 18.  */
4332     /* _POSIX_JOB_CONTROL _POSIX_NGROUPS_MAX */
4333     /* Offset 12 gives the best switch position.  */
4334     switch (name[12]) {
4335     case 'O':
4336       if (memEQ(name, "_POSIX_JOB_CONTROL", 18)) {
4337       /*                           ^            */
4338 #ifdef _POSIX_JOB_CONTROL
4339         *iv_return = 1;
4340         return PERL_constant_ISIV;
4341 #else
4342         *iv_return = 0;
4343         return PERL_constant_ISIV;
4344 #endif
4345       }
4346       break;
4347     case 'P':
4348       if (memEQ(name, "_POSIX_NGROUPS_MAX", 18)) {
4349       /*                           ^            */
4350 #ifdef _POSIX_NGROUPS_MAX
4351         *iv_return = _POSIX_NGROUPS_MAX;
4352         return PERL_constant_ISIV;
4353 #else
4354         *iv_return = 0;
4355         return PERL_constant_ISIV;
4356 #endif
4357       }
4358       break;
4359     }
4360     break;
4361   case 20:
4362     if (memEQ(name, "_PC_CHOWN_RESTRICTED", 20)) {
4363 #ifdef _PC_CHOWN_RESTRICTED
4364       *iv_return = _PC_CHOWN_RESTRICTED;
4365       return PERL_constant_ISIV;
4366 #else
4367       return PERL_constant_NOTDEF;
4368 #endif
4369     }
4370     break;
4371   case 23:
4372     if (memEQ(name, "_POSIX_CHOWN_RESTRICTED", 23)) {
4373 #ifdef _POSIX_CHOWN_RESTRICTED
4374       *iv_return = _POSIX_CHOWN_RESTRICTED;
4375       return PERL_constant_ISIV;
4376 #else
4377       *iv_return = 0;
4378       return PERL_constant_ISIV;
4379 #endif
4380     }
4381     break;
4382   }
4383   return PERL_constant_NOTFOUND;
4384 }
4385
4386 static void
4387 restore_sigmask(sigset_t *ossetp)
4388 {
4389             /* Fortunately, restoring the signal mask can't fail, because
4390              * there's nothing we can do about it if it does -- we're not
4391              * supposed to return -1 from sigaction unless the disposition
4392              * was unaffected.
4393              */
4394             (void)sigprocmask(SIG_SETMASK, ossetp, (sigset_t *)0);
4395 }
4396
4397 MODULE = SigSet         PACKAGE = POSIX::SigSet         PREFIX = sig
4398
4399 POSIX::SigSet
4400 new(packname = "POSIX::SigSet", ...)
4401     char *              packname
4402     CODE:
4403         {
4404             int i;
4405             New(0, RETVAL, 1, sigset_t);
4406             sigemptyset(RETVAL);
4407             for (i = 1; i < items; i++)
4408                 sigaddset(RETVAL, SvIV(ST(i)));
4409         }
4410     OUTPUT:
4411         RETVAL
4412
4413 void
4414 DESTROY(sigset)
4415         POSIX::SigSet   sigset
4416     CODE:
4417         Safefree(sigset);
4418
4419 SysRet
4420 sigaddset(sigset, sig)
4421         POSIX::SigSet   sigset
4422         int             sig
4423
4424 SysRet
4425 sigdelset(sigset, sig)
4426         POSIX::SigSet   sigset
4427         int             sig
4428
4429 SysRet
4430 sigemptyset(sigset)
4431         POSIX::SigSet   sigset
4432
4433 SysRet
4434 sigfillset(sigset)
4435         POSIX::SigSet   sigset
4436
4437 int
4438 sigismember(sigset, sig)
4439         POSIX::SigSet   sigset
4440         int             sig
4441
4442
4443 MODULE = Termios        PACKAGE = POSIX::Termios        PREFIX = cf
4444
4445 POSIX::Termios
4446 new(packname = "POSIX::Termios", ...)
4447     char *              packname
4448     CODE:
4449         {
4450 #ifdef I_TERMIOS
4451             New(0, RETVAL, 1, struct termios);
4452 #else
4453             not_here("termios");
4454         RETVAL = 0;
4455 #endif
4456         }
4457     OUTPUT:
4458         RETVAL
4459
4460 void
4461 DESTROY(termios_ref)
4462         POSIX::Termios  termios_ref
4463     CODE:
4464 #ifdef I_TERMIOS
4465         Safefree(termios_ref);
4466 #else
4467             not_here("termios");
4468 #endif
4469
4470 SysRet
4471 getattr(termios_ref, fd = 0)
4472         POSIX::Termios  termios_ref
4473         int             fd
4474     CODE:
4475         RETVAL = tcgetattr(fd, termios_ref);
4476     OUTPUT:
4477         RETVAL
4478
4479 SysRet
4480 setattr(termios_ref, fd = 0, optional_actions = 0)
4481         POSIX::Termios  termios_ref
4482         int             fd
4483         int             optional_actions
4484     CODE:
4485         RETVAL = tcsetattr(fd, optional_actions, termios_ref);
4486     OUTPUT:
4487         RETVAL
4488
4489 speed_t
4490 cfgetispeed(termios_ref)
4491         POSIX::Termios  termios_ref
4492
4493 speed_t
4494 cfgetospeed(termios_ref)
4495         POSIX::Termios  termios_ref
4496
4497 tcflag_t
4498 getiflag(termios_ref)
4499         POSIX::Termios  termios_ref
4500     CODE:
4501 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
4502         RETVAL = termios_ref->c_iflag;
4503 #else
4504      not_here("getiflag");
4505      RETVAL = 0;
4506 #endif
4507     OUTPUT:
4508         RETVAL
4509
4510 tcflag_t
4511 getoflag(termios_ref)
4512         POSIX::Termios  termios_ref
4513     CODE:
4514 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
4515         RETVAL = termios_ref->c_oflag;
4516 #else
4517      not_here("getoflag");
4518      RETVAL = 0;
4519 #endif
4520     OUTPUT:
4521         RETVAL
4522
4523 tcflag_t
4524 getcflag(termios_ref)
4525         POSIX::Termios  termios_ref
4526     CODE:
4527 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
4528         RETVAL = termios_ref->c_cflag;
4529 #else
4530      not_here("getcflag");
4531      RETVAL = 0;
4532 #endif
4533     OUTPUT:
4534         RETVAL
4535
4536 tcflag_t
4537 getlflag(termios_ref)
4538         POSIX::Termios  termios_ref
4539     CODE:
4540 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
4541         RETVAL = termios_ref->c_lflag;
4542 #else
4543      not_here("getlflag");
4544      RETVAL = 0;
4545 #endif
4546     OUTPUT:
4547         RETVAL
4548
4549 cc_t
4550 getcc(termios_ref, ccix)
4551         POSIX::Termios  termios_ref
4552         int             ccix
4553     CODE:
4554 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
4555         if (ccix >= NCCS)
4556             croak("Bad getcc subscript");
4557         RETVAL = termios_ref->c_cc[ccix];
4558 #else
4559      not_here("getcc");
4560      RETVAL = 0;
4561 #endif
4562     OUTPUT:
4563         RETVAL
4564
4565 SysRet
4566 cfsetispeed(termios_ref, speed)
4567         POSIX::Termios  termios_ref
4568         speed_t         speed
4569
4570 SysRet
4571 cfsetospeed(termios_ref, speed)
4572         POSIX::Termios  termios_ref
4573         speed_t         speed
4574
4575 void
4576 setiflag(termios_ref, iflag)
4577         POSIX::Termios  termios_ref
4578         tcflag_t        iflag
4579     CODE:
4580 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
4581         termios_ref->c_iflag = iflag;
4582 #else
4583             not_here("setiflag");
4584 #endif
4585
4586 void
4587 setoflag(termios_ref, oflag)
4588         POSIX::Termios  termios_ref
4589         tcflag_t        oflag
4590     CODE:
4591 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
4592         termios_ref->c_oflag = oflag;
4593 #else
4594             not_here("setoflag");
4595 #endif
4596
4597 void
4598 setcflag(termios_ref, cflag)
4599         POSIX::Termios  termios_ref
4600         tcflag_t        cflag
4601     CODE:
4602 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
4603         termios_ref->c_cflag = cflag;
4604 #else
4605             not_here("setcflag");
4606 #endif
4607
4608 void
4609 setlflag(termios_ref, lflag)
4610         POSIX::Termios  termios_ref
4611         tcflag_t        lflag
4612     CODE:
4613 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
4614         termios_ref->c_lflag = lflag;
4615 #else
4616             not_here("setlflag");
4617 #endif
4618
4619 void
4620 setcc(termios_ref, ccix, cc)
4621         POSIX::Termios  termios_ref
4622         int             ccix
4623         cc_t            cc
4624     CODE:
4625 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
4626         if (ccix >= NCCS)
4627             croak("Bad setcc subscript");
4628         termios_ref->c_cc[ccix] = cc;
4629 #else
4630             not_here("setcc");
4631 #endif
4632
4633
4634 MODULE = POSIX          PACKAGE = POSIX
4635
4636 void
4637 constant(sv)
4638     PREINIT:
4639         dXSTARG;
4640         STRLEN          len;
4641         int             type;
4642         IV              iv;
4643         NV              nv;
4644         /* const char   *pv;    Uncomment this if you need to return PVs */
4645     INPUT:
4646         SV *            sv;
4647         const char *    s = SvPV(sv, len);
4648     PPCODE:
4649         type = constant(s, len, &iv, &nv);
4650       /* Return 1 or 2 items. First is error message, or undef if no error.
4651            Second, if present, is found value */
4652         switch (type) {
4653         case PERL_constant_NOTFOUND:
4654           sv = sv_2mortal(newSVpvf("%s is not a valid POSIX macro", s));
4655           PUSHs(sv);
4656           break;
4657         case PERL_constant_NOTDEF:
4658           sv = sv_2mortal(newSVpvf(
4659             "Your vendor has not defined POSIX macro %s, used", s));
4660           PUSHs(sv);
4661           break;
4662         case PERL_constant_ISIV:
4663           EXTEND(SP, 1);
4664           PUSHs(&PL_sv_undef);
4665           PUSHi(iv);
4666           break;
4667         /* Uncomment this if you need to return NOs
4668         case PERL_constant_ISNO:
4669           EXTEND(SP, 1);
4670           PUSHs(&PL_sv_undef);
4671           PUSHs(&PL_sv_no);
4672           break; */
4673         case PERL_constant_ISNV:
4674           EXTEND(SP, 1);
4675           PUSHs(&PL_sv_undef);
4676           PUSHn(nv);
4677           break;
4678         /* Uncomment this if you need to return UNDEFs
4679         case PERL_constant_ISUNDEF:
4680           break; */
4681         case PERL_constant_ISUV:
4682           EXTEND(SP, 1);
4683           PUSHs(&PL_sv_undef);
4684           PUSHu((UV)iv);
4685           break;
4686         /* Uncomment this if you need to return YESs
4687         case PERL_constant_ISYES:
4688           EXTEND(SP, 1);
4689           PUSHs(&PL_sv_undef);
4690           PUSHs(&PL_sv_yes);
4691           break; */
4692         default:
4693           sv = sv_2mortal(newSVpvf(
4694             "Unexpected return type %d while processing POSIX macro %s, used",
4695                type, s));
4696           PUSHs(sv);
4697         }
4698
4699 void
4700 int_macro_int(sv, iv)
4701     PREINIT:
4702         dXSTARG;
4703         STRLEN          len;
4704         int             type;
4705     INPUT:
4706         SV *            sv;
4707         const char *    s = SvPV(sv, len);
4708         IV              iv;
4709     PPCODE:
4710         /* Change this to int_macro_int(s, len, &iv, &nv);
4711            if you need to return both NVs and IVs */
4712         type = int_macro_int(s, len, &iv);
4713       /* Return 1 or 2 items. First is error message, or undef if no error.
4714            Second, if present, is found value */
4715         switch (type) {
4716         case PERL_constant_NOTFOUND:
4717           sv = sv_2mortal(newSVpvf("%s is not a valid POSIX macro", s));
4718           EXTEND(SP, 1);
4719           PUSHs(&PL_sv_undef);
4720           PUSHs(sv);
4721           break;
4722         case PERL_constant_NOTDEF:
4723           sv = sv_2mortal(newSVpvf(
4724             "Your vendor has not defined POSIX macro %s, used", s));
4725           EXTEND(SP, 1);
4726           PUSHs(&PL_sv_undef);
4727           PUSHs(sv);
4728           break;
4729         case PERL_constant_ISIV:
4730           PUSHi(iv);
4731           break;
4732         default:
4733           sv = sv_2mortal(newSVpvf(
4734             "Unexpected return type %d while processing POSIX macro %s, used",
4735                type, s));
4736           EXTEND(SP, 1);
4737           PUSHs(&PL_sv_undef);
4738           PUSHs(sv);
4739         }
4740
4741 int
4742 isalnum(charstring)
4743         unsigned char * charstring
4744     CODE:
4745         unsigned char *s = charstring;
4746         unsigned char *e = s + PL_na;   /* "PL_na" set by typemap side effect */
4747         for (RETVAL = 1; RETVAL && s < e; s++)
4748             if (!isalnum(*s))
4749                 RETVAL = 0;
4750     OUTPUT:
4751         RETVAL
4752
4753 int
4754 isalpha(charstring)
4755         unsigned char * charstring
4756     CODE:
4757         unsigned char *s = charstring;
4758         unsigned char *e = s + PL_na;   /* "PL_na" set by typemap side effect */
4759         for (RETVAL = 1; RETVAL && s < e; s++)
4760             if (!isalpha(*s))
4761                 RETVAL = 0;
4762     OUTPUT:
4763         RETVAL
4764
4765 int
4766 iscntrl(charstring)
4767         unsigned char * charstring
4768     CODE:
4769         unsigned char *s = charstring;
4770         unsigned char *e = s + PL_na;   /* "PL_na" set by typemap side effect */
4771         for (RETVAL = 1; RETVAL && s < e; s++)
4772             if (!iscntrl(*s))
4773                 RETVAL = 0;
4774     OUTPUT:
4775         RETVAL
4776
4777 int
4778 isdigit(charstring)
4779         unsigned char * charstring
4780     CODE:
4781         unsigned char *s = charstring;
4782         unsigned char *e = s + PL_na;   /* "PL_na" set by typemap side effect */
4783         for (RETVAL = 1; RETVAL && s < e; s++)
4784             if (!isdigit(*s))
4785                 RETVAL = 0;
4786     OUTPUT:
4787         RETVAL
4788
4789 int
4790 isgraph(charstring)
4791         unsigned char * charstring
4792     CODE:
4793         unsigned char *s = charstring;
4794         unsigned char *e = s + PL_na;   /* "PL_na" set by typemap side effect */
4795         for (RETVAL = 1; RETVAL && s < e; s++)
4796             if (!isgraph(*s))
4797                 RETVAL = 0;
4798     OUTPUT:
4799         RETVAL
4800
4801 int
4802 islower(charstring)
4803         unsigned char * charstring
4804     CODE:
4805         unsigned char *s = charstring;
4806         unsigned char *e = s + PL_na;   /* "PL_na" set by typemap side effect */
4807         for (RETVAL = 1; RETVAL && s < e; s++)
4808             if (!islower(*s))
4809                 RETVAL = 0;
4810     OUTPUT:
4811         RETVAL
4812
4813 int
4814 isprint(charstring)
4815         unsigned char * charstring
4816     CODE:
4817         unsigned char *s = charstring;
4818         unsigned char *e = s + PL_na;   /* "PL_na" set by typemap side effect */
4819         for (RETVAL = 1; RETVAL && s < e; s++)
4820             if (!isprint(*s))
4821                 RETVAL = 0;
4822     OUTPUT:
4823         RETVAL
4824
4825 int
4826 ispunct(charstring)
4827         unsigned char * charstring
4828     CODE:
4829         unsigned char *s = charstring;
4830         unsigned char *e = s + PL_na;   /* "PL_na" set by typemap side effect */
4831         for (RETVAL = 1; RETVAL && s < e; s++)
4832             if (!ispunct(*s))
4833                 RETVAL = 0;
4834     OUTPUT:
4835         RETVAL
4836
4837 int
4838 isspace(charstring)
4839         unsigned char * charstring
4840     CODE:
4841         unsigned char *s = charstring;
4842         unsigned char *e = s + PL_na;   /* "PL_na" set by typemap side effect */
4843         for (RETVAL = 1; RETVAL && s < e; s++)
4844             if (!isspace(*s))
4845                 RETVAL = 0;
4846     OUTPUT:
4847         RETVAL
4848
4849 int
4850 isupper(charstring)
4851         unsigned char * charstring
4852     CODE:
4853         unsigned char *s = charstring;
4854         unsigned char *e = s + PL_na;   /* "PL_na" set by typemap side effect */
4855         for (RETVAL = 1; RETVAL && s < e; s++)
4856             if (!isupper(*s))
4857                 RETVAL = 0;
4858     OUTPUT:
4859         RETVAL
4860
4861 int
4862 isxdigit(charstring)
4863         unsigned char * charstring
4864     CODE:
4865         unsigned char *s = charstring;
4866         unsigned char *e = s + PL_na;   /* "PL_na" set by typemap side effect */
4867         for (RETVAL = 1; RETVAL && s < e; s++)
4868             if (!isxdigit(*s))
4869                 RETVAL = 0;
4870     OUTPUT:
4871         RETVAL
4872
4873 SysRet
4874 open(filename, flags = O_RDONLY, mode = 0666)
4875         char *          filename
4876         int             flags
4877         Mode_t          mode
4878     CODE:
4879         if (flags & (O_APPEND|O_CREAT|O_TRUNC|O_RDWR|O_WRONLY|O_EXCL))
4880             TAINT_PROPER("open");
4881         RETVAL = open(filename, flags, mode);
4882     OUTPUT:
4883         RETVAL
4884
4885
4886 HV *
4887 localeconv()
4888     CODE:
4889 #ifdef HAS_LOCALECONV
4890         struct lconv *lcbuf;
4891         RETVAL = newHV();
4892         if ((lcbuf = localeconv())) {
4893             /* the strings */
4894             if (lcbuf->decimal_point && *lcbuf->decimal_point)
4895                 hv_store(RETVAL, "decimal_point", 13,
4896                     newSVpv(lcbuf->decimal_point, 0), 0);
4897             if (lcbuf->thousands_sep && *lcbuf->thousands_sep)
4898                 hv_store(RETVAL, "thousands_sep", 13,
4899                     newSVpv(lcbuf->thousands_sep, 0), 0);
4900 #ifndef NO_LOCALECONV_GROUPING
4901             if (lcbuf->grouping && *lcbuf->grouping)
4902                 hv_store(RETVAL, "grouping", 8,
4903                     newSVpv(lcbuf->grouping, 0), 0);
4904 #endif
4905             if (lcbuf->int_curr_symbol && *lcbuf->int_curr_symbol)
4906                 hv_store(RETVAL, "int_curr_symbol", 15,
4907                     newSVpv(lcbuf->int_curr_symbol, 0), 0);
4908             if (lcbuf->currency_symbol && *lcbuf->currency_symbol)
4909                 hv_store(RETVAL, "currency_symbol", 15,
4910                     newSVpv(lcbuf->currency_symbol, 0), 0);
4911             if (lcbuf->mon_decimal_point && *lcbuf->mon_decimal_point)
4912                 hv_store(RETVAL, "mon_decimal_point", 17,
4913                     newSVpv(lcbuf->mon_decimal_point, 0), 0);
4914 #ifndef NO_LOCALECONV_MON_THOUSANDS_SEP
4915             if (lcbuf->mon_thousands_sep && *lcbuf->mon_thousands_sep)
4916                 hv_store(RETVAL, "mon_thousands_sep", 17,
4917                     newSVpv(lcbuf->mon_thousands_sep, 0), 0);
4918 #endif                    
4919 #ifndef NO_LOCALECONV_MON_GROUPING
4920             if (lcbuf->mon_grouping && *lcbuf->mon_grouping)
4921                 hv_store(RETVAL, "mon_grouping", 12,
4922                     newSVpv(lcbuf->mon_grouping, 0), 0);
4923 #endif
4924             if (lcbuf->positive_sign && *lcbuf->positive_sign)
4925                 hv_store(RETVAL, "positive_sign", 13,
4926                     newSVpv(lcbuf->positive_sign, 0), 0);
4927             if (lcbuf->negative_sign && *lcbuf->negative_sign)
4928                 hv_store(RETVAL, "negative_sign", 13,
4929                     newSVpv(lcbuf->negative_sign, 0), 0);
4930             /* the integers */
4931             if (lcbuf->int_frac_digits != CHAR_MAX)
4932                 hv_store(RETVAL, "int_frac_digits", 15,
4933                     newSViv(lcbuf->int_frac_digits), 0);
4934             if (lcbuf->frac_digits != CHAR_MAX)
4935                 hv_store(RETVAL, "frac_digits", 11,
4936                     newSViv(lcbuf->frac_digits), 0);
4937             if (lcbuf->p_cs_precedes != CHAR_MAX)
4938                 hv_store(RETVAL, "p_cs_precedes", 13,
4939                     newSViv(lcbuf->p_cs_precedes), 0);
4940             if (lcbuf->p_sep_by_space != CHAR_MAX)
4941                 hv_store(RETVAL, "p_sep_by_space", 14,
4942                     newSViv(lcbuf->p_sep_by_space), 0);
4943             if (lcbuf->n_cs_precedes != CHAR_MAX)
4944                 hv_store(RETVAL, "n_cs_precedes", 13,
4945                     newSViv(lcbuf->n_cs_precedes), 0);
4946             if (lcbuf->n_sep_by_space != CHAR_MAX)
4947                 hv_store(RETVAL, "n_sep_by_space", 14,
4948                     newSViv(lcbuf->n_sep_by_space), 0);
4949             if (lcbuf->p_sign_posn != CHAR_MAX)
4950                 hv_store(RETVAL, "p_sign_posn", 11,
4951                     newSViv(lcbuf->p_sign_posn), 0);
4952             if (lcbuf->n_sign_posn != CHAR_MAX)
4953                 hv_store(RETVAL, "n_sign_posn", 11,
4954                     newSViv(lcbuf->n_sign_posn), 0);
4955         }
4956 #else
4957         localeconv(); /* A stub to call not_here(). */
4958 #endif
4959     OUTPUT:
4960         RETVAL
4961
4962 char *
4963 setlocale(category, locale = 0)
4964         int             category
4965         char *          locale
4966     CODE:
4967         RETVAL = setlocale(category, locale);
4968         if (RETVAL) {
4969 #ifdef USE_LOCALE_CTYPE
4970             if (category == LC_CTYPE
4971 #ifdef LC_ALL
4972                 || category == LC_ALL
4973 #endif
4974                 )
4975             {
4976                 char *newctype;
4977 #ifdef LC_ALL
4978                 if (category == LC_ALL)
4979                     newctype = setlocale(LC_CTYPE, NULL);
4980                 else
4981 #endif
4982                     newctype = RETVAL;
4983                 new_ctype(newctype);
4984             }
4985 #endif /* USE_LOCALE_CTYPE */
4986 #ifdef USE_LOCALE_COLLATE
4987             if (category == LC_COLLATE
4988 #ifdef LC_ALL
4989                 || category == LC_ALL
4990 #endif
4991                 )
4992             {
4993                 char *newcoll;
4994 #ifdef LC_ALL
4995                 if (category == LC_ALL)
4996                     newcoll = setlocale(LC_COLLATE, NULL);
4997                 else
4998 #endif
4999                     newcoll = RETVAL;
5000                 new_collate(newcoll);
5001             }
5002 #endif /* USE_LOCALE_COLLATE */
5003 #ifdef USE_LOCALE_NUMERIC
5004             if (category == LC_NUMERIC
5005 #ifdef LC_ALL
5006                 || category == LC_ALL
5007 #endif
5008                 )
5009             {
5010                 char *newnum;
5011 #ifdef LC_ALL
5012                 if (category == LC_ALL)
5013                     newnum = setlocale(LC_NUMERIC, NULL);
5014                 else
5015 #endif
5016                     newnum = RETVAL;
5017                 new_numeric(newnum);
5018             }
5019 #endif /* USE_LOCALE_NUMERIC */
5020         }
5021     OUTPUT:
5022         RETVAL
5023
5024
5025 NV
5026 acos(x)
5027         NV              x
5028
5029 NV
5030 asin(x)
5031         NV              x
5032
5033 NV
5034 atan(x)
5035         NV              x
5036
5037 NV
5038 ceil(x)
5039         NV              x
5040
5041 NV
5042 cosh(x)
5043         NV              x
5044
5045 NV
5046 floor(x)
5047         NV              x
5048
5049 NV
5050 fmod(x,y)
5051         NV              x
5052         NV              y
5053
5054 void
5055 frexp(x)
5056         NV              x
5057     PPCODE:
5058         int expvar;
5059         /* (We already know stack is long enough.) */
5060         PUSHs(sv_2mortal(newSVnv(frexp(x,&expvar))));
5061         PUSHs(sv_2mortal(newSViv(expvar)));
5062
5063 NV
5064 ldexp(x,exp)
5065         NV              x
5066         int             exp
5067
5068 NV
5069 log10(x)
5070         NV              x
5071
5072 void
5073 modf(x)
5074         NV              x
5075     PPCODE:
5076         NV intvar;
5077         /* (We already know stack is long enough.) */
5078         PUSHs(sv_2mortal(newSVnv(Perl_modf(x,&intvar))));
5079         PUSHs(sv_2mortal(newSVnv(intvar)));
5080
5081 NV
5082 sinh(x)
5083         NV              x
5084
5085 NV
5086 tan(x)
5087         NV              x
5088
5089 NV
5090 tanh(x)
5091         NV              x
5092
5093 SysRet
5094 sigaction(sig, optaction, oldaction = 0)
5095         int                     sig
5096         SV *                    optaction
5097         POSIX::SigAction        oldaction
5098     CODE:
5099 #ifdef WIN32
5100         RETVAL = not_here("sigaction");
5101 #else
5102 # This code is really grody because we're trying to make the signal
5103 # interface look beautiful, which is hard.
5104
5105         {
5106             POSIX__SigAction action;
5107             GV *siggv = gv_fetchpv("SIG", TRUE, SVt_PVHV);
5108             struct sigaction act;
5109             struct sigaction oact;
5110             sigset_t sset;
5111             sigset_t osset;
5112             POSIX__SigSet sigset;
5113             SV** svp;
5114             SV** sigsvp = hv_fetch(GvHVn(siggv),
5115                                  PL_sig_name[sig],
5116                                  strlen(PL_sig_name[sig]),
5117                                  TRUE);
5118
5119             /* Check optaction and set action */
5120             if(SvTRUE(optaction)) {
5121                 if(sv_isa(optaction, "POSIX::SigAction"))
5122                         action = (HV*)SvRV(optaction);
5123                 else
5124                         croak("action is not of type POSIX::SigAction");
5125             }
5126             else {
5127                 action=0;
5128             }
5129
5130             /* sigaction() is supposed to look atomic. In particular, any
5131              * signal handler invoked during a sigaction() call should
5132              * see either the old or the new disposition, and not something
5133              * in between. We use sigprocmask() to make it so.
5134              */
5135             sigfillset(&sset);
5136             RETVAL=sigprocmask(SIG_BLOCK, &sset, &osset);
5137             if(RETVAL == -1)
5138                 XSRETURN(1);
5139             ENTER;
5140             /* Restore signal mask no matter how we exit this block. */
5141             SAVEDESTRUCTOR(restore_sigmask, &osset);
5142
5143             RETVAL=-1; /* In case both oldaction and action are 0. */
5144
5145             /* Remember old disposition if desired. */
5146             if (oldaction) {
5147                 svp = hv_fetch(oldaction, "HANDLER", 7, TRUE);
5148                 if(!svp)
5149                     croak("Can't supply an oldaction without a HANDLER");
5150                 if(SvTRUE(*sigsvp)) { /* TBD: what if "0"? */
5151                         sv_setsv(*svp, *sigsvp);
5152                 }
5153                 else {
5154                         sv_setpv(*svp, "DEFAULT");
5155                 }
5156                 RETVAL = sigaction(sig, (struct sigaction *)0, & oact);
5157                 if(RETVAL == -1)
5158                     XSRETURN(1);
5159                 /* Get back the mask. */
5160                 svp = hv_fetch(oldaction, "MASK", 4, TRUE);
5161                 if (sv_isa(*svp, "POSIX::SigSet")) {
5162                     IV tmp = SvIV((SV*)SvRV(*svp));
5163                     sigset = INT2PTR(sigset_t*, tmp);
5164                 }
5165                 else {
5166                     New(0, sigset, 1, sigset_t);
5167                     sv_setptrobj(*svp, sigset, "POSIX::SigSet");
5168                 }
5169                 *sigset = oact.sa_mask;
5170
5171                 /* Get back the flags. */
5172                 svp = hv_fetch(oldaction, "FLAGS", 5, TRUE);
5173                 sv_setiv(*svp, oact.sa_flags);
5174             }
5175
5176             if (action) {
5177                 /* Vector new handler through %SIG.  (We always use sighandler
5178                    for the C signal handler, which reads %SIG to dispatch.) */
5179                 svp = hv_fetch(action, "HANDLER", 7, FALSE);
5180                 if (!svp)
5181                     croak("Can't supply an action without a HANDLER");
5182                 sv_setsv(*sigsvp, *svp);
5183                 mg_set(*sigsvp);        /* handles DEFAULT and IGNORE */
5184                 if(SvPOK(*svp)) {
5185                         char *s=SvPVX(*svp);
5186                         if(strEQ(s,"IGNORE")) {
5187                                 act.sa_handler = SIG_IGN;
5188                         }
5189                         else if(strEQ(s,"DEFAULT")) {
5190                                 act.sa_handler = SIG_DFL;
5191                         }
5192                         else {
5193                                 act.sa_handler = PL_sighandlerp;
5194                         }
5195                 }
5196                 else {
5197                         act.sa_handler = PL_sighandlerp;
5198                 }
5199
5200                 /* Set up any desired mask. */
5201                 svp = hv_fetch(action, "MASK", 4, FALSE);
5202                 if (svp && sv_isa(*svp, "POSIX::SigSet")) {
5203                     IV tmp = SvIV((SV*)SvRV(*svp));
5204                     sigset = INT2PTR(sigset_t*, tmp);
5205                     act.sa_mask = *sigset;
5206                 }
5207                 else
5208                     sigemptyset(& act.sa_mask);
5209
5210                 /* Set up any desired flags. */
5211                 svp = hv_fetch(action, "FLAGS", 5, FALSE);
5212                 act.sa_flags = svp ? SvIV(*svp) : 0;
5213
5214                 /* Don't worry about cleaning up *sigsvp if this fails,
5215                  * because that means we tried to disposition a
5216                  * nonblockable signal, in which case *sigsvp is
5217                  * essentially meaningless anyway.
5218                  */
5219                 RETVAL = sigaction(sig, & act, (struct sigaction *)0);
5220             }
5221
5222             LEAVE;
5223         }
5224 #endif
5225     OUTPUT:
5226         RETVAL
5227
5228 SysRet
5229 sigpending(sigset)
5230         POSIX::SigSet           sigset
5231
5232 SysRet
5233 sigprocmask(how, sigset, oldsigset = 0)
5234         int                     how
5235         POSIX::SigSet           sigset
5236         POSIX::SigSet           oldsigset = NO_INIT
5237 INIT:
5238         if ( items < 3 ) {
5239             oldsigset = 0;
5240         }
5241         else if (sv_derived_from(ST(2), "POSIX::SigSet")) {
5242             IV tmp = SvIV((SV*)SvRV(ST(2)));
5243             oldsigset = INT2PTR(POSIX__SigSet,tmp);
5244         }
5245         else {
5246             New(0, oldsigset, 1, sigset_t);
5247             sigemptyset(oldsigset);
5248             sv_setref_pv(ST(2), "POSIX::SigSet", (void*)oldsigset);
5249         }
5250
5251 SysRet
5252 sigsuspend(signal_mask)
5253         POSIX::SigSet           signal_mask
5254
5255 void
5256 _exit(status)
5257         int             status
5258
5259 SysRet
5260 close(fd)
5261         int             fd
5262
5263 SysRet
5264 dup(fd)
5265         int             fd
5266
5267 SysRet
5268 dup2(fd1, fd2)
5269         int             fd1
5270         int             fd2
5271
5272 SysRetLong
5273 lseek(fd, offset, whence)
5274         int             fd
5275         Off_t           offset
5276         int             whence
5277
5278 SysRet
5279 nice(incr)
5280         int             incr
5281
5282 void
5283 pipe()
5284     PPCODE:
5285         int fds[2];
5286         if (pipe(fds) != -1) {
5287             EXTEND(SP,2);
5288             PUSHs(sv_2mortal(newSViv(fds[0])));
5289             PUSHs(sv_2mortal(newSViv(fds[1])));
5290         }
5291
5292 SysRet
5293 read(fd, buffer, nbytes)
5294     PREINIT:
5295         SV *sv_buffer = SvROK(ST(1)) ? SvRV(ST(1)) : ST(1);
5296     INPUT:
5297         int             fd
5298         size_t          nbytes
5299         char *          buffer = sv_grow( sv_buffer, nbytes+1 );
5300     CLEANUP:
5301         if (RETVAL >= 0) {
5302             SvCUR(sv_buffer) = RETVAL;
5303             SvPOK_only(sv_buffer);
5304             *SvEND(sv_buffer) = '\0';
5305             SvTAINTED_on(sv_buffer);
5306         }
5307
5308 SysRet
5309 setpgid(pid, pgid)
5310         pid_t           pid
5311         pid_t           pgid
5312
5313 pid_t
5314 setsid()
5315
5316 pid_t
5317 tcgetpgrp(fd)
5318         int             fd
5319
5320 SysRet
5321 tcsetpgrp(fd, pgrp_id)
5322         int             fd
5323         pid_t           pgrp_id
5324
5325 void
5326 uname()
5327     PPCODE:
5328 #ifdef HAS_UNAME
5329         struct utsname buf;
5330         if (uname(&buf) >= 0) {
5331             EXTEND(SP, 5);
5332             PUSHs(sv_2mortal(newSVpv(buf.sysname, 0)));
5333             PUSHs(sv_2mortal(newSVpv(buf.nodename, 0)));
5334             PUSHs(sv_2mortal(newSVpv(buf.release, 0)));
5335             PUSHs(sv_2mortal(newSVpv(buf.version, 0)));
5336             PUSHs(sv_2mortal(newSVpv(buf.machine, 0)));
5337         }
5338 #else
5339         uname((char *) 0); /* A stub to call not_here(). */
5340 #endif
5341
5342 SysRet
5343 write(fd, buffer, nbytes)
5344         int             fd
5345         char *          buffer
5346         size_t          nbytes
5347
5348 SV *
5349 tmpnam()
5350     PREINIT:
5351         STRLEN i;
5352         int len;
5353     CODE:
5354         RETVAL = newSVpvn("", 0);
5355         SvGROW(RETVAL, L_tmpnam);
5356         len = strlen(tmpnam(SvPV(RETVAL, i)));
5357         SvCUR_set(RETVAL, len);
5358     OUTPUT:
5359         RETVAL
5360
5361 void
5362 abort()
5363
5364 int
5365 mblen(s, n)
5366         char *          s
5367         size_t          n
5368
5369 size_t
5370 mbstowcs(s, pwcs, n)
5371         wchar_t *       s
5372         char *          pwcs
5373         size_t          n
5374
5375 int
5376 mbtowc(pwc, s, n)
5377         wchar_t *       pwc
5378         char *          s
5379         size_t          n
5380
5381 int
5382 wcstombs(s, pwcs, n)
5383         char *          s
5384         wchar_t *       pwcs
5385         size_t          n
5386
5387 int
5388 wctomb(s, wchar)
5389         char *          s
5390         wchar_t         wchar
5391
5392 int
5393 strcoll(s1, s2)
5394         char *          s1
5395         char *          s2
5396
5397 void
5398 strtod(str)
5399         char *          str
5400     PREINIT:
5401         double num;
5402         char *unparsed;
5403     PPCODE:
5404         SET_NUMERIC_LOCAL();
5405         num = strtod(str, &unparsed);
5406         PUSHs(sv_2mortal(newSVnv(num)));
5407         if (GIMME == G_ARRAY) {
5408             EXTEND(SP, 1);
5409             if (unparsed)
5410                 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
5411             else
5412                 PUSHs(&PL_sv_undef);
5413         }
5414
5415 void
5416 strtol(str, base = 0)
5417         char *          str
5418         int             base
5419     PREINIT:
5420         long num;
5421         char *unparsed;
5422     PPCODE:
5423         num = strtol(str, &unparsed, base);
5424 #if IVSIZE <= LONGSIZE
5425         if (num < IV_MIN || num > IV_MAX)
5426             PUSHs(sv_2mortal(newSVnv((double)num)));
5427         else
5428 #endif
5429             PUSHs(sv_2mortal(newSViv((IV)num)));
5430         if (GIMME == G_ARRAY) {
5431             EXTEND(SP, 1);
5432             if (unparsed)
5433                 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
5434             else
5435                 PUSHs(&PL_sv_undef);
5436         }
5437
5438 void
5439 strtoul(str, base = 0)
5440         char *          str
5441         int             base
5442     PREINIT:
5443         unsigned long num;
5444         char *unparsed;
5445     PPCODE:
5446         num = strtoul(str, &unparsed, base);
5447         if (num <= IV_MAX)
5448             PUSHs(sv_2mortal(newSViv((IV)num)));
5449         else
5450             PUSHs(sv_2mortal(newSVnv((double)num)));
5451         if (GIMME == G_ARRAY) {
5452             EXTEND(SP, 1);
5453             if (unparsed)
5454                 PUSHs(sv_2mortal(newSViv(strlen(unparsed))));
5455             else
5456                 PUSHs(&PL_sv_undef);
5457         }
5458
5459 void
5460 strxfrm(src)
5461         SV *            src
5462     CODE:
5463         {
5464           STRLEN srclen;
5465           STRLEN dstlen;
5466           char *p = SvPV(src,srclen);
5467           srclen++;
5468           ST(0) = sv_2mortal(NEWSV(800,srclen));
5469           dstlen = strxfrm(SvPVX(ST(0)), p, (size_t)srclen);
5470           if (dstlen > srclen) {
5471               dstlen++;
5472               SvGROW(ST(0), dstlen);
5473               strxfrm(SvPVX(ST(0)), p, (size_t)dstlen);
5474               dstlen--;
5475           }
5476           SvCUR(ST(0)) = dstlen;
5477             SvPOK_only(ST(0));
5478         }
5479
5480 SysRet
5481 mkfifo(filename, mode)
5482         char *          filename
5483         Mode_t          mode
5484     CODE:
5485         TAINT_PROPER("mkfifo");
5486         RETVAL = mkfifo(filename, mode);
5487     OUTPUT:
5488         RETVAL
5489
5490 SysRet
5491 tcdrain(fd)
5492         int             fd
5493
5494
5495 SysRet
5496 tcflow(fd, action)
5497         int             fd
5498         int             action
5499
5500
5501 SysRet
5502 tcflush(fd, queue_selector)
5503         int             fd
5504         int             queue_selector
5505
5506 SysRet
5507 tcsendbreak(fd, duration)
5508         int             fd
5509         int             duration
5510
5511 char *
5512 asctime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
5513         int             sec
5514         int             min
5515         int             hour
5516         int             mday
5517         int             mon
5518         int             year
5519         int             wday
5520         int             yday
5521         int             isdst
5522     CODE:
5523         {
5524             struct tm mytm;
5525             init_tm(&mytm);     /* XXX workaround - see init_tm() above */
5526             mytm.tm_sec = sec;
5527             mytm.tm_min = min;
5528             mytm.tm_hour = hour;
5529             mytm.tm_mday = mday;
5530             mytm.tm_mon = mon;
5531             mytm.tm_year = year;
5532             mytm.tm_wday = wday;
5533             mytm.tm_yday = yday;
5534             mytm.tm_isdst = isdst;
5535             RETVAL = asctime(&mytm);
5536         }
5537     OUTPUT:
5538         RETVAL
5539
5540 long
5541 clock()
5542
5543 char *
5544 ctime(time)
5545         Time_t          &time
5546
5547 void
5548 times()
5549         PPCODE:
5550         struct tms tms;
5551         clock_t realtime;
5552         realtime = times( &tms );
5553         EXTEND(SP,5);
5554         PUSHs( sv_2mortal( newSViv( (IV) realtime ) ) );
5555         PUSHs( sv_2mortal( newSViv( (IV) tms.tms_utime ) ) );
5556         PUSHs( sv_2mortal( newSViv( (IV) tms.tms_stime ) ) );
5557         PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cutime ) ) );
5558         PUSHs( sv_2mortal( newSViv( (IV) tms.tms_cstime ) ) );
5559
5560 double
5561 difftime(time1, time2)
5562         Time_t          time1
5563         Time_t          time2
5564
5565 SysRetLong
5566 mktime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
5567         int             sec
5568         int             min
5569         int             hour
5570         int             mday
5571         int             mon
5572         int             year
5573         int             wday
5574         int             yday
5575         int             isdst
5576     CODE:
5577         {
5578             struct tm mytm;
5579             init_tm(&mytm);     /* XXX workaround - see init_tm() above */
5580             mytm.tm_sec = sec;
5581             mytm.tm_min = min;
5582             mytm.tm_hour = hour;
5583             mytm.tm_mday = mday;
5584             mytm.tm_mon = mon;
5585             mytm.tm_year = year;
5586             mytm.tm_wday = wday;
5587             mytm.tm_yday = yday;
5588             mytm.tm_isdst = isdst;
5589             RETVAL = mktime(&mytm);
5590         }
5591     OUTPUT:
5592         RETVAL
5593
5594 #XXX: if $xsubpp::WantOptimize is always the default
5595 #     sv_setpv(TARG, ...) could be used rather than
5596 #     ST(0) = sv_2mortal(newSVpv(...))
5597 void
5598 strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1)
5599         char *          fmt
5600         int             sec
5601         int             min
5602         int             hour
5603         int             mday
5604         int             mon
5605         int             year
5606         int             wday
5607         int             yday
5608         int             isdst
5609     CODE:
5610         {
5611             char *buf = my_strftime(fmt, sec, min, hour, mday, mon, year, wday, yday, isdst);
5612             if (buf) {
5613                 ST(0) = sv_2mortal(newSVpv(buf, 0));
5614                 Safefree(buf);
5615             }
5616         }
5617
5618 void
5619 tzset()
5620
5621 void
5622 tzname()
5623     PPCODE:
5624         EXTEND(SP,2);
5625         PUSHs(sv_2mortal(newSVpvn(tzname[0],strlen(tzname[0]))));
5626         PUSHs(sv_2mortal(newSVpvn(tzname[1],strlen(tzname[1]))));
5627
5628 SysRet
5629 access(filename, mode)
5630         char *          filename
5631         Mode_t          mode
5632
5633 char *
5634 ctermid(s = 0)
5635         char *          s = 0;
5636
5637 char *
5638 cuserid(s = 0)
5639         char *          s = 0;
5640
5641 SysRetLong
5642 fpathconf(fd, name)
5643         int             fd
5644         int             name
5645
5646 SysRetLong
5647 pathconf(filename, name)
5648         char *          filename
5649         int             name
5650
5651 SysRet
5652 pause()
5653
5654 SysRet
5655 setgid(gid)
5656         Gid_t           gid
5657
5658 SysRet
5659 setuid(uid)
5660         Uid_t           uid
5661
5662 SysRetLong
5663 sysconf(name)
5664         int             name
5665
5666 char *
5667 ttyname(fd)
5668         int             fd
5669
5670 #XXX: use sv_getcwd()
5671 void
5672 getcwd()
5673         PPCODE:
5674 #ifdef HAS_GETCWD
5675         char *          buf;
5676         int             buflen = 128;
5677
5678         New(0, buf, buflen, char);
5679         /* Many getcwd()s know how to automatically allocate memory
5680          * for the directory if the buffer argument is NULL but...
5681          * (1) we cannot assume all getcwd()s do that
5682          * (2) this may interfere with Perl's malloc
5683          * So let's not.  --jhi */
5684         while ((getcwd(buf, buflen) == NULL) && errno == ERANGE) {
5685             buflen += 128;
5686             if (buflen > MAXPATHLEN) {
5687                 Safefree(buf);
5688                 buf = NULL;
5689                 break;
5690             }
5691             Renew(buf, buflen, char);
5692         }
5693         if (buf) {
5694             PUSHs(sv_2mortal(newSVpv(buf, 0)));
5695             Safefree(buf);
5696         }
5697         else
5698             PUSHs(&PL_sv_undef);
5699 #else
5700         require_pv("Cwd.pm");
5701         /* Module require may have grown the stack */
5702         SPAGAIN;
5703         PUSHMARK(sp);
5704         PUTBACK;
5705         XSRETURN(call_pv("Cwd::cwd", GIMME_V));
5706 #endif