Skip to content

Commit 9af9966

Browse files
committed
more fixes - jetjmp and co
1 parent 7f45488 commit 9af9966

6 files changed

Lines changed: 174 additions & 16 deletions

File tree

dll/ntdll/def/ntdll.spec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1800,8 +1800,8 @@
18001800
@ cdecl _ltow(long ptr long)
18011801
@ cdecl _memccpy(ptr ptr long long)
18021802
@ cdecl _memicmp(str str long)
1803-
@ cdecl -arch=x86_64,arm _setjmp(ptr ptr)
1804-
@ cdecl -arch=x86_64,arm _setjmpex(ptr ptr)
1803+
@ cdecl -arch=x86_64,arm,arm64 _setjmp(ptr ptr)
1804+
@ cdecl -arch=x86_64,arm,arm64 _setjmpex(ptr ptr)
18051805
@ varargs _snprintf(ptr long str)
18061806
@ varargs _snwprintf(ptr long wstr)
18071807
@ cdecl _splitpath(str ptr ptr ptr ptr)

ntoskrnl/ntoskrnl.spec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,8 +1570,8 @@
15701570
@ cdecl -arch=i386,arm _local_unwind2()
15711571
@ cdecl -arch=x86_64 _local_unwind()
15721572
@ cdecl _purecall()
1573-
@ cdecl -arch=x86_64,arm _setjmp(ptr ptr)
1574-
@ cdecl -arch=x86_64,arm _setjmpex(ptr ptr)
1573+
@ cdecl -arch=x86_64,arm,arm64 _setjmp(ptr ptr)
1574+
@ cdecl -arch=x86_64,arm,arm64 _setjmpex(ptr ptr)
15751575
@ cdecl _snprintf()
15761576
@ cdecl _snwprintf()
15771577
@ cdecl _stricmp()

sdk/include/vcruntime/intrin.h

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ void _mm_stream_si64x(__int64 *, __int64);
832832
#endif
833833
#endif /* _M_X64 */
834834

835-
#if defined(_M_ARM) || defined(_M_X64)
835+
#if defined(_M_ARM) || defined(_M_X64) || defined(_M_ARM64)
836836

837837
__int64 _InterlockedAnd64(_Interlocked_operand_ __int64 volatile * _Value, __int64 _Mask);
838838
__int64 _InterlockedDecrement64(_Interlocked_operand_ __int64 volatile * _Addend);
@@ -1009,6 +1009,74 @@ int _isunorderedf(float, float);
10091009

10101010
#ifdef _M_ARM64
10111011
unsigned __int64 __getReg(int);
1012+
1013+
/* Thread pointer (x18) accessors */
1014+
unsigned char __readx18byte(unsigned long Offset);
1015+
unsigned short __readx18word(unsigned long Offset);
1016+
unsigned long __readx18dword(unsigned long Offset);
1017+
unsigned __int64 __readx18qword(unsigned long Offset);
1018+
void __writex18byte(unsigned long Offset, unsigned char Value);
1019+
void __writex18word(unsigned long Offset, unsigned short Value);
1020+
void __writex18dword(unsigned long Offset, unsigned long Value);
1021+
void __writex18qword(unsigned long Offset, unsigned __int64 Value);
1022+
void __addx18byte(unsigned long Offset, unsigned char Value);
1023+
void __addx18word(unsigned long Offset, unsigned short Value);
1024+
void __addx18dword(unsigned long Offset, unsigned long Value);
1025+
void __addx18qword(unsigned long Offset, unsigned __int64 Value);
1026+
void __incx18byte(unsigned long Offset);
1027+
void __incx18word(unsigned long Offset);
1028+
void __incx18dword(unsigned long Offset);
1029+
void __incx18qword(unsigned long Offset);
1030+
1031+
/* Status register access */
1032+
__int64 _ReadStatusReg(unsigned int SysReg);
1033+
void _WriteStatusReg(unsigned int SysReg, unsigned __int64 Value);
1034+
1035+
/* Prefetch */
1036+
void __cdecl __prefetch(const void *Address);
1037+
void __prefetch2(const void *Address, int Level);
1038+
1039+
/* Interlocked operations (ARM64 memory-order variants) */
1040+
long _InterlockedAdd(long volatile *Addend, long Value);
1041+
__int64 _InterlockedAdd64(__int64 volatile *Addend, __int64 Value);
1042+
long _InterlockedAdd_acq(long volatile *Addend, long Value);
1043+
long _InterlockedAdd_rel(long volatile *Addend, long Value);
1044+
long _InterlockedAdd_nf (long volatile *Addend, long Value);
1045+
__int64 _InterlockedAdd64_acq(__int64 volatile *Addend, __int64 Value);
1046+
__int64 _InterlockedAdd64_rel(__int64 volatile *Addend, __int64 Value);
1047+
__int64 _InterlockedAdd64_nf (__int64 volatile *Addend, __int64 Value);
1048+
1049+
char _InterlockedAnd8_acq(char volatile *Value, char Mask);
1050+
char _InterlockedAnd8_rel(char volatile *Value, char Mask);
1051+
char _InterlockedAnd8_nf (char volatile *Value, char Mask);
1052+
short _InterlockedAnd16_acq(short volatile *Value, short Mask);
1053+
short _InterlockedAnd16_rel(short volatile *Value, short Mask);
1054+
short _InterlockedAnd16_nf (short volatile *Value, short Mask);
1055+
long _InterlockedAnd_acq(long volatile *Value, long Mask);
1056+
long _InterlockedAnd_rel(long volatile *Value, long Mask);
1057+
long _InterlockedAnd_nf (long volatile *Value, long Mask);
1058+
__int64 _InterlockedAnd64_acq(__int64 volatile *Value, __int64 Mask);
1059+
__int64 _InterlockedAnd64_rel(__int64 volatile *Value, __int64 Mask);
1060+
__int64 _InterlockedAnd64_nf (__int64 volatile *Value, __int64 Mask);
1061+
1062+
char _InterlockedCompareExchange8_acq(char volatile *Destination, char Exchange, char Comparand);
1063+
char _InterlockedCompareExchange8_rel(char volatile *Destination, char Exchange, char Comparand);
1064+
char _InterlockedCompareExchange8_nf (char volatile *Destination, char Exchange, char Comparand);
1065+
short _InterlockedCompareExchange16_acq(short volatile *Destination, short Exchange, short Comparand);
1066+
short _InterlockedCompareExchange16_rel(short volatile *Destination, short Exchange, short Comparand);
1067+
short _InterlockedCompareExchange16_nf (short volatile *Destination, short Exchange, short Comparand);
1068+
long _InterlockedCompareExchange(long volatile *Destination, long Exchange, long Comparand);
1069+
long _InterlockedCompareExchange_acq(long volatile *Destination, long Exchange, long Comparand);
1070+
long _InterlockedCompareExchange_rel(long volatile *Destination, long Exchange, long Comparand);
1071+
long _InterlockedCompareExchange_nf (long volatile *Destination, long Exchange, long Comparand);
1072+
__int64 _InterlockedCompareExchange64_acq(__int64 volatile *Destination, __int64 Exchange, __int64 Comparand);
1073+
__int64 _InterlockedCompareExchange64_rel(__int64 volatile *Destination, __int64 Exchange, __int64 Comparand);
1074+
__int64 _InterlockedCompareExchange64_nf (__int64 volatile *Destination, __int64 Exchange, __int64 Comparand);
1075+
void * _InterlockedCompareExchangePointer(void * volatile *Destination, void *Exchange, void *Comparand);
1076+
void * _InterlockedCompareExchangePointer_acq(void * volatile *Destination, void *Exchange, void *Comparand);
1077+
void * _InterlockedCompareExchangePointer_rel(void * volatile *Destination, void *Exchange, void *Comparand);
1078+
void * _InterlockedCompareExchangePointer_nf (void * volatile *Destination, void *Exchange, void *Comparand);
1079+
unsigned char _InterlockedCompareExchange128(__int64 volatile *Destination, __int64 ExchangeHigh, __int64 ExchangeLow, __int64 *ComparandResult);
10121080
#endif
10131081

10141082
#if defined(_M_CEE_PURE)

sdk/include/vcruntime/msc/intrin.h

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ extern "C" {
3030
#pragma intrinsic(__iso_volatile_store32)
3131
#pragma intrinsic(__iso_volatile_store64)
3232
#pragma intrinsic(__iso_volatile_store8)
33+
#elif defined(_M_ARM64)
34+
#pragma intrinsic(__iso_volatile_load16)
35+
#pragma intrinsic(__iso_volatile_load32)
36+
#pragma intrinsic(__iso_volatile_load64)
37+
#pragma intrinsic(__iso_volatile_load8)
38+
#pragma intrinsic(__iso_volatile_store16)
39+
#pragma intrinsic(__iso_volatile_store32)
40+
#pragma intrinsic(__iso_volatile_store64)
41+
#pragma intrinsic(__iso_volatile_store8)
3342
#endif
3443

3544
/*** Atomic operations ***/
@@ -90,7 +99,47 @@ extern "C" {
9099
#pragma intrinsic(_InterlockedXor_np)
91100
#pragma intrinsic(_InterlockedOr64_np)
92101
#elif defined(_M_ARM)
93-
102+
#elif defined(_M_ARM64)
103+
#pragma intrinsic(_InterlockedAdd)
104+
#pragma intrinsic(_InterlockedAdd64)
105+
#pragma intrinsic(_InterlockedAdd64_acq)
106+
#pragma intrinsic(_InterlockedAdd64_nf)
107+
#pragma intrinsic(_InterlockedAdd64_rel)
108+
#pragma intrinsic(_InterlockedAdd_acq)
109+
#pragma intrinsic(_InterlockedAdd_nf)
110+
#pragma intrinsic(_InterlockedAdd_rel)
111+
#pragma intrinsic(_InterlockedAnd16_acq)
112+
#pragma intrinsic(_InterlockedAnd16_nf)
113+
#pragma intrinsic(_InterlockedAnd16_rel)
114+
#pragma intrinsic(_InterlockedAnd64)
115+
#pragma intrinsic(_InterlockedAnd64_acq)
116+
#pragma intrinsic(_InterlockedAnd64_nf)
117+
#pragma intrinsic(_InterlockedAnd64_rel)
118+
#pragma intrinsic(_InterlockedAnd8_acq)
119+
#pragma intrinsic(_InterlockedAnd8_nf)
120+
#pragma intrinsic(_InterlockedAnd8_rel)
121+
#pragma intrinsic(_InterlockedAnd_acq)
122+
#pragma intrinsic(_InterlockedAnd_nf)
123+
#pragma intrinsic(_InterlockedAnd_rel)
124+
#pragma intrinsic(_InterlockedCompareExchange_acq)
125+
#pragma intrinsic(_InterlockedCompareExchange_nf)
126+
#pragma intrinsic(_InterlockedCompareExchange_rel)
127+
#pragma intrinsic(_InterlockedCompareExchange16_acq)
128+
#pragma intrinsic(_InterlockedCompareExchange16_nf)
129+
#pragma intrinsic(_InterlockedCompareExchange16_rel)
130+
#pragma intrinsic(_InterlockedCompareExchange64_acq)
131+
#pragma intrinsic(_InterlockedCompareExchange64_nf)
132+
#pragma intrinsic(_InterlockedCompareExchange64_rel)
133+
#pragma intrinsic(_InterlockedCompareExchange8_acq)
134+
#pragma intrinsic(_InterlockedCompareExchange8_nf)
135+
#pragma intrinsic(_InterlockedCompareExchange8_rel)
136+
#pragma intrinsic(_InterlockedCompareExchangePointer)
137+
#pragma intrinsic(_InterlockedCompareExchangePointer_acq)
138+
#pragma intrinsic(_InterlockedCompareExchangePointer_nf)
139+
#pragma intrinsic(_InterlockedCompareExchangePointer_rel)
140+
#pragma intrinsic(_InterlockedCompareExchange128)
141+
#pragma intrinsic(_InterlockedDecrement64)
142+
#pragma intrinsic(_InterlockedExchange64)
94143
#endif
95144

96145
#if defined(_M_AMD64) || defined(_M_ARM)

sdk/lib/vcruntime/arm64/_setjmp.s

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,65 @@
11
/*
22
* PROJECT: ReactOS vcruntime library
33
* LICENSE: MIT (https://spdx.org/licenses/MIT)
4-
* PURPOSE: Implementation of _setjmp for ARM64
4+
* PURPOSE: Implementation of _setjmp/_setjmpex for ARM64
55
* COPYRIGHT: Copyright Timo Kreuzer <timo.kreuzer@reactos.org>
6+
* ARM64 port and wiring by contributors
67
*/
78

8-
//#include <kxarm64.h>
9+
#include <kxarm64.h>
910

1011
TEXTAREA
1112

13+
// Export all common entry points to the same implementation
1214
LEAF_ENTRY _setjmpex
15+
_setjmp:
16+
__intrinsic_setjmp:
17+
__intrinsic_setjmpex:
1318

14-
brk #0xf000
19+
// x0: _JUMP_BUFFER* _Env
20+
// x1: void* _Frame (context)
1521

16-
LEAF_END _setjmpex
22+
// Save Frame and zero Reserved
23+
str x1, [x0, #0x00] // Frame
24+
mov x2, xzr
25+
str x2, [x0, #0x08] // Reserved = 0
26+
27+
// Save callee-saved integer registers x19-x28
28+
stp x19, x20, [x0, #0x10]
29+
stp x21, x22, [x0, #0x20]
30+
stp x23, x24, [x0, #0x30]
31+
stp x25, x26, [x0, #0x40]
32+
stp x27, x28, [x0, #0x50]
33+
34+
// Save FP (x29) and LR (x30)
35+
stp x29, x30, [x0, #0x60]
36+
37+
// Save SP
38+
mov x2, sp
39+
str x2, [x0, #0x70]
1740

18-
IMPORT __intrinsic_setjmpex, WEAK _setjmpex
19-
IMPORT _setjmp, WEAK _setjmpex
20-
IMPORT setjmp, WEAK _setjmpex
41+
// Save FPCR/FPSR (32-bit each)
42+
mrs x2, FPCR
43+
mrs x3, FPSR
44+
str w2, [x0, #0x78]
45+
str w3, [x0, #0x7C]
46+
47+
// Save floating point callee-saved d8-d15
48+
str d8, [x0, #0x80]
49+
str d9, [x0, #0x88]
50+
str d10, [x0, #0x90]
51+
str d11, [x0, #0x98]
52+
str d12, [x0, #0xA0]
53+
str d13, [x0, #0xA8]
54+
str d14, [x0, #0xB0]
55+
str d15, [x0, #0xB8]
56+
57+
// Return 0 from setjmp
58+
mov w0, #0
59+
ret
60+
61+
LEAF_END _setjmpex
2162

2263
END
2364

24-
/* EOF */
65+
/* EOF */

win32ss/win32k.spec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,8 @@
239239
@ cdecl _itow() NTOSKRNL._itow
240240
@ cdecl -arch=i386 _local_unwind2() NTOSKRNL._local_unwind2
241241
@ cdecl -arch=x86_64 _local_unwind() NTOSKRNL._local_unwind
242-
@ cdecl -arch=x86_64,arm _setjmp(ptr ptr) NTOSKRNL._setjmp
243-
@ cdecl -arch=x86_64,arm _setjmpex(ptr ptr) NTOSKRNL._setjmpex
242+
@ cdecl -arch=x86_64,arm,arm64 _setjmp(ptr ptr) NTOSKRNL._setjmp
243+
@ cdecl -arch=x86_64,arm,arm64 _setjmpex(ptr ptr) NTOSKRNL._setjmpex
244244
@ cdecl -arch=x86_64,arm longjmp(ptr long) NTOSKRNL.longjmp
245245
@ cdecl -arch=x86_64,arm memcmp() NTOSKRNL.memcmp
246246
@ cdecl -arch=x86_64,arm memcpy() NTOSKRNL.memcpy

0 commit comments

Comments
 (0)