This repository has been archived by the owner on Oct 23, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
misc.h
78 lines (61 loc) · 2.05 KB
/
misc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// misc.h
#ifndef _MISC_H
# define _MISC_H
# include "compiler_specific.h"
#if defined(WIN32)
# include <windows.h>
#elif defined(__linux__)
# elif defined(__APPLE__)
#endif
# include <cassert>
#include "wintypes.h"
#include <iostream>
using namespace std;
typedef unsigned char u_char; /// unsigned char
typedef unsigned short u_short; /// unsigned short
typedef unsigned long u_long; /// unsigned long
typedef char int8; /// signed 8bit
typedef short int16; /// signed 16bit
typedef long int32; /// signed 32bit
typedef unsigned char u_int8; /// unsigned 8bit
typedef unsigned short u_int16; /// unsigned 16bit
typedef unsigned long u_int32; /// unsigned 32bit
#if defined(__BORLANDC__)
typedef unsigned __int64 u_int64; /// unsigned 64bit
#elif defined(_MSC_VER) && _MSC_VER <= 1300
typedef unsigned _int64 u_int64; /// unsigned 64bit
#else
typedef unsigned long long u_int64; /// unsigned 64bit
#endif
#if defined(__linux__) || defined(__APPLE__)
typedef long long _int64; /// signed 64bit
#endif
# ifdef NDEBUG
# define ASSERT(i_exp)
# define CHECK(i_cond, i_exp) i_exp
# define CHECK_TRUE(i_exp) i_exp
# define CHECK_FALSE(i_exp) i_exp
# else // NDEBUG
/// assertion. i_exp is evaluated only in debug build
# define ASSERT(i_exp) assert(i_exp)
/// assertion, but i_exp is always evaluated
# define CHECK(i_cond, i_exp) assert(i_cond (i_exp))
/// identical to CHECK(!!, i_exp)
# define CHECK_TRUE(i_exp) assert(!!(i_exp))
/// identical to CHECK(!, i_exp)
# define CHECK_FALSE(i_exp) assert(!(i_exp))
# endif // NDEBUG
/// get number of array elements
# define NUMBER_OF(i_array) (sizeof(i_array) / sizeof((i_array)[0]))
/// max path length
# define GANA_MAX_PATH (MAX_PATH * 4)
/// max length of global atom
# define GANA_MAX_ATOM_LENGTH 256
# undef MAX
/// redefine MAX macro
# define MAX(a, b) (((b) < (a)) ? (a) : (b))
# undef MIN
/// redefine MIN macro
# define MIN(a, b) (((a) < (b)) ? (a) : (b))
#endif // !_MISC_H