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