2010-09-30 21:57:31 +00:00
|
|
|
/*
|
|
|
|
* copyright (c) 2010 Michael Niedermayer <michaelni@gmx.at>
|
|
|
|
*
|
|
|
|
* This file is part of FFmpeg.
|
|
|
|
*
|
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* simple assert() macros that are a bit more flexible than ISO C assert().
|
|
|
|
* @author Michael Niedermayer <michaelni@gmx.at>
|
|
|
|
*/
|
|
|
|
|
2010-10-01 13:55:13 +00:00
|
|
|
#ifndef AVUTIL_AVASSERT_H
|
|
|
|
#define AVUTIL_AVASSERT_H
|
2010-09-30 21:57:31 +00:00
|
|
|
|
2010-10-01 13:55:20 +00:00
|
|
|
#include <stdlib.h>
|
2023-04-26 12:29:29 +00:00
|
|
|
#ifdef HAVE_AV_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
2010-09-30 21:57:31 +00:00
|
|
|
#include "log.h"
|
2021-07-23 15:50:51 +00:00
|
|
|
#include "macros.h"
|
2010-09-30 21:57:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* assert() equivalent, that is always enabled.
|
|
|
|
*/
|
2010-10-01 13:55:16 +00:00
|
|
|
#define av_assert0(cond) do { \
|
|
|
|
if (!(cond)) { \
|
2012-12-03 19:42:08 +00:00
|
|
|
av_log(NULL, AV_LOG_PANIC, "Assertion %s failed at %s:%d\n", \
|
2010-10-01 13:55:16 +00:00
|
|
|
AV_STRINGIFY(cond), __FILE__, __LINE__); \
|
|
|
|
abort(); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
2010-09-30 21:57:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* assert() equivalent, that does not lie in speed critical code.
|
2016-04-27 17:45:23 +00:00
|
|
|
* These asserts() thus can be enabled without fearing speed loss.
|
2010-09-30 21:57:31 +00:00
|
|
|
*/
|
|
|
|
#if defined(ASSERT_LEVEL) && ASSERT_LEVEL > 0
|
2010-09-30 22:52:29 +00:00
|
|
|
#define av_assert1(cond) av_assert0(cond)
|
2010-09-30 21:57:31 +00:00
|
|
|
#else
|
|
|
|
#define av_assert1(cond) ((void)0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* assert() equivalent, that does lie in speed critical code.
|
|
|
|
*/
|
|
|
|
#if defined(ASSERT_LEVEL) && ASSERT_LEVEL > 1
|
2010-09-30 22:52:29 +00:00
|
|
|
#define av_assert2(cond) av_assert0(cond)
|
2016-10-21 10:50:03 +00:00
|
|
|
#define av_assert2_fpu() av_assert0_fpu()
|
2010-09-30 21:57:31 +00:00
|
|
|
#else
|
|
|
|
#define av_assert2(cond) ((void)0)
|
2016-10-21 10:50:03 +00:00
|
|
|
#define av_assert2_fpu() ((void)0)
|
2010-09-30 21:57:31 +00:00
|
|
|
#endif
|
|
|
|
|
2016-10-21 10:50:03 +00:00
|
|
|
/**
|
2018-08-30 06:56:18 +00:00
|
|
|
* Assert that floating point operations can be executed.
|
2016-10-21 10:50:03 +00:00
|
|
|
*
|
|
|
|
* This will av_assert0() that the cpu is not in MMX state on X86
|
|
|
|
*/
|
|
|
|
void av_assert0_fpu(void);
|
|
|
|
|
2011-05-17 14:58:04 +00:00
|
|
|
#endif /* AVUTIL_AVASSERT_H */
|