xref: /haiku/headers/build/HaikuBuildCompatibility.h (revision 2600324b57fa31cdea1627d584d314f2a579c4a8)
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 #	define _IMPEXP_NET			__declspec(dllimport)
78 #endif
79 
80 #ifdef __cplusplus
81 class BBuffer;
82 class BBufferConsumer;
83 class BBufferGroup;
84 class BContinuousParameter;
85 class BControllable;
86 class BFileInterface;
87 class BMimeType;
88 class BParameterWeb;
89 class BRegion;
90 class BTextView;
91 class BTranslator;
92 class BTimeSource;
93 struct entry_ref;
94 struct media_node;
95 #endif
96 
97 #ifdef __cplusplus
98 extern "C" {
99 #endif
100 
101 extern int32	atomic_set(vint32 *value, int32 newValue);
102 extern int32	atomic_test_and_set(vint32 *value, int32 newValue,
103 					int32 testAgainst);
104 extern int32	atomic_get(vint32 *value);
105 extern int64	atomic_set64(vint64 *value, int64 newValue);
106 extern int64	atomic_test_and_set64(vint64 *value, int64 newValue,
107 					int64 testAgainst);
108 extern int64	atomic_get64(vint64 *value);
109 extern int64	atomic_add64(vint64 *value, int64 addValue);
110 extern int64	atomic_and64(vint64 *value, int64 andValue);
111 extern int64	atomic_or64(vint64 *value, int64 orValue);
112 
113 extern size_t	strnlen(const char *string, size_t count);
114 
115 extern size_t	strlcat(char *dest, const char *source, size_t length);
116 extern size_t   strlcpy(char *dest, const char *source, size_t length);
117 
118 extern char		*strcasestr(const char *string, const char *searchString);
119 
120 extern float	roundf(float value);
121 
122 #ifdef __cplusplus
123 }
124 #endif
125 
126 // These are R1-specific extensions
127 #ifndef HAIKU_TARGET_PLATFORM_LIBBE_TEST
128 #	define B_TRANSLATION_MAKE_VERSION(major, minor, revision) \
129 		((major << 8) | ((minor << 4) & 0xf0) | (revision & 0x0f))
130 #	define B_TRANSLATION_MAJOR_VERSION(v) (v >> 8)
131 #	define B_TRANSLATION_MINOR_VERSION(v) ((v >> 4) & 0xf)
132 #	define B_TRANSLATION_REVISION_VERSION(v) (v & 0xf)
133 #	ifndef USING_HAIKU_TYPE_CONSTANTS_H
134 #		define B_LARGE_ICON_TYPE		'ICON'
135 #		define B_MINI_ICON_TYPE			'MICN'
136 #		define B_VECTOR_ICON_TYPE		'VICN'
137 #		define B_BITMAP_NO_SERVER_LINK	0
138 #		define B_BITMAP_SCALE_BILINEAR	0
139 #	endif
140 #endif	// HAIKU_TARGET_PLATFORM_LIBBE_TEST
141 
142 #if defined(HAIKU_TARGET_PLATFORM_BEOS) || defined(HAIKU_TARGET_PLATFORM_BONE)
143 #	define B_REDO						'REDO'
144 #	define B_BAD_DATA					(B_NOT_ALLOWED + 1)
145 #	define B_DOCUMENT_BACKGROUND_COLOR	B_PANEL_BACKGROUND_COLOR
146 #	define B_DOCUMENT_TEXT_COLOR		B_MENU_ITEM_TEXT_COLOR
147 #endif
148 
149 #if !defined(HAIKU_TARGET_PLATFORM_HAIKU) && !defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST)
150 #	if !defined(B_NOT_SUPPORTED) && !defined(HAIKU_HOST_PLATFORM_DANO)
151 #		define B_NOT_SUPPORTED			(B_ERROR)
152 #	endif
153 #	define B_KERNEL_READ_AREA			0
154 #	define B_KERNEL_WRITE_AREA			0
155 #endif
156 
157 #if defined(HAIKU_TARGET_PLATFORM_BONE) || defined(HAIKU_TARGET_PLATFORM_DANO)
158 #	define IF_NAMESIZE IFNAMSIZ
159 #	define ifc_value ifc_val
160 #	define IFF_AUTO_CONFIGURED 0
161 #endif
162 
163 #include <limits.h>
164 
165 #ifndef INT32_MAX
166 #	define INT32_MAX INT_MAX
167 #endif
168 
169 #ifndef INT64_MAX
170 #	define INT64_MAX LONGLONG_MAX
171 #endif
172 
173 #define	B_MPEG_2_AUDIO_LAYER_1 (enum mpeg_id)0x201
174 #define	B_MPEG_2_AUDIO_LAYER_2 (enum mpeg_id)0x202
175 #define	B_MPEG_2_AUDIO_LAYER_3 (enum mpeg_id)0x203
176 #define	B_MPEG_2_VIDEO (enum mpeg_id)0x211
177 #define	B_MPEG_2_5_AUDIO_LAYER_1 (enum mpeg_id)0x301
178 #define	B_MPEG_2_5_AUDIO_LAYER_2 (enum mpeg_id)0x302
179 #define	B_MPEG_2_5_AUDIO_LAYER_3 (enum mpeg_id)0x303
180 
181 // TODO: experimental API (keep in sync with Accelerant.h)
182 typedef struct {
183 	uint32	version;
184 	char	vendor[128];
185 	char	name[128];
186 	char	serial_number[128];
187 	uint32	product_id;
188 	struct {
189 		uint16	week;
190 		uint16	year;
191 	}		produced;
192 	float	width;
193 	float	height;
194 	uint32	min_horizontal_frequency;	// in kHz
195 	uint32	max_horizontal_frequency;
196 	uint32	min_vertical_frequency;		// in Hz
197 	uint32	max_vertical_frequency;
198 	uint32	max_pixel_clock;			// in kHz
199 } monitor_info;
200 
201 
202 #endif	// HAIKU_BUILD_COMPATIBILITY_H
203 
204