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
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.