make safesysmalloc() etc., always available; safemalloc() et al are
[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";
31 output_symbol("perl_alloc");
32 exit(0);
33}
34
04dc04aa 35if ($CCTYPE ne 'GCC')
36 {
37 print "LIBRARY Perl\n";
38 print "DESCRIPTION 'Perl interpreter, export autogenerated'\n";
04dc04aa 39 }
22239a37 40else
41 {
42 $define{'PERL_GLOBAL_STRUCT'} = 1;
43 $define{'MULTIPLICITY'} = 1;
44 }
45
bbc8f9de 46print "EXPORTS\n";
47
22239a37 48my %skip;
49my %export;
50
51sub skip_symbols
52{
53 my $list = shift;
54 foreach my $symbol (@$list)
55 {
56 $skip{$symbol} = 1;
57 }
58}
59
60sub emit_symbols
61{
62 my $list = shift;
63 foreach my $symbol (@$list)
64 {
65 emit_symbol($symbol) unless exists $skip{$symbol};
66 }
67}
68
69skip_symbols [qw(
db15561c 70PL_statusvalue_vms
71PL_archpat_auto
72PL_cryptseen
73PL_DBcv
74PL_generation
db15561c 75PL_lastgotoprobe
76PL_linestart
77PL_modcount
78PL_pending_ident
79PL_sortcxix
80PL_sublex_info
81PL_timesbuf
0a753a76 82Perl_additem
83Perl_cast_ulong
84Perl_check_uni
85Perl_checkcomma
86Perl_chsize
87Perl_ck_aelem
0a753a76 88Perl_cx_dump
0a753a76 89Perl_do_ipcctl
90Perl_do_ipcget
91Perl_do_msgrcv
92Perl_do_msgsnd
93Perl_do_semop
94Perl_do_shmio
95Perl_doeval
96Perl_dofindlabel
97Perl_dopoptoeval
98Perl_dump_eval
99Perl_dump_fds
100Perl_dump_form
101Perl_dump_gv
102Perl_dump_mstats
103Perl_dump_op
104Perl_dump_packsubs
105Perl_dump_pm
106Perl_dump_sub
107Perl_expectterm
108Perl_fetch_gv
109Perl_fetch_io
110Perl_force_ident
111Perl_force_next
112Perl_force_word
113Perl_hv_stashpv
114Perl_intuit_more
d55594ae 115Perl_init_thread_intern
0a753a76 116Perl_know_next
117Perl_modkids
118Perl_mstats
119Perl_my_bzero
120Perl_my_htonl
121Perl_my_ntohl
122Perl_my_swap
123Perl_my_chsize
124Perl_newXSUB
125Perl_no_fh_allowed
126Perl_no_op
127Perl_nointrp
128Perl_nomem
129Perl_pp_cswitch
130Perl_pp_entersubr
131Perl_pp_evalonce
132Perl_pp_interp
133Perl_pp_map
134Perl_pp_nswitch
0a753a76 135Perl_reall_srchlen
0a753a76 136Perl_same_dirent
137Perl_saw_return
138Perl_scan_const
139Perl_scan_formline
140Perl_scan_heredoc
141Perl_scan_ident
142Perl_scan_inputsymbol
143Perl_scan_pat
144Perl_scan_prefix
145Perl_scan_str
146Perl_scan_subst
147Perl_scan_trans
148Perl_scan_word
68dc0745 149Perl_setenv_getix
0a753a76 150Perl_skipspace
76e3520e 151Perl_sort_mutex
0a753a76 152Perl_sublex_done
153Perl_sublex_start
0a753a76 154Perl_sv_ref
155Perl_sv_setptrobj
0a753a76 156Perl_too_few_arguments
157Perl_too_many_arguments
158Perl_unlnk
0a753a76 159Perl_watch
160Perl_yyname
161Perl_yyrule
162allgvs
163curblock
0a753a76 164curcsv
0a753a76 165lastretstr
166mystack_mark
167perl_init_ext
168perl_requirepv
0a753a76 169stack
0a753a76 170Perl_safexcalloc
171Perl_safexmalloc
172Perl_safexfree
173Perl_safexrealloc
68dc0745 174Perl_my_memcmp
8b10511d 175Perl_my_memset
db15561c 176PL_cshlen
177PL_cshname
178PL_opsave
22239a37 179)];
0a753a76 180
c69f112c 181
bbc8f9de 182if ($define{'MYMALLOC'})
183 {
22239a37 184 emit_symbols [qw(
185 Perl_malloc
f2517201 186 Perl_mfree
22239a37 187 Perl_realloc
188 Perl_calloc)];
bbc8f9de 189 }
32fcaa0b 190else
191 {
192 skip_symbols [qw(
193 Perl_malloced_size)];
194 }
bbc8f9de 195
d55594ae 196unless ($define{'USE_THREADS'})
197 {
22239a37 198 skip_symbols [qw(
db15561c 199PL_thr_key
200PL_sv_mutex
46124e9e 201PL_strtab_mutex
db15561c 202PL_svref_mutex
203PL_malloc_mutex
5ff3f7a4 204PL_cred_mutex
db15561c 205PL_eval_mutex
206PL_eval_cond
207PL_eval_owner
208PL_threads_mutex
209PL_nthreads
210PL_nthreads_cond
211PL_threadnum
212PL_threadsv_names
213PL_thrsv
22c35a8c 214PL_vtbl_mutex
eb480a0b 215Perl_getTHR
216Perl_setTHR
d55594ae 217Perl_condpair_magic
32f822de 218Perl_new_struct_thread
32f822de 219Perl_per_thread_magicals
d4cce5f1 220Perl_thread_create
221Perl_find_threadsv
d55594ae 222Perl_unlock_condpair
d55594ae 223Perl_magic_mutexfree
95906810 224)];
910dfcc8 225 }
d4cce5f1 226
910dfcc8 227unless ($define{'FAKE_THREADS'})
228 {
db15561c 229 skip_symbols [qw(PL_curthr)];
d55594ae 230 }
231
22239a37 232sub readvar
233{
234 my $file = shift;
235 open(VARS,$file) || die "Cannot open $file:$!";
236 my @syms;
237 while (<VARS>)
238 {
239 # All symbols have a Perl_ prefix because that's what embed.h
240 # sticks in front of them.
db15561c 241 push(@syms,"PL_".$1) if (/\bPERLVARI?C?\([IGT](\w+)/);
22239a37 242 }
243 close(VARS);
244 return \@syms;
245}
246
d4cce5f1 247if ($define{'USE_THREADS'} || $define{'MULTIPLICITY'})
d55594ae 248 {
22239a37 249 my $thrd = readvar("../thrdvar.h");
250 skip_symbols $thrd;
d55594ae 251 }
252
d4cce5f1 253if ($define{'MULTIPLICITY'})
d55594ae 254 {
22239a37 255 my $interp = readvar("../intrpvar.h");
256 skip_symbols $interp;
257 }
258
259if ($define{'PERL_GLOBAL_STRUCT'})
260 {
261 my $global = readvar("../perlvars.h");
262 skip_symbols $global;
852c2e52 263 emit_symbols [qw(Perl_GetVars)];
db15561c 264 emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
d4cce5f1 265 }
d55594ae 266
36c15d3f 267unless ($define{'DEBUGGING'})
268 {
22239a37 269 skip_symbols [qw(
fea7140c 270 Perl_deb
271 Perl_deb_growlevel
272 Perl_debop
273 Perl_debprofdump
274 Perl_debstack
275 Perl_debstackptrs
22239a37 276 Perl_runops_debug
277 Perl_sv_peek
3836fe67 278 PL_block_type
22c35a8c 279 PL_watchaddr
280 PL_watchok)];
36c15d3f 281 }
282
26618a56 283if ($define{'HAVE_DES_FCRYPT'})
284 {
285 emit_symbols [qw(win32_crypt)];
286 }
287
22c35a8c 288# functions from *.sym files
289
290for my $syms ('../global.sym','../pp.sym', '../globvar.sym')
22239a37 291 {
22c35a8c 292 open (GLOBAL, "<$syms") || die "failed to open $syms" . $!;
293 while (<GLOBAL>)
294 {
295 next if (!/^[A-Za-z]/);
296 # Functions have a Perl_ prefix
297 # Variables have a PL_ prefix
298 chomp($_);
299 my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "Perl_");
300 $symbol .= $_;
301 emit_symbol($symbol) unless exists $skip{$symbol};
302 }
303 close(GLOBAL);
22239a37 304 }
0a753a76 305
22c35a8c 306# variables
0a753a76 307
852c2e52 308unless ($define{'PERL_GLOBAL_STRUCT'})
22239a37 309 {
310 my $glob = readvar("../perlvars.h");
311 emit_symbols $glob;
312 }
313
314unless ($define{'MULTIPLICITY'})
315 {
316 my $glob = readvar("../intrpvar.h");
317 emit_symbols $glob;
318 }
0a753a76 319
22239a37 320unless ($define{'MULTIPLICITY'} || $define{'USE_THREADS'})
321 {
322 my $glob = readvar("../thrdvar.h");
323 emit_symbols $glob;
324 }
0a753a76 325
326while (<DATA>) {
327 my $symbol;
328 next if (!/^[A-Za-z]/);
329 next if (/^#/);
a868473f 330 s/\r//g;
22239a37 331 chomp($_);
0a753a76 332 $symbol = $_;
22239a37 333 next if exists $skip{$symbol};
3e3baf6d 334 emit_symbol($symbol);
335}
336
22239a37 337foreach my $symbol (sort keys %export)
338 {
ac4c12e7 339 output_symbol($symbol);
22239a37 340 }
341
342sub emit_symbol {
343 my $symbol = shift;
344 chomp($symbol);
345 $export{$symbol} = 1;
3e3baf6d 346}
0a753a76 347
ac4c12e7 348sub output_symbol {
349 my $symbol = shift;
350 if ($CCTYPE eq "BORLAND") {
351 # workaround Borland quirk by exporting both the straight
352 # name and a name with leading underscore. Note the
353 # alias *must* come after the symbol itself, if both
354 # are to be exported. (Linker bug?)
355 print "\t_$symbol\n";
356 print "\t$symbol = _$symbol\n";
357 }
358 elsif ($CCTYPE eq 'GCC') {
359 # Symbols have leading _ whole process is $%£"% slow
360 # so skip aliases for now
361 print "\t$symbol\n";
362 }
363 else {
364 # for binary coexistence, export both the symbol and
365 # alias with leading underscore
366 print "\t$symbol\n";
367 print "\t_$symbol = $symbol\n";
368 }
369}
370
0a753a76 3711;
372__DATA__
373# extra globals not included above.
374perl_init_i18nl10n
375perl_init_ext
376perl_alloc
4b556e6c 377perl_atexit
0a753a76 378perl_construct
379perl_destruct
380perl_free
381perl_parse
382perl_run
383perl_get_sv
384perl_get_av
385perl_get_hv
386perl_get_cv
387perl_call_argv
388perl_call_pv
389perl_call_method
390perl_call_sv
10dd38fc 391perl_require_pv
392perl_eval_pv
393perl_eval_sv
6dead956 394perl_new_ctype
395perl_new_collate
396perl_new_numeric
397perl_set_numeric_standard
398perl_set_numeric_local
d28b3ca3 399boot_DynaLoader
d55594ae 400Perl_thread_create
68dc0745 401win32_errno
96e4d5b1 402win32_environ
68dc0745 403win32_stdin
404win32_stdout
96e4d5b1 405win32_stderr
68dc0745 406win32_ferror
407win32_feof
408win32_strerror
409win32_fprintf
410win32_printf
411win32_vfprintf
96e4d5b1 412win32_vprintf
68dc0745 413win32_fread
414win32_fwrite
415win32_fopen
416win32_fdopen
417win32_freopen
418win32_fclose
419win32_fputs
420win32_fputc
421win32_ungetc
422win32_getc
423win32_fileno
424win32_clearerr
425win32_fflush
426win32_ftell
427win32_fseek
428win32_fgetpos
429win32_fsetpos
430win32_rewind
431win32_tmpfile
432win32_abort
433win32_fstat
96e4d5b1 434win32_stat
68dc0745 435win32_pipe
436win32_popen
437win32_pclose
e24c7c18 438win32_rename
68dc0745 439win32_setmode
96e4d5b1 440win32_lseek
441win32_tell
68dc0745 442win32_dup
443win32_dup2
96e4d5b1 444win32_open
445win32_close
446win32_eof
68dc0745 447win32_read
448win32_write
3e3baf6d 449win32_spawnvp
5aabfad6 450win32_mkdir
451win32_rmdir
452win32_chdir
c90c0ff4 453win32_flock
eb62e965 454win32_execv
6890e559 455win32_execvp
54310121 456win32_htons
457win32_ntohs
458win32_htonl
459win32_ntohl
460win32_inet_addr
461win32_inet_ntoa
462win32_socket
463win32_bind
464win32_listen
465win32_accept
466win32_connect
467win32_send
468win32_sendto
469win32_recv
470win32_recvfrom
471win32_shutdown
3a25acb4 472win32_closesocket
54310121 473win32_ioctlsocket
474win32_setsockopt
475win32_getsockopt
476win32_getpeername
477win32_getsockname
478win32_gethostname
479win32_gethostbyname
480win32_gethostbyaddr
481win32_getprotobyname
482win32_getprotobynumber
483win32_getservbyname
484win32_getservbyport
485win32_select
486win32_endhostent
487win32_endnetent
488win32_endprotoent
489win32_endservent
490win32_getnetent
491win32_getnetbyname
492win32_getnetbyaddr
493win32_getprotoent
494win32_getservent
495win32_sethostent
496win32_setnetent
497win32_setprotoent
498win32_setservent
ad2e33dc 499win32_getenv
84902520 500win32_perror
501win32_setbuf
502win32_setvbuf
503win32_flushall
504win32_fcloseall
505win32_fgets
506win32_gets
507win32_fgetc
508win32_putc
509win32_puts
510win32_getchar
511win32_putchar
512win32_malloc
513win32_calloc
514win32_realloc
515win32_free
f3986ebb 516win32_sleep
517win32_times
518win32_alarm
65e48ea9 519win32_open_osfhandle
520win32_get_osfhandle
f998180f 521win32_ioctl
ad0751ec 522win32_utime
22fae026 523win32_wait
f55ee38a 524win32_waitpid
525win32_kill
22fae026 526win32_str_os_error
ce2e26e5 527win32_opendir
528win32_readdir
529win32_telldir
530win32_seekdir
531win32_rewinddir
532win32_closedir
ad2e33dc 533Perl_win32_init
f3986ebb 534Perl_init_os_extras
9811a7d7 535Perl_getTHR
0fefa03b 536Perl_setTHR
84902520 537RunPerl
22239a37 538