mirror of
https://github.com/mauiaaron/apple2.git
synced 2025-02-28 21:29:35 +00:00
macro refactoring for clarity [sic]
This commit is contained in:
parent
a063669cb8
commit
0f26899420
51
src/common.h
51
src/common.h
@ -1,7 +1,5 @@
|
||||
/*
|
||||
* Apple // emulator : misc defines
|
||||
*
|
||||
* Copyright 2013 Aaron Culliney
|
||||
* Apple // emulator for *nix
|
||||
*
|
||||
* This software package is subject to the GNU General Public License
|
||||
* version 2 or later (your choice) as published by the Free Software
|
||||
@ -18,20 +16,25 @@
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
||||
#if defined(__GNUC__)
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wunused-variable"
|
||||
#elif defined(__clang__)
|
||||
# pragma clang diagnostic push
|
||||
# pragma clang diagnostic ignored "-Werror=unused-variable"
|
||||
#endif
|
||||
# if defined(__GNUC__)
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wunused-variable"
|
||||
# elif defined(__clang__)
|
||||
# pragma clang diagnostic push
|
||||
# pragma clang diagnostic ignored "-Wunused-variable"
|
||||
# endif
|
||||
|
||||
static FILE *error_log=0;
|
||||
#define ERRLOG(/* err message format string, args */...) \
|
||||
{ \
|
||||
do { \
|
||||
int saverr = errno; errno = 0; \
|
||||
fprintf(error_log ? error_log : stderr, "%s:%d - ", __FILE__, __LINE__); \
|
||||
fprintf(error_log ? error_log : stderr, __VA_ARGS__); \
|
||||
@ -39,13 +42,13 @@ static FILE *error_log=0;
|
||||
fprintf(error_log ? error_log : stderr, " (syserr: %s)", strerror(saverr)); \
|
||||
} \
|
||||
fprintf(error_log ? error_log : stderr, "\n"); \
|
||||
}
|
||||
} while(0);
|
||||
|
||||
#define ERRQUIT(...) \
|
||||
{ \
|
||||
do { \
|
||||
ERRLOG(__VA_ARGS__); \
|
||||
exit(0); \
|
||||
}
|
||||
} while(0);
|
||||
|
||||
#else // NDEBUG
|
||||
|
||||
@ -55,15 +58,23 @@ static FILE *error_log=0;
|
||||
# pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
#define ERRLOG(...) \
|
||||
do \
|
||||
{ \
|
||||
#define ERRLOG(...) \
|
||||
do \
|
||||
{ \
|
||||
} while(0);
|
||||
|
||||
#endif
|
||||
|
||||
#define LOG(...) ERRLOG(__VA_ARGS__)
|
||||
#define LOG(...) \
|
||||
do { \
|
||||
errno = 0; \
|
||||
ERRLOG(__VA_ARGS__); \
|
||||
} while(0);
|
||||
|
||||
static void inline Free(void *x) { free(x); x=NULL; }
|
||||
#define Free(X) \
|
||||
do { \
|
||||
free(X); \
|
||||
X=NULL; \
|
||||
} while (0);
|
||||
|
||||
#endif // whole file
|
||||
|
Loading…
x
Reference in New Issue
Block a user