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