X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=arch%2Fmips%2Fsyscall_arch.h;h=5b7c38de2043f6250db3cb691aa1782a71e3d273;hb=159d1f6c02569091c7a48bdb2e2e824b844a1902;hp=1aa2c812a1e48455f584cbd222d6517e9cc12294;hpb=f61be1f875a2758509d6e9e2cf6f1d9603b28b65;p=musl diff --git a/arch/mips/syscall_arch.h b/arch/mips/syscall_arch.h index 1aa2c812..5b7c38de 100644 --- a/arch/mips/syscall_arch.h +++ b/arch/mips/syscall_arch.h @@ -3,34 +3,28 @@ ((union { long long ll; long l[2]; }){ .ll = x }).l[1] #define __SYSCALL_LL_O(x) 0, __SYSCALL_LL_E((x)) -long (__syscall)(long, ...); - #define SYSCALL_RLIM_INFINITY (-1UL/2) -#if _MIPSEL || __MIPSEL || __MIPSEL__ -#define __stat_fix(st) ((st),(void)0) +#if __mips_isa_rev >= 6 +#define SYSCALL_CLOBBERLIST \ + "$1", "$3", "$11", "$12", "$13", \ + "$14", "$15", "$24", "$25", "memory" #else -#include -static inline void __stat_fix(long p) -{ - struct stat *st = (struct stat *)p; - st->st_dev >>= 32; - st->st_rdev >>= 32; -} +#define SYSCALL_CLOBBERLIST \ + "$1", "$3", "$11", "$12", "$13", \ + "$14", "$15", "$24", "$25", "hi", "lo", "memory" #endif -#ifndef __clang__ - static inline long __syscall0(long n) { register long r7 __asm__("$7"); register long r2 __asm__("$2"); __asm__ __volatile__ ( "addu $2,$0,%2 ; syscall" - : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7) - : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", - "$14", "$15", "$24", "$25", "hi", "lo", "memory"); - return r7 ? -r2 : r2; + : "=&r"(r2), "=r"(r7) + : "ir"(n), "0"(r2) + : SYSCALL_CLOBBERLIST, "$8", "$9", "$10"); + return r7 && r2>0 ? -r2 : r2; } static inline long __syscall1(long n, long a) @@ -40,11 +34,10 @@ static inline long __syscall1(long n, long a) register long r2 __asm__("$2"); __asm__ __volatile__ ( "addu $2,$0,%2 ; syscall" - : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7), - "r"(r4) - : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", - "$14", "$15", "$24", "$25", "hi", "lo", "memory"); - return r7 ? -r2 : r2; + : "=&r"(r2), "=r"(r7) + : "ir"(n), "0"(r2), "r"(r4) + : SYSCALL_CLOBBERLIST, "$8", "$9", "$10"); + return r7 && r2>0 ? -r2 : r2; } static inline long __syscall2(long n, long a, long b) @@ -55,13 +48,10 @@ static inline long __syscall2(long n, long a, long b) register long r2 __asm__("$2"); __asm__ __volatile__ ( "addu $2,$0,%2 ; syscall" - : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7), - "r"(r4), "r"(r5) - : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", - "$14", "$15", "$24", "$25", "hi", "lo", "memory"); - if (r7) return -r2; - if (n == SYS_stat64 || n == SYS_fstat64 || n == SYS_lstat64) __stat_fix(b); - return r2; + : "=&r"(r2), "=r"(r7) + : "ir"(n), "0"(r2), "r"(r4), "r"(r5) + : SYSCALL_CLOBBERLIST, "$8", "$9", "$10"); + return r7 && r2>0 ? -r2 : r2; } static inline long __syscall3(long n, long a, long b, long c) @@ -73,13 +63,10 @@ static inline long __syscall3(long n, long a, long b, long c) register long r2 __asm__("$2"); __asm__ __volatile__ ( "addu $2,$0,%2 ; syscall" - : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7), - "r"(r4), "r"(r5), "r"(r6) - : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", - "$14", "$15", "$24", "$25", "hi", "lo", "memory"); - if (r7) return -r2; - if (n == SYS_stat64 || n == SYS_fstat64 || n == SYS_lstat64) __stat_fix(b); - return r2; + : "=&r"(r2), "=r"(r7) + : "ir"(n), "0"(r2), "r"(r4), "r"(r5), "r"(r6) + : SYSCALL_CLOBBERLIST, "$8", "$9", "$10"); + return r7 && r2>0 ? -r2 : r2; } static inline long __syscall4(long n, long a, long b, long c, long d) @@ -91,69 +78,76 @@ static inline long __syscall4(long n, long a, long b, long c, long d) register long r2 __asm__("$2"); __asm__ __volatile__ ( "addu $2,$0,%2 ; syscall" - : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7), - "r"(r4), "r"(r5), "r"(r6) - : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", - "$14", "$15", "$24", "$25", "hi", "lo", "memory"); - if (r7) return -r2; - if (n == SYS_stat64 || n == SYS_fstat64 || n == SYS_lstat64) __stat_fix(b); - if (n == SYS_fstatat) __stat_fix(c); - return r2; -} - -#else - -static inline long __syscall0(long n) -{ - return (__syscall)(n); -} - -static inline long __syscall1(long n, long a) -{ - return (__syscall)(n, a); + : "=&r"(r2), "+r"(r7) + : "ir"(n), "0"(r2), "r"(r4), "r"(r5), "r"(r6) + : SYSCALL_CLOBBERLIST, "$8", "$9", "$10"); + return r7 && r2>0 ? -r2 : r2; } -static inline long __syscall2(long n, long a, long b) +static inline long __syscall5(long n, long a, long b, long c, long d, long e) { - long r2 = (__syscall)(n, a, b); - if (r2 > -4096UL) return -r2; - if (n == SYS_stat64 || n == SYS_fstat64 || n == SYS_lstat64) __stat_fix(b); - return r2; + register long r4 __asm__("$4") = a; + register long r5 __asm__("$5") = b; + register long r6 __asm__("$6") = c; + register long r7 __asm__("$7") = d; + register long r8 __asm__("$8") = e; + register long r2 __asm__("$2"); + __asm__ __volatile__ ( + "subu $sp,$sp,32 ; sw $8,16($sp) ; " + "addu $2,$0,%3 ; syscall ;" + "addu $sp,$sp,32" + : "=&r"(r2), "+r"(r7), "+r"(r8) + : "ir"(n), "0"(r2), "r"(r4), "r"(r5), "r"(r6) + : SYSCALL_CLOBBERLIST, "$9", "$10"); + return r7 && r2>0 ? -r2 : r2; } -static inline long __syscall3(long n, long a, long b, long c) +static inline long __syscall6(long n, long a, long b, long c, long d, long e, long f) { - long r2 = (__syscall)(n, a, b, c); - if (r2 > -4096UL) return -r2; - if (n == SYS_stat64 || n == SYS_fstat64 || n == SYS_lstat64) __stat_fix(b); - return r2; + register long r4 __asm__("$4") = a; + register long r5 __asm__("$5") = b; + register long r6 __asm__("$6") = c; + register long r7 __asm__("$7") = d; + register long r8 __asm__("$8") = e; + register long r9 __asm__("$9") = f; + register long r2 __asm__("$2"); + __asm__ __volatile__ ( + "subu $sp,$sp,32 ; sw $8,16($sp) ; sw $9,20($sp) ; " + "addu $2,$0,%4 ; syscall ;" + "addu $sp,$sp,32" + : "=&r"(r2), "+r"(r7), "+r"(r8), "+r"(r9) + : "ir"(n), "0"(r2), "r"(r4), "r"(r5), "r"(r6) + : SYSCALL_CLOBBERLIST, "$10"); + return r7 && r2>0 ? -r2 : r2; } -static inline long __syscall4(long n, long a, long b, long c, long d) +static inline long __syscall7(long n, long a, long b, long c, long d, long e, long f, long g) { - long r2 = (__syscall)(n, a, b, c, d); - if (r2 > -4096UL) return -r2; - if (n == SYS_stat64 || n == SYS_fstat64 || n == SYS_lstat64) __stat_fix(b); - if (n == SYS_fstatat) __stat_fix(c); - return r2; + register long r4 __asm__("$4") = a; + register long r5 __asm__("$5") = b; + register long r6 __asm__("$6") = c; + register long r7 __asm__("$7") = d; + register long r8 __asm__("$8") = e; + register long r9 __asm__("$9") = f; + register long r10 __asm__("$10") = g; + register long r2 __asm__("$2"); + __asm__ __volatile__ ( + "subu $sp,$sp,32 ; sw $8,16($sp) ; sw $9,20($sp) ; sw $10,24($sp) ; " + "addu $2,$0,%5 ; syscall ;" + "addu $sp,$sp,32" + : "=&r"(r2), "+r"(r7), "+r"(r8), "+r"(r9), "+r"(r10) + : "ir"(n), "0"(r2), "r"(r4), "r"(r5), "r"(r6) + : SYSCALL_CLOBBERLIST); + return r7 && r2>0 ? -r2 : r2; } -#endif +#define VDSO_USEFUL +#define VDSO_CGT32_SYM "__vdso_clock_gettime" +#define VDSO_CGT32_VER "LINUX_2.6" +#define VDSO_CGT_SYM "__vdso_clock_gettime64" +#define VDSO_CGT_VER "LINUX_2.6" -static inline long __syscall5(long n, long a, long b, long c, long d, long e) -{ - long r2 = (__syscall)(n, a, b, c, d, e); - if (r2 > -4096UL) return -r2; - if (n == SYS_stat64 || n == SYS_fstat64 || n == SYS_lstat64) __stat_fix(b); - if (n == SYS_fstatat) __stat_fix(c); - return r2; -} +#define SO_SNDTIMEO_OLD 0x1005 +#define SO_RCVTIMEO_OLD 0x1006 -static inline long __syscall6(long n, long a, long b, long c, long d, long e, long f) -{ - long r2 = (__syscall)(n, a, b, c, d, e, f); - if (r2 > -4096UL) return -r2; - if (n == SYS_stat64 || n == SYS_fstat64 || n == SYS_lstat64) __stat_fix(b); - if (n == SYS_fstatat) __stat_fix(c); - return r2; -} +#undef SYS_socketcall