Blame sysdeps/unix/alpha/sysdep.S

Packit Service 82fcde
/* Copyright (C) 1993-2018 Free Software Foundation, Inc.
Packit Service 82fcde
   This file is part of the GNU C Library.
Packit Service 82fcde
   Contributed by Brendan Kehoe (brendan@zen.org).
Packit Service 82fcde
Packit Service 82fcde
   The GNU C Library is free software; you can redistribute it and/or
Packit Service 82fcde
   modify it under the terms of the GNU Lesser General Public
Packit Service 82fcde
   License as published by the Free Software Foundation; either
Packit Service 82fcde
   version 2.1 of the License, or (at your option) any later version.
Packit Service 82fcde
Packit Service 82fcde
   The GNU C Library is distributed in the hope that it will be useful,
Packit Service 82fcde
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 82fcde
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 82fcde
   Lesser General Public License for more details.
Packit Service 82fcde
Packit Service 82fcde
   You should have received a copy of the GNU Lesser General Public
Packit Service 82fcde
   License along with the GNU C Library.  If not, see
Packit Service 82fcde
   <http://www.gnu.org/licenses/>.  */
Packit Service 82fcde
Packit Service 82fcde
#include <sysdep.h>
Packit Service 82fcde
#include <features.h>
Packit Service 82fcde
Packit Service 82fcde
#if defined(PIC)
Packit Service 82fcde
	/* Put this at the end of libc's text segment so that all of
Packit Service 82fcde
	   the direct branches from the syscalls are forward, and
Packit Service 82fcde
	   thus predicted not taken.  */
Packit Service 82fcde
	.section .text.last, "ax", @progbits
Packit Service 82fcde
#else
Packit Service 82fcde
	.text
Packit Service 82fcde
#endif
Packit Service 82fcde
Packit Service 82fcde
#if IS_IN (libc)
Packit Service 82fcde
# define SYSCALL_ERROR_ERRNO __libc_errno
Packit Service 82fcde
#else
Packit Service 82fcde
# define SYSCALL_ERROR_ERRNO errno
Packit Service 82fcde
#endif
Packit Service 82fcde
Packit Service 82fcde
	.align 4
Packit Service 82fcde
	.globl	__syscall_error
Packit Service 82fcde
	.ent	__syscall_error
Packit Service 82fcde
__syscall_error:
Packit Service 82fcde
	/* When building a shared library, we branch here without having
Packit Service 82fcde
	   loaded the GP.  Nor, since it was a direct branch, have we
Packit Service 82fcde
	   loaded PV with our address.
Packit Service 82fcde
Packit Service 82fcde
	   When building a static library, we tail call here from another
Packit Service 82fcde
	   object file, possibly with a different GP, and must return with
Packit Service 82fcde
	   the GP of our caller in place so that linker relaxation works.
Packit Service 82fcde
Packit Service 82fcde
	   Both issues are solved by computing the GP into T1 instead of
Packit Service 82fcde
	   clobbering the traditional GP register.  */
Packit Service 82fcde
	.prologue 0
Packit Service 82fcde
	mov	v0, t0
Packit Service 82fcde
	br	t1, 1f
Packit Service 82fcde
1:	ldah	t1, 0(t1) !gpdisp!1
Packit Service 82fcde
	call_pal PAL_rduniq
Packit Service 82fcde
Packit Service 82fcde
	lda	t1, 0(t1) !gpdisp!1
Packit Service 82fcde
	ldq	t1, SYSCALL_ERROR_ERRNO(t1) !gottprel
Packit Service 82fcde
	addq	v0, t1, t1
Packit Service 82fcde
	lda	v0, -1
Packit Service 82fcde
Packit Service 82fcde
	stl	t0, 0(t1)
Packit Service 82fcde
	ret
Packit Service 82fcde
Packit Service 82fcde
	.end __syscall_error