1338b8dc3SIngo Weinhold#ifndef HAIKU_BUILD_COMPATIBILITY_H
2338b8dc3SIngo Weinhold#define HAIKU_BUILD_COMPATIBILITY_H
3338b8dc3SIngo Weinhold
4b69e38d8SAxel Dörfler/*!
5b69e38d8SAxel Dörfler	This header is automatically included in all Haiku applications
66236ae85SIngo Weinhold	that are built for BeOS or a Haiku host (which might not be compatible
76236ae85SIngo Weinhold	with the current Haiku source anymore).
86236ae85SIngo Weinhold	It will make BeOS/Haiku a bit more Haiku compatible, and slightly more
9b69e38d8SAxel Dörfler	POSIX compatible, too. It is supposed to keep the BeOS compatibility
10b69e38d8SAxel Dörfler	kludges in our source files at a minimum.
11b69e38d8SAxel Dörfler*/
12b69e38d8SAxel Dörfler
13487b83f3SAxel Dörfler#ifdef HAIKU_TARGET_PLATFORM_LIBBE_TEST
14340ac5d0SAxel Dörfler#	define _BE_ERRNO_H_
15340ac5d0SAxel Dörfler		// this is what Dano/Zeta is using
16340ac5d0SAxel Dörfler#	include <Errors.h>
17340ac5d0SAxel Dörfler#endif
18340ac5d0SAxel Dörfler
196236ae85SIngo Weinhold#include <sys/stat.h>
209c800a96SAxel Dörfler#include <sys/types.h>
219c800a96SAxel Dörfler#include <SupportDefs.h>
226236ae85SIngo Weinhold#include <TypeConstants.h>
239c800a96SAxel Dörfler
24338b8dc3SIngo Weinhold#include <string.h>
25338b8dc3SIngo Weinhold
26ca9e5772SIngo Weinhold// no addr_t under standard BeOS
27af669347SStephan Aßmus#if !defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST) \
28af669347SStephan Aßmus	&& !defined(HAIKU_HOST_PLATFORM_HAIKU)
296236ae85SIngo Weinhold	typedef unsigned long haiku_build_addr_t;
306236ae85SIngo Weinhold#	define addr_t haiku_build_addr_t
316236ae85SIngo Weinhold#endif
326236ae85SIngo Weinhold
33af669347SStephan Aßmus#if !defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST) \
34af669347SStephan Aßmus	&& !defined(HAIKU_HOST_PLATFORM_HAIKU)
35338b8dc3SIngo Weinhold
36f033aee1SAxel Dörflerstruct sockaddr_storage {
37f033aee1SAxel Dörfler	uint8	ss_len;			/* total length */
38f033aee1SAxel Dörfler	uint8	ss_family;		/* address family */
39f033aee1SAxel Dörfler	uint8	__ss_pad1[6];	/* align to quad */
40f033aee1SAxel Dörfler	uint64	__ss_pad2;		/* force alignment to 64 bit */
41f033aee1SAxel Dörfler	uint8	__ss_pad3[112];	/* pad to a total of 128 bytes */
42f033aee1SAxel Dörfler};
43f033aee1SAxel Dörfler
44b69e38d8SAxel Dörflertypedef int socklen_t;
45b69e38d8SAxel Dörfler
466236ae85SIngo Weinhold#endif	// !HAIKU_HOST_PLATFORM_HAIKU
476236ae85SIngo Weinhold
48ca9e5772SIngo Weinhold#ifndef DEFFILEMODE
49340ac5d0SAxel Dörfler#	define	DEFFILEMODE	(S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
50338b8dc3SIngo Weinhold#endif
51338b8dc3SIngo Weinhold
52ca9e5772SIngo Weinhold#ifndef FS_WRITE_FSINFO_NAME
53340ac5d0SAxel Dörfler#	define	FS_WRITE_FSINFO_NAME	0x0001
54338b8dc3SIngo Weinhold#endif
55338b8dc3SIngo Weinhold
56ca9e5772SIngo Weinhold#ifndef B_CURRENT_TEAM
57340ac5d0SAxel Dörfler#	define B_CURRENT_TEAM	0
58ca9e5772SIngo Weinhold#endif
59338b8dc3SIngo Weinhold
609ecf9d1cSIngo Weinhold#ifndef SYMLOOP_MAX
619ecf9d1cSIngo Weinhold#	define SYMLOOP_MAX	(16)
629ecf9d1cSIngo Weinhold#endif
639ecf9d1cSIngo Weinhold
645f3c5830SJérôme Duval#ifndef B_FIRST_REAL_TIME_PRIORITY
655f3c5830SJérôme Duval#	define B_FIRST_REAL_TIME_PRIORITY B_REAL_TIME_DISPLAY_PRIORITY
665f3c5830SJérôme Duval#endif
67338b8dc3SIngo Weinhold
68e883b3c9SStephan Aßmus#if !defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST) \
696d19a82fSStephan Aßmus	&& !defined(B_SPINLOCK_INITIALIZER)
70620d4151SJérôme Duval#	define B_SPINLOCK_INITIALIZER 0
71620d4151SJérôme Duval#endif
72620d4151SJérôme Duval
736236ae85SIngo Weinhold#if defined(__GNUC__) && !defined(_PRINTFLIKE)
7427599988SStephan Aßmus#	define _PRINTFLIKE(_format_, _args_) \
7527599988SStephan Aßmus		__attribute__((format(__printf__, _format_, _args_)))
7627599988SStephan Aßmus#endif
779ecf9d1cSIngo Weinhold
78af669347SStephan Aßmus#if 0
79af669347SStephan Aßmus// NOTE: This is probably only needed on platforms which don't use ELF
80af669347SStephan Aßmus// as binary format. So could probably be removed completely.
816236ae85SIngo Weinhold#if defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST) \
826236ae85SIngo Weinhold	&& !defined(HAIKU_HOST_PLATFORM_HAIKU)
8355f2592dSStephan Aßmus// BeOS version of BeBuild.h defines this
84662e5c8cSAxel Dörfler#	define _IMPEXP_ROOT			__declspec(dllimport)
85662e5c8cSAxel Dörfler#	define _IMPEXP_BE			__declspec(dllimport)
86662e5c8cSAxel Dörfler#	define _IMPEXP_MEDIA		__declspec(dllimport)
87662e5c8cSAxel Dörfler#	define _IMPEXP_TRACKER		__declspec(dllimport)
88662e5c8cSAxel Dörfler#	define _IMPEXP_TRANSLATION	__declspec(dllimport)
89662e5c8cSAxel Dörfler#	define _IMPEXP_DEVICE		__declspec(dllimport)
903d4b8c87SStephan Aßmus#	define _IMPEXP_NET			__declspec(dllimport)
91662e5c8cSAxel Dörfler#endif
92af669347SStephan Aßmus#endif
9355f2592dSStephan Aßmus
946236ae85SIngo Weinhold#if defined(__cplusplus) && !defined(HAIKU_HOST_PLATFORM_HAIKU)
9555f2592dSStephan Aßmusclass BBuffer;
9655f2592dSStephan Aßmusclass BBufferConsumer;
9755f2592dSStephan Aßmusclass BBufferGroup;
9855f2592dSStephan Aßmusclass BContinuousParameter;
9955f2592dSStephan Aßmusclass BControllable;
10055f2592dSStephan Aßmusclass BFileInterface;
101d5f66210SStephan Aßmusclass BMimeType;
10255f2592dSStephan Aßmusclass BParameterWeb;
103d5f66210SStephan Aßmusclass BRegion;
10455f2592dSStephan Aßmusclass BTextView;
10555f2592dSStephan Aßmusclass BTranslator;
10655f2592dSStephan Aßmusclass BTimeSource;
10755f2592dSStephan Aßmusstruct entry_ref;
10855f2592dSStephan Aßmusstruct media_node;
10955f2592dSStephan Aßmus#endif
11055f2592dSStephan Aßmus
111ca9e5772SIngo Weinhold#ifdef __cplusplus
112ca9e5772SIngo Weinholdextern "C" {
113ca9e5772SIngo Weinhold#endif
114338b8dc3SIngo Weinhold
115ca9e5772SIngo Weinholdextern size_t	strnlen(const char *string, size_t count);
116338b8dc3SIngo Weinhold
117ca9e5772SIngo Weinholdextern size_t	strlcat(char *dest, const char *source, size_t length);
118ca9e5772SIngo Weinholdextern size_t   strlcpy(char *dest, const char *source, size_t length);
119338b8dc3SIngo Weinhold
120ca9e5772SIngo Weinholdextern char		*strcasestr(const char *string, const char *searchString);
121338b8dc3SIngo Weinhold
1228bd2c11fSAxel Dörflerextern float	roundf(float value);
1238bd2c11fSAxel Dörfler
124338b8dc3SIngo Weinhold#ifdef __cplusplus
125340ac5d0SAxel Dörfler}
126338b8dc3SIngo Weinhold#endif
127338b8dc3SIngo Weinhold
128374fa7fcSDarkWyrm// These are R1-specific extensions
1296236ae85SIngo Weinhold#if !defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST) \
1306236ae85SIngo Weinhold	&& !defined(HAIKU_HOST_PLATFORM_HAIKU)
1319c800a96SAxel Dörfler#	define B_TRANSLATION_MAKE_VERSION(major, minor, revision) \
1329c800a96SAxel Dörfler		((major << 8) | ((minor << 4) & 0xf0) | (revision & 0x0f))
133340ac5d0SAxel Dörfler#	define B_TRANSLATION_MAJOR_VERSION(v) (v >> 8)
134340ac5d0SAxel Dörfler#	define B_TRANSLATION_MINOR_VERSION(v) ((v >> 4) & 0xf)
135340ac5d0SAxel Dörfler#	define B_TRANSLATION_REVISION_VERSION(v) (v & 0xf)
136dd8a8496SAxel Dörfler#	ifndef USING_HAIKU_TYPE_CONSTANTS_H
1379c800a96SAxel Dörfler#		define B_LARGE_ICON_TYPE		'ICON'
1389c800a96SAxel Dörfler#		define B_MINI_ICON_TYPE			'MICN'
1399c800a96SAxel Dörfler#		define B_VECTOR_ICON_TYPE		'VICN'
1409c800a96SAxel Dörfler#		define B_BITMAP_NO_SERVER_LINK	0
141dcd70f0eSStephan Aßmus#		define B_BITMAP_SCALE_BILINEAR	0
1429c800a96SAxel Dörfler#	endif
14366cd7e6cSStephan Aßmus#endif	// HAIKU_TARGET_PLATFORM_LIBBE_TEST
14466cd7e6cSStephan Aßmus
145af669347SStephan Aßmus#if !defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST) \
146af669347SStephan Aßmus	&& !defined(HAIKU_HOST_PLATFORM_HAIKU)
147b357daa5SAugustin Cavalier#	if !defined(B_NOT_SUPPORTED)
1489c800a96SAxel Dörfler#		define B_NOT_SUPPORTED			(B_ERROR)
1497019a435SAxel Dörfler#	endif
150f033aee1SAxel Dörfler#	define B_KERNEL_READ_AREA			0
151f033aee1SAxel Dörfler#	define B_KERNEL_WRITE_AREA			0
1529e88e05bSDarkWyrm#endif
1539e88e05bSDarkWyrm
15437deb729SIngo Weinhold#include <limits.h>
15537deb729SIngo Weinhold
15637deb729SIngo Weinhold#ifndef INT32_MAX
15737deb729SIngo Weinhold#	define INT32_MAX INT_MAX
15837deb729SIngo Weinhold#endif
15937deb729SIngo Weinhold
160c332e7f7SJérôme Duval#ifndef INT64_MAX
1617019a435SAxel Dörfler#	define INT64_MAX LONGLONG_MAX
162c332e7f7SJérôme Duval#endif
163c332e7f7SJérôme Duval
164af669347SStephan Aßmus#if !defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST) \
165af669347SStephan Aßmus	&& !defined(HAIKU_HOST_PLATFORM_HAIKU)
1666236ae85SIngo Weinhold#	define	B_MPEG_2_AUDIO_LAYER_1 (enum mpeg_id)0x201
1676236ae85SIngo Weinhold#	define	B_MPEG_2_AUDIO_LAYER_2 (enum mpeg_id)0x202
1686236ae85SIngo Weinhold#	define	B_MPEG_2_AUDIO_LAYER_3 (enum mpeg_id)0x203
1696236ae85SIngo Weinhold#	define	B_MPEG_2_VIDEO (enum mpeg_id)0x211
1706236ae85SIngo Weinhold#	define	B_MPEG_2_5_AUDIO_LAYER_1 (enum mpeg_id)0x301
1716236ae85SIngo Weinhold#	define	B_MPEG_2_5_AUDIO_LAYER_2 (enum mpeg_id)0x302
1726236ae85SIngo Weinhold#	define	B_MPEG_2_5_AUDIO_LAYER_3 (enum mpeg_id)0x303
1736236ae85SIngo Weinhold#endif
1744d275b2bSJérôme Duval
17527599988SStephan Aßmus// TODO: experimental API (keep in sync with Accelerant.h)
176af669347SStephan Aßmus#if !defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST) \
177af669347SStephan Aßmus	&& !defined(HAIKU_HOST_PLATFORM_HAIKU)
17827599988SStephan Aßmustypedef struct {
17927599988SStephan Aßmus	uint32	version;
18027599988SStephan Aßmus	char	vendor[128];
18127599988SStephan Aßmus	char	name[128];
18227599988SStephan Aßmus	char	serial_number[128];
18327599988SStephan Aßmus	uint32	product_id;
18427599988SStephan Aßmus	struct {
18527599988SStephan Aßmus		uint16	week;
18627599988SStephan Aßmus		uint16	year;
18727599988SStephan Aßmus	}		produced;
18827599988SStephan Aßmus	float	width;
18927599988SStephan Aßmus	float	height;
19027599988SStephan Aßmus	uint32	min_horizontal_frequency;	// in kHz
19127599988SStephan Aßmus	uint32	max_horizontal_frequency;
19227599988SStephan Aßmus	uint32	min_vertical_frequency;		// in Hz
19327599988SStephan Aßmus	uint32	max_vertical_frequency;
19427599988SStephan Aßmus	uint32	max_pixel_clock;			// in kHz
19527599988SStephan Aßmus} monitor_info;
1966236ae85SIngo Weinhold#endif // !HAIKU_HOST_PLATFORM_HAIKU
19727599988SStephan Aßmus
19827599988SStephan Aßmus
1996236ae85SIngo Weinhold#if !defined(B_HAIKU_32_BIT) && !defined(B_HAIKU_64_BIT)
2006236ae85SIngo Weinhold#	ifdef HAIKU_HOST_PLATFORM_64_BIT
2016236ae85SIngo Weinhold#		define B_HAIKU_64_BIT	1
2026236ae85SIngo Weinhold#	else
2036236ae85SIngo Weinhold#		define B_HAIKU_32_BIT	1
2046236ae85SIngo Weinhold#	endif
2056236ae85SIngo Weinhold#endif
206338b8dc3SIngo Weinhold
2076236ae85SIngo Weinhold#ifndef B_PRId8
2086236ae85SIngo Weinhold#	define	__HAIKU_PRI_PREFIX_32		"l"
2096236ae85SIngo Weinhold#	define	__HAIKU_PRI_PREFIX_64		"ll"
2106236ae85SIngo Weinhold#	define	__HAIKU_PRI_PREFIX_ADDR		"l"
2116236ae85SIngo Weinhold
2126236ae85SIngo Weinhold	/* printf()/scanf() format strings for [u]int* types */
2136236ae85SIngo Weinhold#	define B_PRId8			"d"
2146236ae85SIngo Weinhold#	define B_PRIi8			"i"
2156236ae85SIngo Weinhold#	define B_PRId16			"d"
2166236ae85SIngo Weinhold#	define B_PRIi16			"i"
2176236ae85SIngo Weinhold#	define B_PRId32			__HAIKU_PRI_PREFIX_32 "d"
2186236ae85SIngo Weinhold#	define B_PRIi32			__HAIKU_PRI_PREFIX_32 "i"
2196236ae85SIngo Weinhold#	define B_PRId64			__HAIKU_PRI_PREFIX_64 "d"
2206236ae85SIngo Weinhold#	define B_PRIi64			__HAIKU_PRI_PREFIX_64 "i"
2216236ae85SIngo Weinhold#	define B_PRIu8			"u"
2226236ae85SIngo Weinhold#	define B_PRIo8			"o"
2236236ae85SIngo Weinhold#	define B_PRIx8			"x"
2246236ae85SIngo Weinhold#	define B_PRIX8			"X"
2256236ae85SIngo Weinhold#	define B_PRIu16			"u"
2266236ae85SIngo Weinhold#	define B_PRIo16			"o"
2276236ae85SIngo Weinhold#	define B_PRIx16			"x"
2286236ae85SIngo Weinhold#	define B_PRIX16			"X"
2296236ae85SIngo Weinhold#	define B_PRIu32			__HAIKU_PRI_PREFIX_32 "u"
2306236ae85SIngo Weinhold#	define B_PRIo32			__HAIKU_PRI_PREFIX_32 "o"
2316236ae85SIngo Weinhold#	define B_PRIx32			__HAIKU_PRI_PREFIX_32 "x"
2326236ae85SIngo Weinhold#	define B_PRIX32			__HAIKU_PRI_PREFIX_32 "X"
2336236ae85SIngo Weinhold#	define B_PRIu64			__HAIKU_PRI_PREFIX_64 "u"
2346236ae85SIngo Weinhold#	define B_PRIo64			__HAIKU_PRI_PREFIX_64 "o"
2356236ae85SIngo Weinhold#	define B_PRIx64			__HAIKU_PRI_PREFIX_64 "x"
2366236ae85SIngo Weinhold#	define B_PRIX64			__HAIKU_PRI_PREFIX_64 "X"
2376236ae85SIngo Weinhold
2386236ae85SIngo Weinhold#	define B_SCNd8 			"hhd"
2396236ae85SIngo Weinhold#	define B_SCNi8 			"hhi"
2406236ae85SIngo Weinhold#	define B_SCNd16			"hd"
2416236ae85SIngo Weinhold#	define B_SCNi16	 		"hi"
2426236ae85SIngo Weinhold#	define B_SCNd32 		__HAIKU_PRI_PREFIX_32 "d"
2436236ae85SIngo Weinhold#	define B_SCNi32	 		__HAIKU_PRI_PREFIX_32 "i"
2446236ae85SIngo Weinhold#	define B_SCNd64			__HAIKU_PRI_PREFIX_64 "d"
2456236ae85SIngo Weinhold#	define B_SCNi64 		__HAIKU_PRI_PREFIX_64 "i"
2466236ae85SIngo Weinhold#	define B_SCNu8 			"hhu"
2476236ae85SIngo Weinhold#	define B_SCNo8 			"hho"
2486236ae85SIngo Weinhold#	define B_SCNx8 			"hhx"
2496236ae85SIngo Weinhold#	define B_SCNu16			"hu"
2506236ae85SIngo Weinhold#	define B_SCNo16			"ho"
2516236ae85SIngo Weinhold#	define B_SCNx16			"hx"
2526236ae85SIngo Weinhold#	define B_SCNu32 		__HAIKU_PRI_PREFIX_32 "u"
2536236ae85SIngo Weinhold#	define B_SCNo32 		__HAIKU_PRI_PREFIX_32 "o"
2546236ae85SIngo Weinhold#	define B_SCNx32 		__HAIKU_PRI_PREFIX_32 "x"
2556236ae85SIngo Weinhold#	define B_SCNu64			__HAIKU_PRI_PREFIX_64 "u"
2566236ae85SIngo Weinhold#	define B_SCNo64			__HAIKU_PRI_PREFIX_64 "o"
2576236ae85SIngo Weinhold#	define B_SCNx64			__HAIKU_PRI_PREFIX_64 "x"
2586236ae85SIngo Weinhold
2596236ae85SIngo Weinhold	/* printf() format strings for some standard types */
2606236ae85SIngo Weinhold	/* size_t */
2616236ae85SIngo Weinhold#	define B_PRIuSIZE		__HAIKU_PRI_PREFIX_ADDR "u"
2626236ae85SIngo Weinhold#	define B_PRIoSIZE		__HAIKU_PRI_PREFIX_ADDR "o"
2636236ae85SIngo Weinhold#	define B_PRIxSIZE		__HAIKU_PRI_PREFIX_ADDR "x"
2646236ae85SIngo Weinhold#	define B_PRIXSIZE		__HAIKU_PRI_PREFIX_ADDR "X"
2656236ae85SIngo Weinhold	/* ssize_t */
2666236ae85SIngo Weinhold#	define B_PRIdSSIZE		__HAIKU_PRI_PREFIX_ADDR "d"
2676236ae85SIngo Weinhold#	define B_PRIiSSIZE		__HAIKU_PRI_PREFIX_ADDR "i"
2686236ae85SIngo Weinhold	/* addr_t */
2696236ae85SIngo Weinhold#	define B_PRIuADDR		__HAIKU_PRI_PREFIX_ADDR "u"
2706236ae85SIngo Weinhold#	define B_PRIoADDR		__HAIKU_PRI_PREFIX_ADDR "o"
2716236ae85SIngo Weinhold#	define B_PRIxADDR		__HAIKU_PRI_PREFIX_ADDR "x"
2726236ae85SIngo Weinhold#	define B_PRIXADDR		__HAIKU_PRI_PREFIX_ADDR "X"
2736236ae85SIngo Weinhold	/* off_t */
2746236ae85SIngo Weinhold#	define B_PRIdOFF		B_PRId64
2756236ae85SIngo Weinhold#	define B_PRIiOFF		B_PRIi64
2766236ae85SIngo Weinhold	/* dev_t */
2776236ae85SIngo Weinhold#	define B_PRIdDEV		B_PRId32
2786236ae85SIngo Weinhold#	define B_PRIiDEV		B_PRIi32
2796236ae85SIngo Weinhold	/* ino_t */
2806236ae85SIngo Weinhold#	define B_PRIdINO		B_PRId64
2816236ae85SIngo Weinhold#	define B_PRIiINO		B_PRIi64
2826236ae85SIngo Weinhold	/* time_t */
28339efd913SAugustin Cavalier#	if defined(__i386__) && !defined(__x86_64__)
28439efd913SAugustin Cavalier#		define B_PRIdTIME		B_PRId32
28539efd913SAugustin Cavalier#		define B_PRIiTIME		B_PRIi32
28639efd913SAugustin Cavalier#	else
28739efd913SAugustin Cavalier#		define B_PRIdTIME		B_PRId64
28839efd913SAugustin Cavalier#		define B_PRIiTIME		B_PRIi64
28939efd913SAugustin Cavalier#	endif
2906236ae85SIngo Weinhold#endif	// !B_PRId8
2916236ae85SIngo Weinhold
2926236ae85SIngo Weinhold
2936236ae85SIngo Weinhold#endif	// HAIKU_BUILD_COMPATIBILITY_H
294