diff options
author | kib <kib@FreeBSD.org> | 2012-01-21 18:00:28 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2012-01-21 18:00:28 +0000 |
commit | 8c121450bcfa7aaf7c661baf2809bafc48c1f60f (patch) | |
tree | 4806ea5a2bf8eb5da87e290d16da86d5e5f5222f /lib/libc/gen | |
parent | 3572bdc783bebdf33330a1218e74826c4096ae81 (diff) | |
download | FreeBSD-src-8c121450bcfa7aaf7c661baf2809bafc48c1f60f.zip FreeBSD-src-8c121450bcfa7aaf7c661baf2809bafc48c1f60f.tar.gz |
Add API for obtaining extended machine context states that cannot be
fit into existing mcontext_t.
On i386 and amd64 do return the extended FPU states using
getcontextx(3). For other architectures, getcontextx(3) returns the
same information as getcontext(2).
Tested by: pho
MFC after: 1 month
Diffstat (limited to 'lib/libc/gen')
-rw-r--r-- | lib/libc/gen/Symbol.map | 3 | ||||
-rw-r--r-- | lib/libc/gen/getcontext.3 | 31 | ||||
-rw-r--r-- | lib/libc/gen/ucontext.3 | 4 |
3 files changed, 36 insertions, 2 deletions
diff --git a/lib/libc/gen/Symbol.map b/lib/libc/gen/Symbol.map index e00e746..d794c0a 100644 --- a/lib/libc/gen/Symbol.map +++ b/lib/libc/gen/Symbol.map @@ -384,6 +384,7 @@ FBSD_1.2 { FBSD_1.3 { fdlopen; __FreeBSD_libc_enter_restricted_mode; + getcontextx; }; FBSDprivate_1.0 { @@ -507,4 +508,6 @@ FBSDprivate_1.0 { __elf_aux_vector; __pthread_map_stacks_exec; + __fillcontextx; + __getcontextx_size; }; diff --git a/lib/libc/gen/getcontext.3 b/lib/libc/gen/getcontext.3 index 2fda6b8..5b801fd 100644 --- a/lib/libc/gen/getcontext.3 +++ b/lib/libc/gen/getcontext.3 @@ -35,11 +35,11 @@ .\" .\" $FreeBSD$ .\" -.Dd September 10, 2002 +.Dd December 26, 2011 .Dt GETCONTEXT 3 .Os .Sh NAME -.Nm getcontext , setcontext +.Nm getcontext , getcontextx , setcontext .Nd get and set user thread context .Sh LIBRARY .Lb libc @@ -59,6 +59,20 @@ This saved context may then later be restored by calling .Fn setcontext . .Pp The +.Fn getcontextx +function saves the current execution context in the newly allocated structure +.Vt ucontext_t , +which is returned on success. +If architecture defines additional CPU states that can be stored in extended +blocks referenced from the +.Vt ucontext_t , +the memory for them may be allocated and their context also stored. +Memory returned by +.Fn getcontextx +function shall be freed using +.Fn free 3 . +.Pp +The .Fn setcontext function makes a previously saved thread context the current thread context, i.e., @@ -109,11 +123,24 @@ If successful, returns zero and .Fn setcontext does not return; otherwise \-1 is returned. +The +.Fn getcontextx +returns pointer to the allocated and initialized context on success, and +.Va NULL +on failure. .Sh ERRORS No errors are defined for .Fn getcontext or .Fn setcontext . +The +.Fn getcontextx +may return the following errors in +.Va errno : +.Bl -tag -width Er +.It Bq Er ENOMEM +No memory was available to allocate for the context or some extended state. +.El .Sh SEE ALSO .Xr sigaction 2 , .Xr sigaltstack 2 , diff --git a/lib/libc/gen/ucontext.3 b/lib/libc/gen/ucontext.3 index 0574322..69ecbc1 100644 --- a/lib/libc/gen/ucontext.3 +++ b/lib/libc/gen/ucontext.3 @@ -92,6 +92,9 @@ structures: .Ft int .Fn getcontext "ucontext_t *" ; .It +.Ft "ucontext_t *" +.Fn getcontextx "void" ; +.It .Ft int .Fn setcontext "const ucontext_t *" ; .It @@ -104,4 +107,5 @@ structures: .Sh SEE ALSO .Xr sigaltstack 2 , .Xr getcontext 3 , +.Xr getcontextx 3 , .Xr makecontext 3 |