Files
memtest86plus/lib/assert.h
T

30 lines
579 B
C
Raw Normal View History

2022-02-28 20:21:50 +00:00
// 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) {
2024-08-30 19:38:46 +08:00
#if defined(__i386__) || defined(__x86_64__)
2022-02-28 20:21:50 +00:00
__asm__ __volatile__ ("int $3");
2024-08-30 19:38:46 +08:00
#elif defined(__loongarch_lp64)
__asm__ __volatile__ ("break 0");
#endif
2022-02-28 20:21:50 +00:00
}
}
#endif // ASSERT_H