mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-18 21:29:18 +02:00
Added atomic_type
This commit is contained in:
parent
5b87573371
commit
d3e679fd03
3 changed files with 45 additions and 22 deletions
9
gc.c
9
gc.c
|
@ -895,6 +895,13 @@ char *gc_copy_obj(object dest, char *obj, gc_thread_data * thd)
|
|||
// NOTE: don't copy cond_var itself, caller will do that (this is a special case)
|
||||
return (char *)hp;
|
||||
}
|
||||
case atomic_tag:{
|
||||
atomic_type *hp = dest;
|
||||
mark(hp) = thd->gc_alloc_color;
|
||||
type_of(hp) = atomic_tag;
|
||||
hp->obj = ((atomic_type *)obj)->obj; // TODO: should access via CK atomic operations, though this may not be needed at all since we alloc directly on heap
|
||||
return (char *)hp;
|
||||
}
|
||||
case macro_tag:{
|
||||
macro_type *hp = dest;
|
||||
mark(hp) = thd->gc_alloc_color;
|
||||
|
@ -1505,6 +1512,8 @@ size_t gc_allocated_bytes(object obj, gc_free_list * q, gc_free_list * r)
|
|||
return gc_heap_align(sizeof(mutex_type));
|
||||
if (t == cond_var_tag)
|
||||
return gc_heap_align(sizeof(cond_var_type));
|
||||
if (t == atomic_tag)
|
||||
return gc_heap_align(sizeof(atomic_type));
|
||||
if (t == integer_tag)
|
||||
return gc_heap_align(sizeof(integer_type));
|
||||
if (t == complex_num_tag)
|
||||
|
|
|
@ -35,28 +35,29 @@ typedef void *object;
|
|||
*\ingroup objects
|
||||
*/
|
||||
enum object_tag {
|
||||
boolean_tag = 0 // 0
|
||||
, bytevector_tag // 1
|
||||
, c_opaque_tag // 2
|
||||
, closure0_tag // 3
|
||||
, closure1_tag // 4
|
||||
, closureN_tag // 5
|
||||
, cond_var_tag // 6
|
||||
, cvar_tag // 7
|
||||
, double_tag // 8
|
||||
, eof_tag // 9
|
||||
, forward_tag // 10
|
||||
, integer_tag // 11
|
||||
, bignum_tag // 12
|
||||
, macro_tag // 13
|
||||
, mutex_tag // 14
|
||||
, pair_tag // 15
|
||||
, port_tag // 16
|
||||
, primitive_tag // 17
|
||||
, string_tag // 18
|
||||
, symbol_tag // 19
|
||||
, vector_tag // 20
|
||||
, complex_num_tag // 21
|
||||
boolean_tag = 0
|
||||
, bytevector_tag = 1
|
||||
, c_opaque_tag = 2
|
||||
, closure0_tag = 3
|
||||
, closure1_tag = 4
|
||||
, closureN_tag = 5
|
||||
, cond_var_tag = 6
|
||||
, cvar_tag = 7
|
||||
, double_tag = 8
|
||||
, eof_tag = 9
|
||||
, forward_tag = 10
|
||||
, integer_tag = 11
|
||||
, bignum_tag = 12
|
||||
, macro_tag = 13
|
||||
, mutex_tag = 14
|
||||
, pair_tag = 15
|
||||
, port_tag = 16
|
||||
, primitive_tag = 17
|
||||
, string_tag = 18
|
||||
, symbol_tag = 19
|
||||
, vector_tag = 20
|
||||
, complex_num_tag = 21
|
||||
, atomic_tag = 22
|
||||
};
|
||||
|
||||
#define type_is_pair_prim(clo) \
|
||||
|
@ -667,6 +668,18 @@ typedef struct {
|
|||
} cond_var_type;
|
||||
typedef cond_var_type *cond_var;
|
||||
|
||||
/**
|
||||
* @brief The atomic thread synchronization type
|
||||
*
|
||||
* Atomics are always allocated directly on the heap.
|
||||
*/
|
||||
typedef struct {
|
||||
gc_header_type hdr;
|
||||
tag_type tag;
|
||||
object obj;
|
||||
} atomic_type;
|
||||
typedef atomic_type *atomic;
|
||||
|
||||
/**
|
||||
* @brief The boolean type: True or False
|
||||
*
|
||||
|
|
|
@ -57,6 +57,7 @@ const char *tag_names[] = {
|
|||
/*symbol_tag */ , "symbol"
|
||||
/*vector_tag */ , "vector"
|
||||
/*complex_num_tag*/ , "complex number"
|
||||
/*atomic_tag*/ , "atomic"
|
||||
, "Reserved for future use"
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue