1 /*
2  * Copyright (c) 2011 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 /*
8  * NaCl Server Runtime time abstraction layer.
9  * This is the host-OS-independent interface.
10  */
11 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLATFORM_NACL_TIME_H_
12 #define NATIVE_CLIENT_SRC_TRUSTED_PLATFORM_NACL_TIME_H_
13 
14 #include "native_client/src/include/nacl_base.h"
15 
16 #include "native_client/src/trusted/service_runtime/include/sys/time.h"
17 
18 EXTERN_C_BEGIN
19 
20 void NaClTimeInit(void);
21 
22 void NaClTimeFini(void);
23 
24 /*
25  * Allow use of low resolution timer to update time of day. This
26  * must be called before NaClTimeInit().
27  */
28 void NaClAllowLowResolutionTimeOfDay(void);
29 
30 uint64_t NaClTimerResolutionNanoseconds(void);
31 
32 int NaClGetTimeOfDay(struct nacl_abi_timeval *tv);
33 
34 /* Convenience function */
35 int64_t NaClGetTimeOfDayMicroseconds(void);
36 
37 int NaClNanosleep(struct nacl_abi_timespec const  *req,
38                   struct nacl_abi_timespec        *rem);
39 
40 /* internal / testing APIs */
41 struct NaClTimeState;  /* defined in platform-specific directory */
42 
43 void NaClTimeInternalInit(struct NaClTimeState *);
44 void NaClTimeInternalFini(struct NaClTimeState *);
45 uint64_t NaClTimerResolutionNsInternal(struct NaClTimeState *);
46 
47 EXTERN_C_END
48 
49 #endif  /* NATIVE_CLIENT_SRC_TRUSTED_PLATFORM_NACL_TIME_H_ */
50