From 0a41dae5f406d498b5c9ab1542cb5660e0d982f6 Mon Sep 17 00:00:00 2001 From: Scott Gasch Date: Wed, 1 Jun 2016 19:37:09 -0700 Subject: Initial checkin of toy OS project. --- kernel/inc/macros.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 kernel/inc/macros.h (limited to 'kernel/inc/macros.h') 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_ */ -- cgit v1.3