authorgravatar for emekankurumeh@outlook.comemekoi <emekankurumeh@outlook.com> 2019-05-19 15:26:43-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-05-19 16:33:31-04:00
log1c73c08298fc3a19886038d935e45cf74ba152fb
tree0583f8c9b0118e3e9f3c0268d6e6ea14063cd363
parent6672ee9eb39a1cd9a3d6874ac1fb6de347ee2d33

ran zig fmt on stdlib


8 files changed, 71 insertions(+), 149 deletions(-)

std/debug.zig+10-8
...@@ -1490,14 +1490,16 @@ fn parseFormValueTargetAddrSize(in_stream: var) !u64 {...@@ -1490,14 +1490,16 @@ fn parseFormValueTargetAddrSize(in_stream: var) !u64 {
1490}1490}
14911491
1492fn parseFormValueRef(allocator: *mem.Allocator, in_stream: var, size: i32) !FormValue {1492fn parseFormValueRef(allocator: *mem.Allocator, in_stream: var, size: i32) !FormValue {
1493 return FormValue{ .Ref = switch (size) {1493 return FormValue{
1494 1 => try in_stream.readIntLittle(u8),1494 .Ref = switch (size) {
1495 2 => try in_stream.readIntLittle(u16),1495 1 => try in_stream.readIntLittle(u8),
1496 4 => try in_stream.readIntLittle(u32),1496 2 => try in_stream.readIntLittle(u16),
1497 8 => try in_stream.readIntLittle(u64),1497 4 => try in_stream.readIntLittle(u32),
1498 -1 => try leb.readULEB128(u64, in_stream),1498 8 => try in_stream.readIntLittle(u64),
1499 else => unreachable,1499 -1 => try leb.readULEB128(u64, in_stream),
1500 } };1500 else => unreachable,
1501 },
1502 };
1501}1503}
15021504
1503fn parseFormValue(allocator: *mem.Allocator, in_stream: var, form_id: u64, is_64: bool) anyerror!FormValue {1505fn parseFormValue(allocator: *mem.Allocator, in_stream: var, form_id: u64, is_64: bool) anyerror!FormValue {
std/io.zig+12-8
...@@ -1116,10 +1116,12 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing,...@@ -1116,10 +1116,12 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing,
1116 pub const Stream = InStream(Error);1116 pub const Stream = InStream(Error);
11171117
1118 pub fn init(in_stream: *Stream) Self {1118 pub fn init(in_stream: *Stream) Self {
1119 return Self{ .in_stream = switch (packing) {1119 return Self{
1120 .Bit => BitInStream(endian, Stream.Error).init(in_stream),1120 .in_stream = switch (packing) {
1121 .Byte => in_stream,1121 .Bit => BitInStream(endian, Stream.Error).init(in_stream),
1122 } };1122 .Byte => in_stream,
1123 },
1124 };
1123 }1125 }
11241126
1125 pub fn alignToByte(self: *Self) void {1127 pub fn alignToByte(self: *Self) void {
...@@ -1325,10 +1327,12 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co...@@ -1325,10 +1327,12 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co
1325 pub const Stream = OutStream(Error);1327 pub const Stream = OutStream(Error);
13261328
1327 pub fn init(out_stream: *Stream) Self {1329 pub fn init(out_stream: *Stream) Self {
1328 return Self{ .out_stream = switch (packing) {1330 return Self{
1329 .Bit => BitOutStream(endian, Stream.Error).init(out_stream),1331 .out_stream = switch (packing) {
1330 .Byte => out_stream,1332 .Bit => BitOutStream(endian, Stream.Error).init(out_stream),
1331 } };1333 .Byte => out_stream,
1334 },
1335 };
1332 }1336 }
13331337
1334 /// Flushes any unwritten bits to the stream1338 /// Flushes any unwritten bits to the stream
std/os/linux/tls.zig+1-1
...@@ -114,7 +114,7 @@ pub fn setThreadPointer(addr: usize) void {...@@ -114,7 +114,7 @@ pub fn setThreadPointer(addr: usize) void {
114 .aarch64 => {114 .aarch64 => {
115 asm volatile (115 asm volatile (
116 \\ msr tpidr_el0, %[addr]116 \\ msr tpidr_el0, %[addr]
117 :117 :
118 : [addr] "r" (addr)118 : [addr] "r" (addr)
119 );119 );
120 },120 },
std/special/bootstrap.zig+4-1
...@@ -8,7 +8,10 @@ const assert = std.debug.assert;...@@ -8,7 +8,10 @@ const assert = std.debug.assert;
88
9var argc_ptr: [*]usize = undefined;9var argc_ptr: [*]usize = undefined;
1010
11const is_wasm = switch (builtin.arch) { .wasm32, .wasm64 => true, else => false};11const is_wasm = switch (builtin.arch) {
12 .wasm32, .wasm64 => true,
13 else => false,
14};
1215
13comptime {16comptime {
14 if (builtin.link_libc) {17 if (builtin.link_libc) {
std/special/c.zig+8-2
...@@ -8,8 +8,14 @@ const std = @import("std");...@@ -8,8 +8,14 @@ const std = @import("std");
8const builtin = @import("builtin");8const builtin = @import("builtin");
9const maxInt = std.math.maxInt;9const maxInt = std.math.maxInt;
1010
11const is_wasm = switch (builtin.arch) { .wasm32, .wasm64 => true, else => false};11const is_wasm = switch (builtin.arch) {
12const is_freestanding = switch (builtin.os) { .freestanding => true, else => false };12 .wasm32, .wasm64 => true,
13 else => false,
14};
15const is_freestanding = switch (builtin.os) {
16 .freestanding => true,
17 else => false,
18};
13comptime {19comptime {
14 if (is_freestanding and is_wasm and builtin.link_libc) {20 if (is_freestanding and is_wasm and builtin.link_libc) {
15 @export("_start", wasm_start, .Strong);21 @export("_start", wasm_start, .Strong);
std/special/compiler_rt/extendXfYf2.zig+1-1
...@@ -76,7 +76,7 @@ fn extendXfYf2(comptime dst_t: type, comptime src_t: type, a: @IntType(false, @t...@@ -76,7 +76,7 @@ fn extendXfYf2(comptime dst_t: type, comptime src_t: type, a: @IntType(false, @t
76 // renormalize the significand and clear the leading bit, then insert76 // renormalize the significand and clear the leading bit, then insert
77 // the correct adjusted exponent in the destination type.77 // the correct adjusted exponent in the destination type.
78 const scale: u32 = @clz(src_rep_t, aAbs) -78 const scale: u32 = @clz(src_rep_t, aAbs) -
79 @clz(src_rep_t, src_rep_t(srcMinNormal));79 @clz(src_rep_t, src_rep_t(srcMinNormal));
80 absResult = dst_rep_t(aAbs) << @intCast(DstShift, dstSigBits - srcSigBits + scale);80 absResult = dst_rep_t(aAbs) << @intCast(DstShift, dstSigBits - srcSigBits + scale);
81 absResult ^= dstMinNormal;81 absResult ^= dstMinNormal;
82 const resultExponent: u32 = dstExpBias - srcExpBias - scale + 1;82 const resultExponent: u32 = dstExpBias - srcExpBias - scale + 1;
std/valgrind/callgrind.zig+9-32
...@@ -10,70 +10,48 @@ pub const CallgrindClientRequest = extern enum {...@@ -10,70 +10,48 @@ pub const CallgrindClientRequest = extern enum {
10 StopInstrumentation,10 StopInstrumentation,
11};11};
1212
13fn doCallgrindClientRequestExpr(default: usize, request: CallgrindClientRequest,13fn doCallgrindClientRequestExpr(default: usize, request: CallgrindClientRequest, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize) usize {
14 a1: usize, a2: usize, a3: usize, a4: usize, a5: usize14 return valgrind.doClientRequest(default, @intCast(usize, @enumToInt(request)), a1, a2, a3, a4, a5);
15 ) usize
16{
17 return valgrind.doClientRequest(
18 default,
19 @intCast(usize, @enumToInt(request)),
20 a1, a2, a3, a4, a5);
21}15}
2216
23fn doCallgrindClientRequestStmt(request: CallgrindClientRequest,17fn doCallgrindClientRequestStmt(request: CallgrindClientRequest, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize) void {
24 a1: usize, a2: usize, a3: usize, a4: usize, a5: usize
25 ) void
26{
27 _ = doCallgrindClientRequestExpr(0, request, a1, a2, a3, a4, a5);18 _ = doCallgrindClientRequestExpr(0, request, a1, a2, a3, a4, a5);
28}19}
2920
30
31
32/// Dump current state of cost centers, and zero them afterwards21/// Dump current state of cost centers, and zero them afterwards
33pub fn dumpStats() void {22pub fn dumpStats() void {
34 doCallgrindClientRequestStmt(CallgrindClientRequest.DumpStats,23 doCallgrindClientRequestStmt(CallgrindClientRequest.DumpStats, 0, 0, 0, 0, 0);
35 0, 0, 0, 0, 0);
36}24}
3725
38
39/// Dump current state of cost centers, and zero them afterwards.26/// Dump current state of cost centers, and zero them afterwards.
40/// The argument is appended to a string stating the reason which triggered27/// The argument is appended to a string stating the reason which triggered
41/// the dump. This string is written as a description field into the28/// the dump. This string is written as a description field into the
42/// profile data dump.29/// profile data dump.
43pub fn dumpStatsAt(pos_str: [*]u8) void {30pub fn dumpStatsAt(pos_str: [*]u8) void {
44 doCallgrindClientRequestStmt(CallgrindClientRequest.DumpStatsAt,31 doCallgrindClientRequestStmt(CallgrindClientRequest.DumpStatsAt, @ptrToInt(pos_str), 0, 0, 0, 0);
45 @ptrToInt(pos_str),
46 0, 0, 0, 0);
47}32}
4833
49
50/// Zero cost centers34/// Zero cost centers
51pub fn zeroStats() void {35pub fn zeroStats() void {
52 doCallgrindClientRequestStmt(CallgrindClientRequest.ZeroStats,36 doCallgrindClientRequestStmt(CallgrindClientRequest.ZeroStats, 0, 0, 0, 0, 0);
53 0, 0, 0, 0, 0);
54}37}
5538
56
57/// Toggles collection state.39/// Toggles collection state.
58/// The collection state specifies whether the happening of events40/// The collection state specifies whether the happening of events
59/// should be noted or if they are to be ignored. Events are noted41/// should be noted or if they are to be ignored. Events are noted
60/// by increment of counters in a cost center42/// by increment of counters in a cost center
61pub fn toggleCollect() void {43pub fn toggleCollect() void {
62 doCallgrindClientRequestStmt(CallgrindClientRequest.ToggleCollect,44 doCallgrindClientRequestStmt(CallgrindClientRequest.ToggleCollect, 0, 0, 0, 0, 0);
63 0, 0, 0, 0, 0);
64}45}
6546
66
67/// Start full callgrind instrumentation if not already switched on.47/// Start full callgrind instrumentation if not already switched on.
68/// When cache simulation is done, it will flush the simulated cache;48/// When cache simulation is done, it will flush the simulated cache;
69/// this will lead to an artificial cache warmup phase afterwards with49/// this will lead to an artificial cache warmup phase afterwards with
70/// cache misses which would not have happened in reality.50/// cache misses which would not have happened in reality.
71pub fn startInstrumentation() void {51pub fn startInstrumentation() void {
72 doCallgrindClientRequestStmt(CallgrindClientRequest.StartInstrumentation,52 doCallgrindClientRequestStmt(CallgrindClientRequest.StartInstrumentation, 0, 0, 0, 0, 0);
73 0, 0, 0, 0, 0);
74}53}
7554
76
77/// Stop full callgrind instrumentation if not already switched off.55/// Stop full callgrind instrumentation if not already switched off.
78/// This flushes Valgrinds translation cache, and does no additional56/// This flushes Valgrinds translation cache, and does no additional
79/// instrumentation afterwards, which effectivly will run at the same57/// instrumentation afterwards, which effectivly will run at the same
...@@ -82,6 +60,5 @@ pub fn startInstrumentation() void {...@@ -82,6 +60,5 @@ pub fn startInstrumentation() void {
82/// To start Callgrind in this mode to ignore the setup phase, use60/// To start Callgrind in this mode to ignore the setup phase, use
83/// the option "--instr-atstart=no".61/// the option "--instr-atstart=no".
84pub fn stopInstrumentation() void {62pub fn stopInstrumentation() void {
85 doCallgrindClientRequestStmt(CallgrindClientRequest.StopInstrumentation,63 doCallgrindClientRequestStmt(CallgrindClientRequest.StopInstrumentation, 0, 0, 0, 0, 0);
86 0, 0, 0, 0, 0);
87}64}
std/valgrind/memcheck.zig+26-96
...@@ -19,149 +19,102 @@ pub const MemCheckClientRequest = extern enum {...@@ -19,149 +19,102 @@ pub const MemCheckClientRequest = extern enum {
19 DisableAddrErrorReportingInRange,19 DisableAddrErrorReportingInRange,
20};20};
2121
22fn doMemCheckClientRequestExpr(default: usize, request: MemCheckClientRequest,22fn doMemCheckClientRequestExpr(default: usize, request: MemCheckClientRequest, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize) usize {
23 a1: usize, a2: usize, a3: usize, a4: usize, a5: usize23 return valgrind.doClientRequest(default, @intCast(usize, @enumToInt(request)), a1, a2, a3, a4, a5);
24 ) usize
25{
26 return valgrind.doClientRequest(
27 default,
28 @intCast(usize, @enumToInt(request)),
29 a1, a2, a3, a4, a5);
30}
31
32fn doMemCheckClientRequestStmt(request: MemCheckClientRequest,
33 a1: usize, a2: usize, a3: usize, a4: usize, a5: usize
34 ) void
35{
36 _ = doMemCheckClientRequestExpr(0, request, a1, a2, a3, a4, a5);
37}24}
3825
3926fn doMemCheckClientRequestStmt(request: MemCheckClientRequest, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize) void {
27 _ = doMemCheckClientRequestExpr(0, request, a1, a2, a3, a4, a5);
28}
4029
41/// Mark memory at qzz.ptr as unaddressable for qzz.len bytes.30/// Mark memory at qzz.ptr as unaddressable for qzz.len bytes.
42/// This returns -1 when run on Valgrind and 0 otherwise.31/// This returns -1 when run on Valgrind and 0 otherwise.
43pub fn makeMemNoAccess(qzz: []u8) i1 {32pub fn makeMemNoAccess(qzz: []u8) i1 {
44 return @intCast(i1, doMemCheckClientRequestExpr(0, // default return33 return @intCast(i1, doMemCheckClientRequestExpr(0, // default return
45 MemCheckClientRequest.MakeMemNoAccess,34 MemCheckClientRequest.MakeMemNoAccess, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0));
46 @ptrToInt(qzz.ptr), qzz.len,
47 0, 0, 0));
48}35}
4936
50
51/// Similarly, mark memory at qzz.ptr as addressable but undefined37/// Similarly, mark memory at qzz.ptr as addressable but undefined
52/// for qzz.len bytes.38/// for qzz.len bytes.
53/// This returns -1 when run on Valgrind and 0 otherwise.39/// This returns -1 when run on Valgrind and 0 otherwise.
54pub fn makeMemUndefined(qzz: []u8) i1 {40pub fn makeMemUndefined(qzz: []u8) i1 {
55 return @intCast(i1, doMemCheckClientRequestExpr(0, // default return41 return @intCast(i1, doMemCheckClientRequestExpr(0, // default return
56 MemCheckClientRequest.MakeMemUndefined,42 MemCheckClientRequest.MakeMemUndefined, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0));
57 @ptrToInt(qzz.ptr), qzz.len,
58 0, 0, 0));
59}43}
6044
61
62/// Similarly, mark memory at qzz.ptr as addressable and defined45/// Similarly, mark memory at qzz.ptr as addressable and defined
63/// for qzz.len bytes.46/// for qzz.len bytes.
64pub fn makeMemDefined(qzz: []u8) i1 {47pub fn makeMemDefined(qzz: []u8) i1 {
65// This returns -1 when run on Valgrind and 0 otherwise.48 // This returns -1 when run on Valgrind and 0 otherwise.
66 return @intCast(i1, doMemCheckClientRequestExpr(0, // default return49 return @intCast(i1, doMemCheckClientRequestExpr(0, // default return
67 MemCheckClientRequest.MakeMemDefined,50 MemCheckClientRequest.MakeMemDefined, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0));
68 @ptrToInt(qzz.ptr), qzz.len,
69 0, 0, 0));
70}51}
7152
72
73/// Similar to makeMemDefined except that addressability is53/// Similar to makeMemDefined except that addressability is
74/// not altered: bytes which are addressable are marked as defined,54/// not altered: bytes which are addressable are marked as defined,
75/// but those which are not addressable are left unchanged.55/// but those which are not addressable are left unchanged.
76/// This returns -1 when run on Valgrind and 0 otherwise.56/// This returns -1 when run on Valgrind and 0 otherwise.
77pub fn makeMemDefinedIfAddressable(qzz: []u8) i1 {57pub fn makeMemDefinedIfAddressable(qzz: []u8) i1 {
78 return @intCast(i1, doMemCheckClientRequestExpr(0, // default return58 return @intCast(i1, doMemCheckClientRequestExpr(0, // default return
79 MemCheckClientRequest.MakeMemDefinedIfAddressable,59 MemCheckClientRequest.MakeMemDefinedIfAddressable, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0));
80 @ptrToInt(qzz.ptr), qzz.len,
81 0, 0, 0));
82}60}
8361
84
85/// Create a block-description handle. The description is an ascii62/// Create a block-description handle. The description is an ascii
86/// string which is included in any messages pertaining to addresses63/// string which is included in any messages pertaining to addresses
87/// within the specified memory range. Has no other effect on the64/// within the specified memory range. Has no other effect on the
88/// properties of the memory range.65/// properties of the memory range.
89pub fn createBlock(qzz: []u8, desc: [*]u8) usize {66pub fn createBlock(qzz: []u8, desc: [*]u8) usize {
90 return doMemCheckClientRequestExpr(0, // default return67 return doMemCheckClientRequestExpr(0, // default return
91 MemCheckClientRequest.CreateBlock,68 MemCheckClientRequest.CreateBlock, @ptrToInt(qzz.ptr), qzz.len, @ptrToInt(desc), 0, 0);
92 @ptrToInt(qzz.ptr), qzz.len, @ptrToInt(desc),
93 0, 0);
94}69}
9570
96
97/// Discard a block-description-handle. Returns 1 for an71/// Discard a block-description-handle. Returns 1 for an
98/// invalid handle, 0 for a valid handle.72/// invalid handle, 0 for a valid handle.
99pub fn discard(blkindex) bool {73pub fn discard(blkindex) bool {
100 return doMemCheckClientRequestExpr(0, // default return74 return doMemCheckClientRequestExpr(0, // default return
101 MemCheckClientRequest.Discard,75 MemCheckClientRequest.Discard, 0, blkindex, 0, 0, 0) != 0;
102 0, blkindex,
103 0, 0, 0) != 0;
104}76}
10577
106
107/// Check that memory at qzz.ptr is addressable for qzz.len bytes.78/// Check that memory at qzz.ptr is addressable for qzz.len bytes.
108/// If suitable addressibility is not established, Valgrind prints an79/// If suitable addressibility is not established, Valgrind prints an
109/// error message and returns the address of the first offending byte.80/// error message and returns the address of the first offending byte.
110/// Otherwise it returns zero.81/// Otherwise it returns zero.
111pub fn checkMemIsAddressable(qzz: []u8) usize {82pub fn checkMemIsAddressable(qzz: []u8) usize {
112 return doMemCheckClientRequestExpr(0,83 return doMemCheckClientRequestExpr(0, MemCheckClientRequest.CheckMemIsAddressable, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0);
113 MemCheckClientRequest.CheckMemIsAddressable,
114 @ptrToInt(qzz.ptr), qzz.len,
115 0, 0, 0);
116}84}
11785
118
119/// Check that memory at qzz.ptr is addressable and defined for86/// Check that memory at qzz.ptr is addressable and defined for
120/// qzz.len bytes. If suitable addressibility and definedness are not87/// qzz.len bytes. If suitable addressibility and definedness are not
121/// established, Valgrind prints an error message and returns the88/// established, Valgrind prints an error message and returns the
122/// address of the first offending byte. Otherwise it returns zero.89/// address of the first offending byte. Otherwise it returns zero.
123pub fn checkMemIsDefined(qzz: []u8) usize {90pub fn checkMemIsDefined(qzz: []u8) usize {
124 return doMemCheckClientRequestExpr(0,91 return doMemCheckClientRequestExpr(0, MemCheckClientRequest.CheckMemIsDefined, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0);
125 MemCheckClientRequest.CheckMemIsDefined,
126 @ptrToInt(qzz.ptr), qzz.len,
127 0, 0, 0);
128}92}
12993
130/// Do a full memory leak check (like --leak-check=full) mid-execution.94/// Do a full memory leak check (like --leak-check=full) mid-execution.
131pub fn doLeakCheck() void {95pub fn doLeakCheck() void {
132 doMemCheckClientRequestStmt(MemCheckClientRequest.DO_LEAK_CHECK,96 doMemCheckClientRequestStmt(MemCheckClientRequest.DO_LEAK_CHECK, 0, 0, 0, 0, 0);
133 0, 0,
134 0, 0, 0);
135}97}
13698
137/// Same as doLeakCheck() but only showing the entries for99/// Same as doLeakCheck() but only showing the entries for
138/// which there was an increase in leaked bytes or leaked nr of blocks100/// which there was an increase in leaked bytes or leaked nr of blocks
139/// since the previous leak search.101/// since the previous leak search.
140pub fn doAddedLeakCheck() void {102pub fn doAddedLeakCheck() void {
141 doMemCheckClientRequestStmt(MemCheckClientRequest.DO_LEAK_CHECK,103 doMemCheckClientRequestStmt(MemCheckClientRequest.DO_LEAK_CHECK, 0, 1, 0, 0, 0);
142 0, 1,
143 0, 0, 0);
144}104}
145105
146
147/// Same as doAddedLeakCheck() but showing entries with106/// Same as doAddedLeakCheck() but showing entries with
148/// increased or decreased leaked bytes/blocks since previous leak107/// increased or decreased leaked bytes/blocks since previous leak
149/// search.108/// search.
150pub fn doChangedLeakCheck() void {109pub fn doChangedLeakCheck() void {
151 doMemCheckClientRequestStmt(MemCheckClientRequest.DO_LEAK_CHECK,110 doMemCheckClientRequestStmt(MemCheckClientRequest.DO_LEAK_CHECK, 0, 2, 0, 0, 0);
152 0, 2,
153 0, 0, 0);
154}111}
155112
156
157/// Do a summary memory leak check (like --leak-check=summary) mid-execution.113/// Do a summary memory leak check (like --leak-check=summary) mid-execution.
158pub fn doQuickLeakCheck() void {114pub fn doQuickLeakCheck() void {
159 doMemCheckClientRequestStmt(MemCheckClientRequest.DO_LEAK_CHECK,115 doMemCheckClientRequestStmt(MemCheckClientRequest.DO_LEAK_CHECK, 1, 0, 0, 0, 0);
160 1, 0,
161 0, 0, 0);
162}116}
163117
164
165/// Return number of leaked, dubious, reachable and suppressed bytes found by118/// Return number of leaked, dubious, reachable and suppressed bytes found by
166/// all previous leak checks.119/// all previous leak checks.
167const CountResult = struct {120const CountResult = struct {
...@@ -172,34 +125,27 @@ const CountResult = struct {...@@ -172,34 +125,27 @@ const CountResult = struct {
172};125};
173126
174pub fn countLeaks() CountResult {127pub fn countLeaks() CountResult {
175 var res = CountResult {128 var res = CountResult{
176 .leaked = 0,129 .leaked = 0,
177 .dubious = 0,130 .dubious = 0,
178 .reachable = 0,131 .reachable = 0,
179 .suppressed = 0,132 .suppressed = 0,
180 };133 };
181 doMemCheckClientRequestStmt(MemCheckClientRequest.CountLeaks,134 doMemCheckClientRequestStmt(MemCheckClientRequest.CountLeaks, &res.leaked, &res.dubious, &res.reachable, &res.suppressed, 0);
182 &res.leaked, &res.dubious,
183 &res.reachable, &res.suppressed,
184 0);
185 return res;135 return res;
186}136}
187137
188pub fn countLeakBlocks() CountResult {138pub fn countLeakBlocks() CountResult {
189 var res = CountResult {139 var res = CountResult{
190 .leaked = 0,140 .leaked = 0,
191 .dubious = 0,141 .dubious = 0,
192 .reachable = 0,142 .reachable = 0,
193 .suppressed = 0,143 .suppressed = 0,
194 };144 };
195 doMemCheckClientRequestStmt(MemCheckClientRequest.CountLeakBlocks,145 doMemCheckClientRequestStmt(MemCheckClientRequest.CountLeakBlocks, &res.leaked, &res.dubious, &res.reachable, &res.suppressed, 0);
196 &res.leaked, &res.dubious,
197 &res.reachable, &res.suppressed,
198 0);
199 return res;146 return res;
200}147}
201148
202
203/// Get the validity data for addresses zza and copy it149/// Get the validity data for addresses zza and copy it
204/// into the provided zzvbits array. Return values:150/// into the provided zzvbits array. Return values:
205/// 0 if not running on valgrind151/// 0 if not running on valgrind
...@@ -210,15 +156,9 @@ pub fn countLeakBlocks() CountResult {...@@ -210,15 +156,9 @@ pub fn countLeakBlocks() CountResult {
210/// impossible to segfault your system by using this call.156/// impossible to segfault your system by using this call.
211pub fn getVbits(zza: []u8, zzvbits: []u8) u2 {157pub fn getVbits(zza: []u8, zzvbits: []u8) u2 {
212 std.debug.assert(zzvbits.len >= zza.len / 8);158 std.debug.assert(zzvbits.len >= zza.len / 8);
213 return @intCast(u2, doMemCheckClientRequestExpr(0,159 return @intCast(u2, doMemCheckClientRequestExpr(0, MemCheckClientRequest.GetVbits, @ptrToInt(zza.ptr), @ptrToInt(zzvbits), zza.len, 0, 0));
214 MemCheckClientRequest.GetVbits,
215 @ptrToInt(zza.ptr),
216 @ptrToInt(zzvbits),
217 zza.len,
218 0, 0));
219}160}
220161
221
222/// Set the validity data for addresses zza, copying it162/// Set the validity data for addresses zza, copying it
223/// from the provided zzvbits array. Return values:163/// from the provided zzvbits array. Return values:
224/// 0 if not running on valgrind164/// 0 if not running on valgrind
...@@ -229,27 +169,17 @@ pub fn getVbits(zza: []u8, zzvbits: []u8) u2 {...@@ -229,27 +169,17 @@ pub fn getVbits(zza: []u8, zzvbits: []u8) u2 {
229/// impossible to segfault your system by using this call.169/// impossible to segfault your system by using this call.
230pub fn setVbits(zzvbits: []u8, zza: []u8) u2 {170pub fn setVbits(zzvbits: []u8, zza: []u8) u2 {
231 std.debug.assert(zzvbits.len >= zza.len / 8);171 std.debug.assert(zzvbits.len >= zza.len / 8);
232 return @intCast(u2, doMemCheckClientRequestExpr(0,172 return @intCast(u2, doMemCheckClientRequestExpr(0, MemCheckClientRequest.SetVbits, @ptrToInt(zza.ptr), @ptrToInt(zzvbits), zza.len, 0, 0));
233 MemCheckClientRequest.SetVbits,
234 @ptrToInt(zza.ptr),
235 @ptrToInt(zzvbits),
236 zza.len,
237 0, 0));
238}173}
239174
240
241/// Disable and re-enable reporting of addressing errors in the175/// Disable and re-enable reporting of addressing errors in the
242/// specified address range.176/// specified address range.
243pub fn disableAddrErrorReportingInRange(qzz: []u8) usize {177pub fn disableAddrErrorReportingInRange(qzz: []u8) usize {
244 return doMemCheckClientRequestExpr(0, // default return178 return doMemCheckClientRequestExpr(0, // default return
245 MemCheckClientRequest.DisableAddrErrorReportingInRange,179 MemCheckClientRequest.DisableAddrErrorReportingInRange, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0);
246 @ptrToInt(qzz.ptr), qzz.len,
247 0, 0, 0);
248}180}
249181
250pub fn enableAddrErrorReportingInRange(qzz: []u8) usize {182pub fn enableAddrErrorReportingInRange(qzz: []u8) usize {
251 return doMemCheckClientRequestExpr(0, // default return183 return doMemCheckClientRequestExpr(0, // default return
252 MemCheckClientRequest.EnableAddrErrorReportingInRange,184 MemCheckClientRequest.EnableAddrErrorReportingInRange, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0);
253 @ptrToInt(qzz.ptr), qzz.len,
254 0, 0, 0);
255}185}