]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: add syscalls needed for android/amd64 logging.
authorHyang-Ah Hana Kim <hyangah@gmail.com>
Fri, 16 Oct 2015 18:17:25 +0000 (14:17 -0400)
committerHyang-Ah Hana Kim <hyangah@gmail.com>
Tue, 20 Oct 2015 16:56:58 +0000 (16:56 +0000)
access, connect, socket.

In Android-L, logging is done by writing the log messages to the logd
process through a unix domain socket.

Also, changed the arg types of those syscall stubs to match linux
programming APIs.

For golang/go#10743

Change-Id: I66368a03316e253561e9e76aadd180c2cd2e48f3
Reviewed-on: https://go-review.googlesource.com/15993
Reviewed-by: David Crawshaw <crawshaw@golang.org>
src/runtime/defs_linux_amd64.go
src/runtime/print1_write_android.go
src/runtime/stubs_android.go
src/runtime/sys_linux_amd64.s

index 48aeb8020334889555e273b16fe3d689967efdff..19362855e76c2aafb702644790185c4149742d5f 100644 (file)
@@ -87,6 +87,10 @@ const (
        _EPOLL_CTL_ADD = 0x1
        _EPOLL_CTL_DEL = 0x2
        _EPOLL_CTL_MOD = 0x3
+
+       _AF_UNIX    = 0x1
+       _F_SETFL    = 0x4
+       _SOCK_DGRAM = 0x2
 )
 
 type timespec struct {
@@ -253,3 +257,8 @@ type sigcontext struct {
        fpstate     *fpstate1
        __reserved1 [8]uint64
 }
+
+type sockaddr_un struct {
+       family uint16
+       path   [108]byte
+}
index 54d4826375e7114c73c123ebdd9fae1ad628f3d8..4411a1475548994e4cf2e990fb5bf90bb3c1456b 100644 (file)
@@ -116,7 +116,7 @@ func initLogd() {
                exit(2)
        }
 
-       errno := connect(uintptr(fd), unsafe.Pointer(&logdAddr), int32(unsafe.Sizeof(logdAddr)))
+       errno := connect(fd, unsafe.Pointer(&logdAddr), int32(unsafe.Sizeof(logdAddr)))
        if errno < 0 {
                msg := []byte("runtime: cannot connect to /dev/socket/logdw\x00")
                write(2, unsafe.Pointer(&msg[0]), int32(len(msg)))
index e3723778d9a69c49543540677fdd123e0aac2783..0380dca8919dff6adbe9df4e9b517c9fcccb9a2c 100644 (file)
@@ -2,9 +2,15 @@ package runtime
 
 import "unsafe"
 
+// Return values of access/connect/socket are the return values of the syscall
+// (may encode error numbers).
+
+// int access(const char *, int)
 //go:noescape
 func access(name *byte, mode int32) int32
 
-func connect(fd uintptr, addr unsafe.Pointer, len int32) int32
+// int connect(int, const struct sockaddr*, socklen_t)
+func connect(fd int32, addr unsafe.Pointer, len int32) int32
 
+// int socket(int, int, int)
 func socket(domain int32, typ int32, prot int32) int32
index 7ad704f3066efd3c78dbb05bf8da644c5e4fe444..df72a77afc345cb98b47eaa9b84ea65990f7f5cf 100644 (file)
@@ -442,3 +442,33 @@ TEXT runtime·closeonexec(SB),NOSPLIT,$0
        MOVL    $72, AX  // fcntl
        SYSCALL
        RET
+
+
+// int access(const char *name, int mode)
+TEXT runtime·access(SB),NOSPLIT,$0
+       MOVQ    name+0(FP), DI
+       MOVL    mode+8(FP), SI
+       MOVL    $21, AX  // syscall entry
+       SYSCALL
+       MOVL    AX, ret+16(FP)
+       RET
+
+// int connect(int fd, const struct sockaddr *addr, socklen_t addrlen)
+TEXT runtime·connect(SB),NOSPLIT,$0-28
+       MOVL    fd+0(FP), DI
+       MOVQ    addr+8(FP), SI
+       MOVL    addrlen+16(FP), DX
+       MOVL    $42, AX  // syscall entry
+       SYSCALL
+       MOVL    AX, ret+24(FP)
+       RET
+
+// int socket(int domain, int type, int protocol)
+TEXT runtime·socket(SB),NOSPLIT,$0-20
+       MOVL    domain+0(FP), DI
+       MOVL    type+4(FP), SI
+       MOVL    protocol+8(FP), DX
+       MOVL    $41, AX  // syscall entry
+       SYSCALL
+       MOVL    AX, ret+16(FP)
+       RET