Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit 59546fb

Browse files
committed
core.sys.posix.ucontext: Add complete definition of mcontext_t for Darwin x86 and PPC
1 parent 3f0cc9c commit 59546fb

File tree

1 file changed

+59
-7
lines changed

1 file changed

+59
-7
lines changed

src/core/sys/posix/ucontext.d

Lines changed: 59 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ else version (TVOS)
3333
else version (WatchOS)
3434
version = Darwin;
3535

36+
version (ARM) version = ARM_Any;
37+
version (AArch64) version = ARM_Any;
3638
version (MIPS32) version = MIPS_Any;
3739
version (MIPS64) version = MIPS_Any;
3840
version (PPC) version = PPC_Any;
@@ -921,16 +923,66 @@ else version (CRuntime_Musl)
921923
}
922924
else version (Darwin)
923925
{
924-
alias mcontext_t = void;
926+
private
927+
{
928+
version (X86_64)
929+
{
930+
struct __darwin_mcontext
931+
{
932+
ulong[89] __opaque;
933+
}
934+
static assert(__darwin_mcontext.sizeof == 712);
935+
}
936+
else version (X86)
937+
{
938+
struct __darwin_mcontext
939+
{
940+
uint[150] __opaque;
941+
}
942+
static assert(__darwin_mcontext.sizeof == 600);
943+
}
944+
else version (AArch64)
945+
{
946+
struct __darwin_mcontext
947+
{
948+
align(16) ulong[102] __opaque;
949+
}
950+
static assert(__darwin_mcontext.sizeof == 816);
951+
}
952+
else version (ARM)
953+
{
954+
struct __darwin_mcontext
955+
{
956+
uint[85] __opaque;
957+
}
958+
static assert(__darwin_mcontext.sizeof == 340);
959+
}
960+
else version (PPC_Any)
961+
{
962+
struct __darwin_mcontext
963+
{
964+
version (PPC64)
965+
ulong[129] __opaque;
966+
else
967+
uint[258] __opaque;
968+
}
969+
static assert(__darwin_mcontext.sizeof == 1032);
970+
}
971+
else
972+
static assert(false, "mcontext_t unimplemented for this platform.");
973+
}
974+
975+
alias mcontext_t = __darwin_mcontext*;
925976

926977
struct ucontext
927978
{
928-
int uc_onstack;
929-
sigset_t uc_sigmask;
930-
stack_t uc_stack;
931-
ucontext* uc_link;
932-
size_t uc_mcsize;
933-
mcontext_t* uc_mcontext;
979+
int uc_onstack;
980+
sigset_t uc_sigmask;
981+
stack_t uc_stack;
982+
ucontext* uc_link;
983+
size_t uc_mcsize;
984+
__darwin_mcontext* uc_mcontext;
985+
__darwin_mcontext __mcontext_data;
934986
}
935987

936988
alias ucontext_t = ucontext;

0 commit comments

Comments
 (0)