summaryrefslogtreecommitdiffstats
path: root/include/jemalloc
diff options
context:
space:
mode:
authorJason Evans <jasone@canonware.com>2016-02-21 19:25:02 (GMT)
committerJason Evans <jasone@canonware.com>2016-02-22 05:39:05 (GMT)
commit9bad07903962962de9f656d281b9b1e7e9501c87 (patch)
tree1468055ff093f7a7d341e739f2b6df4f097f868c /include/jemalloc
parent788d29d397574396c4c93bf1f90da59dd7efc5cc (diff)
downloadjemalloc-9bad07903962962de9f656d281b9b1e7e9501c87.zip
jemalloc-9bad07903962962de9f656d281b9b1e7e9501c87.tar.gz
jemalloc-9bad07903962962de9f656d281b9b1e7e9501c87.tar.bz2
Refactor time_* into nstime_*.
Use a single uint64_t in nstime_t to store nanoseconds rather than using struct timespec. This reduces fragility around conversions between long and uint64_t, especially missing casts that only cause problems on 32-bit platforms.
Diffstat (limited to 'include/jemalloc')
-rw-r--r--include/jemalloc/internal/arena.h6
-rw-r--r--include/jemalloc/internal/jemalloc_internal.h.in8
-rw-r--r--include/jemalloc/internal/nstime.h48
-rw-r--r--include/jemalloc/internal/private_symbols.txt24
-rw-r--r--include/jemalloc/internal/time.h41
5 files changed, 68 insertions, 59 deletions
diff --git a/include/jemalloc/internal/arena.h b/include/jemalloc/internal/arena.h
index 76d3be1..65d4158 100644
--- a/include/jemalloc/internal/arena.h
+++ b/include/jemalloc/internal/arena.h
@@ -395,7 +395,7 @@ struct arena_s {
*/
ssize_t decay_time;
/* decay_time / SMOOTHSTEP_NSTEPS. */
- struct timespec decay_interval;
+ nstime_t decay_interval;
/*
* Time at which the current decay interval logically started. We do
* not actually advance to a new epoch until sometime after it starts
@@ -403,7 +403,7 @@ struct arena_s {
* to completely skip epochs. In all cases, during epoch advancement we
* merge all relevant activity into the most recently recorded epoch.
*/
- struct timespec decay_epoch;
+ nstime_t decay_epoch;
/* decay_deadline randomness generator. */
uint64_t decay_jitter_state;
/*
@@ -413,7 +413,7 @@ struct arena_s {
* decay_interval, but we randomize the deadline to reduce the
* likelihood of arenas purging in lockstep.
*/
- struct timespec decay_deadline;
+ nstime_t decay_deadline;
/*
* Number of dirty pages at beginning of current epoch. During epoch
* advancement we use the delta between decay_ndirty and ndirty to
diff --git a/include/jemalloc/internal/jemalloc_internal.h.in b/include/jemalloc/internal/jemalloc_internal.h.in
index aa97d7c..0260b9a 100644
--- a/include/jemalloc/internal/jemalloc_internal.h.in
+++ b/include/jemalloc/internal/jemalloc_internal.h.in
@@ -356,7 +356,7 @@ typedef unsigned szind_t;
# define VARIABLE_ARRAY(type, name, count) type name[(count)]
#endif
-#include "jemalloc/internal/time.h"
+#include "jemalloc/internal/nstime.h"
#include "jemalloc/internal/valgrind.h"
#include "jemalloc/internal/util.h"
#include "jemalloc/internal/atomic.h"
@@ -387,7 +387,7 @@ typedef unsigned szind_t;
/******************************************************************************/
#define JEMALLOC_H_STRUCTS
-#include "jemalloc/internal/time.h"
+#include "jemalloc/internal/nstime.h"
#include "jemalloc/internal/valgrind.h"
#include "jemalloc/internal/util.h"
#include "jemalloc/internal/atomic.h"
@@ -477,7 +477,7 @@ void jemalloc_prefork(void);
void jemalloc_postfork_parent(void);
void jemalloc_postfork_child(void);
-#include "jemalloc/internal/time.h"
+#include "jemalloc/internal/nstime.h"
#include "jemalloc/internal/valgrind.h"
#include "jemalloc/internal/util.h"
#include "jemalloc/internal/atomic.h"
@@ -508,7 +508,7 @@ void jemalloc_postfork_child(void);
/******************************************************************************/
#define JEMALLOC_H_INLINES
-#include "jemalloc/internal/time.h"
+#include "jemalloc/internal/nstime.h"
#include "jemalloc/internal/valgrind.h"
#include "jemalloc/internal/util.h"
#include "jemalloc/internal/atomic.h"
diff --git a/include/jemalloc/internal/nstime.h b/include/jemalloc/internal/nstime.h
new file mode 100644
index 0000000..bd04f04
--- /dev/null
+++ b/include/jemalloc/internal/nstime.h
@@ -0,0 +1,48 @@
+/******************************************************************************/
+#ifdef JEMALLOC_H_TYPES
+
+#define JEMALLOC_CLOCK_GETTIME defined(_POSIX_MONOTONIC_CLOCK) \
+ && _POSIX_MONOTONIC_CLOCK >= 0
+
+typedef struct nstime_s nstime_t;
+
+/* Maximum supported number of seconds (~584 years). */
+#define NSTIME_SEC_MAX 18446744072
+
+#endif /* JEMALLOC_H_TYPES */
+/******************************************************************************/
+#ifdef JEMALLOC_H_STRUCTS
+
+struct nstime_s {
+ uint64_t ns;
+};
+
+#endif /* JEMALLOC_H_STRUCTS */
+/******************************************************************************/
+#ifdef JEMALLOC_H_EXTERNS
+
+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_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_update_t)(nstime_t *);
+extern nstime_update_t *nstime_update;
+#else
+bool nstime_update(nstime_t *time);
+#endif
+
+#endif /* JEMALLOC_H_EXTERNS */
+/******************************************************************************/
+#ifdef JEMALLOC_H_INLINES
+
+#endif /* JEMALLOC_H_INLINES */
+/******************************************************************************/
diff --git a/include/jemalloc/internal/private_symbols.txt b/include/jemalloc/internal/private_symbols.txt
index 8428cf4..c12baad 100644
--- a/include/jemalloc/internal/private_symbols.txt
+++ b/include/jemalloc/internal/private_symbols.txt
@@ -327,6 +327,19 @@ narenas_tdata_cleanup
narenas_total_get
ncpus
nhbins
+nstime_add
+nstime_compare
+nstime_copy
+nstime_divide
+nstime_idivide
+nstime_imultiply
+nstime_init
+nstime_init2
+nstime_ns
+nstime_nsec
+nstime_sec
+nstime_subtract
+nstime_update
opt_abort
opt_decay_time
opt_dss
@@ -484,17 +497,6 @@ ticker_init
ticker_read
ticker_tick
ticker_ticks
-time_add
-time_compare
-time_copy
-time_divide
-time_idivide
-time_imultiply
-time_init
-time_nsec
-time_sec
-time_subtract
-time_update
tsd_arena_get
tsd_arena_set
tsd_boot
diff --git a/include/jemalloc/internal/time.h b/include/jemalloc/internal/time.h
deleted file mode 100644
index dd1dd5b..0000000
--- a/include/jemalloc/internal/time.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/******************************************************************************/
-#ifdef JEMALLOC_H_TYPES
-
-#define JEMALLOC_CLOCK_GETTIME defined(_POSIX_MONOTONIC_CLOCK) \
- && _POSIX_MONOTONIC_CLOCK >= 0
-
-/* Maximum supported number of seconds (~584 years). */
-#define TIME_SEC_MAX 18446744072
-
-#endif /* JEMALLOC_H_TYPES */
-/******************************************************************************/
-#ifdef JEMALLOC_H_STRUCTS
-
-#endif /* JEMALLOC_H_STRUCTS */
-/******************************************************************************/
-#ifdef JEMALLOC_H_EXTERNS
-
-void time_init(struct timespec *time, time_t sec, long nsec);
-time_t time_sec(const struct timespec *time);
-long time_nsec(const struct timespec *time);
-void time_copy(struct timespec *time, const struct timespec *source);
-int time_compare(const struct timespec *a, const struct timespec *b);
-void time_add(struct timespec *time, const struct timespec *addend);
-void time_subtract(struct timespec *time, const struct timespec *subtrahend);
-void time_imultiply(struct timespec *time, uint64_t multiplier);
-void time_idivide(struct timespec *time, uint64_t divisor);
-uint64_t time_divide(const struct timespec *time,
- const struct timespec *divisor);
-#ifdef JEMALLOC_JET
-typedef bool (time_update_t)(struct timespec *);
-extern time_update_t *time_update;
-#else
-bool time_update(struct timespec *time);
-#endif
-
-#endif /* JEMALLOC_H_EXTERNS */
-/******************************************************************************/
-#ifdef JEMALLOC_H_INLINES
-
-#endif /* JEMALLOC_H_INLINES */
-/******************************************************************************/