msvcrt: Import acosf from musl.
[wine.git] / tools / winapi / nativeapi.pm
blobbc58d96eb4d562612d0096782f51d51f3482c745
2 # Copyright 1999, 2000, 2001 Patrik Stridvall
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 package nativeapi;
21 use strict;
22 use warnings 'all';
24 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
25 require Exporter;
27 @ISA = qw(Exporter);
28 @EXPORT = qw();
29 @EXPORT_OK = qw($nativeapi);
31 use vars qw($nativeapi);
33 use config qw(file_type $current_dir $wine_dir $winapi_dir);
34 use options qw($options);
35 use output qw($output);
37 $nativeapi = 'nativeapi'->new;
39 sub new($) {
40 my $proto = shift;
41 my $class = ref($proto) || $proto;
42 my $self = {};
43 bless ($self, $class);
45 my $functions = \%{$self->{FUNCTIONS}};
46 my $conditionals = \%{$self->{CONDITIONALS}};
47 my $conditional_headers = \%{$self->{CONDITIONAL_HEADERS}};
48 my $conditional_functions = \%{$self->{CONDITIONAL_FUNCTIONS}};
50 my $api_file = "$winapi_dir/nativeapi.dat";
51 my $configure_ac_file = "$wine_dir/configure.ac";
52 my $config_h_in_file = "$wine_dir/include/config.h.in";
54 $api_file =~ s/^\.\///;
55 $configure_ac_file =~ s/^\.\///;
56 $config_h_in_file =~ s/^\.\///;
59 $$conditional_headers{"config.h"}++;
61 $output->progress("$api_file");
63 open(IN, "< $api_file") || die "Error: Can't open $api_file: $!\n";
64 local $/ = "\n";
65 while(<IN>) {
66 s/^\s*(.*?)\s*$/$1/; # remove whitespace at begin and end of line
67 s/^(.*?)\s*#.*$/$1/; # remove comments
68 /^$/ && next; # skip empty lines
70 $$functions{$_}++;
72 close(IN);
74 $output->progress("$configure_ac_file");
76 my $again = 0;
77 open(IN, "< $configure_ac_file") || die "Error: Can't open $configure_ac_file: $!\n";
78 local $/ = "\n";
79 while($again || (defined($_ = <IN>))) {
80 $again = 0;
81 chomp;
82 if(/^(.*?)\\$/) {
83 my $current = $1;
84 my $next = <IN>;
85 if(defined($next)) {
86 # remove trailing whitespace
87 $current =~ s/\s+$//;
89 # remove leading whitespace
90 $next =~ s/^\s+//;
92 $_ = $current . " " . $next;
94 $again = 1;
95 next;
99 # remove leading and trailing whitespace
100 s/^\s*(.*?)\s*$/$1/;
102 # skip empty lines
103 if(/^$/) { next; }
105 # skip comments
106 if(/^dnl/) { next; }
108 if(/AC_CHECK_HEADERS\(\s*([^,\)]*)(?:,|\))?/) {
109 my $headers = $1;
110 $headers =~ s/^\s*\[\s*(.*?)\s*\]\s*$/$1/;
111 foreach my $name (split(/\s+/, $headers)) {
112 $$conditional_headers{$name}++;
114 } elsif(/AC_HEADER_STAT\(\)/) {
115 # This checks for a bunch of standard headers
116 # There's stdlib.h, string.h and sys/types.h too but we don't
117 # want to force ifdefs for those at this point.
118 foreach my $name ("sys/stat.h", "memory.h", "strings.h",
119 "inttypes.h", "stdint.h", "unistd.h") {
120 $$conditional_headers{$name}++;
122 } elsif(/AC_CHECK_FUNCS\(\s*([^,\)]*)(?:,|\))?/) {
123 my $funcs = $1;
124 $funcs =~ s/^\s*\[\s*(.*?)\s*\]\s*$/$1/;
125 foreach my $name (split(/\s+/, $funcs)) {
126 $$conditional_functions{$name}++;
128 } elsif(/AC_FUNC_ALLOCA/) {
129 $$conditional_headers{"alloca.h"}++;
130 } elsif (/AC_DEFINE\(\s*HAVE_(.*?)_H/) {
131 my $name = lc($1);
132 $name =~ s/_/\//;
133 $name .= ".h";
135 next if $name =~ m%correct/%;
137 $$conditional_headers{$name}++;
141 close(IN);
143 $output->progress("$config_h_in_file");
145 open(IN, "< $config_h_in_file") || die "Error: Can't open $config_h_in_file: $!\n";
146 local $/ = "\n";
147 while(<IN>) {
148 # remove leading and trailing whitespace
149 s/^\s*(.*?)\s*$/$1/;
151 # skip empty lines
152 if(/^$/) { next; }
154 if(/^\#undef\s+(\S+)$/) {
155 $$conditionals{$1}++;
158 close(IN);
160 $nativeapi = $self;
162 return $self;
165 sub is_function($$) {
166 my $self = shift;
167 my $functions = \%{$self->{FUNCTIONS}};
169 my $name = shift;
171 return ($$functions{$name} || 0);
174 sub is_conditional($$) {
175 my $self = shift;
176 my $conditionals = \%{$self->{CONDITIONALS}};
178 my $name = shift;
180 return ($$conditionals{$name} || 0);
183 sub found_conditional($$) {
184 my $self = shift;
185 my $conditional_found = \%{$self->{CONDITIONAL_FOUND}};
187 my $name = shift;
189 $$conditional_found{$name}++;
192 sub is_conditional_header($$) {
193 my $self = shift;
194 my $conditional_headers = \%{$self->{CONDITIONAL_HEADERS}};
196 my $name = shift;
198 return ($$conditional_headers{$name} || 0);
201 sub is_conditional_function($$) {
202 my $self = shift;
203 my $conditional_functions = \%{$self->{CONDITIONAL_FUNCTIONS}};
205 my $name = shift;
207 return ($$conditional_functions{$name} || 0);
210 sub global_report($) {
211 my $self = shift;
213 my $output = \${$self->{OUTPUT}};
214 my $conditional_found = \%{$self->{CONDITIONAL_FOUND}};
215 my $conditionals = \%{$self->{CONDITIONALS}};
217 my @messages;
218 foreach my $name (sort(keys(%$conditionals))) {
219 if($name =~ /^(?:const|inline|size_t)$/) { next; }
221 if(0 && !$$conditional_found{$name}) {
222 push @messages, "config.h.in: conditional $name not used\n";
226 foreach my $message (sort(@messages)) {
227 $output->write($message);