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. 7 It will make BeOS a bit more Haiku compatible, and slightly more 8 POSIX compatible, too. It is supposed to keep the BeOS compatibility 9 kludges in our source files at a minimum. 10 */ 11 12 #ifdef HAIKU_HOST_PLATFORM_DANO 13 # include <be_setup.h> 14 # include <be_errors.h> 15 # define _ERRORS_H 16 // this is what Haiku/BeOS is using 17 #endif 18 19 #ifdef HAIKU_TARGET_PLATFORM_LIBBE_TEST 20 # define _BE_ERRNO_H_ 21 // this is what Dano/Zeta is using 22 # include <Errors.h> 23 #endif 24 25 #include <sys/types.h> 26 #include <SupportDefs.h> 27 28 #include <string.h> 29 30 // no addr_t under standard BeOS 31 typedef unsigned long haiku_build_addr_t; 32 #define addr_t haiku_build_addr_t 33 34 struct sockaddr_storage { 35 uint8 ss_len; /* total length */ 36 uint8 ss_family; /* address family */ 37 uint8 __ss_pad1[6]; /* align to quad */ 38 uint64 __ss_pad2; /* force alignment to 64 bit */ 39 uint8 __ss_pad3[112]; /* pad to a total of 128 bytes */ 40 }; 41 42 typedef int socklen_t; 43 44 #ifndef DEFFILEMODE 45 # define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) 46 #endif 47 48 #ifndef FS_WRITE_FSINFO_NAME 49 # define FS_WRITE_FSINFO_NAME 0x0001 50 #endif 51 52 #ifndef B_CURRENT_TEAM 53 # define B_CURRENT_TEAM 0 54 #endif 55 56 #ifndef SYMLOOP_MAX 57 # define SYMLOOP_MAX (16) 58 #endif 59 60 #ifndef B_FIRST_REAL_TIME_PRIORITY 61 # define B_FIRST_REAL_TIME_PRIORITY B_REAL_TIME_DISPLAY_PRIORITY 62 #endif 63 64 #if __GNUC__ 65 # define _PRINTFLIKE(_format_, _args_) \ 66 __attribute__((format(__printf__, _format_, _args_))) 67 #endif 68 69 #ifdef HAIKU_TARGET_PLATFORM_LIBBE_TEST 70 // BeOS version of BeBuild.h defines this 71 # define _IMPEXP_ROOT __declspec(dllimport) 72 # define _IMPEXP_BE __declspec(dllimport) 73 # define _IMPEXP_MEDIA __declspec(dllimport) 74 # define _IMPEXP_TRACKER __declspec(dllimport) 75 # define _IMPEXP_TRANSLATION __declspec(dllimport) 76 # define _IMPEXP_DEVICE __declspec(dllimport) 77 #endif 78 79 #ifdef __cplusplus 80 class BBuffer; 81 class BBufferConsumer; 82 class BBufferGroup; 83 class BContinuousParameter; 84 class BControllable; 85 class BFileInterface; 86 class BMimeType; 87 class BParameterWeb; 88 class BRegion; 89 class BTextView; 90 class BTranslator; 91 class BTimeSource; 92 struct entry_ref; 93 struct media_node; 94 #endif 95 96 #ifdef __cplusplus 97 extern "C" { 98 #endif 99 100 extern int32 atomic_set(vint32 *value, int32 newValue); 101 extern int32 atomic_test_and_set(vint32 *value, int32 newValue, 102 int32 testAgainst); 103 extern int32 atomic_get(vint32 *value); 104 extern int64 atomic_set64(vint64 *value, int64 newValue); 105 extern int64 atomic_test_and_set64(vint64 *value, int64 newValue, 106 int64 testAgainst); 107 extern int64 atomic_get64(vint64 *value); 108 extern int64 atomic_add64(vint64 *value, int64 addValue); 109 extern int64 atomic_and64(vint64 *value, int64 andValue); 110 extern int64 atomic_or64(vint64 *value, int64 orValue); 111 112 extern size_t strnlen(const char *string, size_t count); 113 114 extern size_t strlcat(char *dest, const char *source, size_t length); 115 extern size_t strlcpy(char *dest, const char *source, size_t length); 116 117 extern char *strcasestr(const char *string, const char *searchString); 118 119 extern float roundf(float value); 120 121 #ifdef __cplusplus 122 } 123 #endif 124 125 // These are R1-specific extensions 126 #ifndef HAIKU_TARGET_PLATFORM_LIBBE_TEST 127 # define B_TRANSLATION_MAKE_VERSION(major, minor, revision) \ 128 ((major << 8) | ((minor << 4) & 0xf0) | (revision & 0x0f)) 129 # define B_TRANSLATION_MAJOR_VERSION(v) (v >> 8) 130 # define B_TRANSLATION_MINOR_VERSION(v) ((v >> 4) & 0xf) 131 # define B_TRANSLATION_REVISION_VERSION(v) (v & 0xf) 132 # ifndef USING_HAIKU_TYPE_CONSTANTS_H 133 # define B_LARGE_ICON_TYPE 'ICON' 134 # define B_MINI_ICON_TYPE 'MICN' 135 # define B_VECTOR_ICON_TYPE 'VICN' 136 # define B_BITMAP_NO_SERVER_LINK 0 137 # endif 138 #endif // HAIKU_TARGET_PLATFORM_LIBBE_TEST 139 140 #if defined(HAIKU_TARGET_PLATFORM_BEOS) || defined(HAIKU_TARGET_PLATFORM_BONE) 141 # define B_REDO 'REDO' 142 # define B_BAD_DATA (B_NOT_ALLOWED + 1) 143 # define B_DOCUMENT_BACKGROUND_COLOR B_PANEL_BACKGROUND_COLOR 144 # define B_DOCUMENT_TEXT_COLOR B_MENU_ITEM_TEXT_COLOR 145 #endif 146 147 #if !defined(HAIKU_TARGET_PLATFORM_HAIKU) && !defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST) 148 # ifndef HAIKU_HOST_PLATFORM_DANO 149 # define B_NOT_SUPPORTED (B_ERROR) 150 # endif 151 # define B_KERNEL_READ_AREA 0 152 # define B_KERNEL_WRITE_AREA 0 153 #endif 154 155 #if defined(HAIKU_TARGET_PLATFORM_BONE) || defined(HAIKU_TARGET_PLATFORM_DANO) 156 # define IF_NAMESIZE IFNAMSIZ 157 # define ifc_value ifc_val 158 # define IFF_AUTO_CONFIGURED 0 159 #endif 160 161 #ifndef INT64_MAX 162 # include <limits.h> 163 # define INT64_MAX LONGLONG_MAX 164 #endif 165 166 #define B_MPEG_2_AUDIO_LAYER_1 (enum mpeg_id)0x201 167 #define B_MPEG_2_AUDIO_LAYER_2 (enum mpeg_id)0x202 168 #define B_MPEG_2_AUDIO_LAYER_3 (enum mpeg_id)0x203 169 #define B_MPEG_2_VIDEO (enum mpeg_id)0x211 170 #define B_MPEG_2_5_AUDIO_LAYER_1 (enum mpeg_id)0x301 171 #define B_MPEG_2_5_AUDIO_LAYER_2 (enum mpeg_id)0x302 172 #define B_MPEG_2_5_AUDIO_LAYER_3 (enum mpeg_id)0x303 173 174 // TODO: experimental API (keep in sync with Accelerant.h) 175 typedef struct { 176 uint32 version; 177 char vendor[128]; 178 char name[128]; 179 char serial_number[128]; 180 uint32 product_id; 181 struct { 182 uint16 week; 183 uint16 year; 184 } produced; 185 float width; 186 float height; 187 uint32 min_horizontal_frequency; // in kHz 188 uint32 max_horizontal_frequency; 189 uint32 min_vertical_frequency; // in Hz 190 uint32 max_vertical_frequency; 191 uint32 max_pixel_clock; // in kHz 192 } monitor_info; 193 194 195 #endif // HAIKU_BUILD_COMPATIBILITY_H 196 197