Blame src/microhttpd/mhd_assert.h

Packit 875988
/*
Packit 875988
  This file is part of libmicrohttpd
Packit 875988
  Copyright (C) 2017 Karlson2k (Evgeny Grin)
Packit 875988
Packit 875988
  This library is free software; you can redistribute it and/or
Packit 875988
  modify it under the terms of the GNU Lesser General Public
Packit 875988
  License as published by the Free Software Foundation; either
Packit 875988
  version 2.1 of the License, or (at your option) any later version.
Packit 875988
Packit 875988
  This library is distributed in the hope that it will be useful,
Packit 875988
  but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 875988
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 875988
  Lesser General Public License for more details.
Packit 875988
Packit 875988
  You should have received a copy of the GNU Lesser General Public
Packit 875988
  License along with this library.
Packit 875988
  If not, see <http://www.gnu.org/licenses/>.
Packit 875988
*/
Packit 875988
Packit 875988
/**
Packit 875988
 * @file microhttpd/mhd_assert.h
Packit 875988
 * @brief  macros for mhd_assert()
Packit 875988
 * @author Karlson2k (Evgeny Grin)
Packit 875988
 */
Packit 875988
Packit 875988
#ifndef MHD_ASSERT_H
Packit 875988
#define MHD_ASSERT_H 1
Packit 875988
Packit 875988
#include "mhd_options.h"
Packit 875988
#ifdef NDEBUG
Packit 875988
#  define mhd_assert(ignore) ((void)0)
Packit 875988
#else  /* _DEBUG */
Packit 875988
#  ifdef HAVE_ASSERT
Packit 875988
#    include <assert.h>
Packit 875988
#    define mhd_assert(CHK) assert(CHK)
Packit 875988
#  else  /* ! HAVE_ASSERT */
Packit 875988
#    include <stdio.h>
Packit 875988
#    include <stdlib.h>
Packit 875988
#    define mhd_assert(CHK) \
Packit 875988
       do { \
Packit 875988
           if (!(CHK)) { \
Packit 875988
             fprintf(stderr, "%s:%u Assertion failed: %s\nProgram aborted.\n", \
Packit 875988
                     __FILE__, (unsigned)__LINE__, #CHK); \
Packit 875988
             fflush(stderr); abort(); } \
Packit 875988
          } while(0)
Packit 875988
#  endif /* ! HAVE_ASSERT */
Packit 875988
#endif /* _DEBUG */
Packit 875988
Packit 875988
#endif /* ! MHD_ASSERT_H */