This source file includes following definitions.
- __put_user
- __get_user
- get_user_byte
- get_user_word
- get_user_long
- put_user_byte
- put_user_word
- put_user_long
- get_fs
- get_ds
- set_fs
1
2 #ifndef _ASM_SEGMENT_H
3 #define _ASM_SEGMENT_H
4
5 #ifdef __KERNEL__
6 #include <asm/vac-ops.h>
7 #endif
8
9 #ifndef __ASSEMBLY__
10
11
12
13
14
15
16 #define put_user(x,ptr) __put_user((unsigned long)(x),(ptr),sizeof(*(ptr)))
17 #define get_user(ptr) ((__typeof__(*(ptr)))__get_user((ptr),sizeof(*(ptr))))
18
19
20
21
22
23
24 extern int bad_user_access_length(void);
25
26
27 static inline void __put_user(unsigned long x, void * y, int size)
28 {
29 switch (size) {
30 case 1:
31 *(char *) y = x;
32 break;
33 case 2:
34 *(short *) y = x;
35 break;
36 case 4:
37 *(int *) y = x;
38 break;
39 default:
40 bad_user_access_length();
41 }
42 }
43
44
45 static inline unsigned long __get_user(const void * y, int size)
46 {
47 switch (size) {
48 case 1:
49 return *(unsigned char *) y;
50 case 2:
51 return *(unsigned short *) y;
52 case 4:
53 return *(unsigned int *) y;
54 default:
55 return bad_user_access_length();
56 }
57 }
58
59
60
61
62
63 static inline unsigned char get_user_byte(const char * addr)
64 {
65 return *addr;
66 }
67
68 #define get_fs_byte(addr) get_user_byte((char *)(addr))
69
70 static inline unsigned short get_user_word(const short *addr)
71 {
72 return *addr;
73 }
74
75 #define get_fs_word(addr) get_user_word((short *)(addr))
76
77 static inline unsigned long get_user_long(const int *addr)
78 {
79 return *addr;
80 }
81
82 #define get_fs_long(addr) get_user_long((int *)(addr))
83
84 static inline void put_user_byte(char val,char *addr)
85 {
86 *addr = val;
87 }
88
89 #define put_fs_byte(x,addr) put_user_byte((x),(char *)(addr))
90
91 static inline void put_user_word(short val,short * addr)
92 {
93 *addr = val;
94 }
95
96 #define put_fs_word(x,addr) put_user_word((x),(short *)(addr))
97
98 static inline void put_user_long(unsigned long val,int * addr)
99 {
100 *addr = val;
101 }
102
103 #define put_fs_long(x,addr) put_user_long((x),(int *)(addr))
104
105 #define memcpy_fromfs(to, from, n) memcpy((to),(from),(n))
106
107 #define memcpy_tofs(to, from, n) memcpy((to),(from),(n))
108
109
110
111
112 #define KERNEL_DS 0
113 #define USER_DS 1
114
115 extern int active_ds;
116
117 static inline int get_fs(void)
118 {
119 return active_ds;
120 }
121
122 static inline int get_ds(void)
123 {
124 return KERNEL_DS;
125 }
126
127 static inline void set_fs(int val)
128 {
129 active_ds = val;
130 }
131
132 #endif
133
134 #endif