forked from idealvin/coost
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdef.h
59 lines (47 loc) · 1.59 KB
/
def.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
#pragma once
#include <stdint.h>
typedef int8_t int8;
typedef int16_t int16;
typedef int32_t int32;
typedef int64_t int64;
typedef uint8_t uint8;
typedef uint16_t uint16;
typedef uint32_t uint32;
typedef uint64_t uint64;
#ifdef _MSC_VER
#define __thread __declspec(thread)
#else
#define __forceinline __attribute__((always_inline))
#endif
#define load8(p) (*(const uint8*) (p))
#define load16(p) (*(const uint16*)(p))
#define load32(p) (*(const uint32*)(p))
#define load64(p) (*(const uint64*)(p))
#define save8(p, v) (*(uint8*) (p) = (v))
#define save16(p, v) (*(uint16*)(p) = (v))
#define save32(p, v) (*(uint32*)(p) = (v))
#define save64(p, v) (*(uint64*)(p) = (v))
#define MAX_UINT8 ((uint8) ~((uint8) 0))
#define MAX_UINT16 ((uint16) ~((uint16)0))
#define MAX_UINT32 ((uint32) ~((uint32)0))
#define MAX_UINT64 ((uint64) ~((uint64)0))
#define MAX_INT8 ((int8) (MAX_UINT8 >> 1))
#define MAX_INT16 ((int16) (MAX_UINT16 >> 1))
#define MAX_INT32 ((int32) (MAX_UINT32 >> 1))
#define MAX_INT64 ((int64) (MAX_UINT64 >> 1))
#define MIN_INT8 ((int8) ~MAX_INT8)
#define MIN_INT16 ((int16) ~MAX_INT16)
#define MIN_INT32 ((int32) ~MAX_INT32)
#define MIN_INT64 ((int64) ~MAX_INT64)
#define DISALLOW_COPY_AND_ASSIGN(Type) \
Type(const Type&) = delete; \
void operator=(const Type&) = delete
template<typename To, typename From>
inline To force_cast(From f) {
return (To) f;
}
#if (defined(__GNUC__) && __GNUC__ >= 3) || defined(__clang__)
#define unlikely(x) __builtin_expect(!!(x), 0)
#else
#define unlikely(x) (x)
#endif