1eda14cbcSMatt Macy/*
2eda14cbcSMatt Macy * CDDL HEADER START
3eda14cbcSMatt Macy *
4eda14cbcSMatt Macy * The contents of this file are subject to the terms of the
5eda14cbcSMatt Macy * Common Development and Distribution License (the "License").
6eda14cbcSMatt Macy * You may not use this file except in compliance with the License.
7eda14cbcSMatt Macy *
8eda14cbcSMatt Macy * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9271171e0SMartin Matuska * or https://opensource.org/licenses/CDDL-1.0.
10eda14cbcSMatt Macy * See the License for the specific language governing permissions
11eda14cbcSMatt Macy * and limitations under the License.
12eda14cbcSMatt Macy *
13eda14cbcSMatt Macy * When distributing Covered Code, include this CDDL HEADER in each
14eda14cbcSMatt Macy * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15eda14cbcSMatt Macy * If applicable, add the following below this CDDL HEADER, with the
16eda14cbcSMatt Macy * fields enclosed by brackets "[]" replaced with your own identifying
17eda14cbcSMatt Macy * information: Portions Copyright [yyyy] [name of copyright owner]
18eda14cbcSMatt Macy *
19eda14cbcSMatt Macy * CDDL HEADER END
20eda14cbcSMatt Macy */
21eda14cbcSMatt Macy
22eda14cbcSMatt Macy/*
23eda14cbcSMatt Macy * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
24eda14cbcSMatt Macy */
25eda14cbcSMatt Macy
26dbd5678dSMartin Matuska#if defined(_KERNEL) && defined(__linux__)
27dbd5678dSMartin Matuska#include <linux/linkage.h>
28dbd5678dSMartin Matuska#endif
29eda14cbcSMatt Macy
30eda14cbcSMatt Macy/*
31eda14cbcSMatt Macy * Setjmp and longjmp implement non-local gotos using state vectors
32eda14cbcSMatt Macy * type label_t.
33eda14cbcSMatt Macy */
34eda14cbcSMatt Macy#ifdef __x86_64__
35eda14cbcSMatt Macy
36*15f0b8c3SMartin Matuska#define _ASM
37*15f0b8c3SMartin Matuska#include <sys/asm_linkage.h>
38*15f0b8c3SMartin Matuska
39*15f0b8c3SMartin MatuskaENTRY_ALIGN(setjmp, 8)
40eda14cbcSMatt Macy	movq	%rsp, 0(%rdi)
41eda14cbcSMatt Macy	movq	%rbp, 8(%rdi)
42eda14cbcSMatt Macy	movq	%rbx, 16(%rdi)
43eda14cbcSMatt Macy	movq	%r12, 24(%rdi)
44eda14cbcSMatt Macy	movq	%r13, 32(%rdi)
45eda14cbcSMatt Macy	movq	%r14, 40(%rdi)
46eda14cbcSMatt Macy	movq	%r15, 48(%rdi)
47eda14cbcSMatt Macy	movq	0(%rsp), %rdx		/* return address */
48eda14cbcSMatt Macy	movq	%rdx, 56(%rdi)		/* rip */
49eda14cbcSMatt Macy	xorl	%eax, %eax		/* return 0 */
50a0b956f5SMartin Matuska	RET
51eda14cbcSMatt Macy	SET_SIZE(setjmp)
52eda14cbcSMatt Macy
53*15f0b8c3SMartin MatuskaENTRY_ALIGN(longjmp, 8)
54eda14cbcSMatt Macy	movq	0(%rdi), %rsp
55eda14cbcSMatt Macy	movq	8(%rdi), %rbp
56eda14cbcSMatt Macy	movq	16(%rdi), %rbx
57eda14cbcSMatt Macy	movq	24(%rdi), %r12
58eda14cbcSMatt Macy	movq	32(%rdi), %r13
59eda14cbcSMatt Macy	movq	40(%rdi), %r14
60eda14cbcSMatt Macy	movq	48(%rdi), %r15
61eda14cbcSMatt Macy	movq	56(%rdi), %rdx		/* return address */
62eda14cbcSMatt Macy	movq	%rdx, 0(%rsp)
63eda14cbcSMatt Macy	xorl	%eax, %eax
64eda14cbcSMatt Macy	incl	%eax			/* return 1 */
65a0b956f5SMartin Matuska	RET
66eda14cbcSMatt Macy	SET_SIZE(longjmp)
67eda14cbcSMatt Macy
68eda14cbcSMatt Macy#ifdef __ELF__
69eda14cbcSMatt Macy.section .note.GNU-stack,"",%progbits
70eda14cbcSMatt Macy#endif
71eda14cbcSMatt Macy
72eda14cbcSMatt Macy#endif /* __x86_64__ */
73