mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-04-30 09:07:53 +03:00
Track the initialized state of nstime_t on debug build.
Some nstime_t operations require and assume the input nstime is initialized (e.g. nstime_update) -- uninitialized input may cause silent failures which is difficult to reproduce / debug. Add an explicit flag to track the state (limited to debug build only). Also fixed an use case in hpa (time of last_purge).
This commit is contained in:
parent
400c59895a
commit
cdabe908d0
3 changed files with 72 additions and 2 deletions
|
|
@ -3,10 +3,19 @@
|
|||
|
||||
/* Maximum supported number of seconds (~584 years). */
|
||||
#define NSTIME_SEC_MAX KQU(18446744072)
|
||||
#define NSTIME_ZERO_INITIALIZER {0}
|
||||
|
||||
#define NSTIME_MAGIC ((uint32_t)0xb8a9ce37)
|
||||
#ifdef JEMALLOC_DEBUG
|
||||
# define NSTIME_ZERO_INITIALIZER {0, NSTIME_MAGIC}
|
||||
#else
|
||||
# define NSTIME_ZERO_INITIALIZER {0}
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
uint64_t ns;
|
||||
#ifdef JEMALLOC_DEBUG
|
||||
uint32_t magic; /* Tracks if initialized. */
|
||||
#endif
|
||||
} nstime_t;
|
||||
|
||||
static const nstime_t zero = NSTIME_ZERO_INITIALIZER;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue