From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: pclouds@gmail.com
Cc: git@vger.kernel.org, gitster@pobox.com, peff@peff.net
Subject: [PATCH v3 02/15] commit-slab: support shared commit-slab
Date: Sat, 19 May 2018 07:28:18 +0200 [thread overview]
Message-ID: <20180519052831.12603-3-pclouds@gmail.com> (raw)
In-Reply-To: <20180519052831.12603-1-pclouds@gmail.com>
define_shared_commit_slab() could be used in a header file to define a
commit-slab. One of these C files must include commit-slab-impl.h and
"call" implement_shared_commit_slab().
---
commit-slab-decl.h | 13 +++++++++++++
commit-slab-impl.h | 22 ++++++++++++++--------
commit-slab.h | 2 +-
3 files changed, 28 insertions(+), 9 deletions(-)
diff --git a/commit-slab-decl.h b/commit-slab-decl.h
index fb5220fb7d..adc7b46c83 100644
--- a/commit-slab-decl.h
+++ b/commit-slab-decl.h
@@ -27,4 +27,17 @@ struct slabname { \
(stride), 0, NULL \
}
+#define declare_commit_slab_prototypes(slabname, elemtype) \
+ \
+void init_ ##slabname## _with_stride(struct slabname *s, unsigned stride); \
+void init_ ##slabname(struct slabname *s); \
+void clear_ ##slabname(struct slabname *s); \
+elemtype *slabname## _at_peek(struct slabname *s, const struct commit *c, int add_if_missing); \
+elemtype *slabname## _at(struct slabname *s, const struct commit *c); \
+elemtype *slabname## _peek(struct slabname *s, const struct commit *c)
+
+#define define_shared_commit_slab(slabname, elemtype) \
+ declare_commit_slab(slabname, elemtype); \
+ declare_commit_slab_prototypes(slabname, elemtype)
+
#endif /* COMMIT_SLAB_HDR_H */
diff --git a/commit-slab-impl.h b/commit-slab-impl.h
index 234d9ee5f0..87a9cadfcc 100644
--- a/commit-slab-impl.h
+++ b/commit-slab-impl.h
@@ -3,11 +3,17 @@
#define MAYBE_UNUSED __attribute__((__unused__))
-#define implement_commit_slab(slabname, elemtype) \
+#define implement_static_commit_slab(slabname, elemtype) \
+ implement_commit_slab(slabname, elemtype, static MAYBE_UNUSED)
+
+#define implement_shared_commit_slab(slabname, elemtype) \
+ implement_commit_slab(slabname, elemtype, )
+
+#define implement_commit_slab(slabname, elemtype, scope) \
\
static int stat_ ##slabname## realloc; \
\
-static MAYBE_UNUSED void init_ ##slabname## _with_stride(struct slabname *s, \
+scope void init_ ##slabname## _with_stride(struct slabname *s, \
unsigned stride) \
{ \
unsigned int elem_size; \
@@ -20,12 +26,12 @@ static MAYBE_UNUSED void init_ ##slabname## _with_stride(struct slabname *s, \
s->slab = NULL; \
} \
\
-static MAYBE_UNUSED void init_ ##slabname(struct slabname *s) \
+scope void init_ ##slabname(struct slabname *s) \
{ \
init_ ##slabname## _with_stride(s, 1); \
} \
\
-static MAYBE_UNUSED void clear_ ##slabname(struct slabname *s) \
+scope void clear_ ##slabname(struct slabname *s) \
{ \
unsigned int i; \
for (i = 0; i < s->slab_count; i++) \
@@ -34,7 +40,7 @@ static MAYBE_UNUSED void clear_ ##slabname(struct slabname *s) \
FREE_AND_NULL(s->slab); \
} \
\
-static MAYBE_UNUSED elemtype *slabname## _at_peek(struct slabname *s, \
+scope elemtype *slabname## _at_peek(struct slabname *s, \
const struct commit *c, \
int add_if_missing) \
{ \
@@ -62,13 +68,13 @@ static MAYBE_UNUSED elemtype *slabname## _at_peek(struct slabname *s, \
return &s->slab[nth_slab][nth_slot * s->stride]; \
} \
\
-static MAYBE_UNUSED elemtype *slabname## _at(struct slabname *s, \
+scope elemtype *slabname## _at(struct slabname *s, \
const struct commit *c) \
{ \
return slabname##_at_peek(s, c, 1); \
} \
\
-static MAYBE_UNUSED elemtype *slabname## _peek(struct slabname *s, \
+scope elemtype *slabname## _peek(struct slabname *s, \
const struct commit *c) \
{ \
return slabname##_at_peek(s, c, 0); \
@@ -81,7 +87,7 @@ struct slabname
* to allow a terminating semicolon, which makes instantiations look
* like function declarations. I.e., the expansion of
*
- * implement_commit_slab(indegree, int);
+ * implement_commit_slab(indegree, int, static);
*
* ends in 'struct indegree;'. This would otherwise
* be a syntax error according (at least) to ISO C. It's hard to
diff --git a/commit-slab.h b/commit-slab.h
index 32aa2c0e46..69bf0c807c 100644
--- a/commit-slab.h
+++ b/commit-slab.h
@@ -46,6 +46,6 @@
#define define_commit_slab(slabname, elemtype) \
declare_commit_slab(slabname, elemtype); \
- implement_commit_slab(slabname, elemtype)
+ implement_static_commit_slab(slabname, elemtype)
#endif /* COMMIT_SLAB_H */
--
2.17.0.705.g3525833791
next prev parent reply other threads:[~2018-05-19 5:28 UTC|newest]
Thread overview: 82+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-12 8:00 [PATCH 00/12] Die commit->util, die! Nguyễn Thái Ngọc Duy
2018-05-12 8:00 ` [PATCH 01/12] blame: use commit-slab for blame suspects instead of commit->util Nguyễn Thái Ngọc Duy
2018-05-12 9:22 ` Jeff King
2018-05-12 12:13 ` Duy Nguyen
2018-05-12 8:00 ` [PATCH 02/12] describe: use commit-slab for commit names " Nguyễn Thái Ngọc Duy
2018-05-12 8:00 ` [PATCH 03/12] shallow.c: use commit-slab for commit depth " Nguyễn Thái Ngọc Duy
2018-05-12 9:07 ` Jeff King
2018-05-12 9:18 ` Jeff King
2018-05-12 12:09 ` Duy Nguyen
2018-05-12 19:12 ` Jeff King
2018-05-12 11:59 ` Duy Nguyen
2018-05-12 8:00 ` [PATCH 04/12] sequencer.c: use commit-slab to mark seen commits Nguyễn Thái Ngọc Duy
2018-05-12 9:25 ` Jeff King
2018-05-12 13:43 ` Junio C Hamano
2018-05-12 14:00 ` Duy Nguyen
2018-05-12 8:00 ` [PATCH 05/12] sequencer.c: use commit-slab to associate todo items to commits Nguyễn Thái Ngọc Duy
2018-05-12 9:28 ` Jeff King
2018-05-12 8:00 ` [PATCH 06/12] revision.c: use commit-slab for show_source Nguyễn Thái Ngọc Duy
2018-05-12 9:33 ` Jeff King
2018-05-12 13:58 ` Junio C Hamano
2018-05-12 14:13 ` Duy Nguyen
2018-05-12 19:06 ` Jeff King
2018-05-12 8:00 ` [PATCH 07/12] bisect.c: use commit-slab for commit weight instead of commit->util Nguyễn Thái Ngọc Duy
2018-05-12 13:59 ` Junio C Hamano
2018-05-12 8:00 ` [PATCH 08/12] name-rev: use commit-slab for rev-name " Nguyễn Thái Ngọc Duy
2018-05-12 8:00 ` [PATCH 09/12] show-branch: use commit-slab for commit-name " Nguyễn Thái Ngọc Duy
2018-05-12 8:00 ` [PATCH 10/12] log: use commit-slab in prepare_bases() " Nguyễn Thái Ngọc Duy
2018-05-12 8:00 ` [PATCH 11/12] merge: use commit-slab in merge remote desc " Nguyễn Thái Ngọc Duy
2018-05-12 8:00 ` [PATCH 12/12] commit.h: delete 'util' field in struct commit Nguyễn Thái Ngọc Duy
2018-05-12 9:41 ` [PATCH 00/12] Die commit->util, die! Jeff King
2018-05-12 18:50 ` Jakub Narebski
2018-05-13 5:39 ` Duy Nguyen
2018-05-13 5:51 ` [PATCH v2 00/14] " Nguyễn Thái Ngọc Duy
2018-05-13 5:51 ` [PATCH v2 01/14] commit-slab.h: code split Nguyễn Thái Ngọc Duy
2018-05-13 23:33 ` Junio C Hamano
2018-05-13 5:51 ` [PATCH v2 02/14] commit-slab: support shared commit-slab Nguyễn Thái Ngọc Duy
2018-05-13 23:36 ` Junio C Hamano
2018-05-13 5:51 ` [PATCH v2 03/14] blame: use commit-slab for blame suspects instead of commit->util Nguyễn Thái Ngọc Duy
2018-05-13 23:42 ` Junio C Hamano
2018-05-13 5:51 ` [PATCH v2 04/14] describe: use commit-slab for commit names " Nguyễn Thái Ngọc Duy
2018-05-13 23:45 ` Junio C Hamano
2018-05-13 5:51 ` [PATCH v2 05/14] shallow.c: use commit-slab for commit depth " Nguyễn Thái Ngọc Duy
2018-05-13 5:52 ` [PATCH v2 06/14] sequencer.c: use commit-slab to mark seen commits Nguyễn Thái Ngọc Duy
2018-05-14 4:17 ` Junio C Hamano
2018-05-13 5:52 ` [PATCH v2 07/14] sequencer.c: use commit-slab to associate todo items to commits Nguyễn Thái Ngọc Duy
2018-05-13 5:52 ` [PATCH v2 08/14] revision.c: use commit-slab for show_source Nguyễn Thái Ngọc Duy
2018-05-14 5:10 ` Junio C Hamano
2018-05-14 5:37 ` Junio C Hamano
2018-05-13 5:52 ` [PATCH v2 09/14] bisect.c: use commit-slab for commit weight instead of commit->util Nguyễn Thái Ngọc Duy
2018-05-14 6:16 ` Junio C Hamano
2018-05-13 5:52 ` [PATCH v2 10/14] name-rev: use commit-slab for rev-name " Nguyễn Thái Ngọc Duy
2018-05-13 5:52 ` [PATCH v2 11/14] show-branch: use commit-slab for commit-name " Nguyễn Thái Ngọc Duy
2018-05-14 6:45 ` Junio C Hamano
2018-05-19 4:51 ` Duy Nguyen
2018-05-13 5:52 ` [PATCH v2 12/14] log: use commit-slab in prepare_bases() " Nguyễn Thái Ngọc Duy
2018-05-13 5:52 ` [PATCH v2 13/14] merge: use commit-slab in merge remote desc " Nguyễn Thái Ngọc Duy
2018-05-18 2:16 ` Junio C Hamano
2018-05-18 17:54 ` Ramsay Jones
2018-05-13 5:52 ` [PATCH v2 14/14] commit.h: delete 'util' field in struct commit Nguyễn Thái Ngọc Duy
2018-05-14 7:52 ` Junio C Hamano
2018-05-14 16:07 ` Duy Nguyen
2018-05-14 17:30 ` Duy Nguyen
2018-05-14 18:14 ` Derrick Stolee
2018-05-19 5:41 ` Duy Nguyen
2018-05-19 5:28 ` [PATCH v3 00/15] Die commit->util, die! Nguyễn Thái Ngọc Duy
2018-05-19 5:28 ` [PATCH v3 01/15] commit-slab.h: code split Nguyễn Thái Ngọc Duy
2018-05-21 5:11 ` Junio C Hamano
2018-05-19 5:28 ` Nguyễn Thái Ngọc Duy [this message]
2018-05-19 5:28 ` [PATCH v3 03/15] blame: use commit-slab for blame suspects instead of commit->util Nguyễn Thái Ngọc Duy
2018-05-19 5:28 ` [PATCH v3 04/15] describe: use commit-slab for commit names " Nguyễn Thái Ngọc Duy
2018-05-19 5:28 ` [PATCH v3 05/15] shallow.c: use commit-slab for commit depth " Nguyễn Thái Ngọc Duy
2018-05-19 5:28 ` [PATCH v3 06/15] sequencer.c: use commit-slab to mark seen commits Nguyễn Thái Ngọc Duy
2018-05-19 5:28 ` [PATCH v3 07/15] sequencer.c: use commit-slab to associate todo items to commits Nguyễn Thái Ngọc Duy
2018-05-19 5:28 ` [PATCH v3 08/15] revision.c: use commit-slab for show_source Nguyễn Thái Ngọc Duy
2018-05-19 5:28 ` [PATCH v3 09/15] bisect.c: use commit-slab for commit weight instead of commit->util Nguyễn Thái Ngọc Duy
2018-05-19 5:28 ` [PATCH v3 10/15] name-rev: use commit-slab for rev-name " Nguyễn Thái Ngọc Duy
2018-05-19 5:28 ` [PATCH v3 11/15] show-branch: use commit-slab for commit-name " Nguyễn Thái Ngọc Duy
2018-05-19 5:28 ` [PATCH v3 12/15] show-branch: note about its object flags usage Nguyễn Thái Ngọc Duy
2018-05-19 5:28 ` [PATCH v3 13/15] log: use commit-slab in prepare_bases() instead of commit->util Nguyễn Thái Ngọc Duy
2018-05-19 5:28 ` [PATCH v3 14/15] merge: use commit-slab in merge remote desc " Nguyễn Thái Ngọc Duy
2018-05-19 5:28 ` [PATCH v3 15/15] commit.h: delete 'util' field in struct commit Nguyễn Thái Ngọc Duy
2018-05-22 22:40 ` [PATCH 00/12] Die commit->util, die! Stefan Beller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180519052831.12603-3-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).