All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: Vineet Gupta <Vineet.Gupta1@synopsys.com>
Cc: dhowells@redhat.com, arc-linux-dev@synopsys.com,
	"arnd@arndb.de" <arnd@arndb.de>,
	"linux-arch@vger.kernel.org" <linux-arch@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [arc-linux-dev] Re: UAPI for new arches (was Re: [GIT PULL] User API Disintegrate: Preparatory patches)
Date: Mon, 12 Nov 2012 13:14:00 +0000	[thread overview]
Message-ID: <9377.1352726040@warthog.procyon.org.uk> (raw)
In-Reply-To: <50A0D634.20005@synopsys.com>

[-- Attachment #1: Type: text/plain, Size: 1922 bytes --]

Vineet Gupta <Vineet.Gupta1@synopsys.com> wrote:

> >> Per you email from last week, When I ran the disintergrate-one.pl script
> >> myself I saw a whole bunch of empty UAPI files being generated with
> >> references in orig header.  I'm not sure what I'm doing wrong.
> > Can you give an example of such a header?
> 
> tlb.h - despite having __KERNEL__ guard in orig file. Here's how I did it.
> 
> 1. In my orig tree, I created arch/arc/include/uapi/asm/Kbuild, with
> following 2 lines
> 
> # UAPI Header export list
> include include/uapi/asm-generic/Kbuild.asm
> 
> 2.  ./disintegrate-one.pl arch/arc/include/asm/tlb.h
> arch/arc/include/uapi/asm/tlb.h
> 
> This generates a empty uapi/asm/tlb.h, a reference to it in asm/tlb.h
> and is also exported from Kbuild.asm - all 3 of which are wrong.

Actually, this is the correct operation - it's just that there's nothing in
tlb.h to export.  (Note that Kbuild.asm is not modified, but rather
uapi/asm/Kbuild.  asm/Kbuild would too, but there's no export line there to be
removed.)

However... tlb.h isn't exported in Kbuild.asm - nor is it exported in arc's
asm/Kbuild, so the script shouldn't be run on that.

> But now that I think about it - I was wrong to call this script for
> all/any arch headers. It should be done only for the ones in
> include/uapi/asm-generic/Kbuild.asm or any specific ones that arch wants
> to export (cachectl.h for our case).

Exactly so.  I should probably have mentioned that, but I've had it automated
for so long, that I don't think about it any more.  You should only call it
for arch headers

I've attached a script that I use to work out which files need disintegration
in a directory.  Run as:

	genfilelist.pl arch/arc/include/asm/

I get:

	byteorder.h
	cachectl.h
	page.h
	ptrace.h
	setup.h
	sigcontext.h
	signal.h
	swab.h
	unistd.h

as being all that you need to disintegrate.  Almost everything seems to be
generic.

David


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: genfilelist.pl --]
[-- Type: text/x-perl, Size: 1685 bytes --]

#!/usr/bin/perl -w
#
# Find all the UAPI files in the nominated directory
#

die "Need directory argument\n"
    if ($#ARGV == -1);

my $dir = $ARGV[0];
my $kbuild = $dir . "/Kbuild";

die "$kbuild not present"
    unless (-r "$dir/Kbuild");

#
# We assume that only Kbuild files in include directories are pertinent to
# determining which headers are UAPI headers.
#
my %headers = ();

opendir my $dh, $dir or die;
foreach $_ (readdir($dh)) {
    $headers{$_} = 1
	if ($_ =~ /[.]h$/ || $_ =~ /[.]agh$/ || $_ =~ /[.]inc$/);
}
closedir($dh) or die;

# Read the common arch list
open FD, '<include/uapi/asm-generic/Kbuild.asm' or die "open Kbuild.asm: $!\n";
my @kbuild_asm = <FD>;
close FD or die;

my %uapihdrs = ();

open FD, '<', $kbuild or die "open $kbuild: $!\n";
my @lines = <FD>;
close FD or die;

for (my $l = 0; $l <= $#lines; $l++) {
    my $line = $lines[$l];

    # parse out the blocks
    # - this may be split over multiple lines using backslashes
    my $block = $line;
  restart:
    $block =~ s@#.*$@@;
    $block =~ s@\s+$@@g;
    $block =~ s@\s+@ @g;

    if ($block =~ /^(.*)[\\]$/) {
	$l++;
	$block = $1 . $lines[$l];
	goto restart;
    }

    $block =~ s@\s+$@@g;
    $block =~ s@\s\s+@ @g;

    if ($block =~ m@^include include/asm-generic/Kbuild.asm@) {
	push @lines, @kbuild_asm;
    }

    if ($block =~ m@^header-y\s*[+:]?=\s*(.*)@ ||
	$block =~ m@^opt-header\s*[+:]?=\s*(.*)@ ||
	$block =~ m@^asm-headers\s*[+:]?=\s*(.*)@
	) {
	my $files = $1;
	next if ($block =~ m@[$][(]foreach@);
	foreach $h (grep m@[^/]$@, split /\s+/, $files) {
	    if (exists $headers{"$h"}) {
		$uapihdrs{"$h"} = 1;
	    }
	}
    }
}

print map { $_ . "\n"; } sort keys %uapihdrs;

WARNING: multiple messages have this Message-ID (diff)
From: David Howells <dhowells@redhat.com>
To: Vineet Gupta <Vineet.Gupta1@synopsys.com>
Cc: dhowells@redhat.com, arc-linux-dev@synopsys.com,
	"arnd\@arndb.de" <arnd@arndb.de>,
	"linux-arch\@vger.kernel.org" <linux-arch@vger.kernel.org>,
	"linux-kernel\@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [arc-linux-dev] Re: UAPI for new arches (was Re: [GIT PULL] User API Disintegrate: Preparatory patches)
Date: Mon, 12 Nov 2012 13:14:00 +0000	[thread overview]
Message-ID: <9377.1352726040@warthog.procyon.org.uk> (raw)
In-Reply-To: <50A0D634.20005@synopsys.com>

[-- Attachment #1: Type: text/plain, Size: 1922 bytes --]

Vineet Gupta <Vineet.Gupta1@synopsys.com> wrote:

> >> Per you email from last week, When I ran the disintergrate-one.pl script
> >> myself I saw a whole bunch of empty UAPI files being generated with
> >> references in orig header.  I'm not sure what I'm doing wrong.
> > Can you give an example of such a header?
> 
> tlb.h - despite having __KERNEL__ guard in orig file. Here's how I did it.
> 
> 1. In my orig tree, I created arch/arc/include/uapi/asm/Kbuild, with
> following 2 lines
> 
> # UAPI Header export list
> include include/uapi/asm-generic/Kbuild.asm
> 
> 2.  ./disintegrate-one.pl arch/arc/include/asm/tlb.h
> arch/arc/include/uapi/asm/tlb.h
> 
> This generates a empty uapi/asm/tlb.h, a reference to it in asm/tlb.h
> and is also exported from Kbuild.asm - all 3 of which are wrong.

Actually, this is the correct operation - it's just that there's nothing in
tlb.h to export.  (Note that Kbuild.asm is not modified, but rather
uapi/asm/Kbuild.  asm/Kbuild would too, but there's no export line there to be
removed.)

However... tlb.h isn't exported in Kbuild.asm - nor is it exported in arc's
asm/Kbuild, so the script shouldn't be run on that.

> But now that I think about it - I was wrong to call this script for
> all/any arch headers. It should be done only for the ones in
> include/uapi/asm-generic/Kbuild.asm or any specific ones that arch wants
> to export (cachectl.h for our case).

Exactly so.  I should probably have mentioned that, but I've had it automated
for so long, that I don't think about it any more.  You should only call it
for arch headers

I've attached a script that I use to work out which files need disintegration
in a directory.  Run as:

	genfilelist.pl arch/arc/include/asm/

I get:

	byteorder.h
	cachectl.h
	page.h
	ptrace.h
	setup.h
	sigcontext.h
	signal.h
	swab.h
	unistd.h

as being all that you need to disintegrate.  Almost everything seems to be
generic.

David


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: genfilelist.pl --]
[-- Type: text/x-perl, Size: 1685 bytes --]

#!/usr/bin/perl -w
#
# Find all the UAPI files in the nominated directory
#

die "Need directory argument\n"
    if ($#ARGV == -1);

my $dir = $ARGV[0];
my $kbuild = $dir . "/Kbuild";

die "$kbuild not present"
    unless (-r "$dir/Kbuild");

#
# We assume that only Kbuild files in include directories are pertinent to
# determining which headers are UAPI headers.
#
my %headers = ();

opendir my $dh, $dir or die;
foreach $_ (readdir($dh)) {
    $headers{$_} = 1
	if ($_ =~ /[.]h$/ || $_ =~ /[.]agh$/ || $_ =~ /[.]inc$/);
}
closedir($dh) or die;

# Read the common arch list
open FD, '<include/uapi/asm-generic/Kbuild.asm' or die "open Kbuild.asm: $!\n";
my @kbuild_asm = <FD>;
close FD or die;

my %uapihdrs = ();

open FD, '<', $kbuild or die "open $kbuild: $!\n";
my @lines = <FD>;
close FD or die;

for (my $l = 0; $l <= $#lines; $l++) {
    my $line = $lines[$l];

    # parse out the blocks
    # - this may be split over multiple lines using backslashes
    my $block = $line;
  restart:
    $block =~ s@#.*$@@;
    $block =~ s@\s+$@@g;
    $block =~ s@\s+@ @g;

    if ($block =~ /^(.*)[\\]$/) {
	$l++;
	$block = $1 . $lines[$l];
	goto restart;
    }

    $block =~ s@\s+$@@g;
    $block =~ s@\s\s+@ @g;

    if ($block =~ m@^include include/asm-generic/Kbuild.asm@) {
	push @lines, @kbuild_asm;
    }

    if ($block =~ m@^header-y\s*[+:]?=\s*(.*)@ ||
	$block =~ m@^opt-header\s*[+:]?=\s*(.*)@ ||
	$block =~ m@^asm-headers\s*[+:]?=\s*(.*)@
	) {
	my $files = $1;
	next if ($block =~ m@[$][(]foreach@);
	foreach $h (grep m@[^/]$@, split /\s+/, $files) {
	    if (exists $headers{"$h"}) {
		$uapihdrs{"$h"} = 1;
	    }
	}
    }
}

print map { $_ . "\n"; } sort keys %uapihdrs;

  reply	other threads:[~2012-11-12 13:14 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-02 18:36 [GIT PULL] User API Disintegrate: Preparatory patches David Howells
2012-10-04 17:12 ` Geert Uytterhoeven
2012-10-04 17:36   ` David Howells
2012-10-17  8:42 ` James Hogan
2012-10-22 11:50   ` James Hogan
2012-11-01 10:41     ` UAPI for new arches (was Re: [GIT PULL] User API Disintegrate: Preparatory patches) Vineet Gupta
2012-11-01 10:41       ` Vineet Gupta
2012-11-08 12:38       ` David Howells
2012-11-08 14:36       ` David Howells
2012-11-08 15:07       ` David Howells
2012-11-08 18:21         ` Vineet Gupta
2012-11-08 23:19           ` David Howells
2012-11-12 10:57             ` [arc-linux-dev] " Vineet Gupta
2012-11-12 10:57               ` Vineet Gupta
2012-11-12 13:14               ` David Howells [this message]
2012-11-12 13:14                 ` David Howells
2012-11-14 13:01                 ` James Hogan
2012-11-14 16:28                   ` David Howells

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9377.1352726040@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=Vineet.Gupta1@synopsys.com \
    --cc=arc-linux-dev@synopsys.com \
    --cc=arnd@arndb.de \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.