diff options
Diffstat (limited to 'man3/makecontext.3')
-rw-r--r-- | man3/makecontext.3 | 45 |
1 files changed, 22 insertions, 23 deletions
diff --git a/man3/makecontext.3 b/man3/makecontext.3 index 6cd65e339..c4e237829 100644 --- a/man3/makecontext.3 +++ b/man3/makecontext.3 @@ -6,7 +6,7 @@ .\" .\" 2006-08-02, mtk, Added example program .\" -.TH makecontext 3 2022-12-15 "Linux man-pages 6.03" +.TH makecontext 3 2023-07-20 "Linux man-pages 6.05.01" .SH NAME makecontext, swapcontext \- manipulate user context .SH LIBRARY @@ -85,41 +85,40 @@ to indicate the error. .TP .B ENOMEM Insufficient stack space left. -.SH VERSIONS -.BR makecontext () -and -.BR swapcontext () -are provided since glibc 2.1. .SH ATTRIBUTES For an explanation of the terms used in this section, see .BR attributes (7). -.ad l -.nh .TS allbox; lb lb lbx l l l. Interface Attribute Value T{ +.na +.nh .BR makecontext () T} Thread safety T{ +.na +.nh MT-Safe race:ucp T} T{ +.na +.nh .BR swapcontext () T} Thread safety T{ +.na +.nh MT-Safe race:oucp race:ucp T} .TE -.hy -.ad .sp 1 .SH STANDARDS +None. +.SH HISTORY +glibc 2.1. SUSv2, POSIX.1-2001. -POSIX.1-2008 removes the specifications of -.BR makecontext () -and -.BR swapcontext (), +Removed in POSIX.1-2008, citing portability issues, and recommending that applications be rewritten to use POSIX threads instead. .SH NOTES @@ -174,12 +173,12 @@ main: exiting #include <stdio.h> #include <stdlib.h> #include <ucontext.h> - +\& static ucontext_t uctx_main, uctx_func1, uctx_func2; - +\& #define handle_error(msg) \e do { perror(msg); exit(EXIT_FAILURE); } while (0) - +\& static void func1(void) { @@ -189,7 +188,7 @@ func1(void) handle_error("swapcontext"); printf("%s: returning\en", __func__); } - +\& static void func2(void) { @@ -199,20 +198,20 @@ func2(void) handle_error("swapcontext"); printf("%s: returning\en", __func__); } - +\& int main(int argc, char *argv[]) { char func1_stack[16384]; char func2_stack[16384]; - +\& if (getcontext(&uctx_func1) == \-1) handle_error("getcontext"); uctx_func1.uc_stack.ss_sp = func1_stack; uctx_func1.uc_stack.ss_size = sizeof(func1_stack); uctx_func1.uc_link = &uctx_main; makecontext(&uctx_func1, func1, 0); - +\& if (getcontext(&uctx_func2) == \-1) handle_error("getcontext"); uctx_func2.uc_stack.ss_sp = func2_stack; @@ -220,11 +219,11 @@ main(int argc, char *argv[]) /* Successor context is f1(), unless argc > 1 */ uctx_func2.uc_link = (argc > 1) ? NULL : &uctx_func1; makecontext(&uctx_func2, func2, 0); - +\& printf("%s: swapcontext(&uctx_main, &uctx_func2)\en", __func__); if (swapcontext(&uctx_main, &uctx_func2) == \-1) handle_error("swapcontext"); - +\& printf("%s: exiting\en", __func__); exit(EXIT_SUCCESS); } |