From 969973e3cdc2414566e2525a9c77c198b4c77bc6 Mon Sep 17 00:00:00 2001 From: falkTX Date: Sat, 22 Apr 2023 22:28:16 +0200 Subject: [PATCH] Cleanup, remove old mingw stdio hacks Signed-off-by: falkTX --- include/mingw-compat/cstdio | 58 ------------------------- include/mingw-compat/{stdio.h => mutex} | 24 +++------- include/mingw-compat/thread | 25 +++++++++++ 3 files changed, 32 insertions(+), 75 deletions(-) delete mode 100644 include/mingw-compat/cstdio rename include/mingw-compat/{stdio.h => mutex} (51%) create mode 100644 include/mingw-compat/thread diff --git a/include/mingw-compat/cstdio b/include/mingw-compat/cstdio deleted file mode 100644 index bdcb7e8..0000000 --- a/include/mingw-compat/cstdio +++ /dev/null @@ -1,58 +0,0 @@ -/* - * DISTRHO Cardinal Plugin - * Copyright (C) 2021 Filipe Coelho - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 3 of - * the License, or any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * For a full copy of the GNU General Public License see the LICENSE file. - */ - -#pragma once - -/* On mingw stdio functions like printf are not inline, and thus get defined every time they are used. - * Its also does `#undef printf` which invalidates our macros :( - * We go through a few steps to ensure unique symbol names. - */ -#ifdef STDIO_OVERRIDE - -// helper macros -# define STDIO_OVERRIDE_HELPER(NS, SEP, FN) NS ## SEP ## FN -# define STDIO_OVERRIDE_MACRO(NS, FN) STDIO_OVERRIDE_HELPER(NS, _, FN) - -// step 1: prefix the needed stdio functions -# define printf STDIO_OVERRIDE_MACRO(STDIO_OVERRIDE, printf) - -// step 2: inlude which will use our prefixed names -# include - -// step 3: undef and define dummy functions required for (it uses `using ::printf` syntax) -# undef printf -static inline void printf() {} - -// step 4: we can safely include now -# include_next - -// step 5: define the same macros as in step 1 -# define printf STDIO_OVERRIDE_MACRO(STDIO_OVERRIDE, printf) - -// step 6: place the macro prefixed names in std namespace -/* -namespace std { - using ::printf; -} -*/ - -#else // STDIO_OVERRIDE - -// if STDIO_OVERRIDE is not defined, we have nothing to do -# include_next - -#endif // STDIO_OVERRIDE diff --git a/include/mingw-compat/stdio.h b/include/mingw-compat/mutex similarity index 51% rename from include/mingw-compat/stdio.h rename to include/mingw-compat/mutex index ea67f0d..ae24f4f 100644 --- a/include/mingw-compat/stdio.h +++ b/include/mingw-compat/mutex @@ -1,6 +1,6 @@ /* * DISTRHO Cardinal Plugin - * Copyright (C) 2021 Filipe Coelho + * Copyright (C) 2021-2023 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -16,20 +16,10 @@ */ #pragma once +#include_next -/* On mingw stdio functions like printf are not inline, and thus get defined every time they are used. - * We go through a few steps to ensure unique symbol names. - */ -#ifdef STDIO_OVERRIDE - -// helper macros -# define STDIO_OVERRIDE_HELPER(NS, SEP, FN) NS ## SEP ## FN -# define STDIO_OVERRIDE_MACRO(NS, FN) STDIO_OVERRIDE_HELPER(NS, _, FN) - -// prefix the needed stdio functions -# define printf STDIO_OVERRIDE_MACRO(STDIO_OVERRIDE, printf) - -#endif // STDIO_OVERRIDE - -// now just include the real stdio.h -#include_next +// fix macro pollution from Windows headers +#undef IN +#undef OUT +#undef far +#undef near diff --git a/include/mingw-compat/thread b/include/mingw-compat/thread new file mode 100644 index 0000000..24fb7d2 --- /dev/null +++ b/include/mingw-compat/thread @@ -0,0 +1,25 @@ +/* + * DISTRHO Cardinal Plugin + * Copyright (C) 2021-2023 Filipe Coelho + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 3 of + * the License, or any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * For a full copy of the GNU General Public License see the LICENSE file. + */ + +#pragma once +#include_next + +// fix macro pollution from Windows headers +#undef IN +#undef OUT +#undef far +#undef near