xref: /freebsd/sys/contrib/openzfs/module/lua/setjmp/setjmp_i386.S (revision b197d4b893974c9eb4d7b38704c6d5c486235d6f)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or https://opensource.org/licenses/CDDL-1.0.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22/*
23 * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
24 */
25
26#define	ENTRY(x) \
27	.text; \
28	.align	8; \
29	.globl	x; \
30	.type	x, @function; \
31x:
32
33#define	SET_SIZE(x) \
34	.size	x, [.-x]
35
36/*
37 * Setjmp and longjmp implement non-local gotos using state vectors
38 * type label_t.
39 */
40#ifdef __i386__
41
42	ENTRY(setjmp)			/* save area is passed in eax */
43	movl	%ebp, 0(%eax)		/* save ebp */
44	movl	%ebx, 4(%eax)		/* save ebx */
45	movl	%esi, 8(%eax)		/* save esi */
46	movl	%edi, 12(%eax)		/* save edi */
47	movl	%esp, 16(%eax)		/* save esp */
48	movl	(%esp), %ecx		/* %eip (return address) */
49	movl	%ecx, 20(%eax)		/* save eip */
50	subl	%eax, %eax		/* return 0 */
51	ret
52	SET_SIZE(setjmp)
53
54	ENTRY(longjmp)			/* save area is passed in eax */
55	movl	0(%eax), %ebp		/* restore ebp */
56	movl	4(%eax), %ebx		/* restore ebx */
57	movl	8(%eax), %esi		/* restore esi */
58	movl	12(%eax), %edi		/* restore edi */
59	movl	16(%eax), %esp		/* restore esp */
60	movl	20(%eax), %ecx		/* %eip (return address) */
61	addl	$4, %esp		/* pop ret adr */
62	jmp	*%ecx			/* indirect jump */
63	SET_SIZE(longjmp)
64
65#ifdef __ELF__
66.section .note.GNU-stack,"",%progbits
67#endif
68
69#endif /* __i386__ */
70