summaryrefslogtreecommitdiff
path: root/lib/System/System.cpp
blob: 4964921a4a7136c18c48d21e2081d578de1dc1ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <sys/time.h>
#include <stdint.h>
#include "System/System.h"

// FIXME: windows support.

static timeval programStart;

LIBFLANG_ABI void libflang_sys_init() {
  gettimeofday(&programStart, nullptr);
}

LIBFLANG_ABI float libflang_etime(float *time0, float *time1) {
  timeval stop;
  gettimeofday(&stop, nullptr);
  int64_t diff = stop.tv_usec - programStart.tv_usec;

  *time0 = float(double(diff) / 1000000.0);
  *time1 = 0.0f;
  return *time0 + *time1;
}