Update copyright dates with scripts/update-copyrights.
[glibc.git] / sysdeps / unix / sysv / linux / x86_64 / __start_context.S
blob52a5afa9a62579391ed4ebc6d873ac1a523b8350
1 /* Copyright (C) 2002-2015 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3    Contributed by Andreas Jaeger <aj@suse.de>, 2002.
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, see
17    <http://www.gnu.org/licenses/>.  */
19 #include <sysdep.h>
21 /* This is the helper code which gets called if a function which is
22    registered with 'makecontext' returns.  In this case we have to
23    install the context listed in the uc_link element of the context
24    'makecontext' manipulated at the time of the 'makecontext' call.
25    If the pointer is NULL the process must terminate.  */
28 ENTRY(__start_context)
29         /* This removes the parameters passed to the function given to
30            'makecontext' from the stack.  RBX contains the address
31            on the stack pointer for the next context.  */
32         movq    %rbx, %rsp
34         popq    %rdi                    /* This is the next context.  */
35         cfi_adjust_cfa_offset(-8)
36         testq   %rdi, %rdi
37         je      2f                      /* If it is zero exit.  */
39         call    JUMPTARGET(__setcontext)
40         /* If this returns (which can happen if the syscall fails) we'll
41            exit the program with the return error value (-1).  */
42         movq    %rax,%rdi
45         call    HIDDEN_JUMPTARGET(exit)
46         /* The 'exit' call should never return.  In case it does cause
47            the process to terminate.  */
48         hlt
49 END(__start_context)