An emulator, assembler, and disassembler for the Sega Game Gear
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.
 
 
 
 
 

28 lines
1.0 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. /* Internal usage only */
  8. #define LOG_MSG(level, extra, after, ...) { \
  9. fprintf(stderr, level ": " __VA_ARGS__); \
  10. extra; \
  11. fprintf(stderr, ".\n"); \
  12. after; \
  13. }
  14. #define PRINT_ERRNO() fprintf(stderr, ": %s", strerror(errno))
  15. /* Public error logging macros */
  16. #define FATAL(...) LOG_MSG("Error", {}, exit(EXIT_FAILURE), __VA_ARGS__)
  17. #define FATAL_ERRNO(...) LOG_MSG("Error", PRINT_ERRNO(), exit(EXIT_FAILURE), __VA_ARGS__)
  18. #define WARN(...) LOG_MSG("Warning", {}, {}, __VA_ARGS__)
  19. #define WARN_ERRNO(...) LOG_MSG("Warning", PRINT_ERRNO(), {}, __VA_ARGS__)
  20. #define OUT_OF_MEMORY() FATAL("couldn't allocate enough memory")