Removing __kernel_old_uid_t, git_t, dev_t
Subsystems (2)
Hi Arnd,
on the base our discussion some month ago you recommend me to remove old kernel types.
I did some tests and I found that first step must be to remove all references in linux kernel code because of compilation error. Just perform grep to include linux folder.
I think we should create this patch first and then I can remove them from MB posix_types.h.
Do you agree with me?
Thanks,
Michal
Signature · 3 lines
Michal Simek, Ing. (M.Eng) PetaLogix - Linux Solutions for a Reconfigurable World w: www.petalogix.com p: +61-7-30090663,+42-0-721842854 f: +61-7-30090663
Arnd Bergmann
maintainerQuoted 10 lines · Michal Simek
on the base our discussion some month ago you recommend me to remove old kernel types.
I did some tests and I found that first step must be to remove all references in linux kernel code because of compilation error. Just perform grep to include linux folder.I think we should create this patch first and then I can remove them from MB
posix_types.h.Do you agree with me?
I've experimented with this in the meantime, and concluded that we can't easily remove them, but should rather define them to the current ones.
How does this look?
---
Provide generic asm/types.h and asm/posix_types.h
For new architectures, the base data types should always be the same, so let's have a version in asm/generic that can be used by all of them out of the box. Other architectures can simplify their code by #including them after defining their platform specific types.
include/asm-generic/posix_types.h new file +162 -0
@@ -0,0 +1,162 @@ +#ifndef __ASM_GENERIC_POSIX_TYPES_H +#define __ASM_GENERIC_POSIX_TYPES_H + +#include <asm/types.h> + +/* +* This file is generally used by user-level software, so you need to +* be a little careful about namespace pollution etc. +* +* First the types that are often defined in different ways across +* architectures, so that you can override them. +*/ + +#ifndef __kernel_ino_t +typedef unsigned long __kernel_ino_t ; +#endif + +#ifndef __kernel_mode_t +typedef unsigned int __kernel_mode_t ; +#endif + +#ifndef __kernel_nlink_t +typedef unsigned long __kernel_nlink_t ; +#endif + +#ifndef __kernel_pid_t +typedef int __kernel_pid_t ; +#endif + +#ifndef __kernel_ipc_pid_t +typedef int __kernel_ipc_pid_t ; +#endif + +#ifndef __kernel_uid_t +typedef unsigned int __kernel_uid_t ; +typedef unsigned int __kernel_gid_t ; +#endif + +#ifndef __kernel_suseconds_t +typedef long __kernel_suseconds_t ; +#endif + +#ifndef __kernel_daddr_t +typedef int __kernel_daddr_t ; +#endif + +#ifndef __kernel_uid32_t +typedef __kernel_uid_t __kernel_uid32_t ; +typedef __kernel_gid_t __kernel_gid32_t ; +#endif + +#ifndef __kernel_old_uid_t +typedef __kernel_uid_t __kernel_old_uid_t ; +typedef __kernel_gid_t __kernel_old_gid_t ; +#endif + +#ifndef __kernel_old_dev_t +typedef unsigned int __kernel_old_dev_t ; +#endif + +#ifndef __kernel_size_t +#if __BITS_PER_LONG !=64 +typedef unsigned int __kernel_size_t ; +typedef int __kernel_ssize_t ; +typedef int __kernel_ptrdiff_t ; +#else +typedef unsigned long __kernel_size_t ; +typedef long __kernel_ssize_t ; +typedef long __kernel_ptrdiff_t ; +#endif +#endif + +/* +* anything below here should be completely generic +*/ +typedef long __kernel_off_t ; +typedef long long __kernel_loff_t ; +typedef long __kernel_time_t ; +typedef long __kernel_clock_t ; +typedef int __kernel_timer_t ; +typedef int __kernel_clockid_t ; +typedef char *__kernel_caddr_t ; +typedef unsigned short __kernel_uid16_t ; +typedef unsigned short __kernel_gid16_t ; + +typedef struct { +int val[2 ]; +}__kernel_fsid_t ; + +#ifdef __KERNEL__ + +#undef __FD_SET +static inline void __FD_SET (unsigned long __fd,__kernel_fd_set *__fdsetp) +{ +unsigned long __tmp = __fd / __NFDBITS; +unsigned long __rem = __fd % __NFDBITS; + __fdsetp->fds_bits[__tmp] |= (1UL <<__rem); +} + +#undef __FD_CLR +static inline void __FD_CLR (unsigned long __fd,__kernel_fd_set *__fdsetp) +{ +unsigned long __tmp = __fd / __NFDBITS; +unsigned long __rem = __fd % __NFDBITS; + __fdsetp->fds_bits[__tmp] &= ~(1UL <<__rem); +} + +#undef __FD_ISSET +static inline int __FD_ISSET (unsigned long __fd,const __kernel_fd_set *__p) +{ +unsigned long __tmp = __fd / __NFDBITS; +unsigned long __rem = __fd % __NFDBITS; +return (__p->fds_bits[__tmp] & (1UL <<__rem)) !=0 ; +} + +/* +* This will unroll the loop for the normal constant case (8 ints, +* for a 256-bit fd_set) +*/ +#undef __FD_ZERO +static inline void __FD_ZERO (__kernel_fd_set *__p) +{ +unsigned long *__tmp = __p->fds_bits; +int __i; + +if (__builtin_constant_p (__FDSET_LONGS)) { +switch (__FDSET_LONGS) { +case 16 : + __tmp[0 ] =0 ; __tmp[1 ] =0 ; + __tmp[2 ] =0 ; __tmp[3 ] =0 ; + __tmp[4 ] =0 ; __tmp[5 ] =0 ; + __tmp[6 ] =0 ; __tmp[7 ] =0 ; + __tmp[8 ] =0 ; __tmp[9 ] =0 ; + __tmp[10 ] =0 ; __tmp[11 ] =0 ; + __tmp[12 ] =0 ; __tmp[13 ] =0 ; + __tmp[14 ] =0 ; __tmp[15 ] =0 ; +return ; + +case 8 : + __tmp[0 ] =0 ; __tmp[1 ] =0 ; + __tmp[2 ] =0 ; __tmp[3 ] =0 ; + __tmp[4 ] =0 ; __tmp[5 ] =0 ; + __tmp[6 ] =0 ; __tmp[7 ] =0 ; +return ; + +case 4 : + __tmp[0 ] =0 ; __tmp[1 ] =0 ; + __tmp[2 ] =0 ; __tmp[3 ] =0 ; +return ; + } + } + __i = __FDSET_LONGS; +while (__i) { + __i--; + *__tmp =0 ; + __tmp++; + } +} + +#endif /* __KERNEL__ */ + +#endif /* __ASM_GENERIC_POSIX_TYPES_H */
include/asm-generic/types.h new file +56 -0
56 lines not on this page · raw message
Quoted 6 lines · Arnd Bergmann
include/asm-generic/types.h new file +0
-0
include/asm-generic/types.h line 9
Quoted 9 lines
include/asm-generic/types.h new file +9
-0@@ -0,0 +1,56 @@ +#ifndef __ASM_GENERIC_TYPES_H +#define __ASM_GENERIC_TYPES_H + +/* +* int-ll64 is used on all 32 bit architectures and on x86-64, +* so use it as a reasonable default. +*/ +#include <asm-generic/int-ll64.h> +
Most 64-bit archs have been migrated to ll64 by now. Alpha, ia64, and mips64 are the remaining exceptions.
include/asm-generic/types.h line 50
Quoted 10 lines
include/asm-generic/types.h new file +10
-0+/* +* DMA addresses may be larger than pointers, but not smaller. +* Do not define the dma64_addr_t type, which never really +* worked. +*/ +#if defined(CONFIG_64BIT ) || defined(CONFIG_PHYS_64BIT ) +typedef u64 dma_addr_t ; +#else +typedef u32 dma_addr_t ; +#endif /* 64 bit DMA pointer */
Is there any specific reason why dma_addr_t is in <asm/types.h>, while phys_addr_t is in
<linux/types.h>?
Furthermore, CONFIG_PHYS_64BIT is used on PPC only. Probably it should be replaced by CONFIG_PHYS_ADDR_T_64BIT, which is always set if CONFIG_64BIT, so the #ifdef above becomes even simpler?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Arnd Bergmann
maintainerQuoted 10 lines · Geert Uytterhoeven
include/asm-generic/types.h line 9
Quoted 6 lines · Arnd Bergmann
include/asm-generic/types.h new file +6
-0+/* +* int-ll64 is used on all 32 bit architectures and on x86-64, +* so use it as a reasonable default. +*/ +#include <asm-generic/int-ll64.h> +Most 64-bit archs have been migrated to ll64 by now. Alpha, ia64, and mips64 are the remaining exceptions.
Right, the comment is stale.
Quoted 6 lines
Quoted 6 lines
include/asm-generic/types.h new file +6
-0+/* +* DMA addresses may be larger than pointers, but not smaller. +* Do not define the dma64_addr_t type, which never really +* worked. +*/ +#if defined(CONFIG_64BIT ) || defined(CONFIG_PHYS_64BIT )
Quoted 8 lines
include/asm-generic/types.h line 50
Quoted 4 lines
include/asm-generic/types.h new file +4
-0+typedef u64 dma_addr_t ; +#else +typedef u32 dma_addr_t ; +#endif /* 64 bit DMA pointer */ Is there any specific reason why
dma_addr_tis in <asm/types.h>, whilephys_addr_tis in
<linux/types.h>?
dma_addr_t is a big mess that was traditionally defined per architecture, in lots of wrong ways, including the misconception of dma64_addr_t. Sparc64 still uses a 32 bit dma_addr_t, possibly because it always uses an IOMMU (?). It can save some space in scatterlists, but might come back to bite us if someone tries to build a sparc64 system with actual 64-bit DMA.
phys_addr_t is a new definition that was added last August (after I did my patch) by Jeremy Fitzhardinge and is for DMA purposes.
Quoted 3 lines
Furthermore,
CONFIG_PHYS_64BITis used on PPC only. Probably it should be replaced byCONFIG_PHYS_ADDR_T_64BIT, which is always set ifCONFIG_64BIT, so the #ifdef above becomes even simpler?
Yes, they could be consolidated now, which would make the default dma_addr_t the same as phys_addr_t, with the possible exception of sparc64.
Arnd <><
--
To unsubscribe from this list: send the line "unsubscribe linux-api" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Arnd Bergmann <[email protected]>
Date: Mon, 30 Mar 2009 17:17:56 +0200
Quoted 6 lines
dma_addr_tis a big mess that was traditionally defined per architecture, in lots of wrong ways, including the misconception ofdma64_addr_t. Sparc64 still uses a 32 bitdma_addr_t, possibly because it always uses an IOMMU (?). It can save some space in scatterlists, but might come back to bite us if someone tries to build a sparc64 system with actual 64-bit DMA.
There is no reason to use anything larger than a 32-bit DMA address type on sparc64, and using 32-bit saves lots of space in many data structures so I am unlikely to ever change this. :-)
--
To unsubscribe from this list: send the line "unsubscribe linux-api" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Arnd Bergmann
maintainerQuoted 3 lines · David Miller
There is no reason to use anything larger than a 32-bit DMA address type on sparc64, and using 32-bit saves lots of space in many data structures so I am unlikely to ever change this. :-)
Ok, fair enough. So I'll change my asm-generic/types.h to use
#ifndef dma_addr_t
#ifdef CONFIG_PHYS_ADDR_T_64BIT
typedef u64 dma_addr_t;
#else
typedef u32 dma_addr_t;
#endif /* CONFIG_PHYS_ADDR_T_64BIT */
#endif /* dma_addr_t */
If you eventually want to use the the generic version, you just need to add
#define dma_addr_t dma_addr_t
before the #include. Or you just ignore the asm-generic version and don't have to do anything.
Arnd <><
--
To unsubscribe from this list: send the line "unsubscribe linux-api" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Arnd Bergmann
maintainerRFC 1/1 asm-generic/{unistd,types,posix_types}.h for new arch
In reply to Arnd BergmannI've spent more time on my asm-generic patches and believe I now have an unistd.h implementation that can be used by the new architectures (score and microblaze) so they don't have to go through the error-prone process of coming up with their own lists.
It would be good if more people could in particular look over the system call lists. I have left the syscalls that I think should be dropped in #ifdef __ARCH_WANT_SYSCALL_{DEPRECATED,NO_AT,NO_FLAGS,OFF_T} so that it becomes easy to reenable them temporarily while porting the libc, and to easily see which ones get left out.
I have also changed checksyscalls.sh to stop complaining when the old syscalls are not present.
--- include/asm-generic/posix_types.h | 162 ++++++ include/asm-generic/types.h | 63 ++ include/asm-generic/unistd.h | 829 +++++++++++++++++++++++++++++ kernel/Makefile | 1 + kernel/syscall_table.c | 12 + scripts/checksyscalls.sh | 93 +++- 6 files changed, 1157 insertions(+), 3 deletions(-)
include/asm-generic/posix_types.h new file +162 -0
@@ -0,0 +1,162 @@ +#ifndef __ASM_GENERIC_POSIX_TYPES_H +#define __ASM_GENERIC_POSIX_TYPES_H + +#include <asm/types.h> + +/* +* This file is generally used by user-level software, so you need to +* be a little careful about namespace pollution etc. +* +* First the types that are often defined in different ways across +* architectures, so that you can override them. +*/ + +#ifndef __kernel_ino_t +typedef unsigned long __kernel_ino_t ; +#endif + +#ifndef __kernel_mode_t +typedef unsigned int __kernel_mode_t ; +#endif + +#ifndef __kernel_nlink_t +typedef unsigned long __kernel_nlink_t ; +#endif + +#ifndef __kernel_pid_t +typedef int __kernel_pid_t ; +#endif + +#ifndef __kernel_ipc_pid_t +typedef int __kernel_ipc_pid_t ; +#endif + +#ifndef __kernel_uid_t +typedef unsigned int __kernel_uid_t ; +typedef unsigned int __kernel_gid_t ; +#endif + +#ifndef __kernel_suseconds_t +typedef long __kernel_suseconds_t ; +#endif + +#ifndef __kernel_daddr_t +typedef int __kernel_daddr_t ; +#endif + +#ifndef __kernel_uid32_t +typedef __kernel_uid_t __kernel_uid32_t ; +typedef __kernel_gid_t __kernel_gid32_t ; +#endif + +#ifndef __kernel_old_uid_t +typedef __kernel_uid_t __kernel_old_uid_t ; +typedef __kernel_gid_t __kernel_old_gid_t ; +#endif + +#ifndef __kernel_old_dev_t +typedef unsigned int __kernel_old_dev_t ; +#endif + +#ifndef __kernel_size_t +#if __BITS_PER_LONG !=64 +typedef unsigned int __kernel_size_t ; +typedef int __kernel_ssize_t ; +typedef int __kernel_ptrdiff_t ; +#else +typedef unsigned long __kernel_size_t ; +typedef long __kernel_ssize_t ; +typedef long __kernel_ptrdiff_t ; +#endif +#endif + +/* +* anything below here should be completely generic +*/ +typedef long __kernel_off_t ; +typedef long long __kernel_loff_t ; +typedef long __kernel_time_t ; +typedef long __kernel_clock_t ; +typedef int __kernel_timer_t ; +typedef int __kernel_clockid_t ; +typedef char *__kernel_caddr_t ; +typedef unsigned short __kernel_uid16_t ; +typedef unsigned short __kernel_gid16_t ; + +typedef struct { +int val[2 ]; +}__kernel_fsid_t ; + +#ifdef __KERNEL__ + +#undef __FD_SET +static inline void __FD_SET (unsigned long __fd,__kernel_fd_set *__fdsetp) +{ +unsigned long __tmp = __fd / __NFDBITS; +unsigned long __rem = __fd % __NFDBITS; + __fdsetp->fds_bits[__tmp] |= (1UL <<__rem); +} + +#undef __FD_CLR +static inline void __FD_CLR (unsigned long __fd,__kernel_fd_set *__fdsetp) +{ +unsigned long __tmp = __fd / __NFDBITS; +unsigned long __rem = __fd % __NFDBITS; + __fdsetp->fds_bits[__tmp] &= ~(1UL <<__rem); +} + +#undef __FD_ISSET +static inline int __FD_ISSET (unsigned long __fd,const __kernel_fd_set *__p) +{ +unsigned long __tmp = __fd / __NFDBITS; +unsigned long __rem = __fd % __NFDBITS; +return (__p->fds_bits[__tmp] & (1UL <<__rem)) !=0 ; +} + +/* +* This will unroll the loop for the normal constant case (8 ints, +* for a 256-bit fd_set) +*/ +#undef __FD_ZERO +static inline void __FD_ZERO (__kernel_fd_set *__p) +{ +unsigned long *__tmp = __p->fds_bits; +int __i; + +if (__builtin_constant_p (__FDSET_LONGS)) { +switch (__FDSET_LONGS) { +case 16 : + __tmp[0 ] =0 ; __tmp[1 ] =0 ; + __tmp[2 ] =0 ; __tmp[3 ] =0 ; + __tmp[4 ] =0 ; __tmp[5 ] =0 ; + __tmp[6 ] =0 ; __tmp[7 ] =0 ; + __tmp[8 ] =0 ; __tmp[9 ] =0 ; + __tmp[10 ] =0 ; __tmp[11 ] =0 ; + __tmp[12 ] =0 ; __tmp[13 ] =0 ; + __tmp[14 ] =0 ; __tmp[15 ] =0 ; +return ; + +case 8 : + __tmp[0 ] =0 ; __tmp[1 ] =0 ; + __tmp[2 ] =0 ; __tmp[3 ] =0 ; + __tmp[4 ] =0 ; __tmp[5 ] =0 ; + __tmp[6 ] =0 ; __tmp[7 ] =0 ; +return ; + +case 4 : + __tmp[0 ] =0 ; __tmp[1 ] =0 ; + __tmp[2 ] =0 ; __tmp[3 ] =0 ; +return ; + } + } + __i = __FDSET_LONGS; +while (__i) { + __i--; + *__tmp =0 ; + __tmp++; + } +} + +#endif /* __KERNEL__ */ + +#endif /* __ASM_GENERIC_POSIX_TYPES_H */
include/asm-generic/types.h new file +63 -0
63 lines not on this page · raw message
include/asm-generic/unistd.h new file +829 -0
829 lines not on this page · raw message
kernel/Makefile +1 -0
@@ -93,6 +93,7 @@ obj-$(CONFIG_HAVE_GENERIC_DMA_COHERENT) += dma-coherent.o obj-$(CONFIG_FUNCTION_TRACER) += trace/ obj-$(CONFIG_TRACING) += trace/ obj-$(CONFIG_SMP) += sched_cpupri.o +obj-$(CONFIG_GENERIC_SYSCALL_TABLE) += syscall_table.o ifneq ($(CONFIG_SCHED_OMIT_FRAME_POINTER),y) # According to Alan Modra <[email protected]>, the -fno-omit-frame-pointer is
kernel/syscall_table.c new file +12 -0
@@ -0,0 +1,12 @@ +#include <linux/syscalls.h> +#include <linux/signal.h> +#include <linux/unistd.h> + +#include <asm/syscalls.h> + +#undef __SYSCALL +#define __SYSCALL (nr, call) [nr] (call), + +void *sys_call_table[] = { +#include <asm/unistd.h> +};
scripts/checksyscalls.sh +90 -3
131 lines not on this page · raw message
--
To unsubscribe from this list: send the line "unsubscribe linux-api" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC] asm-generic/{unistd,types,posix_types}.h for new arch
Quoted 4 lines · Arnd Bergmann
I've spent more time on my asm-generic patches and believe I now have an
unistd.himplementation that can be used by the new architectures (score and microblaze) so they don't have to go through the error-prone process of coming up with their own lists.
I appreciate your work on this, it should make porting to a new arch much less error-prone.
Quoted 206 lines
It would be good if more people could in particular look over the system call lists. I have left the syscalls that I think should be dropped in #ifdef __ARCH_WANT_SYSCALL_{DEPRECATED,NO_AT,NO_FLAGS,OFF_T} so that it becomes easy to reenable them temporarily while porting the libc, and to easily see which ones get left out.
I have also changed
checksyscalls.shto stop complaining when the old syscalls are not present.Signed-off-by Arnd Bergmann <[email protected]>---
include/asm-generic/posix_types.h | 162 ++++++include/asm-generic/types.h| 63 ++include/asm-generic/unistd.h| 829 +++++++++++++++++++++++++++++ kernel/Makefile | 1 +kernel/syscall_table.c| 12 +scripts/checksyscalls.sh| 93 +++-6 files changed, 1157 insertions(+), 3 deletions(-)include/asm-generic/posix_types.h new file +162
-0@@ -0,0 +1,162 @@ +#ifndef __ASM_GENERIC_POSIX_TYPES_H +#define __ASM_GENERIC_POSIX_TYPES_H + +#include <asm/types.h> + +/* +* This file is generally used by user-level software, so you need to +* be a little careful about namespace pollution etc. +* +* First the types that are often defined in different ways across +* architectures, so that you can override them. +*/ + +#ifndef __kernel_ino_t +typedef unsigned long __kernel_ino_t; +#endif + +#ifndef __kernel_mode_t +typedef unsigned int __kernel_mode_t; +#endif + +#ifndef __kernel_nlink_t +typedef unsigned long __kernel_nlink_t; +#endif + +#ifndef __kernel_pid_t +typedef int __kernel_pid_t; +#endif + +#ifndef __kernel_ipc_pid_t +typedef int __kernel_ipc_pid_t; +#endif + +#ifndef __kernel_uid_t +typedef unsigned int __kernel_uid_t; +typedef unsigned int __kernel_gid_t; +#endif + +#ifndef __kernel_suseconds_t +typedef long __kernel_suseconds_t; +#endif + +#ifndef __kernel_daddr_t +typedef int __kernel_daddr_t; +#endif + +#ifndef __kernel_uid32_t +typedef __kernel_uid_t __kernel_uid32_t ; +typedef __kernel_gid_t __kernel_gid32_t ; +#endif + +#ifndef __kernel_old_uid_t +typedef __kernel_uid_t __kernel_old_uid_t ; +typedef __kernel_gid_t __kernel_old_gid_t ; +#endif + +#ifndef __kernel_old_dev_t +typedef unsigned int __kernel_old_dev_t; +#endif + +#ifndef __kernel_size_t +#if __BITS_PER_LONG !=64 +typedef unsigned int __kernel_size_t; +typedef int __kernel_ssize_t; +typedef int __kernel_ptrdiff_t; +#else +typedef unsigned long __kernel_size_t; +typedef long __kernel_ssize_t; +typedef long __kernel_ptrdiff_t; +#endif +#endif + +/* +* anything below here should be completely generic +*/ +typedef long __kernel_off_t; +typedef long long __kernel_loff_t; +typedef long __kernel_time_t; +typedef long __kernel_clock_t; +typedef int __kernel_timer_t; +typedef int __kernel_clockid_t; +typedef char * __kernel_caddr_t; +typedef unsigned short __kernel_uid16_t ; +typedef unsigned short __kernel_gid16_t ; + +typedef struct { + int val[2]; +}__kernel_fsid_t ; + +#ifdef __KERNEL__ + +#undef __FD_SET +static inline void __FD_SET (unsigned long __fd,__kernel_fd_set *__fdsetp) +{ + unsigned long __tmp = __fd / __NFDBITS; + unsigned long __rem = __fd % __NFDBITS; + __fdsetp->fds_bits[__tmp] |= (1UL<<__rem); +} + +#undef __FD_CLR +static inline void __FD_CLR (unsigned long __fd,__kernel_fd_set *__fdsetp) +{ + unsigned long __tmp = __fd / __NFDBITS; + unsigned long __rem = __fd % __NFDBITS; + __fdsetp->fds_bits[__tmp] &= ~(1UL<<__rem); +} + +#undef __FD_ISSET +static inline int __FD_ISSET (unsigned long __fd,const __kernel_fd_set *__p) +{ + unsigned long __tmp = __fd / __NFDBITS; + unsigned long __rem = __fd % __NFDBITS; + return (__p->fds_bits[__tmp] & (1UL<<__rem)) != 0; +} + +/* +* This will unroll the loop for the normal constant case (8 ints, +* for a 256-bit fd_set) +*/ +#undef __FD_ZERO +static inline void __FD_ZERO (__kernel_fd_set *__p) +{ + unsigned long *__tmp = __p->fds_bits; + int __i; + + if (__builtin_constant_p(__FDSET_LONGS)) { + switch (__FDSET_LONGS) { + case 16: + __tmp[ 0] = 0; __tmp[ 1] = 0; + __tmp[ 2] = 0; __tmp[ 3] = 0; + __tmp[ 4] = 0; __tmp[ 5] = 0; + __tmp[ 6] = 0; __tmp[ 7] = 0; + __tmp[ 8] = 0; __tmp[ 9] = 0; + __tmp[10] = 0; __tmp[11] = 0; + __tmp[12] = 0; __tmp[13] = 0; + __tmp[14] = 0; __tmp[15] = 0; + return; + + case 8: + __tmp[ 0] = 0; __tmp[ 1] = 0; + __tmp[ 2] = 0; __tmp[ 3] = 0; + __tmp[ 4] = 0; __tmp[ 5] = 0; + __tmp[ 6] = 0; __tmp[ 7] = 0; + return; + + case 4: + __tmp[ 0] = 0; __tmp[ 1] = 0; + __tmp[ 2] = 0; __tmp[ 3] = 0; + return; + } + } + __i = __FDSET_LONGS; + while (__i) { + __i--; + *__tmp = 0; + __tmp++; + } +} + +#endif /* __KERNEL__ */ + +#endif /* __ASM_GENERIC_POSIX_TYPES_H */ include/asm-generic/types.h new file +12
-0@@ -0,0 +1,63 @@ +#ifndef _ASM_GENERIC_TYPES_H +#define _ASM_GENERIC_TYPES_H + +/* +* int-ll64 is used practically everywhere now, +* so use it as a reasonable default. +*/ +#include <asm-generic/int-ll64.h> + +#ifndef __ASSEMBLY__ + +typedef unsigned short umode_t ;
include/asm-generic/types.h line 22
Quoted 10 lines
include/asm-generic/types.h new file +10
-0+ +#endif /* __ASSEMBLY__ */ + +/* +* There seems to be no way of detecting this automatically from user +* space, so 64 bit architectures should override this in their types.h. +*/ +#ifndef __BITS_PER_LONG +#define __BITS_PER_LONG 32 +#endif
Why is this define required? It doesn't seem to be in any existing headers.
Quoted 31 lines
include/asm-generic/types.h new file +31
-0+ +/* +* These aren't exported outside the kernel to avoid name space clashes +*/ +#ifdef __KERNEL__ + +#ifdef CONFIG_64BIT +#define BITS_PER_LONG 64 +#else +#define BITS_PER_LONG 32 +#endif /* CONFIG_64BIT */ + +#if BITS_PER_LONG != __BITS_PER_LONG +#error cannot determine word size +#endif + +#ifndef __ASSEMBLY__ + +/* +* DMA addresses may be very different from physical addresses +* and pointers. i386 and powerpc may have 64 bit DMA on 32 bit +* systems, while sparc64 uses 32 bit DMA addresses for 64 bit +* physical addresses. +* This default defines dma_addr_t to have the same size as +* phys_addr_t, which is the most common way. +* Do not define the dma64_addr_t type, which never really +* worked. +*/ +#ifndef dma_addr_t +#ifdef CONFIG_PHYS_ADDR_T_64BIT +typedef u64 dma_addr_t ;
include/asm-generic/types.h line 63
Quoted 10 lines
include/asm-generic/types.h new file +10
-0+#else +typedef u32 dma_addr_t ; +#endif /* CONFIG_PHYS_ADDR_T_64BIT */ +#endif /* dma_addr_t */ + +#endif /* __ASSEMBLY__ */ + +#endif /* __KERNEL__ */ + +#endif /* _ASM_GENERIC_TYPES_H */
--
To unsubscribe from this list: send the line "unsubscribe linux-api" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Arnd Bergmann
maintainerRe: [RFC] asm-generic/{unistd,types,posix_types}.h for new arch
Quoted 8 lines · Will Newton
include/asm-generic/types.h line 22
Quoted 6 lines
+ * There seems to be no way of detecting this automatically from user
+ * space, so 64 bit architectures should override this in theirtypes.h.
+ */include/asm-generic/types.h new file +3
-0+#ifndef __BITS_PER_LONG +#define __BITS_PER_LONG 32 +#endif Why is this define required? It doesn't seem to be in any existing headers.
Unfortunately, there is no generic way to detect the word size yet, but every architecture uses its own preprocessor macro (__x86_64__, __s390x__, __ppc64__). We also can't use CONFIG_64BIT in an user-exported interface header file, because the use space can also be compiled for 32 bits when the kernel uses 64 bits.
__BITS_PER_LONG is actually defined in parisc now, and was the result of the last time we had this discussion. I'm still thinking about making a separate <asm/bitsperlong.h> header, or a <asm/bits.h> that also contains the respective __BIG_ENDIAN/__LITTLE_ENDIAN macros which have the same problem. The advantage would be that other header files (e.g. unistd.h) can known the word size without getting the whole types.h name space.
Arnd <><
Re: [RFC] asm-generic/{unistd,types,posix_types}.h for new arch
Quoted 7 lines · Arnd Bergmann
Unfortunately, there is no generic way to detect the word size yet, but every architecture uses its own preprocessor macro (
__x86_64__,__s390x__,__ppc64__). We also can't useCONFIG_64BITin an user-exported interface header file, because the use space can also be compiled for 32 bits when the kernel uses 64 bits.
Actually, gcc does have the _LP64 and __SIZEOF_POINTER__ macros (as well as __CHAR_BIT__), although I don't know how far back it does have that.
If it has been with us for long enough it might be possible to
switch over to using panarch macros.
-hpa
Re: [RFC] asm-generic/{unistd,types,posix_types}.h for new arch
Quoted 4 lines
Actually, gcc does have the
_LP64and__SIZEOF_POINTER__macros (as well as__CHAR_BIT__), although I don't know how far back it does have that.
If it has been with us for long enough it might be possible to
switch over to using panarch macros.
Worst case the oldest compilers had <limits.h> and "#if ULONG_MAX == 0xffffffffUL", though I wouldn't like myself to be using a setup where <limits.h> got pulled in.
Thanks,
Roland
Arnd Bergmann
maintainerRe: [RFC] asm-generic/{unistd,types,posix_types}.h for new arch
Quoted 4 lines · Roland McGrath
Quoted 4 lines
Actually, gcc does have the
_LP64and__SIZEOF_POINTER__macros (as well as__CHAR_BIT__), although I don't know how far back it does have that. If it has been with us for long enough it might be possible to switch over to using panarch macros.
For user space, we also need to consider non-gcc compilers that could have a different set of macros. As long as we don't start relying on any new ones besides those we already use (__x86_64__, __s390x__, __powerpc64__, __mips64, __arch64__), we at least don't break anything accidentally.
Quoted 3 lines
Worst case the oldest compilers had <
limits.h> and "#ifULONG_MAX==0xffffffffUL", though I wouldn't like myself to be using a setup where <limits.h> got pulled in.
That would of course work with non-gcc, but we are really not allowed to pull in <limits.h> from places like <types.h> where it would be needed then.
Arnd <><
--
To unsubscribe from this list: send the line "unsubscribe linux-api" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Arnd Bergmann
maintainerRe: [RFC] asm-generic/{unistd,types,posix_types}.h for new arch
In reply to Arnd Bergmanninclude/asm-generic/unistd.h line 191
Quoted 3 lines · Arnd Bergmann
include/asm-generic/unistd.h new file +3
-0+/* fs/readdir.c */ +#define __NR3264_getdents __LINE__ +__SC_3264 (__NR3264_getdents, sys_getdents64, sys_getdents)
Just noticed myself that getdents64 changed more than just off_t (namely the file type) and should be used even on 64-bit platforms, so I'm putting sys_getdents into my deprecated list now.
Arnd <><