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