@@ -56,11 +56,33 @@ static const int64_t CENT = 1000000;
56
56
#define UINTBEGIN (a ) ((uint32_t *)&(a))
57
57
#define CUINTBEGIN (a ) ((const uint32_t *)&(a))
58
58
59
+ #ifndef PRId64
60
+ #if defined(_MSC_VER) || defined(__MSVCRT__)
61
+ #define PRIu64 " I64u"
62
+ #define PRId64 " I64d"
63
+ #define PRIx64 " I64x"
64
+ #else
65
+ #define PRId64 " lld"
66
+ #define PRIu64 " llu"
67
+ #define PRIx64 " llx"
68
+ #endif
69
+ #endif
70
+
71
+ #ifndef THROW_WITH_STACKTRACE
72
+ #define THROW_WITH_STACKTRACE (exception ) \
73
+ { \
74
+ LogStackTrace (); \
75
+ throw (exception); \
76
+ }
77
+ void LogStackTrace ();
78
+ #endif
79
+
59
80
/* Format characters for (s)size_t and ptrdiff_t */
60
81
#if defined(_MSC_VER) || defined(__MSVCRT__)
61
82
/* (s)size_t and ptrdiff_t have the same size specifier in MSVC:
62
83
http://msdn.microsoft.com/en-us/library/tcxf1dw6%28v=vs.100%29.aspx
63
84
*/
85
+
64
86
#define PRIszx " Ix"
65
87
#define PRIszu " Iu"
66
88
#define PRIszd " Id"
@@ -74,13 +96,6 @@ static const int64_t CENT = 1000000;
74
96
#define PRIpdx " tx"
75
97
#define PRIpdu " tu"
76
98
#define PRIpdd " td"
77
- #undef PRIu64
78
- #undef PRId64
79
- #undef PRIx64
80
-
81
- #define PRIu64 " I64u"
82
- #define PRId64 " I64d"
83
- #define PRIx64 " I64x"
84
99
#endif
85
100
86
101
// This is needed because the foreach macro can't get over the comma in pair<t1, t2>
@@ -110,6 +125,8 @@ T* alignup(T* p)
110
125
#endif
111
126
#else
112
127
#define MAX_PATH 1024
128
+ #endif
129
+
113
130
inline void Sleep (int64_t n)
114
131
{
115
132
/* Boost has a year 2038 problem— if the request sleep time is past epoch+2^31 seconds the sleep returns instantly.
@@ -131,21 +148,56 @@ inline void Sleep(int64_t n)
131
148
132
149
133
150
151
+
152
+
153
+
154
+
134
155
extern std::map<std::string, std::string> mapArgs;
135
156
extern std::map<std::string, std::vector<std::string> > mapMultiArgs;
136
157
extern bool fDebug ;
158
+ extern bool fDebugNet ;
137
159
extern bool fPrintToConsole ;
138
160
extern bool fPrintToDebugLog ;
161
+ extern bool fRequestShutdown ;
162
+ extern bool fShutdown ;
139
163
extern bool fDaemon ;
140
164
extern bool fServer ;
141
165
extern bool fCommandLine ;
142
166
extern std::string strMiscWarning;
167
+ extern bool fTestNet ;
143
168
extern bool fNoListen ;
144
169
extern bool fLogTimestamps ;
145
170
extern volatile bool fReopenDebugLog ;
146
171
147
172
void RandAddSeed ();
148
173
void RandAddSeedPerfmon ();
174
+ int ATTR_WARN_PRINTF (1 ,2 ) OutputDebugStringF(const char * pszFormat, ...);
175
+
176
+ /*
177
+ Rationale for the real_strprintf / strprintf construction:
178
+ It is not allowed to use va_start with a pass-by-reference argument.
179
+ (C++ standard, 18.7, paragraph 3). Use a dummy argument to work around this, and use a
180
+ macro to keep similar semantics.
181
+ */
182
+
183
+ /* * Overload strprintf for char*, so that GCC format type warnings can be given */
184
+ std::string ATTR_WARN_PRINTF (1 ,3 ) real_strprintf(const char *format, int dummy, ...);
185
+ /* * Overload strprintf for std::string, to be able to use it with _ (translation).
186
+ * This will not support GCC format type warnings (-Wformat) so be careful.
187
+ */
188
+ std::string real_strprintf (const std::string &format, int dummy, ...);
189
+ #define strprintf (format, ...) real_strprintf(format, 0 , __VA_ARGS__)
190
+ std::string vstrprintf (const char *format, va_list ap);
191
+
192
+ bool ATTR_WARN_PRINTF (1 ,2 ) error(const char *format, ...);
193
+
194
+ /* Redefine printf so that it directs output to debug.log
195
+ *
196
+ * Do this *after* defining the other printf-like functions, because otherwise the
197
+ * __attribute__((format(printf,X,Y))) gets expanded to __attribute__((format(OutputDebugStringF,X,Y)))
198
+ * which confuses gcc.
199
+ */
200
+ #define printf OutputDebugStringF
149
201
150
202
/* Return true if log accepts specified category */
151
203
bool LogAcceptCategory (const char * category);
@@ -189,7 +241,6 @@ static inline bool error(const char* format)
189
241
return false ;
190
242
}
191
243
192
-
193
244
void PrintException (std::exception* pex, const char * pszThread);
194
245
void PrintExceptionContinue (std::exception* pex, const char * pszThread);
195
246
void ParseString (const std::string& str, char c, std::vector<std::string>& v);
@@ -231,14 +282,9 @@ uint256 GetRandHash();
231
282
int64_t GetTime ();
232
283
int64_t GetTimeMillis ();
233
284
int64_t GetTimeMicros ();
234
- void SetMockTime (int64_t nMockTimeIn);
235
- std::string FormatFullVersion ();
236
- std::string FormatSubVersion (const std::string& name, int nClientVersion, const std::vector<std::string>& comments);
237
- void runCommand (std::string strCommand);
238
-
239
285
int64_t GetAdjustedTime ();
240
286
int64_t GetTimeOffset ();
241
- int64_t GetNodesOffset ( );
287
+ void SetMockTime ( int64_t nMockTimeIn );
242
288
std::string FormatFullVersion ();
243
289
std::string FormatSubVersion (const std::string& name, int nClientVersion, const std::vector<std::string>& comments);
244
290
void AddTimeData (const CNetAddr& ip, int64_t nTime);
0 commit comments