From 5f7a06c66e477d4e1f1462f3661ae125db8b315a Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Tue, 24 Oct 2017 15:24:35 +0300 Subject: [PATCH] Fixed non-portable usage of __solaris__ preprocessor definition GCC: this use of "defined" may not be portable [-Wexpansion-to-defined] Clang: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined] --- src/m_alloc.cpp | 8 ++++---- src/posix/i_system.h | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/m_alloc.cpp b/src/m_alloc.cpp index bec5581e3..d08913b85 100644 --- a/src/m_alloc.cpp +++ b/src/m_alloc.cpp @@ -54,14 +54,14 @@ #endif #if defined(__APPLE__) #define _msize(p) malloc_size(p) -#elif __solaris__ || defined(__OpenBSD__) +#elif defined(__solaris__) || defined(__OpenBSD__) #define _msize(p) (*((size_t*)(p)-1)) #elif !defined(_WIN32) #define _msize(p) malloc_usable_size(p) // from glibc/FreeBSD #endif #ifndef _DEBUG -#if !__solaris__ && !defined(__OpenBSD__) +#if !defined(__solaris__) && !defined(__OpenBSD__) void *M_Malloc(size_t size) { void *block = malloc(size); @@ -131,7 +131,7 @@ void *M_Realloc(void *memblock, size_t size) #include #endif -#if !__solaris__ && !defined(__OpenBSD__) +#if !defined(__solaris__) && !defined(__OpenBSD__) void *M_Malloc_Dbg(size_t size, const char *file, int lineno) { void *block = _malloc_dbg(size, _NORMAL_BLOCK, file, lineno); @@ -199,7 +199,7 @@ void *M_Realloc_Dbg(void *memblock, size_t size, const char *file, int lineno) #endif #endif -#if !__solaris__ && !defined(__OpenBSD__) +#if !defined(__solaris__) && !defined(__OpenBSD__) void M_Free (void *block) { if (block != NULL) diff --git a/src/posix/i_system.h b/src/posix/i_system.h index 9b29185a3..0649b7f3c 100644 --- a/src/posix/i_system.h +++ b/src/posix/i_system.h @@ -30,7 +30,9 @@ #include #include -#define __solaris__ (defined(__sun) || defined(__sun__) || defined(__SRV4) || defined(__srv4__)) +#if defined(__sun) || defined(__sun__) || defined(__SRV4) || defined(__srv4__) +#define __solaris__ 1 +#endif #include "doomtype.h"