1
/*********************************************************
2
* Copyright (C) 2002 VMware, Inc. All rights reserved.
4
* This program is free software; you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License as published by the
6
* Free Software Foundation version 2 and no later version.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13
* You should have received a copy of the GNU General Public License along
14
* with this program; if not, write to the Free Software Foundation, Inc.,
15
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
*********************************************************/
19
#ifndef __COMPAT_UACCESS_H__
20
# define __COMPAT_UACCESS_H__
23
/* User space access functions moved in 2.1.7 to asm/uaccess.h --hpreg */
24
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 1, 7)
25
# include <asm/uaccess.h>
27
# include <asm/segment.h>
31
/* get_user() API modified in 2.1.4 to take 2 arguments --hpreg */
32
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 1, 4)
33
# define compat_get_user get_user
36
* We assign 0 to the variable in case of failure to prevent "`_var' might be
37
* used uninitialized in this function" compiler warnings. I think it is OK,
38
* because the hardware-based version in newer kernels probably has the same
39
* semantics and does not guarantee that the value of _var will not be
40
* modified, should the access fail --hpreg
42
# define compat_get_user(_var, _uvAddr) ({ \
45
_status = verify_area(VERIFY_READ, _uvAddr, sizeof(*(_uvAddr))); \
47
(_var) = get_user(_uvAddr); \
57
* The copy_from_user() API appeared in 2.1.4
59
* The emulation is not perfect here, but it is conservative: on failure, we
60
* always return the total size, instead of the potentially smaller faulty
63
* Since 2.5.55 copy_from_user() is no longer macro.
65
#if !defined(copy_from_user) && LINUX_VERSION_CODE < KERNEL_VERSION(2, 2, 0)
66
# define copy_from_user(_to, _from, _size) ( \
67
verify_area(VERIFY_READ, _from, _size) \
69
: (memcpy_fromfs(_to, _from, _size), 0) \
71
# define copy_to_user(_to, _from, _size) ( \
72
verify_area(VERIFY_WRITE, _to, _size) \
74
: (memcpy_tofs(_to, _from, _size), 0) \
79
#endif /* __COMPAT_UACCESS_H__ */