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.
 
 
 
 
 

37 lignes
1.4 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. fprintf(dest, level ": " __VA_ARGS__); \
  11. extra; \
  12. fprintf(dest, "\n"); \
  13. after; \
  14. }
  15. #define PRINT_ERRNO() fprintf(stderr, ": %s", strerror(errno))
  16. /* Public logging macros */
  17. #define FATAL(...) LOG_MSG(stderr, "Error", {}, exit(EXIT_FAILURE), __VA_ARGS__)
  18. #define FATAL_ERRNO(...) LOG_MSG(stderr, "Error", PRINT_ERRNO(), exit(EXIT_FAILURE), __VA_ARGS__)
  19. #define ERROR(...) LOG_MSG(stderr, "Error", {}, {}, __VA_ARGS__)
  20. #define ERROR_ERRNO(...) LOG_MSG(stderr, "Error", PRINT_ERRNO(), {}, __VA_ARGS__)
  21. #define WARN(...) LOG_MSG(stderr, "Warning", {}, {}, __VA_ARGS__)
  22. #define WARN_ERRNO(...) LOG_MSG(stderr, "Warning", PRINT_ERRNO(), {}, __VA_ARGS__)
  23. #ifdef DEBUG_MODE
  24. #define DEBUG(...) LOG_MSG(stdout, "[DEBUG]", {}, {}, __VA_ARGS__)
  25. #else
  26. #define DEBUG(...) {}
  27. #endif
  28. #define OUT_OF_MEMORY() FATAL("couldn't allocate enough memory")