diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-01-27 23:26:42 +0100 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-01-27 23:26:42 +0100 |
commit | 679f7928e27a95e559eb3a69febf0c6336e40234 (patch) | |
tree | af9c5bb35253086eb8e3ad3d7774e7349b3beefe /vendor/librune/include/internal/qmacros.h | |
parent | fd502fd87b40ae7f60314d8d9009f739f1c5fcf3 (diff) |
Bump librune
Diffstat (limited to 'vendor/librune/include/internal/qmacros.h')
-rw-r--r-- | vendor/librune/include/internal/qmacros.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/vendor/librune/include/internal/qmacros.h b/vendor/librune/include/internal/qmacros.h new file mode 100644 index 0000000..5369c48 --- /dev/null +++ b/vendor/librune/include/internal/qmacros.h @@ -0,0 +1,25 @@ +#ifndef RUNE_INTERNAL_QMACROS_H +#define RUNE_INTERNAL_QMACROS_H + +/* Macros for qualifier-preserving functions. These are wrappers around some + functions declared above which will return a const-qualified pointer if the + input string is const-qualified, and a non-const-qualified pointer otherwise. + + The macros are taken from the N3020 proposal for C23. */ + +/* clang-format off */ +#define _RUNE_PTR_IS_CONST(P) \ + _Generic(1 ? (P) : (void *)(P), \ + const void *: 1, \ + default: 0) +#define _RUNE_STATIC_IF(P, T, E) \ + _Generic(&(char[!!(P) + 1]){0}, \ + char(*)[2]: T, \ + char(*)[1]: E) +#define _RUNE_Q_PTR(F, S, ...) \ + _RUNE_STATIC_IF(_RUNE_PTR_IS_CONST((S)), \ + (const char8_t *)(F)(__VA_ARGS__), \ + ( char8_t *)(F)(__VA_ARGS__)) +/* clang-format on */ + +#endif /* !RUNE_INTERNAL_QMACROS_H */ |