This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[win32] tweak op.c to avoid warning
[perl5.git] / win32 / makedef.pl
CommitLineData
0a753a76
PP
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
GS
17my $CCTYPE = "MSVC"; # default
18
19while (@ARGV)
d55594ae
GS
20 {
21 my $flag = shift;
22 $define{$1} = 1 if ($flag =~ /^-D(\w+)$/);
910dfcc8 23 $CCTYPE = $1 if ($flag =~ /^CCTYPE=(\w+)$/);
d55594ae
GS
24 }
25
bbc8f9de
NIS
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
GS
33warn join(' ',keys %define)."\n";
34
04dc04aa
NIS
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
NIS
42else
43 {
44 $define{'PERL_GLOBAL_STRUCT'} = 1;
45 $define{'MULTIPLICITY'} = 1;
46 }
47
bbc8f9de
NIS
48print "EXPORTS\n";
49
22239a37
NIS
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
PP
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
PP
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
PP
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
PP
158Perl_skipspace
159Perl_sublex_done
160Perl_sublex_start
0a753a76
PP
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
PP
174lastretstr
175mystack_mark
176perl_init_ext
177perl_requirepv
0a753a76 178stack
ff0cee69 179statusvalue_vms
0a753a76
PP
180Perl_safexcalloc
181Perl_safexmalloc
182Perl_safexfree
183Perl_safexrealloc
68dc0745 184Perl_my_memcmp
8b10511d 185Perl_my_memset
68dc0745
PP
186Perl_cshlen
187Perl_cshname
0da3735a 188Perl_opsave
22239a37 189)];
0a753a76 190
c69f112c 191
bbc8f9de
NIS
192if ($define{'MYMALLOC'})
193 {
22239a37
NIS
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
NIS
204 }
205
d55594ae
GS
206unless ($define{'USE_THREADS'})
207 {
22239a37 208 skip_symbols [qw(
d55594ae
GS
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
GS
217Perl_new_struct_thread
218Perl_nthreads
d55594ae 219Perl_nthreads_cond
32f822de 220Perl_per_thread_magicals
d4cce5f1
NIS
221Perl_thread_create
222Perl_find_threadsv
223Perl_threadsv_names
32f822de 224Perl_thrsv
d55594ae
GS
225Perl_unlock_condpair
226Perl_vtbl_mutex
227Perl_magic_mutexfree
228Perl_sv_iv
229Perl_sv_nv
230Perl_sv_true
231Perl_sv_uv
232Perl_sv_pvn
22239a37 233Perl_newRV_noinc)];
910dfcc8 234 }
d4cce5f1 235
910dfcc8
GS
236unless ($define{'FAKE_THREADS'})
237 {
238 skip_symbols [qw(Perl_curthr)];
d55594ae
GS
239 }
240
22239a37
NIS
241sub readvar
242{
243 my $file = shift;
244 open(VARS,$file) || die "Cannot open $file:$!";
245 my @syms;
246 while (<VARS>)
247 {
248 # All symbols have a Perl_ prefix because that's what embed.h
249 # sticks in front of them.
83921c94 250 push(@syms,"Perl_".$1) if (/\bPERLVARI?C?\([IGT](\w+)/);
22239a37
NIS
251 }
252 close(VARS);
253 return \@syms;
254}
255
d4cce5f1 256if ($define{'USE_THREADS'} || $define{'MULTIPLICITY'})
d55594ae 257 {
22239a37
NIS
258 my $thrd = readvar("../thrdvar.h");
259 skip_symbols $thrd;
d55594ae
GS
260 }
261
d4cce5f1 262if ($define{'MULTIPLICITY'})
d55594ae 263 {
22239a37
NIS
264 my $interp = readvar("../intrpvar.h");
265 skip_symbols $interp;
266 }
267
268if ($define{'PERL_GLOBAL_STRUCT'})
269 {
270 my $global = readvar("../perlvars.h");
271 skip_symbols $global;
d4cce5f1 272 }
d55594ae 273
36c15d3f
NIS
274unless ($define{'DEBUGGING'})
275 {
22239a37
NIS
276 skip_symbols [qw(
277 Perl_runops_debug
278 Perl_sv_peek
279 Perl_watchaddr
280 Perl_watchok)];
36c15d3f
NIS
281 }
282
0a753a76 283open (GLOBAL, "<../global.sym") || die "failed to open global.sym" . $!;
22239a37
NIS
284while (<GLOBAL>)
285 {
286 next if (!/^[A-Za-z]/);
287 next if (/_amg[ \t]*$/);
288 # All symbols have a Perl_ prefix because that's what embed.h
289 # sticks in front of them.
290 chomp($_);
291 my $symbol = "Perl_$_";
292 emit_symbol($symbol) unless exists $skip{$symbol};
293 }
0a753a76
PP
294close(GLOBAL);
295
296# also add symbols from interp.sym
297# They are only needed if -DMULTIPLICITY is not set but it
298# doesn't hurt to include them anyway.
299# these don't have Perl prefix
300
22239a37
NIS
301if ($define{'PERL_GLOBAL_STRUCT'})
302 {
303 emit_symbol( ($CCTYPE eq 'GCC') ? 'Perl_GetVars' : 'Perl_VarsPtr')
304 }
305else
306 {
307 my $glob = readvar("../perlvars.h");
308 emit_symbols $glob;
309 }
310
311unless ($define{'MULTIPLICITY'})
312 {
313 my $glob = readvar("../intrpvar.h");
314 emit_symbols $glob;
315 }
0a753a76 316
22239a37
NIS
317unless ($define{'MULTIPLICITY'} || $define{'USE_THREADS'})
318 {
319 my $glob = readvar("../thrdvar.h");
320 emit_symbols $glob;
321 }
0a753a76
PP
322
323while (<DATA>) {
324 my $symbol;
325 next if (!/^[A-Za-z]/);
326 next if (/^#/);
a868473f 327 s/\r//g;
22239a37 328 chomp($_);
0a753a76 329 $symbol = $_;
22239a37 330 next if exists $skip{$symbol};
3e3baf6d
TB
331 emit_symbol($symbol);
332}
333
22239a37
NIS
334foreach my $symbol (sort keys %export)
335 {
3e3baf6d
TB
336 if ($CCTYPE eq "BORLAND") {
337 # workaround Borland quirk by exporting both the straight
84902520
TB
338 # name and a name with leading underscore. Note the
339 # alias *must* come after the symbol itself, if both
340 # are to be exported. (Linker bug?)
3e3baf6d 341 print "\t_$symbol\n";
84902520 342 print "\t$symbol = _$symbol\n";
3e3baf6d 343 }
22239a37
NIS
344 elsif ($CCTYPE eq 'GCC') {
345 # Symbols have leading _ whole process is $%£"% slow
346 # so skip aliases for now
347 print "\t$symbol\n";
348 }
3e3baf6d 349 else {
84902520
TB
350 # for binary coexistence, export both the symbol and
351 # alias with leading underscore
3e3baf6d 352 print "\t$symbol\n";
84902520 353 print "\t_$symbol = $symbol\n";
3e3baf6d 354 }
22239a37
NIS
355 }
356
357sub emit_symbol {
358 my $symbol = shift;
359 chomp($symbol);
360 $export{$symbol} = 1;
3e3baf6d 361}
0a753a76
PP
362
3631;
364__DATA__
365# extra globals not included above.
366perl_init_i18nl10n
367perl_init_ext
368perl_alloc
369perl_construct
370perl_destruct
371perl_free
372perl_parse
373perl_run
374perl_get_sv
375perl_get_av
376perl_get_hv
377perl_get_cv
378perl_call_argv
379perl_call_pv
380perl_call_method
381perl_call_sv
10dd38fc
GS
382perl_require_pv
383perl_eval_pv
384perl_eval_sv
d28b3ca3 385boot_DynaLoader
d55594ae 386Perl_thread_create
68dc0745 387win32_errno
96e4d5b1 388win32_environ
68dc0745
PP
389win32_stdin
390win32_stdout
96e4d5b1 391win32_stderr
68dc0745
PP
392win32_ferror
393win32_feof
394win32_strerror
395win32_fprintf
396win32_printf
397win32_vfprintf
96e4d5b1 398win32_vprintf
68dc0745
PP
399win32_fread
400win32_fwrite
401win32_fopen
402win32_fdopen
403win32_freopen
404win32_fclose
405win32_fputs
406win32_fputc
407win32_ungetc
408win32_getc
409win32_fileno
410win32_clearerr
411win32_fflush
412win32_ftell
413win32_fseek
414win32_fgetpos
415win32_fsetpos
416win32_rewind
417win32_tmpfile
418win32_abort
419win32_fstat
96e4d5b1 420win32_stat
68dc0745
PP
421win32_pipe
422win32_popen
423win32_pclose
424win32_setmode
96e4d5b1
PP
425win32_lseek
426win32_tell
68dc0745
PP
427win32_dup
428win32_dup2
96e4d5b1
PP
429win32_open
430win32_close
431win32_eof
68dc0745
PP
432win32_read
433win32_write
3e3baf6d 434win32_spawnvp
5aabfad6
PP
435win32_mkdir
436win32_rmdir
437win32_chdir
c90c0ff4 438win32_flock
6890e559 439win32_execvp
54310121
PP
440win32_htons
441win32_ntohs
442win32_htonl
443win32_ntohl
444win32_inet_addr
445win32_inet_ntoa
446win32_socket
447win32_bind
448win32_listen
449win32_accept
450win32_connect
451win32_send
452win32_sendto
453win32_recv
454win32_recvfrom
455win32_shutdown
3a25acb4 456win32_closesocket
54310121
PP
457win32_ioctlsocket
458win32_setsockopt
459win32_getsockopt
460win32_getpeername
461win32_getsockname
462win32_gethostname
463win32_gethostbyname
464win32_gethostbyaddr
465win32_getprotobyname
466win32_getprotobynumber
467win32_getservbyname
468win32_getservbyport
469win32_select
470win32_endhostent
471win32_endnetent
472win32_endprotoent
473win32_endservent
474win32_getnetent
475win32_getnetbyname
476win32_getnetbyaddr
477win32_getprotoent
478win32_getservent
479win32_sethostent
480win32_setnetent
481win32_setprotoent
482win32_setservent
ad2e33dc 483win32_getenv
84902520
TB
484win32_perror
485win32_setbuf
486win32_setvbuf
487win32_flushall
488win32_fcloseall
489win32_fgets
490win32_gets
491win32_fgetc
492win32_putc
493win32_puts
494win32_getchar
495win32_putchar
496win32_malloc
497win32_calloc
498win32_realloc
499win32_free
f3986ebb
GS
500win32_sleep
501win32_times
502win32_alarm
65e48ea9
GS
503win32_open_osfhandle
504win32_get_osfhandle
ad2e33dc 505Perl_win32_init
f3986ebb 506Perl_init_os_extras
9811a7d7 507Perl_getTHR
0fefa03b 508Perl_setTHR
84902520 509RunPerl
22239a37 510