1 : /*
2 : * Copyright (c) 2013 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 : #include "native_client/tests/performance/perf_test_compat_osx.h"
8 :
9 : #include <errno.h>
10 :
11 : #include "native_client/src/include/nacl_assert.h"
12 : #include "native_client/src/include/nacl_compiler_annotations.h"
13 : #include "native_client/src/shared/platform/nacl_clock.h"
14 :
15 5630818 : int clock_gettime(int clk_id, struct timespec *tp) {
16 16892454 : ASSERT_EQ(clk_id, CLOCK_MONOTONIC);
17 :
18 5630821 : static int clock_init_rv = NaClClockInit();
19 : // clock_init_rv is only present for its side effect, static initialization.
20 11261636 : UNREFERENCED_PARAMETER(clock_init_rv);
21 :
22 5630818 : nacl_abi_timespec nts;
23 5630818 : int rv = NaClClockGetTime(NACL_CLOCK_MONOTONIC, &nts);
24 5630818 : if (rv != 0) {
25 : // This assumes that NaCl errno values and Mac OS X errno values are
26 : // compatible.
27 0 : errno = -rv;
28 0 : return -1;
29 : }
30 :
31 5630818 : tp->tv_sec = nts.tv_sec;
32 5630818 : tp->tv_nsec = nts.tv_nsec;
33 :
34 5630818 : return 0;
35 5630818 : }
|