yet more cleanups of the PERL_OBJECT, MULTIPLICITY and USE_THREADS
[p5sagit/p5-mst-13.2.git] / win32 / makedef.pl
CommitLineData
0a753a76 1#!../miniperl
2
22c35a8c 3# Create the export list for perl. Needed by WIN32 for creating perl.dll.
0a753a76 4
22c35a8c 5# reads global.sym, pp.sym, perlvars.h, intrpvar.h, thrdvar.h, config.h
0a753a76 6
910dfcc8 7my $CCTYPE = "MSVC"; # default
8
9while (@ARGV)
d55594ae 10 {
11 my $flag = shift;
12 $define{$1} = 1 if ($flag =~ /^-D(\w+)$/);
910dfcc8 13 $CCTYPE = $1 if ($flag =~ /^CCTYPE=(\w+)$/);
d55594ae 14 }
15
bbc8f9de 16open(CFG,'config.h') || die "Cannot open config.h:$!";
17while (<CFG>)
18 {
19 $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
924b3ec4 20 $define{$1} = 1 if /^\s*#\s*define\s+(USE_THREADS)\b/;
b86a2fa7 21 $define{$1} = 1 if /^\s*#\s*define\s+(MULTIPLICITY)\b/;
bbc8f9de 22 }
23close(CFG);
24
d55594ae 25warn join(' ',keys %define)."\n";
26
ac4c12e7 27if ($define{PERL_OBJECT}) {
28 print "LIBRARY PerlCore\n";
29 print "DESCRIPTION 'Perl interpreter'\n";
30 print "EXPORTS\n";
51371543 31# output_symbol("perl_alloc");
0cb96387 32 output_symbol("perl_get_host_info");
33 output_symbol("perl_alloc_using");
51371543 34# output_symbol("perl_construct");
35# output_symbol("perl_destruct");
36# output_symbol("perl_free");
37# output_symbol("perl_parse");
38# output_symbol("perl_run");
39# output_symbol("RunPerl");
51371543 40# exit(0);
41}
42else {
43 if ($CCTYPE ne 'GCC') {
44 print "LIBRARY Perl\n";
45 print "DESCRIPTION 'Perl interpreter, export autogenerated'\n";
46 }
47 else {
48 $define{'PERL_GLOBAL_STRUCT'} = 1;
49 $define{'MULTIPLICITY'} = 1;
50 }
51 print "EXPORTS\n";
ac4c12e7 52}
bbc8f9de 53
22239a37 54my %skip;
55my %export;
56
51371543 57sub skip_symbols {
58 my $list = shift;
59 foreach my $symbol (@$list) {
60 $skip{$symbol} = 1;
61 }
22239a37 62}
63
51371543 64sub emit_symbols {
65 my $list = shift;
66 foreach my $symbol (@$list) {
67 my $skipsym = $symbol;
68 # XXX hack
69 if ($define{PERL_OBJECT}) {
70 $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
71 }
72 emit_symbol($symbol) unless exists $skip{$skipsym};
73 }
22239a37 74}
75
76skip_symbols [qw(
db15561c 77PL_statusvalue_vms
78PL_archpat_auto
79PL_cryptseen
80PL_DBcv
81PL_generation
db15561c 82PL_lastgotoprobe
83PL_linestart
84PL_modcount
85PL_pending_ident
86PL_sortcxix
87PL_sublex_info
88PL_timesbuf
4f63d024 89main
90Perl_ErrorNo
91Perl_GetVars
a6c40364 92Perl_do_exec3
0a753a76 93Perl_do_ipcctl
94Perl_do_ipcget
95Perl_do_msgrcv
96Perl_do_msgsnd
97Perl_do_semop
98Perl_do_shmio
0a753a76 99Perl_dump_fds
d55594ae 100Perl_init_thread_intern
0a753a76 101Perl_my_bzero
102Perl_my_htonl
103Perl_my_ntohl
104Perl_my_swap
105Perl_my_chsize
0a753a76 106Perl_same_dirent
68dc0745 107Perl_setenv_getix
0a753a76 108Perl_unlnk
0a753a76 109Perl_watch
0a753a76 110Perl_safexcalloc
111Perl_safexmalloc
112Perl_safexfree
113Perl_safexrealloc
68dc0745 114Perl_my_memcmp
8b10511d 115Perl_my_memset
db15561c 116PL_cshlen
117PL_cshname
118PL_opsave
22239a37 119)];
0a753a76 120
51371543 121if ($define{'PERL_OBJECT'}) {
122 skip_symbols [qw(
123 Perl_getenv_len
124 Perl_my_popen
125 Perl_my_pclose
126 )];
127}
128else {
129 skip_symbols [qw(
130 PL_Dir
131 PL_Env
132 PL_LIO
133 PL_Mem
134 PL_Proc
135 PL_Sock
136 PL_StdIO
137 )];
138}
c69f112c 139
bbc8f9de 140if ($define{'MYMALLOC'})
141 {
22239a37 142 emit_symbols [qw(
9423c6fc 143 Perl_dump_mstats
22239a37 144 Perl_malloc
f2517201 145 Perl_mfree
22239a37 146 Perl_realloc
147 Perl_calloc)];
bbc8f9de 148 }
32fcaa0b 149else
150 {
151 skip_symbols [qw(
df31f264 152 Perl_dump_mstats
4f63d024 153 Perl_malloc
154 Perl_mfree
155 Perl_realloc
156 Perl_calloc
32fcaa0b 157 Perl_malloced_size)];
158 }
bbc8f9de 159
d55594ae 160unless ($define{'USE_THREADS'})
161 {
22239a37 162 skip_symbols [qw(
db15561c 163PL_thr_key
164PL_sv_mutex
46124e9e 165PL_strtab_mutex
db15561c 166PL_svref_mutex
167PL_malloc_mutex
5ff3f7a4 168PL_cred_mutex
db15561c 169PL_eval_mutex
170PL_eval_cond
171PL_eval_owner
172PL_threads_mutex
173PL_nthreads
174PL_nthreads_cond
175PL_threadnum
176PL_threadsv_names
177PL_thrsv
22c35a8c 178PL_vtbl_mutex
eb480a0b 179Perl_getTHR
180Perl_setTHR
d55594ae 181Perl_condpair_magic
32f822de 182Perl_new_struct_thread
32f822de 183Perl_per_thread_magicals
d4cce5f1 184Perl_thread_create
185Perl_find_threadsv
d55594ae 186Perl_unlock_condpair
d55594ae 187Perl_magic_mutexfree
95906810 188)];
910dfcc8 189 }
c5be433b 190unless ($define{'USE_THREADS'} or $define{'PERL_IMPLICIT_CONTEXT'}
191 or $define{'PERL_OBJECT'})
192{
4f63d024 193 skip_symbols [qw(
194 Perl_croak_nocontext
195 Perl_die_nocontext
c5be433b 196 Perl_deb_nocontext
4f63d024 197 Perl_form_nocontext
198 Perl_warn_nocontext
c5be433b 199 Perl_warner_nocontext
4f63d024 200 Perl_newSVpvf_nocontext
201 Perl_sv_catpvf_nocontext
202 Perl_sv_setpvf_nocontext
203 Perl_sv_catpvf_mg_nocontext
204 Perl_sv_setpvf_mg_nocontext
205 )];
206 }
d4cce5f1 207
910dfcc8 208unless ($define{'FAKE_THREADS'})
209 {
db15561c 210 skip_symbols [qw(PL_curthr)];
d55594ae 211 }
212
22239a37 213sub readvar
214{
215 my $file = shift;
51371543 216 my $proc = shift || sub { "PL_$_[2]" };
22239a37 217 open(VARS,$file) || die "Cannot open $file:$!";
218 my @syms;
219 while (<VARS>)
220 {
221 # All symbols have a Perl_ prefix because that's what embed.h
222 # sticks in front of them.
51371543 223 push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?C?)\(([IGT])(\w+)/);
22239a37 224 }
225 close(VARS);
226 return \@syms;
227}
228
d4cce5f1 229if ($define{'USE_THREADS'} || $define{'MULTIPLICITY'})
d55594ae 230 {
22239a37 231 my $thrd = readvar("../thrdvar.h");
232 skip_symbols $thrd;
d55594ae 233 }
234
d4cce5f1 235if ($define{'MULTIPLICITY'})
d55594ae 236 {
22239a37 237 my $interp = readvar("../intrpvar.h");
238 skip_symbols $interp;
239 }
240
241if ($define{'PERL_GLOBAL_STRUCT'})
242 {
243 my $global = readvar("../perlvars.h");
244 skip_symbols $global;
852c2e52 245 emit_symbols [qw(Perl_GetVars)];
db15561c 246 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
d4cce5f1 247 }
d55594ae 248
36c15d3f 249unless ($define{'DEBUGGING'})
250 {
22239a37 251 skip_symbols [qw(
fea7140c 252 Perl_deb
253 Perl_deb_growlevel
254 Perl_debop
255 Perl_debprofdump
256 Perl_debstack
257 Perl_debstackptrs
22239a37 258 Perl_runops_debug
259 Perl_sv_peek
3836fe67 260 PL_block_type
22c35a8c 261 PL_watchaddr
262 PL_watchok)];
36c15d3f 263 }
264
26618a56 265if ($define{'HAVE_DES_FCRYPT'})
266 {
267 emit_symbols [qw(win32_crypt)];
268 }
269
22c35a8c 270# functions from *.sym files
271
272for my $syms ('../global.sym','../pp.sym', '../globvar.sym')
22239a37 273 {
22c35a8c 274 open (GLOBAL, "<$syms") || die "failed to open $syms" . $!;
275 while (<GLOBAL>)
276 {
277 next if (!/^[A-Za-z]/);
278 # Functions have a Perl_ prefix
279 # Variables have a PL_ prefix
280 chomp($_);
4f63d024 281 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
22c35a8c 282 $symbol .= $_;
283 emit_symbol($symbol) unless exists $skip{$symbol};
284 }
285 close(GLOBAL);
22239a37 286 }
0a753a76 287
22c35a8c 288# variables
0a753a76 289
51371543 290if ($define{'PERL_OBJECT'}) {
291 for my $f ("../perlvars.h", "../intrpvar.h", "../thrdvar.h") {
292 my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
293 emit_symbols $glob;
294 }
295}
296else {
297 unless ($define{'PERL_GLOBAL_STRUCT'}) {
298 my $glob = readvar("../perlvars.h");
299 emit_symbols $glob;
300 }
301 unless ($define{'MULTIPLICITY'}) {
302 my $glob = readvar("../intrpvar.h");
303 emit_symbols $glob;
304 }
305
306 unless ($define{'MULTIPLICITY'} || $define{'USE_THREADS'}) {
307 my $glob = readvar("../thrdvar.h");
308 emit_symbols $glob;
309 }
310}
0a753a76 311
312while (<DATA>) {
313 my $symbol;
314 next if (!/^[A-Za-z]/);
315 next if (/^#/);
a868473f 316 s/\r//g;
22239a37 317 chomp($_);
0a753a76 318 $symbol = $_;
22239a37 319 next if exists $skip{$symbol};
3e3baf6d 320 emit_symbol($symbol);
321}
322
22239a37 323foreach my $symbol (sort keys %export)
324 {
ac4c12e7 325 output_symbol($symbol);
22239a37 326 }
327
328sub emit_symbol {
329 my $symbol = shift;
330 chomp($symbol);
331 $export{$symbol} = 1;
3e3baf6d 332}
0a753a76 333
ac4c12e7 334sub output_symbol {
335 my $symbol = shift;
51371543 336 print "\t$symbol\n";
337# XXX: binary compatibility between compilers is an exercise
338# in frustration :-(
339# if ($CCTYPE eq "BORLAND") {
340# # workaround Borland quirk by exporting both the straight
341# # name and a name with leading underscore. Note the
342# # alias *must* come after the symbol itself, if both
343# # are to be exported. (Linker bug?)
344# print "\t_$symbol\n";
345# print "\t$symbol = _$symbol\n";
346# }
347# elsif ($CCTYPE eq 'GCC') {
348# # Symbols have leading _ whole process is $%@"% slow
349# # so skip aliases for now
350# print "\t$symbol\n";
351# }
352# else {
353# # for binary coexistence, export both the symbol and
354# # alias with leading underscore
355# print "\t$symbol\n";
356# print "\t_$symbol = $symbol\n";
357# }
ac4c12e7 358}
359
0a753a76 3601;
361__DATA__
362# extra globals not included above.
0a753a76 363perl_alloc
364perl_construct
365perl_destruct
366perl_free
367perl_parse
368perl_run
d28b3ca3 369boot_DynaLoader
d55594ae 370Perl_thread_create
68dc0745 371win32_errno
96e4d5b1 372win32_environ
68dc0745 373win32_stdin
374win32_stdout
96e4d5b1 375win32_stderr
68dc0745 376win32_ferror
377win32_feof
378win32_strerror
379win32_fprintf
380win32_printf
381win32_vfprintf
96e4d5b1 382win32_vprintf
68dc0745 383win32_fread
384win32_fwrite
385win32_fopen
386win32_fdopen
387win32_freopen
388win32_fclose
389win32_fputs
390win32_fputc
391win32_ungetc
392win32_getc
393win32_fileno
394win32_clearerr
395win32_fflush
396win32_ftell
397win32_fseek
398win32_fgetpos
399win32_fsetpos
400win32_rewind
401win32_tmpfile
402win32_abort
403win32_fstat
96e4d5b1 404win32_stat
68dc0745 405win32_pipe
406win32_popen
407win32_pclose
e24c7c18 408win32_rename
68dc0745 409win32_setmode
96e4d5b1 410win32_lseek
411win32_tell
68dc0745 412win32_dup
413win32_dup2
96e4d5b1 414win32_open
415win32_close
416win32_eof
68dc0745 417win32_read
418win32_write
3e3baf6d 419win32_spawnvp
5aabfad6 420win32_mkdir
421win32_rmdir
422win32_chdir
c90c0ff4 423win32_flock
eb62e965 424win32_execv
6890e559 425win32_execvp
54310121 426win32_htons
427win32_ntohs
428win32_htonl
429win32_ntohl
430win32_inet_addr
431win32_inet_ntoa
432win32_socket
433win32_bind
434win32_listen
435win32_accept
436win32_connect
437win32_send
438win32_sendto
439win32_recv
440win32_recvfrom
441win32_shutdown
3a25acb4 442win32_closesocket
54310121 443win32_ioctlsocket
444win32_setsockopt
445win32_getsockopt
446win32_getpeername
447win32_getsockname
448win32_gethostname
449win32_gethostbyname
450win32_gethostbyaddr
451win32_getprotobyname
452win32_getprotobynumber
453win32_getservbyname
454win32_getservbyport
455win32_select
456win32_endhostent
457win32_endnetent
458win32_endprotoent
459win32_endservent
460win32_getnetent
461win32_getnetbyname
462win32_getnetbyaddr
463win32_getprotoent
464win32_getservent
465win32_sethostent
466win32_setnetent
467win32_setprotoent
468win32_setservent
ad2e33dc 469win32_getenv
ac5c734f 470win32_putenv
84902520 471win32_perror
472win32_setbuf
473win32_setvbuf
474win32_flushall
475win32_fcloseall
476win32_fgets
477win32_gets
478win32_fgetc
479win32_putc
480win32_puts
481win32_getchar
482win32_putchar
483win32_malloc
484win32_calloc
485win32_realloc
486win32_free
f3986ebb 487win32_sleep
488win32_times
489win32_alarm
65e48ea9 490win32_open_osfhandle
491win32_get_osfhandle
f998180f 492win32_ioctl
ad0751ec 493win32_utime
b2af26b1 494win32_uname
22fae026 495win32_wait
f55ee38a 496win32_waitpid
497win32_kill
22fae026 498win32_str_os_error
ce2e26e5 499win32_opendir
500win32_readdir
501win32_telldir
502win32_seekdir
503win32_rewinddir
504win32_closedir
8ac9c18d 505win32_longpath
0cb96387 506win32_os_id
ad2e33dc 507Perl_win32_init
f3986ebb 508Perl_init_os_extras
9811a7d7 509Perl_getTHR
0fefa03b 510Perl_setTHR
84902520 511RunPerl
c5be433b 512GetPerlInterpreter
513SetPerlInterpreter
22239a37 514