trace_nt.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* trace_nt.h - Debugging routines
  2. Written by Juan Grigera<grigera@isis.unlp.edu.ar>
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. */
  15. /* ------------------------------------------------------------------------------------------ *
  16. TRACER FUNCTIONS
  17. * ------------------------------------------------------------------------------------------ */
  18. #ifdef HAVE_TRACE
  19. /************************/
  20. /* Debug version */
  21. /************************/
  22. /* Macros
  23. ------
  24. win32Trace(x) - Trace macro. Use double in parenthesis for x. Same args as printf.
  25. win32ASSERT(x) - assert macro, but will not abort program and output sent to trace routine.
  26. win32APICALL(x) - Use to enclose a Win32 system call that should return TRUE.
  27. win32APICALL_HANDLE(h,api) - Use to enclose a Win32 system call that should return a handle.
  28. */
  29. #define win32Trace(x) if (__win32_tracing_enabled) _win32Trace x
  30. #define win32ASSERT(x) if (!(x)) _win32DebugAssertionFailed (#x, __LINE__, __FILE__)
  31. #define win32APICALL(x) if (!(x)) _win32DebugFailedWin32APICall (#x, __LINE__, __FILE__)
  32. #define win32APICALL_HANDLE(h,api) h=api; if (h==INVALID_HANDLE_VALUE) _win32DebugFailedWin32APICall (#h" = "#api, __LINE__, __FILE__)
  33. /* Prototypes */
  34. void _win32Trace (const char *, ...);
  35. void _win32DebugFailedWin32APICall (const char *name, int line, const char *file);
  36. void _win32DebugAssertionFailed (const char *name, int line, const char *file);
  37. void _win32SetTrace (int trace);
  38. void _win32TraceOn (void);
  39. void _win32TraceOff (void);
  40. #define SetTrace _win32SetTrace
  41. #define TraceOn _win32TraceOn
  42. #define TraceOff _win32TraceOff
  43. /* Global variables */
  44. extern int __win32_tracing_enabled;
  45. #else
  46. /************************/
  47. /* Non-debug version */
  48. /************************/
  49. /* Wipe-out these macros */
  50. #define win32Trace(x)
  51. #define win32ASSERT(x)
  52. #define win32APICALL(x) x
  53. #define win32APICALL_HANDLE(h,api) h=api;
  54. /* Wipe-out these funcs */
  55. #define SetTrace(x)
  56. #define TraceOn()
  57. #define TraceOff()
  58. #endif