[tor-commits] [torsocks/master] Add NetBSD support

dgoulet at torproject.org dgoulet at torproject.org
Fri Apr 4 22:40:27 UTC 2014


commit 6adfba809267d9c217906d6974468db22293ab9b
Author: Thomas Klausner <wiz at NetBSD.org>
Date:   Wed Nov 6 18:26:39 2013 -0500

    Add NetBSD support
    
    Signed-off-by: David Goulet <dgoulet at ev0ke.net>
---
 src/common/compat.c   |    4 ++--
 src/common/compat.h   |   12 ++++++++----
 src/common/ref.h      |    2 +-
 src/lib/torsocks.h    |    8 ++++----
 tests/utils/tap/tap.c |    2 +-
 5 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/src/common/compat.c b/src/common/compat.c
index b4cdd1d..7d8431d 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -19,7 +19,7 @@
 
 #include "compat.h"
 
-#if (defined(__GLIBC__) || defined(__FreeBSD__) || defined(__darwin__))
+#if (defined(__GLIBC__) || defined(__FreeBSD__) || defined(__darwin__) || defined(__NetBSD__))
 
 /*
  * Initialize a pthread mutex. This never fails.
@@ -71,4 +71,4 @@ void tsocks_mutex_unlock(tsocks_mutex_t *m)
 	assert(!ret);
 }
 
-#endif /* __GLIBC__, __darwin__, __FreeBSD__ */
+#endif /* __GLIBC__, __darwin__, __FreeBSD__, __NetBSD__ */
diff --git a/src/common/compat.h b/src/common/compat.h
index 2eacb35..9173caf 100644
--- a/src/common/compat.h
+++ b/src/common/compat.h
@@ -22,7 +22,7 @@
 #define __darwin__	1
 #endif
 
-#if (defined(__GLIBC__) || defined(__FreeBSD__) || defined(__darwin__))
+#if (defined(__GLIBC__) || defined(__FreeBSD__) || defined(__darwin__) || defined(__NetBSD__))
 
 #define RTLD_NEXT	((void *) -1)
 
@@ -43,7 +43,7 @@ void tsocks_mutex_unlock(tsocks_mutex_t *m);
 
 #else
 #error "OS not supported."
-#endif /* __GLIBC__, __darwin__, __FreeBSD__ */
+#endif /* __GLIBC__, __darwin__, __FreeBSD__, __NetBSD__ */
 
 #if defined(__linux__)
 
@@ -84,17 +84,21 @@ void tsocks_mutex_unlock(tsocks_mutex_t *m);
 
 #endif /* __linux__ */
 
-#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__darwin__))
+#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__darwin__) || defined(__NetBSD__))
 
 #include <sys/syscall.h>
 #include <unistd.h>
 
+#if defined(__NetBSD__)
+#define SYS_socket          SYS___socket30
+#endif
+
 #define TSOCKS_NR_SOCKET    SYS_socket
 #define TSOCKS_NR_CONNECT   SYS_connect
 #define TSOCKS_NR_CLOSE     SYS_close
 #define TSOCKS_NR_MMAP      SYS_mmap
 #define TSOCKS_NR_MUNMAP    SYS_munmap
 
-#endif /* __FreeBSD__, __FreeBSD_kernel__, __darwin__ */
+#endif /* __FreeBSD__, __FreeBSD_kernel__, __darwin__, __NetBSD__ */
 
 #endif /* TORSOCKS_COMPAT_H */
diff --git a/src/common/ref.h b/src/common/ref.h
index f80fd19..88aec2e 100644
--- a/src/common/ref.h
+++ b/src/common/ref.h
@@ -26,7 +26,7 @@ struct ref {
 	long count;
 };
 
-#if (defined(__GLIBC__) || defined(__FreeBSD__) || defined(__darwin__))
+#if (defined(__GLIBC__) || defined(__FreeBSD__) || defined(__darwin__) || defined(__NetBSD__))
 
 /*
  * Get a reference by incrementing the refcount.
diff --git a/src/lib/torsocks.h b/src/lib/torsocks.h
index a931d2a..78dc3ec 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(__GLIBC__) || defined(__FreeBSD__) || defined(__darwin__))
+#if (defined(__GLIBC__) || defined(__FreeBSD__) || defined(__darwin__) || defined(__NetBSD__))
 
 /* connect(2) */
 #include <sys/types.h>
@@ -171,7 +171,7 @@ struct hostent **__result, int *__h_errnop
 
 #else
 #error "OS not supported."
-#endif /* __GLIBC__ , __FreeBSD__, __darwin__ */
+#endif /* __GLIBC__ , __FreeBSD__, __darwin__, __NetBSD__ */
 
 #if (defined(__linux__))
 
@@ -186,7 +186,7 @@ struct hostent **__result, int *__h_errnop
 
 #endif /* __linux__ */
 
-#if (defined(__FreeBSD__) || defined(__darwin__))
+#if (defined(__FreeBSD__) || defined(__darwin__) || defined(__NetBSD__))
 
 /* syscall(2) */
 #define LIBC_SYSCALL_NAME syscall
@@ -195,7 +195,7 @@ struct hostent **__result, int *__h_errnop
 #define LIBC_SYSCALL_SIG int __number, ...
 #define LIBC_SYSCALL_ARGS __number
 
-#endif /* __FreeBSD__, __darwin__ */
+#endif /* __FreeBSD__, __darwin__, __NetBSD__ */
 
 #if defined(__GLIBC__) && defined(__FreeBSD_kernel__)
 
diff --git a/tests/utils/tap/tap.c b/tests/utils/tap/tap.c
index 8bf72f6..d52cb03 100644
--- a/tests/utils/tap/tap.c
+++ b/tests/utils/tap/tap.c
@@ -94,7 +94,7 @@ _gen_result(int ok, const char *func, char *file, unsigned int line,
 		if(local_test_name) {
 			name_is_digits = 1;
 			for(c = local_test_name; *c != '\0'; c++) {
-				if(!isdigit(*c) && !isspace(*c)) {
+				if(!isdigit((unsigned char)*c) && !isspace((unsigned char)*c)) {
 					name_is_digits = 0;
 					break;
 				}





More information about the tor-commits mailing list