Merge "Nullability check for threads_inlines module."
This commit is contained in:
commit
71985ed110
1 changed files with 30 additions and 29 deletions
|
@ -48,46 +48,46 @@ static __inline int __bionic_thrd_error(int __pthread_code) {
|
|||
}
|
||||
}
|
||||
|
||||
__BIONIC_THREADS_INLINE void call_once(once_flag* __flag,
|
||||
void (*__function)(void)) {
|
||||
__BIONIC_THREADS_INLINE void call_once(once_flag* _Nonnull __flag,
|
||||
void (* _Nonnull __function)(void)) {
|
||||
pthread_once(__flag, __function);
|
||||
}
|
||||
|
||||
|
||||
|
||||
__BIONIC_THREADS_INLINE int cnd_broadcast(cnd_t* __cnd) {
|
||||
__BIONIC_THREADS_INLINE int cnd_broadcast(cnd_t* _Nonnull __cnd) {
|
||||
return __bionic_thrd_error(pthread_cond_broadcast(__cnd));
|
||||
}
|
||||
|
||||
__BIONIC_THREADS_INLINE void cnd_destroy(cnd_t* __cnd) {
|
||||
__BIONIC_THREADS_INLINE void cnd_destroy(cnd_t* _Nonnull __cnd) {
|
||||
pthread_cond_destroy(__cnd);
|
||||
}
|
||||
|
||||
__BIONIC_THREADS_INLINE int cnd_init(cnd_t* __cnd) {
|
||||
__BIONIC_THREADS_INLINE int cnd_init(cnd_t* _Nonnull __cnd) {
|
||||
return __bionic_thrd_error(pthread_cond_init(__cnd, NULL));
|
||||
}
|
||||
|
||||
__BIONIC_THREADS_INLINE int cnd_signal(cnd_t* __cnd) {
|
||||
__BIONIC_THREADS_INLINE int cnd_signal(cnd_t* _Nonnull __cnd) {
|
||||
return __bionic_thrd_error(pthread_cond_signal(__cnd));
|
||||
}
|
||||
|
||||
__BIONIC_THREADS_INLINE int cnd_timedwait(cnd_t* __cnd,
|
||||
mtx_t* __mtx,
|
||||
const struct timespec* __timeout) {
|
||||
__BIONIC_THREADS_INLINE int cnd_timedwait(cnd_t* _Nonnull __cnd,
|
||||
mtx_t* _Nonnull __mtx,
|
||||
const struct timespec* _Nullable __timeout) {
|
||||
return __bionic_thrd_error(pthread_cond_timedwait(__cnd, __mtx, __timeout));
|
||||
}
|
||||
|
||||
__BIONIC_THREADS_INLINE int cnd_wait(cnd_t* __cnd, mtx_t* __mtx) {
|
||||
__BIONIC_THREADS_INLINE int cnd_wait(cnd_t* _Nonnull __cnd, mtx_t* _Nonnull __mtx) {
|
||||
return __bionic_thrd_error(pthread_cond_wait(__cnd, __mtx));
|
||||
}
|
||||
|
||||
|
||||
|
||||
__BIONIC_THREADS_INLINE void mtx_destroy(mtx_t* __mtx) {
|
||||
__BIONIC_THREADS_INLINE void mtx_destroy(mtx_t* _Nonnull __mtx) {
|
||||
pthread_mutex_destroy(__mtx);
|
||||
}
|
||||
|
||||
__BIONIC_THREADS_INLINE int mtx_init(mtx_t* __mtx, int __type) {
|
||||
__BIONIC_THREADS_INLINE int mtx_init(mtx_t* _Nonnull __mtx, int __type) {
|
||||
int __pthread_type = (__type & mtx_recursive) ? PTHREAD_MUTEX_RECURSIVE
|
||||
: PTHREAD_MUTEX_NORMAL;
|
||||
__type &= ~mtx_recursive;
|
||||
|
@ -99,31 +99,32 @@ __BIONIC_THREADS_INLINE int mtx_init(mtx_t* __mtx, int __type) {
|
|||
return __bionic_thrd_error(pthread_mutex_init(__mtx, &__attr));
|
||||
}
|
||||
|
||||
__BIONIC_THREADS_INLINE int mtx_lock(mtx_t* __mtx) {
|
||||
__BIONIC_THREADS_INLINE int mtx_lock(mtx_t* _Nonnull __mtx) {
|
||||
return __bionic_thrd_error(pthread_mutex_lock(__mtx));
|
||||
}
|
||||
|
||||
__BIONIC_THREADS_INLINE int mtx_timedlock(mtx_t* __mtx,
|
||||
const struct timespec* __timeout) {
|
||||
__BIONIC_THREADS_INLINE int mtx_timedlock(mtx_t* _Nonnull __mtx,
|
||||
const struct timespec* _Nullable __timeout) {
|
||||
return __bionic_thrd_error(pthread_mutex_timedlock(__mtx, __timeout));
|
||||
}
|
||||
|
||||
__BIONIC_THREADS_INLINE int mtx_trylock(mtx_t* __mtx) {
|
||||
__BIONIC_THREADS_INLINE int mtx_trylock(mtx_t* _Nonnull __mtx) {
|
||||
return __bionic_thrd_error(pthread_mutex_trylock(__mtx));
|
||||
}
|
||||
|
||||
__BIONIC_THREADS_INLINE int mtx_unlock(mtx_t* __mtx) {
|
||||
__BIONIC_THREADS_INLINE int mtx_unlock(mtx_t* _Nonnull __mtx) {
|
||||
return __bionic_thrd_error(pthread_mutex_unlock(__mtx));
|
||||
}
|
||||
|
||||
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wnullability-completeness"
|
||||
struct __bionic_thrd_data {
|
||||
thrd_start_t __func;
|
||||
void* __arg;
|
||||
};
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
static inline void* __bionic_thrd_trampoline(void* __arg) {
|
||||
static inline void* _Nonnull __bionic_thrd_trampoline(void* _Nonnull __arg) {
|
||||
struct __bionic_thrd_data __data =
|
||||
*__BIONIC_CAST(static_cast, struct __bionic_thrd_data*, __arg);
|
||||
free(__arg);
|
||||
|
@ -132,9 +133,9 @@ static inline void* __bionic_thrd_trampoline(void* __arg) {
|
|||
__BIONIC_CAST(static_cast, uintptr_t, __result));
|
||||
}
|
||||
|
||||
__BIONIC_THREADS_INLINE int thrd_create(thrd_t* __thrd,
|
||||
thrd_start_t __func,
|
||||
void* __arg) {
|
||||
__BIONIC_THREADS_INLINE int thrd_create(thrd_t* _Nonnull __thrd,
|
||||
thrd_start_t _Nonnull __func,
|
||||
void* _Nullable __arg) {
|
||||
struct __bionic_thrd_data* __pthread_arg =
|
||||
__BIONIC_CAST(static_cast, struct __bionic_thrd_data*,
|
||||
malloc(sizeof(struct __bionic_thrd_data)));
|
||||
|
@ -164,7 +165,7 @@ __BIONIC_THREADS_INLINE void thrd_exit(int __result) {
|
|||
__BIONIC_CAST(static_cast, uintptr_t, __result)));
|
||||
}
|
||||
|
||||
__BIONIC_THREADS_INLINE int thrd_join(thrd_t __thrd, int* __result) {
|
||||
__BIONIC_THREADS_INLINE int thrd_join(thrd_t __thrd, int* _Nullable __result) {
|
||||
void* __pthread_result;
|
||||
if (pthread_join(__thrd, &__pthread_result) != 0) return thrd_error;
|
||||
if (__result) {
|
||||
|
@ -173,8 +174,8 @@ __BIONIC_THREADS_INLINE int thrd_join(thrd_t __thrd, int* __result) {
|
|||
return thrd_success;
|
||||
}
|
||||
|
||||
__BIONIC_THREADS_INLINE int thrd_sleep(const struct timespec* __duration,
|
||||
struct timespec* __remaining) {
|
||||
__BIONIC_THREADS_INLINE int thrd_sleep(const struct timespec* _Nonnull __duration,
|
||||
struct timespec* _Nullable __remaining) {
|
||||
int __rc = nanosleep(__duration, __remaining);
|
||||
if (__rc == 0) return 0;
|
||||
return (errno == EINTR) ? -1 : -2;
|
||||
|
@ -186,7 +187,7 @@ __BIONIC_THREADS_INLINE void thrd_yield(void) {
|
|||
|
||||
|
||||
|
||||
__BIONIC_THREADS_INLINE int tss_create(tss_t* __key, tss_dtor_t __dtor) {
|
||||
__BIONIC_THREADS_INLINE int tss_create(tss_t* _Nonnull __key, tss_dtor_t _Nullable __dtor) {
|
||||
return __bionic_thrd_error(pthread_key_create(__key, __dtor));
|
||||
}
|
||||
|
||||
|
@ -194,11 +195,11 @@ __BIONIC_THREADS_INLINE void tss_delete(tss_t __key) {
|
|||
pthread_key_delete(__key);
|
||||
}
|
||||
|
||||
__BIONIC_THREADS_INLINE void* tss_get(tss_t __key) {
|
||||
__BIONIC_THREADS_INLINE void* _Nullable tss_get(tss_t __key) {
|
||||
return pthread_getspecific(__key);
|
||||
}
|
||||
|
||||
__BIONIC_THREADS_INLINE int tss_set(tss_t __key, void* __value) {
|
||||
__BIONIC_THREADS_INLINE int tss_set(tss_t __key, void* _Nonnull __value) {
|
||||
return __bionic_thrd_error(pthread_setspecific(__key, __value));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue