1 //------------------------------------------------------------------------------ 2 // Copyright (c) 2001-2002, OpenBeOS 3 // 4 // Permission is hereby granted, free of charge, to any person obtaining a 5 // copy of this software and associated documentation files (the "Software"), 6 // to deal in the Software without restriction, including without limitation 7 // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 // and/or sell copies of the Software, and to permit persons to whom the 9 // Software is furnished to do so, subject to the following conditions: 10 // 11 // The above copyright notice and this permission notice shall be included in 12 // all copies or substantial portions of the Software. 13 // 14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 // DEALINGS IN THE SOFTWARE. 21 // 22 // File Name: SupportDefs.h 23 // Author: Erik Jaesler (erik@cgsoftware.com) 24 // Description: Common type definitions. 25 //------------------------------------------------------------------------------ 26 27 #ifndef _SUPPORT_DEFS_H 28 #define _SUPPORT_DEFS_H 29 30 /* this !must! be located before the include of sys/types.h */ 31 #ifndef _SYS_TYPES_H 32 typedef unsigned long ulong; 33 typedef unsigned int uint; 34 typedef unsigned short ushort; 35 #endif // _SYS_TYPES_H 36 37 38 // Standard Includes ----------------------------------------------------------- 39 40 // System Includes ------------------------------------------------------------- 41 #include <BeBuild.h> 42 #include <sys/types.h> 43 #include <support/Errors.h> 44 45 // Project Includes ------------------------------------------------------------ 46 47 // Local Includes -------------------------------------------------------------- 48 49 // Local Defines --------------------------------------------------------------- 50 51 // Globals --------------------------------------------------------------------- 52 53 // Shorthand type formats ------------------------------------------------------ 54 55 typedef signed char int8; 56 typedef unsigned char uint8; 57 typedef volatile signed char vint8; 58 typedef volatile unsigned char vuint8; 59 60 typedef short int16; 61 typedef unsigned short uint16; 62 typedef volatile short vint16; 63 typedef volatile unsigned short vuint16; 64 65 typedef long int32; 66 typedef unsigned long uint32; 67 typedef volatile long vint32; 68 typedef volatile unsigned long vuint32; 69 70 typedef long long int64; 71 typedef unsigned long long uint64; 72 typedef volatile long long vint64; 73 typedef volatile unsigned long long vuint64; 74 75 typedef volatile long vlong; 76 typedef volatile int vint; 77 typedef volatile short vshort; 78 typedef volatile char vchar; 79 80 typedef volatile unsigned long vulong; 81 typedef volatile unsigned int vuint; 82 typedef volatile unsigned short vushort; 83 typedef volatile unsigned char vuchar; 84 85 typedef unsigned char uchar; 86 typedef unsigned short unichar; 87 88 89 // Descriptive formats --------------------------------------------------------- 90 typedef int32 status_t; 91 typedef int64 bigtime_t; 92 typedef uint32 type_code; 93 typedef uint32 perform_code; 94 95 96 // Empty string ("") ----------------------------------------------------------- 97 #ifdef __cplusplus 98 extern _IMPEXP_BE const char *B_EMPTY_STRING; 99 #endif 100 101 102 // min and max comparisons ----------------------------------------------------- 103 // min() and max() won't work in C++ 104 #define min_c(a,b) ((a)>(b)?(b):(a)) 105 #define max_c(a,b) ((a)>(b)?(a):(b)) 106 107 #ifndef __cplusplus 108 #ifndef min 109 #define min(a,b) ((a)>(b)?(b):(a)) 110 #endif 111 #ifndef max 112 #define max(a,b) ((a)>(b)?(a):(b)) 113 #endif 114 #endif 115 116 117 // Grandfathering -------------------------------------------------------------- 118 119 #ifndef __cplusplus 120 typedef unsigned char bool; 121 #define false 0 122 #define true 1 123 #endif 124 125 #ifndef NULL 126 #define NULL (0) 127 #endif 128 129 130 //------------------------------------------------------------------------------ 131 #ifdef __cplusplus 132 extern "C" { 133 #endif 134 135 //----- Atomic functions; old value is returned -------------------------------- 136 extern _IMPEXP_ROOT int32 atomic_add(vint32 *value, int32 addvalue); 137 extern _IMPEXP_ROOT int32 atomic_and(vint32 *value, int32 andvalue); 138 extern _IMPEXP_ROOT int32 atomic_or(vint32 *value, int32 orvalue); 139 140 // Other stuff ----------------------------------------------------------------- 141 extern _IMPEXP_ROOT void * get_stack_frame(void); 142 143 #ifdef __cplusplus 144 } 145 #endif 146 147 //-------- Obsolete or discouraged API ----------------------------------------- 148 149 // use 'true' and 'false' 150 #ifndef FALSE 151 #define FALSE 0 152 #endif 153 #ifndef TRUE 154 #define TRUE 1 155 #endif 156 157 158 //------------------------------------------------------------------------------ 159 160 #endif // _SUPPORT_DEFS_H 161 162 /* 163 * $Log $ 164 * 165 * $Id $ 166 * 167 */ 168 169