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>
17 #include <linux/err.h>
19 static inline long syscall_get_nr(struct task_struct *task,
23 * We always sign-extend a -1 value being set here,
24 * so this is always either -1L or a syscall number.
29 static inline void syscall_rollback(struct task_struct *task,
32 regs->ax = regs->orig_ax;
35 static inline long syscall_get_error(struct task_struct *task,
38 unsigned long error = regs->ax;
39 #ifdef CONFIG_IA32_EMULATION
41 * TS_COMPAT is set for 32-bit syscall entries and then
42 * remains set until we return to user mode.
44 if (task_thread_info(task)->status & TS_COMPAT)
46 * Sign-extend the value so (int)-EFOO becomes (long)-EFOO
47 * and will match correctly in comparisons.
49 error = (long) (int) error;
51 return IS_ERR_VALUE(error) ? error : 0;
54 static inline long syscall_get_return_value(struct task_struct *task,
60 static inline void syscall_set_return_value(struct task_struct *task,
64 regs->ax = (long) error ?: val;
69 static inline void syscall_get_arguments(struct task_struct *task,
71 unsigned int i, unsigned int n,
75 memcpy(args, ®s->bx + i, n * sizeof(args[0]));
78 static inline void syscall_set_arguments(struct task_struct *task,
80 unsigned int i, unsigned int n,
81 const unsigned long *args)
84 memcpy(®s->bx + i, args, n * sizeof(args[0]));
87 #else /* CONFIG_X86_64 */
89 static inline void syscall_get_arguments(struct task_struct *task,
91 unsigned int i, unsigned int n,
94 # ifdef CONFIG_IA32_EMULATION
95 if (task_thread_info(task)->status & TS_COMPAT)
150 static inline void syscall_set_arguments(struct task_struct *task,
151 struct pt_regs *regs,
152 unsigned int i, unsigned int n,
153 const unsigned long *args)
155 # ifdef CONFIG_IA32_EMULATION
156 if (task_thread_info(task)->status & TS_COMPAT)
209 #endif /* CONFIG_X86_32 */
211 #endif /* _ASM_SYSCALL_H */