| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| #include "edge-impulse-sdk/porting/ei_classifier_porting.h" |
| #if EI_PORTING_POSIX == 1 |
|
|
| #include <inttypes.h> |
| #include <math.h> |
| #include <stdio.h> |
| #include <time.h> |
| #include <unistd.h> |
| #include <stdarg.h> |
| #include <stdlib.h> |
|
|
| __attribute__((weak)) EI_IMPULSE_ERROR ei_run_impulse_check_canceled() { |
| return EI_IMPULSE_OK; |
| } |
|
|
| |
| |
| |
| __attribute__((weak)) EI_IMPULSE_ERROR ei_sleep(int32_t time_ms) { |
| usleep(time_ms * 1000); |
| return EI_IMPULSE_OK; |
| } |
|
|
| uint64_t ei_read_timer_ms() { |
| return ei_read_timer_us() / 1000; |
| } |
|
|
| uint64_t ei_read_timer_us() { |
| #if defined(__APPLE__) && EI_CLASSIFIER_USE_GPU_DELEGATES==1 |
| return clock_gettime_nsec_np(CLOCK_MONOTONIC_RAW) / 1e3; |
| #else |
|
|
| #if EI_CLASSIFIER_USE_GPU_DELEGATES==1 || EI_CLASSIFIER_USE_QNN_DELEGATES==1 |
| clockid_t clock_id = CLOCK_MONOTONIC; |
| #else |
| clockid_t clock_id = CLOCK_PROCESS_CPUTIME_ID; |
| #endif |
|
|
| struct timespec spec; |
| clock_gettime(clock_id, &spec); |
| return ((static_cast<uint64_t>(spec.tv_sec) * 1e6) + |
| (static_cast<uint64_t>(spec.tv_nsec) / 1e3)); |
| #endif |
| } |
|
|
| __attribute__((weak)) void ei_printf(const char *format, ...) { |
| va_list myargs; |
| va_start(myargs, format); |
| vprintf(format, myargs); |
| va_end(myargs); |
| } |
|
|
| __attribute__((weak)) void ei_printf_float(float f) { |
| ei_printf("%f", f); |
| } |
|
|
| __attribute__((weak)) void ei_putchar(char data) |
| { |
| putchar(data); |
| } |
|
|
| __attribute__((weak)) char ei_getchar(void) |
| { |
| return getchar(); |
| } |
|
|
| __attribute__((weak)) void *ei_malloc(size_t size) { |
| return malloc(size); |
| } |
|
|
| __attribute__((weak)) void *ei_calloc(size_t nitems, size_t size) { |
| return calloc(nitems, size); |
| } |
|
|
| __attribute__((weak)) void ei_free(void *ptr) { |
| free(ptr); |
| } |
|
|
| #if defined(__cplusplus) && EI_C_LINKAGE == 1 |
| extern "C" |
| #endif |
| __attribute__((weak)) void DebugLog(const char* s) { |
| ei_printf("%s", s); |
| } |
|
|
| #endif |
|
|