I386_GET_FSBASE(2)

NAME
i386_get_fsbase, i386_set_fsbase - manage i386 per-thread %fs base address

SYNOPSIS
#include <sys/types.h>
#include <machine/sysarch.h>
int
i386_get_fsbase(void **base);
int
i386_set_fsbase(void *base);

DESCRIPTION
i386_get_fsbase() copies the current base address of the segment that, by default, is referenced by the %fs selector into the memory referenced by base.

i386_set_fsbase() sets the base address of the segment that, by default, is referenced by %fs to the address base.

When rfork(RFPROC | RFTHREAD) is used, the segment base address for the above calls is a per-thread value. When a new thread is created, it inherits the base from the thread that created it.

Note: Code using the i386_get_fsbase() and i386_set_fsbase() functions must be compiled using -li386.

RETURN VALUES
Upon successful completion, i386_get_fsbase() and i386_set_fsbase() return 0. Otherwise, a value of -1 is returned and the global variable errno is set to indicate the error.

ERRORS
i386_get_fsbase() will fail if:

[EFAULT]
    base points outside the process's allocated address space.

SEE ALSO
Intel, i386 Microprocessor Programmer's Reference Manual.