summaryrefslogtreecommitdiff
blob: c11cf69155064d59e6218b1ac7675d3715451e12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
From 3e793e9eac05ad926cc016da5129e95986d105f2 Mon Sep 17 00:00:00 2001
From: David Goulet <dgoulet@ev0ke.net>
Date: Mon, 13 Jun 2016 14:39:53 -0400
Subject: [PATCH] Add support for musl-libc

Musl library does not have a specific define so use __linux__ instead.

Signed-off-by: David Goulet <dgoulet@ev0ke.net>
---
 src/common/compat.c | 5 +++--
 src/common/compat.h | 5 +++--
 src/common/ref.h    | 5 +++--
 src/lib/torsocks.h  | 9 +++++----
 4 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/src/common/compat.c b/src/common/compat.c
index a861b3d..323f2ed 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -19,7 +19,8 @@
 
 #include "compat.h"
 
-#if (defined(__GLIBC__) || defined(__FreeBSD__) || defined(__darwin__) || defined(__NetBSD__))
+#if (defined(__linux__) || defined(__GLIBC__) || defined(__FreeBSD__) || \
+		defined(__darwin__) || defined(__NetBSD__))
 
 /*
  * Initialize a pthread mutex. This never fails.
@@ -96,4 +97,4 @@ void tsocks_once(tsocks_once_t *o, void (*init_routine)(void))
 	tsocks_mutex_unlock(&o->mutex);
 }
 
-#endif /* __GLIBC__, __darwin__, __FreeBSD__, __NetBSD__ */
+#endif /* __linux__, __GLIBC__, __darwin__, __FreeBSD__, __NetBSD__ */
diff --git a/src/common/compat.h b/src/common/compat.h
index ce47129..6c8ce32 100644
--- a/src/common/compat.h
+++ b/src/common/compat.h
@@ -22,7 +22,8 @@
 #define __darwin__	1
 #endif
 
-#if (defined(__GLIBC__) || defined(__FreeBSD__) || defined(__darwin__) || defined(__NetBSD__))
+#if (defined(__linux__) || defined(__GLIBC__) || defined(__FreeBSD__) || \
+		defined(__darwin__) || defined(__NetBSD__))
 
 #define RTLD_NEXT	((void *) -1)
 
@@ -55,7 +56,7 @@ void tsocks_once(tsocks_once_t *o, void (*init_routine)(void));
 
 #else
 #error "OS not supported."
-#endif /* __GLIBC__, __darwin__, __FreeBSD__, __NetBSD__ */
+#endif /* __linux__, __GLIBC__, __darwin__, __FreeBSD__, __NetBSD__ */
 
 #if defined(__linux__)
 #include <unistd.h>
diff --git a/src/common/ref.h b/src/common/ref.h
index 88aec2e..d9b9df8 100644
--- a/src/common/ref.h
+++ b/src/common/ref.h
@@ -26,7 +26,8 @@ struct ref {
 	long count;
 };
 
-#if (defined(__GLIBC__) || defined(__FreeBSD__) || defined(__darwin__) || defined(__NetBSD__))
+#if (defined(__linux__) || defined(__GLIBC__) || defined(__FreeBSD__) || \
+		defined(__darwin__) || defined(__NetBSD__))
 
 /*
  * Get a reference by incrementing the refcount.
@@ -57,6 +58,6 @@ static inline void ref_put(struct ref *r,
 
 #else
 #error "OS not supported"
-#endif /* __GLIBC__, __FreeBSD__, __darwin__ */
+#endif /* __linux__, __GLIBC__, __FreeBSD__, __darwin__, __NetBSD__ */
 
 #endif /* TORSOCKS_REF_H */
diff --git a/src/lib/torsocks.h b/src/lib/torsocks.h
index 076f3a5..0eeef2a 100644
--- a/src/lib/torsocks.h
+++ b/src/lib/torsocks.h
@@ -33,7 +33,8 @@
 #define TSOCKS_DECL(name, type, sig) \
 	extern type tsocks_##name(sig);
 
-#if (defined(__GLIBC__) || defined(__FreeBSD__) || defined(__darwin__) || defined(__NetBSD__))
+#if (defined(__linux__) || defined(__GLIBC__) || defined(__FreeBSD__) || \
+		defined(__darwin__) || defined(__NetBSD__))
 
 /* connect(2) */
 #include <sys/types.h>
@@ -207,7 +208,7 @@ struct hostent **result, int *h_errnop
 
 #else
 #error "OS not supported."
-#endif /* __GLIBC__ , __FreeBSD__, __darwin__, __NetBSD__ */
+#endif /* __linux__, __GLIBC__ , __FreeBSD__, __darwin__, __NetBSD__ */
 
 #if (defined(__linux__))
 
@@ -241,7 +242,7 @@ struct hostent **result, int *h_errnop
 
 #endif /* __FreeBSD__, __darwin__, __NetBSD__ */
 
-#if defined(__GLIBC__) && defined(__FreeBSD_kernel__)
+#if (defined(__linux__) || defined(__GLIBC__)) && defined(__FreeBSD_kernel__)
 
 /* syscall(2) */
 #define LIBC_SYSCALL_NAME syscall
@@ -250,7 +251,7 @@ struct hostent **result, int *h_errnop
 #define LIBC_SYSCALL_SIG long int number, ...
 #define LIBC_SYSCALL_ARGS number
 
-#endif /* __GLIBC__ && __FreeBSD_kernel__ */
+#endif /* (__linux__ || __GLIBC__) && __FreeBSD_kernel__ */
 
 /* __syscall(2) */
 #if defined(__FreeBSD__)