Initial checkin of toy OS project.
[os.git] / kernel / inc / macros.h
1 //+----------------------------------------------------------------------------
2 //
3 // File:     macros.h
4 //
5 // Module:   
6 //
7 // Synopsis: 
8 //
9 // Copyright (C) 2003 
10 //
11 // Created:  sgasch  10 Oct 2003
12 //
13 //+----------------------------------------------------------------------------
14
15 #ifndef _MACROS_H_
16 #define _MACROS_H_
17
18 //
19 // Macros
20 //
21 #define ARRAY_LENGTH(a)            (sizeof((a)) / sizeof((a)[0]))
22 #define MIN(x, y)                  (((x) < (y)) ? (x) : (y))
23 #define MAX(x, y)                  (((x) > (y)) ? (x) : (y))
24
25 #if 1
26 void _assert(CHAR *, CHAR *, ULONG);
27 void VideoPrint(CHAR *, ...);
28 #define ASSERT(x)                  if (x)    \
29                                    { ; }     \
30                                    else      \
31                                    { _assert(__FUNCTION__ , \
32                                              __FILE__ , \
33                                              __LINE__); }
34 #define TRACE(f, ...)              VideoPrint("%s:%u> " ##f , __FUNCTION__ , \
35                                               __LINE__ , ##__VA_ARGS__)
36 #else
37 #define ASSERT(x)                      ;
38 #define TRACE(f, ...)              ;
39 #endif // DEBUG
40
41 #define CURRENT_STAMP(a)           asm volatile("rdtsc" : "=a"(((unsigned int *)(a))[0]), "=d"(((unsigned int *)a)[1]))
42
43 #endif /* _MACROS_H_ */