e1e6b28e406635c7a655625221440b84457197cd
[p5sagit/p5-mst-13.2.git] / ext / POSIX / POSIX.pm
1 package POSIX;
2
3 our(@ISA, %EXPORT_TAGS, @EXPORT_OK, $AUTOLOAD) = ();
4
5 use AutoLoader;
6
7 use XSLoader ();
8
9 our $VERSION = "1.03" ;
10
11 # Grandfather old foo_h form to new :foo_h form
12 my $loaded;
13
14 sub import {
15     load_imports() unless $loaded++;
16     my $this = shift;
17     my @list = map { m/^\w+_h$/ ? ":$_" : $_ } @_;
18     local $Exporter::ExportLevel = 1;
19     Exporter::import($this,@list);
20 }
21
22 sub croak { require Carp;  goto &Carp::croak }
23
24 XSLoader::load 'POSIX', $VERSION;
25
26 my $EINVAL = constant("EINVAL", 0);
27 my $EAGAIN = constant("EAGAIN", 0);
28
29 sub AUTOLOAD {
30     if ($AUTOLOAD =~ /::(_?[a-z])/) {
31         # require AutoLoader;
32         $AutoLoader::AUTOLOAD = $AUTOLOAD;
33         goto &AutoLoader::AUTOLOAD
34     }
35     local $! = 0;
36     my $constname = $AUTOLOAD;
37     $constname =~ s/.*:://;
38     my $val = constant($constname, @_ ? $_[0] : 0);
39     if ($! == 0) {
40         *$AUTOLOAD = sub { $val };
41     }
42     elsif ($! == $EAGAIN) {     # Not really a constant, so always call.
43         *$AUTOLOAD = sub { constant($constname, $_[0]) };
44     }
45     elsif ($! == $EINVAL) {
46         croak "$constname is not a valid POSIX macro";
47     }
48     else {
49         croak "Your vendor has not defined POSIX macro $constname, used";
50     }
51
52     goto &$AUTOLOAD;
53 }
54
55 sub usage { 
56     my ($mess) = @_;
57     croak "Usage: POSIX::$mess";
58 }
59
60 sub redef { 
61     my ($mess) = @_;
62     croak "Use method $mess instead";
63 }
64
65 sub unimpl { 
66     my ($mess) = @_;
67     $mess =~ s/xxx//;
68     croak "Unimplemented: POSIX::$mess";
69 }
70
71 ############################
72 package POSIX::SigAction;
73
74 sub new {
75     bless {HANDLER => $_[1], MASK => $_[2], FLAGS => $_[3] || 0}, $_[0];
76 }
77
78 ############################
79 package POSIX; # return to package POSIX so AutoSplit is happy
80 1;
81 __END__
82
83 sub assert {
84     usage "assert(expr)" if @_ != 1;
85     if (!$_[0]) {
86         croak "Assertion failed";
87     }
88 }
89
90 sub tolower {
91     usage "tolower(string)" if @_ != 1;
92     lc($_[0]);
93 }
94
95 sub toupper {
96     usage "toupper(string)" if @_ != 1;
97     uc($_[0]);
98 }
99
100 sub closedir {
101     usage "closedir(dirhandle)" if @_ != 1;
102     CORE::closedir($_[0]);
103 }
104
105 sub opendir {
106     usage "opendir(directory)" if @_ != 1;
107     my $dirhandle;
108     CORE::opendir($dirhandle, $_[0])
109         ? $dirhandle
110         : undef;
111 }
112
113 sub readdir {
114     usage "readdir(dirhandle)" if @_ != 1;
115     CORE::readdir($_[0]);
116 }
117
118 sub rewinddir {
119     usage "rewinddir(dirhandle)" if @_ != 1;
120     CORE::rewinddir($_[0]);
121 }
122
123 sub errno {
124     usage "errno()" if @_ != 0;
125     $! + 0;
126 }
127
128 sub creat {
129     usage "creat(filename, mode)" if @_ != 2;
130     &open($_[0], &O_WRONLY | &O_CREAT | &O_TRUNC, $_[1]);
131 }
132
133 sub fcntl {
134     usage "fcntl(filehandle, cmd, arg)" if @_ != 3;
135     CORE::fcntl($_[0], $_[1], $_[2]);
136 }
137
138 sub getgrgid {
139     usage "getgrgid(gid)" if @_ != 1;
140     CORE::getgrgid($_[0]);
141 }
142
143 sub getgrnam {
144     usage "getgrnam(name)" if @_ != 1;
145     CORE::getgrnam($_[0]);
146 }
147
148 sub atan2 {
149     usage "atan2(x,y)" if @_ != 2;
150     CORE::atan2($_[0], $_[1]);
151 }
152
153 sub cos {
154     usage "cos(x)" if @_ != 1;
155     CORE::cos($_[0]);
156 }
157
158 sub exp {
159     usage "exp(x)" if @_ != 1;
160     CORE::exp($_[0]);
161 }
162
163 sub fabs {
164     usage "fabs(x)" if @_ != 1;
165     CORE::abs($_[0]);
166 }
167
168 sub log {
169     usage "log(x)" if @_ != 1;
170     CORE::log($_[0]);
171 }
172
173 sub pow {
174     usage "pow(x,exponent)" if @_ != 2;
175     $_[0] ** $_[1];
176 }
177
178 sub sin {
179     usage "sin(x)" if @_ != 1;
180     CORE::sin($_[0]);
181 }
182
183 sub sqrt {
184     usage "sqrt(x)" if @_ != 1;
185     CORE::sqrt($_[0]);
186 }
187
188 sub getpwnam {
189     usage "getpwnam(name)" if @_ != 1;
190     CORE::getpwnam($_[0]);
191 }
192
193 sub getpwuid {
194     usage "getpwuid(uid)" if @_ != 1;
195     CORE::getpwuid($_[0]);
196 }
197
198 sub longjmp {
199     unimpl "longjmp() is C-specific: use die instead";
200 }
201
202 sub setjmp {
203     unimpl "setjmp() is C-specific: use eval {} instead";
204 }
205
206 sub siglongjmp {
207     unimpl "siglongjmp() is C-specific: use die instead";
208 }
209
210 sub sigsetjmp {
211     unimpl "sigsetjmp() is C-specific: use eval {} instead";
212 }
213
214 sub kill {
215     usage "kill(pid, sig)" if @_ != 2;
216     CORE::kill $_[1], $_[0];
217 }
218
219 sub raise {
220     usage "raise(sig)" if @_ != 1;
221     CORE::kill $_[0], $$;       # Is this good enough?
222 }
223
224 sub offsetof {
225     unimpl "offsetof() is C-specific, stopped";
226 }
227
228 sub clearerr {
229     redef "IO::Handle::clearerr()";
230 }
231
232 sub fclose {
233     redef "IO::Handle::close()";
234 }
235
236 sub fdopen {
237     redef "IO::Handle::new_from_fd()";
238 }
239
240 sub feof {
241     redef "IO::Handle::eof()";
242 }
243
244 sub fgetc {
245     redef "IO::Handle::getc()";
246 }
247
248 sub fgets {
249     redef "IO::Handle::gets()";
250 }
251
252 sub fileno {
253     redef "IO::Handle::fileno()";
254 }
255
256 sub fopen {
257     redef "IO::File::open()";
258 }
259
260 sub fprintf {
261     unimpl "fprintf() is C-specific--use printf instead";
262 }
263
264 sub fputc {
265     unimpl "fputc() is C-specific--use print instead";
266 }
267
268 sub fputs {
269     unimpl "fputs() is C-specific--use print instead";
270 }
271
272 sub fread {
273     unimpl "fread() is C-specific--use read instead";
274 }
275
276 sub freopen {
277     unimpl "freopen() is C-specific--use open instead";
278 }
279
280 sub fscanf {
281     unimpl "fscanf() is C-specific--use <> and regular expressions instead";
282 }
283
284 sub fseek {
285     redef "IO::Seekable::seek()";
286 }
287
288 sub ferror {
289     redef "IO::Handle::error()";
290 }
291
292 sub fflush {
293     redef "IO::Handle::flush()";
294 }
295
296 sub fgetpos {
297     redef "IO::Seekable::getpos()";
298 }
299
300 sub fsetpos {
301     redef "IO::Seekable::setpos()";
302 }
303
304 sub ftell {
305     redef "IO::Seekable::tell()";
306 }
307
308 sub fwrite {
309     unimpl "fwrite() is C-specific--use print instead";
310 }
311
312 sub getc {
313     usage "getc(handle)" if @_ != 1;
314     CORE::getc($_[0]);
315 }
316
317 sub getchar {
318     usage "getchar()" if @_ != 0;
319     CORE::getc(STDIN);
320 }
321
322 sub gets {
323     usage "gets()" if @_ != 0;
324     scalar <STDIN>;
325 }
326
327 sub perror {
328     print STDERR "@_: " if @_;
329     print STDERR $!,"\n";
330 }
331
332 sub printf {
333     usage "printf(pattern, args...)" if @_ < 1;
334     CORE::printf STDOUT @_;
335 }
336
337 sub putc {
338     unimpl "putc() is C-specific--use print instead";
339 }
340
341 sub putchar {
342     unimpl "putchar() is C-specific--use print instead";
343 }
344
345 sub puts {
346     unimpl "puts() is C-specific--use print instead";
347 }
348
349 sub remove {
350     usage "remove(filename)" if @_ != 1;
351     CORE::unlink($_[0]);
352 }
353
354 sub rename {
355     usage "rename(oldfilename, newfilename)" if @_ != 2;
356     CORE::rename($_[0], $_[1]);
357 }
358
359 sub rewind {
360     usage "rewind(filehandle)" if @_ != 1;
361     CORE::seek($_[0],0,0);
362 }
363
364 sub scanf {
365     unimpl "scanf() is C-specific--use <> and regular expressions instead";
366 }
367
368 sub sprintf {
369     usage "sprintf(pattern,args)" if @_ == 0;
370     CORE::sprintf(shift,@_);
371 }
372
373 sub sscanf {
374     unimpl "sscanf() is C-specific--use regular expressions instead";
375 }
376
377 sub tmpfile {
378     redef "IO::File::new_tmpfile()";
379 }
380
381 sub ungetc {
382     redef "IO::Handle::ungetc()";
383 }
384
385 sub vfprintf {
386     unimpl "vfprintf() is C-specific";
387 }
388
389 sub vprintf {
390     unimpl "vprintf() is C-specific";
391 }
392
393 sub vsprintf {
394     unimpl "vsprintf() is C-specific";
395 }
396
397 sub abs {
398     usage "abs(x)" if @_ != 1;
399     CORE::abs($_[0]);
400 }
401
402 sub atexit {
403     unimpl "atexit() is C-specific: use END {} instead";
404 }
405
406 sub atof {
407     unimpl "atof() is C-specific, stopped";
408 }
409
410 sub atoi {
411     unimpl "atoi() is C-specific, stopped";
412 }
413
414 sub atol {
415     unimpl "atol() is C-specific, stopped";
416 }
417
418 sub bsearch {
419     unimpl "bsearch() not supplied";
420 }
421
422 sub calloc {
423     unimpl "calloc() is C-specific, stopped";
424 }
425
426 sub div {
427     unimpl "div() is C-specific, stopped";
428 }
429
430 sub exit {
431     usage "exit(status)" if @_ != 1;
432     CORE::exit($_[0]);
433 }
434
435 sub free {
436     unimpl "free() is C-specific, stopped";
437 }
438
439 sub getenv {
440     usage "getenv(name)" if @_ != 1;
441     $ENV{$_[0]};
442 }
443
444 sub labs {
445     unimpl "labs() is C-specific, use abs instead";
446 }
447
448 sub ldiv {
449     unimpl "ldiv() is C-specific, use / and int instead";
450 }
451
452 sub malloc {
453     unimpl "malloc() is C-specific, stopped";
454 }
455
456 sub qsort {
457     unimpl "qsort() is C-specific, use sort instead";
458 }
459
460 sub rand {
461     unimpl "rand() is non-portable, use Perl's rand instead";
462 }
463
464 sub realloc {
465     unimpl "realloc() is C-specific, stopped";
466 }
467
468 sub srand {
469     unimpl "srand()";
470 }
471
472 sub system {
473     usage "system(command)" if @_ != 1;
474     CORE::system($_[0]);
475 }
476
477 sub memchr {
478     unimpl "memchr() is C-specific, use index() instead";
479 }
480
481 sub memcmp {
482     unimpl "memcmp() is C-specific, use eq instead";
483 }
484
485 sub memcpy {
486     unimpl "memcpy() is C-specific, use = instead";
487 }
488
489 sub memmove {
490     unimpl "memmove() is C-specific, use = instead";
491 }
492
493 sub memset {
494     unimpl "memset() is C-specific, use x instead";
495 }
496
497 sub strcat {
498     unimpl "strcat() is C-specific, use .= instead";
499 }
500
501 sub strchr {
502     unimpl "strchr() is C-specific, use index() instead";
503 }
504
505 sub strcmp {
506     unimpl "strcmp() is C-specific, use eq instead";
507 }
508
509 sub strcpy {
510     unimpl "strcpy() is C-specific, use = instead";
511 }
512
513 sub strcspn {
514     unimpl "strcspn() is C-specific, use regular expressions instead";
515 }
516
517 sub strerror {
518     usage "strerror(errno)" if @_ != 1;
519     local $! = $_[0];
520     $! . "";
521 }
522
523 sub strlen {
524     unimpl "strlen() is C-specific, use length instead";
525 }
526
527 sub strncat {
528     unimpl "strncat() is C-specific, use .= instead";
529 }
530
531 sub strncmp {
532     unimpl "strncmp() is C-specific, use eq instead";
533 }
534
535 sub strncpy {
536     unimpl "strncpy() is C-specific, use = instead";
537 }
538
539 sub strpbrk {
540     unimpl "strpbrk() is C-specific, stopped";
541 }
542
543 sub strrchr {
544     unimpl "strrchr() is C-specific, use rindex() instead";
545 }
546
547 sub strspn {
548     unimpl "strspn() is C-specific, stopped";
549 }
550
551 sub strstr {
552     usage "strstr(big, little)" if @_ != 2;
553     CORE::index($_[0], $_[1]);
554 }
555
556 sub strtok {
557     unimpl "strtok() is C-specific, stopped";
558 }
559
560 sub chmod {
561     usage "chmod(mode, filename)" if @_ != 2;
562     CORE::chmod($_[0], $_[1]);
563 }
564
565 sub fstat {
566     usage "fstat(fd)" if @_ != 1;
567     local *TMP;
568     CORE::open(TMP, "<&$_[0]");         # Gross.
569     my @l = CORE::stat(TMP);
570     CORE::close(TMP);
571     @l;
572 }
573
574 sub mkdir {
575     usage "mkdir(directoryname, mode)" if @_ != 2;
576     CORE::mkdir($_[0], $_[1]);
577 }
578
579 sub stat {
580     usage "stat(filename)" if @_ != 1;
581     CORE::stat($_[0]);
582 }
583
584 sub umask {
585     usage "umask(mask)" if @_ != 1;
586     CORE::umask($_[0]);
587 }
588
589 sub wait {
590     usage "wait()" if @_ != 0;
591     CORE::wait();
592 }
593
594 sub waitpid {
595     usage "waitpid(pid, options)" if @_ != 2;
596     CORE::waitpid($_[0], $_[1]);
597 }
598
599 sub gmtime {
600     usage "gmtime(time)" if @_ != 1;
601     CORE::gmtime($_[0]);
602 }
603
604 sub localtime {
605     usage "localtime(time)" if @_ != 1;
606     CORE::localtime($_[0]);
607 }
608
609 sub time {
610     usage "time()" if @_ != 0;
611     CORE::time;
612 }
613
614 sub alarm {
615     usage "alarm(seconds)" if @_ != 1;
616     CORE::alarm($_[0]);
617 }
618
619 sub chdir {
620     usage "chdir(directory)" if @_ != 1;
621     CORE::chdir($_[0]);
622 }
623
624 sub chown {
625     usage "chown(filename, uid, gid)" if @_ != 3;
626     CORE::chown($_[0], $_[1], $_[2]);
627 }
628
629 sub execl {
630     unimpl "execl() is C-specific, stopped";
631 }
632
633 sub execle {
634     unimpl "execle() is C-specific, stopped";
635 }
636
637 sub execlp {
638     unimpl "execlp() is C-specific, stopped";
639 }
640
641 sub execv {
642     unimpl "execv() is C-specific, stopped";
643 }
644
645 sub execve {
646     unimpl "execve() is C-specific, stopped";
647 }
648
649 sub execvp {
650     unimpl "execvp() is C-specific, stopped";
651 }
652
653 sub fork {
654     usage "fork()" if @_ != 0;
655     CORE::fork;
656 }
657
658 sub getcwd
659 {
660     usage "getcwd()" if @_ != 0;
661     if ($^O eq 'MSWin32') {
662         # this perhaps applies to everyone else also?
663         require Cwd;
664         $cwd = &Cwd::cwd;
665     }
666     else {
667         chop($cwd = `pwd`);
668     }
669     $cwd;
670 }
671
672 sub getegid {
673     usage "getegid()" if @_ != 0;
674     $) + 0;
675 }
676
677 sub geteuid {
678     usage "geteuid()" if @_ != 0;
679     $> + 0;
680 }
681
682 sub getgid {
683     usage "getgid()" if @_ != 0;
684     $( + 0;
685 }
686
687 sub getgroups {
688     usage "getgroups()" if @_ != 0;
689     my %seen;
690     grep(!$seen{$_}++, split(' ', $) ));
691 }
692
693 sub getlogin {
694     usage "getlogin()" if @_ != 0;
695     CORE::getlogin();
696 }
697
698 sub getpgrp {
699     usage "getpgrp()" if @_ != 0;
700     CORE::getpgrp;
701 }
702
703 sub getpid {
704     usage "getpid()" if @_ != 0;
705     $$;
706 }
707
708 sub getppid {
709     usage "getppid()" if @_ != 0;
710     CORE::getppid;
711 }
712
713 sub getuid {
714     usage "getuid()" if @_ != 0;
715     $<;
716 }
717
718 sub isatty {
719     usage "isatty(filehandle)" if @_ != 1;
720     -t $_[0];
721 }
722
723 sub link {
724     usage "link(oldfilename, newfilename)" if @_ != 2;
725     CORE::link($_[0], $_[1]);
726 }
727
728 sub rmdir {
729     usage "rmdir(directoryname)" if @_ != 1;
730     CORE::rmdir($_[0]);
731 }
732
733 sub setbuf {
734     redef "IO::Handle::setbuf()";
735 }
736
737 sub setvbuf {
738     redef "IO::Handle::setvbuf()";
739 }
740
741 sub sleep {
742     usage "sleep(seconds)" if @_ != 1;
743     CORE::sleep($_[0]);
744 }
745
746 sub unlink {
747     usage "unlink(filename)" if @_ != 1;
748     CORE::unlink($_[0]);
749 }
750
751 sub utime {
752     usage "utime(filename, atime, mtime)" if @_ != 3;
753     CORE::utime($_[1], $_[2], $_[0]);
754 }
755
756 sub load_imports {
757 %EXPORT_TAGS = (
758
759     assert_h => [qw(assert NDEBUG)],
760
761     ctype_h =>  [qw(isalnum isalpha iscntrl isdigit isgraph islower
762                 isprint ispunct isspace isupper isxdigit tolower toupper)],
763
764     dirent_h => [qw()],
765
766     errno_h =>  [qw(E2BIG EACCES EADDRINUSE EADDRNOTAVAIL EAFNOSUPPORT
767                 EAGAIN EALREADY EBADF EBUSY ECHILD ECONNABORTED
768                 ECONNREFUSED ECONNRESET EDEADLK EDESTADDRREQ EDOM EDQUOT
769                 EEXIST EFAULT EFBIG EHOSTDOWN EHOSTUNREACH EINPROGRESS
770                 EINTR EINVAL EIO EISCONN EISDIR ELOOP EMFILE EMLINK
771                 EMSGSIZE ENAMETOOLONG ENETDOWN ENETRESET ENETUNREACH
772                 ENFILE ENOBUFS ENODEV ENOENT ENOEXEC ENOLCK ENOMEM
773                 ENOPROTOOPT ENOSPC ENOSYS ENOTBLK ENOTCONN ENOTDIR
774                 ENOTEMPTY ENOTSOCK ENOTTY ENXIO EOPNOTSUPP EPERM
775                 EPFNOSUPPORT EPIPE EPROCLIM EPROTONOSUPPORT EPROTOTYPE
776                 ERANGE EREMOTE ERESTART EROFS ESHUTDOWN ESOCKTNOSUPPORT
777                 ESPIPE ESRCH ESTALE ETIMEDOUT ETOOMANYREFS ETXTBSY
778                 EUSERS EWOULDBLOCK EXDEV errno)],
779
780     fcntl_h =>  [qw(FD_CLOEXEC F_DUPFD F_GETFD F_GETFL F_GETLK F_RDLCK
781                 F_SETFD F_SETFL F_SETLK F_SETLKW F_UNLCK F_WRLCK
782                 O_ACCMODE O_APPEND O_CREAT O_EXCL O_NOCTTY O_NONBLOCK
783                 O_RDONLY O_RDWR O_TRUNC O_WRONLY
784                 creat
785                 SEEK_CUR SEEK_END SEEK_SET
786                 S_IRGRP S_IROTH S_IRUSR S_IRWXG S_IRWXO S_IRWXU
787                 S_ISBLK S_ISCHR S_ISDIR S_ISFIFO S_ISGID S_ISREG S_ISUID
788                 S_IWGRP S_IWOTH S_IWUSR)],
789
790     float_h =>  [qw(DBL_DIG DBL_EPSILON DBL_MANT_DIG
791                 DBL_MAX DBL_MAX_10_EXP DBL_MAX_EXP
792                 DBL_MIN DBL_MIN_10_EXP DBL_MIN_EXP
793                 FLT_DIG FLT_EPSILON FLT_MANT_DIG
794                 FLT_MAX FLT_MAX_10_EXP FLT_MAX_EXP
795                 FLT_MIN FLT_MIN_10_EXP FLT_MIN_EXP
796                 FLT_RADIX FLT_ROUNDS
797                 LDBL_DIG LDBL_EPSILON LDBL_MANT_DIG
798                 LDBL_MAX LDBL_MAX_10_EXP LDBL_MAX_EXP
799                 LDBL_MIN LDBL_MIN_10_EXP LDBL_MIN_EXP)],
800
801     grp_h =>    [qw()],
802
803     limits_h => [qw( ARG_MAX CHAR_BIT CHAR_MAX CHAR_MIN CHILD_MAX
804                 INT_MAX INT_MIN LINK_MAX LONG_MAX LONG_MIN MAX_CANON
805                 MAX_INPUT MB_LEN_MAX NAME_MAX NGROUPS_MAX OPEN_MAX
806                 PATH_MAX PIPE_BUF SCHAR_MAX SCHAR_MIN SHRT_MAX SHRT_MIN
807                 SSIZE_MAX STREAM_MAX TZNAME_MAX UCHAR_MAX UINT_MAX
808                 ULONG_MAX USHRT_MAX _POSIX_ARG_MAX _POSIX_CHILD_MAX
809                 _POSIX_LINK_MAX _POSIX_MAX_CANON _POSIX_MAX_INPUT
810                 _POSIX_NAME_MAX _POSIX_NGROUPS_MAX _POSIX_OPEN_MAX
811                 _POSIX_PATH_MAX _POSIX_PIPE_BUF _POSIX_SSIZE_MAX
812                 _POSIX_STREAM_MAX _POSIX_TZNAME_MAX)],
813
814     locale_h => [qw(LC_ALL LC_COLLATE LC_CTYPE LC_MONETARY LC_NUMERIC
815                 LC_TIME NULL localeconv setlocale)],
816
817     math_h =>   [qw(HUGE_VAL acos asin atan ceil cosh fabs floor fmod
818                 frexp ldexp log10 modf pow sinh tan tanh)],
819
820     pwd_h =>    [qw()],
821
822     setjmp_h => [qw(longjmp setjmp siglongjmp sigsetjmp)],
823
824     signal_h => [qw(SA_NOCLDSTOP SA_NOCLDWAIT SA_NODEFER SA_ONSTACK
825                 SA_RESETHAND SA_RESTART SA_SIGINFO SIGABRT SIGALRM
826                 SIGCHLD SIGCONT SIGFPE SIGHUP SIGILL SIGINT SIGKILL
827                 SIGPIPE SIGQUIT SIGSEGV SIGSTOP SIGTERM SIGTSTP SIGTTIN
828                 SIGTTOU SIGUSR1 SIGUSR2 SIG_BLOCK SIG_DFL SIG_ERR
829                 SIG_IGN SIG_SETMASK SIG_UNBLOCK raise sigaction signal
830                 sigpending sigprocmask sigsuspend)],
831
832     stdarg_h => [qw()],
833
834     stddef_h => [qw(NULL offsetof)],
835
836     stdio_h =>  [qw(BUFSIZ EOF FILENAME_MAX L_ctermid L_cuserid
837                 L_tmpname NULL SEEK_CUR SEEK_END SEEK_SET
838                 STREAM_MAX TMP_MAX stderr stdin stdout
839                 clearerr fclose fdopen feof ferror fflush fgetc fgetpos
840                 fgets fopen fprintf fputc fputs fread freopen
841                 fscanf fseek fsetpos ftell fwrite getchar gets
842                 perror putc putchar puts remove rewind
843                 scanf setbuf setvbuf sscanf tmpfile tmpnam
844                 ungetc vfprintf vprintf vsprintf)],
845
846     stdlib_h => [qw(EXIT_FAILURE EXIT_SUCCESS MB_CUR_MAX NULL RAND_MAX
847                 abort atexit atof atoi atol bsearch calloc div
848                 free getenv labs ldiv malloc mblen mbstowcs mbtowc
849                 qsort realloc strtod strtol strtoul wcstombs wctomb)],
850
851     string_h => [qw(NULL memchr memcmp memcpy memmove memset strcat
852                 strchr strcmp strcoll strcpy strcspn strerror strlen
853                 strncat strncmp strncpy strpbrk strrchr strspn strstr
854                 strtok strxfrm)],
855
856     sys_stat_h => [qw(S_IRGRP S_IROTH S_IRUSR S_IRWXG S_IRWXO S_IRWXU
857                 S_ISBLK S_ISCHR S_ISDIR S_ISFIFO S_ISGID S_ISREG
858                 S_ISUID S_IWGRP S_IWOTH S_IWUSR S_IXGRP S_IXOTH S_IXUSR
859                 fstat mkfifo)],
860
861     sys_times_h => [qw()],
862
863     sys_types_h => [qw()],
864
865     sys_utsname_h => [qw(uname)],
866
867     sys_wait_h => [qw(WEXITSTATUS WIFEXITED WIFSIGNALED WIFSTOPPED
868                 WNOHANG WSTOPSIG WTERMSIG WUNTRACED)],
869
870     termios_h => [qw( B0 B110 B1200 B134 B150 B1800 B19200 B200 B2400
871                 B300 B38400 B4800 B50 B600 B75 B9600 BRKINT CLOCAL
872                 CREAD CS5 CS6 CS7 CS8 CSIZE CSTOPB ECHO ECHOE ECHOK
873                 ECHONL HUPCL ICANON ICRNL IEXTEN IGNBRK IGNCR IGNPAR
874                 INLCR INPCK ISIG ISTRIP IXOFF IXON NCCS NOFLSH OPOST
875                 PARENB PARMRK PARODD TCIFLUSH TCIOFF TCIOFLUSH TCION
876                 TCOFLUSH TCOOFF TCOON TCSADRAIN TCSAFLUSH TCSANOW
877                 TOSTOP VEOF VEOL VERASE VINTR VKILL VMIN VQUIT VSTART
878                 VSTOP VSUSP VTIME
879                 cfgetispeed cfgetospeed cfsetispeed cfsetospeed tcdrain
880                 tcflow tcflush tcgetattr tcsendbreak tcsetattr )],
881
882     time_h =>   [qw(CLK_TCK CLOCKS_PER_SEC NULL asctime clock ctime
883                 difftime mktime strftime tzset tzname)],
884
885     unistd_h => [qw(F_OK NULL R_OK SEEK_CUR SEEK_END SEEK_SET
886                 STDERR_FILENO STDIN_FILENO STDOUT_FILENO W_OK X_OK
887                 _PC_CHOWN_RESTRICTED _PC_LINK_MAX _PC_MAX_CANON
888                 _PC_MAX_INPUT _PC_NAME_MAX _PC_NO_TRUNC _PC_PATH_MAX
889                 _PC_PIPE_BUF _PC_VDISABLE _POSIX_CHOWN_RESTRICTED
890                 _POSIX_JOB_CONTROL _POSIX_NO_TRUNC _POSIX_SAVED_IDS
891                 _POSIX_VDISABLE _POSIX_VERSION _SC_ARG_MAX
892                 _SC_CHILD_MAX _SC_CLK_TCK _SC_JOB_CONTROL
893                 _SC_NGROUPS_MAX _SC_OPEN_MAX _SC_SAVED_IDS
894                 _SC_STREAM_MAX _SC_TZNAME_MAX _SC_VERSION
895                 _exit access ctermid cuserid
896                 dup2 dup execl execle execlp execv execve execvp
897                 fpathconf getcwd getegid geteuid getgid getgroups
898                 getpid getuid isatty lseek pathconf pause setgid setpgid
899                 setsid setuid sysconf tcgetpgrp tcsetpgrp ttyname)],
900
901     utime_h =>  [qw()],
902
903 );
904
905 # Exporter::export_tags();
906 for (values %EXPORT_TAGS) {
907   push @EXPORT, @$_;
908 }
909
910 @EXPORT_OK = qw(
911     closedir opendir readdir rewinddir
912     fcntl open
913     getgrgid getgrnam
914     atan2 cos exp log sin sqrt
915     getpwnam getpwuid
916     kill
917     fileno getc printf rename sprintf
918     abs exit rand srand system
919     chmod mkdir stat umask
920     times
921     wait waitpid
922     gmtime localtime time 
923     alarm chdir chown close fork getlogin getppid getpgrp link
924         pipe read rmdir sleep unlink write
925     utime
926     nice
927 );
928
929 require Exporter;
930 }