Skip to content

Commit cba8733

Browse files
committed
Rewrite MMTk-specific code with WHEN_USING_MMTK
When the "#if USE_MMTK" directive and the `if (rb_mmtk_enabled_p())` statement are used together, it will be very complicated and confusing. We rewrite `string.c` using the convenient `WHEN_USING_MMTK`, `WHEN_NOT_USING_MMTK` and `WHEN_USING_MMTK2` macros when possible. This commit does not change the semantics of the existing code in `string.c`.
1 parent 69db488 commit cba8733

File tree

2 files changed

+123
-168
lines changed

2 files changed

+123
-168
lines changed

Diff for: internal/mmtk_macros.h

+4
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@
55

66
#if USE_MMTK
77
#define IF_USE_MMTK(a) a
8+
#define IF_NOT_USE_MMTK(a)
89
#define IF_USE_MMTK2(a, b) a
910
#define WHEN_USING_MMTK(a) if (rb_mmtk_enabled_p()) { a }
11+
#define WHEN_NOT_USING_MMTK(a) if (!rb_mmtk_enabled_p()) { a }
1012
#define WHEN_USING_MMTK2(a, b) if (rb_mmtk_enabled_p()) { a } else { b }
1113
#else
1214
#define IF_USE_MMTK(a)
15+
#define IF_NOT_USE_MMTK(a) a
1316
#define IF_USE_MMTK2(a, b) b
1417
#define WHEN_USING_MMTK(a)
18+
#define WHEN_NOT_USING_MMTK(a) a
1519
#define WHEN_USING_MMTK2(a, b) b
1620
#endif
1721

0 commit comments

Comments
 (0)