Skip to content

Commit

Permalink
options/internal: make MLIBC_STUB_BODY a statement expression
Browse files Browse the repository at this point in the history
  • Loading branch information
64 committed Nov 18, 2024
1 parent 7b719b2 commit 9a77e2d
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 38 deletions.
44 changes: 22 additions & 22 deletions options/ansi/generic/stdio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<mlibc::abstract_file *>(file_base);
Expand Down
24 changes: 12 additions & 12 deletions options/ansi/generic/string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,9 @@ char *strchrnul(const char *s, int c) {
return const_cast<char *>(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<long, wchar_t>(nptr, endptr, base);
Expand Down Expand Up @@ -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++) {
Expand All @@ -307,18 +307,18 @@ 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;
for(p = s + wcslen(s); p >= s && *p != c; p--);
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;
Expand Down
2 changes: 1 addition & 1 deletion options/ansi/generic/uchar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <uchar.h>
#include <wchar.h>

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;
Expand Down
4 changes: 2 additions & 2 deletions options/ansi/generic/wctype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
#include <mlibc/debug.hpp>
#include <frg/string.hpp>

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; }

2 changes: 1 addition & 1 deletion options/internal/include/bits/ensure.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 9a77e2d

Please sign in to comment.