Blame


1 0c7c441e 2006-02-10 devnull /* Copyright (C) 2001 Free Software Foundation, Inc.
2 0c7c441e 2006-02-10 devnull This file is part of the GNU C Library.
3 0c7c441e 2006-02-10 devnull Contributed by Jakub Jelinek <jakub@redhat.com>.
4 0c7c441e 2006-02-10 devnull
5 0c7c441e 2006-02-10 devnull The GNU C Library is free software; you can redistribute it and/or
6 0c7c441e 2006-02-10 devnull modify it under the terms of the GNU Lesser General Public
7 0c7c441e 2006-02-10 devnull License as published by the Free Software Foundation; either
8 0c7c441e 2006-02-10 devnull version 2.1 of the License, or (at your option) any later version.
9 0c7c441e 2006-02-10 devnull
10 0c7c441e 2006-02-10 devnull The GNU C Library is distributed in the hope that it will be useful,
11 0c7c441e 2006-02-10 devnull but WITHOUT ANY WARRANTY; without even the implied warranty of
12 0c7c441e 2006-02-10 devnull MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 0c7c441e 2006-02-10 devnull Lesser General Public License for more details.
14 0c7c441e 2006-02-10 devnull
15 0c7c441e 2006-02-10 devnull You should have received a copy of the GNU Lesser General Public
16 0c7c441e 2006-02-10 devnull License along with the GNU C Library; if not, write to the Free
17 0c7c441e 2006-02-10 devnull Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 0c7c441e 2006-02-10 devnull 02111-1307 USA. */
19 0c7c441e 2006-02-10 devnull
20 0c7c441e 2006-02-10 devnull #include <ucontext.h>
21 0c7c441e 2006-02-10 devnull
22 0c7c441e 2006-02-10 devnull extern int __getcontext (ucontext_t *ucp);
23 0c7c441e 2006-02-10 devnull extern int __setcontext (const ucontext_t *ucp, int restoremask);
24 0c7c441e 2006-02-10 devnull
25 0c7c441e 2006-02-10 devnull int
26 0c7c441e 2006-02-10 devnull __swapcontext (ucontext_t *oucp, const ucontext_t *ucp)
27 0c7c441e 2006-02-10 devnull {
28 0c7c441e 2006-02-10 devnull extern void __swapcontext_ret (void);
29 0c7c441e 2006-02-10 devnull /* Save the current machine context to oucp. */
30 0c7c441e 2006-02-10 devnull __getcontext (oucp);
31 0c7c441e 2006-02-10 devnull /* Modify oucp to skip the __setcontext call on reactivation. */
32 0c7c441e 2006-02-10 devnull oucp->uc_mcontext.mc_gregs[MC_PC] = (long) __swapcontext_ret;
33 0c7c441e 2006-02-10 devnull oucp->uc_mcontext.mc_gregs[MC_NPC] = ((long) __swapcontext_ret) + 4;
34 0c7c441e 2006-02-10 devnull /* Restore the machine context in ucp. */
35 0c7c441e 2006-02-10 devnull __setcontext (ucp, 1);
36 0c7c441e 2006-02-10 devnull return 0;
37 0c7c441e 2006-02-10 devnull }
38 0c7c441e 2006-02-10 devnull
39 0c7c441e 2006-02-10 devnull asm (" \n\
40 0c7c441e 2006-02-10 devnull .text \n\
41 0c7c441e 2006-02-10 devnull .type __swapcontext_ret, #function \n\
42 0c7c441e 2006-02-10 devnull __swapcontext_ret: \n\
43 0c7c441e 2006-02-10 devnull return %i7 + 8 \n\
44 0c7c441e 2006-02-10 devnull clr %o0 \n\
45 0c7c441e 2006-02-10 devnull .size __swapcontext_ret, .-__swapcontext_ret \n\
46 0c7c441e 2006-02-10 devnull ");
47 0c7c441e 2006-02-10 devnull
48 0c7c441e 2006-02-10 devnull weak_alias (__swapcontext, swapcontext)