debug.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /****************************************************************************
  2. **
  3. ** NAME:
  4. ** debug.h
  5. **
  6. ** DESCRIPTION:
  7. ** This header file defines the debug macros used in pthreads. To turn
  8. ** debugging on, add -DDEBUG_PT to CFLAGS. It was added to the original
  9. ** distribution of linuxthreads.
  10. **
  11. ** This program is free software; you can redistribute it and/or
  12. ** modify it under the terms of the GNU Library General Public License
  13. ** as published by the Free Software Foundation; either version 2
  14. ** of the License, or (at your option) any later version.
  15. **
  16. ** This program is distributed in the hope that it will be useful,
  17. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. ** GNU Library General Public License for more details.
  20. **
  21. ****************************************************************************/
  22. #ifndef _PT_DEBUG_H
  23. #define _PT_DEBUG_H
  24. #include <features.h>
  25. #ifdef __DODEBUG_PT__
  26. # define DEBUG_PT
  27. #endif
  28. /* include asserts for now */
  29. #define DO_ASSERT
  30. /* define the PDEBUG macro here */
  31. #undef PDEBUG
  32. #ifdef DEBUG_PT
  33. # define PDEBUG(fmt, args...) __pthread_message("%s: " fmt, __FUNCTION__, ## args)
  34. #else
  35. # define PDEBUG(fmt, args...) /* debug switched off */
  36. #endif
  37. /* nothing; placeholder to disable a PDEBUG message but don't delete it */
  38. #undef PDEBUGG
  39. #define PDEBUGG(fmt, args...)
  40. /* Define ASSERT to stop/warn. Should be void in production code */
  41. #undef ASSERT
  42. #ifdef DO_ASSERT
  43. # define ASSERT(x) if (!(x)) fprintf(stderr, "pt: assertion failed in %s:%i.\n",\
  44. __FILE__, __LINE__)
  45. #else
  46. # define ASSERT(x)
  47. #endif
  48. #endif /* _PT_DEBUG_H */