2 * Access to user system call parameters and results
4 * Copyright (C) 2008 Red Hat, Inc. All rights reserved.
6 * This copyrighted material is made available to anyone wishing to use,
7 * modify, copy, or redistribute it subject to the terms and conditions
8 * of the GNU General Public License v.2.
10 * See asm-generic/syscall.h for descriptions of what we must do here.
13 #ifndef _ASM_SYSCALL_H
14 #define _ASM_SYSCALL_H 1
16 #include <linux/sched.h>
18 static inline long syscall_get_nr(struct task_struct *task,
22 * We always sign-extend a -1 value being set here,
23 * so this is always either -1L or a syscall number.
28 static inline void syscall_rollback(struct task_struct *task,
31 regs->ax = regs->orig_ax;
34 static inline long syscall_get_error(struct task_struct *task,
37 unsigned long error = regs->ax;
38 #ifdef CONFIG_IA32_EMULATION
40 * TS_COMPAT is set for 32-bit syscall entries and then
41 * remains set until we return to user mode.
43 if (task_thread_info(task)->status & TS_COMPAT)
45 * Sign-extend the value so (int)-EFOO becomes (long)-EFOO
46 * and will match correctly in comparisons.
48 error = (long) (int) error;
50 return error >= -4095L ? error : 0;
53 static inline long syscall_get_return_value(struct task_struct *task,
59 static inline void syscall_set_return_value(struct task_struct *task,
63 regs->ax = (long) error ?: val;
68 static inline void syscall_get_arguments(struct task_struct *task,
70 unsigned int i, unsigned int n,
74 memcpy(args, ®s->bx + i, n * sizeof(args[0]));
77 static inline void syscall_set_arguments(struct task_struct *task,
79 unsigned int i, unsigned int n,
80 const unsigned long *args)
83 memcpy(®s->bx + i, args, n * sizeof(args[0]));
86 #else /* CONFIG_X86_64 */
88 static inline void syscall_get_arguments(struct task_struct *task,
90 unsigned int i, unsigned int n,
93 # ifdef CONFIG_IA32_EMULATION
94 if (task_thread_info(task)->status & TS_COMPAT)
149 static inline void syscall_set_arguments(struct task_struct *task,
150 struct pt_regs *regs,
151 unsigned int i, unsigned int n,
152 const unsigned long *args)
154 # ifdef CONFIG_IA32_EMULATION
155 if (task_thread_info(task)->status & TS_COMPAT)
208 #endif /* CONFIG_X86_32 */
210 #endif /* _ASM_SYSCALL_H */