commit 3eef0073a9b4460b62a62e9d0556667cb475da3b Author: Jérémy Bobbio lunar@debian.org Date: Fri Oct 25 09:48:22 2013 -0400
Add compatibility with GNU/kFreeBSD
Signed-off-by: Jérémy Bobbio lunar@debian.org Signed-off-by: David Goulet dgoulet@ev0ke.net --- src/common/compat.c | 4 ++-- src/common/compat.h | 10 ++++++---- src/common/ref.h | 4 ++-- src/lib/torsocks.h | 15 +++++++++++++-- 4 files changed, 23 insertions(+), 10 deletions(-)
diff --git a/src/common/compat.c b/src/common/compat.c index 5e3cf77..b4cdd1d 100644 --- a/src/common/compat.c +++ b/src/common/compat.c @@ -19,7 +19,7 @@
#include "compat.h"
-#if (defined(__linux__) || defined(__FreeBSD__) || defined(__darwin__)) +#if (defined(__GLIBC__) || defined(__FreeBSD__) || defined(__darwin__))
/* * Initialize a pthread mutex. This never fails. @@ -71,4 +71,4 @@ void tsocks_mutex_unlock(tsocks_mutex_t *m) assert(!ret); }
-#endif /* __linux__, __darwin__, __FreeBSD__ */ +#endif /* __GLIBC__, __darwin__, __FreeBSD__ */ diff --git a/src/common/compat.h b/src/common/compat.h index 31de549..8207fc0 100644 --- a/src/common/compat.h +++ b/src/common/compat.h @@ -22,7 +22,7 @@ #define __darwin__ 1 #endif
-#if (defined(__linux__) || defined(__FreeBSD__) || defined(__darwin__)) +#if (defined(__GLIBC__) || defined(__FreeBSD__) || defined(__darwin__))
#define RTLD_NEXT ((void *) -1)
@@ -41,7 +41,9 @@ void tsocks_mutex_destroy(tsocks_mutex_t *m); void tsocks_mutex_lock(tsocks_mutex_t *m); void tsocks_mutex_unlock(tsocks_mutex_t *m);
-#endif /* __linux__, __darwin__, __FreeBSD__ */ +#else +#error "OS not supported." +#endif /* __GLIBC__, __darwin__, __FreeBSD__ */
#if defined(__linux__)
@@ -74,7 +76,7 @@ void tsocks_mutex_unlock(tsocks_mutex_t *m);
#endif /* __linux__ */
-#if (defined(__FreeBSD__) || defined(__darwin__)) +#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__darwin__))
#include <sys/syscall.h> #include <unistd.h> @@ -83,6 +85,6 @@ void tsocks_mutex_unlock(tsocks_mutex_t *m); #define TSOCKS_NR_CONNECT SYS_connect #define TSOCKS_NR_CLOSE SYS_close
-#endif /* __FreeBSD__, __darwin__ */ +#endif /* __FreeBSD__, __FreeBSD_kernel__, __darwin__ */
#endif /* TORSOCKS_COMPAT_H */ diff --git a/src/common/ref.h b/src/common/ref.h index c7b878f..f80fd19 100644 --- a/src/common/ref.h +++ b/src/common/ref.h @@ -26,7 +26,7 @@ struct ref { long count; };
-#if (defined(__linux__) || defined(__FreeBSD__) || defined(__darwin__)) +#if (defined(__GLIBC__) || defined(__FreeBSD__) || defined(__darwin__))
/* * Get a reference by incrementing the refcount. @@ -57,6 +57,6 @@ static inline void ref_put(struct ref *r,
#else #error "OS not supported" -#endif /* __linux__, __FreeBSD__, __darwin__ */ +#endif /* __GLIBC__, __FreeBSD__, __darwin__ */
#endif /* TORSOCKS_REF_H */ diff --git a/src/lib/torsocks.h b/src/lib/torsocks.h index 4adf532..a931d2a 100644 --- a/src/lib/torsocks.h +++ b/src/lib/torsocks.h @@ -33,7 +33,7 @@ #define TSOCKS_DECL(name, type, sig) \ extern type tsocks_##name(sig);
-#if (defined(__linux__) || defined(__FreeBSD__) || defined(__darwin__)) +#if (defined(__GLIBC__) || defined(__FreeBSD__) || defined(__darwin__))
/* connect(2) */ #include <sys/types.h> @@ -171,7 +171,7 @@ struct hostent **__result, int *__h_errnop
#else #error "OS not supported." -#endif /* __linux__ , __FreeBSD__, __darwin__ */ +#endif /* __GLIBC__ , __FreeBSD__, __darwin__ */
#if (defined(__linux__))
@@ -197,6 +197,17 @@ struct hostent **__result, int *__h_errnop
#endif /* __FreeBSD__, __darwin__ */
+#if defined(__GLIBC__) && defined(__FreeBSD_kernel__) + +/* syscall(2) */ +#define LIBC_SYSCALL_NAME syscall +#define LIBC_SYSCALL_NAME_STR XSTR(LIBC_SYSCALL_NAME) +#define LIBC_SYSCALL_RET_TYPE long int +#define LIBC_SYSCALL_SIG long int __number, ... +#define LIBC_SYSCALL_ARGS __number + +#endif /* __GLIBC__ && __FreeBSD_kernel__ */ + /* * The following defines are libc function declarations using the macros * defined above on a per OS basis.
tor-commits@lists.torproject.org