aboutsummaryrefslogtreecommitdiff
path: root/util.h
blob: cef238c81f8acc26ffdc527f14ab88bafc4cf361 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#ifndef UTIL_H
#define UTIL_H

#include <stdio.h> // fprintf()
#include <stdlib.h> // exit()

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define UNUSED(a) ((void) (a))

#define D(...) do { \
  fprintf(stderr, "DEBUG: %s(): ", __func__); \
  fprintf(stderr, __VA_ARGS__); \
  fputs("\n", stderr); \
} while (0)

#define die(...) do { \
  fputs("FATAL: ", stderr); \
  fprintf(stderr, __VA_ARGS__); \
  fputs("\n", stderr); \
  exit(EXIT_FAILURE); \
} while (0)

#endif /* UTIL_H */