#ifndef __ASSEMBLER__
-#define INLINE_SYSCALL(name, nr, args...) \
+#define INLINE_SYSCALL_NCS(name, nr, args...) \
({ \
long _sc_ret, _sc_err; \
- inline_syscall##nr(__NR_##name, args); \
+ inline_syscall##nr(name, args); \
if (__builtin_expect (_sc_err, 0)) \
{ \
__set_errno (_sc_ret); \
_sc_ret; \
})
-#define INTERNAL_SYSCALL(name, err_out, nr, args...) \
+#define INTERNAL_SYSCALL_NCS(name, err_out, nr, args...) \
({ \
long _sc_ret, _sc_err; \
- inline_syscall##nr(__NR_##name, args); \
+ inline_syscall##nr(name, args); \
err_out = _sc_err; \
_sc_ret; \
})
#include <errno.h>
-#define INLINE_SYSCALL(name, nr, args...) \
- ({ unsigned int _inline_sys_result = INTERNAL_SYSCALL (name, , nr, args); \
+#define INLINE_SYSCALL_NCS(name, nr, args...) \
+ ({ unsigned int _inline_sys_result = INTERNAL_SYSCALL_NCS (name, , nr, args); \
if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (_inline_sys_result, ), 0)) \
{ \
__set_errno (INTERNAL_SYSCALL_ERRNO (_inline_sys_result, )); \
#if !defined(__thumb__)
#if defined(__ARM_EABI__)
-#define INTERNAL_SYSCALL(name, err, nr, args...) \
+#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
({unsigned int __sys_result; \
{ \
register int _a1 __asm__ ("r0"), _nr __asm__ ("r7"); \
LOAD_ARGS_##nr (args) \
- _nr = SYS_ify(name); \
+ _nr = (name); \
__asm__ __volatile__ ("swi 0x0 @ syscall " #name \
: "=r" (_a1) \
: "r" (_nr) ASM_ARGS_##nr \
(int) __sys_result; })
#else /* defined(__ARM_EABI__) */
-#define INTERNAL_SYSCALL(name, err, nr, args...) \
+#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
({ unsigned int __sys_result; \
{ \
register int _a1 __asm__ ("a1"); \
LOAD_ARGS_##nr (args) \
__asm__ __volatile__ ("swi %1 @ syscall " #name \
: "=r" (_a1) \
- : "i" (SYS_ify(name)) ASM_ARGS_##nr \
+ : "i" (name) ASM_ARGS_##nr \
: "memory"); \
__sys_result = _a1; \
} \
/* We can't use push/pop inside the asm because that breaks
unwinding (ie. thread cancellation).
*/
-#define INTERNAL_SYSCALL(name, err, nr, args...) \
+#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
({ unsigned int __sys_result; \
{ \
int _sys_buf[2]; \
register int _a1 __asm__ ("a1"); \
register int *_v3 __asm__ ("v3") = _sys_buf; \
- *_v3 = (int) (SYS_ify(name)); \
+ *_v3 = (int) (name); \
LOAD_ARGS_##nr (args) \
__asm__ __volatile__ ("str r7, [v3, #4]\n" \
"\tldr r7, [v3]\n" \
#include <errno.h>
-#define INTERNAL_SYSCALL(name, err, nr, args...) \
+#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
({ \
register int _a1 __asm__("r12"); \
- register int _scno __asm__("r8") = SYS_ify(name); \
+ register int _scno __asm__("r8") = name; \
LOAD_ARGS_##nr (args); \
__asm__ __volatile__("scall /* syscall " #name " */" \
: "=r" (_a1) \
#ifndef __ASSEMBLER__
-#define INTERNAL_SYSCALL(name, err, nr, args...) \
+#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
({ \
long __res; \
__asm__ __volatile__ ( \
"excpt 0;\n\t" \
: "=q0" (__res) \
- : "qA" (__NR_##name) ASMFMT_##nr(args) \
+ : "qA" (name) ASMFMT_##nr(args) \
: "memory","CC"); \
__res; \
})
/* Define a macro which expands into the inline wrapper code for a system call */
#ifndef INLINE_SYSCALL
-# define INLINE_SYSCALL(name, nr, args...) \
+# define INLINE_SYSCALL(name, nr, args...) INLINE_SYSCALL_NCS(__NR_##name, nr, args)
+#endif
+
+/* Just like INLINE_SYSCALL(), but take a non-constant syscall (NCS) argument */
+#ifndef INLINE_SYSCALL_NCS
+# define INLINE_SYSCALL_NCS(name, nr, args...) \
({ \
INTERNAL_SYSCALL_DECL(err); \
- long res = INTERNAL_SYSCALL(name, err, nr, args); \
+ long res = INTERNAL_SYSCALL_NCS(name, err, nr, args); \
if (unlikely(INTERNAL_SYSCALL_ERROR_P(res, err))) { \
__set_errno(INTERNAL_SYSCALL_ERRNO(res, err)); \
res = -1L; \
})
#endif
+/* No point in forcing people to implement both when they only need one */
+#ifndef INTERNAL_SYSCALL
+# define INTERNAL_SYSCALL(name, err, nr, args...) INTERNAL_SYSCALL_NCS(__NR_##name, err, nr, args)
+#endif
+
+#ifndef INTERNAL_SYSCALL_NCS
+# error your port needs to define INTERNAL_SYSCALL_NCS in bits/syscalls.h
+#endif
+
#ifndef _syscall0
#define C_DECL_ARGS_0() void
*/
#error You have not provided architecture specific bits/syscalls.h
-#error You should need to define only INTERNAL_SYSCALL
+#error You should need to define only INTERNAL_SYSCALL_NCS
".endm\n\t");
#endif
-#define INTERNAL_SYSCALL(name, err, nr, args...) \
+#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
({ \
register unsigned int resultvar; \
- __asm__ __volatile__ ( \
+ __asm__ __volatile__ ( \
LOADARGS_##nr \
"movl %1, %%eax\n\t" \
"int $0x80\n\t" \
RESTOREARGS_##nr \
: "=a" (resultvar) \
- : "i" (__NR_##name) ASMFMT_##nr(args) : "memory", "cc"); \
+ : "i" (name) ASMFMT_##nr(args) : "memory", "cc"); \
(int) resultvar; })
#define LOADARGS_0
: "memory" ASM_CLOBBERS_##nr); \
_retval = _r8;
-#define DO_INLINE_SYSCALL(name, nr, args...) \
- DO_INLINE_SYSCALL_NCS (__NR_##name, nr, ##args)
-
-#define INLINE_SYSCALL(name, nr, args...) \
+#define INLINE_SYSCALL_NCS(name, nr, args...) \
({ \
- DO_INLINE_SYSCALL_NCS (__NR_##name, nr, args) \
+ DO_INLINE_SYSCALL_NCS (name, nr, args) \
if (_r10 == -1) \
{ \
__set_errno (_retval); \
DO_INLINE_SYSCALL_NCS (name, nr, args) \
err = _r10; \
_retval; })
-#define INTERNAL_SYSCALL(name, err, nr, args...) \
- INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args)
#define INTERNAL_SYSCALL_ERROR_P(val, err) (err == -1)
/* Define a macro which expands into the inline wrapper code for a system
call. */
-#define INLINE_SYSCALL(name, nr, args...) \
+#define INLINE_SYSCALL_NCS(name, nr, args...) \
({ INTERNAL_SYSCALL_DECL(err); \
- long result_var = INTERNAL_SYSCALL (name, err, nr, args); \
+ long result_var = INTERNAL_SYSCALL_NCS (name, err, nr, args); \
if ( INTERNAL_SYSCALL_ERROR_P (result_var, err) ) \
{ \
__set_errno (INTERNAL_SYSCALL_ERRNO (result_var, err)); \
(int) r3; \
})
-# define INLINE_SYSCALL(name, nr, args...) \
- ({ \
- INTERNAL_SYSCALL_DECL (sc_err); \
- long int sc_ret = INTERNAL_SYSCALL (name, sc_err, nr, args); \
- if (INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err)) \
- { \
- __set_errno (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err)); \
- sc_ret = -1L; \
- } \
- sc_ret; \
- })
-
/* Define a macro which expands inline into the wrapper code for a system
call. This use is for internal calls that do not need to handle errors
normally. It will never touch errno.
err = r0; \
(int) r3; \
})
-# define INTERNAL_SYSCALL(name, err, nr, args...) \
- INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args)
# define INTERNAL_SYSCALL_ERROR_P(val, err) \
((void) (val), __builtin_expect ((err) & (1 << 28), 0))
register long int r1 __asm__ ("%r1") = (long int) (_arg6); \
register long int r2 __asm__ ("%r2") = (long int) (_arg7)
-#define INLINE_SYSCALL(name, nr, args...) \
- ({ \
- unsigned int __resultvar = INTERNAL_SYSCALL (name, , nr, args); \
- if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (__resultvar, ), 0)) \
- { \
- __set_errno (INTERNAL_SYSCALL_ERRNO (__resultvar, )); \
- __resultvar = 0xffffffff; \
- } \
- (int) __resultvar; })
-
-#define INTERNAL_SYSCALL(name, err, nr, args...) \
- ({ \
- unsigned long int resultvar; \
- register long int r3 __asm__ ("%r3") = SYS_ify (name); \
- SUBSTITUTE_ARGS_##nr(args); \
- \
- __asm__ volatile (SYSCALL_INST_STR##nr SYSCALL_INST_PAD \
- : "=z" (resultvar) \
- : "r" (r3) ASMFMT_##nr \
- : "memory"); \
- \
- (int) resultvar; })
-
/* The _NCS variant allows non-constant syscall numbers. */
#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
({ \
#define DEBUG_SYSCALL(name) do{} while(0)
#endif
-
-#define INTERNAL_SYSCALL( name, err, nr, args...) \
- INTERNAL_SYSCALL_NCS( __NR_##name, err, nr, args )
-
-
#define INTERNAL_SYSCALL_NCS(sys_num, err, nr, args...) \
({ \
unsigned int __res; \
: "=a" (resultvar) \
: "0" (name) ASM_ARGS_##nr : "memory", "cc", "r11", "cx"); \
(long) resultvar; })
-#define INTERNAL_SYSCALL(name, err, nr, args...) \
- INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args)
#define LOAD_ARGS_0()
#define LOAD_REGS_0
: "memory"); \
(long) _a2; })
-#define INTERNAL_SYSCALL(name, err, nr, args...) \
- INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args)
-
#endif /* not __ASSEMBLER__ */
#endif /* _BITS_SYSCALLS_H */