Branch: Tag:

2011-10-22

2011-10-22 22:01:49 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Added convenience macro SET_SVAL().

104:   #define SUBTYPEOF(SVAL) ((SVAL).subtype)   #define SET_SVAL_TYPE(SVAL, TYPE) (TYPEOF(SVAL) = (TYPE))   #define SET_SVAL_SUBTYPE(SVAL, TYPE) (SUBTYPEOF(SVAL) = (TYPE)) + #define SET_SVAL(SVAL, TYPE, SUBTYPE, FIELD, EXPR) do { \ +  /* Set the type afterwards to avoid a clobbered \ +  * svalue in case EXPR throws. */ \ +  (SVAL).u.FIELD = (EXPR); \ +  SET_SVAL_TYPE((SVAL), (TYPE)); \ +  SET_SVAL_SUBTYPE((SVAL), (SUBTYPE)); \ +  } while(0)      #define PIKE_T_ARRAY 0   #define PIKE_T_MAPPING 1
359:    struct svalue *_s=(S); \    if(IS_DESTRUCTED(_s)) { \    free_object(_s->u.object); \ -  SET_SVAL_TYPE(*_s, PIKE_T_INT); \ -  SET_SVAL_SUBTYPE(*_s, NUMBER_DESTRUCTED); \ -  _s->u.integer = 0; \ +  SET_SVAL(*_s, PIKE_T_INT, \ +  NUMBER_DESTRUCTED, \ +  integer, 0); \    } \    }while(0)   
714:    ptrdiff_t num_=(Y); \    for(;num_-- > 0;s_++) \    { \ -  SET_SVAL_TYPE(*s_, PIKE_T_INT); \ -  SET_SVAL_SUBTYPE(*s_, (N)); \ -  s_->u.integer = 0; \ +  SET_SVAL(*s_, PIKE_T_INT, (N), integer, 0); \    } \   }while(0)   
895: Inside #if undefined(free_svalue)
  {    INT64 tmp;    struct svalue zero; -  zero.type=PIKE_T_INT; -  zero.subtype = NUMBER_NUMBER; +  SET_SVAL(zero, PIKE_T_INT, NUMBER_NUMBER, integer, 0);    tmp=pike_atomic_swap64((INT64 *)s, *(INT64 *)&zero);    free_svalue_unlocked((struct svalue *)&tmp);   }