consolidate umode_t declarations
[linux-2.6.git] / arch / sparc / include / asm / posix_types.h
1 /*
2  * This file is generally used by user-level software, so you need to
3  * be a little careful about namespace pollution etc.  Also, we cannot
4  * assume GCC is being used.
5  */
6
7 #ifndef __SPARC_POSIX_TYPES_H
8 #define __SPARC_POSIX_TYPES_H
9
10 #if defined(__sparc__) && defined(__arch64__)
11 /* sparc 64 bit */
12 typedef unsigned long          __kernel_size_t;
13 typedef long                   __kernel_ssize_t;
14 typedef long                   __kernel_ptrdiff_t;
15 typedef long                   __kernel_time_t;
16 typedef long                   __kernel_clock_t;
17 typedef int                    __kernel_pid_t;
18 typedef int                    __kernel_ipc_pid_t;
19 typedef unsigned int           __kernel_uid_t;
20 typedef unsigned int           __kernel_gid_t;
21 typedef unsigned long          __kernel_ino_t;
22 typedef unsigned int           __kernel_mode_t;
23 typedef unsigned int           __kernel_nlink_t;
24 typedef int                    __kernel_daddr_t;
25 typedef long                   __kernel_off_t;
26 typedef char *                 __kernel_caddr_t;
27 typedef unsigned short         __kernel_uid16_t;
28 typedef unsigned short         __kernel_gid16_t;
29 typedef int                    __kernel_clockid_t;
30 typedef int                    __kernel_timer_t;
31
32 typedef unsigned short         __kernel_old_uid_t;
33 typedef unsigned short         __kernel_old_gid_t;
34 typedef __kernel_uid_t         __kernel_uid32_t;
35 typedef __kernel_gid_t         __kernel_gid32_t;
36
37 typedef unsigned int           __kernel_old_dev_t;
38
39 /* Note this piece of asymmetry from the v9 ABI.  */
40 typedef int                    __kernel_suseconds_t;
41
42 #else
43 /* sparc 32 bit */
44
45 typedef unsigned int           __kernel_size_t;
46 typedef int                    __kernel_ssize_t;
47 typedef long int               __kernel_ptrdiff_t;
48 typedef long                   __kernel_time_t;
49 typedef long                   __kernel_suseconds_t;
50 typedef long                   __kernel_clock_t;
51 typedef int                    __kernel_pid_t;
52 typedef unsigned short         __kernel_ipc_pid_t;
53 typedef unsigned short         __kernel_uid_t;
54 typedef unsigned short         __kernel_gid_t;
55 typedef unsigned long          __kernel_ino_t;
56 typedef unsigned short         __kernel_mode_t;
57 typedef short                  __kernel_nlink_t;
58 typedef long                   __kernel_daddr_t;
59 typedef long                   __kernel_off_t;
60 typedef char *                 __kernel_caddr_t;
61 typedef unsigned short         __kernel_uid16_t;
62 typedef unsigned short         __kernel_gid16_t;
63 typedef unsigned int           __kernel_uid32_t;
64 typedef unsigned int           __kernel_gid32_t;
65 typedef unsigned short         __kernel_old_uid_t;
66 typedef unsigned short         __kernel_old_gid_t;
67 typedef unsigned short         __kernel_old_dev_t;
68 typedef int                    __kernel_clockid_t;
69 typedef int                    __kernel_timer_t;
70
71 #endif /* defined(__sparc__) && defined(__arch64__) */
72
73 #ifdef __GNUC__
74 typedef long long              __kernel_loff_t;
75 #endif
76
77 typedef struct {
78         int     val[2];
79 } __kernel_fsid_t;
80
81 #ifdef __KERNEL__
82
83 #undef __FD_SET
84 static inline void __FD_SET(unsigned long fd, __kernel_fd_set *fdsetp)
85 {
86         unsigned long _tmp = fd / __NFDBITS;
87         unsigned long _rem = fd % __NFDBITS;
88         fdsetp->fds_bits[_tmp] |= (1UL<<_rem);
89 }
90
91 #undef __FD_CLR
92 static inline void __FD_CLR(unsigned long fd, __kernel_fd_set *fdsetp)
93 {
94         unsigned long _tmp = fd / __NFDBITS;
95         unsigned long _rem = fd % __NFDBITS;
96         fdsetp->fds_bits[_tmp] &= ~(1UL<<_rem);
97 }
98
99 #undef __FD_ISSET
100 static inline int __FD_ISSET(unsigned long fd, __const__ __kernel_fd_set *p)
101 {
102         unsigned long _tmp = fd / __NFDBITS;
103         unsigned long _rem = fd % __NFDBITS;
104         return (p->fds_bits[_tmp] & (1UL<<_rem)) != 0;
105 }
106
107 /*
108  * This will unroll the loop for the normal constant cases (8 or 32 longs,
109  * for 256 and 1024-bit fd_sets respectively)
110  */
111 #undef __FD_ZERO
112 static inline void __FD_ZERO(__kernel_fd_set *p)
113 {
114         unsigned long *tmp = p->fds_bits;
115         int i;
116
117         if (__builtin_constant_p(__FDSET_LONGS)) {
118                 switch (__FDSET_LONGS) {
119                         case 32:
120                           tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0;
121                           tmp[ 4] = 0; tmp[ 5] = 0; tmp[ 6] = 0; tmp[ 7] = 0;
122                           tmp[ 8] = 0; tmp[ 9] = 0; tmp[10] = 0; tmp[11] = 0;
123                           tmp[12] = 0; tmp[13] = 0; tmp[14] = 0; tmp[15] = 0;
124                           tmp[16] = 0; tmp[17] = 0; tmp[18] = 0; tmp[19] = 0;
125                           tmp[20] = 0; tmp[21] = 0; tmp[22] = 0; tmp[23] = 0;
126                           tmp[24] = 0; tmp[25] = 0; tmp[26] = 0; tmp[27] = 0;
127                           tmp[28] = 0; tmp[29] = 0; tmp[30] = 0; tmp[31] = 0;
128                           return;
129                         case 16:
130                           tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0;
131                           tmp[ 4] = 0; tmp[ 5] = 0; tmp[ 6] = 0; tmp[ 7] = 0;
132                           tmp[ 8] = 0; tmp[ 9] = 0; tmp[10] = 0; tmp[11] = 0;
133                           tmp[12] = 0; tmp[13] = 0; tmp[14] = 0; tmp[15] = 0;
134                           return;
135                         case 8:
136                           tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0;
137                           tmp[ 4] = 0; tmp[ 5] = 0; tmp[ 6] = 0; tmp[ 7] = 0;
138                           return;
139                         case 4:
140                           tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0;
141                           return;
142                 }
143         }
144         i = __FDSET_LONGS;
145         while (i) {
146                 i--;
147                 *tmp = 0;
148                 tmp++;
149         }
150 }
151
152 #endif /* __KERNEL__ */
153 #endif /* __SPARC_POSIX_TYPES_H */