Patchwork libgo patch committed: Add syscall.Times

login
register
mail settings
Submitter Ian Taylor
Date Feb. 2, 2012, 6:40 a.m.
Message ID <mcrpqdxbuwh.fsf@dhcp-172-18-216-180.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/139088/
State New
Headers show

Comments

Ian Taylor - Feb. 2, 2012, 6:40 a.m.
This patch to libgo adds the syscall.Times function, which corresponds
to the POSIX function times.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

Patch

diff -r 492a0c57d461 libgo/go/syscall/libcall_posix.go
--- a/libgo/go/syscall/libcall_posix.go	Wed Feb 01 22:22:41 2012 -0800
+++ b/libgo/go/syscall/libcall_posix.go	Wed Feb 01 22:38:30 2012 -0800
@@ -133,15 +133,15 @@ 
 }
 
 func FDSet(fd int, set *FdSet) {
-	set.Bits[fd / nfdbits] |= (1 << (uint)(fd % nfdbits))
+	set.Bits[fd/nfdbits] |= (1 << (uint)(fd%nfdbits))
 }
 
 func FDClr(fd int, set *FdSet) {
-	set.Bits[fd / nfdbits] &^= (1 << (uint)(fd % nfdbits))
+	set.Bits[fd/nfdbits] &^= (1 << (uint)(fd%nfdbits))
 }
 
 func FDIsSet(fd int, set *FdSet) bool {
-	if set.Bits[fd / nfdbits] & (1 << (uint)(fd % nfdbits)) != 0 {
+	if set.Bits[fd/nfdbits]&(1<<(uint)(fd%nfdbits)) != 0 {
 		return true
 	} else {
 		return false
@@ -323,9 +323,8 @@ 
 // //sysnb	Time(t *Time_t) (tt Time_t, err error)
 // //time(t *Time_t) Time_t
 
-// FIXME: mksysinfo Tms
-// //sysnb	Times(tms *Tms) (ticks uintptr, err error)
-// //times(tms *Tms) _clock_t
+//sysnb	Times(tms *Tms) (ticks uintptr, err error)
+//times(tms *Tms) _clock_t
 
 //sysnb	Umask(mask int) (oldmask int)
 //umask(mask Mode_t) Mode_t
diff -r 492a0c57d461 libgo/mksysinfo.sh
--- a/libgo/mksysinfo.sh	Wed Feb 01 22:22:41 2012 -0800
+++ b/libgo/mksysinfo.sh	Wed Feb 01 22:38:30 2012 -0800
@@ -66,6 +66,7 @@ 
 #include <sys/socket.h>
 #include <sys/stat.h>
 #include <sys/time.h>
+#include <sys/times.h>
 #include <sys/wait.h>
 #include <sys/un.h>
 #if defined(HAVE_SYS_USER_H)
@@ -368,6 +369,15 @@ 
         -e 's/tv_nsec *[a-zA-Z0-9_]*/Nsec Timestruc_nsec_t/' >> ${OUT}
 fi
 
+# The tms struct.
+grep '^type _tms ' gen-sysinfo.go | \
+    sed -e 's/type _tms/type Tms/' \
+      -e 's/tms_utime/Utime/' \
+      -e 's/tms_stime/Stime/' \
+      -e 's/tms_cutime/Cutime/' \
+      -e 's/tms_cstime/Cstime/' \
+    >> ${OUT}
+
 # The stat type.
 # Prefer largefile variant if available.
 stat=`grep '^type _stat64 ' gen-sysinfo.go || true`