Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mono] Look for Native Signal SIMD Context #89467

Merged
merged 3 commits into from
Jul 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions src/mono/mono/utils/mono-context.c
Original file line number Diff line number Diff line change
Expand Up @@ -534,11 +534,32 @@ mono_sigctx_to_monoctx (void *sigctx, MonoContext *mctx)
#endif
#ifdef __linux__
struct fpsimd_context *fpctx = (struct fpsimd_context*)&((ucontext_t*)sigctx)->uc_mcontext.__reserved;
int i;

g_assert (fpctx->head.magic == FPSIMD_MAGIC);
for (i = 0; i < 32; ++i)
mctx->fregs [i] = fpctx->vregs [i];
size_t size = 0;
do {
struct fpsimd_context *fpctx_temp = (struct fpsimd_context*)&(((ucontext_t*)sigctx)->uc_mcontext.__reserved[size]);

if (fpctx_temp->head.magic == FPSIMD_MAGIC)
{
g_assert (fpctx_temp->head.size >= sizeof (struct fpsimd_context));
g_assert (size + fpctx_temp->head.size <= sizeof (((ucontext_t*)sigctx)->uc_mcontext.__reserved));

fpctx = fpctx_temp;
break;
}

if (fpctx_temp->head.size == 0)
break;

size += fpctx_temp->head.size;
} while (size + sizeof (struct fpsimd_context) <= sizeof (((ucontext_t*)sigctx)->uc_mcontext.__reserved));

if (fpctx->head.magic == FPSIMD_MAGIC)
for (int i = 0; i < 32; ++i)
mctx->fregs [i] = fpctx->vregs [i];
else
for (int i = 0; i < 32; ++i)
mctx->fregs [i] = 0;
#endif
/* FIXME: apple */
#endif
Expand Down
Loading