diff --git a/js/src/plify_jsdhash.sed b/js/src/plify_jsdhash.sed index ea3b2e73428d..b58e7fde43fb 100644 --- a/js/src/plify_jsdhash.sed +++ b/js/src/plify_jsdhash.sed @@ -9,7 +9,7 @@ s/jsbit\.h/prbit.h/ s/jsdhash\.h/pldhash.h/ s/jsdhash\.c/pldhash.c/ s/jsdhash:/pldhash:/ -s/jsutil\.h/prlog.h/ +s/jsutil\.h/nsDebug.h/ s/JS_DHASH/PL_DHASH/g s/JS_DHash/PL_DHash/g s/JSDHash/PLDHash/g @@ -28,4 +28,5 @@ s/JS_PUBLIC_API(\([^()]*\))/\1/ s/JS_DLL_CALLBACK/PR_CALLBACK/ s/JS_STATIC_DLL_CALLBACK/PR_STATIC_CALLBACK/ s/JS_NewDHashTable/PL_NewDHashTable/ +s/JS_ASSERT(\(.*\));/NS_ASSERTION(\1, "PLDHash precondition");/ s/JS_/PR_/g diff --git a/layout/xul/base/src/nsBox.h b/layout/xul/base/src/nsBox.h index dbcbf3a5d21d..507156cb7c46 100644 --- a/layout/xul/base/src/nsBox.h +++ b/layout/xul/base/src/nsBox.h @@ -181,7 +181,7 @@ private: #define NS_BOX_ASSERTION(box,expr,str) \ if (!(expr)) { \ box->DumpBox(stdout); \ - nsDebug::Assertion(str, #expr, __FILE__, __LINE__); \ + NSGlue_Assertion(str, #expr, __FILE__, __LINE__); \ } #else #define NS_BOX_ASSERTION(box,expr,str) {} diff --git a/xpcom/base/nsDebugImpl.cpp b/xpcom/base/nsDebugImpl.cpp index 1e863a3797bd..9e1595d4cfdc 100644 --- a/xpcom/base/nsDebugImpl.cpp +++ b/xpcom/base/nsDebugImpl.cpp @@ -244,7 +244,7 @@ nsDebugImpl::Assertion(const char *aStr, const char *aExpr, const char *aFile, P "Click Enter to continue running the Application.", buf); ULONG code = MBID_ERROR; code = WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, msg, - "nsDebug::Assertion", 0, + "NSGlue_Assertion", 0, MB_ERROR | MB_ENTERCANCEL); /* It is possible that we are executing on a thread that doesn't have a diff --git a/xpcom/glue/nsDebug.cpp b/xpcom/glue/nsDebug.cpp index cc1b3f978fa8..604ae480b9e0 100644 --- a/xpcom/glue/nsDebug.cpp +++ b/xpcom/glue/nsDebug.cpp @@ -75,7 +75,7 @@ void GlueShutdownDebug() } #endif -NS_COM_GLUE void nsDebug::Abort(const char* aFile, PRIntn aLine) +void NSGlue_Abort(const char* aFile, PRIntn aLine) { if (!ENSURE_DEBUGOBJECT) return; @@ -83,7 +83,7 @@ NS_COM_GLUE void nsDebug::Abort(const char* aFile, PRIntn aLine) gDebugObject->Abort(aFile, aLine); } -NS_COM_GLUE void nsDebug::Break(const char* aFile, PRIntn aLine) +void NSGlue_Break(const char* aFile, PRIntn aLine) { if (!ENSURE_DEBUGOBJECT) return; @@ -91,17 +91,15 @@ NS_COM_GLUE void nsDebug::Break(const char* aFile, PRIntn aLine) gDebugObject->Break(aFile, aLine); } -NS_COM_GLUE void nsDebug::Warning(const char* aStr, - const char* aFile, - PRIntn aLine) +void NSGlue_Warning(const char* aStr, const char* aFile, PRIntn aLine) { if (!ENSURE_DEBUGOBJECT) return; gDebugObject->Warning(aStr, aFile, aLine); } -NS_COM_GLUE void nsDebug::Assertion(const char* aStr, const char* aExpr, - const char* aFile, PRIntn aLine) +void NSGlue_Assertion(const char* aStr, const char* aExpr, + const char* aFile, PRIntn aLine) { if (!ENSURE_DEBUGOBJECT) return; diff --git a/xpcom/glue/nsDebug.h b/xpcom/glue/nsDebug.h index 6e4d0811c5e6..0baf782815d9 100644 --- a/xpcom/glue/nsDebug.h +++ b/xpcom/glue/nsDebug.h @@ -56,34 +56,34 @@ * conditionally compiled out. */ -/* in case this is included by a C file */ -#ifdef __cplusplus +PR_BEGIN_EXTERN_C -class nsDebug { -public: +/** + * Log a warning message to the debug log. + */ +NS_COM_GLUE NS_HIDDEN_(void) NS_FASTCALL +NSGlue_Warning(const char *aMessage, const char *aFile, PRIntn aLine); - /** - * Log a warning message to the debug log. - */ - static NS_COM_GLUE void Warning(const char* aMessage, - const char* aFile, PRIntn aLine); +/** + * Abort the executing program. This works on all architectures. + */ +NS_COM_GLUE NS_HIDDEN_(void) NS_FASTCALL +NSGlue_Abort(const char *aFile, PRIntn aLine); - /** - * Abort the executing program. This works on all architectures. - */ - static NS_COM_GLUE void Abort(const char* aFile, PRIntn aLine); +/** + * Break the executing program into the debugger. + */ +NS_COM_GLUE NS_HIDDEN_(void) NS_FASTCALL +NSGlue_Break(const char* aFile, PRIntn aLine); - /** - * Break the executing program into the debugger. - */ - static NS_COM_GLUE void Break(const char* aFile, PRIntn aLine); +/** + * Log an assertion message to the debug log + */ +NS_COM_GLUE NS_HIDDEN_(void) NS_FASTCALL +NSGlue_Assertion(const char* aStr, const char* aExpr, + const char* aFile, PRIntn aLine); - /** - * Log an assertion message to the debug log - */ - static NS_COM_GLUE void Assertion(const char* aStr, const char* aExpr, - const char* aFile, PRIntn aLine); -}; +PR_END_EXTERN_C #ifdef DEBUG @@ -106,7 +106,7 @@ public: #define NS_ABORT_IF_FALSE(_expr, _msg) \ PR_BEGIN_MACRO \ if (!(_expr)) { \ - nsDebug::Assertion(_msg, #_expr, __FILE__, __LINE__); \ + NSGlue_Assertion(_msg, #_expr, __FILE__, __LINE__); \ } \ PR_END_MACRO @@ -121,7 +121,7 @@ public: #define NS_WARN_IF_FALSE(_expr,_msg) \ PR_BEGIN_MACRO \ if (!(_expr)) { \ - nsDebug::Assertion(_msg, #_expr, __FILE__, __LINE__); \ + NSGlue_Assertion(_msg, #_expr, __FILE__, __LINE__); \ } \ PR_END_MACRO @@ -132,7 +132,7 @@ public: #define NS_PRECONDITION(expr, str) \ PR_BEGIN_MACRO \ if (!(expr)) { \ - nsDebug::Assertion(str, #expr, __FILE__, __LINE__); \ + NSGlue_Assertion(str, #expr, __FILE__, __LINE__); \ } \ PR_END_MACRO @@ -143,7 +143,7 @@ public: #define NS_ASSERTION(expr, str) \ PR_BEGIN_MACRO \ if (!(expr)) { \ - nsDebug::Assertion(str, #expr, __FILE__, __LINE__); \ + NSGlue_Assertion(str, #expr, __FILE__, __LINE__); \ } \ PR_END_MACRO @@ -154,7 +154,7 @@ public: #define NS_POSTCONDITION(expr, str) \ PR_BEGIN_MACRO \ if (!(expr)) { \ - nsDebug::Assertion(str, #expr, __FILE__, __LINE__); \ + NSGlue_Assertion(str, #expr, __FILE__, __LINE__); \ } \ PR_END_MACRO @@ -163,38 +163,38 @@ public: * an attempt was made to execute some unimplemented functionality. */ #define NS_NOTYETIMPLEMENTED(str) \ - nsDebug::Assertion(str, "NotYetImplemented", __FILE__, __LINE__) + NSGlue_Assertion(str, "NotYetImplemented", __FILE__, __LINE__) /** * This macros triggers a program failure if executed. It indicates that * an attempt was made to execute some unimplemented functionality. */ #define NS_NOTREACHED(str) \ - nsDebug::Assertion(str, "Not Reached", __FILE__, __LINE__) + NSGlue_Assertion(str, "Not Reached", __FILE__, __LINE__) /** * Log an error message. */ #define NS_ERROR(str) \ - nsDebug::Assertion(str, "Error", __FILE__, __LINE__) + NSGlue_Assertion(str, "Error", __FILE__, __LINE__) /** * Log a warning message. */ #define NS_WARNING(str) \ - nsDebug::Warning(str, __FILE__, __LINE__) + NSGlue_Warning(str, __FILE__, __LINE__) /** * Trigger an abort */ #define NS_ABORT() \ - nsDebug::Abort(__FILE__, __LINE__) + NSGlue_Abort(__FILE__, __LINE__) /** * Cause a break */ #define NS_BREAK() \ - nsDebug::Break(__FILE__, __LINE__) + NSGlue_Break(__FILE__, __LINE__) #else /* NS_DEBUG */ @@ -215,7 +215,6 @@ public: #define NS_BREAK() PR_BEGIN_MACRO /* nothing */ PR_END_MACRO #endif /* ! NS_DEBUG */ -#endif /* __cplusplus */ // Macros for checking the trueness of an expression passed in within an // interface implementation. These need to be compiled regardless of the diff --git a/xpcom/glue/pldhash.c b/xpcom/glue/pldhash.c index cee4f27d0243..552d7fb23fc3 100644 --- a/xpcom/glue/pldhash.c +++ b/xpcom/glue/pldhash.c @@ -46,7 +46,7 @@ #include #include "prbit.h" #include "pldhash.h" -#include "prlog.h" /* for PR_ASSERT */ +#include "nsDebug.h" /* for PR_ASSERT */ #ifdef PL_DHASHMETER # if defined MOZILLA_CLIENT && defined DEBUG_XXXbrendan @@ -247,7 +247,7 @@ PL_DHashTableSetAlphaBounds(PLDHashTable *table, * Reject obviously insane bounds, rather than trying to guess what the * buggy caller intended. */ - PR_ASSERT(0.5 <= maxAlpha && maxAlpha < 1 && 0 <= minAlpha); + NS_ASSERTION(0.5 <= maxAlpha && maxAlpha < 1 && 0 <= minAlpha, "PLDHash precondition"); if (maxAlpha < 0.5 || 1 <= maxAlpha || minAlpha < 0) return; @@ -256,7 +256,7 @@ PL_DHashTableSetAlphaBounds(PLDHashTable *table, * minimum size leaves no entries free, reduce maxAlpha based on minimum * size and the precision limit of maxAlphaFrac's fixed point format. */ - PR_ASSERT(PL_DHASH_MIN_SIZE - (maxAlpha * PL_DHASH_MIN_SIZE) >= 1); + NS_ASSERTION(PL_DHASH_MIN_SIZE - (maxAlpha * PL_DHASH_MIN_SIZE) >= 1, "PLDHash precondition"); if (PL_DHASH_MIN_SIZE - (maxAlpha * PL_DHASH_MIN_SIZE) < 1) { maxAlpha = (float) (PL_DHASH_MIN_SIZE - PR_MAX(PL_DHASH_MIN_SIZE / 256, 1)) @@ -268,7 +268,7 @@ PL_DHashTableSetAlphaBounds(PLDHashTable *table, * not to truncate an entry's worth of alpha when storing in minAlphaFrac * (8-bit fixed point format). */ - PR_ASSERT(minAlpha < maxAlpha / 2); + NS_ASSERTION(minAlpha < maxAlpha / 2, "PLDHash precondition"); if (minAlpha >= maxAlpha / 2) { size = PL_DHASH_TABLE_SIZE(table); minAlpha = (size * maxAlpha - PR_MAX(size / 256, 1)) / (2 * size); @@ -362,7 +362,7 @@ SearchTable(PLDHashTable *table, const void *key, PLDHashNumber keyHash, PRUint32 sizeMask; METER(table->stats.searches++); - PR_ASSERT(!(keyHash & COLLISION_FLAG)); + NS_ASSERTION(!(keyHash & COLLISION_FLAG), "PLDHash precondition"); /* Compute the primary hash address. */ hashShift = table->hashShift; @@ -470,7 +470,7 @@ ChangeTable(PLDHashTable *table, int deltaLog2) oldEntry->keyHash &= ~COLLISION_FLAG; newEntry = SearchTable(table, getKey(table, oldEntry), oldEntry->keyHash, PL_DHASH_ADD); - PR_ASSERT(PL_DHASH_ENTRY_IS_FREE(newEntry)); + NS_ASSERTION(PL_DHASH_ENTRY_IS_FREE(newEntry), "PLDHash precondition"); moveEntry(table, oldEntry, newEntry); newEntry->keyHash = oldEntry->keyHash; } @@ -575,7 +575,7 @@ PL_DHashTableOperate(PLDHashTable *table, const void *key, PLDHashOperator op) break; default: - PR_ASSERT(0); + NS_ASSERTION(0, "PLDHash precondition"); entry = NULL; } @@ -587,7 +587,7 @@ PL_DHashTableRawRemove(PLDHashTable *table, PLDHashEntryHdr *entry) { PLDHashNumber keyHash; /* load first in case clearEntry goofs it */ - PR_ASSERT(PL_DHASH_ENTRY_IS_LIVE(entry)); + NS_ASSERTION(PL_DHASH_ENTRY_IS_LIVE(entry), "PLDHash precondition"); keyHash = entry->keyHash; table->ops->clearEntry(table, entry); if (keyHash & COLLISION_FLAG) { diff --git a/xpcom/windbgdlg/windbgdlg.cpp b/xpcom/windbgdlg/windbgdlg.cpp index 4b6c881db761..1a19f0165694 100644 --- a/xpcom/windbgdlg/windbgdlg.cpp +++ b/xpcom/windbgdlg/windbgdlg.cpp @@ -85,7 +85,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, "Click Ignore to continue running the Application.", lpszCmdLine); - return MessageBox(NULL, msg, "nsDebug::Assertion", + return MessageBox(NULL, msg, "NSGlue_Assertion", MB_ICONSTOP | MB_SYSTEMMODAL| MB_ABORTRETRYIGNORE | MB_DEFBUTTON3); }