Skip to content

Commit 0ad6b3c

Browse files
committed
feat: darwin/arm64 test pass
1 parent a8b4c74 commit 0ad6b3c

26 files changed

+4056
-143
lines changed

cmake/darwin-arm64-toolchain.cmake

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
set(CMAKE_C_COMPILER cc)
2+
set(CMAKE_CXX_COMPILER c++)
3+
4+
set(CMAKE_C_STANDARD 11)
5+
6+
set(CMAKE_SYSTEM_NAME darwin)
7+
set(CMAKE_SYSTEM_PROCESSOR arm64)
8+
9+
10+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-format -Wno-return-type")

include/uv/darwin.h

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
2+
*
3+
* Permission is hereby granted, free of charge, to any person obtaining a copy
4+
* of this software and associated documentation files (the "Software"), to
5+
* deal in the Software without restriction, including without limitation the
6+
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7+
* sell copies of the Software, and to permit persons to whom the Software is
8+
* furnished to do so, subject to the following conditions:
9+
*
10+
* The above copyright notice and this permission notice shall be included in
11+
* all copies or substantial portions of the Software.
12+
*
13+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19+
* IN THE SOFTWARE.
20+
*/
21+
22+
#ifndef UV_DARWIN_H
23+
#define UV_DARWIN_H
24+
25+
#if defined(__APPLE__) && defined(__MACH__)
26+
# include <mach/mach.h>
27+
# include <mach/task.h>
28+
# include <mach/semaphore.h>
29+
# include <TargetConditionals.h>
30+
# define UV_PLATFORM_SEM_T semaphore_t
31+
#endif
32+
33+
#define UV_IO_PRIVATE_PLATFORM_FIELDS \
34+
int rcount; \
35+
int wcount; \
36+
37+
#define UV_PLATFORM_LOOP_FIELDS \
38+
uv_thread_t cf_thread; \
39+
void* _cf_reserved; \
40+
void* cf_state; \
41+
uv_mutex_t cf_mutex; \
42+
uv_sem_t cf_sem; \
43+
struct uv__queue cf_signals; \
44+
45+
#define UV_PLATFORM_FS_EVENT_FIELDS \
46+
uv__io_t event_watcher; \
47+
char* realpath; \
48+
int realpath_len; \
49+
int cf_flags; \
50+
uv_async_t* cf_cb; \
51+
struct uv__queue cf_events; \
52+
struct uv__queue cf_member; \
53+
int cf_error; \
54+
uv_mutex_t cf_mutex; \
55+
56+
#define UV_STREAM_PRIVATE_PLATFORM_FIELDS \
57+
void* select; \
58+
59+
#define UV_HAVE_KQUEUE 1
60+
61+
#endif /* UV_DARWIN_H */

lib/darwin_arm64/libSystem.tbd

+3,709
Large diffs are not rendered by default.

lib/darwin_arm64/libuv.a

1.06 MB
Binary file not shown.

runtime/aco/acosw.S

+26-20
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
.text
44
.globl acosw
5-
#if defined(__APPLE__)
5+
#if defined(__DARWIN)
66
#else
77
.type acosw, @function
88
#endif
9-
#ifndef __aarch64__
9+
#ifndef __ARM64
1010
.intel_syntax noprefix
1111
#endif
1212
acosw:
13-
#ifdef __x86_64__
13+
#ifdef __AMD64
1414
/*
1515
0x00 --> 0xff
1616
r12 r13 r14 r15 rip rsp rbx rbp fpucw16 mxcsr32
@@ -46,7 +46,7 @@ acosw:
4646
mov rsp,rcx
4747
jmp rax
4848

49-
#elif defined(__aarch64__)
49+
#elif defined(__ARM64)
5050
/*
5151
0x00 --> 0xff
5252
x16 x17 x19 ... x29 lr sp fpcr
@@ -96,12 +96,12 @@ acosw:
9696
#endif
9797

9898
.globl async_preempt
99-
#if defined(__APPLE__)
99+
#if defined(__DARWIN)
100100
#else
101101
.type async_preempt, @function
102102
#endif
103103
async_preempt:
104-
#ifdef __x86_64__
104+
#ifdef __AMD64
105105
push rbp
106106
mov rbp, rsp
107107
pushfq
@@ -186,7 +186,7 @@ async_preempt:
186186
add rsp, 1032
187187
jmp [rsp - 1032]
188188

189-
#elif defined(__aarch64__)
189+
#elif defined(__ARM64)
190190
// 保存所有通用寄存器
191191
stp x29, x30, [sp, #-16]!
192192
mov x29, sp
@@ -279,18 +279,18 @@ async_preempt:
279279

280280

281281
.globl aco_save_reg
282-
#if defined(__APPLE__)
282+
#if defined(__DARWIN)
283283
#else
284284
.type aco_save_reg, @function
285285
#endif
286286

287-
#ifndef __aarch64__
287+
#ifndef __ARM64
288288
.intel_syntax noprefix
289289
#endif
290290

291291
aco_save_reg:
292292

293-
#ifdef __x86_64__
293+
#ifdef __AMD64
294294
mov rdx,QWORD PTR [rsp] // retaddr
295295
lea rcx,[rsp+0x8] // rsp
296296
mov QWORD PTR [rdi+0x0], r12
@@ -307,7 +307,7 @@ aco_save_reg:
307307
#endif
308308
ret
309309

310-
#elif defined(__aarch64__)
310+
#elif defined(__ARM64)
311311
// x0 包含目标地址
312312
stp x19, x20, [x0, #0]
313313
stp x21, x22, [x0, #16]
@@ -324,28 +324,28 @@ aco_save_reg:
324324
#endif
325325

326326
.globl aco_save_fpucw_mxcsr
327-
#if defined(__APPLE__)
327+
#if defined(__DARWIN)
328328
#else
329329
.type aco_save_fpucw_mxcsr, @function
330330
#endif
331-
#ifndef __aarch64__
331+
#ifndef __ARM64
332332
.intel_syntax noprefix
333333
#endif
334334

335335
aco_save_fpucw_mxcsr:
336-
#ifdef __x86_64__
336+
#ifdef __AMD64
337337
fnstcw WORD PTR [rdi]
338338
stmxcsr DWORD PTR [rdi+0x4]
339339
ret
340-
#elif __aarch64__
340+
#elif __ARM64
341341
mrs x1, fpcr
342342
str x1, [x0]
343343
ret
344344
#else
345345
#error "platform not support"
346346
#endif
347347

348-
#if defined(__APPLE__)
348+
#if defined(__DARWIN)
349349
.globl _abort
350350
.globl _aco_funcp_protector
351351
#else
@@ -354,27 +354,33 @@ aco_save_fpucw_mxcsr:
354354
#endif
355355

356356
.globl aco_funcp_protector_asm
357-
#if defined(__APPLE__)
357+
#if defined(__DARWIN)
358358
#else
359359
.type aco_funcp_protector_asm, @function
360360
#endif
361361

362-
#ifndef __aarch64__
362+
#ifndef __ARM64
363363
.intel_syntax noprefix
364364
#endif
365365

366366
aco_funcp_protector_asm:
367-
#ifdef __x86_64__
367+
#if defined(__AMD64)
368368
and rsp,0xfffffffffffffff0
369369
call SYM(aco_funcp_protector)
370370
call SYM(abort)
371371
ret
372-
#elif defined(__aarch64__)
372+
#elif defined(__ARM64)
373373
mov x9, sp
374374
and x9, x9, #0xfffffffffffffff0
375375
mov sp, x9
376+
#if defined(__DARWIN)
377+
bl _aco_funcp_protector
378+
bl _abort
379+
#else
376380
bl aco_funcp_protector
377381
bl abort
382+
#endif
383+
378384
ret
379385
#else
380386
#error "platform not support"

0 commit comments

Comments
 (0)