• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisionfa9cfbfcb70bd3736ec54eeeb4d0796aa4b9521f (tree)
Zeit2018-11-23 22:24:29
AutorVolodymyr Boyko <boyko.cxx@gmai...>
CommiterWaldemar Brodkorb

Log Message

Defined INLINE_SYSCALL_NOERR_NCS in mips/bits/syscalls.h

On Linux/MIPS (O32 ABI) for system call we have two result registers - v0 and a3.
v0 contains actual syscall result on success or error number on fail, a3 set to 0/1
for indicating syscall success/fail. (if a3 == 1, v0 contains errno).
Now as we can see from definition of handle_sys (arch/mips/kernel/scall32-o32.S),
handler treats returned by syscall function (let's call "original") values in
range [-EMAXERRNO; 0[ as -errno, a3 is set to 1 and final returned (to userspace)
value is (-original).

INLINE_SYSCALL_NOERR_NCS defined in mips/bits/syscalls.h will handle
this behaviour.

Signed-off-by: Volodymyr Boyko <boyko.cxx@gmail.com>

Ändern Zusammenfassung

Diff

--- a/libc/sysdeps/linux/mips/bits/syscalls.h
+++ b/libc/sysdeps/linux/mips/bits/syscalls.h
@@ -29,6 +29,16 @@
2929 } \
3030 result_var; })
3131
32+#define INLINE_SYSCALL_NOERR_NCS(name, nr, args...) \
33+({ \
34+ INTERNAL_SYSCALL_DECL(err); \
35+ long res = INTERNAL_SYSCALL_NCS(name, err, nr, args); \
36+ if (unlikely(INTERNAL_SYSCALL_ERROR_P(res, err))) { \
37+ res = -res; \
38+ } \
39+ res; \
40+})
41+
3242 #define INTERNAL_SYSCALL_DECL(err) long err attribute_unused
3343
3444 #define INTERNAL_SYSCALL_ERROR_P(val, err) ((long) (err))