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