3
3
4
4
#define MAYBE_UNUSED __attribute__((__unused__))
5
5
6
- #define implement_commit_slab (slabname , elemtype ) \
6
+ #define implement_static_commit_slab (slabname , elemtype ) \
7
+ implement_commit_slab(slabname, elemtype, static MAYBE_UNUSED)
8
+
9
+ #define implement_shared_commit_slab (slabname , elemtype ) \
10
+ implement_commit_slab(slabname, elemtype, )
11
+
12
+ #define implement_commit_slab (slabname , elemtype , scope ) \
7
13
\
8
14
static int stat_ ##slabname## realloc; \
9
15
\
10
- static MAYBE_UNUSED void init_ ##slabname## _with_stride(struct slabname *s, \
16
+ scope void init_ ##slabname## _with_stride(struct slabname *s, \
11
17
unsigned stride) \
12
18
{ \
13
19
unsigned int elem_size; \
@@ -20,12 +26,12 @@ static MAYBE_UNUSED void init_ ##slabname## _with_stride(struct slabname *s, \
20
26
s->slab = NULL; \
21
27
} \
22
28
\
23
- static MAYBE_UNUSED void init_ ##slabname(struct slabname *s) \
29
+ scope void init_ ##slabname(struct slabname *s) \
24
30
{ \
25
31
init_ ##slabname## _with_stride(s, 1); \
26
32
} \
27
33
\
28
- static MAYBE_UNUSED void clear_ ##slabname(struct slabname *s) \
34
+ scope void clear_ ##slabname(struct slabname *s) \
29
35
{ \
30
36
unsigned int i; \
31
37
for (i = 0; i < s->slab_count; i++) \
@@ -34,7 +40,7 @@ static MAYBE_UNUSED void clear_ ##slabname(struct slabname *s) \
34
40
FREE_AND_NULL(s->slab); \
35
41
} \
36
42
\
37
- static MAYBE_UNUSED elemtype *slabname## _at_peek(struct slabname *s, \
43
+ scope elemtype *slabname## _at_peek(struct slabname *s, \
38
44
const struct commit *c, \
39
45
int add_if_missing) \
40
46
{ \
@@ -62,13 +68,13 @@ static MAYBE_UNUSED elemtype *slabname## _at_peek(struct slabname *s, \
62
68
return &s->slab[nth_slab][nth_slot * s->stride]; \
63
69
} \
64
70
\
65
- static MAYBE_UNUSED elemtype *slabname## _at(struct slabname *s, \
71
+ scope elemtype *slabname## _at(struct slabname *s, \
66
72
const struct commit *c) \
67
73
{ \
68
74
return slabname##_at_peek(s, c, 1); \
69
75
} \
70
76
\
71
- static MAYBE_UNUSED elemtype *slabname## _peek(struct slabname *s, \
77
+ scope elemtype *slabname## _peek(struct slabname *s, \
72
78
const struct commit *c) \
73
79
{ \
74
80
return slabname##_at_peek(s, c, 0); \
@@ -81,7 +87,7 @@ struct slabname
81
87
* to allow a terminating semicolon, which makes instantiations look
82
88
* like function declarations. I.e., the expansion of
83
89
*
84
- * implement_commit_slab(indegree, int);
90
+ * implement_commit_slab(indegree, int, static );
85
91
*
86
92
* ends in 'struct indegree;'. This would otherwise
87
93
* be a syntax error according (at least) to ISO C. It's hard to
0 commit comments