| 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 #include "native_client/src/include/portability.h" | 7 #include "native_client/src/include/portability.h" |
| 8 | 8 |
| 9 #include <windows.h> | 9 #include <windows.h> |
| 10 #include <io.h> | 10 #include <io.h> |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 * (1000 \cdot \Delta n) \bmod 2^{32} | 85 * (1000 \cdot \Delta n) \bmod 2^{32} |
| 86 * &\equiv ((1000 \bmod 2^{32}) \cdot (\Delta n \bmod 2^{32}) \bmod 2^{32}\\ | 86 * &\equiv ((1000 \bmod 2^{32}) \cdot (\Delta n \bmod 2^{32}) \bmod 2^{32}\\ |
| 87 * &\equiv (1000 \cdot (\Delta n \bmod 2^{32})) \bmod 2^{32}. | 87 * &\equiv (1000 \cdot (\Delta n \bmod 2^{32})) \bmod 2^{32}. |
| 88 * \end{align*} | 88 * \end{align*} |
| 89 * | 89 * |
| 90 * so when $\Delta n$ is small, the time difference is going to be a | 90 * so when $\Delta n$ is small, the time difference is going to be a |
| 91 * small multiple of $1000$, regardless of wraparound. | 91 * small multiple of $1000$, regardless of wraparound. |
| 92 */ | 92 */ |
| 93 return retval; | 93 return retval; |
| 94 } | 94 } |
| 95 | |
| 96 int32_t NaClSysSysconf(struct NaClAppThread *natp, | |
| 97 int32_t name, | |
| 98 int32_t *result) { | |
| 99 int32_t retval = -NACL_ABI_EINVAL; | |
| 100 static int32_t number_of_workers = 0; | |
| 101 int32_t result_value; | |
| 102 | |
| 103 NaClLog(3, | |
| 104 ("Entered NaClSysSysconf(%08"NACL_PRIxPTR | |
| 105 "x, %d, 0x%08"NACL_PRIxPTR")\n"), | |
| 106 (uintptr_t) natp, name, (uintptr_t) result); | |
| 107 | |
| 108 switch (name) { | |
| 109 case NACL_ABI__SC_NPROCESSORS_ONLN: { | |
| 110 if (0 == number_of_workers) { | |
| 111 SYSTEM_INFO si; | |
| 112 GetSystemInfo(&si); | |
| 113 number_of_workers = (int32_t) si.dwNumberOfProcessors; | |
| 114 } | |
| 115 result_value = number_of_workers; | |
| 116 break; | |
| 117 } | |
| 118 case NACL_ABI__SC_SENDMSG_MAX_SIZE: { | |
| 119 /* TODO(sehr,bsy): this value needs to be determined at run time. */ | |
| 120 const int32_t kImcSendMsgMaxSize = 1 << 16; | |
| 121 result_value = kImcSendMsgMaxSize; | |
| 122 break; | |
| 123 } | |
| 124 case NACL_ABI__SC_PAGESIZE: { | |
| 125 result_value = 1 << 16; /* always 64k pages */ | |
| 126 break; | |
| 127 } | |
| 128 default: { | |
| 129 retval = -NACL_ABI_EINVAL; | |
| 130 goto cleanup; | |
| 131 } | |
| 132 } | |
| 133 if (!NaClCopyOutToUser(natp->nap, (uintptr_t) result, &result_value, | |
| 134 sizeof result_value)) { | |
| 135 retval = -NACL_ABI_EFAULT; | |
| 136 goto cleanup; | |
| 137 } | |
| 138 retval = 0; | |
| 139 cleanup: | |
| 140 return retval; | |
| 141 } | |
| OLD | NEW |