From 7f4230bdc8cd47571764354da759866cc89b9037 Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Fri, 21 Mar 2014 20:20:53 +0000 Subject: [PATCH] 2014-03-21 Sabrini Ni * nds32/Makefile.in: Add syscall_error_handler.o. * nds32/syscall_error_handler.S: New. * nds32/syscall_extra.h: Reduce code size. --- libgloss/ChangeLog | 6 ++++ libgloss/nds32/Makefile.in | 2 +- libgloss/nds32/syscall_error_handler.S | 48 ++++++++++++++++++++++++++ libgloss/nds32/syscall_extra.h | 10 ++---- 4 files changed, 57 insertions(+), 9 deletions(-) create mode 100644 libgloss/nds32/syscall_error_handler.S diff --git a/libgloss/ChangeLog b/libgloss/ChangeLog index a6965cdc1..4cd416893 100644 --- a/libgloss/ChangeLog +++ b/libgloss/ChangeLog @@ -1,3 +1,9 @@ +2014-03-21 Sabrini Ni + + * nds32/Makefile.in: Add syscall_error_handler.o. + * nds32/syscall_error_handler.S: New. + * nds32/syscall_extra.h: Reduce code size. + 2014-03-21 Sabrini Ni * nds32/syscall_extra.h: Define macro. diff --git a/libgloss/nds32/Makefile.in b/libgloss/nds32/Makefile.in index 6345957a5..976e9ad77 100644 --- a/libgloss/nds32/Makefile.in +++ b/libgloss/nds32/Makefile.in @@ -72,7 +72,7 @@ SYSCALLS1 = syscall_exit.o syscall_open.o syscall_close.o syscall_read.o syscall SYSCALLS2 = syscall_lseek.o syscall_unlink.o syscall_getpid.o syscall_kill.o syscall_fstat.o SYSCALLS3 = syscall_argvlen.o syscall_argv.o syscall_chdir.o syscall_stat.o syscall_chmod.o SYSCALLS4 = syscall_utime.o syscall_time.o syscall_gettimeofday.o syscall_times.o syscall_link.o -SYSCALLS5 = syscall_rename.o syscall_isatty.o syscall_system.o syscall_sbrk.o +SYSCALLS5 = syscall_rename.o syscall_isatty.o syscall_system.o syscall_sbrk.o syscall_error_handler.o SYSCALLS = $(SYSCALLS1) $(SYSCALLS2) $(SYSCALLS3) $(SYSCALLS4) $(SYSCALLS5) GENERIC_LIBOBJS = diff --git a/libgloss/nds32/syscall_error_handler.S b/libgloss/nds32/syscall_error_handler.S new file mode 100644 index 000000000..dbb5f6856 --- /dev/null +++ b/libgloss/nds32/syscall_error_handler.S @@ -0,0 +1,48 @@ +/* +Copyright (c) 2013 Andes Technology Corporation. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + The name of the company may not be used to endorse or promote + products derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#include "../syscall.h" +#include "syscall_extra.h" + + + .extern errno + .text + .global __syscall_error_handler + .type __syscall_error_handler, @function + .hidden __syscall_error_handler + .align 2 +__syscall_error_handler: + addi $r1, $r0, 1 + bnez $r1, 1f /* Branch if success. */ + syscall SYS_geterr /* There is something wrong. */ + s.w $r0, errno /* Store error code into errno. */ + move $r0, -1 +1: + ret + .size __syscall_error_handler, .-__syscall_error_handler diff --git a/libgloss/nds32/syscall_extra.h b/libgloss/nds32/syscall_extra.h index 73d36b973..7af4a4550 100644 --- a/libgloss/nds32/syscall_extra.h +++ b/libgloss/nds32/syscall_extra.h @@ -51,14 +51,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. If there is something wrong, make syscall to get `SYS_geterr' to get error code to see what exactly happens and store it in errno . */ syscall \num /* Make syscall with arg=`\num'. */ - addi $r1, $r0, 1 - bnez $r1, 1f /* Branch if success. */ - syscall SYS_geterr /* There is something wrong. */ - s.w $r0, errno /* Store error code into errno. */ - move $r0, -1 -1: - ret - .size \name, .-\name + j __syscall_error_handler + .size \name, .-\name .endm #endif /* _SYSCALL_EXTRA_H */