Index: nsprpub/pr/include/md/_freebsd.h
--- nsprpub/pr/include/md/_freebsd.h.orig	2003-01-16 17:16:27 +0100
+++ nsprpub/pr/include/md/_freebsd.h	2004-12-27 19:50:46 +0100
@@ -40,6 +40,7 @@
 #if __FreeBSD__ >= 2
 #include <osreldate.h>  /* for __FreeBSD_version */
 #endif
+#include <sys/param.h>
 #include <sys/syscall.h>
 
 #define PR_LINKER_ARCH	"freebsd"
Index: nsprpub/pr/include/md/_pth.h
--- nsprpub/pr/include/md/_pth.h.orig	2002-12-12 00:10:39 +0100
+++ nsprpub/pr/include/md/_pth.h	2004-12-27 19:52:48 +0100
@@ -90,7 +90,7 @@
 #define _PT_PTHREAD_MUTEXATTR_INIT        pthread_mutexattr_init
 #define _PT_PTHREAD_MUTEXATTR_DESTROY     pthread_mutexattr_destroy
 #define _PT_PTHREAD_MUTEX_INIT(m, a)      pthread_mutex_init(&(m), &(a))
-#define _PT_PTHREAD_MUTEX_IS_LOCKED(m)    (EBUSY == pthread_mutex_trylock(&(m)))
+#define _PT_PTHREAD_MUTEX_IS_LOCKED(m)    (0 != pthread_mutex_trylock(&(m)))
 #if defined(DARWIN)
 #define _PT_PTHREAD_CONDATTR_INIT(x)      0
 #else
Index: nsprpub/pr/src/md/unix/unix.c
--- nsprpub/pr/src/md/unix/unix.c.orig	2002-12-12 00:03:31 +0100
+++ nsprpub/pr/src/md/unix/unix.c	2004-12-27 19:50:46 +0100
@@ -65,7 +65,8 @@
  * PRInt32* pointer to a _PRSockLen_t* pointer.
  */
 #if defined(HAVE_SOCKLEN_T) \
-    || (defined(LINUX) && defined(__GLIBC__) && __GLIBC__ >= 2)
+    || (defined(LINUX) && defined(__GLIBC__) && __GLIBC__ >= 2) \
+    || defined(FREEBSD)
 #define _PRSockLen_t socklen_t
 #elif defined(IRIX) || defined(HPUX) || defined(OSF1) || defined(SOLARIS) \
     || defined(AIX4_1) || defined(LINUX) || defined(SONY) \
@@ -73,7 +74,7 @@
     || defined(SUNOS4) || defined(NCR) || defined(DARWIN) \
     || defined(NEXTSTEP) || defined(QNX)
 #define _PRSockLen_t int
-#elif (defined(AIX) && !defined(AIX4_1)) || defined(FREEBSD) \
+#elif (defined(AIX) && !defined(AIX4_1)) \
     || defined(NETBSD) || defined(OPENBSD) || defined(UNIXWARE) \
     || defined(DGUX) || defined(VMS) || defined(NTO)
 #define _PRSockLen_t size_t
Index: nsprpub/pr/src/pthreads/ptio.c
--- nsprpub/pr/src/pthreads/ptio.c.orig	2003-07-15 00:12:19 +0200
+++ nsprpub/pr/src/pthreads/ptio.c	2004-12-27 19:54:28 +0100
@@ -189,7 +189,7 @@
 #endif
 #endif
 
-#ifdef DARWIN
+#if defined(DARWIN) || defined(FREEBSD)
 static PRBool _pr_ipv6_v6only_on_by_default;
 /* The IPV6_V6ONLY socket option is not defined on Mac OS X 10.1. */
 #ifndef IPV6_V6ONLY
@@ -1154,7 +1154,7 @@
     _pr_stderr = pt_SetMethods(2, PR_DESC_FILE, PR_FALSE, PR_TRUE);
     PR_ASSERT(_pr_stdin && _pr_stdout && _pr_stderr);
 
-#ifdef DARWIN
+#if defined(DARWIN) || defined(FREEBSD)
     /* In Mac OS X v10.3 Panther Beta the IPV6_V6ONLY socket option
      * is turned on by default, contrary to what RFC 3493, Section
      * 5.3 says.  So we have to turn it off.  Find out whether we
@@ -3462,7 +3462,7 @@
     if (osfd == -1) pt_MapError(_PR_MD_MAP_SOCKET_ERROR, errno);
     else
     {
-#ifdef DARWIN
+#if defined(DARWIN) || defined(FREEBSD)
         if ((domain == AF_INET6) && _pr_ipv6_v6only_on_by_default)
         {
             int on = 0;
@@ -3470,6 +3470,17 @@
                     &on, sizeof(on));
         }
 #endif
+#if (defined(_PR_INET6_PROBE) || defined(_PR_INET6)) && \
+	defined(__FreeBSD__) && defined(IPV6_V6ONLY)
+		if (domain == PR_AF_INET6) {
+			int opt = 0;
+			if (setsockopt(osfd, IPPROTO_IPV6, IPV6_V6ONLY,
+			    &opt, sizeof(opt))) {
+				close(osfd);
+				return NULL;
+			}
+		}
+#endif  
         fd = pt_SetMethods(osfd, ftype, PR_FALSE, PR_FALSE);
         if (fd == NULL) close(osfd);
     }
Index: layout/svg/renderer/src/cairo/nsSVGCairoCanvas.cpp
--- layout/svg/renderer/src/cairo/nsSVGCairoCanvas.cpp.orig	2005-02-04 20:01:59 +0100
+++ layout/svg/renderer/src/cairo/nsSVGCairoCanvas.cpp	2005-02-04 20:02:52 +0100
@@ -50,6 +50,11 @@
 #include "nsRenderingContextGTK.h"
 #include <gdk/gdkx.h>
 #include <cairo.h>
+#ifdef CAIRO_HAS_XLIB_SURFACE
+#include <cairo-xlib.h>
+#else
+#error Require Cairo with Xlib backend
+#endif
 
 /**
  * \addtogroup cairo_renderer Cairo Rendering Engine
Index: layout/svg/renderer/src/cairo/nsSVGCairoGlyphMetrics.cpp
--- layout/svg/renderer/src/cairo/nsSVGCairoGlyphMetrics.cpp.orig	2004-03-16 22:40:07 +0100
+++ layout/svg/renderer/src/cairo/nsSVGCairoGlyphMetrics.cpp	2005-02-04 20:03:40 +0100
@@ -50,6 +50,7 @@
 #include "nsIDOMSVGRect.h"
 #include "nsSVGTypeCIDs.h"
 #include "nsIComponentManager.h"
+#include <stdlib.h>
 #include <cairo.h>
 
 /**
Index: calendar/libxpical/token.c
--- calendar/libxpical/token.c.orig	2003-10-24 22:40:32 +0200
+++ calendar/libxpical/token.c	2005-08-13 13:13:58 +0200
@@ -266,7 +266,7 @@
     unsigned char seed[16];
 
     get_random_info(seed);
-    seed[0] |= 0x80;
+    seed[0] |= 0x01;
     memcpy(node, seed, sizeof(*node));
 }
 
Index: security/nss/lib/pki1/oiddata.h
--- security/nss/lib/pki1/oiddata.h.orig	2002-01-04 06:22:07 +0100
+++ security/nss/lib/pki1/oiddata.h	2005-10-06 08:23:42 +0200
@@ -40,5 +40,8 @@
 #endif /* DEBUG */
 
+#ifndef PKI1T_H
+#include "pki1t.h"
+#endif
 #ifndef NSSPKI1T_H
 #include "nsspki1t.h"
 #endif /* NSSPKI1T_H */
