summaryrefslogtreecommitdiff
path: root/src/util.h
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@gnugeneration.com>2017-02-24 19:36:08 -0800
committerVito Caputo <vcaputo@gnugeneration.com>2017-03-14 19:41:48 -0700
commitec9fd6bc0e7558c58e27692147f185bf5a596e2b (patch)
tree8de10239343ff2a4c9f77aee364edc246493de08 /src/util.h
parentecd88826ac1f0bf3513c23a5ee90ae360422f618 (diff)
vwm: split out helper macros into util.h
In preparation for separating out the monitoring overlay code from being vwm-coupled, moving these into an independent header since they'll be used throughout.
Diffstat (limited to 'src/util.h')
-rw-r--r--src/util.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/util.h b/src/util.h
new file mode 100644
index 0000000..9bd6a31
--- /dev/null
+++ b/src/util.h
@@ -0,0 +1,21 @@
+#ifndef _UTIL_H
+#define _UTIL_H
+
+#include <stdio.h>
+#include <errno.h>
+
+#define VWM_ERROR(_fmt, _args...) fprintf(stderr, "%s:%i\t%s() "_fmt"\n", __FILE__, __LINE__, __FUNCTION__, ##_args)
+#define VWM_PERROR(_fmt, _args...) fprintf(stderr, "%s:%i\t%s() "_fmt"; %s\n", __FILE__, __LINE__, __FUNCTION__, ##_args, strerror(errno))
+#define VWM_BUG(_fmt, _args...) fprintf(stderr, "BUG %s:%i\t%s() "_fmt"; %s\n", __FILE__, __LINE__, __FUNCTION__, ##_args, strerror(errno))
+
+#ifdef TRACE
+#define VWM_TRACE(_fmt, _args...) fprintf(stderr, "%s:%i\t%s() "_fmt"\n", __FILE__, __LINE__, __FUNCTION__, ##_args)
+#else
+#define VWM_TRACE(_fmt, _args...) do { } while(0)
+#endif
+
+#define MIN(_a, _b) ((_a) < (_b) ? (_a) : (_b))
+#define MAX(_a, _b) ((_a) > (_b) ? (_a) : (_b))
+#define NELEMS(_a) (sizeof(_a) / sizeof(_a[0]))
+
+#endif
© All Rights Reserved