oi_stddefs.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. /******************************************************************************
  2. *
  3. * Copyright (C) 2014 The Android Open Source Project
  4. * Copyright 2002 - 2004 Open Interface North America, Inc. All rights reserved.
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at:
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. *
  18. ******************************************************************************/
  19. #ifndef OI_STDDEFS_H
  20. #define OI_STDDEFS_H
  21. /**
  22. * @file
  23. * This file contains BM3 standard type definitions.
  24. *
  25. */
  26. /**********************************************************************************
  27. $Revision: #1 $
  28. ***********************************************************************************/
  29. #include "oi_cpu_dep.h"
  30. /** \addtogroup Misc Miscellaneous APIs */
  31. /**@{*/
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. #ifndef FALSE
  36. #define FALSE 0 /**< This define statement sets FALSE as a preprocessor alias for 0. */
  37. #endif
  38. #ifndef TRUE
  39. #define TRUE (!FALSE) /**< This define statement sets TRUE as a preprocessor alias for !FALSE. */
  40. #endif
  41. #ifdef HEW_TOOLCHAIN
  42. #ifdef NULL
  43. #undef NULL /**< Override HEW toolchain NULL definition */
  44. #endif
  45. #define NULL 0 /**< HEW toolchain does not allow us to compare (void*) type to function pointer */
  46. #else
  47. #ifndef NULL
  48. #define NULL ((void*)0) /**< This define statement sets NULL as a preprocessor alias for (void*)0 */
  49. #endif
  50. #endif
  51. /**
  52. * @name Maximum and minimum values for basic types
  53. * @{
  54. */
  55. #define OI_INT8_MIN ((OI_INT8)0x80) /**< decimal value: -128 */
  56. #define OI_INT8_MAX ((OI_INT8)0x7F) /**< decimal value: 127 */
  57. #define OI_INT16_MIN ((OI_INT16)0x8000) /**< decimal value: -32768 */
  58. #define OI_INT16_MAX ((OI_INT16)0x7FFF) /**< decimal value: 32767 */
  59. #define OI_INT32_MIN ((OI_INT32)0x80000000) /**< decimal value: -2,147,483,648 */
  60. #define OI_INT32_MAX ((OI_INT32)0x7FFFFFFF) /**< decimal value: 2,147,483,647 */
  61. #define OI_UINT8_MIN ((OI_UINT8)0) /**< decimal value: 0 */
  62. #define OI_UINT8_MAX ((OI_UINT8)0xFF) /**< decimal value: 255 */
  63. #define OI_UINT16_MIN ((OI_UINT16)0) /**< decimal value: 0 */
  64. #define OI_UINT16_MAX ((OI_UINT16)0xFFFF) /**< decimal value: 65535 */
  65. #define OI_UINT32_MIN ((OI_UINT32)0) /**< decimal value: 0 */
  66. #define OI_UINT32_MAX ((OI_UINT32)0xFFFFFFFF) /**< decimal value: 4,294,967,295 */
  67. /**
  68. * @}
  69. */
  70. /**
  71. * @name Integer types required by the Service Discovery Protocol
  72. * @{
  73. */
  74. /** unsigned 64-bit integer as a structure of two unsigned 32-bit integers */
  75. typedef struct {
  76. OI_UINT32 I1; /**< most significant 32 bits */
  77. OI_UINT32 I2; /**< least significant 32 bits */
  78. } OI_UINT64;
  79. #define OI_UINT64_MIN { (OI_UINT32)0x00000000, (OI_UINT32)0x00000000 }
  80. #define OI_UINT64_MAX { (OI_UINT32)0XFFFFFFFF, (OI_UINT32)0XFFFFFFFF }
  81. /** signed 64-bit integer as a structure of one unsigned 32-bit integer and one signed 32-bit integer */
  82. typedef struct {
  83. OI_INT32 I1; /**< most significant 32 bits as a signed integer */
  84. OI_UINT32 I2; /**< least significant 32 bits as an unsigned integer */
  85. } OI_INT64;
  86. #define OI_INT64_MIN { (OI_INT32)0x80000000, (OI_UINT32)0x00000000 }
  87. #define OI_INT64_MAX { (OI_INT32)0X7FFFFFFF, (OI_UINT32)0XFFFFFFFF }
  88. /** unsigned 128-bit integer as a structure of four unsigned 32-bit integers */
  89. typedef struct {
  90. OI_UINT32 I1; /**< most significant 32 bits */
  91. OI_UINT32 I2; /**< second-most significant 32 bits */
  92. OI_UINT32 I3; /**< third-most significant 32 bits */
  93. OI_UINT32 I4; /**< least significant 32 bits */
  94. } OI_UINT128;
  95. #define OI_UINT128_MIN { (OI_UINT32)0x00000000, (OI_UINT32)0x00000000, (OI_UINT32)0x00000000, (OI_UINT32)0x00000000 }
  96. #define OI_UINT128_MAX { (OI_UINT32)0XFFFFFFFF, (OI_UINT32)0XFFFFFFFF, (OI_UINT32)0XFFFFFFFF, (OI_UINT32)0XFFFFFFFF }
  97. /** signed 128-bit integer as a structure of three unsigned 32-bit integers and one signed 32-bit integer */
  98. typedef struct {
  99. OI_INT32 I1; /**< most significant 32 bits as a signed integer */
  100. OI_UINT32 I2; /**< second-most significant 32 bits as an unsigned integer */
  101. OI_UINT32 I3; /**< third-most significant 32 bits as an unsigned integer */
  102. OI_UINT32 I4; /**< least significant 32 bits as an unsigned integer */
  103. } OI_INT128;
  104. #define OI_INT128_MIN { (OI_UINT32)0x80000000, (OI_UINT32)0x00000000, (OI_UINT32)0x00000000, (OI_UINT32)0x00000000 }
  105. #define OI_INT128_MAX { (OI_UINT32)0X7FFFFFFF, (OI_UINT32)0XFFFFFFFF, (OI_UINT32)0XFFFFFFFF, (OI_UINT32)0XFFFFFFFF }
  106. /**
  107. * @}
  108. */
  109. /**
  110. * type for ASCII character data items
  111. */
  112. typedef char OI_CHAR;
  113. /**
  114. * type for double-byte character data items
  115. */
  116. typedef OI_UINT16 OI_CHAR16;
  117. /**
  118. * types for UTF encoded strings.
  119. */
  120. typedef OI_UINT8 OI_UTF8;
  121. typedef OI_UINT16 OI_UTF16;
  122. typedef OI_UINT32 OI_UTF32;
  123. /**
  124. * @name Single-bit operation macros
  125. * @{
  126. * In these macros, x is the data item for which a bit is to be tested or set and y specifies which bit
  127. * is to be tested or set.
  128. */
  129. /** This macro's value is TRUE if the bit specified by y is set in data item x. */
  130. #define OI_BIT_TEST(x,y) ((x) & (y))
  131. /** This macro's value is TRUE if the bit specified by y is not set in data item x. */
  132. #define OI_BIT_CLEAR_TEST(x,y) (((x) & (y)) == 0)
  133. /** This macro sets the bit specified by y in data item x. */
  134. #define OI_BIT_SET(x,y) ((x) |= (y))
  135. /** This macro clears the bit specified by y in data item x. */
  136. #define OI_BIT_CLEAR(x,y) ((x) &= ~(y))
  137. /** @} */
  138. /**
  139. * The OI_ARRAYSIZE macro is set to the number of elements in an array
  140. * (instead of the number of bytes, which is returned by sizeof()).
  141. */
  142. #ifndef OI_ARRAYSIZE
  143. #define OI_ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
  144. #endif
  145. /**
  146. * @name Preprocessor aliases for individual bit positions
  147. * Bits are defined here only if they are not already defined.
  148. * @{
  149. */
  150. #ifndef BIT0
  151. #define BIT0 0x00000001 /**< preprocessor alias for 32-bit value with bit 0 set, used to specify this single bit */
  152. #define BIT1 0x00000002 /**< preprocessor alias for 32-bit value with bit 1 set, used to specify this single bit */
  153. #define BIT2 0x00000004 /**< preprocessor alias for 32-bit value with bit 2 set, used to specify this single bit */
  154. #define BIT3 0x00000008 /**< preprocessor alias for 32-bit value with bit 3 set, used to specify this single bit */
  155. #define BIT4 0x00000010 /**< preprocessor alias for 32-bit value with bit 4 set, used to specify this single bit */
  156. #define BIT5 0x00000020 /**< preprocessor alias for 32-bit value with bit 5 set, used to specify this single bit */
  157. #define BIT6 0x00000040 /**< preprocessor alias for 32-bit value with bit 6 set, used to specify this single bit */
  158. #define BIT7 0x00000080 /**< preprocessor alias for 32-bit value with bit 7 set, used to specify this single bit */
  159. #define BIT8 0x00000100 /**< preprocessor alias for 32-bit value with bit 8 set, used to specify this single bit */
  160. #define BIT9 0x00000200 /**< preprocessor alias for 32-bit value with bit 9 set, used to specify this single bit */
  161. #define BIT10 0x00000400 /**< preprocessor alias for 32-bit value with bit 10 set, used to specify this single bit */
  162. #define BIT11 0x00000800 /**< preprocessor alias for 32-bit value with bit 11 set, used to specify this single bit */
  163. #define BIT12 0x00001000 /**< preprocessor alias for 32-bit value with bit 12 set, used to specify this single bit */
  164. #define BIT13 0x00002000 /**< preprocessor alias for 32-bit value with bit 13 set, used to specify this single bit */
  165. #define BIT14 0x00004000 /**< preprocessor alias for 32-bit value with bit 14 set, used to specify this single bit */
  166. #define BIT15 0x00008000 /**< preprocessor alias for 32-bit value with bit 15 set, used to specify this single bit */
  167. #define BIT16 0x00010000 /**< preprocessor alias for 32-bit value with bit 16 set, used to specify this single bit */
  168. #define BIT17 0x00020000 /**< preprocessor alias for 32-bit value with bit 17 set, used to specify this single bit */
  169. #define BIT18 0x00040000 /**< preprocessor alias for 32-bit value with bit 18 set, used to specify this single bit */
  170. #define BIT19 0x00080000 /**< preprocessor alias for 32-bit value with bit 19 set, used to specify this single bit */
  171. #define BIT20 0x00100000 /**< preprocessor alias for 32-bit value with bit 20 set, used to specify this single bit */
  172. #define BIT21 0x00200000 /**< preprocessor alias for 32-bit value with bit 21 set, used to specify this single bit */
  173. #define BIT22 0x00400000 /**< preprocessor alias for 32-bit value with bit 22 set, used to specify this single bit */
  174. #define BIT23 0x00800000 /**< preprocessor alias for 32-bit value with bit 23 set, used to specify this single bit */
  175. #define BIT24 0x01000000 /**< preprocessor alias for 32-bit value with bit 24 set, used to specify this single bit */
  176. #define BIT25 0x02000000 /**< preprocessor alias for 32-bit value with bit 25 set, used to specify this single bit */
  177. #define BIT26 0x04000000 /**< preprocessor alias for 32-bit value with bit 26 set, used to specify this single bit */
  178. #define BIT27 0x08000000 /**< preprocessor alias for 32-bit value with bit 27 set, used to specify this single bit */
  179. #define BIT28 0x10000000 /**< preprocessor alias for 32-bit value with bit 28 set, used to specify this single bit */
  180. #define BIT29 0x20000000 /**< preprocessor alias for 32-bit value with bit 29 set, used to specify this single bit */
  181. #define BIT30 0x40000000 /**< preprocessor alias for 32-bit value with bit 30 set, used to specify this single bit */
  182. #define BIT31 0x80000000 /**< preprocessor alias for 32-bit value with bit 31 set, used to specify this single bit */
  183. #endif /* BIT0 et al */
  184. /** @} */
  185. #ifdef __cplusplus
  186. }
  187. #endif
  188. /**@}*/
  189. /*****************************************************************************/
  190. #endif /* OI_STDDEFS_H */