3
/* Copyright 2009 10gen Inc.
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
9
* http://www.apache.org/licenses/LICENSE-2.0
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
27
typedef struct _Ints {
30
typedef struct _Chars {
34
typedef char CHARS[400];
42
// for now, running on win32 means development not production --
43
// use this to log things just there.
56
#define DEBUGGING if( 0 )
58
// The following declare one unique counter per enclosing function.
59
// NOTE The implementation double-increments on a match, but we don't really care.
60
#define SOMETIMES( occasion, howOften ) for( static unsigned occasion = 0; ++occasion % howOften == 0; )
61
#define OCCASIONALLY SOMETIMES( occasionally, 16 )
62
#define RARELY SOMETIMES( rarely, 128 )
63
#define ONCE for( static bool undone = true; undone; undone = false )
66
#define strcasecmp _stricmp
69
// Sets SIGTRAP handler to launch GDB
70
// Noop unless on *NIX and compiled with _DEBUG
71
void setupSIGTRAPforGDB();
74
inline void breakpoint() {} //noop
75
#else // defined(_WIN32)
76
// code to raise a breakpoint in GDB
77
inline void breakpoint(){
79
//prevent SIGTRAP from crashing the program if default action is specified and we are not in gdb
80
struct sigaction current;
81
sigaction(SIGTRAP, NULL, ¤t);
82
if (current.sa_handler == SIG_DFL){
83
signal(SIGTRAP, SIG_IGN);
89
#endif // defined(_WIN32)
91
// conditional breakpoint
92
inline void breakif(bool test){