OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <errno.h> | 5 #include <errno.h> |
6 #include <sched.h> | 6 #include <sched.h> |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 #include <sys/time.h> | 8 #include <sys/time.h> |
9 #include <time.h> | 9 #include <time.h> |
10 #include <unistd.h> | 10 #include <unistd.h> |
11 | 11 |
| 12 #include "components/nacl/loader/nonsfi/abi_conversion.h" |
12 #include "components/nacl/loader/nonsfi/irt_interfaces.h" | 13 #include "components/nacl/loader/nonsfi/irt_interfaces.h" |
13 #include "native_client/src/trusted/service_runtime/include/sys/time.h" | 14 #include "native_client/src/trusted/service_runtime/include/sys/time.h" |
14 #include "native_client/src/trusted/service_runtime/include/sys/unistd.h" | 15 #include "native_client/src/trusted/service_runtime/include/sys/unistd.h" |
15 | 16 |
16 namespace nacl { | 17 namespace nacl { |
17 namespace nonsfi { | 18 namespace nonsfi { |
18 namespace { | 19 namespace { |
19 | 20 |
20 void IrtExit(int status) { | 21 void IrtExit(int status) { |
21 _exit(status); | 22 _exit(status); |
(...skipping 11 matching lines...) Expand all Loading... |
33 int IrtClock(nacl_abi_clock_t* ticks) { | 34 int IrtClock(nacl_abi_clock_t* ticks) { |
34 // There is no definition of errno when clock is failed. | 35 // There is no definition of errno when clock is failed. |
35 // So we assume it always succeeds. | 36 // So we assume it always succeeds. |
36 *ticks = clock(); | 37 *ticks = clock(); |
37 return 0; | 38 return 0; |
38 } | 39 } |
39 | 40 |
40 int IrtNanoSleep(const struct nacl_abi_timespec* req, | 41 int IrtNanoSleep(const struct nacl_abi_timespec* req, |
41 struct nacl_abi_timespec* rem) { | 42 struct nacl_abi_timespec* rem) { |
42 struct timespec host_req; | 43 struct timespec host_req; |
43 host_req.tv_sec = req->tv_sec; | 44 NaClAbiTimeSpecToTimeSpec(*req, &host_req); |
44 host_req.tv_nsec = req->tv_nsec; | |
45 struct timespec host_rem; | 45 struct timespec host_rem; |
46 if (nanosleep(&host_req, &host_rem)) | 46 if (nanosleep(&host_req, &host_rem)) |
47 return errno; | 47 return errno; |
48 | 48 |
49 if (rem) { | 49 if (rem) |
50 rem->tv_sec = host_rem.tv_sec; | 50 TimeSpecToNaClAbiTimeSpec(host_rem, rem); |
51 rem->tv_nsec = host_rem.tv_nsec; | |
52 } | |
53 return 0; | 51 return 0; |
54 } | 52 } |
55 | 53 |
56 int IrtSchedYield() { | 54 int IrtSchedYield() { |
57 if (sched_yield()) | 55 if (sched_yield()) |
58 return errno; | 56 return errno; |
59 | 57 |
60 return 0; | 58 return 0; |
61 } | 59 } |
62 | 60 |
(...skipping 29 matching lines...) Expand all Loading... |
92 reinterpret_cast<int(*)(struct timeval*)>(IrtGetToD), | 90 reinterpret_cast<int(*)(struct timeval*)>(IrtGetToD), |
93 reinterpret_cast<int(*)(clock_t*)>(IrtClock), | 91 reinterpret_cast<int(*)(clock_t*)>(IrtClock), |
94 reinterpret_cast<int(*)(const struct timespec*, struct timespec*)>( | 92 reinterpret_cast<int(*)(const struct timespec*, struct timespec*)>( |
95 IrtNanoSleep), | 93 IrtNanoSleep), |
96 IrtSchedYield, | 94 IrtSchedYield, |
97 IrtSysconf, | 95 IrtSysconf, |
98 }; | 96 }; |
99 | 97 |
100 } // namespace nonsfi | 98 } // namespace nonsfi |
101 } // namespace nacl | 99 } // namespace nacl |
OLD | NEW |