summaryrefslogtreecommitdiff
path: root/src/common/compat.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-03-16 17:09:32 -0400
committerNick Mathewson <nickm@torproject.org>2011-03-16 17:09:32 -0400
commit57b954293e3880f3b39d2f0f0f7710250e8ffc5f (patch)
tree06800a08323c179e6e38292ebba543165b0fb22d /src/common/compat.h
parent415caba967b9b470623ab29230b820b3470a91e6 (diff)
parent6617822b841e32d6339bac13c79dd5f2b566c3c6 (diff)
downloadtor-57b954293e3880f3b39d2f0f0f7710250e8ffc5f.tar.gz
tor-57b954293e3880f3b39d2f0f0f7710250e8ffc5f.zip
Merge remote-tracking branch 'origin/maint-0.2.2'
Trivial Conflicts in src/common/crypto.c src/or/main.h src/or/or.h
Diffstat (limited to 'src/common/compat.h')
-rw-r--r--src/common/compat.h24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/common/compat.h b/src/common/compat.h
index a7970109d7..db352de9ee 100644
--- a/src/common/compat.h
+++ b/src/common/compat.h
@@ -314,6 +314,7 @@ const char *tor_fix_source_file(const char *fname);
/* ===== Time compatibility */
#if !defined(HAVE_GETTIMEOFDAY) && !defined(HAVE_STRUCT_TIMEVAL_TV_SEC)
+/** Implementation of timeval for platforms that don't have it. */
struct timeval {
time_t tv_sec;
unsigned int tv_usec;
@@ -376,9 +377,9 @@ int get_n_open_sockets(void);
#define tor_socket_send(s, buf, len, flags) send(s, buf, len, flags)
#define tor_socket_recv(s, buf, len, flags) recv(s, buf, len, flags)
-/* Define struct in6_addr on platforms that do not have it. Generally,
- * these platforms are ones without IPv6 support, but we want to have
- * a working in6_addr there anyway, so we can use it to parse IPv6
+/** Implementatino of struct in6_addr for platforms that do not have it.
+ * Generally, these platforms are ones without IPv6 support, but we want to
+ * have a working in6_addr there anyway, so we can use it to parse IPv6
* addresses. */
#if !defined(HAVE_STRUCT_IN6_ADDR)
struct in6_addr
@@ -394,9 +395,10 @@ struct in6_addr
};
#endif
+/** @{ */
+/** Many BSD variants seem not to define these. */
#if defined(__APPLE__) || defined(__darwin__) || defined(__FreeBSD__) \
|| defined(__NetBSD__) || defined(__OpenBSD__)
-/* Many BSD variants seem not to define these. */
#ifndef s6_addr16
#define s6_addr16 __u6_addr.__u6_addr16
#endif
@@ -404,12 +406,15 @@ struct in6_addr
#define s6_addr32 __u6_addr.__u6_addr32
#endif
#endif
+/** @} */
#ifndef HAVE_SA_FAMILY_T
typedef uint16_t sa_family_t;
#endif
-/* Apparently, MS and Solaris don't define s6_addr16 or s6_addr32. */
+/** @{ */
+/** Apparently, MS and Solaris don't define s6_addr16 or s6_addr32; these
+ * macros get you a pointer to s6_addr32 or local equivalent. */
#ifdef HAVE_STRUCT_IN6_ADDR_S6_ADDR32
#define S6_ADDR32(x) ((uint32_t*)(x).s6_addr32)
#else
@@ -420,9 +425,10 @@ typedef uint16_t sa_family_t;
#else
#define S6_ADDR16(x) ((uint16_t*)((char*)&(x).s6_addr))
#endif
+/** @} */
-/* Define struct sockaddr_in6 on platforms that do not have it. See notes
- * on struct in6_addr. */
+/** Implementation of struct sockaddr_in6 on platforms that do not have
+ * it. See notes on struct in6_addr. */
#if !defined(HAVE_STRUCT_SOCKADDR_IN6)
struct sockaddr_in6 {
sa_family_t sin6_family;
@@ -548,10 +554,14 @@ int compute_num_cpus(void);
/** A generic lock structure for multithreaded builds. */
typedef struct tor_mutex_t {
#if defined(USE_WIN32_THREADS)
+ /** Windows-only: on windows, we implement locks with CRITICAL_SECTIONS. */
CRITICAL_SECTION mutex;
#elif defined(USE_PTHREADS)
+ /** Pthreads-only: with pthreads, we implement locks with
+ * pthread_mutex_t. */
pthread_mutex_t mutex;
#else
+ /** No-threads only: Dummy variable so that tor_mutex_t takes up space. */
int _unused;
#endif
} tor_mutex_t;