| 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 Exception Context | 8 * NaCl Exception Context |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #ifndef __NATIVE_CLIENT_SRC_SERVICE_RUNTIME_INCLUDE_SYS_NACL_EXCEPTION_H__ | 11 #ifndef __NATIVE_CLIENT_SRC_SERVICE_RUNTIME_INCLUDE_SYS_NACL_EXCEPTION_H__ |
| 12 #define __NATIVE_CLIENT_SRC_SERVICE_RUNTIME_INCLUDE_SYS_NACL_EXCEPTION_H__ 1 | 12 #define __NATIVE_CLIENT_SRC_SERVICE_RUNTIME_INCLUDE_SYS_NACL_EXCEPTION_H__ 1 |
| 13 | 13 |
| 14 #include <stdlib.h> |
| 15 |
| 14 #if defined(__native_client__) | 16 #if defined(__native_client__) |
| 15 # include <stdint.h> | 17 # include <stdint.h> |
| 16 #else | 18 #else |
| 17 # include "native_client/src/include/portability.h" | 19 # include "native_client/src/include/portability.h" |
| 18 #endif | 20 #endif |
| 19 | 21 |
| 22 #if defined(__cplusplus) |
| 23 extern "C" { |
| 24 #endif |
| 25 |
| 20 /* | 26 /* |
| 21 * NaClUserRegisterState is similar to NaClSignalContext except that: | 27 * NaClUserRegisterState is similar to NaClSignalContext except that: |
| 22 * | 28 * |
| 23 * - It does not contain x86 segment register state that we don't | 29 * - It does not contain x86 segment register state that we don't |
| 24 * want to report to untrusted code. | 30 * want to report to untrusted code. |
| 25 * | 31 * |
| 26 * - We provide all architectures' definitions side by side so that, | 32 * - We provide all architectures' definitions side by side so that, |
| 27 * for example, a multiarch crash dump processor can use these to | 33 * for example, a multiarch crash dump processor can use these to |
| 28 * interpret register state for all architectures. | 34 * interpret register state for all architectures. |
| 29 * | 35 * |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 }; | 232 }; |
| 227 | 233 |
| 228 #if defined(__native_client__) | 234 #if defined(__native_client__) |
| 229 static inline struct NaClExceptionPortableContext * | 235 static inline struct NaClExceptionPortableContext * |
| 230 nacl_exception_context_get_portable(struct NaClExceptionContext *context) { | 236 nacl_exception_context_get_portable(struct NaClExceptionContext *context) { |
| 231 return (struct NaClExceptionPortableContext *) | 237 return (struct NaClExceptionPortableContext *) |
| 232 ((uintptr_t) context + context->portable_context_offset); | 238 ((uintptr_t) context + context->portable_context_offset); |
| 233 } | 239 } |
| 234 #endif | 240 #endif |
| 235 | 241 |
| 242 typedef void (*nacl_exception_handler_t)(struct NaClExceptionContext *context); |
| 243 |
| 244 /* |
| 245 * The following functions return 0 on success or an errno value on |
| 246 * failure. |
| 247 */ |
| 248 |
| 249 /* |
| 250 * Set the exception handler function. This applies to all threads in |
| 251 * the process. In this regard, this API is similar to signal() or |
| 252 * sigaction() in POSIX. |
| 253 */ |
| 254 int nacl_exception_set_handler(nacl_exception_handler_t handler); |
| 255 |
| 256 /* |
| 257 * Set the stack that the exception handler will run on. This applies |
| 258 * to the current thread only. This API is similar to sigaltstack() |
| 259 * in POSIX. |
| 260 */ |
| 261 int nacl_exception_set_stack(void *stack, size_t size); |
| 262 |
| 263 /* |
| 264 * Clear the current thread's exception flag. |
| 265 * |
| 266 * The purpose of the exception flag is to prevent the exception |
| 267 * handler from being re-entered if an exception occurs while handling |
| 268 * an exception. If an exception occurs on a thread while the |
| 269 * thread's exception flag is set, the process is terminated. The |
| 270 * exception flag is set when an exception occurs and the exception |
| 271 * handler is invoked. |
| 272 * |
| 273 * The exception flag is similar to signal masks in POSIX. |
| 274 * nacl_exception_clear_flag() is similar to sigprocmask() in POSIX. |
| 275 */ |
| 276 int nacl_exception_clear_flag(void); |
| 277 |
| 278 #if defined(__cplusplus) |
| 279 } |
| 280 #endif |
| 281 |
| 236 #endif /* __NATIVE_CLIENT_SRC_SERVICE_RUNTIME_INCLUDE_SYS_NACL_EXCEPTION_H__ */ | 282 #endif /* __NATIVE_CLIENT_SRC_SERVICE_RUNTIME_INCLUDE_SYS_NACL_EXCEPTION_H__ */ |
| OLD | NEW |