Lines Matching refs:h
96 static inline bool big_heap(struct z_heap *h) in big_heap() argument
98 return big_heap_chunks(h->end_chunk); in big_heap()
101 static inline chunk_unit_t *chunk_buf(struct z_heap *h) in chunk_buf() argument
104 return (chunk_unit_t *)h; in chunk_buf()
107 static inline chunkid_t chunk_field(struct z_heap *h, chunkid_t c, in chunk_field() argument
110 chunk_unit_t *buf = chunk_buf(h); in chunk_field()
113 if (big_heap(h)) { in chunk_field()
120 static inline void chunk_set(struct z_heap *h, chunkid_t c, in chunk_set() argument
123 CHECK(c <= h->end_chunk); in chunk_set()
125 chunk_unit_t *buf = chunk_buf(h); in chunk_set()
128 if (big_heap(h)) { in chunk_set()
137 static inline bool chunk_used(struct z_heap *h, chunkid_t c) in chunk_used() argument
139 return chunk_field(h, c, SIZE_AND_USED) & 1U; in chunk_used()
142 static inline chunksz_t chunk_size(struct z_heap *h, chunkid_t c) in chunk_size() argument
144 return chunk_field(h, c, SIZE_AND_USED) >> 1; in chunk_size()
147 static inline void set_chunk_used(struct z_heap *h, chunkid_t c, bool used) in set_chunk_used() argument
149 chunk_unit_t *buf = chunk_buf(h); in set_chunk_used()
152 if (big_heap(h)) { in set_chunk_used()
172 static inline void set_chunk_size(struct z_heap *h, chunkid_t c, chunksz_t size) in set_chunk_size() argument
174 chunk_set(h, c, SIZE_AND_USED, size << 1); in set_chunk_size()
177 static inline chunkid_t prev_free_chunk(struct z_heap *h, chunkid_t c) in prev_free_chunk() argument
179 return chunk_field(h, c, FREE_PREV); in prev_free_chunk()
182 static inline chunkid_t next_free_chunk(struct z_heap *h, chunkid_t c) in next_free_chunk() argument
184 return chunk_field(h, c, FREE_NEXT); in next_free_chunk()
187 static inline void set_prev_free_chunk(struct z_heap *h, chunkid_t c, in set_prev_free_chunk() argument
190 chunk_set(h, c, FREE_PREV, prev); in set_prev_free_chunk()
193 static inline void set_next_free_chunk(struct z_heap *h, chunkid_t c, in set_next_free_chunk() argument
196 chunk_set(h, c, FREE_NEXT, next); in set_next_free_chunk()
199 static inline chunkid_t left_chunk(struct z_heap *h, chunkid_t c) in left_chunk() argument
201 return c - chunk_field(h, c, LEFT_SIZE); in left_chunk()
204 static inline chunkid_t right_chunk(struct z_heap *h, chunkid_t c) in right_chunk() argument
206 return c + chunk_size(h, c); in right_chunk()
209 static inline void set_left_chunk_size(struct z_heap *h, chunkid_t c, in set_left_chunk_size() argument
212 chunk_set(h, c, LEFT_SIZE, size); in set_left_chunk_size()
215 static inline bool solo_free_header(struct z_heap *h, chunkid_t c) in solo_free_header() argument
217 return big_heap(h) && (chunk_size(h, c) == 1U); in solo_free_header()
220 static inline size_t chunk_header_bytes(struct z_heap *h) in chunk_header_bytes() argument
222 return big_heap(h) ? 8 : 4; in chunk_header_bytes()
235 static inline chunksz_t bytes_to_chunksz(struct z_heap *h, size_t bytes) in bytes_to_chunksz() argument
237 return chunksz(chunk_header_bytes(h) + bytes); in bytes_to_chunksz()
240 static inline chunksz_t min_chunk_size(struct z_heap *h) in min_chunk_size() argument
242 return bytes_to_chunksz(h, 1); in min_chunk_size()
245 static inline size_t chunksz_to_bytes(struct z_heap *h, chunksz_t chunksz_in) in chunksz_to_bytes() argument
247 return chunksz_in * CHUNK_UNIT - chunk_header_bytes(h); in chunksz_to_bytes()
250 static inline int bucket_idx(struct z_heap *h, chunksz_t sz) in bucket_idx() argument
252 unsigned int usable_sz = sz - min_chunk_size(h) + 1; in bucket_idx()
256 static inline bool size_too_big(struct z_heap *h, size_t bytes) in size_too_big() argument
262 return (bytes / CHUNK_UNIT) >= h->end_chunk; in size_too_big()
265 static inline void get_alloc_info(struct z_heap *h, size_t *alloc_bytes, in get_alloc_info() argument
273 for (c = right_chunk(h, 0); c < h->end_chunk; c = right_chunk(h, c)) { in get_alloc_info()
274 if (chunk_used(h, c)) { in get_alloc_info()
275 *alloc_bytes += chunksz_to_bytes(h, chunk_size(h, c)); in get_alloc_info()
276 } else if (!solo_free_header(h, c)) { in get_alloc_info()
277 *free_bytes += chunksz_to_bytes(h, chunk_size(h, c)); in get_alloc_info()