zassert.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * $Id: zassert.h,v 1.2 2004/12/03 18:01:04 ajs Exp $
  3. *
  4. * This file is part of Quagga.
  5. *
  6. * Quagga is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation; either version 2, or (at your option) any
  9. * later version.
  10. *
  11. * Quagga is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Quagga; see the file COPYING. If not, write to the Free
  18. * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  19. * 02111-1307, USA.
  20. */
  21. #ifndef _QUAGGA_ASSERT_H
  22. #define _QUAGGA_ASSERT_H
  23. extern void _zlog_assert_failed (const char *assertion, const char *file,
  24. unsigned int line, const char *function)
  25. __attribute__ ((noreturn));
  26. #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  27. #define __ASSERT_FUNCTION __func__
  28. #elif defined(__GNUC__)
  29. #define __ASSERT_FUNCTION __FUNCTION__
  30. #else
  31. #define __ASSERT_FUNCTION NULL
  32. #endif
  33. #define zassert(EX) ((void)((EX) ? 0 : \
  34. (_zlog_assert_failed(#EX, __FILE__, __LINE__, \
  35. __ASSERT_FUNCTION), 0)))
  36. #undef assert
  37. #define assert(EX) zassert(EX)
  38. #endif /* _QUAGGA_ASSERT_H */