2001-03-23
2001-03-23 03:14:41 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>
-
e83eb988ee51a103ddc7b3b6e5271eced0a330c7
(39 lines)
(+33/-6)
[
Show
| Annotate
]
Branch: 7.9
experimental code for SMP, does nothing exciting yet
Rev: src/acconfig.h:1.83
Rev: src/array.h:1.32
Rev: src/configure.in:1.508
Rev: src/global.h:1.59
Rev: src/mapping.h:1.35
Rev: src/multiset.h:1.17
Rev: src/object.h:1.60
Rev: src/pike_cpulib.h:1.1
Rev: src/program.h:1.121
Rev: src/stralloc.h:1.60
Rev: src/svalue.h:1.82
5:
\*/
/*
- * $Id: svalue.h,v 1.81 2001/03/19 00:41:20 grubba Exp $
+ * $Id: svalue.h,v 1.82 2001/03/23 03:14:41 hubbe Exp $
*/
#ifndef SVALUE_H
#define SVALUE_H
53:
void *pointer_a, *pointer_b;
};
+ struct ref_dummy
+ {
+ INT32 refs;
+ };
+
union anything
{
struct callable *efun;
64:
struct pike_string *string;
struct pike_type *type;
INT32 *refs;
+ struct ref_dummy *dummy;
INT_TYPE integer;
FLOAT_TYPE float_number;
struct svalue *lval; /* only used on stack */
264:
} \
}while(0)
+
+ #ifdef PIKE_RUN_UNLOCKED
+ #define add_ref(X) pike_atomic_add_ref(&(X)->refs)
+ #define sub_ref(X) pike_atomic_sub_ref(&(X)->refs)
+ #else
+ #define add_ref(X) (X)->refs++
+ #define sub_ref(X) (X)->refs--
+ #endif
+
+
#ifdef PIKE_DEBUG
PMOD_EXPORT extern void describe(void *); /* defined in gc.c */
#define check_type(T) if(T > MAX_TYPE && T!=T_LVALUE && T!=T_SHORT_LVALUE && T!=T_VOID && T!=T_DELETED && T!=T_ARRAY_LVALUE) fatal("Type error: %d\n",T)
303: Inside #if defined(DEBUG_MALLOC)
return u;
}
+ #undef add_ref
+ #undef sub_ref
+
+ #ifdef PIKE_RUN_UNLOCKED
+ #define add_ref(X) pike_atomic_add_ref((INT32 *)debug_malloc_pass( &((X)->refs)))
+ #define sub_ref(X) pike_atomic_sub_ref((INT32 *)debug_malloc_pass( &((X)->refs)))
+ #else
#define add_ref(X) ((INT32 *)debug_malloc_pass( &((X)->refs)))[0]++
-
+ #define sub_ref(X) ((INT32 *)debug_malloc_pass( &((X)->refs)))[0]--
+ #endif
+
+
#else
#define dmalloc_check_svalue(S,L) (S)
#define dmalloc_check_union(U,T,L) (U)
- #define add_ref(X) (X)->refs++
+
#endif
-
+
#else
#define check_svalue(S)
319:
#define check_refs2(S,T)
#define dmalloc_check_svalue(S,L) (S)
#define dmalloc_check_union(U,T,L) (U)
- #define add_ref(X) (X)->refs++
+
-
+
#endif
#define swap_svalues(X,Y) do { struct svalue *_a=(X),*_b=(Y),_tmp; _tmp=*_a; *_a=*_b; *_b=_tmp; }while(0)
#define free_svalue(X) do { struct svalue *_s=(X); check_type(_s->type); check_refs(_s); if(_s->type<=MAX_REF_TYPE) { debug_malloc_touch(_s->u.refs); if(--*(_s->u.refs) <=0) { really_free_svalue(_s); } DO_IF_DMALLOC(_s->u.refs=(void *)-1;) }}while(0)
#define free_short_svalue(X,T) do { union anything *_s=(X); TYPE_T _t=(T); check_type(_t); check_refs2(_s,_t); if(_t<=MAX_REF_TYPE && _s->refs) if(--*(_s->refs) <= 0) { really_free_short_svalue(_s,_t); } DO_IF_DMALLOC(_s->refs=(void *)-1;) }while(0)
- #define add_ref_svalue(X) do { struct svalue *_tmp=(X); check_type(_tmp->type); check_refs(_tmp); if(_tmp->type <= MAX_REF_TYPE) { debug_malloc_touch(_tmp->u.refs); _tmp->u.refs[0]++; } }while(0)
- #define assign_svalue_no_free(X,Y) do { struct svalue _tmp, *_to=(X), *_from=(Y); check_type(_from->type); check_refs(_from); *_to=_tmp=*_from; if(_tmp.type <= MAX_REF_TYPE) { debug_malloc_touch(_tmp.u.refs); _tmp.u.refs[0]++; } }while(0)
+ #define add_ref_svalue(X) do { struct svalue *_tmp=(X); check_type(_tmp->type); check_refs(_tmp); if(_tmp->type <= MAX_REF_TYPE) { add_ref(_tmp->u.dummy); } }while(0)
+ #define assign_svalue_no_free(X,Y) do { struct svalue _tmp, *_to=(X), *_from=(Y); check_type(_from->type); check_refs(_from); *_to=_tmp=*_from; if(_tmp.type <= MAX_REF_TYPE) { add_ref(_tmp.u.dummy); } }while(0)
#define assign_svalue(X,Y) do { struct svalue *_to2=(X), *_from2=(Y); if (_to2 != _from2) { free_svalue(_to2); assign_svalue_no_free(_to2, _from2); } }while(0)
extern struct svalue dest_ob_zero;