summaryrefslogtreecommitdiffstats
path: root/libgloss/nds32/syscall_extra.h
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2014-03-21 20:16:14 +0000
committerJeff Johnston <jjohnstn@redhat.com>2014-03-21 20:16:14 +0000
commit9246fbeced54764200564131ab1fad7e7819e91f (patch)
treea68687ead3b627c5efbf79c0a2da5155b433ec84 /libgloss/nds32/syscall_extra.h
parent5805cb1f8c1644bb888b03538af2aec30ca27da0 (diff)
downloadcygnal-9246fbeced54764200564131ab1fad7e7819e91f.tar.gz
cygnal-9246fbeced54764200564131ab1fad7e7819e91f.tar.bz2
cygnal-9246fbeced54764200564131ab1fad7e7819e91f.zip
2014-03-21 Sabrini Ni <sabrinanitw@gmail.com>
* nds32/syscall_extra.h: Define macro. * nds32/syscall_argv.S: Use define macro. * nds32/syscall_argvlen.S: Ditto. * nds32/syscall_chdir.S: Ditto. * nds32/syscall_chmod.S: Ditto. * nds32/syscall_close.S: Ditto. * nds32/syscall_fstat.S: Ditto. * nds32/syscall_getpid.S: Ditto. * nds32/syscall_gettimeofday.S: Ditto. * nds32/syscall_isatty.S: Ditto. * nds32/syscall_kill.S: Ditto. * nds32/syscall_link.S: Ditto. * nds32/syscall_lseek.S: Ditto. * nds32/syscall_open.S: Ditto. * nds32/syscall_read.S: Ditto. * nds32/syscall_rename.S: Ditto. * nds32/syscall_stat.S: Ditto. * nds32/syscall_system.S: Ditto. * nds32/syscall_time.S: Ditto. * nds32/syscall_times.S: Ditto. * nds32/syscall_unlink.S: Ditto. * nds32/syscall_utime.S: Ditto. * nds32/syscall_write.S: Ditto.
Diffstat (limited to 'libgloss/nds32/syscall_extra.h')
-rw-r--r--libgloss/nds32/syscall_extra.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/libgloss/nds32/syscall_extra.h b/libgloss/nds32/syscall_extra.h
index f2ab2d562..73d36b973 100644
--- a/libgloss/nds32/syscall_extra.h
+++ b/libgloss/nds32/syscall_extra.h
@@ -38,4 +38,27 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define SYS_geterr 6001
+
+/* Define macros that generate assembly output. */
+.macro SYS_WRAPPER name num
+ .text
+ .global \name
+ .type \name, @function
+ .align 2
+\name:
+ /* Make syscall with arg=`\num'.
+ Reture value `-1' stored in $r0 means there is something wrong.
+ 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
+.endm
+
#endif /* _SYSCALL_EXTRA_H */