posix_types.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*
  2. * Copyright (C) 2006 Atmel Corporation
  3. *
  4. * See file CREDITS for list of people who contributed to this
  5. * project.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. */
  22. #ifndef __ASM_AVR32_POSIX_TYPES_H
  23. #define __ASM_AVR32_POSIX_TYPES_H
  24. /*
  25. * This file is generally used by user-level software, so you need to
  26. * be a little careful about namespace pollution etc. Also, we cannot
  27. * assume GCC is being used.
  28. */
  29. typedef unsigned long __kernel_dev_t;
  30. typedef unsigned long __kernel_ino_t;
  31. typedef unsigned short __kernel_mode_t;
  32. typedef unsigned short __kernel_nlink_t;
  33. typedef long __kernel_off_t;
  34. typedef int __kernel_pid_t;
  35. typedef unsigned short __kernel_ipc_pid_t;
  36. typedef unsigned int __kernel_uid_t;
  37. typedef unsigned int __kernel_gid_t;
  38. typedef unsigned long __kernel_size_t;
  39. typedef int __kernel_ssize_t;
  40. typedef int __kernel_ptrdiff_t;
  41. typedef long __kernel_time_t;
  42. typedef long __kernel_suseconds_t;
  43. typedef long __kernel_clock_t;
  44. typedef int __kernel_timer_t;
  45. typedef int __kernel_clockid_t;
  46. typedef int __kernel_daddr_t;
  47. typedef char * __kernel_caddr_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 short __kernel_old_uid_t;
  53. typedef unsigned short __kernel_old_gid_t;
  54. typedef unsigned short __kernel_old_dev_t;
  55. #ifdef __GNUC__
  56. typedef long long __kernel_loff_t;
  57. #endif
  58. typedef struct {
  59. #if defined(__KERNEL__) || defined(__USE_ALL)
  60. int val[2];
  61. #else /* !defined(__KERNEL__) && !defined(__USE_ALL) */
  62. int __val[2];
  63. #endif /* !defined(__KERNEL__) && !defined(__USE_ALL) */
  64. } __kernel_fsid_t;
  65. #if defined(__KERNEL__)
  66. #undef __FD_SET
  67. static __inline__ void __FD_SET(unsigned long __fd, __kernel_fd_set *__fdsetp)
  68. {
  69. unsigned long __tmp = __fd / __NFDBITS;
  70. unsigned long __rem = __fd % __NFDBITS;
  71. __fdsetp->fds_bits[__tmp] |= (1UL<<__rem);
  72. }
  73. #undef __FD_CLR
  74. static __inline__ void __FD_CLR(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. #undef __FD_ISSET
  81. static __inline__ int __FD_ISSET(unsigned long __fd, const __kernel_fd_set *__p)
  82. {
  83. unsigned long __tmp = __fd / __NFDBITS;
  84. unsigned long __rem = __fd % __NFDBITS;
  85. return (__p->fds_bits[__tmp] & (1UL<<__rem)) != 0;
  86. }
  87. /*
  88. * This will unroll the loop for the normal constant case (8 ints,
  89. * for a 256-bit fd_set)
  90. */
  91. #undef __FD_ZERO
  92. static __inline__ void __FD_ZERO(__kernel_fd_set *__p)
  93. {
  94. unsigned long *__tmp = __p->fds_bits;
  95. int __i;
  96. if (__builtin_constant_p(__FDSET_LONGS)) {
  97. switch (__FDSET_LONGS) {
  98. case 16:
  99. __tmp[ 0] = 0; __tmp[ 1] = 0;
  100. __tmp[ 2] = 0; __tmp[ 3] = 0;
  101. __tmp[ 4] = 0; __tmp[ 5] = 0;
  102. __tmp[ 6] = 0; __tmp[ 7] = 0;
  103. __tmp[ 8] = 0; __tmp[ 9] = 0;
  104. __tmp[10] = 0; __tmp[11] = 0;
  105. __tmp[12] = 0; __tmp[13] = 0;
  106. __tmp[14] = 0; __tmp[15] = 0;
  107. return;
  108. case 8:
  109. __tmp[ 0] = 0; __tmp[ 1] = 0;
  110. __tmp[ 2] = 0; __tmp[ 3] = 0;
  111. __tmp[ 4] = 0; __tmp[ 5] = 0;
  112. __tmp[ 6] = 0; __tmp[ 7] = 0;
  113. return;
  114. case 4:
  115. __tmp[ 0] = 0; __tmp[ 1] = 0;
  116. __tmp[ 2] = 0; __tmp[ 3] = 0;
  117. return;
  118. }
  119. }
  120. __i = __FDSET_LONGS;
  121. while (__i) {
  122. __i--;
  123. *__tmp = 0;
  124. __tmp++;
  125. }
  126. }
  127. #endif /* defined(__KERNEL__) */
  128. #endif /* __ASM_AVR32_POSIX_TYPES_H */