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 #endif
#if defined(__APPLE__) #if defined(__APPLE__)
#define _msize(p) malloc_size(p) #define _msize(p) malloc_size(p)
#elif __solaris__ || defined(__OpenBSD__) #elif defined(__solaris__) || defined(__OpenBSD__)
#define _msize(p) (*((size_t*)(p)-1)) #define _msize(p) (*((size_t*)(p)-1))
#elif !defined(_WIN32) #elif !defined(_WIN32)
#define _msize(p) malloc_usable_size(p) // from glibc/FreeBSD #define _msize(p) malloc_usable_size(p) // from glibc/FreeBSD
#endif #endif
#ifndef _DEBUG #ifndef _DEBUG
#if !__solaris__ && !defined(__OpenBSD__) #if !defined(__solaris__) && !defined(__OpenBSD__)
void *M_Malloc(size_t size) void *M_Malloc(size_t size)
{ {
void *block = malloc(size); void *block = malloc(size);
@ -131,7 +131,7 @@ void *M_Realloc(void *memblock, size_t size)
#include <crtdbg.h> #include <crtdbg.h>
#endif #endif
#if !__solaris__ && !defined(__OpenBSD__) #if !defined(__solaris__) && !defined(__OpenBSD__)
void *M_Malloc_Dbg(size_t size, const char *file, int lineno) void *M_Malloc_Dbg(size_t size, const char *file, int lineno)
{ {
void *block = _malloc_dbg(size, _NORMAL_BLOCK, file, 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
#endif #endif
#if !__solaris__ && !defined(__OpenBSD__) #if !defined(__solaris__) && !defined(__OpenBSD__)
void M_Free (void *block) void M_Free (void *block)
{ {
if (block != NULL) if (block != NULL)

View file

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