Blame sysdeps/unix/sysv/linux/riscv/sysdep.S

Packit 6c4009
/* syscall error handlers
Packit 6c4009
   Copyright (C) 2011-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library.  If not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#include <sysdep.h>
Packit 6c4009
Packit 6c4009
#if IS_IN (libc)
Packit 6c4009
# define errno __libc_errno
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
ENTRY (__syscall_error)
Packit 6c4009
	mv t0, ra
Packit 6c4009
	/* Fall through to __syscall_set_errno.  */
Packit 6c4009
END (__syscall_error)
Packit 6c4009
Packit 6c4009
/* Non-standard calling convention: argument in a0, return address in t0,
Packit 6c4009
   and clobber only t1.  */
Packit 6c4009
ENTRY (__syscall_set_errno)
Packit 6c4009
	/* We got here because a0 < 0, but only codes in the range [-4095, -1]
Packit 6c4009
	  represent errors.  Otherwise, just return the result normally.  */
Packit 6c4009
	li t1, -4096
Packit 6c4009
	bleu a0, t1, 1f
Packit 6c4009
	neg a0, a0
Packit 6c4009
#if RTLD_PRIVATE_ERRNO
Packit 6c4009
	sw a0, rtld_errno, t1
Packit 6c4009
#elif defined(__PIC__)
Packit 6c4009
	la.tls.ie t1, errno
Packit 6c4009
	add t1, t1, tp
Packit 6c4009
	sw a0, 0(t1)
Packit 6c4009
#else
Packit 6c4009
	lui t1, %tprel_hi(errno)
Packit 6c4009
	add t1, t1, tp, %tprel_add(errno)
Packit 6c4009
	sw a0, %tprel_lo(errno)(t1)
Packit 6c4009
#endif
Packit 6c4009
	li a0, -1
Packit 6c4009
1:	jr t0
Packit 6c4009
END (__syscall_set_errno)