mirror of
https://github.com/torvalds/linux.git
synced 2024-11-01 09:41:44 +00:00
56c176c9ca
Strip the _UAPI prefix from header guards during header installation so that any userspace dependencies aren't affected. glibc, for example, checks for linux/types.h, linux/kernel.h, linux/compiler.h and linux/list.h by their guards - though the last two aren't actually exported. libtool: compile: gcc -std=gnu99 -DHAVE_CONFIG_H -I. -Wall -Werror -Wformat -Wformat-security -D_FORTIFY_SOURCE=2 -fno-delete-null-pointer-checks -fstack-protector -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -c child.c -fPIC -DPIC -o .libs/child.o In file included from cli.c:20:0: common.h:152:8: error: redefinition of 'struct sysinfo' In file included from /usr/include/linux/kernel.h:4:0, from /usr/include/linux/sysctl.h:25, from /usr/include/sys/sysctl.h:43, from common.h:50, from cli.c:20: /usr/include/linux/sysinfo.h:7:8: note: originally defined here Reported-by: Tomasz Torcz <tomek@pipebreaker.pl> Signed-off-by: David Howells <dhowells@redhat.com> Acked-by: Josh Boyer <jwboyer@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
64 lines
1.9 KiB
Perl
64 lines
1.9 KiB
Perl
#!/usr/bin/perl -w
|
|
#
|
|
# headers_install prepare the listed header files for use in
|
|
# user space and copy the files to their destination.
|
|
#
|
|
# Usage: headers_install.pl readdir installdir arch [files...]
|
|
# installdir: dir to install the files to
|
|
# arch: current architecture
|
|
# arch is used to force a reinstallation when the arch
|
|
# changes because kbuild then detect a command line change.
|
|
# files: list of files to check
|
|
#
|
|
# Step in preparation for users space:
|
|
# 1) Drop all use of compiler.h definitions
|
|
# 2) Drop include of compiler.h
|
|
# 3) Drop all sections defined out by __KERNEL__ (using unifdef)
|
|
|
|
use strict;
|
|
|
|
my ($installdir, $arch, @files) = @ARGV;
|
|
|
|
my $unifdef = "scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__";
|
|
|
|
foreach my $filename (@files) {
|
|
my $file = $filename;
|
|
$file =~ s!^.*/!!;
|
|
|
|
my $tmpfile = "$installdir/$file.tmp";
|
|
|
|
open(my $in, '<', $filename)
|
|
or die "$filename: $!\n";
|
|
open(my $out, '>', $tmpfile)
|
|
or die "$tmpfile: $!\n";
|
|
while (my $line = <$in>) {
|
|
$line =~ s/([\s(])__user\s/$1/g;
|
|
$line =~ s/([\s(])__force\s/$1/g;
|
|
$line =~ s/([\s(])__iomem\s/$1/g;
|
|
$line =~ s/\s__attribute_const__\s/ /g;
|
|
$line =~ s/\s__attribute_const__$//g;
|
|
$line =~ s/\b__packed\b/__attribute__((packed))/g;
|
|
$line =~ s/^#include <linux\/compiler.h>//;
|
|
$line =~ s/(^|\s)(inline)\b/$1__$2__/g;
|
|
$line =~ s/(^|\s)(asm)\b(\s|[(]|$)/$1__$2__$3/g;
|
|
$line =~ s/(^|\s|[(])(volatile)\b(\s|[(]|$)/$1__$2__$3/g;
|
|
$line =~ s/#ifndef _UAPI/#ifndef /;
|
|
$line =~ s/#define _UAPI/#define /;
|
|
$line =~ s!#endif /[*] _UAPI!#endif /* !;
|
|
printf {$out} "%s", $line;
|
|
}
|
|
close $out;
|
|
close $in;
|
|
|
|
system $unifdef . " $tmpfile > $installdir/$file";
|
|
# unifdef will exit 0 on success, and will exit 1 when the
|
|
# file was processed successfully but no changes were made,
|
|
# so abort only when it's higher than that.
|
|
my $e = $? >> 8;
|
|
if ($e > 1) {
|
|
die "$tmpfile: $!\n";
|
|
}
|
|
unlink $tmpfile;
|
|
}
|
|
exit 0;
|