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 #ifndef NATIVE_CLIENT_SRC_UNTRUSTED_IRT_IRT_H_ | 6 #ifndef NATIVE_CLIENT_SRC_UNTRUSTED_IRT_IRT_H_ |
7 #define NATIVE_CLIENT_SRC_UNTRUSTED_IRT_IRT_H_ | 7 #define NATIVE_CLIENT_SRC_UNTRUSTED_IRT_IRT_H_ |
8 | 8 |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 #include <stdint.h> | 10 #include <stdint.h> |
11 #include <sys/types.h> | 11 #include <sys/types.h> |
12 #include <time.h> | 12 #include <time.h> |
13 | 13 |
14 struct timeval; | 14 struct timeval; |
15 struct timespec; | 15 struct timespec; |
16 struct stat; | 16 struct stat; |
17 struct dirent; | 17 struct dirent; |
18 | 18 |
19 struct NaClExceptionContext; | 19 struct NaClExceptionContext; |
20 struct NaClMemMappingInfo; | 20 struct NaClMemMappingInfo; |
21 | 21 |
22 typedef int64_t nacl_irt_off_t; | 22 typedef int64_t nacl_irt_off_t; |
23 typedef uint32_t nacl_irt_clockid_t; | 23 typedef uint32_t nacl_irt_clockid_t; |
24 typedef uintptr_t nacl_irt_tid_t; | |
24 | 25 |
25 #if defined(__cplusplus) | 26 #if defined(__cplusplus) |
26 extern "C" { | 27 extern "C" { |
27 #endif | 28 #endif |
28 | 29 |
29 /* | 30 /* |
30 * The only interface exposed directly to user code is a single function | 31 * The only interface exposed directly to user code is a single function |
31 * of this type. It is passed via the AT_SYSINFO field of the ELF | 32 * of this type. It is passed via the AT_SYSINFO field of the ELF |
32 * auxiliary vector on the stack at program startup. The interfaces | 33 * auxiliary vector on the stack at program startup. The interfaces |
33 * below are accessed by calling this function with the appropriate | 34 * below are accessed by calling this function with the appropriate |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
234 * |*stack_flag|. This is intended to be used by a threading | 235 * |*stack_flag|. This is intended to be used by a threading |
235 * library to determine when the thread's stack can be deallocated | 236 * library to determine when the thread's stack can be deallocated |
236 * or reused. The system will not read or write the thread's stack | 237 * or reused. The system will not read or write the thread's stack |
237 * after writing 0 to |*stack_flag|. | 238 * after writing 0 to |*stack_flag|. |
238 */ | 239 */ |
239 void (*thread_exit)(int32_t *stack_flag); | 240 void (*thread_exit)(int32_t *stack_flag); |
240 int (*thread_nice)(const int nice); | 241 int (*thread_nice)(const int nice); |
241 }; | 242 }; |
242 | 243 |
243 /* | 244 /* |
245 * This interface is only available on Non-SFI Mode. | |
246 */ | |
247 #define NACL_IRT_THREAD_v0_2 "nacl-irt-thread-0.2" | |
248 struct nacl_irt_thread_v0_2 { | |
249 /* | |
250 * Now this interface assigns the thread ID of the child thread into | |
251 * |child_tid| atomically when the thread is created. It will be the | |
252 * |parent_tid| argument to the clone() system call. | |
253 */ | |
254 int (*thread_create)(void (*start_func)(void), void *stack, void *thread_ptr, | |
255 nacl_irt_tid_t *child_tid); | |
Mark Seaborn
2015/07/16 23:21:16
Can the child_tid pointer be NULL? Please clarify
Luis Héctor Chávez
2015/07/20 18:13:47
Done.
| |
256 void (*thread_exit)(int32_t *stack_flag); | |
257 int (*thread_nice)(const int nice); | |
258 }; | |
259 | |
260 /* | |
244 * The irt_futex interface is based on Linux's futex() system call. | 261 * The irt_futex interface is based on Linux's futex() system call. |
245 * | 262 * |
246 * irt_futex provides process-private futexes, so futex wait queues are | 263 * irt_futex provides process-private futexes, so futex wait queues are |
247 * associated with numeric virtual addresses only. This is equivalent to | 264 * associated with numeric virtual addresses only. This is equivalent to |
248 * Linux's FUTEX_PRIVATE_FLAG. If a page is mmap()'d twice, futex_wake() | 265 * Linux's FUTEX_PRIVATE_FLAG. If a page is mmap()'d twice, futex_wake() |
249 * on one mapping will *not* wake a thread that is waiting on the other | 266 * on one mapping will *not* wake a thread that is waiting on the other |
250 * mapping with futex_wait_abs() -- futex wait queues are not associated | 267 * mapping with futex_wait_abs() -- futex wait queues are not associated |
251 * with pages' identities. | 268 * with pages' identities. |
252 */ | 269 */ |
253 #define NACL_IRT_FUTEX_v0_1 "nacl-irt-futex-0.1" | 270 #define NACL_IRT_FUTEX_v0_1 "nacl-irt-futex-0.1" |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
429 */ | 446 */ |
430 #define NACL_IRT_ICACHE_v0_1 "nacl-irt-icache-0.1" | 447 #define NACL_IRT_ICACHE_v0_1 "nacl-irt-icache-0.1" |
431 struct nacl_irt_icache { | 448 struct nacl_irt_icache { |
432 /* | 449 /* |
433 * clear_cache() makes instruction cache and data cache for the address | 450 * clear_cache() makes instruction cache and data cache for the address |
434 * range from |addr| to |(intptr_t)addr + size| (exclusive) coherent. | 451 * range from |addr| to |(intptr_t)addr + size| (exclusive) coherent. |
435 */ | 452 */ |
436 int (*clear_cache)(void *addr, size_t size); | 453 int (*clear_cache)(void *addr, size_t size); |
437 }; | 454 }; |
438 | 455 |
456 /* | |
457 * This interface is only available on Non-SFI Mode. | |
458 */ | |
459 #define NACL_IRT_ASYNC_SIGNAL_HANDLING_v0_1 "nacl-irt-async-signal-handling-0.1" | |
460 typedef void (*NaClIrtSignalHandler)(struct NaClExceptionContext *context); | |
461 struct nacl_irt_async_signal_handling { | |
462 /* | |
463 * When send_async_signal is called, |handler| is invoked on the thread | |
464 * specified by |tid| on the thread's stack and without modifying the | |
465 * underlying signal mask, so |handler| must be reentrant. | |
466 * | |
467 * You can safely use only async-signal-safe operations in |handler|. The | |
468 * following NaCl IRT functions are async-signal-safe: | |
469 * | |
470 * - tls_get | |
471 * - futex_wait_abs | |
472 * - futex_wake | |
473 * - send_async_signal | |
474 * | |
475 * If the thread was executing an IRT function, the suspended thread will | |
476 * continue it after |handler| finishes. In other words, no IRT function will | |
477 * be aborted. | |
478 */ | |
479 int (*set_async_signal_handler)(NaClIrtSignalHandler handler); | |
480 /* | |
481 * |tid| should be zero or a value returned by thread_create. If |tid| is | |
482 * zero, the signal will be sent to the main thread. | |
483 * | |
484 * When |tid| is invalid, the result is unspecified. This IRT function | |
485 * returns 0 on success or may return ESRCH or EINVAL. | |
486 */ | |
487 int (*send_async_signal)(nacl_irt_tid_t tid); | |
488 }; | |
489 | |
439 #if defined(__cplusplus) | 490 #if defined(__cplusplus) |
440 } | 491 } |
441 #endif | 492 #endif |
442 | 493 |
443 #endif /* NATIVE_CLIENT_SRC_UNTRUSTED_IRT_IRT_H */ | 494 #endif /* NATIVE_CLIENT_SRC_UNTRUSTED_IRT_IRT_H */ |
OLD | NEW |