Pull trivial into release branch
[sfrench/cifs-2.6.git] / arch / um / os-Linux / tls.c
1 #include <errno.h>
2 #include <sys/ptrace.h>
3 #include <asm/ldt.h>
4 #include "sysdep/tls.h"
5 #include "uml-config.h"
6
7 /* TLS support - we basically rely on the host's one.*/
8
9 /* In TT mode, this should be called only by the tracing thread, and makes sense
10  * only for PTRACE_SET_THREAD_AREA. In SKAS mode, it's used normally.
11  *
12  */
13
14 #ifndef PTRACE_GET_THREAD_AREA
15 #define PTRACE_GET_THREAD_AREA 25
16 #endif
17
18 #ifndef PTRACE_SET_THREAD_AREA
19 #define PTRACE_SET_THREAD_AREA 26
20 #endif
21
22 int os_set_thread_area(user_desc_t *info, int pid)
23 {
24         int ret;
25
26         ret = ptrace(PTRACE_SET_THREAD_AREA, pid, info->entry_number,
27                      (unsigned long) info);
28         if (ret < 0)
29                 ret = -errno;
30         return ret;
31 }
32
33 #ifdef UML_CONFIG_MODE_SKAS
34
35 int os_get_thread_area(user_desc_t *info, int pid)
36 {
37         int ret;
38
39         ret = ptrace(PTRACE_GET_THREAD_AREA, pid, info->entry_number,
40                      (unsigned long) info);
41         if (ret < 0)
42                 ret = -errno;
43         return ret;
44 }
45
46 #endif
47
48 #ifdef UML_CONFIG_MODE_TT
49 #include "linux/unistd.h"
50
51 static _syscall1(int, get_thread_area, user_desc_t *, u_info);
52 static _syscall1(int, set_thread_area, user_desc_t *, u_info);
53
54 int do_set_thread_area_tt(user_desc_t *info)
55 {
56         int ret;
57
58         ret = set_thread_area(info);
59         if (ret < 0) {
60                 ret = -errno;
61         }
62         return ret;
63 }
64
65 int do_get_thread_area_tt(user_desc_t *info)
66 {
67         int ret;
68
69         ret = get_thread_area(info);
70         if (ret < 0) {
71                 ret = -errno;
72         }
73         return ret;
74 }
75
76 #endif /* UML_CONFIG_MODE_TT */