Added attrs to internal-exported C API header

Remove -fanalyzer: Too many false positives

Fortune for cpprng's current commit: Middle blessing − 中吉
lib
Avril 3 years ago
parent 595fd74a97
commit ef25f978ff
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -24,7 +24,7 @@ LDFLAGS +=
STRIP=strip STRIP=strip
RELEASE_COMMON_FLAGS+= # -Werror RELEASE_COMMON_FLAGS+= # -Werror
DEBUG_COMMON_FLAGS+= -fanalyzer DEBUG_COMMON_FLAGS+=
ifneq ($(TARGET_SPEC_FLAGS),no) ifneq ($(TARGET_SPEC_FLAGS),no)
RELEASE_CFLAGS?= -O3 -flto $(OPT_FLAGS) RELEASE_CFLAGS?= -O3 -flto $(OPT_FLAGS)

@ -9,8 +9,10 @@ extern "C" {
#include <stddef.h> #include <stddef.h>
#include <stdlib.h> #include <stdlib.h>
#define IFUNC_IMPL(name, ver) _impl__ ## name ## __ ## ver #define IFUNC_NAME(name, ver) _impl__ ## name ## __ ## ver
#define IFUNC_RESOLVER(name) (*_ifun__ ## name (void)) #define IFUNC_IMPL(name, ver) __attribute__((copy(name))) IFUNC_NAME(name, ver)
#define IFUNC_RESOLVER_A(attr, name) __attribute__((returns_nonnull)) (* __attribute__(attr) _ifun__ ## name (void)) // When the ifunc resolver wants to return a function pointer that has attributes on it, the attribute inner list (e.g. `(returns_nonnull, const, nonnull)') can be provided as the first argument
#define IFUNC_RESOLVER(name) IFUNC_RESOLVER_A((copy(name)), name)
#define IFUNC_DEF(name, params) name params __attribute__((__ifunc__("_ifun__" #name))) #define IFUNC_DEF(name, params) name params __attribute__((__ifunc__("_ifun__" #name)))
#define _export(kind) __attribute__((visibility(#kind))) #define _export(kind) __attribute__((visibility(#kind)))

@ -93,7 +93,7 @@ namespace mem
return (*this = other.clone()); return (*this = other.clone());
} }
inline aligned_ptr(const aligned_ptr<T, H>& copy) : ptr(aligned_ptr_util::make<T>(copy.get())){} inline aligned_ptr(const aligned_ptr<T, H>& copy) : ptr(aligned_ptr_util::make<T>(copy.get())){}
T* const ptr; T* __restrict__ const ptr;
}; };
template<typename T, typename... Args> template<typename T, typename... Args>

@ -32,26 +32,26 @@ typedef __typeof(((struct jr_state*)NULL)->st) jr_xsub_t;
_Static_assert( sizeof(uint48_t) == (sizeof(uint16_t) * 3), "bad uint48 (ushort[3])"); _Static_assert( sizeof(uint48_t) == (sizeof(uint16_t) * 3), "bad uint48 (ushort[3])");
_Static_assert( sizeof(((struct jr_state*)NULL)->st) == sizeof(uint64_t), "bad uint64 (union st)"); _Static_assert( sizeof(((struct jr_state*)NULL)->st) == sizeof(uint64_t), "bad uint64 (union st)");
__attribute__((nonnull, returns_nonnull)) static unsigned short* IFUNC_DEF(_jr_st_resolv, (jr_xsub_t* restrict state)
__attribute__((const, nonnull, returns_nonnull)));
static unsigned short* IFUNC_IMPL(_jr_st_resolv, low) (jr_xsub_t* restrict state) static unsigned short* IFUNC_IMPL(_jr_st_resolv, low) (jr_xsub_t* restrict state)
{ {
return state->xsubi; return state->xsubi;
} }
__attribute__((nonnull, returns_nonnull))
static unsigned short* IFUNC_IMPL(_jr_st_resolv, high) (jr_xsub_t* restrict state) static unsigned short* IFUNC_IMPL(_jr_st_resolv, high) (jr_xsub_t* restrict state)
{ {
return state->xsubi+1; return state->xsubi+1;
} }
__attribute__((returns_nonnull)) __attribute__((const))
static unsigned short* IFUNC_RESOLVER(_jr_st_resolv) (jr_xsub_t* restrict state) static unsigned short* IFUNC_RESOLVER(_jr_st_resolv) (jr_xsub_t* restrict state)
{ {
struct jr_state chk = {0}; struct jr_state chk = {0};
chk.st.xsubh = JR_MAX; chk.st.xsubh = JR_MAX;
return chk.st._xsub return chk.st._xsub
? & IFUNC_IMPL(_jr_st_resolv, high) ? & IFUNC_NAME(_jr_st_resolv, high)
: & IFUNC_IMPL(_jr_st_resolv, low); : & IFUNC_NAME(_jr_st_resolv, low);
} }
static unsigned short* IFUNC_DEF(_jr_st_resolv, (jr_xsub_t* restrict state) __attribute__((nonnull, returns_nonnull)));
internal void _jr_seed(struct jr_state* restrict state, unsigned long with) internal void _jr_seed(struct jr_state* restrict state, unsigned long with)
{ {
@ -71,6 +71,7 @@ internal double _jr_procf(struct jr_state* restrict state)
return state->fresult; return state->fresult;
} }
__attribute__((malloc(_jr_free)))
internal struct jr_state* _jr_alloc() internal struct jr_state* _jr_alloc()
{ {
struct jr_state* bx = aligned_alloc(_Alignof(struct jr_state), sizeof(struct jr_state)); struct jr_state* bx = aligned_alloc(_Alignof(struct jr_state), sizeof(struct jr_state));
@ -78,7 +79,7 @@ internal struct jr_state* _jr_alloc()
return bx; return bx;
} }
__attribute__((malloc(_jr_free)))
internal struct jr_state* _jr_new(unsigned long with) internal struct jr_state* _jr_new(unsigned long with)
{ {
struct jr_state* state = _jr_alloc(); struct jr_state* state = _jr_alloc();

@ -14,10 +14,10 @@ struct jr_state;
void _jr_seed(struct jr_state* restrict state, unsigned long with) _export(internal); void _jr_seed(struct jr_state* restrict state, unsigned long with) _export(internal);
long _jr_proc(struct jr_state* restrict state) _export(internal); long _jr_proc(struct jr_state* restrict state) _export(internal);
double _jr_procf(struct jr_state* restrict state) _export(internal); double _jr_procf(struct jr_state* restrict state) _export(internal);
struct jr_state* _jr_alloc() _export(internal);
void _jr_free(struct jr_state* restrict state) _export(internal); void _jr_free(struct jr_state* restrict state) _export(internal);
struct jr_state* _jr_alloc() _export(internal) __attribute__((malloc(_jr_free)));
struct jr_state* _jr_new(unsigned long with) _export(internal); struct jr_state* _jr_new(unsigned long with) _export(internal) __attribute__((malloc(_jr_free)));
#ifdef __cplusplus #ifdef __cplusplus
} }

Loading…
Cancel
Save