mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-06 02:24:14 +08:00
f210735fe2
checkpatch.pl warns about using __attribute__((packed)) in kernel headers: "__packed is preferred over __attribute__((packed))". If one follows that advice it could cause problems in the exported header files, because the outside world doesn't know about this shortcut. For example busybox will fail to compile: CC miscutils/ubi_attach_detach.o In file included from miscutils/ubi_attach_detach.c:27:0: /usr/include/mtd/ubi-user.h:330:3: error: conflicting types for ‘__packed’ /usr/include/mtd/ubi-user.h:314:3: note: previous declaration of ‘__packed’ was here ... Fix the problem by substituting __packed with __attribute__((packed)) in the header_install.pl script. Cc: Artem Bityutskiy <Artem.Bityutskiy@nokia.com> CC: Joe Perches <joe@perches.com> Signed-off-by: Markus Trippelsdorf <markus@trippelsdorf.de> Signed-off-by: Michal Marek <mmarek@suse.cz>
59 lines
1.8 KiB
Perl
59 lines
1.8 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...]
|
|
# readdir: dir to open files
|
|
# installdir: dir to install the files
|
|
# 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 ($readdir, $installdir, $arch, @files) = @ARGV;
|
|
|
|
my $unifdef = "scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__";
|
|
|
|
foreach my $file (@files) {
|
|
my $tmpfile = "$installdir/$file.tmp";
|
|
|
|
open(my $in, '<', "$readdir/$file")
|
|
or die "$readdir/$file: $!\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;
|
|
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;
|