CLOCK_MONOTONIC and uint64_t aren't entirely portable.
This commit is contained in:
parent
cec35b4d7c
commit
d80e0c1fd3
10
gc.c
10
gc.c
|
|
@ -10,6 +10,12 @@
|
||||||
|
|
||||||
#include "gc.h"
|
#include "gc.h"
|
||||||
|
|
||||||
|
#if _CLOCK_MONOTONIC
|
||||||
|
# define TIMING_CLOCK CLOCK_MONOTONIC
|
||||||
|
#else
|
||||||
|
# define TIMING_CLOCK CLOCK_REALTIME
|
||||||
|
#endif
|
||||||
|
|
||||||
gc_stats_t gc_stats;
|
gc_stats_t gc_stats;
|
||||||
|
|
||||||
/* Helper macros to reduce duplication */
|
/* Helper macros to reduce duplication */
|
||||||
|
|
@ -652,7 +658,7 @@ static void _collect_garbage(size_t min_free)
|
||||||
#ifndef NO_STATS
|
#ifndef NO_STATS
|
||||||
#ifndef NO_TIMING_STATS
|
#ifndef NO_TIMING_STATS
|
||||||
struct timespec start_time;
|
struct timespec start_time;
|
||||||
clock_gettime(CLOCK_MONOTONIC, &start_time);
|
clock_gettime(TIMING_CLOCK, &start_time);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gc_stats.total_freed -= gc_free_space();
|
gc_stats.total_freed -= gc_free_space();
|
||||||
|
|
@ -705,7 +711,7 @@ static void _collect_garbage(size_t min_free)
|
||||||
struct timespec end_time;
|
struct timespec end_time;
|
||||||
nsec_t nsec;
|
nsec_t nsec;
|
||||||
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &end_time);
|
clock_gettime(TIMING_CLOCK, &end_time);
|
||||||
|
|
||||||
nsec = (end_time.tv_sec - start_time.tv_sec) * 1000000000LL;
|
nsec = (end_time.tv_sec - start_time.tv_sec) * 1000000000LL;
|
||||||
nsec += (end_time.tv_nsec - start_time.tv_nsec);
|
nsec += (end_time.tv_nsec - start_time.tv_nsec);
|
||||||
|
|
|
||||||
6
gc.h
6
gc.h
|
|
@ -114,13 +114,15 @@ typedef struct gc_root
|
||||||
struct gc_root *next;
|
struct gc_root *next;
|
||||||
} gc_root_t;
|
} gc_root_t;
|
||||||
|
|
||||||
typedef uint64_t nsec_t;
|
/* uint64_t isn't present everywhere */
|
||||||
|
typedef unsigned long long nsec_t;
|
||||||
|
typedef unsigned long long llsize_t;
|
||||||
|
|
||||||
typedef struct gc_stats
|
typedef struct gc_stats
|
||||||
{
|
{
|
||||||
int collections;
|
int collections;
|
||||||
nsec_t total_ns;
|
nsec_t total_ns;
|
||||||
uint64_t total_freed;
|
llsize_t total_freed;
|
||||||
size_t high_water;
|
size_t high_water;
|
||||||
nsec_t max_ns;
|
nsec_t max_ns;
|
||||||
} gc_stats_t;
|
} gc_stats_t;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue