UINT64_C() work continues.
[p5sagit/p5-mst-13.2.git] / makedef.pl
1 #
2 # Create the export list for perl.
3 #
4 # Needed by WIN32 and OS/2 for creating perl.dll
5 # and by AIX for creating libperl.a when -Dusershrplib is in effect.
6 #
7 # reads global.sym, pp.sym, perlvars.h, intrpvar.h, thrdvar.h, config.h
8 # On OS/2 reads miniperl.map as well
9
10 my $PLATFORM;
11 my $CCTYPE;
12
13 my %bincompat5005 =
14       (
15        Perl_call_atexit         =>      "perl_atexit",
16        Perl_eval_sv             =>      "perl_eval_sv",
17        Perl_eval_pv             =>      "perl_eval_pv",
18        Perl_call_argv           =>      "perl_call_argv",
19        Perl_call_method         =>      "perl_call_method",
20        Perl_call_pv             =>      "perl_call_pv",
21        Perl_call_sv             =>      "perl_call_sv",
22        Perl_get_av              =>      "perl_get_av",
23        Perl_get_cv              =>      "perl_get_cv",
24        Perl_get_hv              =>      "perl_get_hv",
25        Perl_get_sv              =>      "perl_get_sv",
26        Perl_init_i18nl10n       =>      "perl_init_i18nl10n",
27        Perl_init_i18nl14n       =>      "perl_init_i18nl14n",
28        Perl_new_collate         =>      "perl_new_collate",
29        Perl_new_ctype           =>      "perl_new_ctype",
30        Perl_new_numeric         =>      "perl_new_numeric",
31        Perl_require_pv          =>      "perl_require_pv",
32        Perl_safesyscalloc       =>      "Perl_safecalloc",
33        Perl_safesysfree         =>      "Perl_safefree",
34        Perl_safesysmalloc       =>      "Perl_safemalloc",
35        Perl_safesysrealloc      =>      "Perl_saferealloc",
36        Perl_set_numeric_local   =>      "perl_set_numeric_local",
37        Perl_set_numeric_standard  =>    "perl_set_numeric_standard",
38        Perl_malloc              =>      "malloc",
39        Perl_mfree               =>      "free",
40        Perl_realloc             =>      "realloc",
41        Perl_calloc              =>      "calloc",
42       );
43
44 my $bincompat5005 = join("|", keys %bincompat5005);
45
46 while (@ARGV) {
47     my $flag = shift;
48     $define{$1} = 1 if ($flag =~ /^-D(\w+)$/);
49     $define{$1} = $2 if ($flag =~ /^-D(\w+)=(.+)$/);
50     $CCTYPE   = $1 if ($flag =~ /^CCTYPE=(\w+)$/);
51     $PLATFORM = $1 if ($flag =~ /^PLATFORM=(\w+)$/);
52 }
53
54 my @PLATFORM = qw(aix win32 os2);
55 my %PLATFORM;
56 @PLATFORM{@PLATFORM} = ();
57
58 defined $PLATFORM || die "PLATFORM undefined, must be one of: @PLATFORM\n";
59 exists $PLATFORM{$PLATFORM} || die "PLATFORM must be one of: @PLATFORM\n"; 
60
61 my $config_sh   = "config.sh";
62 my $config_h    = "config.h";
63 my $thrdvar_h   = "thrdvar.h";
64 my $intrpvar_h  = "intrpvar.h";
65 my $perlvars_h  = "perlvars.h";
66 my $global_sym  = "global.sym";
67 my $pp_sym      = "pp.sym";
68 my $globvar_sym = "globvar.sym";
69 my $perlio_sym  = "perlio.sym";
70
71 if ($PLATFORM eq 'aix') { 
72     # Nothing for now.
73 }
74 elsif ($PLATFORM eq 'win32') {
75     $CCTYPE = "MSVC" unless defined $CCTYPE;
76     foreach ($thrdvar_h, $intrpvar_h, $perlvars_h, $global_sym,
77                 $pp_sym, $globvar_sym, $perlio_sym) {
78         s!^!..\\!;
79     }
80 }
81
82 unless ($PLATFORM eq 'win32') {
83     open(CFG,$config_sh) || die "Cannot open $config_sh: $!\n";
84     while (<CFG>) {
85         if (/^(?:ccflags|optimize)='(.+)'$/) {
86             $_ = $1;
87             $define{$1} = 1 while /-D(\w+)/g;
88         }
89         if ($PLATFORM eq 'os2') {
90             $CONFIG_ARGS = $1 if /^(?:config_args)='(.+)'$/;
91             $ARCHNAME = $1 if /^(?:archname)='(.+)'$/;
92         }
93     }
94     close(CFG);
95 }
96
97 open(CFG,$config_h) || die "Cannot open $config_h: $!\n";
98 while (<CFG>) {
99     $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
100     $define{$1} = 1 if /^\s*#\s*define\s+(USE_5005THREADS)\b/;
101     $define{$1} = 1 if /^\s*#\s*define\s+(USE_ITHREADS)\b/;
102     $define{$1} = 1 if /^\s*#\s*define\s+(USE_PERLIO)\b/;
103     $define{$1} = 1 if /^\s*#\s*define\s+(MULTIPLICITY)\b/;
104     $define{$1} = 1 if /^\s*#\s*define\s+(PERL_IMPLICIT_SYS)\b/;
105     $define{$1} = 1 if /^\s*#\s*define\s+(PERL_BINCOMPAT_5005)\b/;
106 }
107 close(CFG);
108
109 # perl.h logic duplication begins
110
111 if ($define{USE_ITHREADS}) {
112     if (!$define{MULTIPLICITY} && !$define{PERL_OBJECT}) {
113         $define{MULTIPLICITY} = 1;
114     }
115 }
116
117 $define{PERL_IMPLICIT_CONTEXT} ||=
118     $define{USE_ITHREADS} ||
119     $define{USE_5005THREADS}  ||
120     $define{MULTIPLICITY} ;
121
122 if ($define{PERL_CAPI}) {
123     delete $define{PERL_OBJECT};
124     $define{MULTIPLICITY} = 1; 
125     $define{PERL_IMPLICIT_CONTEXT} = 1;
126     $define{PERL_IMPLICIT_SYS}     = 1;
127 }
128
129 if ($define{PERL_OBJECT}) {
130     $define{PERL_IMPLICIT_CONTEXT} = 1;
131     $define{PERL_IMPLICIT_SYS}     = 1;
132 }
133
134 # perl.h logic duplication ends
135
136 if ($PLATFORM eq 'win32') {
137     warn join(' ',keys %define)."\n";
138     print "LIBRARY Perl56\n";
139     print "DESCRIPTION 'Perl interpreter'\n";
140     print "EXPORTS\n";
141     if ($define{PERL_IMPLICIT_SYS}) {
142         output_symbol("perl_get_host_info");
143         output_symbol("perl_alloc_override");
144     }
145 }
146 elsif ($PLATFORM eq 'os2') {
147     ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
148     $v .= '-thread' if $ARCHNAME =~ /-thread/;
149     #$sum = 0;
150     #for (split //, $v) {
151     #   $sum = ($sum * 33) + ord;
152     #   $sum &= 0xffffff;
153     #}
154     #$sum += $sum >> 5;
155     #$sum &= 0xffff;
156     #$sum = printf '%X', $sum;
157     ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
158     # print STDERR "'$dll' <= '$define{PERL_DLL}'\n";
159     print <<"---EOP---";
160 LIBRARY '$dll' INITINSTANCE TERMINSTANCE
161 DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter'
162 STACKSIZE 32768
163 CODE LOADONCALL
164 DATA LOADONCALL NONSHARED MULTIPLE
165 EXPORTS
166 ---EOP---
167 }
168 elsif ($PLATFORM eq 'aix') {
169     print "#!\n";
170 }
171
172 my %skip;
173 my %export;
174
175 sub skip_symbols {
176     my $list = shift;
177     foreach my $symbol (@$list) {
178         $skip{$symbol} = 1;
179     }
180 }
181
182 sub emit_symbols {
183     my $list = shift;
184     foreach my $symbol (@$list) {
185         my $skipsym = $symbol;
186         # XXX hack
187         if ($define{PERL_OBJECT} || $define{MULTIPLICITY}) {
188             $skipsym =~ s/^Perl_[GIT](\w+)_ptr$/PL_$1/;
189         }
190         emit_symbol($symbol) unless exists $skip{$skipsym};
191     }
192 }
193
194 if ($PLATFORM eq 'win32') {
195     skip_symbols [qw(
196                      PL_statusvalue_vms
197                      PL_archpat_auto
198                      PL_cryptseen
199                      PL_DBcv
200                      PL_generation
201                      PL_lastgotoprobe
202                      PL_linestart
203                      PL_modcount
204                      PL_pending_ident
205                      PL_sortcxix
206                      PL_sublex_info
207                      PL_timesbuf
208                      main
209                      Perl_ErrorNo
210                      Perl_GetVars
211                      Perl_do_exec3
212                      Perl_do_ipcctl
213                      Perl_do_ipcget
214                      Perl_do_msgrcv
215                      Perl_do_msgsnd
216                      Perl_do_semop
217                      Perl_do_shmio
218                      Perl_dump_fds
219                      Perl_init_thread_intern
220                      Perl_my_bzero
221                      Perl_my_htonl
222                      Perl_my_ntohl
223                      Perl_my_swap
224                      Perl_my_chsize
225                      Perl_same_dirent
226                      Perl_setenv_getix
227                      Perl_unlnk
228                      Perl_watch
229                      Perl_safexcalloc
230                      Perl_safexmalloc
231                      Perl_safexfree
232                      Perl_safexrealloc
233                      Perl_my_memcmp
234                      Perl_my_memset
235                      PL_cshlen
236                      PL_cshname
237                      PL_opsave
238                      Perl_do_exec
239                      Perl_getenv_len
240                      Perl_my_pclose
241                      Perl_my_popen
242                      )];
243 }
244 elsif ($PLATFORM eq 'aix') {
245     skip_symbols([qw(
246                      Perl_dump_fds
247                      Perl_ErrorNo
248                      Perl_GetVars
249                      Perl_my_bcopy
250                      Perl_my_bzero
251                      Perl_my_chsize
252                      Perl_my_htonl
253                      Perl_my_memcmp
254                      Perl_my_memset
255                      Perl_my_ntohl
256                      Perl_my_swap
257                      Perl_safexcalloc
258                      Perl_safexfree
259                      Perl_safexmalloc
260                      Perl_safexrealloc
261                      Perl_same_dirent
262                      Perl_unlnk
263                      Perl_sys_intern_clear
264                      Perl_sys_intern_dup
265                      Perl_sys_intern_init
266                      PL_cryptseen
267                      PL_opsave
268                      PL_statusvalue_vms
269                      PL_sys_intern
270                      )]);
271 }
272 elsif ($PLATFORM eq 'os2') {
273     emit_symbols([qw(
274                     ctermid
275                     get_sysinfo
276                     Perl_OS2_init
277                     OS2_Perl_data
278                     dlopen
279                     dlsym
280                     dlerror
281                     dlclose
282                     my_tmpfile
283                     my_tmpnam
284                     my_flock
285                     malloc_mutex
286                     threads_mutex
287                     nthreads
288                     nthreads_cond
289                     os2_cond_wait
290                     os2_stat
291                     pthread_join
292                     pthread_create
293                     pthread_detach
294                     XS_Cwd_change_drive
295                     XS_Cwd_current_drive
296                     XS_Cwd_extLibpath
297                     XS_Cwd_extLibpath_set
298                     XS_Cwd_sys_abspath
299                     XS_Cwd_sys_chdir
300                     XS_Cwd_sys_cwd
301                     XS_Cwd_sys_is_absolute
302                     XS_Cwd_sys_is_relative
303                     XS_Cwd_sys_is_rooted
304                     XS_DynaLoader_mod2fname
305                     XS_File__Copy_syscopy
306                     Perl_Register_MQ
307                     Perl_Deregister_MQ
308                     Perl_Serve_Messages
309                     Perl_Process_Messages
310                     init_PMWIN_entries
311                     PMWIN_entries
312                     Perl_hab_GET
313                     )]);
314 }
315
316 unless ($define{'DEBUGGING'}) {
317     skip_symbols [qw(
318                     Perl_deb
319                     Perl_deb_growlevel
320                     Perl_debop
321                     Perl_debprofdump
322                     Perl_debstack
323                     Perl_debstackptrs
324                     Perl_runops_debug
325                     Perl_sv_peek
326                     PL_block_type
327                     PL_watchaddr
328                     PL_watchok
329                     )];
330 }
331
332 if ($define{'PERL_IMPLICIT_SYS'}) {
333     skip_symbols [qw(
334                     Perl_getenv_len
335                     Perl_my_popen
336                     Perl_my_pclose
337                     )];
338 }
339 else {
340     skip_symbols [qw(
341                     PL_Mem
342                     PL_MemShared
343                     PL_MemParse
344                     PL_Env
345                     PL_StdIO
346                     PL_LIO
347                     PL_Dir
348                     PL_Sock
349                     PL_Proc
350                     )];
351 }
352
353 unless ($define{'PERL_FLEXIBLE_EXCEPTIONS'}) {
354     skip_symbols [qw(
355                     PL_protect
356                     Perl_default_protect
357                     Perl_vdefault_protect
358                     )];
359 }
360
361 if ($define{'MYMALLOC'}) {
362     emit_symbols [qw(
363                     Perl_dump_mstats
364                     Perl_get_mstats
365                     Perl_malloc
366                     Perl_mfree
367                     Perl_realloc
368                     Perl_calloc
369                     )];
370     if ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
371         emit_symbols [qw(
372                         PL_malloc_mutex
373                         )];
374     }
375     else {
376         skip_symbols [qw(
377                         PL_malloc_mutex
378                         )];
379     }
380 }
381 else {
382     skip_symbols [qw(
383                     PL_malloc_mutex
384                     Perl_dump_mstats
385                     Perl_get_mstats
386                     Perl_malloc
387                     Perl_mfree
388                     Perl_realloc
389                     Perl_calloc
390                     Perl_malloced_size
391                     )];
392 }
393
394 unless ($define{'USE_5005THREADS'} || $define{'USE_ITHREADS'}) {
395     skip_symbols [qw(
396                     PL_thr_key
397                     )];
398 }
399
400 unless ($define{'USE_5005THREADS'}) {
401     skip_symbols [qw(
402                     PL_sv_mutex
403                     PL_strtab_mutex
404                     PL_svref_mutex
405                     PL_cred_mutex
406                     PL_eval_mutex
407                     PL_fdpid_mutex
408                     PL_sv_lock_mutex
409                     PL_eval_cond
410                     PL_eval_owner
411                     PL_threads_mutex
412                     PL_nthreads
413                     PL_nthreads_cond
414                     PL_threadnum
415                     PL_threadsv_names
416                     PL_thrsv
417                     PL_vtbl_mutex
418                     Perl_condpair_magic
419                     Perl_new_struct_thread
420                     Perl_per_thread_magicals
421                     Perl_thread_create
422                     Perl_find_threadsv
423                     Perl_unlock_condpair
424                     Perl_magic_mutexfree
425                     Perl_sv_lock
426                     )];
427 }
428
429 unless ($define{'USE_ITHREADS'}) {
430     skip_symbols [qw(
431                     PL_ptr_table
432                     PL_op_mutex
433                     Perl_dirp_dup
434                     Perl_cx_dup
435                     Perl_si_dup
436                     Perl_any_dup
437                     Perl_ss_dup
438                     Perl_fp_dup
439                     Perl_gp_dup
440                     Perl_he_dup
441                     Perl_mg_dup
442                     Perl_re_dup
443                     Perl_sv_dup
444                     Perl_sys_intern_dup
445                     Perl_ptr_table_fetch
446                     Perl_ptr_table_new
447                     Perl_ptr_table_split
448                     Perl_ptr_table_store
449                     perl_clone
450                     perl_clone_using
451                     )];
452 }
453
454 unless ($define{'PERL_IMPLICIT_CONTEXT'}) {
455     skip_symbols [qw(
456                     Perl_croak_nocontext
457                     Perl_die_nocontext
458                     Perl_deb_nocontext
459                     Perl_form_nocontext
460                     Perl_load_module_nocontext
461                     Perl_mess_nocontext
462                     Perl_warn_nocontext
463                     Perl_warner_nocontext
464                     Perl_newSVpvf_nocontext
465                     Perl_sv_catpvf_nocontext
466                     Perl_sv_setpvf_nocontext
467                     Perl_sv_catpvf_mg_nocontext
468                     Perl_sv_setpvf_mg_nocontext
469                     )];
470 }
471
472 unless ($define{'PERL_IMPLICIT_SYS'}) {
473     skip_symbols [qw(
474                     perl_alloc_using
475                     perl_clone_using
476                     )];
477 }
478
479 unless ($define{'FAKE_THREADS'}) {
480     skip_symbols [qw(PL_curthr)];
481 }
482
483 sub readvar {
484     my $file = shift;
485     my $proc = shift || sub { "PL_$_[2]" };
486     open(VARS,$file) || die "Cannot open $file: $!\n";
487     my @syms;
488     while (<VARS>) {
489         # All symbols have a Perl_ prefix because that's what embed.h
490         # sticks in front of them.
491         push(@syms, &$proc($1,$2,$3)) if (/\bPERLVAR(A?I?C?)\(([IGT])(\w+)/);
492     } 
493     close(VARS); 
494     return \@syms;
495 }
496
497 if ($define{'USE_5005THREADS'}) {
498     my $thrd = readvar($thrdvar_h);
499     skip_symbols $thrd;
500 }
501
502 if ($define{'PERL_GLOBAL_STRUCT'}) {
503     my $global = readvar($perlvars_h);
504     skip_symbols $global;
505     emit_symbol('Perl_GetVars');
506     emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
507 }
508
509 # functions from *.sym files
510
511 my @syms = ($global_sym, $globvar_sym); # $pp_sym is not part of the API
512
513 if ($define{'USE_PERLIO'}) {
514      push @syms, $perlio_sym;
515 }
516
517 for my $syms (@syms) {
518     open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
519     while (<GLOBAL>) {
520         next if (!/^[A-Za-z]/);
521         # Functions have a Perl_ prefix
522         # Variables have a PL_ prefix
523         chomp($_);
524         my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
525         $symbol .= $_;
526         emit_symbol($symbol) unless exists $skip{$symbol};
527     }
528     close(GLOBAL);
529 }
530
531 # variables
532
533 if ($define{'PERL_OBJECT'} || $define{'MULTIPLICITY'}) {
534     for my $f ($perlvars_h, $intrpvar_h, $thrdvar_h) {
535         my $glob = readvar($f, sub { "Perl_" . $_[1] . $_[2] . "_ptr" });
536         emit_symbols $glob;
537     }
538     # XXX AIX seems to want the perlvars.h symbols, for some reason
539     if ($PLATFORM eq 'aix') {
540         my $glob = readvar($perlvars_h);
541         emit_symbols $glob;
542     }
543 }
544 else {
545     unless ($define{'PERL_GLOBAL_STRUCT'}) {
546         my $glob = readvar($perlvars_h);
547         emit_symbols $glob;
548     } 
549     unless ($define{'MULTIPLICITY'}) {
550         my $glob = readvar($intrpvar_h);
551         emit_symbols $glob;
552     } 
553     unless ($define{'MULTIPLICITY'} || $define{'USE_5005THREADS'}) {
554         my $glob = readvar($thrdvar_h);
555         emit_symbols $glob;
556     } 
557 }
558
559 sub try_symbol {
560     my $symbol = shift;
561
562     return if $symbol !~ /^[A-Za-z]/;
563     return if $symbol =~ /^\#/;
564     $symbol =~s/\r//g;
565     chomp($symbol);
566     return if exists $skip{$symbol};
567     emit_symbol($symbol);
568 }
569
570 while (<DATA>) {
571     try_symbol($_);
572 }
573
574 if ($PLATFORM eq 'win32') {
575     foreach my $symbol (qw(
576                             setuid
577                             setgid
578                             boot_DynaLoader
579                             Perl_init_os_extras
580                             Perl_thread_create
581                             Perl_win32_init
582                             RunPerl
583                             win32_errno
584                             win32_environ
585                             win32_abort
586                             win32_fstat
587                             win32_stat
588                             win32_pipe
589                             win32_popen
590                             win32_pclose
591                             win32_rename
592                             win32_setmode
593                             win32_lseek
594                             win32_tell
595                             win32_dup
596                             win32_dup2
597                             win32_open
598                             win32_close
599                             win32_eof
600                             win32_read
601                             win32_write
602                             win32_spawnvp
603                             win32_mkdir
604                             win32_rmdir
605                             win32_chdir
606                             win32_flock
607                             win32_execv
608                             win32_execvp
609                             win32_htons
610                             win32_ntohs
611                             win32_htonl
612                             win32_ntohl
613                             win32_inet_addr
614                             win32_inet_ntoa
615                             win32_socket
616                             win32_bind
617                             win32_listen
618                             win32_accept
619                             win32_connect
620                             win32_send
621                             win32_sendto
622                             win32_recv
623                             win32_recvfrom
624                             win32_shutdown
625                             win32_closesocket
626                             win32_ioctlsocket
627                             win32_setsockopt
628                             win32_getsockopt
629                             win32_getpeername
630                             win32_getsockname
631                             win32_gethostname
632                             win32_gethostbyname
633                             win32_gethostbyaddr
634                             win32_getprotobyname
635                             win32_getprotobynumber
636                             win32_getservbyname
637                             win32_getservbyport
638                             win32_select
639                             win32_endhostent
640                             win32_endnetent
641                             win32_endprotoent
642                             win32_endservent
643                             win32_getnetent
644                             win32_getnetbyname
645                             win32_getnetbyaddr
646                             win32_getprotoent
647                             win32_getservent
648                             win32_sethostent
649                             win32_setnetent
650                             win32_setprotoent
651                             win32_setservent
652                             win32_getenv
653                             win32_putenv
654                             win32_perror
655                             win32_malloc
656                             win32_calloc
657                             win32_realloc
658                             win32_free
659                             win32_sleep
660                             win32_times
661                             win32_access
662                             win32_alarm
663                             win32_chmod
664                             win32_open_osfhandle
665                             win32_get_osfhandle
666                             win32_ioctl
667                             win32_link
668                             win32_unlink
669                             win32_utime
670                             win32_uname
671                             win32_wait
672                             win32_waitpid
673                             win32_kill
674                             win32_str_os_error
675                             win32_opendir
676                             win32_readdir
677                             win32_telldir
678                             win32_seekdir
679                             win32_rewinddir
680                             win32_closedir
681                             win32_longpath
682                             win32_os_id
683                             win32_getpid
684                             win32_crypt
685                             win32_dynaload
686
687                             win32_stdin
688                             win32_stdout
689                             win32_stderr
690                             win32_ferror
691                             win32_feof
692                             win32_strerror
693                             win32_fprintf
694                             win32_printf
695                             win32_vfprintf
696                             win32_vprintf
697                             win32_fread
698                             win32_fwrite
699                             win32_fopen
700                             win32_fdopen
701                             win32_freopen
702                             win32_fclose
703                             win32_fputs
704                             win32_fputc
705                             win32_ungetc
706                             win32_getc
707                             win32_fileno
708                             win32_clearerr
709                             win32_fflush
710                             win32_ftell
711                             win32_fseek
712                             win32_fgetpos
713                             win32_fsetpos
714                             win32_rewind
715                             win32_tmpfile
716                             win32_setbuf
717                             win32_setvbuf
718                             win32_flushall
719                             win32_fcloseall
720                             win32_fgets
721                             win32_gets
722                             win32_fgetc
723                             win32_putc
724                             win32_puts
725                             win32_getchar
726                             win32_putchar
727                            ))
728     {
729         try_symbol($symbol);
730     }
731 }
732 elsif ($PLATFORM eq 'os2') {
733     open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
734     /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
735     close MAP or die 'Cannot close miniperl.map';
736
737     @missing = grep { !exists $mapped{$_} and !exists $bincompat5005{$_} }
738                     keys %export;
739     delete $export{$_} foreach @missing;
740 }
741
742 # Now all symbols should be defined because
743 # next we are going to output them.
744
745 foreach my $symbol (sort keys %export) {
746     output_symbol($symbol);
747 }
748
749 sub emit_symbol {
750     my $symbol = shift;
751     chomp($symbol); 
752     $export{$symbol} = 1;
753 }
754
755 sub output_symbol {
756     my $symbol = shift;
757     $symbol = $bincompat5005{$symbol}
758         if $define{PERL_BINCOMPAT_5005} and $symbol =~ /^($bincompat5005)$/;
759     if ($PLATFORM eq 'win32') {
760         $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
761         print "\t$symbol\n";
762 # XXX: binary compatibility between compilers is an exercise
763 # in frustration :-(
764 #        if ($CCTYPE eq "BORLAND") {
765 #           # workaround Borland quirk by exporting both the straight
766 #           # name and a name with leading underscore.  Note the
767 #           # alias *must* come after the symbol itself, if both
768 #           # are to be exported. (Linker bug?)
769 #           print "\t_$symbol\n";
770 #           print "\t$symbol = _$symbol\n";
771 #       }
772 #       elsif ($CCTYPE eq 'GCC') {
773 #           # Symbols have leading _ whole process is $%@"% slow
774 #           # so skip aliases for now
775 #           nprint "\t$symbol\n";
776 #       }
777 #       else {
778 #           # for binary coexistence, export both the symbol and
779 #           # alias with leading underscore
780 #           print "\t$symbol\n";
781 #           print "\t_$symbol = $symbol\n";
782 #       }
783     }
784     elsif ($PLATFORM eq 'os2') {
785         print qq(    "$symbol"\n);
786     }
787     elsif ($PLATFORM eq 'aix') {
788         print "$symbol\n";
789     }
790 }
791
792 1;
793 __DATA__
794 # extra globals not included above.
795 perl_alloc
796 perl_alloc_using
797 perl_clone
798 perl_clone_using
799 perl_construct
800 perl_destruct
801 perl_free
802 perl_parse
803 perl_run