]> Cypherpunks repositories - gostls13.git/commitdiff
syscall: add {Set,Get}priority for Linux, and consistency tests
authorShenghou Ma <minux.ma@gmail.com>
Mon, 10 Jun 2013 18:47:04 +0000 (02:47 +0800)
committerShenghou Ma <minux.ma@gmail.com>
Mon, 10 Jun 2013 18:47:04 +0000 (02:47 +0800)
R=golang-dev, iant, bradfitz, dave
CC=golang-dev
https://golang.org/cl/7430044

19 files changed:
src/pkg/syscall/consistency_unix_test.go [new file with mode: 0644]
src/pkg/syscall/mkerrors.sh
src/pkg/syscall/syscall_linux.go
src/pkg/syscall/zerrors_darwin_386.go
src/pkg/syscall/zerrors_darwin_amd64.go
src/pkg/syscall/zerrors_freebsd_386.go
src/pkg/syscall/zerrors_freebsd_amd64.go
src/pkg/syscall/zerrors_freebsd_arm.go
src/pkg/syscall/zerrors_linux_386.go
src/pkg/syscall/zerrors_linux_amd64.go
src/pkg/syscall/zerrors_linux_arm.go
src/pkg/syscall/zerrors_netbsd_386.go
src/pkg/syscall/zerrors_netbsd_amd64.go
src/pkg/syscall/zerrors_netbsd_arm.go
src/pkg/syscall/zerrors_openbsd_386.go
src/pkg/syscall/zerrors_openbsd_amd64.go
src/pkg/syscall/zsyscall_linux_386.go
src/pkg/syscall/zsyscall_linux_amd64.go
src/pkg/syscall/zsyscall_linux_arm.go

diff --git a/src/pkg/syscall/consistency_unix_test.go b/src/pkg/syscall/consistency_unix_test.go
new file mode 100644 (file)
index 0000000..d2416c1
--- /dev/null
@@ -0,0 +1,25 @@
+// Copyright 2013 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.
+
+// +build freebsd darwin linux netbsd openbsd
+
+// This file tests that some basic syscalls are consistent across
+// all Unixes.
+
+package syscall_test
+
+import "syscall"
+
+// {Set,Get}priority and needed constants for them
+func _() {
+       var (
+               _ func(int, int, int) error   = syscall.Setpriority
+               _ func(int, int) (int, error) = syscall.Getpriority
+       )
+       const (
+               _ int = syscall.PRIO_USER
+               _ int = syscall.PRIO_PROCESS
+               _ int = syscall.PRIO_PGRP
+       )
+}
index 66cb690c7a30407f465d78435a55acbed7cef1e7..1492c82937187e61b1be2e0d779d55a82a2a5c39 100755 (executable)
@@ -71,6 +71,7 @@ includes_Linux='
 #include <sys/prctl.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <sys/time.h>
 #include <sys/socket.h>
 #include <linux/if_addr.h>
 #include <linux/if_ether.h>
@@ -222,6 +223,7 @@ ccflags="$@"
                $2 ~ /^BIOC/ ||
                $2 ~ /^RUSAGE_(SELF|CHILDREN|THREAD)/ ||
                $2 ~ /^RLIMIT_(AS|CORE|CPU|DATA|FSIZE|NOFILE|STACK)|RLIM_INFINITY/ ||
+               $2 ~ /^PRIO_(PROCESS|PGRP|USER)/ ||
                $2 !~ /^(BPF_TIMEVAL)$/ &&
                $2 ~ /^(BPF|DLT)_/ ||
                $2 !~ "WMESGLEN" &&
index 391d80e5fba2109b0fa44190edfe8ef040418249..6cd047ef1f8490a340d4c9d996edfa040ed5362b 100644 (file)
@@ -926,6 +926,7 @@ func Mount(source string, target string, fstype string, flags uintptr, data stri
 //sysnb        Getpgrp() (pid int)
 //sysnb        Getpid() (pid int)
 //sysnb        Getppid() (ppid int)
+//sys  Getpriority(which int, who int) (prio int, err error)
 //sysnb        Getrusage(who int, rusage *Rusage) (err error)
 //sysnb        Gettid() (tid int)
 //sys  Getxattr(path string, attr string, dest []byte) (sz int, err error)
@@ -957,6 +958,7 @@ func Mount(source string, target string, fstype string, flags uintptr, data stri
 //sysnb        Setsid() (pid int, err error)
 //sysnb        Settimeofday(tv *Timeval) (err error)
 //sysnb        Setuid(uid int) (err error)
+//sys  Setpriority(which int, who int, prio int) (err error)
 //sys  Setxattr(path string, attr string, data []byte, flags int) (err error)
 //sys  Symlink(oldpath string, newpath string) (err error)
 //sys  Sync()
@@ -1036,7 +1038,6 @@ func Munmap(b []byte) (err error) {
 // GetThreadArea
 // Getitimer
 // Getpmsg
-// Getpriority
 // IoCancel
 // IoDestroy
 // IoGetevents
@@ -1112,7 +1113,6 @@ func Munmap(b []byte) (err error) {
 // SetRobustList
 // SetThreadArea
 // SetTidAddress
-// Setpriority
 // Shmat
 // Shmctl
 // Shmdt
index 29e6190a92ee5b99b8699af87047d968ffa81353..bb3a1610c0c68b5fcd4d849d645ddf87ff251789 100644 (file)
@@ -747,6 +747,9 @@ const (
        PARMRK                            = 0x8
        PARODD                            = 0x2000
        PENDIN                            = 0x20000000
+       PRIO_PGRP                         = 0x1
+       PRIO_PROCESS                      = 0x0
+       PRIO_USER                         = 0x2
        PROT_EXEC                         = 0x4
        PROT_NONE                         = 0x0
        PROT_READ                         = 0x1
index db02b6a541380995eeffda272706a3243c071409..05ab48ee3292344061fd0541baf3668e839ffd16 100644 (file)
@@ -747,6 +747,9 @@ const (
        PARMRK                            = 0x8
        PARODD                            = 0x2000
        PENDIN                            = 0x20000000
+       PRIO_PGRP                         = 0x1
+       PRIO_PROCESS                      = 0x0
+       PRIO_USER                         = 0x2
        PROT_EXEC                         = 0x4
        PROT_NONE                         = 0x0
        PROT_READ                         = 0x1
index 55f255a54b827f6f11747880d3fb29848238c373..24af6ab09b8712e602baa50dab58c739a3adde0e 100644 (file)
@@ -1089,6 +1089,9 @@ const (
        PARMRK                            = 0x8
        PARODD                            = 0x2000
        PENDIN                            = 0x20000000
+       PRIO_PGRP                         = 0x1
+       PRIO_PROCESS                      = 0x0
+       PRIO_USER                         = 0x2
        PROT_EXEC                         = 0x4
        PROT_NONE                         = 0x0
        PROT_READ                         = 0x1
index ab92a94920b1ca6a7271ecd1cc01cc33e301a274..d766cd13a08d4c6ed094accdf4139b14de6af1a3 100644 (file)
@@ -1089,6 +1089,9 @@ const (
        PARMRK                            = 0x8
        PARODD                            = 0x2000
        PENDIN                            = 0x20000000
+       PRIO_PGRP                         = 0x1
+       PRIO_PROCESS                      = 0x0
+       PRIO_USER                         = 0x2
        PROT_EXEC                         = 0x4
        PROT_NONE                         = 0x0
        PROT_READ                         = 0x1
index 29d92be2ecdc7e321f1c01272cfb96717cce1967..269f179b3097f614eac39a7b20ab6c7a4e9d58b7 100644 (file)
@@ -1094,6 +1094,9 @@ const (
        PARMRK                            = 0x8
        PARODD                            = 0x2000
        PENDIN                            = 0x20000000
+       PRIO_PGRP                         = 0x1
+       PRIO_PROCESS                      = 0x0
+       PRIO_USER                         = 0x2
        PROT_EXEC                         = 0x4
        PROT_NONE                         = 0x0
        PROT_READ                         = 0x1
index 9510cccd6daa4a5edb402fb63a101a4d64c3d59c..ea568ce4e3797b8461f6e6922ebae787564586d8 100644 (file)
@@ -658,6 +658,9 @@ const (
        PACKET_RECV_OUTPUT               = 0x3
        PACKET_RX_RING                   = 0x5
        PACKET_STATISTICS                = 0x6
+       PRIO_PGRP                        = 0x1
+       PRIO_PROCESS                     = 0x0
+       PRIO_USER                        = 0x2
        PROT_EXEC                        = 0x4
        PROT_GROWSDOWN                   = 0x1000000
        PROT_GROWSUP                     = 0x2000000
index 7435155e2057491d1e5c0ed9c6d6c78c64d7f95c..337dc62d1b35b4ead7e48464ffd49ae18b1634e0 100644 (file)
@@ -658,6 +658,9 @@ const (
        PACKET_RECV_OUTPUT               = 0x3
        PACKET_RX_RING                   = 0x5
        PACKET_STATISTICS                = 0x6
+       PRIO_PGRP                        = 0x1
+       PRIO_PROCESS                     = 0x0
+       PRIO_USER                        = 0x2
        PROT_EXEC                        = 0x4
        PROT_GROWSDOWN                   = 0x1000000
        PROT_GROWSUP                     = 0x2000000
index fe54fe72d9d3669e9547e8e5e0de0977d00423f2..51e3b927194dbbfc42f983182b4e978e074567e6 100644 (file)
@@ -654,6 +654,9 @@ const (
        PACKET_RECV_OUTPUT               = 0x3
        PACKET_RX_RING                   = 0x5
        PACKET_STATISTICS                = 0x6
+       PRIO_PGRP                        = 0x1
+       PRIO_PROCESS                     = 0x0
+       PRIO_USER                        = 0x2
        PROT_EXEC                        = 0x4
        PROT_GROWSDOWN                   = 0x1000000
        PROT_GROWSUP                     = 0x2000000
index c0ef19fdda4bfebf7b0a234dd50188f396417b3c..9b93f5a1548a70b0ea4a1626d5a1af794c1d0c1a 100644 (file)
@@ -1040,6 +1040,9 @@ const (
        PARODD                            = 0x2000
        PENDIN                            = 0x20000000
        PRI_IOFLUSH                       = 0x7c
+       PRIO_PGRP                         = 0x1
+       PRIO_PROCESS                      = 0x0
+       PRIO_USER                         = 0x2
        RLIMIT_AS                         = 0xa
        RLIMIT_CORE                       = 0x4
        RLIMIT_CPU                        = 0x0
index e4f5a903f4c942172bb24757971e955e5c0a9c0c..4db30fa5ce480691dbdac1822cef8fbe9704c40d 100644 (file)
@@ -1030,6 +1030,9 @@ const (
        PARODD                            = 0x2000
        PENDIN                            = 0x20000000
        PRI_IOFLUSH                       = 0x7c
+       PRIO_PGRP                         = 0x1
+       PRIO_PROCESS                      = 0x0
+       PRIO_USER                         = 0x2
        RLIMIT_AS                         = 0xa
        RLIMIT_CORE                       = 0x4
        RLIMIT_CPU                        = 0x0
index 3264cef89dd3297cce48105e729480cf8762a7aa..9262d5afb71d9dfd3acc0b332d15513a858df669 100644 (file)
@@ -1030,6 +1030,9 @@ const (
        PARODD                            = 0x2000
        PENDIN                            = 0x20000000
        PRI_IOFLUSH                       = 0x7c
+       PRIO_PGRP                         = 0x1
+       PRIO_PROCESS                      = 0x0
+       PRIO_USER                         = 0x2
        RLIMIT_AS                         = 0xa
        RLIMIT_CORE                       = 0x4
        RLIMIT_CPU                        = 0x0
index 003958efaf836b4c95a2021754dc24941a19c31e..e546243b07bee67f52aba6cb7f73e5ace6c6af6d 100644 (file)
@@ -927,6 +927,9 @@ const (
        PENDIN                            = 0x20000000
        PF_FLUSH                          = 0x1
        PT_MASK                           = 0x3ff000
+       PRIO_PGRP                         = 0x1
+       PRIO_PROCESS                      = 0x0
+       PRIO_USER                         = 0x2
        RLIMIT_CORE                       = 0x4
        RLIMIT_CPU                        = 0x0
        RLIMIT_DATA                       = 0x2
index 7c53ceca69bea97ad9e16af79c7e948462e14d2c..411b51a68c0ab0e8edd2b575f678c7c89561ef04 100644 (file)
@@ -933,6 +933,9 @@ const (
        PENDIN                            = 0x20000000
        PF_FLUSH                          = 0x1
        PMC5_PIPELINE_FLUSH               = 0x15
+       PRIO_PGRP                         = 0x1
+       PRIO_PROCESS                      = 0x0
+       PRIO_USER                         = 0x2
        RLIMIT_CORE                       = 0x4
        RLIMIT_CPU                        = 0x0
        RLIMIT_DATA                       = 0x2
index 3f0470c988d1946309286dc63a35b4cf90310b30..810cba00425df52e690182b00c1a454e85f8a28a 100644 (file)
@@ -534,6 +534,17 @@ func Getppid() (ppid int) {
 
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
+func Getpriority(which int, who int) (prio int, err error) {
+       r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0)
+       prio = int(r0)
+       if e1 != 0 {
+               err = e1
+       }
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
 func Getrusage(who int, rusage *Rusage) (err error) {
        _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
        if e1 != 0 {
@@ -994,6 +1005,16 @@ func Setuid(uid int) (err error) {
 
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
+func Setpriority(which int, who int, prio int) (err error) {
+       _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio))
+       if e1 != 0 {
+               err = e1
+       }
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
 func Setxattr(path string, attr string, data []byte, flags int) (err error) {
        var _p0 *byte
        _p0, err = BytePtrFromString(path)
index 43f24e7731d76ed2952f54dab59151e193772731..9978b81383d158120a454b389c6a520e9c418f7d 100644 (file)
@@ -534,6 +534,17 @@ func Getppid() (ppid int) {
 
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
+func Getpriority(which int, who int) (prio int, err error) {
+       r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0)
+       prio = int(r0)
+       if e1 != 0 {
+               err = e1
+       }
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
 func Getrusage(who int, rusage *Rusage) (err error) {
        _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
        if e1 != 0 {
@@ -994,6 +1005,16 @@ func Setuid(uid int) (err error) {
 
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
+func Setpriority(which int, who int, prio int) (err error) {
+       _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio))
+       if e1 != 0 {
+               err = e1
+       }
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
 func Setxattr(path string, attr string, data []byte, flags int) (err error) {
        var _p0 *byte
        _p0, err = BytePtrFromString(path)
index 804821eb3fc3caffaae0cc0da6ddff29c24f810c..80d3f9b39deda44ade85f8e1769d88b4ac53ffe3 100644 (file)
@@ -534,6 +534,17 @@ func Getppid() (ppid int) {
 
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
+func Getpriority(which int, who int) (prio int, err error) {
+       r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0)
+       prio = int(r0)
+       if e1 != 0 {
+               err = e1
+       }
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
 func Getrusage(who int, rusage *Rusage) (err error) {
        _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
        if e1 != 0 {
@@ -994,6 +1005,16 @@ func Setuid(uid int) (err error) {
 
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
+func Setpriority(which int, who int, prio int) (err error) {
+       _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio))
+       if e1 != 0 {
+               err = e1
+       }
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
 func Setxattr(path string, attr string, data []byte, flags int) (err error) {
        var _p0 *byte
        _p0, err = BytePtrFromString(path)