From 418d96a86ce95e36f3dbd3dd700a30b5b7cdbcfd Mon Sep 17 00:00:00 2001 From: David Goldblatt Date: Mon, 17 Apr 2017 16:17:02 -0700 Subject: Header refactoring: unify nstime.h and move it out of the catch-all --- include/jemalloc/internal/arena_structs_b.h | 1 + .../jemalloc/internal/jemalloc_internal_includes.h | 3 -- include/jemalloc/internal/mutex_inlines.h | 2 ++ include/jemalloc/internal/mutex_structs.h | 1 + include/jemalloc/internal/nstime.h | 36 ++++++++++++++++++++++ include/jemalloc/internal/nstime_externs.h | 27 ---------------- include/jemalloc/internal/nstime_structs.h | 8 ----- include/jemalloc/internal/nstime_types.h | 11 ------- src/ctl.c | 1 + src/nstime.c | 2 ++ test/include/test/jemalloc_test.h.in | 4 +-- 11 files changed, 44 insertions(+), 52 deletions(-) create mode 100644 include/jemalloc/internal/nstime.h delete mode 100644 include/jemalloc/internal/nstime_externs.h delete mode 100644 include/jemalloc/internal/nstime_structs.h delete mode 100644 include/jemalloc/internal/nstime_types.h diff --git a/include/jemalloc/internal/arena_structs_b.h b/include/jemalloc/internal/arena_structs_b.h index 14c473c..f2195f6 100644 --- a/include/jemalloc/internal/arena_structs_b.h +++ b/include/jemalloc/internal/arena_structs_b.h @@ -2,6 +2,7 @@ #define JEMALLOC_INTERNAL_ARENA_STRUCTS_B_H #include "jemalloc/internal/atomic.h" +#include "jemalloc/internal/nstime.h" #include "jemalloc/internal/ql.h" /* diff --git a/include/jemalloc/internal/jemalloc_internal_includes.h b/include/jemalloc/internal/jemalloc_internal_includes.h index 7a51c2d..f31fed6 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/nstime_types.h" #include "jemalloc/internal/spin_types.h" #include "jemalloc/internal/prng_types.h" #include "jemalloc/internal/ticker_types.h" @@ -66,7 +65,6 @@ /* STRUCTS */ /******************************************************************************/ -#include "jemalloc/internal/nstime_structs.h" #include "jemalloc/internal/spin_structs.h" #include "jemalloc/internal/ticker_structs.h" #include "jemalloc/internal/ckh_structs.h" @@ -90,7 +88,6 @@ /******************************************************************************/ #include "jemalloc/internal/jemalloc_internal_externs.h" -#include "jemalloc/internal/nstime_externs.h" #include "jemalloc/internal/ckh_externs.h" #include "jemalloc/internal/stats_externs.h" #include "jemalloc/internal/ctl_externs.h" diff --git a/include/jemalloc/internal/mutex_inlines.h b/include/jemalloc/internal/mutex_inlines.h index 0552e19..5ec439f 100644 --- a/include/jemalloc/internal/mutex_inlines.h +++ b/include/jemalloc/internal/mutex_inlines.h @@ -1,6 +1,8 @@ #ifndef JEMALLOC_INTERNAL_MUTEX_INLINES_H #define JEMALLOC_INTERNAL_MUTEX_INLINES_H +#include "jemalloc/internal/nstime.h" + void malloc_mutex_lock_slow(malloc_mutex_t *mutex); #ifndef JEMALLOC_ENABLE_INLINE diff --git a/include/jemalloc/internal/mutex_structs.h b/include/jemalloc/internal/mutex_structs.h index 7b7085d..dc75554 100644 --- a/include/jemalloc/internal/mutex_structs.h +++ b/include/jemalloc/internal/mutex_structs.h @@ -2,6 +2,7 @@ #define JEMALLOC_INTERNAL_MUTEX_STRUCTS_H #include "jemalloc/internal/atomic.h" +#include "jemalloc/internal/nstime.h" struct mutex_prof_data_s { /* diff --git a/include/jemalloc/internal/nstime.h b/include/jemalloc/internal/nstime.h new file mode 100644 index 0000000..cfccca0 --- /dev/null +++ b/include/jemalloc/internal/nstime.h @@ -0,0 +1,36 @@ +#ifndef JEMALLOC_INTERNAL_NSTIME_H +#define JEMALLOC_INTERNAL_NSTIME_H + +/* Maximum supported number of seconds (~584 years). */ +#define NSTIME_SEC_MAX KQU(18446744072) +#define NSTIME_ZERO_INITIALIZER {0} + +typedef struct { + uint64_t ns; +} nstime_t; + +void nstime_init(nstime_t *time, uint64_t ns); +void nstime_init2(nstime_t *time, uint64_t sec, uint64_t nsec); +uint64_t nstime_ns(const nstime_t *time); +uint64_t nstime_sec(const nstime_t *time); +uint64_t nstime_msec(const nstime_t *time); +uint64_t nstime_nsec(const nstime_t *time); +void nstime_copy(nstime_t *time, const nstime_t *source); +int nstime_compare(const nstime_t *a, const nstime_t *b); +void nstime_add(nstime_t *time, const nstime_t *addend); +void nstime_subtract(nstime_t *time, const nstime_t *subtrahend); +void nstime_imultiply(nstime_t *time, uint64_t multiplier); +void nstime_idivide(nstime_t *time, uint64_t divisor); +uint64_t nstime_divide(const nstime_t *time, const nstime_t *divisor); +#ifdef JEMALLOC_JET +typedef bool (nstime_monotonic_t)(void); +extern nstime_monotonic_t *nstime_monotonic; +typedef bool (nstime_update_t)(nstime_t *); +extern nstime_update_t *nstime_update; +#else +bool nstime_monotonic(void); +bool nstime_update(nstime_t *time); +#endif + + +#endif /* JEMALLOC_INTERNAL_NSTIME_H */ diff --git a/include/jemalloc/internal/nstime_externs.h b/include/jemalloc/internal/nstime_externs.h deleted file mode 100644 index 1abc84d..0000000 --- a/include/jemalloc/internal/nstime_externs.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef JEMALLOC_INTERNAL_NSTIME_EXTERNS_H -#define JEMALLOC_INTERNAL_NSTIME_EXTERNS_H - -void nstime_init(nstime_t *time, uint64_t ns); -void nstime_init2(nstime_t *time, uint64_t sec, uint64_t nsec); -uint64_t nstime_ns(const nstime_t *time); -uint64_t nstime_sec(const nstime_t *time); -uint64_t nstime_msec(const nstime_t *time); -uint64_t nstime_nsec(const nstime_t *time); -void nstime_copy(nstime_t *time, const nstime_t *source); -int nstime_compare(const nstime_t *a, const nstime_t *b); -void nstime_add(nstime_t *time, const nstime_t *addend); -void nstime_subtract(nstime_t *time, const nstime_t *subtrahend); -void nstime_imultiply(nstime_t *time, uint64_t multiplier); -void nstime_idivide(nstime_t *time, uint64_t divisor); -uint64_t nstime_divide(const nstime_t *time, const nstime_t *divisor); -#ifdef JEMALLOC_JET -typedef bool (nstime_monotonic_t)(void); -extern nstime_monotonic_t *nstime_monotonic; -typedef bool (nstime_update_t)(nstime_t *); -extern nstime_update_t *nstime_update; -#else -bool nstime_monotonic(void); -bool nstime_update(nstime_t *time); -#endif - -#endif /* JEMALLOC_INTERNAL_NSTIME_EXTERNS_H */ diff --git a/include/jemalloc/internal/nstime_structs.h b/include/jemalloc/internal/nstime_structs.h deleted file mode 100644 index a637f61..0000000 --- a/include/jemalloc/internal/nstime_structs.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef JEMALLOC_INTERNAL_NSTIME_STRUCTS_H -#define JEMALLOC_INTERNAL_NSTIME_STRUCTS_H - -struct nstime_s { - uint64_t ns; -}; - -#endif /* JEMALLOC_INTERNAL_NSTIME_STRUCTS_H */ diff --git a/include/jemalloc/internal/nstime_types.h b/include/jemalloc/internal/nstime_types.h deleted file mode 100644 index 6e7e74c..0000000 --- a/include/jemalloc/internal/nstime_types.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef JEMALLOC_INTERNAL_NSTIME_TYPES_H -#define JEMALLOC_INTERNAL_NSTIME_TYPES_H - -typedef struct nstime_s nstime_t; - -/* Maximum supported number of seconds (~584 years). */ -#define NSTIME_SEC_MAX KQU(18446744072) - -#define NSTIME_ZERO_INITIALIZER {0} - -#endif /* JEMALLOC_INTERNAL_NSTIME_TYPES_H */ diff --git a/src/ctl.c b/src/ctl.c index 4fba2cd..069e535 100644 --- a/src/ctl.c +++ b/src/ctl.c @@ -3,6 +3,7 @@ #include "jemalloc/internal/jemalloc_internal_includes.h" #include "jemalloc/internal/assert.h" +#include "jemalloc/internal/nstime.h" #include "jemalloc/internal/util.h" /******************************************************************************/ diff --git a/src/nstime.c b/src/nstime.c index e089547..9f5d192 100644 --- a/src/nstime.c +++ b/src/nstime.c @@ -1,6 +1,8 @@ #include "jemalloc/internal/jemalloc_preamble.h" #include "jemalloc/internal/jemalloc_internal_includes.h" +#include "jemalloc/internal/nstime.h" + #include "jemalloc/internal/assert.h" #define BILLION UINT64_C(1000000000) diff --git a/test/include/test/jemalloc_test.h.in b/test/include/test/jemalloc_test.h.in index 02eaac2..67caa86 100644 --- a/test/include/test/jemalloc_test.h.in +++ b/test/include/test/jemalloc_test.h.in @@ -74,12 +74,10 @@ static const bool config_debug = /* Hermetic headers. */ # include "jemalloc/internal/assert.h" # include "jemalloc/internal/malloc_io.h" +# include "jemalloc/internal/nstime.h" # include "jemalloc/internal/util.h" /* Non-hermetic headers. */ -# include "jemalloc/internal/nstime_types.h" -# include "jemalloc/internal/nstime_structs.h" -# include "jemalloc/internal/nstime_externs.h" # include "jemalloc/internal/qr.h" # include "jemalloc/internal/ql.h" -- cgit v0.12