Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: src/untrusted/irt/irt.h

Issue 1293793009: Reland "Non-SFI mode: Add Linux asynchronous signal support" (Closed) Base URL: https://chromium.googlesource.com/native_client/src/native_client.git@master
Patch Set: Fixed races on thread termination and removed the broken FP-restoration code Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 dirent; 16 struct dirent;
17 17
18 struct NaClExceptionContext; 18 struct NaClExceptionContext;
19 struct NaClMemMappingInfo; 19 struct NaClMemMappingInfo;
20 20
21 typedef int64_t nacl_irt_off_t; 21 typedef int64_t nacl_irt_off_t;
22 typedef uint32_t nacl_irt_clockid_t; 22 typedef uint32_t nacl_irt_clockid_t;
23 typedef uintptr_t nacl_irt_tid_t;
24 #define NACL_IRT_MAIN_THREAD_TID 0
23 25
24 /* 26 /*
25 * Under newlib, the 'struct stat' defined in <sys/stat.h> matches the 27 * Under newlib, the 'struct stat' defined in <sys/stat.h> matches the
26 * layout of 'struct nacl_abi_stat', so the standard type 'struct stat' 28 * layout of 'struct nacl_abi_stat', so the standard type 'struct stat'
27 * is used in IRT function signatures. Under glibc, the 'struct stat' 29 * is used in IRT function signatures. Under glibc, the 'struct stat'
28 * defined by the C library differs and translation between the C 30 * defined by the C library differs and translation between the C
29 * library format and the IRT format is required. 31 * library format and the IRT format is required.
30 */ 32 */
31 #if defined(__native_client__) && defined(__GLIBC__) 33 #if defined(__native_client__) && defined(__GLIBC__)
32 typedef struct nacl_abi_stat nacl_irt_stat_t; 34 typedef struct nacl_abi_stat nacl_irt_stat_t;
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 * |*stack_flag|. This is intended to be used by a threading 248 * |*stack_flag|. This is intended to be used by a threading
247 * library to determine when the thread's stack can be deallocated 249 * library to determine when the thread's stack can be deallocated
248 * or reused. The system will not read or write the thread's stack 250 * or reused. The system will not read or write the thread's stack
249 * after writing 0 to |*stack_flag|. 251 * after writing 0 to |*stack_flag|.
250 */ 252 */
251 void (*thread_exit)(int32_t *stack_flag); 253 void (*thread_exit)(int32_t *stack_flag);
252 int (*thread_nice)(const int nice); 254 int (*thread_nice)(const int nice);
253 }; 255 };
254 256
255 /* 257 /*
258 * This interface is only available on Non-SFI Mode.
259 */
260 #define NACL_IRT_THREAD_v0_2 "nacl-irt-thread-0.2"
261 struct nacl_irt_thread_v0_2 {
262 /*
263 * This interface is the same as nacl_irt_thread_v0_1, with the additional
264 * feature that it assigns the thread ID of the child thread into
265 * |child_tid| before the child thread starts and before execution control
266 * returns to the parent.
267 */
268 int (*thread_create)(void (*start_func)(void), void *stack, void *thread_ptr,
269 nacl_irt_tid_t *child_tid);
270 void (*thread_exit)(int32_t *stack_flag);
271 int (*thread_nice)(const int nice);
272 };
273
274 /*
256 * The irt_futex interface is based on Linux's futex() system call. 275 * The irt_futex interface is based on Linux's futex() system call.
257 * 276 *
258 * irt_futex provides process-private futexes, so futex wait queues are 277 * irt_futex provides process-private futexes, so futex wait queues are
259 * associated with numeric virtual addresses only. This is equivalent to 278 * associated with numeric virtual addresses only. This is equivalent to
260 * Linux's FUTEX_PRIVATE_FLAG. If a page is mmap()'d twice, futex_wake() 279 * Linux's FUTEX_PRIVATE_FLAG. If a page is mmap()'d twice, futex_wake()
261 * on one mapping will *not* wake a thread that is waiting on the other 280 * on one mapping will *not* wake a thread that is waiting on the other
262 * mapping with futex_wait_abs() -- futex wait queues are not associated 281 * mapping with futex_wait_abs() -- futex wait queues are not associated
263 * with pages' identities. 282 * with pages' identities.
264 */ 283 */
265 #define NACL_IRT_FUTEX_v0_1 "nacl-irt-futex-0.1" 284 #define NACL_IRT_FUTEX_v0_1 "nacl-irt-futex-0.1"
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 */ 460 */
442 #define NACL_IRT_ICACHE_v0_1 "nacl-irt-icache-0.1" 461 #define NACL_IRT_ICACHE_v0_1 "nacl-irt-icache-0.1"
443 struct nacl_irt_icache { 462 struct nacl_irt_icache {
444 /* 463 /*
445 * clear_cache() makes instruction cache and data cache for the address 464 * clear_cache() makes instruction cache and data cache for the address
446 * range from |addr| to |(intptr_t)addr + size| (exclusive) coherent. 465 * range from |addr| to |(intptr_t)addr + size| (exclusive) coherent.
447 */ 466 */
448 int (*clear_cache)(void *addr, size_t size); 467 int (*clear_cache)(void *addr, size_t size);
449 }; 468 };
450 469
470 /*
471 * This interface is only available on Non-SFI Mode.
472 *
473 * For more information, consult documentation/nonsfi_mode_async_signals.txt.
474 */
475
476 typedef void (*NaClIrtAsyncSignalHandler)(
477 struct NaClExceptionContext *context);
478
479 #define NACL_IRT_ASYNC_SIGNAL_HANDLING_v0_1 "nacl-irt-async-signal-handling-0.1"
480 struct nacl_irt_async_signal_handling {
481 /*
482 * NaCl applications can register a single, global async signal handler that
483 * will be invoked on the thread that receives the signal. When
484 * send_async_signal is called, |handler| is invoked on the thread specified
485 * by |tid| on the thread's stack and without modifying the underlying signal
486 * mask (as opposed to the POSIX behavior), so it is possible for |handler| to
487 * be invoked recursively (if a signal is sent from |handler|) and
488 * concurrently (if two threads send signals at the same time).
489 *
490 * If the thread was executing an IRT function, the suspended thread will
491 * continue it after |handler| finishes. In other words, no IRT function will
492 * be aborted.
493 *
494 * You can safely use only async-signal-safe operations in |handler|. The
495 * following NaCl IRT functions are async-signal-safe:
496 *
497 * - tls_get
498 * - futex_wait_abs
499 * - futex_wake
500 * - send_async_signal
501 *
502 * This function in particular is not async-signal-safe and must not be called
503 * from signal handlers.
504 */
505 int (*set_async_signal_handler)(NaClIrtAsyncSignalHandler handler);
506 /*
507 * Asynchronously delivers a signal to the thread identified by |tid| within
508 * the same process as the caller. |tid| should be a valid thread identifier
509 * obtained when creating a thread (through the |child_tid| parameter to
510 * create_thread()) and the thread must still be alive. The constant
511 * NACL_IRT_MAIN_THREAD_TID can be used to refer to the main thread.
512 *
513 * As opposed to POSIX, NaCl only provides a way to send a single signal.
514 * Delivery of different kinds of signals to be POSIX-compliant can be
515 * implemented in userspace.
516 *
517 * When |tid| is invalid, the result is unspecified. This IRT function
Mark Seaborn 2015/08/20 15:44:30 Here you say "unspecified". In documentation/nons
Luis Héctor Chávez 2015/08/20 16:13:49 Done.
518 * returns 0 on success or may return ESRCH or EINVAL on failure.
519 */
520 int (*send_async_signal)(nacl_irt_tid_t tid);
521 };
522
451 #if defined(__cplusplus) 523 #if defined(__cplusplus)
452 } 524 }
453 #endif 525 #endif
454 526
455 #endif /* NATIVE_CLIENT_SRC_UNTRUSTED_IRT_IRT_H */ 527 #endif /* NATIVE_CLIENT_SRC_UNTRUSTED_IRT_IRT_H */
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698