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