1 #ifndef HAIKU_BUILD_COMPATIBILITY_H
2 #define HAIKU_BUILD_COMPATIBILITY_H
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.
13 #ifdef HAIKU_HOST_PLATFORM_DANO
14 # include <be_setup.h>
15 # include <be_errors.h>
17 // this is what Haiku/BeOS is using
20 #ifdef HAIKU_TARGET_PLATFORM_LIBBE_TEST
22 // this is what Dano/Zeta is using
27 #include <sys/types.h>
28 #include <SupportDefs.h>
29 #include <TypeConstants.h>
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
40 #if !defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST) \
41 && !defined(HAIKU_HOST_PLATFORM_HAIKU)
43 struct 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 */
51 typedef int socklen_t
;
53 #endif // !HAIKU_HOST_PLATFORM_HAIKU
56 # define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
59 #ifndef FS_WRITE_FSINFO_NAME
60 # define FS_WRITE_FSINFO_NAME 0x0001
63 #ifndef B_CURRENT_TEAM
64 # define B_CURRENT_TEAM 0
68 # define SYMLOOP_MAX (16)
71 #ifndef B_FIRST_REAL_TIME_PRIORITY
72 # define B_FIRST_REAL_TIME_PRIORITY B_REAL_TIME_DISPLAY_PRIORITY
75 #if !defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST) \
76 && !defined(B_SPINLOCK_INITIALIZER)
77 # define B_SPINLOCK_INITIALIZER 0
80 #if defined(__GNUC__) && !defined(_PRINTFLIKE)
81 # define _PRINTFLIKE(_format_, _args_) \
82 __attribute__((format(__printf__, _format_, _args_)))
86 // NOTE: This is probably only needed on platforms which don't use ELF
87 // as binary format. So could probably be removed completely.
88 #if defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST) \
89 && !defined(HAIKU_HOST_PLATFORM_HAIKU)
90 // BeOS version of BeBuild.h defines this
91 # define _IMPEXP_ROOT __declspec(dllimport)
92 # define _IMPEXP_BE __declspec(dllimport)
93 # define _IMPEXP_MEDIA __declspec(dllimport)
94 # define _IMPEXP_TRACKER __declspec(dllimport)
95 # define _IMPEXP_TRANSLATION __declspec(dllimport)
96 # define _IMPEXP_DEVICE __declspec(dllimport)
97 # define _IMPEXP_NET __declspec(dllimport)
101 #if defined(__cplusplus) && !defined(HAIKU_HOST_PLATFORM_HAIKU)
103 class BBufferConsumer
;
105 class BContinuousParameter
;
107 class BFileInterface
;
122 extern size_t strnlen(const char *string
, size_t count
);
124 extern size_t strlcat(char *dest
, const char *source
, size_t length
);
125 extern size_t strlcpy(char *dest
, const char *source
, size_t length
);
127 extern char *strcasestr(const char *string
, const char *searchString
);
129 extern float roundf(float value
);
135 // These are R1-specific extensions
136 #if !defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST) \
137 && !defined(HAIKU_HOST_PLATFORM_HAIKU)
138 # define B_TRANSLATION_MAKE_VERSION(major, minor, revision) \
139 ((major << 8) | ((minor << 4) & 0xf0) | (revision & 0x0f))
140 # define B_TRANSLATION_MAJOR_VERSION(v) (v >> 8)
141 # define B_TRANSLATION_MINOR_VERSION(v) ((v >> 4) & 0xf)
142 # define B_TRANSLATION_REVISION_VERSION(v) (v & 0xf)
143 # ifndef USING_HAIKU_TYPE_CONSTANTS_H
144 # define B_LARGE_ICON_TYPE 'ICON'
145 # define B_MINI_ICON_TYPE 'MICN'
146 # define B_VECTOR_ICON_TYPE 'VICN'
147 # define B_BITMAP_NO_SERVER_LINK 0
148 # define B_BITMAP_SCALE_BILINEAR 0
150 #endif // HAIKU_TARGET_PLATFORM_LIBBE_TEST
152 #if defined(HAIKU_TARGET_PLATFORM_BEOS) || defined(HAIKU_TARGET_PLATFORM_BONE)
153 # define B_REDO 'REDO'
154 # define B_BAD_DATA (B_NOT_ALLOWED + 1)
155 # define B_DOCUMENT_BACKGROUND_COLOR B_PANEL_BACKGROUND_COLOR
156 # define B_DOCUMENT_TEXT_COLOR B_MENU_ITEM_TEXT_COLOR
159 #if !defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST) \
160 && !defined(HAIKU_HOST_PLATFORM_HAIKU)
161 # if !defined(B_NOT_SUPPORTED) && !defined(HAIKU_HOST_PLATFORM_DANO)
162 # define B_NOT_SUPPORTED (B_ERROR)
164 # define B_KERNEL_READ_AREA 0
165 # define B_KERNEL_WRITE_AREA 0
168 #if defined(HAIKU_TARGET_PLATFORM_BONE) || defined(HAIKU_TARGET_PLATFORM_DANO)
169 # define IF_NAMESIZE IFNAMSIZ
170 # define ifc_value ifc_val
171 # define IFF_AUTO_CONFIGURED 0
177 # define INT32_MAX INT_MAX
181 # define INT64_MAX LONGLONG_MAX
184 #if !defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST) \
185 && !defined(HAIKU_HOST_PLATFORM_HAIKU)
186 # define B_MPEG_2_AUDIO_LAYER_1 (enum mpeg_id)0x201
187 # define B_MPEG_2_AUDIO_LAYER_2 (enum mpeg_id)0x202
188 # define B_MPEG_2_AUDIO_LAYER_3 (enum mpeg_id)0x203
189 # define B_MPEG_2_VIDEO (enum mpeg_id)0x211
190 # define B_MPEG_2_5_AUDIO_LAYER_1 (enum mpeg_id)0x301
191 # define B_MPEG_2_5_AUDIO_LAYER_2 (enum mpeg_id)0x302
192 # define B_MPEG_2_5_AUDIO_LAYER_3 (enum mpeg_id)0x303
195 // TODO: experimental API (keep in sync with Accelerant.h)
196 #if !defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST) \
197 && !defined(HAIKU_HOST_PLATFORM_HAIKU)
202 char serial_number
[128];
210 uint32 min_horizontal_frequency
; // in kHz
211 uint32 max_horizontal_frequency
;
212 uint32 min_vertical_frequency
; // in Hz
213 uint32 max_vertical_frequency
;
214 uint32 max_pixel_clock
; // in kHz
216 #endif // !HAIKU_HOST_PLATFORM_HAIKU
219 #if !defined(B_HAIKU_32_BIT) && !defined(B_HAIKU_64_BIT)
220 # ifdef HAIKU_HOST_PLATFORM_64_BIT
221 # define B_HAIKU_64_BIT 1
223 # define B_HAIKU_32_BIT 1
228 # define __HAIKU_PRI_PREFIX_32 "l"
229 # define __HAIKU_PRI_PREFIX_64 "ll"
230 # define __HAIKU_PRI_PREFIX_ADDR "l"
232 /* printf()/scanf() format strings for [u]int* types */
235 # define B_PRId16 "d"
236 # define B_PRIi16 "i"
237 # define B_PRId32 __HAIKU_PRI_PREFIX_32 "d"
238 # define B_PRIi32 __HAIKU_PRI_PREFIX_32 "i"
239 # define B_PRId64 __HAIKU_PRI_PREFIX_64 "d"
240 # define B_PRIi64 __HAIKU_PRI_PREFIX_64 "i"
245 # define B_PRIu16 "u"
246 # define B_PRIo16 "o"
247 # define B_PRIx16 "x"
248 # define B_PRIX16 "X"
249 # define B_PRIu32 __HAIKU_PRI_PREFIX_32 "u"
250 # define B_PRIo32 __HAIKU_PRI_PREFIX_32 "o"
251 # define B_PRIx32 __HAIKU_PRI_PREFIX_32 "x"
252 # define B_PRIX32 __HAIKU_PRI_PREFIX_32 "X"
253 # define B_PRIu64 __HAIKU_PRI_PREFIX_64 "u"
254 # define B_PRIo64 __HAIKU_PRI_PREFIX_64 "o"
255 # define B_PRIx64 __HAIKU_PRI_PREFIX_64 "x"
256 # define B_PRIX64 __HAIKU_PRI_PREFIX_64 "X"
258 # define B_SCNd8 "hhd"
259 # define B_SCNi8 "hhi"
260 # define B_SCNd16 "hd"
261 # define B_SCNi16 "hi"
262 # define B_SCNd32 __HAIKU_PRI_PREFIX_32 "d"
263 # define B_SCNi32 __HAIKU_PRI_PREFIX_32 "i"
264 # define B_SCNd64 __HAIKU_PRI_PREFIX_64 "d"
265 # define B_SCNi64 __HAIKU_PRI_PREFIX_64 "i"
266 # define B_SCNu8 "hhu"
267 # define B_SCNo8 "hho"
268 # define B_SCNx8 "hhx"
269 # define B_SCNu16 "hu"
270 # define B_SCNo16 "ho"
271 # define B_SCNx16 "hx"
272 # define B_SCNu32 __HAIKU_PRI_PREFIX_32 "u"
273 # define B_SCNo32 __HAIKU_PRI_PREFIX_32 "o"
274 # define B_SCNx32 __HAIKU_PRI_PREFIX_32 "x"
275 # define B_SCNu64 __HAIKU_PRI_PREFIX_64 "u"
276 # define B_SCNo64 __HAIKU_PRI_PREFIX_64 "o"
277 # define B_SCNx64 __HAIKU_PRI_PREFIX_64 "x"
279 /* printf() format strings for some standard types */
281 # define B_PRIuSIZE __HAIKU_PRI_PREFIX_ADDR "u"
282 # define B_PRIoSIZE __HAIKU_PRI_PREFIX_ADDR "o"
283 # define B_PRIxSIZE __HAIKU_PRI_PREFIX_ADDR "x"
284 # define B_PRIXSIZE __HAIKU_PRI_PREFIX_ADDR "X"
286 # define B_PRIdSSIZE __HAIKU_PRI_PREFIX_ADDR "d"
287 # define B_PRIiSSIZE __HAIKU_PRI_PREFIX_ADDR "i"
289 # define B_PRIuADDR __HAIKU_PRI_PREFIX_ADDR "u"
290 # define B_PRIoADDR __HAIKU_PRI_PREFIX_ADDR "o"
291 # define B_PRIxADDR __HAIKU_PRI_PREFIX_ADDR "x"
292 # define B_PRIXADDR __HAIKU_PRI_PREFIX_ADDR "X"
294 # define B_PRIdOFF B_PRId64
295 # define B_PRIiOFF B_PRIi64
297 # define B_PRIdDEV B_PRId32
298 # define B_PRIiDEV B_PRIi32
300 # define B_PRIdINO B_PRId64
301 # define B_PRIiINO B_PRIi64
303 # define B_PRIdTIME B_PRId32
304 # define B_PRIiTIME B_PRIi32
308 #endif // HAIKU_BUILD_COMPATIBILITY_H