source:
src/examples/gc_no_raii/src/internal/object_header.h
@
f80e0218
Last change on this file since f80e0218 was 1b5c81ed, checked in by , 8 years ago | |
---|---|
|
|
File size: 989 bytes |
Rev | Line | |
---|---|---|
[15db1ab] | 1 | #pragma once |
2 | ||
[1b5c81ed] | 3 | #include <stdbool.h> |
[e47f529] | 4 | #include <stddef.h> |
[15db1ab] | 5 | #include <stdint.h> |
6 | ||
7 | #include "tools.h" | |
8 | ||
[6be0cf9] | 9 | #if DEBUG |
[29ad0ac] | 10 | static const long unsigned int CANARY_VALUE = 0xCAFEBABACAFEBABA; |
[6be0cf9] | 11 | #endif |
[15db1ab] | 12 | |
13 | struct gcpointer_t; | |
[6be0cf9] | 14 | struct gc_object_header; |
[15db1ab] | 15 | |
16 | struct gc_object_header | |
17 | { | |
[6be0cf9] | 18 | #if DEBUG |
[15db1ab] | 19 | void* canary_start; |
20 | #endif | |
21 | ||
[6be0cf9] | 22 | size_t size; |
23 | gcpointer_t* root_chain; | |
24 | gcpointer_t* type_chain; | |
25 | gc_object_header* forward; | |
26 | bool is_forwarded; | |
[15db1ab] | 27 | |
[6be0cf9] | 28 | #if DEBUG |
[15db1ab] | 29 | void* canary_end; |
30 | #endif | |
31 | }; | |
[6be0cf9] | 32 | |
[16cfd8c] | 33 | void ctor(gc_object_header* const this, size_t size); |
34 | void copy_ctor(gc_object_header* const this, const gc_object_header* const other); | |
35 | ||
36 | static inline gc_object_header* placement_ctor(void* address, size_t size) | |
37 | { | |
38 | gc_object_header* const this = (gc_object_header* const) address; | |
39 | ctor(this, size); | |
40 | return this; | |
41 | } | |
42 | ||
43 | static inline gc_object_header* placement_copy_ctor(void* address, const gc_object_header* const other) | |
44 | { | |
45 | gc_object_header* const this = (gc_object_header* const) address; | |
46 | copy_ctor(this, other); | |
47 | return this; | |
48 | } |
Note: See TracBrowser
for help on using the repository browser.