Bug 489299 TestSynchronization.cpp failed to compile with Sun Studio r=benjamin, jones.chris.g
authorGinn Chen <ginn.chen@sun.com>
Thu, 11 Jun 2009 14:46:13 +0800
changeset 29041 660b51f966388f5bb6de5eae37fb22f568c3d3c5
parent 29040 0102de270b206c04c0facadcdf6acae7c33fbb3c
child 29042 ef153536c6494480db29faac42107c938ebebc45
push idunknown
push userunknown
push dateunknown
reviewersbenjamin, jones.chris.g
bugs489299
milestone1.9.2a1pre
Bug 489299 TestSynchronization.cpp failed to compile with Sun Studio r=benjamin, jones.chris.g
xpcom/tests/Makefile.in
xpcom/tests/TestDeadlockDetector.cpp
xpcom/tests/TestDeadlockDetectorScalability.cpp
--- a/xpcom/tests/Makefile.in
+++ b/xpcom/tests/Makefile.in
@@ -147,16 +147,20 @@ endif
 
 LIBS += $(XPCOM_LIBS)
 
 # Needed to resolve __yylex (?)
 ifeq ($(OS_ARCH)$(OS_RELEASE),FreeBSD2)
 LIBS		+= -lpcap
 endif
 
+ifdef SOLARIS_SUNPRO_CXX
+CXXFLAGS += -features=extensions -D__FUNCTION__=__func__
+endif
+
 ENABLE_CXX_EXCEPTIONS = 1
 
 XPCSHELL_TESTS = unit
 
 # Make sure we have symbols in case we need to debug these.
 MOZ_DEBUG_SYMBOLS = 1
 
 include $(topsrcdir)/config/rules.mk
--- a/xpcom/tests/TestDeadlockDetector.cpp
+++ b/xpcom/tests/TestDeadlockDetector.cpp
@@ -513,17 +513,18 @@ ContentionNoDeadlock_Child()
         delete cndMs[i];
 
     return 0;
 }
 
 nsresult
 ContentionNoDeadlock()
 {
-    Subprocess proc(__FUNCTION__);
+    const char * func = __func__;
+    Subprocess proc(func);
     proc.RunToCompletion(10000);
     if (0 != proc.mExitCode) {
         printf("(expected 0 == return code, got %d)\n", proc.mExitCode);
         puts("(output)\n----------------------------------\n");
         puts(proc.mStdout.get());
         puts("----------------------------------\n");
         puts("(error output)\n----------------------------------\n");
         puts(proc.mStderr.get());
--- a/xpcom/tests/TestDeadlockDetectorScalability.cpp
+++ b/xpcom/tests/TestDeadlockDetectorScalability.cpp
@@ -51,23 +51,23 @@
 #define FAIL(why)                               \
     do {                                        \
         fail(why);                              \
         return NS_ERROR_FAILURE;                \
     } while (0);
 
 #ifdef OLD_API
 #  include "nsAutoLock.h"
-   typedef PRLock* lock_t;
+   typedef PRLock* moz_lock_t;
 #  define NEWLOCK(n) nsAutoLock::NewLock(n)
 #  define DELETELOCK(v) nsAutoLock::DestroyLock(v)
 #  define AUTOLOCK(v, l) nsAutoLock v(l)
 #else
 #  include "mozilla/Mutex.h"
-   typedef mozilla::Mutex* lock_t;
+   typedef mozilla::Mutex* moz_lock_t;
 #  define NEWLOCK(n) new mozilla::Mutex(n)
 #  define DELETELOCK(v) delete (v)
 #  define AUTOLOCK(v, l) mozilla::MutexAutoLock v(*l)
 #endif
 
 // def/undef these to run particular tests.
 #undef DD_TEST1
 #undef DD_TEST2
@@ -78,17 +78,17 @@
 #ifdef DD_TEST1
 
 static void
 AllocLockRecurseUnlockFree(int i)
 {
     if (0 == i)
         return;
 
-    lock_t lock = NEWLOCK("deadlockDetector.scalability.t1");
+    moz_lock_t lock = NEWLOCK("deadlockDetector.scalability.t1");
     {
         AUTOLOCK(_, lock);
         AllocLockRecurseUnlockFree(i - 1);
     }
     DELETELOCK(lock);
 }
 
 // This test creates a resource dependency chain N elements long, then
@@ -106,18 +106,18 @@ LengthNDepChain(int N)
 
 #ifdef DD_TEST2
 
 // This test creates a single lock that is ordered < N resources, then
 // repeatedly exercises this order k times.
 static nsresult
 OneLockNDeps(const int N, const int K)
 {
-    lock_t lock = NEWLOCK("deadlockDetector.scalability.t2.master");
-    lock_t* locks = new lock_t[N];
+    moz_lock_t lock = NEWLOCK("deadlockDetector.scalability.t2.master");
+    moz_lock_t* locks = new moz_lock_t[N];
     if (!locks)
         NS_RUNTIMEABORT("couldn't allocate lock array");
 
     for (int i = 0; i < N; ++i)
         locks[i] =
             NEWLOCK("deadlockDetector.scalability.t2.dep");
 
     // establish orders
@@ -151,17 +151,17 @@ OneLockNDeps(const int N, const int K)
 // acquisitions k times.  Finally, all resources are freed.
 //
 // It's very difficult to perform well on this test.  It's put forth as a
 // challenge problem.
 
 static nsresult
 MaxDepsNsq(const int N, const int K)
 {
-    lock_t* locks = new lock_t[N];
+    moz_lock_t* locks = new moz_lock_t[N];
     if (!locks)
         NS_RUNTIMEABORT("couldn't allocate lock array");
 
     for (int i = 0; i < N; ++i)
         locks[i] = NEWLOCK("deadlockDetector.scalability.t3");
 
     for (int i = 0; i < N; ++i) {
         AUTOLOCK(al1, locks[i]);