mirror of
https://github.com/ziglang/zig.git
synced 2024-11-16 00:57:04 +00:00
zig fmt on the standard library
This commit is contained in:
parent
ed5a6d74ad
commit
c1793d6106
@ -44,16 +44,22 @@ pub const pthread_attr_t = extern struct {
|
||||
pub const msghdr = extern struct {
|
||||
/// optional address
|
||||
msg_name: ?*sockaddr,
|
||||
|
||||
/// size of address
|
||||
msg_namelen: socklen_t,
|
||||
|
||||
/// scatter/gather array
|
||||
msg_iov: [*]iovec,
|
||||
|
||||
/// # elements in msg_iov
|
||||
msg_iovlen: i32,
|
||||
|
||||
/// ancillary data
|
||||
msg_control: ?*c_void,
|
||||
|
||||
/// ancillary data buffer len
|
||||
msg_controllen: socklen_t,
|
||||
|
||||
/// flags on received message
|
||||
msg_flags: i32,
|
||||
};
|
||||
@ -61,16 +67,22 @@ pub const msghdr = extern struct {
|
||||
pub const msghdr_const = extern struct {
|
||||
/// optional address
|
||||
msg_name: ?*const sockaddr,
|
||||
|
||||
/// size of address
|
||||
msg_namelen: socklen_t,
|
||||
|
||||
/// scatter/gather array
|
||||
msg_iov: [*]iovec_const,
|
||||
|
||||
/// # elements in msg_iov
|
||||
msg_iovlen: i32,
|
||||
|
||||
/// ancillary data
|
||||
msg_control: ?*c_void,
|
||||
|
||||
/// ancillary data buffer len
|
||||
msg_controllen: socklen_t,
|
||||
|
||||
/// flags on received message
|
||||
msg_flags: i32,
|
||||
};
|
||||
|
@ -44,16 +44,22 @@ pub const pthread_attr_t = extern struct {
|
||||
pub const msghdr = extern struct {
|
||||
/// optional address
|
||||
msg_name: ?*sockaddr,
|
||||
|
||||
/// size of address
|
||||
msg_namelen: socklen_t,
|
||||
|
||||
/// scatter/gather array
|
||||
msg_iov: [*]iovec,
|
||||
|
||||
/// # elements in msg_iov
|
||||
msg_iovlen: i32,
|
||||
|
||||
/// ancillary data
|
||||
msg_control: ?*c_void,
|
||||
|
||||
/// ancillary data buffer len
|
||||
msg_controllen: socklen_t,
|
||||
|
||||
/// flags on received message
|
||||
msg_flags: i32,
|
||||
};
|
||||
@ -61,16 +67,22 @@ pub const msghdr = extern struct {
|
||||
pub const msghdr_const = extern struct {
|
||||
/// optional address
|
||||
msg_name: ?*const sockaddr,
|
||||
|
||||
/// size of address
|
||||
msg_namelen: socklen_t,
|
||||
|
||||
/// scatter/gather array
|
||||
msg_iov: [*]iovec_const,
|
||||
|
||||
/// # elements in msg_iov
|
||||
msg_iovlen: i32,
|
||||
|
||||
/// ancillary data
|
||||
msg_control: ?*c_void,
|
||||
|
||||
/// ancillary data buffer len
|
||||
msg_controllen: socklen_t,
|
||||
|
||||
/// flags on received message
|
||||
msg_flags: i32,
|
||||
};
|
||||
|
@ -93,7 +93,7 @@ pub fn linkmap_iterator(phdrs: []elf.Phdr) !LinkMap.Iterator {
|
||||
// second slot
|
||||
break :init @intToPtr(?*LinkMap, got_table[1]);
|
||||
},
|
||||
else => { }
|
||||
else => {},
|
||||
}
|
||||
}
|
||||
return error.InvalidExe;
|
||||
|
@ -86,8 +86,7 @@ const tls_dtv_offset = switch (builtin.arch) {
|
||||
};
|
||||
|
||||
// Per-thread storage for Zig's use
|
||||
const CustomData = packed struct {
|
||||
};
|
||||
const CustomData = packed struct {};
|
||||
|
||||
// Dynamic Thread Vector
|
||||
const DTV = packed struct {
|
||||
@ -109,14 +108,14 @@ pub var tls_image: ?TLSImage = null;
|
||||
pub fn setThreadPointer(addr: usize) void {
|
||||
switch (builtin.arch) {
|
||||
.x86_64 => {
|
||||
const rc = std.os.linux.syscall2(std.os.linux.SYS_arch_prctl,
|
||||
std.os.linux.ARCH_SET_FS, addr);
|
||||
const rc = std.os.linux.syscall2(std.os.linux.SYS_arch_prctl, std.os.linux.ARCH_SET_FS, addr);
|
||||
assert(rc == 0);
|
||||
},
|
||||
.aarch64 => {
|
||||
asm volatile (
|
||||
\\ msr tpidr_el0, %[addr]
|
||||
: : [addr] "r" (addr)
|
||||
:
|
||||
: [addr] "r" (addr)
|
||||
);
|
||||
},
|
||||
else => @compileError("Unsupported architecture"),
|
||||
@ -194,7 +193,7 @@ pub fn initTLS() void {
|
||||
dtv_offset = l;
|
||||
l += @sizeOf(DTV);
|
||||
break :blk l;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
tls_image = TLSImage{
|
||||
@ -238,8 +237,7 @@ pub fn allocateTLS(size: usize) usize {
|
||||
return @ptrToInt(&main_thread_tls_buffer);
|
||||
}
|
||||
|
||||
const addr = posix.mmap(null, size, posix.PROT_READ | posix.PROT_WRITE,
|
||||
posix.MAP_PRIVATE | posix.MAP_ANONYMOUS, -1, 0);
|
||||
const addr = posix.mmap(null, size, posix.PROT_READ | posix.PROT_WRITE, posix.MAP_PRIVATE | posix.MAP_ANONYMOUS, -1, 0);
|
||||
|
||||
if (posix.getErrno(addr) != 0) @panic("out of memory");
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
use @import("../windows.zig");
|
||||
|
||||
pub extern "shell32" stdcallcc fn SHGetKnownFolderPath(rfid: *const KNOWNFOLDERID, dwFlags: DWORD, hToken: ?HANDLE, ppszPath: *[*]WCHAR) HRESULT;
|
||||
|
||||
|
@ -338,7 +338,10 @@ extern fn __umoddi3(a: u64, b: u64) u64 {
|
||||
return r;
|
||||
}
|
||||
|
||||
extern fn __aeabi_uidivmod(n: u32, d: u32) extern struct{q: u32, r: u32} {
|
||||
extern fn __aeabi_uidivmod(n: u32, d: u32) extern struct {
|
||||
q: u32,
|
||||
r: u32,
|
||||
} {
|
||||
@setRuntimeSafety(is_test);
|
||||
|
||||
var result: @typeOf(__aeabi_uidivmod).ReturnType = undefined;
|
||||
@ -346,7 +349,10 @@ extern fn __aeabi_uidivmod(n: u32, d: u32) extern struct{q: u32, r: u32} {
|
||||
return result;
|
||||
}
|
||||
|
||||
extern fn __aeabi_uldivmod(n: u64, d: u64) extern struct{q: u64, r: u64} {
|
||||
extern fn __aeabi_uldivmod(n: u64, d: u64) extern struct {
|
||||
q: u64,
|
||||
r: u64,
|
||||
} {
|
||||
@setRuntimeSafety(is_test);
|
||||
|
||||
var result: @typeOf(__aeabi_uldivmod).ReturnType = undefined;
|
||||
@ -354,7 +360,10 @@ extern fn __aeabi_uldivmod(n: u64, d: u64) extern struct{q: u64, r: u64} {
|
||||
return result;
|
||||
}
|
||||
|
||||
extern fn __aeabi_idivmod(n: i32, d: i32) extern struct{q: i32, r: i32} {
|
||||
extern fn __aeabi_idivmod(n: i32, d: i32) extern struct {
|
||||
q: i32,
|
||||
r: i32,
|
||||
} {
|
||||
@setRuntimeSafety(is_test);
|
||||
|
||||
var result: @typeOf(__aeabi_idivmod).ReturnType = undefined;
|
||||
@ -362,7 +371,10 @@ extern fn __aeabi_idivmod(n: i32, d: i32) extern struct{q: i32, r: i32} {
|
||||
return result;
|
||||
}
|
||||
|
||||
extern fn __aeabi_ldivmod(n: i64, d: i64) extern struct{q: i64, r:i64} {
|
||||
extern fn __aeabi_ldivmod(n: i64, d: i64) extern struct {
|
||||
q: i64,
|
||||
r: i64,
|
||||
} {
|
||||
@setRuntimeSafety(is_test);
|
||||
|
||||
var result: @typeOf(__aeabi_ldivmod).ReturnType = undefined;
|
||||
|
@ -12,7 +12,6 @@ fn test__fixdfdi(a: f64, expected: i64) void {
|
||||
|
||||
test "fixdfdi" {
|
||||
//warn("\n");
|
||||
|
||||
test__fixdfdi(-math.f64_max, math.minInt(i64));
|
||||
|
||||
test__fixdfdi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i64));
|
||||
|
@ -12,7 +12,6 @@ fn test__fixdfsi(a: f64, expected: i32) void {
|
||||
|
||||
test "fixdfsi" {
|
||||
//warn("\n");
|
||||
|
||||
test__fixdfsi(-math.f64_max, math.minInt(i32));
|
||||
|
||||
test__fixdfsi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i32));
|
||||
|
@ -12,7 +12,6 @@ fn test__fixdfti(a: f64, expected: i128) void {
|
||||
|
||||
test "fixdfti" {
|
||||
//warn("\n");
|
||||
|
||||
test__fixdfti(-math.f64_max, math.minInt(i128));
|
||||
|
||||
test__fixdfti(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i128));
|
||||
|
@ -12,7 +12,6 @@ fn test__fixsfdi(a: f32, expected: i64) void {
|
||||
|
||||
test "fixsfdi" {
|
||||
//warn("\n");
|
||||
|
||||
test__fixsfdi(-math.f32_max, math.minInt(i64));
|
||||
|
||||
test__fixsfdi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i64));
|
||||
|
@ -12,7 +12,6 @@ fn test__fixsfsi(a: f32, expected: i32) void {
|
||||
|
||||
test "fixsfsi" {
|
||||
//warn("\n");
|
||||
|
||||
test__fixsfsi(-math.f32_max, math.minInt(i32));
|
||||
|
||||
test__fixsfsi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i32));
|
||||
|
@ -12,7 +12,6 @@ fn test__fixsfti(a: f32, expected: i128) void {
|
||||
|
||||
test "fixsfti" {
|
||||
//warn("\n");
|
||||
|
||||
test__fixsfti(-math.f32_max, math.minInt(i128));
|
||||
|
||||
test__fixsfti(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i128));
|
||||
|
@ -12,7 +12,6 @@ fn test__fixtfdi(a: f128, expected: i64) void {
|
||||
|
||||
test "fixtfdi" {
|
||||
//warn("\n");
|
||||
|
||||
test__fixtfdi(-math.f128_max, math.minInt(i64));
|
||||
|
||||
test__fixtfdi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i64));
|
||||
|
@ -12,7 +12,6 @@ fn test__fixtfsi(a: f128, expected: i32) void {
|
||||
|
||||
test "fixtfsi" {
|
||||
//warn("\n");
|
||||
|
||||
test__fixtfsi(-math.f128_max, math.minInt(i32));
|
||||
|
||||
test__fixtfsi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i32));
|
||||
|
@ -12,7 +12,6 @@ fn test__fixtfti(a: f128, expected: i128) void {
|
||||
|
||||
test "fixtfti" {
|
||||
//warn("\n");
|
||||
|
||||
test__fixtfti(-math.f128_max, math.minInt(i128));
|
||||
|
||||
test__fixtfti(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i128));
|
||||
|
@ -51,7 +51,7 @@ pub nakedcc fn zig_probe_stack() void {
|
||||
\\ ret
|
||||
);
|
||||
},
|
||||
else => { }
|
||||
else => {},
|
||||
}
|
||||
|
||||
unreachable;
|
||||
@ -103,7 +103,7 @@ fn win_probe_stack_only() void {
|
||||
\\ ret
|
||||
);
|
||||
},
|
||||
else => { }
|
||||
else => {},
|
||||
}
|
||||
|
||||
unreachable;
|
||||
@ -189,7 +189,7 @@ pub nakedcc fn __chkstk() void {
|
||||
switch (builtin.arch) {
|
||||
.i386 => @inlineCall(win_probe_stack_adjust_sp),
|
||||
.x86_64 => @inlineCall(win_probe_stack_only),
|
||||
else => unreachable
|
||||
else => unreachable,
|
||||
}
|
||||
}
|
||||
pub nakedcc fn ___chkstk() void {
|
||||
|
162
std/valgrind.zig
162
std/valgrind.zig
@ -1,11 +1,7 @@
|
||||
const builtin = @import("builtin");
|
||||
const math = @import("index.zig").math;
|
||||
|
||||
|
||||
pub fn doClientRequest(default: usize, request: usize,
|
||||
a1: usize, a2: usize, a3: usize, a4: usize, a5: usize
|
||||
) usize
|
||||
{
|
||||
pub fn doClientRequest(default: usize, request: usize, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize) usize {
|
||||
if (!builtin.valgrind_support) {
|
||||
return default;
|
||||
}
|
||||
@ -42,10 +38,9 @@ pub fn doClientRequest(default: usize, request: usize,
|
||||
// mips64
|
||||
else => {
|
||||
return default;
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub const ClientRequest = extern enum {
|
||||
RunningOnValgrind = 4097,
|
||||
@ -87,53 +82,33 @@ pub fn IsTool(base: [2]u8, code: usize) bool {
|
||||
return ToolBase(base) == (code & 0xffff0000);
|
||||
}
|
||||
|
||||
fn doClientRequestExpr(default: usize, request: ClientRequest,
|
||||
a1: usize, a2: usize, a3: usize, a4: usize, a5: usize
|
||||
) usize
|
||||
{
|
||||
return doClientRequest(
|
||||
default,
|
||||
@intCast(usize, @enumToInt(request)),
|
||||
a1, a2, a3, a4, a5);
|
||||
fn doClientRequestExpr(default: usize, request: ClientRequest, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize) usize {
|
||||
return doClientRequest(default, @intCast(usize, @enumToInt(request)), a1, a2, a3, a4, a5);
|
||||
}
|
||||
|
||||
fn doClientRequestStmt(request: ClientRequest,
|
||||
a1: usize, a2: usize, a3: usize, a4: usize, a5: usize
|
||||
) void
|
||||
{
|
||||
fn doClientRequestStmt(request: ClientRequest, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize) void {
|
||||
_ = doClientRequestExpr(0, request, a1, a2, a3, a4, a5);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// Returns the number of Valgrinds this code is running under. That
|
||||
/// is, 0 if running natively, 1 if running under Valgrind, 2 if
|
||||
/// running under Valgrind which is running under another Valgrind,
|
||||
/// etc.
|
||||
pub fn runningOnValgrind() usize {
|
||||
return doClientRequestExpr(0,
|
||||
ClientRequest.RunningOnValgrind,
|
||||
0, 0, 0, 0, 0);
|
||||
return doClientRequestExpr(0, ClientRequest.RunningOnValgrind, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
/// Discard translation of code in the slice qzz. Useful if you are debugging
|
||||
/// a JITter or some such, since it provides a way to make sure valgrind will
|
||||
/// retranslate the invalidated area. Returns no value.
|
||||
pub fn discardTranslations(qzz: []const u8) void {
|
||||
doClientRequestStmt(ClientRequest.DiscardTranslations,
|
||||
@ptrToInt(qzz.ptr), qzz.len,
|
||||
0, 0, 0);
|
||||
doClientRequestStmt(ClientRequest.DiscardTranslations, @ptrToInt(qzz.ptr), qzz.len, 0, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
pub fn innerThreads(qzz: [*]u8) void {
|
||||
doClientRequestStmt(ClientRequest.InnerThreads,
|
||||
qzz,
|
||||
0, 0, 0, 0);
|
||||
doClientRequestStmt(ClientRequest.InnerThreads, qzz, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
//pub fn printf(format: [*]const u8, args: ...) usize {
|
||||
// return doClientRequestExpr(0,
|
||||
// ClientRequest.PrintfValistByRef,
|
||||
@ -141,7 +116,6 @@ pub fn innerThreads(qzz: [*]u8) void {
|
||||
// 0, 0, 0);
|
||||
//}
|
||||
|
||||
|
||||
//pub fn printfBacktrace(format: [*]const u8, args: ...) usize {
|
||||
// return doClientRequestExpr(0,
|
||||
// ClientRequest.PrintfBacktraceValistByRef,
|
||||
@ -149,161 +123,105 @@ pub fn innerThreads(qzz: [*]u8) void {
|
||||
// 0, 0, 0);
|
||||
//}
|
||||
|
||||
|
||||
pub fn nonSIMDCall0(func: fn (usize) usize) usize {
|
||||
return doClientRequestExpr(0,
|
||||
ClientRequest.ClientCall0,
|
||||
@ptrToInt(func),
|
||||
0, 0, 0, 0);
|
||||
return doClientRequestExpr(0, ClientRequest.ClientCall0, @ptrToInt(func), 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
pub fn nonSIMDCall1(func: fn (usize, usize) usize, a1: usize) usize {
|
||||
return doClientRequestExpr(0,
|
||||
ClientRequest.ClientCall1,
|
||||
@ptrToInt(func), a1,
|
||||
0, 0, 0);
|
||||
return doClientRequestExpr(0, ClientRequest.ClientCall1, @ptrToInt(func), a1, 0, 0, 0);
|
||||
}
|
||||
|
||||
pub fn nonSIMDCall2(func: fn(usize, usize, usize) usize,
|
||||
a1: usize, a2: usize) usize
|
||||
{
|
||||
return doClientRequestExpr(0,
|
||||
ClientRequest.ClientCall2,
|
||||
@ptrToInt(func), a1, a2,
|
||||
0, 0);
|
||||
pub fn nonSIMDCall2(func: fn (usize, usize, usize) usize, a1: usize, a2: usize) usize {
|
||||
return doClientRequestExpr(0, ClientRequest.ClientCall2, @ptrToInt(func), a1, a2, 0, 0);
|
||||
}
|
||||
|
||||
pub fn nonSIMDCall3(func: fn(usize, usize, usize, usize) usize,
|
||||
a1: usize, a2: usize, a3: usize) usize
|
||||
{
|
||||
return doClientRequestExpr(0,
|
||||
ClientRequest.ClientCall3,
|
||||
@ptrToInt(func), a1, a2, a3,
|
||||
0);
|
||||
pub fn nonSIMDCall3(func: fn (usize, usize, usize, usize) usize, a1: usize, a2: usize, a3: usize) usize {
|
||||
return doClientRequestExpr(0, ClientRequest.ClientCall3, @ptrToInt(func), a1, a2, a3, 0);
|
||||
}
|
||||
|
||||
|
||||
/// Counts the number of errors that have been recorded by a tool. Nb:
|
||||
/// the tool must record the errors with VG_(maybe_record_error)() or
|
||||
/// VG_(unique_error)() for them to be counted.
|
||||
pub fn countErrors() usize {
|
||||
return doClientRequestExpr(0, // default return
|
||||
ClientRequest.CountErrors,
|
||||
0, 0, 0, 0, 0);
|
||||
ClientRequest.CountErrors, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
pub fn mallocLikeBlock(mem: []u8, rzB: usize, is_zeroed: bool) void {
|
||||
doClientRequestStmt(ClientRequest.MalloclikeBlock,
|
||||
@ptrToInt(mem.ptr), mem.len, rzB, @boolToInt(is_zeroed),
|
||||
0);
|
||||
doClientRequestStmt(ClientRequest.MalloclikeBlock, @ptrToInt(mem.ptr), mem.len, rzB, @boolToInt(is_zeroed), 0);
|
||||
}
|
||||
|
||||
|
||||
pub fn resizeInPlaceBlock(oldmem: []u8, newsize: usize, rzB: usize) void {
|
||||
doClientRequestStmt(ClientRequest.ResizeinplaceBlock,
|
||||
@ptrToInt(oldmem.ptr), oldmem.len, newsize, rzB,
|
||||
0);
|
||||
doClientRequestStmt(ClientRequest.ResizeinplaceBlock, @ptrToInt(oldmem.ptr), oldmem.len, newsize, rzB, 0);
|
||||
}
|
||||
|
||||
|
||||
pub fn freeLikeBlock(addr: [*]u8, rzB: usize) void {
|
||||
doClientRequestStmt(ClientRequest.FreelikeBlock,
|
||||
@ptrToInt(addr), rzB,
|
||||
0, 0, 0);
|
||||
doClientRequestStmt(ClientRequest.FreelikeBlock, @ptrToInt(addr), rzB, 0, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
/// Create a memory pool.
|
||||
pub const MempoolFlags = extern enum {
|
||||
AutoFree = 1,
|
||||
MetaPool = 2,
|
||||
};
|
||||
pub fn createMempool(pool: [*]u8, rzB: usize, is_zeroed: bool, flags: usize) void {
|
||||
doClientRequestStmt(ClientRequest.CreateMempool,
|
||||
@ptrToInt(pool), rzB, @boolToInt(is_zeroed), flags,
|
||||
0);
|
||||
doClientRequestStmt(ClientRequest.CreateMempool, @ptrToInt(pool), rzB, @boolToInt(is_zeroed), flags, 0);
|
||||
}
|
||||
|
||||
/// Destroy a memory pool.
|
||||
pub fn destroyMempool(pool: [*]u8) void {
|
||||
doClientRequestStmt(ClientRequest.DestroyMempool,
|
||||
pool,
|
||||
0, 0, 0, 0);
|
||||
doClientRequestStmt(ClientRequest.DestroyMempool, pool, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
/// Associate a piece of memory with a memory pool.
|
||||
pub fn mempoolAlloc(pool: [*]u8, mem: []u8) void {
|
||||
doClientRequestStmt(ClientRequest.MempoolAlloc,
|
||||
@ptrToInt(pool), @ptrToInt(mem.ptr), mem.len,
|
||||
0, 0);
|
||||
doClientRequestStmt(ClientRequest.MempoolAlloc, @ptrToInt(pool), @ptrToInt(mem.ptr), mem.len, 0, 0);
|
||||
}
|
||||
|
||||
/// Disassociate a piece of memory from a memory pool.
|
||||
pub fn mempoolFree(pool: [*]u8, addr: [*]u8) void {
|
||||
doClientRequestStmt(ClientRequest.MempoolFree,
|
||||
@ptrToInt(pool), @ptrToInt(addr),
|
||||
0, 0, 0);
|
||||
doClientRequestStmt(ClientRequest.MempoolFree, @ptrToInt(pool), @ptrToInt(addr), 0, 0, 0);
|
||||
}
|
||||
|
||||
/// Disassociate any pieces outside a particular range.
|
||||
pub fn mempoolTrim(pool: [*]u8, mem: []u8) void {
|
||||
doClientRequestStmt(ClientRequest.MempoolTrim,
|
||||
@ptrToInt(pool), @ptrToInt(mem.ptr), mem.len,
|
||||
0, 0);
|
||||
doClientRequestStmt(ClientRequest.MempoolTrim, @ptrToInt(pool), @ptrToInt(mem.ptr), mem.len, 0, 0);
|
||||
}
|
||||
|
||||
/// Resize and/or move a piece associated with a memory pool.
|
||||
pub fn moveMempool(poolA: [*]u8, poolB: [*]u8) void {
|
||||
doClientRequestStmt(ClientRequest.MoveMempool,
|
||||
@ptrToInt(poolA), @ptrToInt(poolB),
|
||||
0, 0, 0);
|
||||
doClientRequestStmt(ClientRequest.MoveMempool, @ptrToInt(poolA), @ptrToInt(poolB), 0, 0, 0);
|
||||
}
|
||||
|
||||
/// Resize and/or move a piece associated with a memory pool.
|
||||
pub fn mempoolChange(pool: [*]u8, addrA: [*]u8, mem: []u8) void {
|
||||
doClientRequestStmt(ClientRequest.MempoolChange,
|
||||
@ptrToInt(pool), @ptrToInt(addrA), @ptrToInt(mem.ptr), mem.len,
|
||||
0);
|
||||
doClientRequestStmt(ClientRequest.MempoolChange, @ptrToInt(pool), @ptrToInt(addrA), @ptrToInt(mem.ptr), mem.len, 0);
|
||||
}
|
||||
|
||||
/// Return if a mempool exists.
|
||||
pub fn mempoolExists(pool: [*]u8) bool {
|
||||
return doClientRequestExpr(0,
|
||||
ClientRequest.MempoolExists,
|
||||
@ptrToInt(pool),
|
||||
0, 0, 0, 0) != 0;
|
||||
return doClientRequestExpr(0, ClientRequest.MempoolExists, @ptrToInt(pool), 0, 0, 0, 0) != 0;
|
||||
}
|
||||
|
||||
|
||||
/// Mark a piece of memory as being a stack. Returns a stack id.
|
||||
/// start is the lowest addressable stack byte, end is the highest
|
||||
/// addressable stack byte.
|
||||
pub fn stackRegister(stack: []u8) usize {
|
||||
return doClientRequestExpr(0,
|
||||
ClientRequest.StackRegister,
|
||||
@ptrToInt(stack.ptr), @ptrToInt(stack.ptr) + stack.len,
|
||||
0, 0, 0);
|
||||
return doClientRequestExpr(0, ClientRequest.StackRegister, @ptrToInt(stack.ptr), @ptrToInt(stack.ptr) + stack.len, 0, 0, 0);
|
||||
}
|
||||
|
||||
/// Unmark the piece of memory associated with a stack id as being a stack.
|
||||
pub fn stackDeregister(id: usize) void {
|
||||
doClientRequestStmt(ClientRequest.StackDeregister,
|
||||
id,
|
||||
0, 0, 0, 0);
|
||||
doClientRequestStmt(ClientRequest.StackDeregister, id, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
/// Change the start and end address of the stack id.
|
||||
/// start is the new lowest addressable stack byte, end is the new highest
|
||||
/// addressable stack byte.
|
||||
pub fn stackChange(id: usize, newstack: []u8) void {
|
||||
doClientRequestStmt(ClientRequest.StackChange,
|
||||
id, @ptrToInt(newstack.ptr), @ptrToInt(newstack.ptr) + newstack.len,
|
||||
0, 0);
|
||||
doClientRequestStmt(ClientRequest.StackChange, id, @ptrToInt(newstack.ptr), @ptrToInt(newstack.ptr) + newstack.len, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
// Load PDB debug info for Wine PE image_map.
|
||||
// pub fn loadPdbDebuginfo(fd, ptr, total_size, delta) void {
|
||||
// doClientRequestStmt(ClientRequest.LoadPdbDebuginfo,
|
||||
@ -311,19 +229,14 @@ pub fn stackChange(id: usize, newstack: []u8) void {
|
||||
// 0);
|
||||
// }
|
||||
|
||||
|
||||
/// Map a code address to a source file name and line number. buf64
|
||||
/// must point to a 64-byte buffer in the caller's address space. The
|
||||
/// result will be dumped in there and is guaranteed to be zero
|
||||
/// terminated. If no info is found, the first byte is set to zero.
|
||||
pub fn mapIpToSrcloc(addr: *const u8, buf64: [64]u8) usize {
|
||||
return doClientRequestExpr(0,
|
||||
ClientRequest.MapIpToSrcloc,
|
||||
@ptrToInt(addr), @ptrToInt(&buf64[0]),
|
||||
0, 0, 0);
|
||||
return doClientRequestExpr(0, ClientRequest.MapIpToSrcloc, @ptrToInt(addr), @ptrToInt(&buf64[0]), 0, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
/// Disable error reporting for this thread. Behaves in a stack like
|
||||
/// way, so you can safely call this multiple times provided that
|
||||
/// enableErrorReporting() is called the same number of times
|
||||
@ -333,31 +246,22 @@ pub fn mapIpToSrcloc(addr: *const u8, buf64: [64]u8) usize {
|
||||
/// reporting. Child threads do not inherit this setting from their
|
||||
/// parents -- they are always created with reporting enabled.
|
||||
pub fn disableErrorReporting() void {
|
||||
doClientRequestStmt(ClientRequest.ChangeErrDisablement,
|
||||
1,
|
||||
0, 0, 0, 0);
|
||||
doClientRequestStmt(ClientRequest.ChangeErrDisablement, 1, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
/// Re-enable error reporting, (see disableErrorReporting())
|
||||
pub fn enableErrorReporting() void {
|
||||
doClientRequestStmt(ClientRequest.ChangeErrDisablement,
|
||||
math.maxInt(usize),
|
||||
0, 0, 0, 0);
|
||||
doClientRequestStmt(ClientRequest.ChangeErrDisablement, math.maxInt(usize), 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
/// Execute a monitor command from the client program.
|
||||
/// If a connection is opened with GDB, the output will be sent
|
||||
/// according to the output mode set for vgdb.
|
||||
/// If no connection is opened, output will go to the log output.
|
||||
/// Returns 1 if command not recognised, 0 otherwise.
|
||||
pub fn monitorCommand(command: [*]u8) bool {
|
||||
return doClientRequestExpr(0,
|
||||
ClientRequest.GdbMonitorCommand,
|
||||
@ptrToInt(command.ptr),
|
||||
0, 0, 0, 0) != 0;
|
||||
return doClientRequestExpr(0, ClientRequest.GdbMonitorCommand, @ptrToInt(command.ptr), 0, 0, 0, 0) != 0;
|
||||
}
|
||||
|
||||
|
||||
pub const memcheck = @import("memcheck.zig");
|
||||
pub const callgrind = @import("callgrind.zig");
|
||||
|
@ -13,4 +13,3 @@ test "std.zig tests" {
|
||||
_ = @import("zig/tokenizer.zig");
|
||||
_ = @import("zig/parse_string_literal.zig");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user