Changeset View
Changeset View
Standalone View
Standalone View
lib/libthr/thread/thr_syscalls.c
Show First 20 Lines • Show All 182 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* Cancellation behavior: | * Cancellation behavior: | ||||
* According to specification, only F_SETLKW is a cancellation point. | * According to specification, only F_SETLKW is a cancellation point. | ||||
* Thread is only canceled at start, or canceled if the system call | * Thread is only canceled at start, or canceled if the system call | ||||
* is failure, this means the function does not generate side effect | * is failure, this means the function does not generate side effect | ||||
* if it is canceled. | * if it is canceled. | ||||
*/ | */ | ||||
static int | static int | ||||
__thr_fcntl(int fd, int cmd, ...) | __thr_fcntl(int fd, int cmd, __intptr_t arg) | ||||
{ | { | ||||
struct pthread *curthread; | struct pthread *curthread; | ||||
int ret; | int ret; | ||||
va_list ap; | |||||
curthread = _get_curthread(); | curthread = _get_curthread(); | ||||
va_start(ap, cmd); | |||||
if (cmd == F_OSETLKW || cmd == F_SETLKW) { | if (cmd == F_OSETLKW || cmd == F_SETLKW) { | ||||
_thr_cancel_enter(curthread); | _thr_cancel_enter(curthread); | ||||
ret = __sys_fcntl(fd, cmd, (intptr_t)va_arg(ap, void *)); | ret = __sys_fcntl(fd, cmd, arg); | ||||
_thr_cancel_leave(curthread, ret == -1); | _thr_cancel_leave(curthread, ret == -1); | ||||
} else { | } else { | ||||
ret = __sys_fcntl(fd, cmd, (intptr_t)va_arg(ap, void *)); | ret = __sys_fcntl(fd, cmd, arg); | ||||
} | } | ||||
va_end(ap); | |||||
return (ret); | return (ret); | ||||
} | } | ||||
/* | /* | ||||
* Cancellation behavior: | * Cancellation behavior: | ||||
* Thread may be canceled after system call. | * Thread may be canceled after system call. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | __thr_nanosleep(const struct timespec *time_to_sleep, | ||||
return (ret); | return (ret); | ||||
} | } | ||||
/* | /* | ||||
* Cancellation behavior: | * Cancellation behavior: | ||||
* If the thread is canceled, file is not opened. | * If the thread is canceled, file is not opened. | ||||
*/ | */ | ||||
static int | static int | ||||
__thr_openat(int fd, const char *path, int flags, ...) | __thr_openat(int fd, const char *path, int flags, int mode) | ||||
{ | { | ||||
struct pthread *curthread; | struct pthread *curthread; | ||||
int mode, ret; | int ret; | ||||
va_list ap; | |||||
/* Check if the file is being created: */ | |||||
if ((flags & O_CREAT) != 0) { | |||||
/* Get the creation mode: */ | |||||
va_start(ap, flags); | |||||
mode = va_arg(ap, int); | |||||
va_end(ap); | |||||
} else { | |||||
mode = 0; | |||||
} | |||||
curthread = _get_curthread(); | curthread = _get_curthread(); | ||||
_thr_cancel_enter(curthread); | _thr_cancel_enter(curthread); | ||||
ret = __sys_openat(fd, path, flags, mode); | ret = __sys_openat(fd, path, flags, mode); | ||||
_thr_cancel_leave(curthread, ret == -1); | _thr_cancel_leave(curthread, ret == -1); | ||||
return (ret); | return (ret); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 376 Lines • Show Last 20 Lines |