Commit | Line | Data |
---|---|---|
d6480c9d NC |
1 | #!/usr/bin/perl -w |
2 | use strict; | |
3 | ||
36bb303b NC |
4 | BEGIN { |
5 | # Get function prototypes | |
9ad884cb | 6 | require 'regen_lib.pl'; |
36bb303b | 7 | } |
79072805 | 8 | |
d6480c9d NC |
9 | my $opcode_new = 'opcode.h-new'; |
10 | my $opname_new = 'opnames.h-new'; | |
bb6f4497 | 11 | open(OC, ">$opcode_new") || die "Can't create $opcode_new: $!\n"; |
dfb1454f | 12 | binmode OC; |
bb6f4497 | 13 | open(ON, ">$opname_new") || die "Can't create $opname_new: $!\n"; |
dfb1454f | 14 | binmode ON; |
79072805 LW |
15 | select OC; |
16 | ||
17 | # Read data. | |
18 | ||
d6480c9d | 19 | my %seen; |
e71197e2 | 20 | my (@ops, %desc, %check, %ckname, %flags, %args, %opnum); |
d6480c9d | 21 | |
79072805 LW |
22 | while (<DATA>) { |
23 | chop; | |
24 | next unless $_; | |
25 | next if /^#/; | |
d6480c9d NC |
26 | my ($key, $desc, $check, $flags, $args) = split(/\t+/, $_, 5); |
27 | $args = '' unless defined $args; | |
c07a80fd | 28 | |
29 | warn qq[Description "$desc" duplicates $seen{$desc}\n] if $seen{$desc}; | |
30 | die qq[Opcode "$key" duplicates $seen{$key}\n] if $seen{$key}; | |
31 | $seen{$desc} = qq[description of opcode "$key"]; | |
32 | $seen{$key} = qq[opcode "$key"]; | |
33 | ||
79072805 | 34 | push(@ops, $key); |
e71197e2 | 35 | $opnum{$key} = $#ops; |
c07a80fd | 36 | $desc{$key} = $desc; |
79072805 LW |
37 | $check{$key} = $check; |
38 | $ckname{$check}++; | |
39 | $flags{$key} = $flags; | |
40 | $args{$key} = $args; | |
41 | } | |
42 | ||
1d5774de NC |
43 | # Set up aliases |
44 | ||
45 | my %alias; | |
46 | ||
47 | # Format is "this function" => "does these op names" | |
48 | my @raw_alias = ( | |
6faeeb49 | 49 | Perl_do_kv => [qw( keys values )], |
d83386fa | 50 | Perl_unimplemented_op => [qw(padany mapstart custom)], |
0b612f93 NC |
51 | # All the ops with a body of { return NORMAL; } |
52 | Perl_pp_null => [qw(scalar regcmaybe lineseq scope)], | |
53 | ||
54 | Perl_pp_goto => ['dump'], | |
55 | Perl_pp_require => ['dofile'], | |
56 | Perl_pp_untie => ['dbmclose'], | |
57 | Perl_pp_sysread => [qw(read recv)], | |
58 | Perl_pp_sysseek => ['seek'], | |
59 | Perl_pp_ioctl => ['fcntl'], | |
60 | Perl_pp_ssockopt => ['gsockopt'], | |
61 | Perl_pp_getpeername => ['getsockname'], | |
62 | Perl_pp_stat => ['lstat'], | |
f1cb2d48 | 63 | Perl_pp_ftrowned => [qw(fteowned ftzero ftsock ftchr ftblk |
17ad201a NC |
64 | ftfile ftdir ftpipe ftsuid ftsgid |
65 | ftsvtx)], | |
0b612f93 NC |
66 | Perl_pp_fttext => ['ftbinary'], |
67 | Perl_pp_gmtime => ['localtime'], | |
68 | Perl_pp_semget => [qw(shmget msgget)], | |
69 | Perl_pp_semctl => [qw(shmctl msgctl)], | |
0b612f93 NC |
70 | Perl_pp_ghostent => [qw(ghbyname ghbyaddr)], |
71 | Perl_pp_gnetent => [qw(gnbyname gnbyaddr)], | |
72 | Perl_pp_gprotoent => [qw(gpbyname gpbynumber)], | |
73 | Perl_pp_gservent => [qw(gsbyname gsbyport)], | |
74 | Perl_pp_gpwent => [qw(gpwnam gpwuid)], | |
75 | Perl_pp_ggrent => [qw(ggrnam ggrgid)], | |
957b0e1d | 76 | Perl_pp_ftis => [qw(ftsize ftmtime ftatime ftctime)], |
605b9385 | 77 | Perl_pp_chown => [qw(unlink chmod utime kill)], |
ce6987d0 | 78 | Perl_pp_link => ['symlink'], |
af9e49b4 NC |
79 | Perl_pp_ftrread => [qw(ftrwrite ftrexec fteread ftewrite |
80 | fteexec)], | |
ca563b4e | 81 | Perl_pp_shmwrite => [qw(shmread msgsnd msgrcv semop)], |
64a1bc8e | 82 | Perl_pp_send => ['syswrite'], |
c960fc3b | 83 | Perl_pp_defined => [qw(dor dorassign)], |
62726f23 SP |
84 | Perl_pp_and => ['andassign'], |
85 | Perl_pp_or => ['orassign'], | |
12e9c124 | 86 | Perl_pp_ucfirst => ['lcfirst'], |
afd9910b | 87 | Perl_pp_sle => [qw(slt sgt sge)], |
0d863452 | 88 | Perl_pp_print => ['say'], |
2723d216 | 89 | Perl_pp_index => ['rindex'], |
daa2adfd | 90 | Perl_pp_oct => ['hex'], |
789b4bc9 | 91 | Perl_pp_shift => ['pop'], |
71302fe3 | 92 | Perl_pp_sin => [qw(cos exp log sqrt)], |
3658c1f1 | 93 | Perl_pp_bit_or => ['bit_xor'], |
17ab7946 | 94 | Perl_pp_rv2av => ['rv2hv'], |
878d132a | 95 | Perl_pp_akeys => ['avalues'], |
605b9385 | 96 | ); |
1d5774de NC |
97 | |
98 | while (my ($func, $names) = splice @raw_alias, 0, 2) { | |
6faeeb49 | 99 | $alias{$_} = $func for @$names; |
1d5774de NC |
100 | } |
101 | ||
79072805 LW |
102 | # Emit defines. |
103 | ||
748a9306 | 104 | print <<"END"; |
37442d52 RGS |
105 | /* -*- buffer-read-only: t -*- |
106 | * | |
d6376244 JH |
107 | * opcode.h |
108 | * | |
699a97de RGS |
109 | * Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, |
110 | * 2001, 2002, 2003, 2004, 2005, 2006, 2007 by Larry Wall and others | |
d6376244 JH |
111 | * |
112 | * You may distribute under the terms of either the GNU General Public | |
113 | * License or the Artistic License, as specified in the README file. | |
114 | * | |
115 | * !!!!!!! DO NOT EDIT THIS FILE !!!!!!! | |
116 | * This file is built by opcode.pl from its data. Any changes made here | |
117 | * will be lost! | |
118 | */ | |
a27f85b3 | 119 | |
27da23d5 JH |
120 | #ifndef PERL_GLOBAL_STRUCT_INIT |
121 | ||
864dbfa3 GS |
122 | #define Perl_pp_i_preinc Perl_pp_preinc |
123 | #define Perl_pp_i_predec Perl_pp_predec | |
124 | #define Perl_pp_i_postinc Perl_pp_postinc | |
125 | #define Perl_pp_i_postdec Perl_pp_postdec | |
748a9306 | 126 | |
65bca31a NC |
127 | PERL_PPDEF(Perl_unimplemented_op) |
128 | ||
748a9306 | 129 | END |
abdd5c84 GS |
130 | |
131 | print ON <<"END"; | |
37442d52 RGS |
132 | /* -*- buffer-read-only: t -*- |
133 | * | |
d6376244 JH |
134 | * opnames.h |
135 | * | |
cfc85103 | 136 | * Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, |
699a97de | 137 | * 2007 by Larry Wall and others |
d6376244 JH |
138 | * |
139 | * You may distribute under the terms of either the GNU General Public | |
140 | * License or the Artistic License, as specified in the README file. | |
141 | * | |
142 | * | |
143 | * !!!!!!! DO NOT EDIT THIS FILE !!!!!!! | |
144 | * This file is built by opcode.pl from its data. Any changes made here | |
145 | * will be lost! | |
146 | */ | |
abdd5c84 GS |
147 | |
148 | typedef enum opcode { | |
149 | END | |
150 | ||
d6480c9d | 151 | my $i = 0; |
79072805 | 152 | for (@ops) { |
e71197e2 JC |
153 | # print ON "\t", &tab(3,"OP_\U$_,"), "/* ", $i++, " */\n"; |
154 | print ON "\t", &tab(3,"OP_\U$_"), " = ", $i++, ",\n"; | |
79072805 | 155 | } |
abdd5c84 GS |
156 | print ON "\t", &tab(3,"OP_max"), "\n"; |
157 | print ON "} opcode;\n"; | |
4c80c0b2 NC |
158 | print ON "\n#define MAXO ", scalar @ops, "\n"; |
159 | print ON "#define OP_phoney_INPUT_ONLY -1\n"; | |
160 | print ON "#define OP_phoney_OUTPUT_ONLY -2\n\n"; | |
79072805 | 161 | |
c07a80fd | 162 | # Emit op names and descriptions. |
79072805 LW |
163 | |
164 | print <<END; | |
73c4f7a1 GS |
165 | START_EXTERN_C |
166 | ||
4a36906c RGS |
167 | #define OP_NAME(o) ((o)->op_type == OP_CUSTOM ? custom_op_name(o) : \\ |
168 | PL_op_name[(o)->op_type]) | |
169 | #define OP_DESC(o) ((o)->op_type == OP_CUSTOM ? custom_op_desc(o) : \\ | |
170 | PL_op_desc[(o)->op_type]) | |
53e06cf0 | 171 | |
79072805 | 172 | #ifndef DOINIT |
27da23d5 | 173 | EXTCONST char* const PL_op_name[]; |
79072805 | 174 | #else |
27da23d5 | 175 | EXTCONST char* const PL_op_name[] = { |
79072805 LW |
176 | END |
177 | ||
178 | for (@ops) { | |
c07a80fd | 179 | print qq(\t"$_",\n); |
180 | } | |
181 | ||
182 | print <<END; | |
183 | }; | |
184 | #endif | |
185 | ||
186 | END | |
187 | ||
188 | print <<END; | |
189 | #ifndef DOINIT | |
27da23d5 | 190 | EXTCONST char* const PL_op_desc[]; |
c07a80fd | 191 | #else |
27da23d5 | 192 | EXTCONST char* const PL_op_desc[] = { |
c07a80fd | 193 | END |
194 | ||
195 | for (@ops) { | |
42d38218 MS |
196 | my($safe_desc) = $desc{$_}; |
197 | ||
a567e93b | 198 | # Have to escape double quotes and escape characters. |
42d38218 MS |
199 | $safe_desc =~ s/(^|[^\\])([\\"])/$1\\$2/g; |
200 | ||
201 | print qq(\t"$safe_desc",\n); | |
79072805 LW |
202 | } |
203 | ||
204 | print <<END; | |
205 | }; | |
206 | #endif | |
207 | ||
73c4f7a1 GS |
208 | END_EXTERN_C |
209 | ||
27da23d5 | 210 | #endif /* !PERL_GLOBAL_STRUCT_INIT */ |
22c35a8c | 211 | END |
79072805 | 212 | |
22c35a8c | 213 | # Emit function declarations. |
79072805 | 214 | |
22c35a8c | 215 | #for (sort keys %ckname) { |
cea2e8a9 | 216 | # print "OP *\t", &tab(3,$_),"(pTHX_ OP* o);\n"; |
22c35a8c GS |
217 | #} |
218 | # | |
219 | #print "\n"; | |
220 | # | |
221 | #for (@ops) { | |
cea2e8a9 | 222 | # print "OP *\t", &tab(3, "pp_$_"), "(pTHX);\n"; |
22c35a8c | 223 | #} |
79072805 LW |
224 | |
225 | # Emit ppcode switch array. | |
226 | ||
227 | print <<END; | |
228 | ||
73c4f7a1 GS |
229 | START_EXTERN_C |
230 | ||
27da23d5 | 231 | #ifdef PERL_GLOBAL_STRUCT_INIT |
97aff369 | 232 | # define PERL_PPADDR_INITED |
27da23d5 | 233 | static const Perl_ppaddr_t Gppaddr[] |
79072805 | 234 | #else |
27da23d5 | 235 | # ifndef PERL_GLOBAL_STRUCT |
97aff369 | 236 | # define PERL_PPADDR_INITED |
27da23d5 JH |
237 | EXT Perl_ppaddr_t PL_ppaddr[] /* or perlvars.h */ |
238 | # endif | |
239 | #endif /* PERL_GLOBAL_STRUCT */ | |
240 | #if (defined(DOINIT) && !defined(PERL_GLOBAL_STRUCT)) || defined(PERL_GLOBAL_STRUCT_INIT) | |
97aff369 | 241 | # define PERL_PPADDR_INITED |
27da23d5 | 242 | = { |
79072805 LW |
243 | END |
244 | ||
245 | for (@ops) { | |
6faeeb49 MB |
246 | if (my $name = $alias{$_}) { |
247 | print "\tMEMBER_TO_FPTR($name),\t/* Perl_pp_$_ */\n"; | |
248 | } | |
249 | else { | |
250 | print "\tMEMBER_TO_FPTR(Perl_pp_$_),\n"; | |
251 | } | |
79072805 LW |
252 | } |
253 | ||
254 | print <<END; | |
27da23d5 | 255 | } |
79072805 | 256 | #endif |
97aff369 | 257 | #ifdef PERL_PPADDR_INITED |
27da23d5 | 258 | ; |
97aff369 | 259 | #endif |
79072805 LW |
260 | |
261 | END | |
262 | ||
263 | # Emit check routines. | |
264 | ||
265 | print <<END; | |
27da23d5 | 266 | #ifdef PERL_GLOBAL_STRUCT_INIT |
97aff369 | 267 | # define PERL_CHECK_INITED |
27da23d5 | 268 | static const Perl_check_t Gcheck[] |
79072805 | 269 | #else |
27da23d5 | 270 | # ifndef PERL_GLOBAL_STRUCT |
97aff369 | 271 | # define PERL_CHECK_INITED |
27da23d5 JH |
272 | EXT Perl_check_t PL_check[] /* or perlvars.h */ |
273 | # endif | |
274 | #endif | |
275 | #if (defined(DOINIT) && !defined(PERL_GLOBAL_STRUCT)) || defined(PERL_GLOBAL_STRUCT_INIT) | |
97aff369 | 276 | # define PERL_CHECK_INITED |
27da23d5 | 277 | = { |
79072805 LW |
278 | END |
279 | ||
280 | for (@ops) { | |
2b260de0 | 281 | print "\t", &tab(3, "MEMBER_TO_FPTR(Perl_$check{$_}),"), "\t/* $_ */\n"; |
79072805 LW |
282 | } |
283 | ||
284 | print <<END; | |
27da23d5 | 285 | } |
79072805 | 286 | #endif |
97aff369 | 287 | #ifdef PERL_CHECK_INITED |
27da23d5 | 288 | ; |
97aff369 | 289 | #endif /* #ifdef PERL_CHECK_INITED */ |
79072805 LW |
290 | |
291 | END | |
292 | ||
293 | # Emit allowed argument types. | |
294 | ||
c2dedb93 MHM |
295 | my $ARGBITS = 32; |
296 | ||
79072805 | 297 | print <<END; |
27da23d5 JH |
298 | #ifndef PERL_GLOBAL_STRUCT_INIT |
299 | ||
79072805 | 300 | #ifndef DOINIT |
1ccb7c8d | 301 | EXTCONST U32 PL_opargs[]; |
79072805 | 302 | #else |
1ccb7c8d | 303 | EXTCONST U32 PL_opargs[] = { |
79072805 LW |
304 | END |
305 | ||
d6480c9d NC |
306 | my %argnum = ( |
307 | 'S', 1, # scalar | |
308 | 'L', 2, # list | |
309 | 'A', 3, # array value | |
310 | 'H', 4, # hash value | |
311 | 'C', 5, # code value | |
312 | 'F', 6, # file value | |
313 | 'R', 7, # scalar reference | |
79072805 LW |
314 | ); |
315 | ||
d6480c9d | 316 | my %opclass = ( |
db173bac MB |
317 | '0', 0, # baseop |
318 | '1', 1, # unop | |
319 | '2', 2, # binop | |
320 | '|', 3, # logop | |
1a67a97c SM |
321 | '@', 4, # listop |
322 | '/', 5, # pmop | |
350de78d | 323 | '$', 6, # svop_or_padop |
7934575e | 324 | '#', 7, # padop |
1a67a97c SM |
325 | '"', 8, # pvop_or_svop |
326 | '{', 9, # loop | |
327 | ';', 10, # cop | |
328 | '%', 11, # baseop_or_unop | |
329 | '-', 12, # filestatop | |
330 | '}', 13, # loopexop | |
db173bac MB |
331 | ); |
332 | ||
c2dedb93 MHM |
333 | my %opflags = ( |
334 | 'm' => 1, # needs stack mark | |
335 | 'f' => 2, # fold constants | |
336 | 's' => 4, # always produces scalar | |
337 | 't' => 8, # needs target scalar | |
338 | 'T' => 8 | 256, # ... which may be lexical | |
339 | 'i' => 16, # always produces integer | |
340 | 'I' => 32, # has corresponding int op | |
341 | 'd' => 64, # danger, unknown side effects | |
342 | 'u' => 128, # defaults to $_ | |
343 | ); | |
344 | ||
a85d93d9 JH |
345 | my %OP_IS_SOCKET; |
346 | my %OP_IS_FILETEST; | |
c2dedb93 MHM |
347 | my $OCSHIFT = 9; |
348 | my $OASHIFT = 13; | |
a85d93d9 | 349 | |
c2dedb93 | 350 | for my $op (@ops) { |
d6480c9d | 351 | my $argsum = 0; |
c2dedb93 MHM |
352 | my $flags = $flags{$op}; |
353 | for my $flag (keys %opflags) { | |
354 | if ($flags =~ s/$flag//) { | |
355 | die "Flag collision for '$op' ($flags{$op}, $flag)" | |
356 | if $argsum & $opflags{$flag}; | |
357 | $argsum |= $opflags{$flag}; | |
358 | } | |
359 | } | |
360 | die qq[Opcode '$op' has no class indicator ($flags{$op} => $flags)] | |
361 | unless exists $opclass{$flags}; | |
362 | $argsum |= $opclass{$flags} << $OCSHIFT; | |
363 | my $argshift = $OASHIFT; | |
364 | for my $arg (split(' ',$args{$op})) { | |
a85d93d9 | 365 | if ($arg =~ /^F/) { |
e71197e2 JC |
366 | # record opnums of these opnames |
367 | $OP_IS_SOCKET{$op} = $opnum{$op} if $arg =~ s/s//; | |
368 | $OP_IS_FILETEST{$op} = $opnum{$op} if $arg =~ s/-//; | |
a85d93d9 | 369 | } |
d6480c9d | 370 | my $argnum = ($arg =~ s/\?//) ? 8 : 0; |
c2dedb93 MHM |
371 | die "op = $op, arg = $arg\n" |
372 | unless exists $argnum{$arg}; | |
79072805 | 373 | $argnum += $argnum{$arg}; |
c2dedb93 MHM |
374 | die "Argument overflow for '$op'\n" |
375 | if $argshift >= $ARGBITS || | |
376 | $argnum > ((1 << ($ARGBITS - $argshift)) - 1); | |
377 | $argsum += $argnum << $argshift; | |
378 | $argshift += 4; | |
79072805 LW |
379 | } |
380 | $argsum = sprintf("0x%08x", $argsum); | |
c2dedb93 | 381 | print "\t", &tab(3, "$argsum,"), "/* $op */\n"; |
79072805 LW |
382 | } |
383 | ||
384 | print <<END; | |
385 | }; | |
386 | #endif | |
73c4f7a1 | 387 | |
bae1192d JH |
388 | #endif /* !PERL_GLOBAL_STRUCT_INIT */ |
389 | ||
73c4f7a1 | 390 | END_EXTERN_C |
27da23d5 | 391 | |
79072805 LW |
392 | END |
393 | ||
e71197e2 JC |
394 | # Emit OP_IS_* macros |
395 | ||
396 | print ON <<EO_OP_IS_COMMENT; | |
397 | ||
398 | /* the OP_IS_(SOCKET|FILETEST) macros are optimized to a simple range | |
399 | check because all the member OPs are contiguous in opcode.pl | |
400 | <DATA> table. opcode.pl verifies the range contiguity. */ | |
401 | ||
402 | EO_OP_IS_COMMENT | |
403 | ||
404 | gen_op_is_macro( \%OP_IS_SOCKET, 'OP_IS_SOCKET'); | |
405 | gen_op_is_macro( \%OP_IS_FILETEST, 'OP_IS_FILETEST'); | |
406 | ||
407 | sub gen_op_is_macro { | |
408 | my ($op_is, $macname) = @_; | |
409 | if (keys %$op_is) { | |
410 | ||
411 | # get opnames whose numbers are lowest and highest | |
412 | my ($first, @rest) = sort { | |
413 | $op_is->{$a} <=> $op_is->{$b} | |
414 | } keys %$op_is; | |
415 | ||
416 | my $last = pop @rest; # @rest slurped, get its last | |
417 | ||
418 | # verify that op-ct matches 1st..last range (and fencepost) | |
419 | # (we know there are no dups) | |
420 | if ( $op_is->{$last} - $op_is->{$first} == scalar @rest + 1) { | |
421 | ||
422 | # contiguous ops -> optimized version | |
423 | print ON "#define $macname(op) \\\n\t("; | |
424 | print ON "(op) >= OP_" . uc($first) . " && (op) <= OP_" . uc($last); | |
425 | print ON ")\n\n"; | |
426 | } | |
427 | else { | |
428 | print ON "\n#define $macname(op) \\\n\t("; | |
429 | print ON join(" || \\\n\t ", | |
430 | map { "(op) == OP_" . uc() } sort keys %OP_IS_SOCKET); | |
431 | print ON ")\n\n"; | |
432 | } | |
433 | } | |
a85d93d9 JH |
434 | } |
435 | ||
37442d52 RGS |
436 | print OC "/* ex: set ro: */\n"; |
437 | print ON "/* ex: set ro: */\n"; | |
438 | ||
735e0d5c | 439 | close OC or die "Error closing opcode.h: $!"; |
abdd5c84 | 440 | close ON or die "Error closing opnames.h: $!"; |
735e0d5c | 441 | |
36bb303b NC |
442 | foreach ('opcode.h', 'opnames.h') { |
443 | safer_rename_silent $_, "$_-old"; | |
444 | } | |
445 | safer_rename $opcode_new, 'opcode.h'; | |
446 | safer_rename $opname_new, 'opnames.h'; | |
46f659cb | 447 | |
d6480c9d NC |
448 | my $pp_proto_new = 'pp_proto.h-new'; |
449 | my $pp_sym_new = 'pp.sym-new'; | |
bb6f4497 CL |
450 | |
451 | open PP, ">$pp_proto_new" or die "Error creating $pp_proto_new: $!"; | |
dfb1454f | 452 | binmode PP; |
bb6f4497 | 453 | open PPSYM, ">$pp_sym_new" or die "Error creating $pp_sym_new: $!"; |
dfb1454f | 454 | binmode PPSYM; |
22c35a8c | 455 | |
a27f85b3 | 456 | print PP <<"END"; |
37442d52 RGS |
457 | /* -*- buffer-read-only: t -*- |
458 | !!!!!!! DO NOT EDIT THIS FILE !!!!!!! | |
a27f85b3 GS |
459 | This file is built by opcode.pl from its data. Any changes made here |
460 | will be lost! | |
461 | */ | |
462 | ||
463 | END | |
464 | ||
465 | print PPSYM <<"END"; | |
37442d52 | 466 | # -*- buffer-read-only: t -*- |
a27f85b3 | 467 | # |
a567e93b | 468 | # !!!!!!! DO NOT EDIT THIS FILE !!!!!!! |
a27f85b3 GS |
469 | # This file is built by opcode.pl from its data. Any changes made here |
470 | # will be lost! | |
471 | # | |
472 | ||
473 | END | |
474 | ||
475 | ||
22c35a8c | 476 | for (sort keys %ckname) { |
864dbfa3 GS |
477 | print PP "PERL_CKDEF(Perl_$_)\n"; |
478 | print PPSYM "Perl_$_\n"; | |
20ce7b12 | 479 | #OP *\t", &tab(3,$_),"(OP* o);\n"; |
22c35a8c GS |
480 | } |
481 | ||
482 | print PP "\n\n"; | |
483 | ||
735e0d5c | 484 | for (@ops) { |
15e52e56 | 485 | next if /^i_(pre|post)(inc|dec)$/; |
53e06cf0 | 486 | next if /^custom$/; |
864dbfa3 GS |
487 | print PP "PERL_PPDEF(Perl_pp_$_)\n"; |
488 | print PPSYM "Perl_pp_$_\n"; | |
735e0d5c | 489 | } |
37442d52 RGS |
490 | print PP "\n/* ex: set ro: */\n"; |
491 | print PPSYM "\n# ex: set ro:\n"; | |
735e0d5c IZ |
492 | |
493 | close PP or die "Error closing pp_proto.h: $!"; | |
22c35a8c | 494 | close PPSYM or die "Error closing pp.sym: $!"; |
735e0d5c | 495 | |
36bb303b NC |
496 | foreach ('pp_proto.h', 'pp.sym') { |
497 | safer_rename_silent $_, "$_-old"; | |
498 | } | |
499 | safer_rename $pp_proto_new, 'pp_proto.h'; | |
500 | safer_rename $pp_sym_new, 'pp.sym'; | |
46f659cb | 501 | |
24600adc JH |
502 | END { |
503 | foreach ('opcode.h', 'opnames.h', 'pp_proto.h', 'pp.sym') { | |
504 | 1 while unlink "$_-old"; | |
505 | } | |
506 | } | |
507 | ||
79072805 LW |
508 | ########################################################################### |
509 | sub tab { | |
d6480c9d | 510 | my ($l, $t) = @_; |
79072805 LW |
511 | $t .= "\t" x ($l - (length($t) + 1) / 8); |
512 | $t; | |
513 | } | |
514 | ########################################################################### | |
b162f9ea IZ |
515 | |
516 | # Some comments about 'T' opcode classifier: | |
517 | ||
518 | # Safe to set if the ppcode uses: | |
519 | # tryAMAGICbin, tryAMAGICun, SETn, SETi, SETu, PUSHn, PUSHTARG, SETTARG, | |
520 | # SETs(TARG), XPUSHn, XPUSHu, | |
521 | ||
522 | # Unsafe to set if the ppcode uses dTARG or [X]RETPUSH[YES|NO|UNDEF] | |
523 | ||
524 | # lt and friends do SETs (including ncmp, but not scmp) | |
525 | ||
21f5b33c GS |
526 | # Additional mode of failure: the opcode can modify TARG before it "used" |
527 | # all the arguments (or may call an external function which does the same). | |
528 | # If the target coincides with one of the arguments ==> kaboom. | |
529 | ||
b162f9ea IZ |
530 | # pp.c pos substr each not OK (RETPUSHUNDEF) |
531 | # substr vec also not OK due to LV to target (are they???) | |
532 | # ref not OK (RETPUSHNO) | |
533 | # trans not OK (dTARG; TARG = sv_newmortal();) | |
534 | # ucfirst etc not OK: TMP arg processed inplace | |
69b47968 | 535 | # quotemeta not OK (unsafe when TARG == arg) |
91e74348 | 536 | # each repeat not OK too due to list context |
b162f9ea | 537 | # pack split - unknown whether they are safe |
dae78bb1 IZ |
538 | # sprintf: is calling do_sprintf(TARG,...) which can act on TARG |
539 | # before other args are processed. | |
b162f9ea | 540 | |
21f5b33c GS |
541 | # Suspicious wrt "additional mode of failure" (and only it): |
542 | # schop, chop, postinc/dec, bit_and etc, negate, complement. | |
543 | ||
544 | # Also suspicious: 4-arg substr, sprintf, uc/lc (POK_only), reverse, pack. | |
545 | ||
546 | # substr/vec: doing TAINT_off()??? | |
547 | ||
b162f9ea IZ |
548 | # pp_hot.c |
549 | # readline - unknown whether it is safe | |
550 | # match subst not OK (dTARG) | |
551 | # grepwhile not OK (not always setting) | |
69b47968 | 552 | # join not OK (unsafe when TARG == arg) |
b162f9ea | 553 | |
21f5b33c GS |
554 | # Suspicious wrt "additional mode of failure": concat (dealt with |
555 | # in ck_sassign()), join (same). | |
556 | ||
b162f9ea IZ |
557 | # pp_ctl.c |
558 | # mapwhile flip caller not OK (not always setting) | |
559 | ||
560 | # pp_sys.c | |
561 | # backtick glob warn die not OK (not always setting) | |
562 | # warn not OK (RETPUSHYES) | |
563 | # open fileno getc sysread syswrite ioctl accept shutdown | |
564 | # ftsize(etc) readlink telldir fork alarm getlogin not OK (RETPUSHUNDEF) | |
565 | # umask select not OK (XPUSHs(&PL_sv_undef);) | |
566 | # fileno getc sysread syswrite tell not OK (meth("FILENO" "GETC")) | |
567 | # sselect shm* sem* msg* syscall - unknown whether they are safe | |
568 | # gmtime not OK (list context) | |
569 | ||
21f5b33c GS |
570 | # Suspicious wrt "additional mode of failure": warn, die, select. |
571 | ||
79072805 LW |
572 | __END__ |
573 | ||
d83386fa NC |
574 | # New ops always go at the end |
575 | # The restriction on having custom as the last op has been removed | |
7399586d | 576 | |
64b99527 SC |
577 | # A recapitulation of the format of this file: |
578 | # The file consists of five columns: the name of the op, an English | |
579 | # description, the name of the "check" routine used to optimize this | |
580 | # operation, some flags, and a description of the operands. | |
581 | ||
582 | # The flags consist of options followed by a mandatory op class signifier | |
583 | ||
584 | # The classes are: | |
585 | # baseop - 0 unop - 1 binop - 2 | |
586 | # logop - | listop - @ pmop - / | |
587 | # padop/svop - $ padop - # (unused) loop - { | |
588 | # baseop/unop - % loopexop - } filestatop - - | |
3508218b | 589 | # pvop/svop - " cop - ; |
64b99527 SC |
590 | |
591 | # Other options are: | |
592 | # needs stack mark - m | |
593 | # needs constant folding - f | |
594 | # produces a scalar - s | |
595 | # produces an integer - i | |
596 | # needs a target - t | |
597 | # target can be in a pad - T | |
598 | # has a corresponding integer version - I | |
599 | # has side effects - d | |
600 | # uses $_ if no argument given - u | |
601 | ||
602 | # Values for the operands are: | |
603 | # scalar - S list - L array - A | |
604 | # hash - H sub (CV) - C file - F | |
605 | # socket - Fs filetest - F- reference - R | |
606 | # "?" denotes an optional operand. | |
607 | ||
79072805 LW |
608 | # Nothing. |
609 | ||
610 | null null operation ck_null 0 | |
93a17b20 | 611 | stub stub ck_null 0 |
db173bac | 612 | scalar scalar ck_fun s% S |
79072805 LW |
613 | |
614 | # Pushy stuff. | |
615 | ||
db173bac MB |
616 | pushmark pushmark ck_null s0 |
617 | wantarray wantarray ck_null is0 | |
79072805 | 618 | |
db173bac | 619 | const constant item ck_svconst s$ |
79072805 | 620 | |
7934575e GS |
621 | gvsv scalar variable ck_null ds$ |
622 | gv glob value ck_null ds$ | |
db173bac MB |
623 | gelem glob elem ck_null d2 S S |
624 | padsv private variable ck_null ds0 | |
625 | padav private array ck_null d0 | |
626 | padhv private hash ck_null d0 | |
f1612b5c | 627 | padany private value ck_null d0 |
79072805 | 628 | |
1167e5da | 629 | pushre push regexp ck_null d/ |
79072805 LW |
630 | |
631 | # References and stuff. | |
632 | ||
db173bac | 633 | rv2gv ref-to-glob cast ck_rvconst ds1 |
b89fed5f | 634 | rv2sv scalar dereference ck_rvconst ds1 |
db173bac | 635 | av2arylen array length ck_null is1 |
b89fed5f | 636 | rv2cv subroutine dereference ck_rvconst d1 |
db173bac MB |
637 | anoncode anonymous subroutine ck_anoncode $ |
638 | prototype subroutine prototype ck_null s% S | |
5d11ae5e | 639 | refgen reference constructor ck_spair m1 L |
dfa0f641 | 640 | srefgen single ref constructor ck_null fs1 S |
db173bac MB |
641 | ref reference-type operator ck_fun stu% S? |
642 | bless bless ck_fun s@ S S? | |
79072805 LW |
643 | |
644 | # Pushy I/O. | |
645 | ||
01f5bc1b | 646 | backtick quoted execution (``, qx) ck_open tu% S? |
0a753a76 | 647 | # glob defaults its first arg to $_ |
649da076 | 648 | glob glob ck_glob t@ S? |
e4b7ebf3 | 649 | readline <HANDLE> ck_readline t% F? |
5fc9b9e4 | 650 | rcatline append I/O operator ck_null t$ |
79072805 LW |
651 | |
652 | # Bindable operators. | |
653 | ||
f1612b5c GS |
654 | regcmaybe regexp internal guard ck_fun s1 S |
655 | regcreset regexp internal reset ck_fun s1 S | |
656 | regcomp regexp compilation ck_null s| S | |
657 | match pattern match (m//) ck_match d/ | |
658 | qr pattern quote (qr//) ck_match s/ | |
59f00321 | 659 | subst substitution (s///) ck_match dis/ S |
f1612b5c | 660 | substcont substitution iterator ck_null dis| |
59f00321 | 661 | trans transliteration (tr///) ck_match is" S |
79072805 LW |
662 | |
663 | # Lvalue operators. | |
db173bac MB |
664 | # sassign is special-cased for op class |
665 | ||
b162f9ea | 666 | sassign scalar assignment ck_sassign s0 |
db173bac MB |
667 | aassign list assignment ck_null t2 L L |
668 | ||
21f5b33c GS |
669 | chop chop ck_spair mts% L |
670 | schop scalar chop ck_null stu% S? | |
f1612b5c GS |
671 | chomp chomp ck_spair mTs% L |
672 | schomp scalar chomp ck_null sTu% S? | |
69794302 | 673 | defined defined operator ck_defined isu% S? |
db173bac MB |
674 | undef undef operator ck_lfun s% S? |
675 | study study ck_fun su% S? | |
676 | pos match position ck_lfun stu% S? | |
677 | ||
42d38218 MS |
678 | preinc preincrement (++) ck_lfun dIs1 S |
679 | i_preinc integer preincrement (++) ck_lfun dis1 S | |
680 | predec predecrement (--) ck_lfun dIs1 S | |
681 | i_predec integer predecrement (--) ck_lfun dis1 S | |
21f5b33c | 682 | postinc postincrement (++) ck_lfun dIst1 S |
42d38218 | 683 | i_postinc integer postincrement (++) ck_lfun disT1 S |
21f5b33c | 684 | postdec postdecrement (--) ck_lfun dIst1 S |
42d38218 | 685 | i_postdec integer postdecrement (--) ck_lfun disT1 S |
79072805 LW |
686 | |
687 | # Ordinary operators. | |
688 | ||
42d38218 MS |
689 | pow exponentiation (**) ck_null fsT2 S S |
690 | ||
f1612b5c | 691 | multiply multiplication (*) ck_null IfsT2 S S |
42d38218 MS |
692 | i_multiply integer multiplication (*) ck_null ifsT2 S S |
693 | divide division (/) ck_null IfsT2 S S | |
694 | i_divide integer division (/) ck_null ifsT2 S S | |
695 | modulo modulus (%) ck_null IifsT2 S S | |
696 | i_modulo integer modulus (%) ck_null ifsT2 S S | |
697 | repeat repeat (x) ck_repeat mt2 L S | |
698 | ||
699 | add addition (+) ck_null IfsT2 S S | |
700 | i_add integer addition (+) ck_null ifsT2 S S | |
701 | subtract subtraction (-) ck_null IfsT2 S S | |
702 | i_subtract integer subtraction (-) ck_null ifsT2 S S | |
df91b2c5 | 703 | concat concatenation (.) or string ck_concat fsT2 S S |
b162f9ea | 704 | stringify string ck_fun fsT@ S |
db173bac | 705 | |
42d38218 MS |
706 | left_shift left bitshift (<<) ck_bitop fsT2 S S |
707 | right_shift right bitshift (>>) ck_bitop fsT2 S S | |
708 | ||
709 | lt numeric lt (<) ck_null Iifs2 S S | |
710 | i_lt integer lt (<) ck_null ifs2 S S | |
711 | gt numeric gt (>) ck_null Iifs2 S S | |
712 | i_gt integer gt (>) ck_null ifs2 S S | |
713 | le numeric le (<=) ck_null Iifs2 S S | |
714 | i_le integer le (<=) ck_null ifs2 S S | |
715 | ge numeric ge (>=) ck_null Iifs2 S S | |
716 | i_ge integer ge (>=) ck_null ifs2 S S | |
717 | eq numeric eq (==) ck_null Iifs2 S S | |
718 | i_eq integer eq (==) ck_null ifs2 S S | |
719 | ne numeric ne (!=) ck_null Iifs2 S S | |
720 | i_ne integer ne (!=) ck_null ifs2 S S | |
721 | ncmp numeric comparison (<=>) ck_null Iifst2 S S | |
722 | i_ncmp integer comparison (<=>) ck_null ifst2 S S | |
db173bac | 723 | |
2de3dbcc JH |
724 | slt string lt ck_null ifs2 S S |
725 | sgt string gt ck_null ifs2 S S | |
726 | sle string le ck_null ifs2 S S | |
727 | sge string ge ck_null ifs2 S S | |
db173bac MB |
728 | seq string eq ck_null ifs2 S S |
729 | sne string ne ck_null ifs2 S S | |
2de3dbcc | 730 | scmp string comparison (cmp) ck_null ifst2 S S |
db173bac | 731 | |
21f5b33c GS |
732 | bit_and bitwise and (&) ck_bitop fst2 S S |
733 | bit_xor bitwise xor (^) ck_bitop fst2 S S | |
734 | bit_or bitwise or (|) ck_bitop fst2 S S | |
db173bac | 735 | |
21f5b33c | 736 | negate negation (-) ck_null Ifst1 S |
f1612b5c | 737 | i_negate integer negation (-) ck_null ifsT1 S |
db173bac | 738 | not not ck_null ifs1 S |
21f5b33c | 739 | complement 1's complement (~) ck_bitop fst1 S |
79072805 | 740 | |
fdecdb95 NC |
741 | smartmatch smart match ck_smartmatch s2 |
742 | ||
79072805 LW |
743 | # High falutin' math. |
744 | ||
f1612b5c GS |
745 | atan2 atan2 ck_fun fsT@ S S |
746 | sin sin ck_fun fsTu% S? | |
747 | cos cos ck_fun fsTu% S? | |
748 | rand rand ck_fun sT% S? | |
749 | srand srand ck_fun s% S? | |
750 | exp exp ck_fun fsTu% S? | |
751 | log log ck_fun fsTu% S? | |
752 | sqrt sqrt ck_fun fsTu% S? | |
79072805 | 753 | |
cf26c822 CS |
754 | # Lowbrow math. |
755 | ||
b162f9ea IZ |
756 | int int ck_fun fsTu% S? |
757 | hex hex ck_fun fsTu% S? | |
758 | oct oct ck_fun fsTu% S? | |
759 | abs abs ck_fun fsTu% S? | |
79072805 LW |
760 | |
761 | # String stuff. | |
762 | ||
b162f9ea | 763 | length length ck_lengthconst isTu% S? |
35fba0d9 | 764 | substr substr ck_substr st@ S S S? S? |
db173bac | 765 | vec vec ck_fun ist@ S S S |
79072805 | 766 | |
b162f9ea IZ |
767 | index index ck_index isT@ S S S? |
768 | rindex rindex ck_index isT@ S S S? | |
79072805 | 769 | |
fc7325bb | 770 | sprintf sprintf ck_fun mst@ S L |
db173bac | 771 | formline formline ck_fun ms@ S L |
b162f9ea IZ |
772 | ord ord ck_fun ifsTu% S? |
773 | chr chr ck_fun fsTu% S? | |
774 | crypt crypt ck_fun fsT@ S S | |
2de3dbcc JH |
775 | ucfirst ucfirst ck_fun fstu% S? |
776 | lcfirst lcfirst ck_fun fstu% S? | |
777 | uc uc ck_fun fstu% S? | |
778 | lc lc ck_fun fstu% S? | |
69b47968 | 779 | quotemeta quotemeta ck_fun fstu% S? |
79072805 LW |
780 | |
781 | # Arrays. | |
782 | ||
f1612b5c | 783 | rv2av array dereference ck_rvconst dt1 |
7934575e | 784 | aelemfast constant array element ck_null s$ A S |
db173bac MB |
785 | aelem array element ck_null s2 A S |
786 | aslice array slice ck_null m@ A L | |
79072805 | 787 | |
878d132a NC |
788 | aeach each on array ck_each % A |
789 | akeys keys on array ck_each t% A | |
790 | avalues values on array ck_each t% A | |
791 | ||
aa689395 | 792 | # Hashes. |
79072805 | 793 | |
878d132a NC |
794 | each each ck_each % H |
795 | values values ck_each t% H | |
796 | keys keys ck_each t% H | |
db173bac | 797 | delete delete ck_delete % S |
42d38218 | 798 | exists exists ck_exists is% S |
f1612b5c | 799 | rv2hv hash dereference ck_rvconst dt1 |
c2dedb93 | 800 | helem hash element ck_null s2 H S |
db173bac | 801 | hslice hash slice ck_null m@ H L |
79072805 LW |
802 | |
803 | # Explosives and implosives. | |
804 | ||
bab9c0ac | 805 | unpack unpack ck_unpack @ S S? |
db173bac MB |
806 | pack pack ck_fun mst@ S L |
807 | split split ck_split t@ S S S | |
297b36dc | 808 | join join or string ck_join mst@ S L |
79072805 LW |
809 | |
810 | # List operators. | |
811 | ||
db173bac MB |
812 | list list ck_null m@ L |
813 | lslice list slice ck_null 2 H L L | |
42d38218 MS |
814 | anonlist anonymous list ([]) ck_fun ms@ L |
815 | anonhash anonymous hash ({}) ck_fun ms@ L | |
79072805 | 816 | |
db173bac | 817 | splice splice ck_fun m@ A S? S? L |
b162f9ea | 818 | push push ck_fun imsT@ A L |
26f600bc RGS |
819 | pop pop ck_shift s% A? |
820 | shift shift ck_shift s% A? | |
b162f9ea | 821 | unshift unshift ck_fun imsT@ A L |
9850bf21 | 822 | sort sort ck_sort dm@ C? L |
db173bac | 823 | reverse reverse ck_fun mt@ L |
79072805 | 824 | |
f1612b5c GS |
825 | grepstart grep ck_grep dm@ C L |
826 | grepwhile grep iterator ck_null dt| | |
79072805 | 827 | |
f1612b5c GS |
828 | mapstart map ck_grep dm@ C L |
829 | mapwhile map iterator ck_null dt| | |
a0d0e21e | 830 | |
79072805 LW |
831 | # Range stuff. |
832 | ||
1a67a97c | 833 | range flipflop ck_null | S S |
db173bac MB |
834 | flip range (or flip) ck_null 1 S S |
835 | flop range (or flop) ck_null 1 | |
79072805 LW |
836 | |
837 | # Control. | |
838 | ||
42d38218 | 839 | and logical and (&&) ck_null | |
f1612b5c GS |
840 | or logical or (||) ck_null | |
841 | xor logical xor ck_null fs2 S S | |
fdecdb95 | 842 | dor defined or (//) ck_null | |
f1612b5c | 843 | cond_expr conditional expression ck_null d| |
42d38218 MS |
844 | andassign logical and assignment (&&=) ck_null s| |
845 | orassign logical or assignment (||=) ck_null s| | |
fdecdb95 | 846 | dorassign defined or assignment (//=) ck_null s| |
db173bac | 847 | |
f5d5a27c | 848 | method method lookup ck_method d1 |
db173bac MB |
849 | entersub subroutine entry ck_subr dmt1 L |
850 | leavesub subroutine exit ck_null 1 | |
78f9721b | 851 | leavesublv lvalue subroutine return ck_null 1 |
db173bac MB |
852 | caller caller ck_fun t% S? |
853 | warn warn ck_fun imst@ L | |
96e176bf | 854 | die die ck_die dimst@ L |
f1612b5c | 855 | reset symbol reset ck_fun is% S? |
db173bac MB |
856 | |
857 | lineseq line sequence ck_null @ | |
722969e2 DM |
858 | nextstate next statement ck_null s; |
859 | dbstate debug next statement ck_null s; | |
e9c54c90 | 860 | unstack iteration finalizer ck_null s0 |
79072805 | 861 | enter block entry ck_null 0 |
db173bac MB |
862 | leave block exit ck_null @ |
863 | scope block ck_null @ | |
864 | enteriter foreach loop entry ck_null d{ | |
79072805 | 865 | iter foreach loop iterator ck_null 0 |
db173bac MB |
866 | enterloop loop entry ck_null d{ |
867 | leaveloop loop exit ck_null 2 | |
78f9721b | 868 | return return ck_return dm@ L |
db173bac MB |
869 | last last ck_null ds} |
870 | next next ck_null ds} | |
871 | redo redo ck_null ds} | |
872 | dump dump ck_null ds} | |
873 | goto goto ck_null ds} | |
d98f61e7 | 874 | exit exit ck_exit ds% S? |
fdecdb95 NC |
875 | method_named method with known name ck_null d$ |
876 | ||
877 | entergiven given() ck_null d| | |
878 | leavegiven leave given block ck_null 1 | |
879 | enterwhen when() ck_null d| | |
880 | leavewhen leave when block ck_null 1 | |
881 | break break ck_null 0 | |
882 | continue continue ck_null 0 | |
79072805 | 883 | |
79072805 LW |
884 | # I/O. |
885 | ||
a567e93b | 886 | open open ck_open ismt@ F S? L |
db173bac MB |
887 | close close ck_fun is% F? |
888 | pipe_op pipe ck_fun is@ F F | |
79072805 | 889 | |
db173bac | 890 | fileno fileno ck_fun ist% F |
a86a20aa | 891 | umask umask ck_fun ist% S? |
1c1fc3ea | 892 | binmode binmode ck_fun s@ F S? |
79072805 | 893 | |
db173bac MB |
894 | tie tie ck_fun idms@ R S L |
895 | untie untie ck_fun is% R | |
896 | tied tied ck_fun s% R | |
897 | dbmopen dbmopen ck_fun is@ H S S | |
898 | dbmclose dbmclose ck_fun is% H | |
79072805 | 899 | |
db173bac MB |
900 | sselect select system call ck_select t@ S S S S |
901 | select select ck_select st@ F? | |
79072805 | 902 | |
db173bac | 903 | getc getc ck_eof st% F? |
d1a002d4 | 904 | read read ck_fun imst@ F R S S? |
db173bac MB |
905 | enterwrite write ck_fun dis% F? |
906 | leavewrite write exit ck_null 1 | |
79072805 | 907 | |
db173bac MB |
908 | prtf printf ck_listiob ims@ F? L |
909 | print print ck_listiob ims@ F? L | |
fdecdb95 | 910 | say say ck_listiob ims@ F? L |
79072805 | 911 | |
db173bac MB |
912 | sysopen sysopen ck_fun s@ F S S S? |
913 | sysseek sysseek ck_fun s@ F S S | |
d1a002d4 | 914 | sysread sysread ck_fun imst@ F R S S? |
145d37e2 | 915 | syswrite syswrite ck_fun imst@ F S S? S? |
79072805 | 916 | |
db173bac MB |
917 | eof eof ck_eof is% F? |
918 | tell tell ck_fun st% F? | |
919 | seek seek ck_fun s@ F S S | |
9b01e405 | 920 | # truncate really behaves as if it had both "S S" and "F S" |
db173bac | 921 | truncate truncate ck_trunc is@ S S |
79072805 | 922 | |
db173bac MB |
923 | fcntl fcntl ck_fun st@ F S S |
924 | ioctl ioctl ck_fun st@ F S S | |
b162f9ea | 925 | flock flock ck_fun isT@ F S |
79072805 | 926 | |
e71197e2 JC |
927 | # Sockets. OP_IS_SOCKET wants them consecutive (so moved 1st 2) |
928 | ||
929 | send send ck_fun imst@ Fs S S S? | |
930 | recv recv ck_fun imst@ Fs R S S | |
79072805 | 931 | |
a85d93d9 JH |
932 | socket socket ck_fun is@ Fs S S S |
933 | sockpair socketpair ck_fun is@ Fs Fs S S S | |
79072805 | 934 | |
a85d93d9 JH |
935 | bind bind ck_fun is@ Fs S |
936 | connect connect ck_fun is@ Fs S | |
937 | listen listen ck_fun is@ Fs S | |
938 | accept accept ck_fun ist@ Fs Fs | |
939 | shutdown shutdown ck_fun ist@ Fs S | |
79072805 | 940 | |
a85d93d9 JH |
941 | gsockopt getsockopt ck_fun is@ Fs S S |
942 | ssockopt setsockopt ck_fun is@ Fs S S S | |
79072805 | 943 | |
a85d93d9 JH |
944 | getsockname getsockname ck_fun is% Fs |
945 | getpeername getpeername ck_fun is% Fs | |
79072805 | 946 | |
e71197e2 | 947 | # Stat calls. OP_IS_FILETEST wants them consecutive. |
79072805 | 948 | |
db173bac MB |
949 | lstat lstat ck_ftst u- F |
950 | stat stat ck_ftst u- F | |
a85d93d9 JH |
951 | ftrread -R ck_ftst isu- F- |
952 | ftrwrite -W ck_ftst isu- F- | |
953 | ftrexec -X ck_ftst isu- F- | |
954 | fteread -r ck_ftst isu- F- | |
955 | ftewrite -w ck_ftst isu- F- | |
956 | fteexec -x ck_ftst isu- F- | |
957 | ftis -e ck_ftst isu- F- | |
a85d93d9 JH |
958 | ftsize -s ck_ftst istu- F- |
959 | ftmtime -M ck_ftst stu- F- | |
960 | ftatime -A ck_ftst stu- F- | |
961 | ftctime -C ck_ftst stu- F- | |
7834bb7e NC |
962 | ftrowned -O ck_ftst isu- F- |
963 | fteowned -o ck_ftst isu- F- | |
964 | ftzero -z ck_ftst isu- F- | |
a85d93d9 JH |
965 | ftsock -S ck_ftst isu- F- |
966 | ftchr -c ck_ftst isu- F- | |
967 | ftblk -b ck_ftst isu- F- | |
968 | ftfile -f ck_ftst isu- F- | |
969 | ftdir -d ck_ftst isu- F- | |
970 | ftpipe -p ck_ftst isu- F- | |
a85d93d9 JH |
971 | ftsuid -u ck_ftst isu- F- |
972 | ftsgid -g ck_ftst isu- F- | |
973 | ftsvtx -k ck_ftst isu- F- | |
7834bb7e | 974 | ftlink -l ck_ftst isu- F- |
a85d93d9 JH |
975 | fttty -t ck_ftst is- F- |
976 | fttext -T ck_ftst isu- F- | |
977 | ftbinary -B ck_ftst isu- F- | |
79072805 LW |
978 | |
979 | # File calls. | |
980 | ||
d4ac975e GA |
981 | # chdir really behaves as if it had both "S?" and "F?" |
982 | chdir chdir ck_chdir isT% S? | |
b162f9ea IZ |
983 | chown chown ck_fun imsT@ L |
984 | chroot chroot ck_fun isTu% S? | |
985 | unlink unlink ck_fun imsTu@ L | |
a86a20aa | 986 | chmod chmod ck_fun imsT@ L |
b162f9ea IZ |
987 | utime utime ck_fun imsT@ L |
988 | rename rename ck_fun isT@ S S | |
989 | link link ck_fun isT@ S S | |
990 | symlink symlink ck_fun isT@ S S | |
db173bac | 991 | readlink readlink ck_fun stu% S? |
491873e5 | 992 | mkdir mkdir ck_fun isTu@ S? S? |
b162f9ea | 993 | rmdir rmdir ck_fun isTu% S? |
79072805 LW |
994 | |
995 | # Directory calls. | |
996 | ||
1e2c6ed7 | 997 | open_dir opendir ck_fun is@ F S |
db173bac MB |
998 | readdir readdir ck_fun % F |
999 | telldir telldir ck_fun st% F | |
1000 | seekdir seekdir ck_fun s@ F S | |
1001 | rewinddir rewinddir ck_fun s% F | |
1002 | closedir closedir ck_fun is% F | |
79072805 LW |
1003 | |
1004 | # Process control. | |
1005 | ||
db173bac | 1006 | fork fork ck_null ist0 |
b162f9ea IZ |
1007 | wait wait ck_null isT0 |
1008 | waitpid waitpid ck_fun isT@ S S | |
1009 | system system ck_exec imsT@ S? L | |
1010 | exec exec ck_exec dimsT@ S? L | |
1011 | kill kill ck_fun dimsT@ L | |
1012 | getppid getppid ck_null isT0 | |
1013 | getpgrp getpgrp ck_fun isT% S? | |
1014 | setpgrp setpgrp ck_fun isT@ S? S? | |
1015 | getpriority getpriority ck_fun isT@ S S | |
1016 | setpriority setpriority ck_fun isT@ S S S | |
79072805 LW |
1017 | |
1018 | # Time calls. | |
1019 | ||
cd39f2b6 JH |
1020 | # NOTE: MacOS patches the 'i' of time() away later when the interpreter |
1021 | # is created because in MacOS time() is already returning times > 2**31-1, | |
1022 | # that is, non-integers. | |
1023 | ||
b162f9ea | 1024 | time time ck_null isT0 |
79072805 | 1025 | tms times ck_null 0 |
db173bac MB |
1026 | localtime localtime ck_fun t% S? |
1027 | gmtime gmtime ck_fun t% S? | |
1028 | alarm alarm ck_fun istu% S? | |
b162f9ea | 1029 | sleep sleep ck_fun isT% S? |
79072805 LW |
1030 | |
1031 | # Shared memory. | |
1032 | ||
db173bac MB |
1033 | shmget shmget ck_fun imst@ S S S |
1034 | shmctl shmctl ck_fun imst@ S S S | |
1035 | shmread shmread ck_fun imst@ S S S S | |
1036 | shmwrite shmwrite ck_fun imst@ S S S S | |
79072805 LW |
1037 | |
1038 | # Message passing. | |
1039 | ||
db173bac MB |
1040 | msgget msgget ck_fun imst@ S S |
1041 | msgctl msgctl ck_fun imst@ S S S | |
1042 | msgsnd msgsnd ck_fun imst@ S S S | |
1043 | msgrcv msgrcv ck_fun imst@ S S S S S | |
79072805 LW |
1044 | |
1045 | # Semaphores. | |
1046 | ||
7834bb7e | 1047 | semop semop ck_fun imst@ S S |
db173bac MB |
1048 | semget semget ck_fun imst@ S S S |
1049 | semctl semctl ck_fun imst@ S S S S | |
79072805 LW |
1050 | |
1051 | # Eval. | |
1052 | ||
db173bac | 1053 | require require ck_require du% S? |
b3f4d674 GS |
1054 | dofile do "file" ck_fun d1 S |
1055 | entereval eval "string" ck_eval d% S | |
1056 | leaveeval eval "string" exit ck_null 1 S | |
db173bac | 1057 | #evalonce eval constant string ck_null d1 S |
42d38218 | 1058 | entertry eval {block} ck_null | |
f1612b5c | 1059 | leavetry eval {block} exit ck_null @ |
79072805 LW |
1060 | |
1061 | # Get system info. | |
1062 | ||
db173bac MB |
1063 | ghbyname gethostbyname ck_fun % S |
1064 | ghbyaddr gethostbyaddr ck_fun @ S S | |
79072805 | 1065 | ghostent gethostent ck_null 0 |
db173bac MB |
1066 | gnbyname getnetbyname ck_fun % S |
1067 | gnbyaddr getnetbyaddr ck_fun @ S S | |
79072805 | 1068 | gnetent getnetent ck_null 0 |
db173bac MB |
1069 | gpbyname getprotobyname ck_fun % S |
1070 | gpbynumber getprotobynumber ck_fun @ S | |
79072805 | 1071 | gprotoent getprotoent ck_null 0 |
db173bac MB |
1072 | gsbyname getservbyname ck_fun @ S S |
1073 | gsbyport getservbyport ck_fun @ S S | |
79072805 | 1074 | gservent getservent ck_null 0 |
db173bac MB |
1075 | shostent sethostent ck_fun is% S |
1076 | snetent setnetent ck_fun is% S | |
1077 | sprotoent setprotoent ck_fun is% S | |
1078 | sservent setservent ck_fun is% S | |
1079 | ehostent endhostent ck_null is0 | |
1080 | enetent endnetent ck_null is0 | |
1081 | eprotoent endprotoent ck_null is0 | |
1082 | eservent endservent ck_null is0 | |
1083 | gpwnam getpwnam ck_fun % S | |
1084 | gpwuid getpwuid ck_fun % S | |
79072805 | 1085 | gpwent getpwent ck_null 0 |
db173bac MB |
1086 | spwent setpwent ck_null is0 |
1087 | epwent endpwent ck_null is0 | |
1088 | ggrnam getgrnam ck_fun % S | |
1089 | ggrgid getgrgid ck_fun % S | |
79072805 | 1090 | ggrent getgrent ck_null 0 |
db173bac MB |
1091 | sgrent setgrent ck_null is0 |
1092 | egrent endgrent ck_null is0 | |
1093 | getlogin getlogin ck_null st0 | |
79072805 LW |
1094 | |
1095 | # Miscellaneous. | |
1096 | ||
db173bac | 1097 | syscall syscall ck_fun imst@ S L |
c0329465 MB |
1098 | |
1099 | # For multi-threading | |
5a47f09b | 1100 | lock lock ck_rfun s% R |
7399586d | 1101 | |
c5917253 NC |
1102 | # For state support |
1103 | ||
1104 | once once ck_null | | |
1105 | ||
53e06cf0 | 1106 | custom unknown custom operator ck_null 0 |