aboutsummaryrefslogtreecommitdiff
path: root/gcc/vec.h
diff options
context:
space:
mode:
authorLaurynas Biveinis <laurynas.biveinis@gmail.com>2012-07-30 02:30:52 +0000
committerLaurynas Biveinis <laurynas.biveinis@gmail.com>2012-07-30 02:30:52 +0000
commita6ce6b93126637dc239426320b76c0697ee8ab8c (patch)
tree17345bf96a8e18558d9570c89caead4ccc1f2122 /gcc/vec.h
parente50574053cf0a7f0e100cfa0b6a74892d51357a6 (diff)
gcc:
2012-07-27 Laurynas Biveinis <laurynas.biveinis@gmail.com> Steven Bosscher <steven@gcc.gnu.org> * gengtype.c (adjust_field_type): Diagnose duplicate "length" option applications and option being applied to arrays of atomic types. (walk_type): Allow "atomic" option on strings too. * dwarf2out.h (struct dw_vec_struct): Use the "atomic" GTY option for the array field. * vec.h: Describe the atomic object "A" type of the macros in the header comment. (VEC_T_GTY_ATOMIC, DEF_VEC_A, DEF_VEC_ALLOC_A): Define. * emit-rtl.c (locations_locators_vals): use the atomic object vector. * doc/gty.texi: Clarify that GTY option "length" is only for arrays of non-atomic objects. Fix typo in the description of the "atomic" option. gcc/java: 2012-07-24 Laurynas Biveinis <laurynas.biveinis@gmail.com> * jcf.h (CPool): Use the "atomic" GTY option for the tags field. (bootstrap_method): Likewise for the bootstrap_arguments field. libcpp: 2012-07-24 Laurynas Biveinis <laurynas.biveinis@gmail.com> * include/line-map.h (line_map_macro): Use the "atomic" GTY option for the macro_locations field. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@189951 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/vec.h')
-rw-r--r--gcc/vec.h40
1 files changed, 28 insertions, 12 deletions
diff --git a/gcc/vec.h b/gcc/vec.h
index f38c763104f..cb871124ce2 100644
--- a/gcc/vec.h
+++ b/gcc/vec.h
@@ -95,24 +95,25 @@ along with GCC; see the file COPYING3. If not see
the 'space' predicate will tell you whether there is spare capacity
in the vector. You will not normally need to use these two functions.
- Vector types are defined using a DEF_VEC_{O,P,I}(TYPEDEF) macro, to
+ Vector types are defined using a DEF_VEC_{O,A,P,I}(TYPEDEF) macro, to
get the non-memory allocation version, and then a
- DEF_VEC_ALLOC_{O,P,I}(TYPEDEF,ALLOC) macro to get memory managed
+ DEF_VEC_ALLOC_{O,A,P,I}(TYPEDEF,ALLOC) macro to get memory managed
vectors. Variables of vector type are declared using a
VEC(TYPEDEF,ALLOC) macro. The ALLOC argument specifies the
allocation strategy, and can be either 'gc' or 'heap' for garbage
collected and heap allocated respectively. It can be 'none' to get
a vector that must be explicitly allocated (for instance as a
- trailing array of another structure). The characters O, P and I
- indicate whether TYPEDEF is a pointer (P), object (O) or integral
- (I) type. Be careful to pick the correct one, as you'll get an
- awkward and inefficient API if you use the wrong one. There is a
- check, which results in a compile-time warning, for the P and I
- versions, but there is no check for the O versions, as that is not
- possible in plain C. Due to the way GTY works, you must annotate
- any structures you wish to insert or reference from a vector with a
- GTY(()) tag. You need to do this even if you never declare the GC
- allocated variants.
+ trailing array of another structure). The characters O, A, P and I
+ indicate whether TYPEDEF is a pointer (P), object (O), atomic object
+ (A) or integral (I) type. Be careful to pick the correct one, as
+ you'll get an awkward and inefficient API if you use the wrong one or
+ a even a crash if you pick the atomic object version when the object
+ version should have been chosen instead. There is a check, which
+ results in a compile-time warning, for the P and I versions, but there
+ is no check for the O versions, as that is not possible in plain C.
+ Due to the way GTY works, you must annotate any structures you wish to
+ insert or reference from a vector with a GTY(()) tag. You need to do
+ this even if you never declare the GC allocated variants.
An example of their use would be,
@@ -530,6 +531,13 @@ typedef struct GTY(()) VEC(T,B) \
T GTY ((length ("%h.prefix.num"))) vec[1]; \
} VEC(T,B)
+#define VEC_T_GTY_ATOMIC(T,B) \
+typedef struct GTY(()) VEC(T,B) \
+{ \
+ struct vec_prefix prefix; \
+ T GTY ((atomic)) vec[1]; \
+} VEC(T,B)
+
/* Derived vector type, user visible. */
#define VEC_TA_GTY(T,B,A,GTY) \
typedef struct GTY VEC(T,A) \
@@ -904,6 +912,14 @@ DEF_VEC_ALLOC_FUNC_O(T,A) \
DEF_VEC_NONALLOC_FUNCS_O(T,A) \
struct vec_swallow_trailing_semi
+/* Vector of atomic object. */
+#define DEF_VEC_A(T) \
+VEC_T_GTY_ATOMIC(T,base); \
+VEC_TA(T,base,none); \
+DEF_VEC_FUNC_O(T) \
+struct vec_swallow_trailing_semi
+#define DEF_VEC_ALLOC_A(T,A) DEF_VEC_ALLOC_O(T,A)
+
#define DEF_VEC_FUNC_O(T) \
static inline unsigned VEC_OP (T,base,length) (const VEC(T,base) *vec_) \
{ \