memtest86plus/lib/assert.h
Martin Whitaker 4078b7760e Faster barrier implementation.
The old barrier implementation was very slow when running on a multi-socket
machine (pcmemtest issue 16).

The new implementation provides two options:

  - when blocked, spin on a thread-local flag
  - when blocked, execute a HLT instruction and wait for a NMI

The first option might be faster, but we need to measure it to find out. A
new boot command line option is provided to select between the two, with a
third setting that uses a mixture of the two.
2022-02-28 22:05:21 +00:00

26 lines
453 B
C

// SPDX-License-Identifier: GPL-2.0
#ifndef ASSERT_H
#define ASSERT_H
/**
* \file
*
* Provides a function to terminate the program if an unexpected and fatal
* error is detected.
*
*//*
* Copyright (C) 2022 Martin Whitaker.
*/
/*
* Terminates the program (using a breakpoint exception) if expr is equal
* to zero.
*/
static inline void assert(int expr)
{
if (!expr) {
__asm__ __volatile__ ("int $3");
}
}
#endif // ASSERT_H