Make use of gcc attributes in some standard include headers.
The `nonnull' attribute specifies that some function parameters should be non-null pointers. This is very useful as it helps the compiler generate warnings on suspicious code and can also enable some small optimizations. Also start using 'alloc_size' attribute in the allocator functions. This is an initial step to better integrate our libc with the compiler: these attributes are fully supported by clang and they are also useful for the static analyzer. Note that due to some bogus internal procedure in the way gcc ports are built they may require updating if they were built before r280801. Relnotes: yes Hinted by: Android's bionic libc Differential Revision: https://reviews.freebsd.org/D2107
This commit is contained in:
parent
a1c1feb511
commit
153cbcd657
@ -144,19 +144,25 @@ struct _pthread_cleanup_info {
|
||||
*/
|
||||
__BEGIN_DECLS
|
||||
int pthread_atfork(void (*)(void), void (*)(void), void (*)(void));
|
||||
int pthread_attr_destroy(pthread_attr_t *);
|
||||
int pthread_attr_destroy(pthread_attr_t *) __nonnull(1);
|
||||
int pthread_attr_getstack(const pthread_attr_t * __restrict,
|
||||
void ** __restrict, size_t * __restrict);
|
||||
int pthread_attr_getstacksize(const pthread_attr_t *, size_t *);
|
||||
void ** __restrict, size_t * __restrict)
|
||||
__nonnull_all;
|
||||
int pthread_attr_getstacksize(const pthread_attr_t *, size_t *)
|
||||
__nonnull_all;
|
||||
int pthread_attr_getguardsize(const pthread_attr_t *, size_t *);
|
||||
int pthread_attr_getstackaddr(const pthread_attr_t *, void **);
|
||||
int pthread_attr_getdetachstate(const pthread_attr_t *, int *);
|
||||
int pthread_attr_init(pthread_attr_t *);
|
||||
int pthread_attr_setstacksize(pthread_attr_t *, size_t);
|
||||
int pthread_attr_setguardsize(pthread_attr_t *, size_t);
|
||||
int pthread_attr_setstack(pthread_attr_t *, void *, size_t);
|
||||
int pthread_attr_getdetachstate(const pthread_attr_t *, int *)
|
||||
__nonnull_all;
|
||||
int pthread_attr_init(pthread_attr_t *) __nonnull(1);
|
||||
int pthread_attr_setstacksize(pthread_attr_t *, size_t)
|
||||
__nonnull(1);
|
||||
int pthread_attr_setguardsize(pthread_attr_t *, size_t)
|
||||
__nonnull(1);
|
||||
int pthread_attr_setstack(pthread_attr_t *, void *, size_t)
|
||||
__nonnull(1);
|
||||
int pthread_attr_setstackaddr(pthread_attr_t *, void *);
|
||||
int pthread_attr_setdetachstate(pthread_attr_t *, int);
|
||||
int pthread_attr_setdetachstate(pthread_attr_t *, int) __nonnull(1);
|
||||
int pthread_barrier_destroy(pthread_barrier_t *);
|
||||
int pthread_barrier_init(pthread_barrier_t *,
|
||||
const pthread_barrierattr_t *, unsigned);
|
||||
@ -164,7 +170,7 @@ int pthread_barrier_wait(pthread_barrier_t *);
|
||||
int pthread_barrierattr_destroy(pthread_barrierattr_t *);
|
||||
int pthread_barrierattr_getpshared(const pthread_barrierattr_t *,
|
||||
int *);
|
||||
int pthread_barrierattr_init(pthread_barrierattr_t *);
|
||||
int pthread_barrierattr_init(pthread_barrierattr_t *) __nonnull(1);
|
||||
int pthread_barrierattr_setpshared(pthread_barrierattr_t *, int);
|
||||
|
||||
#define pthread_cleanup_push(cleanup_routine, cleanup_arg) \
|
||||
@ -180,98 +186,109 @@ int pthread_barrierattr_setpshared(pthread_barrierattr_t *, int);
|
||||
__pthread_cleanup_pop_imp(execute); \
|
||||
}
|
||||
|
||||
int pthread_condattr_destroy(pthread_condattr_t *);
|
||||
int pthread_condattr_destroy(pthread_condattr_t *) __nonnull(1);
|
||||
int pthread_condattr_getclock(const pthread_condattr_t *,
|
||||
clockid_t *);
|
||||
int pthread_condattr_getpshared(const pthread_condattr_t *, int *);
|
||||
int pthread_condattr_init(pthread_condattr_t *);
|
||||
int pthread_condattr_setclock(pthread_condattr_t *, clockid_t);
|
||||
int pthread_condattr_setpshared(pthread_condattr_t *, int);
|
||||
int pthread_cond_broadcast(pthread_cond_t *);
|
||||
int pthread_cond_destroy(pthread_cond_t *);
|
||||
clockid_t *) __nonnull_all;
|
||||
int pthread_condattr_getpshared(const pthread_condattr_t *, int *)
|
||||
__nonnull_all;
|
||||
int pthread_condattr_init(pthread_condattr_t *) __nonnull(1);
|
||||
int pthread_condattr_setclock(pthread_condattr_t *, clockid_t)
|
||||
__nonnull(1);
|
||||
int pthread_condattr_setpshared(pthread_condattr_t *, int)
|
||||
__nonnull(1);
|
||||
int pthread_cond_broadcast(pthread_cond_t *)
|
||||
__nonnull(1);
|
||||
int pthread_cond_destroy(pthread_cond_t *)
|
||||
__nonnull(1);
|
||||
int pthread_cond_init(pthread_cond_t *,
|
||||
const pthread_condattr_t *);
|
||||
int pthread_cond_signal(pthread_cond_t *);
|
||||
const pthread_condattr_t *) __nonnull(1);
|
||||
int pthread_cond_signal(pthread_cond_t *) __nonnull(1);
|
||||
int pthread_cond_timedwait(pthread_cond_t *,
|
||||
pthread_mutex_t *__mutex, const struct timespec *)
|
||||
__requires_exclusive(*__mutex);
|
||||
__nonnull_all __requires_exclusive(*__mutex);
|
||||
int pthread_cond_wait(pthread_cond_t *, pthread_mutex_t *__mutex)
|
||||
__requires_exclusive(*__mutex);
|
||||
__nonnull_all __requires_exclusive(*__mutex);
|
||||
int pthread_create(pthread_t *, const pthread_attr_t *,
|
||||
void *(*) (void *), void *);
|
||||
void *(*) (void *), void *) __nonnull(1) __nonnull(3);
|
||||
int pthread_detach(pthread_t);
|
||||
int pthread_equal(pthread_t, pthread_t);
|
||||
void pthread_exit(void *) __dead2;
|
||||
void *pthread_getspecific(pthread_key_t);
|
||||
int pthread_getcpuclockid(pthread_t, clockid_t *);
|
||||
int pthread_getcpuclockid(pthread_t, clockid_t *) __nonnull(2);
|
||||
int pthread_join(pthread_t, void **);
|
||||
int pthread_key_create(pthread_key_t *,
|
||||
void (*) (void *));
|
||||
void (*) (void *)) __nonnull(1);
|
||||
int pthread_key_delete(pthread_key_t);
|
||||
int pthread_mutexattr_init(pthread_mutexattr_t *);
|
||||
int pthread_mutexattr_destroy(pthread_mutexattr_t *);
|
||||
int pthread_mutexattr_init(pthread_mutexattr_t *) __nonnull(1);
|
||||
int pthread_mutexattr_destroy(pthread_mutexattr_t *) __nonnull(1);
|
||||
int pthread_mutexattr_getpshared(const pthread_mutexattr_t *,
|
||||
int *);
|
||||
int pthread_mutexattr_gettype(pthread_mutexattr_t *, int *);
|
||||
int pthread_mutexattr_settype(pthread_mutexattr_t *, int);
|
||||
int pthread_mutexattr_setpshared(pthread_mutexattr_t *, int);
|
||||
int *) __nonnull_all;
|
||||
int pthread_mutexattr_gettype(pthread_mutexattr_t *, int *)
|
||||
__nonnull_all;
|
||||
int pthread_mutexattr_settype(pthread_mutexattr_t *, int)
|
||||
__nonnull(1);
|
||||
int pthread_mutexattr_setpshared(pthread_mutexattr_t *, int)
|
||||
__nonnull(1);
|
||||
int pthread_mutex_destroy(pthread_mutex_t *__mutex)
|
||||
__requires_unlocked(*__mutex);
|
||||
__nonnull(1) __requires_unlocked(*__mutex);
|
||||
int pthread_mutex_init(pthread_mutex_t *__mutex,
|
||||
const pthread_mutexattr_t *)
|
||||
__requires_unlocked(*__mutex);
|
||||
__nonnull(1) __requires_unlocked(*__mutex);
|
||||
int pthread_mutex_lock(pthread_mutex_t *__mutex)
|
||||
__locks_exclusive(*__mutex);
|
||||
__nonnull(1) __locks_exclusive(*__mutex);
|
||||
int pthread_mutex_trylock(pthread_mutex_t *__mutex)
|
||||
__trylocks_exclusive(0, *__mutex);
|
||||
__nonnull(1) __trylocks_exclusive(0, *__mutex);
|
||||
int pthread_mutex_timedlock(pthread_mutex_t *__mutex,
|
||||
const struct timespec *)
|
||||
__trylocks_exclusive(0, *__mutex);
|
||||
__nonnull_all __trylocks_exclusive(0, *__mutex);
|
||||
int pthread_mutex_unlock(pthread_mutex_t *__mutex)
|
||||
__unlocks(*__mutex);
|
||||
int pthread_once(pthread_once_t *, void (*) (void));
|
||||
__nonnull(1) __unlocks(*__mutex);
|
||||
int pthread_once(pthread_once_t *, void (*) (void)) __nonnull_all;
|
||||
int pthread_rwlock_destroy(pthread_rwlock_t *__rwlock)
|
||||
__requires_unlocked(*__rwlock);
|
||||
__nonnull(1) __requires_unlocked(*__rwlock);
|
||||
int pthread_rwlock_init(pthread_rwlock_t *__rwlock,
|
||||
const pthread_rwlockattr_t *)
|
||||
__requires_unlocked(*__rwlock);
|
||||
__nonnull(1) __requires_unlocked(*__rwlock);
|
||||
int pthread_rwlock_rdlock(pthread_rwlock_t *__rwlock)
|
||||
__locks_shared(*__rwlock);
|
||||
__nonnull(1) __locks_shared(*__rwlock);
|
||||
int pthread_rwlock_timedrdlock(pthread_rwlock_t *__rwlock,
|
||||
const struct timespec *)
|
||||
__trylocks_shared(0, *__rwlock);
|
||||
__nonnull_all __trylocks_shared(0, *__rwlock);
|
||||
int pthread_rwlock_timedwrlock(pthread_rwlock_t *__rwlock,
|
||||
const struct timespec *)
|
||||
__trylocks_exclusive(0, *__rwlock);
|
||||
__nonnull_all __trylocks_exclusive(0, *__rwlock);
|
||||
int pthread_rwlock_tryrdlock(pthread_rwlock_t *__rwlock)
|
||||
__trylocks_shared(0, *__rwlock);
|
||||
__nonnull(1) __trylocks_shared(0, *__rwlock);
|
||||
int pthread_rwlock_trywrlock(pthread_rwlock_t *__rwlock)
|
||||
__trylocks_exclusive(0, *__rwlock);
|
||||
__nonnull(1) __trylocks_exclusive(0, *__rwlock);
|
||||
int pthread_rwlock_unlock(pthread_rwlock_t *__rwlock)
|
||||
__unlocks(*__rwlock);
|
||||
__nonnull(1) __unlocks(*__rwlock);
|
||||
int pthread_rwlock_wrlock(pthread_rwlock_t *__rwlock)
|
||||
__locks_exclusive(*__rwlock);
|
||||
int pthread_rwlockattr_destroy(pthread_rwlockattr_t *);
|
||||
__nonnull(1) __locks_exclusive(*__rwlock);
|
||||
int pthread_rwlockattr_destroy(pthread_rwlockattr_t *)
|
||||
__nonnull(1);
|
||||
int pthread_rwlockattr_getkind_np(const pthread_rwlockattr_t *,
|
||||
int *);
|
||||
int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *,
|
||||
int *);
|
||||
int pthread_rwlockattr_init(pthread_rwlockattr_t *);
|
||||
int *) __nonnull_all;
|
||||
int pthread_rwlockattr_init(pthread_rwlockattr_t *)
|
||||
__nonnull(1);
|
||||
int pthread_rwlockattr_setkind_np(pthread_rwlockattr_t *, int);
|
||||
int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *, int);
|
||||
int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *, int)
|
||||
__nonnull(1);
|
||||
pthread_t pthread_self(void);
|
||||
int pthread_setspecific(pthread_key_t, const void *);
|
||||
|
||||
int pthread_spin_init(pthread_spinlock_t *__spin, int)
|
||||
__requires_unlocked(*__spin);
|
||||
__requires_unlocked(*__spin);
|
||||
int pthread_spin_destroy(pthread_spinlock_t *__spin)
|
||||
__requires_unlocked(*__spin);
|
||||
__requires_unlocked(*__spin);
|
||||
int pthread_spin_lock(pthread_spinlock_t *__spin)
|
||||
__locks_exclusive(*__spin);
|
||||
__locks_exclusive(*__spin);
|
||||
int pthread_spin_trylock(pthread_spinlock_t *__spin)
|
||||
__trylocks_exclusive(0, *__spin);
|
||||
__trylocks_exclusive(0, *__spin);
|
||||
int pthread_spin_unlock(pthread_spinlock_t *__spin)
|
||||
__unlocks(*__spin);
|
||||
__unlocks(*__spin);
|
||||
int pthread_cancel(pthread_t);
|
||||
int pthread_setcancelstate(int, int *);
|
||||
int pthread_setcanceltype(int, int *);
|
||||
@ -295,18 +312,20 @@ int pthread_mutexattr_setprotocol(pthread_mutexattr_t *, int);
|
||||
|
||||
int pthread_attr_getinheritsched(const pthread_attr_t *, int *);
|
||||
int pthread_attr_getschedparam(const pthread_attr_t *,
|
||||
struct sched_param *);
|
||||
int pthread_attr_getschedpolicy(const pthread_attr_t *, int *);
|
||||
int pthread_attr_getscope(const pthread_attr_t *, int *);
|
||||
struct sched_param *) __nonnull_all;
|
||||
int pthread_attr_getschedpolicy(const pthread_attr_t *, int *)
|
||||
__nonnull_all;
|
||||
int pthread_attr_getscope(const pthread_attr_t *, int *)
|
||||
__nonnull_all;
|
||||
int pthread_attr_setinheritsched(pthread_attr_t *, int);
|
||||
int pthread_attr_setschedparam(pthread_attr_t *,
|
||||
const struct sched_param *);
|
||||
int pthread_attr_setschedpolicy(pthread_attr_t *, int);
|
||||
int pthread_attr_setscope(pthread_attr_t *, int);
|
||||
const struct sched_param *) __nonnull(1) __nonnull(2);
|
||||
int pthread_attr_setschedpolicy(pthread_attr_t *, int) __nonnull(1);
|
||||
int pthread_attr_setscope(pthread_attr_t *, int) __nonnull(1);
|
||||
int pthread_getschedparam(pthread_t pthread, int *,
|
||||
struct sched_param *);
|
||||
struct sched_param *) __nonnull(2) __nonnull(3);
|
||||
int pthread_setschedparam(pthread_t, int,
|
||||
const struct sched_param *);
|
||||
const struct sched_param *) __nonnull(3);
|
||||
#if __XSI_VISIBLE
|
||||
int pthread_getconcurrency(void);
|
||||
int pthread_setconcurrency(int);
|
||||
|
@ -78,10 +78,10 @@ int sigdelset(sigset_t *, int);
|
||||
int sigemptyset(sigset_t *);
|
||||
int sigfillset(sigset_t *);
|
||||
int sigismember(const sigset_t *, int);
|
||||
int sigpending(sigset_t *);
|
||||
int sigpending(sigset_t *) __nonnull(1);
|
||||
int sigprocmask(int, const sigset_t * __restrict, sigset_t * __restrict);
|
||||
int sigsuspend(const sigset_t *);
|
||||
int sigwait(const sigset_t * __restrict, int * __restrict);
|
||||
int sigsuspend(const sigset_t *) __nonnull(1);
|
||||
int sigwait(const sigset_t * __restrict, int * __restrict) __nonnull_all;
|
||||
#endif
|
||||
|
||||
#if __POSIX_VISIBLE >= 199506 || __XSI_VISIBLE >= 600
|
||||
|
@ -87,21 +87,22 @@ int atoi(const char *);
|
||||
long atol(const char *);
|
||||
void *bsearch(const void *, const void *, size_t,
|
||||
size_t, int (*)(const void *, const void *));
|
||||
void *calloc(size_t, size_t) __malloc_like;
|
||||
void *calloc(size_t, size_t) __malloc_like __result_use_check
|
||||
__alloc_size(1) __alloc_size(2);
|
||||
div_t div(int, int) __pure2;
|
||||
_Noreturn void exit(int);
|
||||
void free(void *);
|
||||
char *getenv(const char *);
|
||||
long labs(long) __pure2;
|
||||
ldiv_t ldiv(long, long) __pure2;
|
||||
void *malloc(size_t) __malloc_like;
|
||||
void *malloc(size_t) __malloc_like __result_use_check __alloc_size(1);
|
||||
int mblen(const char *, size_t);
|
||||
size_t mbstowcs(wchar_t * __restrict , const char * __restrict, size_t);
|
||||
int mbtowc(wchar_t * __restrict, const char * __restrict, size_t);
|
||||
void qsort(void *, size_t, size_t,
|
||||
int (*)(const void *, const void *));
|
||||
int rand(void);
|
||||
void *realloc(void *, size_t);
|
||||
void *realloc(void *, size_t) __result_use_check __alloc_size(2);
|
||||
void srand(unsigned);
|
||||
double strtod(const char * __restrict, char ** __restrict);
|
||||
float strtof(const char * __restrict, char ** __restrict);
|
||||
@ -155,7 +156,7 @@ _Noreturn void _Exit(int);
|
||||
* If we're in a mode greater than C99, expose C11 functions.
|
||||
*/
|
||||
#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
|
||||
void * aligned_alloc(size_t, size_t) __malloc_like;
|
||||
void * aligned_alloc(size_t, size_t) __malloc_like __alloc_size(2);
|
||||
int at_quick_exit(void (*)(void));
|
||||
_Noreturn void
|
||||
quick_exit(int);
|
||||
@ -170,7 +171,8 @@ char *realpath(const char * __restrict, char * __restrict);
|
||||
int rand_r(unsigned *); /* (TSF) */
|
||||
#endif
|
||||
#if __POSIX_VISIBLE >= 200112
|
||||
int posix_memalign(void **, size_t, size_t); /* (ADV) */
|
||||
int posix_memalign(void **, size_t, size_t) __nonnull(1)
|
||||
__alloc_size(3); /* (ADV) */
|
||||
int setenv(const char *, const char *, int);
|
||||
int unsetenv(const char *);
|
||||
#endif
|
||||
@ -301,7 +303,7 @@ void qsort_r(void *, size_t, size_t, void *,
|
||||
int (*)(void *, const void *, const void *));
|
||||
int radixsort(const unsigned char **, int, const unsigned char *,
|
||||
unsigned);
|
||||
void *reallocf(void *, size_t);
|
||||
void *reallocf(void *, size_t) __result_use_check __alloc_size(2);
|
||||
int rpmatch(const char *);
|
||||
void setprogname(const char *);
|
||||
int sradixsort(const unsigned char **, int, const unsigned char *,
|
||||
|
Loading…
Reference in New Issue
Block a user