1 /*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1996, 1997, 1998, 1999, 2000 by Ralf Baechle
7 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
8 */
9 #ifndef _ASM_POSIX_TYPES_H
10 #define _ASM_POSIX_TYPES_H
11
12 /*
13 * This file is generally used by user-level software, so you need to
14 * be a little careful about namespace pollution etc. Also, we cannot
15 * assume GCC is being used.
16 */
17
18 typedef unsigned int __kernel_dev_t;
19 typedef unsigned long __kernel_ino_t;
20 typedef unsigned int __kernel_mode_t;
21 typedef unsigned int __kernel_nlink_t;
22 typedef long __kernel_off_t;
23 typedef int __kernel_pid_t;
24 typedef int __kernel_ipc_pid_t;
25 typedef int __kernel_uid_t;
26 typedef int __kernel_gid_t;
27 typedef unsigned long __kernel_size_t;
28 typedef long __kernel_ssize_t;
29 typedef long __kernel_ptrdiff_t;
30 typedef long __kernel_time_t;
31 typedef long __kernel_suseconds_t;
32 typedef long __kernel_clock_t;
33 typedef long __kernel_daddr_t;
34 typedef char * __kernel_caddr_t;
35
36 typedef unsigned short __kernel_uid16_t;
37 typedef unsigned short __kernel_gid16_t;
38 typedef int __kernel_uid32_t;
39 typedef int __kernel_gid32_t;
40 typedef __kernel_uid_t __kernel_old_uid_t;
41 typedef __kernel_gid_t __kernel_old_gid_t;
42
43 #ifdef __GNUC__
44 typedef long long __kernel_loff_t;
45 #endif
46
47 typedef struct {
48 int val[2];
49 } __kernel_fsid_t;
50
51 /* Now 32bit compatibility types */
52 typedef unsigned int __kernel_dev_t32;
53 typedef unsigned int __kernel_ino_t32;
54 typedef unsigned int __kernel_mode_t32;
55 typedef unsigned int __kernel_nlink_t32;
56 typedef int __kernel_off_t32;
57 typedef int __kernel_pid_t32;
58 typedef int __kernel_ipc_pid_t32;
59 typedef int __kernel_uid_t32;
60 typedef int __kernel_gid_t32;
61 typedef unsigned int __kernel_size_t32;
62 typedef int __kernel_ssize_t32;
63 typedef int __kernel_ptrdiff_t32;
64 typedef int __kernel_time_t32;
65 typedef int __kernel_suseconds_t32;
66 typedef int __kernel_clock_t32;
67 typedef int __kernel_daddr_t32;
68 typedef unsigned int __kernel_caddr_t32;
69 typedef __kernel_fsid_t __kernel_fsid_t32;
70
71 #if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
72
73 #undef __FD_SET
__FD_SET(unsigned long __fd,__kernel_fd_set * __fdsetp)74 static __inline__ void __FD_SET(unsigned long __fd, __kernel_fd_set *__fdsetp)
75 {
76 unsigned long __tmp = __fd / __NFDBITS;
77 unsigned long __rem = __fd % __NFDBITS;
78 __fdsetp->fds_bits[__tmp] |= (1UL<<__rem);
79 }
80
81 #undef __FD_CLR
__FD_CLR(unsigned long __fd,__kernel_fd_set * __fdsetp)82 static __inline__ void __FD_CLR(unsigned long __fd, __kernel_fd_set *__fdsetp)
83 {
84 unsigned long __tmp = __fd / __NFDBITS;
85 unsigned long __rem = __fd % __NFDBITS;
86 __fdsetp->fds_bits[__tmp] &= ~(1UL<<__rem);
87 }
88
89 #undef __FD_ISSET
__FD_ISSET(unsigned long __fd,const __kernel_fd_set * __p)90 static __inline__ int __FD_ISSET(unsigned long __fd, const __kernel_fd_set *__p)
91 {
92 unsigned long __tmp = __fd / __NFDBITS;
93 unsigned long __rem = __fd % __NFDBITS;
94 return (__p->fds_bits[__tmp] & (1UL<<__rem)) != 0;
95 }
96
97 /*
98 * This will unroll the loop for the normal constant case (8 ints,
99 * for a 256-bit fd_set)
100 */
101 #undef __FD_ZERO
__FD_ZERO(__kernel_fd_set * __p)102 static __inline__ void __FD_ZERO(__kernel_fd_set *__p)
103 {
104 unsigned long *__tmp = __p->fds_bits;
105 int __i;
106
107 if (__builtin_constant_p(__FDSET_LONGS)) {
108 switch (__FDSET_LONGS) {
109 case 16:
110 __tmp[ 0] = 0; __tmp[ 1] = 0;
111 __tmp[ 2] = 0; __tmp[ 3] = 0;
112 __tmp[ 4] = 0; __tmp[ 5] = 0;
113 __tmp[ 6] = 0; __tmp[ 7] = 0;
114 __tmp[ 8] = 0; __tmp[ 9] = 0;
115 __tmp[10] = 0; __tmp[11] = 0;
116 __tmp[12] = 0; __tmp[13] = 0;
117 __tmp[14] = 0; __tmp[15] = 0;
118 return;
119
120 case 8:
121 __tmp[ 0] = 0; __tmp[ 1] = 0;
122 __tmp[ 2] = 0; __tmp[ 3] = 0;
123 __tmp[ 4] = 0; __tmp[ 5] = 0;
124 __tmp[ 6] = 0; __tmp[ 7] = 0;
125 return;
126
127 case 4:
128 __tmp[ 0] = 0; __tmp[ 1] = 0;
129 __tmp[ 2] = 0; __tmp[ 3] = 0;
130 return;
131 }
132 }
133 __i = __FDSET_LONGS;
134 while (__i) {
135 __i--;
136 *__tmp = 0;
137 __tmp++;
138 }
139 }
140
141 #endif /* defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) */
142
143 #endif /* _ASM_POSIX_TYPES_H */
144