layout: doc title: “Starboard Module Reference: time.h”

Provides access to system time and timers.

Functions

SbTimeFromPosix

Description

Converts microseconds from the POSIX epoch into an SbTime.

Declaration

static SB_C_FORCE_INLINE SbTime SbTimeFromPosix(int64_t time) {
  return time - kSbTimeToPosixDelta;
}

Parameters

SbTimeGetMonotonicNow

Description

Gets a monotonically increasing time representing right now.

Declaration and definitions

#include "starboard/time.h"

SbTimeMonotonic SbTimeGetMonotonicNow() {
  return SbTimeMonotonic();
}

SbTimeGetMonotonicThreadNow

Description

Gets a monotonically increasing time representing how long the current thread has been in the executing state (i.e. not pre-empted nor waiting on an event). This is not necessarily total time and is intended to allow measuring thread execution time between two timestamps. If this is not available then SbTimeGetMonotonicNow() should be used.

Declaration and definitions

#include "starboard/time.h"

SbTimeMonotonic SbTimeGetMonotonicThreadNow() {
  return SbTimeMonotonic(0);
}

SbTimeGetNow

Description

Gets the current system time as an SbTime.

Declaration and definitions

#include "starboard/time.h"

SbTime SbTimeGetNow() {
  return SbTime();
}

SbTimeNarrow

Description

Safely narrows a number from a more precise unit to a less precise one. This function rounds negative values toward negative infinity.

Declaration

static SB_C_FORCE_INLINE int64_t SbTimeNarrow(int64_t time, int64_t divisor) {
  return time >= 0 ? time / divisor : (time - divisor + 1) / divisor;
}

Parameters

SbTimeToPosix

Description

Converts SbTime into microseconds from the POSIX epoch.

Declaration

static SB_C_FORCE_INLINE int64_t SbTimeToPosix(SbTime time) {
  return time + kSbTimeToPosixDelta;
}

Parameters