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]
This commit is contained in:
alexey.lysiuk 2017-10-24 15:24:35 +03:00
parent 1e7b692c77
commit 5f7a06c66e
2 changed files with 7 additions and 5 deletions

View file

@ -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 <crtdbg.h>
#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)

View file

@ -30,7 +30,9 @@
#include <dirent.h>
#include <ctype.h>
#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"