1*0a2b7583Sjoerg /* $NetBSD: resumecontext.c,v 1.4 2011/09/19 21:24:58 joerg Exp $ */
2d48f1466Sross
3d48f1466Sross /*-
4d48f1466Sross * Copyright (c) 2001 The NetBSD Foundation, Inc.
5d48f1466Sross * All rights reserved.
6d48f1466Sross *
7d48f1466Sross * This code is derived from software contributed to The NetBSD Foundation
8d48f1466Sross * by Klaus Klein.
9d48f1466Sross *
10d48f1466Sross * Redistribution and use in source and binary forms, with or without
11d48f1466Sross * modification, are permitted provided that the following conditions
12d48f1466Sross * are met:
13d48f1466Sross * 1. Redistributions of source code must retain the above copyright
14d48f1466Sross * notice, this list of conditions and the following disclaimer.
15d48f1466Sross * 2. Redistributions in binary form must reproduce the above copyright
16d48f1466Sross * notice, this list of conditions and the following disclaimer in the
17d48f1466Sross * documentation and/or other materials provided with the distribution.
18d48f1466Sross *
19d48f1466Sross * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20d48f1466Sross * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21d48f1466Sross * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22d48f1466Sross * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23d48f1466Sross * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24d48f1466Sross * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25d48f1466Sross * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26d48f1466Sross * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27d48f1466Sross * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28d48f1466Sross * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29d48f1466Sross * POSSIBILITY OF SUCH DAMAGE.
30d48f1466Sross */
31d48f1466Sross
32d48f1466Sross #include <sys/cdefs.h>
33d48f1466Sross #if defined(LIBC_SCCS) && !defined(lint)
34*0a2b7583Sjoerg __RCSID("$NetBSD: resumecontext.c,v 1.4 2011/09/19 21:24:58 joerg Exp $");
35d48f1466Sross #endif
36d48f1466Sross
37d48f1466Sross #include "namespace.h"
38e56cdf1dSmartin #include <stdlib.h>
39d48f1466Sross #include <ucontext.h>
40e56cdf1dSmartin #include <unistd.h>
41d48f1466Sross #include "extern.h"
42d48f1466Sross
43d48f1466Sross void
_resumecontext(void)44*0a2b7583Sjoerg _resumecontext(void)
45d48f1466Sross {
46d48f1466Sross ucontext_t uct;
47d48f1466Sross
48d48f1466Sross (void)getcontext(&uct);
49e56cdf1dSmartin if (uct.uc_link == NULL)
50e56cdf1dSmartin exit(0);
51d48f1466Sross (void)setcontext(uct.uc_link);
52e56cdf1dSmartin _exit(-1);
53d48f1466Sross /* NOTREACHED */
54d48f1466Sross }
55