diff options
author | Rich Felker <dalias@aerifal.cx> | 2018-09-07 16:20:39 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2018-09-12 14:34:29 -0400 |
commit | 60056a8010c3dbaabd713f7a3e4f2963bb921a1b (patch) | |
tree | a78579a799af861818ab9831beb945ddfd8970bd /src/thread/cnd_timedwait.c | |
parent | c98bf5b8691b21373ff8d9698e89a75acdefdc75 (diff) | |
download | musl-60056a8010c3dbaabd713f7a3e4f2963bb921a1b.tar.gz musl-60056a8010c3dbaabd713f7a3e4f2963bb921a1b.tar.bz2 musl-60056a8010c3dbaabd713f7a3e4f2963bb921a1b.tar.xz musl-60056a8010c3dbaabd713f7a3e4f2963bb921a1b.zip |
for c11 mtx and cnd functions, use externally consistent type names
despite looking like undefined behavior, the affected code is correct
both before and after this patch. the pairs mtx_t and pthread_mutex_t,
and cnd_t and pthread_cond_t, are not mutually compatible within a
single translation unit (because they are distinct untagged aggregate
instances), but they are compatible with an object of either type from
another translation unit (6.2.7 ΒΆ1), and therefore a given translation
unit can choose which one it wants to use.
in the interest of being able to move declarations out of source files
to headers that facilitate checking, use the pthread type names in
declaring the namespace-safe versions of the pthread functions and
cast the argument pointer types when calling them.
Diffstat (limited to 'src/thread/cnd_timedwait.c')
-rw-r--r-- | src/thread/cnd_timedwait.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/thread/cnd_timedwait.c b/src/thread/cnd_timedwait.c index 59976793..7bfe1045 100644 --- a/src/thread/cnd_timedwait.c +++ b/src/thread/cnd_timedwait.c @@ -1,11 +1,12 @@ #include <threads.h> +#include <pthread.h> #include <errno.h> -int __pthread_cond_timedwait(cnd_t *restrict, mtx_t *restrict, const struct timespec *restrict); +int __pthread_cond_timedwait(pthread_cond_t *restrict, pthread_mutex_t *restrict, const struct timespec *restrict); int cnd_timedwait(cnd_t *restrict c, mtx_t *restrict m, const struct timespec *restrict ts) { - int ret = __pthread_cond_timedwait(c, m, ts); + int ret = __pthread_cond_timedwait((pthread_cond_t *)c, (pthread_mutex_t *)m, ts); switch (ret) { /* May also return EINVAL or EPERM. */ default: return thrd_error; |