aboutsummaryrefslogtreecommitdiff
path: root/src/codegen
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-11-01 14:45:05 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-11-01 14:45:05 -0700
commit63f4778827bf7e48e7b451d3d04dc1a74126a6d3 (patch)
tree6a63513d8f7b2853cecd9ee6d5775471bdd32bbf /src/codegen
parent70ef9bc75c42ec00e9d4231a2e1f1dca84144748 (diff)
downloadzig-63f4778827bf7e48e7b451d3d04dc1a74126a6d3.tar.gz
zig-63f4778827bf7e48e7b451d3d04dc1a74126a6d3.zip
std: add Linux perf syscall bits
Example usage: ```zig const std = @import("std"); const PERF = std.os.linux.PERF; const assert = std.debug.assert; test "perf" { var attr: std.os.linux.perf_event_attr = .{ .type = PERF.TYPE.HARDWARE, .config = @enumToInt(PERF.COUNT.HW.INSTRUCTIONS), .flags = .{ .disabled = true, .exclude_kernel = true, .exclude_hv = true, }, }; const fd = try std.os.perf_event_open(&attr, 0, -1, -1, PERF.FLAG.FD_CLOEXEC); defer std.os.close(fd); _ = std.os.linux.ioctl(fd, PERF.EVENT_IOC.RESET, 0); _ = std.os.linux.ioctl(fd, PERF.EVENT_IOC.ENABLE, 0); long(); _ = std.os.linux.ioctl(fd, PERF.EVENT_IOC.DISABLE, 0); var result: usize = 0; assert((try std.os.read(fd, std.mem.asBytes(&result))) == @sizeOf(usize)); std.debug.print("instruction count: {d}\n", .{result}); } fn long() void { var i: usize = 0; while (i < 100000) : (i += 1) {} } ```
Diffstat (limited to 'src/codegen')
0 files changed, 0 insertions, 0 deletions