Pull altix-fpga-reset into release branch
[sfrench/cifs-2.6.git] / arch / um / include / um_uaccess.h
1 /* 
2  * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
3  * Licensed under the GPL
4  */
5
6 #ifndef __ARCH_UM_UACCESS_H
7 #define __ARCH_UM_UACCESS_H
8
9 #include "linux/config.h"
10 #include "choose-mode.h"
11
12 #ifdef CONFIG_MODE_TT
13 #include "uaccess-tt.h"
14 #endif
15
16 #ifdef CONFIG_MODE_SKAS
17 #include "uaccess-skas.h"
18 #endif
19
20 #define access_ok(type, addr, size) \
21         CHOOSE_MODE_PROC(access_ok_tt, access_ok_skas, type, addr, size)
22
23 static inline int copy_from_user(void *to, const void __user *from, int n)
24 {
25         return(CHOOSE_MODE_PROC(copy_from_user_tt, copy_from_user_skas, to,
26                                 from, n));
27 }
28
29 static inline int copy_to_user(void __user *to, const void *from, int n)
30 {
31         return(CHOOSE_MODE_PROC(copy_to_user_tt, copy_to_user_skas, to, 
32                                 from, n));
33 }
34
35 /*
36  * strncpy_from_user: - Copy a NUL terminated string from userspace.
37  * @dst:   Destination address, in kernel space.  This buffer must be at
38  *         least @count bytes long.
39  * @src:   Source address, in user space.
40  * @count: Maximum number of bytes to copy, including the trailing NUL.
41  *
42  * Copies a NUL-terminated string from userspace to kernel space.
43  *
44  * On success, returns the length of the string (not including the trailing
45  * NUL).
46  *
47  * If access to userspace fails, returns -EFAULT (some data may have been
48  * copied).
49  *
50  * If @count is smaller than the length of the string, copies @count bytes
51  * and returns @count.
52  */
53
54 static inline int strncpy_from_user(char *dst, const char __user *src, int count)
55 {
56         return(CHOOSE_MODE_PROC(strncpy_from_user_tt, strncpy_from_user_skas,
57                                 dst, src, count));
58 }
59
60 /*
61  * __clear_user: - Zero a block of memory in user space, with less checking.
62  * @to:   Destination address, in user space.
63  * @n:    Number of bytes to zero.
64  *
65  * Zero a block of memory in user space.  Caller must check
66  * the specified block with access_ok() before calling this function.
67  *
68  * Returns number of bytes that could not be cleared.
69  * On success, this will be zero.
70  */
71 static inline int __clear_user(void *mem, int len)
72 {
73         return(CHOOSE_MODE_PROC(__clear_user_tt, __clear_user_skas, mem, len));
74 }
75
76 /*
77  * clear_user: - Zero a block of memory in user space.
78  * @to:   Destination address, in user space.
79  * @n:    Number of bytes to zero.
80  *
81  * Zero a block of memory in user space.
82  *
83  * Returns number of bytes that could not be cleared.
84  * On success, this will be zero.
85  */
86 static inline int clear_user(void __user *mem, int len)
87 {
88         return(CHOOSE_MODE_PROC(clear_user_tt, clear_user_skas, mem, len));
89 }
90
91 /*
92  * strlen_user: - Get the size of a string in user space.
93  * @str: The string to measure.
94  * @n:   The maximum valid length
95  *
96  * Get the size of a NUL-terminated string in user space.
97  *
98  * Returns the size of the string INCLUDING the terminating NUL.
99  * On exception, returns 0.
100  * If the string is too long, returns a value greater than @n.
101  */
102 static inline int strnlen_user(const void __user *str, long len)
103 {
104         return(CHOOSE_MODE_PROC(strnlen_user_tt, strnlen_user_skas, str, len));
105 }
106
107 #endif
108
109 /*
110  * Overrides for Emacs so that we follow Linus's tabbing style.
111  * Emacs will notice this stuff at the end of the file and automatically
112  * adjust the settings for this buffer only.  This must remain at the end
113  * of the file.
114  * ---------------------------------------------------------------------------
115  * Local variables:
116  * c-file-style: "linux"
117  * End:
118  */