-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathglobals_extern.h
More file actions
157 lines (130 loc) · 4.06 KB
/
globals_extern.h
File metadata and controls
157 lines (130 loc) · 4.06 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/*
* File: globals_extern.h
* Author: trbot
*
* Created on March 9, 2015, 1:32 PM
*/
#pragma once
// enable USE_TRACE if you want low level functionality tracing using std::cout
// #define USE_TRACE
#include <string>
#ifdef MAIN_BENCH
#include "debugprinting.h"
#include "plaf.h"
#include <atomic>
#ifndef __rtm_force_inline
#define __rtm_force_inline __attribute__((always_inline)) inline
#endif
#ifndef DEBUG
#define DEBUG if (0)
#define DEBUG1 if (0)
#define DEBUG2 if (0)
#define DEBUG3 if (0) /* rarely used */
#endif
#ifdef __unix__
#define POSIX_SYSTEM
#else
#error NOT UNIX SYSTEM
#endif
#ifndef TRACE
#ifdef USE_TRACE
extern std::atomic_bool ___trace;
#define TRACE_TOGGLE \
{ \
bool ___t = ___trace; \
___trace = !___t; \
}
#define TRACE_ON \
{ \
___trace = true; \
}
#define TRACE DEBUG if (___trace)
extern std::atomic_bool ___validateops;
#define VALIDATEOPS_ON \
{ \
___validateops = true; \
}
#define VALIDATEOPS DEBUG if (___validateops)
#endif
#endif
/**
* Enable global statistics access using gstats_global.h
*/
#include "gstats_global.h"
/**
* Setup timing code
*/
#include "server_clock.h"
/**
* Configure record manager: reclaimer, allocator and pool
*/
#ifndef PRINTS
#define STR(x) XSTR(x)
#define XSTR(x) #x
#define PRINTI(name) \
{ \
std::cout << #name << "=" << name << std::endl; \
}
#define PRINTS(name) \
{ \
std::cout << #name << "=" << STR(name) << std::endl; \
}
#endif
#define _EVAL(a) a
#define _PASTE2(a, b) a##b
#define PASTE(a, b) _PASTE2(a, b)
#ifdef RECLAIM_TYPE
#define RECLAIM PASTE(reclaimer_, RECLAIM_TYPE)
// #define RECLAIM_DOT_H PASTE(RECLAIM,.h)
#include STR(RECLAIM.h)
#else
#define RECLAIM reclaimer_debra
#include "reclaimer_debra.h"
#endif
#ifdef ALLOC_TYPE
#define ALLOC PASTE(allocator_, ALLOC_TYPE)
// #define ALLOC_DOT_H PASTE(ALLOC,.h)
#include STR(ALLOC.h)
#else
#define ALLOC allocator_new
#include "allocator_new.h"
#endif
#ifdef POOL_TYPE
#define POOL PASTE(pool_, POOL_TYPE)
// #define POOL_DOT_H PASTE(POOL,.h)
#include STR(POOL.h)
#else
#define POOL pool_none
#include "pool_none.h"
#endif
#endif
std::string indented_title(const std::string& title, size_t indents = 1, size_t indent_length = 2) {
return std::string(indents * indent_length, ' ') + title + ":\n";
}
template <typename T>
std::string indented_title_with_data(const std::string& title, const T& data, size_t indents = 1,
size_t line_length = 28, size_t indent_length = 2) {
return std::string(indents * indent_length, ' ') + title + ":" +
(title.size() + indents * indent_length < line_length
? std::string(line_length - title.size() - indents * indent_length, ' ')
: "\t") +
std::to_string(data) + "\n";
}
std::string indented_title_with_str_data(const std::string& title, const std::string& data,
size_t indents = 1, size_t line_length = 28,
size_t indent_length = 2) {
return std::string(indents * indent_length, ' ') + title + ":" +
(title.size() + indents * indent_length < line_length
? std::string(line_length - title.size() - indents * indent_length, ' ')
: "\t") +
data + "\n";
}
std::string to_string_stage(const std::string& stage_name) {
return std::string(80, '-') + "\n" + stage_name + "\n" + std::string(80, '-') + "\n";
}
std::string to_string_big_stage(const std::string& stage_name) {
size_t size = (78 - stage_name.size()) / 2;
return std::string(80, '#') + "\n" +
std::string(78 - size * 2 - stage_name.size() == 0 ? size : size + 1, '#') + ' ' +
stage_name + ' ' + std::string(size, '#') + "\n" + std::string(80, '#') + "\n";
}