00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00018 #ifndef _PALMTYPES_H_
00019 #define _PALMTYPES_H_
00020
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #include <BuildDefaults.h>
00038
00039
00040
00041
00042
00043
00044 #include <stdint.h>
00045 #include <stddef.h>
00046 #if TARGET_HOST == TARGET_HOST_PALMOS
00047 # include <sys/types.h>
00048
00049
00050
00051
00052
00053 typedef int32_t status_t;
00054 typedef int64_t nsecs_t;
00055 typedef uint32_t type_code;
00056 typedef uint32_t perform_code;
00057
00058
00059 typedef int FDCELL;
00060 typedef void* PCELL;
00061 typedef int32_t pl_t;
00062
00063 # ifndef uuid_t
00064 typedef struct uuid_t
00065 {
00066 uint32_t time_low;
00067 uint16_t time_mid;
00068 uint16_t time_hi_and_version;
00069 uint8_t clock_seq_hi_and_reserved;
00070 uint8_t clock_seq_low;
00071 uint8_t node[6];
00072 } uuid_t;
00073 # endif
00074 #elif (TARGET_HOST == TARGET_HOST_MACOS) || (TARGET_HOST == TARGET_HOST_LINUX)
00075 typedef int32_t status_t;
00076 typedef int64_t nsecs_t;
00077 typedef uint32_t type_code;
00078 typedef uint32_t perform_code;
00079
00080 typedef int FDCELL;
00081 typedef void* PCELL;
00082 typedef int32_t pl_t;
00083 #else
00084
00085 # include <sys/types.h>
00086 #endif
00087
00088
00089 typedef uint16_t wchar16_t;
00090 typedef uint32_t wchar32_t;
00091
00092 typedef int16_t Coord;
00093 typedef float fcoord_t;
00094
00095 typedef float coord;
00096
00097 typedef unsigned char Boolean;
00098
00099
00100 #ifndef TRUE
00101 #define TRUE (1)
00102 #endif
00103 #ifndef FALSE
00104 #define FALSE (0)
00105 #endif
00106
00107
00108 typedef uint8_t Enum8;
00109 typedef uint16_t Enum16;
00110 typedef int8_t SignedEnum8;
00111 typedef int16_t SignedEnum16;
00112
00113 typedef void * MemPtr;
00114 typedef struct _opaque * MemHandle;
00115
00116 typedef uint32_t VAddr;
00117 typedef uint32_t SysHandle;
00118
00119 typedef int32_t (*ProcPtr)();
00120
00121
00122
00123
00124
00125 #ifndef ErrConvertFrom68k
00126 #define ErrConvertFrom68k(x) ( (((status_t)(x))&0xFFFF) | 0x80000000 )
00127 #endif
00128
00129 #ifndef ErrConvertTo68k
00130 #define ErrConvertTo68k(x) ((uint16_t)(((uint32_t)(x))&0xFFFF))
00131 #endif
00132
00133
00134 #define B_ONE_NANOSECOND ((nsecs_t)1)
00135 #define B_ONE_MICROSECOND (B_ONE_NANOSECOND*1000)
00136 #define B_ONE_MILLISECOND (B_ONE_MICROSECOND*1000)
00137 #define B_ONE_SECOND (B_ONE_MILLISECOND*1000)
00138
00139
00140 #define B_US2NS(us) ((nsecs_t)(us) * 1000)
00141 #define B_MS2NS(ms) ((nsecs_t)(ms) * 1000000)
00142 #define B_S2NS(s) ((nsecs_t)(s) * 1000000000)
00143 #define B_MICROSECONDS_TO_NANOSECONDS(us) B_US2NS(us)
00144 #define B_MILLISECONDS_TO_NANOSECONDS(ms) B_MS2NS(ms)
00145 #define B_SECONDS_TO_NANOSECONDS(s) B_S2NS(s)
00146
00147
00148 #define B_NS2US(ns) ((int64_t)(ns) / 1000)
00149 #define B_NS2MS(ns) ((int64_t)(ns) / 1000000)
00150 #define B_NS2S(ns) ((int64_t)(ns) / 1000000000)
00151 #define B_NANOSECONDS_TO_MICROSECONDS(ns) B_NS2US(ns)
00152 #define B_NANOSECONDS_TO_MILLISECONDS(ns) B_NS2MS(ns)
00153 #define B_NANOSECONDS_TO_SECONDS(ns) B_NS2S(ns)
00154
00155
00156 #define _FLB_FIRST32(x) *((uint32_t *) &x)
00157 #define _FLB_SECOND32(x) *((uint32_t *) &x + 1)
00158 #define _FLB_ALL32(x) *((uint32_t *) &x)
00159
00160 #if CPU_ENDIAN == CPU_ENDIAN_LITTLE
00161 #define _FLB_LO32(x) *((uint32_t *) &x)
00162 #define _FLB_HI32(x) *((uint32_t *) &x + 1)
00163
00164 #else
00165 #define _FLB_HI32(x) *((uint32_t *) &x)
00166 #define _FLB_LO32(x) *((uint32_t *) &x + 1)
00167
00168 #endif
00169
00170
00171
00172
00173 #ifndef NULL
00174 #define NULL 0
00175 #endif // NULL
00176
00177
00178 #ifdef __MWERKS__
00179 #if !__option(bool)
00180 #ifndef true
00181 #define true 1
00182 #endif
00183 #ifndef false
00184 #define false 0
00185 #endif
00186 #endif
00187 #else
00188 #ifndef __cplusplus
00189 #ifndef true
00190 enum {false, true};
00191 #endif
00192 #endif
00193 #endif
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204 #define EndianSwap16(n) (((((uint16_t) n) << 8) & 0xFF00) | \
00205 ((((uint16_t) n) >> 8) & 0x00FF))
00206
00207 #define EndianSwap32(n) (((((uint32_t) n) << 24) & 0xFF000000) | \
00208 ((((uint32_t) n) << 8) & 0x00FF0000) | \
00209 ((((uint32_t) n) >> 8) & 0x0000FF00) | \
00210 ((((uint32_t) n) >> 24) & 0x000000FF))
00211
00212
00213
00214
00215 #if CPU_ENDIAN == CPU_ENDIAN_BIG
00216
00217 #define RsrcEndianSwap16(x) (x)
00218
00219
00220 #define RsrcEndianSwap32(x) (x)
00221
00222 #elif CPU_ENDIAN == CPU_ENDIAN_LITTLE
00223
00224
00225
00226 #define RsrcEndianSwap16(x) EndianSwap16(*(uint16_t*)&(x))
00227
00228
00229 #define RsrcEndianSwap32(x) EndianSwap32(*(uint32_t*)&(x))
00230
00231 #endif
00232
00233
00234
00235
00236
00237 #if defined(NO_RUNTIME_SHARED_LIBRARIES) && defined(__arm)
00238
00239
00240 __global_reg(6) uint32_t sb;
00241 #endif
00242
00243
00244 #if defined(__arm) && defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 130000)
00245 #define _STACK_ALIGN(x) __align(x)
00246 #else
00247 #define _STACK_ALIGN(x)
00248 #endif
00249
00252 #endif