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