Skip to content

Commit f12d9db

Browse files
Merge pull request ladislav-zezula#157 from extrowerk/haiku_support
SormLib: Haiku support
2 parents f2c8d24 + 93b5a8b commit f12d9db

File tree

2 files changed

+86
-56
lines changed

2 files changed

+86
-56
lines changed

src/StormPort.h

+31-6
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
#if (__ppc__ == 1) || (__POWERPC__ == 1) || (_ARCH_PPC == 1)
8282
#include <stdint.h>
8383
#include <CoreFoundation/CFByteOrder.h>
84-
#endif
84+
#endif
8585

8686
#define PKEXPORT
8787
#define __SYS_ZLIB
@@ -96,6 +96,31 @@
9696

9797
#endif
9898

99+
#if !defined(PLATFORM_DEFINED) && defined(__HAIKU__)
100+
101+
#include <sys/types.h>
102+
#include <sys/stat.h>
103+
#include <sys/mman.h>
104+
#include <fcntl.h>
105+
#include <unistd.h>
106+
#include <stdint.h>
107+
#include <stdlib.h>
108+
#include <stdio.h>
109+
#include <stdarg.h>
110+
#include <string.h>
111+
#include <ctype.h>
112+
#include <assert.h>
113+
#include <errno.h>
114+
115+
#ifndef __BIG_ENDIAN__
116+
#define PLATFORM_LITTLE_ENDIAN
117+
#endif
118+
119+
#define PLATFORM_HAIKU
120+
#define PLATFORM_DEFINED // The platform is known now
121+
122+
#endif
123+
99124
//-----------------------------------------------------------------------------
100125
// Assumption: we are not on Windows nor Macintosh, so this must be linux *grin*
101126

@@ -165,8 +190,8 @@
165190
#ifndef _countof
166191
#define _countof(x) (sizeof(x) / sizeof(x[0]))
167192
#endif
168-
169-
#define WINAPI
193+
194+
#define WINAPI
170195

171196
#define FILE_BEGIN SEEK_SET
172197
#define FILE_CURRENT SEEK_CUR
@@ -193,17 +218,17 @@
193218
#endif // !PLATFORM_WINDOWS
194219

195220
// 64-bit calls are supplied by "normal" calls on Mac
196-
#if defined(PLATFORM_MAC)
221+
#if defined(PLATFORM_MAC) || defined(PLATFORM_HAIKU)
197222
#define stat64 stat
198223
#define fstat64 fstat
199224
#define lseek64 lseek
200225
#define ftruncate64 ftruncate
201226
#define off64_t off_t
202227
#define O_LARGEFILE 0
203228
#endif
204-
229+
205230
// Platform-specific error codes for UNIX-based platforms
206-
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX)
231+
#if defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) || defined(PLATFORM_HAIKU)
207232
#define ERROR_SUCCESS 0
208233
#define ERROR_FILE_NOT_FOUND ENOENT
209234
#define ERROR_ACCESS_DENIED EPERM

0 commit comments

Comments
 (0)