From bf2dc7e67840807fb90451ab34e7150401f7f7c4 Mon Sep 17 00:00:00 2001 From: David Goldblatt Date: Wed, 19 Apr 2017 13:39:33 -0700 Subject: [PATCH] Header refactoring: ticker module - remove from the catchall and unify. --- include/jemalloc/internal/arena_inlines_b.h | 1 + include/jemalloc/internal/arena_structs_b.h | 1 + .../internal/jemalloc_internal_includes.h | 3 --- .../internal/jemalloc_internal_inlines_a.h | 1 + include/jemalloc/internal/tcache_inlines.h | 1 + include/jemalloc/internal/tcache_structs.h | 1 + .../internal/{ticker_inlines.h => ticker.h} | 19 ++++++++++++++++--- include/jemalloc/internal/ticker_structs.h | 9 --------- include/jemalloc/internal/ticker_types.h | 6 ------ src/jemalloc.c | 1 + test/unit/decay.c | 2 ++ test/unit/ticker.c | 2 ++ 12 files changed, 26 insertions(+), 21 deletions(-) rename include/jemalloc/internal/{ticker_inlines.h => ticker.h} (52%) delete mode 100644 include/jemalloc/internal/ticker_structs.h delete mode 100644 include/jemalloc/internal/ticker_types.h diff --git a/include/jemalloc/internal/arena_inlines_b.h b/include/jemalloc/internal/arena_inlines_b.h index 526103bc..054757d4 100644 --- a/include/jemalloc/internal/arena_inlines_b.h +++ b/include/jemalloc/internal/arena_inlines_b.h @@ -2,6 +2,7 @@ #define JEMALLOC_INTERNAL_ARENA_INLINES_B_H #include "jemalloc/internal/jemalloc_internal_types.h" +#include "jemalloc/internal/ticker.h" static inline szind_t arena_bin_index(arena_t *arena, arena_bin_t *bin) { diff --git a/include/jemalloc/internal/arena_structs_b.h b/include/jemalloc/internal/arena_structs_b.h index f2195f68..7b133f2e 100644 --- a/include/jemalloc/internal/arena_structs_b.h +++ b/include/jemalloc/internal/arena_structs_b.h @@ -4,6 +4,7 @@ #include "jemalloc/internal/atomic.h" #include "jemalloc/internal/nstime.h" #include "jemalloc/internal/ql.h" +#include "jemalloc/internal/ticker.h" /* * Read-only information associated with each element of arena_t's bins array diff --git a/include/jemalloc/internal/jemalloc_internal_includes.h b/include/jemalloc/internal/jemalloc_internal_includes.h index 5e80f96c..8ce7864f 100644 --- a/include/jemalloc/internal/jemalloc_internal_includes.h +++ b/include/jemalloc/internal/jemalloc_internal_includes.h @@ -40,7 +40,6 @@ /* TYPES */ /******************************************************************************/ -#include "jemalloc/internal/ticker_types.h" #include "jemalloc/internal/ckh_types.h" #include "jemalloc/internal/size_classes.h" #include "jemalloc/internal/smoothstep.h" @@ -63,7 +62,6 @@ /* STRUCTS */ /******************************************************************************/ -#include "jemalloc/internal/ticker_structs.h" #include "jemalloc/internal/ckh_structs.h" #include "jemalloc/internal/witness_structs.h" #include "jemalloc/internal/mutex_structs.h" @@ -107,7 +105,6 @@ /* INLINES */ /******************************************************************************/ -#include "jemalloc/internal/ticker_inlines.h" #include "jemalloc/internal/tsd_inlines.h" #include "jemalloc/internal/witness_inlines.h" #include "jemalloc/internal/mutex_inlines.h" diff --git a/include/jemalloc/internal/jemalloc_internal_inlines_a.h b/include/jemalloc/internal/jemalloc_internal_inlines_a.h index 9cb933c2..06a5c717 100644 --- a/include/jemalloc/internal/jemalloc_internal_inlines_a.h +++ b/include/jemalloc/internal/jemalloc_internal_inlines_a.h @@ -4,6 +4,7 @@ #include "jemalloc/internal/atomic.h" #include "jemalloc/internal/bit_util.h" #include "jemalloc/internal/jemalloc_internal_types.h" +#include "jemalloc/internal/ticker.h" JEMALLOC_ALWAYS_INLINE pszind_t psz2ind(size_t psz) { diff --git a/include/jemalloc/internal/tcache_inlines.h b/include/jemalloc/internal/tcache_inlines.h index 8b42af66..25931d82 100644 --- a/include/jemalloc/internal/tcache_inlines.h +++ b/include/jemalloc/internal/tcache_inlines.h @@ -2,6 +2,7 @@ #define JEMALLOC_INTERNAL_TCACHE_INLINES_H #include "jemalloc/internal/jemalloc_internal_types.h" +#include "jemalloc/internal/ticker.h" #include "jemalloc/internal/util.h" static inline bool diff --git a/include/jemalloc/internal/tcache_structs.h b/include/jemalloc/internal/tcache_structs.h index fe27f362..c01098f1 100644 --- a/include/jemalloc/internal/tcache_structs.h +++ b/include/jemalloc/internal/tcache_structs.h @@ -2,6 +2,7 @@ #define JEMALLOC_INTERNAL_TCACHE_STRUCTS_H #include "jemalloc/internal/ql.h" +#include "jemalloc/internal/ticker.h" /* * Read-only information associated with each element of tcache_t's tbins array diff --git a/include/jemalloc/internal/ticker_inlines.h b/include/jemalloc/internal/ticker.h similarity index 52% rename from include/jemalloc/internal/ticker_inlines.h rename to include/jemalloc/internal/ticker.h index cd5821f9..faaac91d 100644 --- a/include/jemalloc/internal/ticker_inlines.h +++ b/include/jemalloc/internal/ticker.h @@ -1,5 +1,18 @@ -#ifndef JEMALLOC_INTERNAL_TICKER_INLINES_H -#define JEMALLOC_INTERNAL_TICKER_INLINES_H +#ifndef JEMALLOC_INTERNAL_TICKER_H +#define JEMALLOC_INTERNAL_TICKER_H + +/** + * A ticker makes it easy to count-down events until some limit. You + * ticker_init the ticker to trigger every nticks events. You then notify it + * that an event has occurred with calls to ticker_tick (or that nticks events + * have occurred with a call to ticker_ticks), which will return true (and reset + * the counter) if the countdown hit zero. + */ + +typedef struct { + int32_t tick; + int32_t nticks; +} ticker_t; static inline void ticker_init(ticker_t *ticker, int32_t nticks) { @@ -32,4 +45,4 @@ ticker_tick(ticker_t *ticker) { return ticker_ticks(ticker, 1); } -#endif /* JEMALLOC_INTERNAL_TICKER_INLINES_H */ +#endif /* JEMALLOC_INTERNAL_TICKER_H */ diff --git a/include/jemalloc/internal/ticker_structs.h b/include/jemalloc/internal/ticker_structs.h deleted file mode 100644 index e30c4e21..00000000 --- a/include/jemalloc/internal/ticker_structs.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef JEMALLOC_INTERNAL_TICKER_STRUCTS_H -#define JEMALLOC_INTERNAL_TICKER_STRUCTS_H - -struct ticker_s { - int32_t tick; - int32_t nticks; -}; - -#endif /* JEMALLOC_INTERNAL_TICKER_STRUCTS_H */ diff --git a/include/jemalloc/internal/ticker_types.h b/include/jemalloc/internal/ticker_types.h deleted file mode 100644 index 62d67f3d..00000000 --- a/include/jemalloc/internal/ticker_types.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef JEMALLOC_INTERNAL_TICKER_TYPES_H -#define JEMALLOC_INTERNAL_TICKER_TYPES_H - -typedef struct ticker_s ticker_t; - -#endif /* JEMALLOC_INTERNAL_TICKER_TYPES_H */ diff --git a/src/jemalloc.c b/src/jemalloc.c index 51194992..108258bd 100644 --- a/src/jemalloc.c +++ b/src/jemalloc.c @@ -7,6 +7,7 @@ #include "jemalloc/internal/jemalloc_internal_types.h" #include "jemalloc/internal/malloc_io.h" #include "jemalloc/internal/spin.h" +#include "jemalloc/internal/ticker.h" #include "jemalloc/internal/util.h" /******************************************************************************/ diff --git a/test/unit/decay.c b/test/unit/decay.c index 26359faf..389f6e06 100644 --- a/test/unit/decay.c +++ b/test/unit/decay.c @@ -1,5 +1,7 @@ #include "test/jemalloc_test.h" +#include "jemalloc/internal/ticker.h" + static nstime_monotonic_t *nstime_monotonic_orig; static nstime_update_t *nstime_update_orig; diff --git a/test/unit/ticker.c b/test/unit/ticker.c index c2ad7295..e5790a31 100644 --- a/test/unit/ticker.c +++ b/test/unit/ticker.c @@ -1,5 +1,7 @@ #include "test/jemalloc_test.h" +#include "jemalloc/internal/ticker.h" + TEST_BEGIN(test_ticker_tick) { #define NREPS 2 #define NTICKS 3