xref: /freebsd/lib/libc/sys/swapcontext.c (revision 6e83504c603157e9fc1660d2a1556036492662fc)
1d7847a8dSBrooks Davis /*
2d7847a8dSBrooks Davis  * Copyright (c) 2001 Daniel M. Eischen <deischen@freebsd.org>
3d7847a8dSBrooks Davis  * Copyright (c) 2014 The FreeBSD Foundation.
4d7847a8dSBrooks Davis  * All rights reserved.
5d7847a8dSBrooks Davis  *
6d7847a8dSBrooks Davis  * Portions of this software were developed by Konstantin Belousov
7d7847a8dSBrooks Davis  * under sponsorship from the FreeBSD Foundation.
8d7847a8dSBrooks Davis  *
9d7847a8dSBrooks Davis  * Redistribution and use in source and binary forms, with or without
10d7847a8dSBrooks Davis  * modification, are permitted provided that the following conditions
11d7847a8dSBrooks Davis  * are met:
12d7847a8dSBrooks Davis  * 1. Redistributions of source code must retain the above copyright
13d7847a8dSBrooks Davis  *    notice, this list of conditions and the following disclaimer.
14d7847a8dSBrooks Davis  * 2. Neither the name of the author nor the names of its contributors
15d7847a8dSBrooks Davis  *    may be used to endorse or promote products derived from this software
16d7847a8dSBrooks Davis  *    without specific prior written permission.
17d7847a8dSBrooks Davis  *
18d7847a8dSBrooks Davis  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19d7847a8dSBrooks Davis  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20d7847a8dSBrooks Davis  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21d7847a8dSBrooks Davis  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22d7847a8dSBrooks Davis  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23d7847a8dSBrooks Davis  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24d7847a8dSBrooks Davis  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25d7847a8dSBrooks Davis  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26d7847a8dSBrooks Davis  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27d7847a8dSBrooks Davis  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28d7847a8dSBrooks Davis  * SUCH DAMAGE.
29d7847a8dSBrooks Davis  */
30d7847a8dSBrooks Davis 
31d7847a8dSBrooks Davis #include <sys/param.h>
32d7847a8dSBrooks Davis #include <sys/signal.h>
33d7847a8dSBrooks Davis #include <sys/ucontext.h>
34d7847a8dSBrooks Davis #include <errno.h>
35d7847a8dSBrooks Davis #include <stddef.h>
36d7847a8dSBrooks Davis #include "libc_private.h"
37d7847a8dSBrooks Davis 
38d7847a8dSBrooks Davis __weak_reference(__sys_swapcontext, __swapcontext);
39d7847a8dSBrooks Davis __sym_compat(swapcontext, __impl_swapcontext, FBSD_1.0);
40d7847a8dSBrooks Davis __weak_reference(swapcontext, __impl_swapcontext);
41*6e83504cSBrooks Davis __sym_default(swapcontext, swapcontext, FBSD_1.2);
42d7847a8dSBrooks Davis 
43d7847a8dSBrooks Davis #pragma weak swapcontext
44d7847a8dSBrooks Davis int
45d7847a8dSBrooks Davis swapcontext(ucontext_t *oucp, const ucontext_t *ucp)
46d7847a8dSBrooks Davis {
477dd9070eSBrooks Davis 	return (INTERPOS_SYS(swapcontext, oucp, ucp));
48d7847a8dSBrooks Davis }
49