posix_types.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. * (C) Copyright 2000 - 2002
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * (C) Copyright 2007, taken from asm-ppc/posix_types.h
  6. * Daniel Hellstrom, Gaisler Research, daniel@gaisler.com.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. *
  23. */
  24. #ifndef __SPARC_POSIX_TYPES_H__
  25. #define __SPARC_POSIX_TYPES_H__
  26. /*
  27. * This file is generally used by user-level software, so you need to
  28. * be a little careful about namespace pollution etc. Also, we cannot
  29. * assume GCC is being used.
  30. */
  31. typedef unsigned int __kernel_dev_t;
  32. typedef unsigned int __kernel_ino_t;
  33. typedef unsigned int __kernel_mode_t;
  34. typedef unsigned short __kernel_nlink_t;
  35. typedef long __kernel_off_t;
  36. typedef int __kernel_pid_t;
  37. typedef unsigned int __kernel_uid_t;
  38. typedef unsigned int __kernel_gid_t;
  39. typedef unsigned int __kernel_size_t;
  40. typedef int __kernel_ssize_t;
  41. typedef long __kernel_ptrdiff_t;
  42. typedef long __kernel_time_t;
  43. typedef long __kernel_suseconds_t;
  44. typedef long __kernel_clock_t;
  45. typedef int __kernel_daddr_t;
  46. typedef char *__kernel_caddr_t;
  47. typedef short __kernel_ipc_pid_t;
  48. typedef unsigned short __kernel_uid16_t;
  49. typedef unsigned short __kernel_gid16_t;
  50. typedef unsigned int __kernel_uid32_t;
  51. typedef unsigned int __kernel_gid32_t;
  52. typedef unsigned int __kernel_old_uid_t;
  53. typedef unsigned int __kernel_old_gid_t;
  54. #ifdef __GNUC__
  55. typedef long long __kernel_loff_t;
  56. #endif
  57. typedef struct {
  58. int val[2];
  59. } __kernel_fsid_t;
  60. #ifndef __GNUC__
  61. #define __FD_SET(d, set) ((set)->fds_bits[__FDELT(d)] |= __FDMASK(d))
  62. #define __FD_CLR(d, set) ((set)->fds_bits[__FDELT(d)] &= ~__FDMASK(d))
  63. #define __FD_ISSET(d, set) ((set)->fds_bits[__FDELT(d)] & __FDMASK(d))
  64. #define __FD_ZERO(set) \
  65. ((void) memset ((__ptr_t) (set), 0, sizeof (__kernel_fd_set)))
  66. #else /* __GNUC__ */
  67. #if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) \
  68. || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 0)
  69. /* With GNU C, use inline functions instead so args are evaluated only once: */
  70. #undef __FD_SET
  71. static __inline__ void __FD_SET(unsigned long fd, __kernel_fd_set * fdsetp)
  72. {
  73. unsigned long _tmp = fd / __NFDBITS;
  74. unsigned long _rem = fd % __NFDBITS;
  75. fdsetp->fds_bits[_tmp] |= (1UL << _rem);
  76. }
  77. #undef __FD_CLR
  78. static __inline__ void __FD_CLR(unsigned long fd, __kernel_fd_set * fdsetp)
  79. {
  80. unsigned long _tmp = fd / __NFDBITS;
  81. unsigned long _rem = fd % __NFDBITS;
  82. fdsetp->fds_bits[_tmp] &= ~(1UL << _rem);
  83. }
  84. #undef __FD_ISSET
  85. static __inline__ int __FD_ISSET(unsigned long fd, __kernel_fd_set * p)
  86. {
  87. unsigned long _tmp = fd / __NFDBITS;
  88. unsigned long _rem = fd % __NFDBITS;
  89. return (p->fds_bits[_tmp] & (1UL << _rem)) != 0;
  90. }
  91. /*
  92. * This will unroll the loop for the normal constant case (8 ints,
  93. * for a 256-bit fd_set)
  94. */
  95. #undef __FD_ZERO
  96. static __inline__ void __FD_ZERO(__kernel_fd_set * p)
  97. {
  98. unsigned int *tmp = (unsigned int *)p->fds_bits;
  99. int i;
  100. if (__builtin_constant_p(__FDSET_LONGS)) {
  101. switch (__FDSET_LONGS) {
  102. case 8:
  103. tmp[0] = 0;
  104. tmp[1] = 0;
  105. tmp[2] = 0;
  106. tmp[3] = 0;
  107. tmp[4] = 0;
  108. tmp[5] = 0;
  109. tmp[6] = 0;
  110. tmp[7] = 0;
  111. return;
  112. }
  113. }
  114. i = __FDSET_LONGS;
  115. while (i) {
  116. i--;
  117. *tmp = 0;
  118. tmp++;
  119. }
  120. }
  121. #endif /* defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) */
  122. #endif /* __GNUC__ */
  123. #endif /* _SPARC_POSIX_TYPES_H */