static int nacl_irt_read(int fd, void *buf, size_t count, size_t *nread) { int rv = NACL_GC_WRAP_SYSCALL(NACL_SYSCALL(read)(fd, buf, count)); if (rv < 0) return -rv; *nread = rv; return 0; }
static int nacl_irt_getdents(int fd, struct dirent *buf, size_t count, size_t *nread) { int rv = NACL_GC_WRAP_SYSCALL(NACL_SYSCALL(getdents)(fd, buf, count)); if (rv < 0) return -rv; *nread = rv; return 0; }
static int nacl_irt_write(int fd, const void *buf, size_t count, size_t *nwrote) { int rv = NACL_GC_WRAP_SYSCALL(NACL_SYSCALL(write)(fd, buf, count)); if (rv < 0) return -rv; *nwrote = rv; return 0; }
int write(int desc, void const *buf, size_t count) { int retval = NACL_GC_WRAP_SYSCALL(NACL_SYSCALL(write)(desc, buf, count)); if (retval < 0) { errno = -retval; return -1; } return retval; }
int pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex) { pthread_cond_validate(cond); int retval = -NACL_GC_WRAP_SYSCALL( NACL_SYSCALL(cond_wait)(cond->handle, mutex->mutex_handle)); if (retval == 0) { mutex->owner_thread_id = pthread_self(); mutex->recursion_counter = 1; } return retval; }
static int nacl_irt_get_random_bytes(void *buf, size_t count, size_t *nread) { int error = prepare_secure_random(); if (error == 0) { int rv = NACL_GC_WRAP_SYSCALL(NACL_SYSCALL(read)(secure_random_fd, buf, count)); if (rv < 0) error = -rv; else *nread = rv; } return error; }
int pthread_cond_timedwait_abs(pthread_cond_t *cond, pthread_mutex_t *mutex, struct timespec *abstime) { pthread_cond_validate(cond); int retval = -NACL_GC_WRAP_SYSCALL( NACL_SYSCALL(cond_timed_wait_abs)(cond->handle, mutex->mutex_handle, abstime)); if (retval == 0) { mutex->owner_thread_id = pthread_self(); mutex->recursion_counter = 1; } return retval; }
static int nacl_irt_sched_yield(void) { return NACL_GC_WRAP_SYSCALL(-NACL_SYSCALL(sched_yield)()); }
static int nacl_irt_nanosleep(const struct timespec *req, struct timespec *rem) { return NACL_GC_WRAP_SYSCALL(-NACL_SYSCALL(nanosleep)(req, rem)); }
static int nacl_irt_futex_wait(volatile int *addr, int value, const struct timespec *abstime) { return NACL_GC_WRAP_SYSCALL(-NACL_SYSCALL(futex_wait_abs)(addr, value, abstime)); }
int pthread_cond_broadcast (pthread_cond_t *cond) { pthread_cond_validate(cond); return -NACL_GC_WRAP_SYSCALL(NACL_SYSCALL(cond_broadcast)(cond->handle)); }
/* * Wake up one thread waiting for condition variable COND. */ int pthread_cond_signal (pthread_cond_t *cond) { pthread_cond_validate(cond); return -NACL_GC_WRAP_SYSCALL(NACL_SYSCALL(cond_signal)(cond->handle)); }
static int nacl_irt_mutex_lock(int mutex_handle) { return NACL_GC_WRAP_SYSCALL(-NACL_SYSCALL(mutex_lock)(mutex_handle)); }
static int nacl_irt_cond_timed_wait_abs(int cond_handle, int mutex_handle, const struct timespec *abstime) { return NACL_GC_WRAP_SYSCALL(-NACL_SYSCALL(cond_timed_wait_abs)(cond_handle, mutex_handle, abstime)); }
static int nacl_irt_cond_wait(int cond_handle, int mutex_handle) { return NACL_GC_WRAP_SYSCALL(-NACL_SYSCALL(cond_wait)(cond_handle, mutex_handle)); }