00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef _SUPPORT_DEFS_H
00014 #define _SUPPORT_DEFS_H
00015
00031
00032
00033 #include <support/SupportBuild.h>
00034 #include <SysThread.h>
00035 #include <stdint.h>
00036
00037
00038 #define LIBBE2 1
00039
00040 #if defined(_MSC_VER) && _MSC_VER
00041 # define B_MAKE_INT64(_x) _x##i64
00042 # define B_MAKE_UINT64(_x) _x##ui64
00043 #else
00044 # define B_MAKE_INT64(_x) _x##LL
00045 # define B_MAKE_UINT64(_x) _x##ULL
00046 #endif
00047
00048 #if TARGET_HOST == TARGET_HOST_WIN32
00049 # define B_FORMAT_INT64 "I64"
00050 #elif TARGET_HOST == TARGET_HOST_BEOS
00051 # define B_FORMAT_INT64 "L"
00052 #else
00053 # define B_FORMAT_INT64 "ll"
00054 #endif
00055
00056 #include <support/Errors.h>
00057
00058 #ifndef SUPPORTS_ATOM_DEBUG
00059 #if BUILD_TYPE == BUILD_TYPE_DEBUG
00060 #define SUPPORTS_ATOM_DEBUG 1
00061 #else
00062 #define SUPPORTS_ATOM_DEBUG 0
00063 #endif
00064 #endif
00065
00066
00067
00068
00069
00070
00071 #if TARGET_HOST == TARGET_HOST_BEOS
00072
00073 #include <kernel/OS.h>
00074 #include <kernel/image.h>
00075
00076 #define B_OS_NAME_LENGTH B_OS_NAME_LENGTH
00077 #define B_INFINITE_TIMEOUT B_INFINITE_TIMEOUT
00078
00079 #define B_LOW_PRIORITY B_LOW_PRIORITY
00080 #define B_NORMAL_PRIORITY B_NORMAL_PRIORITY
00081 #define B_TRANSACTION_PRIORITY B_NORMAL_PRIORITY
00082 #define B_DISPLAY_PRIORITY B_DISPLAY_PRIORITY
00083 #define B_URGENT_DISPLAY_PRIORITY B_URGENT_DISPLAY_PRIORITY
00084 #define B_REAL_TIME_DISPLAY_PRIORITY B_REAL_TIME_DISPLAY_PRIORITY
00085 #define B_URGENT_PRIORITY B_URGENT_PRIORITY
00086 #define B_REAL_TIME_PRIORITY B_REAL_TIME_PRIORITY
00087
00088 #else
00089
00090 #include <fcntl.h>
00091 #include <sys/param.h>
00092 #include <time.h>
00093
00094 #ifdef __cplusplus
00095 extern "C" {
00096 #endif
00097
00098
00099
00100 #define B_OS_NAME_LENGTH 32
00101
00102 #define B_INFINITE_TIMEOUT B_MAKE_INT64(9223372036854775807)
00103
00104 #define B_MICROSECONDS(n) (B_ONE_MICROSECOND*n)
00105 #define B_MILLISECONDS(n) (B_ONE_MILLISECOND*n)
00106 #define B_SECONDS(n) (B_ONE_SECOND*n)
00107
00108
00109
00110 typedef int32_t area_id;
00111 typedef int32_t port_id;
00112 typedef SysHandle sem_id;
00113 typedef int32_t thread_id;
00114 typedef int32_t team_id;
00115
00116
00117
00118
00119
00120
00121
00122 enum {
00123 B_CAN_INTERRUPT = 1,
00124 B_DO_NOT_RESCHEDULE = 2,
00125 B_CHECK_PERMISSION = 4,
00126 B_TIMEOUT = 8,
00127
00128
00129 B_USE_REAL_TIME = 32,
00130 B_WAKE_ON_TIMEOUT = 64
00131 };
00132
00133
00134
00135 typedef enum {
00136 B_THREAD_RUNNING=1,
00137 B_THREAD_READY,
00138 B_THREAD_RECEIVING,
00139 B_THREAD_ASLEEP,
00140 B_THREAD_SUSPENDED,
00141 B_THREAD_WAITING,
00142
00143 _thread_state_force_int32 = 0x10000000
00144 } thread_state;
00145
00146 #if (TARGET_HOST == TARGET_HOST_PALMOS) || (TARGET_HOST == TARGET_HOST_LINUX)
00147
00148
00149 #define B_LOW_PRIORITY sysThreadPriorityLow
00150 #define B_NORMAL_PRIORITY sysThreadPriorityNormal
00151 #define B_TRANSACTION_PRIORITY sysThreadPriorityTransaction
00152 #define B_DISPLAY_PRIORITY sysThreadPriorityDisplay
00153 #define B_URGENT_DISPLAY_PRIORITY sysThreadPriorityUrgentDisplay
00154 #define B_REAL_TIME_PRIORITY sysThreadPriorityHigh
00155
00156 #elif TARGET_HOST == TARGET_HOST_WIN32
00157
00158
00159 #define B_LOW_PRIORITY -2
00160 #define B_NORMAL_PRIORITY -1
00161 #define B_TRANSACTION_PRIORITY 0
00162 #define B_DISPLAY_PRIORITY 0
00163 #define B_URGENT_DISPLAY_PRIORITY 1
00164 #define B_REAL_TIME_DISPLAY_PRIORITY 2
00165 #define B_URGENT_PRIORITY 16
00166 #define B_REAL_TIME_PRIORITY 17
00167
00168 #else
00169
00170 #define B_LOW_PRIORITY 5
00171 #define B_NORMAL_PRIORITY 10
00172 #define B_TRANSACTION_PRIORITY 13
00173 #define B_DISPLAY_PRIORITY 15
00174 #define B_URGENT_DISPLAY_PRIORITY 20
00175 #define B_REAL_TIME_DISPLAY_PRIORITY 100
00176 #define B_URGENT_PRIORITY 110
00177 #define B_REAL_TIME_PRIORITY 120
00178
00179 #endif
00180
00181 typedef int32_t (*thread_func) (void *);
00182
00183
00184 #if TARGET_HOST == TARGET_HOST_LINUX
00185 typedef void* image_id;
00186 #define B_BAD_IMAGE_ID NULL
00187 #elif TARGET_HOST == TARGET_HOST_WIN32
00188 typedef int32_t image_id;
00189 #define B_BAD_IMAGE_ID -1
00190 #else
00191 #error "image_id -- unknown platform"
00192 #endif
00193
00194 #if TARGET_HOST == TARGET_HOST_WIN32
00195
00196
00197
00198 typedef enum {
00199 B_APP_IMAGE = 1,
00200 B_LIBRARY_IMAGE,
00201 B_ADD_ON_IMAGE,
00202 B_SYSTEM_IMAGE,
00203
00204 _image_type_force_int32 = 0x10000000
00205 } image_type;
00206
00207 typedef struct {
00208 image_id id;
00209 image_type type;
00210 int32_t sequence;
00211 int32_t init_order;
00212 void (*init_routine)(image_id imid);
00213 void (*term_routine)(image_id imid);
00214 dev_t device;
00215 ino_t node;
00216 char name[MAXPATHLEN];
00217 void *text;
00218 void *data;
00219 int32_t text_size;
00220 int32_t data_size;
00221 } image_info;
00222
00223 extern image_id load_add_on(const char *path);
00224 extern status_t unload_add_on(image_id imid);
00225
00226
00227 extern _IMPEXP_SUPPORT status_t get_image_info(image_id image, image_info *info);
00228 extern _IMPEXP_SUPPORT status_t get_next_image_info(team_id team, int32_t *cookie, image_info *info);
00229
00230 #define B_SYMBOL_TYPE_DATA 0x1
00231 #define B_SYMBOL_TYPE_TEXT 0x2
00232 #define B_SYMBOL_TYPE_ANY 0x5
00233
00234 extern _IMPEXP_SUPPORT status_t get_image_symbol(image_id imid, const char *name, int32_t sclass, void **ptr);
00235 extern _IMPEXP_SUPPORT status_t get_nth_image_symbol(image_id imid, int32_t index, char *buf, int32_t *bufsize, int32_t *sclass, void **ptr);
00236
00237
00238 #endif
00239
00240 #if TARGET_HOST != TARGET_HOST_PALMOS
00241 static inline void* inplace_realloc (void* mem, size_t size)
00242 {
00243 return NULL;
00244 }
00245
00246
00247
00248 #ifndef _UUID_T
00249 #define _UUID_T
00250 typedef struct uuid_t
00251 {
00252 uint32_t time_low;
00253 uint16_t time_mid;
00254 uint16_t time_hi_and_version;
00255 uint8_t clock_seq_hi_and_reserved;
00256 uint8_t clock_seq_low;
00257 uint8_t node[6];
00258 } uuid_t;
00259 #endif
00260 #endif
00261
00262 #ifdef __cplusplus
00263 }
00264 #endif
00265
00266 #endif
00267
00268 #ifdef __cplusplus
00269 extern "C" {
00270 #endif
00271
00272
00280 void* inplace_realloc (void *, size_t);
00281 #ifdef __cplusplus
00282 }
00283 #endif
00284
00285
00286
00288 struct lock_status_t {
00289 void (*unlock_func)(void* data);
00290 union {
00291 status_t error;
00292 void* data;
00293 } value;
00294
00295 #ifdef __cplusplus
00296
00297 inline lock_status_t(void (*f)(void*), void* d) { unlock_func = f; value.data = d; }
00299 inline lock_status_t(status_t e) { unlock_func = NULL; value.error = e; }
00300
00302 inline bool is_locked() const { return (unlock_func != NULL); }
00304 inline status_t status() const { return is_locked() ? (status_t) B_OK : value.error; }
00306 inline void unlock() const { if (unlock_func) unlock_func(value.data); }
00307
00309 inline operator status_t() const { return status(); }
00310 #endif
00311 };
00312
00313
00314
00316 enum no_init_t {
00317 B_DO_NOT_INITIALIZE = 1
00318 };
00319
00320
00321
00323 enum {
00324 B_PRINT_STREAM_HEADER = 0x00000001
00325 };
00326
00327
00328
00329
00332 #endif