summaryrefslogtreecommitdiff
path: root/kernel/inc/macros.h
diff options
context:
space:
mode:
authorScott Gasch <[email protected]>2016-06-01 19:37:09 -0700
committerScott Gasch <[email protected]>2016-06-01 19:37:09 -0700
commit0a41dae5f406d498b5c9ab1542cb5660e0d982f6 (patch)
tree67ade9fe31cfd0458cc485e95550f7aaf14abdd1 /kernel/inc/macros.h
Initial checkin of toy OS project.HEADmaster
Diffstat (limited to 'kernel/inc/macros.h')
-rw-r--r--kernel/inc/macros.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/kernel/inc/macros.h b/kernel/inc/macros.h
new file mode 100644
index 0000000..21340ad
--- /dev/null
+++ b/kernel/inc/macros.h
@@ -0,0 +1,43 @@
+//+----------------------------------------------------------------------------
+//
+// File: macros.h
+//
+// Module:
+//
+// Synopsis:
+//
+// Copyright (C) 2003
+//
+// Created: sgasch 10 Oct 2003
+//
+//+----------------------------------------------------------------------------
+
+#ifndef _MACROS_H_
+#define _MACROS_H_
+
+//
+// Macros
+//
+#define ARRAY_LENGTH(a) (sizeof((a)) / sizeof((a)[0]))
+#define MIN(x, y) (((x) < (y)) ? (x) : (y))
+#define MAX(x, y) (((x) > (y)) ? (x) : (y))
+
+#if 1
+void _assert(CHAR *, CHAR *, ULONG);
+void VideoPrint(CHAR *, ...);
+#define ASSERT(x) if (x) \
+ { ; } \
+ else \
+ { _assert(__FUNCTION__ , \
+ __FILE__ , \
+ __LINE__); }
+#define TRACE(f, ...) VideoPrint("%s:%u> " ##f , __FUNCTION__ , \
+ __LINE__ , ##__VA_ARGS__)
+#else
+#define ASSERT(x) ;
+#define TRACE(f, ...) ;
+#endif // DEBUG
+
+#define CURRENT_STAMP(a) asm volatile("rdtsc" : "=a"(((unsigned int *)(a))[0]), "=d"(((unsigned int *)a)[1]))
+
+#endif /* _MACROS_H_ */