1 module memutils.constants;
2 
3 package:
4 
5 enum { // overhead allocator definitions, lazily loaded
6 	NativeGC = 0x01, // instances are freed automatically when no references exist in the program's threads
7 	LocklessFreeList = 0x02, // instances are owned by the creating thread thus must be freed by it
8 	CryptoSafe = 0x03, // Same as above, but zeroise is called upon freeing
9 }
10 
11 enum Mallocator = 0x05; // For use by the DebugAllocator.
12 
13 const LogLevel = Error;
14 version(CryptoSafe) 	const HasCryptoSafe = true;
15 else					const HasCryptoSafe = false;
16 
17 /// uses a swap protected pool on top of CryptoSafeAllocator
18 /// otherwise, uses a regular lockless freelist
19 version(SecurePool)		const HasSecurePool = true;
20 else				const HasSecurePool = false;
21 
22 const SecurePool_MLock_Max = 524_287;
23 
24 version(Have_botan) 	const HasBotan = true; 
25 else			const HasBotan = false;
26 version(DictionaryDebugger) const HasDictionaryDebugger = true;
27 else					const HasDictionaryDebugger = false;
28 version(EnableDebugger) const HasDebuggerEnabled = true;
29 else					  const HasDebuggerEnabled = false;
30 version(DisableDebugger)   const DisableDebugAllocations = true;
31 else version(VibeNoDebug) const DisableDebugAllocations = true;
32 else					const DisableDebugAllocations = false;
33 public:
34 static if (HasDebuggerEnabled && !DisableDebugAllocations ) const HasDebugAllocations = true;
35 else static if (!DisableDebugAllocations) const HasDebugAllocations = true;
36 else					  const HasDebugAllocations = false;
37 package:
38 version(SkipMemutilsTests) const SkipUnitTests = true;
39 else					   const SkipUnitTests = false;
40 
41 enum { // LogLevel
42 	Trace,
43 	Info,
44 	Debug,
45 	Error,
46 	None
47 }
48 
49 void logTrace(ARGS...)(lazy ARGS args) {
50 	static if (LogLevel <= Trace) {
51 		import std.stdio: writeln;
52 		writeln("T: ", args);
53 	}
54 }
55 
56 void logInfo(ARGS...)(lazy ARGS args) {
57 	static if (LogLevel <= Info) {
58 		import std.stdio: writeln;
59 		writeln("I: ", args);
60 	}
61 }
62 
63 void logDebug(ARGS...)(lazy ARGS args) {
64 	
65 	static if (LogLevel <= Debug) {
66 		import std.stdio: writeln;
67 		writeln("D: ", args);
68 	}
69 }
70 
71 void logError(ARGS...)(lazy ARGS args) {
72 	static if (LogLevel <= Error) {
73 		import std.stdio: writeln, stderr;
74 		stderr.writeln("E: ", args);
75 	}
76 }