From 9a77e2df20483f2803e71c3a13ccf8e338c03cf0 Mon Sep 17 00:00:00 2001 From: Matt Staveley-Taylor Date: Mon, 18 Nov 2024 21:59:01 +0100 Subject: [PATCH] options/internal: make MLIBC_STUB_BODY a statement expression --- options/ansi/generic/stdio.cpp | 44 +++++++++++++------------- options/ansi/generic/string.cpp | 24 +++++++------- options/ansi/generic/uchar.cpp | 2 +- options/ansi/generic/wctype.cpp | 4 +-- options/internal/include/bits/ensure.h | 2 +- 5 files changed, 38 insertions(+), 38 deletions(-) diff --git a/options/ansi/generic/stdio.cpp b/options/ansi/generic/stdio.cpp index 2b8a55cb38..dd050408fc 100644 --- a/options/ansi/generic/stdio.cpp +++ b/options/ansi/generic/stdio.cpp @@ -891,20 +891,20 @@ int vsscanf(const char *__restrict buffer, const char *__restrict format, __buil return result; } -int fwprintf(FILE *__restrict, const wchar_t *__restrict, ...) MLIBC_STUB_BODY -int fwscanf(FILE *__restrict, const wchar_t *__restrict, ...) MLIBC_STUB_BODY -int vfwprintf(FILE *__restrict, const wchar_t *__restrict, __builtin_va_list) MLIBC_STUB_BODY -int vfwscanf(FILE *__restrict, const wchar_t *__restrict, __builtin_va_list) MLIBC_STUB_BODY +int fwprintf(FILE *__restrict, const wchar_t *__restrict, ...) { MLIBC_STUB_BODY; } +int fwscanf(FILE *__restrict, const wchar_t *__restrict, ...) { MLIBC_STUB_BODY; } +int vfwprintf(FILE *__restrict, const wchar_t *__restrict, __builtin_va_list) { MLIBC_STUB_BODY; } +int vfwscanf(FILE *__restrict, const wchar_t *__restrict, __builtin_va_list) { MLIBC_STUB_BODY; } -int swprintf(wchar_t *__restrict, size_t, const wchar_t *__restrict, ...) MLIBC_STUB_BODY -int swscanf(wchar_t *__restrict, const wchar_t *__restrict, ...) MLIBC_STUB_BODY -int vswprintf(wchar_t *__restrict, size_t, const wchar_t *__restrict, __builtin_va_list) MLIBC_STUB_BODY -int vswscanf(wchar_t *__restrict, const wchar_t *__restrict, __builtin_va_list) MLIBC_STUB_BODY +int swprintf(wchar_t *__restrict, size_t, const wchar_t *__restrict, ...) { MLIBC_STUB_BODY; } +int swscanf(wchar_t *__restrict, const wchar_t *__restrict, ...) { MLIBC_STUB_BODY; } +int vswprintf(wchar_t *__restrict, size_t, const wchar_t *__restrict, __builtin_va_list) { MLIBC_STUB_BODY; } +int vswscanf(wchar_t *__restrict, const wchar_t *__restrict, __builtin_va_list) { MLIBC_STUB_BODY; } -int wprintf(const wchar_t *__restrict, ...) MLIBC_STUB_BODY -int wscanf(const wchar_t *__restrict, ...) MLIBC_STUB_BODY -int vwprintf(const wchar_t *__restrict, __builtin_va_list) MLIBC_STUB_BODY -int vwscanf(const wchar_t *__restrict, __builtin_va_list) MLIBC_STUB_BODY +int wprintf(const wchar_t *__restrict, ...) { MLIBC_STUB_BODY; } +int wscanf(const wchar_t *__restrict, ...) { MLIBC_STUB_BODY; } +int vwprintf(const wchar_t *__restrict, __builtin_va_list) { MLIBC_STUB_BODY; } +int vwscanf(const wchar_t *__restrict, __builtin_va_list) { MLIBC_STUB_BODY; } int fgetc(FILE *stream) { char c; @@ -1014,16 +1014,16 @@ int puts(const char *string) { return 1; } -wint_t fgetwc(FILE *) MLIBC_STUB_BODY -wchar_t *fgetws(wchar_t *__restrict, int, FILE *__restrict) MLIBC_STUB_BODY -wint_t fputwc(wchar_t, FILE *) MLIBC_STUB_BODY -int fputws(const wchar_t *__restrict, FILE *__restrict) MLIBC_STUB_BODY -int fwide(FILE *, int) MLIBC_STUB_BODY -wint_t getwc(FILE *) MLIBC_STUB_BODY -wint_t getwchar(void) MLIBC_STUB_BODY -wint_t putwc(wchar_t, FILE *) MLIBC_STUB_BODY -wint_t putwchar(wchar_t) MLIBC_STUB_BODY -wint_t ungetwc(wint_t, FILE *) MLIBC_STUB_BODY +wint_t fgetwc(FILE *) { MLIBC_STUB_BODY; } +wchar_t *fgetws(wchar_t *__restrict, int, FILE *__restrict) { MLIBC_STUB_BODY; } +wint_t fputwc(wchar_t, FILE *) { MLIBC_STUB_BODY; } +int fputws(const wchar_t *__restrict, FILE *__restrict) { MLIBC_STUB_BODY; } +int fwide(FILE *, int) { MLIBC_STUB_BODY; } +wint_t getwc(FILE *) { MLIBC_STUB_BODY; } +wint_t getwchar(void) { MLIBC_STUB_BODY; } +wint_t putwc(wchar_t, FILE *) { MLIBC_STUB_BODY; } +wint_t putwchar(wchar_t) { MLIBC_STUB_BODY; } +wint_t ungetwc(wint_t, FILE *) { MLIBC_STUB_BODY; } size_t fread(void *buffer, size_t size, size_t count, FILE *file_base) { auto file = static_cast(file_base); diff --git a/options/ansi/generic/string.cpp b/options/ansi/generic/string.cpp index 8defd0e5ad..8ffde7aeb0 100644 --- a/options/ansi/generic/string.cpp +++ b/options/ansi/generic/string.cpp @@ -231,9 +231,9 @@ char *strchrnul(const char *s, int c) { return const_cast(s + i); } -double wcstod(const wchar_t *__restrict, wchar_t **__restrict) MLIBC_STUB_BODY -float wcstof(const wchar_t *__restrict, wchar_t **__restrict) MLIBC_STUB_BODY -long double wcstold(const wchar_t *__restrict, wchar_t **__restrict) MLIBC_STUB_BODY +double wcstod(const wchar_t *__restrict, wchar_t **__restrict) { MLIBC_STUB_BODY; } +float wcstof(const wchar_t *__restrict, wchar_t **__restrict) { MLIBC_STUB_BODY; } +long double wcstold(const wchar_t *__restrict, wchar_t **__restrict) { MLIBC_STUB_BODY; } long wcstol(const wchar_t *__restrict nptr, wchar_t **__restrict endptr, int base) { return mlibc::stringToInteger(nptr, endptr, base); @@ -277,16 +277,16 @@ wchar_t *wcscat(wchar_t *__restrict dest, const wchar_t *__restrict src) { return dest; } -wchar_t *wcsncat(wchar_t *__restrict, const wchar_t *__restrict, size_t) MLIBC_STUB_BODY +wchar_t *wcsncat(wchar_t *__restrict, const wchar_t *__restrict, size_t) { MLIBC_STUB_BODY; } int wcscmp(const wchar_t *l, const wchar_t *r) { for(; *l == *r && *l && *r; l++, r++); return *l - *r; } -int wcscoll(const wchar_t *, const wchar_t *) MLIBC_STUB_BODY -int wcsncmp(const wchar_t *, const wchar_t *, size_t) MLIBC_STUB_BODY -int wcsxfrm(wchar_t *__restrict, const wchar_t *__restrict, size_t) MLIBC_STUB_BODY +int wcscoll(const wchar_t *, const wchar_t *) { MLIBC_STUB_BODY; } +int wcsncmp(const wchar_t *, const wchar_t *, size_t) { MLIBC_STUB_BODY; } +int wcsxfrm(wchar_t *__restrict, const wchar_t *__restrict, size_t) { MLIBC_STUB_BODY; } int wmemcmp(const wchar_t *a, const wchar_t *b, size_t size) { for(size_t i = 0; i < size; i++) { @@ -307,8 +307,8 @@ wchar_t *wcschr(const wchar_t *s, wchar_t c) { return *s ? (wchar_t *)s : 0; } -size_t wcscspn(const wchar_t *, const wchar_t *) MLIBC_STUB_BODY -wchar_t *wcspbrk(const wchar_t *, const wchar_t *) MLIBC_STUB_BODY +size_t wcscspn(const wchar_t *, const wchar_t *) { MLIBC_STUB_BODY; } +wchar_t *wcspbrk(const wchar_t *, const wchar_t *) { MLIBC_STUB_BODY; } wchar_t *wcsrchr(const wchar_t *s, wchar_t c) { const wchar_t *p; @@ -316,9 +316,9 @@ wchar_t *wcsrchr(const wchar_t *s, wchar_t c) { return p >= s ? (wchar_t *)p : 0; } -size_t wcsspn(const wchar_t *, const wchar_t *) MLIBC_STUB_BODY -wchar_t *wcsstr(const wchar_t *, const wchar_t *) MLIBC_STUB_BODY -wchar_t *wcstok(wchar_t *__restrict, const wchar_t *__restrict, wchar_t **__restrict) MLIBC_STUB_BODY +size_t wcsspn(const wchar_t *, const wchar_t *) { MLIBC_STUB_BODY; } +wchar_t *wcsstr(const wchar_t *, const wchar_t *) { MLIBC_STUB_BODY; } +wchar_t *wcstok(wchar_t *__restrict, const wchar_t *__restrict, wchar_t **__restrict) { MLIBC_STUB_BODY; } wchar_t *wmemchr(const wchar_t *s, wchar_t c, size_t size) { auto s_bytes = s; diff --git a/options/ansi/generic/uchar.cpp b/options/ansi/generic/uchar.cpp index cb13c12f4d..f7b4b603a0 100644 --- a/options/ansi/generic/uchar.cpp +++ b/options/ansi/generic/uchar.cpp @@ -2,7 +2,7 @@ #include #include -size_t c32rtomb(char *, char32_t, mbstate_t *) MLIBC_STUB_BODY +size_t c32rtomb(char *, char32_t, mbstate_t *) { MLIBC_STUB_BODY; } size_t mbrtoc32(char32_t *__restrict pc32, const char *__restrict pmb, size_t max, mbstate_t *__restrict ps) { static mbstate_t internal_state; diff --git a/options/ansi/generic/wctype.cpp b/options/ansi/generic/wctype.cpp index 57dcbc9fd2..b89291da4b 100644 --- a/options/ansi/generic/wctype.cpp +++ b/options/ansi/generic/wctype.cpp @@ -4,6 +4,6 @@ #include #include -wctrans_t wctrans(const char *) MLIBC_STUB_BODY -wint_t towctrans(wint_t, wctrans_t) MLIBC_STUB_BODY +wctrans_t wctrans(const char *) { MLIBC_STUB_BODY; } +wint_t towctrans(wint_t, wctrans_t) { MLIBC_STUB_BODY; } diff --git a/options/internal/include/bits/ensure.h b/options/internal/include/bits/ensure.h index 17c96a8674..7bea3e2d0b 100644 --- a/options/internal/include/bits/ensure.h +++ b/options/internal/include/bits/ensure.h @@ -35,7 +35,7 @@ void __ensure_warn(const char *assertion, const char *file, unsigned int line, sysdep; \ }) -#define MLIBC_STUB_BODY { MLIBC_UNIMPLEMENTED(); __builtin_unreachable(); } +#define MLIBC_STUB_BODY ({ MLIBC_UNIMPLEMENTED(); __builtin_unreachable(); }) #ifdef __cplusplus }