Checked in the fixes for Bugzilla bugs 106386, 266981, and 266327 on the NSPRPUB_PRE_4_2_CLIENT_BRANCH
authorwchang0222%aol.com
Tue, 23 Nov 2004 21:22:35 +0000
branchNSPRPUB_PRE_4_2_CLIENT_BRANCH
changeset 3221 efd28f5bea070f2895a2d2d4c84f1ba4507edaec
parent 3217 3edfae65f9608a3a9d020a8da2fb4177f983fa84
child 3223 bf4419aa74ea3207ae595ccd3e16de4331c85b29
push idunknown
push userunknown
push dateunknown
bugs106386, 266981, 266327
Checked in the fixes for Bugzilla bugs 106386, 266981, and 266327 on the NSPRPUB_PRE_4_2_CLIENT_BRANCH. Modified Files: plresolv.h plstr.h prgc.h prolock.h prtypes.h _darwin.h _freebsd.cfg, _freebsd.h _pth.h bfile.c ptio.c ptsynch.c
lib/libc/include/plresolv.h
lib/libc/include/plstr.h
lib/msgc/include/prgc.h
pr/include/md/_darwin.h
pr/include/md/_freebsd.cfg
pr/include/md/_freebsd.h
pr/include/md/_pth.h
pr/include/prolock.h
pr/include/prtypes.h
pr/src/md/beos/bfile.c
pr/src/pthreads/ptio.c
pr/src/pthreads/ptsynch.c
--- a/lib/libc/include/plresolv.h
+++ b/lib/libc/include/plresolv.h
@@ -61,17 +61,17 @@ NSPR_BEGIN_EXTERN_C
 /* Error return codes */
 #define PL_RESOLVE_OK            0
 #define PL_RESOLVE_EWINIT        1           /* Failed to initialize window */
 #define PL_RESOLVE_EMAKE         2           /* Failed to create request */
 #define PL_RESOLVE_ELAUNCH       3           /* Error launching Async request */
 #define PL_RESOLVE_ETIMEDOUT     4           /* Request timed-out */
 #define PL_RESOLVE_EINVAL        5           /* Invalid argument */
 #define PL_RESOLVE_EOVERFLOW     6           /* Buffer Overflow */
-#define PL_RESOLVE_EUNKNOWN      7           /* berzerk error */
+#define PL_RESOLVE_EUNKNOWN      7           /* berserk error */
 
 /* ----------- Function Prototypes ----------------*/
 
 PR_EXTERN(PRStatus) PL_ResolveName(
     const char *name, unsigned char *buf,
     PRIntn bufsize, PRIntervalTime timeout,
     PRHostEnt *hostentry, PRIntervalTime *ttl);
 
--- a/lib/libc/include/plstr.h
+++ b/lib/libc/include/plstr.h
@@ -43,17 +43,17 @@
  * plstr.h
  *
  * This header file exports the API to the NSPR portable library or string-
  * handling functions.  
  * 
  * This API was not designed as an "optimal" or "ideal" string library; it 
  * was based on the good ol' unix string.3 functions, and was written to
  *
- *  1) replace the libc functions, for cross-platform consistancy, 
+ *  1) replace the libc functions, for cross-platform consistency, 
  *  2) complete the API on platforms lacking common functions (e.g., 
  *     strcase*), and
  *  3) to implement some obvious "closure" functions that I've seen
  *     people hacking around in our code.
  *
  * Point number three largely means that most functions have an "strn"
  * limited-length version, and all comparison routines have a non-case-
  * sensitive version available.
@@ -413,17 +413,17 @@ PL_strcasestr(const char *big, const cha
  */
 
 PR_EXTERN(char *)
 PL_strcaserstr(const char *big, const char *little);
 
 /*
  * PL_strncasestr
  *
- * Returns a pointer to the first instance of the listtle string within the first
+ * Returns a pointer to the first instance of the little string within the first
  * n characters of the big one, ignoring case.  It returns null if either string is 
  * null.  It returns null if the length of the little string is greater than n.
  */
 
 PR_EXTERN(char *)
 PL_strncasestr(const char *big, const char *little, PRUint32 max);
 
 /*
--- a/lib/msgc/include/prgc.h
+++ b/lib/msgc/include/prgc.h
@@ -315,17 +315,17 @@ PR_EXTERN(void) PR_DumpIndent(FILE *out,
 **    The lowest segment currently used in the GC heap.
 **
 ** highSeg:
 **    The highest segment currently used in the GC heap.  
 **    The lowSeg and highSeg members are used for a "quick test" of whether 
 **    a pointer falls within the GC heap. [ see GC_IN_HEAP(...) ]
 **
 ** lock:
-**    Monitor used for syncronization within the GC.
+**    Monitor used for synchronization within the GC.
 **
 ** finalizer:
 **    Thread in which the GC finalizer is running.
 **
 ** liveBlock:
 **    Object scanning functions call through this function pointer to
 **    register a potential block of pointers with the collector. (This is
 **    currently not at all different than processRoot.)
@@ -347,17 +347,17 @@ PR_EXTERN(void) PR_DumpIndent(FILE *out,
 */
 typedef struct GCInfoStr {
     PRWord  flags;         /* trace flags (see below)               */
     PRWord  busyMemory;    /* memory in use right now               */
     PRWord  freeMemory;    /* memory free right now                 */
     PRWord  allocMemory;   /* sum of busy & free memory             */
     PRWord  maxMemory;     /* max memory we are allowed to allocate */
     PRWord *lowSeg;        /* lowest segment in the GC heap         */
-    PRWord *highSeg;       /* higest segment in the GC heap         */
+    PRWord *highSeg;       /* highest segment in the GC heap         */
 
     PRMonitor *lock;
     PRThread  *finalizer;
 
     void (PR_CALLBACK *liveBlock)(void **base, PRInt32 count);
     void (PR_CALLBACK *livePointer)(void *ptr);
     void (PR_CALLBACK *processRootBlock)(void **base, PRInt32 count);
     void (PR_CALLBACK *processRootPointer)(void *ptr);
--- a/pr/include/md/_darwin.h
+++ b/pr/include/md/_darwin.h
@@ -83,16 +83,21 @@
  */
 #if MACOS_DEPLOYMENT_TARGET < 100300
 #define _PR_INET6_PROBE
 #endif
 /* Mac OS X 10.2 has inet_ntop and inet_pton. */
 #if MACOS_DEPLOYMENT_TARGET >= 100200
 #define _PR_HAVE_INET_NTOP
 #endif
+#define _PR_IPV6_V6ONLY_PROBE
+/* The IPV6_V6ONLY socket option is not defined on Mac OS X 10.1. */
+#ifndef IPV6_V6ONLY
+#define IPV6_V6ONLY 27
+#endif
 
 #if defined(__ppc__)
 #define _PR_HAVE_ATOMIC_OPS
 #define _MD_INIT_ATOMIC()
 extern PRInt32 _PR_DarwinPPC_AtomicIncrement(PRInt32 *val);
 #define _MD_ATOMIC_INCREMENT(val)   _PR_DarwinPPC_AtomicIncrement(val)
 extern PRInt32 _PR_DarwinPPC_AtomicDecrement(PRInt32 *val);
 #define _MD_ATOMIC_DECREMENT(val)   _PR_DarwinPPC_AtomicDecrement(val)
--- a/pr/include/md/_freebsd.cfg
+++ b/pr/include/md/_freebsd.cfg
@@ -89,17 +89,17 @@
 #define PR_ALIGN_OF_SHORT   2
 #define PR_ALIGN_OF_INT     4
 #define PR_ALIGN_OF_LONG    4
 #define PR_ALIGN_OF_INT64   4
 #define PR_ALIGN_OF_FLOAT   4
 #define PR_ALIGN_OF_DOUBLE  4
 #define PR_ALIGN_OF_POINTER 4
 
-#elif defined(__alpha)
+#elif defined(__alpha__)
 
 #define IS_LITTLE_ENDIAN 1
 #undef  IS_BIG_ENDIAN
 #define	HAVE_LONG_LONG
 #define	HAVE_ALIGNED_DOUBLES
 #define	HAVE_ALIGNED_LONGLONGS
 #define IS_64
 
@@ -138,17 +138,17 @@
 #define PR_ALIGN_OF_LONG    8
 #define PR_ALIGN_OF_INT64   8
 #define PR_ALIGN_OF_FLOAT   4
 #define PR_ALIGN_OF_DOUBLE  8
 #define PR_ALIGN_OF_POINTER 8
 
 #elif defined(__sparc__)
 
-#undef IS_LITTLE_ENDIAN
+#undef  IS_LITTLE_ENDIAN
 #define IS_BIG_ENDIAN 1
 #define	HAVE_LONG_LONG
 #define	HAVE_ALIGNED_DOUBLES
 #define	HAVE_ALIGNED_LONGLONGS
 #define IS_64
 
 #define PR_BYTES_PER_BYTE   1
 #define PR_BYTES_PER_SHORT  2
@@ -183,16 +183,112 @@
 #define PR_ALIGN_OF_SHORT   2
 #define PR_ALIGN_OF_INT     4
 #define PR_ALIGN_OF_LONG    8
 #define PR_ALIGN_OF_INT64   8
 #define PR_ALIGN_OF_FLOAT   4
 #define PR_ALIGN_OF_DOUBLE  8
 #define PR_ALIGN_OF_POINTER 8
 
+#elif defined(__ia64__)
+
+#define IS_LITTLE_ENDIAN 1
+#undef  IS_BIG_ENDIAN
+#define	HAVE_LONG_LONG
+#define	HAVE_ALIGNED_DOUBLES
+#define	HAVE_ALIGNED_LONGLONGS
+#define IS_64
+
+#define PR_BYTES_PER_BYTE   1
+#define PR_BYTES_PER_SHORT  2
+#define PR_BYTES_PER_INT    4
+#define PR_BYTES_PER_INT64  8
+#define PR_BYTES_PER_LONG   8
+#define PR_BYTES_PER_FLOAT  4
+#define PR_BYTES_PER_DOUBLE 8
+#define PR_BYTES_PER_WORD   8
+#define PR_BYTES_PER_DWORD  8
+#define PR_BYTES_PER_WORD_LOG2   3
+#define PR_BYTES_PER_DWORD_LOG2  3
+
+#define PR_BITS_PER_BYTE    8
+#define PR_BITS_PER_SHORT   16
+#define PR_BITS_PER_INT     32
+#define PR_BITS_PER_INT64   64
+#define PR_BITS_PER_LONG    64
+#define PR_BITS_PER_FLOAT   32
+#define PR_BITS_PER_DOUBLE  64
+#define PR_BITS_PER_WORD    64
+
+#define PR_BITS_PER_BYTE_LOG2   3
+#define PR_BITS_PER_SHORT_LOG2  4
+#define PR_BITS_PER_INT_LOG2    5
+#define PR_BITS_PER_INT64_LOG2  6
+#define PR_BITS_PER_LONG_LOG2   6
+#define PR_BITS_PER_FLOAT_LOG2  5
+#define PR_BITS_PER_DOUBLE_LOG2 6
+#define PR_BITS_PER_WORD_LOG2   6
+
+#define PR_ALIGN_OF_SHORT   2
+#define PR_ALIGN_OF_INT     4
+#define PR_ALIGN_OF_LONG    8
+#define PR_ALIGN_OF_INT64   8
+#define PR_ALIGN_OF_FLOAT   4
+#define PR_ALIGN_OF_DOUBLE  8
+#define PR_ALIGN_OF_POINTER 8
+#define PR_ALIGN_OF_WORD    8
+
+#elif defined(__amd64__)
+
+#define IS_LITTLE_ENDIAN 1
+#undef  IS_BIG_ENDIAN
+#define	HAVE_LONG_LONG
+#define	HAVE_ALIGNED_DOUBLES
+#define	HAVE_ALIGNED_LONGLONGS
+#define IS_64
+
+#define PR_BYTES_PER_BYTE   1
+#define PR_BYTES_PER_SHORT  2
+#define PR_BYTES_PER_INT    4
+#define PR_BYTES_PER_INT64  8
+#define PR_BYTES_PER_LONG   8
+#define PR_BYTES_PER_FLOAT  4
+#define PR_BYTES_PER_DOUBLE 8
+#define PR_BYTES_PER_WORD   8
+#define PR_BYTES_PER_DWORD  8
+#define PR_BYTES_PER_WORD_LOG2   3
+#define PR_BYTES_PER_DWORD_LOG2  3
+
+#define PR_BITS_PER_BYTE    8
+#define PR_BITS_PER_SHORT   16
+#define PR_BITS_PER_INT     32
+#define PR_BITS_PER_INT64   64
+#define PR_BITS_PER_LONG    64
+#define PR_BITS_PER_FLOAT   32
+#define PR_BITS_PER_DOUBLE  64
+#define PR_BITS_PER_WORD    64
+
+#define PR_BITS_PER_BYTE_LOG2   3
+#define PR_BITS_PER_SHORT_LOG2  4
+#define PR_BITS_PER_INT_LOG2    5
+#define PR_BITS_PER_INT64_LOG2  6
+#define PR_BITS_PER_LONG_LOG2   6
+#define PR_BITS_PER_FLOAT_LOG2  5
+#define PR_BITS_PER_DOUBLE_LOG2 6
+#define PR_BITS_PER_WORD_LOG2   6
+
+#define PR_ALIGN_OF_SHORT   2
+#define PR_ALIGN_OF_INT     4
+#define PR_ALIGN_OF_LONG    8
+#define PR_ALIGN_OF_INT64   8
+#define PR_ALIGN_OF_FLOAT   4
+#define PR_ALIGN_OF_DOUBLE  8
+#define PR_ALIGN_OF_POINTER 8
+#define PR_ALIGN_OF_WORD    8
+
 #else
 
 #error "Unknown CPU architecture"
 
 #endif
 
 #ifndef NO_NSPR_10_SUPPORT
 
--- a/pr/include/md/_freebsd.h
+++ b/pr/include/md/_freebsd.h
@@ -44,20 +44,24 @@
 #include <osreldate.h>  /* for __FreeBSD_version */
 #endif
 #include <sys/syscall.h>
 
 #define PR_LINKER_ARCH	"freebsd"
 #define _PR_SI_SYSNAME  "FREEBSD"
 #if defined(__i386__)
 #define _PR_SI_ARCHITECTURE "x86"
-#elif defined(__alpha)
+#elif defined(__alpha__)
 #define _PR_SI_ARCHITECTURE "alpha"
 #elif defined(__sparc__)
 #define _PR_SI_ARCHITECTURE "sparc"
+#elif defined(__ia64__)
+#define _PR_SI_ARCHITECTURE "ia64"
+#elif defined(__amd64__)
+#define _PR_SI_ARCHITECTURE "amd64"
 #else
 #error "Unknown CPU architecture"
 #endif
 #if defined(__ELF__)
 #define PR_DLL_SUFFIX          ".so"
 #else
 #define PR_DLL_SUFFIX          ".so.1.0"
 #endif
@@ -94,16 +98,17 @@
 #define PR_HAVE_SYSV_NAMED_SHARED_MEMORY
 
 #if __FreeBSD_version >= 400014
 #define _PR_INET6
 #define _PR_HAVE_INET_NTOP
 #define _PR_HAVE_GETHOSTBYNAME2
 #define _PR_HAVE_GETADDRINFO
 #define _PR_INET6_PROBE
+#define _PR_IPV6_V6ONLY_PROBE
 #endif
 
 #define USE_SETJMP
 
 #ifndef _PR_PTHREADS
 #include <setjmp.h>
 
 #define PR_CONTEXT_TYPE	sigjmp_buf
--- a/pr/include/md/_pth.h
+++ b/pr/include/md/_pth.h
@@ -88,17 +88,21 @@
 #define _PT_PTHREAD_CONDATTR_INIT(x)      0
 #define _PT_PTHREAD_CONDATTR_DESTROY(x)   /* */
 #define _PT_PTHREAD_COND_INIT(m, a)       (memset(&(m), 0, sizeof(m)), \
                                       pthread_cond_init(&(m), NULL))
 #else
 #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))
+#if defined(FREEBSD)
+#define _PT_PTHREAD_MUTEX_IS_LOCKED(m)    pt_pthread_mutex_is_locked(&(m))
+#else
 #define _PT_PTHREAD_MUTEX_IS_LOCKED(m)    (EBUSY == pthread_mutex_trylock(&(m)))
+#endif
 #if defined(DARWIN)
 #define _PT_PTHREAD_CONDATTR_INIT(x)      0
 #else
 #define _PT_PTHREAD_CONDATTR_INIT         pthread_condattr_init
 #endif
 #define _PT_PTHREAD_CONDATTR_DESTROY      pthread_condattr_destroy
 #define _PT_PTHREAD_COND_INIT(m, a)       pthread_cond_init(&(m), &(a))
 #endif
--- a/pr/include/prolock.h
+++ b/pr/include/prolock.h
@@ -154,17 +154,17 @@ NSPR_API(void)
 ** 
 ** DESCRIPTION: PR_LockOrderedLock() locks the ordered lock
 ** referenced by lock. If the order of lock is less than or equal
 ** to the order of the highest lock held by the locking thread,
 ** the function asserts.
 ** 
 ** INPUTS: lock: a pointer to a PROrderedLock
 ** 
-** OUTPUTS: The lock is held or the fucntion asserts.
+** OUTPUTS: The lock is held or the function asserts.
 ** 
 ** RETURNS: void
 ** 
 ** RESTRICTIONS:
 ** 
 */
 #if defined(DEBUG) || defined(FORCE_NSPR_ORDERED_LOCKS)
 #define PR_LOCK_ORDERED_LOCK(lock) PR_LockOrderedLock((lock))
--- a/pr/include/prtypes.h
+++ b/pr/include/prtypes.h
@@ -34,18 +34,18 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 /*
 ** File:                prtypes.h
 ** Description: Definitions of NSPR's basic types
 **
-** Prototypes and macros used to make up for deficiencies in ANSI environments
-** that we have found.
+** Prototypes and macros used to make up for deficiencies that we have found
+** in ANSI environments.
 **
 ** Since we do not wrap <stdlib.h> and all the other standard headers, authors
 ** of portable code will not know in general that they need these definitions.
 ** Instead of requiring these authors to find the dependent uses in their code
 ** and take the following steps only in those C files, we take steps once here
 ** for all C files.
 **/
 
@@ -419,17 +419,17 @@ typedef size_t PRSize;
 ************************************************************************/
 typedef PRInt32 PROffset32;
 typedef PRInt64 PROffset64;
 
 /************************************************************************
 ** TYPES:       PRPtrDiff
 ** DESCRIPTION:
 **  A type for pointer difference. Variables of this type are suitable
-**      for storing a pointer or pointer sutraction. 
+**      for storing a pointer or pointer subtraction. 
 ************************************************************************/
 typedef ptrdiff_t PRPtrdiff;
 
 /************************************************************************
 ** TYPES:       PRUptrdiff
 ** DESCRIPTION:
 **  A type for pointer difference. Variables of this type are suitable
 **      for storing a pointer or pointer sutraction. 
@@ -437,26 +437,26 @@ typedef ptrdiff_t PRPtrdiff;
 typedef unsigned long PRUptrdiff;
 
 /************************************************************************
 ** TYPES:       PRBool
 ** DESCRIPTION:
 **  Use PRBool for variables and parameter types. Use PR_FALSE and PR_TRUE
 **      for clarity of target type in assignments and actual arguments. Use
 **      'if (bool)', 'while (!bool)', '(bool) ? x : y' etc., to test booleans
-**      juast as you would C int-valued conditions. 
+**      just as you would C int-valued conditions. 
 ************************************************************************/
 typedef PRIntn PRBool;
 #define PR_TRUE 1
 #define PR_FALSE 0
 
 /************************************************************************
 ** TYPES:       PRPackedBool
 ** DESCRIPTION:
-**  Use PRPackedBOol within structs where bitfields are not desireable
+**  Use PRPackedBool within structs where bitfields are not desirable
 **      but minimum and consistant overhead matters.
 ************************************************************************/
 typedef PRUint8 PRPackedBool;
 
 /*
 ** Status code used by some routines that have a single point of failure or 
 ** special status return.
 */
--- a/pr/src/md/beos/bfile.c
+++ b/pr/src/md/beos/bfile.c
@@ -168,26 +168,28 @@ PRInt32
 	if (flags & PR_RDWR) {
 		osflags = O_RDWR;
 	} else if (flags & PR_WRONLY) {
 		osflags = O_WRONLY;
 	} else {
 		osflags = O_RDONLY;
 	}
 
-        if (flags & PR_APPEND)
-                osflags |= O_APPEND;
-        if (flags & PR_TRUNCATE)
-                osflags |= O_TRUNC;
-        if (flags & PR_SYNC) {
+	if (flags & PR_EXCL)
+		osflags |= O_EXCL;
+	if (flags & PR_APPEND)
+		osflags |= O_APPEND;
+	if (flags & PR_TRUNCATE)
+		osflags |= O_TRUNC;
+	if (flags & PR_SYNC) {
 /* Ummmm.  BeOS doesn't appear to
    support sync in any way shape or
    form. */
 		return PR_NOT_IMPLEMENTED_ERROR;
-        }
+	}
 
 	/*
 	** On creations we hold the 'create' lock in order to enforce
 	** the semantics of PR_Rename. (see the latter for more details)
 	*/
 	if (flags & PR_CREATE_FILE)
 	{
 		osflags |= O_CREAT ;
--- a/pr/src/pthreads/ptio.c
+++ b/pr/src/pthreads/ptio.c
@@ -190,22 +190,18 @@ static ssize_t (*pt_aix_sendfile_fptr)()
 #include <netinet/tcp.h>  /* TCP_NODELAY, TCP_MAXSEG */
 #ifdef LINUX
 /* TCP_CORK is not defined in <netinet/tcp.h> on Red Hat Linux 6.0 */
 #ifndef TCP_CORK
 #define TCP_CORK 3
 #endif
 #endif
 
-#ifdef DARWIN
+#ifdef _PR_IPV6_V6ONLY_PROBE
 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
-#define IPV6_V6ONLY 27
-#endif
 #endif
 
 #if defined(SOLARIS)
 #define _PRSockOptVal_t char *
 #elif defined(IRIX) || defined(OSF1) || defined(AIX) || defined(HPUX) \
     || defined(LINUX) || defined(FREEBSD) || defined(BSDI) || defined(VMS) \
     || defined(NTO) || defined(OPENBSD) || defined(DARWIN) \
     || defined(UNIXWARE) || defined(NETBSD)
@@ -1155,17 +1151,17 @@ void _PR_InitIO(void)
 
     _PR_InitFdCache();  /* do that */   
 
     _pr_stdin = pt_SetMethods(0, PR_DESC_FILE, PR_FALSE, PR_TRUE);
     _pr_stdout = pt_SetMethods(1, PR_DESC_FILE, PR_FALSE, PR_TRUE);
     _pr_stderr = pt_SetMethods(2, PR_DESC_FILE, PR_FALSE, PR_TRUE);
     PR_ASSERT(_pr_stdin && _pr_stdout && _pr_stderr);
 
-#ifdef DARWIN
+#ifdef _PR_IPV6_V6ONLY_PROBE
     /* 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
      * are running on such a system.
      */
     {
         int osfd;
         osfd = socket(AF_INET6, SOCK_STREAM, 0);
@@ -3475,17 +3471,17 @@ PR_IMPLEMENT(PRFileDesc*) PR_Socket(PRIn
 	if (PR_AF_INET6 == domain)
 		domain = AF_INET;
 #endif
 
     osfd = socket(domain, type, proto);
     if (osfd == -1) pt_MapError(_PR_MD_MAP_SOCKET_ERROR, errno);
     else
     {
-#ifdef DARWIN
+#ifdef _PR_IPV6_V6ONLY_PROBE
         if ((domain == AF_INET6) && _pr_ipv6_v6only_on_by_default)
         {
             int on = 0;
             (void)setsockopt(osfd, IPPROTO_IPV6, IPV6_V6ONLY,
                     &on, sizeof(on));
         }
 #endif
         fd = pt_SetMethods(osfd, ftype, PR_FALSE, PR_FALSE);
--- a/pr/src/pthreads/ptsynch.c
+++ b/pr/src/pthreads/ptsynch.c
@@ -57,16 +57,29 @@ static pthread_condattr_t _pt_cvar_attr;
 extern PTDebug pt_debug;  /* this is shared between several modules */
 
 #if defined(_PR_DCETHREADS)
 static pthread_t pt_zero_tid;  /* a null pthread_t (pthread_t is a struct
                                 * in DCE threads) to compare with */
 #endif  /* defined(_PR_DCETHREADS) */
 #endif  /* defined(DEBUG) */
 
+#if defined(FREEBSD)
+/*
+ * On older versions of FreeBSD, pthread_mutex_trylock returns EDEADLK.
+ * Newer versions return EBUSY.  We still need to support both.
+ */
+static int
+pt_pthread_mutex_is_locked(pthread_mutex_t *m)
+{
+    int rv = pthread_mutex_trylock(m);
+    return (EBUSY == rv || EDEADLK == rv);
+}
+#endif
+
 /**************************************************************/
 /**************************************************************/
 /*****************************LOCKS****************************/
 /**************************************************************/
 /**************************************************************/
 
 void _PR_InitLocks(void)
 {