]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android-sdk/platform-bionic.git/blob - libc/arch-x86_64/bionic/_setjmp.S
c617030614a711f93c07f96a9cf24597bf97c821
[android-sdk/platform-bionic.git] / libc / arch-x86_64 / bionic / _setjmp.S
1 /*      $OpenBSD: _setjmp.S,v 1.1 2004/01/28 01:44:45 mickey Exp $      */
2 /*      $NetBSD: _setjmp.S,v 1.1 2001/06/19 00:25:02 fvdl Exp $ */
4 /*
5  * Copyright (c) 2001 Wasabi Systems, Inc.
6  * All rights reserved.
7  *
8  * Written by Frank van der Linden for Wasabi Systems, Inc.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. All advertising materials mentioning features or use of this software
19  *    must display the following acknowledgement:
20  *      This product includes software developed for the NetBSD Project by
21  *      Wasabi Systems, Inc.
22  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
23  *    or promote products derived from this software without specific prior
24  *    written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  * POSSIBILITY OF SUCH DAMAGE.
37  */
39 #include <private/bionic_asm.h>
40 #include <machine/setjmp.h>
42 /*
43  * C library -- _setjmp, _longjmp
44  *
45  *      _longjmp(a,v)
46  * will generate a "return(v)" from the last call to
47  *      _setjmp(a)
48  * by restoring registers from the stack.
49  * The previous signal state is NOT restored.
50  */
52 ENTRY(_setjmp)
53         movq    (%rsp),%r11
54         movq    %rbx,(_JB_RBX * 8)(%rdi)
55         movq    %rbp,(_JB_RBP * 8)(%rdi)
56         movq    %r12,(_JB_R12 * 8)(%rdi)
57         movq    %r13,(_JB_R13 * 8)(%rdi)
58         movq    %r14,(_JB_R14 * 8)(%rdi)
59         movq    %r15,(_JB_R15 * 8)(%rdi)
60         movq    %rsp,(_JB_RSP * 8)(%rdi)
61         movq    %r11,(_JB_PC  * 8)(%rdi)
63         xorl    %eax,%eax
64         ret
65 END(_setjmp)
67 ENTRY(_longjmp)
68         movq    (_JB_RBX * 8)(%rdi),%rbx
69         movq    (_JB_RBP * 8)(%rdi),%rbp
70         movq    (_JB_R12 * 8)(%rdi),%r12
71         movq    (_JB_R13 * 8)(%rdi),%r13
72         movq    (_JB_R14 * 8)(%rdi),%r14
73         movq    (_JB_R15 * 8)(%rdi),%r15
74         movq    (_JB_RSP * 8)(%rdi),%rsp
75         movq    (_JB_PC  * 8)(%rdi),%r11
77         movl    %esi,%eax
78         testl   %eax,%eax
79         jnz     1f
80         incl    %eax
81 1:      movq    %r11,0(%rsp)
82         ret
83 END(_longjmp)