File: assert.h

package info (click to toggle)
memtest86%2B 6.10-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,532 kB
  • sloc: ansic: 19,267; asm: 2,027; makefile: 367; sh: 134
file content (25 lines) | stat: -rw-r--r-- 453 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// 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