aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/cgo/gcc_darwin_arm64.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime/cgo/gcc_darwin_arm64.c')
-rw-r--r--src/runtime/cgo/gcc_darwin_arm64.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/runtime/cgo/gcc_darwin_arm64.c b/src/runtime/cgo/gcc_darwin_arm64.c
index fd7d4084c9..dbe848b4ee 100644
--- a/src/runtime/cgo/gcc_darwin_arm64.c
+++ b/src/runtime/cgo/gcc_darwin_arm64.c
@@ -10,12 +10,16 @@
#include <unistd.h>
#include <stdlib.h>
-#include <CoreFoundation/CFBundle.h>
-#include <CoreFoundation/CFString.h>
-
#include "libcgo.h"
#include "libcgo_unix.h"
+#include <TargetConditionals.h>
+
+#if TARGET_OS_IPHONE
+#include <CoreFoundation/CFBundle.h>
+#include <CoreFoundation/CFString.h>
+#endif
+
#define magic (0xc476c475c47957UL)
// inittls allocates a thread-local storage slot for g.
@@ -87,14 +91,18 @@ threadentry(void *v)
ts = *(ThreadStart*)v;
free(v);
+#if TARGET_OS_IPHONE
darwin_arm_init_thread_exception_port();
+#endif
crosscall1(ts.fn, setg_gcc, (void*)ts.g);
return nil;
}
+#if TARGET_OS_IPHONE
+
// init_working_dir sets the current working directory to the app root.
-// By default darwin/arm64 processes start in "/".
+// By default ios/arm64 processes start in "/".
static void
init_working_dir()
{
@@ -131,7 +139,7 @@ init_working_dir()
fprintf(stderr, "runtime/cgo: chdir(%s) failed\n", dir);
}
- // The test harness in go_darwin_arm_exec passes the relative working directory
+ // The test harness in go_ios_exec passes the relative working directory
// in the GoExecWrapperWorkingDirectory property of the app bundle.
CFStringRef wd_ref = CFBundleGetValueForInfoDictionaryKey(bundle, CFSTR("GoExecWrapperWorkingDirectory"));
if (wd_ref != NULL) {
@@ -145,6 +153,8 @@ init_working_dir()
}
}
+#endif // TARGET_OS_IPHONE
+
void
x_cgo_init(G *g, void (*setg)(void*), void **tlsg, void **tlsbase)
{
@@ -161,8 +171,9 @@ x_cgo_init(G *g, void (*setg)(void*), void **tlsg, void **tlsbase)
// yes, tlsbase from mrs might not be correctly aligned.
inittls(tlsg, (void**)((uintptr)tlsbase & ~7));
+#if TARGET_OS_IPHONE
darwin_arm_init_mach_exception_handler();
darwin_arm_init_thread_exception_port();
-
init_working_dir();
+#endif
}