Browse Source

Merge remote-tracking branch 'public/bug3894'

Nick Mathewson 12 years ago
parent
commit
7f45ea5c41
5 changed files with 20 additions and 1 deletions
  1. 4 0
      changes/bug3894_more
  2. 2 0
      configure.in
  3. 3 0
      src/common/compat.h
  4. 10 0
      src/common/torint.h
  5. 1 1
      src/common/util.c

+ 4 - 0
changes/bug3894_more

@@ -0,0 +1,4 @@
+  o Build fixes:
+    - Clean up some code issues that prevented Tor from building on older
+      BSDs.  Fixes bug 3894; reported by grarpamp.
+      

+ 2 - 0
configure.in

@@ -680,6 +680,8 @@ AC_CHECK_HEADERS(
         utime.h
 )
 
+AC_CHECK_HEADERS(sys/param.h)
+
 TOR_CHECK_PROTOTYPE(malloc_good_size, HAVE_MALLOC_GOOD_SIZE_PROTOTYPE,
 [#ifdef HAVE_MALLOC_H
 #include <malloc.h>

+ 3 - 0
src/common/compat.h

@@ -20,6 +20,9 @@
 #include <ws2tcpip.h>
 #endif
 #endif
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif

+ 10 - 0
src/common/torint.h

@@ -191,6 +191,16 @@ typedef unsigned __int64 uint64_t;
 #endif
 #endif
 
+#ifndef SIZE_MAX
+#if SIZEOF_SIZE_T == 8
+#define SIZE_MAX UINT64_MAX
+#elif  SIZEOF_SIZE_T == 4
+#define SIZE_MAX UINT32_MAX
+#else
+#error "Can't define SIZE_MAX"
+#endif
+#endif
+
 #ifndef HAVE_SSIZE_T
 #if SIZEOF_SIZE_T == 8
 typedef int64_t ssize_t;

+ 1 - 1
src/common/util.c

@@ -80,7 +80,7 @@
 #include <malloc/malloc.h>
 #endif
 #ifdef HAVE_MALLOC_H
-#ifndef OPENBSD
+#if !defined(OPENBSD) && !defined(__FreeBSD__)
 /* OpenBSD has a malloc.h, but for our purposes, it only exists in order to
  * scold us for being so stupid as to autodetect its presence.  To be fair,
  * they've done this since 1996, when autoconf was only 5 years old. */