MakeMaker should attempt to "require" rather than "use" prerequisites
[p5sagit/p5-mst-13.2.git] / opcode.pl
CommitLineData
79072805 1#!/usr/bin/perl
2
abdd5c84 3unlink "opcode.h", "opnames.h";
79072805 4open(OC, ">opcode.h") || die "Can't create opcode.h: $!\n";
abdd5c84 5open(ON, ">opnames.h") || die "Can't create opnames.h: $!\n";
79072805 6select OC;
7
8# Read data.
9
10while (<DATA>) {
11 chop;
12 next unless $_;
13 next if /^#/;
c07a80fd 14 ($key, $desc, $check, $flags, $args) = split(/\t+/, $_, 5);
15
16 warn qq[Description "$desc" duplicates $seen{$desc}\n] if $seen{$desc};
17 die qq[Opcode "$key" duplicates $seen{$key}\n] if $seen{$key};
18 $seen{$desc} = qq[description of opcode "$key"];
19 $seen{$key} = qq[opcode "$key"];
20
79072805 21 push(@ops, $key);
c07a80fd 22 $desc{$key} = $desc;
79072805 23 $check{$key} = $check;
24 $ckname{$check}++;
25 $flags{$key} = $flags;
26 $args{$key} = $args;
27}
28
29# Emit defines.
30
31$i = 0;
748a9306 32print <<"END";
a27f85b3 33/* !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
34 This file is built by opcode.pl from its data. Any changes made here
35 will be lost!
36*/
37
864dbfa3 38#define Perl_pp_i_preinc Perl_pp_preinc
39#define Perl_pp_i_predec Perl_pp_predec
40#define Perl_pp_i_postinc Perl_pp_postinc
41#define Perl_pp_i_postdec Perl_pp_postdec
748a9306 42
748a9306 43END
abdd5c84 44
45print ON <<"END";
46/* !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
47 This file is built by opcode.pl from its data. Any changes made here
48 will be lost!
49*/
50
51typedef enum opcode {
52END
53
79072805 54for (@ops) {
abdd5c84 55 print ON "\t", &tab(3,"OP_\U$_,"), "/* ", $i++, " */\n";
79072805 56}
abdd5c84 57print ON "\t", &tab(3,"OP_max"), "\n";
58print ON "} opcode;\n";
59print ON "\n#define MAXO ", scalar @ops, "\n\n";
79072805 60
c07a80fd 61# Emit op names and descriptions.
79072805 62
63print <<END;
73c4f7a1 64
65START_EXTERN_C
66
79072805 67#ifndef DOINIT
22c35a8c 68EXT char *PL_op_name[];
79072805 69#else
22c35a8c 70EXT char *PL_op_name[] = {
79072805 71END
72
73for (@ops) {
c07a80fd 74 print qq(\t"$_",\n);
75}
76
77print <<END;
78};
79#endif
80
81END
82
83print <<END;
84#ifndef DOINIT
22c35a8c 85EXT char *PL_op_desc[];
c07a80fd 86#else
22c35a8c 87EXT char *PL_op_desc[] = {
c07a80fd 88END
89
90for (@ops) {
42d38218 91 my($safe_desc) = $desc{$_};
92
93 # Have to escape double quotes and escape characters.
94 $safe_desc =~ s/(^|[^\\])([\\"])/$1\\$2/g;
95
96 print qq(\t"$safe_desc",\n);
79072805 97}
98
99print <<END;
100};
101#endif
102
73c4f7a1 103END_EXTERN_C
104
22c35a8c 105END
79072805 106
22c35a8c 107# Emit function declarations.
79072805 108
22c35a8c 109#for (sort keys %ckname) {
cea2e8a9 110# print "OP *\t", &tab(3,$_),"(pTHX_ OP* o);\n";
22c35a8c 111#}
112#
113#print "\n";
114#
115#for (@ops) {
cea2e8a9 116# print "OP *\t", &tab(3, "pp_$_"), "(pTHX);\n";
22c35a8c 117#}
79072805 118
119# Emit ppcode switch array.
120
121print <<END;
122
73c4f7a1 123START_EXTERN_C
124
79072805 125#ifndef DOINIT
cea2e8a9 126EXT OP * (CPERLscope(*PL_ppaddr)[])(pTHX);
79072805 127#else
cea2e8a9 128EXT OP * (CPERLscope(*PL_ppaddr)[])(pTHX) = {
79072805 129END
130
131for (@ops) {
2b260de0 132 print "\tMEMBER_TO_FPTR(Perl_pp_$_),\n";
79072805 133}
134
135print <<END;
136};
137#endif
138
139END
140
141# Emit check routines.
142
143print <<END;
144#ifndef DOINIT
cea2e8a9 145EXT OP * (CPERLscope(*PL_check)[]) (pTHX_ OP *op);
79072805 146#else
cea2e8a9 147EXT OP * (CPERLscope(*PL_check)[]) (pTHX_ OP *op) = {
79072805 148END
149
150for (@ops) {
2b260de0 151 print "\t", &tab(3, "MEMBER_TO_FPTR(Perl_$check{$_}),"), "\t/* $_ */\n";
79072805 152}
153
154print <<END;
155};
156#endif
157
158END
159
160# Emit allowed argument types.
161
162print <<END;
163#ifndef DOINIT
22c35a8c 164EXT U32 PL_opargs[];
79072805 165#else
22c35a8c 166EXT U32 PL_opargs[] = {
79072805 167END
168
169%argnum = (
170 S, 1, # scalar
171 L, 2, # list
172 A, 3, # array value
173 H, 4, # hash value
174 C, 5, # code value
175 F, 6, # file value
176 R, 7, # scalar reference
177);
178
db173bac 179%opclass = (
180 '0', 0, # baseop
181 '1', 1, # unop
182 '2', 2, # binop
183 '|', 3, # logop
1a67a97c 184 '@', 4, # listop
185 '/', 5, # pmop
350de78d 186 '$', 6, # svop_or_padop
7934575e 187 '#', 7, # padop
1a67a97c 188 '"', 8, # pvop_or_svop
189 '{', 9, # loop
190 ';', 10, # cop
191 '%', 11, # baseop_or_unop
192 '-', 12, # filestatop
193 '}', 13, # loopexop
db173bac 194);
195
79072805 196for (@ops) {
197 $argsum = 0;
198 $flags = $flags{$_};
199 $argsum |= 1 if $flags =~ /m/; # needs stack mark
200 $argsum |= 2 if $flags =~ /f/; # fold constants
201 $argsum |= 4 if $flags =~ /s/; # always produces scalar
202 $argsum |= 8 if $flags =~ /t/; # needs target scalar
b162f9ea 203 $argsum |= (8|256) if $flags =~ /T/; # ... which may be lexical
79072805 204 $argsum |= 16 if $flags =~ /i/; # always produces integer
205 $argsum |= 32 if $flags =~ /I/; # has corresponding int op
206 $argsum |= 64 if $flags =~ /d/; # danger, unknown side effects
a0d0e21e 207 $argsum |= 128 if $flags =~ /u/; # defaults to $_
db173bac 208
8be7d673 209 $flags =~ /([\W\d_])/ or die qq[Opcode "$_" has no class indicator];
b162f9ea 210 $argsum |= $opclass{$1} << 9;
211 $mul = 0x2000; # 2 ^ OASHIFT
79072805 212 for $arg (split(' ',$args{$_})) {
213 $argnum = ($arg =~ s/\?//) ? 8 : 0;
214 $argnum += $argnum{$arg};
b162f9ea 215 warn "# Conflicting bit 32 for '$_'.\n"
216 if $argnum & 8 and $mul == 0x10000000;
79072805 217 $argsum += $argnum * $mul;
218 $mul <<= 4;
219 }
220 $argsum = sprintf("0x%08x", $argsum);
db173bac 221 print "\t", &tab(3, "$argsum,"), "/* $_ */\n";
79072805 222}
223
224print <<END;
225};
226#endif
73c4f7a1 227
228END_EXTERN_C
79072805 229END
230
735e0d5c 231close OC or die "Error closing opcode.h: $!";
abdd5c84 232close ON or die "Error closing opnames.h: $!";
735e0d5c 233
2cd61cdb 234unlink "pp_proto.h";
22c35a8c 235unlink "pp.sym";
735e0d5c 236open PP, '>pp_proto.h' or die "Error creating pp_proto.h: $!";
22c35a8c 237open PPSYM, '>pp.sym' or die "Error creating pp.sym: $!";
238
a27f85b3 239print PP <<"END";
240/* !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
241 This file is built by opcode.pl from its data. Any changes made here
242 will be lost!
243*/
244
245END
246
247print PPSYM <<"END";
248#
249# !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
250# This file is built by opcode.pl from its data. Any changes made here
251# will be lost!
252#
253
254END
255
256
22c35a8c 257for (sort keys %ckname) {
864dbfa3 258 print PP "PERL_CKDEF(Perl_$_)\n";
259 print PPSYM "Perl_$_\n";
20ce7b12 260#OP *\t", &tab(3,$_),"(OP* o);\n";
22c35a8c 261}
262
263print PP "\n\n";
264
735e0d5c 265for (@ops) {
15e52e56 266 next if /^i_(pre|post)(inc|dec)$/;
864dbfa3 267 print PP "PERL_PPDEF(Perl_pp_$_)\n";
268 print PPSYM "Perl_pp_$_\n";
735e0d5c 269}
270
271close PP or die "Error closing pp_proto.h: $!";
22c35a8c 272close PPSYM or die "Error closing pp.sym: $!";
735e0d5c 273
79072805 274###########################################################################
275sub tab {
276 local($l, $t) = @_;
277 $t .= "\t" x ($l - (length($t) + 1) / 8);
278 $t;
279}
280###########################################################################
b162f9ea 281
282# Some comments about 'T' opcode classifier:
283
284# Safe to set if the ppcode uses:
285# tryAMAGICbin, tryAMAGICun, SETn, SETi, SETu, PUSHn, PUSHTARG, SETTARG,
286# SETs(TARG), XPUSHn, XPUSHu,
287
288# Unsafe to set if the ppcode uses dTARG or [X]RETPUSH[YES|NO|UNDEF]
289
290# lt and friends do SETs (including ncmp, but not scmp)
291
21f5b33c 292# Additional mode of failure: the opcode can modify TARG before it "used"
293# all the arguments (or may call an external function which does the same).
294# If the target coincides with one of the arguments ==> kaboom.
295
b162f9ea 296# pp.c pos substr each not OK (RETPUSHUNDEF)
297# substr vec also not OK due to LV to target (are they???)
298# ref not OK (RETPUSHNO)
299# trans not OK (dTARG; TARG = sv_newmortal();)
300# ucfirst etc not OK: TMP arg processed inplace
301# each repeat not OK too due to array context
302# pack split - unknown whether they are safe
dae78bb1 303# sprintf: is calling do_sprintf(TARG,...) which can act on TARG
304# before other args are processed.
b162f9ea 305
21f5b33c 306# Suspicious wrt "additional mode of failure" (and only it):
307# schop, chop, postinc/dec, bit_and etc, negate, complement.
308
309# Also suspicious: 4-arg substr, sprintf, uc/lc (POK_only), reverse, pack.
310
311# substr/vec: doing TAINT_off()???
312
b162f9ea 313# pp_hot.c
314# readline - unknown whether it is safe
315# match subst not OK (dTARG)
316# grepwhile not OK (not always setting)
317
21f5b33c 318# Suspicious wrt "additional mode of failure": concat (dealt with
319# in ck_sassign()), join (same).
320
b162f9ea 321# pp_ctl.c
322# mapwhile flip caller not OK (not always setting)
323
324# pp_sys.c
325# backtick glob warn die not OK (not always setting)
326# warn not OK (RETPUSHYES)
327# open fileno getc sysread syswrite ioctl accept shutdown
328# ftsize(etc) readlink telldir fork alarm getlogin not OK (RETPUSHUNDEF)
329# umask select not OK (XPUSHs(&PL_sv_undef);)
330# fileno getc sysread syswrite tell not OK (meth("FILENO" "GETC"))
331# sselect shm* sem* msg* syscall - unknown whether they are safe
332# gmtime not OK (list context)
333
21f5b33c 334# Suspicious wrt "additional mode of failure": warn, die, select.
335
79072805 336__END__
337
7399586d 338# New ops always go at the very end
339
79072805 340# Nothing.
341
342null null operation ck_null 0
93a17b20 343stub stub ck_null 0
db173bac 344scalar scalar ck_fun s% S
79072805 345
346# Pushy stuff.
347
db173bac 348pushmark pushmark ck_null s0
349wantarray wantarray ck_null is0
79072805 350
db173bac 351const constant item ck_svconst s$
79072805 352
7934575e 353gvsv scalar variable ck_null ds$
354gv glob value ck_null ds$
db173bac 355gelem glob elem ck_null d2 S S
356padsv private variable ck_null ds0
357padav private array ck_null d0
358padhv private hash ck_null d0
f1612b5c 359padany private value ck_null d0
79072805 360
1167e5da 361pushre push regexp ck_null d/
79072805 362
363# References and stuff.
364
db173bac 365rv2gv ref-to-glob cast ck_rvconst ds1
b89fed5f 366rv2sv scalar dereference ck_rvconst ds1
db173bac 367av2arylen array length ck_null is1
b89fed5f 368rv2cv subroutine dereference ck_rvconst d1
db173bac 369anoncode anonymous subroutine ck_anoncode $
370prototype subroutine prototype ck_null s% S
5d11ae5e 371refgen reference constructor ck_spair m1 L
dfa0f641 372srefgen single ref constructor ck_null fs1 S
db173bac 373ref reference-type operator ck_fun stu% S?
374bless bless ck_fun s@ S S?
79072805 375
376# Pushy I/O.
377
b3f4d674 378backtick quoted execution (``, qx) ck_null t%
0a753a76 379# glob defaults its first arg to $_
db173bac 380glob glob ck_glob t@ S? S?
381readline <HANDLE> ck_null t%
382rcatline append I/O operator ck_null t%
79072805 383
384# Bindable operators.
385
f1612b5c 386regcmaybe regexp internal guard ck_fun s1 S
387regcreset regexp internal reset ck_fun s1 S
388regcomp regexp compilation ck_null s| S
389match pattern match (m//) ck_match d/
390qr pattern quote (qr//) ck_match s/
391subst substitution (s///) ck_null dis/ S
392substcont substitution iterator ck_null dis|
393trans transliteration (tr///) ck_null is" S
79072805 394
395# Lvalue operators.
db173bac 396# sassign is special-cased for op class
397
b162f9ea 398sassign scalar assignment ck_sassign s0
db173bac 399aassign list assignment ck_null t2 L L
400
21f5b33c 401chop chop ck_spair mts% L
402schop scalar chop ck_null stu% S?
f1612b5c 403chomp chomp ck_spair mTs% L
404schomp scalar chomp ck_null sTu% S?
69794302 405defined defined operator ck_defined isu% S?
db173bac 406undef undef operator ck_lfun s% S?
407study study ck_fun su% S?
408pos match position ck_lfun stu% S?
409
42d38218 410preinc preincrement (++) ck_lfun dIs1 S
411i_preinc integer preincrement (++) ck_lfun dis1 S
412predec predecrement (--) ck_lfun dIs1 S
413i_predec integer predecrement (--) ck_lfun dis1 S
21f5b33c 414postinc postincrement (++) ck_lfun dIst1 S
42d38218 415i_postinc integer postincrement (++) ck_lfun disT1 S
21f5b33c 416postdec postdecrement (--) ck_lfun dIst1 S
42d38218 417i_postdec integer postdecrement (--) ck_lfun disT1 S
79072805 418
419# Ordinary operators.
420
42d38218 421pow exponentiation (**) ck_null fsT2 S S
422
f1612b5c 423multiply multiplication (*) ck_null IfsT2 S S
42d38218 424i_multiply integer multiplication (*) ck_null ifsT2 S S
425divide division (/) ck_null IfsT2 S S
426i_divide integer division (/) ck_null ifsT2 S S
427modulo modulus (%) ck_null IifsT2 S S
428i_modulo integer modulus (%) ck_null ifsT2 S S
429repeat repeat (x) ck_repeat mt2 L S
430
431add addition (+) ck_null IfsT2 S S
432i_add integer addition (+) ck_null ifsT2 S S
433subtract subtraction (-) ck_null IfsT2 S S
434i_subtract integer subtraction (-) ck_null ifsT2 S S
435concat concatenation (.) ck_concat fsT2 S S
b162f9ea 436stringify string ck_fun fsT@ S
db173bac 437
42d38218 438left_shift left bitshift (<<) ck_bitop fsT2 S S
439right_shift right bitshift (>>) ck_bitop fsT2 S S
440
441lt numeric lt (<) ck_null Iifs2 S S
442i_lt integer lt (<) ck_null ifs2 S S
443gt numeric gt (>) ck_null Iifs2 S S
444i_gt integer gt (>) ck_null ifs2 S S
445le numeric le (<=) ck_null Iifs2 S S
446i_le integer le (<=) ck_null ifs2 S S
447ge numeric ge (>=) ck_null Iifs2 S S
448i_ge integer ge (>=) ck_null ifs2 S S
449eq numeric eq (==) ck_null Iifs2 S S
450i_eq integer eq (==) ck_null ifs2 S S
451ne numeric ne (!=) ck_null Iifs2 S S
452i_ne integer ne (!=) ck_null ifs2 S S
453ncmp numeric comparison (<=>) ck_null Iifst2 S S
454i_ncmp integer comparison (<=>) ck_null ifst2 S S
db173bac 455
456slt string lt ck_scmp ifs2 S S
457sgt string gt ck_scmp ifs2 S S
458sle string le ck_scmp ifs2 S S
459sge string ge ck_scmp ifs2 S S
460seq string eq ck_null ifs2 S S
461sne string ne ck_null ifs2 S S
f1612b5c 462scmp string comparison (cmp) ck_scmp ifst2 S S
db173bac 463
21f5b33c 464bit_and bitwise and (&) ck_bitop fst2 S S
465bit_xor bitwise xor (^) ck_bitop fst2 S S
466bit_or bitwise or (|) ck_bitop fst2 S S
db173bac 467
21f5b33c 468negate negation (-) ck_null Ifst1 S
f1612b5c 469i_negate integer negation (-) ck_null ifsT1 S
db173bac 470not not ck_null ifs1 S
21f5b33c 471complement 1's complement (~) ck_bitop fst1 S
79072805 472
473# High falutin' math.
474
f1612b5c 475atan2 atan2 ck_fun fsT@ S S
476sin sin ck_fun fsTu% S?
477cos cos ck_fun fsTu% S?
478rand rand ck_fun sT% S?
479srand srand ck_fun s% S?
480exp exp ck_fun fsTu% S?
481log log ck_fun fsTu% S?
482sqrt sqrt ck_fun fsTu% S?
79072805 483
cf26c822 484# Lowbrow math.
485
b162f9ea 486int int ck_fun fsTu% S?
487hex hex ck_fun fsTu% S?
488oct oct ck_fun fsTu% S?
489abs abs ck_fun fsTu% S?
79072805 490
491# String stuff.
492
b162f9ea 493length length ck_lengthconst isTu% S?
7b8d334a 494substr substr ck_fun st@ S S S? S?
db173bac 495vec vec ck_fun ist@ S S S
79072805 496
b162f9ea 497index index ck_index isT@ S S S?
498rindex rindex ck_index isT@ S S S?
79072805 499
dae78bb1 500sprintf sprintf ck_fun_locale mfst@ S L
db173bac 501formline formline ck_fun ms@ S L
b162f9ea 502ord ord ck_fun ifsTu% S?
503chr chr ck_fun fsTu% S?
504crypt crypt ck_fun fsT@ S S
42d38218 505ucfirst ucfirst ck_fun_locale fstu% S?
506lcfirst lcfirst ck_fun_locale fstu% S?
507uc uc ck_fun_locale fstu% S?
508lc lc ck_fun_locale fstu% S?
509quotemeta quotemeta ck_fun fsTu% S?
79072805 510
511# Arrays.
512
f1612b5c 513rv2av array dereference ck_rvconst dt1
7934575e 514aelemfast constant array element ck_null s$ A S
db173bac 515aelem array element ck_null s2 A S
516aslice array slice ck_null m@ A L
79072805 517
aa689395 518# Hashes.
79072805 519
59af0135 520each each ck_fun % H
db173bac 521values values ck_fun t% H
522keys keys ck_fun t% H
523delete delete ck_delete % S
42d38218 524exists exists ck_exists is% S
f1612b5c 525rv2hv hash dereference ck_rvconst dt1
526helem hash element ck_null s2@ H S
db173bac 527hslice hash slice ck_null m@ H L
79072805 528
529# Explosives and implosives.
530
db173bac 531unpack unpack ck_fun @ S S
532pack pack ck_fun mst@ S L
533split split ck_split t@ S S S
eb6e2d6f 534join join ck_join msT@ S L
79072805 535
536# List operators.
537
db173bac 538list list ck_null m@ L
539lslice list slice ck_null 2 H L L
42d38218 540anonlist anonymous list ([]) ck_fun ms@ L
541anonhash anonymous hash ({}) ck_fun ms@ L
79072805 542
db173bac 543splice splice ck_fun m@ A S? S? L
b162f9ea 544push push ck_fun imsT@ A L
a9f58cad 545pop pop ck_shift s% A
db173bac 546shift shift ck_shift s% A
b162f9ea 547unshift unshift ck_fun imsT@ A L
db173bac 548sort sort ck_sort m@ C? L
549reverse reverse ck_fun mt@ L
79072805 550
f1612b5c 551grepstart grep ck_grep dm@ C L
552grepwhile grep iterator ck_null dt|
79072805 553
f1612b5c 554mapstart map ck_grep dm@ C L
555mapwhile map iterator ck_null dt|
a0d0e21e 556
79072805 557# Range stuff.
558
1a67a97c 559range flipflop ck_null | S S
db173bac 560flip range (or flip) ck_null 1 S S
561flop range (or flop) ck_null 1
79072805 562
563# Control.
564
42d38218 565and logical and (&&) ck_null |
f1612b5c 566or logical or (||) ck_null |
567xor logical xor ck_null fs2 S S
568cond_expr conditional expression ck_null d|
42d38218 569andassign logical and assignment (&&=) ck_null s|
570orassign logical or assignment (||=) ck_null s|
db173bac 571
f5d5a27c 572method method lookup ck_method d1
db173bac 573entersub subroutine entry ck_subr dmt1 L
574leavesub subroutine exit ck_null 1
cd06dffe 575leavesublv lvalue subroutine exit ck_null 1
db173bac 576caller caller ck_fun t% S?
577warn warn ck_fun imst@ L
578die die ck_fun dimst@ L
f1612b5c 579reset symbol reset ck_fun is% S?
db173bac 580
581lineseq line sequence ck_null @
582nextstate next statement ck_null s;
583dbstate debug next statement ck_null s;
e9c54c90 584unstack iteration finalizer ck_null s0
79072805 585enter block entry ck_null 0
db173bac 586leave block exit ck_null @
587scope block ck_null @
588enteriter foreach loop entry ck_null d{
79072805 589iter foreach loop iterator ck_null 0
db173bac 590enterloop loop entry ck_null d{
591leaveloop loop exit ck_null 2
592return return ck_null dm@ L
593last last ck_null ds}
594next next ck_null ds}
595redo redo ck_null ds}
596dump dump ck_null ds}
597goto goto ck_null ds}
598exit exit ck_fun ds% S?
7399586d 599# continued below
79072805 600
f1612b5c 601#nswitch numeric switch ck_null d
602#cswitch character switch ck_null d
79072805 603
604# I/O.
605
6170680b 606open open ck_fun ist@ F S? S?
db173bac 607close close ck_fun is% F?
608pipe_op pipe ck_fun is@ F F
79072805 609
db173bac 610fileno fileno ck_fun ist% F
611umask umask ck_fun ist% S?
612binmode binmode ck_fun s% F
79072805 613
db173bac 614tie tie ck_fun idms@ R S L
615untie untie ck_fun is% R
616tied tied ck_fun s% R
617dbmopen dbmopen ck_fun is@ H S S
618dbmclose dbmclose ck_fun is% H
79072805 619
db173bac 620sselect select system call ck_select t@ S S S S
621select select ck_select st@ F?
79072805 622
db173bac 623getc getc ck_eof st% F?
d1a002d4 624read read ck_fun imst@ F R S S?
db173bac 625enterwrite write ck_fun dis% F?
626leavewrite write exit ck_null 1
79072805 627
db173bac 628prtf printf ck_listiob ims@ F? L
629print print ck_listiob ims@ F? L
79072805 630
db173bac 631sysopen sysopen ck_fun s@ F S S S?
632sysseek sysseek ck_fun s@ F S S
d1a002d4 633sysread sysread ck_fun imst@ F R S S?
145d37e2 634syswrite syswrite ck_fun imst@ F S S? S?
79072805 635
db173bac 636send send ck_fun imst@ F S S S?
d1a002d4 637recv recv ck_fun imst@ F R S S
79072805 638
db173bac 639eof eof ck_eof is% F?
640tell tell ck_fun st% F?
641seek seek ck_fun s@ F S S
9b01e405 642# truncate really behaves as if it had both "S S" and "F S"
db173bac 643truncate truncate ck_trunc is@ S S
79072805 644
db173bac 645fcntl fcntl ck_fun st@ F S S
646ioctl ioctl ck_fun st@ F S S
b162f9ea 647flock flock ck_fun isT@ F S
79072805 648
649# Sockets.
650
db173bac 651socket socket ck_fun is@ F S S S
652sockpair socketpair ck_fun is@ F F S S S
79072805 653
db173bac 654bind bind ck_fun is@ F S
655connect connect ck_fun is@ F S
656listen listen ck_fun is@ F S
657accept accept ck_fun ist@ F F
658shutdown shutdown ck_fun ist@ F S
79072805 659
db173bac 660gsockopt getsockopt ck_fun is@ F S S
661ssockopt setsockopt ck_fun is@ F S S S
79072805 662
db173bac 663getsockname getsockname ck_fun is% F
664getpeername getpeername ck_fun is% F
79072805 665
666# Stat calls.
667
db173bac 668lstat lstat ck_ftst u- F
669stat stat ck_ftst u- F
670ftrread -R ck_ftst isu- F
671ftrwrite -W ck_ftst isu- F
672ftrexec -X ck_ftst isu- F
673fteread -r ck_ftst isu- F
674ftewrite -w ck_ftst isu- F
675fteexec -x ck_ftst isu- F
676ftis -e ck_ftst isu- F
677fteowned -O ck_ftst isu- F
678ftrowned -o ck_ftst isu- F
679ftzero -z ck_ftst isu- F
680ftsize -s ck_ftst istu- F
681ftmtime -M ck_ftst stu- F
682ftatime -A ck_ftst stu- F
683ftctime -C ck_ftst stu- F
684ftsock -S ck_ftst isu- F
685ftchr -c ck_ftst isu- F
686ftblk -b ck_ftst isu- F
687ftfile -f ck_ftst isu- F
688ftdir -d ck_ftst isu- F
689ftpipe -p ck_ftst isu- F
690ftlink -l ck_ftst isu- F
691ftsuid -u ck_ftst isu- F
692ftsgid -g ck_ftst isu- F
693ftsvtx -k ck_ftst isu- F
694fttty -t ck_ftst is- F
695fttext -T ck_ftst isu- F
696ftbinary -B ck_ftst isu- F
79072805 697
698# File calls.
699
b162f9ea 700chdir chdir ck_fun isT% S?
701chown chown ck_fun imsT@ L
702chroot chroot ck_fun isTu% S?
703unlink unlink ck_fun imsTu@ L
704chmod chmod ck_fun imsT@ L
705utime utime ck_fun imsT@ L
706rename rename ck_fun isT@ S S
707link link ck_fun isT@ S S
708symlink symlink ck_fun isT@ S S
db173bac 709readlink readlink ck_fun stu% S?
b162f9ea 710mkdir mkdir ck_fun isT@ S S
711rmdir rmdir ck_fun isTu% S?
79072805 712
713# Directory calls.
714
db173bac 715open_dir opendir ck_fun is@ F S
716readdir readdir ck_fun % F
717telldir telldir ck_fun st% F
718seekdir seekdir ck_fun s@ F S
719rewinddir rewinddir ck_fun s% F
720closedir closedir ck_fun is% F
79072805 721
722# Process control.
723
db173bac 724fork fork ck_null ist0
b162f9ea 725wait wait ck_null isT0
726waitpid waitpid ck_fun isT@ S S
727system system ck_exec imsT@ S? L
728exec exec ck_exec dimsT@ S? L
729kill kill ck_fun dimsT@ L
730getppid getppid ck_null isT0
731getpgrp getpgrp ck_fun isT% S?
732setpgrp setpgrp ck_fun isT@ S? S?
733getpriority getpriority ck_fun isT@ S S
734setpriority setpriority ck_fun isT@ S S S
79072805 735
736# Time calls.
737
cd39f2b6 738# NOTE: MacOS patches the 'i' of time() away later when the interpreter
739# is created because in MacOS time() is already returning times > 2**31-1,
740# that is, non-integers.
741
b162f9ea 742time time ck_null isT0
79072805 743tms times ck_null 0
db173bac 744localtime localtime ck_fun t% S?
745gmtime gmtime ck_fun t% S?
746alarm alarm ck_fun istu% S?
b162f9ea 747sleep sleep ck_fun isT% S?
79072805 748
749# Shared memory.
750
db173bac 751shmget shmget ck_fun imst@ S S S
752shmctl shmctl ck_fun imst@ S S S
753shmread shmread ck_fun imst@ S S S S
754shmwrite shmwrite ck_fun imst@ S S S S
79072805 755
756# Message passing.
757
db173bac 758msgget msgget ck_fun imst@ S S
759msgctl msgctl ck_fun imst@ S S S
760msgsnd msgsnd ck_fun imst@ S S S
761msgrcv msgrcv ck_fun imst@ S S S S S
79072805 762
763# Semaphores.
764
db173bac 765semget semget ck_fun imst@ S S S
766semctl semctl ck_fun imst@ S S S S
767semop semop ck_fun imst@ S S
79072805 768
769# Eval.
770
db173bac 771require require ck_require du% S?
b3f4d674 772dofile do "file" ck_fun d1 S
773entereval eval "string" ck_eval d% S
774leaveeval eval "string" exit ck_null 1 S
db173bac 775#evalonce eval constant string ck_null d1 S
42d38218 776entertry eval {block} ck_null |
f1612b5c 777leavetry eval {block} exit ck_null @
79072805 778
779# Get system info.
780
db173bac 781ghbyname gethostbyname ck_fun % S
782ghbyaddr gethostbyaddr ck_fun @ S S
79072805 783ghostent gethostent ck_null 0
db173bac 784gnbyname getnetbyname ck_fun % S
785gnbyaddr getnetbyaddr ck_fun @ S S
79072805 786gnetent getnetent ck_null 0
db173bac 787gpbyname getprotobyname ck_fun % S
788gpbynumber getprotobynumber ck_fun @ S
79072805 789gprotoent getprotoent ck_null 0
db173bac 790gsbyname getservbyname ck_fun @ S S
791gsbyport getservbyport ck_fun @ S S
79072805 792gservent getservent ck_null 0
db173bac 793shostent sethostent ck_fun is% S
794snetent setnetent ck_fun is% S
795sprotoent setprotoent ck_fun is% S
796sservent setservent ck_fun is% S
797ehostent endhostent ck_null is0
798enetent endnetent ck_null is0
799eprotoent endprotoent ck_null is0
800eservent endservent ck_null is0
801gpwnam getpwnam ck_fun % S
802gpwuid getpwuid ck_fun % S
79072805 803gpwent getpwent ck_null 0
db173bac 804spwent setpwent ck_null is0
805epwent endpwent ck_null is0
806ggrnam getgrnam ck_fun % S
807ggrgid getgrgid ck_fun % S
79072805 808ggrent getgrent ck_null 0
db173bac 809sgrent setgrent ck_null is0
810egrent endgrent ck_null is0
811getlogin getlogin ck_null st0
79072805 812
813# Miscellaneous.
814
db173bac 815syscall syscall ck_fun imst@ S L
c0329465 816
817# For multi-threading
db173bac 818lock lock ck_rfun s% S
f1612b5c 819threadsv per-thread value ck_null ds0
7399586d 820
821# Control (contd.)
3f872cb9 822setstate set statement info ck_null s;
f5d5a27c 823method_named method with known name ck_null d$