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