unify exported sparc header files?
Hi David et al.
While looking into improving our current headers_check stuff I noticed that sparc is the sole user of ALTARCH in include/asm-sparc64/Kbuild and getting rid of this hack would be really nice.
So I started to look into the two possibilities:
- Unifying all sparc header files
Assisted by a small script this was a trivial
excersise but it left me with a lot of
header files named *_32.h and *_64.h
This was too messy IMO so I dropped that.
- Unifying only the userspace exported headers This turned out to achieveable but before proceeding I request a bit feedback.
I started out analysing current situation.
The following is a list of all user exported headers for sparc and sparc64:
apb.h sparc64 only apc.h sparc32 only asi.h non-unified bbc.h sparc64 only bpp.h unified (master in asm-sparc) display7seg.h sparc64 only envctrl.h sparc64 only fbio.h non-unified jsflash.h sparc32 only openprom.h non-unified openpromio.h equal perfctr.h equal psrcompat.h sparc64 only psr.h sparc64 only pstate.h sparc64 only reg.h non-unified traps.h sparc32 only uctx.h sparc64 only utrap.h sparc64 only vfc_ioctls.h sparc32 only watchdog.h sparc64 only
sparc32 only => This header file exist only in asm-sparc32/ sparc64 only => This header file exist only in asm-sparc64/
non-unified => The 32 and 64 bit variant differs unified => A straight include of asm-sparc/file.h form asm-sparc64 equal => The files are identical for 32 and 64 bit
To sum up:
4 files are sparc32 specific
10 files are sparc64 specific
4 files differ between 32 and 64 bit
2 files should be unified (will send a patch)
What I suggest to do:
For all sparc32 specific files:
- nothing
For all the sparc64 specific files:
- copy file to asm-sparc
- wrap the copied file in
#if defined(__sparc_v9__) || defined(CONFIG_SPARC64)
... file content ... #endif
- straight include from asm-sparc64 of the asm-sparc file
- Or I could just drop the wrapping?
For the non-unified files:
- Add content to asm-sparc file and wrap it into:
#if defined(__sparc_v9__) || defined(CONFIG_SPARC64)
... sparc64 file content
#else
... sparc32 file content
#endif
Comments?
Sam
From: Sam Ravnborg <[email protected]>
Date: Sun, 1 Jun 2008 09:20:45 +0200
Quoted 12 lines
For all sparc32 specific files:
- nothingFor all the sparc64 specific files:
- copy file to asm-sparc
- wrap the copied file in#if defined(__sparc_v9__) || defined(CONFIG_SPARC64) ... file content ...#endif
- straight include from asm-sparc64 of the asm-sparc file
- Or I could just drop the wrapping?
Quoted 7 lines
For the non-unified files:
- Add content to asm-sparc file and wrap it into:#if defined(__sparc_v9__) || defined(CONFIG_SPARC64) ... sparc64 file content #else ... sparc32 file content #endif
This sounds fine to me.
Quoted 23 lines · David Miller
From: Sam Ravnborg <[email protected]>
Date: Sun, 1 Jun 2008 09:20:45 +0200Quoted 12 lines
For all sparc32 specific files:
- nothingFor all the sparc64 specific files:
- copy file to asm-sparc
- wrap the copied file in#if defined(__sparc_v9__) || defined(CONFIG_SPARC64) ... file content ...#endif
- straight include from asm-sparc64 of the asm-sparc file
- Or I could just drop the wrapping?Quoted 7 lines
For the non-unified files:
- Add content to asm-sparc file and wrap it into:#if defined(__sparc_v9__) || defined(CONFIG_SPARC64) ... sparc64 file content #else ... sparc32 file content #endif
Quoted 1 line
This sounds fine to me.
I just realised we have a common set of files specified in asm-generic/Kbuild.asm
The diff alone looks like this for these files:
byteorder.h | 58 ------------- errno.h | 114 --------------------------- fcntl.h | 9 -- ioctl.h | 6 - ioctls.h | 10 +- ipcbuf.h | 33 +++---- kvm.h | 6 - mman.h | 10 +- msgbuf.h | 6 - param.h | 7 - poll.h | 4 posix_types.h | 42 +++++----- ptrace.h | 241 +++++++++++++++++++++++++++++++++++++++++++++++++--------- resource.h | 15 --- sembuf.h | 11 -- setup.h | 8 - shmbuf.h | 14 +-- sigcontext.h | 77 ++++++++++++------ siginfo.h | 23 ++++- signal.h | 103 ++++++++++-------------- socket.h | 3 sockios.h | 6 - stat.h | 91 +++++++-------------- statfs.h | 54 ++++++++++++ termbits.h | 13 +-- termios.h | 93 +++++++++++----------- types.h | 14 +-- unistd.h | 77 ++++++++----------
Half of this is trivial differences but anyway more work than I initially anticipated :-(
Sam
From: Sam Ravnborg <[email protected]>
Date: Thu, 5 Jun 2008 22:25:18 +0200
Quoted 2 lines
Half of this is trivial differences but anyway more work than I initially anticipated :-(
Things are never as simple as they initially seem. :)
BTW, the correct test for 64-bit sparc in userspace is something like:
#if defined(__sparc__) && defined(__arch64__)
That "__sparc_v9__" is a deprecated old cpp define which shouldn't be used in new files.
Quoted 23 lines · David Miller
From: Sam Ravnborg <[email protected]>
Date: Sun, 1 Jun 2008 09:20:45 +0200Quoted 12 lines
For all sparc32 specific files:
- nothingFor all the sparc64 specific files:
- copy file to asm-sparc
- wrap the copied file in#if defined(__sparc_v9__) || defined(CONFIG_SPARC64) ... file content ...#endif
- straight include from asm-sparc64 of the asm-sparc file
- Or I could just drop the wrapping?Quoted 7 lines
For the non-unified files:
- Add content to asm-sparc file and wrap it into:#if defined(__sparc_v9__) || defined(CONFIG_SPARC64) ... sparc64 file content #else ... sparc32 file content #endif
Quoted 1 line
This sounds fine to me.
Sorry that I missed this in the original email.
Can we use the same #if test we use for userspace also in kernelspace?
I'm asking since Sam's proposal would result in more CONFIG_ leakage to userspace headers.
cu
Adrian
Signature · 4 lines
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon SeedQuoted 3 lines · Sam Ravnborg
...
Half of this is trivial differences but anyway more work than I initially anticipated :-(
Is there anything where I could/should help?
Quoted 1 line
Sam
cu
Adrian
Signature · 4 lines
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon SeedQuoted 6 lines · Adrian Bunk
Quoted 3 lines · Sam Ravnborg
...
Half of this is trivial differences but anyway more work than I initially anticipated :-(Is there anything where I could/should help?
The ones I have not yet finished is:
posix_types.hptrace.hsigcontext.hsiginfo.hsignal.hstat.htermbits.htermios.htypes.hunistd.h
Except for termios.h (or was is termbits.h) then they all looks like they will require two different sections in the .h file.
Any help with these are appreciated.
I will look at it tonight again and will concentrate on the patches I already have.
Sam
From: Adrian Bunk <[email protected]>
Date: Fri, 6 Jun 2008 14:05:23 +0300
Quoted 1 line
Can we use the same #if test we use for userspace also in kernelspace?
It would work.
Quoted 21 lines · Sam Ravnborg
Quoted 6 lines · Adrian Bunk
Quoted 3 lines · Sam Ravnborg
...
Half of this is trivial differences but anyway more work than I initially anticipated :-(Is there anything where I could/should help?
The ones I have not yet finished is:
posix_types.hptrace.hsigcontext.hsiginfo.hsignal.hstat.htermbits.htermios.htypes.hunistd.h
Quoted 3 lines
Except for
termios.h(or was istermbits.h) then they all looks like they will require two different sections in the .h file.
...
Sorry for being late, I'll look at this basedon your patchset this night.
Quoted 1 line
Sam
cu
Adrian
Signature · 4 lines
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon SeedQuoted 22 lines · Adrian Bunk
Quoted 21 lines · Sam Ravnborg
Quoted 6 lines · Adrian Bunk
Quoted 3 lines · Sam Ravnborg
...
Half of this is trivial differences but anyway more work than I initially anticipated :-(Is there anything where I could/should help?
The ones I have not yet finished is:
posix_types.hptrace.hsigcontext.hsiginfo.hsignal.hstat.htermbits.htermios.htypes.hunistd.h
Quoted 5 lines
Quoted 3 lines
Except for
termios.h(or was istermbits.h) then they all looks like they will require two different sections in the .h file.
...Sorry for being late, I'll look at this basedon your patchset this night.
This was not something easy shareable anyway.
And you are in no hurry - I do not expect David to look at this until mid/late of the week (I gues hes has a bit queued up to finish first when he gets home).
But any input are appreciated!
Sam
Quoted 6 lines
...
This was not something easy shareable anyway.
And you are in no hurry - I do not expect David to look at this until mid/late of the week (I gues hes has a bit queued up to finish first when he gets home).
...
Finally got around to start working on this.
A first batch of unification patches based on your patches is coming, any comments on them are appreciated.
Quoted 1 line
Sam
cu
Adrian
Signature · 4 lines
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon SeedQuoted 11 lines · Adrian Bunk
Quoted 6 lines
...
This was not something easy shareable anyway.
And you are in no hurry - I do not expect David to look at this until mid/late of the week (I gues hes has a bit queued up to finish first when he gets home).
...Finally got around to start working on this.
A first batch of unification patches based on your patches is coming, any comments on them are appreciated.
I decided to join asi.h together in my patchset - so these are dropped.
And then I cannot find my way around "make headers_check" when I split up the files in _32 and _64 because we do so for a limited set of files and not all of them.
So if I do not come up with anything clever I will most likely just join them together too but with proper ifdef guards around them.
The problem is that I need to do:
#ifndef _ASM_SPARC_OPENPROM_H
#define _ASM_SPARC_OPENPROM_H
#if defined(__sparc__) && defined(__arch64__)
#include <asm-sparc/openprom_64.h>
#else
#include <asm/openprom_32.h>
#endif
#endif
This works well for the build case.
But headers_check complain that it cannot find <asm-sparc/openprom_64.h> becuase we copy all files to asm/ and not asm-sparc/ when we export for sparc.
And it needs to be "<asm-sparc/" because "<asm/" points to the wrong directory when we build sparc64.
One way around it would be to drop asm-sparc64/ entirely and do the _32, _64 trick for all files that differ.
But I do not have time to do so and I'm not sure David approves it.
Sam
Quoted 24 lines · Sam Ravnborg
Quoted 11 lines · Adrian Bunk
Quoted 6 lines
...
This was not something easy shareable anyway.
And you are in no hurry - I do not expect David to look at this until mid/late of the week (I gues hes has a bit queued up to finish first when he gets home).
...Finally got around to start working on this.
A first batch of unification patches based on your patches is coming, any comments on them are appreciated.
I decided to join
asi.htogether in my patchset - so these are dropped.And then I cannot find my way around "make
headers_check" when I split up the files in _32 and _64 because we do so for a limited set of files and not all of them.So if I do not come up with anything clever I will most likely just join them together too but with proper ifdef guards around them.
The problem is that I need to do:
Quoted 8 lines
#ifndef
_ASM_SPARC_OPENPROM_H
#define_ASM_SPARC_OPENPROM_H
#ifdefined(__sparc__)&&defined(__arch64__)
#include <asm-sparc/openprom_64.h>
#else
#include <asm/openprom_32.h>
#endif
#endif
What about my patches that merge openprom_32.h and openprom_64.h into openprom.h?
Quoted 11 lines
This works well for the build case.
Butheaders_checkcomplain that it cannot find <asm-sparc/openprom_64.h> becuase we copy all files to asm/ and not asm-sparc/ when we export for sparc.And it needs to be "<asm-sparc/" because "<asm/" points to the wrong directory when we build sparc64.
One way around it would be to drop asm-sparc64/ entirely and do the _32, _64 trick for all files that differ.
But I do not have time to do so and I'm not sure David approves it.
I'd assume the goal is to merge the complete sparc64 architecture into sparc?
If that's true I'm willing to work on it.
Quoted 1 line
Sam
cu
Adrian
Signature · 4 lines
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon SeedHi Adrian.
Quoted 2 lines
What about my patches that merge
openprom_32.handopenprom_64.hintoopenprom.h?
Looked good.
But I just stopped where I reached now as I ran out of time and wanted to get what I had upstream.
Where I wrote (join them) I was obviously planning to
find the parts that are equal and your patch-set would be a great help here. Even better if you could redo it on too
of what is in sparc-next now (so we avoid the _32.h, _64.h step).
I would be glad if you could take a look at the few remaining .h files because avoinding the _32.h and _64.h files is a plus.
Quoted 2 lines
I'd assume the goal is to merge the complete sparc64 architecture into sparc?
David - do you have such plans?
I will most likely not be able to contribute until late this year as I soon will be on leave from the kernel businness as I am building a new house and moving and stuff (announcement to kbuild
in a few weeks).
But then it could be fun (but need to get my sparc64 box operational then).
Sam
From: Sam Ravnborg <[email protected]>
Date: Tue, 17 Jun 2008 14:35:15 +0200
Quoted 5 lines
Hi Adrian.
Quoted 2 lines
I'd assume the goal is to merge the complete sparc64 architecture into sparc?
David - do you have such plans?
Yes, in the end I'd like to make that happen.
Quoted 5 lines
I will most likely not be able to contribute until late this year as I soon will be on leave from the kernel businness as I am building a new house and moving and stuff (announcement to kbuild
in a few weeks).
But then it could be fun (but need to get my sparc64 box operational then).
No worries :-)