| 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 * NaCl service run-time, non-platform specific system call helper routines. | 8 * NaCl service run-time, non-platform specific system call helper routines. |
| 9 */ | 9 */ |
| 10 #include <sys/types.h> | 10 #include <sys/types.h> |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 &zero, sizeof zero)) { | 137 &zero, sizeof zero)) { |
| 138 NaClLog(4, "NaClSysThreadExit: ignoring invalid stack_flag_addr\n"); | 138 NaClLog(4, "NaClSysThreadExit: ignoring invalid stack_flag_addr\n"); |
| 139 } | 139 } |
| 140 } | 140 } |
| 141 | 141 |
| 142 NaClAppThreadTeardown(natp); | 142 NaClAppThreadTeardown(natp); |
| 143 /* NOTREACHED */ | 143 /* NOTREACHED */ |
| 144 return -NACL_ABI_EINVAL; | 144 return -NACL_ABI_EINVAL; |
| 145 } | 145 } |
| 146 | 146 |
| 147 int32_t NaClSysNameService(struct NaClAppThread *natp, | |
| 148 uint32_t desc_addr) { | |
| 149 struct NaClApp *nap = natp->nap; | |
| 150 int32_t retval = -NACL_ABI_EINVAL; | |
| 151 int32_t desc; | |
| 152 | |
| 153 NaClLog(3, | |
| 154 ("NaClSysNameService(0x%08"NACL_PRIxPTR"," | |
| 155 " 0x%08"NACL_PRIx32")\n"), | |
| 156 (uintptr_t) natp, | |
| 157 desc_addr); | |
| 158 | |
| 159 if (!NaClCopyInFromUser(nap, &desc, desc_addr, sizeof desc)) { | |
| 160 NaClLog(LOG_ERROR, | |
| 161 "Invalid address argument to NaClSysNameService\n"); | |
| 162 retval = -NACL_ABI_EFAULT; | |
| 163 goto done; | |
| 164 } | |
| 165 | |
| 166 if (-1 == desc) { | |
| 167 /* read */ | |
| 168 desc = NaClAppSetDescAvail(nap, NaClDescRef(nap->name_service_conn_cap)); | |
| 169 if (NaClCopyOutToUser(nap, desc_addr, &desc, sizeof desc)) { | |
| 170 retval = 0; | |
| 171 } else { | |
| 172 retval = -NACL_ABI_EFAULT; | |
| 173 } | |
| 174 } else { | |
| 175 struct NaClDesc *desc_obj_ptr = NaClAppGetDesc(nap, desc); | |
| 176 | |
| 177 if (NULL == desc_obj_ptr) { | |
| 178 retval = -NACL_ABI_EBADF; | |
| 179 goto done; | |
| 180 } | |
| 181 if (NACL_DESC_CONN_CAP != NACL_VTBL(NaClDesc, desc_obj_ptr)->typeTag && | |
| 182 NACL_DESC_CONN_CAP_FD != NACL_VTBL(NaClDesc, desc_obj_ptr)->typeTag) { | |
| 183 retval = -NACL_ABI_EINVAL; | |
| 184 goto done; | |
| 185 } | |
| 186 /* write */ | |
| 187 NaClXMutexLock(&nap->mu); | |
| 188 NaClDescUnref(nap->name_service_conn_cap); | |
| 189 nap->name_service_conn_cap = desc_obj_ptr; | |
| 190 NaClXMutexUnlock(&nap->mu); | |
| 191 retval = 0; | |
| 192 } | |
| 193 | |
| 194 done: | |
| 195 return retval; | |
| 196 } | |
| 197 | |
| 198 int32_t NaClSysTlsInit(struct NaClAppThread *natp, | 147 int32_t NaClSysTlsInit(struct NaClAppThread *natp, |
| 199 uint32_t thread_ptr) { | 148 uint32_t thread_ptr) { |
| 200 int32_t retval = -NACL_ABI_EINVAL; | 149 int32_t retval = -NACL_ABI_EINVAL; |
| 201 uintptr_t sys_tls; | 150 uintptr_t sys_tls; |
| 202 | 151 |
| 203 NaClLog(3, | 152 NaClLog(3, |
| 204 ("Entered NaClSysTlsInit(0x%08"NACL_PRIxPTR | 153 ("Entered NaClSysTlsInit(0x%08"NACL_PRIxPTR |
| 205 ", 0x%08"NACL_PRIxPTR")\n"), | 154 ", 0x%08"NACL_PRIxPTR")\n"), |
| 206 (uintptr_t) natp, (uintptr_t) thread_ptr); | 155 (uintptr_t) natp, (uintptr_t) thread_ptr); |
| 207 | 156 |
| (...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1040 return NaClSysClockGetCommon(natp, clk_id, (uintptr_t) tsp, | 989 return NaClSysClockGetCommon(natp, clk_id, (uintptr_t) tsp, |
| 1041 NaClClockGetRes, 1); | 990 NaClClockGetRes, 1); |
| 1042 } | 991 } |
| 1043 | 992 |
| 1044 int32_t NaClSysClockGetTime(struct NaClAppThread *natp, | 993 int32_t NaClSysClockGetTime(struct NaClAppThread *natp, |
| 1045 int clk_id, | 994 int clk_id, |
| 1046 uint32_t tsp) { | 995 uint32_t tsp) { |
| 1047 return NaClSysClockGetCommon(natp, clk_id, (uintptr_t) tsp, | 996 return NaClSysClockGetCommon(natp, clk_id, (uintptr_t) tsp, |
| 1048 NaClClockGetTime, 0); | 997 NaClClockGetTime, 0); |
| 1049 } | 998 } |
| OLD | NEW |