From 3a1343fb062adeca3940f79b433359950bbcaad9 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Thu, 2 Aug 2012 10:49:32 -0600 Subject: [PATCH] add support for FreeBSD on x86_64 --- makefile | 1 + src/posix.cpp | 2 +- src/x86.h | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/makefile b/makefile index 2a91344f2e..ae1ff9a240 100755 --- a/makefile +++ b/makefile @@ -6,6 +6,7 @@ version = 0.6 build-arch := $(shell uname -m \ | sed 's/^i.86$$/i386/' \ | sed 's/^x86pc$$/i386/' \ + | sed 's/amd64/x86_64/' \ | sed 's/^arm.*$$/arm/' \ | sed 's/ppc/powerpc/') diff --git a/src/posix.cpp b/src/posix.cpp index afa4c0ca38..1394a26886 100644 --- a/src/posix.cpp +++ b/src/posix.cpp @@ -627,7 +627,7 @@ class MySystem: public System { } virtual void* tryAllocateExecutable(unsigned sizeInBytes) { -#if (! defined __APPLE__) && (defined __x86_64__) +#ifdef MAP_32BIT // map to the lower 32 bits of memory when possible so as to avoid // expensive relative jumps const unsigned Extra = MAP_32BIT; diff --git a/src/x86.h b/src/x86.h index 42cf083d77..bda55bee7d 100644 --- a/src/x86.h +++ b/src/x86.h @@ -123,6 +123,12 @@ dynamicCall(void* function, uintptr_t* arguments, uint8_t*, # define FRAME_REGISTER(context) \ THREAD_STATE_FRAME(context->uc_mcontext->FIELD(ss)) +# elif (defined __FreeBSD__) +# define IP_REGISTER(context) (context->uc_mcontext.mc_rip) +# define STACK_REGISTER(context) (context->uc_mcontext.mc_rsp) +# define THREAD_REGISTER(context) (context->uc_mcontext.mc_rbx) +# define LINK_REGISTER(context) (context->uc_mcontext.mc_rcx) +# define FRAME_REGISTER(context) (context->uc_mcontext.mc_rbp) # else # define IP_REGISTER(context) (context->uc_mcontext.gregs[REG_RIP]) # define STACK_REGISTER(context) (context->uc_mcontext.gregs[REG_RSP])