Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _PPC_POSIX_TYPES_H |
| 2 | #define _PPC_POSIX_TYPES_H |
| 3 | |
| 4 | /* |
| 5 | * This file is generally used by user-level software, so you need to |
| 6 | * be a little careful about namespace pollution etc. Also, we cannot |
| 7 | * assume GCC is being used. |
| 8 | */ |
| 9 | |
| 10 | typedef unsigned long __kernel_ino_t; |
| 11 | typedef unsigned int __kernel_mode_t; |
| 12 | typedef unsigned short __kernel_nlink_t; |
| 13 | typedef long __kernel_off_t; |
| 14 | typedef int __kernel_pid_t; |
| 15 | typedef unsigned int __kernel_uid_t; |
| 16 | typedef unsigned int __kernel_gid_t; |
| 17 | typedef unsigned int __kernel_size_t; |
| 18 | typedef int __kernel_ssize_t; |
| 19 | typedef long __kernel_ptrdiff_t; |
| 20 | typedef long __kernel_time_t; |
| 21 | typedef long __kernel_suseconds_t; |
| 22 | typedef long __kernel_clock_t; |
| 23 | typedef int __kernel_timer_t; |
| 24 | typedef int __kernel_clockid_t; |
| 25 | typedef int __kernel_daddr_t; |
| 26 | typedef char * __kernel_caddr_t; |
| 27 | typedef short __kernel_ipc_pid_t; |
| 28 | typedef unsigned short __kernel_uid16_t; |
| 29 | typedef unsigned short __kernel_gid16_t; |
| 30 | typedef unsigned int __kernel_uid32_t; |
| 31 | typedef unsigned int __kernel_gid32_t; |
| 32 | |
| 33 | typedef unsigned int __kernel_old_uid_t; |
| 34 | typedef unsigned int __kernel_old_gid_t; |
| 35 | typedef unsigned int __kernel_old_dev_t; |
| 36 | |
| 37 | #ifdef __GNUC__ |
| 38 | typedef long long __kernel_loff_t; |
| 39 | #endif |
| 40 | |
| 41 | typedef struct { |
| 42 | int val[2]; |
| 43 | } __kernel_fsid_t; |
| 44 | |
| 45 | #ifndef __GNUC__ |
| 46 | |
| 47 | #define __FD_SET(d, set) ((set)->fds_bits[__FDELT(d)] |= __FDMASK(d)) |
| 48 | #define __FD_CLR(d, set) ((set)->fds_bits[__FDELT(d)] &= ~__FDMASK(d)) |
| 49 | #define __FD_ISSET(d, set) ((set)->fds_bits[__FDELT(d)] & __FDMASK(d)) |
| 50 | #define __FD_ZERO(set) \ |
| 51 | ((void) memset ((__ptr_t) (set), 0, sizeof (__kernel_fd_set))) |
| 52 | |
| 53 | #else /* __GNUC__ */ |
| 54 | |
| 55 | #if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) \ |
| 56 | || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 0) |
| 57 | /* With GNU C, use inline functions instead so args are evaluated only once: */ |
| 58 | |
| 59 | #undef __FD_SET |
| 60 | static __inline__ void __FD_SET(unsigned long fd, __kernel_fd_set *fdsetp) |
| 61 | { |
| 62 | unsigned long _tmp = fd / __NFDBITS; |
| 63 | unsigned long _rem = fd % __NFDBITS; |
| 64 | fdsetp->fds_bits[_tmp] |= (1UL<<_rem); |
| 65 | } |
| 66 | |
| 67 | #undef __FD_CLR |
| 68 | static __inline__ void __FD_CLR(unsigned long fd, __kernel_fd_set *fdsetp) |
| 69 | { |
| 70 | unsigned long _tmp = fd / __NFDBITS; |
| 71 | unsigned long _rem = fd % __NFDBITS; |
| 72 | fdsetp->fds_bits[_tmp] &= ~(1UL<<_rem); |
| 73 | } |
| 74 | |
| 75 | #undef __FD_ISSET |
| 76 | static __inline__ int __FD_ISSET(unsigned long fd, __kernel_fd_set *p) |
| 77 | { |
| 78 | unsigned long _tmp = fd / __NFDBITS; |
| 79 | unsigned long _rem = fd % __NFDBITS; |
| 80 | return (p->fds_bits[_tmp] & (1UL<<_rem)) != 0; |
| 81 | } |
| 82 | |
| 83 | /* |
| 84 | * This will unroll the loop for the normal constant case (8 ints, |
| 85 | * for a 256-bit fd_set) |
| 86 | */ |
| 87 | #undef __FD_ZERO |
| 88 | static __inline__ void __FD_ZERO(__kernel_fd_set *p) |
| 89 | { |
| 90 | unsigned int *tmp = (unsigned int *)p->fds_bits; |
| 91 | int i; |
| 92 | |
| 93 | if (__builtin_constant_p(__FDSET_LONGS)) { |
| 94 | switch (__FDSET_LONGS) { |
| 95 | case 8: |
| 96 | tmp[0] = 0; tmp[1] = 0; tmp[2] = 0; tmp[3] = 0; |
| 97 | tmp[4] = 0; tmp[5] = 0; tmp[6] = 0; tmp[7] = 0; |
| 98 | return; |
| 99 | } |
| 100 | } |
| 101 | i = __FDSET_LONGS; |
| 102 | while (i) { |
| 103 | i--; |
| 104 | *tmp = 0; |
| 105 | tmp++; |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | #endif /* defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) */ |
| 110 | #endif /* __GNUC__ */ |
| 111 | #endif /* _PPC_POSIX_TYPES_H */ |