Skip to content

Commit ffcef3d

Browse files
Haiku: Add Haiku support for CoreCLR/PAL (#93907)
* Haiku: Add Haiku support for CoreCLR/PAL This contains a part of the code required to build CoreCLR and get `paltests` to pass on Haiku. This commit covers `src/coreclr/pal/**`. Co-authored-by: Jessica Hamilton <jessica.l.hamilton@gmail.com> * ilasm: Haiku build fixes Some OSes like Haiku define the `_EXPORT` and `_IMPORT` marcos. Symbols beginning with an underscore followed immediately by an uppercase letter are reserved anyway. Add the guards to get them out of the way. * pal: Remove usage of MAP_FILE This flag is a compatibility flag and not required on most OSes. Some, including Haiku, does not even define it. --------- Co-authored-by: Jessica Hamilton <jessica.l.hamilton@gmail.com>
1 parent 2d07d3d commit ffcef3d

File tree

25 files changed

+152
-35
lines changed

25 files changed

+152
-35
lines changed

src/coreclr/ilasm/ilasmpch.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,12 @@
2525
#include "mdfileformat.h"
2626
#include "stgpooli.h"
2727

28+
#ifdef _EXPORT
29+
#undef _EXPORT
30+
#endif
31+
32+
#ifdef _IMPORT
33+
#undef _IMPORT
34+
#endif
35+
2836
#endif

src/coreclr/pal/inc/pal.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2644,6 +2644,8 @@ PALIMPORT BOOL PALAPI PAL_GetUnwindInfoSize(SIZE_T baseAddress, ULONG64 ehFrameH
26442644
#define PAL_CS_NATIVE_DATA_SIZE 96
26452645
#elif defined(__linux__) && defined(__riscv) && __riscv_xlen == 64
26462646
#define PAL_CS_NATIVE_DATA_SIZE 96
2647+
#elif defined(__HAIKU__) && defined(__x86_64__)
2648+
#define PAL_CS_NATIVE_DATA_SIZE 56
26472649
#else
26482650
#error PAL_CS_NATIVE_DATA_SIZE is not defined for this architecture
26492651
#endif
@@ -3952,7 +3954,9 @@ unsigned int __cdecl _rotr(unsigned int value, int shift)
39523954
PALIMPORT DLLEXPORT char * __cdecl PAL_getenv(const char *);
39533955
PALIMPORT DLLEXPORT int __cdecl _putenv(const char *);
39543956

3957+
#ifndef ERANGE
39553958
#define ERANGE 34
3959+
#endif
39563960

39573961
/****************PAL Perf functions for PInvoke*********************/
39583962
#if PAL_PERF

src/coreclr/pal/inc/rt/safecrt.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,6 @@ typedef int errno_t; /* standard */
112112
/* error codes */
113113
#if !defined(_SECURECRT_ERRCODE_VALUES_DEFINED)
114114
#define _SECURECRT_ERRCODE_VALUES_DEFINED
115-
#if !defined(EINVAL)
116-
#define EINVAL 22
117-
#endif
118-
#if !defined(ERANGE)
119-
#define ERANGE 34
120-
#endif
121-
#if !defined(EILSEQ)
122-
#define EILSEQ 42
123-
#endif
124115
#if !defined(STRUNCATE)
125116
#define STRUNCATE 80
126117
#endif

src/coreclr/pal/src/arch/amd64/signalhandlerhelper.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ SET_DEFAULT_DEBUG_CHANNEL(EXCEPT); // some headers have code with asserts, so do
88
#include "pal/context.h"
99
#include "pal/signal.hpp"
1010
#include "pal/utils.h"
11+
12+
#if HAVE_SYS_UCONTEXT_H
1113
#include <sys/ucontext.h>
14+
#endif
1215

1316
/*++
1417
Function :

src/coreclr/pal/src/config.h.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#cmakedefine01 HAVE_PTHREAD_NP_H
2222
#cmakedefine01 HAVE_AUXV_HWCAP_H
2323
#cmakedefine01 HAVE_SYS_PTRACE_H
24+
#cmakedefine01 HAVE_SYS_UCONTEXT_H
25+
#cmakedefine01 HAVE_SYS_MOUNT_H
2426
#cmakedefine01 HAVE_UCONTEXT_H
2527
#cmakedefine01 HAVE_GETAUXVAL
2628

src/coreclr/pal/src/configure.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ check_include_files(semaphore.h HAVE_SEMAPHORE_H)
4747
check_include_files(sys/prctl.h HAVE_PRCTL_H)
4848
check_include_files("sys/auxv.h;asm/hwcap.h" HAVE_AUXV_HWCAP_H)
4949
check_include_files("sys/ptrace.h" HAVE_SYS_PTRACE_H)
50+
check_include_files("sys/ucontext.h" HAVE_SYS_UCONTEXT_H)
51+
check_include_files("sys/mount.h" HAVE_SYS_MOUNT_H)
5052
check_include_files(ucontext.h HAVE_UCONTEXT_H)
5153
check_symbol_exists(getauxval sys/auxv.h HAVE_GETAUXVAL)
5254

src/coreclr/pal/src/debug/debug.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ SET_DEFAULT_DEBUG_CHANNEL(DEBUG); // some headers have code with asserts, so do
4545
#include <unistd.h>
4646
#elif defined(HAVE_TTRACE) // HAVE_PROCFS_CTL
4747
#include <sys/ttrace.h>
48-
#else // defined(HAVE_TTRACE)
48+
#elif HAVE_SYS_PTRACE_H
4949
#include <sys/ptrace.h>
5050
#endif // HAVE_PROCFS_CTL
5151
#if HAVE_VM_READ
@@ -635,7 +635,7 @@ PAL_CloseProcessMemory(
635635
PAL_ReadProcessMemory
636636
637637
Abstract
638-
Reads process memory.
638+
Reads process memory.
639639
640640
Parameter
641641
handle : from PAL_OpenProcessMemory
@@ -753,7 +753,7 @@ PAL_ProbeMemory(
753753

754754
flags = fcntl(fds[0], F_GETFL, 0);
755755
fcntl(fds[0], F_SETFL, flags | O_NONBLOCK);
756-
756+
757757
flags = fcntl(fds[1], F_GETFL, 0);
758758
fcntl(fds[1], F_SETFL, flags | O_NONBLOCK);
759759

src/coreclr/pal/src/exception/seh.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ PAL_ERROR SEHEnable(CPalThread *pthrCurrent)
305305
{
306306
#if HAVE_MACH_EXCEPTIONS
307307
return pthrCurrent->EnableMachExceptions();
308-
#elif defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__sun)
308+
#elif defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__sun) || defined(__HAIKU__)
309309
return NO_ERROR;
310310
#else// HAVE_MACH_EXCEPTIONS
311311
#error not yet implemented
@@ -330,7 +330,7 @@ PAL_ERROR SEHDisable(CPalThread *pthrCurrent)
330330
{
331331
#if HAVE_MACH_EXCEPTIONS
332332
return pthrCurrent->DisableMachExceptions();
333-
#elif defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__sun)
333+
#elif defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__sun) || defined(__HAIKU__)
334334
return NO_ERROR;
335335
#else // HAVE_MACH_EXCEPTIONS
336336
#error not yet implemented

src/coreclr/pal/src/exception/signal.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,13 @@ SET_DEFAULT_DEBUG_CHANNEL(EXCEPT); // some headers have code with asserts, so do
4444
#include "pal/utils.h"
4545

4646
#include <string.h>
47-
#include <sys/ucontext.h>
4847
#include <sys/utsname.h>
4948
#include <unistd.h>
5049
#include <sys/mman.h>
5150

51+
#if HAVE_SYS_UCONTEXT_H
52+
#include <sys/ucontext.h>
53+
#endif // HAVE_SYS_UCONTEXT_H
5254

5355
#endif // !HAVE_MACH_EXCEPTIONS
5456
#include "pal/context.h"

src/coreclr/pal/src/file/file.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,14 @@ SET_DEFAULT_DEBUG_CHANNEL(FILE); // some headers have code with asserts, so do t
3232
#include <sys/types.h>
3333
#include <sys/stat.h>
3434
#include <sys/param.h>
35-
#include <sys/mount.h>
3635
#include <errno.h>
3736
#include <limits.h>
3837
#include <fcntl.h>
3938

39+
#if HAVE_SYS_MOUNT_H
40+
#include <sys/mount.h>
41+
#endif
42+
4043
using namespace CorUnix;
4144

4245
int MaxWCharToAcpLengthFactor = 3;

0 commit comments

Comments
 (0)