syscall_arch.h 3.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#define __SYSCALL_LL_E(x) (x)
#define __SYSCALL_LL_O(x) (x)

#define SYSCALL_RLIM_INFINITY (-1UL/2)

#if _MIPSEL || __MIPSEL || __MIPSEL__
#define __stat_fix(st) ((st),(void)0)
#else
#include <sys/stat.h>
static inline void __stat_fix(long p)
{
	struct stat *st = (struct stat *)p;
	st->st_dev >>= 32;
	st->st_rdev >>= 32;
}
#endif

18 19 20 21
#define SYSCALL_CLOBBERLIST \
	"$1", "$3", "$10", "$11", "$12", "$13", \
	"$14", "$15", "$24", "$25", "hi", "lo", "memory"

22 23 24
static inline long __syscall0(long n)
{
	register long r7 __asm__("$7");
25
	register long r2 __asm__("$2") = n;
26
	__asm__ __volatile__ (
27 28 29
		"syscall"
		: "+&r"(r2), "=r"(r7)
		:
30
		: SYSCALL_CLOBBERLIST);
31 32 33 34 35 36 37
	return r7 ? -r2 : r2;
}

static inline long __syscall1(long n, long a)
{
	register long r4 __asm__("$4") = a;
	register long r7 __asm__("$7");
38
	register long r2 __asm__("$2") = n;
39
	__asm__ __volatile__ (
40 41 42
		"syscall"
		: "+&r"(r2), "=r"(r7)
		: "r"(r4)
43
		: SYSCALL_CLOBBERLIST);
44 45 46 47 48 49 50 51
	return r7 ? -r2 : r2;
}

static inline long __syscall2(long n, long a, long b)
{
	register long r4 __asm__("$4") = a;
	register long r5 __asm__("$5") = b;
	register long r7 __asm__("$7");
52
	register long r2 __asm__("$2") = n;
53
	__asm__ __volatile__ (
54 55 56
		"syscall"
		: "+&r"(r2), "=r"(r7)
		: "r"(r4), "r"(r5)
57
		: SYSCALL_CLOBBERLIST);
58 59 60 61 62 63 64 65 66 67 68 69
	if (r7) return -r2;
	long ret = r2;
	if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat) __stat_fix(b);
	return ret;
}

static inline long __syscall3(long n, long a, long b, long c)
{
	register long r4 __asm__("$4") = a;
	register long r5 __asm__("$5") = b;
	register long r6 __asm__("$6") = c;
	register long r7 __asm__("$7");
70
	register long r2 __asm__("$2") = n;
71
	__asm__ __volatile__ (
72 73 74
		"syscall"
		: "+&r"(r2), "=r"(r7)
		: "r"(r4), "r"(r5), "r"(r6)
75
		: SYSCALL_CLOBBERLIST);
76 77 78 79 80 81 82 83 84 85 86 87
	if (r7) return -r2;
	long ret = r2;
	if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat) __stat_fix(b);
	return ret;
}

static inline long __syscall4(long n, long a, long b, long c, long d)
{
	register long r4 __asm__("$4") = a;
	register long r5 __asm__("$5") = b;
	register long r6 __asm__("$6") = c;
	register long r7 __asm__("$7") = d;
88
	register long r2 __asm__("$2") = n;
89
	__asm__ __volatile__ (
90 91 92
		"syscall"
		: "+&r"(r2), "+r"(r7)
		: "r"(r4), "r"(r5), "r"(r6)
93
		: SYSCALL_CLOBBERLIST);
94 95 96
	if (r7) return -r2;
	long ret = r2;
	if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat) __stat_fix(b);
97
	if (n == SYS_newfstatat) __stat_fix(c);
98 99 100 101 102
	return ret;
}

static inline long __syscall5(long n, long a, long b, long c, long d, long e)
{
103 104 105 106 107
	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;
108
	register long r2 __asm__("$2") = n;
109
	__asm__ __volatile__ (
110 111 112
		"syscall"
		: "+&r"(r2), "+r"(r7)
		: "r"(r4), "r"(r5), "r"(r6), "r"(r8)
113
		: SYSCALL_CLOBBERLIST);
114
	if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat) __stat_fix(b);
115
	if (n == SYS_newfstatat) __stat_fix(c);
116 117 118 119 120
	return r2;
}

static inline long __syscall6(long n, long a, long b, long c, long d, long e, long f)
{
121 122 123 124 125
	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;
126
	register long r9 __asm__("$9") = f;
127
	register long r2 __asm__("$2") = n;
128
	__asm__ __volatile__ (
129 130 131
		"syscall"
		: "+&r"(r2), "+r"(r7)
		: "r"(r4), "r"(r5), "r"(r6), "r"(r8), "r"(r9)
132
		: SYSCALL_CLOBBERLIST);
133
	if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat) __stat_fix(b);
134
	if (n == SYS_newfstatat) __stat_fix(c);
135 136 137 138 139 140
	return r2;
}

#define VDSO_USEFUL
#define VDSO_CGT_SYM "__vdso_clock_gettime"
#define VDSO_CGT_VER "LINUX_2.6"