1 /* 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. 3 * Use of this source code is governed by a BSD-style license that can be 4 * found in the LICENSE file. 5 */ 6 7 #ifndef NATIVE_CLIENT_SRC_SHARED_PLATFORM_NACL_CLOCK_H_ 8 #define NATIVE_CLIENT_SRC_SHARED_PLATFORM_NACL_CLOCK_H_ 9 10 /* 11 * A platform-abstracted implementation of clock_getres, 12 * clock_gettime, clock_settime, providing CLOCK_REALTIME 13 * (gettimeofday equivalent) and CLOCK_MONOTONIC / 14 * CLOCK_MONOTONIC_RAW. 15 */ 16 17 #include "native_client/src/include/nacl_base.h" 18 #include "native_client/src/include/nacl_compiler_annotations.h" 19 #include "native_client/src/trusted/service_runtime/include/sys/time.h" 20 21 EXTERN_C_BEGIN 22 23 typedef enum NaClClockIdEnum { 24 NACL_CLOCK_REALTIME = NACL_ABI_CLOCK_REALTIME, 25 NACL_CLOCK_MONOTONIC = NACL_ABI_CLOCK_MONOTONIC, 26 NACL_CLOCK_PROCESS_CPUTIME_ID = NACL_ABI_CLOCK_PROCESS_CPUTIME_ID, 27 NACL_CLOCK_THREAD_CPUTIME_ID = NACL_ABI_CLOCK_THREAD_CPUTIME_ID 28 } nacl_clockid_t; 29 30 /* 31 * NaClClockInit should be invoked *after* NaClTimeInit. Using 32 * NaClPlatformInit will do the right thing. 33 * 34 * Returns bool-as-int, with true for success -- if NaClClockInit 35 * fails, it's pretty catastrophic and the NaClClock module is 36 * unusable. 37 */ 38 int NaClClockInit(void); 39 40 void NaClClockFini(void); 41 42 int NaClClockGetRes(nacl_clockid_t clk_id, 43 struct nacl_abi_timespec *res) NACL_WUR; 44 45 int NaClClockGetTime(nacl_clockid_t clk_id, 46 struct nacl_abi_timespec *tp) NACL_WUR; 47 48 EXTERN_C_END 49 50 #endif 51