Skip to content

Commit d983034

Browse files
committed
#168 changes to compile on freebsd 11
1 parent beb98c0 commit d983034

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

setup.py

+15-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ def run(self):
1212

1313
BASEDIR = os.path.dirname(os.path.abspath(__file__))
1414

15+
def _supported_unix():
16+
if sys.platform.startswith('linux'):
17+
return 'linux'
18+
if sys.platform.startswith('freebsd'):
19+
return 'bsd'
20+
return False
21+
1522
if IS_PYPY:
1623
ext_modules = [] # built-in
1724
else:
@@ -35,14 +42,19 @@ def run(self):
3542
extra_compile_args += ['-g']
3643
extra_compile_args += ['-O2']
3744
extra_source_files += ['src/vmprof_unix.c', 'src/vmprof_mt.c']
38-
elif sys.platform.startswith('linux'):
45+
elif _supported_unix():
3946
libraries = ['dl','unwind']
4047
extra_compile_args = ['-Wno-unused']
41-
extra_compile_args += ['-DVMPROF_LINUX=1']
48+
if _supported_unix() == 'linux':
49+
extra_compile_args += ['-DVMPROF_LINUX=1']
50+
if _supported_unix() == 'bsd':
51+
libraries = ['unwind']
52+
extra_compile_args += ['-DVMPROF_BSD=1']
53+
extra_compile_args += ['-I/usr/local/include']
4254
extra_compile_args += ['-DVMPROF_UNIX=1']
4355
if platform.machine().startswith("arm"):
4456
libraries.append('unwind-arm')
45-
elif platform.machine().startswith("x86"):
57+
elif platform.machine().startswith("x86") or platform.machine().startswith("amd64"):
4658
if sys.maxsize == 2**63-1:
4759
libraries.append('unwind-x86_64')
4860
else:

src/vmp_stack.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
#ifdef VMP_SUPPORTS_NATIVE_PROFILING
1818

19-
#ifdef VMPROF_LINUX
19+
#if defined(VMPROF_LINUX) || defined(VMPROF_BSD)
2020
#include "unwind/vmprof_unwind.h"
2121
typedef mcontext_t unw_context_t;
2222

src/vmprof_common.h

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
#include <syscall.h>
2424
#endif
2525

26+
#ifdef VMPROF_BSD
27+
#include <sys/syscall.h>
28+
#endif
29+
2630
#define MAX_FUNC_NAME 1024
2731

2832
#ifdef VMPROF_UNIX

0 commit comments

Comments
 (0)