ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change
on this file since 17a0ede2 was
bf71cfd,
checked in by Thierry Delisle <tdelisle@…>, 6 years ago
|
Moved up many directories in source
|
-
Property mode set to
100644
|
File size:
906 bytes
|
Rev | Line | |
---|
[e47f529] | 1 | #pragma once |
---|
| 2 | |
---|
| 3 | #include <stddef.h> |
---|
| 4 | #include <stdint.h> |
---|
| 5 | |
---|
| 6 | #include "tools.h" |
---|
| 7 | #include "globals.h" |
---|
| 8 | |
---|
[16cfd8c] | 9 | static inline bool gc_is_aligned(void* address) |
---|
[e47f529] | 10 | { |
---|
| 11 | return (((intptr_t)address) & (~OBJECT_PTR_MASK)) == 0; |
---|
| 12 | } |
---|
| 13 | |
---|
[16cfd8c] | 14 | static inline void* gc_get_aligned_ptr(void* address) |
---|
[385c130] | 15 | { |
---|
| 16 | return (void*)(((intptr_t)address) & (OBJECT_PTR_MASK)); |
---|
| 17 | } |
---|
| 18 | |
---|
[16cfd8c] | 19 | static inline void* gc_write_aligned_ptr(void** reference, void* address) |
---|
[385c130] | 20 | { |
---|
| 21 | size_t ref_last_bits = ((intptr_t)*reference) & (~OBJECT_PTR_MASK); |
---|
| 22 | |
---|
| 23 | size_t new_val = ((intptr_t)address) & OBJECT_PTR_MASK; |
---|
| 24 | |
---|
| 25 | (*reference) = (void*)(new_val | ref_last_bits); |
---|
| 26 | |
---|
| 27 | return *reference; |
---|
| 28 | } |
---|
| 29 | |
---|
[16cfd8c] | 30 | static inline size_t gc_compute_size(size_t size) |
---|
[385c130] | 31 | { |
---|
| 32 | size_t word_size = ((size - 1) / OBJECT_ALLIGNMENT) + 1; |
---|
| 33 | size_t ret = word_size * OBJECT_ALLIGNMENT; |
---|
| 34 | |
---|
| 35 | check(ret >= size); |
---|
| 36 | check((ret % OBJECT_ALLIGNMENT) == 0); |
---|
| 37 | check( ((size % OBJECT_ALLIGNMENT) != 0) || (ret == size) ); |
---|
| 38 | |
---|
| 39 | return ret; |
---|
| 40 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.