OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. | 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 | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 | 7 |
8 #include <time.h> | 8 #include <time.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 #include <sys/types.h> | 10 #include <sys/types.h> |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 int32_t NaClSysClock(struct NaClAppThread *natp) { | 67 int32_t NaClSysClock(struct NaClAppThread *natp) { |
68 int32_t retval; | 68 int32_t retval; |
69 | 69 |
70 NaClLog(3, | 70 NaClLog(3, |
71 ("Entered NaClSysClock(%08"NACL_PRIxPTR")\n"), | 71 ("Entered NaClSysClock(%08"NACL_PRIxPTR")\n"), |
72 (uintptr_t) natp); | 72 (uintptr_t) natp); |
73 | 73 |
74 retval = clock(); | 74 retval = clock(); |
75 return retval; | 75 return retval; |
76 } | 76 } |
77 | |
78 int32_t NaClSysSysconf(struct NaClAppThread *natp, | |
79 int32_t name, | |
80 int32_t *result) { | |
81 int32_t retval = -NACL_ABI_EINVAL; | |
82 int32_t result_value; | |
83 | |
84 NaClLog(3, | |
85 ("Entered NaClSysSysconf(%08"NACL_PRIxPTR | |
86 "x, %d, 0x%08"NACL_PRIxPTR")\n"), | |
87 (uintptr_t) natp, name, (uintptr_t) result); | |
88 | |
89 switch (name) { | |
90 case NACL_ABI__SC_NPROCESSORS_ONLN: { | |
91 if (-1 == natp->nap->sc_nprocessors_onln) { | |
92 /* Unable to get the number of processors at startup. */ | |
93 retval = -NACL_ABI_EINVAL; | |
94 goto cleanup; | |
95 } | |
96 result_value = natp->nap->sc_nprocessors_onln; | |
97 break; | |
98 } | |
99 case NACL_ABI__SC_SENDMSG_MAX_SIZE: { | |
100 /* TODO(sehr,bsy): this value needs to be determined at run time. */ | |
101 const int32_t kImcSendMsgMaxSize = 1 << 16; | |
102 result_value = kImcSendMsgMaxSize; | |
103 break; | |
104 } | |
105 case NACL_ABI__SC_PAGESIZE: { | |
106 result_value = 1 << 16; /* always 64k pages */ | |
107 break; | |
108 } | |
109 default: { | |
110 retval = -NACL_ABI_EINVAL; | |
111 goto cleanup; | |
112 } | |
113 } | |
114 if (!NaClCopyOutToUser(natp->nap, (uintptr_t) result, &result_value, | |
115 sizeof result_value)) { | |
116 retval = -NACL_ABI_EFAULT; | |
117 goto cleanup; | |
118 } | |
119 retval = 0; | |
120 cleanup: | |
121 return retval; | |
122 } | |
OLD | NEW |