16516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru/******************************************************************************
26516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru *
36516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru *  Copyright (C) 2014 The Android Open Source Project
46516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru *  Copyright 2002 - 2004 Open Interface North America, Inc. All rights reserved.
56516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru *
66516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru *  Licensed under the Apache License, Version 2.0 (the "License");
76516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru *  you may not use this file except in compliance with the License.
86516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru *  You may obtain a copy of the License at:
96516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru *
106516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru *  http://www.apache.org/licenses/LICENSE-2.0
116516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru *
126516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru *  Unless required by applicable law or agreed to in writing, software
136516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru *  distributed under the License is distributed on an "AS IS" BASIS,
146516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
156516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru *  See the License for the specific language governing permissions and
166516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru *  limitations under the License.
176516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru *
186516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru ******************************************************************************/
196516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru#ifndef OI_STDDEFS_H
206516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru#define OI_STDDEFS_H
216516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru/**
226516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru * @file
236516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru * This file contains BM3 standard type definitions.
246516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru *
256516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru */
266516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru
276516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru/**********************************************************************************
286516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru  $Revision: #1 $
296516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru***********************************************************************************/
306516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru
316516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru#include "oi_cpu_dep.h"
326516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru
336516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru/** \addtogroup Misc Miscellaneous APIs */
346516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru/**@{*/
356516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru
366516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru#ifdef __cplusplus
376516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queruextern "C" {
386516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru#endif
396516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru
406516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru#ifndef FALSE
416516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru#define FALSE 0         /**< This define statement sets FALSE as a preprocessor alias for 0. */
426516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru#endif
436516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru
446516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru#ifndef TRUE
456516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru#define TRUE (!FALSE)  /**< This define statement sets TRUE as a preprocessor alias for !FALSE. */
466516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru#endif
476516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru
486516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru#ifdef HEW_TOOLCHAIN
496516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru    #ifdef NULL
506516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru        #undef NULL         /**< Override HEW toolchain NULL definition */
516516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru    #endif
526516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru    #define NULL 0          /**< HEW toolchain does not allow us to compare (void*) type to function pointer */
536516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru#else
546516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru    #ifndef NULL
556516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru        #define NULL ((void*)0) /**< This define statement sets NULL as a preprocessor alias for (void*)0 */
566516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru    #endif
576516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru#endif
586516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru
596516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru/**
606516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru * @name  Maximum and minimum values for basic types
616516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru * @{
626516b99bb74dfb7187a08f7090bf7ca22a006f15Jean-Baptiste Queru */
63#define OI_INT8_MIN   ((OI_INT8)0x80)          /**< decimal value: -128 */
64#define OI_INT8_MAX   ((OI_INT8)0x7F)          /**< decimal value: 127 */
65#define OI_INT16_MIN  ((OI_INT16)0x8000)       /**< decimal value: -32768 */
66#define OI_INT16_MAX  ((OI_INT16)0x7FFF)       /**< decimal value: 32767 */
67#define OI_INT32_MIN  ((OI_INT32)0x80000000)   /**< decimal value: -2,147,483,648 */
68#define OI_INT32_MAX  ((OI_INT32)0x7FFFFFFF)   /**< decimal value: 2,147,483,647 */
69#define OI_UINT8_MIN  ((OI_UINT8)0)            /**< decimal value: 0 */
70#define OI_UINT8_MAX  ((OI_UINT8)0xFF)         /**< decimal value: 255 */
71#define OI_UINT16_MIN ((OI_UINT16)0)           /**< decimal value: 0 */
72#define OI_UINT16_MAX ((OI_UINT16)0xFFFF)      /**< decimal value: 65535 */
73#define OI_UINT32_MIN ((OI_UINT32)0)           /**< decimal value: 0 */
74#define OI_UINT32_MAX ((OI_UINT32)0xFFFFFFFF)  /**< decimal value: 4,294,967,295 */
75
76/**
77 * @}
78 */
79
80/**
81 * @name  Integer types required by the Service Discovery Protocol
82 * @{
83 */
84
85/** unsigned 64-bit integer as a structure of two unsigned 32-bit integers */
86typedef struct {
87    OI_UINT32 I1; /**< most significant 32 bits */
88    OI_UINT32 I2; /**< least significant 32 bits */
89} OI_UINT64;
90
91#define OI_UINT64_MIN { (OI_UINT32)0x00000000, (OI_UINT32)0x00000000 }
92#define OI_UINT64_MAX { (OI_UINT32)0XFFFFFFFF, (OI_UINT32)0XFFFFFFFF }
93
94/** signed 64-bit integer as a structure of one unsigned 32-bit integer and one signed 32-bit integer */
95typedef struct {
96    OI_INT32  I1; /**< most significant 32 bits  as a signed integer */
97    OI_UINT32 I2; /**< least significant 32 bits as an unsigned integer */
98} OI_INT64;
99
100#define OI_INT64_MIN { (OI_INT32)0x80000000, (OI_UINT32)0x00000000 }
101#define OI_INT64_MAX { (OI_INT32)0X7FFFFFFF, (OI_UINT32)0XFFFFFFFF }
102
103/** unsigned 128-bit integer as a structure of four unsigned 32-bit integers */
104typedef struct {
105    OI_UINT32 I1; /**< most significant 32 bits */
106    OI_UINT32 I2; /**< second-most significant 32 bits */
107    OI_UINT32 I3; /**< third-most significant 32 bits */
108    OI_UINT32 I4; /**< least significant 32 bits */
109} OI_UINT128;
110
111#define OI_UINT128_MIN { (OI_UINT32)0x00000000, (OI_UINT32)0x00000000,  (OI_UINT32)0x00000000, (OI_UINT32)0x00000000 }
112#define OI_UINT128_MAX { (OI_UINT32)0XFFFFFFFF, (OI_UINT32)0XFFFFFFFF,  (OI_UINT32)0XFFFFFFFF, (OI_UINT32)0XFFFFFFFF }
113
114/** signed 128-bit integer as a structure of three unsigned 32-bit integers and one signed 32-bit integer */
115typedef struct {
116    OI_INT32  I1;  /**< most significant 32 bits as a signed integer */
117    OI_UINT32 I2;  /**< second-most significant 32 bits as an unsigned integer */
118    OI_UINT32 I3;  /**< third-most significant 32 bits as an unsigned integer */
119    OI_UINT32 I4;  /**< least significant 32 bits as an unsigned integer */
120} OI_INT128;
121
122#define OI_INT128_MIN { (OI_UINT32)0x80000000, (OI_UINT32)0x00000000,  (OI_UINT32)0x00000000, (OI_UINT32)0x00000000 }
123#define OI_INT128_MAX { (OI_UINT32)0X7FFFFFFF, (OI_UINT32)0XFFFFFFFF,  (OI_UINT32)0XFFFFFFFF, (OI_UINT32)0XFFFFFFFF }
124
125/**
126 * @}
127 */
128
129
130/**
131 * type for ASCII character data items
132 */
133typedef char OI_CHAR;
134
135/**
136 * type for double-byte character data items
137 */
138typedef OI_UINT16 OI_CHAR16;
139
140/**
141 * types for UTF encoded strings.
142 */
143typedef OI_UINT8  OI_UTF8;
144typedef OI_UINT16 OI_UTF16;
145typedef OI_UINT32 OI_UTF32;
146
147
148/**
149 * @name Single-bit operation macros
150 * @{
151 * In these macros, x is the data item for which a bit is to be tested or set and y specifies which bit
152 * is to be tested or set.
153 */
154
155/** This macro's value is TRUE if the bit specified by y is set in data item x. */
156#define OI_BIT_TEST(x,y)   ((x) & (y))
157
158/** This macro's value is TRUE if the bit specified by y is not set in data item x. */
159#define OI_BIT_CLEAR_TEST(x,y)  (((x) & (y)) == 0)
160
161/** This macro sets the bit specified by y in data item x. */
162#define OI_BIT_SET(x,y)    ((x) |= (y))
163
164/** This macro clears the bit specified by y in data item x. */
165#define OI_BIT_CLEAR(x,y)  ((x) &= ~(y))
166
167/** @} */
168
169/**
170 * The OI_ARRAYSIZE macro is set to the number of elements in an array
171 * (instead of the number of bytes, which is returned by sizeof()).
172 */
173
174#ifndef OI_ARRAYSIZE
175#define OI_ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
176#endif
177
178/**
179 * @name Preprocessor aliases for individual bit positions
180 *      Bits are defined here only if they are not already defined.
181 * @{
182 */
183
184#ifndef BIT0
185
186#define BIT0   0x00000001  /**< preprocessor alias for 32-bit value with bit 0 set, used to specify this single bit */
187#define BIT1   0x00000002  /**< preprocessor alias for 32-bit value with bit 1 set, used to specify this single bit */
188#define BIT2   0x00000004  /**< preprocessor alias for 32-bit value with bit 2 set, used to specify this single bit */
189#define BIT3   0x00000008  /**< preprocessor alias for 32-bit value with bit 3 set, used to specify this single bit */
190#define BIT4   0x00000010  /**< preprocessor alias for 32-bit value with bit 4 set, used to specify this single bit */
191#define BIT5   0x00000020  /**< preprocessor alias for 32-bit value with bit 5 set, used to specify this single bit */
192#define BIT6   0x00000040  /**< preprocessor alias for 32-bit value with bit 6 set, used to specify this single bit */
193#define BIT7   0x00000080  /**< preprocessor alias for 32-bit value with bit 7 set, used to specify this single bit */
194#define BIT8   0x00000100  /**< preprocessor alias for 32-bit value with bit 8 set, used to specify this single bit */
195#define BIT9   0x00000200  /**< preprocessor alias for 32-bit value with bit 9 set, used to specify this single bit */
196#define BIT10  0x00000400  /**< preprocessor alias for 32-bit value with bit 10 set, used to specify this single bit */
197#define BIT11  0x00000800  /**< preprocessor alias for 32-bit value with bit 11 set, used to specify this single bit */
198#define BIT12  0x00001000  /**< preprocessor alias for 32-bit value with bit 12 set, used to specify this single bit */
199#define BIT13  0x00002000  /**< preprocessor alias for 32-bit value with bit 13 set, used to specify this single bit */
200#define BIT14  0x00004000  /**< preprocessor alias for 32-bit value with bit 14 set, used to specify this single bit */
201#define BIT15  0x00008000  /**< preprocessor alias for 32-bit value with bit 15 set, used to specify this single bit */
202#define BIT16  0x00010000  /**< preprocessor alias for 32-bit value with bit 16 set, used to specify this single bit */
203#define BIT17  0x00020000  /**< preprocessor alias for 32-bit value with bit 17 set, used to specify this single bit */
204#define BIT18  0x00040000  /**< preprocessor alias for 32-bit value with bit 18 set, used to specify this single bit */
205#define BIT19  0x00080000  /**< preprocessor alias for 32-bit value with bit 19 set, used to specify this single bit */
206#define BIT20  0x00100000  /**< preprocessor alias for 32-bit value with bit 20 set, used to specify this single bit */
207#define BIT21  0x00200000  /**< preprocessor alias for 32-bit value with bit 21 set, used to specify this single bit */
208#define BIT22  0x00400000  /**< preprocessor alias for 32-bit value with bit 22 set, used to specify this single bit */
209#define BIT23  0x00800000  /**< preprocessor alias for 32-bit value with bit 23 set, used to specify this single bit */
210#define BIT24  0x01000000  /**< preprocessor alias for 32-bit value with bit 24 set, used to specify this single bit */
211#define BIT25  0x02000000  /**< preprocessor alias for 32-bit value with bit 25 set, used to specify this single bit */
212#define BIT26  0x04000000  /**< preprocessor alias for 32-bit value with bit 26 set, used to specify this single bit */
213#define BIT27  0x08000000  /**< preprocessor alias for 32-bit value with bit 27 set, used to specify this single bit */
214#define BIT28  0x10000000  /**< preprocessor alias for 32-bit value with bit 28 set, used to specify this single bit */
215#define BIT29  0x20000000  /**< preprocessor alias for 32-bit value with bit 29 set, used to specify this single bit */
216#define BIT30  0x40000000  /**< preprocessor alias for 32-bit value with bit 30 set, used to specify this single bit */
217#define BIT31  0x80000000  /**< preprocessor alias for 32-bit value with bit 31 set, used to specify this single bit */
218
219#endif  /* BIT0 et al */
220
221
222/** @} */
223
224
225#ifdef __cplusplus
226}
227#endif
228
229/**@}*/
230
231/*****************************************************************************/
232#endif /* OI_STDDEFS_H */
233