blob: 73277801ef14b69a8656ee978a63759be9b5c29f [file] [log] [blame]
Paolo 'Blaisorblade' Giarrussoaa6758d2006-03-31 02:30:22 -08001#include <errno.h>
2#include <sys/ptrace.h>
Paolo 'Blaisorblade' Giarrussodd77aec2006-03-31 02:30:23 -08003#include "sysdep/tls.h"
Paolo 'Blaisorblade' Giarrussoaa6758d2006-03-31 02:30:22 -08004
5/* TLS support - we basically rely on the host's one.*/
6
Paolo 'Blaisorblade' Giarrussoaa6758d2006-03-31 02:30:22 -08007#ifndef PTRACE_GET_THREAD_AREA
8#define PTRACE_GET_THREAD_AREA 25
9#endif
10
11#ifndef PTRACE_SET_THREAD_AREA
12#define PTRACE_SET_THREAD_AREA 26
13#endif
14
Paolo 'Blaisorblade' Giarrussodd77aec2006-03-31 02:30:23 -080015int os_set_thread_area(user_desc_t *info, int pid)
Paolo 'Blaisorblade' Giarrussoaa6758d2006-03-31 02:30:22 -080016{
Paolo 'Blaisorblade' Giarrussoaa6758d2006-03-31 02:30:22 -080017 int ret;
18
19 ret = ptrace(PTRACE_SET_THREAD_AREA, pid, info->entry_number,
20 (unsigned long) info);
21 if (ret < 0)
22 ret = -errno;
23 return ret;
24}
25
Paolo 'Blaisorblade' Giarrussodd77aec2006-03-31 02:30:23 -080026int os_get_thread_area(user_desc_t *info, int pid)
Paolo 'Blaisorblade' Giarrussoaa6758d2006-03-31 02:30:22 -080027{
Paolo 'Blaisorblade' Giarrussoaa6758d2006-03-31 02:30:22 -080028 int ret;
29
30 ret = ptrace(PTRACE_GET_THREAD_AREA, pid, info->entry_number,
31 (unsigned long) info);
32 if (ret < 0)
33 ret = -errno;
34 return ret;
35}