Print this page
15254 %ymm registers not restored after signal handler
15367 x86 getfpregs() summons corrupting %xmm ghosts
15333 want x86 /proc xregs support (libc_db, libproc, mdb, etc.)
15336 want libc functions for extended ucontext_t
15334 want ps_lwphandle-specific reg routines
15328 FPU_CW_INIT mistreats reserved bit
15335 i86pc fpu_subr.c isn't really platform-specific
15332 setcontext(2) isn't actually noreturn
15331 need <sys/stdalign.h>
Change-Id: I7060aa86042dfb989f77fc3323c065ea2eafa9ad
Conflicts:
usr/src/uts/common/fs/proc/prcontrol.c
usr/src/uts/intel/os/archdep.c
usr/src/uts/intel/sys/ucontext.h
usr/src/uts/intel/syscall/getcontext.c
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/man/man3c/makecontext.3c.man.txt
+++ new/usr/src/man/man3c/makecontext.3c.man.txt
1 1 MAKECONTEXT(3C) Standard C Library Functions MAKECONTEXT(3C)
2 2
3 3 NAME
4 - makecontext, swapcontext - manipulate user contexts
4 + makecontext, swapcontext, swapcontext_extd - manipulate user contexts
5 5
6 6 SYNOPSIS
7 - #include <ucontext.h>
7 + #include <ucontext.h>
8 8
9 - void makecontext(ucontext_t *ucp, void (*func)(), int argc...);
9 + void
10 + makecontext(ucontext_t *ucp, void (*ifunc)(), int argc, ...);
10 11
12 + int
13 + swapcontext(ucontext_t *restrict oucp, const ucontext_t *restrict ucp);
11 14
12 - int swapcontext(ucontext_t *restrict oucp,
13 - const ucontext_t *restrict ucp);
15 + int
16 + swapcontext_extd(ucontext_t *restrict oucp, uint32_t flags,
17 + const ucontext_t *restrict ucp);
14 18
15 -
16 19 DESCRIPTION
17 - The makecontext() function modifies the context specified by ucp, which
18 - has been initialized using getcontext(2). When this context is resumed
19 - using swapcontext() or setcontext(2), execution continues by calling
20 - the function func, passing it the arguments that follow argc in the
21 - makecontext() call. The value of argc must match the number of pointer-
22 - sized integer arguments passed to func, otherwise the behavior is
23 - undefined.
20 + The makecontext() function modifies the context specified by ucp, which
21 + has been initialized using getcontext(2) or getcontext_extd(2). When
22 + this context is resumed using swapcontext(), swapcontext_extd(), or
23 + setcontext(2), execution continues by calling the function func, passing
24 + it the arguments that follow argc in the makecontext() call. The value
25 + of argc must match the number of pointer-sized integer arguments passed
26 + to func, otherwise the behavior is undefined.
24 27
28 + Before a call is made to makecontext(), the context being modified should
29 + have a stack allocated for it. The stack is assigned to the context by
30 + initializing the uc_stack member.
25 31
26 - Before a call is made to makecontext(), the context being modified
27 - should have a stack allocated for it. The stack is assigned to the
28 - context by initializing the uc_stack member.
32 + The uc_link member is used to determine the context that will be resumed
33 + when the context being modified by makecontext() returns. The uc_link
34 + member should be initialized prior to the call to makecontext(). If the
35 + uc_link member is initialized to NULL, the thread executing func will
36 + exit when func returns. See pthread_exit(3C).
29 37
38 + The swapcontext() function saves the current context in the context
39 + structure pointed to by oucp and sets the context to the context
40 + structure pointed to by ucp.
30 41
31 - The uc_link member is used to determine the context that will be
32 - resumed when the context being modified by makecontext() returns. The
33 - uc_link member should be initialized prior to the call to
34 - makecontext(). If the uc_link member is initialized to NULL, the thread
35 - executing func will exit when func returns. See pthread_exit(3C).
42 + If the ucp or oucp argument points to an invalid address, the behavior is
43 + undefined and errno may be set to EFAULT.
36 44
45 + The swapcontext_extd() function is similar to swapcontext() except that
46 + it performs a call to getcontext_extd(2) to get and save the current
47 + context, passing the flags argument to getcontext_extd(2). Note, the
48 + same constraints around the initialization of the ucontext_t that are
49 + discussed in getcontext_extd(2) still apply. Mainly, the context must
50 + either have originally come from ucontext_alloc(3C) or prior to its first
51 + use been zeroed. See getcontext_extd(2) for more information.
37 52
38 - The swapcontext() function saves the current context in the context
39 - structure pointed to by oucp and sets the context to the context
40 - structure pointed to by ucp.
41 -
42 -
43 - If the ucp or oucp argument points to an invalid address, the behavior
44 - is undefined and errno may be set to EFAULT.
45 -
46 53 RETURN VALUES
47 - On successful completion, swapcontext() returns 0. Otherwise, -1 is
48 - returned and errno is set to indicate the error.
54 + On successful completion, swapcontext() and swapcontext_extd() return 0.
55 + Otherwise, -1 is returned and errno is set to indicate the error.
49 56
50 -ERRORS
51 - The swapcontext() function will fail if:
57 +EXAMPLES
58 + Example 1 Alternate execution context on a stack whose memory was
59 + allocated using mmap().
52 60
53 - ENOMEM
54 - The ucp argument does not have enough stack left to complete
55 - the operation.
61 + #include <stdio.h>
62 + #include <ucontext.h>
63 + #include <sys/mman.h>
56 64
65 + void
66 + assign(long a, int *b)
67 + {
68 + *b = (int)a;
69 + }
57 70
71 + int
72 + main(int argc, char **argv)
73 + {
74 + ucontext_t uc, back;
75 + size_t sz = 0x10000;
76 + int value = 0;
58 77
59 - The swapcontext() function may fail if:
78 + getcontext(&uc);
60 79
61 - EFAULT
62 - The ucp or oucp argument points to an invalid address.
80 + uc.uc_stack.ss_sp = mmap(0, sz,
81 + PROT_READ | PROT_WRITE | PROT_EXEC,
82 + MAP_PRIVATE | MAP_ANON, -1, 0);
83 + uc.uc_stack.ss_size = sz;
84 + uc.uc_stack.ss_flags = 0;
63 85
86 + uc.uc_link = &back;
64 87
65 -EXAMPLES
66 - Example 1 Alternate execution context on a stack whose memory was
67 - allocated using mmap().
88 + makecontext(&uc, assign, 2, 100L, &value);
89 + swapcontext(&back, &uc);
68 90
69 - #include <stdio.h>
70 - #include <ucontext.h>
71 - #include <sys/mman.h>
91 + printf("done %d\n", value);
72 92
73 - void
74 - assign(long a, int *b)
75 - {
76 - *b = (int)a;
77 - }
93 + return (0);
94 + }
78 95
79 - int
80 - main(int argc, char **argv)
81 - {
82 - ucontext_t uc, back;
83 - size_t sz = 0x10000;
84 - int value = 0;
96 +ERRORS
97 + The swapcontext() and swapcontext_extd() function will fail if:
85 98
86 - getcontext(&uc);
99 + ENOMEM The ucp argument does not have enough stack left to
100 + complete the operation.
87 101
88 - uc.uc_stack.ss_sp = mmap(0, sz,
89 - PROT_READ | PROT_WRITE | PROT_EXEC,
90 - MAP_PRIVATE | MAP_ANON, -1, 0);
91 - uc.uc_stack.ss_size = sz;
92 - uc.uc_stack.ss_flags = 0;
102 + The swapcontext() and swapcontext_extd() functions may fail if:
93 103
94 - uc.uc_link = &back;
104 + EFAULT The ucp or oucp argument points to an invalid address.
95 105
96 - makecontext(&uc, assign, 2, 100L, &value);
97 - swapcontext(&back, &uc);
106 + The swapcontext_extd() function may additionally fail if:
98 107
99 - printf("done %d\n", value);
108 + EINVAL The flags argument contains invalid values.
100 109
101 - return (0);
102 - }
103 -
104 -
105 110 USAGE
106 - These functions are useful for implementing user-level context
107 - switching between multiple threads of control within a process (co-
108 - processing). More effective multiple threads of control can be obtained
109 - by using native support for multithreading. See threads(7).
111 + These functions are useful for implementing user-level context switching
112 + between multiple threads of control within a process (co-processing).
113 + More effective multiple threads of control can be obtained by using
114 + native support for multithreading. See threads(7).
110 115
111 -ATTRIBUTES
112 - See attributes(7) for descriptions of the following attributes:
116 +INTERFACE STABILITY
117 + Committed
113 118
119 +MT-LEVEL
120 + MT-Safe
114 121
115 -
116 -
117 - +--------------------+-----------------+
118 - | ATTRIBUTE TYPE | ATTRIBUTE VALUE |
119 - +--------------------+-----------------+
120 - |Interface Stability | Standard |
121 - +--------------------+-----------------+
122 - |MT-Level | MT-Safe |
123 - +--------------------+-----------------+
124 -
125 122 SEE ALSO
126 - getcontext(2), mmap(2), sigaction(2), sigprocmask(2), pthread_exit(3C),
127 - ucontext.h(3HEAD), attributes(7), standards(7), threads(7)
123 + getcontext(2), getcontext_extd(2), mmap(2), sigaction(2), sigprocmask(2),
124 + pthread_exit(3C), ucontext_alloc(3C), ucontext.h(3HEAD), attributes(7),
125 + standards(7), threads(7)
128 126
129 127 NOTES
130 - The semantics of the uc_stack member of the ucontext_t structure have
131 - changed as they apply to inputs to makecontext(). Prior to Solaris 10,
132 - the ss_sp member of the uc_stack structure represented the high memory
133 - address of the area reserved for the stack. The ss_sp member now
134 - represents the base (low memory address), in keeping with other uses of
135 - ss_sp.
128 + The semantics of the uc_stack member of the ucontext_t structure have
129 + changed as they apply to inputs to makecontext(). Prior to Solaris 10,
130 + the ss_sp member of the uc_stack tructure represented the high memory
131 + address of the area reserved for the stack. The ss_sp member now
132 + represents the base (low memory address), in keeping with other uses of
133 + ss_sp. This change in the meaning of ss_sp is the default behavior.
136 134
135 + Binary compatibility has been preserved with releases prior to Solaris
136 + 10. Before recompiling, applications that use makecontext() must be
137 + updated to reflect this behavior change. The example below demonstrates
138 + a typical change that must be applied:
137 139
138 - This change in the meaning of ss_sp is now the default behavior. The
139 - -D__MAKECONTEXT_V2_SOURCE compilation flag used in Solaris 9 update
140 - releases to access this behavior is obsolete.
140 + --- example1_s9.c Thu Oct 3 11:58:17 2002
141 + +++ example1.c Thu Jun 27 13:28:16 2002
142 + @@ -27,12 +27,9 @@
143 + uc.uc_stack.ss_sp = mmap(0, sz,
144 + PROT_READ | PROT_WRITE | PROT_EXEC,
145 + MAP_PRIVATE | MAP_ANON, -1, 0);
146 + - uc.uc_stack.ss_sp = (char *)uc.uc_stack.ss_sp + sz - 8;
147 + uc.uc_stack.ss_size = sz;
148 + uc.uc_stack.ss_flags = 0;
141 149
150 + uc.uc_link = &back
142 151
143 - Binary compatibility has been preserved with releases prior to Solaris
144 - 10. Before recompiling, applications that use makecontext() must be
145 - updated to reflect this behavior change. The example below demonstrates
146 - a typical change that must be applied:
152 + makecontext(&uc, assign, 2, 100L, &value);
147 153
148 - --- example1_s9.c Thu Oct 3 11:58:17 2002
149 - +++ example1.c Thu Jun 27 13:28:16 2002
150 - @@ -27,12 +27,9 @@
151 - uc.uc_stack.ss_sp = mmap(0, sz,
152 - PROT_READ | PROT_WRITE | PROT_EXEC,
153 - MAP_PRIVATE | MAP_ANON, -1, 0);
154 - - uc.uc_stack.ss_sp = (char *)uc.uc_stack.ss_sp + sz - 8;
155 - uc.uc_stack.ss_size = sz;
156 - uc.uc_stack.ss_flags = 0;
157 -
158 - uc.uc_link = &back
159 -
160 - makecontext(&uc, assign, 2, 100L, &value);
161 -
162 -
163 - February 17, 2023 MAKECONTEXT(3C)
154 +illumos March 20, 2023 illumos
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX