Partially Restore Darling-Specific Changes

Since we don't build the kernel module anymore, I want to take the opportunity to only include changes that are needed for Darling to function (build and sucessfully bring up `bash`).
This commit is contained in:
Thomas A 2023-05-19 09:48:55 -07:00
parent e5177fae0a
commit c128ce938e
3 changed files with 37 additions and 2 deletions

View File

@ -31,7 +31,7 @@
/* If we're hosted, fall back to the system's stdatomic.h. FreeBSD, for
* example, already has a Clang-compatible stdatomic.h header.
*/
#if __STDC_HOSTED__ && __has_include_next(<stdatomic.h>)
#if !defined(DARLING) && __STDC_HOSTED__ && __has_include_next(<stdatomic.h>)
# include_next <stdatomic.h>
#else

View File

@ -42,7 +42,9 @@ typedef void *xpc_object_t;
__BEGIN_DECLS
#ifndef DARLING
extern void *__dso_handle;
#endif
OS_ALWAYS_INLINE
static inline void

View File

@ -74,20 +74,39 @@
/*
* Syscall entry macros for use in libc:
*/
#ifndef DARLING
#define UNIX_SYSCALL_TRAP \
int $(UNIX_INT)
#define MACHDEP_SYSCALL_TRAP \
int $(MACHDEP_INT)
#else // DARLING
#define UNIX_SYSCALL_TRAP \
call __darling_bsd_syscall
#define MACHDEP_SYSCALL_TRAP \
call __darling_machdep_syscall
#endif
/*
* Macro to generate Mach call stubs in libc:
*/
#ifndef DARLING
#define kernel_trap(trap_name,trap_number,number_args) \
LEAF(_##trap_name,0) ;\
movl $##trap_number, %eax ;\
call __sysenter_trap ;\
END(_##trap_name)
#else // DARLING
#define kernel_trap(trap_name,trap_number,number_args) \
LEAF(_##trap_name,0) ;\
movl $##trap_number, %eax ;\
call __darling_mach_syscall ;\
END(_##trap_name)
#endif
#endif /* !KERNEL */
@ -97,10 +116,17 @@ END(_##trap_name)
#ifndef KERNEL
#ifndef DARLING
#define UNIX_SYSCALL_TRAP \
syscall
#define MACHDEP_SYSCALL_TRAP \
syscall
#else // DARLING
#define UNIX_SYSCALL_TRAP \
call __darling_bsd_syscall
#define MACHDEP_SYSCALL_TRAP \
call __darling_machdep_syscall
#endif
/*
* Macro to generate Mach call stubs in Libc.
@ -109,13 +135,20 @@ END(_##trap_name)
* macro above, we negate those numbers here for the 64-bit
* code path.
*/
#ifndef DARLING
#define kernel_trap(trap_name,trap_number,number_args) \
LEAF(_##trap_name,0) ;\
movq %rcx, %r10 ;\
movl $ SYSCALL_CONSTRUCT_MACH(-##trap_number), %eax ;\
syscall ;\
END(_##trap_name)
#else // DARLING
#define kernel_trap(trap_name,trap_number,number_args) \
LEAF(_##trap_name,0) ;\
movl $##trap_number, %eax ;\
call __darling_mach_syscall;\
END(_##trap_name)
#endif
#endif /* !KERNEL */
#endif /* defined(__x86_64__) */