LibreOffice Module onlineupdate (master) 1
Macros | Functions
Assertions.h File Reference
#include "Attributes.h"
#include "Compiler.h"
#include "Likely.h"
#include "MacroArgs.h"
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
Include dependency graph for Assertions.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MOZ_STATIC_ASSERT_UNUSED_ATTRIBUTE   /* nothing */
 
#define MOZ_STATIC_ASSERT_GLUE1(x, y)   x##y
 
#define MOZ_STATIC_ASSERT_GLUE(x, y)   MOZ_STATIC_ASSERT_GLUE1(x, y)
 
#define MOZ_STATIC_ASSERT(cond, reason)    extern void MOZ_STATIC_ASSERT_GLUE(moz_static_assert, __LINE__)(int arg[(cond) ? 1 : -1]) MOZ_STATIC_ASSERT_UNUSED_ATTRIBUTE
 
#define MOZ_STATIC_ASSERT_IF(cond, expr, reason)   MOZ_STATIC_ASSERT(!(cond) || (expr), reason)
 
#define MOZ_REALLY_CRASH()
 MOZ_REALLY_CRASH is used in the implementation of MOZ_CRASH(). More...
 
#define MOZ_CRASH(...)
 
#define MOZ_VALIDATE_ASSERT_CONDITION_TYPE(x)
 
#define MOZ_ASSERT_HELPER1(expr)
 
#define MOZ_ASSERT_HELPER2(expr, explain)
 
#define MOZ_RELEASE_ASSERT_GLUE(a, b)   a b
 
#define MOZ_RELEASE_ASSERT(...)
 
#define MOZ_ASSERT(...)   MOZ_RELEASE_ASSERT(__VA_ARGS__)
 
#define MOZ_DIAGNOSTIC_ASSERT   MOZ_RELEASE_ASSERT
 
#define MOZ_ASSERT_IF(cond, expr)
 
#define MOZ_ASSUME_UNREACHABLE_MARKER()   abort()
 
#define MOZ_ASSERT_UNREACHABLE(reason)    MOZ_ASSERT(false, "MOZ_ASSERT_UNREACHABLE: " reason)
 
#define MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE(reason)
 
#define MOZ_ALWAYS_TRUE(expr)   MOZ_ASSERT((expr))
 
#define MOZ_ALWAYS_FALSE(expr)   MOZ_ASSERT(!(expr))
 

Functions

static MOZ_COLD MOZ_ALWAYS_INLINE void MOZ_ReportAssertionFailure (const char *aStr, const char *aFilename, int aLine) MOZ_PRETEND_NORETURN_FOR_STATIC_ANALYSIS
 
static MOZ_COLD MOZ_ALWAYS_INLINE void MOZ_ReportCrash (const char *aStr, const char *aFilename, int aLine) MOZ_PRETEND_NORETURN_FOR_STATIC_ANALYSIS
 

Macro Definition Documentation

◆ MOZ_ALWAYS_FALSE

#define MOZ_ALWAYS_FALSE (   expr)    MOZ_ASSERT(!(expr))

Definition at line 495 of file Assertions.h.

◆ MOZ_ALWAYS_TRUE

#define MOZ_ALWAYS_TRUE (   expr)    MOZ_ASSERT((expr))

Definition at line 494 of file Assertions.h.

◆ MOZ_ASSERT

#define MOZ_ASSERT (   ...)    MOZ_RELEASE_ASSERT(__VA_ARGS__)

Definition at line 383 of file Assertions.h.

◆ MOZ_ASSERT_HELPER1

#define MOZ_ASSERT_HELPER1 (   expr)
Value:
do { \
MOZ_VALIDATE_ASSERT_CONDITION_TYPE(expr); \
if (MOZ_UNLIKELY(!(expr))) { \
MOZ_ReportAssertionFailure(#expr, __FILE__, __LINE__); \
MOZ_REALLY_CRASH(); \
} \
} while (0)
#define MOZ_UNLIKELY(x)
Definition: Likely.h:20

Definition at line 358 of file Assertions.h.

◆ MOZ_ASSERT_HELPER2

#define MOZ_ASSERT_HELPER2 (   expr,
  explain 
)
Value:
do { \
MOZ_VALIDATE_ASSERT_CONDITION_TYPE(expr); \
if (MOZ_UNLIKELY(!(expr))) { \
MOZ_ReportAssertionFailure(#expr " (" explain ")", __FILE__, __LINE__); \
MOZ_REALLY_CRASH(); \
} \
} while (0)

Definition at line 367 of file Assertions.h.

◆ MOZ_ASSERT_IF

#define MOZ_ASSERT_IF (   cond,
  expr 
)
Value:
do { \
if (cond) { \
MOZ_ASSERT(expr); \
} \
} while (0)

Definition at line 404 of file Assertions.h.

◆ MOZ_ASSERT_UNREACHABLE

#define MOZ_ASSERT_UNREACHABLE (   reason)     MOZ_ASSERT(false, "MOZ_ASSERT_UNREACHABLE: " reason)

Definition at line 478 of file Assertions.h.

◆ MOZ_ASSUME_UNREACHABLE_MARKER

#define MOZ_ASSUME_UNREACHABLE_MARKER ( )    abort()

Definition at line 429 of file Assertions.h.

◆ MOZ_CRASH

#define MOZ_CRASH (   ...)
Value:
do { \
MOZ_ReportCrash("" __VA_ARGS__, __FILE__, __LINE__); \
MOZ_REALLY_CRASH(); \
} while (0)

Definition at line 254 of file Assertions.h.

◆ MOZ_DIAGNOSTIC_ASSERT

#define MOZ_DIAGNOSTIC_ASSERT   MOZ_RELEASE_ASSERT

Definition at line 391 of file Assertions.h.

◆ MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE

#define MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE (   reason)
Value:
do { \
MOZ_ASSERT_UNREACHABLE(reason); \
MOZ_ASSUME_UNREACHABLE_MARKER(); \
} while (0)

Definition at line 481 of file Assertions.h.

◆ MOZ_REALLY_CRASH

#define MOZ_REALLY_CRASH ( )
Value:
do { \
*((volatile int*) NULL) = __LINE__; \
abort(); \
} while (0)

MOZ_REALLY_CRASH is used in the implementation of MOZ_CRASH().

You should call MOZ_CRASH instead.

Definition at line 222 of file Assertions.h.

◆ MOZ_RELEASE_ASSERT

#define MOZ_RELEASE_ASSERT (   ...)
Value:
MOZ_PASTE_PREFIX_AND_ARG_COUNT(MOZ_ASSERT_HELPER, __VA_ARGS__), \
(__VA_ARGS__))
#define MOZ_RELEASE_ASSERT_GLUE(a, b)
Definition: Assertions.h:376
#define MOZ_PASTE_PREFIX_AND_ARG_COUNT(aPrefix,...)
Definition: MacroArgs.h:39

Definition at line 377 of file Assertions.h.

◆ MOZ_RELEASE_ASSERT_GLUE

#define MOZ_RELEASE_ASSERT_GLUE (   a,
 
)    a b

Definition at line 376 of file Assertions.h.

◆ MOZ_STATIC_ASSERT

#define MOZ_STATIC_ASSERT (   cond,
  reason 
)     extern void MOZ_STATIC_ASSERT_GLUE(moz_static_assert, __LINE__)(int arg[(cond) ? 1 : -1]) MOZ_STATIC_ASSERT_UNUSED_ATTRIBUTE

Definition at line 113 of file Assertions.h.

◆ MOZ_STATIC_ASSERT_GLUE

#define MOZ_STATIC_ASSERT_GLUE (   x,
  y 
)    MOZ_STATIC_ASSERT_GLUE1(x, y)

Definition at line 80 of file Assertions.h.

◆ MOZ_STATIC_ASSERT_GLUE1

#define MOZ_STATIC_ASSERT_GLUE1 (   x,
  y 
)    x##y

Definition at line 79 of file Assertions.h.

◆ MOZ_STATIC_ASSERT_IF

#define MOZ_STATIC_ASSERT_IF (   cond,
  expr,
  reason 
)    MOZ_STATIC_ASSERT(!(cond) || (expr), reason)

Definition at line 117 of file Assertions.h.

◆ MOZ_STATIC_ASSERT_UNUSED_ATTRIBUTE

#define MOZ_STATIC_ASSERT_UNUSED_ATTRIBUTE   /* nothing */

Definition at line 77 of file Assertions.h.

◆ MOZ_VALIDATE_ASSERT_CONDITION_TYPE

#define MOZ_VALIDATE_ASSERT_CONDITION_TYPE (   x)

Definition at line 354 of file Assertions.h.

Function Documentation

◆ MOZ_ReportAssertionFailure()

static MOZ_COLD MOZ_ALWAYS_INLINE void MOZ_ReportAssertionFailure ( const char *  aStr,
const char *  aFilename,
int  aLine 
)
static

Definition at line 135 of file Assertions.h.

References aStr, and nsTraceRefcnt::WalkTheStack().

◆ MOZ_ReportCrash()

static MOZ_COLD MOZ_ALWAYS_INLINE void MOZ_ReportCrash ( const char *  aStr,
const char *  aFilename,
int  aLine 
)
static

Definition at line 152 of file Assertions.h.

References aStr, and nsTraceRefcnt::WalkTheStack().