perl 5.0 alpha 8
[p5sagit/p5-mst-13.2.git] / lib / POSIX.pm
1 package POSIX;
2
3 require Exporter;
4 require AutoLoader;
5 @ISA = (Exporter, AutoLoader, DynamicLoader);
6
7 $H{assert_h} =  [qw(assert NDEBUG)];
8
9 $H{ctype_h} =   [qw(isalnum isalpha iscntrl isdigit isgraph islower
10                 isprint ispunct isspace isupper isxdigit tolower toupper)];
11
12 $H{dirent_h} =  [qw(closedir opendir readdir rewinddir)];
13
14 $H{errno_h} =   [qw(E2BIG EACCES EAGAIN EBADF EBUSY ECHILD EDEADLK EDOM
15                 EEXIST EFAULT EFBIG EINTR EINVAL EIO EISDIR EMFILE
16                 EMLINK ENAMETOOLONG ENFILE ENODEV ENOENT ENOEXEC ENOLCK
17                 ENOMEM ENOSPC ENOSYS ENOTDIR ENOTEMPTY ENOTTY ENXIO
18                 EPERM EPIPE ERANGE EROFS ESPIPE ESRCH EXDEV errno)];
19
20 $H{fcntl_h} =   [qw(FD_CLOEXEC F_DUPFD F_GETFD F_GETFL F_GETLK F_RDLCK
21                 F_SETFD F_SETFL F_SETLK F_SETLKW F_UNLCK F_WRLCK
22                 O_ACCMODE O_APPEND O_CREAT O_EXCL O_NOCTTY O_NONBLOCK
23                 O_RDONLY O_RDWR O_TRUNC O_WRONLY
24                 creat fcntl open
25                 SEEK_CUR SEEK_END SEEK_SET
26                 S_IRGRP S_IROTH S_IRUSR S_IRWXG S_IRWXO S_IRWXU
27                 S_ISBLK S_ISCHR S_ISDIR S_ISFIFO S_ISGID S_ISREG S_ISUID
28                 S_IWGRP S_IWOTH S_IWUSR)];
29
30 $H{float_h} =   [qw(DBL_DIG DBL_EPSILON DBL_MANT_DIG
31                 DBL_MAX DBL_MAX_10_EXP DBL_MAX_EXP
32                 DBL_MIN DBL_MIN_10_EXP DBL_MIN_EXP
33                 FLT_DIG FLT_EPSILON FLT_MANT_DIG
34                 FLT_MAX FLT_MAX_10_EXP FLT_MAX_EXP
35                 FLT_MIN FLT_MIN_10_EXP FLT_MIN_EXP
36                 FLT_RADIX FLT_ROUNDS
37                 LDBL_DIG LDBL_EPSILON LDBL_MANT_DIG
38                 LDBL_MAX LDBL_MAX_10_EXP LDBL_MAX_EXP
39                 LDBL_MIN LDBL_MIN_10_EXP LDBL_MIN_EXP)];
40
41 $H{grp_h} =     [qw(getgrgid getgrnam)];
42
43 $H{limits_h} =  [qw( ARG_MAX CHAR_BIT CHAR_MAX CHAR_MIN CHILD_MAX
44                 INT_MAX INT_MIN LINK_MAX LONG_MAX LONG_MIN MAX_CANON
45                 MAX_INPUT MB_LEN_MAX NAME_MAX NGROUPS_MAX OPEN_MAX
46                 PATH_MAX PIPE_BUF SCHAR_MAX SCHAR_MIN SHRT_MAX SHRT_MIN
47                 SSIZE_MAX STREAM_MAX TZNAME_MAX UCHAR_MAX UINT_MAX
48                 ULONG_MAX USHRT_MAX _POSIX_ARG_MAX _POSIX_CHILD_MAX
49                 _POSIX_LINK_MAX _POSIX_MAX_CANON _POSIX_MAX_INPUT
50                 _POSIX_NAME_MAX _POSIX_NGROUPS_MAX _POSIX_OPEN_MAX
51                 _POSIX_PATH_MAX _POSIX_PIPE_BUF _POSIX_SSIZE_MAX
52                 _POSIX_STREADM_MAX _POSIX_TZNAME_MAX)];
53
54 $H{locale_h} =  [qw(LC_ALL LC_COLLATE LC_CTYPE LC_MONETARY LC_NUMERIC
55                 LC_TIME NULL localeconv setlocale)];
56
57 $H{math_h} =    [qw(HUGE_VAL acos asin atan2 atan ceil cos cosh exp
58                 fabs floor fmod frexp ldexp log10 log modf pow sin sinh
59                 sqrt tan tanh)];
60
61 $H{pwd_h} =     [qw(getpwnam getpwuid)];
62
63 $H{setjmp_h} =  [qw(longjmp setjmp siglongjmp sigsetjmp)];
64
65 $H{signal_h} =  [qw(SA_NOCLDSTOP SIGABRT SIGALRM SIGCHLD SIGCONT SIGFPE
66                 SIGHUP SIGILL SIGINT SIGKILL SIGPIPE SIGQUIT SIGSEGV
67                 SIGSTOP SIGTERM SIGTSTP SIGTTIN SIGTTOU SIGUSR1 SIGUSR2
68                 SIG_BLOCK SIG_DFL SIG_ERR SIG_IGN SIG_SETMASK SIG_UNBLOCK
69                 kill raise sigaction signal sigpending sigprocmask
70                 sigsuspend)];
71
72 $H{stdarg_h} =  [qw()];
73
74 $H{stddef_h} =  [qw(NULL offsetof)];
75
76 $H{stdio_h} =   [qw(BUFSIZ EOF FILENAME_MAX L_ctermid L_cuserid
77                 L_tmpname NULL SEEK_CUR SEEK_END SEEK_SET STREAM_MAX
78                 TMP_MAX stderr stdin stdout _IOFBF _IOLBF _IONBF
79                 clearerr fclose fdopen feof ferror fflush fgetc fgetpos
80                 fgets fileno fopen fprintf fputc fputs fread freopen
81                 fscanf fseek fsetpos ftell fwrite getc getchar gets
82                 perror printf putc putchar puts remove rename rewind
83                 scanf setbuf setvbuf sprintf sscanf tmpfile tmpnam
84                 ungetc vfprintf vprintf vsprintf)];
85
86 $H{stdlib_h} =  [qw(EXIT_FAILURE EXIT_SUCCESS MB_CUR_MAX NULL RAND_MAX
87                 abort abs atexit atof atoi atol bsearch calloc div exit
88                 free getenv labs ldiv malloc mblen mbstowcs mbtowc
89                 qsort rand realloc srand strtod strtol stroul system
90                 wcstombs wctomb)];
91
92 $H{string_h} =  [qw(NULL memchr memcmp memcpy memmove memset strcat
93                 strchr strcmp strcoll strcpy strcspn strerror strlen
94                 strncat strncmp strncpy strpbrk strrchr strspn strstr
95                 strtok strxfrm)];
96
97 $H{sys_stat_h} = [qw(S_IRGRP S_IROTH S_IRUSR S_IRWXG S_IRWXO S_IRWXU
98                 S_ISBLK S_ISCHR S_ISDIR S_ISFIFO S_ISGID S_ISREG
99                 S_ISUID S_IWGRP S_IWOTH S_IWUSR S_IXGRP S_IXOTH S_IXUSR
100                 chmod fstat mkdir mkfifo stat umask)];
101
102 $H{sys_times_h} = [qw(times)];
103
104 $H{sys_types_h} = [qw()];
105
106 $H{sys_utsname_h} = [qw(uname)];
107
108 $H{sys_wait_h} = [qw(WEXITSTATUS WIFEXITED WIFSIGNALED WIFSTOPPED
109                 WNOHANG WSTOPSIG WTERMSIG WUNTRACED wait waitpid)];
110
111 $H{termios_h} = [qw( B0 B110 B1200 B134 B150 B1800 B19200 B200 B2400
112                 B300 B38400 B4800 B50 B600 B75 B9600 BRKINT CLOCAL
113                 CREAD CS5 CS6 CS7 CS8 CSIZE CSTOPB ECHO ECHOE ECHOK
114                 ECHONL HUPCL ICANON ICRNL IEXTEN IGNBRK IGNCR IGNPAR
115                 INLCR INPCK ISIG ISTRIP IXOFF IXON NCCS NOFLSH OPOST
116                 PARENB PARMRK PARODD TCIFLUSH TCIOFF TCIOFLUSH TCION
117                 TCOFLUSH TCOOFF TCOON TCSADRAIN TCSAFLUSH TCSANOW
118                 TOSTOP VEOF VEOL VERASE VINTR VKILL VMIN VQUIT VSTART
119                 VSTOP VSUSP VTIME
120                 cfgetispeed cfgetospeed cfsetispeed cfsetospeed tcdrain
121                 tcflow tcflush tcgetattr tcsendbreak tcsetattr )];
122
123 $H{time_h} =    [qw(CLK_TCK CLOCKS_PER_SEC NULL asctime clock ctime
124                 difftime gmtime localtime mktime strftime time tzset tzname)];
125
126 $H{unistd_h} =  [qw(F_OK NULL R_OK SEEK_CUR SEEK_END SEEK_SET
127                 STRERR_FILENO STDIN_FILENO STDOUT_FILENO W_OK X_OK
128                 _PC_CHOWN_RESTRICTED _PC_LINK_MAX _PC_MAX_CANON
129                 _PC_MAX_INPUT _PC_NAME_MAX _PC_NO_TRUNC _PC_PATH_MAX
130                 _PC_PIPE_BUF _PC_VDISABLE _POSIX_CHOWN_RESTRICTED
131                 _POSIX_JOB_CONTROL _POSIX_NO_TRUNC _POSIX_SAVED_IDS
132                 _POSIX_VDISABLE _POSIX_VERSION _SC_ARG_MAX
133                 _SC_CHILD_MAX _SC_CLK_TCK _SC_JOB_CONTROL
134                 _SC_NGROUPS_MAX _SC_OPEN_MAX _SC_SAVED_IDS
135                 _SC_STREAM_MAX _SC_TZNAME_MAX _SC_VERSION
136                 _exit access alarm chdir chown close ctermid cuserid
137                 dup2 dup execl execle execlp execv execve execvp fork
138                 fpathconf getcwd getegid geteuid getgid getgroups
139                 getlogin getpgrp getpid getppid getuid isatty link
140                 lseek pathconf pause pipe read rmdir setgid setpgid
141                 setsid setuid sleep sysconf tcgetpgrp tcsetpgrp ttyname
142                 unlink write)];
143
144 $H{utime_h} =   [qw(utime)];
145
146 sub expand {
147     local (@mylist);
148     foreach $entry (@_) {
149         if ($H{$entry}) {
150             push(@mylist, @{$H{$entry}});
151         }
152         else {
153             push(@mylist, $entry);
154         }
155     }
156     @mylist;
157 }
158
159 @EXPORT = expand qw(assert_h ctype_h dirent_h errno_h fcntl_h float_h
160                 grp_h limits_h locale_h math_h pwd_h setjmp_h signal_h
161                 stdarg_h stddef_h stdio_h stdlib_h string_h sys_stat_h
162                 sys_times_h sys_types_h sys_utsname_h sys_wait_h
163                 termios_h time_h unistd_h utime_h);
164
165 sub import {
166     my $this = shift;
167     my @list = expand @_;
168     local $Exporter::ExportLevel = 1;
169     Exporter::import($this,@list);
170 }
171
172 sub AUTOLOAD {
173     if ($AUTOLOAD =~ /::(_?[a-z])/) {
174         $AutoLoader::AUTOLOAD = $AUTOLOAD;
175         goto &AutoLoader::AUTOLOAD
176     }
177     local $constname = $AUTOLOAD;
178     $constname =~ s/.*:://;
179     $val = constant($constname, $_[0]);
180     if ($! != 0) {
181         ($pack,$file,$line) = caller;
182         if ($! =~ /Invalid/) {
183             die "$constname is not a valid POSIX macro at $file line $line.\n";
184         }
185         else {
186             die "Your vendor has not defined POSIX macro $constname, used at $file line $line.\n";
187         }
188     }
189     eval "sub $AUTOLOAD { $val }";
190     goto &$AUTOLOAD;
191 }
192
193 bootstrap POSIX;
194
195 sub usage { 
196     local ($mess, $pack, $file, $line) = @_;
197     die "Usage: POSIX::$mess at $file line $line\n";
198 }
199
200 sub unimpl { 
201     local ($mess, $pack, $file, $line) = @_;
202     $mess =~ s/xxx//;
203     die "Unimplemented: POSIX::$mess at $file line $line\n";
204 }
205
206 $gensym = "SYM000";
207
208 sub gensym {
209     $gensym++;
210 }
211
212 sub ungensym {
213     delete $_POSIX{$_[0]};
214 }
215
216 1;
217
218 package POSIX::SigAction;
219
220 sub new {
221     bless {HANDLER => $_[1], MASK => $_[2], FLAGS => $_[3]};
222 }
223 __END__
224
225 sub assert {
226     usage "assert(expr)", caller if @_ != 1;
227     if (!$_[0]) {
228         local ($pack,$file,$line) = caller;
229         die "Assertion failed at $file line $line\n";
230     }
231 }
232
233 sub tolower {
234     usage "tolower(string)", caller if @_ != 1;
235     lc($_[0]);
236 }
237
238 sub toupper {
239     usage "toupper(string)", caller if @_ != 1;
240     uc($_[0]);
241 }
242
243 sub closedir {
244     usage "closedir(dirhandle)", caller if @_ != 1;
245     closedir($_[0]);
246     ungensym($_[0]);
247 }
248
249 sub opendir {
250     usage "opendir(directory)", caller if @_ != 1;
251     local($dirhandle) = &gensym;
252     opendir($dirhandle, $_[0])
253         ? $dirhandle
254         : (ungensym($dirhandle), undef);
255 }
256
257 sub readdir {
258     usage "readdir(dirhandle)", caller if @_ != 1;
259     readdir($_[0]);
260 }
261
262 sub rewinddir {
263     usage "rewinddir(dirhandle)", caller if @_ != 1;
264     rewinddir($_[0]);
265 }
266
267 sub errno {
268     usage "errno()", caller if @_ != 0;
269     $! + 0;
270 }
271
272 sub creat {
273     usage "creat(filename, mode)", caller if @_ != 2;
274     &open($_[0], &O_WRONLY | &O_CREAT | &O_TRUNC, $_[2]);
275 }
276
277 sub fcntl {
278     usage "fcntl(filehandle, cmd, arg)", caller if @_ != 3;
279     fcntl($_[0], $_[1], $_[2]);
280 }
281
282 sub getgrgid {
283     usage "getgrgid(gid)", caller if @_ != 1;
284     getgrgid($_[0]);
285 }
286
287 sub getgrnam {
288     usage "getgrnam(name)", caller if @_ != 1;
289     getgrnam($_[0]);
290 }
291
292 sub atan2 {
293     usage "atan2(x,y)", caller if @_ != 2;
294     atan2($_[0], $_[1]);
295 }
296
297 sub cos {
298     usage "cos(x)", caller if @_ != 1;
299     cos($_[0]);
300 }
301
302 sub exp {
303     usage "exp(x)", caller if @_ != 1;
304     exp($_[0]);
305 }
306
307 sub fabs {
308     usage "fabs(x)", caller if @_ != 1;
309     abs($_[0]);
310 }
311
312 sub log {
313     usage "log(x)", caller if @_ != 1;
314     log($_[0]);
315 }
316
317 sub pow {
318     usage "pow(x,exponent)", caller if @_ != 2;
319     $_[0] ** $_[1];
320 }
321
322 sub sin {
323     usage "sin(x)", caller if @_ != 1;
324     sin($_[0]);
325 }
326
327 sub sqrt {
328     usage "sqrt(x)", caller if @_ != 1;
329     sqrt($_[0]);
330 }
331
332 sub tan {
333     usage "tan(x)", caller if @_ != 1;
334     tan($_[0]);
335 }
336
337 sub getpwnam {
338     usage "getpwnam(name)", caller if @_ != 1;
339     getpwnam($_[0]);
340 }
341
342 sub getpwuid {
343     usage "getpwuid(uid)", caller if @_ != 1;
344     getpwuid($_[0]);
345 }
346
347 sub longjmp {
348     unimpl "longjmp() is C-specific: use die instead", caller;
349 }
350
351 sub setjmp {
352     unimpl "setjmp() is C-specific: use eval {} instead", caller;
353 }
354
355 sub siglongjmp {
356     unimpl "siglongjmp() is C-specific: use die instead", caller;
357 }
358
359 sub sigsetjmp {
360     unimpl "sigsetjmp() is C-specific: use eval {} instead", caller;
361 }
362
363 sub kill {
364     usage "kill(pid, sig)", caller if @_ != 2;
365     kill $_[1], $_[0];
366 }
367
368 sub raise {
369     usage "raise(sig)", caller if @_ != 1;
370     kill $$, $_[0];     # Is this good enough?
371 }
372
373 sub offsetof {
374     unimpl "offsetof() is C-specific, stopped", caller;
375 }
376
377 sub clearerr {
378     usage "clearerr(filehandle)", caller if @_ != 1;
379     seek($_[0], 0, 1);
380 }
381
382 sub fclose {
383     unimpl "fclose() is C-specific--use close instead", caller;
384 }
385
386 sub feof {
387     usage "feof(filehandle)", caller if @_ != 1;
388     eof($_[0]);
389 }
390
391 sub fgetc {
392     usage "fgetc(filehandle)", caller if @_ != 1;
393     getc($_[0]);
394 }
395
396 sub fgetpos {
397     unimpl "fgetpos(xxx)", caller if @_ != 123;
398     fgetpos($_[0]);
399 }
400
401 sub fgets {
402     usage "fgets(filehandle)", caller if @_ != 1;
403     local($handle) = @_;
404     scalar <$handle>;
405 }
406
407 sub fileno {
408     usage "fileno(filehandle)", caller if @_ != 1;
409     fileno($_[0]);
410 }
411
412 sub fopen {
413     unimpl "fopen() is C-specific--use open instead", caller;
414 }
415
416 sub fprintf {
417     unimpl "fprintf() is C-specific--use printf instead", caller;
418 }
419
420 sub fputc {
421     unimpl "fputc() is C-specific--use print instead", caller;
422 }
423
424 sub fputs {
425     unimpl "fputs() is C-specific--use print instead", caller;
426     usage "fputs(string, handle)", caller if @_ != 2;
427     local($handle) = pop;
428     print $handle @_;
429 }
430
431 sub fread {
432     unimpl "fread() is C-specific--use read instead", caller;
433     unimpl "fread(xxx)", caller if @_ != 123;
434     fread($_[0]);
435 }
436
437 sub freopen {
438     unimpl "freopen() is C-specific--use open instead", caller;
439     unimpl "freopen(xxx)", caller if @_ != 123;
440     freopen($_[0]);
441 }
442
443 sub fscanf {
444     unimpl "fscanf() is C-specific--use <> and regular expressions instead", caller;
445     unimpl "fscanf(xxx)", caller if @_ != 123;
446     fscanf($_[0]);
447 }
448
449 sub fseek {
450     unimpl "fseek() is C-specific--use seek instead", caller;
451     unimpl "fseek(xxx)", caller if @_ != 123;
452     fseek($_[0]);
453 }
454
455 sub fsetpos {
456     unimpl "fsetpos() is C-specific--use seek instead", caller;
457     unimpl "fsetpos(xxx)", caller if @_ != 123;
458     fsetpos($_[0]);
459 }
460
461 sub ftell {
462     unimpl "ftell() is C-specific--use tell instead", caller;
463     unimpl "ftell(xxx)", caller if @_ != 123;
464     ftell($_[0]);
465 }
466
467 sub fwrite {
468     unimpl "fwrite() is C-specific--use print instead", caller;
469     unimpl "fwrite(xxx)", caller if @_ != 123;
470     fwrite($_[0]);
471 }
472
473 sub getc {
474     usage "getc(handle)", caller if @_ != 1;
475     getc($_[0]);
476 }
477
478 sub getchar {
479     usage "getchar()", caller if @_ != 0;
480     getc(STDIN);
481 }
482
483 sub gets {
484     usage "gets(handle)", caller if @_ != 1;
485     local($handle) = shift;
486     scalar <$handle>;
487 }
488
489 sub perror {
490     unimpl "perror() is C-specific--print $! instead", caller;
491     unimpl "perror(xxx)", caller if @_ != 123;
492     perror($_[0]);
493 }
494
495 sub printf {
496     usage "printf(pattern, args...)", caller if @_ < 1;
497     printf STDOUT @_;
498 }
499
500 sub putc {
501     unimpl "putc() is C-specific--use print instead", caller;
502     unimpl "putc(xxx)", caller if @_ != 123;
503     putc($_[0]);
504 }
505
506 sub putchar {
507     unimpl "putchar() is C-specific--use print instead", caller;
508     unimpl "putchar(xxx)", caller if @_ != 123;
509     putchar($_[0]);
510 }
511
512 sub puts {
513     unimpl "puts() is C-specific--use print instead", caller;
514     unimpl "puts(xxx)", caller if @_ != 123;
515     puts($_[0]);
516 }
517
518 sub remove {
519     unimpl "remove(xxx)", caller if @_ != 123;
520     remove($_[0]);
521 }
522
523 sub rename {
524     unimpl "rename(xxx)", caller if @_ != 123;
525     rename($_[0]);
526 }
527
528 sub rewind {
529     unimpl "rewind(xxx)", caller if @_ != 123;
530     rewind($_[0]);
531 }
532
533 sub scanf {
534     unimpl "scanf(xxx)", caller if @_ != 123;
535     scanf($_[0]);
536 }
537
538 sub setbuf {
539     unimpl "setbuf(xxx)", caller if @_ != 123;
540     setbuf($_[0]);
541 }
542
543 sub setvbuf {
544     unimpl "setvbuf(xxx)", caller if @_ != 123;
545     setvbuf($_[0]);
546 }
547
548 sub sprintf {
549     unimpl "sprintf(xxx)", caller if @_ != 123;
550     sprintf($_[0]);
551 }
552
553 sub sscanf {
554     unimpl "sscanf(xxx)", caller if @_ != 123;
555     sscanf($_[0]);
556 }
557
558 sub tmpfile {
559     unimpl "tmpfile(xxx)", caller if @_ != 123;
560     tmpfile($_[0]);
561 }
562
563 sub tmpnam {
564     unimpl "tmpnam(xxx)", caller if @_ != 123;
565     tmpnam($_[0]);
566 }
567
568 sub ungetc {
569     unimpl "ungetc(xxx)", caller if @_ != 123;
570     ungetc($_[0]);
571 }
572
573 sub vfprintf {
574     unimpl "vfprintf(xxx)", caller if @_ != 123;
575     vfprintf($_[0]);
576 }
577
578 sub vprintf {
579     unimpl "vprintf(xxx)", caller if @_ != 123;
580     vprintf($_[0]);
581 }
582
583 sub vsprintf {
584     unimpl "vsprintf(xxx)", caller if @_ != 123;
585     vsprintf($_[0]);
586 }
587
588 sub abort {
589     unimpl "abort(xxx)", caller if @_ != 123;
590     abort($_[0]);
591 }
592
593 sub abs {
594     usage "abs(x)", caller if @_ != 1;
595     abs($_[0]);
596 }
597
598 sub atexit {
599     unimpl "atexit() is C-specific: use END {} instead", caller;
600 }
601
602 sub atof {
603     unimpl "atof() is C-specific, stopped", caller;
604 }
605
606 sub atoi {
607     unimpl "atoi() is C-specific, stopped", caller;
608 }
609
610 sub atol {
611     unimpl "atol() is C-specific, stopped", caller;
612 }
613
614 sub bsearch {
615     unimpl "bsearch(xxx)", caller if @_ != 123;
616     bsearch($_[0]);
617 }
618
619 sub calloc {
620     unimpl "calloc(xxx)", caller if @_ != 123;
621     calloc($_[0]);
622 }
623
624 sub div {
625     unimpl "div(xxx)", caller if @_ != 123;
626     div($_[0]);
627 }
628
629 sub exit {
630     unimpl "exit(xxx)", caller if @_ != 123;
631     exit($_[0]);
632 }
633
634 sub free {
635     unimpl "free(xxx)", caller if @_ != 123;
636     free($_[0]);
637 }
638
639 sub getenv {
640     unimpl "getenv(xxx)", caller if @_ != 123;
641     getenv($_[0]);
642 }
643
644 sub labs {
645     unimpl "labs(xxx)", caller if @_ != 123;
646     labs($_[0]);
647 }
648
649 sub ldiv {
650     unimpl "ldiv(xxx)", caller if @_ != 123;
651     ldiv($_[0]);
652 }
653
654 sub malloc {
655     unimpl "malloc(xxx)", caller if @_ != 123;
656     malloc($_[0]);
657 }
658
659 sub mblen {
660     unimpl "mblen(xxx)", caller if @_ != 123;
661     mblen($_[0]);
662 }
663
664 sub mbstowcs {
665     unimpl "mbstowcs(xxx)", caller if @_ != 123;
666     mbstowcs($_[0]);
667 }
668
669 sub mbtowc {
670     unimpl "mbtowc(xxx)", caller if @_ != 123;
671     mbtowc($_[0]);
672 }
673
674 sub qsort {
675     unimpl "qsort(xxx)", caller if @_ != 123;
676     qsort($_[0]);
677 }
678
679 sub rand {
680     unimpl "rand(xxx)", caller if @_ != 123;
681     rand($_[0]);
682 }
683
684 sub realloc {
685     unimpl "realloc(xxx)", caller if @_ != 123;
686     realloc($_[0]);
687 }
688
689 sub srand {
690     unimpl "srand(xxx)", caller if @_ != 123;
691     srand($_[0]);
692 }
693
694 sub strtod {
695     unimpl "strtod(xxx)", caller if @_ != 123;
696     strtod($_[0]);
697 }
698
699 sub strtol {
700     unimpl "strtol(xxx)", caller if @_ != 123;
701     strtol($_[0]);
702 }
703
704 sub stroul {
705     unimpl "stroul(xxx)", caller if @_ != 123;
706     stroul($_[0]);
707 }
708
709 sub system {
710     unimpl "system(xxx)", caller if @_ != 123;
711     system($_[0]);
712 }
713
714 sub wcstombs {
715     unimpl "wcstombs(xxx)", caller if @_ != 123;
716     wcstombs($_[0]);
717 }
718
719 sub wctomb {
720     unimpl "wctomb(xxx)", caller if @_ != 123;
721     wctomb($_[0]);
722 }
723
724 sub memchr {
725     unimpl "memchr(xxx)", caller if @_ != 123;
726     memchr($_[0]);
727 }
728
729 sub memcmp {
730     unimpl "memcmp(xxx)", caller if @_ != 123;
731     memcmp($_[0]);
732 }
733
734 sub memcpy {
735     unimpl "memcpy(xxx)", caller if @_ != 123;
736     memcpy($_[0]);
737 }
738
739 sub memmove {
740     unimpl "memmove(xxx)", caller if @_ != 123;
741     memmove($_[0]);
742 }
743
744 sub memset {
745     unimpl "memset(xxx)", caller if @_ != 123;
746     memset($_[0]);
747 }
748
749 sub strcat {
750     unimpl "strcat(xxx)", caller if @_ != 123;
751     strcat($_[0]);
752 }
753
754 sub strchr {
755     unimpl "strchr(xxx)", caller if @_ != 123;
756     strchr($_[0]);
757 }
758
759 sub strcmp {
760     unimpl "strcmp(xxx)", caller if @_ != 123;
761     strcmp($_[0]);
762 }
763
764 sub strcoll {
765     unimpl "strcoll(xxx)", caller if @_ != 123;
766     strcoll($_[0]);
767 }
768
769 sub strcpy {
770     unimpl "strcpy(xxx)", caller if @_ != 123;
771     strcpy($_[0]);
772 }
773
774 sub strcspn {
775     unimpl "strcspn(xxx)", caller if @_ != 123;
776     strcspn($_[0]);
777 }
778
779 sub strerror {
780     unimpl "strerror(xxx)", caller if @_ != 123;
781     strerror($_[0]);
782 }
783
784 sub strlen {
785     unimpl "strlen(xxx)", caller if @_ != 123;
786     strlen($_[0]);
787 }
788
789 sub strncat {
790     unimpl "strncat(xxx)", caller if @_ != 123;
791     strncat($_[0]);
792 }
793
794 sub strncmp {
795     unimpl "strncmp(xxx)", caller if @_ != 123;
796     strncmp($_[0]);
797 }
798
799 sub strncpy {
800     unimpl "strncpy(xxx)", caller if @_ != 123;
801     strncpy($_[0]);
802 }
803
804 sub strpbrk {
805     unimpl "strpbrk(xxx)", caller if @_ != 123;
806     strpbrk($_[0]);
807 }
808
809 sub strrchr {
810     unimpl "strrchr(xxx)", caller if @_ != 123;
811     strrchr($_[0]);
812 }
813
814 sub strspn {
815     unimpl "strspn(xxx)", caller if @_ != 123;
816     strspn($_[0]);
817 }
818
819 sub strstr {
820     unimpl "strstr(xxx)", caller if @_ != 123;
821     strstr($_[0]);
822 }
823
824 sub strtok {
825     unimpl "strtok(xxx)", caller if @_ != 123;
826     strtok($_[0]);
827 }
828
829 sub strxfrm {
830     unimpl "strxfrm(xxx)", caller if @_ != 123;
831     strxfrm($_[0]);
832 }
833
834 sub chmod {
835     unimpl "chmod(xxx)", caller if @_ != 123;
836     chmod($_[0]);
837 }
838
839 sub fstat {
840     unimpl "fstat(xxx)", caller if @_ != 123;
841     fstat($_[0]);
842 }
843
844 sub mkdir {
845     unimpl "mkdir(xxx)", caller if @_ != 123;
846     mkdir($_[0]);
847 }
848
849 sub mkfifo {
850     unimpl "mkfifo(xxx)", caller if @_ != 123;
851     mkfifo($_[0]);
852 }
853
854 sub stat {
855     unimpl "stat(xxx)", caller if @_ != 123;
856     stat($_[0]);
857 }
858
859 sub umask {
860     unimpl "umask(xxx)", caller if @_ != 123;
861     umask($_[0]);
862 }
863
864 sub times {
865     unimpl "times(xxx)", caller if @_ != 123;
866     times($_[0]);
867 }
868
869 sub wait {
870     unimpl "wait(xxx)", caller if @_ != 123;
871     wait($_[0]);
872 }
873
874 sub waitpid {
875     unimpl "waitpid(xxx)", caller if @_ != 123;
876     waitpid($_[0]);
877 }
878
879 sub cfgetispeed {
880     unimpl "cfgetispeed(xxx)", caller if @_ != 123;
881     cfgetispeed($_[0]);
882 }
883
884 sub cfgetospeed {
885     unimpl "cfgetospeed(xxx)", caller if @_ != 123;
886     cfgetospeed($_[0]);
887 }
888
889 sub cfsetispeed {
890     unimpl "cfsetispeed(xxx)", caller if @_ != 123;
891     cfsetispeed($_[0]);
892 }
893
894 sub cfsetospeed {
895     unimpl "cfsetospeed(xxx)", caller if @_ != 123;
896     cfsetospeed($_[0]);
897 }
898
899 sub tcdrain {
900     unimpl "tcdrain(xxx)", caller if @_ != 123;
901     tcdrain($_[0]);
902 }
903
904 sub tcflow {
905     unimpl "tcflow(xxx)", caller if @_ != 123;
906     tcflow($_[0]);
907 }
908
909 sub tcflush {
910     unimpl "tcflush(xxx)", caller if @_ != 123;
911     tcflush($_[0]);
912 }
913
914 sub tcgetattr {
915     unimpl "tcgetattr(xxx)", caller if @_ != 123;
916     tcgetattr($_[0]);
917 }
918
919 sub tcsendbreak {
920     unimpl "tcsendbreak(xxx)", caller if @_ != 123;
921     tcsendbreak($_[0]);
922 }
923
924 sub tcsetattr {
925     unimpl "tcsetattr(xxx)", caller if @_ != 123;
926     tcsetattr($_[0]);
927 }
928
929 sub asctime {
930     unimpl "asctime(xxx)", caller if @_ != 123;
931     asctime($_[0]);
932 }
933
934 sub clock {
935     unimpl "clock(xxx)", caller if @_ != 123;
936     clock($_[0]);
937 }
938
939 sub ctime {
940     unimpl "ctime(xxx)", caller if @_ != 123;
941     ctime($_[0]);
942 }
943
944 sub difftime {
945     unimpl "difftime(xxx)", caller if @_ != 123;
946     difftime($_[0]);
947 }
948
949 sub gmtime {
950     unimpl "gmtime(xxx)", caller if @_ != 123;
951     gmtime($_[0]);
952 }
953
954 sub localtime {
955     unimpl "localtime(xxx)", caller if @_ != 123;
956     localtime($_[0]);
957 }
958
959 sub mktime {
960     unimpl "mktime(xxx)", caller if @_ != 123;
961     mktime($_[0]);
962 }
963
964 sub strftime {
965     unimpl "strftime(xxx)", caller if @_ != 123;
966     strftime($_[0]);
967 }
968
969 sub time {
970     unimpl "time(xxx)", caller if @_ != 123;
971     time($_[0]);
972 }
973
974 sub tzset {
975     unimpl "tzset(xxx)", caller if @_ != 123;
976     tzset($_[0]);
977 }
978
979 sub tzname {
980     unimpl "tzname(xxx)", caller if @_ != 123;
981     tzname($_[0]);
982 }
983
984 sub _exit {
985     unimpl "_exit(xxx)", caller if @_ != 123;
986     _exit($_[0]);
987 }
988
989 sub access {
990     unimpl "access(xxx)", caller if @_ != 123;
991     access($_[0]);
992 }
993
994 sub alarm {
995     unimpl "alarm(xxx)", caller if @_ != 123;
996     alarm($_[0]);
997 }
998
999 sub chdir {
1000     unimpl "chdir(xxx)", caller if @_ != 123;
1001     chdir($_[0]);
1002 }
1003
1004 sub chown {
1005     unimpl "chown(xxx)", caller if @_ != 123;
1006     chown($_[0]);
1007 }
1008
1009 sub close {
1010     unimpl "close(xxx)", caller if @_ != 123;
1011     close($_[0]);
1012 }
1013
1014 sub ctermid {
1015     unimpl "ctermid(xxx)", caller if @_ != 123;
1016     ctermid($_[0]);
1017 }
1018
1019 sub cuserid {
1020     unimpl "cuserid(xxx)", caller if @_ != 123;
1021     cuserid($_[0]);
1022 }
1023
1024 sub dup2 {
1025     unimpl "dup2(xxx)", caller if @_ != 123;
1026     dup2($_[0]);
1027 }
1028
1029 sub dup {
1030     unimpl "dup(xxx)", caller if @_ != 123;
1031     dup($_[0]);
1032 }
1033
1034 sub execl {
1035     unimpl "execl(xxx)", caller if @_ != 123;
1036     execl($_[0]);
1037 }
1038
1039 sub execle {
1040     unimpl "execle(xxx)", caller if @_ != 123;
1041     execle($_[0]);
1042 }
1043
1044 sub execlp {
1045     unimpl "execlp(xxx)", caller if @_ != 123;
1046     execlp($_[0]);
1047 }
1048
1049 sub execv {
1050     unimpl "execv(xxx)", caller if @_ != 123;
1051     execv($_[0]);
1052 }
1053
1054 sub execve {
1055     unimpl "execve(xxx)", caller if @_ != 123;
1056     execve($_[0]);
1057 }
1058
1059 sub execvp {
1060     unimpl "execvp(xxx)", caller if @_ != 123;
1061     execvp($_[0]);
1062 }
1063
1064 sub fork {
1065     usage "fork()", caller if @_ != 0;
1066     fork;
1067 }
1068
1069 sub fpathconf {
1070     unimpl "fpathconf(xxx)", caller if @_ != 123;
1071     fpathconf($_[0]);
1072 }
1073
1074 sub getcwd {
1075     unimpl "getcwd(xxx)", caller if @_ != 123;
1076     getcwd($_[0]);
1077 }
1078
1079 sub getegid {
1080     unimpl "getegid(xxx)", caller if @_ != 123;
1081     getegid($_[0]);
1082 }
1083
1084 sub geteuid {
1085     unimpl "geteuid(xxx)", caller if @_ != 123;
1086     geteuid($_[0]);
1087 }
1088
1089 sub getgid {
1090     unimpl "getgid(xxx)", caller if @_ != 123;
1091     getgid($_[0]);
1092 }
1093
1094 sub getgroups {
1095     unimpl "getgroups(xxx)", caller if @_ != 123;
1096     getgroups($_[0]);
1097 }
1098
1099 sub getlogin {
1100     unimpl "getlogin(xxx)", caller if @_ != 123;
1101     getlogin($_[0]);
1102 }
1103
1104 sub getpgrp {
1105     unimpl "getpgrp(xxx)", caller if @_ != 123;
1106     getpgrp($_[0]);
1107 }
1108
1109 sub getpid {
1110     usage "getpid()", caller if @_ != 0;
1111     $$;
1112 }
1113
1114 sub getppid {
1115     usage "getppid()", caller if @_ != 0;
1116     getppid;
1117 }
1118
1119 sub getuid {
1120     unimpl "getuid(xxx)", caller if @_ != 123;
1121     getuid($_[0]);
1122 }
1123
1124 sub isatty {
1125     unimpl "isatty(xxx)", caller if @_ != 123;
1126     isatty($_[0]);
1127 }
1128
1129 sub link {
1130     unimpl "link(xxx)", caller if @_ != 123;
1131     link($_[0]);
1132 }
1133
1134 sub lseek {
1135     unimpl "lseek(xxx)", caller if @_ != 123;
1136     lseek($_[0]);
1137 }
1138
1139 sub pathconf {
1140     unimpl "pathconf(xxx)", caller if @_ != 123;
1141     pathconf($_[0]);
1142 }
1143
1144 sub pause {
1145     unimpl "pause(xxx)", caller if @_ != 123;
1146     pause($_[0]);
1147 }
1148
1149 sub pipe {
1150     unimpl "pipe(xxx)", caller if @_ != 123;
1151     pipe($_[0]);
1152 }
1153
1154 sub read {
1155     unimpl "read(xxx)", caller if @_ != 123;
1156     read($_[0]);
1157 }
1158
1159 sub rmdir {
1160     unimpl "rmdir(xxx)", caller if @_ != 123;
1161     rmdir($_[0]);
1162 }
1163
1164 sub setgid {
1165     unimpl "setgid(xxx)", caller if @_ != 123;
1166     setgid($_[0]);
1167 }
1168
1169 sub setpgid {
1170     unimpl "setpgid(xxx)", caller if @_ != 123;
1171     setpgid($_[0]);
1172 }
1173
1174 sub setsid {
1175     unimpl "setsid(xxx)", caller if @_ != 123;
1176     setsid($_[0]);
1177 }
1178
1179 sub setuid {
1180     unimpl "setuid(xxx)", caller if @_ != 123;
1181     setuid($_[0]);
1182 }
1183
1184 sub sleep {
1185     unimpl "sleep(xxx)", caller if @_ != 123;
1186     sleep($_[0]);
1187 }
1188
1189 sub sysconf {
1190     unimpl "sysconf(xxx)", caller if @_ != 123;
1191     sysconf($_[0]);
1192 }
1193
1194 sub tcgetpgrp {
1195     unimpl "tcgetpgrp(xxx)", caller if @_ != 123;
1196     tcgetpgrp($_[0]);
1197 }
1198
1199 sub tcsetpgrp {
1200     unimpl "tcsetpgrp(xxx)", caller if @_ != 123;
1201     tcsetpgrp($_[0]);
1202 }
1203
1204 sub ttyname {
1205     unimpl "ttyname(xxx)", caller if @_ != 123;
1206     ttyname($_[0]);
1207 }
1208
1209 sub unlink {
1210     unimpl "unlink(xxx)", caller if @_ != 123;
1211     unlink($_[0]);
1212 }
1213
1214 sub write {
1215     unimpl "write(xxx)", caller if @_ != 123;
1216     write($_[0]);
1217 }
1218
1219 sub utime {
1220     unimpl "utime(xxx)", caller if @_ != 123;
1221     utime($_[0]);
1222 }
1223