-
Notifications
You must be signed in to change notification settings - Fork 7
/
diskimpl.pxd
119 lines (81 loc) · 2.72 KB
/
diskimpl.pxd
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
from libc.stdint cimport uint64_t
from libc.string cimport memcpy
# Extract returns the same size type..
cpdef inline uint64_t Extract(int hi, int lo, uint64_t val):
return val >> lo & ((<uint64_t>1 << (hi - lo + 1)) - <uint64_t>1)
cpdef inline uint64_t USub(uint64_t a, uint64_t b):
return a - b
cpdef inline uint64_t Concat32(uint64_t a, uint64_t b):
return a << 32 | b
cpdef inline bint ULE(uint64_t a, uint64_t b):
return a <= b
cpdef inline bint ULT(uint64_t a, uint64_t b):
return a < b
cpdef inline bint UGE(uint64_t a, uint64_t b):
return a >= b
cpdef inline bint UGT(uint64_t a, uint64_t b):
return a > b
cpdef inline uint64_t URem(uint64_t a, uint64_t b):
return a % b
cpdef inline uint64_t UDiv(uint64_t a, uint64_t b):
return a / b
cpdef inline uint64_t LShR(uint64_t a, uint64_t b):
return a >> b
cpdef inline uint64_t Extend(uint64_t val, uint64_t size):
assert size == 64
return val
cpdef inline uint64_t BitVecVal(uint64_t val, uint64_t size):
assert size <= 64
return val
cpdef inline bint Not(bint cond):
return not cond
cpdef inline bint Or(bint a, bint b):
return (a or b)
cpdef bint And(bint a=*, bint b=*, bint c=*)
cpdef Block ConstBlock(uint64_t c)
cpdef inline If(bint cond, a, b):
if cond:
return a
return b
cpdef void assertion(bint b, object msg=*)
cdef class Stat:
cdef public uint64_t size
cdef public uint64_t mtime
cdef public uint64_t mode
cdef public uint64_t nlink
cdef class Block:
cdef uint64_t *buf
cdef readonly int size # buf size
cpdef Block copy(self)
cdef void set(self, uint64_t, uint64_t) nogil
cdef uint64_t get(self, uint64_t) nogil
cdef class AsyncDisk:
cdef char* fn
cdef int fd
cpdef void write(self, uint64_t blknum, Block block, bint cond=*)
cpdef Block read(self, uint64_t blknum)
cpdef void flush(self)
cdef class Dict(object):
cdef dict _map
cpdef get(self, gkey, dresult)
cpdef has_key(self, gkey)
cdef class PartitionAsyncDisk:
cdef AsyncDisk adisk
cdef uint64_t start
cdef uint64_t end
cdef bint debug
cpdef void write(self, uint64_t blknum, Block block, bint cond=*)
cpdef Block read(self, uint64_t blknum)
cpdef void flush(self)
cdef class Allocator:
cdef readfn
cdef uint64_t start
cdef uint64_t end
cdef uint64_t _alloc(self, uint64_t i, Block block) nogil
cpdef uint64_t alloc(self)
cdef class DentryLookup:
cdef object _inode
cdef int locate_dentry(self, Block block, uint64_t[15] name) nogil
cdef int locate_empty_slot(self, Block block) nogil
cdef tuple locate_dentry_ino(self, uint64_t ino, uint64_t[15] name)
cdef tuple locate_empty_slot_ino(self, uint64_t ino)