gma500: continue abstracting platform specific code
[linux-2.6/kvm.git] / include / asm-generic / posix_types.h
blob3dab00860e7183f555c10130f683a716f2d2b448
1 #ifndef __ASM_GENERIC_POSIX_TYPES_H
2 #define __ASM_GENERIC_POSIX_TYPES_H
4 #include <asm/bitsperlong.h>
5 /*
6 * This file is generally used by user-level software, so you need to
7 * be a little careful about namespace pollution etc.
9 * First the types that are often defined in different ways across
10 * architectures, so that you can override them.
13 #ifndef __kernel_ino_t
14 typedef unsigned long __kernel_ino_t;
15 #endif
17 #ifndef __kernel_mode_t
18 typedef unsigned int __kernel_mode_t;
19 #endif
21 #ifndef __kernel_nlink_t
22 typedef unsigned long __kernel_nlink_t;
23 #endif
25 #ifndef __kernel_pid_t
26 typedef int __kernel_pid_t;
27 #endif
29 #ifndef __kernel_ipc_pid_t
30 typedef int __kernel_ipc_pid_t;
31 #endif
33 #ifndef __kernel_uid_t
34 typedef unsigned int __kernel_uid_t;
35 typedef unsigned int __kernel_gid_t;
36 #endif
38 #ifndef __kernel_suseconds_t
39 typedef long __kernel_suseconds_t;
40 #endif
42 #ifndef __kernel_daddr_t
43 typedef int __kernel_daddr_t;
44 #endif
46 #ifndef __kernel_uid32_t
47 typedef __kernel_uid_t __kernel_uid32_t;
48 typedef __kernel_gid_t __kernel_gid32_t;
49 #endif
51 #ifndef __kernel_old_uid_t
52 typedef __kernel_uid_t __kernel_old_uid_t;
53 typedef __kernel_gid_t __kernel_old_gid_t;
54 #endif
56 #ifndef __kernel_old_dev_t
57 typedef unsigned int __kernel_old_dev_t;
58 #endif
61 * Most 32 bit architectures use "unsigned int" size_t,
62 * and all 64 bit architectures use "unsigned long" size_t.
64 #ifndef __kernel_size_t
65 #if __BITS_PER_LONG != 64
66 typedef unsigned int __kernel_size_t;
67 typedef int __kernel_ssize_t;
68 typedef int __kernel_ptrdiff_t;
69 #else
70 typedef unsigned long __kernel_size_t;
71 typedef long __kernel_ssize_t;
72 typedef long __kernel_ptrdiff_t;
73 #endif
74 #endif
77 * anything below here should be completely generic
79 typedef long __kernel_off_t;
80 typedef long long __kernel_loff_t;
81 typedef long __kernel_time_t;
82 typedef long __kernel_clock_t;
83 typedef int __kernel_timer_t;
84 typedef int __kernel_clockid_t;
85 typedef char * __kernel_caddr_t;
86 typedef unsigned short __kernel_uid16_t;
87 typedef unsigned short __kernel_gid16_t;
89 typedef struct {
90 int val[2];
91 } __kernel_fsid_t;
93 #ifdef __KERNEL__
95 #undef __FD_SET
96 static inline void __FD_SET(unsigned long __fd, __kernel_fd_set *__fdsetp)
98 unsigned long __tmp = __fd / __NFDBITS;
99 unsigned long __rem = __fd % __NFDBITS;
100 __fdsetp->fds_bits[__tmp] |= (1UL<<__rem);
103 #undef __FD_CLR
104 static inline void __FD_CLR(unsigned long __fd, __kernel_fd_set *__fdsetp)
106 unsigned long __tmp = __fd / __NFDBITS;
107 unsigned long __rem = __fd % __NFDBITS;
108 __fdsetp->fds_bits[__tmp] &= ~(1UL<<__rem);
111 #undef __FD_ISSET
112 static inline int __FD_ISSET(unsigned long __fd, const __kernel_fd_set *__p)
114 unsigned long __tmp = __fd / __NFDBITS;
115 unsigned long __rem = __fd % __NFDBITS;
116 return (__p->fds_bits[__tmp] & (1UL<<__rem)) != 0;
120 * This will unroll the loop for the normal constant case (8 ints,
121 * for a 256-bit fd_set)
123 #undef __FD_ZERO
124 static inline void __FD_ZERO(__kernel_fd_set *__p)
126 unsigned long *__tmp = __p->fds_bits;
127 int __i;
129 if (__builtin_constant_p(__FDSET_LONGS)) {
130 switch (__FDSET_LONGS) {
131 case 16:
132 __tmp[ 0] = 0; __tmp[ 1] = 0;
133 __tmp[ 2] = 0; __tmp[ 3] = 0;
134 __tmp[ 4] = 0; __tmp[ 5] = 0;
135 __tmp[ 6] = 0; __tmp[ 7] = 0;
136 __tmp[ 8] = 0; __tmp[ 9] = 0;
137 __tmp[10] = 0; __tmp[11] = 0;
138 __tmp[12] = 0; __tmp[13] = 0;
139 __tmp[14] = 0; __tmp[15] = 0;
140 return;
142 case 8:
143 __tmp[ 0] = 0; __tmp[ 1] = 0;
144 __tmp[ 2] = 0; __tmp[ 3] = 0;
145 __tmp[ 4] = 0; __tmp[ 5] = 0;
146 __tmp[ 6] = 0; __tmp[ 7] = 0;
147 return;
149 case 4:
150 __tmp[ 0] = 0; __tmp[ 1] = 0;
151 __tmp[ 2] = 0; __tmp[ 3] = 0;
152 return;
155 __i = __FDSET_LONGS;
156 while (__i) {
157 __i--;
158 *__tmp = 0;
159 __tmp++;
163 #endif /* __KERNEL__ */
165 #endif /* __ASM_GENERIC_POSIX_TYPES_H */