xref: /openbsd-src/lib/libarch/i386/i386_get_fsbase.2 (revision d13be5d47e4149db2549a9828e244d59dbc43f15)
1.\"	$OpenBSD: i386_get_fsbase.2,v 1.1 2011/03/12 04:12:29 guenther Exp $
2.\"	$NetBSD: i386_get_ioperm.2,v 1.3 1996/02/27 22:57:17 jtc Exp $
3.\"
4.\" Copyright (c) 1996 The NetBSD Foundation, Inc.
5.\" All rights reserved.
6.\"
7.\" This code is derived from software contributed to The NetBSD Foundation
8.\" by John T. Kohl and Charles M. Hannum.
9.\"
10.\" Redistribution and use in source and binary forms, with or without
11.\" modification, are permitted provided that the following conditions
12.\" are met:
13.\" 1. Redistributions of source code must retain the above copyright
14.\"    notice, this list of conditions and the following disclaimer.
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\"    notice, this list of conditions and the following disclaimer in the
17.\"    documentation and/or other materials provided with the distribution.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
23.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29.\" POSSIBILITY OF SUCH DAMAGE.
30.\"
31.Dd $Mdocdate: March 12 2011 $
32.Dt I386_GET_FSBASE 2 i386
33.Os
34.Sh NAME
35.Nm i386_get_fsbase ,
36.Nm i386_set_fsbase
37.Nd manage i386 per-thread %fs base address
38.Sh SYNOPSIS
39.Fd #include <sys/types.h>
40.Fd #include <machine/sysarch.h>
41.Ft int
42.Fn i386_get_fsbase "void **base"
43.Ft int
44.Fn i386_set_fsbase "void *base"
45.Sh DESCRIPTION
46.Fn i386_get_fsbase
47copies the current base address of the segment that, by default,
48is referenced by the %fs selector into the memory referenced by
49.Fa base .
50.Pp
51.Fn i386_set_fsbase
52sets the base address of the segment that, by default, is referenced
53by %fs to the address
54.Fa base .
55.Pp
56When rfork(RFPROC | RFTHREAD) is used, the segment base address
57for the above calls is a per-thread value.
58When a new thread is created,
59it inherits the base from the thread that created it.
60.Pp
61.Sy Note:
62Code using the
63.Fn i386_get_fsbase
64and
65.Fn i386_set_fsbase
66functions must be compiled using
67.Cm -li386 .
68.Sh RETURN VALUES
69Upon successful completion,
70.Fn i386_get_fsbase
71and
72.Fn i386_set_fsbase
73return 0.
74Otherwise, a value of \-1 is returned and the global variable
75.Va errno
76is set to indicate the error.
77.Sh ERRORS
78.Fn i386_get_fsbase
79will fail if:
80.Bl -tag -width [EINVAL]
81.It Bq Er EFAULT
82.Fa base
83points outside the process's allocated address space.
84.El
85.Sh SEE ALSO
86.Rs
87.%A Intel
88.%T i386 Microprocessor Programmer's Reference Manual
89.Re
90