Skip to content

Commit 06cc09b

Browse files
authored
Merge pull request #167 from DataDog/ivoanjo/fix-incorrect-timestamp-math-posix-monotonic
Fix timestamp math for platforms with _POSIX_MONOTONIC_CLOCK
2 parents 6524e61 + 4f7ee11 commit 06cc09b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ext/stackprof/stackprof.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ static const char *fake_frame_cstrs[] = {
4949
}
5050

5151
static int64_t delta_usec(timestamp_t *start, timestamp_t *end) {
52-
int64_t result = 1000 * (end->tv_sec - start->tv_sec);
52+
int64_t result = MICROSECONDS_IN_SECOND * (end->tv_sec - start->tv_sec);
5353
if (end->tv_nsec < start->tv_nsec) {
54-
result -= 1000;
54+
result -= MICROSECONDS_IN_SECOND;
5555
result += (NANOSECONDS_IN_SECOND + end->tv_nsec - start->tv_nsec) / 1000;
5656
} else {
5757
result += (end->tv_nsec - start->tv_nsec) / 1000;

0 commit comments

Comments
 (0)