diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2009-10-17 19:09:09 -0400 |
---|---|---|
committer | Frederic Weisbecker <fweisbec@gmail.com> | 2009-10-17 19:12:33 -0400 |
commit | 0f8f86c7bdd1c954fbe153af437a0d91a6c5721a (patch) | |
tree | 94a8d419a470a4f9852ca397bb9bbe48db92ff5c /include/linux/flex_array.h | |
parent | dca2d6ac09d9ef59ff46820d4f0c94b08a671202 (diff) | |
parent | f39cdf25bf77219676ec5360980ac40b1a7e144a (diff) |
Merge commit 'perf/core' into perf/hw-breakpoint
Conflicts:
kernel/Makefile
kernel/trace/Makefile
kernel/trace/trace.h
samples/Makefile
Merge reason: We need to be uptodate with the perf events development
branch because we plan to rewrite the breakpoints API on top of
perf events.
Diffstat (limited to 'include/linux/flex_array.h')
-rw-r--r-- | include/linux/flex_array.h | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/include/linux/flex_array.h b/include/linux/flex_array.h index 45ff18491514..1d747f72298b 100644 --- a/include/linux/flex_array.h +++ b/include/linux/flex_array.h | |||
@@ -31,10 +31,32 @@ struct flex_array { | |||
31 | }; | 31 | }; |
32 | }; | 32 | }; |
33 | 33 | ||
34 | #define FLEX_ARRAY_INIT(size, total) { { {\ | 34 | /* Number of bytes left in base struct flex_array, excluding metadata */ |
35 | .element_size = (size), \ | 35 | #define FLEX_ARRAY_BASE_BYTES_LEFT \ |
36 | .total_nr_elements = (total), \ | 36 | (FLEX_ARRAY_BASE_SIZE - offsetof(struct flex_array, parts)) |
37 | } } } | 37 | |
38 | /* Number of pointers in base to struct flex_array_part pages */ | ||
39 | #define FLEX_ARRAY_NR_BASE_PTRS \ | ||
40 | (FLEX_ARRAY_BASE_BYTES_LEFT / sizeof(struct flex_array_part *)) | ||
41 | |||
42 | /* Number of elements of size that fit in struct flex_array_part */ | ||
43 | #define FLEX_ARRAY_ELEMENTS_PER_PART(size) \ | ||
44 | (FLEX_ARRAY_PART_SIZE / size) | ||
45 | |||
46 | /* | ||
47 | * Defines a statically allocated flex array and ensures its parameters are | ||
48 | * valid. | ||
49 | */ | ||
50 | #define DEFINE_FLEX_ARRAY(__arrayname, __element_size, __total) \ | ||
51 | struct flex_array __arrayname = { { { \ | ||
52 | .element_size = (__element_size), \ | ||
53 | .total_nr_elements = (__total), \ | ||
54 | } } }; \ | ||
55 | static inline void __arrayname##_invalid_parameter(void) \ | ||
56 | { \ | ||
57 | BUILD_BUG_ON((__total) > FLEX_ARRAY_NR_BASE_PTRS * \ | ||
58 | FLEX_ARRAY_ELEMENTS_PER_PART(__element_size)); \ | ||
59 | } | ||
38 | 60 | ||
39 | struct flex_array *flex_array_alloc(int element_size, unsigned int total, | 61 | struct flex_array *flex_array_alloc(int element_size, unsigned int total, |
40 | gfp_t flags); | 62 | gfp_t flags); |
@@ -44,6 +66,8 @@ void flex_array_free(struct flex_array *fa); | |||
44 | void flex_array_free_parts(struct flex_array *fa); | 66 | void flex_array_free_parts(struct flex_array *fa); |
45 | int flex_array_put(struct flex_array *fa, unsigned int element_nr, void *src, | 67 | int flex_array_put(struct flex_array *fa, unsigned int element_nr, void *src, |
46 | gfp_t flags); | 68 | gfp_t flags); |
69 | int flex_array_clear(struct flex_array *fa, unsigned int element_nr); | ||
47 | void *flex_array_get(struct flex_array *fa, unsigned int element_nr); | 70 | void *flex_array_get(struct flex_array *fa, unsigned int element_nr); |
71 | int flex_array_shrink(struct flex_array *fa); | ||
48 | 72 | ||
49 | #endif /* _FLEX_ARRAY_H */ | 73 | #endif /* _FLEX_ARRAY_H */ |