From e0e5d176273e979187cc4a8164643ee0d379e9a6 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sun, 28 Sep 2003 15:12:27 +0000 Subject: [PATCH] Handy functions to copy from and to userland reference parameters. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4837 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/kernel/util/syscall_args.h | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 headers/private/kernel/util/syscall_args.h diff --git a/headers/private/kernel/util/syscall_args.h b/headers/private/kernel/util/syscall_args.h new file mode 100644 index 0000000000..f988b8b172 --- /dev/null +++ b/headers/private/kernel/util/syscall_args.h @@ -0,0 +1,30 @@ +// syscall_args.h + +#ifndef _SYSCALL_ARGS_H +#define _SYSCALL_ARGS_H + +#include + +// copy_ref_var_from_user +template +inline +status_t +copy_ref_var_from_user(T *user, T &kernel) +{ + if (CHECK_USER_ADDRESS(user)) + return B_BAD_ADDRESS; + return user_memcpy(&kernel, user, sizeof(T)); +} + +// copy_ref_var_to_user +template +inline +status_t +copy_ref_var_to_user(T &kernel, T *user) +{ + if (CHECK_USER_ADDRESS(user)) + return B_BAD_ADDRESS; + return user_memcpy(user, &kernel, sizeof(T)); +} + +#endif // _SYSCALL_ARGS_H