Nullability check for thread module

Bugs: b/245972273
Test: adb shell
Change-Id: Id93d0456e063adf0d41483a1f99f66c2d67bd4df
This commit is contained in:
zijunzhao 2023-03-10 06:03:58 +00:00
parent d2e55dd05b
commit e589574d22

View file

@ -51,9 +51,9 @@ typedef pthread_key_t tss_t;
typedef pthread_mutex_t mtx_t;
/** The type for a thread-specific storage destructor. */
typedef void (*tss_dtor_t)(void*);
typedef void (*tss_dtor_t)(void* _Nullable);
/** The type of the function passed to thrd_create() to create a new thread. */
typedef int (*thrd_start_t)(void*);
typedef int (*thrd_start_t)(void* _Nullable);
/** The type used by call_once(). */
typedef pthread_once_t once_flag;
@ -82,72 +82,72 @@ __BEGIN_DECLS
// This file is implemented as static inlines before API level 30.
/** Uses `__flag` to ensure that `__function` is called exactly once. */
void call_once(once_flag* __flag, void (*__function)(void)) __INTRODUCED_IN(30);
void call_once(once_flag* _Nonnull __flag, void (* _Nonnull __function)(void)) __INTRODUCED_IN(30);
/**
* Unblocks all threads blocked on `__cond`.
*/
int cnd_broadcast(cnd_t* __cond) __INTRODUCED_IN(30);
int cnd_broadcast(cnd_t* _Nonnull __cond) __INTRODUCED_IN(30);
/**
* Destroys a condition variable.
*/
void cnd_destroy(cnd_t* __cond) __INTRODUCED_IN(30);
void cnd_destroy(cnd_t* _Nonnull __cond) __INTRODUCED_IN(30);
/**
* Creates a condition variable.
*/
int cnd_init(cnd_t* __cond) __INTRODUCED_IN(30);
int cnd_init(cnd_t* _Nonnull __cond) __INTRODUCED_IN(30);
/**
* Unblocks one thread blocked on `__cond`.
*/
int cnd_signal(cnd_t* __cond) __INTRODUCED_IN(30);
int cnd_signal(cnd_t* _Nonnull __cond) __INTRODUCED_IN(30);
/**
* Unlocks `__mutex` and blocks until `__cond` is signaled or `__timeout` occurs.
*/
int cnd_timedwait(cnd_t* __cond, mtx_t* __mutex, const struct timespec* __timeout)
int cnd_timedwait(cnd_t* _Nonnull __cond, mtx_t* _Nonnull __mutex, const struct timespec* _Nonnull __timeout)
__INTRODUCED_IN(30);
/**
* Unlocks `__mutex` and blocks until `__cond` is signaled.
*/
int cnd_wait(cnd_t* __cond, mtx_t* __mutex) __INTRODUCED_IN(30);
int cnd_wait(cnd_t* _Nonnull __cond, mtx_t* _Nonnull __mutex) __INTRODUCED_IN(30);
/**
* Destroys a mutex.
*/
void mtx_destroy(mtx_t* __mutex) __INTRODUCED_IN(30);
void mtx_destroy(mtx_t* _Nonnull __mutex) __INTRODUCED_IN(30);
/**
* Creates a mutex.
*/
int mtx_init(mtx_t* __mutex, int __type) __INTRODUCED_IN(30);
int mtx_init(mtx_t* _Nonnull __mutex, int __type) __INTRODUCED_IN(30);
/**
* Blocks until `__mutex` is acquired.
*/
int mtx_lock(mtx_t* __mutex) __INTRODUCED_IN(30);
int mtx_lock(mtx_t* _Nonnull __mutex) __INTRODUCED_IN(30);
/**
* Blocks until `__mutex` is acquired or `__timeout` expires.
*/
int mtx_timedlock(mtx_t* __mutex, const struct timespec* __timeout) __INTRODUCED_IN(30);
int mtx_timedlock(mtx_t* _Nonnull __mutex, const struct timespec* _Nonnull __timeout) __INTRODUCED_IN(30);
/**
* Acquires `__mutex` or returns `thrd_busy`.
*/
int mtx_trylock(mtx_t* __mutex) __INTRODUCED_IN(30);
int mtx_trylock(mtx_t* _Nonnull __mutex) __INTRODUCED_IN(30);
/**
* Unlocks `__mutex`.
*/
int mtx_unlock(mtx_t* __mutex) __INTRODUCED_IN(30);
int mtx_unlock(mtx_t* _Nonnull __mutex) __INTRODUCED_IN(30);
@ -155,7 +155,7 @@ int mtx_unlock(mtx_t* __mutex) __INTRODUCED_IN(30);
* Creates a new thread running `__function(__arg)`, and sets `*__thrd` to
* the new thread.
*/
int thrd_create(thrd_t* __thrd, thrd_start_t __function, void* __arg) __INTRODUCED_IN(30);
int thrd_create(thrd_t* _Nonnull __thrd, thrd_start_t _Nonnull __function, void* _Nullable __arg) __INTRODUCED_IN(30);
/**
* Returns the `thrd_t` corresponding to the caller.
@ -181,7 +181,7 @@ void thrd_exit(int __result) __noreturn __INTRODUCED_IN(30);
* Blocks until `__thrd` terminates. If `__result` is not null, `*__result`
* is set to the exiting thread's result.
*/
int thrd_join(thrd_t __thrd, int* __result) __INTRODUCED_IN(30);
int thrd_join(thrd_t __thrd, int* _Nullable __result) __INTRODUCED_IN(30);
/**
* Blocks the caller for at least `__duration` unless a signal is delivered.
@ -190,7 +190,7 @@ int thrd_join(thrd_t __thrd, int* __result) __INTRODUCED_IN(30);
*
* Returns 0 on success, or -1 if a signal was delivered.
*/
int thrd_sleep(const struct timespec* __duration, struct timespec* __remaining) __INTRODUCED_IN(30);
int thrd_sleep(const struct timespec* _Nonnull __duration, struct timespec* _Nullable __remaining) __INTRODUCED_IN(30);
/**
* Request that other threads should be scheduled.
@ -203,7 +203,7 @@ void thrd_yield(void) __INTRODUCED_IN(30);
* Creates a thread-specific storage key with the associated destructor (which
* may be null).
*/
int tss_create(tss_t* __key, tss_dtor_t __dtor) __INTRODUCED_IN(30);
int tss_create(tss_t* _Nonnull __key, tss_dtor_t _Nullable __dtor) __INTRODUCED_IN(30);
/**
* Destroys a thread-specific storage key.
@ -214,13 +214,13 @@ void tss_delete(tss_t __key) __INTRODUCED_IN(30);
* Returns the value for the current thread held in the thread-specific storage
* identified by `__key`.
*/
void* tss_get(tss_t __key) __INTRODUCED_IN(30);
void* _Nullable tss_get(tss_t __key) __INTRODUCED_IN(30);
/**
* Sets the current thread's value for the thread-specific storage identified
* by `__key` to `__value`.
*/
int tss_set(tss_t __key, void* __value) __INTRODUCED_IN(30);
int tss_set(tss_t __key, void* _Nonnull __value) __INTRODUCED_IN(30);
#endif