[win32] Fix minor problems with non USE_THREADS build. win32 branch
[p5sagit/p5-mst-13.2.git] / win32 / makedef.pl
CommitLineData
0a753a76 1#!../miniperl
2
3# Written: 10 April 1996 Gary Ng (71564.1743@compuserve.com)
4
5# Create the export list for perl.
6# Needed by WIN32 for creating perl.dll
7# based on perl_exp.SH in the main perl distribution directory
8
9# This simple program relys on 'global.sym' being up to date
10# with all of the global symbols that a dynamicly link library
11# might want to access.
12
13# There is some symbol defined in global.sym and interp.sym
14# that does not present in the WIN32 port but there is no easy
84902520 15# way to find them so I just put a exception list here
0a753a76 16
910dfcc8 17my $CCTYPE = "MSVC"; # default
18
19while (@ARGV)
d55594ae 20 {
21 my $flag = shift;
22 $define{$1} = 1 if ($flag =~ /^-D(\w+)$/);
910dfcc8 23 $CCTYPE = $1 if ($flag =~ /^CCTYPE=(\w+)$/);
d55594ae 24 }
25
bbc8f9de 26open(CFG,'config.h') || die "Cannot open config.h:$!";
27while (<CFG>)
28 {
29 $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
30 }
31close(CFG);
32
d55594ae 33warn join(' ',keys %define)."\n";
34
04dc04aa 35if ($CCTYPE ne 'GCC')
36 {
37 print "LIBRARY Perl\n";
38 print "DESCRIPTION 'Perl interpreter, export autogenerated'\n";
39 print "CODE LOADONCALL\n";
40 print "DATA LOADONCALL NONSHARED MULTIPLE\n";
41 }
22239a37 42else
43 {
44 $define{'PERL_GLOBAL_STRUCT'} = 1;
45 $define{'MULTIPLICITY'} = 1;
46 }
47
bbc8f9de 48print "EXPORTS\n";
49
22239a37 50my %skip;
51my %export;
52
53sub skip_symbols
54{
55 my $list = shift;
56 foreach my $symbol (@$list)
57 {
58 $skip{$symbol} = 1;
59 }
60}
61
62sub emit_symbols
63{
64 my $list = shift;
65 foreach my $symbol (@$list)
66 {
67 emit_symbol($symbol) unless exists $skip{$symbol};
68 }
69}
70
71skip_symbols [qw(
72Perl_statusvalue_vms
0a753a76 73Perl_block_type
0a753a76 74Perl_additem
75Perl_cast_ulong
76Perl_check_uni
77Perl_checkcomma
78Perl_chsize
79Perl_ck_aelem
80Perl_cryptseen
81Perl_cx_dump
82Perl_deb
83Perl_deb_growlevel
84Perl_debop
85Perl_debprofdump
86Perl_debstack
87Perl_debstackptrs
88Perl_do_ipcctl
89Perl_do_ipcget
90Perl_do_msgrcv
91Perl_do_msgsnd
92Perl_do_semop
93Perl_do_shmio
94Perl_doeval
95Perl_dofindlabel
96Perl_dopoptoeval
97Perl_dump_eval
98Perl_dump_fds
99Perl_dump_form
100Perl_dump_gv
101Perl_dump_mstats
102Perl_dump_op
103Perl_dump_packsubs
104Perl_dump_pm
105Perl_dump_sub
106Perl_expectterm
107Perl_fetch_gv
108Perl_fetch_io
109Perl_force_ident
110Perl_force_next
111Perl_force_word
112Perl_hv_stashpv
113Perl_intuit_more
d55594ae 114Perl_init_thread_intern
0a753a76 115Perl_know_next
116Perl_modkids
117Perl_mstats
118Perl_my_bzero
119Perl_my_htonl
120Perl_my_ntohl
121Perl_my_swap
122Perl_my_chsize
123Perl_newXSUB
124Perl_no_fh_allowed
125Perl_no_op
126Perl_nointrp
127Perl_nomem
128Perl_pp_cswitch
129Perl_pp_entersubr
130Perl_pp_evalonce
131Perl_pp_interp
132Perl_pp_map
133Perl_pp_nswitch
134Perl_q
d55594ae 135Perl_rcsid
0a753a76 136Perl_reall_srchlen
137Perl_regdump
138Perl_regfold
139Perl_regmyendp
140Perl_regmyp_size
141Perl_regmystartp
142Perl_regnarrate
143Perl_regprop
144Perl_same_dirent
145Perl_saw_return
146Perl_scan_const
147Perl_scan_formline
148Perl_scan_heredoc
149Perl_scan_ident
150Perl_scan_inputsymbol
151Perl_scan_pat
152Perl_scan_prefix
153Perl_scan_str
154Perl_scan_subst
155Perl_scan_trans
156Perl_scan_word
68dc0745 157Perl_setenv_getix
0a753a76 158Perl_skipspace
159Perl_sublex_done
160Perl_sublex_start
0a753a76 161Perl_sv_ref
162Perl_sv_setptrobj
163Perl_timesbuf
164Perl_too_few_arguments
165Perl_too_many_arguments
166Perl_unlnk
167Perl_wait4pid
168Perl_watch
169Perl_yyname
170Perl_yyrule
171allgvs
172curblock
0a753a76 173curcsv
0a753a76 174lastretstr
175mystack_mark
176perl_init_ext
177perl_requirepv
0a753a76 178stack
ff0cee69 179statusvalue_vms
0a753a76 180Perl_safexcalloc
181Perl_safexmalloc
182Perl_safexfree
183Perl_safexrealloc
68dc0745 184Perl_my_memcmp
8b10511d 185Perl_my_memset
68dc0745 186Perl_cshlen
187Perl_cshname
0da3735a 188Perl_opsave
22239a37 189)];
0a753a76 190
c69f112c 191
bbc8f9de 192if ($define{'MYMALLOC'})
193 {
22239a37 194 skip_symbols [qw(
195 Perl_safefree
196 Perl_safemalloc
197 Perl_saferealloc
198 Perl_safecalloc)];
199 emit_symbols [qw(
200 Perl_malloc
201 Perl_free
202 Perl_realloc
203 Perl_calloc)];
bbc8f9de 204 }
205
d55594ae 206unless ($define{'USE_THREADS'})
207 {
22239a37 208 skip_symbols [qw(
d55594ae 209Perl_condpair_magic
210Perl_thr_key
211Perl_sv_mutex
212Perl_malloc_mutex
213Perl_eval_mutex
214Perl_eval_cond
215Perl_eval_owner
216Perl_threads_mutex
32f822de 217Perl_new_struct_thread
218Perl_nthreads
d55594ae 219Perl_nthreads_cond
32f822de 220Perl_per_thread_magicals
d4cce5f1 221Perl_thread_create
93bce2dc 222Perl_threadnum
d4cce5f1 223Perl_find_threadsv
224Perl_threadsv_names
32f822de 225Perl_thrsv
d55594ae 226Perl_unlock_condpair
227Perl_vtbl_mutex
228Perl_magic_mutexfree
229Perl_sv_iv
230Perl_sv_nv
231Perl_sv_true
232Perl_sv_uv
233Perl_sv_pvn
22239a37 234Perl_newRV_noinc)];
910dfcc8 235 }
d4cce5f1 236
910dfcc8 237unless ($define{'FAKE_THREADS'})
238 {
239 skip_symbols [qw(Perl_curthr)];
d55594ae 240 }
241
22239a37 242sub readvar
243{
244 my $file = shift;
245 open(VARS,$file) || die "Cannot open $file:$!";
246 my @syms;
247 while (<VARS>)
248 {
249 # All symbols have a Perl_ prefix because that's what embed.h
250 # sticks in front of them.
83921c94 251 push(@syms,"Perl_".$1) if (/\bPERLVARI?C?\([IGT](\w+)/);
22239a37 252 }
253 close(VARS);
254 return \@syms;
255}
256
d4cce5f1 257if ($define{'USE_THREADS'} || $define{'MULTIPLICITY'})
d55594ae 258 {
22239a37 259 my $thrd = readvar("../thrdvar.h");
260 skip_symbols $thrd;
d55594ae 261 }
262
d4cce5f1 263if ($define{'MULTIPLICITY'})
d55594ae 264 {
22239a37 265 my $interp = readvar("../intrpvar.h");
266 skip_symbols $interp;
267 }
268
269if ($define{'PERL_GLOBAL_STRUCT'})
270 {
271 my $global = readvar("../perlvars.h");
272 skip_symbols $global;
d4cce5f1 273 }
d55594ae 274
36c15d3f 275unless ($define{'DEBUGGING'})
276 {
22239a37 277 skip_symbols [qw(
278 Perl_runops_debug
279 Perl_sv_peek
280 Perl_watchaddr
281 Perl_watchok)];
36c15d3f 282 }
283
26618a56 284if ($define{'HAVE_DES_FCRYPT'})
285 {
286 emit_symbols [qw(win32_crypt)];
287 }
288
0a753a76 289open (GLOBAL, "<../global.sym") || die "failed to open global.sym" . $!;
22239a37 290while (<GLOBAL>)
291 {
292 next if (!/^[A-Za-z]/);
293 next if (/_amg[ \t]*$/);
294 # All symbols have a Perl_ prefix because that's what embed.h
295 # sticks in front of them.
296 chomp($_);
297 my $symbol = "Perl_$_";
298 emit_symbol($symbol) unless exists $skip{$symbol};
299 }
0a753a76 300close(GLOBAL);
301
302# also add symbols from interp.sym
303# They are only needed if -DMULTIPLICITY is not set but it
304# doesn't hurt to include them anyway.
305# these don't have Perl prefix
306
22239a37 307if ($define{'PERL_GLOBAL_STRUCT'})
308 {
309 emit_symbol( ($CCTYPE eq 'GCC') ? 'Perl_GetVars' : 'Perl_VarsPtr')
310 }
311else
312 {
313 my $glob = readvar("../perlvars.h");
314 emit_symbols $glob;
315 }
316
317unless ($define{'MULTIPLICITY'})
318 {
319 my $glob = readvar("../intrpvar.h");
320 emit_symbols $glob;
321 }
0a753a76 322
22239a37 323unless ($define{'MULTIPLICITY'} || $define{'USE_THREADS'})
324 {
325 my $glob = readvar("../thrdvar.h");
326 emit_symbols $glob;
327 }
0a753a76 328
329while (<DATA>) {
330 my $symbol;
331 next if (!/^[A-Za-z]/);
332 next if (/^#/);
a868473f 333 s/\r//g;
22239a37 334 chomp($_);
0a753a76 335 $symbol = $_;
22239a37 336 next if exists $skip{$symbol};
3e3baf6d 337 emit_symbol($symbol);
338}
339
22239a37 340foreach my $symbol (sort keys %export)
341 {
3e3baf6d 342 if ($CCTYPE eq "BORLAND") {
343 # workaround Borland quirk by exporting both the straight
84902520 344 # name and a name with leading underscore. Note the
345 # alias *must* come after the symbol itself, if both
346 # are to be exported. (Linker bug?)
3e3baf6d 347 print "\t_$symbol\n";
84902520 348 print "\t$symbol = _$symbol\n";
3e3baf6d 349 }
22239a37 350 elsif ($CCTYPE eq 'GCC') {
351 # Symbols have leading _ whole process is $%£"% slow
352 # so skip aliases for now
353 print "\t$symbol\n";
354 }
3e3baf6d 355 else {
84902520 356 # for binary coexistence, export both the symbol and
357 # alias with leading underscore
3e3baf6d 358 print "\t$symbol\n";
84902520 359 print "\t_$symbol = $symbol\n";
3e3baf6d 360 }
22239a37 361 }
362
363sub emit_symbol {
364 my $symbol = shift;
365 chomp($symbol);
366 $export{$symbol} = 1;
3e3baf6d 367}
0a753a76 368
3691;
370__DATA__
371# extra globals not included above.
372perl_init_i18nl10n
373perl_init_ext
374perl_alloc
375perl_construct
376perl_destruct
377perl_free
378perl_parse
379perl_run
380perl_get_sv
381perl_get_av
382perl_get_hv
383perl_get_cv
384perl_call_argv
385perl_call_pv
386perl_call_method
387perl_call_sv
10dd38fc 388perl_require_pv
389perl_eval_pv
390perl_eval_sv
d28b3ca3 391boot_DynaLoader
d55594ae 392Perl_thread_create
68dc0745 393win32_errno
96e4d5b1 394win32_environ
68dc0745 395win32_stdin
396win32_stdout
96e4d5b1 397win32_stderr
68dc0745 398win32_ferror
399win32_feof
400win32_strerror
401win32_fprintf
402win32_printf
403win32_vfprintf
96e4d5b1 404win32_vprintf
68dc0745 405win32_fread
406win32_fwrite
407win32_fopen
408win32_fdopen
409win32_freopen
410win32_fclose
411win32_fputs
412win32_fputc
413win32_ungetc
414win32_getc
415win32_fileno
416win32_clearerr
417win32_fflush
418win32_ftell
419win32_fseek
420win32_fgetpos
421win32_fsetpos
422win32_rewind
423win32_tmpfile
424win32_abort
425win32_fstat
96e4d5b1 426win32_stat
68dc0745 427win32_pipe
428win32_popen
429win32_pclose
430win32_setmode
96e4d5b1 431win32_lseek
432win32_tell
68dc0745 433win32_dup
434win32_dup2
96e4d5b1 435win32_open
436win32_close
437win32_eof
68dc0745 438win32_read
439win32_write
3e3baf6d 440win32_spawnvp
5aabfad6 441win32_mkdir
442win32_rmdir
443win32_chdir
c90c0ff4 444win32_flock
6890e559 445win32_execvp
54310121 446win32_htons
447win32_ntohs
448win32_htonl
449win32_ntohl
450win32_inet_addr
451win32_inet_ntoa
452win32_socket
453win32_bind
454win32_listen
455win32_accept
456win32_connect
457win32_send
458win32_sendto
459win32_recv
460win32_recvfrom
461win32_shutdown
3a25acb4 462win32_closesocket
54310121 463win32_ioctlsocket
464win32_setsockopt
465win32_getsockopt
466win32_getpeername
467win32_getsockname
468win32_gethostname
469win32_gethostbyname
470win32_gethostbyaddr
471win32_getprotobyname
472win32_getprotobynumber
473win32_getservbyname
474win32_getservbyport
475win32_select
476win32_endhostent
477win32_endnetent
478win32_endprotoent
479win32_endservent
480win32_getnetent
481win32_getnetbyname
482win32_getnetbyaddr
483win32_getprotoent
484win32_getservent
485win32_sethostent
486win32_setnetent
487win32_setprotoent
488win32_setservent
ad2e33dc 489win32_getenv
84902520 490win32_perror
491win32_setbuf
492win32_setvbuf
493win32_flushall
494win32_fcloseall
495win32_fgets
496win32_gets
497win32_fgetc
498win32_putc
499win32_puts
500win32_getchar
501win32_putchar
502win32_malloc
503win32_calloc
504win32_realloc
505win32_free
f3986ebb 506win32_sleep
507win32_times
508win32_alarm
65e48ea9 509win32_open_osfhandle
510win32_get_osfhandle
f998180f 511win32_ioctl
22fae026 512win32_wait
513win32_str_os_error
ad2e33dc 514Perl_win32_init
f3986ebb 515Perl_init_os_extras
9811a7d7 516Perl_getTHR
0fefa03b 517Perl_setTHR
84902520 518RunPerl
22239a37 519