Changeset 4c1403c


Ignore:
Timestamp:
Sep 14, 2016, 1:15:24 PM (8 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
50c5cf3
Parents:
76af36f
Message:

fixed small issues with gcpointers and added method to validate them

Location:
src/examples/gc_no_raii
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/examples/gc_no_raii/src/gcpointers.c

    r76af36f r4c1403c  
    8080
    8181//Logical operators
    82 bool gcpointer_equal(gcpointer_t* this, gcpointer_t* rhs)
     82bool gcpointer_equal(const gcpointer_t* this, const gcpointer_t* rhs)
    8383{
    8484        return this->ptr == rhs->ptr;
    8585}
    8686
    87 bool gcpointer_not_equal(gcpointer_t* this, gcpointer_t* rhs)
     87bool gcpointer_not_equal(const gcpointer_t* this, const gcpointer_t* rhs)
    8888{
    8989        return this->ptr != rhs->ptr;
    9090}
    9191
    92 bool gcpointer_null(gcpointer_t* this)
     92bool gcpointer_null(const gcpointer_t* this)
    9393{
    9494        return this->ptr == (intptr_t)NULL;
    9595}
     96
     97#ifndef NDEBUG
     98        bool is_valid(const gcpointer_t* this) {
     99                if(gcpointer_null(this)) return true;
     100
     101                gc_object_header* obj = gc_get_object_ptr((void*)this->ptr);
     102                check(obj);
     103                check(is_valid(obj));
     104                check(!obj->root_chain || this->ptr == obj->root_chain->ptr);
     105
     106                if( !gc_is_managed(this))
     107                {
     108                        check( !(this->next) || this->ptr == this->next->ptr );
     109                }
     110
     111                return true;
     112        }
     113#endif
    96114
    97115forall(otype T) void ?{}(gcpointer(T)* this) {
  • src/examples/gc_no_raii/src/gcpointers.h

    r76af36f r4c1403c  
    2222bool gcpointer_equal(gcpointer_t* this, gcpointer_t* rhs);
    2323bool gcpointer_not_equal(gcpointer_t* this, gcpointer_t* rhs);
    24 bool gcpointer_null(gcpointer_t* this);
     24bool gcpointer_null(const gcpointer_t* this);
     25
     26
     27#ifndef NDEBUG
     28        bool is_valid(const gcpointer_t* this);
     29#endif
    2530
    2631forall(dtype T)
  • src/examples/gc_no_raii/test/badlll.c

    r76af36f r4c1403c  
    3535        }
    3636
     37        check(is_valid( &ll0.internal ));
     38
    3739        return ll0;
    3840}
Note: See TracChangeset for help on using the changeset viewer.