Commit d271dbe0a8b230e566fa3385babdc9cc0ca214ea

Jeremy Huddleston Sequoia 2021-03-20T06:06:28

Add some missing #if conditionals from Apple's code drop (#620) * arm/aarch64: Add FFI_CLOSURES conditionals where appropriate Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com> * aarch64: Don't emit the do_closure label when building without FFI_GO_CLOSURES Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>

diff --git a/src/aarch64/ffi.c b/src/aarch64/ffi.c
index 8e24a96..fccc7f2 100644
--- a/src/aarch64/ffi.c
+++ b/src/aarch64/ffi.c
@@ -770,6 +770,8 @@ ffi_call (ffi_cif *cif, void (*fn) (void), void *rvalue, void **avalue)
   ffi_call_int (cif, fn, rvalue, avalue, NULL);
 }
 
+#if FFI_CLOSURES
+
 #ifdef FFI_GO_CLOSURES
 void
 ffi_call_go (ffi_cif *cif, void (*fn) (void), void *rvalue,
@@ -1054,4 +1056,6 @@ ffi_tramp_arch (size_t *tramp_size, size_t *map_size)
 }
 #endif
 
+#endif /* FFI_CLOSURES */
+
 #endif /* (__aarch64__) || defined(__arm64__)|| defined (_M_ARM64)*/
diff --git a/src/aarch64/sysv.S b/src/aarch64/sysv.S
index a3c1508..bc10da8 100644
--- a/src/aarch64/sysv.S
+++ b/src/aarch64/sysv.S
@@ -213,6 +213,8 @@ CNAME(ffi_call_SYSV):
 	.size CNAME(ffi_call_SYSV), .-CNAME(ffi_call_SYSV)
 #endif
 
+#if FFI_CLOSURES
+
 /* ffi_closure_SYSV
 
    Closure invocation glue. This is the low level code invoked directly by
@@ -271,7 +273,9 @@ CNAME(ffi_closure_SYSV):
 	/* Load ffi_closure_inner arguments.  */
 	ldp	PTR_REG(0), PTR_REG(1), [x17, #FFI_TRAMPOLINE_CLOSURE_OFFSET]	/* load cif, fn */
 	ldr	PTR_REG(2), [x17, #FFI_TRAMPOLINE_CLOSURE_OFFSET+PTR_SIZE*2]	/* load user_data */
+#ifdef FFI_GO_CLOSURES
 .Ldo_closure:
+#endif
 	add	x3, sp, #16				/* load context */
 	add	x4, sp, #ffi_closure_SYSV_FS		/* load stack */
 	add	x5, sp, #16+CALL_CONTEXT_SIZE		/* load rvalue */
@@ -513,6 +517,7 @@ CNAME(ffi_go_closure_SYSV):
 	.size	CNAME(ffi_go_closure_SYSV), . - CNAME(ffi_go_closure_SYSV)
 #endif
 #endif /* FFI_GO_CLOSURES */
+#endif /* FFI_CLOSURES */
 #endif /* __arm64__ */
 
 #if defined __ELF__ && defined __linux__
diff --git a/src/arm/ffi.c b/src/arm/ffi.c
index 5ad59ce..b2f60d1 100644
--- a/src/arm/ffi.c
+++ b/src/arm/ffi.c
@@ -537,6 +537,8 @@ ffi_prep_incoming_args_VFP (ffi_cif *cif, void *rvalue, char *stack,
   return rvalue;
 }
 
+#if FFI_CLOSURES
+
 struct closure_frame
 {
   char vfp_space[8*8] __attribute__((aligned(8)));
@@ -686,6 +688,8 @@ ffi_prep_go_closure (ffi_go_closure *closure, ffi_cif *cif,
 }
 #endif
 
+#endif /* FFI_CLOSURES */
+
 /* Below are routines for VFP hard-float support. */
 
 /* A subroutine of vfp_type_p.  Given a structure type, return the type code
diff --git a/src/arm/sysv.S b/src/arm/sysv.S
index 49c561e..e816e32 100644
--- a/src/arm/sysv.S
+++ b/src/arm/sysv.S
@@ -208,6 +208,7 @@ E(ARM_TYPE_STRUCT)
 	UNWIND(.fnend)
 ARM_FUNC_END(ffi_call_SYSV)
 
+#if FFI_CLOSURES
 
 /*
 	int ffi_closure_inner_* (cif, fun, user_data, frame)
@@ -401,6 +402,8 @@ ARM_FUNC_END(trampoline_code_table)
 	.align	ARM_TRAMP_MAP_SHIFT
 #endif /* FFI_EXEC_STATIC_TRAMP */
 
+#endif /* FFI_CLOSURES */
+
 #if FFI_EXEC_TRAMPOLINE_TABLE
 
 #ifdef __MACH__