File: stmtlocal.py

package info (click to toggle)
pypy 2.4.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 86,992 kB
  • ctags: 170,715
  • sloc: python: 1,030,417; ansic: 43,437; cpp: 5,241; asm: 5,169; sh: 458; makefile: 408; xml: 231; lisp: 45
file content (43 lines) | stat: -rw-r--r-- 1,039 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from rpython.rtyper.lltypesystem import lltype, rffi
from rpython.translator.tool.cbuild import ExternalCompilationInfo
from rpython.jit.backend.x86.arch import WORD

SEGMENT_FS = '\x64'
SEGMENT_GS = '\x65'

if WORD == 4:
    SEGMENT_TL = SEGMENT_GS
    _instruction = "movl %%gs:0, %0"
else:
    SEGMENT_TL = SEGMENT_FS
    _instruction = "movq %%fs:0, %0"

eci = ExternalCompilationInfo(post_include_bits=['''
#define RPY_STM_JIT  1
static long pypy__threadlocal_base(void)
{
    /* XXX ONLY LINUX WITH GCC/CLANG FOR NOW XXX */
    long result;
    asm("%s" : "=r"(result));
    return result;
}
static long pypy__get_errno_tl(void)
{
    return ((long)&errno) - pypy__threadlocal_base();
}
''' % _instruction])


threadlocal_base = rffi.llexternal(
    'pypy__threadlocal_base',
    [], lltype.Signed,
    compilation_info=eci,
    _nowrapper=True,
    ) #transactionsafe=True)

get_errno_tl = rffi.llexternal(
    'pypy__get_errno_tl',
    [], lltype.Signed,
    compilation_info=eci,
    _nowrapper=True,
    ) #transactionsafe=True)