Patchwork libgo patch committed: Add gettid on GNU/Linux

login
register
mail settings
Submitter Ian Taylor
Date Jan. 31, 2012, 8:48 p.m.
Message ID <mcrk447ha2z.fsf@dhcp-172-18-216-180.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/138860/
State New
Headers show

Comments

Ian Taylor - Jan. 31, 2012, 8:48 p.m.
This patch to libgo adds support for syscall.Gettid on GNU/Linux.  The
function is different becase it is not in libc, but must be invoked via
Syscall.  Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.

Ian

Patch

diff -r 351201702211 libgo/go/syscall/libcall_linux.go
--- a/libgo/go/syscall/libcall_linux.go	Tue Jan 31 06:21:32 2012 -0800
+++ b/libgo/go/syscall/libcall_linux.go	Tue Jan 31 11:49:40 2012 -0800
@@ -195,9 +195,10 @@ 
 // //sys	Fstatfs(fd int, buf *Statfs_t) (err error)
 // //fstatfs(fd int, buf *Statfs_t) int
 
-// FIXME: Only available as a syscall.
-// //sysnb	Gettid() (tid int)
-// //gettid() Pid_t
+func Gettid() (tid int) {
+	r1, _, _ := Syscall(SYS_GETTID, 0, 0, 0)
+	return int(r1)
+}
 
 // FIXME: mksysinfo linux_dirent
 //    Or just abandon this function.