spacesyms-c-gen.pl 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/perl
  2. #
  3. # spacesyms-c-gen.pl
  4. #
  5. # Output a C file that contains symbols matching the shell glob
  6. # sym{defaultver,longver,shortver}{nospace,SPACE}{default,hidden,protected,internal}
  7. # with symbol visibility matching the final element and at least one relocation
  8. # against each symbol.
  9. #
  10. # When used together with spacesyms-o-map.pl and spacesyms.map, makes a shared
  11. # object that contains symbols that covers all cases of:
  12. #
  13. # 1) has a short, long or Base version,
  14. # 2) has or does not have a space in the symbol name,
  15. # 3) default, hidden, protected or internal visibility.
  16. use strict;
  17. use warnings;
  18. my @symbols;
  19. foreach my $version (qw(defaultver longver shortver)) {
  20. foreach my $space (qw(nospace SPACE)) {
  21. foreach my $visibility (qw(default hidden protected internal)) {
  22. my $symbol = "sym$version$space$visibility";
  23. push @symbols, $symbol;
  24. print "void $symbol(void) __attribute__((visibility(\"$visibility\")));\n";
  25. print "void $symbol(void) {}\n";
  26. }
  27. }
  28. }
  29. print "void (*funcs[])(void) = {\n";
  30. foreach my $symbol (@symbols) {
  31. print "$symbol,\n";
  32. }
  33. print "};\n";