Begun/lockfree-malloc — Issue #6: FreeBSD support
Author: zloidemon
Created: 2011-11-22 19:26:11+00:00
State: open

From 0a2d400d832e6d4f0735330ab796395755460184 Mon Sep 17 00:00:00 2001
From: Veniamin Gvozdikov
Date: Tue, 22 Nov 2011 19:08:39 +0000
Subject: [PATCH] added support FreeBSD

---
Makefile | 3 ++-
lite-hooks-wrap.h | 2 ++
lite-malloc.h | 7 ++++++-
3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 0fec297..add5b83 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,7 @@

# Please specify the directory with boost include files here.
-BOOST_INCLUDES = /usr/include
+PREFIX = /usr/local
+BOOST_INCLUDES = ${PREFIX}/include

CXX = g++
CFLAGS = -I$(BOOST_INCLUDES) -O3 -finline-functions -Wno-inline -Wall -pthread
diff --git a/lite-hooks-wrap.h b/lite-hooks-wrap.h
index 4c28ddf..ae8ed0e 100644
--- a/lite-hooks-wrap.h
+++ b/lite-hooks-wrap.h
@@ -16,7 +16,9 @@
#define __LOCKFREE_LITE_HOOKS_WRAP_H 1

#include "lite-malloc.h"
+#ifndef __FreeBSD__
#include
+#endif
#include

extern "C" {
diff --git a/lite-malloc.h b/lite-malloc.h
index 8e5a0c1..badd477 100644
--- a/lite-malloc.h
+++ b/lite-malloc.h
@@ -24,6 +24,11 @@
#include "l-singleton.h"
#include "stack.h"

+#ifdef __FreeBSD__
+#define __MAP_ANONYMOUS MAP_ANON
+#else
+#define __MAP_ANONYMOUS MAP_ANONYMOUS
+#endif

namespace lite
@@ -159,7 +164,7 @@ private:
void * p = mmap (hint,
size,
PROT_WRITE | PROT_READ,
- MAP_PRIVATE | MAP_ANONYMOUS | (hint ? MAP_FIXED : 0),
+ MAP_PRIVATE | __MAP_ANONYMOUS | (hint ? MAP_FIXED : 0),
-1 /*fd*/,
0);
return (char *) ((long) p == -1 ? 0 : p);
--
1.7.7.3