This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
The regexec.c change of #3606 caused a core dump in fbm_instr()
[perl5.git] / win32 / makedef.pl
CommitLineData
0a753a76
PP
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
GS
7my $CCTYPE = "MSVC"; # default
8
9while (@ARGV)
d55594ae
GS
10 {
11 my $flag = shift;
12 $define{$1} = 1 if ($flag =~ /^-D(\w+)$/);
910dfcc8 13 $CCTYPE = $1 if ($flag =~ /^CCTYPE=(\w+)$/);
d55594ae
GS
14 }
15
bbc8f9de
NIS
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
NIS
22 }
23close(CFG);
24
d55594ae
GS
25warn join(' ',keys %define)."\n";
26
ac4c12e7
GS
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
GS
32 output_symbol("perl_get_host_info");
33 output_symbol("perl_alloc_using");
51371543
GS
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
GS
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
NIS
54my %skip;
55my %export;
56
51371543
GS
57sub skip_symbols {
58 my $list = shift;
59 foreach my $symbol (@$list) {
60 $skip{$symbol} = 1;
61 }
22239a37
NIS
62}
63
51371543
GS
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
NIS
74}
75
76skip_symbols [qw(
db15561c
GS
77PL_statusvalue_vms
78PL_archpat_auto
79PL_cryptseen
80PL_DBcv
81PL_generation
db15561c
GS
82PL_lastgotoprobe
83PL_linestart
84PL_modcount
85PL_pending_ident
86PL_sortcxix
87PL_sublex_info
88PL_timesbuf
4f63d024
GS
89main
90Perl_ErrorNo
91Perl_GetVars
a6c40364 92Perl_do_exec3
0a753a76
PP
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
PP
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
PP
110Perl_safexcalloc
111Perl_safexmalloc
112Perl_safexfree
113Perl_safexrealloc
68dc0745 114Perl_my_memcmp
8b10511d 115Perl_my_memset
db15561c
GS
116PL_cshlen
117PL_cshname
118PL_opsave
22239a37 119)];
0a753a76 120
51371543
GS
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
NIS
140if ($define{'MYMALLOC'})
141 {
22239a37 142 emit_symbols [qw(
9423c6fc 143 Perl_dump_mstats
22239a37 144 Perl_malloc
f2517201 145 Perl_mfree
22239a37
NIS
146 Perl_realloc
147 Perl_calloc)];
bbc8f9de 148 }
32fcaa0b
GS
149else
150 {
151 skip_symbols [qw(
df31f264 152 Perl_dump_mstats
4f63d024
GS
153 Perl_malloc
154 Perl_mfree
155 Perl_realloc
156 Perl_calloc
32fcaa0b
GS
157 Perl_malloced_size)];
158 }
bbc8f9de 159
d55594ae
GS
160unless ($define{'USE_THREADS'})
161 {
22239a37 162 skip_symbols [qw(
db15561c
GS
163PL_thr_key
164PL_sv_mutex
46124e9e 165PL_strtab_mutex
db15561c
GS
166PL_svref_mutex
167PL_malloc_mutex
5ff3f7a4 168PL_cred_mutex
db15561c
GS
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
GS
179Perl_getTHR
180Perl_setTHR
d55594ae 181Perl_condpair_magic
32f822de 182Perl_new_struct_thread
32f822de 183Perl_per_thread_magicals
d4cce5f1
NIS
184Perl_thread_create
185Perl_find_threadsv
d55594ae 186Perl_unlock_condpair
d55594ae 187Perl_magic_mutexfree
95906810 188)];
910dfcc8 189 }
c5be433b
GS
190unless ($define{'USE_THREADS'} or $define{'PERL_IMPLICIT_CONTEXT'}
191 or $define{'PERL_OBJECT'})
192{
4f63d024
GS
193 skip_symbols [qw(
194 Perl_croak_nocontext
195 Perl_die_nocontext
c5be433b 196 Perl_deb_nocontext
4f63d024
GS
197 Perl_form_nocontext
198 Perl_warn_nocontext
c5be433b 199 Perl_warner_nocontext
4f63d024
GS
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
GS
208unless ($define{'FAKE_THREADS'})
209 {
db15561c 210 skip_symbols [qw(PL_curthr)];
d55594ae
GS
211 }
212
22239a37
NIS
213sub readvar
214{
215 my $file = shift;
51371543 216 my $proc = shift || sub { "PL_$_[2]" };
22239a37
NIS
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
NIS
224 }
225 close(VARS);
226 return \@syms;
227}
228
d4cce5f1 229if ($define{'USE_THREADS'} || $define{'MULTIPLICITY'})
d55594ae 230 {
22239a37
NIS
231 my $thrd = readvar("../thrdvar.h");
232 skip_symbols $thrd;
d55594ae
GS
233 }
234
d4cce5f1 235if ($define{'MULTIPLICITY'})
d55594ae 236 {
22239a37
NIS
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
NIS
249unless ($define{'DEBUGGING'})
250 {
22239a37 251 skip_symbols [qw(
fea7140c
GS
252 Perl_deb
253 Perl_deb_growlevel
254 Perl_debop
255 Perl_debprofdump
256 Perl_debstack
257 Perl_debstackptrs
22239a37
NIS
258 Perl_runops_debug
259 Perl_sv_peek
3836fe67 260 PL_block_type
22c35a8c
GS
261 PL_watchaddr
262 PL_watchok)];
36c15d3f
NIS
263 }
264
26618a56
GS
265if ($define{'HAVE_DES_FCRYPT'})
266 {
267 emit_symbols [qw(win32_crypt)];
268 }
269
22c35a8c
GS
270# functions from *.sym files
271
272for my $syms ('../global.sym','../pp.sym', '../globvar.sym')
22239a37 273 {
22c35a8c
GS
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
GS
282 $symbol .= $_;
283 emit_symbol($symbol) unless exists $skip{$symbol};
284 }
285 close(GLOBAL);
22239a37 286 }
0a753a76 287
22c35a8c 288# variables
0a753a76 289
51371543
GS
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
PP
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
TB
320 emit_symbol($symbol);
321}
322
22239a37
NIS
323foreach my $symbol (sort keys %export)
324 {
ac4c12e7 325 output_symbol($symbol);
22239a37
NIS
326 }
327
328sub emit_symbol {
329 my $symbol = shift;
330 chomp($symbol);
331 $export{$symbol} = 1;
3e3baf6d 332}
0a753a76 333
ac4c12e7
GS
334sub output_symbol {
335 my $symbol = shift;
a88c3d7c 336 $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
51371543
GS
337 print "\t$symbol\n";
338# XXX: binary compatibility between compilers is an exercise
339# in frustration :-(
340# if ($CCTYPE eq "BORLAND") {
341# # workaround Borland quirk by exporting both the straight
342# # name and a name with leading underscore. Note the
343# # alias *must* come after the symbol itself, if both
344# # are to be exported. (Linker bug?)
345# print "\t_$symbol\n";
346# print "\t$symbol = _$symbol\n";
347# }
348# elsif ($CCTYPE eq 'GCC') {
349# # Symbols have leading _ whole process is $%@"% slow
350# # so skip aliases for now
351# print "\t$symbol\n";
352# }
353# else {
354# # for binary coexistence, export both the symbol and
355# # alias with leading underscore
356# print "\t$symbol\n";
357# print "\t_$symbol = $symbol\n";
358# }
ac4c12e7
GS
359}
360
0a753a76
PP
3611;
362__DATA__
363# extra globals not included above.
0a753a76
PP
364perl_alloc
365perl_construct
366perl_destruct
367perl_free
368perl_parse
369perl_run
d28b3ca3 370boot_DynaLoader
d55594ae 371Perl_thread_create
68dc0745 372win32_errno
96e4d5b1 373win32_environ
68dc0745
PP
374win32_stdin
375win32_stdout
96e4d5b1 376win32_stderr
68dc0745
PP
377win32_ferror
378win32_feof
379win32_strerror
380win32_fprintf
381win32_printf
382win32_vfprintf
96e4d5b1 383win32_vprintf
68dc0745
PP
384win32_fread
385win32_fwrite
386win32_fopen
387win32_fdopen
388win32_freopen
389win32_fclose
390win32_fputs
391win32_fputc
392win32_ungetc
393win32_getc
394win32_fileno
395win32_clearerr
396win32_fflush
397win32_ftell
398win32_fseek
399win32_fgetpos
400win32_fsetpos
401win32_rewind
402win32_tmpfile
403win32_abort
404win32_fstat
96e4d5b1 405win32_stat
68dc0745
PP
406win32_pipe
407win32_popen
408win32_pclose
e24c7c18 409win32_rename
68dc0745 410win32_setmode
96e4d5b1
PP
411win32_lseek
412win32_tell
68dc0745
PP
413win32_dup
414win32_dup2
96e4d5b1
PP
415win32_open
416win32_close
417win32_eof
68dc0745
PP
418win32_read
419win32_write
3e3baf6d 420win32_spawnvp
5aabfad6
PP
421win32_mkdir
422win32_rmdir
423win32_chdir
c90c0ff4 424win32_flock
eb62e965 425win32_execv
6890e559 426win32_execvp
54310121
PP
427win32_htons
428win32_ntohs
429win32_htonl
430win32_ntohl
431win32_inet_addr
432win32_inet_ntoa
433win32_socket
434win32_bind
435win32_listen
436win32_accept
437win32_connect
438win32_send
439win32_sendto
440win32_recv
441win32_recvfrom
442win32_shutdown
3a25acb4 443win32_closesocket
54310121
PP
444win32_ioctlsocket
445win32_setsockopt
446win32_getsockopt
447win32_getpeername
448win32_getsockname
449win32_gethostname
450win32_gethostbyname
451win32_gethostbyaddr
452win32_getprotobyname
453win32_getprotobynumber
454win32_getservbyname
455win32_getservbyport
456win32_select
457win32_endhostent
458win32_endnetent
459win32_endprotoent
460win32_endservent
461win32_getnetent
462win32_getnetbyname
463win32_getnetbyaddr
464win32_getprotoent
465win32_getservent
466win32_sethostent
467win32_setnetent
468win32_setprotoent
469win32_setservent
ad2e33dc 470win32_getenv
ac5c734f 471win32_putenv
84902520
TB
472win32_perror
473win32_setbuf
474win32_setvbuf
475win32_flushall
476win32_fcloseall
477win32_fgets
478win32_gets
479win32_fgetc
480win32_putc
481win32_puts
482win32_getchar
483win32_putchar
484win32_malloc
485win32_calloc
486win32_realloc
487win32_free
f3986ebb
GS
488win32_sleep
489win32_times
490win32_alarm
65e48ea9
GS
491win32_open_osfhandle
492win32_get_osfhandle
f998180f 493win32_ioctl
ad0751ec 494win32_utime
b2af26b1 495win32_uname
22fae026 496win32_wait
f55ee38a
GS
497win32_waitpid
498win32_kill
22fae026 499win32_str_os_error
ce2e26e5
GS
500win32_opendir
501win32_readdir
502win32_telldir
503win32_seekdir
504win32_rewinddir
505win32_closedir
8ac9c18d 506win32_longpath
0cb96387 507win32_os_id
ad2e33dc 508Perl_win32_init
f3986ebb 509Perl_init_os_extras
9811a7d7 510Perl_getTHR
0fefa03b 511Perl_setTHR
84902520 512RunPerl
c5be433b
GS
513GetPerlInterpreter
514SetPerlInterpreter
22239a37 515