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