#!/usr/bin/perl # Copyright 2003, 2004, 2005 Red Hat, Inc. # # This file is part of Cygwin. # # This software is a copyrighted work licensed under the terms of the # Cygwin license. Please consult the file "CYGWIN_LICENSE" for # details. # use strict; sub nocr(@); my $in = shift; my $tls_offsets = shift; my $out = shift; my $sigfe = shift; $main::first = 0; if (!defined($in) || !defined($out) || !defined($sigfe)) { die "usage: $0 deffile.in cygtls.h deffile.def sigfe.s\n"; } require $tls_offsets; open(IN, $in) or die "$0: couldn't open \"$in\" - $!\n"; my @top = (); while () { push(@top, nocr $_); last if /^\s*exports\s*$/i; } my $libline = nocr scalar(); my @in = nocr ; close(IN); my %sigfe = (); my @data = (); my @nosigfuncs = (); my @out = (); for (@in) { /\sDATA$/o and do { push(@data, $_); next; }; chomp; if (/=/o) { if (s/\s+NOSIGFE\s*$//) { } elsif (s/ SIGFE$//) { my $func = (split(' '))[2]; $sigfe{$func} = '_sigfe_' . $func; } } else { my ($func, $sigfe) = m%^\s*(\S+)(?:\s+((?:NO)?SIGR?FE))?$%o; if (defined($sigfe) && $sigfe =~ /^NO/o) { $_ = $func; } else { $sigfe ||= 'sigfe'; $_ = '_' . lc($sigfe) . '_' . $func; $sigfe{$func} = $_; $_ = $func . ' = ' . $_; } } s/(\S)\s+(\S)/$1 $2/go; s/(\S)\s+$/$1/o; s/^\s+(\S)/$1/o; push(@out, $_ . "\n"); } for (@out) { my ($alias, $func) = /^(\S+) = (\S+)\s*$/o; $_ = $alias . ' = ' . $sigfe{$func} . "\n" if defined($func) && $sigfe{$func}; } open(OUT, '>', $out) or die "$0: couldn't open \"$out\" - $!\n"; print OUT @top, @data, @out; close OUT; open(SIGFE, '>', $sigfe) or die "$0: couldn't open sigfe file \"$sigfe\" - $!\n"; for my $k (sort keys %sigfe) { print SIGFE fefunc($k, $sigfe{$k}); } close SIGFE; sub fefunc { my $func = '_' . shift; my $fe = '_' . shift; my $extra; my $res = <