diff options
author | pinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-05-27 20:19:13 +0000 |
---|---|---|
committer | pinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-05-27 20:19:13 +0000 |
commit | 72e5da43b8cab03e0fbc8ded0b0ceab3ce11d653 (patch) | |
tree | 58b5ea50a0a6ed81e3e2670399e5a95a8309deb1 /gcc/vec.c | |
parent | f67a96a80ba6b3ab38f9f869efad71c53932895b (diff) | |
download | gcc-72e5da43b8cab03e0fbc8ded0b0ceab3ce11d653.tar.gz |
2011-05-27 Andrew Pinski <pinskia@gmail.com>
PR middle-end/48981
* gengtype.c (vec_prefix_type): New function.
(note_def_vec): Use vec_prefix_type and change the length
attribute to be based on the prefix.
* vec.c: Include coretypes.h before vec.h.
(struct vec_prefix): Remove.
(vec_gc_p_reserve): Change the offsetof to sizeof.
(vec_gc_p_reserve_exact): Likewise.
(vec_heap_p_reserve): Likewise.
(vec_heap_p_reserve_exact): Likewise.
(vec_stack_o_reserve_1): Copy from +1 instead of from vec.
(vec_stack_p_reserve): Change the offsetof to sizeof.
(vec_stack_p_reserve_exact): Likewise.
* vec.h (struct vec_prefix): New struct definition.
(VEC_T(T,B)): Use vec_prefix instead of having num/alloc fields.
(VEC_T_GTY(T,B)): Likewise.
(DEF_VEC_FUNC_P(T)): Use prefix field.
(DEF_VEC_NONALLOC_FUNCS_O(T,A)): Likewise.
(DEF_VEC_NONALLOC_FUNCS_I(T,A)): Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@174359 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/vec.c')
-rw-r--r-- | gcc/vec.c | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/gcc/vec.c b/gcc/vec.c index 5b472bd1f05..c1d003492e3 100644 --- a/gcc/vec.c +++ b/gcc/vec.c @@ -28,20 +28,12 @@ along with GCC; see the file COPYING3. If not see #endif #include "system.h" +#include "coretypes.h" #include "ggc.h" #include "vec.h" -#include "coretypes.h" #include "diagnostic-core.h" #include "hashtab.h" -struct vec_prefix -{ - unsigned num; - unsigned alloc; - void *vec[1]; -}; - - #ifdef GATHER_STATISTICS /* Store information about each particular vector. */ @@ -254,7 +246,7 @@ void * vec_gc_p_reserve (void *vec, int reserve MEM_STAT_DECL) { return vec_gc_o_reserve_1 (vec, reserve, - offsetof (struct vec_prefix, vec), + sizeof (struct vec_prefix), sizeof (void *), false PASS_MEM_STAT); } @@ -268,7 +260,7 @@ void * vec_gc_p_reserve_exact (void *vec, int reserve MEM_STAT_DECL) { return vec_gc_o_reserve_1 (vec, reserve, - offsetof (struct vec_prefix, vec), + sizeof (struct vec_prefix), sizeof (void *), true PASS_MEM_STAT); } @@ -337,7 +329,7 @@ void * vec_heap_p_reserve (void *vec, int reserve MEM_STAT_DECL) { return vec_heap_o_reserve_1 (vec, reserve, - offsetof (struct vec_prefix, vec), + sizeof (struct vec_prefix), sizeof (void *), false PASS_MEM_STAT); } @@ -348,7 +340,7 @@ void * vec_heap_p_reserve_exact (void *vec, int reserve MEM_STAT_DECL) { return vec_heap_o_reserve_1 (vec, reserve, - offsetof (struct vec_prefix, vec), + sizeof (struct vec_prefix), sizeof (void *), true PASS_MEM_STAT); } @@ -443,8 +435,8 @@ vec_stack_o_reserve_1 (void *vec, int reserve, size_t vec_offset, if (newvec && vec) { ((struct vec_prefix *) newvec)->num = ((struct vec_prefix *) vec)->num; - memcpy (((struct vec_prefix *) newvec)->vec, - ((struct vec_prefix *) vec)->vec, + memcpy (((struct vec_prefix *) newvec)+1, + ((struct vec_prefix *) vec)+1, ((struct vec_prefix *) vec)->num * elt_size); } return newvec; @@ -456,7 +448,7 @@ void * vec_stack_p_reserve (void *vec, int reserve MEM_STAT_DECL) { return vec_stack_o_reserve_1 (vec, reserve, - offsetof (struct vec_prefix, vec), + sizeof (struct vec_prefix), sizeof (void *), false PASS_MEM_STAT); } @@ -467,7 +459,7 @@ void * vec_stack_p_reserve_exact (void *vec, int reserve MEM_STAT_DECL) { return vec_stack_o_reserve_1 (vec, reserve, - offsetof (struct vec_prefix, vec), + sizeof (struct vec_prefix), sizeof (void *), true PASS_MEM_STAT); } |