diff options
Diffstat (limited to 'src/threads')
| -rw-r--r-- | src/threads/cnd_timedwait.c | 4 | ||||
| -rw-r--r-- | src/threads/cnd_wait.c | 2 | ||||
| -rw-r--r-- | src/threads/mtx_timedlock.c | 2 | ||||
| -rw-r--r-- | src/threads/thrd_create.c | 2 | ||||
| -rw-r--r-- | src/threads/thrd_sleep.c | 2 |
5 files changed, 12 insertions, 0 deletions
diff --git a/src/threads/cnd_timedwait.c b/src/threads/cnd_timedwait.c index dfa13b93..1e86b7e5 100644 --- a/src/threads/cnd_timedwait.c +++ b/src/threads/cnd_timedwait.c @@ -7,6 +7,10 @@ int cnd_timedwait(cnd_t *restrict cond, mtx_t *restrict mtx, const struct timespec *restrict ts) { SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(cond, sizeof(*cond), mtx, sizeof(*mtx)); + ASSERT_NOOVERLAP(cond, sizeof(*cond), ts, sizeof(*ts)); + ASSERT_NOOVERLAP(mtx, sizeof(*mtx), ts, sizeof(*ts)); + switch (pthread_cond_timedwait(cond, mtx, ts)) { case 0: return thrd_success; diff --git a/src/threads/cnd_wait.c b/src/threads/cnd_wait.c index dc929573..bee8ff2b 100644 --- a/src/threads/cnd_wait.c +++ b/src/threads/cnd_wait.c @@ -6,6 +6,8 @@ int cnd_wait(cnd_t *cond, mtx_t *mtx) { SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(cond, sizeof(*cond), mtx, sizeof(*mtx)); + return pthread_cond_wait(cond, mtx) == 0 ? thrd_success : thrd_error; } diff --git a/src/threads/mtx_timedlock.c b/src/threads/mtx_timedlock.c index 1b073786..80069bc5 100644 --- a/src/threads/mtx_timedlock.c +++ b/src/threads/mtx_timedlock.c @@ -7,6 +7,8 @@ int mtx_timedlock(mtx_t *restrict mtx, const struct timespec *restrict ts) { SIGNAL_SAFE(0); + ASSERT_NOOVERLAP(mtx, sizeof(*mtx), ts, sizeof(*ts)); + switch (pthread_mutex_timedlock(mtx, ts)) { case 0: return thrd_success; diff --git a/src/threads/thrd_create.c b/src/threads/thrd_create.c index 0b64b0c6..2e6a875f 100644 --- a/src/threads/thrd_create.c +++ b/src/threads/thrd_create.c @@ -7,6 +7,8 @@ int thrd_create(thrd_t *thr, thrd_start_t func, void *arg) { SIGNAL_SAFE(0); + /* can't detect overlap because arg size is unknown */ + typedef void *(*pthread_start_fn)(void*); switch (pthread_create(thr, 0, (pthread_start_fn)func, arg)) { case 0: diff --git a/src/threads/thrd_sleep.c b/src/threads/thrd_sleep.c index cb8cd448..7ea445a2 100644 --- a/src/threads/thrd_sleep.c +++ b/src/threads/thrd_sleep.c @@ -6,6 +6,8 @@ int thrd_sleep(const struct timespec *duration, struct timespec *remaining) { SIGNAL_SAFE(0); + ASSERT_OVERLAP(duration, sizeof(*duration, remaining, sizeof(*remaining)); + return nanosleep(duration, remaining); } |
