posix_types.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:4k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

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