xref: /dragonfly/lib/libc/x86_64/sys/cerror.S (revision 0f0f9bbd)
1b2b3ffcdSSimon Schubert/*-
2b2b3ffcdSSimon Schubert * Copyright (c) 1990 The Regents of the University of California.
3b2b3ffcdSSimon Schubert * All rights reserved.
4b2b3ffcdSSimon Schubert *
5b2b3ffcdSSimon Schubert * This code is derived from software contributed to Berkeley by
6b2b3ffcdSSimon Schubert * William Jolitz.
7b2b3ffcdSSimon Schubert *
8b2b3ffcdSSimon Schubert * Redistribution and use in source and binary forms, with or without
9b2b3ffcdSSimon Schubert * modification, are permitted provided that the following conditions
10b2b3ffcdSSimon Schubert * are met:
11b2b3ffcdSSimon Schubert * 1. Redistributions of source code must retain the above copyright
12b2b3ffcdSSimon Schubert *    notice, this list of conditions and the following disclaimer.
13b2b3ffcdSSimon Schubert * 2. Redistributions in binary form must reproduce the above copyright
14b2b3ffcdSSimon Schubert *    notice, this list of conditions and the following disclaimer in the
15b2b3ffcdSSimon Schubert *    documentation and/or other materials provided with the distribution.
16*0f0f9bbdSzrj * 3. Neither the name of the University nor the names of its contributors
17b2b3ffcdSSimon Schubert *    may be used to endorse or promote products derived from this software
18b2b3ffcdSSimon Schubert *    without specific prior written permission.
19b2b3ffcdSSimon Schubert *
20b2b3ffcdSSimon Schubert * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21b2b3ffcdSSimon Schubert * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22b2b3ffcdSSimon Schubert * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23b2b3ffcdSSimon Schubert * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24b2b3ffcdSSimon Schubert * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25b2b3ffcdSSimon Schubert * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26b2b3ffcdSSimon Schubert * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27b2b3ffcdSSimon Schubert * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28b2b3ffcdSSimon Schubert * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29b2b3ffcdSSimon Schubert * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30b2b3ffcdSSimon Schubert * SUCH DAMAGE.
31b2b3ffcdSSimon Schubert *
32b2b3ffcdSSimon Schubert * @(#)cerror.s	5.1 (Berkeley) 4/23/90
33b2b3ffcdSSimon Schubert * $FreeBSD: src/lib/libc/amd64/sys/cerror.S,v 1.13 2003/04/30 18:16:33 peter Exp $
34b2b3ffcdSSimon Schubert */
35b2b3ffcdSSimon Schubert
36b2b3ffcdSSimon Schubert#include <machine/asm.h>
37b2b3ffcdSSimon Schubert
38b2b3ffcdSSimon Schubert#include "SYS.h"
39b2b3ffcdSSimon Schubert
40b2b3ffcdSSimon Schubert	.globl HIDENAME(cerror)
41b2b3ffcdSSimon Schubert
42b2b3ffcdSSimon SchubertHIDENAME(cerror):
43b2b3ffcdSSimon Schubert	pushq	%rax
44b2b3ffcdSSimon Schubert#ifdef PIC
45b2b3ffcdSSimon Schubert#  ifdef __thread
46b2b3ffcdSSimon Schubert	movq	PIC_GOT(CNAME(errno)),%rax
47b2b3ffcdSSimon Schubert#  else
48b2b3ffcdSSimon Schubert	leaq	errno@TLSGD(%rip),%rdi
49b2b3ffcdSSimon Schubert	call	__tls_get_addr@PLT
50b2b3ffcdSSimon Schubert#  endif
51b2b3ffcdSSimon Schubert#else
52b2b3ffcdSSimon Schubert#  ifdef __thread
53b2b3ffcdSSimon Schubert	leaq	CNAME(errno)(%rip),%rax
54b2b3ffcdSSimon Schubert#  else
55b2b3ffcdSSimon Schubert	movq	errno@GOTTPOFF(%rip),%rax
56b2b3ffcdSSimon Schubert	addq	%fs:0,%rax
57b2b3ffcdSSimon Schubert#  endif
58b2b3ffcdSSimon Schubert#endif
59b2b3ffcdSSimon Schubert	popq	%rcx
60b2b3ffcdSSimon Schubert	movl	%ecx,(%rax)
61b2b3ffcdSSimon Schubert	movq	$-1,%rax
62b2b3ffcdSSimon Schubert	movq	$-1,%rdx
63b2b3ffcdSSimon Schubert	ret
64b2b3ffcdSSimon Schubert
658b927cb7SJohn Marino	.section .note.GNU-stack,"",%progbits
66