pal_debug.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* -*- mode:c; c-file-style:"k&r"; c-basic-offset: 4; tab-width:4; indent-tabs-mode:nil; mode:auto-fill; fill-column:78; -*- */
  2. /* vim: set ts=4 sw=4 et tw=78 fo=cqt wm=0: */
  3. /* Copyright (C) 2014 OSCAR lab, Stony Brook University
  4. This file is part of Graphene Library OS.
  5. Graphene Library OS is free software: you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License
  7. as published by the Free Software Foundation, either version 3 of the
  8. License, or (at your option) any later version.
  9. Graphene Library OS is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  15. /*
  16. * pal_debug.h
  17. *
  18. * This file contains definitions of APIs used for debug purposes.
  19. */
  20. #ifndef PAL_DEBUG_H
  21. #define PAL_DEBUG_H
  22. #include "pal.h"
  23. #ifdef IN_PAL
  24. void __assert (void);
  25. #define assert(val) \
  26. do { \
  27. if (!(val)) { \
  28. printf("Assertion failed (%s): %s: %d\n", #val, \
  29. __FILE__, __LINE__); \
  30. __assert(); \
  31. _DkProcessExit(1); \
  32. } \
  33. } while (0)
  34. #define abort(msg) \
  35. do { \
  36. if (!(val)) { \
  37. printf("Assertion failed (%s): %s: %d\n", msg, \
  38. __FILE__, __LINE__); \
  39. __assert(); \
  40. _DkProcessExit(1); \
  41. } \
  42. } while (0)
  43. #else
  44. int pal_printf (const char *fmt, ...);
  45. int pal_snprintf (char *buf, size_t n, const char *fmt, ...);
  46. int pal_atoi (const char *nptr);
  47. long int pal_atol (const char *nptr);
  48. #endif
  49. #endif