https://github.com/halide/Halide
Raw File
Tip revision: efb326253c73a555d7a4608e41228665d1785e97 authored by Steven Johnson on 09 December 2020, 12:06:57 UTC
Update images used in apps/ tests (#5538)
Tip revision: efb3262
fuchsia_clock.cpp
#include "HalideRuntime.h"

extern "C" {

typedef int32_t zx_status_t;
typedef int64_t zx_time_t;
typedef int64_t zx_duration_t;

zx_time_t zx_clock_get_monotonic();

zx_time_t zx_deadline_after(zx_duration_t nanoseconds);
zx_status_t zx_nanosleep(zx_time_t deadline);

WEAK bool halide_reference_clock_inited = false;
WEAK zx_time_t halide_reference_clock;

WEAK int halide_start_clock(void *user_context) {
    // Guard against multiple calls
    if (!halide_reference_clock_inited) {
        halide_reference_clock = zx_clock_get_monotonic();
        halide_reference_clock_inited = true;
    }
    return 0;
}

WEAK int64_t halide_current_time_ns(void *user_context) {
    return zx_clock_get_monotonic() - halide_reference_clock;
}

WEAK void halide_sleep_ms(void *user_context, int ms) {
    zx_nanosleep(zx_deadline_after(ms * 1000));
}
}
back to top