diff options
author | hp <hp@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-01-24 15:19:40 +0000 |
---|---|---|
committer | hp <hp@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-01-24 15:19:40 +0000 |
commit | 7f882fe9d2c2c94d333fd7b448bfdca01bcb0e29 (patch) | |
tree | 310851c47ee12a55d837dbf6fd1ad78bfc539dcb /gcc/vec.h | |
parent | ea4b1692d1a67d549f0584f9b46a8932330bc52a (diff) | |
download | gcc-7f882fe9d2c2c94d333fd7b448bfdca01bcb0e29.tar.gz |
* genautomata.c (process_state_for_insn_equiv_partition):
Use xcalloc for insn_arcs_array.
* vec.h (DEF_VEC_ALLOC_FUNC_I): New set of templates.
(DEF_VEC_ALLOC_I): Use it, not DEF_VEC_ALLOC_FUNC_P.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@110172 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/vec.h')
-rw-r--r-- | gcc/vec.h | 87 |
1 files changed, 86 insertions, 1 deletions
diff --git a/gcc/vec.h b/gcc/vec.h index 93453a895ed..09d0f0ac877 100644 --- a/gcc/vec.h +++ b/gcc/vec.h @@ -479,7 +479,7 @@ DEF_VEC_FUNC_P(T) \ struct vec_swallow_trailing_semi #define DEF_VEC_ALLOC_I(T,A) \ VEC_TA_GTY(T,base,A,); \ -DEF_VEC_ALLOC_FUNC_P(T,A) \ +DEF_VEC_ALLOC_FUNC_I(T,A) \ struct vec_swallow_trailing_semi #endif @@ -1032,4 +1032,89 @@ static inline T *VEC_OP (T,A,safe_insert) \ return VEC_OP (T,base,quick_insert) (VEC_BASE(*vec_), ix_, obj_ \ VEC_CHECK_PASS); \ } + +#define DEF_VEC_ALLOC_FUNC_I(T,A) \ +static inline VEC(T,A) *VEC_OP (T,A,alloc) \ + (int alloc_ MEM_STAT_DECL) \ +{ \ + /* We must request exact size allocation, hence the negation. */ \ + return (VEC(T,A) *) vec_##A##_o_reserve (NULL, -alloc_, \ + offsetof (VEC(T,A),base.vec), \ + sizeof (T) \ + PASS_MEM_STAT); \ +} \ + \ +static inline VEC(T,A) *VEC_OP (T,A,copy) (VEC(T,base) *vec_ MEM_STAT_DECL) \ +{ \ + size_t len_ = vec_ ? vec_->num : 0; \ + VEC (T,A) *new_vec_ = NULL; \ + \ + if (len_) \ + { \ + /* We must request exact size allocation, hence the negation. */ \ + new_vec_ = (VEC (T,A) *)(vec_##A##_o_reserve \ + (NULL, -len_, \ + offsetof (VEC(T,A),base.vec), sizeof (T) \ + PASS_MEM_STAT)); \ + \ + new_vec_->base.num = len_; \ + memcpy (new_vec_->base.vec, vec_->vec, sizeof (T) * len_); \ + } \ + return new_vec_; \ +} \ + \ +static inline void VEC_OP (T,A,free) \ + (VEC(T,A) **vec_) \ +{ \ + if (*vec_) \ + vec_##A##_free (*vec_); \ + *vec_ = NULL; \ +} \ + \ +static inline int VEC_OP (T,A,reserve) \ + (VEC(T,A) **vec_, int alloc_ VEC_CHECK_DECL MEM_STAT_DECL) \ +{ \ + int extend = !VEC_OP (T,base,space) (VEC_BASE(*vec_), \ + alloc_ < 0 ? -alloc_ : alloc_ \ + VEC_CHECK_PASS); \ + \ + if (extend) \ + *vec_ = (VEC(T,A) *) vec_##A##_o_reserve (*vec_, alloc_, \ + offsetof (VEC(T,A),base.vec),\ + sizeof (T) \ + PASS_MEM_STAT); \ + \ + return extend; \ +} \ + \ +static inline void VEC_OP (T,A,safe_grow) \ + (VEC(T,A) **vec_, int size_ VEC_CHECK_DECL MEM_STAT_DECL) \ +{ \ + VEC_ASSERT (size_ >= 0 \ + && VEC_OP(T,base,length) VEC_BASE(*vec_) <= (unsigned)size_, \ + "grow", T, A); \ + VEC_OP (T,A,reserve) (vec_, (int)(*vec_ ? VEC_BASE(*vec_)->num : 0) - size_ \ + VEC_CHECK_PASS PASS_MEM_STAT); \ + VEC_BASE (*vec_)->num = size_; \ + VEC_BASE (*vec_)->num = size_; \ +} \ + \ +static inline T *VEC_OP (T,A,safe_push) \ + (VEC(T,A) **vec_, const T obj_ VEC_CHECK_DECL MEM_STAT_DECL) \ +{ \ + VEC_OP (T,A,reserve) (vec_, 1 VEC_CHECK_PASS PASS_MEM_STAT); \ + \ + return VEC_OP (T,base,quick_push) (VEC_BASE(*vec_), obj_ VEC_CHECK_PASS); \ +} \ + \ +static inline T *VEC_OP (T,A,safe_insert) \ + (VEC(T,A) **vec_, unsigned ix_, const T obj_ \ + VEC_CHECK_DECL MEM_STAT_DECL) \ +{ \ + VEC_OP (T,A,reserve) (vec_, 1 VEC_CHECK_PASS PASS_MEM_STAT); \ + \ + return VEC_OP (T,base,quick_insert) (VEC_BASE(*vec_), ix_, obj_ \ + VEC_CHECK_PASS); \ +} + #endif /* GCC_VEC_H */ |