posix_types.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. #ifndef __ASM_GENERIC_POSIX_TYPES_H
  2. #define __ASM_GENERIC_POSIX_TYPES_H
  3. #include <asm/bitsperlong.h>
  4. /*
  5. * This file is generally used by user-level software, so you need to
  6. * be a little careful about namespace pollution etc.
  7. *
  8. * First the types that are often defined in different ways across
  9. * architectures, so that you can override them.
  10. */
  11. #ifndef __kernel_ino_t
  12. typedef unsigned long __kernel_ino_t;
  13. #endif
  14. #ifndef __kernel_mode_t
  15. typedef unsigned int __kernel_mode_t;
  16. #endif
  17. #ifndef __kernel_nlink_t
  18. typedef unsigned long __kernel_nlink_t;
  19. #endif
  20. #ifndef __kernel_pid_t
  21. typedef int __kernel_pid_t;
  22. #endif
  23. #ifndef __kernel_ipc_pid_t
  24. typedef int __kernel_ipc_pid_t;
  25. #endif
  26. #ifndef __kernel_uid_t
  27. typedef unsigned int __kernel_uid_t;
  28. typedef unsigned int __kernel_gid_t;
  29. #endif
  30. #ifndef __kernel_suseconds_t
  31. typedef long __kernel_suseconds_t;
  32. #endif
  33. #ifndef __kernel_daddr_t
  34. typedef int __kernel_daddr_t;
  35. #endif
  36. #ifndef __kernel_uid32_t
  37. typedef __kernel_uid_t __kernel_uid32_t;
  38. typedef __kernel_gid_t __kernel_gid32_t;
  39. #endif
  40. #ifndef __kernel_old_uid_t
  41. typedef __kernel_uid_t __kernel_old_uid_t;
  42. typedef __kernel_gid_t __kernel_old_gid_t;
  43. #endif
  44. #ifndef __kernel_old_dev_t
  45. typedef unsigned int __kernel_old_dev_t;
  46. #endif
  47. /*
  48. * Most 32 bit architectures use "unsigned int" size_t,
  49. * and all 64 bit architectures use "unsigned long" size_t.
  50. */
  51. #ifndef __kernel_size_t
  52. #if __BITS_PER_LONG != 64
  53. typedef unsigned int __kernel_size_t;
  54. typedef int __kernel_ssize_t;
  55. typedef int __kernel_ptrdiff_t;
  56. #else
  57. typedef unsigned long __kernel_size_t;
  58. typedef long __kernel_ssize_t;
  59. typedef long __kernel_ptrdiff_t;
  60. #endif
  61. #endif
  62. /*
  63. * anything below here should be completely generic
  64. */
  65. typedef long __kernel_off_t;
  66. typedef long long __kernel_loff_t;
  67. typedef long __kernel_time_t;
  68. typedef long __kernel_clock_t;
  69. typedef int __kernel_timer_t;
  70. typedef int __kernel_clockid_t;
  71. typedef char * __kernel_caddr_t;
  72. typedef unsigned short __kernel_uid16_t;
  73. typedef unsigned short __kernel_gid16_t;
  74. typedef struct {
  75. int val[2];
  76. } __kernel_fsid_t;
  77. #ifdef __KERNEL__
  78. #undef __FD_SET
  79. static inline void __FD_SET(unsigned long __fd, __kernel_fd_set *__fdsetp)
  80. {
  81. unsigned long __tmp = __fd / __NFDBITS;
  82. unsigned long __rem = __fd % __NFDBITS;
  83. __fdsetp->fds_bits[__tmp] |= (1UL<<__rem);
  84. }
  85. #undef __FD_CLR
  86. static inline void __FD_CLR(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. #undef __FD_ISSET
  93. static inline int __FD_ISSET(unsigned long __fd, const __kernel_fd_set *__p)
  94. {
  95. unsigned long __tmp = __fd / __NFDBITS;
  96. unsigned long __rem = __fd % __NFDBITS;
  97. return (__p->fds_bits[__tmp] & (1UL<<__rem)) != 0;
  98. }
  99. /*
  100. * This will unroll the loop for the normal constant case (8 ints,
  101. * for a 256-bit fd_set)
  102. */
  103. #undef __FD_ZERO
  104. static inline void __FD_ZERO(__kernel_fd_set *__p)
  105. {
  106. unsigned long *__tmp = __p->fds_bits;
  107. int __i;
  108. if (__builtin_constant_p(__FDSET_LONGS)) {
  109. switch (__FDSET_LONGS) {
  110. case 16:
  111. __tmp[ 0] = 0; __tmp[ 1] = 0;
  112. __tmp[ 2] = 0; __tmp[ 3] = 0;
  113. __tmp[ 4] = 0; __tmp[ 5] = 0;
  114. __tmp[ 6] = 0; __tmp[ 7] = 0;
  115. __tmp[ 8] = 0; __tmp[ 9] = 0;
  116. __tmp[10] = 0; __tmp[11] = 0;
  117. __tmp[12] = 0; __tmp[13] = 0;
  118. __tmp[14] = 0; __tmp[15] = 0;
  119. return;
  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. case 4:
  127. __tmp[ 0] = 0; __tmp[ 1] = 0;
  128. __tmp[ 2] = 0; __tmp[ 3] = 0;
  129. return;
  130. }
  131. }
  132. __i = __FDSET_LONGS;
  133. while (__i) {
  134. __i--;
  135. *__tmp = 0;
  136. __tmp++;
  137. }
  138. }
  139. #endif /* __KERNEL__ */
  140. #endif /* __ASM_GENERIC_POSIX_TYPES_H */