Non reinvents the DAW. Powerful enough to form a complete studio, fast and light enough to run on low-end hardware like the eeePC or Raspberry Pi, and so reliable that it can be used live https://non.tuxfamily.org/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

117 lines
4.3KB

  1. /*******************************************************************************/
  2. /* Copyright (C) 2008 Jonathan Moore Liles */
  3. /* */
  4. /* This program is free software; you can redistribute it and/or modify it */
  5. /* under the terms of the GNU General Public License as published by the */
  6. /* Free Software Foundation; either version 2 of the License, or (at your */
  7. /* option) any later version. */
  8. /* */
  9. /* This program is distributed in the hope that it will be useful, but WITHOUT */
  10. /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
  11. /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */
  12. /* more details. */
  13. /* */
  14. /* You should have received a copy of the GNU General Public License along */
  15. /* with This program; see the file COPYING. If not,write to the Free Software */
  16. /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  17. /*******************************************************************************/
  18. /* debug.h
  19. *
  20. * 11/21/2003 - Jonathan Moore Liles
  21. *
  22. * Debuging support.
  23. *
  24. * Disable by defining the preprocessor variable NDEBUG prior to inclusion.
  25. *
  26. * The following macros sould be defined as string literals
  27. *
  28. * name value
  29. *
  30. * __MODULE__ Name of module. eg. "libfoo"
  31. *
  32. * __FILE__ Name of file. eg. "foo.c"
  33. *
  34. * __FUNCTION__ Name of enclosing function. eg. "bar"
  35. *
  36. * (inteter literal)
  37. * __LINE__ Number of enclosing line.
  38. *
  39. *
  40. * __FILE__, and __LINE__ are automatically defined by standard CPP
  41. * implementations. __FUNCTION__ is more or less unique to GNU, and isn't
  42. * strictly a preprocessor macro, but rather a reserved word in the compiler.
  43. * There is a sed script available with this toolset that is able to fake
  44. * __FUNCTION__ (among other things) with an extra preprocesessing step.
  45. *
  46. * __MODULE__ is nonstandard and should be defined the enclosing program(s).
  47. * Autoconf defines PACKAGE as the module name, and these routines will use its
  48. * value instead if __MODULE__ is undefined.
  49. *
  50. * The following routines are provided (as macros) and take the same arguments
  51. * as printf():
  52. *
  53. * MESSAGE( const char *format, ... )
  54. * WARNING( const char *format, ... )
  55. * FATAL( const char *format, ... )
  56. *
  57. * Calling MESSAGE or WARNING prints the message to stderr along with module,
  58. * file and line information, as well as appropriate emphasis. Calling
  59. * FATAL will do the same, and then call abort() to end the program. It is
  60. * unwise to supply any of these marcros with arguments that produce side
  61. * effects. As, doing so will most likely result in Heisenbugs; program
  62. * behavior that changes when debugging is disabled.
  63. *
  64. */
  65. #ifndef _DEBUG_H
  66. #define _DEBUG_H
  67. #ifndef __MODULE__
  68. #ifdef PACKAGE
  69. #define __MODULE__ PACKAGE
  70. #else
  71. #define __MODULE__ NULL
  72. #endif
  73. #endif
  74. #ifndef __GNUC__
  75. #define __FUNCTION__ NULL
  76. #endif
  77. #include <string.h>
  78. #include <stdio.h>
  79. #include <stdarg.h>
  80. typedef enum {
  81. W_MESSAGE = 0,
  82. W_WARNING,
  83. W_FATAL
  84. } warning_t;
  85. void
  86. warnf ( warning_t level,
  87. const char *module,
  88. const char *file,
  89. const char *function, size_t line, const char *fmt, ... );
  90. #ifndef NDEBUG
  91. #define DMESSAGE( fmt, args... ) warnf( W_MESSAGE, __MODULE__, __FILE__, __FUNCTION__, __LINE__, fmt, ## args )
  92. #define DWARNING( fmt, args... ) warnf( W_WARNING, __MODULE__, __FILE__, __FUNCTION__, __LINE__, fmt, ## args )
  93. #define ASSERT( pred, fmt, args... ) do { if ( ! (pred) ) { warnf( W_FATAL, __MODULE__, __FILE__, __FUNCTION__, __LINE__, fmt, ## args ); abort(); } } while ( 0 )
  94. #else
  95. #define DMESSAGE( fmt, args... )
  96. #define DWARNING( fmt, args... )
  97. #define ASSERT( pred, fmt, args... )
  98. #endif
  99. /* these are always defined */
  100. #define MESSAGE( fmt, args... ) warnf( W_MESSAGE, __MODULE__, __FILE__, __FUNCTION__, __LINE__, fmt, ## args )
  101. #define WARNING( fmt, args... ) warnf( W_WARNING, __MODULE__, __FILE__, __FUNCTION__, __LINE__, fmt, ## args )
  102. #define FATAL( fmt, args... ) ( warnf( W_FATAL, __MODULE__, __FILE__, __FUNCTION__, __LINE__, fmt, ## args ), abort() )
  103. #endif