From 60056a8010c3dbaabd713f7a3e4f2963bb921a1b Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Fri, 7 Sep 2018 16:20:39 -0400 Subject: for c11 mtx and cnd functions, use externally consistent type names MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/thread/mtx_trylock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/thread/mtx_trylock.c') diff --git a/src/thread/mtx_trylock.c b/src/thread/mtx_trylock.c index 61e7694e..8d1fb07c 100644 --- a/src/thread/mtx_trylock.c +++ b/src/thread/mtx_trylock.c @@ -1,14 +1,14 @@ #include "pthread_impl.h" #include -int __pthread_mutex_trylock(mtx_t *); +int __pthread_mutex_trylock(pthread_mutex_t *); int mtx_trylock(mtx_t *m) { if (m->_m_type == PTHREAD_MUTEX_NORMAL) return (a_cas(&m->_m_lock, 0, EBUSY) & EBUSY) ? thrd_busy : thrd_success; - int ret = __pthread_mutex_trylock(m); + int ret = __pthread_mutex_trylock((pthread_mutex_t *)m); switch (ret) { default: return thrd_error; case 0: return thrd_success; -- cgit v1.2.1