| 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 <stdio.h> | 7 #include <stdio.h> |
| 8 #include <stdlib.h> | 8 #include <stdlib.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 | 10 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 * (nacl_thread_index). | 70 * (nacl_thread_index). |
| 71 */ | 71 */ |
| 72 void NaClSignalContextGetCurrentThread(const struct NaClSignalContext *sigCtx, | 72 void NaClSignalContextGetCurrentThread(const struct NaClSignalContext *sigCtx, |
| 73 int *is_untrusted, | 73 int *is_untrusted, |
| 74 struct NaClAppThread **result_thread) { | 74 struct NaClAppThread **result_thread) { |
| 75 #if NACL_ARCH(NACL_BUILD_ARCH) == NACL_x86 && NACL_BUILD_SUBARCH == 32 | 75 #if NACL_ARCH(NACL_BUILD_ARCH) == NACL_x86 && NACL_BUILD_SUBARCH == 32 |
| 76 /* For x86-32, if %cs does not match, it is untrusted code. */ | 76 /* For x86-32, if %cs does not match, it is untrusted code. */ |
| 77 *is_untrusted = (NaClGetGlobalCs() != sigCtx->cs); | 77 *is_untrusted = (NaClGetGlobalCs() != sigCtx->cs); |
| 78 *result_thread = nacl_thread[sigCtx->gs >> 3]; | 78 *result_thread = nacl_thread[sigCtx->gs >> 3]; |
| 79 #elif (NACL_ARCH(NACL_BUILD_ARCH) == NACL_x86 && NACL_BUILD_SUBARCH == 64) || \ | 79 #elif (NACL_ARCH(NACL_BUILD_ARCH) == NACL_x86 && NACL_BUILD_SUBARCH == 64) || \ |
| 80 NACL_ARCH(NACL_BUILD_ARCH) == NACL_arm | 80 NACL_ARCH(NACL_BUILD_ARCH) == NACL_arm || \ |
| 81 NACL_ARCH(NACL_BUILD_ARCH) == NACL_mips |
| 81 uint32_t current_thread_index = NaClTlsGetIdx(); | 82 uint32_t current_thread_index = NaClTlsGetIdx(); |
| 82 if (NACL_TLS_INDEX_INVALID == current_thread_index) { | 83 if (NACL_TLS_INDEX_INVALID == current_thread_index) { |
| 83 *is_untrusted = 0; | 84 *is_untrusted = 0; |
| 84 *result_thread = NULL; | 85 *result_thread = NULL; |
| 85 } else { | 86 } else { |
| 86 struct NaClAppThread *thread = nacl_thread[current_thread_index]; | 87 struct NaClAppThread *thread = nacl_thread[current_thread_index]; |
| 87 /* | 88 /* |
| 88 * Get the address of an arbitrary local, stack-allocated variable, | 89 * Get the address of an arbitrary local, stack-allocated variable, |
| 89 * just for the purpose of doing a sanity check. | 90 * just for the purpose of doing a sanity check. |
| 90 */ | 91 */ |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 } | 260 } |
| 260 | 261 |
| 261 NaClSignalHandlerInitPlatform(); | 262 NaClSignalHandlerInitPlatform(); |
| 262 NaClSignalHandlerAdd(NaClSignalHandleUntrusted); | 263 NaClSignalHandlerAdd(NaClSignalHandleUntrusted); |
| 263 } | 264 } |
| 264 | 265 |
| 265 void NaClSignalHandlerFini() { | 266 void NaClSignalHandlerFini() { |
| 266 /* We try to lock, but since we are shutting down, we ignore failures. */ | 267 /* We try to lock, but since we are shutting down, we ignore failures. */ |
| 267 NaClSignalHandlerFiniPlatform(); | 268 NaClSignalHandlerFiniPlatform(); |
| 268 } | 269 } |
| OLD | NEW |