mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 09:41:54 +00:00
Lib: Use access() function attribute
This commit is contained in:
parent
2d6fb31cd1
commit
c130b4e1ae
@ -78,6 +78,16 @@ static inline int u64_cmp(u64 i1, u64 i2)
|
|||||||
#define NONNULL(...) __attribute__((nonnull(__VA_ARGS__)))
|
#define NONNULL(...) __attribute__((nonnull(__VA_ARGS__)))
|
||||||
#define ALLOC_SIZE(...) __attribute__((alloc_size(__VA_ARGS__)))
|
#define ALLOC_SIZE(...) __attribute__((alloc_size(__VA_ARGS__)))
|
||||||
|
|
||||||
|
#if __GNUC_PREREQ(10, 0)
|
||||||
|
#define ACCESS_READ(...) __attribute__((access(read_only, __VA_ARGS__)))
|
||||||
|
#define ACCESS_WRITE(...) __attribute__((access(write_only, __VA_ARGS__)))
|
||||||
|
#define ACCESS_RW(...) __attribute__((access(read_write, __VA_ARGS__)))
|
||||||
|
#else
|
||||||
|
#define ACCESS_READ(...)
|
||||||
|
#define ACCESS_WRITE(...)
|
||||||
|
#define ACCESS_RW(...)
|
||||||
|
#endif
|
||||||
|
|
||||||
#define STATIC_ASSERT(EXP) _Static_assert(EXP, #EXP)
|
#define STATIC_ASSERT(EXP) _Static_assert(EXP, #EXP)
|
||||||
#define STATIC_ASSERT_MSG(EXP,MSG) _Static_assert(EXP, MSG)
|
#define STATIC_ASSERT_MSG(EXP,MSG) _Static_assert(EXP, MSG)
|
||||||
|
|
||||||
|
2
lib/ip.h
2
lib/ip.h
@ -398,7 +398,7 @@ typedef struct mpls_label_stack {
|
|||||||
u32 stack[MPLS_MAX_LABEL_STACK];
|
u32 stack[MPLS_MAX_LABEL_STACK];
|
||||||
} mpls_label_stack;
|
} mpls_label_stack;
|
||||||
|
|
||||||
static inline int
|
static inline int ACCESS_READ(1, 2)
|
||||||
mpls_get(const char *buf, int buflen, u32 *stack)
|
mpls_get(const char *buf, int buflen, u32 *stack)
|
||||||
{
|
{
|
||||||
for (int i=0; (i<MPLS_MAX_LABEL_STACK) && (i*4+3 < buflen); i++)
|
for (int i=0; (i<MPLS_MAX_LABEL_STACK) && (i*4+3 < buflen); i++)
|
||||||
|
@ -639,8 +639,8 @@ void net_normalize(net_addr *N);
|
|||||||
|
|
||||||
|
|
||||||
int net_classify(const net_addr *N);
|
int net_classify(const net_addr *N);
|
||||||
int net_format(const net_addr *N, char *buf, int buflen);
|
int net_format(const net_addr *N, char *buf, int buflen) ACCESS_WRITE(2, 3);
|
||||||
int rd_format(const u64 rd, char *buf, int buflen);
|
int rd_format(const u64 rd, char *buf, int buflen) ACCESS_WRITE(2, 3);
|
||||||
|
|
||||||
static inline int ipa_in_px4(ip4_addr a, ip4_addr prefix, uint pxlen)
|
static inline int ipa_in_px4(ip4_addr a, ip4_addr prefix, uint pxlen)
|
||||||
{ return ip4_zero(ip4_and(ip4_xor(a, prefix), ip4_mkmask(pxlen))); }
|
{ return ip4_zero(ip4_and(ip4_xor(a, prefix), ip4_mkmask(pxlen))); }
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
|
|
||||||
int bsprintf(char *str, const char *fmt, ...);
|
int bsprintf(char *str, const char *fmt, ...);
|
||||||
int bvsprintf(char *str, const char *fmt, va_list args);
|
int bvsprintf(char *str, const char *fmt, va_list args);
|
||||||
int bsnprintf(char *str, int size, const char *fmt, ...);
|
int bsnprintf(char *str, int size, const char *fmt, ...) ACCESS_WRITE(1, 2);
|
||||||
int bvsnprintf(char *str, int size, const char *fmt, va_list args);
|
int bvsnprintf(char *str, int size, const char *fmt, va_list args) ACCESS_WRITE(1, 2);
|
||||||
|
|
||||||
char *mb_sprintf(pool *p, const char *fmt, ...);
|
char *mb_sprintf(pool *p, const char *fmt, ...);
|
||||||
char *mb_vsprintf(pool *p, const char *fmt, va_list args);
|
char *mb_vsprintf(pool *p, const char *fmt, va_list args);
|
||||||
@ -34,7 +34,7 @@ u64 bstrtoul16(const char *str, char **end);
|
|||||||
byte bstrtobyte16(const char *str);
|
byte bstrtobyte16(const char *str);
|
||||||
|
|
||||||
int bstrhextobin(const char *s, byte *b);
|
int bstrhextobin(const char *s, byte *b);
|
||||||
int bstrbintohex(const byte *b, size_t len, char *buf, size_t size, char delim);
|
int bstrbintohex(const byte *b, size_t len, char *buf, size_t size, char delim) ACCESS_READ(1, 2) ACCESS_WRITE(3, 4);
|
||||||
|
|
||||||
int patmatch(const byte *pat, const byte *str);
|
int patmatch(const byte *pat, const byte *str);
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ struct adata *as_path_prepend2(struct linpool *pool, const struct adata *op, int
|
|||||||
struct adata *as_path_to_old(struct linpool *pool, const struct adata *path);
|
struct adata *as_path_to_old(struct linpool *pool, const struct adata *path);
|
||||||
struct adata *as_path_cut(struct linpool *pool, const struct adata *path, uint num);
|
struct adata *as_path_cut(struct linpool *pool, const struct adata *path, uint num);
|
||||||
const struct adata *as_path_merge(struct linpool *pool, const struct adata *p1, const struct adata *p2);
|
const struct adata *as_path_merge(struct linpool *pool, const struct adata *p1, const struct adata *p2);
|
||||||
void as_path_format(const struct adata *path, byte *buf, uint size);
|
void as_path_format(const struct adata *path, byte *buf, uint size) ACCESS_WRITE(2, 3);
|
||||||
int as_path_getlen(const struct adata *path);
|
int as_path_getlen(const struct adata *path);
|
||||||
int as_path_getlen_int(const struct adata *path, int bs);
|
int as_path_getlen_int(const struct adata *path, int bs);
|
||||||
int as_path_get_first(const struct adata *path, u32 *orig_as);
|
int as_path_get_first(const struct adata *path, u32 *orig_as);
|
||||||
@ -212,11 +212,11 @@ enum isf_way {
|
|||||||
ISF_ROUTER_ID,
|
ISF_ROUTER_ID,
|
||||||
};
|
};
|
||||||
|
|
||||||
int int_set_format(const struct adata *set, enum isf_way way, int from, byte *buf, uint size);
|
int int_set_format(const struct adata *set, enum isf_way way, int from, byte *buf, uint size) ACCESS_WRITE(4, 5);
|
||||||
int ec_format(byte *buf, u64 ec);
|
int ec_format(byte *buf, u64 ec);
|
||||||
int ec_set_format(const struct adata *set, int from, byte *buf, uint size);
|
int ec_set_format(const struct adata *set, int from, byte *buf, uint size) ACCESS_WRITE(3, 4);
|
||||||
int lc_format(byte *buf, lcomm lc);
|
int lc_format(byte *buf, lcomm lc);
|
||||||
int lc_set_format(const struct adata *set, int from, byte *buf, uint size);
|
int lc_set_format(const struct adata *set, int from, byte *buf, uint size) ACCESS_WRITE(3, 4);
|
||||||
int int_set_contains(const struct adata *list, u32 val);
|
int int_set_contains(const struct adata *list, u32 val);
|
||||||
int ec_set_contains(const struct adata *list, u64 val);
|
int ec_set_contains(const struct adata *list, u64 val);
|
||||||
int lc_set_contains(const struct adata *list, lcomm val);
|
int lc_set_contains(const struct adata *list, lcomm val);
|
||||||
|
Loading…
Reference in New Issue
Block a user