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