Branch: Tag:

2013-06-11

2013-06-11 20:22:57 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Added macro REFCOUNTED_TYPE().

This is to simplify renumbering of the types.

343:   /* Max type handled by svalue primitives */   #define MAX_TYPE PIKE_T_FLOAT    + #define REFCOUNTED_TYPE(T) ((T) <= MAX_REF_TYPE) +    #define NUMBER_NUMBER 0   #define NUMBER_UNDEFINED 1   #define NUMBER_DESTRUCTED 2
448:    TYPE_T typ_ = (T); \    check_short_svalue (anyth_, typ_); \    if (d_flag <= 50) /* Done directly by check_svalue otherwise. */ \ -  if (typ_ <= MAX_REF_TYPE) \ +  if (REFCOUNTED_TYPE(typ_)) \    low_thorough_check_short_svalue (anyth_, typ_); \    } while (0)   #define thorough_check_svalue(S) do { \    struct svalue *sval_ = (S); \    check_svalue (sval_); \    if (d_flag <= 50) /* Done directly by check_svalue otherwise. */ \ -  if (TYPEOF(*sval_) <= MAX_REF_TYPE) \ +  if (REFCOUNTED_TYPE(TYPEOF(*sval_))) \    low_thorough_check_short_svalue (&sval_->u, TYPEOF(*sval_)); \    } while (0)   
468:      PMOD_EXPORT extern const char msg_sval_obj_wo_refs[];   #define check_refs(S) do {\ -  if(TYPEOF(*(S)) <= MAX_REF_TYPE && (!(S)->u.refs || (S)->u.refs[0] < 0)) { \ +  if(REFCOUNTED_TYPE(TYPEOF(*(S))) && (!(S)->u.refs || (S)->u.refs[0] < 0)) { \    fprintf (stderr, "%s", msg_sval_obj_wo_refs); \    describe((S)->u.refs); \    Pike_fatal("%s", msg_sval_obj_wo_refs); \
476:      PMOD_EXPORT extern const char msg_ssval_obj_wo_refs[];   #define check_refs2(S,T) do { \ - if((T) <= MAX_REF_TYPE && (S)->refs && (S)->refs[0] <= 0) {\ + if(REFCOUNTED_TYPE(T) && (S)->refs && (S)->refs[0] <= 0) {\    fprintf (stderr, "%s", msg_ssval_obj_wo_refs); \    describe((S)->refs); \    Pike_fatal("%s", msg_ssval_obj_wo_refs); \
494: Inside #if defined(DEBUG_MALLOC)
   debug_malloc_update_location(s,l);   #endif   #if 1 -  if(s && TYPEOF(*s) <= MAX_REF_TYPE) +  if(s && REFCOUNTED_TYPE(TYPEOF(*s)))    debug_malloc_update_location(s->u.refs,l);   #endif    return s;
512: Inside #if defined(DEBUG_MALLOC)
   debug_malloc_update_location(u,l);   #endif   #if 1 -  if(u && type <= MAX_REF_TYPE) +  if(u && REFCOUNTED_TYPE(type))    debug_malloc_update_location(u->refs,l);   #endif    return u;
630:    check_refs(_s); \    } \    ); \ -  if (TYPEOF(*_s) > MAX_REF_TYPE) \ +  if (!REFCOUNTED_TYPE(TYPEOF(*_s))) \    assert_free_svalue (_s); \    else { \    DO_IF_DEBUG ( \
648:    union anything *_s=(X); TYPE_T _t=(T); \    check_type(_t); check_refs2(_s,_t); \    assert_svalue_locked(_s); \ -  if(_t<=MAX_REF_TYPE && _s->refs) { \ +  if(REFCOUNTED_TYPE(_t) && _s->refs) { \    DO_IF_DEBUG ( \    DO_IF_PIKE_CLEANUP ( \    if (gc_external_refs_zapped) \
668:    check_refs(_tmp); \    } \    ); \ -  if(TYPEOF(*_tmp) <= MAX_REF_TYPE) add_ref(_tmp->u.dummy); \ +  if(REFCOUNTED_TYPE(TYPEOF(*_tmp))) add_ref(_tmp->u.dummy); \   }while(0)      /* Handles PIKE_T_FREE. */
684:    Pike_fatal(msg_assign_svalue_error, _to); \    ); \    *_to=*_from; \ -  if(TYPEOF(*_to) <= MAX_REF_TYPE) add_ref(_to->u.dummy); \ +  if(REFCOUNTED_TYPE(TYPEOF(*_to))) add_ref(_to->u.dummy); \   }while(0)      /* Handles PIKE_T_FREE. */
917: Inside #if undefined(free_short_svalue)
  #ifndef free_short_svalue   static INLINE void free_short_svalue(union anything *s, int t)   { -  if(t <= MAX_REF_TYPE) +  if(REFCOUNTED_TYPE(t))    {    INT32 tmp;    tmp=pike_atomic_swap32((INT32 *)s, 0);