summaryrefslogtreecommitdiff
path: root/lib/libc/sys
diff options
context:
space:
mode:
authorPhilip Guenthe <guenther@cvs.openbsd.org>2011-10-16 06:21:53 +0000
committerPhilip Guenthe <guenther@cvs.openbsd.org>2011-10-16 06:21:53 +0000
commit2a45f95d13665d24e0b297ff465f09d691dfb1bf (patch)
tree9d57b98c5c200efda13e826ed52ff15a91d2f197 /lib/libc/sys
parente9b2dbe5695582d77448b8fa0769c97400629b97 (diff)
Add stubs and manpage for __{get,set}_tcb
ok deraadt@
Diffstat (limited to 'lib/libc/sys')
-rw-r--r--lib/libc/sys/Makefile.inc7
-rw-r--r--lib/libc/sys/__get_tcb.264
2 files changed, 68 insertions, 3 deletions
diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc
index 4dfab7d3b9c..9c7618565ff 100644
--- a/lib/libc/sys/Makefile.inc
+++ b/lib/libc/sys/Makefile.inc
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile.inc,v 1.94 2011/07/18 23:04:40 matthew Exp $
+# $OpenBSD: Makefile.inc,v 1.95 2011/10/16 06:21:52 guenther Exp $
# $NetBSD: Makefile.inc,v 1.35 1995/10/16 23:49:07 jtc Exp $
# @(#)Makefile.inc 8.1 (Berkeley) 6/17/93
@@ -67,7 +67,7 @@ ASM= accept.o access.o acct.o adjfreq.o adjtime.o bind.o chdir.o chflags.o \
utimes.o wait4.o write.o writev.o nnpfspioctl.o __semctl.o \
__syscall.o __sysctl.o __getcwd.o sched_yield.o getthrid.o \
thrsleep.o thrwakeup.o threxit.o thrsigdivert.o \
- setrtable.o getrtable.o \
+ setrtable.o getrtable.o __set_tcb.o __get_tcb.o \
openat.o fchmodat.o fstatat.o mkdirat.o mkfifoat.o mknodat.o \
faccessat.o fchownat.o linkat.o readlinkat.o renameat.o symlinkat.o \
unlinkat.o utimensat.o futimens.o
@@ -222,7 +222,7 @@ MAN+= accept.2 access.2 acct.2 adjfreq.2 adjtime.2 bind.2 brk.2 chdir.2 \
dup.2 execve.2 _exit.2 fcntl.2 fhopen.2 \
flock.2 fork.2 fsync.2 getdirentries.2 \
getfh.2 getfsstat.2 getgid.2 getgroups.2 getitimer.2 getlogin.2 \
- getpeername.2 getpgrp.2 getrtable.2 \
+ getpeername.2 getpgrp.2 getrtable.2 __get_tcb.2 \
getpid.2 getpriority.2 getrlimit.2 getrusage.2 getsid.2 getsockname.2 \
getsockopt.2 gettimeofday.2 getuid.2 intro.2 issetugid.2 ioctl.2 \
kill.2 kqueue.2 ktrace.2 link.2 \
@@ -266,6 +266,7 @@ MLINKS+=getpriority.2 setpriority.2
MLINKS+=getrlimit.2 setrlimit.2
MLINKS+=getsockopt.2 setsockopt.2
MLINKS+=getrtable.2 setrtable.2
+MLINKS+=__get_tcb.2 __set_tcb.2
MLINKS+=gettimeofday.2 settimeofday.2
MLINKS+=getuid.2 geteuid.2
MLINKS+=kqueue.2 kevent.2 kqueue.2 EV_SET.2
diff --git a/lib/libc/sys/__get_tcb.2 b/lib/libc/sys/__get_tcb.2
new file mode 100644
index 00000000000..6cd28d53fad
--- /dev/null
+++ b/lib/libc/sys/__get_tcb.2
@@ -0,0 +1,64 @@
+.\" $OpenBSD: __get_tcb.2,v 1.1 2011/10/16 06:21:52 guenther Exp $
+.\"
+.\" Copyright (c) 2011 Philip Guenther <guenther@openbsd.org>
+.\"
+.\" Permission to use, copy, modify, and distribute this software for any
+.\" purpose with or without fee is hereby granted, provided that the above
+.\" copyright notice and this permission notice appear in all copies.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+.\"
+.Dd $Mdocdate: October 16 2011 $
+.Dt __GET_TCB 2
+.Os
+.Sh NAME
+.Nm __get_tcb ,
+.Nm __set_tcb
+.Nd "get and set the address of the thread-control-block of the current thread"
+.Sh SYNOPSIS
+.Ft void *
+.Fn __get_tcb "void"
+.Ft void
+.Fn __set_tcb "void *"
+.Sh DESCRIPTION
+The
+.Fn __get_tcb
+and
+.Fn __set_tcb
+are for use by librthread and other parts of the system runtime to
+retrieve and set the address of the current thread's TCB
+(thread-control-block).
+This is used to locate per-thread data such as
+.Va errno .
+Each kernel-level thread in a process has a separate value for this
+address which can be obtained and changed via these system calls.
+New threads (including the first thread of a new process) created using
+.Xr fork 2 ,
+.Xr vfork 2 ,
+or
+.Xr rfork 2 ,
+start with this address set to zero.
+Similarly,
+.Xr execve 2
+resets it to zero.
+.Pp
+On some platforms, this address is also directly mapped to a CPU
+register which can be accessed from userspace.
+.Sh RETURN VALUES
+.Fn __get_tcb
+returns the address of the thread-control-block of the current thread.
+.Sh SEE ALSO
+.Xr rfork 2
+.Sh HISTORY
+The
+.Fn __get_tcb
+and
+.Fn __set_tcb
+system calls appeared in
+.Ox 5.1 .