Lines 1-67
Link Here
|
1 |
--- src/shared.c.orig 2016-06-28 09:47:32 UTC |
|
|
2 |
+++ src/shared.c |
3 |
@@ -10,6 +10,11 @@ |
4 |
#include <stdio.h> |
5 |
#endif |
6 |
|
7 |
+#ifdef __FreeBSD__ |
8 |
+#include <stdio.h> |
9 |
+#include <pthread_np.h> |
10 |
+#endif |
11 |
+ |
12 |
#include <shared.h> |
13 |
#include <limits.h> |
14 |
|
15 |
@@ -2382,7 +2387,7 @@ int tty_fix() |
16 |
} |
17 |
#endif |
18 |
|
19 |
-#ifdef DARWIN |
20 |
+#if defined(DARWIN) || defined(__FreeBSD__) |
21 |
static struct termios savemodes; |
22 |
static int havemodes = 0; |
23 |
|
24 |
@@ -4371,6 +4376,23 @@ char *get_exec_path () |
25 |
|
26 |
const int len = strlen (exec_path); |
27 |
|
28 |
+ #elif __FreeBSD__ |
29 |
+ |
30 |
+ #include <sys/sysctl.h> |
31 |
+ |
32 |
+ int mib[4]; |
33 |
+ mib[0] = CTL_KERN; |
34 |
+ mib[1] = KERN_PROC; |
35 |
+ mib[2] = KERN_PROC_PATHNAME; |
36 |
+ mib[3] = -1; |
37 |
+ |
38 |
+ char tmp[32] = { 0 }; |
39 |
+ |
40 |
+ size_t size = exec_path_len; |
41 |
+ sysctl(mib, 4, exec_path, &size, NULL, 0); |
42 |
+ |
43 |
+ const int len = readlink (tmp, exec_path, exec_path_len - 1); |
44 |
+ |
45 |
#else |
46 |
#error Your Operating System is not supported or detected |
47 |
#endif |
48 |
@@ -4523,6 +4545,9 @@ void set_cpu_affinity (char *cpu_affinit |
49 |
{ |
50 |
#ifdef _WIN |
51 |
DWORD_PTR aff_mask = 0; |
52 |
+ #elif __FreeBSD__ |
53 |
+ cpuset_t cpuset; |
54 |
+ CPU_ZERO (&cpuset); |
55 |
#elif _POSIX |
56 |
cpu_set_t cpuset; |
57 |
CPU_ZERO (&cpuset); |
58 |
@@ -4570,6 +4595,9 @@ void set_cpu_affinity (char *cpu_affinit |
59 |
#ifdef _WIN |
60 |
SetProcessAffinityMask (GetCurrentProcess (), aff_mask); |
61 |
SetThreadAffinityMask (GetCurrentThread (), aff_mask); |
62 |
+ #elif __FreeBSD__ |
63 |
+ pthread_t thread = pthread_self (); |
64 |
+ pthread_setaffinity_np (thread, sizeof (cpuset_t), &cpuset); |
65 |
#elif _POSIX |
66 |
pthread_t thread = pthread_self (); |
67 |
pthread_setaffinity_np (thread, sizeof (cpu_set_t), &cpuset); |