All pastes #534256 Raw Edit

Stuff

public text v1 · immutable
·published 2007-06-03 18:43 UTC
rendered paste body
---
 xpcom/ds/nsExpirationTracker.h |   15 +++++++++++++++
 1 file changed, 15 insertions(+)

Index: mozilla/xpcom/ds/nsExpirationTracker.h
===================================================================
--- mozilla.orig/xpcom/ds/nsExpirationTracker.h	2007-05-28 14:51:08.000000000 +0000
+++ mozilla/xpcom/ds/nsExpirationTracker.h	2007-06-03 18:41:25.000000000 +0000
@@ -40,16 +40,31 @@
 #define NSEXPIRATIONTRACKER_H_
 
 #include "prlog.h"
 #include "nsTArray.h"
 #include "nsITimer.h"
 #include "nsCOMPtr.h"
 #include "nsComponentManagerUtils.h"
 
+/* asac: backported from trunk nspr
+ ** Compile-time assert. "condition" must be a constant expression.
+ ** The macro should be used only once per source line in places where
+ ** a "typedef" declaration is allowed.
+ ** For stringification of the line numbers where the macro is used we need some
+ ** macro indirection. IMPL is required to get macro-expansion of __LINE__ to
+ ** its integer value so that IMPL2 will stringify the number, not "__LINE__".
+ */
+ #define PR_STATIC_ASSERT(condition)                                           \
+     PR_STATIC_ASSERT_IMPL(condition, __LINE__)
+ #define PR_STATIC_ASSERT_IMPL(condition, line)                                \
+     PR_STATIC_ASSERT_IMPL2(condition, line)
+ #define PR_STATIC_ASSERT_IMPL2(condition, line)                               \
+     typedef int pr_static_assert_line_##line[(condition) ? 1 : -1]
+
 /**
  * Data used to track the expiration state of an object. We promise that this
  * is 32 bits so that objects that includes this as a field can pad and align
  * efficiently.
  */
 struct nsExpirationState {
   enum { NOT_TRACKED = (1U << 4) - 1,
          MAX_INDEX_IN_GENERATION = (1U << 28) - 1 };