diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-04-16 10:37:49 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-04-16 10:37:49 +0200 |
commit | ca620251b1233d9147e4820ed38871a8c23a8dc2 (patch) | |
tree | 2a858c76a12ede956748631961ac7a1d0ce7f96e /include | |
parent | 24195dca7e574f54e0ef1177a61df0ca1c00eeb0 (diff) |
Don’t dunder attributes
Diffstat (limited to 'include')
-rw-r--r-- | include/_attrs.h | 5 | ||||
-rw-r--r-- | include/alloc.h | 5 | ||||
-rw-r--r-- | include/errors.h | 6 | ||||
-rw-r--r-- | include/mbstring.h | 20 | ||||
-rw-r--r-- | include/optparse.h | 4 | ||||
-rw-r--r-- | include/unicode/prop.h | 2 | ||||
-rw-r--r-- | include/unicode/string.h | 20 |
7 files changed, 30 insertions, 32 deletions
diff --git a/include/_attrs.h b/include/_attrs.h index d3ab3e8..28640a4 100644 --- a/include/_attrs.h +++ b/include/_attrs.h @@ -1,8 +1,7 @@ #ifndef MLIB__ATTRS_H #define MLIB__ATTRS_H -#define _mlib_pure __nodiscard__, __unsequenced__ -#define _mlib_inline gnu::__always_inline__, clang::__always_inline__ -#define _mlib_printf(n, m) gnu::__format__(printf, n, m) +#define _mlib_inline gnu::always_inline, clang::always_inline +#define _mlib_pure nodiscard, unsequenced #endif /* !MLIB__ATTRS_H */ diff --git a/include/alloc.h b/include/alloc.h index 0855e01..0237334 100644 --- a/include/alloc.h +++ b/include/alloc.h @@ -20,7 +20,7 @@ typedef struct { size_t _init; } arena; -[[gnu::__returns_nonnull__]] void *bufalloc(void *, size_t, size_t); +[[gnu::returns_nonnull]] void *bufalloc(void *, size_t, size_t); void *bufalloc_noterm(void *, size_t, size_t); [[_mlib_pure, _mlib_inline]] @@ -30,8 +30,9 @@ mkarena(size_t n) return (arena){._init = n ? n : MLIB_ARENA_BLKSIZE}; } -[[gnu::__malloc__, gnu::__alloc_size__(2, 3), gnu::__alloc_align__(4)]] +[[gnu::malloc, gnu::alloc_size(2, 3), gnu::alloc_align(4)]] void *arena_alloc(arena *, size_t, size_t, size_t); + void arena_zero(arena *); void arena_free(arena *); diff --git a/include/errors.h b/include/errors.h index 1cd6b70..dfd092a 100644 --- a/include/errors.h +++ b/include/errors.h @@ -5,11 +5,11 @@ #include "_attrs.h" -[[_mlib_printf(1, 2)]] void warn(const char *, ...); +[[gnu::format(printf, 1, 2)]] void warn(const char *, ...); void vwarn(const char *, va_list); -[[__noreturn__, _mlib_printf(1, 2)]] void err(const char *, ...); -[[__noreturn__, _mlib_printf(2, 3)]] void cerr(int, const char *, ...); +[[noreturn, gnu::format(printf, 1, 2)]] void err(const char *, ...); +[[noreturn, gnu::format(printf, 2, 3)]] void cerr(int, const char *, ...); extern const char *__mlib_errors_progname; diff --git a/include/mbstring.h b/include/mbstring.h index 277586e..7e3f453 100644 --- a/include/mbstring.h +++ b/include/mbstring.h @@ -30,28 +30,26 @@ constexpr int U8_LEN_MAX = 4; #define PRIsU8 ".*s" #define U8_PRI_ARGS(sv) ((int)(sv).len), ((sv).p) -[[__nodiscard__]] bool u8haspfx(const char8_t *, size_t, const char8_t *, - size_t); -[[__nodiscard__]] bool u8hassfx(const char8_t *, size_t, const char8_t *, - size_t); +[[nodiscard]] bool u8haspfx(const char8_t *, size_t, const char8_t *, size_t); +[[nodiscard]] bool u8hassfx(const char8_t *, size_t, const char8_t *, size_t); -[[__nodiscard__]] char8_t *u8chk(const char8_t *, size_t); +[[nodiscard]] char8_t *u8chk(const char8_t *, size_t); -[[__nodiscard__]] char8_t *u8chr(const char8_t *, size_t, rune); -[[__nodiscard__]] char8_t *u8rchr(const char8_t *, size_t, rune); +[[nodiscard]] char8_t *u8chr(const char8_t *, size_t, rune); +[[nodiscard]] char8_t *u8rchr(const char8_t *, size_t, rune); int rtou8(char8_t *, size_t, rune); int u8tor(rune *, const char8_t *); -[[__nodiscard__]] int u8cmp(const char8_t *, size_t, const char8_t *, size_t); +[[nodiscard]] int u8cmp(const char8_t *, size_t, const char8_t *, size_t); int u8next(rune *, const char8_t **, size_t *); int u8prev(rune *, const char8_t **, const char8_t *); -[[__nodiscard__]] size_t u8spn(const char8_t *, size_t, const rune *, size_t); -[[__nodiscard__]] size_t u8cspn(const char8_t *, size_t, const rune *, size_t); +[[nodiscard]] size_t u8spn(const char8_t *, size_t, const rune *, size_t); +[[nodiscard]] size_t u8cspn(const char8_t *, size_t, const rune *, size_t); -[[__nodiscard__]] size_t u8len(const char8_t *, size_t); +[[nodiscard]] size_t u8len(const char8_t *, size_t); #define u8chk(s, n) __MLIB_Q_PTR(char8_t, u8chk, (s), (s), (n)) #define u8chr(s, n, ch) __MLIB_Q_PTR(char8_t, u8chr, (s), (s), (n), (ch)) diff --git a/include/optparse.h b/include/optparse.h index 9fce9e7..5f7eafd 100644 --- a/include/optparse.h +++ b/include/optparse.h @@ -30,8 +30,8 @@ struct op_option { enum op_argkind argtype; }; -[[__nodiscard__]] rune optparse(struct optparse *, const struct op_option *, - size_t); +[[nodiscard]] rune optparse(struct optparse *, const struct op_option *, + size_t); [[_mlib_inline]] static inline struct optparse diff --git a/include/unicode/prop.h b/include/unicode/prop.h index 485a0cb..e3e0d5e 100644 --- a/include/unicode/prop.h +++ b/include/unicode/prop.h @@ -482,7 +482,7 @@ enum uprop_ea { EA_W, /* Narrow */ }; -enum [[clang::__flag_enum__]] uprop_gc : uint_least32_t { +enum [[clang::flag_enum]] uprop_gc : uint_least32_t { GC_CN = UINT32_C(1) << 0, /* Not Assigned */ GC_CC = UINT32_C(1) << 1, /* Control */ GC_CF = UINT32_C(1) << 2, /* Format */ diff --git a/include/unicode/string.h b/include/unicode/string.h index 96fef13..81c2aff 100644 --- a/include/unicode/string.h +++ b/include/unicode/string.h @@ -8,7 +8,7 @@ /* clang-format off */ -enum [[clang::__flag_enum__]] caseflags { +enum [[clang::flag_enum]] caseflags { CF_LANG_AZ = 1 << 0, /* Azeri; alias for CF_LANG_TR */ CF_LANG_TR = 1 << 0, /* Turkish; alias for CF_LANG_AZ */ CF_LANG_LT = 1 << 1, /* Lithuanian */ @@ -17,16 +17,16 @@ enum [[clang::__flag_enum__]] caseflags { /* clang-format on */ -[[__nodiscard__]] size_t u8glen(const char8_t *, size_t); +[[nodiscard]] size_t u8glen(const char8_t *, size_t); size_t u8gnext(struct u8view *, const char8_t **, size_t *); -#define _mlib_warn_trunc __nodiscard__("don’t forget to check for truncation") - -[[_mlib_warn_trunc]] size_t u8casefold(char8_t *restrict, size_t, - const char8_t *, size_t, enum caseflags); -[[_mlib_warn_trunc]] size_t u8lower(char8_t *restrict, size_t, const char8_t *, - size_t, enum caseflags); -[[_mlib_warn_trunc]] size_t u8upper(char8_t *restrict, size_t, const char8_t *, - size_t, enum caseflags); +#define mlib_warn_trunc nodiscard("don’t forget to check for truncation") +[[mlib_warn_trunc]] size_t u8casefold(char8_t *restrict, size_t, + const char8_t *, size_t, enum caseflags); +[[mlib_warn_trunc]] size_t u8lower(char8_t *restrict, size_t, const char8_t *, + size_t, enum caseflags); +[[mlib_warn_trunc]] size_t u8upper(char8_t *restrict, size_t, const char8_t *, + size_t, enum caseflags); +#undef mlib_warn_trunc #endif /* !MLIB_UNICODE_STRING_H */ |