From 7a1f842b91af4f916501eaea991b897e3db4c502 Mon Sep 17 00:00:00 2001 From: Mosder Date: Mon, 28 Sep 2026 13:27:35 +0200 Subject: refactor: prefixed compat functions (and added a macro to libc implementations - if they exist), so they do not take reserved names anymore --- compat/compat.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'compat/compat.h') diff --git a/compat/compat.h b/compat/compat.h index 3e46993..5f9424d 100644 --- a/compat/compat.h +++ b/compat/compat.h @@ -6,15 +6,20 @@ #define _GNU_SOURCE -typedef void declaration; +// In C99 TU needs a declaration (which won't be the case if all functions are available) +typedef void mos_compat_decl; -#ifdef NO_STRDUP -extern char *strdup(const char *s); +#ifndef NO_STRDUP +#define mos_strdup strdup +#else +extern char *mos_strdup(const char *s); #endif // NO_STRDUP -#ifdef NO_MEMMEM +#ifndef NO_MEMMEM +#define mos_memmem memmem +#else #include -extern void *memmem(const void *h, size_t h_size, const void *n, size_t n_size); +extern void *mos_memmem(const void *h, size_t h_size, const void *n, size_t n_size); #endif // NO_MEMMEM #endif // MOSLIB_COMPAT_H -- cgit v1.2.3