1 #ifndef HAIKU_BUILD_COMPATIBILITY_H 2 #define HAIKU_BUILD_COMPATIBILITY_H 3 4 /*! 5 This header is automatically included in all Haiku applications 6 that are built for BeOS or a Haiku host (which might not be compatible 7 with the current Haiku source anymore). 8 It will make BeOS/Haiku a bit more Haiku compatible, and slightly more 9 POSIX compatible, too. It is supposed to keep the BeOS compatibility 10 kludges in our source files at a minimum. 11 */ 12 13 #ifdef HAIKU_HOST_PLATFORM_DANO 14 # include <be_setup.h> 15 # include <be_errors.h> 16 # define _ERRORS_H 17 // this is what Haiku/BeOS is using 18 #endif 19 20 #ifdef HAIKU_TARGET_PLATFORM_LIBBE_TEST 21 # define _BE_ERRNO_H_ 22 // this is what Dano/Zeta is using 23 # include <Errors.h> 24 #endif 25 26 #include <sys/stat.h> 27 #include <sys/types.h> 28 #include <SupportDefs.h> 29 #include <TypeConstants.h> 30 31 #include <string.h> 32 33 // no addr_t under standard BeOS 34 #ifndef HAIKU_HOST_PLATFORM_HAIKU 35 typedef unsigned long haiku_build_addr_t; 36 # define addr_t haiku_build_addr_t 37 #endif 38 39 #ifndef HAIKU_HOST_PLATFORM_HAIKU 40 41 struct sockaddr_storage { 42 uint8 ss_len; /* total length */ 43 uint8 ss_family; /* address family */ 44 uint8 __ss_pad1[6]; /* align to quad */ 45 uint64 __ss_pad2; /* force alignment to 64 bit */ 46 uint8 __ss_pad3[112]; /* pad to a total of 128 bytes */ 47 }; 48 49 typedef int socklen_t; 50 51 #endif // !HAIKU_HOST_PLATFORM_HAIKU 52 53 #ifndef DEFFILEMODE 54 # define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) 55 #endif 56 57 #ifndef FS_WRITE_FSINFO_NAME 58 # define FS_WRITE_FSINFO_NAME 0x0001 59 #endif 60 61 #ifndef B_CURRENT_TEAM 62 # define B_CURRENT_TEAM 0 63 #endif 64 65 #ifndef SYMLOOP_MAX 66 # define SYMLOOP_MAX (16) 67 #endif 68 69 #ifndef B_FIRST_REAL_TIME_PRIORITY 70 # define B_FIRST_REAL_TIME_PRIORITY B_REAL_TIME_DISPLAY_PRIORITY 71 #endif 72 73 #ifndef B_SPINLOCK_INITIALIZER 74 # define B_SPINLOCK_INITIALIZER 0 75 #endif 76 77 #if defined(__GNUC__) && !defined(_PRINTFLIKE) 78 # define _PRINTFLIKE(_format_, _args_) \ 79 __attribute__((format(__printf__, _format_, _args_))) 80 #endif 81 82 #if defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST) \ 83 && !defined(HAIKU_HOST_PLATFORM_HAIKU) 84 // BeOS version of BeBuild.h defines this 85 # define _IMPEXP_ROOT __declspec(dllimport) 86 # define _IMPEXP_BE __declspec(dllimport) 87 # define _IMPEXP_MEDIA __declspec(dllimport) 88 # define _IMPEXP_TRACKER __declspec(dllimport) 89 # define _IMPEXP_TRANSLATION __declspec(dllimport) 90 # define _IMPEXP_DEVICE __declspec(dllimport) 91 # define _IMPEXP_NET __declspec(dllimport) 92 #endif 93 94 #if defined(__cplusplus) && !defined(HAIKU_HOST_PLATFORM_HAIKU) 95 class BBuffer; 96 class BBufferConsumer; 97 class BBufferGroup; 98 class BContinuousParameter; 99 class BControllable; 100 class BFileInterface; 101 class BMimeType; 102 class BParameterWeb; 103 class BRegion; 104 class BTextView; 105 class BTranslator; 106 class BTimeSource; 107 struct entry_ref; 108 struct media_node; 109 #endif 110 111 #ifdef __cplusplus 112 extern "C" { 113 #endif 114 115 extern int32 atomic_set(vint32 *value, int32 newValue); 116 extern int32 atomic_test_and_set(vint32 *value, int32 newValue, 117 int32 testAgainst); 118 extern int32 atomic_get(vint32 *value); 119 extern int64 atomic_set64(vint64 *value, int64 newValue); 120 extern int64 atomic_test_and_set64(vint64 *value, int64 newValue, 121 int64 testAgainst); 122 extern int64 atomic_get64(vint64 *value); 123 extern int64 atomic_add64(vint64 *value, int64 addValue); 124 extern int64 atomic_and64(vint64 *value, int64 andValue); 125 extern int64 atomic_or64(vint64 *value, int64 orValue); 126 127 extern size_t strnlen(const char *string, size_t count); 128 129 extern size_t strlcat(char *dest, const char *source, size_t length); 130 extern size_t strlcpy(char *dest, const char *source, size_t length); 131 132 extern char *strcasestr(const char *string, const char *searchString); 133 134 extern float roundf(float value); 135 136 #ifdef __cplusplus 137 } 138 #endif 139 140 // These are R1-specific extensions 141 #if !defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST) \ 142 && !defined(HAIKU_HOST_PLATFORM_HAIKU) 143 # define B_TRANSLATION_MAKE_VERSION(major, minor, revision) \ 144 ((major << 8) | ((minor << 4) & 0xf0) | (revision & 0x0f)) 145 # define B_TRANSLATION_MAJOR_VERSION(v) (v >> 8) 146 # define B_TRANSLATION_MINOR_VERSION(v) ((v >> 4) & 0xf) 147 # define B_TRANSLATION_REVISION_VERSION(v) (v & 0xf) 148 # ifndef USING_HAIKU_TYPE_CONSTANTS_H 149 # define B_LARGE_ICON_TYPE 'ICON' 150 # define B_MINI_ICON_TYPE 'MICN' 151 # define B_VECTOR_ICON_TYPE 'VICN' 152 # define B_BITMAP_NO_SERVER_LINK 0 153 # define B_BITMAP_SCALE_BILINEAR 0 154 # endif 155 #endif // HAIKU_TARGET_PLATFORM_LIBBE_TEST 156 157 #if defined(HAIKU_TARGET_PLATFORM_BEOS) || defined(HAIKU_TARGET_PLATFORM_BONE) 158 # define B_REDO 'REDO' 159 # define B_BAD_DATA (B_NOT_ALLOWED + 1) 160 # define B_DOCUMENT_BACKGROUND_COLOR B_PANEL_BACKGROUND_COLOR 161 # define B_DOCUMENT_TEXT_COLOR B_MENU_ITEM_TEXT_COLOR 162 #endif 163 164 #if !defined(HAIKU_HOST_PLATFORM_HAIKU) && !defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST) 165 # if !defined(B_NOT_SUPPORTED) && !defined(HAIKU_HOST_PLATFORM_DANO) 166 # define B_NOT_SUPPORTED (B_ERROR) 167 # endif 168 # define B_KERNEL_READ_AREA 0 169 # define B_KERNEL_WRITE_AREA 0 170 #endif 171 172 #if defined(HAIKU_TARGET_PLATFORM_BONE) || defined(HAIKU_TARGET_PLATFORM_DANO) 173 # define IF_NAMESIZE IFNAMSIZ 174 # define ifc_value ifc_val 175 # define IFF_AUTO_CONFIGURED 0 176 #endif 177 178 #include <limits.h> 179 180 #ifndef INT32_MAX 181 # define INT32_MAX INT_MAX 182 #endif 183 184 #ifndef INT64_MAX 185 # define INT64_MAX LONGLONG_MAX 186 #endif 187 188 #ifndef HAIKU_HOST_PLATFORM_HAIKU 189 # define B_MPEG_2_AUDIO_LAYER_1 (enum mpeg_id)0x201 190 # define B_MPEG_2_AUDIO_LAYER_2 (enum mpeg_id)0x202 191 # define B_MPEG_2_AUDIO_LAYER_3 (enum mpeg_id)0x203 192 # define B_MPEG_2_VIDEO (enum mpeg_id)0x211 193 # define B_MPEG_2_5_AUDIO_LAYER_1 (enum mpeg_id)0x301 194 # define B_MPEG_2_5_AUDIO_LAYER_2 (enum mpeg_id)0x302 195 # define B_MPEG_2_5_AUDIO_LAYER_3 (enum mpeg_id)0x303 196 #endif 197 198 // TODO: experimental API (keep in sync with Accelerant.h) 199 #ifndef HAIKU_HOST_PLATFORM_HAIKU 200 typedef struct { 201 uint32 version; 202 char vendor[128]; 203 char name[128]; 204 char serial_number[128]; 205 uint32 product_id; 206 struct { 207 uint16 week; 208 uint16 year; 209 } produced; 210 float width; 211 float height; 212 uint32 min_horizontal_frequency; // in kHz 213 uint32 max_horizontal_frequency; 214 uint32 min_vertical_frequency; // in Hz 215 uint32 max_vertical_frequency; 216 uint32 max_pixel_clock; // in kHz 217 } monitor_info; 218 #endif // !HAIKU_HOST_PLATFORM_HAIKU 219 220 221 #if !defined(B_HAIKU_32_BIT) && !defined(B_HAIKU_64_BIT) 222 # ifdef HAIKU_HOST_PLATFORM_64_BIT 223 # define B_HAIKU_64_BIT 1 224 # else 225 # define B_HAIKU_32_BIT 1 226 # endif 227 #endif 228 229 #ifndef B_PRId8 230 # define __HAIKU_PRI_PREFIX_32 "l" 231 # define __HAIKU_PRI_PREFIX_64 "ll" 232 # define __HAIKU_PRI_PREFIX_ADDR "l" 233 234 /* printf()/scanf() format strings for [u]int* types */ 235 # define B_PRId8 "d" 236 # define B_PRIi8 "i" 237 # define B_PRId16 "d" 238 # define B_PRIi16 "i" 239 # define B_PRId32 __HAIKU_PRI_PREFIX_32 "d" 240 # define B_PRIi32 __HAIKU_PRI_PREFIX_32 "i" 241 # define B_PRId64 __HAIKU_PRI_PREFIX_64 "d" 242 # define B_PRIi64 __HAIKU_PRI_PREFIX_64 "i" 243 # define B_PRIu8 "u" 244 # define B_PRIo8 "o" 245 # define B_PRIx8 "x" 246 # define B_PRIX8 "X" 247 # define B_PRIu16 "u" 248 # define B_PRIo16 "o" 249 # define B_PRIx16 "x" 250 # define B_PRIX16 "X" 251 # define B_PRIu32 __HAIKU_PRI_PREFIX_32 "u" 252 # define B_PRIo32 __HAIKU_PRI_PREFIX_32 "o" 253 # define B_PRIx32 __HAIKU_PRI_PREFIX_32 "x" 254 # define B_PRIX32 __HAIKU_PRI_PREFIX_32 "X" 255 # define B_PRIu64 __HAIKU_PRI_PREFIX_64 "u" 256 # define B_PRIo64 __HAIKU_PRI_PREFIX_64 "o" 257 # define B_PRIx64 __HAIKU_PRI_PREFIX_64 "x" 258 # define B_PRIX64 __HAIKU_PRI_PREFIX_64 "X" 259 260 # define B_SCNd8 "hhd" 261 # define B_SCNi8 "hhi" 262 # define B_SCNd16 "hd" 263 # define B_SCNi16 "hi" 264 # define B_SCNd32 __HAIKU_PRI_PREFIX_32 "d" 265 # define B_SCNi32 __HAIKU_PRI_PREFIX_32 "i" 266 # define B_SCNd64 __HAIKU_PRI_PREFIX_64 "d" 267 # define B_SCNi64 __HAIKU_PRI_PREFIX_64 "i" 268 # define B_SCNu8 "hhu" 269 # define B_SCNo8 "hho" 270 # define B_SCNx8 "hhx" 271 # define B_SCNu16 "hu" 272 # define B_SCNo16 "ho" 273 # define B_SCNx16 "hx" 274 # define B_SCNu32 __HAIKU_PRI_PREFIX_32 "u" 275 # define B_SCNo32 __HAIKU_PRI_PREFIX_32 "o" 276 # define B_SCNx32 __HAIKU_PRI_PREFIX_32 "x" 277 # define B_SCNu64 __HAIKU_PRI_PREFIX_64 "u" 278 # define B_SCNo64 __HAIKU_PRI_PREFIX_64 "o" 279 # define B_SCNx64 __HAIKU_PRI_PREFIX_64 "x" 280 281 /* printf() format strings for some standard types */ 282 /* size_t */ 283 # define B_PRIuSIZE __HAIKU_PRI_PREFIX_ADDR "u" 284 # define B_PRIoSIZE __HAIKU_PRI_PREFIX_ADDR "o" 285 # define B_PRIxSIZE __HAIKU_PRI_PREFIX_ADDR "x" 286 # define B_PRIXSIZE __HAIKU_PRI_PREFIX_ADDR "X" 287 /* ssize_t */ 288 # define B_PRIdSSIZE __HAIKU_PRI_PREFIX_ADDR "d" 289 # define B_PRIiSSIZE __HAIKU_PRI_PREFIX_ADDR "i" 290 /* addr_t */ 291 # define B_PRIuADDR __HAIKU_PRI_PREFIX_ADDR "u" 292 # define B_PRIoADDR __HAIKU_PRI_PREFIX_ADDR "o" 293 # define B_PRIxADDR __HAIKU_PRI_PREFIX_ADDR "x" 294 # define B_PRIXADDR __HAIKU_PRI_PREFIX_ADDR "X" 295 /* off_t */ 296 # define B_PRIdOFF B_PRId64 297 # define B_PRIiOFF B_PRIi64 298 /* dev_t */ 299 # define B_PRIdDEV B_PRId32 300 # define B_PRIiDEV B_PRIi32 301 /* ino_t */ 302 # define B_PRIdINO B_PRId64 303 # define B_PRIiINO B_PRIi64 304 /* time_t */ 305 # define B_PRIdTIME B_PRId32 306 # define B_PRIiTIME B_PRIi32 307 #endif // !B_PRId8 308 309 310 #endif // HAIKU_BUILD_COMPATIBILITY_H 311