OpenBSD support

This commit is contained in:
David Carlier 2017-07-25 05:59:10 +01:00 committed by Rachael Alexanderson
commit 64e96c5f46
10 changed files with 23 additions and 21 deletions

View file

@ -38,6 +38,8 @@
#elif defined(__APPLE__)
#include <stdlib.h>
#include <malloc/malloc.h>
#elif defined(__OpenBSD__)
#include <stdlib.h>
#else
#include <malloc.h>
#endif
@ -52,14 +54,14 @@
#endif
#if defined(__APPLE__)
#define _msize(p) malloc_size(p)
#elif defined(__sun)
#elif __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 !defined(__sun)
#if !__solaris__ && !defined(__OpenBSD__)
void *M_Malloc(size_t size)
{
void *block = malloc(size);
@ -129,7 +131,7 @@ void *M_Realloc(void *memblock, size_t size)
#include <crtdbg.h>
#endif
#if !defined(__sun)
#if !__solaris__ && !defined(__OpenBSD__)
void *M_Malloc_Dbg(size_t size, const char *file, int lineno)
{
void *block = _malloc_dbg(size, _NORMAL_BLOCK, file, lineno);
@ -197,7 +199,7 @@ void *M_Realloc_Dbg(void *memblock, size_t size, const char *file, int lineno)
#endif
#endif
#if !defined(__sun)
#if !__solaris__ && !defined(__OpenBSD__)
void M_Free (void *block)
{
if (block != NULL)