PATCH 2.5.2.7: io.h cleanup and userspace nudge
As we are now in 2.5.x series I figured it might be a good time to push this out... The patch removes __KERNEL__ ifdefs from [only] io.h as a nudge to userspace that they should not be including kernel headers.
MDK, RedHat, Caldera, and other distros already distribute a subset of [sanitized?] kernel headers for glibc, so there is plenty of time to notice and deal with any breakage this causes in userspace [which IMHO should not have been including kernel headers in the first place...]
Finally, the patch includes a cosmetic cleanup to use standard u8/u16/u32 types for {read,write}[bwl], similar to patches already applied for sparc64, alpha, and other arches during 2.4.x series.
Jeff
Signature · 3 lines
Jeff Garzik | Only so many songs can be sung Building 1024 | with two lips, two lungs, and one tongue. MandrakeSoft | - nomeansno
include/asm-i386/io.h renamed from spare/tmp/linux-2.5.2-pre7/include/asm-i386/io.h +6 -10
@@ -41,8 +41,6 @@#define XQUAD_PORTIO_BASE 0xfe400000#define XQUAD_PORTIO_LEN 0x40000/* 256k per quad. Only remapping 1st */ -#ifdef __KERNEL__ -#include <linux/vmalloc.h> /*
@@ -108,16 +106,16 @@* memory location directly. */ -#define readb (addr) (*(volatile unsigned char *) __io_virt(addr)) -#define readw (addr) (*(volatile unsigned short *) __io_virt(addr)) -#define readl (addr) (*(volatile unsigned int *) __io_virt(addr)) +#define readb (addr) (*(volatile u8 *) __io_virt(addr)) +#define readw (addr) (*(volatile u16 *) __io_virt(addr)) +#define readl (addr) (*(volatile u32 *) __io_virt(addr))#define __raw_readb readb#define __raw_readw readw#define __raw_readl readl -#define writeb (b,addr) (*(volatile unsigned char *) __io_virt(addr) = (b)) -#define writew (b,addr) (*(volatile unsigned short *) __io_virt(addr) = (b)) -#define writel (b,addr) (*(volatile unsigned int *) __io_virt(addr) = (b)) +#define writeb (b,addr) (*(volatile u8 *) __io_virt(addr) = (b)) +#define writew (b,addr) (*(volatile u16 *) __io_virt(addr) = (b)) +#define writel (b,addr) (*(volatile u32 *) __io_virt(addr) = (b))#define __raw_writeb writeb#define __raw_writew writew#define __raw_writel writel
@@ -215,8 +213,6 @@#define flush_write_buffers ()#endif - -#endif /* __KERNEL__ */ #ifdef SLOW_IO_BY_JUMPING #define __SLOW_DOWN_IO "\njmp 1f\n1:\tjmp 1f\n1:"
Quoted 3 lines · Jeff Garzik
As we are now in 2.5.x series I figured it might be a good time to push this out... The patch removes
__KERNEL__ifdefs from [only]io.has a nudge to userspace that they should not be including kernel headers.
Why not..
#ifndef __KERNEL__
#error This file should not be included by userspace. #endif
?
Signature · 2 lines
| Dave Jones. http://www.codemonkey.org.uk | SuSE Labs
Quoted 7 lines · Dave Jones
Quoted 3 lines · Jeff Garzik
As we are now in 2.5.x series I figured it might be a good time to push this out... The patch removes
__KERNEL__ifdefs from [only]io.has a nudge to userspace that they should not be including kernel headers.
Quoted 5 lines
Why not..
#ifndef
__KERNEL__
#error This file should not be included by userspace. #endif
I thought about it, but then the tree would be littered with that all over the place. Programmers are smart enough to figure this out (I hope :))
Signature · 3 lines
Jeff Garzik | Only so many songs can be sung Building 1024 | with two lips, two lungs, and one tongue. MandrakeSoft | - nomeansno
Quoted 6 lines · Jeff Garzik
Quoted 3 lines
#ifndef
__KERNEL__
#error This file should not be included by userspace. #endifI thought about it, but then the tree would be littered with that all over the place. Programmers are smart enough to figure this out (I hope :))
I doubt you'd need it in that many places. A few well chosen ones should probably suffice.
Signature · 2 lines
| Dave Jones. http://www.codemonkey.org.uk | SuSE Labs
Quoted 2 lines · [email protected] said:
I doubt you'd need it in that many places. A few well chosen ones
should probably suffice.
Just putting it asm-*/types.h should just about be enough.
--
dwmw2
Quoted 1 line
Just putting it
asm-*/types.hshould just about be enough.
That is one of the headers glibc wants to import however. It wants to be hard for applications to do something stupid but easy for glibc to extract the relevant data that it actually needs (because glibc needs the kernel to user information to make syscalls even if it doesnt expose them to apps)
Alan
including kernel headers (was Re: PATCH 2.5.2.7: io.h cleanup and userspace nudge)
Quoted 7 lines · Alan Cox
Quoted 2 lines
Just putting it
asm-*/types.hshould just about be enough.That is one of the headers glibc wants to import however. It wants to be hard for applications to do something stupid but easy for glibc to extract the relevant data that it actually needs (because glibc needs the kernel to user information to make syscalls even if it doesnt expose them to apps)
Thinking -long term- here, I wonder what a good solution for glibc would be? Userspace including glibc should never include kernel headers but I 100% agree we should make it as easy as possible for glibc (and other libc's) to stay in sync with the kernel<->userspace API.
I am betting glibc does not require as much work to become independent of kernel headers... it is more work to get all the userspace apps that reference ioctl structures and constants not using kernel headers.
Jeff
Signature · 3 lines
Jeff Garzik | Only so many songs can be sung Building 1024 | with two lips, two lungs, and one tongue. MandrakeSoft | - nomeansno
Quoted 6 lines · Dave Jones
Quoted 3 lines · Jeff Garzik
Quoted 3 lines
#ifndef
__KERNEL__
#error This file should not be included by userspace. #endif
Quoted 6 lines
Quoted 3 lines
I thought about it, but then the tree would be littered with that all over the place. Programmers are smart enough to figure this out (I hope :))
I doubt you'd need it in that many places. A few well chosen ones should probably suffice.
oh, if Linus would apply it, I would love to see the above code in asm/types.h or linux/kernel.h or similarly popular headers.
But... my patch is merely a small step, a "nudge" as I mentioned. I
don't want to annhilate the glibc developers with a sudden task, just a nudge :)
Jeff
Signature · 3 lines
Jeff Garzik | Only so many songs can be sung Building 1024 | with two lips, two lungs, and one tongue. MandrakeSoft | - nomeansno
Quoted 3 lines · Jeff Garzik
But... my patch is merely a small step, a "nudge" as I mentioned. I
don't want to annhilate the glibc developers with a sudden task, just a nudge :)
Then s/#error/#warning/ 8)
Signature · 2 lines
| Dave Jones. http://www.codemonkey.org.uk | SuSE Labs
Quoted 14 lines · Jeff Garzik
Quoted 6 lines · Dave Jones
Quoted 3 lines · Jeff Garzik
Quoted 3 lines
#ifndef
__KERNEL__
#error This file should not be included by userspace. #endifQuoted 6 lines
Quoted 3 lines
I thought about it, but then the tree would be littered with that all over the place. Programmers are smart enough to figure this out (I hope :))
I doubt you'd need it in that many places. A few well chosen ones should probably suffice.
Quoted 6 lines
oh, if Linus would apply it, I would love to see the above code in
asm/types.horlinux/kernel.hor similarly popular headers.But... my patch is merely a small step, a "nudge" as I mentioned. I
don't want to annhilate the glibc developers with a sudden task, just a nudge :)
Please test this change on a libc5 system before unleashing a potential horror. All the world *is not* glibc!
Regards, Richard.... Permanent: [email protected] Current: [email protected]
Quoted 2 lines · Richard Gooch
Please test this change on a libc5 system before unleashing a potential horror. All the world *is not* glibc!
Am I alone in finding the idea of running 2.5/2.6 on a libc5 system a little strange ?
Signature · 2 lines
| Dave Jones. http://www.codemonkey.org.uk | SuSE Labs
Quoted 7 lines · Dave Jones
Quoted 2 lines · Richard Gooch
Please test this change on a libc5 system before unleashing a potential horror. All the world *is not* glibc!
Am I alone in finding the idea of running 2.5/2.6 on a libc5 system a little strange ?
Not if you want a lightweight C library. Such as when running off a CF card.
Regards, Richard.... Permanent: [email protected] Current: [email protected]
Quoted 2 lines · Richard Gooch
Not if you want a lightweight C library. Such as when running off a CF card.
But aren't there better options for a lightweight C library than libc5?
At least that would involve using something that's being maintained.
mrc
Signature · 3 lines
Mike Castle [email protected] www.netcom.com/~dalgoda/ We are all of us living in the shadow of Manhattan. -- Watchmen fatal ("You are in a maze of twisty compiler features, all different"); -- gcc
Quoted 8 lines · Mike Castle
Quoted 2 lines · Richard Gooch
Not if you want a lightweight C library. Such as when running off a CF card.
But aren't there better options for a lightweight C library than libc5?
At least that would involve using something that's being maintained.
Yes indeed, something like this perhaps?
Regards,
Reid
--
Ignorance of all things is an evil neither terrible nor excessive, nor yet the greatest of all; but great cleverness and much learning, if they be accompanied by a bad training, are a much greater misfortune. - Plato
Quoted 2 lines · Richard Gooch
Please test this change on a libc5 system before unleashing a potential horror. All the world *is not* glibc!
(1) This is a devel series, the time for such changes, and (2) and it's easy enough for libc5 systems to include their own sanitized copy of kernel headers just like MDK, RHAT, and others are doing now for glibc.
Jeff
Signature · 3 lines
Jeff Garzik | Only so many songs can be sung Building 1024 | with two lips, two lungs, and one tongue. MandrakeSoft | - nomeansno
Quoted 10 lines · Jeff Garzik
Quoted 9 lines · Dave Jones
Quoted 3 lines · Jeff Garzik
As we are now in 2.5.x series I figured it might be a good time to push this out... The patch removes
__KERNEL__ifdefs from [only]io.has a nudge to userspace that they should not be including kernel headers.Why not..
Quoted 7 lines
Quoted 3 lines
#ifndef
__KERNEL__
#error This file should not be included by userspace. #endifI thought about it, but then the tree would be littered with that all over the place. Programmers are smart enough to figure this out (I hope :))
You can put it in config.h or the like where it gets included by everyone.
Signature · 1 line
"Love the dolphins," she advised him. "Write by W.A.S.T.E.."