1a9643ea8Slogwang /*- 2*22ce4affSfengbojiang * SPDX-License-Identifier: BSD-3-Clause 3*22ce4affSfengbojiang * 4a9643ea8Slogwang * Copyright (c) 1999 Marcel Moolenaar 5a9643ea8Slogwang * All rights reserved. 6a9643ea8Slogwang * 7a9643ea8Slogwang * Redistribution and use in source and binary forms, with or without 8a9643ea8Slogwang * modification, are permitted provided that the following conditions 9a9643ea8Slogwang * are met: 10a9643ea8Slogwang * 1. Redistributions of source code must retain the above copyright 11a9643ea8Slogwang * notice, this list of conditions and the following disclaimer 12a9643ea8Slogwang * in this position and unchanged. 13a9643ea8Slogwang * 2. Redistributions in binary form must reproduce the above copyright 14a9643ea8Slogwang * notice, this list of conditions and the following disclaimer in the 15a9643ea8Slogwang * documentation and/or other materials provided with the distribution. 16a9643ea8Slogwang * 3. The name of the author may not be used to endorse or promote products 17a9643ea8Slogwang * derived from this software without specific prior written permission. 18a9643ea8Slogwang * 19a9643ea8Slogwang * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20a9643ea8Slogwang * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21a9643ea8Slogwang * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22a9643ea8Slogwang * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23a9643ea8Slogwang * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24a9643ea8Slogwang * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25a9643ea8Slogwang * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26a9643ea8Slogwang * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27a9643ea8Slogwang * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28a9643ea8Slogwang * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29a9643ea8Slogwang * 30a9643ea8Slogwang * $FreeBSD$ 31a9643ea8Slogwang */ 32a9643ea8Slogwang 33a9643ea8Slogwang #ifndef _SYS_UCONTEXT_H_ 34a9643ea8Slogwang #define _SYS_UCONTEXT_H_ 35a9643ea8Slogwang 36a9643ea8Slogwang #include <sys/signal.h> 37a9643ea8Slogwang #include <machine/ucontext.h> 38a9643ea8Slogwang #include <sys/_ucontext.h> 39a9643ea8Slogwang 40a9643ea8Slogwang #define UCF_SWAPPED 0x00000001 /* Used by swapcontext(3). */ 41a9643ea8Slogwang 42a9643ea8Slogwang #if defined(_KERNEL) && defined(COMPAT_FREEBSD4) 43a9643ea8Slogwang #if defined(__i386__) 44a9643ea8Slogwang struct ucontext4 { 45a9643ea8Slogwang sigset_t uc_sigmask; 46a9643ea8Slogwang struct mcontext4 uc_mcontext; 47a9643ea8Slogwang struct ucontext4 *uc_link; 48a9643ea8Slogwang stack_t uc_stack; 49a9643ea8Slogwang int __spare__[8]; 50a9643ea8Slogwang }; 51a9643ea8Slogwang #else /* __i386__ */ 52a9643ea8Slogwang #define ucontext4 ucontext 53a9643ea8Slogwang #endif /* __i386__ */ 54a9643ea8Slogwang #endif /* _KERNEL */ 55a9643ea8Slogwang 56a9643ea8Slogwang #ifndef _KERNEL 57a9643ea8Slogwang 58a9643ea8Slogwang __BEGIN_DECLS 59a9643ea8Slogwang 60a9643ea8Slogwang int getcontext(ucontext_t *) __returns_twice; 61a9643ea8Slogwang ucontext_t *getcontextx(void); 62a9643ea8Slogwang int setcontext(const ucontext_t *); 63a9643ea8Slogwang void makecontext(ucontext_t *, void (*)(void), int, ...); 64a9643ea8Slogwang int signalcontext(ucontext_t *, int, __sighandler_t *); 65a9643ea8Slogwang int swapcontext(ucontext_t *, const ucontext_t *); 66a9643ea8Slogwang 67a9643ea8Slogwang #if __BSD_VISIBLE 68a9643ea8Slogwang int __getcontextx_size(void); 69a9643ea8Slogwang int __fillcontextx(char *ctx) __returns_twice; 70a9643ea8Slogwang int __fillcontextx2(char *ctx); 71a9643ea8Slogwang #endif 72a9643ea8Slogwang 73a9643ea8Slogwang __END_DECLS 74a9643ea8Slogwang 75a9643ea8Slogwang #else /* _KERNEL */ 76a9643ea8Slogwang 77a9643ea8Slogwang struct thread; 78a9643ea8Slogwang 79a9643ea8Slogwang /* 80a9643ea8Slogwang * Flags for get_mcontext(). The low order 4 bits (i.e a mask of 0x0f) are 81a9643ea8Slogwang * reserved for use by machine independent code. All other bits are for use 82a9643ea8Slogwang * by machine dependent code. 83a9643ea8Slogwang */ 84a9643ea8Slogwang #define GET_MC_CLEAR_RET 1 85a9643ea8Slogwang 86a9643ea8Slogwang /* Machine-dependent functions: */ 87a9643ea8Slogwang int get_mcontext(struct thread *, mcontext_t *, int); 88a9643ea8Slogwang int set_mcontext(struct thread *, mcontext_t *); 89a9643ea8Slogwang 90a9643ea8Slogwang #endif /* !_KERNEL */ 91a9643ea8Slogwang 92a9643ea8Slogwang #endif /* !_SYS_UCONTEXT_H_ */ 93