2
from pypy.rpython.module.support import OOSupport
3
from pypy.rpython.module.ll_os import BaseOS
4
from pypy.rpython.ootypesystem import ootype
5
from pypy.rlib.rarithmetic import intmask
7
def _make_tuple(FIELDS):
9
fieldnames = ['item%d' % i for i in range(n)]
10
fields = dict(zip(fieldnames, FIELDS))
11
return ootype.Record(fields)
13
STAT_RESULT = _make_tuple([ootype.Signed]*10)
14
PIPE_RESULT = _make_tuple([ootype.Signed]*2)
15
WAITPID_RESULT = _make_tuple([ootype.Signed]*2)
17
class Implementation(BaseOS, OOSupport):
19
def ll_stat_result(stat0, stat1, stat2, stat3, stat4,
20
stat5, stat6, stat7, stat8, stat9):
21
tup = ootype.new(STAT_RESULT)
22
tup.item0 = intmask(stat0)
23
tup.item1 = intmask(stat1)
24
tup.item2 = intmask(stat2)
25
tup.item3 = intmask(stat3)
26
tup.item4 = intmask(stat4)
27
tup.item5 = intmask(stat5)
28
tup.item6 = intmask(stat6)
29
tup.item7 = intmask(stat7)
30
tup.item8 = intmask(stat8)
31
tup.item9 = intmask(stat9)
33
ll_stat_result = staticmethod(ll_stat_result)
35
def ll_os_read(cls, fd, count):
36
return cls.to_rstr(os.read(fd, count))
37
ll_os_read.suggested_primitive = True
39
def ll_pipe_result(fd1, fd2):
40
tup = ootype.new(PIPE_RESULT)
44
ll_pipe_result = staticmethod(ll_pipe_result)
46
def ll_os_readlink(cls, path):
47
return cls.to_rstr(os.readlink(path))
48
ll_os_readlink.suggested_primitive = True
50
def ll_waitpid_result(fd1, fd2):
51
tup = ootype.new(WAITPID_RESULT)
55
ll_waitpid_result = staticmethod(ll_waitpid_result)