aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/cgo/gcc_darwin_arm.c164
-rw-r--r--src/runtime/cgo/gcc_signal2_darwin_arm64.c (renamed from src/runtime/cgo/gcc_signal2_darwin_armx.c)4
-rw-r--r--src/runtime/cgo/gcc_signal_darwin_arm64.c (renamed from src/runtime/cgo/gcc_signal_darwin_armx.c)2
-rw-r--r--src/runtime/cgo/gcc_signal_darwin_lldb.c2
-rw-r--r--src/runtime/cgo/signal_darwin_arm.s49
-rw-r--r--src/runtime/cgo/signal_darwin_arm64.go (renamed from src/runtime/cgo/signal_darwin_armx.go)3
-rw-r--r--src/runtime/defs_darwin_arm.go231
-rw-r--r--src/runtime/os_darwin_arm.go23
-rw-r--r--src/runtime/rt0_darwin_arm.s11
-rw-r--r--src/runtime/signal_arm.go2
-rw-r--r--src/runtime/signal_darwin_arm.go73
-rw-r--r--src/runtime/sys_darwin_32.go2
-rw-r--r--src/runtime/sys_darwin_arm.s603
13 files changed, 4 insertions, 1165 deletions
diff --git a/src/runtime/cgo/gcc_darwin_arm.c b/src/runtime/cgo/gcc_darwin_arm.c
deleted file mode 100644
index 205977c4ba..0000000000
--- a/src/runtime/cgo/gcc_darwin_arm.c
+++ /dev/null
@@ -1,164 +0,0 @@
-// Copyright 2014 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-#include <limits.h>
-#include <pthread.h>
-#include <signal.h>
-#include <string.h> /* for strerror */
-#include <sys/param.h>
-#include <unistd.h>
-
-#include <CoreFoundation/CFBundle.h>
-#include <CoreFoundation/CFString.h>
-
-#include "libcgo.h"
-#include "libcgo_unix.h"
-
-#define magic (0xe696c4f4U)
-
-// inittls allocates a thread-local storage slot for g.
-//
-// It finds the first available slot using pthread_key_create and uses
-// it as the offset value for runtime.tlsg.
-static void
-inittls(void **tlsg, void **tlsbase)
-{
- pthread_key_t k;
- int i, err;
-
- err = pthread_key_create(&k, nil);
- if(err != 0) {
- fprintf(stderr, "runtime/cgo: pthread_key_create failed: %d\n", err);
- abort();
- }
- //fprintf(stderr, "runtime/cgo: k = %d, tlsbase = %p\n", (int)k, tlsbase); // debug
- pthread_setspecific(k, (void*)magic);
- // The first key should be at 258.
- for (i=0; i<PTHREAD_KEYS_MAX; i++) {
- if (*(tlsbase+i) == (void*)magic) {
- *tlsg = (void*)(i*sizeof(void *));
- pthread_setspecific(k, 0);
- return;
- }
- }
- fprintf(stderr, "runtime/cgo: could not find pthread key.\n");
- abort();
-}
-
-static void *threadentry(void*);
-static void (*setg_gcc)(void*);
-
-void
-_cgo_sys_thread_start(ThreadStart *ts)
-{
- pthread_attr_t attr;
- sigset_t ign, oset;
- pthread_t p;
- size_t size;
- int err;
-
- sigfillset(&ign);
- pthread_sigmask(SIG_SETMASK, &ign, &oset);
-
- pthread_attr_init(&attr);
- size = 0;
- pthread_attr_getstacksize(&attr, &size);
- // Leave stacklo=0 and set stackhi=size; mstart will do the rest.
- ts->g->stackhi = size;
- err = _cgo_try_pthread_create(&p, &attr, threadentry, ts);
-
- pthread_sigmask(SIG_SETMASK, &oset, nil);
-
- if (err != 0) {
- fprintf(stderr, "runtime/cgo: pthread_create failed: %s\n", strerror(err));
- abort();
- }
-}
-
-extern void crosscall_arm1(void (*fn)(void), void (*setg_gcc)(void*), void *g);
-static void*
-threadentry(void *v)
-{
- ThreadStart ts;
-
- ts = *(ThreadStart*)v;
- free(v);
-
- darwin_arm_init_thread_exception_port();
-
- crosscall_arm1(ts.fn, setg_gcc, (void*)ts.g);
- return nil;
-}
-
-// init_working_dir sets the current working directory to the app root.
-// By default darwin/arm processes start in "/".
-static void
-init_working_dir()
-{
- CFBundleRef bundle = CFBundleGetMainBundle();
- if (bundle == NULL) {
- fprintf(stderr, "runtime/cgo: no main bundle\n");
- return;
- }
- CFURLRef url_ref = CFBundleCopyResourceURL(bundle, CFSTR("Info"), CFSTR("plist"), NULL);
- if (url_ref == NULL) {
- // No Info.plist found. It can happen on Corellium virtual devices.
- return;
- }
- CFStringRef url_str_ref = CFURLGetString(url_ref);
- char buf[MAXPATHLEN];
- Boolean res = CFStringGetCString(url_str_ref, buf, sizeof(buf), kCFStringEncodingUTF8);
- CFRelease(url_ref);
- if (!res) {
- fprintf(stderr, "runtime/cgo: cannot get URL string\n");
- return;
- }
-
- // url is of the form "file:///path/to/Info.plist".
- // strip it down to the working directory "/path/to".
- int url_len = strlen(buf);
- if (url_len < sizeof("file://")+sizeof("/Info.plist")) {
- fprintf(stderr, "runtime/cgo: bad URL: %s\n", buf);
- return;
- }
- buf[url_len-sizeof("/Info.plist")+1] = 0;
- char *dir = &buf[0] + sizeof("file://")-1;
-
- if (chdir(dir) != 0) {
- fprintf(stderr, "runtime/cgo: chdir(%s) failed\n", dir);
- }
-
- // The test harness in go_darwin_arm_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) {
- if (!CFStringGetCString(wd_ref, buf, sizeof(buf), kCFStringEncodingUTF8)) {
- fprintf(stderr, "runtime/cgo: cannot get GoExecWrapperWorkingDirectory string\n");
- return;
- }
- if (chdir(buf) != 0) {
- fprintf(stderr, "runtime/cgo: chdir(%s) failed\n", buf);
- }
- }
-}
-
-void
-x_cgo_init(G *g, void (*setg)(void*), void **tlsg, void **tlsbase)
-{
- pthread_attr_t attr;
- size_t size;
-
- setg_gcc = setg;
- pthread_attr_init(&attr);
- pthread_attr_getstacksize(&attr, &size);
- g->stacklo = (uintptr)&attr - size + 4096;
- pthread_attr_destroy(&attr);
-
- // yes, tlsbase from mrc might not be correctly aligned.
- inittls(tlsg, (void**)((uintptr)tlsbase & ~3));
-
- darwin_arm_init_mach_exception_handler();
- darwin_arm_init_thread_exception_port();
- init_working_dir();
-}
diff --git a/src/runtime/cgo/gcc_signal2_darwin_armx.c b/src/runtime/cgo/gcc_signal2_darwin_arm64.c
index 54b7e32658..5b8a18ffd6 100644
--- a/src/runtime/cgo/gcc_signal2_darwin_armx.c
+++ b/src/runtime/cgo/gcc_signal2_darwin_arm64.c
@@ -3,10 +3,8 @@
// license that can be found in the LICENSE file.
// +build lldb
-// +build darwin
-// +build arm arm64
-// Used by gcc_signal_darwin_armx.c when doing the test build during cgo.
+// Used by gcc_signal_darwin_arm64.c when doing the test build during cgo.
// We hope that for real binaries the definition provided by Go will take precedence
// and the linker will drop this .o file altogether, which is why this definition
// is all by itself in its own file.
diff --git a/src/runtime/cgo/gcc_signal_darwin_armx.c b/src/runtime/cgo/gcc_signal_darwin_arm64.c
index 3ab1d8b0d6..6519edd4cc 100644
--- a/src/runtime/cgo/gcc_signal_darwin_armx.c
+++ b/src/runtime/cgo/gcc_signal_darwin_arm64.c
@@ -18,8 +18,6 @@
// The dist tool enables this by build flag when testing.
// +build lldb
-// +build darwin
-// +build arm arm64
#include <limits.h>
#include <pthread.h>
diff --git a/src/runtime/cgo/gcc_signal_darwin_lldb.c b/src/runtime/cgo/gcc_signal_darwin_lldb.c
index 54d91f6390..0ccdae324e 100644
--- a/src/runtime/cgo/gcc_signal_darwin_lldb.c
+++ b/src/runtime/cgo/gcc_signal_darwin_lldb.c
@@ -4,7 +4,7 @@
// +build !lldb
// +build darwin
-// +build arm arm64
+// +build arm64
#include <stdint.h>
diff --git a/src/runtime/cgo/signal_darwin_arm.s b/src/runtime/cgo/signal_darwin_arm.s
deleted file mode 100644
index 0be10c02d3..0000000000
--- a/src/runtime/cgo/signal_darwin_arm.s
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright 2015 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-#include "textflag.h"
-
-// xx_cgo_panicmem is the entrypoint for SIGSEGV as intercepted via a
-// mach thread port as EXC_BAD_ACCESS. As the segfault may have happened
-// in C code, we first need to load_g then call xx_cgo_panicmem.
-//
-// R1 - LR at moment of fault
-// R2 - PC at moment of fault
-TEXT xx_cgo_panicmem(SB),NOSPLIT|NOFRAME,$0
- // If in external C code, we need to load the g register.
- BL runtime·load_g(SB)
- CMP $0, g
- BNE ongothread
-
- // On a foreign thread. We call badsignal, which will, if all
- // goes according to plan, not return.
- SUB $4, R13
- MOVW $11, R1
- MOVW $11, R2
- MOVM.DB.W [R1,R2], (R13)
- // TODO: badsignal should not return, but it does. Issue #10139.
- //BL runtime·badsignal(SB)
- MOVW $139, R1
- MOVW R1, 4(R13)
- B runtime·exit(SB)
-
-ongothread:
- // Trigger a SIGSEGV panic.
- //
- // The goal is to arrange the stack so it looks like the runtime
- // function sigpanic was called from the PC that faulted. It has
- // to be sigpanic, as the stack unwinding code in traceback.go
- // looks explicitly for it.
- //
- // To do this we call into runtime·setsigsegv, which sets the
- // appropriate state inside the g object. We give it the faulting
- // PC on the stack, then put it in the LR before calling sigpanic.
- MOVM.DB.W [R1,R2], (R13)
- BL runtime·setsigsegv(SB)
- MOVM.IA.W (R13), [R1,R2]
-
- SUB $4, R13
- MOVW R1, 0(R13)
- MOVW R2, R14
- B runtime·sigpanic(SB)
diff --git a/src/runtime/cgo/signal_darwin_armx.go b/src/runtime/cgo/signal_darwin_arm64.go
index 9f4b462415..3425c448c4 100644
--- a/src/runtime/cgo/signal_darwin_armx.go
+++ b/src/runtime/cgo/signal_darwin_arm64.go
@@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build darwin
-// +build arm arm64
-
package cgo
import _ "unsafe"
diff --git a/src/runtime/defs_darwin_arm.go b/src/runtime/defs_darwin_arm.go
deleted file mode 100644
index 199886aad1..0000000000
--- a/src/runtime/defs_darwin_arm.go
+++ /dev/null
@@ -1,231 +0,0 @@
-// Note: cgo can't handle some Darwin/ARM structures, so this file can't
-// be auto generated by cgo yet.
-// Created based on output of `cgo -cdefs defs_darwin.go` and Darwin/ARM
-// specific header (mainly mcontext and ucontext related stuff)
-
-package runtime
-
-import "unsafe"
-
-const (
- _EINTR = 0x4
- _EFAULT = 0xe
- _EAGAIN = 0x23
- _ETIMEDOUT = 0x3c
-
- _PROT_NONE = 0x0
- _PROT_READ = 0x1
- _PROT_WRITE = 0x2
- _PROT_EXEC = 0x4
-
- _MAP_ANON = 0x1000
- _MAP_PRIVATE = 0x2
- _MAP_FIXED = 0x10
-
- _MADV_DONTNEED = 0x4
- _MADV_FREE = 0x5
- _MADV_FREE_REUSABLE = 0x7
- _MADV_FREE_REUSE = 0x8
-
- _SA_SIGINFO = 0x40
- _SA_RESTART = 0x2
- _SA_ONSTACK = 0x1
- _SA_USERTRAMP = 0x100
- _SA_64REGSET = 0x200
-
- _SIGHUP = 0x1
- _SIGINT = 0x2
- _SIGQUIT = 0x3
- _SIGILL = 0x4
- _SIGTRAP = 0x5
- _SIGABRT = 0x6
- _SIGEMT = 0x7
- _SIGFPE = 0x8
- _SIGKILL = 0x9
- _SIGBUS = 0xa
- _SIGSEGV = 0xb
- _SIGSYS = 0xc
- _SIGPIPE = 0xd
- _SIGALRM = 0xe
- _SIGTERM = 0xf
- _SIGURG = 0x10
- _SIGSTOP = 0x11
- _SIGTSTP = 0x12
- _SIGCONT = 0x13
- _SIGCHLD = 0x14
- _SIGTTIN = 0x15
- _SIGTTOU = 0x16
- _SIGIO = 0x17
- _SIGXCPU = 0x18
- _SIGXFSZ = 0x19
- _SIGVTALRM = 0x1a
- _SIGPROF = 0x1b
- _SIGWINCH = 0x1c
- _SIGINFO = 0x1d
- _SIGUSR1 = 0x1e
- _SIGUSR2 = 0x1f
-
- _FPE_INTDIV = 0x7
- _FPE_INTOVF = 0x8
- _FPE_FLTDIV = 0x1
- _FPE_FLTOVF = 0x2
- _FPE_FLTUND = 0x3
- _FPE_FLTRES = 0x4
- _FPE_FLTINV = 0x5
- _FPE_FLTSUB = 0x6
-
- _BUS_ADRALN = 0x1
- _BUS_ADRERR = 0x2
- _BUS_OBJERR = 0x3
-
- _SEGV_MAPERR = 0x1
- _SEGV_ACCERR = 0x2
-
- _ITIMER_REAL = 0x0
- _ITIMER_VIRTUAL = 0x1
- _ITIMER_PROF = 0x2
-
- _EV_ADD = 0x1
- _EV_DELETE = 0x2
- _EV_CLEAR = 0x20
- _EV_RECEIPT = 0x40
- _EV_ERROR = 0x4000
- _EV_EOF = 0x8000
- _EVFILT_READ = -0x1
- _EVFILT_WRITE = -0x2
-
- _PTHREAD_CREATE_DETACHED = 0x2
-
- _F_SETFD = 0x2
- _F_GETFL = 0x3
- _F_SETFL = 0x4
- _FD_CLOEXEC = 0x1
-
- _O_NONBLOCK = 4
-)
-
-type stackt struct {
- ss_sp *byte
- ss_size uintptr
- ss_flags int32
-}
-
-type sigactiont struct {
- __sigaction_u [4]byte
- sa_tramp unsafe.Pointer
- sa_mask uint32
- sa_flags int32
-}
-
-type usigactiont struct {
- __sigaction_u [4]byte
- sa_mask uint32
- sa_flags int32
-}
-
-type siginfo struct {
- si_signo int32
- si_errno int32
- si_code int32
- si_pid int32
- si_uid uint32
- si_status int32
- si_addr uint32
- si_value [4]byte
- si_band int32
- __pad [7]uint32
-}
-
-type timeval struct {
- tv_sec int32
- tv_usec int32
-}
-
-func (tv *timeval) set_usec(x int32) {
- tv.tv_usec = x
-}
-
-type itimerval struct {
- it_interval timeval
- it_value timeval
-}
-
-type timespec struct {
- tv_sec int32
- tv_nsec int32
-}
-
-//go:nosplit
-func (ts *timespec) setNsec(ns int64) {
- ts.tv_sec = timediv(ns, 1e9, &ts.tv_nsec)
-}
-
-type floatstate32 struct {
- r [32]uint32
- fpscr uint32
-}
-
-type regs32 struct {
- r [13]uint32 // r0 to r12
- sp uint32 // r13
- lr uint32 // r14
- pc uint32 // r15
- cpsr uint32
-}
-
-type exceptionstate32 struct {
- trapno uint32 // NOTE: on 386, the trapno field is split into trapno and cpu
- err uint32
- faultvaddr uint32
-}
-
-type mcontext32 struct {
- es exceptionstate32
- ss regs32
- fs floatstate32
-}
-
-type ucontext struct {
- uc_onstack int32
- uc_sigmask uint32
- uc_stack stackt
- uc_link *ucontext
- uc_mcsize uint32
- uc_mcontext *mcontext32
-}
-
-type keventt struct {
- ident uint32
- filter int16
- flags uint16
- fflags uint32
- data int32
- udata *byte
-}
-
-type pthread uintptr
-type pthreadattr struct {
- X__sig int32
- X__opaque [36]int8
-}
-type pthreadmutex struct {
- X__sig int32
- X__opaque [40]int8
-}
-type pthreadmutexattr struct {
- X__sig int32
- X__opaque [8]int8
-}
-type pthreadcond struct {
- X__sig int32
- X__opaque [24]int8
-}
-type pthreadcondattr struct {
- X__sig int32
- X__opaque [4]int8
-}
-
-type machTimebaseInfo struct {
- numer uint32
- denom uint32
-}
diff --git a/src/runtime/os_darwin_arm.go b/src/runtime/os_darwin_arm.go
deleted file mode 100644
index 2703e3cff8..0000000000
--- a/src/runtime/os_darwin_arm.go
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright 2014 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package runtime
-
-func checkgoarm() {
- // TODO(minux): FP checks like in os_linux_arm.go.
-
- // osinit not called yet, so ncpu not set: must use getncpu directly.
- if getncpu() > 1 && goarm < 7 {
- print("runtime: this system has multiple CPUs and must use\n")
- print("atomic synchronization instructions. Recompile using GOARM=7.\n")
- exit(1)
- }
-}
-
-//go:nosplit
-func cputicks() int64 {
- // Currently cputicks() is used in blocking profiler and to seed runtime·fastrand().
- // runtime·nanotime() is a poor approximation of CPU ticks that is enough for the profiler.
- return nanotime()
-}
diff --git a/src/runtime/rt0_darwin_arm.s b/src/runtime/rt0_darwin_arm.s
deleted file mode 100644
index 71fbe5f68a..0000000000
--- a/src/runtime/rt0_darwin_arm.s
+++ /dev/null
@@ -1,11 +0,0 @@
-// Copyright 2014 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-#include "textflag.h"
-
-TEXT _rt0_arm_darwin(SB),7,$0
- B _rt0_asm(SB)
-
-TEXT _rt0_arm_darwin_lib(SB),NOSPLIT,$0
- B _rt0_arm_lib(SB)
diff --git a/src/runtime/signal_arm.go b/src/runtime/signal_arm.go
index d11023a0c3..1663d913c3 100644
--- a/src/runtime/signal_arm.go
+++ b/src/runtime/signal_arm.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build darwin dragonfly freebsd linux netbsd openbsd
+// +build dragonfly freebsd linux netbsd openbsd
package runtime
diff --git a/src/runtime/signal_darwin_arm.go b/src/runtime/signal_darwin_arm.go
deleted file mode 100644
index 9098b1053d..0000000000
--- a/src/runtime/signal_darwin_arm.go
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright 2014 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package runtime
-
-import "unsafe"
-
-type sigctxt struct {
- info *siginfo
- ctxt unsafe.Pointer
-}
-
-//go:nosplit
-//go:nowritebarrierrec
-func (c *sigctxt) regs() *regs32 { return &(*ucontext)(c.ctxt).uc_mcontext.ss }
-
-func (c *sigctxt) r0() uint32 { return c.regs().r[0] }
-func (c *sigctxt) r1() uint32 { return c.regs().r[1] }
-func (c *sigctxt) r2() uint32 { return c.regs().r[2] }
-func (c *sigctxt) r3() uint32 { return c.regs().r[3] }
-func (c *sigctxt) r4() uint32 { return c.regs().r[4] }
-func (c *sigctxt) r5() uint32 { return c.regs().r[5] }
-func (c *sigctxt) r6() uint32 { return c.regs().r[6] }
-func (c *sigctxt) r7() uint32 { return c.regs().r[7] }
-func (c *sigctxt) r8() uint32 { return c.regs().r[8] }
-func (c *sigctxt) r9() uint32 { return c.regs().r[9] }
-func (c *sigctxt) r10() uint32 { return c.regs().r[10] }
-func (c *sigctxt) fp() uint32 { return c.regs().r[11] }
-func (c *sigctxt) ip() uint32 { return c.regs().r[12] }
-func (c *sigctxt) sp() uint32 { return c.regs().sp }
-func (c *sigctxt) lr() uint32 { return c.regs().lr }
-
-//go:nosplit
-//go:nowritebarrierrec
-func (c *sigctxt) pc() uint32 { return c.regs().pc }
-
-func (c *sigctxt) cpsr() uint32 { return c.regs().cpsr }
-func (c *sigctxt) fault() uintptr { return uintptr(c.info.si_addr) }
-func (c *sigctxt) sigcode() uint32 { return uint32(c.info.si_code) }
-func (c *sigctxt) trap() uint32 { return 0 }
-func (c *sigctxt) error() uint32 { return 0 }
-func (c *sigctxt) oldmask() uint32 { return 0 }
-
-func (c *sigctxt) set_pc(x uint32) { c.regs().pc = x }
-func (c *sigctxt) set_sp(x uint32) { c.regs().sp = x }
-func (c *sigctxt) set_lr(x uint32) { c.regs().lr = x }
-func (c *sigctxt) set_r10(x uint32) { c.regs().r[10] = x }
-
-func (c *sigctxt) set_sigcode(x uint32) { c.info.si_code = int32(x) }
-func (c *sigctxt) set_sigaddr(x uint32) { c.info.si_addr = x }
-
-//go:nosplit
-func (c *sigctxt) fixsigcode(sig uint32) {
- switch sig {
- case _SIGTRAP:
- // OS X sets c.sigcode() == TRAP_BRKPT unconditionally for all SIGTRAPs,
- // leaving no way to distinguish a breakpoint-induced SIGTRAP
- // from an asynchronous signal SIGTRAP.
- // They all look breakpoint-induced by default.
- // Try looking at the code to see if it's a breakpoint.
- // The assumption is that we're very unlikely to get an
- // asynchronous SIGTRAP at just the moment that the
- // PC started to point at unmapped memory.
- pc := uintptr(c.pc())
- // OS X will leave the pc just after the instruction.
- code := (*uint32)(unsafe.Pointer(pc - 4))
- if *code != 0xe7f001f0 {
- // SIGTRAP on something other than breakpoint.
- c.set_sigcode(_SI_USER)
- }
- }
-}
diff --git a/src/runtime/sys_darwin_32.go b/src/runtime/sys_darwin_32.go
index f126be83e5..6832cf5684 100644
--- a/src/runtime/sys_darwin_32.go
+++ b/src/runtime/sys_darwin_32.go
@@ -3,7 +3,7 @@
// license that can be found in the LICENSE file.
// +build darwin
-// +build 386 arm
+// +build 386
package runtime
diff --git a/src/runtime/sys_darwin_arm.s b/src/runtime/sys_darwin_arm.s
deleted file mode 100644
index c08a29e7e0..0000000000
--- a/src/runtime/sys_darwin_arm.s
+++ /dev/null
@@ -1,603 +0,0 @@
-// Copyright 2014 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// System calls and other sys.stuff for ARM, Darwin
-// System calls are implemented in libSystem, this file contains
-// trampolines that convert from Go to C calling convention.
-
-#include "go_asm.h"
-#include "go_tls.h"
-#include "textflag.h"
-
-TEXT notok<>(SB),NOSPLIT,$0
- MOVW $0, R8
- MOVW R8, (R8)
- B 0(PC)
-
-TEXT runtime·open_trampoline(SB),NOSPLIT,$0
- MOVW 4(R0), R1 // arg 2 mode
- MOVW 8(R0), R2 // arg 3 perm
- MOVW 0(R0), R0 // arg 1 name
- BL libc_open(SB)
- RET
-
-TEXT runtime·close_trampoline(SB),NOSPLIT,$0
- MOVW 0(R0), R0 // arg 1 fd
- BL libc_close(SB)
- RET
-
-TEXT runtime·write_trampoline(SB),NOSPLIT,$0
- MOVW 4(R0), R1 // arg 2 buf
- MOVW 8(R0), R2 // arg 3 count
- MOVW 0(R0), R0 // arg 1 fd
- BL libc_write(SB)
- MOVW $-1, R1
- CMP R0, R1
- BNE noerr
- BL libc_error(SB)
- MOVW (R0), R0
- RSB $0, R0, R0 // caller expects negative errno value
-noerr:
- RET
-
-TEXT runtime·read_trampoline(SB),NOSPLIT,$0
- MOVW 4(R0), R1 // arg 2 buf
- MOVW 8(R0), R2 // arg 3 count
- MOVW 0(R0), R0 // arg 1 fd
- BL libc_read(SB)
- MOVW $-1, R1
- CMP R0, R1
- BNE noerr
- BL libc_error(SB)
- MOVW (R0), R0
- RSB $0, R0, R0 // caller expects negative errno value
-noerr:
- RET
-
-TEXT runtime·pipe_trampoline(SB),NOSPLIT,$0
- BL libc_pipe(SB) // pointer already in R0
- CMP $0, R0
- BEQ 3(PC)
- BL libc_error(SB) // return negative errno value
- RSB $0, R0, R0
- RET
-
-TEXT runtime·exit_trampoline(SB),NOSPLIT|NOFRAME,$0
- MOVW 0(R0), R0 // arg 0 code
- BL libc_exit(SB)
- MOVW $1234, R0
- MOVW $1002, R1
- MOVW R0, (R1) // fail hard
-
-TEXT runtime·raiseproc_trampoline(SB),NOSPLIT,$0
- MOVW 0(R0), R8 // signal
- BL libc_getpid(SB)
- // arg 1 pid already in R0 from getpid
- MOVW R8, R1 // arg 2 signal
- BL libc_kill(SB)
- RET
-
-TEXT runtime·mmap_trampoline(SB),NOSPLIT,$0
- MOVW R0, R8
- MOVW 0(R8), R0 // arg 1 addr
- MOVW 4(R8), R1 // arg 2 len
- MOVW 8(R8), R2 // arg 3 prot
- MOVW 12(R8), R3 // arg 4 flags
- MOVW 16(R8), R4 // arg 5 fid
- MOVW 20(R8), R5 // arg 6 offset
- MOVW $0, R6 // off_t is uint64_t
- // Only R0-R3 are used for arguments, the rest
- // go on the stack.
- MOVM.DB.W [R4-R6], (R13)
- BL libc_mmap(SB)
- ADD $12, R13
- MOVW $0, R1
- MOVW $-1, R2
- CMP R0, R2
- BNE ok
- BL libc_error(SB)
- MOVW (R0), R1
- MOVW $0, R0
-ok:
- MOVW R0, 24(R8) // ret 1 addr
- MOVW R1, 28(R8) // ret 2 err
- RET
-
-TEXT runtime·munmap_trampoline(SB),NOSPLIT,$0
- MOVW 4(R0), R1 // arg 2 len
- MOVW 0(R0), R0 // arg 1 addr
- BL libc_munmap(SB)
- MOVW $-1, R2
- CMP R0, R2
- BL.EQ notok<>(SB)
- RET
-
-TEXT runtime·madvise_trampoline(SB),NOSPLIT,$0
- MOVW 4(R0), R1 // arg 2 len
- MOVW 8(R0), R2 // arg 3 advice
- MOVW 0(R0), R0 // arg 1 addr
- BL libc_madvise(SB)
- MOVW $-1, R2
- CMP R0, R2
- BL.EQ notok<>(SB)
- RET
-
-TEXT runtime·setitimer_trampoline(SB),NOSPLIT,$0
- MOVW 4(R0), R1 // arg 2 new
- MOVW 8(R0), R2 // arg 3 old
- MOVW 0(R0), R0 // arg 1 which
- BL libc_setitimer(SB)
- RET
-
-TEXT runtime·walltime_trampoline(SB),NOSPLIT,$0
- // R0 already has *timeval
- MOVW $0, R1 // no timezone needed
- BL libc_gettimeofday(SB)
- RET
-
-GLOBL timebase<>(SB),NOPTR,$(machTimebaseInfo__size)
-
-TEXT runtime·nanotime_trampoline(SB),NOSPLIT,$0
- MOVW R0, R8
- BL libc_mach_absolute_time(SB)
- MOVW R0, 0(R8)
- MOVW R1, 4(R8)
- MOVW timebase<>+machTimebaseInfo_numer(SB), R6
- MOVW $timebase<>+machTimebaseInfo_denom(SB), R5
- MOVW (R5), R7
- DMB MB_ISH // memory barrier for atomic read
- CMP $0, R7
- BNE initialized
-
- SUB $(machTimebaseInfo__size+7)/8*8, R13
- MOVW R13, R0
- BL libc_mach_timebase_info(SB)
- MOVW machTimebaseInfo_numer(R13), R6
- MOVW machTimebaseInfo_denom(R13), R7
- ADD $(machTimebaseInfo__size+7)/8*8, R13
-
- MOVW R6, timebase<>+machTimebaseInfo_numer(SB)
- MOVW $timebase<>+machTimebaseInfo_denom(SB), R5
- DMB MB_ISH // memory barrier for atomic write
- MOVW R7, (R5)
- DMB MB_ISH
-
-initialized:
- MOVW R6, 8(R8)
- MOVW R7, 12(R8)
- RET
-
-TEXT runtime·sigfwd(SB),NOSPLIT,$0-16
- MOVW sig+4(FP), R0
- MOVW info+8(FP), R1
- MOVW ctx+12(FP), R2
- MOVW fn+0(FP), R11
- MOVW R13, R4
- SUB $24, R13
- BIC $0x7, R13 // alignment for ELF ABI
- BL (R11)
- MOVW R4, R13
- RET
-
-TEXT runtime·sigtramp(SB),NOSPLIT,$0
- // Reserve space for callee-save registers and arguments.
- MOVM.DB.W [R4-R11], (R13)
- SUB $16, R13
-
- // Save arguments.
- MOVW R0, 4(R13) // sig
- MOVW R1, 8(R13) // info
- MOVW R2, 12(R13) // ctx
-
- // this might be called in external code context,
- // where g is not set.
- MOVB runtime·iscgo(SB), R0
- CMP $0, R0
- BL.NE runtime·load_g(SB)
-
- MOVW R13, R6
- CMP $0, g
- BEQ nog
-
- // iOS always use the main stack to run the signal handler.
- // We need to switch to gsignal ourselves.
- MOVW g_m(g), R11
- MOVW m_gsignal(R11), R5
- MOVW (g_stack+stack_hi)(R5), R6
-
-nog:
- // Restore arguments.
- MOVW 4(R13), R0
- MOVW 8(R13), R1
- MOVW 12(R13), R2
-
- // Reserve space for args and the stack pointer on the
- // gsignal stack.
- SUB $24, R6
- // Save stack pointer.
- MOVW R13, R4
- MOVW R4, 16(R6)
- // Switch to gsignal stack.
- MOVW R6, R13
-
- // Call sigtrampgo
- MOVW R0, 4(R13)
- MOVW R1, 8(R13)
- MOVW R2, 12(R13)
- BL runtime·sigtrampgo(SB)
-
- // Switch to old stack.
- MOVW 16(R13), R5
- MOVW R5, R13
-
- // Restore callee-save registers.
- ADD $16, R13
- MOVM.IA.W (R13), [R4-R11]
-
- RET
-
-TEXT runtime·cgoSigtramp(SB),NOSPLIT,$0
- JMP runtime·sigtramp(SB)
-
-TEXT runtime·sigprocmask_trampoline(SB),NOSPLIT,$0
- MOVW 4(R0), R1 // arg 2 new
- MOVW 8(R0), R2 // arg 3 old
- MOVW 0(R0), R0 // arg 1 how
- BL libc_pthread_sigmask(SB)
- CMP $0, R0
- BL.NE notok<>(SB)
- RET
-
-TEXT runtime·sigaction_trampoline(SB),NOSPLIT,$0
- MOVW 4(R0), R1 // arg 2 new
- MOVW 8(R0), R2 // arg 3 old
- MOVW 0(R0), R0 // arg 1 how
- BL libc_sigaction(SB)
- RET
-
-TEXT runtime·usleep_trampoline(SB),NOSPLIT,$0
- MOVW 0(R0), R0 // arg 1 usec
- BL libc_usleep(SB)
- RET
-
-TEXT ·publicationBarrier(SB),NOSPLIT|NOFRAME,$0-0
- B runtime·armPublicationBarrier(SB)
-
-TEXT runtime·sysctl_trampoline(SB),NOSPLIT,$0
- MOVW 4(R0), R1 // arg 2 miblen
- MOVW 8(R0), R2 // arg 3 out
- MOVW 12(R0), R3 // arg 4 size
- MOVW 16(R0), R4 // arg 5 dst
- MOVW 20(R0), R5 // arg 6 ndst
- MOVW 0(R0), R0 // arg 1 mib
- // Only R0-R3 are used for arguments, the rest
- // go on the stack.
- MOVM.DB.W [R4-R5], (R13)
- BL libc_sysctl(SB)
- ADD $(2*4), R13
- RET
-
-TEXT runtime·kqueue_trampoline(SB),NOSPLIT,$0
- BL libc_kqueue(SB)
- RET
-
-// int32 runtime·kevent(int kq, Kevent *changelist, int nchanges, Kevent *eventlist, int events, Timespec *timeout)
-TEXT runtime·kevent_trampoline(SB),NOSPLIT,$0
- MOVW 4(R0), R1 // arg 2 keventss
- MOVW 8(R0), R2 // arg 3 nch
- MOVW 12(R0), R3 // arg 4 ev
- MOVW 16(R0), R4 // arg 5 nev
- MOVW 20(R0), R5 // arg 6 ts
- MOVW 0(R0), R0 // arg 1 kq
- // Only R0-R3 are used for arguments, the rest
- // go on the stack.
- MOVM.DB.W [R4-R5], (R13)
- BL libc_kevent(SB)
- ADD $(2*4), R13
- MOVW $-1, R2
- CMP R0, R2
- BNE ok
- BL libc_error(SB)
- MOVW (R0), R0 // errno
- RSB $0, R0, R0 // caller wants it as a negative error code
-ok:
- RET
-
-TEXT runtime·fcntl_trampoline(SB),NOSPLIT,$0
- MOVW 4(R0), R1 // arg 2 cmd
- MOVW 8(R0), R2 // arg 3 arg
- MOVW 0(R0), R0 // arg 1 fd
- BL libc_fcntl(SB)
- RET
-
-// sigaltstack is not supported on iOS, so our sigtramp has
-// to do the stack switch ourselves.
-TEXT runtime·sigaltstack_trampoline(SB),NOSPLIT,$0
- MOVW $43, R0
- BL libc_exit(SB)
- RET
-
-// Thread related functions
-// Note: On darwin/arm, the runtime always use runtime/cgo to
-// create threads, so all thread related functions will just exit with a
-// unique status.
-
-TEXT runtime·mstart_stub(SB),NOSPLIT,$0
- MOVW $44, R0
- BL libc_exit(SB)
- RET
-
-TEXT runtime·pthread_attr_init_trampoline(SB),NOSPLIT,$0
- MOVW $45, R0
- BL libc_exit(SB)
- RET
-
-TEXT runtime·pthread_attr_getstacksize_trampoline(SB),NOSPLIT,$0
- MOVW $46, R0
- BL libc_exit(SB)
- RET
-
-TEXT runtime·pthread_attr_setdetachstate_trampoline(SB),NOSPLIT,$0
- MOVW $47, R0
- BL libc_exit(SB)
- RET
-
-TEXT runtime·pthread_create_trampoline(SB),NOSPLIT,$0
- MOVW $48, R0
- BL libc_exit(SB)
- RET
-
-TEXT runtime·raise_trampoline(SB),NOSPLIT,$0
- MOVW 0(R0), R0 // arg 1 sig
- BL libc_raise(SB)
- RET
-
-TEXT runtime·pthread_mutex_init_trampoline(SB),NOSPLIT,$0
- MOVW 4(R0), R1 // arg 2 attr
- MOVW 0(R0), R0 // arg 1 mutex
- BL libc_pthread_mutex_init(SB)
- RET
-
-TEXT runtime·pthread_mutex_lock_trampoline(SB),NOSPLIT,$0
- MOVW 0(R0), R0 // arg 1 mutex
- BL libc_pthread_mutex_lock(SB)
- RET
-
-TEXT runtime·pthread_mutex_unlock_trampoline(SB),NOSPLIT,$0
- MOVW 0(R0), R0 // arg 1 mutex
- BL libc_pthread_mutex_unlock(SB)
- RET
-
-TEXT runtime·pthread_cond_init_trampoline(SB),NOSPLIT,$0
- MOVW 4(R0), R1 // arg 2 attr
- MOVW 0(R0), R0 // arg 1 cond
- BL libc_pthread_cond_init(SB)
- RET
-
-TEXT runtime·pthread_cond_wait_trampoline(SB),NOSPLIT,$0
- MOVW 4(R0), R1 // arg 2 mutex
- MOVW 0(R0), R0 // arg 1 cond
- BL libc_pthread_cond_wait(SB)
- RET
-
-TEXT runtime·pthread_cond_timedwait_relative_np_trampoline(SB),NOSPLIT,$0
- MOVW 4(R0), R1 // arg 2 mutex
- MOVW 8(R0), R2 // arg 3 timeout
- MOVW 0(R0), R0 // arg 1 cond
- BL libc_pthread_cond_timedwait_relative_np(SB)
- RET
-
-TEXT runtime·pthread_cond_signal_trampoline(SB),NOSPLIT,$0
- MOVW 0(R0), R0 // arg 1 cond
- BL libc_pthread_cond_signal(SB)
- RET
-
-TEXT runtime·pthread_self_trampoline(SB),NOSPLIT,$0
- MOVW R0, R4 // R4 is callee-save
- BL libc_pthread_self(SB)
- MOVW R0, 0(R4) // return value
- RET
-
-TEXT runtime·pthread_kill_trampoline(SB),NOSPLIT,$0
- MOVW 4(R0), R1 // arg 2 sig
- MOVW 0(R0), R0 // arg 1 thread
- BL libc_pthread_kill(SB)
- RET
-
-// syscall calls a function in libc on behalf of the syscall package.
-// syscall takes a pointer to a struct like:
-// struct {
-// fn uintptr
-// a1 uintptr
-// a2 uintptr
-// a3 uintptr
-// r1 uintptr
-// r2 uintptr
-// err uintptr
-// }
-// syscall must be called on the g0 stack with the
-// C calling convention (use libcCall).
-TEXT runtime·syscall(SB),NOSPLIT,$0
- MOVW.W R0, -4(R13) // push structure pointer
- MOVW 0(R0), R12 // fn
- MOVW 8(R0), R1 // a2
- MOVW 12(R0), R2 // a3
- MOVW 4(R0), R0 // a1
- BL (R12)
- MOVW.P 4(R13), R2 // pop structure pointer
- MOVW R0, 16(R2) // save r1
- MOVW R1, 20(R2) // save r2
- MOVW $-1, R3
- CMP R0, R3
- BNE ok
- MOVW.W R2, -4(R13) // push structure pointer
- BL libc_error(SB)
- MOVW (R0), R0
- MOVW.P 4(R13), R2 // pop structure pointer
- MOVW R0, 24(R2) // save err
-ok:
- RET
-
-// syscallPtr is like syscall except the libc function reports an
-// error by returning NULL and setting errno.
-TEXT runtime·syscallPtr(SB),NOSPLIT,$0
- MOVW.W R0, -4(R13) // push structure pointer
- MOVW 0(R0), R12 // fn
- MOVW 8(R0), R1 // a2
- MOVW 12(R0), R2 // a3
- MOVW 4(R0), R0 // a1
- BL (R12)
- MOVW.P 4(R13), R2 // pop structure pointer
- MOVW R0, 16(R2) // save r1
- MOVW R1, 20(R2) // save r2
- MOVW $0, R3
- CMP R0, R3
- BNE ok
- MOVW.W R2, -4(R13) // push structure pointer
- BL libc_error(SB)
- MOVW (R0), R0
- MOVW.P 4(R13), R2 // pop structure pointer
- MOVW R0, 24(R2) // save err
-ok:
- RET
-
-// syscall6 calls a function in libc on behalf of the syscall package.
-// syscall6 takes a pointer to a struct like:
-// struct {
-// fn uintptr
-// a1 uintptr
-// a2 uintptr
-// a3 uintptr
-// a4 uintptr
-// a5 uintptr
-// a6 uintptr
-// r1 uintptr
-// r2 uintptr
-// err uintptr
-// }
-// syscall6 must be called on the g0 stack with the
-// C calling convention (use libcCall).
-TEXT runtime·syscall6(SB),NOSPLIT,$0
- MOVW.W R0, -4(R13) // push structure pointer
- MOVW 0(R0), R12 // fn
- MOVW 24(R0), R1 // a6
- MOVW.W R1, -4(R13)
- MOVW 20(R0), R1 // a5
- MOVW.W R1, -4(R13)
- MOVW 8(R0), R1 // a2
- MOVW 12(R0), R2 // a3
- MOVW 16(R0), R3 // a4
- MOVW 4(R0), R0 // a1
- BL (R12)
- ADD $8, R13
- MOVW.P 4(R13), R2 // pop structure pointer
- MOVW R0, 28(R2) // save r1
- MOVW R1, 32(R2) // save r2
- MOVW $-1, R3
- CMP R0, R3
- BNE ok
- MOVW.W R2, -4(R13) // push structure pointer
- BL libc_error(SB)
- MOVW (R0), R0
- MOVW.P 4(R13), R2 // pop structure pointer
- MOVW R0, 36(R2) // save err
-ok:
- RET
-
-// syscall6X calls a function in libc on behalf of the syscall package.
-// syscall6X takes a pointer to a struct like:
-// struct {
-// fn uintptr
-// a1 uintptr
-// a2 uintptr
-// a3 uintptr
-// a4 uintptr
-// a5 uintptr
-// a6 uintptr
-// r1 uintptr
-// r2 uintptr
-// err uintptr
-// }
-// syscall6X must be called on the g0 stack with the
-// C calling convention (use libcCall).
-TEXT runtime·syscall6X(SB),NOSPLIT,$0
- MOVW.W R0, -4(R13) // push structure pointer
- MOVW 0(R0), R12 // fn
- MOVW 24(R0), R1 // a6
- MOVW.W R1, -4(R13)
- MOVW 20(R0), R1 // a5
- MOVW.W R1, -4(R13)
- MOVW 8(R0), R1 // a2
- MOVW 12(R0), R2 // a3
- MOVW 16(R0), R3 // a4
- MOVW 4(R0), R0 // a1
- BL (R12)
- ADD $8, R13
- MOVW.P 4(R13), R2 // pop structure pointer
- MOVW R0, 28(R2) // save r1
- MOVW R1, 32(R2) // save r2
- MOVW $-1, R3
- CMP R0, R3
- BNE ok
- CMP R1, R3
- BNE ok
- MOVW.W R2, -4(R13) // push structure pointer
- BL libc_error(SB)
- MOVW (R0), R0
- MOVW.P 4(R13), R2 // pop structure pointer
- MOVW R0, 36(R2) // save err
-ok:
- RET
-
-// syscall9 calls a function in libc on behalf of the syscall package.
-// syscall9 takes a pointer to a struct like:
-// struct {
-// fn uintptr
-// a1 uintptr
-// a2 uintptr
-// a3 uintptr
-// a4 uintptr
-// a5 uintptr
-// a6 uintptr
-// a7 uintptr
-// a8 uintptr
-// a9 uintptr
-// r1 uintptr
-// r2 uintptr
-// err uintptr
-// }
-// syscall9 must be called on the g0 stack with the
-// C calling convention (use libcCall).
-TEXT runtime·syscall9(SB),NOSPLIT,$0
- MOVW.W R0, -4(R13) // push structure pointer
- MOVW 0(R0), R12 // fn
- MOVW 36(R0), R1 // a9
- MOVW.W R1, -4(R13)
- MOVW 32(R0), R1 // a8
- MOVW.W R1, -4(R13)
- MOVW 28(R0), R1 // a7
- MOVW.W R1, -4(R13)
- MOVW 24(R0), R1 // a6
- MOVW.W R1, -4(R13)
- MOVW 20(R0), R1 // a5
- MOVW.W R1, -4(R13)
- MOVW 8(R0), R1 // a2
- MOVW 12(R0), R2 // a3
- MOVW 16(R0), R3 // a4
- MOVW 4(R0), R0 // a1
- BL (R12)
- ADD $20, R13
- MOVW.P 4(R13), R2 // pop structure pointer
- MOVW R0, 40(R2) // save r1
- MOVW R1, 44(R2) // save r2
- MOVW $-1, R3
- CMP R0, R3
- BNE ok
- MOVW.W R2, -4(R13) // push structure pointer
- BL libc_error(SB)
- MOVW (R0), R0
- MOVW.P 4(R13), R2 // pop structure pointer
- MOVW R0, 48(R2) // save err
-ok:
- RET