Ignore:
Timestamp:
Apr 19, 2016, 1:19:25 PM (9 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
9026b4b
Parents:
356bb95
Message:

pre merge

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/examples/gc_no_raii/src/internal/gc_tools.h

    r356bb95 r385c130  
    1212}
    1313
    14 // inline void* gc_get_aligned_ptr(void* address)
    15 // {
    16 //      return (void*)(((intptr_t)address) & (OBJECT_PTR_MASK));
    17 // }
    18 //
    19 // inline void* gc_write_aligned_ptr(void** reference, void* address)
    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 //
    30 // inline size_t gc_compute_size(size_t size)
    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 // }
     14inline void* gc_get_aligned_ptr(void* address)
     15{
     16        return (void*)(((intptr_t)address) & (OBJECT_PTR_MASK));
     17}
     18
     19inline void* gc_write_aligned_ptr(void** reference, void* address)
     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
     30inline size_t gc_compute_size(size_t size)
     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 TracChangeset for help on using the changeset viewer.