PageRenderTime 67ms CodeModel.GetById 45ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

/arch/um/os-Linux/sys-i386/tls.c

https://bitbucket.org/thekraven/iscream_thunderc-2.6.35
C | 36 lines | 26 code | 6 blank | 4 comment | 9 complexity | d2230df0e4862d4ed728503f86474121 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, AGPL-1.0
 1#include <errno.h>
 2#include <linux/unistd.h>
 3
 4#include <sys/syscall.h>
 5#include <unistd.h>
 6
 7#include "sysdep/tls.h"
 8#include "user.h"
 9
10/* Checks whether host supports TLS, and sets *tls_min according to the value
11 * valid on the host.
12 * i386 host have it == 6; x86_64 host have it == 12, for i386 emulation. */
13void check_host_supports_tls(int *supports_tls, int *tls_min) {
14	/* Values for x86 and x86_64.*/
15	int val[] = {GDT_ENTRY_TLS_MIN_I386, GDT_ENTRY_TLS_MIN_X86_64};
16	int i;
17
18	for (i = 0; i < ARRAY_SIZE(val); i++) {
19		user_desc_t info;
20		info.entry_number = val[i];
21
22		if (syscall(__NR_get_thread_area, &info) == 0) {
23			*tls_min = val[i];
24			*supports_tls = 1;
25			return;
26		} else {
27			if (errno == EINVAL)
28				continue;
29			else if (errno == ENOSYS)
30				*supports_tls = 0;
31				return;
32		}
33	}
34
35	*supports_tls = 0;
36}