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