source: src/examples/gc_no_raii/src/gcpointers.c @ 29ad0ac

aaron-thesisarm-ehcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 29ad0ac was 29ad0ac, checked in by Thierry Delisle <tdelisle@…>, 7 years ago

some regression testing

  • Property mode set to 100644
File size: 2.2 KB
Line 
1#include "gcpointers.h"
2
3#include "gc.h"
4#include "internal/collector.h"
5#include "internal/object_header.h"
6#include "internal/state.h"
7
8// void register_ptr(gcpointer_t* this)
9// {
10//      if(gcpointer_null(this)) return;
11//
12//      _Bool managed = gc_is_managed(this);
13//
14//
15//      gc_state* state = gc_get_state();
16//      gc_object_header* obj = 0;
17//      if(managed)
18//      {
19//              obj = gc_get_object_for_ref(state, (void*)this);
20//              check(obj);
21//              check(gc_obj_is_valide(obj));
22//              check(gc_is_managed(this) == gc_is_managed(obj->type_chain) || obj->type_chain == NULL);
23//              this->next = obj->type_chain;
24//              obj->type_chain = this;
25//              check(obj->is_valide());
26//      }
27//      else
28//      {
29//              obj = gc_get_object_ptr(state, (void*)this->ptr);
30//              check(obj);
31//              check(gc_obj_is_valide(obj));
32//              check(gc_is_managed(this) == gc_is_managed(obj->root_chain) || obj->root_chain == NULL);
33//              this->next = obj->root_chain;
34//              obj->root_chain = this;
35//              check(gc_obj_is_valide(obj));
36//      }
37// }
38//
39// void unregister_ptr(gcpointer_t* this)
40// {
41//      if(gcpointer_null(this)) return;
42//
43//      gcpointer_t** prev_next_ptr = gc_find_previous_ref(this);
44//      check((*prev_next_ptr) == this);
45//
46//      (*prev_next_ptr) = this->next;
47// }
48//
49// void gcpointer_ctor(gcpointer_t* this)
50// {
51//      this->ptr = (intptr_t)NULL;
52//      this->next = NULL;
53// }
54//
55// void gcpointer_ctor(gcpointer_t* this, void* address)
56// {
57//      this->ptr = (intptr_t)address;
58//      this->next = NULL;
59//
60//      register_ptr(this);
61// }
62//
63// void gcpointer_ctor(gcpointer_t* this, gcpointer_t* other)
64// {
65//      this->ptr = other->ptr;
66//      this->next = NULL;
67//
68//      register_ptr(this);
69// }
70//
71// void gcpointer_dtor(gcpointer_t* this)
72// {
73//      unregister_ptr(this);
74// }
75//
76// gcpointer_t* gcpointer_assign(gcpointer_t* this, gcpointer_t* rhs)
77// {
78//      if(this != rhs)
79//      {
80//              unregister_ptr(this);
81//
82//              this->ptr = rhs->ptr;
83//
84//              register_ptr(this);
85//      }
86//
87//      return this;
88// }
89//
90// //Logical operators
91// int gcpointer_equal(gcpointer_t* this, gcpointer_t* rhs)
92// {
93//      return this->ptr == rhs->ptr;
94// }
95//
96// int gcpointer_not_equal(gcpointer_t* this, gcpointer_t* rhs)
97// {
98//      return this->ptr != rhs->ptr;
99// }
100//
101// int gcpointer_null(gcpointer_t* this)
102// {
103//      return this->ptr == (intptr_t)NULL;
104// }
Note: See TracBrowser for help on using the repository browser.