OSDN Git Service

add solution and project files for VisualStudio and some utility tools
[yamy/yamy.git] / misc.h
1 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 // misc.h
3
4
5 #ifndef _MISC_H
6 #  define _MISC_H
7
8 #  include "compiler_specific.h"
9 #  include <windows.h>
10 #  include <cassert>
11
12
13 typedef unsigned char u_char;                   /// unsigned char
14 typedef unsigned short u_short;                 /// unsigned short
15 typedef unsigned long u_long;                   /// unsigned long
16
17 typedef char int8;                              /// signed 8bit
18 typedef short int16;                            /// signed 16bit
19 typedef long int32;                             /// signed 32bit
20 typedef unsigned char u_int8;                   /// unsigned 8bit
21 typedef unsigned short u_int16;                 /// unsigned 16bit
22 typedef unsigned long u_int32;                  /// unsigned 32bit
23 #if defined(__BORLANDC__)
24 typedef unsigned __int64 u_int64;                       /// unsigned 64bit
25 #elif _MSC_VER <= 1300
26 typedef unsigned _int64 u_int64;                        /// unsigned 64bit
27 #else
28 typedef unsigned long long u_int64;                     /// unsigned 64bit
29 #endif
30
31
32 #  ifdef NDEBUG
33 #    define ASSERT(i_exp)
34 #    define CHECK(i_cond, i_exp)        i_exp
35 #    define CHECK_TRUE(i_exp)           i_exp
36 #    define CHECK_FALSE(i_exp)          i_exp
37 #  else // NDEBUG
38 /// assertion. i_exp is evaluated only in debug build
39 #    define ASSERT(i_exp)               assert(i_exp)
40 /// assertion, but i_exp is always evaluated
41 #    define CHECK(i_cond, i_exp)        assert(i_cond (i_exp))
42 /// identical to CHECK(!!, i_exp)
43 #    define CHECK_TRUE(i_exp)           assert(!!(i_exp))
44 /// identical to CHECK(!, i_exp)
45 #    define CHECK_FALSE(i_exp)          assert(!(i_exp))
46 #  endif // NDEBUG
47
48
49 /// get number of array elements
50 #  define NUMBER_OF(i_array) (sizeof(i_array) / sizeof((i_array)[0]))
51
52 /// max path length
53 #  define GANA_MAX_PATH         (MAX_PATH * 4)
54
55 /// max length of global atom
56 #  define GANA_MAX_ATOM_LENGTH  256
57
58 #  undef MAX
59 /// redefine MAX macro
60 #  define MAX(a, b)     (((b) < (a)) ? (a) : (b))
61
62 #  undef MIN
63 /// redefine MIN macro
64 #  define MIN(a, b)     (((a) < (b)) ? (a) : (b))
65
66
67 #endif // !_MISC_H