VirtualBox

source: kBuild/trunk/src/grep/lib/assure.h

Last change on this file was 3529, checked in by bird, 3 years ago

Imported grep 3.7 from grep-3.7.tar.gz (sha256: c22b0cf2d4f6bbe599c902387e8058990e1eee99aef333a203829e5fd3dbb342), applying minimal auto-props.

  • Property svn:eol-style set to native
File size: 1.9 KB
Line 
1/* Run-time assert-like macros.
2
3 Copyright (C) 2014-2021 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18/* Written by Paul Eggert. */
19
20#ifndef _GL_ASSURE_H
21#define _GL_ASSURE_H
22
23#include <assert.h>
24#include "verify.h"
25
26/* Evaluate an assertion E that is guaranteed to be true.
27 If NDEBUG is not defined, abort the program if E is false.
28 If NDEBUG is defined, the compiler can assume E and behavior is
29 undefined if E is false, fails to evaluate, or has side effects.
30
31 Unlike standard 'assert', this macro evaluates E even when NDEBUG
32 is defined, so as to catch typos, avoid some GCC warnings, and
33 improve performance when E is simple enough.
34
35 Also see the documentation for 'assume' in verify.h. */
36
37#ifdef NDEBUG
38# define affirm(E) assume (E)
39#else
40# define affirm(E) assert (E)
41#endif
42
43/* Check E's value at runtime, and report an error and abort if not.
44 However, do nothing if NDEBUG is defined.
45
46 Unlike standard 'assert', this macro compiles E even when NDEBUG
47 is defined, so as to catch typos and avoid some GCC warnings.
48 Unlike 'affirm', it is OK for E to use hard-to-optimize features,
49 since E is not executed if NDEBUG is defined. */
50
51#ifdef NDEBUG
52# define assure(E) ((void) (0 && (E)))
53#else
54# define assure(E) assert (E)
55#endif
56
57#endif
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette