An emulator, assembler, and disassembler for the Sega Game Gear
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 

40 lignes
1.5 KiB

  1. /* Copyright (C) 2014-2015 Ben Kurtovic <ben.kurtovic@gmail.com>
  2. Released under the terms of the MIT License. See LICENSE for details. */
  3. #pragma once
  4. #include <errno.h>
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <string.h>
  8. /* Internal usage only */
  9. #define LOG_MSG_(dest, level, extra, after, ...) \
  10. do { \
  11. fprintf(dest, level ": " __VA_ARGS__); \
  12. extra; \
  13. fprintf(dest, "\n"); \
  14. after; \
  15. } while (0);
  16. #define LOG_ERR_(...) LOG_MSG_(stderr, __VA_ARGS__)
  17. #define LOG_OUT_(...) LOG_MSG_(stdout, __VA_ARGS__)
  18. #define PRINT_ERRNO_() fprintf(stderr, ": %s", strerror(errno))
  19. /* Public logging macros */
  20. #define FATAL(...) LOG_ERR_("fatal", {}, exit(EXIT_FAILURE), __VA_ARGS__)
  21. #define FATAL_ERRNO(...) LOG_ERR_("fatal", PRINT_ERRNO_(), exit(EXIT_FAILURE), __VA_ARGS__)
  22. #define ERROR(...) LOG_ERR_("error", {}, {}, __VA_ARGS__)
  23. #define ERROR_ERRNO(...) LOG_ERR_("error", PRINT_ERRNO_(), {}, __VA_ARGS__)
  24. #define WARN(...) LOG_ERR_("warning", {}, {}, __VA_ARGS__)
  25. #define WARN_ERRNO(...) LOG_ERR_("warning", PRINT_ERRNO_(), {}, __VA_ARGS__)
  26. #ifdef DEBUG_MODE
  27. #define DEBUG(...) LOG_OUT_("[DEBUG]", {}, {}, __VA_ARGS__)
  28. #else
  29. #define DEBUG(...) {}
  30. #endif