ReactOS 0.4.16-dev-1946-g52006dd
longjmp.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS vcruntime library
3 * LICENSE: MIT (https://spdx.org/licenses/MIT)
4 * PURPOSE: Implementation of longjmp for ARM64
5 * COPYRIGHT: Copyright 2025 Timo Kreuzer <timo.kreuzer@reactos.org>
6 */
7
8#include <setjmp.h>
9#define RtlUnwind RtlUnwind_imported
10#include <windef.h>
11
12#undef RtlUnwind
13VOID
16 _In_opt_ PVOID TargetFrame,
17 _In_opt_ PVOID TargetIp,
18 _In_opt_ PEXCEPTION_RECORD ExceptionRecord,
20 );
21
22__declspec(noreturn)
23void __longjmp_noframe(const _JUMP_BUFFER* _Buf, int _Value);
24
25__declspec(noreturn)
26void __cdecl longjmp(
27 _In_reads_(_JBLEN) jmp_buf _Buf,
28 _In_ int _Value)
29{
30 const _JUMP_BUFFER* jumpBuffer = (_JUMP_BUFFER*)_Buf;
31
32 /* Ensure _Value is non-zero */
33 _Value = (_Value == 0) ? 1 : _Value;
34
35 EXCEPTION_RECORD exceptionRecord = { 0 };
36 exceptionRecord.ExceptionCode = STATUS_LONGJUMP;
37 exceptionRecord.NumberParameters = 1;
38 exceptionRecord.ExceptionInformation[0] = (ULONG_PTR)jumpBuffer;
39
40 RtlUnwind((PVOID)jumpBuffer->Frame,
41 (PVOID)jumpBuffer->Lr,
42 &exceptionRecord,
44}
#define __cdecl
Definition: accygwin.h:79
UINT32 void void ** ReturnValue
Definition: acevents.h:216
#define RtlUnwind
Definition: longjmp.c:9
_In_ _Value
#define ULONG_PTR
Definition: config.h:101
void __declspec(noinline) __cdecl _free_base(void *const block)
Definition: free_base.cpp:98
#define _In_reads_(s)
Definition: no_sal2.h:168
#define _In_
Definition: no_sal2.h:158
#define _In_opt_
Definition: no_sal2.h:212
#define STATUS_LONGJUMP
Definition: ntstatus.h:297
DWORD ExceptionCode
Definition: compat.h:208
DWORD NumberParameters
Definition: compat.h:212
ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]
Definition: compat.h:213
#define NTAPI
Definition: typedefs.h:36
uint32_t ULONG_PTR
Definition: typedefs.h:65
_JBTYPE jmp_buf[_JBLEN]
Definition: setjmp.h:188