- # Remaining remnants that _may_ be functions
- # are handled in <DATA>
-}
-
-for my $syms (@syms) {
- open (GLOBAL, "<$syms") || die "failed to open $syms: $!\n";
- while (<GLOBAL>) {
- next if (!/^[A-Za-z]/);
- # Functions have a Perl_ prefix
- # Variables have a PL_ prefix
- chomp($_);
- my $symbol = ($syms =~ /var\.sym$/i ? "PL_" : "");
- $symbol .= $_;
- emit_symbol($symbol) unless exists $skip{$symbol};
+ # Remaining remnants that _may_ be functions are handled below.
+}
+
+###############################################################################
+
+# At this point all skip lists should be completed, as we are about to test
+# many symbols against them.
+
+{
+ my %seen;
+ my ($embed) = setup_embed($ARGS{TARG_DIR});
+
+ foreach (@$embed) {
+ my ($flags, $retval, $func, @args) = @$_;
+ next unless $func;
+ if ($flags =~ /[AX]/ && $flags !~ /[xmi]/ || $flags =~ /b/) {
+ # public API, so export
+
+ # If a function is defined twice, for example before and after
+ # an #else, only export its name once. Important to do this test
+ # within the block, as the *first* definition may have flags which
+ # mean "don't export"
+ next if $seen{$func}++;
+ # Should we also skip adding the Perl_ prefix if $flags =~ /o/ ?
+ $func = "Perl_$func" if ($flags =~ /[pbX]/ && $func !~ /^Perl_/);
+ ++$export{$func} unless exists $skip{$func};
+ }
+ }
+}
+
+foreach (@syms) {
+ my $syms = $ARGS{TARG_DIR} . $_;
+ open my $global, '<', $syms or die "failed to open $syms: $!\n";
+ # Functions already have a Perl_ prefix
+ # Variables need a PL_ prefix
+ my $prefix = $syms =~ /var\.sym$/i ? 'PL_' : '';
+ while (<$global>) {
+ next unless /^([A-Za-z].*)/;
+ my $symbol = "$prefix$1";
+ ++$export{$symbol} unless exists $skip{$symbol};