Print this page
Ensured various XPG7 stuff are declared properly in sys/stat.h (and cleanup)
New documentation for wcslen, wcsnlen, wcscasecmp (and friends), wcsdup.
Various other tweaks and markup improvements.
More markup tweaks.
Minor markup tweaks (Sy instead of Nm).
fix incorrect standard citations
first round of POSIX 2008 stuff
*** 1,101 ****
! '\" te
.\" Copyright 1989 AT&T. Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved. Portions Copyright (c) 1992, X/Open Company Limited. All Rights Reserved.
.\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
.\" http://www.opengroup.org/bookstore/.
.\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
.\" This notice shall appear on any product containing this material.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
! .TH MAKECONTEXT 3C "Mar 8, 2004"
! .SH NAME
! makecontext, swapcontext \- manipulate user contexts
! .SH SYNOPSIS
! .LP
! .nf
! #include <ucontext.h>
!
! \fBvoid\fR \fBmakecontext\fR(\fBucontext_t *\fR\fIucp\fR, \fBvoid (*\fR\fIfunc\fR)(), \fBint\fR \fIargc\fR...);
! .fi
!
! .LP
! .nf
! \fBint\fR \fBswapcontext\fR(\fBucontext_t *restrict\fR \fIoucp\fR,
! \fBconst ucontext_t *restrict\fR \fIucp\fR);
! .fi
!
! .SH DESCRIPTION
! .sp
! .LP
! The \fBmakecontext()\fR function modifies the context specified by \fIucp\fR,
! which has been initialized using \fBgetcontext\fR(2). When this context is
! resumed using \fBswapcontext()\fR or \fBsetcontext\fR(2), execution continues
! by calling the function \fIfunc\fR, passing it the arguments that follow
! \fIargc\fR in the \fBmakecontext()\fR call. The value of \fIargc\fR must match
! the number of pointer-sized integer arguments passed to \fIfunc\fR, otherwise
! the behavior is undefined.
! .sp
! .LP
! Before a call is made to \fBmakecontext()\fR, the context being modified should
have a stack allocated for it. The stack is assigned to the context by
! initializing the \fBuc_stack\fR member.
! .sp
! .LP
! The \fBuc_link\fR member is used to determine the context that will be resumed
! when the context being modified by \fBmakecontext()\fR returns. The
! \fBuc_link\fR member should be initialized prior to the call to
! \fBmakecontext()\fR. If the \fBuc_link\fR member is initialized to \fINULL\fR,
! the thread executing \fIfunc\fR will exit when \fIfunc\fR returns. See
! \fBpthread_exit\fR(3C).
! .sp
! .LP
! The \fBswapcontext()\fR function saves the current context in the context
! structure pointed to by \fIoucp\fR and sets the context to the context
! structure pointed to by \fIucp\fR.
! .sp
! .LP
! If the \fIucp\fR or \fIoucp\fR argument points to an invalid address, the
! behavior is undefined and \fBerrno\fR may be set to \fBEFAULT\fR.
! .SH RETURN VALUES
! .sp
! .LP
! On successful completion, \fBswapcontext()\fR returns \fB0\fR. Otherwise,
! \fB\(mi1\fR is returned and \fBerrno\fR is set to indicate the error.
! .SH ERRORS
! .sp
! .LP
! The \fBswapcontext()\fR function will fail if:
! .sp
! .ne 2
! .na
! \fB\fBENOMEM\fR\fR
! .ad
! .RS 10n
! The \fIucp\fR argument does not have enough stack left to complete the
! operation.
! .RE
!
! .sp
! .LP
! The \fBswapcontext()\fR function may fail if:
! .sp
! .ne 2
! .na
! \fB\fBEFAULT\fR\fR
! .ad
! .RS 10n
! The \fIucp\fR or \fIoucp\fR argument points to an invalid address.
! .RE
!
! .SH EXAMPLES
! .LP
! \fBExample 1 \fRAlternate execution context on a stack whose memory was
! allocated using \fBmmap()\fR.
! .sp
! .in +2
! .nf
#include <stdio.h>
#include <ucontext.h>
#include <sys/mman.h>
void
--- 1,104 ----
! .\" Copyright 2014 Garrett D'Amore <garrett@damore.org>
.\" Copyright 1989 AT&T. Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved. Portions Copyright (c) 1992, X/Open Company Limited. All Rights Reserved.
.\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
.\" http://www.opengroup.org/bookstore/.
.\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
.\" This notice shall appear on any product containing this material.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
! .Dd "Jul 14, 2014"
! .Dt MAKECONTEXT 3C
! .Os
! .Sh NAME
! .Nm makecontext, swapcontext
! .Nd manipulate user contexts
! .Sh SYNOPSIS
! .In ucontext.h
! .Ft void
! .Fn makecontext "ucontext_t *ucp" "void \*(lp*func\*(rp\*(lp\*(rp, int argc, ..."
! .Ft int
! .Fn swapcontext "ucontext_t *restrict oucp" "const ucontext_t *restrict ucp"
! .Sh DESCRIPTION
! The
! .Fn makecontext
! function modifies the context specified by
! .Fa ucp ,
! which has been initialized using
! .Xr getcontext 2 .
! When this context is
! resumed using
! .Fn swapcontext
! or
! .Xr setcontext 2 ,
! execution continues by calling the function
! .Fa func ,
! passing it the arguments that follow
! .Fa argc
! in the
! .Fn makecontext
! call. The value of
! .Fa argc
! must match the number of pointer-sized integer arguments passed to
! .Fn func ,
! otherwise the behavior is undefined.
! .Lp
! Before a call is made to
! .Fn makecontext ,
! the context being modified should
have a stack allocated for it. The stack is assigned to the context by
! initializing the
! .Fa uc_stack
! member.
! .Lp
! The
! .Fa uc_link
! member is used to determine the context that will be resumed
! when the context being modified by
! .Fn makecontext
! returns. The
! .Fa uc_link
! member should be initialized prior to the call to
! .Fn makecontext .
! If the
! .Fa uc_link
! member is initialized to
! .Dv NULL ,
! the thread executing
! .Fa func
! will exit when
! .Fa func
! returns. See
! .Xr pthread_exit 3C .
! .Lp
! The
! .Fn swapcontext
! function saves the current context in the context
! structure pointed to by
! .Fa oucp
! and sets the context to the context
! structure pointed to by
! .Fa ucp .
! .Lp
! If the
! .Fa ucp
! or
! .Fa oucp
! argument points to an invalid address, the
! behavior is undefined and
! .Va errno
! may be set to
! .Er EFAULT .
! .Sh RETURN VALUES
! .Rv -std swapcontext
! .Sh EXAMPLES
! .Ss Example 1
! The following example illustrates execution context on a stack whose memory was
! allocated using
! .Xr mmap 2 :
! .Bd -literal -offset indent
#include <stdio.h>
#include <ucontext.h>
#include <sys/mman.h>
void
*** 126,203 ****
printf("done %d\en", value);
return (0);
}
! .fi
! .in -2
!
! .SH USAGE
! .sp
! .LP
These functions are useful for implementing user-level context switching
between multiple threads of control within a process (co-processing). More
effective multiple threads of control can be obtained by using native support
! for multithreading. See \fBthreads\fR(5).
! .SH ATTRIBUTES
! .sp
! .LP
! See \fBattributes\fR(5) for descriptions of the following attributes:
! .sp
!
! .sp
! .TS
! box;
! c | c
! l | l .
! ATTRIBUTE TYPE ATTRIBUTE VALUE
! _
! Interface Stability Standard
! _
! MT-Level MT-Safe
! .TE
!
! .SH SEE ALSO
! .sp
! .LP
! \fBmmap\fR(2), \fBgetcontext\fR(2), \fBsigaction\fR(2), \fBsigprocmask\fR(2),
! \fBpthread_exit\fR(3C), \fBucontext.h\fR(3HEAD), \fBattributes\fR(5),
! \fBstandards\fR(5), \fBthreads\fR(5)
! .SH NOTES
! .sp
! .LP
! The semantics of the \fBuc_stack\fR member of the \fBucontext_t\fR structure
! have changed as they apply to inputs to \fBmakecontext()\fR. Prior to Solaris
! 10, the \fBss_sp\fR member of the \fBuc_stack\fR structure represented the high
memory address of the area reserved for the stack. The \fBss_sp\fR member now
represents the base (low memory address), in keeping with other uses of
! \fBss_sp\fR.
! .sp
! .LP
! This change in the meaning of \fBss_sp\fR is now the default behavior. The
! \fB-D__MAKECONTEXT_V2_SOURCE\fR compilation flag used in Solaris 9 update
releases to access this behavior is obsolete.
! .sp
! .LP
Binary compatibility has been preserved with releases prior to Solaris 10.
! Before recompiling, applications that use \fBmakecontext()\fR must be updated
! to reflect this behavior change. The example below demonstates a typical change
! that must be applied:
! .sp
! .in +2
! .nf
! --- example1_s9.c Thu Oct 3 11:58:17 2002
! +++ example1.c Thu Jun 27 13:28:16 2002
! @@ -27,12 +27,9 @@
! uc.uc_stack.ss_sp = mmap(0, sz,
! PROT_READ | PROT_WRITE | PROT_EXEC,
! MAP_PRIVATE | MAP_ANON, -1, 0);
! - uc.uc_stack.ss_sp = (char *)uc.uc_stack.ss_sp + sz - 8;
! uc.uc_stack.ss_size = sz;
! uc.uc_stack.ss_flags = 0;
!
! uc.uc_link = &back
!
! makecontext(&uc, assign, 2, 100L, &value);
! .fi
! .in -2
!
--- 129,220 ----
printf("done %d\en", value);
return (0);
}
! .Ed
! .Sh ERRORS
! The
! .Fn swapcontext
! function will fail if:
! .Bl -tag -width Er
! .It Er ENOMEM
! The
! .Fa ucp
! argument does not have enough stack left to complete the operation.
! .El
! .Lp
! The
! .Fn swapcontext
! function may fail if:
! .Bl -tag -width Er
! .It Er EFAULT
! The
! .Fa ucp
! or
! .Fa oucp
! argument points to an invalid address.
! .El
! .Sh USAGE
These functions are useful for implementing user-level context switching
between multiple threads of control within a process (co-processing). More
effective multiple threads of control can be obtained by using native support
! for multithreading. See
! .Xr pthreads 5 .
! .Sh INTERFACE STABILITY
! .Sy Obsolete Standard .
! .Sh MT-LEVEL
! .Sy MT-Safe .
! .Sh SEE ALSO
! .Xr mmap 2 ,
! .Xr getcontext 2 ,
! .Xr sigaction 2 ,
! .Xr sigprocmask 2 ,
! .Xr pthread_exit 3C ,
! .Xr ucontext.h 3HEAD ,
! .Xr standards 5 ,
! .Xr pthreads 5
! .Sh NOTES
! The semantics of the
! .Fa uc_stack
! member of the
! .Ft ucontext_t
! structure have changed as they apply to inputs to
! .Fn makecontex .
! Prior to Solaris 10, the
! .Fa ss_sp
! member of the
! .Fa uc_stack
! structure represented the high
memory address of the area reserved for the stack. The \fBss_sp\fR member now
represents the base (low memory address), in keeping with other uses of
! .Fa ss_sp .
! .Lp
! This change in the meaning of
! .Fa ss_sp
! is now the default behavior. The
! .Dv -D__MAKECONTEXT_V2_SOURCE
! compilation flag used in Solaris 9 update
releases to access this behavior is obsolete.
! .Lp
Binary compatibility has been preserved with releases prior to Solaris 10.
! Before recompiling, applications that use
! .Fn makecontext
! must be updated
! to reflect this behavior change.
! .Lp
! Portable applications should not use this function. Instead, applications
! should use
! .Xr pthreads 5
! routines.
! .Lp
! Note that the definition of
! .Fn makecontext
! violates
! .St -isoC .
! There is no way to declare this function that does not violate that
! standard.
! .Sh STANDARDS
! This function was introduced in
! .St -xpg4.2 ,
! and subsequently removed from
! .St -p1003.1-2008 .