aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/defs_darwin_arm64.go
AgeCommit message (Collapse)Author
2020-10-28runtime: set up TLS without cgo on darwin/arm64Cherry Zhang
Currently, on darwin/arm64 we set up TLS using cgo. TLS is not set for pure Go programs. As we use libc for syscalls on darwin, we need to save the G register before the libc call. Otherwise it is not signal-safe, as a signal may land during the execution of a libc function, where the G register may be clobbered. This CL initializes TLS in Go, by calling the pthread functions directly without cgo. This makes it possible to save the G register to TLS in pure Go programs (done in a later CL). Inspired by Elias's CL 209197. Write the logic in Go instead of assembly. Updates #38485, #35853. Change-Id: I257ba2a411ad387b2f4d50d10129d37fec7a226e Reviewed-on: https://go-review.googlesource.com/c/go/+/265118 Trust: Cherry Zhang <cherryyz@google.com> Trust: Elias Naur <mail@eliasnaur.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-10-21runtime: add netpollBreakIan Lance Taylor
The new netpollBreak function can be used to interrupt a blocking netpoll. This function is not currently used; it will be used by later CLs. Updates #27707 Change-Id: I5cb936609ba13c3c127ea1368a49194fc58c9f4d Reviewed-on: https://go-review.googlesource.com/c/go/+/171824 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2019-06-30runtime: use a pipe to wake up signal_recv on DarwinIan Lance Taylor
The implementation of semaphores, and therefore notes, used on Darwin is not async-signal-safe. The runtime has one case where a note needs to be woken up from a signal handler: the call to notewakeup in sigsend. That notewakeup call is only called on a single note, and it doesn't need the full functionality of notes: nothing ever does a timed wait on it. So change that one note to use a different implementation on Darwin, based on a pipe. This lets the wakeup code use the write call, which is async-signal-safe. Fixes #31264 Change-Id: If705072d7a961dd908ea9d639c8d12b222c64806 Reviewed-on: https://go-review.googlesource.com/c/go/+/184169 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
2019-03-15runtime: introduce and consistently use setNsec for timespecIan Lance Taylor
The general code for setting a timespec value sometimes used set_nsec and sometimes used a combination of set_sec and set_nsec. Standardize on a setNsec function that takes a number of nanoseconds and splits them up to set the tv_sec and tv_nsec fields. Consistently mark setNsec as go:nosplit, since it has to be that way on some systems including Darwin and GNU/Linux. Consistently use timediv on 32-bit systems to help stay within split-stack limits on processors that don't have a 64-bit division instruction. Change-Id: I6396bb7ddbef171a96876bdeaf7a1c585a6d725b Reviewed-on: https://go-review.googlesource.com/c/go/+/167389 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-04runtime: use MADV_FREE_REUSABLE on darwinMichael Anthony Knyszek
Currently on darwin we use MADV_FREE, which unfortunately doesn't result in a change in the process's RSS until pages actually get kicked out, which the OS is free to do lazily (e.g. until it finds itself under memory pressure). To remedy this, we instead use MADV_FREE_REUSABLE which has similar semantics, except that it also sets a reusable bit on each page so the process's RSS gets reported more accurately. The one caveat is for every time we call MADV_FREE_REUSABLE on a region we must call MADV_FREE_REUSE to keep the kernel's accounting updated. Also, because this change requires adding new constants that only exist on darwin, it splits mem_bsd.go into mem_bsd.go and mem_darwin.go. Fixes #29844. Change-Id: Idb6421698511138a430807bcbbd1516cd57557c8 Reviewed-on: https://go-review.googlesource.com/c/go/+/159117 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-16runtime: move semaphore ops from system calls to libc calls on iOSElias Naur
Change-Id: I1c7a12497c47dd166cc41230d6e5e005edcbc848 Reviewed-on: https://go-review.googlesource.com/118819 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
2018-06-13runtime: move iOS kevent calls to libcElias Naur
Change-Id: Ie97c9c9163f5af7b4768c34faac726e21627aa79 Reviewed-on: https://go-review.googlesource.com/118660 Run-TryBot: Elias Naur <elias.naur@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
2018-05-21cmd/link,runtime: move syscalls to libc on iOSElias Naur
This CL is the darwin/arm and darwin/arm64 equivalent to CL 108679, 110215, 110437, 110438, 111258, 110655. Updates #17490 Change-Id: Ia95b27b38f9c3535012c566f17a44b4ed26b9db6 Reviewed-on: https://go-review.googlesource.com/111015 TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
2018-04-30runtime,cmd/ld: on darwin, create theads using libcKeith Randall
Replace thread creation with calls to the pthread library in libc. Update #17490 Change-Id: I1e19965c45255deb849b059231252fc6a7861d6c Reviewed-on: https://go-review.googlesource.com/108679 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-10-20runtime: for kqueue treat EVFILT_READ with EV_EOF as permitting a writeIan Lance Taylor
On systems that use kqueue, we always register descriptors for both EVFILT_READ and EVFILT_WRITE. On at least FreeBSD and OpenBSD, when the write end of a pipe is registered for EVFILT_READ and EVFILT_WRITE events, and the read end of the pipe is closed, kqueue reports an EVFILT_READ event with EV_EOF set, but does not report an EVFILT_WRITE event. Since the write to the pipe is waiting for an EVFILT_WRITE event, closing the read end of a pipe can cause the write end to hang rather than attempt another write which will fail with EPIPE. Fix this by treating EVFILT_READ with EV_EOF set as making both reads and writes ready to proceed. The real test for this is in CL 71770, which tests using various timeouts with pipes. Updates #22114 Change-Id: Ib23fbaaddbccd8eee77bdf18f27a7f0aa50e2742 Reviewed-on: https://go-review.googlesource.com/71973 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2015-12-18runtime: write sigsetstack for Darwin, fix sigaction argIan Lance Taylor
It turns out that the second argument for sigaction on Darwin has a different type than the first argument. The second argument is the user visible sigaction struct, and does not have the sa_tramp field. I base this on http://www.opensource.apple.com/source/Libc/Libc-1081.1.3/sys/sigaction.c not to mention actual testing. While I was at it I removed a useless memclr in setsig, a relic of the C code. This CL is Darwin-specific changes. The tests for this CL are in https://golang.org/cl/17903 . Change-Id: I61fe305c72311df6a589b49ad7b6e49b6960ca24 Reviewed-on: https://go-review.googlesource.com/18015 Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-16runtime: darwin/arm64 supportShenghou Ma
Change-Id: I3b3f80791a1db4c2b7318f81a115972cd2237f03 Signed-off-by: Shenghou Ma <minux@golang.org> Reviewed-on: https://go-review.googlesource.com/8782 Reviewed-by: David Crawshaw <crawshaw@golang.org>