code
stringlengths 38
801k
| repo_path
stringlengths 6
263
|
---|---|
const std = @import("std");
const zang = @import("zang");
const zangscript = @import("zangscript");
const common = @import("common.zig");
const c = @import("common/c.zig");
const modules = @import("modules.zig");
pub const AUDIO_FORMAT: zang.AudioFormat = .signed16_lsb;
pub const AUDIO_SAMPLE_RATE = 44100;
pub const AUDIO_BUFFER_SIZE = 1024;
pub const DESCRIPTION =
\\example_script_runtime_poly
\\
\\Play a scripted sound module with the keyboard.
\\
\\Press Enter to reload the script.
;
const a4 = 440.0;
const polyphony = 8;
const custom_builtin_package = zangscript.BuiltinPackage{
.zig_package_name = "_custom0",
.zig_import_path = "examples/modules.zig",
.builtins = &[_]zangscript.BuiltinModule{
zangscript.getBuiltinModule(modules.FilteredSawtoothInstrument),
},
.enums = &[_]zangscript.BuiltinEnum{},
};
const builtin_packages = [_]zangscript.BuiltinPackage{
zangscript.zang_builtin_package,
custom_builtin_package,
};
var error_buffer: [8000]u8 = undefined;
pub const MainModule = struct {
// FIXME (must be at least as many outputs/temps are used in the script)
// to fix this i would have to change the interface of all example MainModules to be something more dynamic
pub const num_outputs = 1;
pub const num_temps = 20;
pub const output_audio = common.AudioOut{ .mono = 0 };
pub const output_visualize = 0;
const filename = "examples/script.txt";
const module_name = "Instrument";
const Params = struct {
sample_rate: f32,
freq: zang.ConstantOrBuffer,
note_on: bool,
};
const Voice = struct {
module: *zangscript.ModuleBase,
trigger: zang.Trigger(Params),
};
allocator: *std.mem.Allocator,
contents: []const u8,
script: *zangscript.CompiledScript,
dispatcher: zang.Notes(Params).PolyphonyDispatcher(polyphony),
voices: [polyphony]Voice,
note_ids: [common.key_bindings.len]?usize,
next_note_id: usize,
iq: zang.Notes(Params).ImpulseQueue,
pub fn init(out_script_error: *?[]const u8) !MainModule {
var allocator = std.heap.page_allocator;
const contents = std.fs.cwd().readFileAlloc(allocator, filename, 16 * 1024 * 1024) catch |err| {
out_script_error.* = "couldn't open file: " ++ filename;
return err;
};
errdefer allocator.free(contents);
var errors_stream: std.io.StreamSource = .{ .buffer = std.io.fixedBufferStream(&error_buffer) };
var script = zangscript.compile(allocator, .{
.builtin_packages = &builtin_packages,
.source = .{ .filename = filename, .contents = contents },
.errors_out = errors_stream.outStream(),
.errors_color = false,
}) catch |err| {
// StreamSource api flaw, see https://github.com/ziglang/zig/issues/5338
const fbs = switch (errors_stream) {
.buffer => |*f| f,
else => unreachable,
};
out_script_error.* = fbs.getWritten();
return err;
};
errdefer script.deinit();
var script_ptr = allocator.create(zangscript.CompiledScript) catch |err| {
out_script_error.* = "out of memory";
return err;
};
errdefer allocator.destroy(script_ptr);
script_ptr.* = script;
const module_index = for (script.exported_modules) |em| {
if (std.mem.eql(u8, em.name, module_name)) break em.module_index;
} else {
out_script_error.* = "module \"" ++ module_name ++ "\" not found";
return error.ModuleNotFound;
};
var self: MainModule = .{
.allocator = allocator,
.contents = contents,
.script = script_ptr,
.note_ids = [1]?usize{null} ** common.key_bindings.len,
.next_note_id = 1,
.iq = zang.Notes(Params).ImpulseQueue.init(),
.dispatcher = zang.Notes(Params).PolyphonyDispatcher(polyphony).init(),
.voices = undefined,
};
var num_voices_initialized: usize = 0;
errdefer for (self.voices[0..num_voices_initialized]) |*voice| {
voice.module.deinit();
};
for (self.voices) |*voice| {
voice.* = .{
.module = try zangscript.initModule(script_ptr, module_index, &builtin_packages, allocator),
.trigger = zang.Trigger(Params).init(),
};
num_voices_initialized += 1;
}
return self;
}
pub fn deinit(self: *MainModule) void {
for (self.voices) |*voice| {
voice.module.deinit();
}
self.script.deinit();
self.allocator.destroy(self.script);
self.allocator.free(self.contents);
}
pub fn paint(self: *MainModule, span: zang.Span, outputs: [num_outputs][]f32, temps: [num_temps][]f32) void {
const iap = self.iq.consume();
const poly_iap = self.dispatcher.dispatch(iap);
for (self.voices) |*voice, i| {
var ctr = voice.trigger.counter(span, poly_iap[i]);
while (voice.trigger.next(&ctr)) |result| {
const params = voice.module.makeParams(Params, result.params) orelse return;
// script modules zero out their output before writing, so i need a temp to accumulate the outputs
zang.zero(result.span, temps[0]);
voice.module.paint(
result.span,
temps[0..1],
temps[1 .. voice.module.num_temps + 1],
result.note_id_changed,
¶ms,
);
zang.addInto(result.span, outputs[0], temps[0]);
}
}
}
pub fn keyEvent(self: *MainModule, key: i32, down: bool, impulse_frame: usize) bool {
for (common.key_bindings) |kb, i| {
if (kb.key != key) {
continue;
}
const freq = a4 * kb.rel_freq;
const params: Params = .{
.sample_rate = AUDIO_SAMPLE_RATE,
.freq = zang.constant(freq),
.note_on = down,
};
if (down) {
if (self.note_ids[i] == null) {
self.iq.push(impulse_frame, self.next_note_id, params);
self.note_ids[i] = self.next_note_id;
self.next_note_id += 1;
}
} else if (self.note_ids[i]) |note_id| {
self.iq.push(impulse_frame, note_id, params);
self.note_ids[i] = null;
}
}
return true;
}
}; | examples/example_script_runtime_poly.zig |
const std = @import("std");
const assert = std.debug.assert;
const tools = @import("tools");
fn modpow(base: u64, exp: u64, m: u64) u64 {
var result: u64 = 1;
var e = exp;
var b = base;
while (e > 0) {
if ((e & 1) != 0) result = (result * b) % m;
e = e / 2;
b = (b * b) % m;
}
return result;
}
fn crypt(subj: u32, loopsz: u32) u32 {
if (true) {
return @intCast(u32, modpow(subj, loopsz, 20201227));
} else {
var val: u64 = 1;
var i: u32 = 0;
while (i < loopsz) : (i += 1) {
val *= subj;
val %= 20201227;
}
//std.debug.print("subj:{}, loop:{} = {}\n", .{ subj, loopsz, val });
assert(val == modpow(subj, loopsz, 20201227));
return @intCast(u32, val);
}
}
pub fn run(input_text: []const u8, allocator: std.mem.Allocator) ![2][]const u8 {
var arena = std.heap.ArenaAllocator.init(allocator);
defer arena.deinit();
_ = input_text;
//const card_pubkey = 5764801;
//const door_pubkey = 17807724;
const card_pubkey = 8458505;
const door_pubkey = 16050997;
//if (false) { // implem bête et directe de l'énoncé
// const subj = 7;
//
// const card_loopsz = blk: {
// var loopsz: u32 = 1;
// while (true) : (loopsz += 1) {
// if (crypt(subj, loopsz) == card_pubkey) break :blk loopsz;
// }
// };
// const door_loopsz = blk: {
// var loopsz: u32 = 1;
// while (true) : (loopsz += 1) {
// if (crypt(subj, loopsz) == door_pubkey) break :blk loopsz;
// }
// };
//
// const ans = crypt(door_pubkey, card_loopsz);
//}
const ans1 = ans: {
if (false) { // pas plus rapide, car les mul + mod sont pas fait en vectoriel, mais il y a le packing / depacking des vecteur en plus..
const u64x2 = std.meta.Vector(2, u64);
var pair: u64x2 = .{ 1, 1 };
const mul: u64x2 = .{ 7, card_pubkey };
const mod: u64x2 = .{ 20201227, 20201227 };
while (true) {
pair = (pair * mul) % mod;
if (pair[0] == door_pubkey) break :ans pair[1];
}
} else {
var v0: u64 = 1;
var v1: u64 = 1;
while (true) {
v0 = (v0 * 7) % 20201227;
v1 = (v1 * card_pubkey) % 20201227;
if (v0 == door_pubkey) break :ans v1;
}
}
};
const ans2 = ans: {
break :ans "gratis!";
};
return [_][]const u8{
try std.fmt.allocPrint(allocator, "{}", .{ans1}),
try std.fmt.allocPrint(allocator, "{s}", .{ans2}),
};
}
pub const main = tools.defaultMain("", run); | 2020/day25.zig |
const std = @import("std");
const fs = std.fs;
// NOTE(sam): I made the first version using a resizable dense map. I was wondering if using an HashMap would
// have been simpler.
// When I read part 2 and realise it was simular, but slightly different than part 1, I decided to try both versions.
// Part 2 uses a sparse HashMap with keys computed from a 4 dimensional point.
// What is the final result?
// Undecided...
// The first implementation is more verbose to write and probably faster for 3d vectors. It's also easier to debug.
// The second one was a lot easier to write, would probably scale better at some point (didn't benchmark) and less code.
// Both were ok... I guess
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
const allocator = &gpa.allocator;
const input = try fs.cwd().readFileAlloc(allocator, "data/input_17_1.txt", std.math.maxInt(usize));
var map = try Map.init(allocator, Point.init(0, 0, -4), Point.init(8,8,4));
defer map.deinit();
var map4 = Map4.init(allocator);
{ // parse input
var lines = std.mem.tokenize(input, "\n");
var li: i32 = 0;
while (lines.next()) |raw_line| {
const line = std.mem.trim(u8, raw_line, " \r\n");
if (line.len == 0)
break;
for (line) |v, x| {
try map.set(Point.init(@intCast(i32, x), li, 0), v);
if (v == '#') {
try map4.set(Point4.init(@intCast(i16, x), @intCast(i16, li), 0, 0), '#');
}
}
li += 1;
}
}
{ // Solution one
{ var it: i32 = 0; while (it < 6) : (it += 1) {
var next = try map.dup();
var z = map.min.z - 1; while (z <= map.max.z) : (z += 1) {
var y = map.min.y - 1; while (y <= map.max.y) : (y += 1) {
var x = map.min.x - 1; while (x <= map.max.x) : (x += 1) {
const p = Point.init(x, y, z);
var ncount: u32 = 0;
var nz = z - 1; while (nz <= z + 1) : (nz += 1) {
var ny = y - 1; while (ny <= y + 1) : (ny += 1) {
var nx = x - 1; while (nx <= x + 1) : (nx += 1) {
const np = Point.init(nx, ny, nz);
if (!Point.eql(p, np)) {
const nv = map.at(np);
if (nv == '#') ncount += 1;
}
}}}
const v = map.at(p);
if (v == '#' and (ncount < 2 or ncount > 3)) {
try next.set(p, '.');
}
else if (v == '.' and ncount == 3) {
try next.set(p, '#');
}
}}}
map.deinit();
map = next;
}}
var count: u32 = 0;
for (map.data.items) |v| {
if (v == '#') count += 1;
}
std.debug.print("Day 17 - Solution 1: {}\n", .{count});
}
{ // Solution two
{ var it: i32 = 0; while (it < 6) : (it += 1) {
var next = try map4.dup();
var w = map4.min.w - 1; while (w <= map4.max.w) : (w += 1) {
var z = map4.min.z - 1; while (z <= map4.max.z) : (z += 1) {
var y = map4.min.y - 1; while (y <= map4.max.y) : (y += 1) {
var x = map4.min.x - 1; while (x <= map4.max.x) : (x += 1) {
const p = Point4.init(x, y, z, w);
var ncount: u32 = 0;
var nw = w - 1; while (nw <= w + 1) : (nw += 1) {
var nz = z - 1; while (nz <= z + 1) : (nz += 1) {
var ny = y - 1; while (ny <= y + 1) : (ny += 1) {
var nx = x - 1; while (nx <= x + 1) : (nx += 1) {
const np = Point4.init(nx, ny, nz, nw);
if (!Point4.eql(p, np)) {
const nv = map4.at(np);
if (nv == '#') ncount += 1;
}
}}}}
const v = map4.at(p);
if (v == '#' and (ncount < 2 or ncount > 3)) {
try next.set(p, '.');
}
else if (v == '.' and ncount == 3) {
try next.set(p, '#');
}
}}}}
map4.deinit();
map4 = next;
}}
var count = map4.data.count();
std.debug.print("Day 17 - Solution 2: {}", .{count});
}
}
const Point = struct {
x: i32 = 0,
y: i32 = 0,
z: i32 = 0,
const Self = @This();
pub fn init(x: i32, y: i32, z: i32) Self {
return .{.x = x, .y = y, .z = z};
}
pub fn sum(a: Self, b: Self) Self {
return .{ .x = a.x + b.x, .y = a.y + b.y, .z = a.z + b.z };
}
pub fn sub(a: Self, b: Self) Self {
return .{ .x = a.x - b.x, .y = a.y - b.y, .z = a.z - b.z };
}
pub fn eql(a: Self, b: Self) bool {
return a.x == b.x and a.y == b.y and a.z == b.z;
}
pub fn lt(a: Self, b: Self) bool {
return a.x < b.x or a.y < b.y or a.z < b.z;
}
pub fn gte(a: Self, b: Self) bool {
return a.x >= b.x or a.y >= b.y or a.z >= b.z;
}
pub fn min(a: Self, b: Self) Self {
return .{.x = std.math.min(a.x, b.x),
.y = std.math.min(a.y, b.y),
.z = std.math.min(a.z, b.z)};
}
pub fn max(a: Self, b: Self) Self {
return .{.x = std.math.max(a.x, b.x),
.y = std.math.max(a.y, b.y),
.z = std.math.max(a.z, b.z)};
}
};
const Map = struct {
data: std.ArrayList(u8),
min: Point = Point.init(0, 0, 0),
max: Point,
allocator: *std.mem.Allocator,
const Self = @This();
pub fn init(a: *std.mem.Allocator, min: Point, max: Point) !Self {
var res = Self{
.data = std.ArrayList(u8).init(a),
.min = min,
.max = max,
.allocator = a
};
try res.data.resize(res.computeCap());
std.mem.set(u8, res.data.items, '.');
return res;
}
pub fn computeCap(self: *const Self) usize {
const ext = Point.sub(self.max, self.
min);
return @intCast(usize, ext.x * ext.y * ext.z);
}
pub fn deinit(self: *Self) void {
self.data.deinit();
}
pub fn at(self: *const Self, p: Point) u8 {
if (Point.lt(p, self.min) or Point.gte(p, self.max))
{
return '.';
}
else {
const i = Self.index(self, p);
return self.data.items[i];
}
}
pub fn extend(self: *Self, p: Point) !void {
var nmin = self.min;
var nmax = self.max;
var resized = false;
if (Point.lt(p, self.min)) {
nmin = Point.min(p, self.min);
resized = true;
}
else if (Point.gte(p, self.max)) {
nmax = Point.init(std.math.max(p.x + 1, self.max.x),
std.math.max(p.y + 1, self.max.y),
std.math.max(p.z + 1, self.max.z));
resized = true;
}
if (resized) {
var nmap = try Self.init(self.allocator, nmin, nmax);
var z: i32 = self.min.z; while (z < self.max.z) : ( z += 1 ) {
var y: i32 = self.min.y; while (y < self.max.y) : ( y += 1 ) {
var x: i32 = self.min.x; while (x < self.max.x) : ( x += 1 ) {
const np = Point.init(x, y, z);
nmap.setInternal(np, self.at(np));
}}}
self.data.deinit();
self.* = nmap;
}
}
pub fn set(self: *Self, p: Point, v: u8) !void {
// Do not extend the map if the value is .
if ((Point.lt(p, self.min) or Point.gte(p, self.max)) and v == '.')
return;
try self.extend(p);
self.setInternal(p, v);
}
fn setInternal(self: *Self, p: Point, v: u8) void {
self.data.items[self.index(p)] = v;
}
fn index(self: *const Self, p: Point) usize {
const ext = Point.sub(self.max, self.min);
const pos = Point.sub(p, self.min);
return @intCast(usize, pos.x + pos.y * ext.x + pos.z * ext.x * ext.y);
}
pub fn print(self: *const Self) void {
const extx = self.max.x - self.min.x;
var z: i32 = self.min.z; while (z < self.max.z) : (z += 1) {
std.debug.print("z={}\n", .{z});
var y: i32 = self.min.y; while (y < self.max.y) : (y += 1){
const rindex = self.index(Point.init(0, y, z));
std.debug.print("{}\n", .{self.data.items[rindex..(rindex + @intCast(usize, extx))]});
}
}
}
pub fn dup(self: *const Self) !Self {
var nmap = self.*;
nmap.data = std.ArrayList(u8).init(self.allocator);
try nmap.data.resize(self.data.items.len);
std.mem.copy(u8, nmap.data.items, self.data.items);
return nmap;
}
};
const Point4 = struct {
x: i16,
y: i16,
z: i16,
w: i16,
const Self = @This();
pub fn init(x: i16, y: i16, z: i16, w: i16) Self {
return .{.x = x, .y = y, .z = z, .w = w};
}
pub fn add(a: Self, b: Self) Self {
return Self.init(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w);
}
pub fn sub(a: Self, b: Self) Self {
return Self.init(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w);
}
pub fn eql(a: Self, b: Self) bool {
return a.x == b.x and
a.y == b.y and
a.z == b.z and
a.w == b.w;
}
pub fn hash(a: Self) u64 {
var v64 = @intCast(i64, a.x) | (@intCast(i64, a.y) << 16) | (@intCast(i64, a.z) << 32) | (@intCast(i64, a.w) << 48);
return std.hash_map.getAutoHashFn(i64)(v64);
}
};
const Map4 = struct {
data: HashMapType,
min: Point4 = Point4.init(0, 0, 0, 0),
max: Point4 = Point4.init(1, 1, 1, 1),
a: *std.mem.Allocator,
pub const HashMapType = hm.HashMap(Point4, u8, Point4.hash, Point4.eql, 80);
const Self = @This();
pub fn init(a: *std.mem.Allocator) Self {
return .{
.data = HashMapType.init(a),
.a = a
};
}
pub fn at(self: *const Self, p: Point4) u8 {
return if (self.data.contains(p)) '#' else '.';
}
pub fn set(self: *Self, p: Point4, v: u8) !void {
if (v == '.') {
_ = self.data.remove(p);
}
else {
self.min.x = std.math.min(self.min.x, p.x);
self.min.y = std.math.min(self.min.y, p.y);
self.min.z = std.math.min(self.min.z, p.z);
self.min.w = std.math.min(self.min.w, p.w);
self.max.x = std.math.max(self.max.x, p.x + 1);
self.max.y = std.math.max(self.max.y, p.y + 1);
self.max.z = std.math.max(self.max.z, p.z + 1);
self.max.w = std.math.max(self.max.w, p.w + 1);
try self.data.put(p, v);
}
}
pub fn dup(self: *const Self) !Self {
var res = self.*;
res.data = try HashMapType.clone(self.data);
return res;
}
pub fn deinit(self: *Self) void {
self.data.deinit();
}
};
const hm = std.hash_map; | 2020/src/day_17.zig |
const std = @import("std");
const assert = std.debug.assert;
const mem = std.mem;
const Allocator = std.mem.Allocator;
// Implements the LZ77 sliding dictionary as used in decompression.
// LZ77 decompresses data through sequences of two forms of commands:
//
// * Literal insertions: Runs of one or more symbols are inserted into the data
// stream as is. This is accomplished through the writeByte method for a
// single symbol, or combinations of writeSlice/writeMark for multiple symbols.
// Any valid stream must start with a literal insertion if no preset dictionary
// is used.
//
// * Backward copies: Runs of one or more symbols are copied from previously
// emitted data. Backward copies come as the tuple (dist, length) where dist
// determines how far back in the stream to copy from and length determines how
// many bytes to copy. Note that it is valid for the length to be greater than
// the distance. Since LZ77 uses forward copies, that situation is used to
// perform a form of run-length encoding on repeated runs of symbols.
// The writeCopy and tryWriteCopy are used to implement this command.
//
// For performance reasons, this implementation performs little to no sanity
// checks about the arguments. As such, the invariants documented for each
// method call must be respected.
pub const DictDecoder = struct {
const Self = @This();
allocator: Allocator = undefined,
hist: []u8 = undefined, // Sliding window history
// Invariant: 0 <= rd_pos <= wr_pos <= hist.len
wr_pos: u32 = 0, // Current output position in buffer
rd_pos: u32 = 0, // Have emitted hist[0..rd_pos] already
full: bool = false, // Has a full window length been written yet?
// init initializes DictDecoder to have a sliding window dictionary of the given
// size. If a preset dict is provided, it will initialize the dictionary with
// the contents of dict.
pub fn init(self: *Self, allocator: Allocator, size: u32, dict: ?[]const u8) !void {
self.allocator = allocator;
self.hist = try allocator.alloc(u8, size);
self.wr_pos = 0;
if (dict != null) {
mem.copy(u8, self.hist, dict.?[dict.?.len -| self.hist.len..]);
self.wr_pos = @intCast(u32, dict.?.len);
}
if (self.wr_pos == self.hist.len) {
self.wr_pos = 0;
self.full = true;
}
self.rd_pos = self.wr_pos;
}
pub fn deinit(self: *Self) void {
self.allocator.free(self.hist);
}
// Reports the total amount of historical data in the dictionary.
pub fn histSize(self: *Self) u32 {
if (self.full) {
return @intCast(u32, self.hist.len);
}
return self.wr_pos;
}
// Reports the number of bytes that can be flushed by readFlush.
pub fn availRead(self: *Self) u32 {
return self.wr_pos - self.rd_pos;
}
// Reports the available amount of output buffer space.
pub fn availWrite(self: *Self) u32 {
return @intCast(u32, self.hist.len - self.wr_pos);
}
// Returns a slice of the available buffer to write data to.
//
// This invariant will be kept: s.len <= availWrite()
pub fn writeSlice(self: *Self) []u8 {
return self.hist[self.wr_pos..];
}
// Advances the writer pointer by `count`.
//
// This invariant must be kept: 0 <= count <= availWrite()
pub fn writeMark(self: *Self, count: u32) void {
assert(0 <= count and count <= self.availWrite());
self.wr_pos += count;
}
// Writes a single byte to the dictionary.
//
// This invariant must be kept: 0 < availWrite()
pub fn writeByte(self: *Self, byte: u8) void {
self.hist[self.wr_pos] = byte;
self.wr_pos += 1;
}
fn copy(dst: []u8, src: []const u8) u32 {
if (src.len > dst.len) {
mem.copy(u8, dst, src[0..dst.len]);
return @intCast(u32, dst.len);
}
mem.copy(u8, dst, src);
return @intCast(u32, src.len);
}
// Copies a string at a given (dist, length) to the output.
// This returns the number of bytes copied and may be less than the requested
// length if the available space in the output buffer is too small.
//
// This invariant must be kept: 0 < dist <= histSize()
pub fn writeCopy(self: *Self, dist: u32, length: u32) u32 {
assert(0 < dist and dist <= self.histSize());
var dst_base = self.wr_pos;
var dst_pos = dst_base;
var src_pos: i32 = @intCast(i32, dst_pos) - @intCast(i32, dist);
var end_pos = dst_pos + length;
if (end_pos > self.hist.len) {
end_pos = @intCast(u32, self.hist.len);
}
// Copy non-overlapping section after destination position.
//
// This section is non-overlapping in that the copy length for this section
// is always less than or equal to the backwards distance. This can occur
// if a distance refers to data that wraps-around in the buffer.
// Thus, a backwards copy is performed here; that is, the exact bytes in
// the source prior to the copy is placed in the destination.
if (src_pos < 0) {
src_pos += @intCast(i32, self.hist.len);
dst_pos += copy(self.hist[dst_pos..end_pos], self.hist[@intCast(usize, src_pos)..]);
src_pos = 0;
}
// Copy possibly overlapping section before destination position.
//
// This section can overlap if the copy length for this section is larger
// than the backwards distance. This is allowed by LZ77 so that repeated
// strings can be succinctly represented using (dist, length) pairs.
// Thus, a forwards copy is performed here; that is, the bytes copied is
// possibly dependent on the resulting bytes in the destination as the copy
// progresses along. This is functionally equivalent to the following:
//
// var i = 0;
// while(i < end_pos - dst_pos) : (i+=1) {
// self.hist[dst_pos+i] = self.hist[src_pos+i];
// }
// dst_pos = end_pos;
//
while (dst_pos < end_pos) {
dst_pos += copy(self.hist[dst_pos..end_pos], self.hist[@intCast(usize, src_pos)..dst_pos]);
}
self.wr_pos = dst_pos;
return dst_pos - dst_base;
}
// Tries to copy a string at a given (distance, length) to the
// output. This specialized version is optimized for short distances.
//
// This method is designed to be inlined for performance reasons.
//
// This invariant must be kept: 0 < dist <= histSize()
pub fn tryWriteCopy(self: *Self, dist: u32, length: u32) u32 {
var dst_pos = self.wr_pos;
var end_pos = dst_pos + length;
if (dst_pos < dist or end_pos > self.hist.len) {
return 0;
}
var dst_base = dst_pos;
var src_pos = dst_pos - dist;
// Copy possibly overlapping section before destination position.
while (dst_pos < end_pos) {
dst_pos += copy(self.hist[dst_pos..end_pos], self.hist[src_pos..dst_pos]);
}
self.wr_pos = dst_pos;
return dst_pos - dst_base;
}
// Returns a slice of the historical buffer that is ready to be
// emitted to the user. The data returned by readFlush must be fully consumed
// before calling any other DictDecoder methods.
pub fn readFlush(self: *Self) []u8 {
var to_read = self.hist[self.rd_pos..self.wr_pos];
self.rd_pos = self.wr_pos;
if (self.wr_pos == self.hist.len) {
self.wr_pos = 0;
self.rd_pos = 0;
self.full = true;
}
return to_read;
}
};
// tests
test "dictionary decoder" {
const ArrayList = std.ArrayList;
const expect = std.testing.expect;
const testing = std.testing;
const abc = "ABC\n";
const fox = "The quick brown fox jumped over the lazy dog!\n";
const poem: []const u8 =
\\The Road Not Taken
\\<NAME>
\\
\\Two roads diverged in a yellow wood,
\\And sorry I could not travel both
\\And be one traveler, long I stood
\\And looked down one as far as I could
\\To where it bent in the undergrowth;
\\
\\Then took the other, as just as fair,
\\And having perhaps the better claim,
\\Because it was grassy and wanted wear;
\\Though as for that the passing there
\\Had worn them really about the same,
\\
\\And both that morning equally lay
\\In leaves no step had trodden black.
\\Oh, I kept the first for another day!
\\Yet knowing how way leads on to way,
\\I doubted if I should ever come back.
\\
\\I shall be telling this with a sigh
\\Somewhere ages and ages hence:
\\Two roads diverged in a wood, and I-
\\I took the one less traveled by,
\\And that has made all the difference.
\\
;
const uppercase: []const u8 =
\\THE ROAD NOT TAKEN
\\<NAME>ROST
\\
\\TWO ROADS DIVERGED IN A YELLOW WOOD,
\\AND SORRY I COULD NOT TRAVEL BOTH
\\AND BE ONE TRAVELER, LONG I STOOD
\\AND LOOKED DOWN ONE AS FAR AS I COULD
\\TO WHERE IT BENT IN THE UNDERGROWTH;
\\
\\THEN TOOK THE OTHER, AS JUST AS FAIR,
\\AND HAVING PERHAPS THE BETTER CLAIM,
\\BECAUSE IT WAS GRASSY AND WANTED WEAR;
\\THOUGH AS FOR THAT THE PASSING THERE
\\HAD WORN THEM REALLY ABOUT THE SAME,
\\
\\AND BOTH THAT MORNING EQUALLY LAY
\\IN LEAVES NO STEP HAD TRODDEN BLACK.
\\OH, I KEPT THE FIRST FOR ANOTHER DAY!
\\YET KNOWING HOW WAY LEADS ON TO WAY,
\\I DOUBTED IF I SHOULD EVER COME BACK.
\\
\\I SHALL BE TELLING THIS WITH A SIGH
\\SOMEWHERE AGES AND AGES HENCE:
\\TWO ROADS DIVERGED IN A WOOD, AND I-
\\I TOOK THE ONE LESS TRAVELED BY,
\\AND THAT HAS MADE ALL THE DIFFERENCE.
\\
;
const PoemRefs = struct {
dist: u32, // Backward distance (0 if this is an insertion)
length: u32, // Length of copy or insertion
};
var poem_refs = [_]PoemRefs{
.{ .dist = 0, .length = 38 }, .{ .dist = 33, .length = 3 }, .{ .dist = 0, .length = 48 },
.{ .dist = 79, .length = 3 }, .{ .dist = 0, .length = 11 }, .{ .dist = 34, .length = 5 },
.{ .dist = 0, .length = 6 }, .{ .dist = 23, .length = 7 }, .{ .dist = 0, .length = 8 },
.{ .dist = 50, .length = 3 }, .{ .dist = 0, .length = 2 }, .{ .dist = 69, .length = 3 },
.{ .dist = 34, .length = 5 }, .{ .dist = 0, .length = 4 }, .{ .dist = 97, .length = 3 },
.{ .dist = 0, .length = 4 }, .{ .dist = 43, .length = 5 }, .{ .dist = 0, .length = 6 },
.{ .dist = 7, .length = 4 }, .{ .dist = 88, .length = 7 }, .{ .dist = 0, .length = 12 },
.{ .dist = 80, .length = 3 }, .{ .dist = 0, .length = 2 }, .{ .dist = 141, .length = 4 },
.{ .dist = 0, .length = 1 }, .{ .dist = 196, .length = 3 }, .{ .dist = 0, .length = 3 },
.{ .dist = 157, .length = 3 }, .{ .dist = 0, .length = 6 }, .{ .dist = 181, .length = 3 },
.{ .dist = 0, .length = 2 }, .{ .dist = 23, .length = 3 }, .{ .dist = 77, .length = 3 },
.{ .dist = 28, .length = 5 }, .{ .dist = 128, .length = 3 }, .{ .dist = 110, .length = 4 },
.{ .dist = 70, .length = 3 }, .{ .dist = 0, .length = 4 }, .{ .dist = 85, .length = 6 },
.{ .dist = 0, .length = 2 }, .{ .dist = 182, .length = 6 }, .{ .dist = 0, .length = 4 },
.{ .dist = 133, .length = 3 }, .{ .dist = 0, .length = 7 }, .{ .dist = 47, .length = 5 },
.{ .dist = 0, .length = 20 }, .{ .dist = 112, .length = 5 }, .{ .dist = 0, .length = 1 },
.{ .dist = 58, .length = 3 }, .{ .dist = 0, .length = 8 }, .{ .dist = 59, .length = 3 },
.{ .dist = 0, .length = 4 }, .{ .dist = 173, .length = 3 }, .{ .dist = 0, .length = 5 },
.{ .dist = 114, .length = 3 }, .{ .dist = 0, .length = 4 }, .{ .dist = 92, .length = 5 },
.{ .dist = 0, .length = 2 }, .{ .dist = 71, .length = 3 }, .{ .dist = 0, .length = 2 },
.{ .dist = 76, .length = 5 }, .{ .dist = 0, .length = 1 }, .{ .dist = 46, .length = 3 },
.{ .dist = 96, .length = 4 }, .{ .dist = 130, .length = 4 }, .{ .dist = 0, .length = 3 },
.{ .dist = 360, .length = 3 }, .{ .dist = 0, .length = 3 }, .{ .dist = 178, .length = 5 },
.{ .dist = 0, .length = 7 }, .{ .dist = 75, .length = 3 }, .{ .dist = 0, .length = 3 },
.{ .dist = 45, .length = 6 }, .{ .dist = 0, .length = 6 }, .{ .dist = 299, .length = 6 },
.{ .dist = 180, .length = 3 }, .{ .dist = 70, .length = 6 }, .{ .dist = 0, .length = 1 },
.{ .dist = 48, .length = 3 }, .{ .dist = 66, .length = 4 }, .{ .dist = 0, .length = 3 },
.{ .dist = 47, .length = 5 }, .{ .dist = 0, .length = 9 }, .{ .dist = 325, .length = 3 },
.{ .dist = 0, .length = 1 }, .{ .dist = 359, .length = 3 }, .{ .dist = 318, .length = 3 },
.{ .dist = 0, .length = 2 }, .{ .dist = 199, .length = 3 }, .{ .dist = 0, .length = 1 },
.{ .dist = 344, .length = 3 }, .{ .dist = 0, .length = 3 }, .{ .dist = 248, .length = 3 },
.{ .dist = 0, .length = 10 }, .{ .dist = 310, .length = 3 }, .{ .dist = 0, .length = 3 },
.{ .dist = 93, .length = 6 }, .{ .dist = 0, .length = 3 }, .{ .dist = 252, .length = 3 },
.{ .dist = 157, .length = 4 }, .{ .dist = 0, .length = 2 }, .{ .dist = 273, .length = 5 },
.{ .dist = 0, .length = 14 }, .{ .dist = 99, .length = 4 }, .{ .dist = 0, .length = 1 },
.{ .dist = 464, .length = 4 }, .{ .dist = 0, .length = 2 }, .{ .dist = 92, .length = 4 },
.{ .dist = 495, .length = 3 }, .{ .dist = 0, .length = 1 }, .{ .dist = 322, .length = 4 },
.{ .dist = 16, .length = 4 }, .{ .dist = 0, .length = 3 }, .{ .dist = 402, .length = 3 },
.{ .dist = 0, .length = 2 }, .{ .dist = 237, .length = 4 }, .{ .dist = 0, .length = 2 },
.{ .dist = 432, .length = 4 }, .{ .dist = 0, .length = 1 }, .{ .dist = 483, .length = 5 },
.{ .dist = 0, .length = 2 }, .{ .dist = 294, .length = 4 }, .{ .dist = 0, .length = 2 },
.{ .dist = 306, .length = 3 }, .{ .dist = 113, .length = 5 }, .{ .dist = 0, .length = 1 },
.{ .dist = 26, .length = 4 }, .{ .dist = 164, .length = 3 }, .{ .dist = 488, .length = 4 },
.{ .dist = 0, .length = 1 }, .{ .dist = 542, .length = 3 }, .{ .dist = 248, .length = 6 },
.{ .dist = 0, .length = 5 }, .{ .dist = 205, .length = 3 }, .{ .dist = 0, .length = 8 },
.{ .dist = 48, .length = 3 }, .{ .dist = 449, .length = 6 }, .{ .dist = 0, .length = 2 },
.{ .dist = 192, .length = 3 }, .{ .dist = 328, .length = 4 }, .{ .dist = 9, .length = 5 },
.{ .dist = 433, .length = 3 }, .{ .dist = 0, .length = 3 }, .{ .dist = 622, .length = 25 },
.{ .dist = 615, .length = 5 }, .{ .dist = 46, .length = 5 }, .{ .dist = 0, .length = 2 },
.{ .dist = 104, .length = 3 }, .{ .dist = 475, .length = 10 }, .{ .dist = 549, .length = 3 },
.{ .dist = 0, .length = 4 }, .{ .dist = 597, .length = 8 }, .{ .dist = 314, .length = 3 },
.{ .dist = 0, .length = 1 }, .{ .dist = 473, .length = 6 }, .{ .dist = 317, .length = 5 },
.{ .dist = 0, .length = 1 }, .{ .dist = 400, .length = 3 }, .{ .dist = 0, .length = 3 },
.{ .dist = 109, .length = 3 }, .{ .dist = 151, .length = 3 }, .{ .dist = 48, .length = 4 },
.{ .dist = 0, .length = 4 }, .{ .dist = 125, .length = 3 }, .{ .dist = 108, .length = 3 },
.{ .dist = 0, .length = 2 },
};
var got_list = ArrayList(u8).init(testing.allocator);
defer got_list.deinit();
var got = got_list.writer();
var want_list = ArrayList(u8).init(testing.allocator);
defer want_list.deinit();
var want = want_list.writer();
var dd = DictDecoder{};
try dd.init(testing.allocator, 1 << 11, null);
defer dd.deinit();
const util = struct {
fn writeCopy(dst_dd: *DictDecoder, dst: anytype, dist: u32, length: u32) !void {
var len = length;
while (len > 0) {
var n = dst_dd.tryWriteCopy(dist, len);
if (n == 0) {
n = dst_dd.writeCopy(dist, len);
}
len -= n;
if (dst_dd.availWrite() == 0) {
_ = try dst.write(dst_dd.readFlush());
}
}
}
fn writeString(dst_dd: *DictDecoder, dst: anytype, str: []const u8) !void {
var string = str;
while (string.len > 0) {
var cnt = DictDecoder.copy(dst_dd.writeSlice(), string);
dst_dd.writeMark(cnt);
string = string[cnt..];
if (dst_dd.availWrite() == 0) {
_ = try dst.write(dst_dd.readFlush());
}
}
}
};
try util.writeString(&dd, got, ".");
_ = try want.write(".");
var str = poem;
for (poem_refs) |ref, i| {
_ = i;
if (ref.dist == 0) {
try util.writeString(&dd, got, str[0..ref.length]);
} else {
try util.writeCopy(&dd, got, ref.dist, ref.length);
}
str = str[ref.length..];
}
_ = try want.write(poem);
try util.writeCopy(&dd, got, dd.histSize(), 33);
_ = try want.write(want_list.items[0..33]);
try util.writeString(&dd, got, abc);
try util.writeCopy(&dd, got, abc.len, 59 * abc.len);
_ = try want.write(abc ** 60);
try util.writeString(&dd, got, fox);
try util.writeCopy(&dd, got, fox.len, 9 * fox.len);
_ = try want.write(fox ** 10);
try util.writeString(&dd, got, ".");
try util.writeCopy(&dd, got, 1, 9);
_ = try want.write("." ** 10);
try util.writeString(&dd, got, uppercase);
try util.writeCopy(&dd, got, uppercase.len, 7 * uppercase.len);
var i: u8 = 0;
while (i < 8) : (i += 1) {
_ = try want.write(uppercase);
}
try util.writeCopy(&dd, got, dd.histSize(), 10);
_ = try want.write(want_list.items[want_list.items.len - dd.histSize() ..][0..10]);
_ = try got.write(dd.readFlush());
try expect(mem.eql(u8, got_list.items, want_list.items));
} | lib/std/compress/deflate/dict_decoder.zig |
const std = @import("../std.zig");
pub const Status = enum(u10) {
@"continue" = 100, // RFC7231, Section 6.2.1
switching_protcols = 101, // RFC7231, Section 6.2.2
processing = 102, // RFC2518
early_hints = 103, // RFC8297
ok = 200, // RFC7231, Section 6.3.1
created = 201, // RFC7231, Section 6.3.2
accepted = 202, // RFC7231, Section 6.3.3
non_authoritative_info = 203, // RFC7231, Section 6.3.4
no_content = 204, // RFC7231, Section 6.3.5
reset_content = 205, // RFC7231, Section 6.3.6
partial_content = 206, // RFC7233, Section 4.1
multi_status = 207, // RFC4918
already_reported = 208, // RFC5842
im_used = 226, // RFC3229
multiple_choice = 300, // RFC7231, Section 6.4.1
moved_permanently = 301, // RFC7231, Section 6.4.2
found = 302, // RFC7231, Section 6.4.3
see_other = 303, // RFC7231, Section 6.4.4
not_modified = 304, // RFC7232, Section 4.1
use_proxy = 305, // RFC7231, Section 6.4.5
temporary_redirect = 307, // RFC7231, Section 6.4.7
permanent_redirect = 308, // RFC7538
bad_request = 400, // RFC7231, Section 6.5.1
unauthorized = 401, // RFC7235, Section 3.1
payment_required = 402, // RFC7231, Section 6.5.2
forbidden = 403, // RFC7231, Section 6.5.3
not_found = 404, // RFC7231, Section 6.5.4
method_not_allowed = 405, // RFC7231, Section 6.5.5
not_acceptable = 406, // RFC7231, Section 6.5.6
proxy_auth_required = 407, // RFC7235, Section 3.2
request_timeout = 408, // RFC7231, Section 6.5.7
conflict = 409, // RFC7231, Section 6.5.8
gone = 410, // RFC7231, Section 6.5.9
length_required = 411, // RFC7231, Section 6.5.10
precondition_failed = 412, // RFC7232, Section 4.2][RFC8144, Section 3.2
payload_too_large = 413, // RFC7231, Section 6.5.11
uri_too_long = 414, // RFC7231, Section 6.5.12
unsupported_media_type = 415, // RFC7231, Section 6.5.13][RFC7694, Section 3
range_not_satisfiable = 416, // RFC7233, Section 4.4
expectation_failed = 417, // RFC7231, Section 6.5.14
teapot = 418, // RFC 7168, 2.3.3
misdirected_request = 421, // RFC7540, Section 9.1.2
unprocessable_entity = 422, // RFC4918
locked = 423, // RFC4918
failed_dependency = 424, // RFC4918
too_early = 425, // RFC8470
upgrade_required = 426, // RFC7231, Section 6.5.15
precondition_required = 428, // RFC6585
too_many_requests = 429, // RFC6585
header_fields_too_large = 431, // RFC6585
unavailable_for_legal_reasons = 451, // RFC7725
internal_server_error = 500, // RFC7231, Section 6.6.1
not_implemented = 501, // RFC7231, Section 6.6.2
bad_gateway = 502, // RFC7231, Section 6.6.3
service_unavailable = 503, // RFC7231, Section 6.6.4
gateway_timeout = 504, // RFC7231, Section 6.6.5
http_version_not_supported = 505, // RFC7231, Section 6.6.6
variant_also_negotiates = 506, // RFC2295
insufficient_storage = 507, // RFC4918
loop_detected = 508, // RFC5842
not_extended = 510, // RFC2774
network_authentication_required = 511, // RFC6585
_,
pub fn phrase(self: Status) ?[]const u8 {
return switch (self) {
// 1xx statuses
.@"continue" => "Continue",
.switching_protcols => "Switching Protocols",
.processing => "Processing",
.early_hints => "Early Hints",
// 2xx statuses
.ok => "OK",
.created => "Created",
.accepted => "Accepted",
.non_authoritative_info => "Non-Authoritative Information",
.no_content => "No Content",
.reset_content => "Reset Content",
.partial_content => "Partial Content",
.multi_status => "Multi-Status",
.already_reported => "Already Reported",
.im_used => "IM Used",
// 3xx statuses
.multiple_choice => "Multiple Choice",
.moved_permanently => "Moved Permanently",
.found => "Found",
.see_other => "See Other",
.not_modified => "Not Modified",
.use_proxy => "Use Proxy",
.temporary_redirect => "Temporary Redirect",
.permanent_redirect => "Permanent Redirect",
// 4xx statuses
.bad_request => "Bad Request",
.unauthorized => "Unauthorized",
.payment_required => "Payment Required",
.forbidden => "Forbidden",
.not_found => "Not Found",
.method_not_allowed => "Method Not Allowed",
.not_acceptable => "Not Acceptable",
.proxy_auth_required => "Proxy Authentication Required",
.request_timeout => "Request Timeout",
.conflict => "Conflict",
.gone => "Gone",
.length_required => "Length Required",
.precondition_failed => "Precondition Failed",
.payload_too_large => "Payload Too Large",
.uri_too_long => "URI Too Long",
.unsupported_media_type => "Unsupported Media Type",
.range_not_satisfiable => "Range Not Satisfiable",
.expectation_failed => "Expectation Failed",
.teapot => "I'm a teapot",
.misdirected_request => "Misdirected Request",
.unprocessable_entity => "Unprocessable Entity",
.locked => "Locked",
.failed_dependency => "Failed Dependency",
.too_early => "Too Early",
.upgrade_required => "Upgrade Required",
.precondition_required => "Precondition Required",
.too_many_requests => "Too Many Requests",
.header_fields_too_large => "Request Header Fields Too Large",
.unavailable_for_legal_reasons => "Unavailable For Legal Reasons",
// 5xx statuses
.internal_server_error => "Internal Server Error",
.not_implemented => "Not Implemented",
.bad_gateway => "Bad Gateway",
.service_unavailable => "Service Unavailable",
.gateway_timeout => "Gateway Timeout",
.http_version_not_supported => "HTTP Version Not Supported",
.variant_also_negotiates => "Variant Also Negotiates",
.insufficient_storage => "Insufficient Storage",
.loop_detected => "Loop Detected",
.not_extended => "Not Extended",
.network_authentication_required => "Network Authentication Required",
else => return null,
};
}
pub const Class = enum {
informational,
success,
redirect,
client_error,
server_error,
};
pub fn class(self: Status) ?Class {
return switch (@enumToInt(self)) {
100...199 => .informational,
200...299 => .success,
300...399 => .redirect,
400...499 => .client_error,
500...599 => .server_error,
else => null,
};
}
};
test {
try std.testing.expectEqualStrings("OK", Status.ok.phrase().?);
try std.testing.expectEqualStrings("Not Found", Status.not_found.phrase().?);
}
test {
try std.testing.expectEqual(@as(?Status.Class, Status.Class.success), Status.ok.class());
try std.testing.expectEqual(@as(?Status.Class, Status.Class.client_error), Status.not_found.class());
} | lib/std/http/status.zig |
const std = @import("std");
const utils = @import("utils.zig");
const attributes = @import("attributes.zig");
const FieldInfo = @import("FieldInfo.zig");
const MethodInfo = @import("MethodInfo.zig");
const ConstantPool = @import("ConstantPool.zig");
const ClassFile = @This();
/// Denotes access permissions to and properties of this class or interface
pub const AccessFlags = struct {
/// Declared public; may be accessed from outside its package
public: bool = false,
/// Declared final; no subclasses allowed.
final: bool = false,
/// Treat superclass methods specially when invoked by the invokespecial instruction
super: bool = false,
/// Is an interface, not a class
interface: bool = false,
/// Declared abstract; must not be instantiated
abstract: bool = false,
/// Declared synthetic; not present in the source code
synthetic: bool = false,
/// Declared as an annotation interface
annotation: bool = false,
/// Declared as an enum class
enum_class: bool = false,
/// Is a module, not a class or interface
module: bool = false,
};
// To see what the major and minor versions actually correspond to, see https://docs.oracle.com/javase/specs/jvms/se16/html/jvms-4.html#jvms-4.1-200-B.2
minor_version: u16,
major_version: u16,
/// The constant_pool is a table of structures ([§4.4](https://docs.oracle.com/javase/specs/jvms/se16/html/jvms-4.html#jvms-4.4)) representing various string constants, class and interface names, field names, and other constants that are referred to within the ClassFile structure and its substructures
///
/// The constant_pool table is indexed from 1 to ConstantPoolcount - 1
constant_pool: *ConstantPool,
/// The value of the access_flags item is a mask of flags used to denote access permissions to and properties of this class or interface. The interpretation of each flag, when set, is specified in [Table 4.1-B](https://docs.oracle.com/javase/specs/jvms/se16/html/jvms-4.html#jvms-4.1-200-E.1)
access_flags: AccessFlags,
/// The value of the this_class item must be a valid index into the constant_pool table and the entry at that index must be a CONSTANT_Class_info structure ([§4.4.1](https://docs.oracle.com/javase/specs/jvms/se16/html/jvms-4.html#jvms-4.4.1)) representing the class or interface defined by this class file
this_class: u16,
/// For a class, the value of the super_class item either must be zero or must be a valid index into the constant_pool table. If the value of the super_class item is nonzero, the constant_pool entry at that index must be a CONSTANT_Class_info structure representing the direct superclass of the class defined by this class file. Neither the direct superclass nor any of its superclasses may have the ACC_FINAL flag set in the access_flags item of its ClassFile structure.
///
/// If the value of the super_class item is zero, then this class file must represent the class Object, the only class or interface without a direct superclass.
///
/// For an interface, the value of the super_class item must always be a valid index into the constant_pool table. The constant_pool entry at that index must be a CONSTANT_Class_info structure representing the class Object.
super_class: ?u16,
/// Each value in the interfaces array must be a valid index into the constant_pool table and the entry at each value of interfaces[i], where 0 ≤ i < interfaces_count, must be a CONSTANT_Class_info structure representing an interface that is a direct superinterface of this class or interface type, in the left-to-right order given in the source for the type
interfaces: std.ArrayList(u16),
/// Fields this class has
fields: std.ArrayList(FieldInfo),
/// Methods the class has
methods: std.ArrayList(MethodInfo),
/// Attributes the class has
attributes: std.ArrayList(attributes.AttributeInfo),
pub fn getConstantPoolEntry(self: ClassFile, index: u16) ConstantPool.Entry {
return self.constant_pool[index - 1];
}
pub fn decode(allocator: std.mem.Allocator, reader: anytype) !ClassFile {
var magic = try reader.readIntBig(u32);
if (magic != 0xCAFEBABE) return error.BadMagicValue;
var minor_version = try reader.readIntBig(u16);
var major_version = try reader.readIntBig(u16);
var entry_count = (try reader.readIntBig(u16)) - 1;
var constant_pool = try ConstantPool.init(allocator, entry_count);
// try constant_pool.entries.ensureTotalCapacity(constant_pool_length);
// constant_pool.entries.items.len = z;
try constant_pool.decodeEntries(reader);
var access_flags_u = try reader.readIntBig(u16);
var access_flags = AccessFlags{
.public = utils.isPresent(u16, access_flags_u, 0x0001),
.final = utils.isPresent(u16, access_flags_u, 0x0010),
.super = utils.isPresent(u16, access_flags_u, 0x0020),
.interface = utils.isPresent(u16, access_flags_u, 0x0200),
.abstract = utils.isPresent(u16, access_flags_u, 0x0400),
.synthetic = utils.isPresent(u16, access_flags_u, 0x1000),
.annotation = utils.isPresent(u16, access_flags_u, 0x2000),
.enum_class = utils.isPresent(u16, access_flags_u, 0x4000),
.module = utils.isPresent(u16, access_flags_u, 0x8000),
};
var this_class_u = try reader.readIntBig(u16);
var this_class = this_class_u;
var super_class_u = try reader.readIntBig(u16);
var super_class = if (super_class_u == 0) null else super_class_u;
var interface_count = try reader.readIntBig(u16);
var interfaces = try std.ArrayList(u16).initCapacity(allocator, interface_count);
interfaces.items.len = interface_count;
for (interfaces.items) |*i| i.* = try reader.readIntBig(u16);
var field_count = try reader.readIntBig(u16);
var fieldss = try std.ArrayList(FieldInfo).initCapacity(allocator, field_count);
fieldss.items.len = field_count;
for (fieldss.items) |*f| f.* = try FieldInfo.decode(constant_pool, allocator, reader);
var method_count = try reader.readIntBig(u16);
var methodss = try std.ArrayList(MethodInfo).initCapacity(allocator, method_count);
methodss.items.len = method_count;
for (methodss.items) |*m| m.* = try MethodInfo.decode(constant_pool, allocator, reader);
// var attributess = try std.ArrayList(attributes.AttributeInfo).initCapacity(allocator, try reader.readIntBig(u16));
// for (attributess.items) |*a| a.* = try attributes.AttributeInfo.decode(&constant_pool, allocator, reader);
// TODO: Fix this awful, dangerous, slow hack
var attributes_length = try reader.readIntBig(u16);
var attributes_index: usize = 0;
var attributess = std.ArrayList(attributes.AttributeInfo).init(allocator);
while (attributes_index < attributes_length) : (attributes_index += 1) {
var decoded = try attributes.AttributeInfo.decode(constant_pool, allocator, reader);
if (decoded == .unknown) {
attributes_length -= 1;
continue;
}
try attributess.append(decoded);
}
return ClassFile{
.minor_version = minor_version,
.major_version = major_version,
.constant_pool = constant_pool,
.access_flags = access_flags,
.this_class = this_class,
.super_class = super_class,
.interfaces = interfaces,
.fields = fieldss,
.methods = methodss,
.attributes = attributess,
};
}
pub fn encode(self: *const ClassFile, writer: anytype) !void {
try writer.writeIntBig(u32, 0xCAFEBABE);
try writer.writeIntBig(u16, self.minor_version);
try writer.writeIntBig(u16, self.major_version);
try writer.writeIntBig(u16, @intCast(u16, self.constant_pool.entries.items.len) + 1);
var constant_pool_index: usize = 0;
while (constant_pool_index < self.constant_pool.entries.items.len) : (constant_pool_index += 1) {
var cp = self.constant_pool.entries.items[constant_pool_index];
try cp.encode(writer);
if (cp == .double or cp == .long) {
constant_pool_index += 1;
}
}
var access_flags_u: u16 = 0;
if (self.access_flags.public) utils.setPresent(u16, &access_flags_u, 0x0001);
if (self.access_flags.final) utils.setPresent(u16, &access_flags_u, 0x0010);
if (self.access_flags.super) utils.setPresent(u16, &access_flags_u, 0x0020);
if (self.access_flags.interface) utils.setPresent(u16, &access_flags_u, 0x0200);
if (self.access_flags.abstract) utils.setPresent(u16, &access_flags_u, 0x0400);
if (self.access_flags.synthetic) utils.setPresent(u16, &access_flags_u, 0x1000);
if (self.access_flags.annotation) utils.setPresent(u16, &access_flags_u, 0x2000);
if (self.access_flags.enum_class) utils.setPresent(u16, &access_flags_u, 0x4000);
if (self.access_flags.module) utils.setPresent(u16, &access_flags_u, 0x8000);
try writer.writeIntBig(u16, access_flags_u);
try writer.writeIntBig(u16, self.this_class);
try writer.writeIntBig(u16, self.super_class orelse 0);
try writer.writeIntBig(u16, @intCast(u16, self.interfaces.items.len));
for (self.interfaces.items) |i| try writer.writeIntBig(u16, i);
try writer.writeIntBig(u16, @intCast(u16, self.fields.items.len));
for (self.fields.items) |f| try f.encode(writer);
try writer.writeIntBig(u16, @intCast(u16, self.methods.items.len));
for (self.methods.items) |m| try m.encode(writer);
try writer.writeIntBig(u16, @intCast(u16, self.attributes.items.len));
for (self.attributes.items) |a| try a.encode(writer);
}
pub fn deinit(self: *ClassFile) void {
self.interfaces.deinit();
for (self.fields.items) |*fie| fie.deinit();
self.fields.deinit();
for (self.methods.items) |*met| met.deinit();
self.methods.deinit();
for (self.attributes.items) |*att| att.deinit();
self.attributes.deinit();
self.constant_pool.deinit();
}
pub const JavaSEVersion = enum { @"1.1", @"1.2", @"1.3", @"1.4", @"5.0", @"6", @"7", @"8", @"9", @"10", @"11", @"12", @"13", @"14", @"15", @"16" };
pub const GetJavaSEVersionError = error{InvalidMajorVersion};
/// Get the Java SE (or JDK for early versions) version corresponding to the ClassFile's `major_version` in accordance with [Table 4.1-A. class file format major versions](https://docs.oracle.com/javase/specs/jvms/se16/html/jvms-4.html#jvms-4.1-200-B.2)
pub fn getJavaSEVersion(self: ClassFile) GetJavaSEVersionError!JavaSEVersion {
return switch (self.major_version) {
45 => .@"1.1",
46 => .@"1.2",
47 => .@"1.3",
48 => .@"1.4",
49 => .@"5.0",
50 => .@"6",
51 => .@"7",
52 => .@"8",
53 => .@"9",
54 => .@"10",
55 => .@"11",
56 => .@"12",
57 => .@"13",
58 => .@"14",
59 => .@"15",
60 => .@"16",
else => error.InvalidMajorVersion,
};
}
test "Decode ClassFile" {
const harness = @import("../test/harness.zig");
var reader = harness.hello.fbs().reader();
var cf = try ClassFile.decode(std.testing.allocator, reader);
defer cf.deinit();
}
test "Encode ClassFile" {
const harness = @import("../test/harness.zig");
var reader = harness.hello.fbs().reader();
var joe_file = try std.fs.cwd().createFile("Hello.class", .{});
defer joe_file.close();
var cf = try ClassFile.decode(std.testing.allocator, reader);
defer cf.deinit();
try cf.encode(joe_file.writer());
var end_result: [harness.hello.data.len]u8 = undefined;
try cf.encode(std.io.fixedBufferStream(&end_result).writer());
try std.testing.expectEqualSlices(u8, harness.hello.data, &end_result);
} | src/ClassFile.zig |
const std = @import("std");
const Allocator = std.mem.Allocator;
const fmtIntSizeBin = std.fmt.fmtIntSizeBin;
const Module = @import("Module.zig");
const Value = @import("value.zig").Value;
const Air = @import("Air.zig");
const Liveness = @import("Liveness.zig");
pub fn dump(gpa: Allocator, air: Air, liveness: Liveness) void {
const instruction_bytes = air.instructions.len *
// Here we don't use @sizeOf(Air.Inst.Data) because it would include
// the debug safety tag but we want to measure release size.
(@sizeOf(Air.Inst.Tag) + 8);
const extra_bytes = air.extra.len * @sizeOf(u32);
const values_bytes = air.values.len * @sizeOf(Value);
const tomb_bytes = liveness.tomb_bits.len * @sizeOf(usize);
const liveness_extra_bytes = liveness.extra.len * @sizeOf(u32);
const liveness_special_bytes = liveness.special.count() * 8;
const total_bytes = @sizeOf(Air) + instruction_bytes + extra_bytes +
values_bytes + @sizeOf(Liveness) + liveness_extra_bytes +
liveness_special_bytes + tomb_bytes;
// zig fmt: off
std.debug.print(
\\# Total AIR+Liveness bytes: {}
\\# AIR Instructions: {d} ({})
\\# AIR Extra Data: {d} ({})
\\# AIR Values Bytes: {d} ({})
\\# Liveness tomb_bits: {}
\\# Liveness Extra Data: {d} ({})
\\# Liveness special table: {d} ({})
\\
, .{
fmtIntSizeBin(total_bytes),
air.instructions.len, fmtIntSizeBin(instruction_bytes),
air.extra.len, fmtIntSizeBin(extra_bytes),
air.values.len, fmtIntSizeBin(values_bytes),
fmtIntSizeBin(tomb_bytes),
liveness.extra.len, fmtIntSizeBin(liveness_extra_bytes),
liveness.special.count(), fmtIntSizeBin(liveness_special_bytes),
});
// zig fmt: on
var arena = std.heap.ArenaAllocator.init(gpa);
defer arena.deinit();
var writer: Writer = .{
.gpa = gpa,
.arena = arena.allocator(),
.air = air,
.liveness = liveness,
.indent = 2,
};
const stream = std.io.getStdErr().writer();
writer.writeAllConstants(stream) catch return;
stream.writeByte('\n') catch return;
writer.writeBody(stream, air.getMainBody()) catch return;
}
const Writer = struct {
gpa: Allocator,
arena: Allocator,
air: Air,
liveness: Liveness,
indent: usize,
fn writeAllConstants(w: *Writer, s: anytype) @TypeOf(s).Error!void {
for (w.air.instructions.items(.tag)) |tag, i| {
const inst = @intCast(u32, i);
switch (tag) {
.constant, .const_ty => {
try s.writeByteNTimes(' ', w.indent);
try s.print("%{d} ", .{inst});
try w.writeInst(s, inst);
try s.writeAll(")\n");
},
else => continue,
}
}
}
fn writeBody(w: *Writer, s: anytype, body: []const Air.Inst.Index) @TypeOf(s).Error!void {
for (body) |inst| {
try s.writeByteNTimes(' ', w.indent);
if (w.liveness.isUnused(inst)) {
try s.print("%{d}!", .{inst});
} else {
try s.print("%{d} ", .{inst});
}
try w.writeInst(s, inst);
try s.writeAll(")\n");
}
}
fn writeInst(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
const tags = w.air.instructions.items(.tag);
const tag = tags[inst];
try s.print("= {s}(", .{@tagName(tags[inst])});
switch (tag) {
.add,
.addwrap,
.add_sat,
.sub,
.subwrap,
.sub_sat,
.mul,
.mulwrap,
.mul_sat,
.div_float,
.div_trunc,
.div_floor,
.div_exact,
.rem,
.mod,
.ptr_add,
.ptr_sub,
.bit_and,
.bit_or,
.xor,
.cmp_lt,
.cmp_lte,
.cmp_eq,
.cmp_gte,
.cmp_gt,
.cmp_neq,
.bool_and,
.bool_or,
.store,
.array_elem_val,
.slice_elem_val,
.ptr_elem_val,
.shl,
.shl_exact,
.shl_sat,
.shr,
.shr_exact,
.set_union_tag,
.min,
.max,
=> try w.writeBinOp(s, inst),
.is_null,
.is_non_null,
.is_null_ptr,
.is_non_null_ptr,
.is_err,
.is_non_err,
.is_err_ptr,
.is_non_err_ptr,
.ptrtoint,
.bool_to_int,
.ret,
.ret_load,
.tag_name,
.error_name,
.sqrt,
.sin,
.cos,
.exp,
.exp2,
.log,
.log2,
.log10,
.fabs,
.floor,
.ceil,
.round,
.trunc_float,
=> try w.writeUnOp(s, inst),
.breakpoint,
.unreach,
.ret_addr,
.frame_addr,
=> try w.writeNoOp(s, inst),
.const_ty,
.alloc,
.ret_ptr,
.arg,
=> try w.writeTy(s, inst),
.not,
.bitcast,
.load,
.fptrunc,
.fpext,
.intcast,
.trunc,
.optional_payload,
.optional_payload_ptr,
.optional_payload_ptr_set,
.errunion_payload_ptr_set,
.wrap_optional,
.unwrap_errunion_payload,
.unwrap_errunion_err,
.unwrap_errunion_payload_ptr,
.unwrap_errunion_err_ptr,
.wrap_errunion_payload,
.wrap_errunion_err,
.slice_ptr,
.slice_len,
.ptr_slice_len_ptr,
.ptr_slice_ptr_ptr,
.struct_field_ptr_index_0,
.struct_field_ptr_index_1,
.struct_field_ptr_index_2,
.struct_field_ptr_index_3,
.array_to_slice,
.int_to_float,
.splat,
.float_to_int,
.get_union_tag,
.clz,
.ctz,
.popcount,
.byte_swap,
.bit_reverse,
=> try w.writeTyOp(s, inst),
.block,
.loop,
=> try w.writeBlock(s, inst),
.slice,
.slice_elem_ptr,
.ptr_elem_ptr,
=> try w.writeTyPlBin(s, inst),
.call,
.call_always_tail,
.call_never_tail,
.call_never_inline,
=> try w.writeCall(s, inst),
.dbg_var_ptr,
.dbg_var_val,
=> try w.writeDbgVar(s, inst),
.struct_field_ptr => try w.writeStructField(s, inst),
.struct_field_val => try w.writeStructField(s, inst),
.constant => try w.writeConstant(s, inst),
.assembly => try w.writeAssembly(s, inst),
.dbg_stmt => try w.writeDbgStmt(s, inst),
.dbg_inline_begin, .dbg_inline_end => try w.writeDbgInline(s, inst),
.aggregate_init => try w.writeAggregateInit(s, inst),
.union_init => try w.writeUnionInit(s, inst),
.br => try w.writeBr(s, inst),
.cond_br => try w.writeCondBr(s, inst),
.switch_br => try w.writeSwitchBr(s, inst),
.cmpxchg_weak, .cmpxchg_strong => try w.writeCmpxchg(s, inst),
.fence => try w.writeFence(s, inst),
.atomic_load => try w.writeAtomicLoad(s, inst),
.prefetch => try w.writePrefetch(s, inst),
.atomic_store_unordered => try w.writeAtomicStore(s, inst, .Unordered),
.atomic_store_monotonic => try w.writeAtomicStore(s, inst, .Monotonic),
.atomic_store_release => try w.writeAtomicStore(s, inst, .Release),
.atomic_store_seq_cst => try w.writeAtomicStore(s, inst, .SeqCst),
.atomic_rmw => try w.writeAtomicRmw(s, inst),
.memcpy => try w.writeMemcpy(s, inst),
.memset => try w.writeMemset(s, inst),
.field_parent_ptr => try w.writeFieldParentPtr(s, inst),
.wasm_memory_size => try w.writeWasmMemorySize(s, inst),
.wasm_memory_grow => try w.writeWasmMemoryGrow(s, inst),
.mul_add => try w.writeMulAdd(s, inst),
.shuffle => try w.writeShuffle(s, inst),
.reduce => try w.writeReduce(s, inst),
.add_with_overflow,
.sub_with_overflow,
.mul_with_overflow,
.shl_with_overflow,
=> try w.writeOverflow(s, inst),
.dbg_block_begin, .dbg_block_end => {},
}
}
fn writeBinOp(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
const bin_op = w.air.instructions.items(.data)[inst].bin_op;
try w.writeOperand(s, inst, 0, bin_op.lhs);
try s.writeAll(", ");
try w.writeOperand(s, inst, 1, bin_op.rhs);
}
fn writeUnOp(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
const un_op = w.air.instructions.items(.data)[inst].un_op;
try w.writeOperand(s, inst, 0, un_op);
}
fn writeNoOp(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
_ = w;
_ = inst;
_ = s;
// no-op, no argument to write
}
fn writeTy(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
const ty = w.air.instructions.items(.data)[inst].ty;
try s.print("{}", .{ty});
}
fn writeTyOp(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
const ty_op = w.air.instructions.items(.data)[inst].ty_op;
try s.print("{}, ", .{w.air.getRefType(ty_op.ty)});
try w.writeOperand(s, inst, 0, ty_op.operand);
}
fn writeBlock(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
const ty_pl = w.air.instructions.items(.data)[inst].ty_pl;
const extra = w.air.extraData(Air.Block, ty_pl.payload);
const body = w.air.extra[extra.end..][0..extra.data.body_len];
try s.print("{}, {{\n", .{w.air.getRefType(ty_pl.ty)});
const old_indent = w.indent;
w.indent += 2;
try w.writeBody(s, body);
w.indent = old_indent;
try s.writeByteNTimes(' ', w.indent);
try s.writeAll("}");
}
fn writeAggregateInit(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
const ty_pl = w.air.instructions.items(.data)[inst].ty_pl;
const vector_ty = w.air.getRefType(ty_pl.ty);
const len = @intCast(usize, vector_ty.arrayLen());
const elements = @bitCast([]const Air.Inst.Ref, w.air.extra[ty_pl.payload..][0..len]);
try s.print("{}, [", .{vector_ty});
for (elements) |elem, i| {
if (i != 0) try s.writeAll(", ");
try w.writeOperand(s, inst, i, elem);
}
try s.writeAll("]");
}
fn writeUnionInit(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
const ty_pl = w.air.instructions.items(.data)[inst].ty_pl;
const extra = w.air.extraData(Air.UnionInit, ty_pl.payload).data;
try s.print("{d}, ", .{extra.field_index});
try w.writeOperand(s, inst, 0, extra.init);
}
fn writeStructField(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
const ty_pl = w.air.instructions.items(.data)[inst].ty_pl;
const extra = w.air.extraData(Air.StructField, ty_pl.payload).data;
try w.writeOperand(s, inst, 0, extra.struct_operand);
try s.print(", {d}", .{extra.field_index});
}
fn writeTyPlBin(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
const ty_pl = w.air.instructions.items(.data)[inst].ty_pl;
const extra = w.air.extraData(Air.Bin, ty_pl.payload).data;
try w.writeOperand(s, inst, 0, extra.lhs);
try s.writeAll(", ");
try w.writeOperand(s, inst, 1, extra.rhs);
}
fn writeCmpxchg(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
const ty_pl = w.air.instructions.items(.data)[inst].ty_pl;
const extra = w.air.extraData(Air.Cmpxchg, ty_pl.payload).data;
try w.writeOperand(s, inst, 0, extra.ptr);
try s.writeAll(", ");
try w.writeOperand(s, inst, 1, extra.expected_value);
try s.writeAll(", ");
try w.writeOperand(s, inst, 2, extra.new_value);
try s.print(", {s}, {s}", .{
@tagName(extra.successOrder()), @tagName(extra.failureOrder()),
});
}
fn writeMulAdd(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
const pl_op = w.air.instructions.items(.data)[inst].pl_op;
const extra = w.air.extraData(Air.Bin, pl_op.payload).data;
try w.writeOperand(s, inst, 0, extra.lhs);
try s.writeAll(", ");
try w.writeOperand(s, inst, 1, extra.rhs);
try s.writeAll(", ");
try w.writeOperand(s, inst, 2, pl_op.operand);
}
fn writeShuffle(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
const ty_pl = w.air.instructions.items(.data)[inst].ty_pl;
const extra = w.air.extraData(Air.Shuffle, ty_pl.payload).data;
try w.writeOperand(s, inst, 0, extra.a);
try s.writeAll(", ");
try w.writeOperand(s, inst, 1, extra.b);
try s.print(", mask {d}, len {d}", .{ extra.mask, extra.mask_len });
}
fn writeReduce(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
const reduce = w.air.instructions.items(.data)[inst].reduce;
try w.writeOperand(s, inst, 0, reduce.operand);
try s.print(", {s}", .{@tagName(reduce.operation)});
}
fn writeFence(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
const atomic_order = w.air.instructions.items(.data)[inst].fence;
try s.print("{s}", .{@tagName(atomic_order)});
}
fn writeAtomicLoad(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
const atomic_load = w.air.instructions.items(.data)[inst].atomic_load;
try w.writeOperand(s, inst, 0, atomic_load.ptr);
try s.print(", {s}", .{@tagName(atomic_load.order)});
}
fn writePrefetch(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
const prefetch = w.air.instructions.items(.data)[inst].prefetch;
try w.writeOperand(s, inst, 0, prefetch.ptr);
try s.print(", {s}, {d}, {s}", .{
@tagName(prefetch.rw), prefetch.locality, @tagName(prefetch.cache),
});
}
fn writeAtomicStore(
w: *Writer,
s: anytype,
inst: Air.Inst.Index,
order: std.builtin.AtomicOrder,
) @TypeOf(s).Error!void {
const bin_op = w.air.instructions.items(.data)[inst].bin_op;
try w.writeOperand(s, inst, 0, bin_op.lhs);
try s.writeAll(", ");
try w.writeOperand(s, inst, 1, bin_op.rhs);
try s.print(", {s}", .{@tagName(order)});
}
fn writeAtomicRmw(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
const pl_op = w.air.instructions.items(.data)[inst].pl_op;
const extra = w.air.extraData(Air.AtomicRmw, pl_op.payload).data;
try w.writeOperand(s, inst, 0, pl_op.operand);
try s.writeAll(", ");
try w.writeOperand(s, inst, 1, extra.operand);
try s.print(", {s}, {s}", .{ @tagName(extra.op()), @tagName(extra.ordering()) });
}
fn writeOverflow(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
const pl_op = w.air.instructions.items(.data)[inst].pl_op;
const extra = w.air.extraData(Air.Bin, pl_op.payload).data;
try w.writeOperand(s, inst, 0, pl_op.operand);
try s.writeAll(", ");
try w.writeOperand(s, inst, 1, extra.lhs);
try s.writeAll(", ");
try w.writeOperand(s, inst, 2, extra.rhs);
}
fn writeMemset(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
const pl_op = w.air.instructions.items(.data)[inst].pl_op;
const extra = w.air.extraData(Air.Bin, pl_op.payload).data;
try w.writeOperand(s, inst, 0, pl_op.operand);
try s.writeAll(", ");
try w.writeOperand(s, inst, 1, extra.lhs);
try s.writeAll(", ");
try w.writeOperand(s, inst, 2, extra.rhs);
}
fn writeFieldParentPtr(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
const pl_op = w.air.instructions.items(.data)[inst].ty_pl;
const extra = w.air.extraData(Air.FieldParentPtr, pl_op.payload).data;
try w.writeOperand(s, inst, 0, extra.field_ptr);
try s.print(", {d}", .{extra.field_index});
}
fn writeMemcpy(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
const pl_op = w.air.instructions.items(.data)[inst].pl_op;
const extra = w.air.extraData(Air.Bin, pl_op.payload).data;
try w.writeOperand(s, inst, 0, pl_op.operand);
try s.writeAll(", ");
try w.writeOperand(s, inst, 1, extra.lhs);
try s.writeAll(", ");
try w.writeOperand(s, inst, 2, extra.rhs);
}
fn writeConstant(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
const ty_pl = w.air.instructions.items(.data)[inst].ty_pl;
const val = w.air.values[ty_pl.payload];
try s.print("{}, {}", .{ w.air.getRefType(ty_pl.ty), val.fmtDebug() });
}
fn writeAssembly(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
const ty_pl = w.air.instructions.items(.data)[inst].ty_pl;
const extra = w.air.extraData(Air.Asm, ty_pl.payload);
const is_volatile = @truncate(u1, extra.data.flags >> 31) != 0;
const clobbers_len = @truncate(u31, extra.data.flags);
var extra_i: usize = extra.end;
var op_index: usize = 0;
const ret_ty = w.air.typeOfIndex(inst);
try s.print("{}", .{ret_ty});
if (is_volatile) {
try s.writeAll(", volatile");
}
const outputs = @bitCast([]const Air.Inst.Ref, w.air.extra[extra_i..][0..extra.data.outputs_len]);
extra_i += outputs.len;
const inputs = @bitCast([]const Air.Inst.Ref, w.air.extra[extra_i..][0..extra.data.inputs_len]);
extra_i += inputs.len;
for (outputs) |output| {
const constraint = w.air.nullTerminatedString(extra_i);
// This equation accounts for the fact that even if we have exactly 4 bytes
// for the string, we still use the next u32 for the null terminator.
extra_i += constraint.len / 4 + 1;
if (output == .none) {
try s.print(", -> {s}", .{constraint});
} else {
try s.print(", out {s} = (", .{constraint});
try w.writeOperand(s, inst, op_index, output);
op_index += 1;
try s.writeByte(')');
}
}
for (inputs) |input| {
const constraint = w.air.nullTerminatedString(extra_i);
// This equation accounts for the fact that even if we have exactly 4 bytes
// for the string, we still use the next u32 for the null terminator.
extra_i += constraint.len / 4 + 1;
try s.print(", in {s} = (", .{constraint});
try w.writeOperand(s, inst, op_index, input);
op_index += 1;
try s.writeByte(')');
}
{
var clobber_i: u32 = 0;
while (clobber_i < clobbers_len) : (clobber_i += 1) {
const clobber = w.air.nullTerminatedString(extra_i);
// This equation accounts for the fact that even if we have exactly 4 bytes
// for the string, we still use the next u32 for the null terminator.
extra_i += clobber.len / 4 + 1;
try s.writeAll(", ~{");
try s.writeAll(clobber);
try s.writeAll("}");
}
}
const asm_source = std.mem.sliceAsBytes(w.air.extra[extra_i..])[0..extra.data.source_len];
try s.print(", \"{s}\"", .{asm_source});
}
fn writeDbgStmt(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
const dbg_stmt = w.air.instructions.items(.data)[inst].dbg_stmt;
try s.print("{d}:{d}", .{ dbg_stmt.line + 1, dbg_stmt.column + 1 });
}
fn writeDbgInline(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
const ty_pl = w.air.instructions.items(.data)[inst].ty_pl;
const function = w.air.values[ty_pl.payload].castTag(.function).?.data;
try s.print("{s}", .{function.owner_decl.name});
}
fn writeDbgVar(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
const pl_op = w.air.instructions.items(.data)[inst].pl_op;
try w.writeOperand(s, inst, 0, pl_op.operand);
const name = w.air.nullTerminatedString(pl_op.payload);
try s.print(", {s}", .{name});
}
fn writeCall(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
const pl_op = w.air.instructions.items(.data)[inst].pl_op;
const extra = w.air.extraData(Air.Call, pl_op.payload);
const args = @bitCast([]const Air.Inst.Ref, w.air.extra[extra.end..][0..extra.data.args_len]);
try w.writeOperand(s, inst, 0, pl_op.operand);
try s.writeAll(", [");
for (args) |arg, i| {
if (i != 0) try s.writeAll(", ");
try w.writeOperand(s, inst, 1 + i, arg);
}
try s.writeAll("]");
}
fn writeBr(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
const br = w.air.instructions.items(.data)[inst].br;
try w.writeInstIndex(s, br.block_inst, false);
try s.writeAll(", ");
try w.writeOperand(s, inst, 0, br.operand);
}
fn writeCondBr(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
const pl_op = w.air.instructions.items(.data)[inst].pl_op;
const extra = w.air.extraData(Air.CondBr, pl_op.payload);
const then_body = w.air.extra[extra.end..][0..extra.data.then_body_len];
const else_body = w.air.extra[extra.end + then_body.len ..][0..extra.data.else_body_len];
const liveness_condbr = w.liveness.getCondBr(inst);
try w.writeOperand(s, inst, 0, pl_op.operand);
try s.writeAll(", {\n");
const old_indent = w.indent;
w.indent += 2;
if (liveness_condbr.then_deaths.len != 0) {
try s.writeByteNTimes(' ', w.indent);
for (liveness_condbr.then_deaths) |operand, i| {
if (i != 0) try s.writeAll(" ");
try s.print("%{d}!", .{operand});
}
try s.writeAll("\n");
}
try w.writeBody(s, then_body);
try s.writeByteNTimes(' ', old_indent);
try s.writeAll("}, {\n");
if (liveness_condbr.else_deaths.len != 0) {
try s.writeByteNTimes(' ', w.indent);
for (liveness_condbr.else_deaths) |operand, i| {
if (i != 0) try s.writeAll(" ");
try s.print("%{d}!", .{operand});
}
try s.writeAll("\n");
}
try w.writeBody(s, else_body);
w.indent = old_indent;
try s.writeByteNTimes(' ', old_indent);
try s.writeAll("}");
}
fn writeSwitchBr(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
const pl_op = w.air.instructions.items(.data)[inst].pl_op;
const switch_br = w.air.extraData(Air.SwitchBr, pl_op.payload);
var extra_index: usize = switch_br.end;
var case_i: u32 = 0;
try w.writeOperand(s, inst, 0, pl_op.operand);
const old_indent = w.indent;
w.indent += 2;
while (case_i < switch_br.data.cases_len) : (case_i += 1) {
const case = w.air.extraData(Air.SwitchBr.Case, extra_index);
const items = @bitCast([]const Air.Inst.Ref, w.air.extra[case.end..][0..case.data.items_len]);
const case_body = w.air.extra[case.end + items.len ..][0..case.data.body_len];
extra_index = case.end + case.data.items_len + case_body.len;
try s.writeAll(", [");
for (items) |item, item_i| {
if (item_i != 0) try s.writeAll(", ");
try w.writeInstRef(s, item, false);
}
try s.writeAll("] => {\n");
w.indent += 2;
try w.writeBody(s, case_body);
w.indent -= 2;
try s.writeByteNTimes(' ', w.indent);
try s.writeAll("}");
}
const else_body = w.air.extra[extra_index..][0..switch_br.data.else_body_len];
if (else_body.len != 0) {
try s.writeAll(", else => {\n");
w.indent += 2;
try w.writeBody(s, else_body);
w.indent -= 2;
try s.writeByteNTimes(' ', w.indent);
try s.writeAll("}");
}
try s.writeAll("\n");
try s.writeByteNTimes(' ', old_indent);
try s.writeAll("}");
}
fn writeWasmMemorySize(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
const pl_op = w.air.instructions.items(.data)[inst].pl_op;
try s.print("{d}", .{pl_op.payload});
}
fn writeWasmMemoryGrow(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
const pl_op = w.air.instructions.items(.data)[inst].pl_op;
try s.print("{d}, ", .{pl_op.payload});
try w.writeOperand(s, inst, 0, pl_op.operand);
}
fn writeOperand(
w: *Writer,
s: anytype,
inst: Air.Inst.Index,
op_index: usize,
operand: Air.Inst.Ref,
) @TypeOf(s).Error!void {
const dies = if (op_index < Liveness.bpi - 1)
w.liveness.operandDies(inst, @intCast(Liveness.OperandInt, op_index))
else blk: {
// TODO
break :blk false;
};
return w.writeInstRef(s, operand, dies);
}
fn writeInstRef(
w: *Writer,
s: anytype,
operand: Air.Inst.Ref,
dies: bool,
) @TypeOf(s).Error!void {
var i: usize = @enumToInt(operand);
if (i < Air.Inst.Ref.typed_value_map.len) {
return s.print("@{}", .{operand});
}
i -= Air.Inst.Ref.typed_value_map.len;
return w.writeInstIndex(s, @intCast(Air.Inst.Index, i), dies);
}
fn writeInstIndex(
w: *Writer,
s: anytype,
inst: Air.Inst.Index,
dies: bool,
) @TypeOf(s).Error!void {
_ = w;
if (dies) {
try s.print("%{d}!", .{inst});
} else {
try s.print("%{d}", .{inst});
}
}
}; | src/print_air.zig |
const LE_LESS = c_int(-1);
const LE_EQUAL = c_int(0);
const LE_GREATER = c_int(1);
const LE_UNORDERED = c_int(1);
const rep_t = u128;
const srep_t = i128;
const typeWidth = rep_t.bit_count;
const significandBits = 112;
const exponentBits = (typeWidth - significandBits - 1);
const signBit = (rep_t(1) << (significandBits + exponentBits));
const absMask = signBit - 1;
const implicitBit = rep_t(1) << significandBits;
const significandMask = implicitBit - 1;
const exponentMask = absMask ^ significandMask;
const infRep = exponentMask;
const builtin = @import("builtin");
const is_test = builtin.is_test;
pub extern fn __letf2(a: f128, b: f128) c_int {
@setRuntimeSafety(is_test);
const aInt = @bitCast(rep_t, a);
const bInt = @bitCast(rep_t, b);
const aAbs: rep_t = aInt & absMask;
const bAbs: rep_t = bInt & absMask;
// If either a or b is NaN, they are unordered.
if (aAbs > infRep or bAbs > infRep) return LE_UNORDERED;
// If a and b are both zeros, they are equal.
if ((aAbs | bAbs) == 0) return LE_EQUAL;
// If at least one of a and b is positive, we get the same result comparing
// a and b as signed integers as we would with a floating-point compare.
return if ((aInt & bInt) >= 0) if (aInt < bInt)
LE_LESS
else if (aInt == bInt)
LE_EQUAL
else
LE_GREATER else
// Otherwise, both are negative, so we need to flip the sense of the
// comparison to get the correct result. (This assumes a twos- or ones-
// complement integer representation; if integers are represented in a
// sign-magnitude representation, then this flip is incorrect).
if (aInt > bInt)
LE_LESS
else if (aInt == bInt)
LE_EQUAL
else
LE_GREATER;
}
// TODO https://github.com/ziglang/zig/issues/305
// and then make the return types of some of these functions the enum instead of c_int
const GE_LESS = c_int(-1);
const GE_EQUAL = c_int(0);
const GE_GREATER = c_int(1);
const GE_UNORDERED = c_int(-1); // Note: different from LE_UNORDERED
pub extern fn __getf2(a: f128, b: f128) c_int {
@setRuntimeSafety(is_test);
const aInt = @bitCast(srep_t, a);
const bInt = @bitCast(srep_t, b);
const aAbs = @bitCast(rep_t, aInt) & absMask;
const bAbs = @bitCast(rep_t, bInt) & absMask;
if (aAbs > infRep or bAbs > infRep) return GE_UNORDERED;
if ((aAbs | bAbs) == 0) return GE_EQUAL;
return if ((aInt & bInt) >= 0) if (aInt < bInt)
GE_LESS
else if (aInt == bInt)
GE_EQUAL
else
GE_GREATER else if (aInt > bInt)
GE_LESS
else if (aInt == bInt)
GE_EQUAL
else
GE_GREATER;
}
pub extern fn __unordtf2(a: f128, b: f128) c_int {
@setRuntimeSafety(is_test);
const aAbs = @bitCast(rep_t, a) & absMask;
const bAbs = @bitCast(rep_t, b) & absMask;
return @boolToInt(aAbs > infRep or bAbs > infRep);
} | std/special/compiler_rt/comparetf2.zig |
/// https://github.com/raspberrypi/firmware/wiki/Mailbox-property-interface
const mmio = @import("mmio.zig");
const cpu = @import("../../cpu.zig").Current;
const VideocoreMbox = struct {
read: u32,
reserved1: [12]u8,
poll: u32,
sender: u32,
status: u32,
config: u32,
write: u32,
fn is_empty(self: *volatile VideocoreMbox) bool {
return self.status & 0x40000000 != 0;
}
fn is_full(self: *volatile VideocoreMbox) bool {
return self.status & 0x80000000 != 0;
}
};
pub const MBOX_REQUEST = 0;
pub const Channel = enum(u8) {
power = 0,
fb = 1,
vuart = 2,
vchiq = 3,
leds = 4,
btns = 5,
touch = 6,
count = 7,
prop = 8,
};
pub const Tag = enum(u32) {
get_serial = 0x10004,
set_clk_rate = 0x38002,
last = 0,
pub fn to_int(self: Tag) u32 {
return @enumToInt(self);
}
};
pub export var data: [36]u32 align(16) = undefined;
var mbox align(32) = @intToPtr(*volatile VideocoreMbox, mmio.VIDEO_CORE_MAILBOX);
pub fn call(channel: Channel) bool {
var f: usize = 0xF;
var add: usize = @intCast(usize, @ptrToInt(&data)) & ~f;
var r: usize = add | (@enumToInt(channel) & 0xF);
while (mbox.is_full()) {
cpu.nop();
}
mbox.write = @intCast(u32, r);
while (true) {
var a = true;
while (mbox.is_empty()) {
cpu.nop();
}
if (r == mbox.read) {
return data[1] == 0x80000000;
}
}
return false;
}
test "mbox registers" {
const expectEqual = @import("std").testing.expectEqual;
var registers = @intToPtr(*VideocoreMbox, 0x10000000);
expectEqual(@as(usize, 0x10000000), @ptrToInt(®isters.read));
expectEqual(@as(usize, 0x10000010), @ptrToInt(®isters.poll));
expectEqual(@as(usize, 0x10000014), @ptrToInt(®isters.sender));
expectEqual(@as(usize, 0x10000018), @ptrToInt(®isters.status));
expectEqual(@as(usize, 0x1000001C), @ptrToInt(®isters.config));
expectEqual(@as(usize, 0x10000020), @ptrToInt(®isters.write));
} | src/arm/io/mbox.zig |
const std = @import("std");
const expect = std.testing.expect;
const builtin = @import("builtin");
const native_arch = builtin.target.cpu.arch;
var foo: u8 align(4) = 100;
test "global variable alignment" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
comptime try expect(@typeInfo(@TypeOf(&foo)).Pointer.alignment == 4);
comptime try expect(@TypeOf(&foo) == *align(4) u8);
{
const slice = @as(*[1]u8, &foo)[0..];
comptime try expect(@TypeOf(slice) == *align(4) [1]u8);
}
{
var runtime_zero: usize = 0;
const slice = @as(*[1]u8, &foo)[runtime_zero..];
comptime try expect(@TypeOf(slice) == []align(4) u8);
}
}
test "default alignment allows unspecified in type syntax" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
try expect(*u32 == *align(@alignOf(u32)) u32);
}
test "implicitly decreasing pointer alignment" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
const a: u32 align(4) = 3;
const b: u32 align(8) = 4;
try expect(addUnaligned(&a, &b) == 7);
}
fn addUnaligned(a: *align(1) const u32, b: *align(1) const u32) u32 {
return a.* + b.*;
}
test "@alignCast pointers" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
var x: u32 align(4) = 1;
expectsOnly1(&x);
try expect(x == 2);
}
fn expectsOnly1(x: *align(1) u32) void {
expects4(@alignCast(4, x));
}
fn expects4(x: *align(4) u32) void {
x.* += 1;
}
test "alignment of structs" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
try expect(@alignOf(struct {
a: i32,
b: *i32,
}) == @alignOf(usize));
}
test "alignment of >= 128-bit integer type" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
try expect(@alignOf(u128) == 16);
try expect(@alignOf(u129) == 16);
}
test "alignment of struct with 128-bit field" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
try expect(@alignOf(struct {
x: u128,
}) == 16);
comptime {
try expect(@alignOf(struct {
x: u128,
}) == 16);
}
}
test "size of extern struct with 128-bit field" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
try expect(@sizeOf(extern struct {
x: u128,
y: u8,
}) == 32);
comptime {
try expect(@sizeOf(extern struct {
x: u128,
y: u8,
}) == 32);
}
}
test "@ptrCast preserves alignment of bigger source" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
var x: u32 align(16) = 1234;
const ptr = @ptrCast(*u8, &x);
try expect(@TypeOf(ptr) == *align(16) u8);
}
test "alignstack" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
try expect(fnWithAlignedStack() == 1234);
}
fn fnWithAlignedStack() i32 {
@setAlignStack(256);
return 1234;
}
test "implicitly decreasing slice alignment" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
const a: u32 align(4) = 3;
const b: u32 align(8) = 4;
try expect(addUnalignedSlice(@as(*const [1]u32, &a)[0..], @as(*const [1]u32, &b)[0..]) == 7);
}
fn addUnalignedSlice(a: []align(1) const u32, b: []align(1) const u32) u32 {
return a[0] + b[0];
}
test "specifying alignment allows pointer cast" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
try testBytesAlign(0x33);
}
fn testBytesAlign(b: u8) !void {
var bytes align(4) = [_]u8{ b, b, b, b };
const ptr = @ptrCast(*u32, &bytes[0]);
try expect(ptr.* == 0x33333333);
}
test "@alignCast slices" {
if (builtin.zig_backend == .stage2_x86_64 or builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
var array align(4) = [_]u32{ 1, 1 };
const slice = array[0..];
sliceExpectsOnly1(slice);
try expect(slice[0] == 2);
}
fn sliceExpectsOnly1(slice: []align(1) u32) void {
sliceExpects4(@alignCast(4, slice));
}
fn sliceExpects4(slice: []align(4) u32) void {
slice[0] += 1;
}
test "return error union with 128-bit integer" {
if (builtin.zig_backend == .stage2_x86_64 or builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
try expect(3 == try give());
}
fn give() anyerror!u128 {
return 3;
}
test "page aligned array on stack" {
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
// Large alignment value to make it hard to accidentally pass.
var array align(0x1000) = [_]u8{ 1, 2, 3, 4, 5, 6, 7, 8 };
var number1: u8 align(16) = 42;
var number2: u8 align(16) = 43;
try expect(@ptrToInt(&array[0]) & 0xFFF == 0);
try expect(array[3] == 4);
try expect(@truncate(u4, @ptrToInt(&number1)) == 0);
try expect(@truncate(u4, @ptrToInt(&number2)) == 0);
try expect(number1 == 42);
try expect(number2 == 43);
}
fn derp() align(@sizeOf(usize) * 2) i32 {
return 1234;
}
fn noop1() align(1) void {}
fn noop4() align(4) void {}
test "function alignment" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
// function alignment is a compile error on wasm32/wasm64
if (native_arch == .wasm32 or native_arch == .wasm64) return error.SkipZigTest;
try expect(derp() == 1234);
try expect(@TypeOf(noop1) == fn () align(1) void);
try expect(@TypeOf(noop4) == fn () align(4) void);
noop1();
noop4();
} | test/behavior/align.zig |
const builtin = @import("builtin");
const std = @import("std");
const testing = std.testing;
const expect = testing.expect;
const expectError = testing.expectError;
test "dereference pointer" {
comptime try testDerefPtr();
try testDerefPtr();
}
fn testDerefPtr() !void {
var x: i32 = 1234;
var y = &x;
y.* += 1;
try expect(x == 1235);
}
test "pointer arithmetic" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
var ptr: [*]const u8 = "abcd";
try expect(ptr[0] == 'a');
ptr += 1;
try expect(ptr[0] == 'b');
ptr += 1;
try expect(ptr[0] == 'c');
ptr += 1;
try expect(ptr[0] == 'd');
ptr += 1;
try expect(ptr[0] == 0);
ptr -= 1;
try expect(ptr[0] == 'd');
ptr -= 1;
try expect(ptr[0] == 'c');
ptr -= 1;
try expect(ptr[0] == 'b');
ptr -= 1;
try expect(ptr[0] == 'a');
}
test "double pointer parsing" {
comptime try expect(PtrOf(PtrOf(i32)) == **i32);
}
fn PtrOf(comptime T: type) type {
return *T;
}
test "implicit cast single item pointer to C pointer and back" {
var y: u8 = 11;
var x: [*c]u8 = &y;
var z: *u8 = x;
z.* += 1;
try expect(y == 12);
}
test "initialize const optional C pointer to null" {
const a: ?[*c]i32 = null;
try expect(a == null);
comptime try expect(a == null);
}
test "assigning integer to C pointer" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
var x: i32 = 0;
var y: i32 = 1;
var ptr: [*c]u8 = 0;
var ptr2: [*c]u8 = x;
var ptr3: [*c]u8 = 1;
var ptr4: [*c]u8 = y;
try expect(ptr == ptr2);
try expect(ptr3 == ptr4);
try expect(ptr3 > ptr and ptr4 > ptr2 and y > x);
try expect(1 > ptr and y > ptr2 and 0 < ptr3 and x < ptr4);
}
test "C pointer comparison and arithmetic" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
const S = struct {
fn doTheTest() !void {
var ptr1: [*c]u32 = 0;
var ptr2 = ptr1 + 10;
try expect(ptr1 == 0);
try expect(ptr1 >= 0);
try expect(ptr1 <= 0);
// expect(ptr1 < 1);
// expect(ptr1 < one);
// expect(1 > ptr1);
// expect(one > ptr1);
try expect(ptr1 < ptr2);
try expect(ptr2 > ptr1);
try expect(ptr2 >= 40);
try expect(ptr2 == 40);
try expect(ptr2 <= 40);
ptr2 -= 10;
try expect(ptr1 == ptr2);
}
};
try S.doTheTest();
comptime try S.doTheTest();
}
test "dereference pointer again" {
try testDerefPtrOneVal();
comptime try testDerefPtrOneVal();
}
const Foo1 = struct {
x: void,
};
fn testDerefPtrOneVal() !void {
// Foo1 satisfies the OnePossibleValueYes criteria
const x = &Foo1{ .x = {} };
const y = x.*;
try expect(@TypeOf(y.x) == void);
}
test "peer type resolution with C pointers" {
var ptr_one: *u8 = undefined;
var ptr_many: [*]u8 = undefined;
var ptr_c: [*c]u8 = undefined;
var t = true;
var x1 = if (t) ptr_one else ptr_c;
var x2 = if (t) ptr_many else ptr_c;
var x3 = if (t) ptr_c else ptr_one;
var x4 = if (t) ptr_c else ptr_many;
try expect(@TypeOf(x1) == [*c]u8);
try expect(@TypeOf(x2) == [*c]u8);
try expect(@TypeOf(x3) == [*c]u8);
try expect(@TypeOf(x4) == [*c]u8);
}
test "peer type resolution with C pointer and const pointer" {
// stage1 incorrectly resolves to [*]u8
if (builtin.zig_backend == .stage1) return error.SkipZigTest;
var ptr_c: [*c]u8 = undefined;
const ptr_const: u8 = undefined;
try expect(@TypeOf(ptr_c, &ptr_const) == [*c]const u8);
}
test "implicit casting between C pointer and optional non-C pointer" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
var slice: []const u8 = "aoeu";
const opt_many_ptr: ?[*]const u8 = slice.ptr;
var ptr_opt_many_ptr = &opt_many_ptr;
var c_ptr: [*c]const [*c]const u8 = ptr_opt_many_ptr;
try expect(c_ptr.*.* == 'a');
ptr_opt_many_ptr = c_ptr;
try expect(ptr_opt_many_ptr.*.?[1] == 'o');
}
test "implicit cast error unions with non-optional to optional pointer" {
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
const S = struct {
fn doTheTest() !void {
try expectError(error.Fail, foo());
}
fn foo() anyerror!?*u8 {
return bar() orelse error.Fail;
}
fn bar() ?*u8 {
return null;
}
};
try S.doTheTest();
comptime try S.doTheTest();
}
test "compare equality of optional and non-optional pointer" {
const a = @intToPtr(*const usize, 0x12345678);
const b = @intToPtr(?*usize, 0x12345678);
try expect(a == b);
try expect(b == a);
}
test "allowzero pointer and slice" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
var ptr = @intToPtr([*]allowzero i32, 0);
var opt_ptr: ?[*]allowzero i32 = ptr;
try expect(opt_ptr != null);
try expect(@ptrToInt(ptr) == 0);
var runtime_zero: usize = 0;
var slice = ptr[runtime_zero..10];
comptime try expect(@TypeOf(slice) == []allowzero i32);
try expect(@ptrToInt(&slice[5]) == 20);
comptime try expect(@typeInfo(@TypeOf(ptr)).Pointer.is_allowzero);
comptime try expect(@typeInfo(@TypeOf(slice)).Pointer.is_allowzero);
}
test "assign null directly to C pointer and test null equality" {
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
var x: [*c]i32 = null;
try expect(x == null);
try expect(null == x);
try expect(!(x != null));
try expect(!(null != x));
if (x) |same_x| {
_ = same_x;
@panic("fail");
}
var otherx: i32 = undefined;
try expect((x orelse &otherx) == &otherx);
const y: [*c]i32 = null;
comptime try expect(y == null);
comptime try expect(null == y);
comptime try expect(!(y != null));
comptime try expect(!(null != y));
if (y) |same_y| {
_ = same_y;
@panic("fail");
}
const othery: i32 = undefined;
comptime try expect((y orelse &othery) == &othery);
var n: i32 = 1234;
var x1: [*c]i32 = &n;
try expect(!(x1 == null));
try expect(!(null == x1));
try expect(x1 != null);
try expect(null != x1);
try expect(x1.?.* == 1234);
if (x1) |same_x1| {
try expect(same_x1.* == 1234);
} else {
@panic("fail");
}
try expect((x1 orelse &otherx) == x1);
const nc: i32 = 1234;
const y1: [*c]const i32 = &nc;
comptime try expect(!(y1 == null));
comptime try expect(!(null == y1));
comptime try expect(y1 != null);
comptime try expect(null != y1);
comptime try expect(y1.?.* == 1234);
if (y1) |same_y1| {
try expect(same_y1.* == 1234);
} else {
@compileError("fail");
}
comptime try expect((y1 orelse &othery) == y1);
}
test "array initialization types" {
const E = enum { A, B, C };
try expect(@TypeOf([_]u8{}) == [0]u8);
try expect(@TypeOf([_:0]u8{}) == [0:0]u8);
try expect(@TypeOf([_:.A]E{}) == [0:.A]E);
try expect(@TypeOf([_:0]u8{ 1, 2, 3 }) == [3:0]u8);
}
test "null terminated pointer" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
const S = struct {
fn doTheTest() !void {
var array_with_zero = [_:0]u8{ 'h', 'e', 'l', 'l', 'o' };
var zero_ptr: [*:0]const u8 = @ptrCast([*:0]const u8, &array_with_zero);
var no_zero_ptr: [*]const u8 = zero_ptr;
var zero_ptr_again = @ptrCast([*:0]const u8, no_zero_ptr);
try expect(std.mem.eql(u8, std.mem.sliceTo(zero_ptr_again, 0), "hello"));
}
};
try S.doTheTest();
comptime try S.doTheTest();
}
test "allow any sentinel" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
const S = struct {
fn doTheTest() !void {
var array = [_:std.math.minInt(i32)]i32{ 1, 2, 3, 4 };
var ptr: [*:std.math.minInt(i32)]i32 = &array;
try expect(ptr[4] == std.math.minInt(i32));
}
};
try S.doTheTest();
comptime try S.doTheTest();
}
test "pointer sentinel with enums" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
const S = struct {
const Number = enum {
one,
two,
sentinel,
};
fn doTheTest() !void {
var ptr: [*:.sentinel]const Number = &[_:.sentinel]Number{ .one, .two, .two, .one };
try expect(ptr[4] == .sentinel); // TODO this should be comptime try expect, see #3731
}
};
try S.doTheTest();
comptime try S.doTheTest();
}
test "pointer sentinel with optional element" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
const S = struct {
fn doTheTest() !void {
var ptr: [*:null]const ?i32 = &[_:null]?i32{ 1, 2, 3, 4 };
try expect(ptr[4] == null); // TODO this should be comptime try expect, see #3731
}
};
try S.doTheTest();
comptime try S.doTheTest();
}
test "pointer sentinel with +inf" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
const S = struct {
fn doTheTest() !void {
const inf = std.math.inf_f32;
var ptr: [*:inf]const f32 = &[_:inf]f32{ 1.1, 2.2, 3.3, 4.4 };
try expect(ptr[4] == inf); // TODO this should be comptime try expect, see #3731
}
};
try S.doTheTest();
comptime try S.doTheTest();
}
test "pointer to array at fixed address" {
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
const array = @intToPtr(*volatile [1]u32, 0x10);
// Silly check just to reference `array`
try expect(@ptrToInt(&array[0]) == 0x10);
}
test "pointer arithmetic affects the alignment" {
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
{
var ptr: [*]align(8) u32 = undefined;
var x: usize = 1;
try expect(@typeInfo(@TypeOf(ptr)).Pointer.alignment == 8);
const ptr1 = ptr + 1; // 1 * 4 = 4 -> lcd(4,8) = 4
try expect(@typeInfo(@TypeOf(ptr1)).Pointer.alignment == 4);
const ptr2 = ptr + 4; // 4 * 4 = 16 -> lcd(16,8) = 8
try expect(@typeInfo(@TypeOf(ptr2)).Pointer.alignment == 8);
const ptr3 = ptr + 0; // no-op
try expect(@typeInfo(@TypeOf(ptr3)).Pointer.alignment == 8);
const ptr4 = ptr + x; // runtime-known addend
try expect(@typeInfo(@TypeOf(ptr4)).Pointer.alignment == 4);
}
{
var ptr: [*]align(8) [3]u8 = undefined;
var x: usize = 1;
const ptr1 = ptr + 17; // 3 * 17 = 51
try expect(@typeInfo(@TypeOf(ptr1)).Pointer.alignment == 1);
const ptr2 = ptr + x; // runtime-known addend
try expect(@typeInfo(@TypeOf(ptr2)).Pointer.alignment == 1);
const ptr3 = ptr + 8; // 3 * 8 = 24 -> lcd(8,24) = 8
try expect(@typeInfo(@TypeOf(ptr3)).Pointer.alignment == 8);
const ptr4 = ptr + 4; // 3 * 4 = 12 -> lcd(8,12) = 4
try expect(@typeInfo(@TypeOf(ptr4)).Pointer.alignment == 4);
}
}
test "@ptrToInt on null optional at comptime" {
{
const pointer = @intToPtr(?*u8, 0x000);
const x = @ptrToInt(pointer);
_ = x;
comptime try expect(0 == @ptrToInt(pointer));
}
{
const pointer = @intToPtr(?*u8, 0xf00);
comptime try expect(0xf00 == @ptrToInt(pointer));
}
}
test "indexing array with sentinel returns correct type" {
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
var s: [:0]const u8 = "abc";
try testing.expectEqualSlices(u8, "*const u8", @typeName(@TypeOf(&s[0])));
}
test "element pointer to slice" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
const S = struct {
fn doTheTest() !void {
var cases: [2][2]i32 = [_][2]i32{
[_]i32{ 0, 1 },
[_]i32{ 2, 3 },
};
const items: []i32 = &cases[0]; // *[2]i32
try testing.expect(items.len == 2);
try testing.expect(items[1] == 1);
try testing.expect(items[0] == 0);
}
};
try S.doTheTest();
comptime try S.doTheTest();
}
test "element pointer arithmetic to slice" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
const S = struct {
fn doTheTest() !void {
var cases: [2][2]i32 = [_][2]i32{
[_]i32{ 0, 1 },
[_]i32{ 2, 3 },
};
const elem_ptr = &cases[0]; // *[2]i32
const many = @ptrCast([*][2]i32, elem_ptr);
const many_elem = @ptrCast(*[2]i32, &many[1]);
const items: []i32 = many_elem;
try testing.expect(items.len == 2);
try testing.expect(items[1] == 3);
try testing.expect(items[0] == 2);
}
};
try S.doTheTest();
comptime try S.doTheTest();
}
test "array slicing to slice" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
const S = struct {
fn doTheTest() !void {
var str: [5]i32 = [_]i32{ 1, 2, 3, 4, 5 };
var sub: *[2]i32 = str[1..3];
var slice: []i32 = sub; // used to cause failures
try testing.expect(slice.len == 2);
try testing.expect(slice[0] == 2);
}
};
try S.doTheTest();
comptime try S.doTheTest();
} | test/behavior/pointers.zig |
const std = @import("std");
const mem = std.mem;
const primes = [_]u64{
0xa0761d6478bd642f,
0xe7037ed1a0b428db,
0x8ebc6af09c88c6e3,
0x589965cc75374cc3,
0x1d8e4e27c47d124f,
};
fn read_bytes(comptime bytes: u8, data: []const u8) u64 {
const T = std.meta.IntType(false, 8 * bytes);
return mem.readIntLittle(T, data[0..bytes]);
}
fn read_8bytes_swapped(data: []const u8) u64 {
return (read_bytes(4, data) << 32 | read_bytes(4, data[4..]));
}
fn mum(a: u64, b: u64) u64 {
var r = std.math.mulWide(u64, a, b);
r = (r >> 64) ^ r;
return @truncate(u64, r);
}
fn mix0(a: u64, b: u64, seed: u64) u64 {
return mum(a ^ seed ^ primes[0], b ^ seed ^ primes[1]);
}
fn mix1(a: u64, b: u64, seed: u64) u64 {
return mum(a ^ seed ^ primes[2], b ^ seed ^ primes[3]);
}
// Wyhash version which does not store internal state for handling partial buffers.
// This is needed so that we can maximize the speed for the short key case, which will
// use the non-iterative api which the public Wyhash exposes.
const WyhashStateless = struct {
seed: u64,
msg_len: usize,
pub fn init(seed: u64) WyhashStateless {
return WyhashStateless{
.seed = seed,
.msg_len = 0,
};
}
fn round(self: *WyhashStateless, b: []const u8) void {
std.debug.assert(b.len == 32);
self.seed = mix0(
read_bytes(8, b[0..]),
read_bytes(8, b[8..]),
self.seed,
) ^ mix1(
read_bytes(8, b[16..]),
read_bytes(8, b[24..]),
self.seed,
);
}
pub fn update(self: *WyhashStateless, b: []const u8) void {
std.debug.assert(b.len % 32 == 0);
var off: usize = 0;
while (off < b.len) : (off += 32) {
@call(.{ .modifier = .always_inline }, self.round, .{b[off .. off + 32]});
}
self.msg_len += b.len;
}
pub fn final(self: *WyhashStateless, b: []const u8) u64 {
std.debug.assert(b.len < 32);
const seed = self.seed;
const rem_len = @intCast(u5, b.len);
const rem_key = b[0..rem_len];
self.seed = switch (rem_len) {
0 => seed,
1 => mix0(read_bytes(1, rem_key), primes[4], seed),
2 => mix0(read_bytes(2, rem_key), primes[4], seed),
3 => mix0((read_bytes(2, rem_key) << 8) | read_bytes(1, rem_key[2..]), primes[4], seed),
4 => mix0(read_bytes(4, rem_key), primes[4], seed),
5 => mix0((read_bytes(4, rem_key) << 8) | read_bytes(1, rem_key[4..]), primes[4], seed),
6 => mix0((read_bytes(4, rem_key) << 16) | read_bytes(2, rem_key[4..]), primes[4], seed),
7 => mix0((read_bytes(4, rem_key) << 24) | (read_bytes(2, rem_key[4..]) << 8) | read_bytes(1, rem_key[6..]), primes[4], seed),
8 => mix0(read_8bytes_swapped(rem_key), primes[4], seed),
9 => mix0(read_8bytes_swapped(rem_key), read_bytes(1, rem_key[8..]), seed),
10 => mix0(read_8bytes_swapped(rem_key), read_bytes(2, rem_key[8..]), seed),
11 => mix0(read_8bytes_swapped(rem_key), (read_bytes(2, rem_key[8..]) << 8) | read_bytes(1, rem_key[10..]), seed),
12 => mix0(read_8bytes_swapped(rem_key), read_bytes(4, rem_key[8..]), seed),
13 => mix0(read_8bytes_swapped(rem_key), (read_bytes(4, rem_key[8..]) << 8) | read_bytes(1, rem_key[12..]), seed),
14 => mix0(read_8bytes_swapped(rem_key), (read_bytes(4, rem_key[8..]) << 16) | read_bytes(2, rem_key[12..]), seed),
15 => mix0(read_8bytes_swapped(rem_key), (read_bytes(4, rem_key[8..]) << 24) | (read_bytes(2, rem_key[12..]) << 8) | read_bytes(1, rem_key[14..]), seed),
16 => mix0(read_8bytes_swapped(rem_key), read_8bytes_swapped(rem_key[8..]), seed),
17 => mix0(read_8bytes_swapped(rem_key), read_8bytes_swapped(rem_key[8..]), seed) ^ mix1(read_bytes(1, rem_key[16..]), primes[4], seed),
18 => mix0(read_8bytes_swapped(rem_key), read_8bytes_swapped(rem_key[8..]), seed) ^ mix1(read_bytes(2, rem_key[16..]), primes[4], seed),
19 => mix0(read_8bytes_swapped(rem_key), read_8bytes_swapped(rem_key[8..]), seed) ^ mix1((read_bytes(2, rem_key[16..]) << 8) | read_bytes(1, rem_key[18..]), primes[4], seed),
20 => mix0(read_8bytes_swapped(rem_key), read_8bytes_swapped(rem_key[8..]), seed) ^ mix1(read_bytes(4, rem_key[16..]), primes[4], seed),
21 => mix0(read_8bytes_swapped(rem_key), read_8bytes_swapped(rem_key[8..]), seed) ^ mix1((read_bytes(4, rem_key[16..]) << 8) | read_bytes(1, rem_key[20..]), primes[4], seed),
22 => mix0(read_8bytes_swapped(rem_key), read_8bytes_swapped(rem_key[8..]), seed) ^ mix1((read_bytes(4, rem_key[16..]) << 16) | read_bytes(2, rem_key[20..]), primes[4], seed),
23 => mix0(read_8bytes_swapped(rem_key), read_8bytes_swapped(rem_key[8..]), seed) ^ mix1((read_bytes(4, rem_key[16..]) << 24) | (read_bytes(2, rem_key[20..]) << 8) | read_bytes(1, rem_key[22..]), primes[4], seed),
24 => mix0(read_8bytes_swapped(rem_key), read_8bytes_swapped(rem_key[8..]), seed) ^ mix1(read_8bytes_swapped(rem_key[16..]), primes[4], seed),
25 => mix0(read_8bytes_swapped(rem_key), read_8bytes_swapped(rem_key[8..]), seed) ^ mix1(read_8bytes_swapped(rem_key[16..]), read_bytes(1, rem_key[24..]), seed),
26 => mix0(read_8bytes_swapped(rem_key), read_8bytes_swapped(rem_key[8..]), seed) ^ mix1(read_8bytes_swapped(rem_key[16..]), read_bytes(2, rem_key[24..]), seed),
27 => mix0(read_8bytes_swapped(rem_key), read_8bytes_swapped(rem_key[8..]), seed) ^ mix1(read_8bytes_swapped(rem_key[16..]), (read_bytes(2, rem_key[24..]) << 8) | read_bytes(1, rem_key[26..]), seed),
28 => mix0(read_8bytes_swapped(rem_key), read_8bytes_swapped(rem_key[8..]), seed) ^ mix1(read_8bytes_swapped(rem_key[16..]), read_bytes(4, rem_key[24..]), seed),
29 => mix0(read_8bytes_swapped(rem_key), read_8bytes_swapped(rem_key[8..]), seed) ^ mix1(read_8bytes_swapped(rem_key[16..]), (read_bytes(4, rem_key[24..]) << 8) | read_bytes(1, rem_key[28..]), seed),
30 => mix0(read_8bytes_swapped(rem_key), read_8bytes_swapped(rem_key[8..]), seed) ^ mix1(read_8bytes_swapped(rem_key[16..]), (read_bytes(4, rem_key[24..]) << 16) | read_bytes(2, rem_key[28..]), seed),
31 => mix0(read_8bytes_swapped(rem_key), read_8bytes_swapped(rem_key[8..]), seed) ^ mix1(read_8bytes_swapped(rem_key[16..]), (read_bytes(4, rem_key[24..]) << 24) | (read_bytes(2, rem_key[28..]) << 8) | read_bytes(1, rem_key[30..]), seed),
};
self.msg_len += b.len;
return mum(self.seed ^ self.msg_len, primes[4]);
}
pub fn hash(seed: u64, input: []const u8) u64 {
const aligned_len = input.len - (input.len % 32);
var c = WyhashStateless.init(seed);
@call(.{ .modifier = .always_inline }, c.update, .{input[0..aligned_len]});
return @call(.{ .modifier = .always_inline }, c.final, .{input[aligned_len..]});
}
};
/// Fast non-cryptographic 64bit hash function.
/// See https://github.com/wangyi-fudan/wyhash
pub const Wyhash = struct {
state: WyhashStateless,
buf: [32]u8,
buf_len: usize,
pub fn init(seed: u64) Wyhash {
return Wyhash{
.state = WyhashStateless.init(seed),
.buf = undefined,
.buf_len = 0,
};
}
pub fn update(self: *Wyhash, b: []const u8) void {
var off: usize = 0;
if (self.buf_len != 0 and self.buf_len + b.len >= 32) {
off += 32 - self.buf_len;
mem.copy(u8, self.buf[self.buf_len..], b[0..off]);
self.state.update(self.buf[0..]);
self.buf_len = 0;
}
const remain_len = b.len - off;
const aligned_len = remain_len - (remain_len % 32);
self.state.update(b[off .. off + aligned_len]);
mem.copy(u8, self.buf[self.buf_len..], b[off + aligned_len ..]);
self.buf_len += @intCast(u8, b[off + aligned_len ..].len);
}
pub fn final(self: *Wyhash) u64 {
const seed = self.state.seed;
const rem_len = @intCast(u5, self.buf_len);
const rem_key = self.buf[0..self.buf_len];
return self.state.final(rem_key);
}
pub fn hash(seed: u64, input: []const u8) u64 {
return WyhashStateless.hash(seed, input);
}
};
const expectEqual = std.testing.expectEqual;
test "test vectors" {
const hash = Wyhash.hash;
expectEqual(hash(0, ""), 0x0);
expectEqual(hash(1, "a"), 0xbed235177f41d328);
expectEqual(hash(2, "abc"), 0xbe348debe59b27c3);
expectEqual(hash(3, "message digest"), 0x37320f657213a290);
expectEqual(hash(4, "abcdefghijklmnopqrstuvwxyz"), 0xd0b270e1d8a7019c);
expectEqual(hash(5, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"), 0x602a1894d3bbfe7f);
expectEqual(hash(6, "12345678901234567890123456789012345678901234567890123456789012345678901234567890"), 0x829e9c148b75970e);
}
test "test vectors streaming" {
var wh = Wyhash.init(5);
for ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") |e| {
wh.update(mem.asBytes(&e));
}
expectEqual(wh.final(), 0x602a1894d3bbfe7f);
const pattern = "1234567890";
const count = 8;
const result = 0x829e9c148b75970e;
expectEqual(Wyhash.hash(6, pattern ** 8), result);
wh = Wyhash.init(6);
var i: u32 = 0;
while (i < count) : (i += 1) {
wh.update(pattern);
}
expectEqual(wh.final(), result);
}
test "iterative non-divisible update" {
var buf: [8192]u8 = undefined;
for (buf) |*e, i| {
e.* = @truncate(u8, i);
}
const seed = 0x128dad08f;
var end: usize = 32;
while (end < buf.len) : (end += 32) {
const non_iterative_hash = Wyhash.hash(seed, buf[0..end]);
var wy = Wyhash.init(seed);
var i: usize = 0;
while (i < end) : (i += 33) {
wy.update(buf[i..std.math.min(i + 33, end)]);
}
const iterative_hash = wy.final();
std.testing.expectEqual(iterative_hash, non_iterative_hash);
}
} | lib/std/hash/wyhash.zig |
const Zld = @This();
const std = @import("std");
const assert = std.debug.assert;
const dwarf = std.dwarf;
const leb = std.leb;
const mem = std.mem;
const meta = std.meta;
const fs = std.fs;
const macho = std.macho;
const math = std.math;
const log = std.log.scoped(.zld);
const aarch64 = @import("../../codegen/aarch64.zig");
const Allocator = mem.Allocator;
const CodeSignature = @import("CodeSignature.zig");
const Archive = @import("Archive.zig");
const Object = @import("Object.zig");
const Trie = @import("Trie.zig");
usingnamespace @import("commands.zig");
usingnamespace @import("bind.zig");
allocator: *Allocator,
arch: ?std.Target.Cpu.Arch = null,
page_size: ?u16 = null,
file: ?fs.File = null,
out_path: ?[]const u8 = null,
// TODO Eventually, we will want to keep track of the archives themselves to be able to exclude objects
// contained within from landing in the final artifact. For now however, since we don't optimise the binary
// at all, we just move all objects from the archives into the final artifact.
objects: std.ArrayListUnmanaged(Object) = .{},
load_commands: std.ArrayListUnmanaged(LoadCommand) = .{},
pagezero_segment_cmd_index: ?u16 = null,
text_segment_cmd_index: ?u16 = null,
data_const_segment_cmd_index: ?u16 = null,
data_segment_cmd_index: ?u16 = null,
linkedit_segment_cmd_index: ?u16 = null,
dyld_info_cmd_index: ?u16 = null,
symtab_cmd_index: ?u16 = null,
dysymtab_cmd_index: ?u16 = null,
dylinker_cmd_index: ?u16 = null,
libsystem_cmd_index: ?u16 = null,
data_in_code_cmd_index: ?u16 = null,
function_starts_cmd_index: ?u16 = null,
main_cmd_index: ?u16 = null,
version_min_cmd_index: ?u16 = null,
source_version_cmd_index: ?u16 = null,
uuid_cmd_index: ?u16 = null,
code_signature_cmd_index: ?u16 = null,
// __TEXT segment sections
text_section_index: ?u16 = null,
stubs_section_index: ?u16 = null,
stub_helper_section_index: ?u16 = null,
text_const_section_index: ?u16 = null,
cstring_section_index: ?u16 = null,
// __DATA segment sections
got_section_index: ?u16 = null,
tlv_section_index: ?u16 = null,
tlv_data_section_index: ?u16 = null,
tlv_bss_section_index: ?u16 = null,
la_symbol_ptr_section_index: ?u16 = null,
data_const_section_index: ?u16 = null,
data_section_index: ?u16 = null,
bss_section_index: ?u16 = null,
locals: std.StringArrayHashMapUnmanaged(std.ArrayListUnmanaged(Symbol)) = .{},
exports: std.StringArrayHashMapUnmanaged(macho.nlist_64) = .{},
nonlazy_imports: std.StringArrayHashMapUnmanaged(Import) = .{},
lazy_imports: std.StringArrayHashMapUnmanaged(Import) = .{},
tlv_bootstrap: ?Import = null,
threadlocal_offsets: std.ArrayListUnmanaged(u64) = .{},
local_rebases: std.ArrayListUnmanaged(Pointer) = .{},
nonlazy_pointers: std.StringArrayHashMapUnmanaged(GotEntry) = .{},
strtab: std.ArrayListUnmanaged(u8) = .{},
stub_helper_stubs_start_off: ?u64 = null,
mappings: std.AutoHashMapUnmanaged(MappingKey, SectionMapping) = .{},
unhandled_sections: std.AutoHashMapUnmanaged(MappingKey, u0) = .{},
// TODO this will require scanning the relocations at least one to work out
// the exact amount of local GOT indirections. For the time being, set some
// default value.
const max_local_got_indirections: u16 = 1000;
const GotEntry = struct {
index: u32,
target_addr: u64,
};
const MappingKey = struct {
object_id: u16,
source_sect_id: u16,
};
const SectionMapping = struct {
source_sect_id: u16,
target_seg_id: u16,
target_sect_id: u16,
offset: u32,
};
const Symbol = struct {
inner: macho.nlist_64,
tt: Type,
object_id: u16,
const Type = enum {
Local,
WeakGlobal,
Global,
};
};
const DebugInfo = struct {
inner: dwarf.DwarfInfo,
debug_info: []u8,
debug_abbrev: []u8,
debug_str: []u8,
debug_line: []u8,
debug_ranges: []u8,
pub fn parseFromObject(allocator: *Allocator, object: Object) !?DebugInfo {
var debug_info = blk: {
const index = object.dwarf_debug_info_index orelse return null;
break :blk try object.readSection(allocator, index);
};
var debug_abbrev = blk: {
const index = object.dwarf_debug_abbrev_index orelse return null;
break :blk try object.readSection(allocator, index);
};
var debug_str = blk: {
const index = object.dwarf_debug_str_index orelse return null;
break :blk try object.readSection(allocator, index);
};
var debug_line = blk: {
const index = object.dwarf_debug_line_index orelse return null;
break :blk try object.readSection(allocator, index);
};
var debug_ranges = blk: {
if (object.dwarf_debug_ranges_index) |ind| {
break :blk try object.readSection(allocator, ind);
}
break :blk try allocator.alloc(u8, 0);
};
var inner: dwarf.DwarfInfo = .{
.endian = .Little,
.debug_info = debug_info,
.debug_abbrev = debug_abbrev,
.debug_str = debug_str,
.debug_line = debug_line,
.debug_ranges = debug_ranges,
};
try dwarf.openDwarfDebugInfo(&inner, allocator);
return DebugInfo{
.inner = inner,
.debug_info = debug_info,
.debug_abbrev = debug_abbrev,
.debug_str = debug_str,
.debug_line = debug_line,
.debug_ranges = debug_ranges,
};
}
pub fn deinit(self: *DebugInfo, allocator: *Allocator) void {
allocator.free(self.debug_info);
allocator.free(self.debug_abbrev);
allocator.free(self.debug_str);
allocator.free(self.debug_line);
allocator.free(self.debug_ranges);
self.inner.abbrev_table_list.deinit();
self.inner.compile_unit_list.deinit();
self.inner.func_list.deinit();
}
};
pub const Import = struct {
/// MachO symbol table entry.
symbol: macho.nlist_64,
/// Id of the dynamic library where the specified entries can be found.
dylib_ordinal: i64,
/// Index of this import within the import list.
index: u32,
};
/// Default path to dyld
/// TODO instead of hardcoding it, we should probably look through some env vars and search paths
/// instead but this will do for now.
const DEFAULT_DYLD_PATH: [*:0]const u8 = "/usr/lib/dyld";
/// Default lib search path
/// TODO instead of hardcoding it, we should probably look through some env vars and search paths
/// instead but this will do for now.
const DEFAULT_LIB_SEARCH_PATH: []const u8 = "/usr/lib";
const LIB_SYSTEM_NAME: [*:0]const u8 = "System";
/// TODO we should search for libSystem and fail if it doesn't exist, instead of hardcoding it
const LIB_SYSTEM_PATH: [*:0]const u8 = DEFAULT_LIB_SEARCH_PATH ++ "/libSystem.B.dylib";
pub fn init(allocator: *Allocator) Zld {
return .{ .allocator = allocator };
}
pub fn deinit(self: *Zld) void {
self.threadlocal_offsets.deinit(self.allocator);
self.strtab.deinit(self.allocator);
self.local_rebases.deinit(self.allocator);
for (self.lazy_imports.items()) |*entry| {
self.allocator.free(entry.key);
}
self.lazy_imports.deinit(self.allocator);
for (self.nonlazy_imports.items()) |*entry| {
self.allocator.free(entry.key);
}
self.nonlazy_imports.deinit(self.allocator);
for (self.nonlazy_pointers.items()) |*entry| {
self.allocator.free(entry.key);
}
self.nonlazy_pointers.deinit(self.allocator);
for (self.exports.items()) |*entry| {
self.allocator.free(entry.key);
}
self.exports.deinit(self.allocator);
for (self.locals.items()) |*entry| {
self.allocator.free(entry.key);
entry.value.deinit(self.allocator);
}
self.locals.deinit(self.allocator);
for (self.objects.items) |*object| {
object.deinit();
}
self.objects.deinit(self.allocator);
for (self.load_commands.items) |*lc| {
lc.deinit(self.allocator);
}
self.load_commands.deinit(self.allocator);
self.mappings.deinit(self.allocator);
self.unhandled_sections.deinit(self.allocator);
if (self.file) |*f| f.close();
}
pub fn link(self: *Zld, files: []const []const u8, out_path: []const u8) !void {
if (files.len == 0) return error.NoInputFiles;
if (out_path.len == 0) return error.EmptyOutputPath;
if (self.arch == null) {
// Try inferring the arch from the object files.
self.arch = blk: {
const file = try fs.cwd().openFile(files[0], .{});
defer file.close();
var reader = file.reader();
const header = try reader.readStruct(macho.mach_header_64);
const arch: std.Target.Cpu.Arch = switch (header.cputype) {
macho.CPU_TYPE_X86_64 => .x86_64,
macho.CPU_TYPE_ARM64 => .aarch64,
else => |value| {
log.err("unsupported cpu architecture 0x{x}", .{value});
return error.UnsupportedCpuArchitecture;
},
};
break :blk arch;
};
}
self.page_size = switch (self.arch.?) {
.aarch64 => 0x4000,
.x86_64 => 0x1000,
else => unreachable,
};
self.out_path = out_path;
self.file = try fs.cwd().createFile(out_path, .{
.truncate = true,
.read = true,
.mode = if (std.Target.current.os.tag == .windows) 0 else 0o777,
});
try self.populateMetadata();
try self.parseInputFiles(files);
try self.sortSections();
try self.resolveImports();
try self.allocateTextSegment();
try self.allocateDataConstSegment();
try self.allocateDataSegment();
self.allocateLinkeditSegment();
try self.writeStubHelperCommon();
try self.resolveSymbols();
try self.doRelocs();
try self.flush();
}
fn parseInputFiles(self: *Zld, files: []const []const u8) !void {
for (files) |file_name| {
const file = try fs.cwd().openFile(file_name, .{});
try_object: {
var object = Object.initFromFile(self.allocator, self.arch.?, file_name, file) catch |err| switch (err) {
error.NotObject => break :try_object,
else => |e| return e,
};
const index = @intCast(u16, self.objects.items.len);
try self.objects.append(self.allocator, object);
try self.updateMetadata(index);
continue;
}
try_archive: {
var archive = Archive.initFromFile(self.allocator, self.arch.?, file_name, file) catch |err| switch (err) {
error.NotArchive => break :try_archive,
else => |e| return e,
};
defer archive.deinit();
while (archive.objects.popOrNull()) |object| {
const index = @intCast(u16, self.objects.items.len);
try self.objects.append(self.allocator, object);
try self.updateMetadata(index);
}
continue;
}
log.err("unexpected file type: expected object '.o' or archive '.a': {s}", .{file_name});
return error.UnexpectedInputFileType;
}
}
fn mapAndUpdateSections(
self: *Zld,
object_id: u16,
source_sect_id: u16,
target_seg_id: u16,
target_sect_id: u16,
) !void {
const object = self.objects.items[object_id];
const source_seg = object.load_commands.items[object.segment_cmd_index.?].Segment;
const source_sect = source_seg.sections.items[source_sect_id];
const target_seg = &self.load_commands.items[target_seg_id].Segment;
const target_sect = &target_seg.sections.items[target_sect_id];
const alignment = try math.powi(u32, 2, target_sect.@"align");
const offset = mem.alignForwardGeneric(u64, target_sect.size, alignment);
const size = mem.alignForwardGeneric(u64, source_sect.size, alignment);
const key = MappingKey{
.object_id = object_id,
.source_sect_id = source_sect_id,
};
try self.mappings.putNoClobber(self.allocator, key, .{
.source_sect_id = source_sect_id,
.target_seg_id = target_seg_id,
.target_sect_id = target_sect_id,
.offset = @intCast(u32, offset),
});
log.debug("{s}: {s},{s} mapped to {s},{s} from 0x{x} to 0x{x}", .{
object.name,
parseName(&source_sect.segname),
parseName(&source_sect.sectname),
parseName(&target_sect.segname),
parseName(&target_sect.sectname),
offset,
offset + size,
});
target_sect.size = offset + size;
}
fn updateMetadata(self: *Zld, object_id: u16) !void {
const object = self.objects.items[object_id];
const object_seg = object.load_commands.items[object.segment_cmd_index.?].Segment;
const text_seg = &self.load_commands.items[self.text_segment_cmd_index.?].Segment;
const data_const_seg = &self.load_commands.items[self.data_const_segment_cmd_index.?].Segment;
const data_seg = &self.load_commands.items[self.data_segment_cmd_index.?].Segment;
// Create missing metadata
for (object_seg.sections.items) |source_sect, id| {
if (id == object.text_section_index.?) continue;
const segname = parseName(&source_sect.segname);
const sectname = parseName(&source_sect.sectname);
const flags = source_sect.flags;
switch (flags) {
macho.S_REGULAR, macho.S_4BYTE_LITERALS, macho.S_8BYTE_LITERALS, macho.S_16BYTE_LITERALS => {
if (mem.eql(u8, segname, "__TEXT")) {
if (self.text_const_section_index != null) continue;
self.text_const_section_index = @intCast(u16, text_seg.sections.items.len);
try text_seg.addSection(self.allocator, .{
.sectname = makeStaticString("__const"),
.segname = makeStaticString("__TEXT"),
.addr = 0,
.size = 0,
.offset = 0,
.@"align" = 0,
.reloff = 0,
.nreloc = 0,
.flags = macho.S_REGULAR,
.reserved1 = 0,
.reserved2 = 0,
.reserved3 = 0,
});
} else if (mem.eql(u8, segname, "__DATA")) {
if (!mem.eql(u8, sectname, "__const")) continue;
if (self.data_const_section_index != null) continue;
self.data_const_section_index = @intCast(u16, data_const_seg.sections.items.len);
try data_const_seg.addSection(self.allocator, .{
.sectname = makeStaticString("__const"),
.segname = makeStaticString("__DATA_CONST"),
.addr = 0,
.size = 0,
.offset = 0,
.@"align" = 0,
.reloff = 0,
.nreloc = 0,
.flags = macho.S_REGULAR,
.reserved1 = 0,
.reserved2 = 0,
.reserved3 = 0,
});
}
},
macho.S_CSTRING_LITERALS => {
if (!mem.eql(u8, segname, "__TEXT")) continue;
if (self.cstring_section_index != null) continue;
self.cstring_section_index = @intCast(u16, text_seg.sections.items.len);
try text_seg.addSection(self.allocator, .{
.sectname = makeStaticString("__cstring"),
.segname = makeStaticString("__TEXT"),
.addr = 0,
.size = 0,
.offset = 0,
.@"align" = 0,
.reloff = 0,
.nreloc = 0,
.flags = macho.S_CSTRING_LITERALS,
.reserved1 = 0,
.reserved2 = 0,
.reserved3 = 0,
});
},
macho.S_ZEROFILL => {
if (!mem.eql(u8, segname, "__DATA")) continue;
if (self.bss_section_index != null) continue;
self.bss_section_index = @intCast(u16, data_seg.sections.items.len);
try data_seg.addSection(self.allocator, .{
.sectname = makeStaticString("__bss"),
.segname = makeStaticString("__DATA"),
.addr = 0,
.size = 0,
.offset = 0,
.@"align" = 0,
.reloff = 0,
.nreloc = 0,
.flags = macho.S_ZEROFILL,
.reserved1 = 0,
.reserved2 = 0,
.reserved3 = 0,
});
},
macho.S_THREAD_LOCAL_VARIABLES => {
if (!mem.eql(u8, segname, "__DATA")) continue;
if (self.tlv_section_index != null) continue;
self.tlv_section_index = @intCast(u16, data_seg.sections.items.len);
try data_seg.addSection(self.allocator, .{
.sectname = makeStaticString("__thread_vars"),
.segname = makeStaticString("__DATA"),
.addr = 0,
.size = 0,
.offset = 0,
.@"align" = 0,
.reloff = 0,
.nreloc = 0,
.flags = macho.S_THREAD_LOCAL_VARIABLES,
.reserved1 = 0,
.reserved2 = 0,
.reserved3 = 0,
});
},
macho.S_THREAD_LOCAL_REGULAR => {
if (!mem.eql(u8, segname, "__DATA")) continue;
if (self.tlv_data_section_index != null) continue;
self.tlv_data_section_index = @intCast(u16, data_seg.sections.items.len);
try data_seg.addSection(self.allocator, .{
.sectname = makeStaticString("__thread_data"),
.segname = makeStaticString("__DATA"),
.addr = 0,
.size = 0,
.offset = 0,
.@"align" = 0,
.reloff = 0,
.nreloc = 0,
.flags = macho.S_THREAD_LOCAL_REGULAR,
.reserved1 = 0,
.reserved2 = 0,
.reserved3 = 0,
});
},
macho.S_THREAD_LOCAL_ZEROFILL => {
if (!mem.eql(u8, segname, "__DATA")) continue;
if (self.tlv_bss_section_index != null) continue;
self.tlv_bss_section_index = @intCast(u16, data_seg.sections.items.len);
try data_seg.addSection(self.allocator, .{
.sectname = makeStaticString("__thread_bss"),
.segname = makeStaticString("__DATA"),
.addr = 0,
.size = 0,
.offset = 0,
.@"align" = 0,
.reloff = 0,
.nreloc = 0,
.flags = macho.S_THREAD_LOCAL_ZEROFILL,
.reserved1 = 0,
.reserved2 = 0,
.reserved3 = 0,
});
},
else => {
log.debug("unhandled section type 0x{x} for '{s}/{s}'", .{ flags, segname, sectname });
},
}
}
// Find ideal section alignment.
for (object_seg.sections.items) |source_sect, id| {
if (self.getMatchingSection(source_sect)) |res| {
const target_seg = &self.load_commands.items[res.seg].Segment;
const target_sect = &target_seg.sections.items[res.sect];
target_sect.@"align" = math.max(target_sect.@"align", source_sect.@"align");
}
}
// Update section mappings
for (object_seg.sections.items) |source_sect, id| {
const source_sect_id = @intCast(u16, id);
if (self.getMatchingSection(source_sect)) |res| {
try self.mapAndUpdateSections(object_id, source_sect_id, res.seg, res.sect);
continue;
}
const segname = parseName(&source_sect.segname);
const sectname = parseName(&source_sect.sectname);
log.debug("section '{s}/{s}' will be unmapped", .{ segname, sectname });
try self.unhandled_sections.putNoClobber(self.allocator, .{
.object_id = object_id,
.source_sect_id = source_sect_id,
}, 0);
}
}
const MatchingSection = struct {
seg: u16,
sect: u16,
};
fn getMatchingSection(self: *Zld, section: macho.section_64) ?MatchingSection {
const segname = parseName(§ion.segname);
const sectname = parseName(§ion.sectname);
const res: ?MatchingSection = blk: {
switch (section.flags) {
macho.S_4BYTE_LITERALS, macho.S_8BYTE_LITERALS, macho.S_16BYTE_LITERALS => {
break :blk .{
.seg = self.text_segment_cmd_index.?,
.sect = self.text_const_section_index.?,
};
},
macho.S_CSTRING_LITERALS => {
break :blk .{
.seg = self.text_segment_cmd_index.?,
.sect = self.cstring_section_index.?,
};
},
macho.S_ZEROFILL => {
break :blk .{
.seg = self.data_segment_cmd_index.?,
.sect = self.bss_section_index.?,
};
},
macho.S_THREAD_LOCAL_VARIABLES => {
break :blk .{
.seg = self.data_segment_cmd_index.?,
.sect = self.tlv_section_index.?,
};
},
macho.S_THREAD_LOCAL_REGULAR => {
break :blk .{
.seg = self.data_segment_cmd_index.?,
.sect = self.tlv_data_section_index.?,
};
},
macho.S_THREAD_LOCAL_ZEROFILL => {
break :blk .{
.seg = self.data_segment_cmd_index.?,
.sect = self.tlv_bss_section_index.?,
};
},
macho.S_REGULAR | macho.S_ATTR_PURE_INSTRUCTIONS | macho.S_ATTR_SOME_INSTRUCTIONS => {
break :blk .{
.seg = self.text_segment_cmd_index.?,
.sect = self.text_section_index.?,
};
},
macho.S_REGULAR => {
if (mem.eql(u8, segname, "__TEXT")) {
break :blk .{
.seg = self.text_segment_cmd_index.?,
.sect = self.text_const_section_index.?,
};
} else if (mem.eql(u8, segname, "__DATA")) {
if (mem.eql(u8, sectname, "__data")) {
break :blk .{
.seg = self.data_segment_cmd_index.?,
.sect = self.data_section_index.?,
};
} else if (mem.eql(u8, sectname, "__const")) {
break :blk .{
.seg = self.data_const_segment_cmd_index.?,
.sect = self.data_const_section_index.?,
};
}
}
break :blk null;
},
else => {
break :blk null;
},
}
};
return res;
}
fn sortSections(self: *Zld) !void {
var text_index_mapping = std.AutoHashMap(u16, u16).init(self.allocator);
defer text_index_mapping.deinit();
var data_const_index_mapping = std.AutoHashMap(u16, u16).init(self.allocator);
defer data_const_index_mapping.deinit();
var data_index_mapping = std.AutoHashMap(u16, u16).init(self.allocator);
defer data_index_mapping.deinit();
{
// __TEXT segment
const seg = &self.load_commands.items[self.text_segment_cmd_index.?].Segment;
var sections = seg.sections.toOwnedSlice(self.allocator);
defer self.allocator.free(sections);
try seg.sections.ensureCapacity(self.allocator, sections.len);
const indices = &[_]*?u16{
&self.text_section_index,
&self.stubs_section_index,
&self.stub_helper_section_index,
&self.text_const_section_index,
&self.cstring_section_index,
};
for (indices) |maybe_index| {
const new_index: u16 = if (maybe_index.*) |index| blk: {
const idx = @intCast(u16, seg.sections.items.len);
seg.sections.appendAssumeCapacity(sections[index]);
try text_index_mapping.putNoClobber(index, idx);
break :blk idx;
} else continue;
maybe_index.* = new_index;
}
}
{
// __DATA_CONST segment
const seg = &self.load_commands.items[self.data_const_segment_cmd_index.?].Segment;
var sections = seg.sections.toOwnedSlice(self.allocator);
defer self.allocator.free(sections);
try seg.sections.ensureCapacity(self.allocator, sections.len);
const indices = &[_]*?u16{
&self.got_section_index,
&self.data_const_section_index,
};
for (indices) |maybe_index| {
const new_index: u16 = if (maybe_index.*) |index| blk: {
const idx = @intCast(u16, seg.sections.items.len);
seg.sections.appendAssumeCapacity(sections[index]);
try data_const_index_mapping.putNoClobber(index, idx);
break :blk idx;
} else continue;
maybe_index.* = new_index;
}
}
{
// __DATA segment
const seg = &self.load_commands.items[self.data_segment_cmd_index.?].Segment;
var sections = seg.sections.toOwnedSlice(self.allocator);
defer self.allocator.free(sections);
try seg.sections.ensureCapacity(self.allocator, sections.len);
// __DATA segment
const indices = &[_]*?u16{
&self.la_symbol_ptr_section_index,
&self.tlv_section_index,
&self.data_section_index,
&self.tlv_data_section_index,
&self.tlv_bss_section_index,
&self.bss_section_index,
};
for (indices) |maybe_index| {
const new_index: u16 = if (maybe_index.*) |index| blk: {
const idx = @intCast(u16, seg.sections.items.len);
seg.sections.appendAssumeCapacity(sections[index]);
try data_index_mapping.putNoClobber(index, idx);
break :blk idx;
} else continue;
maybe_index.* = new_index;
}
}
var it = self.mappings.iterator();
while (it.next()) |entry| {
const mapping = &entry.value;
if (self.text_segment_cmd_index.? == mapping.target_seg_id) {
const new_index = text_index_mapping.get(mapping.target_sect_id) orelse unreachable;
mapping.target_sect_id = new_index;
} else if (self.data_const_segment_cmd_index.? == mapping.target_seg_id) {
const new_index = data_const_index_mapping.get(mapping.target_sect_id) orelse unreachable;
mapping.target_sect_id = new_index;
} else if (self.data_segment_cmd_index.? == mapping.target_seg_id) {
const new_index = data_index_mapping.get(mapping.target_sect_id) orelse unreachable;
mapping.target_sect_id = new_index;
} else unreachable;
}
}
fn resolveImports(self: *Zld) !void {
var imports = std.StringArrayHashMap(bool).init(self.allocator);
defer imports.deinit();
for (self.objects.items) |object| {
for (object.symtab.items) |sym| {
if (isLocal(&sym)) continue;
const name = object.getString(sym.n_strx);
const res = try imports.getOrPut(name);
if (isExport(&sym)) {
res.entry.value = false;
continue;
}
if (res.found_existing and !res.entry.value)
continue;
res.entry.value = true;
}
}
for (imports.items()) |entry| {
if (!entry.value) continue;
const sym_name = entry.key;
const n_strx = try self.makeString(sym_name);
var new_sym: macho.nlist_64 = .{
.n_strx = n_strx,
.n_type = macho.N_UNDF | macho.N_EXT,
.n_value = 0,
.n_desc = macho.REFERENCE_FLAG_UNDEFINED_NON_LAZY | macho.N_SYMBOL_RESOLVER,
.n_sect = 0,
};
var key = try self.allocator.dupe(u8, sym_name);
// TODO handle symbol resolution from non-libc dylibs.
const dylib_ordinal = 1;
// TODO need to rework this. Perhaps should create a set of all possible libc
// symbols which are expected to be nonlazy?
if (mem.eql(u8, sym_name, "___stdoutp") or
mem.eql(u8, sym_name, "___stderrp") or
mem.eql(u8, sym_name, "___stdinp") or
mem.eql(u8, sym_name, "___stack_chk_guard") or
mem.eql(u8, sym_name, "_environ") or
mem.eql(u8, sym_name, "__DefaultRuneLocale") or
mem.eql(u8, sym_name, "_mach_task_self_"))
{
log.debug("writing nonlazy symbol '{s}'", .{sym_name});
const index = @intCast(u32, self.nonlazy_imports.items().len);
try self.nonlazy_imports.putNoClobber(self.allocator, key, .{
.symbol = new_sym,
.dylib_ordinal = dylib_ordinal,
.index = index,
});
} else if (mem.eql(u8, sym_name, "__tlv_bootstrap")) {
log.debug("writing threadlocal symbol '{s}'", .{sym_name});
self.tlv_bootstrap = .{
.symbol = new_sym,
.dylib_ordinal = dylib_ordinal,
.index = 0,
};
} else {
log.debug("writing lazy symbol '{s}'", .{sym_name});
const index = @intCast(u32, self.lazy_imports.items().len);
try self.lazy_imports.putNoClobber(self.allocator, key, .{
.symbol = new_sym,
.dylib_ordinal = dylib_ordinal,
.index = index,
});
}
}
const n_strx = try self.makeString("dyld_stub_binder");
const name = try self.allocator.dupe(u8, "dyld_stub_binder");
log.debug("writing nonlazy symbol 'dyld_stub_binder'", .{});
const index = @intCast(u32, self.nonlazy_imports.items().len);
try self.nonlazy_imports.putNoClobber(self.allocator, name, .{
.symbol = .{
.n_strx = n_strx,
.n_type = std.macho.N_UNDF | std.macho.N_EXT,
.n_sect = 0,
.n_desc = std.macho.REFERENCE_FLAG_UNDEFINED_NON_LAZY | std.macho.N_SYMBOL_RESOLVER,
.n_value = 0,
},
.dylib_ordinal = 1,
.index = index,
});
}
fn allocateTextSegment(self: *Zld) !void {
const seg = &self.load_commands.items[self.text_segment_cmd_index.?].Segment;
const nexterns = @intCast(u32, self.lazy_imports.items().len);
const base_vmaddr = self.load_commands.items[self.pagezero_segment_cmd_index.?].Segment.inner.vmsize;
seg.inner.fileoff = 0;
seg.inner.vmaddr = base_vmaddr;
// Set stubs and stub_helper sizes
const stubs = &seg.sections.items[self.stubs_section_index.?];
const stub_helper = &seg.sections.items[self.stub_helper_section_index.?];
stubs.size += nexterns * stubs.reserved2;
const stub_size: u4 = switch (self.arch.?) {
.x86_64 => 10,
.aarch64 => 3 * @sizeOf(u32),
else => unreachable,
};
stub_helper.size += nexterns * stub_size;
var sizeofcmds: u64 = 0;
for (self.load_commands.items) |lc| {
sizeofcmds += lc.cmdsize();
}
try self.allocateSegment(self.text_segment_cmd_index.?, @sizeOf(macho.mach_header_64) + sizeofcmds);
// Shift all sections to the back to minimize jump size between __TEXT and __DATA segments.
var min_alignment: u32 = 0;
for (seg.sections.items) |sect| {
const alignment = try math.powi(u32, 2, sect.@"align");
min_alignment = math.max(min_alignment, alignment);
}
assert(min_alignment > 0);
const last_sect_idx = seg.sections.items.len - 1;
const last_sect = seg.sections.items[last_sect_idx];
const shift: u32 = blk: {
const diff = seg.inner.filesize - last_sect.offset - last_sect.size;
const factor = @divTrunc(diff, min_alignment);
break :blk @intCast(u32, factor * min_alignment);
};
if (shift > 0) {
for (seg.sections.items) |*sect| {
sect.offset += shift;
sect.addr += shift;
}
}
}
fn allocateDataConstSegment(self: *Zld) !void {
const seg = &self.load_commands.items[self.data_const_segment_cmd_index.?].Segment;
const nonlazy = @intCast(u32, self.nonlazy_imports.items().len);
const text_seg = self.load_commands.items[self.text_segment_cmd_index.?].Segment;
seg.inner.fileoff = text_seg.inner.fileoff + text_seg.inner.filesize;
seg.inner.vmaddr = text_seg.inner.vmaddr + text_seg.inner.vmsize;
// Set got size
const got = &seg.sections.items[self.got_section_index.?];
// TODO this will require scanning the relocations at least one to work out
// the exact amount of local GOT indirections. For the time being, set some
// default value.
got.size += (max_local_got_indirections + nonlazy) * @sizeOf(u64);
try self.allocateSegment(self.data_const_segment_cmd_index.?, 0);
}
fn allocateDataSegment(self: *Zld) !void {
const seg = &self.load_commands.items[self.data_segment_cmd_index.?].Segment;
const lazy = @intCast(u32, self.lazy_imports.items().len);
const data_const_seg = self.load_commands.items[self.data_const_segment_cmd_index.?].Segment;
seg.inner.fileoff = data_const_seg.inner.fileoff + data_const_seg.inner.filesize;
seg.inner.vmaddr = data_const_seg.inner.vmaddr + data_const_seg.inner.vmsize;
// Set la_symbol_ptr and data size
const la_symbol_ptr = &seg.sections.items[self.la_symbol_ptr_section_index.?];
const data = &seg.sections.items[self.data_section_index.?];
la_symbol_ptr.size += lazy * @sizeOf(u64);
data.size += @sizeOf(u64); // TODO when do we need more?
try self.allocateSegment(self.data_segment_cmd_index.?, 0);
}
fn allocateLinkeditSegment(self: *Zld) void {
const seg = &self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment;
const data_seg = self.load_commands.items[self.data_segment_cmd_index.?].Segment;
seg.inner.fileoff = data_seg.inner.fileoff + data_seg.inner.filesize;
seg.inner.vmaddr = data_seg.inner.vmaddr + data_seg.inner.vmsize;
}
fn allocateSegment(self: *Zld, index: u16, offset: u64) !void {
const base_vmaddr = self.load_commands.items[self.pagezero_segment_cmd_index.?].Segment.inner.vmsize;
const seg = &self.load_commands.items[index].Segment;
// Allocate the sections according to their alignment at the beginning of the segment.
var start: u64 = offset;
for (seg.sections.items) |*sect| {
const alignment = try math.powi(u32, 2, sect.@"align");
const start_aligned = mem.alignForwardGeneric(u64, start, alignment);
const end_aligned = mem.alignForwardGeneric(u64, start_aligned + sect.size, alignment);
sect.offset = @intCast(u32, seg.inner.fileoff + start_aligned);
sect.addr = seg.inner.vmaddr + start_aligned;
start = end_aligned;
}
const seg_size_aligned = mem.alignForwardGeneric(u64, start, self.page_size.?);
seg.inner.filesize = seg_size_aligned;
seg.inner.vmsize = seg_size_aligned;
}
fn writeStubHelperCommon(self: *Zld) !void {
const text_segment = &self.load_commands.items[self.text_segment_cmd_index.?].Segment;
const stub_helper = &text_segment.sections.items[self.stub_helper_section_index.?];
const data_const_segment = &self.load_commands.items[self.data_const_segment_cmd_index.?].Segment;
const got = &data_const_segment.sections.items[self.got_section_index.?];
const data_segment = &self.load_commands.items[self.data_segment_cmd_index.?].Segment;
const data = &data_segment.sections.items[self.data_section_index.?];
const la_symbol_ptr = data_segment.sections.items[self.la_symbol_ptr_section_index.?];
self.stub_helper_stubs_start_off = blk: {
switch (self.arch.?) {
.x86_64 => {
const code_size = 15;
var code: [code_size]u8 = undefined;
// lea %r11, [rip + disp]
code[0] = 0x4c;
code[1] = 0x8d;
code[2] = 0x1d;
{
const target_addr = data.addr + data.size - @sizeOf(u64);
const displacement = try math.cast(u32, target_addr - stub_helper.addr - 7);
mem.writeIntLittle(u32, code[3..7], displacement);
}
// push %r11
code[7] = 0x41;
code[8] = 0x53;
// jmp [rip + disp]
code[9] = 0xff;
code[10] = 0x25;
{
const dyld_stub_binder = self.nonlazy_imports.get("dyld_stub_binder").?;
const addr = (got.addr + dyld_stub_binder.index * @sizeOf(u64));
const displacement = try math.cast(u32, addr - stub_helper.addr - code_size);
mem.writeIntLittle(u32, code[11..], displacement);
}
try self.file.?.pwriteAll(&code, stub_helper.offset);
break :blk stub_helper.offset + code_size;
},
.aarch64 => {
var code: [6 * @sizeOf(u32)]u8 = undefined;
data_blk_outer: {
const this_addr = stub_helper.addr;
const target_addr = data.addr + data.size - @sizeOf(u64);
data_blk: {
const displacement = math.cast(i21, target_addr - this_addr) catch |_| break :data_blk;
// adr x17, disp
mem.writeIntLittle(u32, code[0..4], aarch64.Instruction.adr(.x17, displacement).toU32());
// nop
mem.writeIntLittle(u32, code[4..8], aarch64.Instruction.nop().toU32());
break :data_blk_outer;
}
data_blk: {
const new_this_addr = this_addr + @sizeOf(u32);
const displacement = math.cast(i21, target_addr - new_this_addr) catch |_| break :data_blk;
// nop
mem.writeIntLittle(u32, code[0..4], aarch64.Instruction.nop().toU32());
// adr x17, disp
mem.writeIntLittle(u32, code[4..8], aarch64.Instruction.adr(.x17, displacement).toU32());
break :data_blk_outer;
}
// Jump is too big, replace adr with adrp and add.
const this_page = @intCast(i32, this_addr >> 12);
const target_page = @intCast(i32, target_addr >> 12);
const pages = @intCast(i21, target_page - this_page);
mem.writeIntLittle(u32, code[0..4], aarch64.Instruction.adrp(.x17, pages).toU32());
const narrowed = @truncate(u12, target_addr);
mem.writeIntLittle(u32, code[4..8], aarch64.Instruction.add(.x17, .x17, narrowed, false).toU32());
}
// stp x16, x17, [sp, #-16]!
code[8] = 0xf0;
code[9] = 0x47;
code[10] = 0xbf;
code[11] = 0xa9;
binder_blk_outer: {
const dyld_stub_binder = self.nonlazy_imports.get("dyld_stub_binder").?;
const this_addr = stub_helper.addr + 3 * @sizeOf(u32);
const target_addr = (got.addr + dyld_stub_binder.index * @sizeOf(u64));
binder_blk: {
const displacement = math.divExact(u64, target_addr - this_addr, 4) catch |_| break :binder_blk;
const literal = math.cast(u18, displacement) catch |_| break :binder_blk;
// ldr x16, label
mem.writeIntLittle(u32, code[12..16], aarch64.Instruction.ldr(.x16, .{
.literal = literal,
}).toU32());
// nop
mem.writeIntLittle(u32, code[16..20], aarch64.Instruction.nop().toU32());
break :binder_blk_outer;
}
binder_blk: {
const new_this_addr = this_addr + @sizeOf(u32);
const displacement = math.divExact(u64, target_addr - new_this_addr, 4) catch |_| break :binder_blk;
const literal = math.cast(u18, displacement) catch |_| break :binder_blk;
log.debug("2: disp=0x{x}, literal=0x{x}", .{ displacement, literal });
// Pad with nop to please division.
// nop
mem.writeIntLittle(u32, code[12..16], aarch64.Instruction.nop().toU32());
// ldr x16, label
mem.writeIntLittle(u32, code[16..20], aarch64.Instruction.ldr(.x16, .{
.literal = literal,
}).toU32());
break :binder_blk_outer;
}
// Use adrp followed by ldr(immediate).
const this_page = @intCast(i32, this_addr >> 12);
const target_page = @intCast(i32, target_addr >> 12);
const pages = @intCast(i21, target_page - this_page);
mem.writeIntLittle(u32, code[12..16], aarch64.Instruction.adrp(.x16, pages).toU32());
const narrowed = @truncate(u12, target_addr);
const offset = try math.divExact(u12, narrowed, 8);
mem.writeIntLittle(u32, code[16..20], aarch64.Instruction.ldr(.x16, .{
.register = .{
.rn = .x16,
.offset = aarch64.Instruction.LoadStoreOffset.imm(offset),
},
}).toU32());
}
// br x16
code[20] = 0x00;
code[21] = 0x02;
code[22] = 0x1f;
code[23] = 0xd6;
try self.file.?.pwriteAll(&code, stub_helper.offset);
break :blk stub_helper.offset + 6 * @sizeOf(u32);
},
else => unreachable,
}
};
for (self.lazy_imports.items()) |_, i| {
const index = @intCast(u32, i);
try self.writeLazySymbolPointer(index);
try self.writeStub(index);
try self.writeStubInStubHelper(index);
}
}
fn writeLazySymbolPointer(self: *Zld, index: u32) !void {
const text_segment = self.load_commands.items[self.text_segment_cmd_index.?].Segment;
const stub_helper = text_segment.sections.items[self.stub_helper_section_index.?];
const data_segment = self.load_commands.items[self.data_segment_cmd_index.?].Segment;
const la_symbol_ptr = data_segment.sections.items[self.la_symbol_ptr_section_index.?];
const stub_size: u4 = switch (self.arch.?) {
.x86_64 => 10,
.aarch64 => 3 * @sizeOf(u32),
else => unreachable,
};
const stub_off = self.stub_helper_stubs_start_off.? + index * stub_size;
const end = stub_helper.addr + stub_off - stub_helper.offset;
var buf: [@sizeOf(u64)]u8 = undefined;
mem.writeIntLittle(u64, &buf, end);
const off = la_symbol_ptr.offset + index * @sizeOf(u64);
log.debug("writing lazy symbol pointer entry 0x{x} at 0x{x}", .{ end, off });
try self.file.?.pwriteAll(&buf, off);
}
fn writeStub(self: *Zld, index: u32) !void {
const text_segment = self.load_commands.items[self.text_segment_cmd_index.?].Segment;
const stubs = text_segment.sections.items[self.stubs_section_index.?];
const data_segment = self.load_commands.items[self.data_segment_cmd_index.?].Segment;
const la_symbol_ptr = data_segment.sections.items[self.la_symbol_ptr_section_index.?];
const stub_off = stubs.offset + index * stubs.reserved2;
const stub_addr = stubs.addr + index * stubs.reserved2;
const la_ptr_addr = la_symbol_ptr.addr + index * @sizeOf(u64);
log.debug("writing stub at 0x{x}", .{stub_off});
var code = try self.allocator.alloc(u8, stubs.reserved2);
defer self.allocator.free(code);
switch (self.arch.?) {
.x86_64 => {
assert(la_ptr_addr >= stub_addr + stubs.reserved2);
const displacement = try math.cast(u32, la_ptr_addr - stub_addr - stubs.reserved2);
// jmp
code[0] = 0xff;
code[1] = 0x25;
mem.writeIntLittle(u32, code[2..][0..4], displacement);
},
.aarch64 => {
assert(la_ptr_addr >= stub_addr);
outer: {
const this_addr = stub_addr;
const target_addr = la_ptr_addr;
inner: {
const displacement = math.divExact(u64, target_addr - this_addr, 4) catch |_| break :inner;
const literal = math.cast(u18, displacement) catch |_| break :inner;
// ldr x16, literal
mem.writeIntLittle(u32, code[0..4], aarch64.Instruction.ldr(.x16, .{
.literal = literal,
}).toU32());
// nop
mem.writeIntLittle(u32, code[4..8], aarch64.Instruction.nop().toU32());
break :outer;
}
inner: {
const new_this_addr = this_addr + @sizeOf(u32);
const displacement = math.divExact(u64, target_addr - new_this_addr, 4) catch |_| break :inner;
const literal = math.cast(u18, displacement) catch |_| break :inner;
// nop
mem.writeIntLittle(u32, code[0..4], aarch64.Instruction.nop().toU32());
// ldr x16, literal
mem.writeIntLittle(u32, code[4..8], aarch64.Instruction.ldr(.x16, .{
.literal = literal,
}).toU32());
break :outer;
}
// Use adrp followed by ldr(immediate).
const this_page = @intCast(i32, this_addr >> 12);
const target_page = @intCast(i32, target_addr >> 12);
const pages = @intCast(i21, target_page - this_page);
mem.writeIntLittle(u32, code[0..4], aarch64.Instruction.adrp(.x16, pages).toU32());
const narrowed = @truncate(u12, target_addr);
const offset = try math.divExact(u12, narrowed, 8);
mem.writeIntLittle(u32, code[4..8], aarch64.Instruction.ldr(.x16, .{
.register = .{
.rn = .x16,
.offset = aarch64.Instruction.LoadStoreOffset.imm(offset),
},
}).toU32());
}
// br x16
mem.writeIntLittle(u32, code[8..12], aarch64.Instruction.br(.x16).toU32());
},
else => unreachable,
}
try self.file.?.pwriteAll(code, stub_off);
}
fn writeStubInStubHelper(self: *Zld, index: u32) !void {
const text_segment = self.load_commands.items[self.text_segment_cmd_index.?].Segment;
const stub_helper = text_segment.sections.items[self.stub_helper_section_index.?];
const stub_size: u4 = switch (self.arch.?) {
.x86_64 => 10,
.aarch64 => 3 * @sizeOf(u32),
else => unreachable,
};
const stub_off = self.stub_helper_stubs_start_off.? + index * stub_size;
var code = try self.allocator.alloc(u8, stub_size);
defer self.allocator.free(code);
switch (self.arch.?) {
.x86_64 => {
const displacement = try math.cast(
i32,
@intCast(i64, stub_helper.offset) - @intCast(i64, stub_off) - stub_size,
);
// pushq
code[0] = 0x68;
mem.writeIntLittle(u32, code[1..][0..4], 0x0); // Just a placeholder populated in `populateLazyBindOffsetsInStubHelper`.
// jmpq
code[5] = 0xe9;
mem.writeIntLittle(u32, code[6..][0..4], @bitCast(u32, displacement));
},
.aarch64 => {
const displacement = try math.cast(i28, @intCast(i64, stub_helper.offset) - @intCast(i64, stub_off) - 4);
const literal = @divExact(stub_size - @sizeOf(u32), 4);
// ldr w16, literal
mem.writeIntLittle(u32, code[0..4], aarch64.Instruction.ldr(.w16, .{
.literal = literal,
}).toU32());
// b disp
mem.writeIntLittle(u32, code[4..8], aarch64.Instruction.b(displacement).toU32());
mem.writeIntLittle(u32, code[8..12], 0x0); // Just a placeholder populated in `populateLazyBindOffsetsInStubHelper`.
},
else => unreachable,
}
try self.file.?.pwriteAll(code, stub_off);
}
fn resolveSymbols(self: *Zld) !void {
for (self.objects.items) |object, object_id| {
const seg = object.load_commands.items[object.segment_cmd_index.?].Segment;
log.debug("\n\n", .{});
log.debug("resolving symbols in {s}", .{object.name});
for (object.symtab.items) |sym| {
if (isImport(&sym)) continue;
const sym_name = object.getString(sym.n_strx);
const out_name = try self.allocator.dupe(u8, sym_name);
const locs = try self.locals.getOrPut(self.allocator, out_name);
defer {
if (locs.found_existing) self.allocator.free(out_name);
}
if (!locs.found_existing) {
locs.entry.value = .{};
}
const tt: Symbol.Type = blk: {
if (isLocal(&sym)) {
break :blk .Local;
} else if (isWeakDef(&sym)) {
break :blk .WeakGlobal;
} else {
break :blk .Global;
}
};
if (tt == .Global) {
for (locs.entry.value.items) |ss| {
if (ss.tt == .Global) {
log.debug("symbol already defined '{s}'", .{sym_name});
continue;
// log.err("symbol '{s}' defined multiple times: {}", .{ sym_name, sym });
// return error.MultipleSymbolDefinitions;
}
}
}
const source_sect_id = sym.n_sect - 1;
const target_mapping = self.mappings.get(.{
.object_id = @intCast(u16, object_id),
.source_sect_id = source_sect_id,
}) orelse {
if (self.unhandled_sections.get(.{
.object_id = @intCast(u16, object_id),
.source_sect_id = source_sect_id,
}) != null) continue;
log.err("section not mapped for symbol '{s}': {}", .{ sym_name, sym });
return error.SectionNotMappedForSymbol;
};
const source_sect = seg.sections.items[source_sect_id];
const target_seg = self.load_commands.items[target_mapping.target_seg_id].Segment;
const target_sect = target_seg.sections.items[target_mapping.target_sect_id];
const target_addr = target_sect.addr + target_mapping.offset;
const n_value = sym.n_value - source_sect.addr + target_addr;
log.debug("resolving '{s}':{} as {s} symbol at 0x{x}", .{ sym_name, sym, tt, n_value });
// TODO there might be a more generic way of doing this.
var n_sect: u16 = 0;
for (self.load_commands.items) |cmd, cmd_id| {
if (cmd != .Segment) break;
if (cmd_id == target_mapping.target_seg_id) {
n_sect += target_mapping.target_sect_id + 1;
break;
}
n_sect += @intCast(u16, cmd.Segment.sections.items.len);
}
const n_strx = try self.makeString(sym_name);
try locs.entry.value.append(self.allocator, .{
.inner = .{
.n_strx = n_strx,
.n_value = n_value,
.n_type = macho.N_SECT,
.n_desc = sym.n_desc,
.n_sect = @intCast(u8, n_sect),
},
.tt = tt,
.object_id = @intCast(u16, object_id),
});
}
}
}
fn doRelocs(self: *Zld) !void {
for (self.objects.items) |object, object_id| {
log.debug("\n\n", .{});
log.debug("relocating object {s}", .{object.name});
const seg = object.load_commands.items[object.segment_cmd_index.?].Segment;
for (seg.sections.items) |sect, source_sect_id| {
const segname = parseName(§.segname);
const sectname = parseName(§.sectname);
var code = try self.allocator.alloc(u8, sect.size);
_ = try object.file.preadAll(code, sect.offset);
defer self.allocator.free(code);
// Parse relocs (if any)
var raw_relocs = try self.allocator.alloc(u8, @sizeOf(macho.relocation_info) * sect.nreloc);
defer self.allocator.free(raw_relocs);
_ = try object.file.preadAll(raw_relocs, sect.reloff);
const relocs = mem.bytesAsSlice(macho.relocation_info, raw_relocs);
// Get mapping
const target_mapping = self.mappings.get(.{
.object_id = @intCast(u16, object_id),
.source_sect_id = @intCast(u16, source_sect_id),
}) orelse {
log.debug("no mapping for {s},{s}; skipping", .{ segname, sectname });
continue;
};
const target_seg = self.load_commands.items[target_mapping.target_seg_id].Segment;
const target_sect = target_seg.sections.items[target_mapping.target_sect_id];
const target_sect_addr = target_sect.addr + target_mapping.offset;
const target_sect_off = target_sect.offset + target_mapping.offset;
var addend: ?u64 = null;
var sub: ?i64 = null;
for (relocs) |rel| {
const off = @intCast(u32, rel.r_address);
const this_addr = target_sect_addr + off;
switch (self.arch.?) {
.aarch64 => {
const rel_type = @intToEnum(macho.reloc_type_arm64, rel.r_type);
log.debug("{s}", .{rel_type});
log.debug(" | source address 0x{x}", .{this_addr});
log.debug(" | offset 0x{x}", .{off});
if (rel_type == .ARM64_RELOC_ADDEND) {
addend = rel.r_symbolnum;
log.debug(" | calculated addend = 0x{x}", .{addend});
// TODO followed by either PAGE21 or PAGEOFF12 only.
continue;
}
},
.x86_64 => {
const rel_type = @intToEnum(macho.reloc_type_x86_64, rel.r_type);
log.debug("{s}", .{rel_type});
log.debug(" | source address 0x{x}", .{this_addr});
log.debug(" | offset 0x{x}", .{off});
},
else => {},
}
const target_addr = try self.relocTargetAddr(@intCast(u16, object_id), rel);
log.debug(" | target address 0x{x}", .{target_addr});
if (rel.r_extern == 1) {
const target_symname = object.getString(object.symtab.items[rel.r_symbolnum].n_strx);
log.debug(" | target symbol '{s}'", .{target_symname});
} else {
const target_sectname = seg.sections.items[rel.r_symbolnum - 1].sectname;
log.debug(" | target section '{s}'", .{parseName(&target_sectname)});
}
switch (self.arch.?) {
.x86_64 => {
const rel_type = @intToEnum(macho.reloc_type_x86_64, rel.r_type);
switch (rel_type) {
.X86_64_RELOC_BRANCH => {
assert(rel.r_length == 2);
const inst = code[off..][0..4];
const displacement = @bitCast(u32, @intCast(i32, @intCast(i64, target_addr) - @intCast(i64, this_addr) - 4));
mem.writeIntLittle(u32, inst, displacement);
},
.X86_64_RELOC_GOT_LOAD => {
assert(rel.r_length == 2);
const inst = code[off..][0..4];
const displacement = @bitCast(u32, @intCast(i32, @intCast(i64, target_addr) - @intCast(i64, this_addr) - 4));
blk: {
const data_const_seg = self.load_commands.items[self.data_const_segment_cmd_index.?].Segment;
const got = data_const_seg.sections.items[self.got_section_index.?];
if (got.addr <= target_addr and target_addr < got.addr + got.size) break :blk;
log.debug(" | rewriting to leaq", .{});
code[off - 2] = 0x8d;
}
mem.writeIntLittle(u32, inst, displacement);
},
.X86_64_RELOC_GOT => {
assert(rel.r_length == 2);
// TODO Instead of referring to the target symbol directly, we refer to it
// indirectly via GOT. Getting actual target address should be done in the
// helper relocTargetAddr function rather than here.
const sym = object.symtab.items[rel.r_symbolnum];
const sym_name = try self.allocator.dupe(u8, object.getString(sym.n_strx));
const res = try self.nonlazy_pointers.getOrPut(self.allocator, sym_name);
defer if (res.found_existing) self.allocator.free(sym_name);
const data_const_seg = self.load_commands.items[self.data_const_segment_cmd_index.?].Segment;
const got = data_const_seg.sections.items[self.got_section_index.?];
if (!res.found_existing) {
const index = @intCast(u32, self.nonlazy_pointers.items().len) - 1;
assert(index < max_local_got_indirections); // TODO This is just a temp solution.
res.entry.value = .{
.index = index,
.target_addr = target_addr,
};
var buf: [@sizeOf(u64)]u8 = undefined;
mem.writeIntLittle(u64, &buf, target_addr);
const got_offset = got.offset + (index + self.nonlazy_imports.items().len) * @sizeOf(u64);
log.debug(" | GOT off 0x{x}", .{got.offset});
log.debug(" | writing GOT entry 0x{x} at 0x{x}", .{ target_addr, got_offset });
try self.file.?.pwriteAll(&buf, got_offset);
}
const index = res.entry.value.index + self.nonlazy_imports.items().len;
const actual_target_addr = got.addr + index * @sizeOf(u64);
log.debug(" | GOT addr 0x{x}", .{got.addr});
log.debug(" | actual target address in GOT 0x{x}", .{actual_target_addr});
const inst = code[off..][0..4];
const displacement = @bitCast(u32, @intCast(i32, @intCast(i64, actual_target_addr) - @intCast(i64, this_addr) - 4));
mem.writeIntLittle(u32, inst, displacement);
},
.X86_64_RELOC_TLV => {
assert(rel.r_length == 2);
// We need to rewrite the opcode from movq to leaq.
code[off - 2] = 0x8d;
// Add displacement.
const inst = code[off..][0..4];
const displacement = @bitCast(u32, @intCast(i32, @intCast(i64, target_addr) - @intCast(i64, this_addr) - 4));
mem.writeIntLittle(u32, inst, displacement);
},
.X86_64_RELOC_SIGNED,
.X86_64_RELOC_SIGNED_1,
.X86_64_RELOC_SIGNED_2,
.X86_64_RELOC_SIGNED_4,
=> {
assert(rel.r_length == 2);
const inst = code[off..][0..4];
const offset = @intCast(i64, mem.readIntLittle(i32, inst));
log.debug(" | calculated addend 0x{x}", .{offset});
const actual_target_addr = blk: {
if (rel.r_extern == 1) {
break :blk @intCast(i64, target_addr) + offset;
} else {
const correction: i4 = switch (rel_type) {
.X86_64_RELOC_SIGNED => 0,
.X86_64_RELOC_SIGNED_1 => 1,
.X86_64_RELOC_SIGNED_2 => 2,
.X86_64_RELOC_SIGNED_4 => 4,
else => unreachable,
};
log.debug(" | calculated correction 0x{x}", .{correction});
// The value encoded in the instruction is a displacement - 4 - correction.
// To obtain the adjusted target address in the final binary, we need
// calculate the original target address within the object file, establish
// what the offset from the original target section was, and apply this
// offset to the resultant target section with this relocated binary.
const orig_sect_id = @intCast(u16, rel.r_symbolnum - 1);
const target_map = self.mappings.get(.{
.object_id = @intCast(u16, object_id),
.source_sect_id = orig_sect_id,
}) orelse unreachable;
const orig_seg = object.load_commands.items[object.segment_cmd_index.?].Segment;
const orig_sect = orig_seg.sections.items[orig_sect_id];
const orig_offset = off + offset + 4 + correction - @intCast(i64, orig_sect.addr);
log.debug(" | original offset 0x{x}", .{orig_offset});
const adjusted = @intCast(i64, target_addr) + orig_offset;
log.debug(" | adjusted target address 0x{x}", .{adjusted});
break :blk adjusted - correction;
}
};
const result = actual_target_addr - @intCast(i64, this_addr) - 4;
const displacement = @bitCast(u32, @intCast(i32, result));
mem.writeIntLittle(u32, inst, displacement);
},
.X86_64_RELOC_SUBTRACTOR => {
sub = @intCast(i64, target_addr);
},
.X86_64_RELOC_UNSIGNED => {
switch (rel.r_length) {
3 => {
const inst = code[off..][0..8];
const offset = mem.readIntLittle(i64, inst);
const result = outer: {
if (rel.r_extern == 1) {
log.debug(" | calculated addend 0x{x}", .{offset});
if (sub) |s| {
break :outer @intCast(i64, target_addr) - s + offset;
} else {
break :outer @intCast(i64, target_addr) + offset;
}
} else {
// The value encoded in the instruction is an absolute offset
// from the start of MachO header to the target address in the
// object file. To extract the address, we calculate the offset from
// the beginning of the source section to the address, and apply it to
// the target address value.
const orig_sect_id = @intCast(u16, rel.r_symbolnum - 1);
const target_map = self.mappings.get(.{
.object_id = @intCast(u16, object_id),
.source_sect_id = orig_sect_id,
}) orelse unreachable;
const orig_seg = object.load_commands.items[object.segment_cmd_index.?].Segment;
const orig_sect = orig_seg.sections.items[orig_sect_id];
const orig_offset = offset - @intCast(i64, orig_sect.addr);
const actual_target_addr = inner: {
if (sub) |s| {
break :inner @intCast(i64, target_addr) - s + orig_offset;
} else {
break :inner @intCast(i64, target_addr) + orig_offset;
}
};
log.debug(" | adjusted target address 0x{x}", .{actual_target_addr});
break :outer actual_target_addr;
}
};
mem.writeIntLittle(u64, inst, @bitCast(u64, result));
sub = null;
rebases: {
var hit: bool = false;
if (target_mapping.target_seg_id == self.data_segment_cmd_index.?) {
if (self.data_section_index) |index| {
if (index == target_mapping.target_sect_id) hit = true;
}
}
if (target_mapping.target_seg_id == self.data_const_segment_cmd_index.?) {
if (self.data_const_section_index) |index| {
if (index == target_mapping.target_sect_id) hit = true;
}
}
if (!hit) break :rebases;
try self.local_rebases.append(self.allocator, .{
.offset = this_addr - target_seg.inner.vmaddr,
.segment_id = target_mapping.target_seg_id,
});
}
// TLV is handled via a separate offset mechanism.
// Calculate the offset to the initializer.
if (target_sect.flags == macho.S_THREAD_LOCAL_VARIABLES) tlv: {
assert(rel.r_extern == 1);
const sym = object.symtab.items[rel.r_symbolnum];
if (isImport(&sym)) break :tlv;
const base_addr = blk: {
if (self.tlv_data_section_index) |index| {
const tlv_data = target_seg.sections.items[index];
break :blk tlv_data.addr;
} else {
const tlv_bss = target_seg.sections.items[self.tlv_bss_section_index.?];
break :blk tlv_bss.addr;
}
};
// Since we require TLV data to always preceed TLV bss section, we calculate
// offsets wrt to the former if it is defined; otherwise, wrt to the latter.
try self.threadlocal_offsets.append(self.allocator, target_addr - base_addr);
}
},
2 => {
const inst = code[off..][0..4];
const offset = mem.readIntLittle(i32, inst);
log.debug(" | calculated addend 0x{x}", .{offset});
const result = if (sub) |s|
@intCast(i64, target_addr) - s + offset
else
@intCast(i64, target_addr) + offset;
mem.writeIntLittle(u32, inst, @truncate(u32, @bitCast(u64, result)));
sub = null;
},
else => |len| {
log.err("unexpected relocation length 0x{x}", .{len});
return error.UnexpectedRelocationLength;
},
}
},
}
},
.aarch64 => {
const rel_type = @intToEnum(macho.reloc_type_arm64, rel.r_type);
switch (rel_type) {
.ARM64_RELOC_BRANCH26 => {
assert(rel.r_length == 2);
const inst = code[off..][0..4];
const displacement = @intCast(
i28,
@intCast(i64, target_addr) - @intCast(i64, this_addr),
);
var parsed = mem.bytesAsValue(
meta.TagPayload(
aarch64.Instruction,
aarch64.Instruction.UnconditionalBranchImmediate,
),
inst,
);
parsed.imm26 = @truncate(u26, @bitCast(u28, displacement) >> 2);
},
.ARM64_RELOC_PAGE21,
.ARM64_RELOC_GOT_LOAD_PAGE21,
.ARM64_RELOC_TLVP_LOAD_PAGE21,
=> {
assert(rel.r_length == 2);
const inst = code[off..][0..4];
const ta = if (addend) |a| target_addr + a else target_addr;
const this_page = @intCast(i32, this_addr >> 12);
const target_page = @intCast(i32, ta >> 12);
const pages = @bitCast(u21, @intCast(i21, target_page - this_page));
log.debug(" | moving by {} pages", .{pages});
var parsed = mem.bytesAsValue(
meta.TagPayload(
aarch64.Instruction,
aarch64.Instruction.PCRelativeAddress,
),
inst,
);
parsed.immhi = @truncate(u19, pages >> 2);
parsed.immlo = @truncate(u2, pages);
addend = null;
},
.ARM64_RELOC_PAGEOFF12,
.ARM64_RELOC_GOT_LOAD_PAGEOFF12,
=> {
const inst = code[off..][0..4];
if (aarch64IsArithmetic(inst)) {
log.debug(" | detected ADD opcode", .{});
// add
var parsed = mem.bytesAsValue(
meta.TagPayload(
aarch64.Instruction,
aarch64.Instruction.AddSubtractImmediate,
),
inst,
);
const ta = if (addend) |a| target_addr + a else target_addr;
const narrowed = @truncate(u12, ta);
parsed.imm12 = narrowed;
} else {
log.debug(" | detected LDR/STR opcode", .{});
// ldr/str
var parsed = mem.bytesAsValue(
meta.TagPayload(
aarch64.Instruction,
aarch64.Instruction.LoadStoreRegister,
),
inst,
);
const ta = if (addend) |a| target_addr + a else target_addr;
const narrowed = @truncate(u12, ta);
log.debug(" | narrowed 0x{x}", .{narrowed});
log.debug(" | parsed.size 0x{x}", .{parsed.size});
if (rel_type == .ARM64_RELOC_GOT_LOAD_PAGEOFF12) blk: {
const data_const_seg = self.load_commands.items[self.data_const_segment_cmd_index.?].Segment;
const got = data_const_seg.sections.items[self.got_section_index.?];
if (got.addr <= target_addr and target_addr < got.addr + got.size) break :blk;
log.debug(" | rewriting to add", .{});
mem.writeIntLittle(u32, inst, aarch64.Instruction.add(
@intToEnum(aarch64.Register, parsed.rt),
@intToEnum(aarch64.Register, parsed.rn),
narrowed,
false,
).toU32());
addend = null;
continue;
}
const offset: u12 = blk: {
if (parsed.size == 0) {
if (parsed.v == 1) {
// 128-bit SIMD is scaled by 16.
break :blk try math.divExact(u12, narrowed, 16);
}
// Otherwise, 8-bit SIMD or ldrb.
break :blk narrowed;
} else {
const denom: u4 = try math.powi(u4, 2, parsed.size);
break :blk try math.divExact(u12, narrowed, denom);
}
};
parsed.offset = offset;
}
addend = null;
},
.ARM64_RELOC_TLVP_LOAD_PAGEOFF12 => {
const RegInfo = struct {
rd: u5,
rn: u5,
size: u1,
};
const inst = code[off..][0..4];
const parsed: RegInfo = blk: {
if (aarch64IsArithmetic(inst)) {
const curr = mem.bytesAsValue(
meta.TagPayload(
aarch64.Instruction,
aarch64.Instruction.AddSubtractImmediate,
),
inst,
);
break :blk .{ .rd = curr.rd, .rn = curr.rn, .size = curr.sf };
} else {
const curr = mem.bytesAsValue(
meta.TagPayload(
aarch64.Instruction,
aarch64.Instruction.LoadStoreRegister,
),
inst,
);
break :blk .{ .rd = curr.rt, .rn = curr.rn, .size = @truncate(u1, curr.size) };
}
};
const ta = if (addend) |a| target_addr + a else target_addr;
const narrowed = @truncate(u12, ta);
log.debug(" | rewriting TLV access to ADD opcode", .{});
// For TLV, we always generate an add instruction.
mem.writeIntLittle(u32, inst, aarch64.Instruction.add(
@intToEnum(aarch64.Register, parsed.rd),
@intToEnum(aarch64.Register, parsed.rn),
narrowed,
false,
).toU32());
},
.ARM64_RELOC_SUBTRACTOR => {
sub = @intCast(i64, target_addr);
},
.ARM64_RELOC_UNSIGNED => {
switch (rel.r_length) {
3 => {
const inst = code[off..][0..8];
const offset = mem.readIntLittle(i64, inst);
log.debug(" | calculated addend 0x{x}", .{offset});
const result = if (sub) |s|
@intCast(i64, target_addr) - s + offset
else
@intCast(i64, target_addr) + offset;
mem.writeIntLittle(u64, inst, @bitCast(u64, result));
sub = null;
rebases: {
var hit: bool = false;
if (target_mapping.target_seg_id == self.data_segment_cmd_index.?) {
if (self.data_section_index) |index| {
if (index == target_mapping.target_sect_id) hit = true;
}
}
if (target_mapping.target_seg_id == self.data_const_segment_cmd_index.?) {
if (self.data_const_section_index) |index| {
if (index == target_mapping.target_sect_id) hit = true;
}
}
if (!hit) break :rebases;
try self.local_rebases.append(self.allocator, .{
.offset = this_addr - target_seg.inner.vmaddr,
.segment_id = target_mapping.target_seg_id,
});
}
// TLV is handled via a separate offset mechanism.
// Calculate the offset to the initializer.
if (target_sect.flags == macho.S_THREAD_LOCAL_VARIABLES) tlv: {
assert(rel.r_extern == 1);
const sym = object.symtab.items[rel.r_symbolnum];
if (isImport(&sym)) break :tlv;
const base_addr = blk: {
if (self.tlv_data_section_index) |index| {
const tlv_data = target_seg.sections.items[index];
break :blk tlv_data.addr;
} else {
const tlv_bss = target_seg.sections.items[self.tlv_bss_section_index.?];
break :blk tlv_bss.addr;
}
};
// Since we require TLV data to always preceed TLV bss section, we calculate
// offsets wrt to the former if it is defined; otherwise, wrt to the latter.
try self.threadlocal_offsets.append(self.allocator, target_addr - base_addr);
}
},
2 => {
const inst = code[off..][0..4];
const offset = mem.readIntLittle(i32, inst);
log.debug(" | calculated addend 0x{x}", .{offset});
const result = if (sub) |s|
@intCast(i64, target_addr) - s + offset
else
@intCast(i64, target_addr) + offset;
mem.writeIntLittle(u32, inst, @truncate(u32, @bitCast(u64, result)));
sub = null;
},
else => |len| {
log.err("unexpected relocation length 0x{x}", .{len});
return error.UnexpectedRelocationLength;
},
}
},
.ARM64_RELOC_POINTER_TO_GOT => return error.TODOArm64RelocPointerToGot,
else => unreachable,
}
},
else => unreachable,
}
}
log.debug("writing contents of '{s},{s}' section from '{s}' from 0x{x} to 0x{x}", .{
segname,
sectname,
object.name,
target_sect_off,
target_sect_off + code.len,
});
if (target_sect.flags == macho.S_ZEROFILL or
target_sect.flags == macho.S_THREAD_LOCAL_ZEROFILL or
target_sect.flags == macho.S_THREAD_LOCAL_VARIABLES)
{
log.debug("zeroing out '{s},{s}' from 0x{x} to 0x{x}", .{
parseName(&target_sect.segname),
parseName(&target_sect.sectname),
target_sect_off,
target_sect_off + code.len,
});
// Zero-out the space
var zeroes = try self.allocator.alloc(u8, code.len);
defer self.allocator.free(zeroes);
mem.set(u8, zeroes, 0);
try self.file.?.pwriteAll(zeroes, target_sect_off);
} else {
try self.file.?.pwriteAll(code, target_sect_off);
}
}
}
}
fn relocTargetAddr(self: *Zld, object_id: u16, rel: macho.relocation_info) !u64 {
const object = self.objects.items[object_id];
const seg = object.load_commands.items[object.segment_cmd_index.?].Segment;
const target_addr = blk: {
if (rel.r_extern == 1) {
const sym = object.symtab.items[rel.r_symbolnum];
if (isLocal(&sym) or isExport(&sym)) {
// Relocate using section offsets only.
const target_mapping = self.mappings.get(.{
.object_id = object_id,
.source_sect_id = sym.n_sect - 1,
}) orelse unreachable;
const source_sect = seg.sections.items[target_mapping.source_sect_id];
const target_seg = self.load_commands.items[target_mapping.target_seg_id].Segment;
const target_sect = target_seg.sections.items[target_mapping.target_sect_id];
const target_sect_addr = target_sect.addr + target_mapping.offset;
log.debug(" | symbol local to object", .{});
break :blk target_sect_addr + sym.n_value - source_sect.addr;
} else if (isImport(&sym)) {
// Relocate to either the artifact's local symbol, or an import from
// shared library.
const sym_name = object.getString(sym.n_strx);
if (self.locals.get(sym_name)) |locs| {
var n_value: ?u64 = null;
for (locs.items) |loc| {
switch (loc.tt) {
.Global => {
n_value = loc.inner.n_value;
break;
},
.WeakGlobal => {
n_value = loc.inner.n_value;
},
.Local => {},
}
}
if (n_value) |v| {
break :blk v;
}
log.err("local symbol export '{s}' not found", .{sym_name});
return error.LocalSymbolExportNotFound;
} else if (self.lazy_imports.get(sym_name)) |ext| {
const segment = self.load_commands.items[self.text_segment_cmd_index.?].Segment;
const stubs = segment.sections.items[self.stubs_section_index.?];
break :blk stubs.addr + ext.index * stubs.reserved2;
} else if (self.nonlazy_imports.get(sym_name)) |ext| {
const segment = self.load_commands.items[self.data_const_segment_cmd_index.?].Segment;
const got = segment.sections.items[self.got_section_index.?];
break :blk got.addr + ext.index * @sizeOf(u64);
} else if (mem.eql(u8, sym_name, "__tlv_bootstrap")) {
const segment = self.load_commands.items[self.data_segment_cmd_index.?].Segment;
const tlv = segment.sections.items[self.tlv_section_index.?];
break :blk tlv.addr + self.tlv_bootstrap.?.index * @sizeOf(u64);
} else {
log.err("failed to resolve symbol '{s}' as a relocation target", .{sym_name});
return error.FailedToResolveRelocationTarget;
}
} else {
log.err("unexpected symbol {}, {s}", .{ sym, object.getString(sym.n_strx) });
return error.UnexpectedSymbolWhenRelocating;
}
} else {
// TODO I think we need to reparse the relocation_info as scattered_relocation_info
// here to get the actual section plus offset into that section of the relocated
// symbol. Unless the fine-grained location is encoded within the cell in the code
// buffer?
const target_mapping = self.mappings.get(.{
.object_id = object_id,
.source_sect_id = @intCast(u16, rel.r_symbolnum - 1),
}) orelse unreachable;
const target_seg = self.load_commands.items[target_mapping.target_seg_id].Segment;
const target_sect = target_seg.sections.items[target_mapping.target_sect_id];
break :blk target_sect.addr + target_mapping.offset;
}
};
return target_addr;
}
fn populateMetadata(self: *Zld) !void {
if (self.pagezero_segment_cmd_index == null) {
self.pagezero_segment_cmd_index = @intCast(u16, self.load_commands.items.len);
try self.load_commands.append(self.allocator, .{
.Segment = SegmentCommand.empty(.{
.cmd = macho.LC_SEGMENT_64,
.cmdsize = @sizeOf(macho.segment_command_64),
.segname = makeStaticString("__PAGEZERO"),
.vmaddr = 0,
.vmsize = 0x100000000, // size always set to 4GB
.fileoff = 0,
.filesize = 0,
.maxprot = 0,
.initprot = 0,
.nsects = 0,
.flags = 0,
}),
});
}
if (self.text_segment_cmd_index == null) {
self.text_segment_cmd_index = @intCast(u16, self.load_commands.items.len);
try self.load_commands.append(self.allocator, .{
.Segment = SegmentCommand.empty(.{
.cmd = macho.LC_SEGMENT_64,
.cmdsize = @sizeOf(macho.segment_command_64),
.segname = makeStaticString("__TEXT"),
.vmaddr = 0x100000000, // always starts at 4GB
.vmsize = 0,
.fileoff = 0,
.filesize = 0,
.maxprot = macho.VM_PROT_READ | macho.VM_PROT_EXECUTE,
.initprot = macho.VM_PROT_READ | macho.VM_PROT_EXECUTE,
.nsects = 0,
.flags = 0,
}),
});
}
if (self.text_section_index == null) {
const text_seg = &self.load_commands.items[self.text_segment_cmd_index.?].Segment;
self.text_section_index = @intCast(u16, text_seg.sections.items.len);
const alignment: u2 = switch (self.arch.?) {
.x86_64 => 0,
.aarch64 => 2,
else => unreachable, // unhandled architecture type
};
try text_seg.addSection(self.allocator, .{
.sectname = makeStaticString("__text"),
.segname = makeStaticString("__TEXT"),
.addr = 0,
.size = 0,
.offset = 0,
.@"align" = alignment,
.reloff = 0,
.nreloc = 0,
.flags = macho.S_REGULAR | macho.S_ATTR_PURE_INSTRUCTIONS | macho.S_ATTR_SOME_INSTRUCTIONS,
.reserved1 = 0,
.reserved2 = 0,
.reserved3 = 0,
});
}
if (self.stubs_section_index == null) {
const text_seg = &self.load_commands.items[self.text_segment_cmd_index.?].Segment;
self.stubs_section_index = @intCast(u16, text_seg.sections.items.len);
const alignment: u2 = switch (self.arch.?) {
.x86_64 => 0,
.aarch64 => 2,
else => unreachable, // unhandled architecture type
};
const stub_size: u4 = switch (self.arch.?) {
.x86_64 => 6,
.aarch64 => 3 * @sizeOf(u32),
else => unreachable, // unhandled architecture type
};
try text_seg.addSection(self.allocator, .{
.sectname = makeStaticString("__stubs"),
.segname = makeStaticString("__TEXT"),
.addr = 0,
.size = 0,
.offset = 0,
.@"align" = alignment,
.reloff = 0,
.nreloc = 0,
.flags = macho.S_SYMBOL_STUBS | macho.S_ATTR_PURE_INSTRUCTIONS | macho.S_ATTR_SOME_INSTRUCTIONS,
.reserved1 = 0,
.reserved2 = stub_size,
.reserved3 = 0,
});
}
if (self.stub_helper_section_index == null) {
const text_seg = &self.load_commands.items[self.text_segment_cmd_index.?].Segment;
self.stub_helper_section_index = @intCast(u16, text_seg.sections.items.len);
const alignment: u2 = switch (self.arch.?) {
.x86_64 => 0,
.aarch64 => 2,
else => unreachable, // unhandled architecture type
};
const stub_helper_size: u6 = switch (self.arch.?) {
.x86_64 => 15,
.aarch64 => 6 * @sizeOf(u32),
else => unreachable,
};
try text_seg.addSection(self.allocator, .{
.sectname = makeStaticString("__stub_helper"),
.segname = makeStaticString("__TEXT"),
.addr = 0,
.size = stub_helper_size,
.offset = 0,
.@"align" = alignment,
.reloff = 0,
.nreloc = 0,
.flags = macho.S_REGULAR | macho.S_ATTR_PURE_INSTRUCTIONS | macho.S_ATTR_SOME_INSTRUCTIONS,
.reserved1 = 0,
.reserved2 = 0,
.reserved3 = 0,
});
}
if (self.data_const_segment_cmd_index == null) {
self.data_const_segment_cmd_index = @intCast(u16, self.load_commands.items.len);
try self.load_commands.append(self.allocator, .{
.Segment = SegmentCommand.empty(.{
.cmd = macho.LC_SEGMENT_64,
.cmdsize = @sizeOf(macho.segment_command_64),
.segname = makeStaticString("__DATA_CONST"),
.vmaddr = 0,
.vmsize = 0,
.fileoff = 0,
.filesize = 0,
.maxprot = macho.VM_PROT_READ | macho.VM_PROT_WRITE,
.initprot = macho.VM_PROT_READ | macho.VM_PROT_WRITE,
.nsects = 0,
.flags = 0,
}),
});
}
if (self.got_section_index == null) {
const data_const_seg = &self.load_commands.items[self.data_const_segment_cmd_index.?].Segment;
self.got_section_index = @intCast(u16, data_const_seg.sections.items.len);
try data_const_seg.addSection(self.allocator, .{
.sectname = makeStaticString("__got"),
.segname = makeStaticString("__DATA_CONST"),
.addr = 0,
.size = 0,
.offset = 0,
.@"align" = 3, // 2^3 = @sizeOf(u64)
.reloff = 0,
.nreloc = 0,
.flags = macho.S_NON_LAZY_SYMBOL_POINTERS,
.reserved1 = 0,
.reserved2 = 0,
.reserved3 = 0,
});
}
if (self.data_segment_cmd_index == null) {
self.data_segment_cmd_index = @intCast(u16, self.load_commands.items.len);
try self.load_commands.append(self.allocator, .{
.Segment = SegmentCommand.empty(.{
.cmd = macho.LC_SEGMENT_64,
.cmdsize = @sizeOf(macho.segment_command_64),
.segname = makeStaticString("__DATA"),
.vmaddr = 0,
.vmsize = 0,
.fileoff = 0,
.filesize = 0,
.maxprot = macho.VM_PROT_READ | macho.VM_PROT_WRITE,
.initprot = macho.VM_PROT_READ | macho.VM_PROT_WRITE,
.nsects = 0,
.flags = 0,
}),
});
}
if (self.la_symbol_ptr_section_index == null) {
const data_seg = &self.load_commands.items[self.data_segment_cmd_index.?].Segment;
self.la_symbol_ptr_section_index = @intCast(u16, data_seg.sections.items.len);
try data_seg.addSection(self.allocator, .{
.sectname = makeStaticString("__la_symbol_ptr"),
.segname = makeStaticString("__DATA"),
.addr = 0,
.size = 0,
.offset = 0,
.@"align" = 3, // 2^3 = @sizeOf(u64)
.reloff = 0,
.nreloc = 0,
.flags = macho.S_LAZY_SYMBOL_POINTERS,
.reserved1 = 0,
.reserved2 = 0,
.reserved3 = 0,
});
}
if (self.data_section_index == null) {
const data_seg = &self.load_commands.items[self.data_segment_cmd_index.?].Segment;
self.data_section_index = @intCast(u16, data_seg.sections.items.len);
try data_seg.addSection(self.allocator, .{
.sectname = makeStaticString("__data"),
.segname = makeStaticString("__DATA"),
.addr = 0,
.size = 0,
.offset = 0,
.@"align" = 3, // 2^3 = @sizeOf(u64)
.reloff = 0,
.nreloc = 0,
.flags = macho.S_REGULAR,
.reserved1 = 0,
.reserved2 = 0,
.reserved3 = 0,
});
}
if (self.linkedit_segment_cmd_index == null) {
self.linkedit_segment_cmd_index = @intCast(u16, self.load_commands.items.len);
try self.load_commands.append(self.allocator, .{
.Segment = SegmentCommand.empty(.{
.cmd = macho.LC_SEGMENT_64,
.cmdsize = @sizeOf(macho.segment_command_64),
.segname = makeStaticString("__LINKEDIT"),
.vmaddr = 0,
.vmsize = 0,
.fileoff = 0,
.filesize = 0,
.maxprot = macho.VM_PROT_READ,
.initprot = macho.VM_PROT_READ,
.nsects = 0,
.flags = 0,
}),
});
}
if (self.dyld_info_cmd_index == null) {
self.dyld_info_cmd_index = @intCast(u16, self.load_commands.items.len);
try self.load_commands.append(self.allocator, .{
.DyldInfoOnly = .{
.cmd = macho.LC_DYLD_INFO_ONLY,
.cmdsize = @sizeOf(macho.dyld_info_command),
.rebase_off = 0,
.rebase_size = 0,
.bind_off = 0,
.bind_size = 0,
.weak_bind_off = 0,
.weak_bind_size = 0,
.lazy_bind_off = 0,
.lazy_bind_size = 0,
.export_off = 0,
.export_size = 0,
},
});
}
if (self.symtab_cmd_index == null) {
self.symtab_cmd_index = @intCast(u16, self.load_commands.items.len);
try self.load_commands.append(self.allocator, .{
.Symtab = .{
.cmd = macho.LC_SYMTAB,
.cmdsize = @sizeOf(macho.symtab_command),
.symoff = 0,
.nsyms = 0,
.stroff = 0,
.strsize = 0,
},
});
try self.strtab.append(self.allocator, 0);
}
if (self.dysymtab_cmd_index == null) {
self.dysymtab_cmd_index = @intCast(u16, self.load_commands.items.len);
try self.load_commands.append(self.allocator, .{
.Dysymtab = .{
.cmd = macho.LC_DYSYMTAB,
.cmdsize = @sizeOf(macho.dysymtab_command),
.ilocalsym = 0,
.nlocalsym = 0,
.iextdefsym = 0,
.nextdefsym = 0,
.iundefsym = 0,
.nundefsym = 0,
.tocoff = 0,
.ntoc = 0,
.modtaboff = 0,
.nmodtab = 0,
.extrefsymoff = 0,
.nextrefsyms = 0,
.indirectsymoff = 0,
.nindirectsyms = 0,
.extreloff = 0,
.nextrel = 0,
.locreloff = 0,
.nlocrel = 0,
},
});
}
if (self.dylinker_cmd_index == null) {
self.dylinker_cmd_index = @intCast(u16, self.load_commands.items.len);
const cmdsize = @intCast(u32, mem.alignForwardGeneric(
u64,
@sizeOf(macho.dylinker_command) + mem.lenZ(DEFAULT_DYLD_PATH),
@sizeOf(u64),
));
var dylinker_cmd = emptyGenericCommandWithData(macho.dylinker_command{
.cmd = macho.LC_LOAD_DYLINKER,
.cmdsize = cmdsize,
.name = @sizeOf(macho.dylinker_command),
});
dylinker_cmd.data = try self.allocator.alloc(u8, cmdsize - dylinker_cmd.inner.name);
mem.set(u8, dylinker_cmd.data, 0);
mem.copy(u8, dylinker_cmd.data, mem.spanZ(DEFAULT_DYLD_PATH));
try self.load_commands.append(self.allocator, .{ .Dylinker = dylinker_cmd });
}
if (self.libsystem_cmd_index == null) {
self.libsystem_cmd_index = @intCast(u16, self.load_commands.items.len);
const cmdsize = @intCast(u32, mem.alignForwardGeneric(
u64,
@sizeOf(macho.dylib_command) + mem.lenZ(LIB_SYSTEM_PATH),
@sizeOf(u64),
));
// TODO Find a way to work out runtime version from the OS version triple stored in std.Target.
// In the meantime, we're gonna hardcode to the minimum compatibility version of 0.0.0.
const min_version = 0x0;
var dylib_cmd = emptyGenericCommandWithData(macho.dylib_command{
.cmd = macho.LC_LOAD_DYLIB,
.cmdsize = cmdsize,
.dylib = .{
.name = @sizeOf(macho.dylib_command),
.timestamp = 2, // not sure why not simply 0; this is reverse engineered from Mach-O files
.current_version = min_version,
.compatibility_version = min_version,
},
});
dylib_cmd.data = try self.allocator.alloc(u8, cmdsize - dylib_cmd.inner.dylib.name);
mem.set(u8, dylib_cmd.data, 0);
mem.copy(u8, dylib_cmd.data, mem.spanZ(LIB_SYSTEM_PATH));
try self.load_commands.append(self.allocator, .{ .Dylib = dylib_cmd });
}
if (self.main_cmd_index == null) {
self.main_cmd_index = @intCast(u16, self.load_commands.items.len);
try self.load_commands.append(self.allocator, .{
.Main = .{
.cmd = macho.LC_MAIN,
.cmdsize = @sizeOf(macho.entry_point_command),
.entryoff = 0x0,
.stacksize = 0,
},
});
}
if (self.source_version_cmd_index == null) {
self.source_version_cmd_index = @intCast(u16, self.load_commands.items.len);
try self.load_commands.append(self.allocator, .{
.SourceVersion = .{
.cmd = macho.LC_SOURCE_VERSION,
.cmdsize = @sizeOf(macho.source_version_command),
.version = 0x0,
},
});
}
if (self.uuid_cmd_index == null) {
self.uuid_cmd_index = @intCast(u16, self.load_commands.items.len);
var uuid_cmd: macho.uuid_command = .{
.cmd = macho.LC_UUID,
.cmdsize = @sizeOf(macho.uuid_command),
.uuid = undefined,
};
std.crypto.random.bytes(&uuid_cmd.uuid);
try self.load_commands.append(self.allocator, .{ .Uuid = uuid_cmd });
}
if (self.code_signature_cmd_index == null and self.arch.? == .aarch64) {
self.code_signature_cmd_index = @intCast(u16, self.load_commands.items.len);
try self.load_commands.append(self.allocator, .{
.LinkeditData = .{
.cmd = macho.LC_CODE_SIGNATURE,
.cmdsize = @sizeOf(macho.linkedit_data_command),
.dataoff = 0,
.datasize = 0,
},
});
}
if (self.data_in_code_cmd_index == null and self.arch.? == .x86_64) {
self.data_in_code_cmd_index = @intCast(u16, self.load_commands.items.len);
try self.load_commands.append(self.allocator, .{
.LinkeditData = .{
.cmd = macho.LC_DATA_IN_CODE,
.cmdsize = @sizeOf(macho.linkedit_data_command),
.dataoff = 0,
.datasize = 0,
},
});
}
}
fn flush(self: *Zld) !void {
if (self.bss_section_index) |index| {
const seg = &self.load_commands.items[self.data_segment_cmd_index.?].Segment;
const sect = &seg.sections.items[index];
sect.offset = 0;
}
if (self.tlv_bss_section_index) |index| {
const seg = &self.load_commands.items[self.data_segment_cmd_index.?].Segment;
const sect = &seg.sections.items[index];
sect.offset = 0;
}
if (self.tlv_section_index) |index| {
const seg = self.load_commands.items[self.data_segment_cmd_index.?].Segment;
const sect = &seg.sections.items[index];
var buffer = try self.allocator.alloc(u8, sect.size);
defer self.allocator.free(buffer);
_ = try self.file.?.preadAll(buffer, sect.offset);
var stream = std.io.fixedBufferStream(buffer);
var writer = stream.writer();
const seek_amt = 2 * @sizeOf(u64);
while (self.threadlocal_offsets.popOrNull()) |offset| {
try writer.context.seekBy(seek_amt);
try writer.writeIntLittle(u64, offset);
}
try self.file.?.pwriteAll(buffer, sect.offset);
}
try self.setEntryPoint();
try self.writeRebaseInfoTable();
try self.writeBindInfoTable();
try self.writeLazyBindInfoTable();
try self.writeExportInfo();
if (self.arch.? == .x86_64) {
try self.writeDataInCode();
}
{
const seg = &self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment;
const symtab = &self.load_commands.items[self.symtab_cmd_index.?].Symtab;
symtab.symoff = @intCast(u32, seg.inner.fileoff + seg.inner.filesize);
}
try self.writeDebugInfo();
try self.writeSymbolTable();
try self.writeDynamicSymbolTable();
try self.writeStringTable();
{
// Seal __LINKEDIT size
const seg = &self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment;
seg.inner.vmsize = mem.alignForwardGeneric(u64, seg.inner.filesize, self.page_size.?);
}
if (self.arch.? == .aarch64) {
try self.writeCodeSignaturePadding();
}
try self.writeLoadCommands();
try self.writeHeader();
if (self.arch.? == .aarch64) {
try self.writeCodeSignature();
}
if (comptime std.Target.current.isDarwin() and std.Target.current.cpu.arch == .aarch64) {
try fs.cwd().copyFile(self.out_path.?, fs.cwd(), self.out_path.?, .{});
}
}
fn setEntryPoint(self: *Zld) !void {
// TODO we should respect the -entry flag passed in by the user to set a custom
// entrypoint. For now, assume default of `_main`.
const seg = self.load_commands.items[self.text_segment_cmd_index.?].Segment;
const text = seg.sections.items[self.text_section_index.?];
const entry_syms = self.locals.get("_main") orelse return error.MissingMainEntrypoint;
var entry_sym: ?macho.nlist_64 = null;
for (entry_syms.items) |es| {
switch (es.tt) {
.Global => {
entry_sym = es.inner;
break;
},
.WeakGlobal => {
entry_sym = es.inner;
},
.Local => {},
}
}
if (entry_sym == null) {
log.err("no (weak) global definition of _main found", .{});
return error.MissingMainEntrypoint;
}
const name = try self.allocator.dupe(u8, "_main");
try self.exports.putNoClobber(self.allocator, name, .{
.n_strx = entry_sym.?.n_strx,
.n_value = entry_sym.?.n_value,
.n_type = macho.N_SECT | macho.N_EXT,
.n_desc = entry_sym.?.n_desc,
.n_sect = entry_sym.?.n_sect,
});
const ec = &self.load_commands.items[self.main_cmd_index.?].Main;
ec.entryoff = @intCast(u32, entry_sym.?.n_value - seg.inner.vmaddr);
}
fn writeRebaseInfoTable(self: *Zld) !void {
var pointers = std.ArrayList(Pointer).init(self.allocator);
defer pointers.deinit();
try pointers.ensureCapacity(pointers.items.len + self.local_rebases.items.len);
pointers.appendSliceAssumeCapacity(self.local_rebases.items);
if (self.got_section_index) |idx| {
// TODO this should be cleaned up!
try pointers.ensureCapacity(pointers.items.len + self.nonlazy_pointers.items().len);
const seg = self.load_commands.items[self.data_const_segment_cmd_index.?].Segment;
const sect = seg.sections.items[idx];
const base_offset = sect.addr - seg.inner.vmaddr;
const segment_id = @intCast(u16, self.data_const_segment_cmd_index.?);
const index_offset = @intCast(u32, self.nonlazy_imports.items().len);
for (self.nonlazy_pointers.items()) |entry| {
const index = index_offset + entry.value.index;
pointers.appendAssumeCapacity(.{
.offset = base_offset + index * @sizeOf(u64),
.segment_id = segment_id,
});
}
}
if (self.la_symbol_ptr_section_index) |idx| {
try pointers.ensureCapacity(pointers.items.len + self.lazy_imports.items().len);
const seg = self.load_commands.items[self.data_segment_cmd_index.?].Segment;
const sect = seg.sections.items[idx];
const base_offset = sect.addr - seg.inner.vmaddr;
const segment_id = @intCast(u16, self.data_segment_cmd_index.?);
for (self.lazy_imports.items()) |entry| {
pointers.appendAssumeCapacity(.{
.offset = base_offset + entry.value.index * @sizeOf(u64),
.segment_id = segment_id,
});
}
}
std.sort.sort(Pointer, pointers.items, {}, pointerCmp);
const size = try rebaseInfoSize(pointers.items);
var buffer = try self.allocator.alloc(u8, @intCast(usize, size));
defer self.allocator.free(buffer);
var stream = std.io.fixedBufferStream(buffer);
try writeRebaseInfo(pointers.items, stream.writer());
const seg = &self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment;
const dyld_info = &self.load_commands.items[self.dyld_info_cmd_index.?].DyldInfoOnly;
dyld_info.rebase_off = @intCast(u32, seg.inner.fileoff);
dyld_info.rebase_size = @intCast(u32, mem.alignForwardGeneric(u64, buffer.len, @sizeOf(u64)));
seg.inner.filesize += dyld_info.rebase_size;
log.debug("writing rebase info from 0x{x} to 0x{x}", .{ dyld_info.rebase_off, dyld_info.rebase_off + dyld_info.rebase_size });
try self.file.?.pwriteAll(buffer, dyld_info.rebase_off);
}
fn writeBindInfoTable(self: *Zld) !void {
var pointers = std.ArrayList(Pointer).init(self.allocator);
defer pointers.deinit();
if (self.got_section_index) |idx| {
try pointers.ensureCapacity(pointers.items.len + self.nonlazy_imports.items().len);
const seg = self.load_commands.items[self.data_const_segment_cmd_index.?].Segment;
const sect = seg.sections.items[idx];
const base_offset = sect.addr - seg.inner.vmaddr;
const segment_id = @intCast(u16, self.data_const_segment_cmd_index.?);
for (self.nonlazy_imports.items()) |entry| {
pointers.appendAssumeCapacity(.{
.offset = base_offset + entry.value.index * @sizeOf(u64),
.segment_id = segment_id,
.dylib_ordinal = entry.value.dylib_ordinal,
.name = entry.key,
});
}
}
if (self.tlv_section_index) |idx| {
const seg = self.load_commands.items[self.data_segment_cmd_index.?].Segment;
const sect = seg.sections.items[idx];
const base_offset = sect.addr - seg.inner.vmaddr;
const segment_id = @intCast(u16, self.data_segment_cmd_index.?);
try pointers.append(.{
.offset = base_offset + self.tlv_bootstrap.?.index * @sizeOf(u64),
.segment_id = segment_id,
.dylib_ordinal = self.tlv_bootstrap.?.dylib_ordinal,
.name = "__tlv_bootstrap",
});
}
const size = try bindInfoSize(pointers.items);
var buffer = try self.allocator.alloc(u8, @intCast(usize, size));
defer self.allocator.free(buffer);
var stream = std.io.fixedBufferStream(buffer);
try writeBindInfo(pointers.items, stream.writer());
const seg = &self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment;
const dyld_info = &self.load_commands.items[self.dyld_info_cmd_index.?].DyldInfoOnly;
dyld_info.bind_off = @intCast(u32, seg.inner.fileoff + seg.inner.filesize);
dyld_info.bind_size = @intCast(u32, mem.alignForwardGeneric(u64, buffer.len, @alignOf(u64)));
seg.inner.filesize += dyld_info.bind_size;
log.debug("writing binding info from 0x{x} to 0x{x}", .{ dyld_info.bind_off, dyld_info.bind_off + dyld_info.bind_size });
try self.file.?.pwriteAll(buffer, dyld_info.bind_off);
}
fn writeLazyBindInfoTable(self: *Zld) !void {
var pointers = std.ArrayList(Pointer).init(self.allocator);
defer pointers.deinit();
try pointers.ensureCapacity(self.lazy_imports.items().len);
if (self.la_symbol_ptr_section_index) |idx| {
const seg = self.load_commands.items[self.data_segment_cmd_index.?].Segment;
const sect = seg.sections.items[idx];
const base_offset = sect.addr - seg.inner.vmaddr;
const segment_id = @intCast(u16, self.data_segment_cmd_index.?);
for (self.lazy_imports.items()) |entry| {
pointers.appendAssumeCapacity(.{
.offset = base_offset + entry.value.index * @sizeOf(u64),
.segment_id = segment_id,
.dylib_ordinal = entry.value.dylib_ordinal,
.name = entry.key,
});
}
}
const size = try lazyBindInfoSize(pointers.items);
var buffer = try self.allocator.alloc(u8, @intCast(usize, size));
defer self.allocator.free(buffer);
var stream = std.io.fixedBufferStream(buffer);
try writeLazyBindInfo(pointers.items, stream.writer());
const seg = &self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment;
const dyld_info = &self.load_commands.items[self.dyld_info_cmd_index.?].DyldInfoOnly;
dyld_info.lazy_bind_off = @intCast(u32, seg.inner.fileoff + seg.inner.filesize);
dyld_info.lazy_bind_size = @intCast(u32, mem.alignForwardGeneric(u64, buffer.len, @alignOf(u64)));
seg.inner.filesize += dyld_info.lazy_bind_size;
log.debug("writing lazy binding info from 0x{x} to 0x{x}", .{ dyld_info.lazy_bind_off, dyld_info.lazy_bind_off + dyld_info.lazy_bind_size });
try self.file.?.pwriteAll(buffer, dyld_info.lazy_bind_off);
try self.populateLazyBindOffsetsInStubHelper(buffer);
}
fn populateLazyBindOffsetsInStubHelper(self: *Zld, buffer: []const u8) !void {
var stream = std.io.fixedBufferStream(buffer);
var reader = stream.reader();
var offsets = std.ArrayList(u32).init(self.allocator);
try offsets.append(0);
defer offsets.deinit();
var valid_block = false;
while (true) {
const inst = reader.readByte() catch |err| switch (err) {
error.EndOfStream => break,
else => return err,
};
const imm: u8 = inst & macho.BIND_IMMEDIATE_MASK;
const opcode: u8 = inst & macho.BIND_OPCODE_MASK;
switch (opcode) {
macho.BIND_OPCODE_DO_BIND => {
valid_block = true;
},
macho.BIND_OPCODE_DONE => {
if (valid_block) {
const offset = try stream.getPos();
try offsets.append(@intCast(u32, offset));
}
valid_block = false;
},
macho.BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM => {
var next = try reader.readByte();
while (next != @as(u8, 0)) {
next = try reader.readByte();
}
},
macho.BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB => {
_ = try leb.readULEB128(u64, reader);
},
macho.BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB => {
_ = try leb.readULEB128(u64, reader);
},
macho.BIND_OPCODE_SET_ADDEND_SLEB => {
_ = try leb.readILEB128(i64, reader);
},
else => {},
}
}
assert(self.lazy_imports.items().len <= offsets.items.len);
const stub_size: u4 = switch (self.arch.?) {
.x86_64 => 10,
.aarch64 => 3 * @sizeOf(u32),
else => unreachable,
};
const off: u4 = switch (self.arch.?) {
.x86_64 => 1,
.aarch64 => 2 * @sizeOf(u32),
else => unreachable,
};
var buf: [@sizeOf(u32)]u8 = undefined;
for (self.lazy_imports.items()) |entry| {
const symbol = entry.value;
const placeholder_off = self.stub_helper_stubs_start_off.? + symbol.index * stub_size + off;
mem.writeIntLittle(u32, &buf, offsets.items[symbol.index]);
try self.file.?.pwriteAll(&buf, placeholder_off);
}
}
fn writeExportInfo(self: *Zld) !void {
var trie = Trie.init(self.allocator);
defer trie.deinit();
const text_segment = self.load_commands.items[self.text_segment_cmd_index.?].Segment;
for (self.exports.items()) |entry| {
const name = entry.key;
const symbol = entry.value;
// TODO figure out if we should put all exports into the export trie
assert(symbol.n_value >= text_segment.inner.vmaddr);
try trie.put(.{
.name = name,
.vmaddr_offset = symbol.n_value - text_segment.inner.vmaddr,
.export_flags = macho.EXPORT_SYMBOL_FLAGS_KIND_REGULAR,
});
}
try trie.finalize();
var buffer = try self.allocator.alloc(u8, @intCast(usize, trie.size));
defer self.allocator.free(buffer);
var stream = std.io.fixedBufferStream(buffer);
const nwritten = try trie.write(stream.writer());
assert(nwritten == trie.size);
const seg = &self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment;
const dyld_info = &self.load_commands.items[self.dyld_info_cmd_index.?].DyldInfoOnly;
dyld_info.export_off = @intCast(u32, seg.inner.fileoff + seg.inner.filesize);
dyld_info.export_size = @intCast(u32, mem.alignForwardGeneric(u64, buffer.len, @alignOf(u64)));
seg.inner.filesize += dyld_info.export_size;
log.debug("writing export info from 0x{x} to 0x{x}", .{ dyld_info.export_off, dyld_info.export_off + dyld_info.export_size });
try self.file.?.pwriteAll(buffer, dyld_info.export_off);
}
fn writeDebugInfo(self: *Zld) !void {
var stabs = std.ArrayList(macho.nlist_64).init(self.allocator);
defer stabs.deinit();
for (self.objects.items) |object, object_id| {
var debug_info = blk: {
var di = try DebugInfo.parseFromObject(self.allocator, object);
break :blk di orelse continue;
};
defer debug_info.deinit(self.allocator);
// We assume there is only one CU.
const compile_unit = debug_info.inner.findCompileUnit(0x0) catch |err| switch (err) {
error.MissingDebugInfo => {
// TODO audit cases with missing debug info and audit our dwarf.zig module.
log.debug("invalid or missing debug info in {s}; skipping", .{object.name});
continue;
},
else => |e| return e,
};
const name = try compile_unit.die.getAttrString(&debug_info.inner, dwarf.AT_name);
const comp_dir = try compile_unit.die.getAttrString(&debug_info.inner, dwarf.AT_comp_dir);
{
const tu_path = try std.fs.path.join(self.allocator, &[_][]const u8{ comp_dir, name });
defer self.allocator.free(tu_path);
const dirname = std.fs.path.dirname(tu_path) orelse "./";
// Current dir
try stabs.append(.{
.n_strx = try self.makeString(tu_path[0 .. dirname.len + 1]),
.n_type = macho.N_SO,
.n_sect = 0,
.n_desc = 0,
.n_value = 0,
});
// Artifact name
try stabs.append(.{
.n_strx = try self.makeString(tu_path[dirname.len + 1 ..]),
.n_type = macho.N_SO,
.n_sect = 0,
.n_desc = 0,
.n_value = 0,
});
// Path to object file with debug info
var buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined;
const full_path = blk: {
if (object.ar_name) |prefix| {
const path = try std.os.realpath(prefix, &buffer);
break :blk try std.fmt.allocPrint(self.allocator, "{s}({s})", .{ path, object.name });
} else {
const path = try std.os.realpath(object.name, &buffer);
break :blk try mem.dupe(self.allocator, u8, path);
}
};
defer self.allocator.free(full_path);
const stat = try object.file.stat();
const mtime = @intCast(u64, @divFloor(stat.mtime, 1_000_000_000));
try stabs.append(.{
.n_strx = try self.makeString(full_path),
.n_type = macho.N_OSO,
.n_sect = 0,
.n_desc = 1,
.n_value = mtime,
});
}
log.debug("analyzing debug info in '{s}'", .{object.name});
for (object.symtab.items) |source_sym| {
const symname = object.getString(source_sym.n_strx);
const source_addr = source_sym.n_value;
const target_syms = self.locals.get(symname) orelse continue;
const target_sym: Symbol = blk: {
for (target_syms.items) |ts| {
if (ts.object_id == @intCast(u16, object_id)) break :blk ts;
} else continue;
};
const maybe_size = blk: for (debug_info.inner.func_list.items) |func| {
if (func.pc_range) |range| {
if (source_addr >= range.start and source_addr < range.end) {
break :blk range.end - range.start;
}
}
} else null;
if (maybe_size) |size| {
try stabs.append(.{
.n_strx = 0,
.n_type = macho.N_BNSYM,
.n_sect = target_sym.inner.n_sect,
.n_desc = 0,
.n_value = target_sym.inner.n_value,
});
try stabs.append(.{
.n_strx = target_sym.inner.n_strx,
.n_type = macho.N_FUN,
.n_sect = target_sym.inner.n_sect,
.n_desc = 0,
.n_value = target_sym.inner.n_value,
});
try stabs.append(.{
.n_strx = 0,
.n_type = macho.N_FUN,
.n_sect = 0,
.n_desc = 0,
.n_value = size,
});
try stabs.append(.{
.n_strx = 0,
.n_type = macho.N_ENSYM,
.n_sect = target_sym.inner.n_sect,
.n_desc = 0,
.n_value = size,
});
} else {
// TODO need a way to differentiate symbols: global, static, local, etc.
try stabs.append(.{
.n_strx = target_sym.inner.n_strx,
.n_type = macho.N_STSYM,
.n_sect = target_sym.inner.n_sect,
.n_desc = 0,
.n_value = target_sym.inner.n_value,
});
}
}
// Close the source file!
try stabs.append(.{
.n_strx = 0,
.n_type = macho.N_SO,
.n_sect = 0,
.n_desc = 0,
.n_value = 0,
});
}
if (stabs.items.len == 0) return;
// Write stabs into the symbol table
const linkedit = &self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment;
const symtab = &self.load_commands.items[self.symtab_cmd_index.?].Symtab;
symtab.nsyms = @intCast(u32, stabs.items.len);
const stabs_off = symtab.symoff;
const stabs_size = symtab.nsyms * @sizeOf(macho.nlist_64);
log.debug("writing symbol stabs from 0x{x} to 0x{x}", .{ stabs_off, stabs_size + stabs_off });
try self.file.?.pwriteAll(mem.sliceAsBytes(stabs.items), stabs_off);
linkedit.inner.filesize += stabs_size;
// Update dynamic symbol table.
const dysymtab = &self.load_commands.items[self.dysymtab_cmd_index.?].Dysymtab;
dysymtab.nlocalsym = symtab.nsyms;
}
fn writeSymbolTable(self: *Zld) !void {
const seg = &self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment;
const symtab = &self.load_commands.items[self.symtab_cmd_index.?].Symtab;
var locals = std.ArrayList(macho.nlist_64).init(self.allocator);
defer locals.deinit();
for (self.locals.items()) |entries| {
log.debug("'{s}': {} entries", .{ entries.key, entries.value.items.len });
// var symbol: ?macho.nlist_64 = null;
for (entries.value.items) |entry| {
log.debug(" | {}", .{entry.inner});
log.debug(" | {}", .{entry.tt});
log.debug(" | {s}", .{self.objects.items[entry.object_id].name});
try locals.append(entry.inner);
}
}
const nlocals = locals.items.len;
const nexports = self.exports.items().len;
var exports = std.ArrayList(macho.nlist_64).init(self.allocator);
defer exports.deinit();
try exports.ensureCapacity(nexports);
for (self.exports.items()) |entry| {
exports.appendAssumeCapacity(entry.value);
}
const has_tlv: bool = self.tlv_bootstrap != null;
var nundefs = self.lazy_imports.items().len + self.nonlazy_imports.items().len;
if (has_tlv) nundefs += 1;
var undefs = std.ArrayList(macho.nlist_64).init(self.allocator);
defer undefs.deinit();
try undefs.ensureCapacity(nundefs);
for (self.lazy_imports.items()) |entry| {
undefs.appendAssumeCapacity(entry.value.symbol);
}
for (self.nonlazy_imports.items()) |entry| {
undefs.appendAssumeCapacity(entry.value.symbol);
}
if (has_tlv) {
undefs.appendAssumeCapacity(self.tlv_bootstrap.?.symbol);
}
const locals_off = symtab.symoff + symtab.nsyms * @sizeOf(macho.nlist_64);
const locals_size = nlocals * @sizeOf(macho.nlist_64);
log.debug("writing local symbols from 0x{x} to 0x{x}", .{ locals_off, locals_size + locals_off });
try self.file.?.pwriteAll(mem.sliceAsBytes(locals.items), locals_off);
const exports_off = locals_off + locals_size;
const exports_size = nexports * @sizeOf(macho.nlist_64);
log.debug("writing exported symbols from 0x{x} to 0x{x}", .{ exports_off, exports_size + exports_off });
try self.file.?.pwriteAll(mem.sliceAsBytes(exports.items), exports_off);
const undefs_off = exports_off + exports_size;
const undefs_size = nundefs * @sizeOf(macho.nlist_64);
log.debug("writing undefined symbols from 0x{x} to 0x{x}", .{ undefs_off, undefs_size + undefs_off });
try self.file.?.pwriteAll(mem.sliceAsBytes(undefs.items), undefs_off);
symtab.nsyms += @intCast(u32, nlocals + nexports + nundefs);
seg.inner.filesize += locals_size + exports_size + undefs_size;
// Update dynamic symbol table.
const dysymtab = &self.load_commands.items[self.dysymtab_cmd_index.?].Dysymtab;
dysymtab.nlocalsym += @intCast(u32, nlocals);
dysymtab.iextdefsym = dysymtab.nlocalsym;
dysymtab.nextdefsym = @intCast(u32, nexports);
dysymtab.iundefsym = dysymtab.nlocalsym + dysymtab.nextdefsym;
dysymtab.nundefsym = @intCast(u32, nundefs);
}
fn writeDynamicSymbolTable(self: *Zld) !void {
const seg = &self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment;
const text_segment = &self.load_commands.items[self.text_segment_cmd_index.?].Segment;
const stubs = &text_segment.sections.items[self.stubs_section_index.?];
const data_const_segment = &self.load_commands.items[self.data_const_segment_cmd_index.?].Segment;
const got = &data_const_segment.sections.items[self.got_section_index.?];
const data_segment = &self.load_commands.items[self.data_segment_cmd_index.?].Segment;
const la_symbol_ptr = &data_segment.sections.items[self.la_symbol_ptr_section_index.?];
const dysymtab = &self.load_commands.items[self.dysymtab_cmd_index.?].Dysymtab;
const lazy = self.lazy_imports.items();
const nonlazy = self.nonlazy_imports.items();
const got_locals = self.nonlazy_pointers.items();
dysymtab.indirectsymoff = @intCast(u32, seg.inner.fileoff + seg.inner.filesize);
dysymtab.nindirectsyms = @intCast(u32, lazy.len * 2 + nonlazy.len + got_locals.len);
const needed_size = dysymtab.nindirectsyms * @sizeOf(u32);
seg.inner.filesize += needed_size;
log.debug("writing indirect symbol table from 0x{x} to 0x{x}", .{
dysymtab.indirectsymoff,
dysymtab.indirectsymoff + needed_size,
});
var buf = try self.allocator.alloc(u8, needed_size);
defer self.allocator.free(buf);
var stream = std.io.fixedBufferStream(buf);
var writer = stream.writer();
stubs.reserved1 = 0;
for (lazy) |_, i| {
const symtab_idx = @intCast(u32, dysymtab.iundefsym + i);
try writer.writeIntLittle(u32, symtab_idx);
}
const base_id = @intCast(u32, lazy.len);
got.reserved1 = base_id;
for (nonlazy) |_, i| {
const symtab_idx = @intCast(u32, dysymtab.iundefsym + i + base_id);
try writer.writeIntLittle(u32, symtab_idx);
}
// TODO there should be one common set of GOT entries.
for (got_locals) |_| {
try writer.writeIntLittle(u32, macho.INDIRECT_SYMBOL_LOCAL);
}
la_symbol_ptr.reserved1 = got.reserved1 + @intCast(u32, nonlazy.len) + @intCast(u32, got_locals.len);
for (lazy) |_, i| {
const symtab_idx = @intCast(u32, dysymtab.iundefsym + i);
try writer.writeIntLittle(u32, symtab_idx);
}
try self.file.?.pwriteAll(buf, dysymtab.indirectsymoff);
}
fn writeStringTable(self: *Zld) !void {
const seg = &self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment;
const symtab = &self.load_commands.items[self.symtab_cmd_index.?].Symtab;
symtab.stroff = @intCast(u32, seg.inner.fileoff + seg.inner.filesize);
symtab.strsize = @intCast(u32, mem.alignForwardGeneric(u64, self.strtab.items.len, @alignOf(u64)));
seg.inner.filesize += symtab.strsize;
log.debug("writing string table from 0x{x} to 0x{x}", .{ symtab.stroff, symtab.stroff + symtab.strsize });
try self.file.?.pwriteAll(self.strtab.items, symtab.stroff);
if (symtab.strsize > self.strtab.items.len and self.arch.? == .x86_64) {
// This is the last section, so we need to pad it out.
try self.file.?.pwriteAll(&[_]u8{0}, seg.inner.fileoff + seg.inner.filesize - 1);
}
}
fn writeDataInCode(self: *Zld) !void {
const seg = &self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment;
const dice_cmd = &self.load_commands.items[self.data_in_code_cmd_index.?].LinkeditData;
const fileoff = seg.inner.fileoff + seg.inner.filesize;
var buf = std.ArrayList(u8).init(self.allocator);
defer buf.deinit();
const text_seg = self.load_commands.items[self.text_segment_cmd_index.?].Segment;
const text_sect = text_seg.sections.items[self.text_section_index.?];
for (self.objects.items) |object, object_id| {
const source_seg = object.load_commands.items[object.segment_cmd_index.?].Segment;
const source_sect = source_seg.sections.items[object.text_section_index.?];
const target_mapping = self.mappings.get(.{
.object_id = @intCast(u16, object_id),
.source_sect_id = object.text_section_index.?,
}) orelse continue;
try buf.ensureCapacity(
buf.items.len + object.data_in_code_entries.items.len * @sizeOf(macho.data_in_code_entry),
);
for (object.data_in_code_entries.items) |dice| {
const new_dice: macho.data_in_code_entry = .{
.offset = text_sect.offset + target_mapping.offset + dice.offset,
.length = dice.length,
.kind = dice.kind,
};
buf.appendSliceAssumeCapacity(mem.asBytes(&new_dice));
}
}
const datasize = @intCast(u32, buf.items.len);
dice_cmd.dataoff = @intCast(u32, fileoff);
dice_cmd.datasize = datasize;
seg.inner.filesize += datasize;
log.debug("writing data-in-code from 0x{x} to 0x{x}", .{ fileoff, fileoff + datasize });
try self.file.?.pwriteAll(buf.items, fileoff);
}
fn writeCodeSignaturePadding(self: *Zld) !void {
const seg = &self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment;
const code_sig_cmd = &self.load_commands.items[self.code_signature_cmd_index.?].LinkeditData;
const fileoff = seg.inner.fileoff + seg.inner.filesize;
const needed_size = CodeSignature.calcCodeSignaturePaddingSize(
self.out_path.?,
fileoff,
self.page_size.?,
);
code_sig_cmd.dataoff = @intCast(u32, fileoff);
code_sig_cmd.datasize = needed_size;
// Advance size of __LINKEDIT segment
seg.inner.filesize += needed_size;
seg.inner.vmsize = mem.alignForwardGeneric(u64, seg.inner.filesize, self.page_size.?);
log.debug("writing code signature padding from 0x{x} to 0x{x}", .{ fileoff, fileoff + needed_size });
// Pad out the space. We need to do this to calculate valid hashes for everything in the file
// except for code signature data.
try self.file.?.pwriteAll(&[_]u8{0}, fileoff + needed_size - 1);
}
fn writeCodeSignature(self: *Zld) !void {
const text_seg = self.load_commands.items[self.text_segment_cmd_index.?].Segment;
const code_sig_cmd = self.load_commands.items[self.code_signature_cmd_index.?].LinkeditData;
var code_sig = CodeSignature.init(self.allocator, self.page_size.?);
defer code_sig.deinit();
try code_sig.calcAdhocSignature(
self.file.?,
self.out_path.?,
text_seg.inner,
code_sig_cmd,
.Exe,
);
var buffer = try self.allocator.alloc(u8, code_sig.size());
defer self.allocator.free(buffer);
var stream = std.io.fixedBufferStream(buffer);
try code_sig.write(stream.writer());
log.debug("writing code signature from 0x{x} to 0x{x}", .{ code_sig_cmd.dataoff, code_sig_cmd.dataoff + buffer.len });
try self.file.?.pwriteAll(buffer, code_sig_cmd.dataoff);
}
fn writeLoadCommands(self: *Zld) !void {
var sizeofcmds: u32 = 0;
for (self.load_commands.items) |lc| {
sizeofcmds += lc.cmdsize();
}
var buffer = try self.allocator.alloc(u8, sizeofcmds);
defer self.allocator.free(buffer);
var writer = std.io.fixedBufferStream(buffer).writer();
for (self.load_commands.items) |lc| {
try lc.write(writer);
}
const off = @sizeOf(macho.mach_header_64);
log.debug("writing {} load commands from 0x{x} to 0x{x}", .{ self.load_commands.items.len, off, off + sizeofcmds });
try self.file.?.pwriteAll(buffer, off);
}
fn writeHeader(self: *Zld) !void {
var header: macho.mach_header_64 = undefined;
header.magic = macho.MH_MAGIC_64;
const CpuInfo = struct {
cpu_type: macho.cpu_type_t,
cpu_subtype: macho.cpu_subtype_t,
};
const cpu_info: CpuInfo = switch (self.arch.?) {
.aarch64 => .{
.cpu_type = macho.CPU_TYPE_ARM64,
.cpu_subtype = macho.CPU_SUBTYPE_ARM_ALL,
},
.x86_64 => .{
.cpu_type = macho.CPU_TYPE_X86_64,
.cpu_subtype = macho.CPU_SUBTYPE_X86_64_ALL,
},
else => return error.UnsupportedCpuArchitecture,
};
header.cputype = cpu_info.cpu_type;
header.cpusubtype = cpu_info.cpu_subtype;
header.filetype = macho.MH_EXECUTE;
header.flags = macho.MH_NOUNDEFS | macho.MH_DYLDLINK | macho.MH_PIE | macho.MH_TWOLEVEL;
header.reserved = 0;
if (self.tlv_section_index) |_|
header.flags |= macho.MH_HAS_TLV_DESCRIPTORS;
header.ncmds = @intCast(u32, self.load_commands.items.len);
header.sizeofcmds = 0;
for (self.load_commands.items) |cmd| {
header.sizeofcmds += cmd.cmdsize();
}
log.debug("writing Mach-O header {}", .{header});
try self.file.?.pwriteAll(mem.asBytes(&header), 0);
}
pub fn makeStaticString(bytes: []const u8) [16]u8 {
var buf = [_]u8{0} ** 16;
assert(bytes.len <= buf.len);
mem.copy(u8, &buf, bytes);
return buf;
}
fn makeString(self: *Zld, bytes: []const u8) !u32 {
try self.strtab.ensureCapacity(self.allocator, self.strtab.items.len + bytes.len + 1);
const offset = @intCast(u32, self.strtab.items.len);
log.debug("writing new string '{s}' into string table at offset 0x{x}", .{ bytes, offset });
self.strtab.appendSliceAssumeCapacity(bytes);
self.strtab.appendAssumeCapacity(0);
return offset;
}
fn getString(self: *const Zld, str_off: u32) []const u8 {
assert(str_off < self.strtab.items.len);
return mem.spanZ(@ptrCast([*:0]const u8, self.strtab.items.ptr + str_off));
}
pub fn parseName(name: *const [16]u8) []const u8 {
const len = mem.indexOfScalar(u8, name, @as(u8, 0)) orelse name.len;
return name[0..len];
}
fn isLocal(sym: *const macho.nlist_64) callconv(.Inline) bool {
if (isExtern(sym)) return false;
const tt = macho.N_TYPE & sym.n_type;
return tt == macho.N_SECT;
}
fn isExport(sym: *const macho.nlist_64) callconv(.Inline) bool {
if (!isExtern(sym)) return false;
const tt = macho.N_TYPE & sym.n_type;
return tt == macho.N_SECT;
}
fn isImport(sym: *const macho.nlist_64) callconv(.Inline) bool {
if (!isExtern(sym)) return false;
const tt = macho.N_TYPE & sym.n_type;
return tt == macho.N_UNDF;
}
fn isExtern(sym: *const macho.nlist_64) callconv(.Inline) bool {
if ((sym.n_type & macho.N_EXT) == 0) return false;
return (sym.n_type & macho.N_PEXT) == 0;
}
fn isWeakDef(sym: *const macho.nlist_64) callconv(.Inline) bool {
return (sym.n_desc & macho.N_WEAK_DEF) != 0;
}
fn aarch64IsArithmetic(inst: *const [4]u8) callconv(.Inline) bool {
const group_decode = @truncate(u5, inst[3]);
return ((group_decode >> 2) == 4);
} | src/link/MachO/Zld.zig |
pub const DRMHANDLE_INVALID = @as(u32, 0);
pub const DRMENVHANDLE_INVALID = @as(u32, 0);
pub const DRMQUERYHANDLE_INVALID = @as(u32, 0);
pub const DRMHSESSION_INVALID = @as(u32, 0);
pub const DRMPUBHANDLE_INVALID = @as(u32, 0);
pub const DRM_AL_NONSILENT = @as(u32, 1);
pub const DRM_AL_NOPERSIST = @as(u32, 2);
pub const DRM_AL_CANCEL = @as(u32, 4);
pub const DRM_AL_FETCHNOADVISORY = @as(u32, 8);
pub const DRM_AL_NOUI = @as(u32, 16);
pub const DRM_ACTIVATE_MACHINE = @as(u32, 1);
pub const DRM_ACTIVATE_GROUPIDENTITY = @as(u32, 2);
pub const DRM_ACTIVATE_TEMPORARY = @as(u32, 4);
pub const DRM_ACTIVATE_CANCEL = @as(u32, 8);
pub const DRM_ACTIVATE_SILENT = @as(u32, 16);
pub const DRM_ACTIVATE_SHARED_GROUPIDENTITY = @as(u32, 32);
pub const DRM_ACTIVATE_DELAYED = @as(u32, 64);
pub const DRM_EL_MACHINE = @as(u32, 1);
pub const DRM_EL_GROUPIDENTITY = @as(u32, 2);
pub const DRM_EL_GROUPIDENTITY_NAME = @as(u32, 4);
pub const DRM_EL_GROUPIDENTITY_LID = @as(u32, 8);
pub const DRM_EL_SPECIFIED_GROUPIDENTITY = @as(u32, 16);
pub const DRM_EL_EUL = @as(u32, 32);
pub const DRM_EL_EUL_LID = @as(u32, 64);
pub const DRM_EL_CLIENTLICENSOR = @as(u32, 128);
pub const DRM_EL_CLIENTLICENSOR_LID = @as(u32, 256);
pub const DRM_EL_SPECIFIED_CLIENTLICENSOR = @as(u32, 512);
pub const DRM_EL_REVOCATIONLIST = @as(u32, 1024);
pub const DRM_EL_REVOCATIONLIST_LID = @as(u32, 2048);
pub const DRM_EL_EXPIRED = @as(u32, 4096);
pub const DRM_EL_ISSUERNAME = @as(u32, 8192);
pub const DRM_EL_ISSUANCELICENSE_TEMPLATE = @as(u32, 16384);
pub const DRM_EL_ISSUANCELICENSE_TEMPLATE_LID = @as(u32, 32768);
pub const DRM_ADD_LICENSE_NOPERSIST = @as(u32, 0);
pub const DRM_ADD_LICENSE_PERSIST = @as(u32, 1);
pub const DRM_SERVICE_TYPE_ACTIVATION = @as(u32, 1);
pub const DRM_SERVICE_TYPE_CERTIFICATION = @as(u32, 2);
pub const DRM_SERVICE_TYPE_PUBLISHING = @as(u32, 4);
pub const DRM_SERVICE_TYPE_CLIENTLICENSOR = @as(u32, 8);
pub const DRM_SERVICE_TYPE_SILENT = @as(u32, 16);
pub const DRM_SERVICE_LOCATION_INTERNET = @as(u32, 1);
pub const DRM_SERVICE_LOCATION_ENTERPRISE = @as(u32, 2);
pub const DRM_SIGN_ONLINE = @as(u32, 1);
pub const DRM_SIGN_OFFLINE = @as(u32, 2);
pub const DRM_SIGN_CANCEL = @as(u32, 4);
pub const DRM_SERVER_ISSUANCELICENSE = @as(u32, 8);
pub const DRM_AUTO_GENERATE_KEY = @as(u32, 16);
pub const DRM_OWNER_LICENSE_NOPERSIST = @as(u32, 32);
pub const DRM_REUSE_KEY = @as(u32, 64);
pub const DRM_LOCKBOXTYPE_NONE = @as(u32, 0);
pub const DRM_LOCKBOXTYPE_WHITEBOX = @as(u32, 1);
pub const DRM_LOCKBOXTYPE_BLACKBOX = @as(u32, 2);
pub const DRM_LOCKBOXTYPE_DEFAULT = @as(u32, 2);
pub const DRM_AILT_NONSILENT = @as(u32, 1);
pub const DRM_AILT_OBTAIN_ALL = @as(u32, 2);
pub const DRM_AILT_CANCEL = @as(u32, 4);
pub const MSDRM_CLIENT_ZONE = @as(u32, 52992);
pub const MSDRM_POLICY_ZONE = @as(u32, 37632);
pub const DRMIDVERSION = @as(u32, 0);
pub const DRMBOUNDLICENSEPARAMSVERSION = @as(u32, 1);
pub const DRMBINDINGFLAGS_IGNORE_VALIDITY_INTERVALS = @as(u32, 1);
pub const DRMLICENSEACQDATAVERSION = @as(u32, 0);
pub const DRMACTSERVINFOVERSION = @as(u32, 0);
pub const DRMCLIENTSTRUCTVERSION = @as(u32, 1);
pub const DRMCALLBACKVERSION = @as(u32, 1);
//--------------------------------------------------------------------------------
// Section: Types (15)
//--------------------------------------------------------------------------------
pub const DRMID = extern struct {
uVersion: u32,
wszIDType: ?PWSTR,
wszID: ?PWSTR,
};
pub const DRMTIMETYPE = enum(i32) {
UTC = 0,
LOCAL = 1,
};
pub const DRMTIMETYPE_SYSTEMUTC = DRMTIMETYPE.UTC;
pub const DRMTIMETYPE_SYSTEMLOCAL = DRMTIMETYPE.LOCAL;
pub const DRMENCODINGTYPE = enum(i32) {
BASE64 = 0,
STRING = 1,
LONG = 2,
TIME = 3,
UINT = 4,
RAW = 5,
};
pub const DRMENCODINGTYPE_BASE64 = DRMENCODINGTYPE.BASE64;
pub const DRMENCODINGTYPE_STRING = DRMENCODINGTYPE.STRING;
pub const DRMENCODINGTYPE_LONG = DRMENCODINGTYPE.LONG;
pub const DRMENCODINGTYPE_TIME = DRMENCODINGTYPE.TIME;
pub const DRMENCODINGTYPE_UINT = DRMENCODINGTYPE.UINT;
pub const DRMENCODINGTYPE_RAW = DRMENCODINGTYPE.RAW;
pub const DRMATTESTTYPE = enum(i32) {
FULLENVIRONMENT = 0,
HASHONLY = 1,
};
pub const DRMATTESTTYPE_FULLENVIRONMENT = DRMATTESTTYPE.FULLENVIRONMENT;
pub const DRMATTESTTYPE_HASHONLY = DRMATTESTTYPE.HASHONLY;
pub const DRMSPECTYPE = enum(i32) {
UNKNOWN = 0,
FILENAME = 1,
};
pub const DRMSPECTYPE_UNKNOWN = DRMSPECTYPE.UNKNOWN;
pub const DRMSPECTYPE_FILENAME = DRMSPECTYPE.FILENAME;
pub const DRMSECURITYPROVIDERTYPE = enum(i32) {
P = 0,
};
pub const DRMSECURITYPROVIDERTYPE_SOFTWARESECREP = DRMSECURITYPROVIDERTYPE.P;
pub const DRMGLOBALOPTIONS = enum(i32) {
WINHTTP = 0,
SERVERSECURITYPROCESSOR = 1,
};
pub const DRMGLOBALOPTIONS_USE_WINHTTP = DRMGLOBALOPTIONS.WINHTTP;
pub const DRMGLOBALOPTIONS_USE_SERVERSECURITYPROCESSOR = DRMGLOBALOPTIONS.SERVERSECURITYPROCESSOR;
pub const DRMBOUNDLICENSEPARAMS = extern struct {
uVersion: u32,
hEnablingPrincipal: u32,
hSecureStore: u32,
wszRightsRequested: ?PWSTR,
wszRightsGroup: ?PWSTR,
idResource: DRMID,
cAuthenticatorCount: u32,
rghAuthenticators: ?*u32,
wszDefaultEnablingPrincipalCredentials: ?PWSTR,
dwFlags: u32,
};
pub const DRM_LICENSE_ACQ_DATA = extern struct {
uVersion: u32,
wszURL: ?PWSTR,
wszLocalFilename: ?PWSTR,
pbPostData: ?*u8,
dwPostDataSize: u32,
wszFriendlyName: ?PWSTR,
};
pub const DRM_ACTSERV_INFO = extern struct {
uVersion: u32,
wszPubKey: ?PWSTR,
wszURL: ?PWSTR,
};
pub const DRM_CLIENT_VERSION_INFO = extern struct {
uStructVersion: u32,
dwVersion: [4]u32,
wszHierarchy: [256]u16,
wszProductId: [256]u16,
wszProductDescription: [256]u16,
};
pub const DRM_STATUS_MSG = enum(i32) {
ACTIVATE_MACHINE = 0,
ACTIVATE_GROUPIDENTITY = 1,
ACQUIRE_LICENSE = 2,
ACQUIRE_ADVISORY = 3,
SIGN_ISSUANCE_LICENSE = 4,
ACQUIRE_CLIENTLICENSOR = 5,
ACQUIRE_ISSUANCE_LICENSE_TEMPLATE = 6,
};
pub const DRM_MSG_ACTIVATE_MACHINE = DRM_STATUS_MSG.ACTIVATE_MACHINE;
pub const DRM_MSG_ACTIVATE_GROUPIDENTITY = DRM_STATUS_MSG.ACTIVATE_GROUPIDENTITY;
pub const DRM_MSG_ACQUIRE_LICENSE = DRM_STATUS_MSG.ACQUIRE_LICENSE;
pub const DRM_MSG_ACQUIRE_ADVISORY = DRM_STATUS_MSG.ACQUIRE_ADVISORY;
pub const DRM_MSG_SIGN_ISSUANCE_LICENSE = DRM_STATUS_MSG.SIGN_ISSUANCE_LICENSE;
pub const DRM_MSG_ACQUIRE_CLIENTLICENSOR = DRM_STATUS_MSG.ACQUIRE_CLIENTLICENSOR;
pub const DRM_MSG_ACQUIRE_ISSUANCE_LICENSE_TEMPLATE = DRM_STATUS_MSG.ACQUIRE_ISSUANCE_LICENSE_TEMPLATE;
pub const DRM_USAGEPOLICY_TYPE = enum(i32) {
BYNAME = 0,
BYPUBLICKEY = 1,
BYDIGEST = 2,
OSEXCLUSION = 3,
};
pub const DRM_USAGEPOLICY_TYPE_BYNAME = DRM_USAGEPOLICY_TYPE.BYNAME;
pub const DRM_USAGEPOLICY_TYPE_BYPUBLICKEY = DRM_USAGEPOLICY_TYPE.BYPUBLICKEY;
pub const DRM_USAGEPOLICY_TYPE_BYDIGEST = DRM_USAGEPOLICY_TYPE.BYDIGEST;
pub const DRM_USAGEPOLICY_TYPE_OSEXCLUSION = DRM_USAGEPOLICY_TYPE.OSEXCLUSION;
pub const DRM_DISTRIBUTION_POINT_INFO = enum(i32) {
LICENSE_ACQUISITION = 0,
PUBLISHING = 1,
REFERRAL_INFO = 2,
};
pub const DRM_DISTRIBUTION_POINT_LICENSE_ACQUISITION = DRM_DISTRIBUTION_POINT_INFO.LICENSE_ACQUISITION;
pub const DRM_DISTRIBUTION_POINT_PUBLISHING = DRM_DISTRIBUTION_POINT_INFO.PUBLISHING;
pub const DRM_DISTRIBUTION_POINT_REFERRAL_INFO = DRM_DISTRIBUTION_POINT_INFO.REFERRAL_INFO;
pub const DRMCALLBACK = fn(
param0: DRM_STATUS_MSG,
param1: HRESULT,
param2: ?*anyopaque,
param3: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
//--------------------------------------------------------------------------------
// Section: Functions (84)
//--------------------------------------------------------------------------------
pub extern "msdrm" fn DRMSetGlobalOptions(
eGlobalOptions: DRMGLOBALOPTIONS,
pvdata: ?*anyopaque,
dwlen: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMGetClientVersion(
pDRMClientVersionInfo: ?*DRM_CLIENT_VERSION_INFO,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMInitEnvironment(
eSecurityProviderType: DRMSECURITYPROVIDERTYPE,
eSpecification: DRMSPECTYPE,
wszSecurityProvider: ?PWSTR,
wszManifestCredentials: ?PWSTR,
wszMachineCredentials: ?PWSTR,
phEnv: ?*u32,
phDefaultLibrary: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMLoadLibrary(
hEnv: u32,
eSpecification: DRMSPECTYPE,
wszLibraryProvider: ?PWSTR,
wszCredentials: ?PWSTR,
phLibrary: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMCreateEnablingPrincipal(
hEnv: u32,
hLibrary: u32,
wszObject: ?PWSTR,
pidPrincipal: ?*DRMID,
wszCredentials: ?PWSTR,
phEnablingPrincipal: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMCloseHandle(
handle: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMCloseEnvironmentHandle(
hEnv: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMDuplicateHandle(
hToCopy: u32,
phCopy: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMDuplicateEnvironmentHandle(
hToCopy: u32,
phCopy: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMRegisterRevocationList(
hEnv: u32,
wszRevocationList: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMCheckSecurity(
hEnv: u32,
cLevel: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMRegisterContent(
fRegister: BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMEncrypt(
hCryptoProvider: u32,
iPosition: u32,
cNumInBytes: u32,
pbInData: ?*u8,
pcNumOutBytes: ?*u32,
pbOutData: ?*u8,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMDecrypt(
hCryptoProvider: u32,
iPosition: u32,
cNumInBytes: u32,
pbInData: ?*u8,
pcNumOutBytes: ?*u32,
pbOutData: ?*u8,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMCreateBoundLicense(
hEnv: u32,
pParams: ?*DRMBOUNDLICENSEPARAMS,
wszLicenseChain: ?PWSTR,
phBoundLicense: ?*u32,
phErrorLog: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMCreateEnablingBitsDecryptor(
hBoundLicense: u32,
wszRight: ?PWSTR,
hAuxLib: u32,
wszAuxPlug: ?PWSTR,
phDecryptor: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMCreateEnablingBitsEncryptor(
hBoundLicense: u32,
wszRight: ?PWSTR,
hAuxLib: u32,
wszAuxPlug: ?PWSTR,
phEncryptor: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMAttest(
hEnablingPrincipal: u32,
wszData: ?PWSTR,
eType: DRMATTESTTYPE,
pcAttestedBlob: ?*u32,
wszAttestedBlob: [*:0]u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMGetTime(
hEnv: u32,
eTimerIdType: DRMTIMETYPE,
poTimeObject: ?*SYSTEMTIME,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMGetInfo(
handle: u32,
wszAttribute: ?PWSTR,
peEncoding: ?*DRMENCODINGTYPE,
pcBuffer: ?*u32,
pbBuffer: ?*u8,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMGetEnvironmentInfo(
handle: u32,
wszAttribute: ?PWSTR,
peEncoding: ?*DRMENCODINGTYPE,
pcBuffer: ?*u32,
pbBuffer: ?*u8,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMGetProcAddress(
hLibrary: u32,
wszProcName: ?PWSTR,
ppfnProcAddress: ?*?FARPROC,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMGetBoundLicenseObjectCount(
hQueryRoot: u32,
wszSubObjectType: ?PWSTR,
pcSubObjects: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMGetBoundLicenseObject(
hQueryRoot: u32,
wszSubObjectType: ?PWSTR,
iWhich: u32,
phSubObject: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMGetBoundLicenseAttributeCount(
hQueryRoot: u32,
wszAttribute: ?PWSTR,
pcAttributes: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMGetBoundLicenseAttribute(
hQueryRoot: u32,
wszAttribute: ?PWSTR,
iWhich: u32,
peEncoding: ?*DRMENCODINGTYPE,
pcBuffer: ?*u32,
pbBuffer: ?*u8,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMCreateClientSession(
pfnCallback: ?DRMCALLBACK,
uCallbackVersion: u32,
wszGroupIDProviderType: ?PWSTR,
wszGroupID: ?PWSTR,
phClient: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMIsActivated(
hClient: u32,
uFlags: u32,
pActServInfo: ?*DRM_ACTSERV_INFO,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMActivate(
hClient: u32,
uFlags: u32,
uLangID: u32,
pActServInfo: ?*DRM_ACTSERV_INFO,
pvContext: ?*anyopaque,
hParentWnd: ?HWND,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMGetServiceLocation(
hClient: u32,
uServiceType: u32,
uServiceLocation: u32,
wszIssuanceLicense: ?PWSTR,
puServiceURLLength: ?*u32,
wszServiceURL: ?[*:0]u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMCreateLicenseStorageSession(
hEnv: u32,
hDefaultLibrary: u32,
hClient: u32,
uFlags: u32,
wszIssuanceLicense: ?PWSTR,
phLicenseStorage: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMAddLicense(
hLicenseStorage: u32,
uFlags: u32,
wszLicense: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMAcquireAdvisories(
hLicenseStorage: u32,
wszLicense: ?PWSTR,
wszURL: ?PWSTR,
pvContext: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMEnumerateLicense(
hSession: u32,
uFlags: u32,
uIndex: u32,
pfSharedFlag: ?*BOOL,
puCertificateDataLen: ?*u32,
wszCertificateData: ?[*:0]u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMAcquireLicense(
hSession: u32,
uFlags: u32,
wszGroupIdentityCredential: ?PWSTR,
wszRequestedRights: ?PWSTR,
wszCustomData: ?PWSTR,
wszURL: ?PWSTR,
pvContext: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMDeleteLicense(
hSession: u32,
wszLicenseId: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMCloseSession(
hSession: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMDuplicateSession(
hSessionIn: u32,
phSessionOut: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMGetSecurityProvider(
uFlags: u32,
puTypeLen: ?*u32,
wszType: ?[*:0]u16,
puPathLen: ?*u32,
wszPath: ?[*:0]u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMEncode(
wszAlgID: ?PWSTR,
uDataLen: u32,
pbDecodedData: ?*u8,
puEncodedStringLen: ?*u32,
wszEncodedString: ?[*:0]u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMDecode(
wszAlgID: ?PWSTR,
wszEncodedString: ?PWSTR,
puDecodedDataLen: ?*u32,
pbDecodedData: ?*u8,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMConstructCertificateChain(
cCertificates: u32,
rgwszCertificates: [*]?PWSTR,
pcChain: ?*u32,
wszChain: ?[*:0]u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMParseUnboundLicense(
wszCertificate: ?PWSTR,
phQueryRoot: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMCloseQueryHandle(
hQuery: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMGetUnboundLicenseObjectCount(
hQueryRoot: u32,
wszSubObjectType: ?PWSTR,
pcSubObjects: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMGetUnboundLicenseObject(
hQueryRoot: u32,
wszSubObjectType: ?PWSTR,
iIndex: u32,
phSubQuery: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMGetUnboundLicenseAttributeCount(
hQueryRoot: u32,
wszAttributeType: ?PWSTR,
pcAttributes: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMGetUnboundLicenseAttribute(
hQueryRoot: u32,
wszAttributeType: ?PWSTR,
iWhich: u32,
peEncoding: ?*DRMENCODINGTYPE,
pcBuffer: ?*u32,
pbBuffer: ?*u8,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMGetCertificateChainCount(
wszChain: ?PWSTR,
pcCertCount: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMDeconstructCertificateChain(
wszChain: ?PWSTR,
iWhich: u32,
pcCert: ?*u32,
wszCert: ?[*:0]u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMVerify(
wszData: ?PWSTR,
pcAttestedData: ?*u32,
wszAttestedData: ?[*:0]u16,
peType: ?*DRMATTESTTYPE,
pcPrincipal: ?*u32,
wszPrincipal: ?[*:0]u16,
pcManifest: ?*u32,
wszManifest: ?[*:0]u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMCreateUser(
wszUserName: ?PWSTR,
wszUserId: ?PWSTR,
wszUserIdType: ?PWSTR,
phUser: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMCreateRight(
wszRightName: ?PWSTR,
pstFrom: ?*SYSTEMTIME,
pstUntil: ?*SYSTEMTIME,
cExtendedInfo: u32,
pwszExtendedInfoName: ?[*]?PWSTR,
pwszExtendedInfoValue: ?[*]?PWSTR,
phRight: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMCreateIssuanceLicense(
pstTimeFrom: ?*SYSTEMTIME,
pstTimeUntil: ?*SYSTEMTIME,
wszReferralInfoName: ?PWSTR,
wszReferralInfoURL: ?PWSTR,
hOwner: u32,
wszIssuanceLicense: ?PWSTR,
hBoundLicense: u32,
phIssuanceLicense: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMAddRightWithUser(
hIssuanceLicense: u32,
hRight: u32,
hUser: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMClearAllRights(
hIssuanceLicense: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMSetMetaData(
hIssuanceLicense: u32,
wszContentId: ?PWSTR,
wszContentIdType: ?PWSTR,
wszSKUId: ?PWSTR,
wszSKUIdType: ?PWSTR,
wszContentType: ?PWSTR,
wszContentName: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMSetUsagePolicy(
hIssuanceLicense: u32,
eUsagePolicyType: DRM_USAGEPOLICY_TYPE,
fDelete: BOOL,
fExclusion: BOOL,
wszName: ?PWSTR,
wszMinVersion: ?PWSTR,
wszMaxVersion: ?PWSTR,
wszPublicKey: ?PWSTR,
wszDigestAlgorithm: ?PWSTR,
pbDigest: ?*u8,
cbDigest: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMSetRevocationPoint(
hIssuanceLicense: u32,
fDelete: BOOL,
wszId: ?PWSTR,
wszIdType: ?PWSTR,
wszURL: ?PWSTR,
pstFrequency: ?*SYSTEMTIME,
wszName: ?PWSTR,
wszPublicKey: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMSetApplicationSpecificData(
hIssuanceLicense: u32,
fDelete: BOOL,
wszName: ?PWSTR,
wszValue: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMSetNameAndDescription(
hIssuanceLicense: u32,
fDelete: BOOL,
lcid: u32,
wszName: ?PWSTR,
wszDescription: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMSetIntervalTime(
hIssuanceLicense: u32,
cDays: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMGetIssuanceLicenseTemplate(
hIssuanceLicense: u32,
puIssuanceLicenseTemplateLength: ?*u32,
wszIssuanceLicenseTemplate: ?[*:0]u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMGetSignedIssuanceLicense(
hEnv: u32,
hIssuanceLicense: u32,
uFlags: u32,
pbSymKey: ?*u8,
cbSymKey: u32,
wszSymKeyType: ?PWSTR,
wszClientLicensorCertificate: ?PWSTR,
pfnCallback: ?DRMCALLBACK,
wszURL: ?PWSTR,
pvContext: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows6.1'
pub extern "msdrm" fn DRMGetSignedIssuanceLicenseEx(
hEnv: u32,
hIssuanceLicense: u32,
uFlags: u32,
// TODO: what to do with BytesParamIndex 4?
pbSymKey: ?*u8,
cbSymKey: u32,
wszSymKeyType: ?PWSTR,
pvReserved: ?*anyopaque,
hEnablingPrincipal: u32,
hBoundLicenseCLC: u32,
pfnCallback: ?DRMCALLBACK,
pvContext: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMClosePubHandle(
hPub: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMDuplicatePubHandle(
hPubIn: u32,
phPubOut: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMGetUserInfo(
hUser: u32,
puUserNameLength: ?*u32,
wszUserName: ?[*:0]u16,
puUserIdLength: ?*u32,
wszUserId: ?[*:0]u16,
puUserIdTypeLength: ?*u32,
wszUserIdType: ?[*:0]u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMGetRightInfo(
hRight: u32,
puRightNameLength: ?*u32,
wszRightName: ?[*:0]u16,
pstFrom: ?*SYSTEMTIME,
pstUntil: ?*SYSTEMTIME,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMGetRightExtendedInfo(
hRight: u32,
uIndex: u32,
puExtendedInfoNameLength: ?*u32,
wszExtendedInfoName: ?[*:0]u16,
puExtendedInfoValueLength: ?*u32,
wszExtendedInfoValue: ?[*:0]u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMGetUsers(
hIssuanceLicense: u32,
uIndex: u32,
phUser: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMGetUserRights(
hIssuanceLicense: u32,
hUser: u32,
uIndex: u32,
phRight: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMGetMetaData(
hIssuanceLicense: u32,
puContentIdLength: ?*u32,
wszContentId: ?[*:0]u16,
puContentIdTypeLength: ?*u32,
wszContentIdType: ?[*:0]u16,
puSKUIdLength: ?*u32,
wszSKUId: ?[*:0]u16,
puSKUIdTypeLength: ?*u32,
wszSKUIdType: ?[*:0]u16,
puContentTypeLength: ?*u32,
wszContentType: ?[*:0]u16,
puContentNameLength: ?*u32,
wszContentName: ?[*:0]u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMGetApplicationSpecificData(
hIssuanceLicense: u32,
uIndex: u32,
puNameLength: ?*u32,
wszName: ?[*:0]u16,
puValueLength: ?*u32,
wszValue: ?[*:0]u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMGetIssuanceLicenseInfo(
hIssuanceLicense: u32,
pstTimeFrom: ?*SYSTEMTIME,
pstTimeUntil: ?*SYSTEMTIME,
uFlags: u32,
puDistributionPointNameLength: ?*u32,
wszDistributionPointName: ?[*:0]u16,
puDistributionPointURLLength: ?*u32,
wszDistributionPointURL: ?[*:0]u16,
phOwner: ?*u32,
pfOfficial: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMGetRevocationPoint(
hIssuanceLicense: u32,
puIdLength: ?*u32,
wszId: ?[*:0]u16,
puIdTypeLength: ?*u32,
wszIdType: ?[*:0]u16,
puURLLength: ?*u32,
wszRL: ?[*:0]u16,
pstFrequency: ?*SYSTEMTIME,
puNameLength: ?*u32,
wszName: ?[*:0]u16,
puPublicKeyLength: ?*u32,
wszPublicKey: ?[*:0]u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMGetUsagePolicy(
hIssuanceLicense: u32,
uIndex: u32,
peUsagePolicyType: ?*DRM_USAGEPOLICY_TYPE,
pfExclusion: ?*BOOL,
puNameLength: ?*u32,
wszName: ?[*:0]u16,
puMinVersionLength: ?*u32,
wszMinVersion: ?[*:0]u16,
puMaxVersionLength: ?*u32,
wszMaxVersion: ?[*:0]u16,
puPublicKeyLength: ?*u32,
wszPublicKey: ?[*:0]u16,
puDigestAlgorithmLength: ?*u32,
wszDigestAlgorithm: ?[*:0]u16,
pcbDigest: ?*u32,
pbDigest: ?*u8,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMGetNameAndDescription(
hIssuanceLicense: u32,
uIndex: u32,
pulcid: ?*u32,
puNameLength: ?*u32,
wszName: ?[*:0]u16,
puDescriptionLength: ?*u32,
wszDescription: ?[*:0]u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMGetOwnerLicense(
hIssuanceLicense: u32,
puOwnerLicenseLength: ?*u32,
wszOwnerLicense: ?[*:0]u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMGetIntervalTime(
hIssuanceLicense: u32,
pcDays: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
pub extern "msdrm" fn DRMRepair(
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows6.0.6000'
pub extern "msdrm" fn DRMRegisterProtectedWindow(
hEnv: u32,
hwnd: ?HWND,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows6.0.6000'
pub extern "msdrm" fn DRMIsWindowProtected(
hwnd: ?HWND,
pfProtected: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows6.0.6000'
pub extern "msdrm" fn DRMAcquireIssuanceLicenseTemplate(
hClient: u32,
uFlags: u32,
pvReserved: ?*anyopaque,
cTemplates: u32,
pwszTemplateIds: ?[*]?PWSTR,
wszUrl: ?PWSTR,
pvContext: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
//--------------------------------------------------------------------------------
// Section: Unicode Aliases (0)
//--------------------------------------------------------------------------------
const thismodule = @This();
pub usingnamespace switch (@import("../zig.zig").unicode_mode) {
.ansi => struct {
},
.wide => struct {
},
.unspecified => if (@import("builtin").is_test) struct {
} else struct {
},
};
//--------------------------------------------------------------------------------
// Section: Imports (6)
//--------------------------------------------------------------------------------
const BOOL = @import("../foundation.zig").BOOL;
const FARPROC = @import("../foundation.zig").FARPROC;
const HRESULT = @import("../foundation.zig").HRESULT;
const HWND = @import("../foundation.zig").HWND;
const PWSTR = @import("../foundation.zig").PWSTR;
const SYSTEMTIME = @import("../foundation.zig").SYSTEMTIME;
test {
// The following '_ = <FuncPtrType>' lines are a workaround for https://github.com/ziglang/zig/issues/4476
if (@hasDecl(@This(), "DRMCALLBACK")) { _ = DRMCALLBACK; }
@setEvalBranchQuota(
@import("std").meta.declarations(@This()).len * 3
);
// reference all the pub declarations
if (!@import("builtin").is_test) return;
inline for (@import("std").meta.declarations(@This())) |decl| {
if (decl.is_pub) {
_ = decl;
}
}
} | win32/data/rights_management.zig |
const std = @import("std");
const debug = std.debug;
const mem = std.mem;
const FixedBufferAllocator = std.heap.FixedBufferAllocator;
const parse = @import("parse.zig");
const Parser = parse.Parser;
const Expr = parse.Expr;
const ParseError = parse.ParseError;
// Note: Switch to OutStream
var global_buffer: [2048]u8 = undefined;
const StaticWriter = struct {
buffer: []u8,
last: usize,
pub fn init(buffer: []u8) StaticWriter {
return StaticWriter{
.buffer = buffer,
.last = 0,
};
}
pub fn writeFn(self: *StaticWriter, bytes: []const u8) Error!usize {
mem.copy(u8, self.buffer[self.last..], bytes);
self.last += bytes.len;
return bytes.len;
}
pub const Error = error{OutOfMemory};
pub const Writer = std.io.Writer(*StaticWriter, Error, writeFn);
pub fn writer(self: *StaticWriter) Writer {
return .{ .context = self };
}
pub fn printCharEscaped(self: *StaticWriter, ch: u8) !void {
switch (ch) {
'\t' => {
try self.writer().print("\\t", .{});
},
'\r' => {
try self.writer().print("\\r", .{});
},
'\n' => {
try self.writer().print("\\n", .{});
},
// printable characters
32...126 => {
try self.writer().print("{c}", .{ch});
},
else => {
try self.writer().print("0x{x}", .{ch});
},
}
}
};
// Return a minimal string representation of the expression tree.
fn repr(e: *Expr) ![]u8 {
var stream = StaticWriter.init(global_buffer[0..]);
try reprIndent(&stream, e, 0);
return global_buffer[0..stream.last];
}
fn reprIndent(out: *StaticWriter, e: *Expr, indent: usize) anyerror!void {
var i: usize = 0;
while (i < indent) : (i += 1) {
try out.writer().print(" ", .{});
}
switch (e.*) {
Expr.AnyCharNotNL => {
try out.writer().print("dot\n", .{});
},
Expr.EmptyMatch => |assertion| {
try out.writer().print("empty({s})\n", .{@tagName(assertion)});
},
Expr.Literal => |lit| {
try out.writer().print("lit(", .{});
try out.printCharEscaped(lit);
try out.writer().print(")\n", .{});
},
Expr.Capture => |subexpr| {
try out.writer().print("cap\n", .{});
try reprIndent(out, subexpr, indent + 1);
},
Expr.Repeat => |repeat| {
try out.writer().print("rep(", .{});
if (repeat.min == 0 and repeat.max == null) {
try out.writer().print("*", .{});
} else if (repeat.min == 1 and repeat.max == null) {
try out.writer().print("+", .{});
} else if (repeat.min == 0 and repeat.max != null and repeat.max.? == 1) {
try out.writer().print("?", .{});
} else {
try out.writer().print("{{{d},", .{repeat.min});
if (repeat.max) |ok| {
try out.writer().print("{d}", .{ok});
}
try out.writer().print("}}", .{});
}
if (!repeat.greedy) {
try out.writer().print("?", .{});
}
try out.writer().print(")\n", .{});
try reprIndent(out, repeat.subexpr, indent + 1);
},
Expr.ByteClass => |class| {
try out.writer().print("bset(", .{});
for (class.ranges.items) |r| {
try out.writer().print("[", .{});
try out.printCharEscaped(r.min);
try out.writer().print("-", .{});
try out.printCharEscaped(r.max);
try out.writer().print("]", .{});
}
try out.writer().print(")\n", .{});
},
// TODO: Can we get better type unification on enum variants with the same type?
Expr.Concat => |subexprs| {
try out.writer().print("cat\n", .{});
for (subexprs.items) |s|
try reprIndent(out, s, indent + 1);
},
Expr.Alternate => |subexprs| {
try out.writer().print("alt\n", .{});
for (subexprs.items) |s|
try reprIndent(out, s, indent + 1);
},
// NOTE: Shouldn't occur ever in returned output.
Expr.PseudoLeftParen => {
try out.writer().print("{s}\n", .{@tagName(e.*)});
},
}
}
// Debug global allocator is too small for our tests
var fbuffer: [800000]u8 = undefined;
var fixed_allocator = FixedBufferAllocator.init(fbuffer[0..]);
fn check(re: []const u8, expected_ast: []const u8) void {
var p = Parser.init(&fixed_allocator.allocator);
const expr = p.parse(re) catch unreachable;
var ast = repr(expr) catch unreachable;
const spaces = [_]u8{ ' ', '\n' };
const trimmed_ast = mem.trim(u8, ast, &spaces);
const trimmed_expected_ast = mem.trim(u8, expected_ast, &spaces);
if (!mem.eql(u8, trimmed_ast, trimmed_expected_ast)) {
debug.warn(
\\
\\-- parsed the regex
\\
\\{s}
\\
\\-- expected the following
\\
\\{s}
\\
\\-- but instead got
\\
\\{s}
\\
, .{
re,
trimmed_expected_ast,
trimmed_ast,
});
@panic("assertion failure");
}
}
// These are taken off rust-regex for the moment.
test "parse simple" {
check(
\\
,
\\empty(None)
);
check(
\\a
,
\\lit(a)
);
check(
\\ab
,
\\cat
\\ lit(a)
\\ lit(b)
);
check(
\\^a
,
\\cat
\\ empty(BeginLine)
\\ lit(a)
);
check(
\\a?
,
\\rep(?)
\\ lit(a)
);
check(
\\ab?
,
\\cat
\\ lit(a)
\\ rep(?)
\\ lit(b)
);
check(
\\a??
,
\\rep(??)
\\ lit(a)
);
check(
\\a+
,
\\rep(+)
\\ lit(a)
);
check(
\\a+?
,
\\rep(+?)
\\ lit(a)
);
check(
\\a*?
,
\\rep(*?)
\\ lit(a)
);
check(
\\a{5}
,
\\rep({5,5})
\\ lit(a)
);
check(
\\a{5,}
,
\\rep({5,})
\\ lit(a)
);
check(
\\a{5,10}
,
\\rep({5,10})
\\ lit(a)
);
check(
\\a{5}?
,
\\rep({5,5}?)
\\ lit(a)
);
check(
\\a{5,}?
,
\\rep({5,}?)
\\ lit(a)
);
check(
\\a{ 5 }
,
\\rep({5,5})
\\ lit(a)
);
check(
\\(a)
,
\\cap
\\ lit(a)
);
check(
\\(ab)
,
\\cap
\\ cat
\\ lit(a)
\\ lit(b)
);
check(
\\a|b
,
\\alt
\\ lit(a)
\\ lit(b)
);
check(
\\a|b|c
,
\\alt
\\ lit(a)
\\ lit(b)
\\ lit(c)
);
check(
\\(a|b)
,
\\cap
\\ alt
\\ lit(a)
\\ lit(b)
);
check(
\\(a|b|c)
,
\\cap
\\ alt
\\ lit(a)
\\ lit(b)
\\ lit(c)
);
check(
\\(ab|bc|cd)
,
\\cap
\\ alt
\\ cat
\\ lit(a)
\\ lit(b)
\\ cat
\\ lit(b)
\\ lit(c)
\\ cat
\\ lit(c)
\\ lit(d)
);
check(
\\(ab|(bc|(cd)))
,
\\cap
\\ alt
\\ cat
\\ lit(a)
\\ lit(b)
\\ cap
\\ alt
\\ cat
\\ lit(b)
\\ lit(c)
\\ cap
\\ cat
\\ lit(c)
\\ lit(d)
);
check(
\\.
,
\\dot
);
}
test "parse escape" {
check(
\\\a\f\t\n\r\v
,
\\cat
\\ lit(0x7)
\\ lit(0xc)
\\ lit(\t)
\\ lit(\n)
\\ lit(\r)
\\ lit(0xb)
);
check(
\\\\\.\+\*\?\(\)\|\[\]\{\}\^\$
,
\\cat
\\ lit(\)
\\ lit(.)
\\ lit(+)
\\ lit(*)
\\ lit(?)
\\ lit(()
\\ lit())
\\ lit(|)
\\ lit([)
\\ lit(])
\\ lit({)
\\ lit(})
\\ lit(^)
\\ lit($)
);
check("\\123",
\\lit(S)
);
check("\\1234",
\\cat
\\ lit(S)
\\ lit(4)
);
check("\\x53",
\\lit(S)
);
check("\\x534",
\\cat
\\ lit(S)
\\ lit(4)
);
check("\\x{53}",
\\lit(S)
);
check("\\x{53}4",
\\cat
\\ lit(S)
\\ lit(4)
);
}
test "parse character classes" {
check(
\\[a]
,
\\bset([a-a])
);
check(
\\[\x00]
,
\\bset([0x0-0x0])
);
check(
\\[\n]
,
\\bset([\n-\n])
);
check(
\\[^a]
,
\\bset([0x0-`][b-0xff])
);
check(
\\[^\x00]
,
\\bset([0x1-0xff])
);
check(
\\[^\n]
,
\\bset([0x0-\t][0xb-0xff])
);
check(
\\[]]
,
\\bset([]-]])
);
check(
\\[]\[]
,
\\bset([[-[][]-]])
);
check(
\\[\[]]
,
\\cat
\\ bset([[-[])
\\ lit(])
);
check(
\\[]-]
,
\\bset([---][]-]])
);
check(
\\[-]]
,
\\cat
\\ bset([---])
\\ lit(])
);
}
fn checkError(re: []const u8, expected_err: ParseError) void {
var p = Parser.init(std.testing.allocator);
const parse_result = p.parse(re);
if (parse_result) |expr| {
const ast = repr(expr) catch unreachable;
const spaces = [_]u8{ ' ', '\n' };
const trimmed_ast = mem.trim(u8, ast, &spaces);
debug.warn(
\\
\\-- parsed the regex
\\
\\{s}
\\
\\-- expected the following
\\
\\{s}
\\
\\-- but instead got
\\
\\{s}
\\
\\
, .{
re,
@errorName(expected_err),
trimmed_ast,
});
@panic("assertion failure");
} else |found_err| {
if (found_err != expected_err) {
debug.warn(
\\
\\-- parsed the regex
\\
\\{s}
\\
\\-- expected the following
\\
\\{s}
\\
\\-- but instead got
\\
\\{s}
\\
\\
, .{
re,
@errorName(expected_err),
@errorName(found_err),
});
@panic("assertion failure");
}
}
}
test "parse errors repeat" {
checkError(
\\*
, ParseError.MissingRepeatOperand);
checkError(
\\(*
, ParseError.MissingRepeatOperand);
checkError(
\\({5}
, ParseError.MissingRepeatOperand);
checkError(
\\{5}
, ParseError.MissingRepeatOperand);
checkError(
\\a**
, ParseError.MissingRepeatOperand);
checkError(
\\a|*
, ParseError.MissingRepeatOperand);
checkError(
\\a*{5}
, ParseError.MissingRepeatOperand);
checkError(
\\a|{5}
, ParseError.MissingRepeatOperand);
checkError(
\\a{}
, ParseError.InvalidRepeatArgument);
checkError(
\\a{5
, ParseError.UnclosedRepeat);
checkError(
\\a{xyz
, ParseError.InvalidRepeatArgument);
checkError(
\\a{12,xyz
, ParseError.InvalidRepeatArgument);
checkError(
\\a{999999999999}
, ParseError.ExcessiveRepeatCount);
checkError(
\\a{1,999999999999}
, ParseError.ExcessiveRepeatCount);
checkError(
\\a{12x}
, ParseError.UnclosedRepeat);
checkError(
\\a{1,12x}
, ParseError.UnclosedRepeat);
}
test "parse errors alternate" {
checkError(
\\|a
, ParseError.EmptyAlternate);
checkError(
\\(|a)
, ParseError.EmptyAlternate);
checkError(
\\a||
, ParseError.EmptyAlternate);
checkError(
\\)
, ParseError.UnopenedParentheses);
checkError(
\\ab)
, ParseError.UnopenedParentheses);
checkError(
\\a|b)
, ParseError.UnopenedParentheses);
checkError(
\\(a|b
, ParseError.UnclosedParentheses);
//checkError(
// \\(a|)
//,
// ParseError.UnopenedParentheses
//);
//checkError(
// \\()
//,
// ParseError.UnopenedParentheses
//);
checkError(
\\ab(xy
, ParseError.UnclosedParentheses);
//checkError(
// \\()
//,
// ParseError.UnopenedParentheses
//);
//checkError(
// \\a|
//,
// ParseError.UnbalancedParentheses
//);
}
test "parse errors escape" {
checkError("\\", ParseError.OpenEscapeCode);
checkError("\\m", ParseError.UnrecognizedEscapeCode);
checkError("\\x", ParseError.InvalidHexDigit);
//checkError(
// "\\xA"
//,
// ParseError.UnrecognizedEscapeCode
//);
//checkError(
// "\\xAG"
//,
// ParseError.UnrecognizedEscapeCode
//);
checkError("\\x{", ParseError.InvalidHexDigit);
checkError("\\x{A", ParseError.UnclosedHexCharacterCode);
checkError("\\x{AG}", ParseError.UnclosedHexCharacterCode);
checkError("\\x{D800}", ParseError.InvalidHexDigit);
checkError("\\x{110000}", ParseError.InvalidHexDigit);
checkError("\\x{99999999999999}", ParseError.InvalidHexDigit);
}
test "parse errors character class" {
checkError(
\\[
, ParseError.UnclosedBrackets);
checkError(
\\[^
, ParseError.UnclosedBrackets);
checkError(
\\[a
, ParseError.UnclosedBrackets);
checkError(
\\[^a
, ParseError.UnclosedBrackets);
checkError(
\\[a-
, ParseError.UnclosedBrackets);
checkError(
\\[^a-
, ParseError.UnclosedBrackets);
checkError(
\\[---
, ParseError.UnclosedBrackets);
checkError(
\\[\A]
, ParseError.UnrecognizedEscapeCode);
//checkError(
// \\[a-\d]
//,
// ParseError.UnclosedBrackets
//);
//checkError(
// \\[a-\A]
//,
// ParseError.UnrecognizedEscapeCode
//);
checkError(
\\[\A-a]
, ParseError.UnrecognizedEscapeCode);
//checkError(
// \\[z-a]
//,
// ParseError.UnclosedBrackets
//);
checkError(
\\[]
, ParseError.UnclosedBrackets);
checkError(
\\[^]
, ParseError.UnclosedBrackets);
//checkError(
// \\[^\d\D]
//,
// ParseError.UnclosedBrackets
//);
//checkError(
// \\[+--]
//,
// ParseError.UnclosedBrackets
//);
//checkError(
// \\[a-a--\xFF]
//,
// ParseError.UnclosedBrackets
//);
} | src/parse_test.zig |
pub fn Register(comptime R: type) type {
return RegisterRW(R, R);
}
pub fn RegisterRW(comptime Read: type, comptime Write: type) type {
return struct {
raw_ptr: *volatile u32,
const Self = @This();
pub fn init(address: usize) Self {
return Self{ .raw_ptr = @intToPtr(*volatile u32, address) };
}
pub fn initRange(address: usize, comptime dim_increment: usize, comptime num_registers: usize) [num_registers]Self {
var registers: [num_registers]Self = undefined;
var i: usize = 0;
while (i < num_registers) : (i += 1) {
registers[i] = Self.init(address + (i * dim_increment));
}
return registers;
}
pub fn read(self: Self) Read {
return @bitCast(Read, self.raw_ptr.*);
}
pub fn write(self: Self, value: Write) void {
self.raw_ptr.* = @bitCast(u32, value);
}
pub fn modify(self: Self, new_value: anytype) void {
if (Read != Write) {
@compileError("Can't modify because read and write types for this register aren't the same.");
}
var old_value = self.read();
const info = @typeInfo(@TypeOf(new_value));
inline for (info.Struct.fields) |field| {
@field(old_value, field.name) = @field(new_value, field.name);
}
self.write(old_value);
}
pub fn read_raw(self: Self) u32 {
return self.raw_ptr.*;
}
pub fn write_raw(self: Self, value: u32) void {
self.raw_ptr.* = value;
}
pub fn default_read_value(self: Self) Read {
return Read{};
}
pub fn default_write_value(self: Self) Write {
return Write{};
}
};
}
pub const device_name = "STM32F303xE";
pub const device_revision = "1.0";
pub const device_description = "STM32F303xE";
/// General-purpose I/Os
pub const GPIOA = struct {
const base_address = 0x48000000;
/// MODER
const MODER_val = packed struct {
/// MODER0 [0:1]
/// Port x configuration bits (y = 0..15)
MODER0: u2 = 0,
/// MODER1 [2:3]
/// Port x configuration bits (y = 0..15)
MODER1: u2 = 0,
/// MODER2 [4:5]
/// Port x configuration bits (y = 0..15)
MODER2: u2 = 0,
/// MODER3 [6:7]
/// Port x configuration bits (y = 0..15)
MODER3: u2 = 0,
/// MODER4 [8:9]
/// Port x configuration bits (y = 0..15)
MODER4: u2 = 0,
/// MODER5 [10:11]
/// Port x configuration bits (y = 0..15)
MODER5: u2 = 0,
/// MODER6 [12:13]
/// Port x configuration bits (y = 0..15)
MODER6: u2 = 0,
/// MODER7 [14:15]
/// Port x configuration bits (y = 0..15)
MODER7: u2 = 0,
/// MODER8 [16:17]
/// Port x configuration bits (y = 0..15)
MODER8: u2 = 0,
/// MODER9 [18:19]
/// Port x configuration bits (y = 0..15)
MODER9: u2 = 0,
/// MODER10 [20:21]
/// Port x configuration bits (y = 0..15)
MODER10: u2 = 0,
/// MODER11 [22:23]
/// Port x configuration bits (y = 0..15)
MODER11: u2 = 0,
/// MODER12 [24:25]
/// Port x configuration bits (y = 0..15)
MODER12: u2 = 0,
/// MODER13 [26:27]
/// Port x configuration bits (y = 0..15)
MODER13: u2 = 2,
/// MODER14 [28:29]
/// Port x configuration bits (y = 0..15)
MODER14: u2 = 2,
/// MODER15 [30:31]
/// Port x configuration bits (y = 0..15)
MODER15: u2 = 0,
};
/// GPIO port mode register
pub const MODER = Register(MODER_val).init(base_address + 0x0);
/// OTYPER
const OTYPER_val = packed struct {
/// OT0 [0:0]
/// Port x configuration bits (y = 0..15)
OT0: u1 = 0,
/// OT1 [1:1]
/// Port x configuration bits (y = 0..15)
OT1: u1 = 0,
/// OT2 [2:2]
/// Port x configuration bits (y = 0..15)
OT2: u1 = 0,
/// OT3 [3:3]
/// Port x configuration bits (y = 0..15)
OT3: u1 = 0,
/// OT4 [4:4]
/// Port x configuration bits (y = 0..15)
OT4: u1 = 0,
/// OT5 [5:5]
/// Port x configuration bits (y = 0..15)
OT5: u1 = 0,
/// OT6 [6:6]
/// Port x configuration bits (y = 0..15)
OT6: u1 = 0,
/// OT7 [7:7]
/// Port x configuration bits (y = 0..15)
OT7: u1 = 0,
/// OT8 [8:8]
/// Port x configuration bits (y = 0..15)
OT8: u1 = 0,
/// OT9 [9:9]
/// Port x configuration bits (y = 0..15)
OT9: u1 = 0,
/// OT10 [10:10]
/// Port x configuration bits (y = 0..15)
OT10: u1 = 0,
/// OT11 [11:11]
/// Port x configuration bits (y = 0..15)
OT11: u1 = 0,
/// OT12 [12:12]
/// Port x configuration bits (y = 0..15)
OT12: u1 = 0,
/// OT13 [13:13]
/// Port x configuration bits (y = 0..15)
OT13: u1 = 0,
/// OT14 [14:14]
/// Port x configuration bits (y = 0..15)
OT14: u1 = 0,
/// OT15 [15:15]
/// Port x configuration bits (y = 0..15)
OT15: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// GPIO port output type register
pub const OTYPER = Register(OTYPER_val).init(base_address + 0x4);
/// OSPEEDR
const OSPEEDR_val = packed struct {
/// OSPEEDR0 [0:1]
/// Port x configuration bits (y = 0..15)
OSPEEDR0: u2 = 0,
/// OSPEEDR1 [2:3]
/// Port x configuration bits (y = 0..15)
OSPEEDR1: u2 = 0,
/// OSPEEDR2 [4:5]
/// Port x configuration bits (y = 0..15)
OSPEEDR2: u2 = 0,
/// OSPEEDR3 [6:7]
/// Port x configuration bits (y = 0..15)
OSPEEDR3: u2 = 0,
/// OSPEEDR4 [8:9]
/// Port x configuration bits (y = 0..15)
OSPEEDR4: u2 = 0,
/// OSPEEDR5 [10:11]
/// Port x configuration bits (y = 0..15)
OSPEEDR5: u2 = 0,
/// OSPEEDR6 [12:13]
/// Port x configuration bits (y = 0..15)
OSPEEDR6: u2 = 0,
/// OSPEEDR7 [14:15]
/// Port x configuration bits (y = 0..15)
OSPEEDR7: u2 = 0,
/// OSPEEDR8 [16:17]
/// Port x configuration bits (y = 0..15)
OSPEEDR8: u2 = 0,
/// OSPEEDR9 [18:19]
/// Port x configuration bits (y = 0..15)
OSPEEDR9: u2 = 0,
/// OSPEEDR10 [20:21]
/// Port x configuration bits (y = 0..15)
OSPEEDR10: u2 = 0,
/// OSPEEDR11 [22:23]
/// Port x configuration bits (y = 0..15)
OSPEEDR11: u2 = 0,
/// OSPEEDR12 [24:25]
/// Port x configuration bits (y = 0..15)
OSPEEDR12: u2 = 0,
/// OSPEEDR13 [26:27]
/// Port x configuration bits (y = 0..15)
OSPEEDR13: u2 = 0,
/// OSPEEDR14 [28:29]
/// Port x configuration bits (y = 0..15)
OSPEEDR14: u2 = 0,
/// OSPEEDR15 [30:31]
/// Port x configuration bits (y = 0..15)
OSPEEDR15: u2 = 0,
};
/// GPIO port output speed register
pub const OSPEEDR = Register(OSPEEDR_val).init(base_address + 0x8);
/// PUPDR
const PUPDR_val = packed struct {
/// PUPDR0 [0:1]
/// Port x configuration bits (y = 0..15)
PUPDR0: u2 = 0,
/// PUPDR1 [2:3]
/// Port x configuration bits (y = 0..15)
PUPDR1: u2 = 0,
/// PUPDR2 [4:5]
/// Port x configuration bits (y = 0..15)
PUPDR2: u2 = 0,
/// PUPDR3 [6:7]
/// Port x configuration bits (y = 0..15)
PUPDR3: u2 = 0,
/// PUPDR4 [8:9]
/// Port x configuration bits (y = 0..15)
PUPDR4: u2 = 0,
/// PUPDR5 [10:11]
/// Port x configuration bits (y = 0..15)
PUPDR5: u2 = 0,
/// PUPDR6 [12:13]
/// Port x configuration bits (y = 0..15)
PUPDR6: u2 = 0,
/// PUPDR7 [14:15]
/// Port x configuration bits (y = 0..15)
PUPDR7: u2 = 0,
/// PUPDR8 [16:17]
/// Port x configuration bits (y = 0..15)
PUPDR8: u2 = 0,
/// PUPDR9 [18:19]
/// Port x configuration bits (y = 0..15)
PUPDR9: u2 = 0,
/// PUPDR10 [20:21]
/// Port x configuration bits (y = 0..15)
PUPDR10: u2 = 0,
/// PUPDR11 [22:23]
/// Port x configuration bits (y = 0..15)
PUPDR11: u2 = 0,
/// PUPDR12 [24:25]
/// Port x configuration bits (y = 0..15)
PUPDR12: u2 = 0,
/// PUPDR13 [26:27]
/// Port x configuration bits (y = 0..15)
PUPDR13: u2 = 1,
/// PUPDR14 [28:29]
/// Port x configuration bits (y = 0..15)
PUPDR14: u2 = 2,
/// PUPDR15 [30:31]
/// Port x configuration bits (y = 0..15)
PUPDR15: u2 = 0,
};
/// GPIO port pull-up/pull-down register
pub const PUPDR = Register(PUPDR_val).init(base_address + 0xc);
/// IDR
const IDR_val = packed struct {
/// IDR0 [0:0]
/// Port input data (y = 0..15)
IDR0: u1 = 0,
/// IDR1 [1:1]
/// Port input data (y = 0..15)
IDR1: u1 = 0,
/// IDR2 [2:2]
/// Port input data (y = 0..15)
IDR2: u1 = 0,
/// IDR3 [3:3]
/// Port input data (y = 0..15)
IDR3: u1 = 0,
/// IDR4 [4:4]
/// Port input data (y = 0..15)
IDR4: u1 = 0,
/// IDR5 [5:5]
/// Port input data (y = 0..15)
IDR5: u1 = 0,
/// IDR6 [6:6]
/// Port input data (y = 0..15)
IDR6: u1 = 0,
/// IDR7 [7:7]
/// Port input data (y = 0..15)
IDR7: u1 = 0,
/// IDR8 [8:8]
/// Port input data (y = 0..15)
IDR8: u1 = 0,
/// IDR9 [9:9]
/// Port input data (y = 0..15)
IDR9: u1 = 0,
/// IDR10 [10:10]
/// Port input data (y = 0..15)
IDR10: u1 = 0,
/// IDR11 [11:11]
/// Port input data (y = 0..15)
IDR11: u1 = 0,
/// IDR12 [12:12]
/// Port input data (y = 0..15)
IDR12: u1 = 0,
/// IDR13 [13:13]
/// Port input data (y = 0..15)
IDR13: u1 = 0,
/// IDR14 [14:14]
/// Port input data (y = 0..15)
IDR14: u1 = 0,
/// IDR15 [15:15]
/// Port input data (y = 0..15)
IDR15: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// GPIO port input data register
pub const IDR = Register(IDR_val).init(base_address + 0x10);
/// ODR
const ODR_val = packed struct {
/// ODR0 [0:0]
/// Port output data (y = 0..15)
ODR0: u1 = 0,
/// ODR1 [1:1]
/// Port output data (y = 0..15)
ODR1: u1 = 0,
/// ODR2 [2:2]
/// Port output data (y = 0..15)
ODR2: u1 = 0,
/// ODR3 [3:3]
/// Port output data (y = 0..15)
ODR3: u1 = 0,
/// ODR4 [4:4]
/// Port output data (y = 0..15)
ODR4: u1 = 0,
/// ODR5 [5:5]
/// Port output data (y = 0..15)
ODR5: u1 = 0,
/// ODR6 [6:6]
/// Port output data (y = 0..15)
ODR6: u1 = 0,
/// ODR7 [7:7]
/// Port output data (y = 0..15)
ODR7: u1 = 0,
/// ODR8 [8:8]
/// Port output data (y = 0..15)
ODR8: u1 = 0,
/// ODR9 [9:9]
/// Port output data (y = 0..15)
ODR9: u1 = 0,
/// ODR10 [10:10]
/// Port output data (y = 0..15)
ODR10: u1 = 0,
/// ODR11 [11:11]
/// Port output data (y = 0..15)
ODR11: u1 = 0,
/// ODR12 [12:12]
/// Port output data (y = 0..15)
ODR12: u1 = 0,
/// ODR13 [13:13]
/// Port output data (y = 0..15)
ODR13: u1 = 0,
/// ODR14 [14:14]
/// Port output data (y = 0..15)
ODR14: u1 = 0,
/// ODR15 [15:15]
/// Port output data (y = 0..15)
ODR15: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// GPIO port output data register
pub const ODR = Register(ODR_val).init(base_address + 0x14);
/// BSRR
const BSRR_val = packed struct {
/// BS0 [0:0]
/// Port x set bit y (y= 0..15)
BS0: u1 = 0,
/// BS1 [1:1]
/// Port x set bit y (y= 0..15)
BS1: u1 = 0,
/// BS2 [2:2]
/// Port x set bit y (y= 0..15)
BS2: u1 = 0,
/// BS3 [3:3]
/// Port x set bit y (y= 0..15)
BS3: u1 = 0,
/// BS4 [4:4]
/// Port x set bit y (y= 0..15)
BS4: u1 = 0,
/// BS5 [5:5]
/// Port x set bit y (y= 0..15)
BS5: u1 = 0,
/// BS6 [6:6]
/// Port x set bit y (y= 0..15)
BS6: u1 = 0,
/// BS7 [7:7]
/// Port x set bit y (y= 0..15)
BS7: u1 = 0,
/// BS8 [8:8]
/// Port x set bit y (y= 0..15)
BS8: u1 = 0,
/// BS9 [9:9]
/// Port x set bit y (y= 0..15)
BS9: u1 = 0,
/// BS10 [10:10]
/// Port x set bit y (y= 0..15)
BS10: u1 = 0,
/// BS11 [11:11]
/// Port x set bit y (y= 0..15)
BS11: u1 = 0,
/// BS12 [12:12]
/// Port x set bit y (y= 0..15)
BS12: u1 = 0,
/// BS13 [13:13]
/// Port x set bit y (y= 0..15)
BS13: u1 = 0,
/// BS14 [14:14]
/// Port x set bit y (y= 0..15)
BS14: u1 = 0,
/// BS15 [15:15]
/// Port x set bit y (y= 0..15)
BS15: u1 = 0,
/// BR0 [16:16]
/// Port x set bit y (y= 0..15)
BR0: u1 = 0,
/// BR1 [17:17]
/// Port x reset bit y (y = 0..15)
BR1: u1 = 0,
/// BR2 [18:18]
/// Port x reset bit y (y = 0..15)
BR2: u1 = 0,
/// BR3 [19:19]
/// Port x reset bit y (y = 0..15)
BR3: u1 = 0,
/// BR4 [20:20]
/// Port x reset bit y (y = 0..15)
BR4: u1 = 0,
/// BR5 [21:21]
/// Port x reset bit y (y = 0..15)
BR5: u1 = 0,
/// BR6 [22:22]
/// Port x reset bit y (y = 0..15)
BR6: u1 = 0,
/// BR7 [23:23]
/// Port x reset bit y (y = 0..15)
BR7: u1 = 0,
/// BR8 [24:24]
/// Port x reset bit y (y = 0..15)
BR8: u1 = 0,
/// BR9 [25:25]
/// Port x reset bit y (y = 0..15)
BR9: u1 = 0,
/// BR10 [26:26]
/// Port x reset bit y (y = 0..15)
BR10: u1 = 0,
/// BR11 [27:27]
/// Port x reset bit y (y = 0..15)
BR11: u1 = 0,
/// BR12 [28:28]
/// Port x reset bit y (y = 0..15)
BR12: u1 = 0,
/// BR13 [29:29]
/// Port x reset bit y (y = 0..15)
BR13: u1 = 0,
/// BR14 [30:30]
/// Port x reset bit y (y = 0..15)
BR14: u1 = 0,
/// BR15 [31:31]
/// Port x reset bit y (y = 0..15)
BR15: u1 = 0,
};
/// GPIO port bit set/reset register
pub const BSRR = Register(BSRR_val).init(base_address + 0x18);
/// LCKR
const LCKR_val = packed struct {
/// LCK0 [0:0]
/// Port x lock bit y (y= 0..15)
LCK0: u1 = 0,
/// LCK1 [1:1]
/// Port x lock bit y (y= 0..15)
LCK1: u1 = 0,
/// LCK2 [2:2]
/// Port x lock bit y (y= 0..15)
LCK2: u1 = 0,
/// LCK3 [3:3]
/// Port x lock bit y (y= 0..15)
LCK3: u1 = 0,
/// LCK4 [4:4]
/// Port x lock bit y (y= 0..15)
LCK4: u1 = 0,
/// LCK5 [5:5]
/// Port x lock bit y (y= 0..15)
LCK5: u1 = 0,
/// LCK6 [6:6]
/// Port x lock bit y (y= 0..15)
LCK6: u1 = 0,
/// LCK7 [7:7]
/// Port x lock bit y (y= 0..15)
LCK7: u1 = 0,
/// LCK8 [8:8]
/// Port x lock bit y (y= 0..15)
LCK8: u1 = 0,
/// LCK9 [9:9]
/// Port x lock bit y (y= 0..15)
LCK9: u1 = 0,
/// LCK10 [10:10]
/// Port x lock bit y (y= 0..15)
LCK10: u1 = 0,
/// LCK11 [11:11]
/// Port x lock bit y (y= 0..15)
LCK11: u1 = 0,
/// LCK12 [12:12]
/// Port x lock bit y (y= 0..15)
LCK12: u1 = 0,
/// LCK13 [13:13]
/// Port x lock bit y (y= 0..15)
LCK13: u1 = 0,
/// LCK14 [14:14]
/// Port x lock bit y (y= 0..15)
LCK14: u1 = 0,
/// LCK15 [15:15]
/// Port x lock bit y (y= 0..15)
LCK15: u1 = 0,
/// LCKK [16:16]
/// Lok Key
LCKK: u1 = 0,
/// unused [17:31]
_unused17: u7 = 0,
_unused24: u8 = 0,
};
/// GPIO port configuration lock register
pub const LCKR = Register(LCKR_val).init(base_address + 0x1c);
/// AFRL
const AFRL_val = packed struct {
/// AFRL0 [0:3]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL0: u4 = 0,
/// AFRL1 [4:7]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL1: u4 = 0,
/// AFRL2 [8:11]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL2: u4 = 0,
/// AFRL3 [12:15]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL3: u4 = 0,
/// AFRL4 [16:19]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL4: u4 = 0,
/// AFRL5 [20:23]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL5: u4 = 0,
/// AFRL6 [24:27]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL6: u4 = 0,
/// AFRL7 [28:31]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL7: u4 = 0,
};
/// GPIO alternate function low register
pub const AFRL = Register(AFRL_val).init(base_address + 0x20);
/// AFRH
const AFRH_val = packed struct {
/// AFRH8 [0:3]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH8: u4 = 0,
/// AFRH9 [4:7]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH9: u4 = 0,
/// AFRH10 [8:11]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH10: u4 = 0,
/// AFRH11 [12:15]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH11: u4 = 0,
/// AFRH12 [16:19]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH12: u4 = 0,
/// AFRH13 [20:23]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH13: u4 = 0,
/// AFRH14 [24:27]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH14: u4 = 0,
/// AFRH15 [28:31]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH15: u4 = 0,
};
/// GPIO alternate function high register
pub const AFRH = Register(AFRH_val).init(base_address + 0x24);
/// BRR
const BRR_val = packed struct {
/// BR0 [0:0]
/// Port x Reset bit y
BR0: u1 = 0,
/// BR1 [1:1]
/// Port x Reset bit y
BR1: u1 = 0,
/// BR2 [2:2]
/// Port x Reset bit y
BR2: u1 = 0,
/// BR3 [3:3]
/// Port x Reset bit y
BR3: u1 = 0,
/// BR4 [4:4]
/// Port x Reset bit y
BR4: u1 = 0,
/// BR5 [5:5]
/// Port x Reset bit y
BR5: u1 = 0,
/// BR6 [6:6]
/// Port x Reset bit y
BR6: u1 = 0,
/// BR7 [7:7]
/// Port x Reset bit y
BR7: u1 = 0,
/// BR8 [8:8]
/// Port x Reset bit y
BR8: u1 = 0,
/// BR9 [9:9]
/// Port x Reset bit y
BR9: u1 = 0,
/// BR10 [10:10]
/// Port x Reset bit y
BR10: u1 = 0,
/// BR11 [11:11]
/// Port x Reset bit y
BR11: u1 = 0,
/// BR12 [12:12]
/// Port x Reset bit y
BR12: u1 = 0,
/// BR13 [13:13]
/// Port x Reset bit y
BR13: u1 = 0,
/// BR14 [14:14]
/// Port x Reset bit y
BR14: u1 = 0,
/// BR15 [15:15]
/// Port x Reset bit y
BR15: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Port bit reset register
pub const BRR = Register(BRR_val).init(base_address + 0x28);
};
/// General-purpose I/Os
pub const GPIOB = struct {
const base_address = 0x48000400;
/// MODER
const MODER_val = packed struct {
/// MODER0 [0:1]
/// Port x configuration bits (y = 0..15)
MODER0: u2 = 0,
/// MODER1 [2:3]
/// Port x configuration bits (y = 0..15)
MODER1: u2 = 0,
/// MODER2 [4:5]
/// Port x configuration bits (y = 0..15)
MODER2: u2 = 0,
/// MODER3 [6:7]
/// Port x configuration bits (y = 0..15)
MODER3: u2 = 0,
/// MODER4 [8:9]
/// Port x configuration bits (y = 0..15)
MODER4: u2 = 0,
/// MODER5 [10:11]
/// Port x configuration bits (y = 0..15)
MODER5: u2 = 0,
/// MODER6 [12:13]
/// Port x configuration bits (y = 0..15)
MODER6: u2 = 0,
/// MODER7 [14:15]
/// Port x configuration bits (y = 0..15)
MODER7: u2 = 0,
/// MODER8 [16:17]
/// Port x configuration bits (y = 0..15)
MODER8: u2 = 0,
/// MODER9 [18:19]
/// Port x configuration bits (y = 0..15)
MODER9: u2 = 0,
/// MODER10 [20:21]
/// Port x configuration bits (y = 0..15)
MODER10: u2 = 0,
/// MODER11 [22:23]
/// Port x configuration bits (y = 0..15)
MODER11: u2 = 0,
/// MODER12 [24:25]
/// Port x configuration bits (y = 0..15)
MODER12: u2 = 0,
/// MODER13 [26:27]
/// Port x configuration bits (y = 0..15)
MODER13: u2 = 0,
/// MODER14 [28:29]
/// Port x configuration bits (y = 0..15)
MODER14: u2 = 0,
/// MODER15 [30:31]
/// Port x configuration bits (y = 0..15)
MODER15: u2 = 0,
};
/// GPIO port mode register
pub const MODER = Register(MODER_val).init(base_address + 0x0);
/// OTYPER
const OTYPER_val = packed struct {
/// OT0 [0:0]
/// Port x configuration bit 0
OT0: u1 = 0,
/// OT1 [1:1]
/// Port x configuration bit 1
OT1: u1 = 0,
/// OT2 [2:2]
/// Port x configuration bit 2
OT2: u1 = 0,
/// OT3 [3:3]
/// Port x configuration bit 3
OT3: u1 = 0,
/// OT4 [4:4]
/// Port x configuration bit 4
OT4: u1 = 0,
/// OT5 [5:5]
/// Port x configuration bit 5
OT5: u1 = 0,
/// OT6 [6:6]
/// Port x configuration bit 6
OT6: u1 = 0,
/// OT7 [7:7]
/// Port x configuration bit 7
OT7: u1 = 0,
/// OT8 [8:8]
/// Port x configuration bit 8
OT8: u1 = 0,
/// OT9 [9:9]
/// Port x configuration bit 9
OT9: u1 = 0,
/// OT10 [10:10]
/// Port x configuration bit 10
OT10: u1 = 0,
/// OT11 [11:11]
/// Port x configuration bit 11
OT11: u1 = 0,
/// OT12 [12:12]
/// Port x configuration bit 12
OT12: u1 = 0,
/// OT13 [13:13]
/// Port x configuration bit 13
OT13: u1 = 0,
/// OT14 [14:14]
/// Port x configuration bit 14
OT14: u1 = 0,
/// OT15 [15:15]
/// Port x configuration bit 15
OT15: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// GPIO port output type register
pub const OTYPER = Register(OTYPER_val).init(base_address + 0x4);
/// OSPEEDR
const OSPEEDR_val = packed struct {
/// OSPEEDR0 [0:1]
/// Port x configuration bits (y = 0..15)
OSPEEDR0: u2 = 0,
/// OSPEEDR1 [2:3]
/// Port x configuration bits (y = 0..15)
OSPEEDR1: u2 = 0,
/// OSPEEDR2 [4:5]
/// Port x configuration bits (y = 0..15)
OSPEEDR2: u2 = 0,
/// OSPEEDR3 [6:7]
/// Port x configuration bits (y = 0..15)
OSPEEDR3: u2 = 0,
/// OSPEEDR4 [8:9]
/// Port x configuration bits (y = 0..15)
OSPEEDR4: u2 = 0,
/// OSPEEDR5 [10:11]
/// Port x configuration bits (y = 0..15)
OSPEEDR5: u2 = 0,
/// OSPEEDR6 [12:13]
/// Port x configuration bits (y = 0..15)
OSPEEDR6: u2 = 0,
/// OSPEEDR7 [14:15]
/// Port x configuration bits (y = 0..15)
OSPEEDR7: u2 = 0,
/// OSPEEDR8 [16:17]
/// Port x configuration bits (y = 0..15)
OSPEEDR8: u2 = 0,
/// OSPEEDR9 [18:19]
/// Port x configuration bits (y = 0..15)
OSPEEDR9: u2 = 0,
/// OSPEEDR10 [20:21]
/// Port x configuration bits (y = 0..15)
OSPEEDR10: u2 = 0,
/// OSPEEDR11 [22:23]
/// Port x configuration bits (y = 0..15)
OSPEEDR11: u2 = 0,
/// OSPEEDR12 [24:25]
/// Port x configuration bits (y = 0..15)
OSPEEDR12: u2 = 0,
/// OSPEEDR13 [26:27]
/// Port x configuration bits (y = 0..15)
OSPEEDR13: u2 = 0,
/// OSPEEDR14 [28:29]
/// Port x configuration bits (y = 0..15)
OSPEEDR14: u2 = 0,
/// OSPEEDR15 [30:31]
/// Port x configuration bits (y = 0..15)
OSPEEDR15: u2 = 0,
};
/// GPIO port output speed register
pub const OSPEEDR = Register(OSPEEDR_val).init(base_address + 0x8);
/// PUPDR
const PUPDR_val = packed struct {
/// PUPDR0 [0:1]
/// Port x configuration bits (y = 0..15)
PUPDR0: u2 = 0,
/// PUPDR1 [2:3]
/// Port x configuration bits (y = 0..15)
PUPDR1: u2 = 0,
/// PUPDR2 [4:5]
/// Port x configuration bits (y = 0..15)
PUPDR2: u2 = 0,
/// PUPDR3 [6:7]
/// Port x configuration bits (y = 0..15)
PUPDR3: u2 = 0,
/// PUPDR4 [8:9]
/// Port x configuration bits (y = 0..15)
PUPDR4: u2 = 0,
/// PUPDR5 [10:11]
/// Port x configuration bits (y = 0..15)
PUPDR5: u2 = 0,
/// PUPDR6 [12:13]
/// Port x configuration bits (y = 0..15)
PUPDR6: u2 = 0,
/// PUPDR7 [14:15]
/// Port x configuration bits (y = 0..15)
PUPDR7: u2 = 0,
/// PUPDR8 [16:17]
/// Port x configuration bits (y = 0..15)
PUPDR8: u2 = 0,
/// PUPDR9 [18:19]
/// Port x configuration bits (y = 0..15)
PUPDR9: u2 = 0,
/// PUPDR10 [20:21]
/// Port x configuration bits (y = 0..15)
PUPDR10: u2 = 0,
/// PUPDR11 [22:23]
/// Port x configuration bits (y = 0..15)
PUPDR11: u2 = 0,
/// PUPDR12 [24:25]
/// Port x configuration bits (y = 0..15)
PUPDR12: u2 = 0,
/// PUPDR13 [26:27]
/// Port x configuration bits (y = 0..15)
PUPDR13: u2 = 0,
/// PUPDR14 [28:29]
/// Port x configuration bits (y = 0..15)
PUPDR14: u2 = 0,
/// PUPDR15 [30:31]
/// Port x configuration bits (y = 0..15)
PUPDR15: u2 = 0,
};
/// GPIO port pull-up/pull-down register
pub const PUPDR = Register(PUPDR_val).init(base_address + 0xc);
/// IDR
const IDR_val = packed struct {
/// IDR0 [0:0]
/// Port input data (y = 0..15)
IDR0: u1 = 0,
/// IDR1 [1:1]
/// Port input data (y = 0..15)
IDR1: u1 = 0,
/// IDR2 [2:2]
/// Port input data (y = 0..15)
IDR2: u1 = 0,
/// IDR3 [3:3]
/// Port input data (y = 0..15)
IDR3: u1 = 0,
/// IDR4 [4:4]
/// Port input data (y = 0..15)
IDR4: u1 = 0,
/// IDR5 [5:5]
/// Port input data (y = 0..15)
IDR5: u1 = 0,
/// IDR6 [6:6]
/// Port input data (y = 0..15)
IDR6: u1 = 0,
/// IDR7 [7:7]
/// Port input data (y = 0..15)
IDR7: u1 = 0,
/// IDR8 [8:8]
/// Port input data (y = 0..15)
IDR8: u1 = 0,
/// IDR9 [9:9]
/// Port input data (y = 0..15)
IDR9: u1 = 0,
/// IDR10 [10:10]
/// Port input data (y = 0..15)
IDR10: u1 = 0,
/// IDR11 [11:11]
/// Port input data (y = 0..15)
IDR11: u1 = 0,
/// IDR12 [12:12]
/// Port input data (y = 0..15)
IDR12: u1 = 0,
/// IDR13 [13:13]
/// Port input data (y = 0..15)
IDR13: u1 = 0,
/// IDR14 [14:14]
/// Port input data (y = 0..15)
IDR14: u1 = 0,
/// IDR15 [15:15]
/// Port input data (y = 0..15)
IDR15: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// GPIO port input data register
pub const IDR = Register(IDR_val).init(base_address + 0x10);
/// ODR
const ODR_val = packed struct {
/// ODR0 [0:0]
/// Port output data (y = 0..15)
ODR0: u1 = 0,
/// ODR1 [1:1]
/// Port output data (y = 0..15)
ODR1: u1 = 0,
/// ODR2 [2:2]
/// Port output data (y = 0..15)
ODR2: u1 = 0,
/// ODR3 [3:3]
/// Port output data (y = 0..15)
ODR3: u1 = 0,
/// ODR4 [4:4]
/// Port output data (y = 0..15)
ODR4: u1 = 0,
/// ODR5 [5:5]
/// Port output data (y = 0..15)
ODR5: u1 = 0,
/// ODR6 [6:6]
/// Port output data (y = 0..15)
ODR6: u1 = 0,
/// ODR7 [7:7]
/// Port output data (y = 0..15)
ODR7: u1 = 0,
/// ODR8 [8:8]
/// Port output data (y = 0..15)
ODR8: u1 = 0,
/// ODR9 [9:9]
/// Port output data (y = 0..15)
ODR9: u1 = 0,
/// ODR10 [10:10]
/// Port output data (y = 0..15)
ODR10: u1 = 0,
/// ODR11 [11:11]
/// Port output data (y = 0..15)
ODR11: u1 = 0,
/// ODR12 [12:12]
/// Port output data (y = 0..15)
ODR12: u1 = 0,
/// ODR13 [13:13]
/// Port output data (y = 0..15)
ODR13: u1 = 0,
/// ODR14 [14:14]
/// Port output data (y = 0..15)
ODR14: u1 = 0,
/// ODR15 [15:15]
/// Port output data (y = 0..15)
ODR15: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// GPIO port output data register
pub const ODR = Register(ODR_val).init(base_address + 0x14);
/// BSRR
const BSRR_val = packed struct {
/// BS0 [0:0]
/// Port x set bit y (y= 0..15)
BS0: u1 = 0,
/// BS1 [1:1]
/// Port x set bit y (y= 0..15)
BS1: u1 = 0,
/// BS2 [2:2]
/// Port x set bit y (y= 0..15)
BS2: u1 = 0,
/// BS3 [3:3]
/// Port x set bit y (y= 0..15)
BS3: u1 = 0,
/// BS4 [4:4]
/// Port x set bit y (y= 0..15)
BS4: u1 = 0,
/// BS5 [5:5]
/// Port x set bit y (y= 0..15)
BS5: u1 = 0,
/// BS6 [6:6]
/// Port x set bit y (y= 0..15)
BS6: u1 = 0,
/// BS7 [7:7]
/// Port x set bit y (y= 0..15)
BS7: u1 = 0,
/// BS8 [8:8]
/// Port x set bit y (y= 0..15)
BS8: u1 = 0,
/// BS9 [9:9]
/// Port x set bit y (y= 0..15)
BS9: u1 = 0,
/// BS10 [10:10]
/// Port x set bit y (y= 0..15)
BS10: u1 = 0,
/// BS11 [11:11]
/// Port x set bit y (y= 0..15)
BS11: u1 = 0,
/// BS12 [12:12]
/// Port x set bit y (y= 0..15)
BS12: u1 = 0,
/// BS13 [13:13]
/// Port x set bit y (y= 0..15)
BS13: u1 = 0,
/// BS14 [14:14]
/// Port x set bit y (y= 0..15)
BS14: u1 = 0,
/// BS15 [15:15]
/// Port x set bit y (y= 0..15)
BS15: u1 = 0,
/// BR0 [16:16]
/// Port x set bit y (y= 0..15)
BR0: u1 = 0,
/// BR1 [17:17]
/// Port x reset bit y (y = 0..15)
BR1: u1 = 0,
/// BR2 [18:18]
/// Port x reset bit y (y = 0..15)
BR2: u1 = 0,
/// BR3 [19:19]
/// Port x reset bit y (y = 0..15)
BR3: u1 = 0,
/// BR4 [20:20]
/// Port x reset bit y (y = 0..15)
BR4: u1 = 0,
/// BR5 [21:21]
/// Port x reset bit y (y = 0..15)
BR5: u1 = 0,
/// BR6 [22:22]
/// Port x reset bit y (y = 0..15)
BR6: u1 = 0,
/// BR7 [23:23]
/// Port x reset bit y (y = 0..15)
BR7: u1 = 0,
/// BR8 [24:24]
/// Port x reset bit y (y = 0..15)
BR8: u1 = 0,
/// BR9 [25:25]
/// Port x reset bit y (y = 0..15)
BR9: u1 = 0,
/// BR10 [26:26]
/// Port x reset bit y (y = 0..15)
BR10: u1 = 0,
/// BR11 [27:27]
/// Port x reset bit y (y = 0..15)
BR11: u1 = 0,
/// BR12 [28:28]
/// Port x reset bit y (y = 0..15)
BR12: u1 = 0,
/// BR13 [29:29]
/// Port x reset bit y (y = 0..15)
BR13: u1 = 0,
/// BR14 [30:30]
/// Port x reset bit y (y = 0..15)
BR14: u1 = 0,
/// BR15 [31:31]
/// Port x reset bit y (y = 0..15)
BR15: u1 = 0,
};
/// GPIO port bit set/reset register
pub const BSRR = Register(BSRR_val).init(base_address + 0x18);
/// LCKR
const LCKR_val = packed struct {
/// LCK0 [0:0]
/// Port x lock bit y (y= 0..15)
LCK0: u1 = 0,
/// LCK1 [1:1]
/// Port x lock bit y (y= 0..15)
LCK1: u1 = 0,
/// LCK2 [2:2]
/// Port x lock bit y (y= 0..15)
LCK2: u1 = 0,
/// LCK3 [3:3]
/// Port x lock bit y (y= 0..15)
LCK3: u1 = 0,
/// LCK4 [4:4]
/// Port x lock bit y (y= 0..15)
LCK4: u1 = 0,
/// LCK5 [5:5]
/// Port x lock bit y (y= 0..15)
LCK5: u1 = 0,
/// LCK6 [6:6]
/// Port x lock bit y (y= 0..15)
LCK6: u1 = 0,
/// LCK7 [7:7]
/// Port x lock bit y (y= 0..15)
LCK7: u1 = 0,
/// LCK8 [8:8]
/// Port x lock bit y (y= 0..15)
LCK8: u1 = 0,
/// LCK9 [9:9]
/// Port x lock bit y (y= 0..15)
LCK9: u1 = 0,
/// LCK10 [10:10]
/// Port x lock bit y (y= 0..15)
LCK10: u1 = 0,
/// LCK11 [11:11]
/// Port x lock bit y (y= 0..15)
LCK11: u1 = 0,
/// LCK12 [12:12]
/// Port x lock bit y (y= 0..15)
LCK12: u1 = 0,
/// LCK13 [13:13]
/// Port x lock bit y (y= 0..15)
LCK13: u1 = 0,
/// LCK14 [14:14]
/// Port x lock bit y (y= 0..15)
LCK14: u1 = 0,
/// LCK15 [15:15]
/// Port x lock bit y (y= 0..15)
LCK15: u1 = 0,
/// LCKK [16:16]
/// Lok Key
LCKK: u1 = 0,
/// unused [17:31]
_unused17: u7 = 0,
_unused24: u8 = 0,
};
/// GPIO port configuration lock register
pub const LCKR = Register(LCKR_val).init(base_address + 0x1c);
/// AFRL
const AFRL_val = packed struct {
/// AFRL0 [0:3]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL0: u4 = 0,
/// AFRL1 [4:7]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL1: u4 = 0,
/// AFRL2 [8:11]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL2: u4 = 0,
/// AFRL3 [12:15]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL3: u4 = 0,
/// AFRL4 [16:19]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL4: u4 = 0,
/// AFRL5 [20:23]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL5: u4 = 0,
/// AFRL6 [24:27]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL6: u4 = 0,
/// AFRL7 [28:31]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL7: u4 = 0,
};
/// GPIO alternate function low register
pub const AFRL = Register(AFRL_val).init(base_address + 0x20);
/// AFRH
const AFRH_val = packed struct {
/// AFRH8 [0:3]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH8: u4 = 0,
/// AFRH9 [4:7]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH9: u4 = 0,
/// AFRH10 [8:11]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH10: u4 = 0,
/// AFRH11 [12:15]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH11: u4 = 0,
/// AFRH12 [16:19]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH12: u4 = 0,
/// AFRH13 [20:23]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH13: u4 = 0,
/// AFRH14 [24:27]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH14: u4 = 0,
/// AFRH15 [28:31]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH15: u4 = 0,
};
/// GPIO alternate function high register
pub const AFRH = Register(AFRH_val).init(base_address + 0x24);
/// BRR
const BRR_val = packed struct {
/// BR0 [0:0]
/// Port x Reset bit y
BR0: u1 = 0,
/// BR1 [1:1]
/// Port x Reset bit y
BR1: u1 = 0,
/// BR2 [2:2]
/// Port x Reset bit y
BR2: u1 = 0,
/// BR3 [3:3]
/// Port x Reset bit y
BR3: u1 = 0,
/// BR4 [4:4]
/// Port x Reset bit y
BR4: u1 = 0,
/// BR5 [5:5]
/// Port x Reset bit y
BR5: u1 = 0,
/// BR6 [6:6]
/// Port x Reset bit y
BR6: u1 = 0,
/// BR7 [7:7]
/// Port x Reset bit y
BR7: u1 = 0,
/// BR8 [8:8]
/// Port x Reset bit y
BR8: u1 = 0,
/// BR9 [9:9]
/// Port x Reset bit y
BR9: u1 = 0,
/// BR10 [10:10]
/// Port x Reset bit y
BR10: u1 = 0,
/// BR11 [11:11]
/// Port x Reset bit y
BR11: u1 = 0,
/// BR12 [12:12]
/// Port x Reset bit y
BR12: u1 = 0,
/// BR13 [13:13]
/// Port x Reset bit y
BR13: u1 = 0,
/// BR14 [14:14]
/// Port x Reset bit y
BR14: u1 = 0,
/// BR15 [15:15]
/// Port x Reset bit y
BR15: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Port bit reset register
pub const BRR = Register(BRR_val).init(base_address + 0x28);
};
/// General-purpose I/Os
pub const GPIOC = struct {
const base_address = 0x48000800;
/// MODER
const MODER_val = packed struct {
/// MODER0 [0:1]
/// Port x configuration bits (y = 0..15)
MODER0: u2 = 0,
/// MODER1 [2:3]
/// Port x configuration bits (y = 0..15)
MODER1: u2 = 0,
/// MODER2 [4:5]
/// Port x configuration bits (y = 0..15)
MODER2: u2 = 0,
/// MODER3 [6:7]
/// Port x configuration bits (y = 0..15)
MODER3: u2 = 0,
/// MODER4 [8:9]
/// Port x configuration bits (y = 0..15)
MODER4: u2 = 0,
/// MODER5 [10:11]
/// Port x configuration bits (y = 0..15)
MODER5: u2 = 0,
/// MODER6 [12:13]
/// Port x configuration bits (y = 0..15)
MODER6: u2 = 0,
/// MODER7 [14:15]
/// Port x configuration bits (y = 0..15)
MODER7: u2 = 0,
/// MODER8 [16:17]
/// Port x configuration bits (y = 0..15)
MODER8: u2 = 0,
/// MODER9 [18:19]
/// Port x configuration bits (y = 0..15)
MODER9: u2 = 0,
/// MODER10 [20:21]
/// Port x configuration bits (y = 0..15)
MODER10: u2 = 0,
/// MODER11 [22:23]
/// Port x configuration bits (y = 0..15)
MODER11: u2 = 0,
/// MODER12 [24:25]
/// Port x configuration bits (y = 0..15)
MODER12: u2 = 0,
/// MODER13 [26:27]
/// Port x configuration bits (y = 0..15)
MODER13: u2 = 0,
/// MODER14 [28:29]
/// Port x configuration bits (y = 0..15)
MODER14: u2 = 0,
/// MODER15 [30:31]
/// Port x configuration bits (y = 0..15)
MODER15: u2 = 0,
};
/// GPIO port mode register
pub const MODER = Register(MODER_val).init(base_address + 0x0);
/// OTYPER
const OTYPER_val = packed struct {
/// OT0 [0:0]
/// Port x configuration bit 0
OT0: u1 = 0,
/// OT1 [1:1]
/// Port x configuration bit 1
OT1: u1 = 0,
/// OT2 [2:2]
/// Port x configuration bit 2
OT2: u1 = 0,
/// OT3 [3:3]
/// Port x configuration bit 3
OT3: u1 = 0,
/// OT4 [4:4]
/// Port x configuration bit 4
OT4: u1 = 0,
/// OT5 [5:5]
/// Port x configuration bit 5
OT5: u1 = 0,
/// OT6 [6:6]
/// Port x configuration bit 6
OT6: u1 = 0,
/// OT7 [7:7]
/// Port x configuration bit 7
OT7: u1 = 0,
/// OT8 [8:8]
/// Port x configuration bit 8
OT8: u1 = 0,
/// OT9 [9:9]
/// Port x configuration bit 9
OT9: u1 = 0,
/// OT10 [10:10]
/// Port x configuration bit 10
OT10: u1 = 0,
/// OT11 [11:11]
/// Port x configuration bit 11
OT11: u1 = 0,
/// OT12 [12:12]
/// Port x configuration bit 12
OT12: u1 = 0,
/// OT13 [13:13]
/// Port x configuration bit 13
OT13: u1 = 0,
/// OT14 [14:14]
/// Port x configuration bit 14
OT14: u1 = 0,
/// OT15 [15:15]
/// Port x configuration bit 15
OT15: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// GPIO port output type register
pub const OTYPER = Register(OTYPER_val).init(base_address + 0x4);
/// OSPEEDR
const OSPEEDR_val = packed struct {
/// OSPEEDR0 [0:1]
/// Port x configuration bits (y = 0..15)
OSPEEDR0: u2 = 0,
/// OSPEEDR1 [2:3]
/// Port x configuration bits (y = 0..15)
OSPEEDR1: u2 = 0,
/// OSPEEDR2 [4:5]
/// Port x configuration bits (y = 0..15)
OSPEEDR2: u2 = 0,
/// OSPEEDR3 [6:7]
/// Port x configuration bits (y = 0..15)
OSPEEDR3: u2 = 0,
/// OSPEEDR4 [8:9]
/// Port x configuration bits (y = 0..15)
OSPEEDR4: u2 = 0,
/// OSPEEDR5 [10:11]
/// Port x configuration bits (y = 0..15)
OSPEEDR5: u2 = 0,
/// OSPEEDR6 [12:13]
/// Port x configuration bits (y = 0..15)
OSPEEDR6: u2 = 0,
/// OSPEEDR7 [14:15]
/// Port x configuration bits (y = 0..15)
OSPEEDR7: u2 = 0,
/// OSPEEDR8 [16:17]
/// Port x configuration bits (y = 0..15)
OSPEEDR8: u2 = 0,
/// OSPEEDR9 [18:19]
/// Port x configuration bits (y = 0..15)
OSPEEDR9: u2 = 0,
/// OSPEEDR10 [20:21]
/// Port x configuration bits (y = 0..15)
OSPEEDR10: u2 = 0,
/// OSPEEDR11 [22:23]
/// Port x configuration bits (y = 0..15)
OSPEEDR11: u2 = 0,
/// OSPEEDR12 [24:25]
/// Port x configuration bits (y = 0..15)
OSPEEDR12: u2 = 0,
/// OSPEEDR13 [26:27]
/// Port x configuration bits (y = 0..15)
OSPEEDR13: u2 = 0,
/// OSPEEDR14 [28:29]
/// Port x configuration bits (y = 0..15)
OSPEEDR14: u2 = 0,
/// OSPEEDR15 [30:31]
/// Port x configuration bits (y = 0..15)
OSPEEDR15: u2 = 0,
};
/// GPIO port output speed register
pub const OSPEEDR = Register(OSPEEDR_val).init(base_address + 0x8);
/// PUPDR
const PUPDR_val = packed struct {
/// PUPDR0 [0:1]
/// Port x configuration bits (y = 0..15)
PUPDR0: u2 = 0,
/// PUPDR1 [2:3]
/// Port x configuration bits (y = 0..15)
PUPDR1: u2 = 0,
/// PUPDR2 [4:5]
/// Port x configuration bits (y = 0..15)
PUPDR2: u2 = 0,
/// PUPDR3 [6:7]
/// Port x configuration bits (y = 0..15)
PUPDR3: u2 = 0,
/// PUPDR4 [8:9]
/// Port x configuration bits (y = 0..15)
PUPDR4: u2 = 0,
/// PUPDR5 [10:11]
/// Port x configuration bits (y = 0..15)
PUPDR5: u2 = 0,
/// PUPDR6 [12:13]
/// Port x configuration bits (y = 0..15)
PUPDR6: u2 = 0,
/// PUPDR7 [14:15]
/// Port x configuration bits (y = 0..15)
PUPDR7: u2 = 0,
/// PUPDR8 [16:17]
/// Port x configuration bits (y = 0..15)
PUPDR8: u2 = 0,
/// PUPDR9 [18:19]
/// Port x configuration bits (y = 0..15)
PUPDR9: u2 = 0,
/// PUPDR10 [20:21]
/// Port x configuration bits (y = 0..15)
PUPDR10: u2 = 0,
/// PUPDR11 [22:23]
/// Port x configuration bits (y = 0..15)
PUPDR11: u2 = 0,
/// PUPDR12 [24:25]
/// Port x configuration bits (y = 0..15)
PUPDR12: u2 = 0,
/// PUPDR13 [26:27]
/// Port x configuration bits (y = 0..15)
PUPDR13: u2 = 0,
/// PUPDR14 [28:29]
/// Port x configuration bits (y = 0..15)
PUPDR14: u2 = 0,
/// PUPDR15 [30:31]
/// Port x configuration bits (y = 0..15)
PUPDR15: u2 = 0,
};
/// GPIO port pull-up/pull-down register
pub const PUPDR = Register(PUPDR_val).init(base_address + 0xc);
/// IDR
const IDR_val = packed struct {
/// IDR0 [0:0]
/// Port input data (y = 0..15)
IDR0: u1 = 0,
/// IDR1 [1:1]
/// Port input data (y = 0..15)
IDR1: u1 = 0,
/// IDR2 [2:2]
/// Port input data (y = 0..15)
IDR2: u1 = 0,
/// IDR3 [3:3]
/// Port input data (y = 0..15)
IDR3: u1 = 0,
/// IDR4 [4:4]
/// Port input data (y = 0..15)
IDR4: u1 = 0,
/// IDR5 [5:5]
/// Port input data (y = 0..15)
IDR5: u1 = 0,
/// IDR6 [6:6]
/// Port input data (y = 0..15)
IDR6: u1 = 0,
/// IDR7 [7:7]
/// Port input data (y = 0..15)
IDR7: u1 = 0,
/// IDR8 [8:8]
/// Port input data (y = 0..15)
IDR8: u1 = 0,
/// IDR9 [9:9]
/// Port input data (y = 0..15)
IDR9: u1 = 0,
/// IDR10 [10:10]
/// Port input data (y = 0..15)
IDR10: u1 = 0,
/// IDR11 [11:11]
/// Port input data (y = 0..15)
IDR11: u1 = 0,
/// IDR12 [12:12]
/// Port input data (y = 0..15)
IDR12: u1 = 0,
/// IDR13 [13:13]
/// Port input data (y = 0..15)
IDR13: u1 = 0,
/// IDR14 [14:14]
/// Port input data (y = 0..15)
IDR14: u1 = 0,
/// IDR15 [15:15]
/// Port input data (y = 0..15)
IDR15: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// GPIO port input data register
pub const IDR = Register(IDR_val).init(base_address + 0x10);
/// ODR
const ODR_val = packed struct {
/// ODR0 [0:0]
/// Port output data (y = 0..15)
ODR0: u1 = 0,
/// ODR1 [1:1]
/// Port output data (y = 0..15)
ODR1: u1 = 0,
/// ODR2 [2:2]
/// Port output data (y = 0..15)
ODR2: u1 = 0,
/// ODR3 [3:3]
/// Port output data (y = 0..15)
ODR3: u1 = 0,
/// ODR4 [4:4]
/// Port output data (y = 0..15)
ODR4: u1 = 0,
/// ODR5 [5:5]
/// Port output data (y = 0..15)
ODR5: u1 = 0,
/// ODR6 [6:6]
/// Port output data (y = 0..15)
ODR6: u1 = 0,
/// ODR7 [7:7]
/// Port output data (y = 0..15)
ODR7: u1 = 0,
/// ODR8 [8:8]
/// Port output data (y = 0..15)
ODR8: u1 = 0,
/// ODR9 [9:9]
/// Port output data (y = 0..15)
ODR9: u1 = 0,
/// ODR10 [10:10]
/// Port output data (y = 0..15)
ODR10: u1 = 0,
/// ODR11 [11:11]
/// Port output data (y = 0..15)
ODR11: u1 = 0,
/// ODR12 [12:12]
/// Port output data (y = 0..15)
ODR12: u1 = 0,
/// ODR13 [13:13]
/// Port output data (y = 0..15)
ODR13: u1 = 0,
/// ODR14 [14:14]
/// Port output data (y = 0..15)
ODR14: u1 = 0,
/// ODR15 [15:15]
/// Port output data (y = 0..15)
ODR15: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// GPIO port output data register
pub const ODR = Register(ODR_val).init(base_address + 0x14);
/// BSRR
const BSRR_val = packed struct {
/// BS0 [0:0]
/// Port x set bit y (y= 0..15)
BS0: u1 = 0,
/// BS1 [1:1]
/// Port x set bit y (y= 0..15)
BS1: u1 = 0,
/// BS2 [2:2]
/// Port x set bit y (y= 0..15)
BS2: u1 = 0,
/// BS3 [3:3]
/// Port x set bit y (y= 0..15)
BS3: u1 = 0,
/// BS4 [4:4]
/// Port x set bit y (y= 0..15)
BS4: u1 = 0,
/// BS5 [5:5]
/// Port x set bit y (y= 0..15)
BS5: u1 = 0,
/// BS6 [6:6]
/// Port x set bit y (y= 0..15)
BS6: u1 = 0,
/// BS7 [7:7]
/// Port x set bit y (y= 0..15)
BS7: u1 = 0,
/// BS8 [8:8]
/// Port x set bit y (y= 0..15)
BS8: u1 = 0,
/// BS9 [9:9]
/// Port x set bit y (y= 0..15)
BS9: u1 = 0,
/// BS10 [10:10]
/// Port x set bit y (y= 0..15)
BS10: u1 = 0,
/// BS11 [11:11]
/// Port x set bit y (y= 0..15)
BS11: u1 = 0,
/// BS12 [12:12]
/// Port x set bit y (y= 0..15)
BS12: u1 = 0,
/// BS13 [13:13]
/// Port x set bit y (y= 0..15)
BS13: u1 = 0,
/// BS14 [14:14]
/// Port x set bit y (y= 0..15)
BS14: u1 = 0,
/// BS15 [15:15]
/// Port x set bit y (y= 0..15)
BS15: u1 = 0,
/// BR0 [16:16]
/// Port x set bit y (y= 0..15)
BR0: u1 = 0,
/// BR1 [17:17]
/// Port x reset bit y (y = 0..15)
BR1: u1 = 0,
/// BR2 [18:18]
/// Port x reset bit y (y = 0..15)
BR2: u1 = 0,
/// BR3 [19:19]
/// Port x reset bit y (y = 0..15)
BR3: u1 = 0,
/// BR4 [20:20]
/// Port x reset bit y (y = 0..15)
BR4: u1 = 0,
/// BR5 [21:21]
/// Port x reset bit y (y = 0..15)
BR5: u1 = 0,
/// BR6 [22:22]
/// Port x reset bit y (y = 0..15)
BR6: u1 = 0,
/// BR7 [23:23]
/// Port x reset bit y (y = 0..15)
BR7: u1 = 0,
/// BR8 [24:24]
/// Port x reset bit y (y = 0..15)
BR8: u1 = 0,
/// BR9 [25:25]
/// Port x reset bit y (y = 0..15)
BR9: u1 = 0,
/// BR10 [26:26]
/// Port x reset bit y (y = 0..15)
BR10: u1 = 0,
/// BR11 [27:27]
/// Port x reset bit y (y = 0..15)
BR11: u1 = 0,
/// BR12 [28:28]
/// Port x reset bit y (y = 0..15)
BR12: u1 = 0,
/// BR13 [29:29]
/// Port x reset bit y (y = 0..15)
BR13: u1 = 0,
/// BR14 [30:30]
/// Port x reset bit y (y = 0..15)
BR14: u1 = 0,
/// BR15 [31:31]
/// Port x reset bit y (y = 0..15)
BR15: u1 = 0,
};
/// GPIO port bit set/reset register
pub const BSRR = Register(BSRR_val).init(base_address + 0x18);
/// LCKR
const LCKR_val = packed struct {
/// LCK0 [0:0]
/// Port x lock bit y (y= 0..15)
LCK0: u1 = 0,
/// LCK1 [1:1]
/// Port x lock bit y (y= 0..15)
LCK1: u1 = 0,
/// LCK2 [2:2]
/// Port x lock bit y (y= 0..15)
LCK2: u1 = 0,
/// LCK3 [3:3]
/// Port x lock bit y (y= 0..15)
LCK3: u1 = 0,
/// LCK4 [4:4]
/// Port x lock bit y (y= 0..15)
LCK4: u1 = 0,
/// LCK5 [5:5]
/// Port x lock bit y (y= 0..15)
LCK5: u1 = 0,
/// LCK6 [6:6]
/// Port x lock bit y (y= 0..15)
LCK6: u1 = 0,
/// LCK7 [7:7]
/// Port x lock bit y (y= 0..15)
LCK7: u1 = 0,
/// LCK8 [8:8]
/// Port x lock bit y (y= 0..15)
LCK8: u1 = 0,
/// LCK9 [9:9]
/// Port x lock bit y (y= 0..15)
LCK9: u1 = 0,
/// LCK10 [10:10]
/// Port x lock bit y (y= 0..15)
LCK10: u1 = 0,
/// LCK11 [11:11]
/// Port x lock bit y (y= 0..15)
LCK11: u1 = 0,
/// LCK12 [12:12]
/// Port x lock bit y (y= 0..15)
LCK12: u1 = 0,
/// LCK13 [13:13]
/// Port x lock bit y (y= 0..15)
LCK13: u1 = 0,
/// LCK14 [14:14]
/// Port x lock bit y (y= 0..15)
LCK14: u1 = 0,
/// LCK15 [15:15]
/// Port x lock bit y (y= 0..15)
LCK15: u1 = 0,
/// LCKK [16:16]
/// Lok Key
LCKK: u1 = 0,
/// unused [17:31]
_unused17: u7 = 0,
_unused24: u8 = 0,
};
/// GPIO port configuration lock register
pub const LCKR = Register(LCKR_val).init(base_address + 0x1c);
/// AFRL
const AFRL_val = packed struct {
/// AFRL0 [0:3]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL0: u4 = 0,
/// AFRL1 [4:7]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL1: u4 = 0,
/// AFRL2 [8:11]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL2: u4 = 0,
/// AFRL3 [12:15]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL3: u4 = 0,
/// AFRL4 [16:19]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL4: u4 = 0,
/// AFRL5 [20:23]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL5: u4 = 0,
/// AFRL6 [24:27]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL6: u4 = 0,
/// AFRL7 [28:31]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL7: u4 = 0,
};
/// GPIO alternate function low register
pub const AFRL = Register(AFRL_val).init(base_address + 0x20);
/// AFRH
const AFRH_val = packed struct {
/// AFRH8 [0:3]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH8: u4 = 0,
/// AFRH9 [4:7]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH9: u4 = 0,
/// AFRH10 [8:11]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH10: u4 = 0,
/// AFRH11 [12:15]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH11: u4 = 0,
/// AFRH12 [16:19]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH12: u4 = 0,
/// AFRH13 [20:23]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH13: u4 = 0,
/// AFRH14 [24:27]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH14: u4 = 0,
/// AFRH15 [28:31]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH15: u4 = 0,
};
/// GPIO alternate function high register
pub const AFRH = Register(AFRH_val).init(base_address + 0x24);
/// BRR
const BRR_val = packed struct {
/// BR0 [0:0]
/// Port x Reset bit y
BR0: u1 = 0,
/// BR1 [1:1]
/// Port x Reset bit y
BR1: u1 = 0,
/// BR2 [2:2]
/// Port x Reset bit y
BR2: u1 = 0,
/// BR3 [3:3]
/// Port x Reset bit y
BR3: u1 = 0,
/// BR4 [4:4]
/// Port x Reset bit y
BR4: u1 = 0,
/// BR5 [5:5]
/// Port x Reset bit y
BR5: u1 = 0,
/// BR6 [6:6]
/// Port x Reset bit y
BR6: u1 = 0,
/// BR7 [7:7]
/// Port x Reset bit y
BR7: u1 = 0,
/// BR8 [8:8]
/// Port x Reset bit y
BR8: u1 = 0,
/// BR9 [9:9]
/// Port x Reset bit y
BR9: u1 = 0,
/// BR10 [10:10]
/// Port x Reset bit y
BR10: u1 = 0,
/// BR11 [11:11]
/// Port x Reset bit y
BR11: u1 = 0,
/// BR12 [12:12]
/// Port x Reset bit y
BR12: u1 = 0,
/// BR13 [13:13]
/// Port x Reset bit y
BR13: u1 = 0,
/// BR14 [14:14]
/// Port x Reset bit y
BR14: u1 = 0,
/// BR15 [15:15]
/// Port x Reset bit y
BR15: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Port bit reset register
pub const BRR = Register(BRR_val).init(base_address + 0x28);
};
/// General-purpose I/Os
pub const GPIOD = struct {
const base_address = 0x48000c00;
/// MODER
const MODER_val = packed struct {
/// MODER0 [0:1]
/// Port x configuration bits (y = 0..15)
MODER0: u2 = 0,
/// MODER1 [2:3]
/// Port x configuration bits (y = 0..15)
MODER1: u2 = 0,
/// MODER2 [4:5]
/// Port x configuration bits (y = 0..15)
MODER2: u2 = 0,
/// MODER3 [6:7]
/// Port x configuration bits (y = 0..15)
MODER3: u2 = 0,
/// MODER4 [8:9]
/// Port x configuration bits (y = 0..15)
MODER4: u2 = 0,
/// MODER5 [10:11]
/// Port x configuration bits (y = 0..15)
MODER5: u2 = 0,
/// MODER6 [12:13]
/// Port x configuration bits (y = 0..15)
MODER6: u2 = 0,
/// MODER7 [14:15]
/// Port x configuration bits (y = 0..15)
MODER7: u2 = 0,
/// MODER8 [16:17]
/// Port x configuration bits (y = 0..15)
MODER8: u2 = 0,
/// MODER9 [18:19]
/// Port x configuration bits (y = 0..15)
MODER9: u2 = 0,
/// MODER10 [20:21]
/// Port x configuration bits (y = 0..15)
MODER10: u2 = 0,
/// MODER11 [22:23]
/// Port x configuration bits (y = 0..15)
MODER11: u2 = 0,
/// MODER12 [24:25]
/// Port x configuration bits (y = 0..15)
MODER12: u2 = 0,
/// MODER13 [26:27]
/// Port x configuration bits (y = 0..15)
MODER13: u2 = 0,
/// MODER14 [28:29]
/// Port x configuration bits (y = 0..15)
MODER14: u2 = 0,
/// MODER15 [30:31]
/// Port x configuration bits (y = 0..15)
MODER15: u2 = 0,
};
/// GPIO port mode register
pub const MODER = Register(MODER_val).init(base_address + 0x0);
/// OTYPER
const OTYPER_val = packed struct {
/// OT0 [0:0]
/// Port x configuration bit 0
OT0: u1 = 0,
/// OT1 [1:1]
/// Port x configuration bit 1
OT1: u1 = 0,
/// OT2 [2:2]
/// Port x configuration bit 2
OT2: u1 = 0,
/// OT3 [3:3]
/// Port x configuration bit 3
OT3: u1 = 0,
/// OT4 [4:4]
/// Port x configuration bit 4
OT4: u1 = 0,
/// OT5 [5:5]
/// Port x configuration bit 5
OT5: u1 = 0,
/// OT6 [6:6]
/// Port x configuration bit 6
OT6: u1 = 0,
/// OT7 [7:7]
/// Port x configuration bit 7
OT7: u1 = 0,
/// OT8 [8:8]
/// Port x configuration bit 8
OT8: u1 = 0,
/// OT9 [9:9]
/// Port x configuration bit 9
OT9: u1 = 0,
/// OT10 [10:10]
/// Port x configuration bit 10
OT10: u1 = 0,
/// OT11 [11:11]
/// Port x configuration bit 11
OT11: u1 = 0,
/// OT12 [12:12]
/// Port x configuration bit 12
OT12: u1 = 0,
/// OT13 [13:13]
/// Port x configuration bit 13
OT13: u1 = 0,
/// OT14 [14:14]
/// Port x configuration bit 14
OT14: u1 = 0,
/// OT15 [15:15]
/// Port x configuration bit 15
OT15: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// GPIO port output type register
pub const OTYPER = Register(OTYPER_val).init(base_address + 0x4);
/// OSPEEDR
const OSPEEDR_val = packed struct {
/// OSPEEDR0 [0:1]
/// Port x configuration bits (y = 0..15)
OSPEEDR0: u2 = 0,
/// OSPEEDR1 [2:3]
/// Port x configuration bits (y = 0..15)
OSPEEDR1: u2 = 0,
/// OSPEEDR2 [4:5]
/// Port x configuration bits (y = 0..15)
OSPEEDR2: u2 = 0,
/// OSPEEDR3 [6:7]
/// Port x configuration bits (y = 0..15)
OSPEEDR3: u2 = 0,
/// OSPEEDR4 [8:9]
/// Port x configuration bits (y = 0..15)
OSPEEDR4: u2 = 0,
/// OSPEEDR5 [10:11]
/// Port x configuration bits (y = 0..15)
OSPEEDR5: u2 = 0,
/// OSPEEDR6 [12:13]
/// Port x configuration bits (y = 0..15)
OSPEEDR6: u2 = 0,
/// OSPEEDR7 [14:15]
/// Port x configuration bits (y = 0..15)
OSPEEDR7: u2 = 0,
/// OSPEEDR8 [16:17]
/// Port x configuration bits (y = 0..15)
OSPEEDR8: u2 = 0,
/// OSPEEDR9 [18:19]
/// Port x configuration bits (y = 0..15)
OSPEEDR9: u2 = 0,
/// OSPEEDR10 [20:21]
/// Port x configuration bits (y = 0..15)
OSPEEDR10: u2 = 0,
/// OSPEEDR11 [22:23]
/// Port x configuration bits (y = 0..15)
OSPEEDR11: u2 = 0,
/// OSPEEDR12 [24:25]
/// Port x configuration bits (y = 0..15)
OSPEEDR12: u2 = 0,
/// OSPEEDR13 [26:27]
/// Port x configuration bits (y = 0..15)
OSPEEDR13: u2 = 0,
/// OSPEEDR14 [28:29]
/// Port x configuration bits (y = 0..15)
OSPEEDR14: u2 = 0,
/// OSPEEDR15 [30:31]
/// Port x configuration bits (y = 0..15)
OSPEEDR15: u2 = 0,
};
/// GPIO port output speed register
pub const OSPEEDR = Register(OSPEEDR_val).init(base_address + 0x8);
/// PUPDR
const PUPDR_val = packed struct {
/// PUPDR0 [0:1]
/// Port x configuration bits (y = 0..15)
PUPDR0: u2 = 0,
/// PUPDR1 [2:3]
/// Port x configuration bits (y = 0..15)
PUPDR1: u2 = 0,
/// PUPDR2 [4:5]
/// Port x configuration bits (y = 0..15)
PUPDR2: u2 = 0,
/// PUPDR3 [6:7]
/// Port x configuration bits (y = 0..15)
PUPDR3: u2 = 0,
/// PUPDR4 [8:9]
/// Port x configuration bits (y = 0..15)
PUPDR4: u2 = 0,
/// PUPDR5 [10:11]
/// Port x configuration bits (y = 0..15)
PUPDR5: u2 = 0,
/// PUPDR6 [12:13]
/// Port x configuration bits (y = 0..15)
PUPDR6: u2 = 0,
/// PUPDR7 [14:15]
/// Port x configuration bits (y = 0..15)
PUPDR7: u2 = 0,
/// PUPDR8 [16:17]
/// Port x configuration bits (y = 0..15)
PUPDR8: u2 = 0,
/// PUPDR9 [18:19]
/// Port x configuration bits (y = 0..15)
PUPDR9: u2 = 0,
/// PUPDR10 [20:21]
/// Port x configuration bits (y = 0..15)
PUPDR10: u2 = 0,
/// PUPDR11 [22:23]
/// Port x configuration bits (y = 0..15)
PUPDR11: u2 = 0,
/// PUPDR12 [24:25]
/// Port x configuration bits (y = 0..15)
PUPDR12: u2 = 0,
/// PUPDR13 [26:27]
/// Port x configuration bits (y = 0..15)
PUPDR13: u2 = 0,
/// PUPDR14 [28:29]
/// Port x configuration bits (y = 0..15)
PUPDR14: u2 = 0,
/// PUPDR15 [30:31]
/// Port x configuration bits (y = 0..15)
PUPDR15: u2 = 0,
};
/// GPIO port pull-up/pull-down register
pub const PUPDR = Register(PUPDR_val).init(base_address + 0xc);
/// IDR
const IDR_val = packed struct {
/// IDR0 [0:0]
/// Port input data (y = 0..15)
IDR0: u1 = 0,
/// IDR1 [1:1]
/// Port input data (y = 0..15)
IDR1: u1 = 0,
/// IDR2 [2:2]
/// Port input data (y = 0..15)
IDR2: u1 = 0,
/// IDR3 [3:3]
/// Port input data (y = 0..15)
IDR3: u1 = 0,
/// IDR4 [4:4]
/// Port input data (y = 0..15)
IDR4: u1 = 0,
/// IDR5 [5:5]
/// Port input data (y = 0..15)
IDR5: u1 = 0,
/// IDR6 [6:6]
/// Port input data (y = 0..15)
IDR6: u1 = 0,
/// IDR7 [7:7]
/// Port input data (y = 0..15)
IDR7: u1 = 0,
/// IDR8 [8:8]
/// Port input data (y = 0..15)
IDR8: u1 = 0,
/// IDR9 [9:9]
/// Port input data (y = 0..15)
IDR9: u1 = 0,
/// IDR10 [10:10]
/// Port input data (y = 0..15)
IDR10: u1 = 0,
/// IDR11 [11:11]
/// Port input data (y = 0..15)
IDR11: u1 = 0,
/// IDR12 [12:12]
/// Port input data (y = 0..15)
IDR12: u1 = 0,
/// IDR13 [13:13]
/// Port input data (y = 0..15)
IDR13: u1 = 0,
/// IDR14 [14:14]
/// Port input data (y = 0..15)
IDR14: u1 = 0,
/// IDR15 [15:15]
/// Port input data (y = 0..15)
IDR15: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// GPIO port input data register
pub const IDR = Register(IDR_val).init(base_address + 0x10);
/// ODR
const ODR_val = packed struct {
/// ODR0 [0:0]
/// Port output data (y = 0..15)
ODR0: u1 = 0,
/// ODR1 [1:1]
/// Port output data (y = 0..15)
ODR1: u1 = 0,
/// ODR2 [2:2]
/// Port output data (y = 0..15)
ODR2: u1 = 0,
/// ODR3 [3:3]
/// Port output data (y = 0..15)
ODR3: u1 = 0,
/// ODR4 [4:4]
/// Port output data (y = 0..15)
ODR4: u1 = 0,
/// ODR5 [5:5]
/// Port output data (y = 0..15)
ODR5: u1 = 0,
/// ODR6 [6:6]
/// Port output data (y = 0..15)
ODR6: u1 = 0,
/// ODR7 [7:7]
/// Port output data (y = 0..15)
ODR7: u1 = 0,
/// ODR8 [8:8]
/// Port output data (y = 0..15)
ODR8: u1 = 0,
/// ODR9 [9:9]
/// Port output data (y = 0..15)
ODR9: u1 = 0,
/// ODR10 [10:10]
/// Port output data (y = 0..15)
ODR10: u1 = 0,
/// ODR11 [11:11]
/// Port output data (y = 0..15)
ODR11: u1 = 0,
/// ODR12 [12:12]
/// Port output data (y = 0..15)
ODR12: u1 = 0,
/// ODR13 [13:13]
/// Port output data (y = 0..15)
ODR13: u1 = 0,
/// ODR14 [14:14]
/// Port output data (y = 0..15)
ODR14: u1 = 0,
/// ODR15 [15:15]
/// Port output data (y = 0..15)
ODR15: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// GPIO port output data register
pub const ODR = Register(ODR_val).init(base_address + 0x14);
/// BSRR
const BSRR_val = packed struct {
/// BS0 [0:0]
/// Port x set bit y (y= 0..15)
BS0: u1 = 0,
/// BS1 [1:1]
/// Port x set bit y (y= 0..15)
BS1: u1 = 0,
/// BS2 [2:2]
/// Port x set bit y (y= 0..15)
BS2: u1 = 0,
/// BS3 [3:3]
/// Port x set bit y (y= 0..15)
BS3: u1 = 0,
/// BS4 [4:4]
/// Port x set bit y (y= 0..15)
BS4: u1 = 0,
/// BS5 [5:5]
/// Port x set bit y (y= 0..15)
BS5: u1 = 0,
/// BS6 [6:6]
/// Port x set bit y (y= 0..15)
BS6: u1 = 0,
/// BS7 [7:7]
/// Port x set bit y (y= 0..15)
BS7: u1 = 0,
/// BS8 [8:8]
/// Port x set bit y (y= 0..15)
BS8: u1 = 0,
/// BS9 [9:9]
/// Port x set bit y (y= 0..15)
BS9: u1 = 0,
/// BS10 [10:10]
/// Port x set bit y (y= 0..15)
BS10: u1 = 0,
/// BS11 [11:11]
/// Port x set bit y (y= 0..15)
BS11: u1 = 0,
/// BS12 [12:12]
/// Port x set bit y (y= 0..15)
BS12: u1 = 0,
/// BS13 [13:13]
/// Port x set bit y (y= 0..15)
BS13: u1 = 0,
/// BS14 [14:14]
/// Port x set bit y (y= 0..15)
BS14: u1 = 0,
/// BS15 [15:15]
/// Port x set bit y (y= 0..15)
BS15: u1 = 0,
/// BR0 [16:16]
/// Port x set bit y (y= 0..15)
BR0: u1 = 0,
/// BR1 [17:17]
/// Port x reset bit y (y = 0..15)
BR1: u1 = 0,
/// BR2 [18:18]
/// Port x reset bit y (y = 0..15)
BR2: u1 = 0,
/// BR3 [19:19]
/// Port x reset bit y (y = 0..15)
BR3: u1 = 0,
/// BR4 [20:20]
/// Port x reset bit y (y = 0..15)
BR4: u1 = 0,
/// BR5 [21:21]
/// Port x reset bit y (y = 0..15)
BR5: u1 = 0,
/// BR6 [22:22]
/// Port x reset bit y (y = 0..15)
BR6: u1 = 0,
/// BR7 [23:23]
/// Port x reset bit y (y = 0..15)
BR7: u1 = 0,
/// BR8 [24:24]
/// Port x reset bit y (y = 0..15)
BR8: u1 = 0,
/// BR9 [25:25]
/// Port x reset bit y (y = 0..15)
BR9: u1 = 0,
/// BR10 [26:26]
/// Port x reset bit y (y = 0..15)
BR10: u1 = 0,
/// BR11 [27:27]
/// Port x reset bit y (y = 0..15)
BR11: u1 = 0,
/// BR12 [28:28]
/// Port x reset bit y (y = 0..15)
BR12: u1 = 0,
/// BR13 [29:29]
/// Port x reset bit y (y = 0..15)
BR13: u1 = 0,
/// BR14 [30:30]
/// Port x reset bit y (y = 0..15)
BR14: u1 = 0,
/// BR15 [31:31]
/// Port x reset bit y (y = 0..15)
BR15: u1 = 0,
};
/// GPIO port bit set/reset register
pub const BSRR = Register(BSRR_val).init(base_address + 0x18);
/// LCKR
const LCKR_val = packed struct {
/// LCK0 [0:0]
/// Port x lock bit y (y= 0..15)
LCK0: u1 = 0,
/// LCK1 [1:1]
/// Port x lock bit y (y= 0..15)
LCK1: u1 = 0,
/// LCK2 [2:2]
/// Port x lock bit y (y= 0..15)
LCK2: u1 = 0,
/// LCK3 [3:3]
/// Port x lock bit y (y= 0..15)
LCK3: u1 = 0,
/// LCK4 [4:4]
/// Port x lock bit y (y= 0..15)
LCK4: u1 = 0,
/// LCK5 [5:5]
/// Port x lock bit y (y= 0..15)
LCK5: u1 = 0,
/// LCK6 [6:6]
/// Port x lock bit y (y= 0..15)
LCK6: u1 = 0,
/// LCK7 [7:7]
/// Port x lock bit y (y= 0..15)
LCK7: u1 = 0,
/// LCK8 [8:8]
/// Port x lock bit y (y= 0..15)
LCK8: u1 = 0,
/// LCK9 [9:9]
/// Port x lock bit y (y= 0..15)
LCK9: u1 = 0,
/// LCK10 [10:10]
/// Port x lock bit y (y= 0..15)
LCK10: u1 = 0,
/// LCK11 [11:11]
/// Port x lock bit y (y= 0..15)
LCK11: u1 = 0,
/// LCK12 [12:12]
/// Port x lock bit y (y= 0..15)
LCK12: u1 = 0,
/// LCK13 [13:13]
/// Port x lock bit y (y= 0..15)
LCK13: u1 = 0,
/// LCK14 [14:14]
/// Port x lock bit y (y= 0..15)
LCK14: u1 = 0,
/// LCK15 [15:15]
/// Port x lock bit y (y= 0..15)
LCK15: u1 = 0,
/// LCKK [16:16]
/// Lok Key
LCKK: u1 = 0,
/// unused [17:31]
_unused17: u7 = 0,
_unused24: u8 = 0,
};
/// GPIO port configuration lock register
pub const LCKR = Register(LCKR_val).init(base_address + 0x1c);
/// AFRL
const AFRL_val = packed struct {
/// AFRL0 [0:3]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL0: u4 = 0,
/// AFRL1 [4:7]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL1: u4 = 0,
/// AFRL2 [8:11]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL2: u4 = 0,
/// AFRL3 [12:15]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL3: u4 = 0,
/// AFRL4 [16:19]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL4: u4 = 0,
/// AFRL5 [20:23]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL5: u4 = 0,
/// AFRL6 [24:27]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL6: u4 = 0,
/// AFRL7 [28:31]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL7: u4 = 0,
};
/// GPIO alternate function low register
pub const AFRL = Register(AFRL_val).init(base_address + 0x20);
/// AFRH
const AFRH_val = packed struct {
/// AFRH8 [0:3]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH8: u4 = 0,
/// AFRH9 [4:7]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH9: u4 = 0,
/// AFRH10 [8:11]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH10: u4 = 0,
/// AFRH11 [12:15]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH11: u4 = 0,
/// AFRH12 [16:19]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH12: u4 = 0,
/// AFRH13 [20:23]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH13: u4 = 0,
/// AFRH14 [24:27]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH14: u4 = 0,
/// AFRH15 [28:31]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH15: u4 = 0,
};
/// GPIO alternate function high register
pub const AFRH = Register(AFRH_val).init(base_address + 0x24);
/// BRR
const BRR_val = packed struct {
/// BR0 [0:0]
/// Port x Reset bit y
BR0: u1 = 0,
/// BR1 [1:1]
/// Port x Reset bit y
BR1: u1 = 0,
/// BR2 [2:2]
/// Port x Reset bit y
BR2: u1 = 0,
/// BR3 [3:3]
/// Port x Reset bit y
BR3: u1 = 0,
/// BR4 [4:4]
/// Port x Reset bit y
BR4: u1 = 0,
/// BR5 [5:5]
/// Port x Reset bit y
BR5: u1 = 0,
/// BR6 [6:6]
/// Port x Reset bit y
BR6: u1 = 0,
/// BR7 [7:7]
/// Port x Reset bit y
BR7: u1 = 0,
/// BR8 [8:8]
/// Port x Reset bit y
BR8: u1 = 0,
/// BR9 [9:9]
/// Port x Reset bit y
BR9: u1 = 0,
/// BR10 [10:10]
/// Port x Reset bit y
BR10: u1 = 0,
/// BR11 [11:11]
/// Port x Reset bit y
BR11: u1 = 0,
/// BR12 [12:12]
/// Port x Reset bit y
BR12: u1 = 0,
/// BR13 [13:13]
/// Port x Reset bit y
BR13: u1 = 0,
/// BR14 [14:14]
/// Port x Reset bit y
BR14: u1 = 0,
/// BR15 [15:15]
/// Port x Reset bit y
BR15: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Port bit reset register
pub const BRR = Register(BRR_val).init(base_address + 0x28);
};
/// General-purpose I/Os
pub const GPIOE = struct {
const base_address = 0x48001000;
/// MODER
const MODER_val = packed struct {
/// MODER0 [0:1]
/// Port x configuration bits (y = 0..15)
MODER0: u2 = 0,
/// MODER1 [2:3]
/// Port x configuration bits (y = 0..15)
MODER1: u2 = 0,
/// MODER2 [4:5]
/// Port x configuration bits (y = 0..15)
MODER2: u2 = 0,
/// MODER3 [6:7]
/// Port x configuration bits (y = 0..15)
MODER3: u2 = 0,
/// MODER4 [8:9]
/// Port x configuration bits (y = 0..15)
MODER4: u2 = 0,
/// MODER5 [10:11]
/// Port x configuration bits (y = 0..15)
MODER5: u2 = 0,
/// MODER6 [12:13]
/// Port x configuration bits (y = 0..15)
MODER6: u2 = 0,
/// MODER7 [14:15]
/// Port x configuration bits (y = 0..15)
MODER7: u2 = 0,
/// MODER8 [16:17]
/// Port x configuration bits (y = 0..15)
MODER8: u2 = 0,
/// MODER9 [18:19]
/// Port x configuration bits (y = 0..15)
MODER9: u2 = 0,
/// MODER10 [20:21]
/// Port x configuration bits (y = 0..15)
MODER10: u2 = 0,
/// MODER11 [22:23]
/// Port x configuration bits (y = 0..15)
MODER11: u2 = 0,
/// MODER12 [24:25]
/// Port x configuration bits (y = 0..15)
MODER12: u2 = 0,
/// MODER13 [26:27]
/// Port x configuration bits (y = 0..15)
MODER13: u2 = 0,
/// MODER14 [28:29]
/// Port x configuration bits (y = 0..15)
MODER14: u2 = 0,
/// MODER15 [30:31]
/// Port x configuration bits (y = 0..15)
MODER15: u2 = 0,
};
/// GPIO port mode register
pub const MODER = Register(MODER_val).init(base_address + 0x0);
/// OTYPER
const OTYPER_val = packed struct {
/// OT0 [0:0]
/// Port x configuration bit 0
OT0: u1 = 0,
/// OT1 [1:1]
/// Port x configuration bit 1
OT1: u1 = 0,
/// OT2 [2:2]
/// Port x configuration bit 2
OT2: u1 = 0,
/// OT3 [3:3]
/// Port x configuration bit 3
OT3: u1 = 0,
/// OT4 [4:4]
/// Port x configuration bit 4
OT4: u1 = 0,
/// OT5 [5:5]
/// Port x configuration bit 5
OT5: u1 = 0,
/// OT6 [6:6]
/// Port x configuration bit 6
OT6: u1 = 0,
/// OT7 [7:7]
/// Port x configuration bit 7
OT7: u1 = 0,
/// OT8 [8:8]
/// Port x configuration bit 8
OT8: u1 = 0,
/// OT9 [9:9]
/// Port x configuration bit 9
OT9: u1 = 0,
/// OT10 [10:10]
/// Port x configuration bit 10
OT10: u1 = 0,
/// OT11 [11:11]
/// Port x configuration bit 11
OT11: u1 = 0,
/// OT12 [12:12]
/// Port x configuration bit 12
OT12: u1 = 0,
/// OT13 [13:13]
/// Port x configuration bit 13
OT13: u1 = 0,
/// OT14 [14:14]
/// Port x configuration bit 14
OT14: u1 = 0,
/// OT15 [15:15]
/// Port x configuration bit 15
OT15: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// GPIO port output type register
pub const OTYPER = Register(OTYPER_val).init(base_address + 0x4);
/// OSPEEDR
const OSPEEDR_val = packed struct {
/// OSPEEDR0 [0:1]
/// Port x configuration bits (y = 0..15)
OSPEEDR0: u2 = 0,
/// OSPEEDR1 [2:3]
/// Port x configuration bits (y = 0..15)
OSPEEDR1: u2 = 0,
/// OSPEEDR2 [4:5]
/// Port x configuration bits (y = 0..15)
OSPEEDR2: u2 = 0,
/// OSPEEDR3 [6:7]
/// Port x configuration bits (y = 0..15)
OSPEEDR3: u2 = 0,
/// OSPEEDR4 [8:9]
/// Port x configuration bits (y = 0..15)
OSPEEDR4: u2 = 0,
/// OSPEEDR5 [10:11]
/// Port x configuration bits (y = 0..15)
OSPEEDR5: u2 = 0,
/// OSPEEDR6 [12:13]
/// Port x configuration bits (y = 0..15)
OSPEEDR6: u2 = 0,
/// OSPEEDR7 [14:15]
/// Port x configuration bits (y = 0..15)
OSPEEDR7: u2 = 0,
/// OSPEEDR8 [16:17]
/// Port x configuration bits (y = 0..15)
OSPEEDR8: u2 = 0,
/// OSPEEDR9 [18:19]
/// Port x configuration bits (y = 0..15)
OSPEEDR9: u2 = 0,
/// OSPEEDR10 [20:21]
/// Port x configuration bits (y = 0..15)
OSPEEDR10: u2 = 0,
/// OSPEEDR11 [22:23]
/// Port x configuration bits (y = 0..15)
OSPEEDR11: u2 = 0,
/// OSPEEDR12 [24:25]
/// Port x configuration bits (y = 0..15)
OSPEEDR12: u2 = 0,
/// OSPEEDR13 [26:27]
/// Port x configuration bits (y = 0..15)
OSPEEDR13: u2 = 0,
/// OSPEEDR14 [28:29]
/// Port x configuration bits (y = 0..15)
OSPEEDR14: u2 = 0,
/// OSPEEDR15 [30:31]
/// Port x configuration bits (y = 0..15)
OSPEEDR15: u2 = 0,
};
/// GPIO port output speed register
pub const OSPEEDR = Register(OSPEEDR_val).init(base_address + 0x8);
/// PUPDR
const PUPDR_val = packed struct {
/// PUPDR0 [0:1]
/// Port x configuration bits (y = 0..15)
PUPDR0: u2 = 0,
/// PUPDR1 [2:3]
/// Port x configuration bits (y = 0..15)
PUPDR1: u2 = 0,
/// PUPDR2 [4:5]
/// Port x configuration bits (y = 0..15)
PUPDR2: u2 = 0,
/// PUPDR3 [6:7]
/// Port x configuration bits (y = 0..15)
PUPDR3: u2 = 0,
/// PUPDR4 [8:9]
/// Port x configuration bits (y = 0..15)
PUPDR4: u2 = 0,
/// PUPDR5 [10:11]
/// Port x configuration bits (y = 0..15)
PUPDR5: u2 = 0,
/// PUPDR6 [12:13]
/// Port x configuration bits (y = 0..15)
PUPDR6: u2 = 0,
/// PUPDR7 [14:15]
/// Port x configuration bits (y = 0..15)
PUPDR7: u2 = 0,
/// PUPDR8 [16:17]
/// Port x configuration bits (y = 0..15)
PUPDR8: u2 = 0,
/// PUPDR9 [18:19]
/// Port x configuration bits (y = 0..15)
PUPDR9: u2 = 0,
/// PUPDR10 [20:21]
/// Port x configuration bits (y = 0..15)
PUPDR10: u2 = 0,
/// PUPDR11 [22:23]
/// Port x configuration bits (y = 0..15)
PUPDR11: u2 = 0,
/// PUPDR12 [24:25]
/// Port x configuration bits (y = 0..15)
PUPDR12: u2 = 0,
/// PUPDR13 [26:27]
/// Port x configuration bits (y = 0..15)
PUPDR13: u2 = 0,
/// PUPDR14 [28:29]
/// Port x configuration bits (y = 0..15)
PUPDR14: u2 = 0,
/// PUPDR15 [30:31]
/// Port x configuration bits (y = 0..15)
PUPDR15: u2 = 0,
};
/// GPIO port pull-up/pull-down register
pub const PUPDR = Register(PUPDR_val).init(base_address + 0xc);
/// IDR
const IDR_val = packed struct {
/// IDR0 [0:0]
/// Port input data (y = 0..15)
IDR0: u1 = 0,
/// IDR1 [1:1]
/// Port input data (y = 0..15)
IDR1: u1 = 0,
/// IDR2 [2:2]
/// Port input data (y = 0..15)
IDR2: u1 = 0,
/// IDR3 [3:3]
/// Port input data (y = 0..15)
IDR3: u1 = 0,
/// IDR4 [4:4]
/// Port input data (y = 0..15)
IDR4: u1 = 0,
/// IDR5 [5:5]
/// Port input data (y = 0..15)
IDR5: u1 = 0,
/// IDR6 [6:6]
/// Port input data (y = 0..15)
IDR6: u1 = 0,
/// IDR7 [7:7]
/// Port input data (y = 0..15)
IDR7: u1 = 0,
/// IDR8 [8:8]
/// Port input data (y = 0..15)
IDR8: u1 = 0,
/// IDR9 [9:9]
/// Port input data (y = 0..15)
IDR9: u1 = 0,
/// IDR10 [10:10]
/// Port input data (y = 0..15)
IDR10: u1 = 0,
/// IDR11 [11:11]
/// Port input data (y = 0..15)
IDR11: u1 = 0,
/// IDR12 [12:12]
/// Port input data (y = 0..15)
IDR12: u1 = 0,
/// IDR13 [13:13]
/// Port input data (y = 0..15)
IDR13: u1 = 0,
/// IDR14 [14:14]
/// Port input data (y = 0..15)
IDR14: u1 = 0,
/// IDR15 [15:15]
/// Port input data (y = 0..15)
IDR15: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// GPIO port input data register
pub const IDR = Register(IDR_val).init(base_address + 0x10);
/// ODR
const ODR_val = packed struct {
/// ODR0 [0:0]
/// Port output data (y = 0..15)
ODR0: u1 = 0,
/// ODR1 [1:1]
/// Port output data (y = 0..15)
ODR1: u1 = 0,
/// ODR2 [2:2]
/// Port output data (y = 0..15)
ODR2: u1 = 0,
/// ODR3 [3:3]
/// Port output data (y = 0..15)
ODR3: u1 = 0,
/// ODR4 [4:4]
/// Port output data (y = 0..15)
ODR4: u1 = 0,
/// ODR5 [5:5]
/// Port output data (y = 0..15)
ODR5: u1 = 0,
/// ODR6 [6:6]
/// Port output data (y = 0..15)
ODR6: u1 = 0,
/// ODR7 [7:7]
/// Port output data (y = 0..15)
ODR7: u1 = 0,
/// ODR8 [8:8]
/// Port output data (y = 0..15)
ODR8: u1 = 0,
/// ODR9 [9:9]
/// Port output data (y = 0..15)
ODR9: u1 = 0,
/// ODR10 [10:10]
/// Port output data (y = 0..15)
ODR10: u1 = 0,
/// ODR11 [11:11]
/// Port output data (y = 0..15)
ODR11: u1 = 0,
/// ODR12 [12:12]
/// Port output data (y = 0..15)
ODR12: u1 = 0,
/// ODR13 [13:13]
/// Port output data (y = 0..15)
ODR13: u1 = 0,
/// ODR14 [14:14]
/// Port output data (y = 0..15)
ODR14: u1 = 0,
/// ODR15 [15:15]
/// Port output data (y = 0..15)
ODR15: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// GPIO port output data register
pub const ODR = Register(ODR_val).init(base_address + 0x14);
/// BSRR
const BSRR_val = packed struct {
/// BS0 [0:0]
/// Port x set bit y (y= 0..15)
BS0: u1 = 0,
/// BS1 [1:1]
/// Port x set bit y (y= 0..15)
BS1: u1 = 0,
/// BS2 [2:2]
/// Port x set bit y (y= 0..15)
BS2: u1 = 0,
/// BS3 [3:3]
/// Port x set bit y (y= 0..15)
BS3: u1 = 0,
/// BS4 [4:4]
/// Port x set bit y (y= 0..15)
BS4: u1 = 0,
/// BS5 [5:5]
/// Port x set bit y (y= 0..15)
BS5: u1 = 0,
/// BS6 [6:6]
/// Port x set bit y (y= 0..15)
BS6: u1 = 0,
/// BS7 [7:7]
/// Port x set bit y (y= 0..15)
BS7: u1 = 0,
/// BS8 [8:8]
/// Port x set bit y (y= 0..15)
BS8: u1 = 0,
/// BS9 [9:9]
/// Port x set bit y (y= 0..15)
BS9: u1 = 0,
/// BS10 [10:10]
/// Port x set bit y (y= 0..15)
BS10: u1 = 0,
/// BS11 [11:11]
/// Port x set bit y (y= 0..15)
BS11: u1 = 0,
/// BS12 [12:12]
/// Port x set bit y (y= 0..15)
BS12: u1 = 0,
/// BS13 [13:13]
/// Port x set bit y (y= 0..15)
BS13: u1 = 0,
/// BS14 [14:14]
/// Port x set bit y (y= 0..15)
BS14: u1 = 0,
/// BS15 [15:15]
/// Port x set bit y (y= 0..15)
BS15: u1 = 0,
/// BR0 [16:16]
/// Port x set bit y (y= 0..15)
BR0: u1 = 0,
/// BR1 [17:17]
/// Port x reset bit y (y = 0..15)
BR1: u1 = 0,
/// BR2 [18:18]
/// Port x reset bit y (y = 0..15)
BR2: u1 = 0,
/// BR3 [19:19]
/// Port x reset bit y (y = 0..15)
BR3: u1 = 0,
/// BR4 [20:20]
/// Port x reset bit y (y = 0..15)
BR4: u1 = 0,
/// BR5 [21:21]
/// Port x reset bit y (y = 0..15)
BR5: u1 = 0,
/// BR6 [22:22]
/// Port x reset bit y (y = 0..15)
BR6: u1 = 0,
/// BR7 [23:23]
/// Port x reset bit y (y = 0..15)
BR7: u1 = 0,
/// BR8 [24:24]
/// Port x reset bit y (y = 0..15)
BR8: u1 = 0,
/// BR9 [25:25]
/// Port x reset bit y (y = 0..15)
BR9: u1 = 0,
/// BR10 [26:26]
/// Port x reset bit y (y = 0..15)
BR10: u1 = 0,
/// BR11 [27:27]
/// Port x reset bit y (y = 0..15)
BR11: u1 = 0,
/// BR12 [28:28]
/// Port x reset bit y (y = 0..15)
BR12: u1 = 0,
/// BR13 [29:29]
/// Port x reset bit y (y = 0..15)
BR13: u1 = 0,
/// BR14 [30:30]
/// Port x reset bit y (y = 0..15)
BR14: u1 = 0,
/// BR15 [31:31]
/// Port x reset bit y (y = 0..15)
BR15: u1 = 0,
};
/// GPIO port bit set/reset register
pub const BSRR = Register(BSRR_val).init(base_address + 0x18);
/// LCKR
const LCKR_val = packed struct {
/// LCK0 [0:0]
/// Port x lock bit y (y= 0..15)
LCK0: u1 = 0,
/// LCK1 [1:1]
/// Port x lock bit y (y= 0..15)
LCK1: u1 = 0,
/// LCK2 [2:2]
/// Port x lock bit y (y= 0..15)
LCK2: u1 = 0,
/// LCK3 [3:3]
/// Port x lock bit y (y= 0..15)
LCK3: u1 = 0,
/// LCK4 [4:4]
/// Port x lock bit y (y= 0..15)
LCK4: u1 = 0,
/// LCK5 [5:5]
/// Port x lock bit y (y= 0..15)
LCK5: u1 = 0,
/// LCK6 [6:6]
/// Port x lock bit y (y= 0..15)
LCK6: u1 = 0,
/// LCK7 [7:7]
/// Port x lock bit y (y= 0..15)
LCK7: u1 = 0,
/// LCK8 [8:8]
/// Port x lock bit y (y= 0..15)
LCK8: u1 = 0,
/// LCK9 [9:9]
/// Port x lock bit y (y= 0..15)
LCK9: u1 = 0,
/// LCK10 [10:10]
/// Port x lock bit y (y= 0..15)
LCK10: u1 = 0,
/// LCK11 [11:11]
/// Port x lock bit y (y= 0..15)
LCK11: u1 = 0,
/// LCK12 [12:12]
/// Port x lock bit y (y= 0..15)
LCK12: u1 = 0,
/// LCK13 [13:13]
/// Port x lock bit y (y= 0..15)
LCK13: u1 = 0,
/// LCK14 [14:14]
/// Port x lock bit y (y= 0..15)
LCK14: u1 = 0,
/// LCK15 [15:15]
/// Port x lock bit y (y= 0..15)
LCK15: u1 = 0,
/// LCKK [16:16]
/// Lok Key
LCKK: u1 = 0,
/// unused [17:31]
_unused17: u7 = 0,
_unused24: u8 = 0,
};
/// GPIO port configuration lock register
pub const LCKR = Register(LCKR_val).init(base_address + 0x1c);
/// AFRL
const AFRL_val = packed struct {
/// AFRL0 [0:3]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL0: u4 = 0,
/// AFRL1 [4:7]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL1: u4 = 0,
/// AFRL2 [8:11]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL2: u4 = 0,
/// AFRL3 [12:15]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL3: u4 = 0,
/// AFRL4 [16:19]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL4: u4 = 0,
/// AFRL5 [20:23]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL5: u4 = 0,
/// AFRL6 [24:27]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL6: u4 = 0,
/// AFRL7 [28:31]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL7: u4 = 0,
};
/// GPIO alternate function low register
pub const AFRL = Register(AFRL_val).init(base_address + 0x20);
/// AFRH
const AFRH_val = packed struct {
/// AFRH8 [0:3]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH8: u4 = 0,
/// AFRH9 [4:7]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH9: u4 = 0,
/// AFRH10 [8:11]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH10: u4 = 0,
/// AFRH11 [12:15]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH11: u4 = 0,
/// AFRH12 [16:19]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH12: u4 = 0,
/// AFRH13 [20:23]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH13: u4 = 0,
/// AFRH14 [24:27]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH14: u4 = 0,
/// AFRH15 [28:31]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH15: u4 = 0,
};
/// GPIO alternate function high register
pub const AFRH = Register(AFRH_val).init(base_address + 0x24);
/// BRR
const BRR_val = packed struct {
/// BR0 [0:0]
/// Port x Reset bit y
BR0: u1 = 0,
/// BR1 [1:1]
/// Port x Reset bit y
BR1: u1 = 0,
/// BR2 [2:2]
/// Port x Reset bit y
BR2: u1 = 0,
/// BR3 [3:3]
/// Port x Reset bit y
BR3: u1 = 0,
/// BR4 [4:4]
/// Port x Reset bit y
BR4: u1 = 0,
/// BR5 [5:5]
/// Port x Reset bit y
BR5: u1 = 0,
/// BR6 [6:6]
/// Port x Reset bit y
BR6: u1 = 0,
/// BR7 [7:7]
/// Port x Reset bit y
BR7: u1 = 0,
/// BR8 [8:8]
/// Port x Reset bit y
BR8: u1 = 0,
/// BR9 [9:9]
/// Port x Reset bit y
BR9: u1 = 0,
/// BR10 [10:10]
/// Port x Reset bit y
BR10: u1 = 0,
/// BR11 [11:11]
/// Port x Reset bit y
BR11: u1 = 0,
/// BR12 [12:12]
/// Port x Reset bit y
BR12: u1 = 0,
/// BR13 [13:13]
/// Port x Reset bit y
BR13: u1 = 0,
/// BR14 [14:14]
/// Port x Reset bit y
BR14: u1 = 0,
/// BR15 [15:15]
/// Port x Reset bit y
BR15: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Port bit reset register
pub const BRR = Register(BRR_val).init(base_address + 0x28);
};
/// General-purpose I/Os
pub const GPIOF = struct {
const base_address = 0x48001400;
/// MODER
const MODER_val = packed struct {
/// MODER0 [0:1]
/// Port x configuration bits (y = 0..15)
MODER0: u2 = 0,
/// MODER1 [2:3]
/// Port x configuration bits (y = 0..15)
MODER1: u2 = 0,
/// MODER2 [4:5]
/// Port x configuration bits (y = 0..15)
MODER2: u2 = 0,
/// MODER3 [6:7]
/// Port x configuration bits (y = 0..15)
MODER3: u2 = 0,
/// MODER4 [8:9]
/// Port x configuration bits (y = 0..15)
MODER4: u2 = 0,
/// MODER5 [10:11]
/// Port x configuration bits (y = 0..15)
MODER5: u2 = 0,
/// MODER6 [12:13]
/// Port x configuration bits (y = 0..15)
MODER6: u2 = 0,
/// MODER7 [14:15]
/// Port x configuration bits (y = 0..15)
MODER7: u2 = 0,
/// MODER8 [16:17]
/// Port x configuration bits (y = 0..15)
MODER8: u2 = 0,
/// MODER9 [18:19]
/// Port x configuration bits (y = 0..15)
MODER9: u2 = 0,
/// MODER10 [20:21]
/// Port x configuration bits (y = 0..15)
MODER10: u2 = 0,
/// MODER11 [22:23]
/// Port x configuration bits (y = 0..15)
MODER11: u2 = 0,
/// MODER12 [24:25]
/// Port x configuration bits (y = 0..15)
MODER12: u2 = 0,
/// MODER13 [26:27]
/// Port x configuration bits (y = 0..15)
MODER13: u2 = 0,
/// MODER14 [28:29]
/// Port x configuration bits (y = 0..15)
MODER14: u2 = 0,
/// MODER15 [30:31]
/// Port x configuration bits (y = 0..15)
MODER15: u2 = 0,
};
/// GPIO port mode register
pub const MODER = Register(MODER_val).init(base_address + 0x0);
/// OTYPER
const OTYPER_val = packed struct {
/// OT0 [0:0]
/// Port x configuration bit 0
OT0: u1 = 0,
/// OT1 [1:1]
/// Port x configuration bit 1
OT1: u1 = 0,
/// OT2 [2:2]
/// Port x configuration bit 2
OT2: u1 = 0,
/// OT3 [3:3]
/// Port x configuration bit 3
OT3: u1 = 0,
/// OT4 [4:4]
/// Port x configuration bit 4
OT4: u1 = 0,
/// OT5 [5:5]
/// Port x configuration bit 5
OT5: u1 = 0,
/// OT6 [6:6]
/// Port x configuration bit 6
OT6: u1 = 0,
/// OT7 [7:7]
/// Port x configuration bit 7
OT7: u1 = 0,
/// OT8 [8:8]
/// Port x configuration bit 8
OT8: u1 = 0,
/// OT9 [9:9]
/// Port x configuration bit 9
OT9: u1 = 0,
/// OT10 [10:10]
/// Port x configuration bit 10
OT10: u1 = 0,
/// OT11 [11:11]
/// Port x configuration bit 11
OT11: u1 = 0,
/// OT12 [12:12]
/// Port x configuration bit 12
OT12: u1 = 0,
/// OT13 [13:13]
/// Port x configuration bit 13
OT13: u1 = 0,
/// OT14 [14:14]
/// Port x configuration bit 14
OT14: u1 = 0,
/// OT15 [15:15]
/// Port x configuration bit 15
OT15: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// GPIO port output type register
pub const OTYPER = Register(OTYPER_val).init(base_address + 0x4);
/// OSPEEDR
const OSPEEDR_val = packed struct {
/// OSPEEDR0 [0:1]
/// Port x configuration bits (y = 0..15)
OSPEEDR0: u2 = 0,
/// OSPEEDR1 [2:3]
/// Port x configuration bits (y = 0..15)
OSPEEDR1: u2 = 0,
/// OSPEEDR2 [4:5]
/// Port x configuration bits (y = 0..15)
OSPEEDR2: u2 = 0,
/// OSPEEDR3 [6:7]
/// Port x configuration bits (y = 0..15)
OSPEEDR3: u2 = 0,
/// OSPEEDR4 [8:9]
/// Port x configuration bits (y = 0..15)
OSPEEDR4: u2 = 0,
/// OSPEEDR5 [10:11]
/// Port x configuration bits (y = 0..15)
OSPEEDR5: u2 = 0,
/// OSPEEDR6 [12:13]
/// Port x configuration bits (y = 0..15)
OSPEEDR6: u2 = 0,
/// OSPEEDR7 [14:15]
/// Port x configuration bits (y = 0..15)
OSPEEDR7: u2 = 0,
/// OSPEEDR8 [16:17]
/// Port x configuration bits (y = 0..15)
OSPEEDR8: u2 = 0,
/// OSPEEDR9 [18:19]
/// Port x configuration bits (y = 0..15)
OSPEEDR9: u2 = 0,
/// OSPEEDR10 [20:21]
/// Port x configuration bits (y = 0..15)
OSPEEDR10: u2 = 0,
/// OSPEEDR11 [22:23]
/// Port x configuration bits (y = 0..15)
OSPEEDR11: u2 = 0,
/// OSPEEDR12 [24:25]
/// Port x configuration bits (y = 0..15)
OSPEEDR12: u2 = 0,
/// OSPEEDR13 [26:27]
/// Port x configuration bits (y = 0..15)
OSPEEDR13: u2 = 0,
/// OSPEEDR14 [28:29]
/// Port x configuration bits (y = 0..15)
OSPEEDR14: u2 = 0,
/// OSPEEDR15 [30:31]
/// Port x configuration bits (y = 0..15)
OSPEEDR15: u2 = 0,
};
/// GPIO port output speed register
pub const OSPEEDR = Register(OSPEEDR_val).init(base_address + 0x8);
/// PUPDR
const PUPDR_val = packed struct {
/// PUPDR0 [0:1]
/// Port x configuration bits (y = 0..15)
PUPDR0: u2 = 0,
/// PUPDR1 [2:3]
/// Port x configuration bits (y = 0..15)
PUPDR1: u2 = 0,
/// PUPDR2 [4:5]
/// Port x configuration bits (y = 0..15)
PUPDR2: u2 = 0,
/// PUPDR3 [6:7]
/// Port x configuration bits (y = 0..15)
PUPDR3: u2 = 0,
/// PUPDR4 [8:9]
/// Port x configuration bits (y = 0..15)
PUPDR4: u2 = 0,
/// PUPDR5 [10:11]
/// Port x configuration bits (y = 0..15)
PUPDR5: u2 = 0,
/// PUPDR6 [12:13]
/// Port x configuration bits (y = 0..15)
PUPDR6: u2 = 0,
/// PUPDR7 [14:15]
/// Port x configuration bits (y = 0..15)
PUPDR7: u2 = 0,
/// PUPDR8 [16:17]
/// Port x configuration bits (y = 0..15)
PUPDR8: u2 = 0,
/// PUPDR9 [18:19]
/// Port x configuration bits (y = 0..15)
PUPDR9: u2 = 0,
/// PUPDR10 [20:21]
/// Port x configuration bits (y = 0..15)
PUPDR10: u2 = 0,
/// PUPDR11 [22:23]
/// Port x configuration bits (y = 0..15)
PUPDR11: u2 = 0,
/// PUPDR12 [24:25]
/// Port x configuration bits (y = 0..15)
PUPDR12: u2 = 0,
/// PUPDR13 [26:27]
/// Port x configuration bits (y = 0..15)
PUPDR13: u2 = 0,
/// PUPDR14 [28:29]
/// Port x configuration bits (y = 0..15)
PUPDR14: u2 = 0,
/// PUPDR15 [30:31]
/// Port x configuration bits (y = 0..15)
PUPDR15: u2 = 0,
};
/// GPIO port pull-up/pull-down register
pub const PUPDR = Register(PUPDR_val).init(base_address + 0xc);
/// IDR
const IDR_val = packed struct {
/// IDR0 [0:0]
/// Port input data (y = 0..15)
IDR0: u1 = 0,
/// IDR1 [1:1]
/// Port input data (y = 0..15)
IDR1: u1 = 0,
/// IDR2 [2:2]
/// Port input data (y = 0..15)
IDR2: u1 = 0,
/// IDR3 [3:3]
/// Port input data (y = 0..15)
IDR3: u1 = 0,
/// IDR4 [4:4]
/// Port input data (y = 0..15)
IDR4: u1 = 0,
/// IDR5 [5:5]
/// Port input data (y = 0..15)
IDR5: u1 = 0,
/// IDR6 [6:6]
/// Port input data (y = 0..15)
IDR6: u1 = 0,
/// IDR7 [7:7]
/// Port input data (y = 0..15)
IDR7: u1 = 0,
/// IDR8 [8:8]
/// Port input data (y = 0..15)
IDR8: u1 = 0,
/// IDR9 [9:9]
/// Port input data (y = 0..15)
IDR9: u1 = 0,
/// IDR10 [10:10]
/// Port input data (y = 0..15)
IDR10: u1 = 0,
/// IDR11 [11:11]
/// Port input data (y = 0..15)
IDR11: u1 = 0,
/// IDR12 [12:12]
/// Port input data (y = 0..15)
IDR12: u1 = 0,
/// IDR13 [13:13]
/// Port input data (y = 0..15)
IDR13: u1 = 0,
/// IDR14 [14:14]
/// Port input data (y = 0..15)
IDR14: u1 = 0,
/// IDR15 [15:15]
/// Port input data (y = 0..15)
IDR15: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// GPIO port input data register
pub const IDR = Register(IDR_val).init(base_address + 0x10);
/// ODR
const ODR_val = packed struct {
/// ODR0 [0:0]
/// Port output data (y = 0..15)
ODR0: u1 = 0,
/// ODR1 [1:1]
/// Port output data (y = 0..15)
ODR1: u1 = 0,
/// ODR2 [2:2]
/// Port output data (y = 0..15)
ODR2: u1 = 0,
/// ODR3 [3:3]
/// Port output data (y = 0..15)
ODR3: u1 = 0,
/// ODR4 [4:4]
/// Port output data (y = 0..15)
ODR4: u1 = 0,
/// ODR5 [5:5]
/// Port output data (y = 0..15)
ODR5: u1 = 0,
/// ODR6 [6:6]
/// Port output data (y = 0..15)
ODR6: u1 = 0,
/// ODR7 [7:7]
/// Port output data (y = 0..15)
ODR7: u1 = 0,
/// ODR8 [8:8]
/// Port output data (y = 0..15)
ODR8: u1 = 0,
/// ODR9 [9:9]
/// Port output data (y = 0..15)
ODR9: u1 = 0,
/// ODR10 [10:10]
/// Port output data (y = 0..15)
ODR10: u1 = 0,
/// ODR11 [11:11]
/// Port output data (y = 0..15)
ODR11: u1 = 0,
/// ODR12 [12:12]
/// Port output data (y = 0..15)
ODR12: u1 = 0,
/// ODR13 [13:13]
/// Port output data (y = 0..15)
ODR13: u1 = 0,
/// ODR14 [14:14]
/// Port output data (y = 0..15)
ODR14: u1 = 0,
/// ODR15 [15:15]
/// Port output data (y = 0..15)
ODR15: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// GPIO port output data register
pub const ODR = Register(ODR_val).init(base_address + 0x14);
/// BSRR
const BSRR_val = packed struct {
/// BS0 [0:0]
/// Port x set bit y (y= 0..15)
BS0: u1 = 0,
/// BS1 [1:1]
/// Port x set bit y (y= 0..15)
BS1: u1 = 0,
/// BS2 [2:2]
/// Port x set bit y (y= 0..15)
BS2: u1 = 0,
/// BS3 [3:3]
/// Port x set bit y (y= 0..15)
BS3: u1 = 0,
/// BS4 [4:4]
/// Port x set bit y (y= 0..15)
BS4: u1 = 0,
/// BS5 [5:5]
/// Port x set bit y (y= 0..15)
BS5: u1 = 0,
/// BS6 [6:6]
/// Port x set bit y (y= 0..15)
BS6: u1 = 0,
/// BS7 [7:7]
/// Port x set bit y (y= 0..15)
BS7: u1 = 0,
/// BS8 [8:8]
/// Port x set bit y (y= 0..15)
BS8: u1 = 0,
/// BS9 [9:9]
/// Port x set bit y (y= 0..15)
BS9: u1 = 0,
/// BS10 [10:10]
/// Port x set bit y (y= 0..15)
BS10: u1 = 0,
/// BS11 [11:11]
/// Port x set bit y (y= 0..15)
BS11: u1 = 0,
/// BS12 [12:12]
/// Port x set bit y (y= 0..15)
BS12: u1 = 0,
/// BS13 [13:13]
/// Port x set bit y (y= 0..15)
BS13: u1 = 0,
/// BS14 [14:14]
/// Port x set bit y (y= 0..15)
BS14: u1 = 0,
/// BS15 [15:15]
/// Port x set bit y (y= 0..15)
BS15: u1 = 0,
/// BR0 [16:16]
/// Port x set bit y (y= 0..15)
BR0: u1 = 0,
/// BR1 [17:17]
/// Port x reset bit y (y = 0..15)
BR1: u1 = 0,
/// BR2 [18:18]
/// Port x reset bit y (y = 0..15)
BR2: u1 = 0,
/// BR3 [19:19]
/// Port x reset bit y (y = 0..15)
BR3: u1 = 0,
/// BR4 [20:20]
/// Port x reset bit y (y = 0..15)
BR4: u1 = 0,
/// BR5 [21:21]
/// Port x reset bit y (y = 0..15)
BR5: u1 = 0,
/// BR6 [22:22]
/// Port x reset bit y (y = 0..15)
BR6: u1 = 0,
/// BR7 [23:23]
/// Port x reset bit y (y = 0..15)
BR7: u1 = 0,
/// BR8 [24:24]
/// Port x reset bit y (y = 0..15)
BR8: u1 = 0,
/// BR9 [25:25]
/// Port x reset bit y (y = 0..15)
BR9: u1 = 0,
/// BR10 [26:26]
/// Port x reset bit y (y = 0..15)
BR10: u1 = 0,
/// BR11 [27:27]
/// Port x reset bit y (y = 0..15)
BR11: u1 = 0,
/// BR12 [28:28]
/// Port x reset bit y (y = 0..15)
BR12: u1 = 0,
/// BR13 [29:29]
/// Port x reset bit y (y = 0..15)
BR13: u1 = 0,
/// BR14 [30:30]
/// Port x reset bit y (y = 0..15)
BR14: u1 = 0,
/// BR15 [31:31]
/// Port x reset bit y (y = 0..15)
BR15: u1 = 0,
};
/// GPIO port bit set/reset register
pub const BSRR = Register(BSRR_val).init(base_address + 0x18);
/// LCKR
const LCKR_val = packed struct {
/// LCK0 [0:0]
/// Port x lock bit y (y= 0..15)
LCK0: u1 = 0,
/// LCK1 [1:1]
/// Port x lock bit y (y= 0..15)
LCK1: u1 = 0,
/// LCK2 [2:2]
/// Port x lock bit y (y= 0..15)
LCK2: u1 = 0,
/// LCK3 [3:3]
/// Port x lock bit y (y= 0..15)
LCK3: u1 = 0,
/// LCK4 [4:4]
/// Port x lock bit y (y= 0..15)
LCK4: u1 = 0,
/// LCK5 [5:5]
/// Port x lock bit y (y= 0..15)
LCK5: u1 = 0,
/// LCK6 [6:6]
/// Port x lock bit y (y= 0..15)
LCK6: u1 = 0,
/// LCK7 [7:7]
/// Port x lock bit y (y= 0..15)
LCK7: u1 = 0,
/// LCK8 [8:8]
/// Port x lock bit y (y= 0..15)
LCK8: u1 = 0,
/// LCK9 [9:9]
/// Port x lock bit y (y= 0..15)
LCK9: u1 = 0,
/// LCK10 [10:10]
/// Port x lock bit y (y= 0..15)
LCK10: u1 = 0,
/// LCK11 [11:11]
/// Port x lock bit y (y= 0..15)
LCK11: u1 = 0,
/// LCK12 [12:12]
/// Port x lock bit y (y= 0..15)
LCK12: u1 = 0,
/// LCK13 [13:13]
/// Port x lock bit y (y= 0..15)
LCK13: u1 = 0,
/// LCK14 [14:14]
/// Port x lock bit y (y= 0..15)
LCK14: u1 = 0,
/// LCK15 [15:15]
/// Port x lock bit y (y= 0..15)
LCK15: u1 = 0,
/// LCKK [16:16]
/// Lok Key
LCKK: u1 = 0,
/// unused [17:31]
_unused17: u7 = 0,
_unused24: u8 = 0,
};
/// GPIO port configuration lock register
pub const LCKR = Register(LCKR_val).init(base_address + 0x1c);
/// AFRL
const AFRL_val = packed struct {
/// AFRL0 [0:3]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL0: u4 = 0,
/// AFRL1 [4:7]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL1: u4 = 0,
/// AFRL2 [8:11]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL2: u4 = 0,
/// AFRL3 [12:15]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL3: u4 = 0,
/// AFRL4 [16:19]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL4: u4 = 0,
/// AFRL5 [20:23]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL5: u4 = 0,
/// AFRL6 [24:27]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL6: u4 = 0,
/// AFRL7 [28:31]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL7: u4 = 0,
};
/// GPIO alternate function low register
pub const AFRL = Register(AFRL_val).init(base_address + 0x20);
/// AFRH
const AFRH_val = packed struct {
/// AFRH8 [0:3]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH8: u4 = 0,
/// AFRH9 [4:7]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH9: u4 = 0,
/// AFRH10 [8:11]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH10: u4 = 0,
/// AFRH11 [12:15]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH11: u4 = 0,
/// AFRH12 [16:19]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH12: u4 = 0,
/// AFRH13 [20:23]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH13: u4 = 0,
/// AFRH14 [24:27]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH14: u4 = 0,
/// AFRH15 [28:31]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH15: u4 = 0,
};
/// GPIO alternate function high register
pub const AFRH = Register(AFRH_val).init(base_address + 0x24);
/// BRR
const BRR_val = packed struct {
/// BR0 [0:0]
/// Port x Reset bit y
BR0: u1 = 0,
/// BR1 [1:1]
/// Port x Reset bit y
BR1: u1 = 0,
/// BR2 [2:2]
/// Port x Reset bit y
BR2: u1 = 0,
/// BR3 [3:3]
/// Port x Reset bit y
BR3: u1 = 0,
/// BR4 [4:4]
/// Port x Reset bit y
BR4: u1 = 0,
/// BR5 [5:5]
/// Port x Reset bit y
BR5: u1 = 0,
/// BR6 [6:6]
/// Port x Reset bit y
BR6: u1 = 0,
/// BR7 [7:7]
/// Port x Reset bit y
BR7: u1 = 0,
/// BR8 [8:8]
/// Port x Reset bit y
BR8: u1 = 0,
/// BR9 [9:9]
/// Port x Reset bit y
BR9: u1 = 0,
/// BR10 [10:10]
/// Port x Reset bit y
BR10: u1 = 0,
/// BR11 [11:11]
/// Port x Reset bit y
BR11: u1 = 0,
/// BR12 [12:12]
/// Port x Reset bit y
BR12: u1 = 0,
/// BR13 [13:13]
/// Port x Reset bit y
BR13: u1 = 0,
/// BR14 [14:14]
/// Port x Reset bit y
BR14: u1 = 0,
/// BR15 [15:15]
/// Port x Reset bit y
BR15: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Port bit reset register
pub const BRR = Register(BRR_val).init(base_address + 0x28);
};
/// General-purpose I/Os
pub const GPIOG = struct {
const base_address = 0x48001800;
/// MODER
const MODER_val = packed struct {
/// MODER0 [0:1]
/// Port x configuration bits (y = 0..15)
MODER0: u2 = 0,
/// MODER1 [2:3]
/// Port x configuration bits (y = 0..15)
MODER1: u2 = 0,
/// MODER2 [4:5]
/// Port x configuration bits (y = 0..15)
MODER2: u2 = 0,
/// MODER3 [6:7]
/// Port x configuration bits (y = 0..15)
MODER3: u2 = 0,
/// MODER4 [8:9]
/// Port x configuration bits (y = 0..15)
MODER4: u2 = 0,
/// MODER5 [10:11]
/// Port x configuration bits (y = 0..15)
MODER5: u2 = 0,
/// MODER6 [12:13]
/// Port x configuration bits (y = 0..15)
MODER6: u2 = 0,
/// MODER7 [14:15]
/// Port x configuration bits (y = 0..15)
MODER7: u2 = 0,
/// MODER8 [16:17]
/// Port x configuration bits (y = 0..15)
MODER8: u2 = 0,
/// MODER9 [18:19]
/// Port x configuration bits (y = 0..15)
MODER9: u2 = 0,
/// MODER10 [20:21]
/// Port x configuration bits (y = 0..15)
MODER10: u2 = 0,
/// MODER11 [22:23]
/// Port x configuration bits (y = 0..15)
MODER11: u2 = 0,
/// MODER12 [24:25]
/// Port x configuration bits (y = 0..15)
MODER12: u2 = 0,
/// MODER13 [26:27]
/// Port x configuration bits (y = 0..15)
MODER13: u2 = 0,
/// MODER14 [28:29]
/// Port x configuration bits (y = 0..15)
MODER14: u2 = 0,
/// MODER15 [30:31]
/// Port x configuration bits (y = 0..15)
MODER15: u2 = 0,
};
/// GPIO port mode register
pub const MODER = Register(MODER_val).init(base_address + 0x0);
/// OTYPER
const OTYPER_val = packed struct {
/// OT0 [0:0]
/// Port x configuration bit 0
OT0: u1 = 0,
/// OT1 [1:1]
/// Port x configuration bit 1
OT1: u1 = 0,
/// OT2 [2:2]
/// Port x configuration bit 2
OT2: u1 = 0,
/// OT3 [3:3]
/// Port x configuration bit 3
OT3: u1 = 0,
/// OT4 [4:4]
/// Port x configuration bit 4
OT4: u1 = 0,
/// OT5 [5:5]
/// Port x configuration bit 5
OT5: u1 = 0,
/// OT6 [6:6]
/// Port x configuration bit 6
OT6: u1 = 0,
/// OT7 [7:7]
/// Port x configuration bit 7
OT7: u1 = 0,
/// OT8 [8:8]
/// Port x configuration bit 8
OT8: u1 = 0,
/// OT9 [9:9]
/// Port x configuration bit 9
OT9: u1 = 0,
/// OT10 [10:10]
/// Port x configuration bit 10
OT10: u1 = 0,
/// OT11 [11:11]
/// Port x configuration bit 11
OT11: u1 = 0,
/// OT12 [12:12]
/// Port x configuration bit 12
OT12: u1 = 0,
/// OT13 [13:13]
/// Port x configuration bit 13
OT13: u1 = 0,
/// OT14 [14:14]
/// Port x configuration bit 14
OT14: u1 = 0,
/// OT15 [15:15]
/// Port x configuration bit 15
OT15: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// GPIO port output type register
pub const OTYPER = Register(OTYPER_val).init(base_address + 0x4);
/// OSPEEDR
const OSPEEDR_val = packed struct {
/// OSPEEDR0 [0:1]
/// Port x configuration bits (y = 0..15)
OSPEEDR0: u2 = 0,
/// OSPEEDR1 [2:3]
/// Port x configuration bits (y = 0..15)
OSPEEDR1: u2 = 0,
/// OSPEEDR2 [4:5]
/// Port x configuration bits (y = 0..15)
OSPEEDR2: u2 = 0,
/// OSPEEDR3 [6:7]
/// Port x configuration bits (y = 0..15)
OSPEEDR3: u2 = 0,
/// OSPEEDR4 [8:9]
/// Port x configuration bits (y = 0..15)
OSPEEDR4: u2 = 0,
/// OSPEEDR5 [10:11]
/// Port x configuration bits (y = 0..15)
OSPEEDR5: u2 = 0,
/// OSPEEDR6 [12:13]
/// Port x configuration bits (y = 0..15)
OSPEEDR6: u2 = 0,
/// OSPEEDR7 [14:15]
/// Port x configuration bits (y = 0..15)
OSPEEDR7: u2 = 0,
/// OSPEEDR8 [16:17]
/// Port x configuration bits (y = 0..15)
OSPEEDR8: u2 = 0,
/// OSPEEDR9 [18:19]
/// Port x configuration bits (y = 0..15)
OSPEEDR9: u2 = 0,
/// OSPEEDR10 [20:21]
/// Port x configuration bits (y = 0..15)
OSPEEDR10: u2 = 0,
/// OSPEEDR11 [22:23]
/// Port x configuration bits (y = 0..15)
OSPEEDR11: u2 = 0,
/// OSPEEDR12 [24:25]
/// Port x configuration bits (y = 0..15)
OSPEEDR12: u2 = 0,
/// OSPEEDR13 [26:27]
/// Port x configuration bits (y = 0..15)
OSPEEDR13: u2 = 0,
/// OSPEEDR14 [28:29]
/// Port x configuration bits (y = 0..15)
OSPEEDR14: u2 = 0,
/// OSPEEDR15 [30:31]
/// Port x configuration bits (y = 0..15)
OSPEEDR15: u2 = 0,
};
/// GPIO port output speed register
pub const OSPEEDR = Register(OSPEEDR_val).init(base_address + 0x8);
/// PUPDR
const PUPDR_val = packed struct {
/// PUPDR0 [0:1]
/// Port x configuration bits (y = 0..15)
PUPDR0: u2 = 0,
/// PUPDR1 [2:3]
/// Port x configuration bits (y = 0..15)
PUPDR1: u2 = 0,
/// PUPDR2 [4:5]
/// Port x configuration bits (y = 0..15)
PUPDR2: u2 = 0,
/// PUPDR3 [6:7]
/// Port x configuration bits (y = 0..15)
PUPDR3: u2 = 0,
/// PUPDR4 [8:9]
/// Port x configuration bits (y = 0..15)
PUPDR4: u2 = 0,
/// PUPDR5 [10:11]
/// Port x configuration bits (y = 0..15)
PUPDR5: u2 = 0,
/// PUPDR6 [12:13]
/// Port x configuration bits (y = 0..15)
PUPDR6: u2 = 0,
/// PUPDR7 [14:15]
/// Port x configuration bits (y = 0..15)
PUPDR7: u2 = 0,
/// PUPDR8 [16:17]
/// Port x configuration bits (y = 0..15)
PUPDR8: u2 = 0,
/// PUPDR9 [18:19]
/// Port x configuration bits (y = 0..15)
PUPDR9: u2 = 0,
/// PUPDR10 [20:21]
/// Port x configuration bits (y = 0..15)
PUPDR10: u2 = 0,
/// PUPDR11 [22:23]
/// Port x configuration bits (y = 0..15)
PUPDR11: u2 = 0,
/// PUPDR12 [24:25]
/// Port x configuration bits (y = 0..15)
PUPDR12: u2 = 0,
/// PUPDR13 [26:27]
/// Port x configuration bits (y = 0..15)
PUPDR13: u2 = 0,
/// PUPDR14 [28:29]
/// Port x configuration bits (y = 0..15)
PUPDR14: u2 = 0,
/// PUPDR15 [30:31]
/// Port x configuration bits (y = 0..15)
PUPDR15: u2 = 0,
};
/// GPIO port pull-up/pull-down register
pub const PUPDR = Register(PUPDR_val).init(base_address + 0xc);
/// IDR
const IDR_val = packed struct {
/// IDR0 [0:0]
/// Port input data (y = 0..15)
IDR0: u1 = 0,
/// IDR1 [1:1]
/// Port input data (y = 0..15)
IDR1: u1 = 0,
/// IDR2 [2:2]
/// Port input data (y = 0..15)
IDR2: u1 = 0,
/// IDR3 [3:3]
/// Port input data (y = 0..15)
IDR3: u1 = 0,
/// IDR4 [4:4]
/// Port input data (y = 0..15)
IDR4: u1 = 0,
/// IDR5 [5:5]
/// Port input data (y = 0..15)
IDR5: u1 = 0,
/// IDR6 [6:6]
/// Port input data (y = 0..15)
IDR6: u1 = 0,
/// IDR7 [7:7]
/// Port input data (y = 0..15)
IDR7: u1 = 0,
/// IDR8 [8:8]
/// Port input data (y = 0..15)
IDR8: u1 = 0,
/// IDR9 [9:9]
/// Port input data (y = 0..15)
IDR9: u1 = 0,
/// IDR10 [10:10]
/// Port input data (y = 0..15)
IDR10: u1 = 0,
/// IDR11 [11:11]
/// Port input data (y = 0..15)
IDR11: u1 = 0,
/// IDR12 [12:12]
/// Port input data (y = 0..15)
IDR12: u1 = 0,
/// IDR13 [13:13]
/// Port input data (y = 0..15)
IDR13: u1 = 0,
/// IDR14 [14:14]
/// Port input data (y = 0..15)
IDR14: u1 = 0,
/// IDR15 [15:15]
/// Port input data (y = 0..15)
IDR15: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// GPIO port input data register
pub const IDR = Register(IDR_val).init(base_address + 0x10);
/// ODR
const ODR_val = packed struct {
/// ODR0 [0:0]
/// Port output data (y = 0..15)
ODR0: u1 = 0,
/// ODR1 [1:1]
/// Port output data (y = 0..15)
ODR1: u1 = 0,
/// ODR2 [2:2]
/// Port output data (y = 0..15)
ODR2: u1 = 0,
/// ODR3 [3:3]
/// Port output data (y = 0..15)
ODR3: u1 = 0,
/// ODR4 [4:4]
/// Port output data (y = 0..15)
ODR4: u1 = 0,
/// ODR5 [5:5]
/// Port output data (y = 0..15)
ODR5: u1 = 0,
/// ODR6 [6:6]
/// Port output data (y = 0..15)
ODR6: u1 = 0,
/// ODR7 [7:7]
/// Port output data (y = 0..15)
ODR7: u1 = 0,
/// ODR8 [8:8]
/// Port output data (y = 0..15)
ODR8: u1 = 0,
/// ODR9 [9:9]
/// Port output data (y = 0..15)
ODR9: u1 = 0,
/// ODR10 [10:10]
/// Port output data (y = 0..15)
ODR10: u1 = 0,
/// ODR11 [11:11]
/// Port output data (y = 0..15)
ODR11: u1 = 0,
/// ODR12 [12:12]
/// Port output data (y = 0..15)
ODR12: u1 = 0,
/// ODR13 [13:13]
/// Port output data (y = 0..15)
ODR13: u1 = 0,
/// ODR14 [14:14]
/// Port output data (y = 0..15)
ODR14: u1 = 0,
/// ODR15 [15:15]
/// Port output data (y = 0..15)
ODR15: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// GPIO port output data register
pub const ODR = Register(ODR_val).init(base_address + 0x14);
/// BSRR
const BSRR_val = packed struct {
/// BS0 [0:0]
/// Port x set bit y (y= 0..15)
BS0: u1 = 0,
/// BS1 [1:1]
/// Port x set bit y (y= 0..15)
BS1: u1 = 0,
/// BS2 [2:2]
/// Port x set bit y (y= 0..15)
BS2: u1 = 0,
/// BS3 [3:3]
/// Port x set bit y (y= 0..15)
BS3: u1 = 0,
/// BS4 [4:4]
/// Port x set bit y (y= 0..15)
BS4: u1 = 0,
/// BS5 [5:5]
/// Port x set bit y (y= 0..15)
BS5: u1 = 0,
/// BS6 [6:6]
/// Port x set bit y (y= 0..15)
BS6: u1 = 0,
/// BS7 [7:7]
/// Port x set bit y (y= 0..15)
BS7: u1 = 0,
/// BS8 [8:8]
/// Port x set bit y (y= 0..15)
BS8: u1 = 0,
/// BS9 [9:9]
/// Port x set bit y (y= 0..15)
BS9: u1 = 0,
/// BS10 [10:10]
/// Port x set bit y (y= 0..15)
BS10: u1 = 0,
/// BS11 [11:11]
/// Port x set bit y (y= 0..15)
BS11: u1 = 0,
/// BS12 [12:12]
/// Port x set bit y (y= 0..15)
BS12: u1 = 0,
/// BS13 [13:13]
/// Port x set bit y (y= 0..15)
BS13: u1 = 0,
/// BS14 [14:14]
/// Port x set bit y (y= 0..15)
BS14: u1 = 0,
/// BS15 [15:15]
/// Port x set bit y (y= 0..15)
BS15: u1 = 0,
/// BR0 [16:16]
/// Port x set bit y (y= 0..15)
BR0: u1 = 0,
/// BR1 [17:17]
/// Port x reset bit y (y = 0..15)
BR1: u1 = 0,
/// BR2 [18:18]
/// Port x reset bit y (y = 0..15)
BR2: u1 = 0,
/// BR3 [19:19]
/// Port x reset bit y (y = 0..15)
BR3: u1 = 0,
/// BR4 [20:20]
/// Port x reset bit y (y = 0..15)
BR4: u1 = 0,
/// BR5 [21:21]
/// Port x reset bit y (y = 0..15)
BR5: u1 = 0,
/// BR6 [22:22]
/// Port x reset bit y (y = 0..15)
BR6: u1 = 0,
/// BR7 [23:23]
/// Port x reset bit y (y = 0..15)
BR7: u1 = 0,
/// BR8 [24:24]
/// Port x reset bit y (y = 0..15)
BR8: u1 = 0,
/// BR9 [25:25]
/// Port x reset bit y (y = 0..15)
BR9: u1 = 0,
/// BR10 [26:26]
/// Port x reset bit y (y = 0..15)
BR10: u1 = 0,
/// BR11 [27:27]
/// Port x reset bit y (y = 0..15)
BR11: u1 = 0,
/// BR12 [28:28]
/// Port x reset bit y (y = 0..15)
BR12: u1 = 0,
/// BR13 [29:29]
/// Port x reset bit y (y = 0..15)
BR13: u1 = 0,
/// BR14 [30:30]
/// Port x reset bit y (y = 0..15)
BR14: u1 = 0,
/// BR15 [31:31]
/// Port x reset bit y (y = 0..15)
BR15: u1 = 0,
};
/// GPIO port bit set/reset register
pub const BSRR = Register(BSRR_val).init(base_address + 0x18);
/// LCKR
const LCKR_val = packed struct {
/// LCK0 [0:0]
/// Port x lock bit y (y= 0..15)
LCK0: u1 = 0,
/// LCK1 [1:1]
/// Port x lock bit y (y= 0..15)
LCK1: u1 = 0,
/// LCK2 [2:2]
/// Port x lock bit y (y= 0..15)
LCK2: u1 = 0,
/// LCK3 [3:3]
/// Port x lock bit y (y= 0..15)
LCK3: u1 = 0,
/// LCK4 [4:4]
/// Port x lock bit y (y= 0..15)
LCK4: u1 = 0,
/// LCK5 [5:5]
/// Port x lock bit y (y= 0..15)
LCK5: u1 = 0,
/// LCK6 [6:6]
/// Port x lock bit y (y= 0..15)
LCK6: u1 = 0,
/// LCK7 [7:7]
/// Port x lock bit y (y= 0..15)
LCK7: u1 = 0,
/// LCK8 [8:8]
/// Port x lock bit y (y= 0..15)
LCK8: u1 = 0,
/// LCK9 [9:9]
/// Port x lock bit y (y= 0..15)
LCK9: u1 = 0,
/// LCK10 [10:10]
/// Port x lock bit y (y= 0..15)
LCK10: u1 = 0,
/// LCK11 [11:11]
/// Port x lock bit y (y= 0..15)
LCK11: u1 = 0,
/// LCK12 [12:12]
/// Port x lock bit y (y= 0..15)
LCK12: u1 = 0,
/// LCK13 [13:13]
/// Port x lock bit y (y= 0..15)
LCK13: u1 = 0,
/// LCK14 [14:14]
/// Port x lock bit y (y= 0..15)
LCK14: u1 = 0,
/// LCK15 [15:15]
/// Port x lock bit y (y= 0..15)
LCK15: u1 = 0,
/// LCKK [16:16]
/// Lok Key
LCKK: u1 = 0,
/// unused [17:31]
_unused17: u7 = 0,
_unused24: u8 = 0,
};
/// GPIO port configuration lock register
pub const LCKR = Register(LCKR_val).init(base_address + 0x1c);
/// AFRL
const AFRL_val = packed struct {
/// AFRL0 [0:3]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL0: u4 = 0,
/// AFRL1 [4:7]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL1: u4 = 0,
/// AFRL2 [8:11]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL2: u4 = 0,
/// AFRL3 [12:15]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL3: u4 = 0,
/// AFRL4 [16:19]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL4: u4 = 0,
/// AFRL5 [20:23]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL5: u4 = 0,
/// AFRL6 [24:27]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL6: u4 = 0,
/// AFRL7 [28:31]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL7: u4 = 0,
};
/// GPIO alternate function low register
pub const AFRL = Register(AFRL_val).init(base_address + 0x20);
/// AFRH
const AFRH_val = packed struct {
/// AFRH8 [0:3]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH8: u4 = 0,
/// AFRH9 [4:7]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH9: u4 = 0,
/// AFRH10 [8:11]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH10: u4 = 0,
/// AFRH11 [12:15]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH11: u4 = 0,
/// AFRH12 [16:19]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH12: u4 = 0,
/// AFRH13 [20:23]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH13: u4 = 0,
/// AFRH14 [24:27]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH14: u4 = 0,
/// AFRH15 [28:31]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH15: u4 = 0,
};
/// GPIO alternate function high register
pub const AFRH = Register(AFRH_val).init(base_address + 0x24);
/// BRR
const BRR_val = packed struct {
/// BR0 [0:0]
/// Port x Reset bit y
BR0: u1 = 0,
/// BR1 [1:1]
/// Port x Reset bit y
BR1: u1 = 0,
/// BR2 [2:2]
/// Port x Reset bit y
BR2: u1 = 0,
/// BR3 [3:3]
/// Port x Reset bit y
BR3: u1 = 0,
/// BR4 [4:4]
/// Port x Reset bit y
BR4: u1 = 0,
/// BR5 [5:5]
/// Port x Reset bit y
BR5: u1 = 0,
/// BR6 [6:6]
/// Port x Reset bit y
BR6: u1 = 0,
/// BR7 [7:7]
/// Port x Reset bit y
BR7: u1 = 0,
/// BR8 [8:8]
/// Port x Reset bit y
BR8: u1 = 0,
/// BR9 [9:9]
/// Port x Reset bit y
BR9: u1 = 0,
/// BR10 [10:10]
/// Port x Reset bit y
BR10: u1 = 0,
/// BR11 [11:11]
/// Port x Reset bit y
BR11: u1 = 0,
/// BR12 [12:12]
/// Port x Reset bit y
BR12: u1 = 0,
/// BR13 [13:13]
/// Port x Reset bit y
BR13: u1 = 0,
/// BR14 [14:14]
/// Port x Reset bit y
BR14: u1 = 0,
/// BR15 [15:15]
/// Port x Reset bit y
BR15: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Port bit reset register
pub const BRR = Register(BRR_val).init(base_address + 0x28);
};
/// General-purpose I/Os
pub const GPIOH = struct {
const base_address = 0x48001c00;
/// MODER
const MODER_val = packed struct {
/// MODER0 [0:1]
/// Port x configuration bits (y = 0..15)
MODER0: u2 = 0,
/// MODER1 [2:3]
/// Port x configuration bits (y = 0..15)
MODER1: u2 = 0,
/// MODER2 [4:5]
/// Port x configuration bits (y = 0..15)
MODER2: u2 = 0,
/// MODER3 [6:7]
/// Port x configuration bits (y = 0..15)
MODER3: u2 = 0,
/// MODER4 [8:9]
/// Port x configuration bits (y = 0..15)
MODER4: u2 = 0,
/// MODER5 [10:11]
/// Port x configuration bits (y = 0..15)
MODER5: u2 = 0,
/// MODER6 [12:13]
/// Port x configuration bits (y = 0..15)
MODER6: u2 = 0,
/// MODER7 [14:15]
/// Port x configuration bits (y = 0..15)
MODER7: u2 = 0,
/// MODER8 [16:17]
/// Port x configuration bits (y = 0..15)
MODER8: u2 = 0,
/// MODER9 [18:19]
/// Port x configuration bits (y = 0..15)
MODER9: u2 = 0,
/// MODER10 [20:21]
/// Port x configuration bits (y = 0..15)
MODER10: u2 = 0,
/// MODER11 [22:23]
/// Port x configuration bits (y = 0..15)
MODER11: u2 = 0,
/// MODER12 [24:25]
/// Port x configuration bits (y = 0..15)
MODER12: u2 = 0,
/// MODER13 [26:27]
/// Port x configuration bits (y = 0..15)
MODER13: u2 = 0,
/// MODER14 [28:29]
/// Port x configuration bits (y = 0..15)
MODER14: u2 = 0,
/// MODER15 [30:31]
/// Port x configuration bits (y = 0..15)
MODER15: u2 = 0,
};
/// GPIO port mode register
pub const MODER = Register(MODER_val).init(base_address + 0x0);
/// OTYPER
const OTYPER_val = packed struct {
/// OT0 [0:0]
/// Port x configuration bit 0
OT0: u1 = 0,
/// OT1 [1:1]
/// Port x configuration bit 1
OT1: u1 = 0,
/// OT2 [2:2]
/// Port x configuration bit 2
OT2: u1 = 0,
/// OT3 [3:3]
/// Port x configuration bit 3
OT3: u1 = 0,
/// OT4 [4:4]
/// Port x configuration bit 4
OT4: u1 = 0,
/// OT5 [5:5]
/// Port x configuration bit 5
OT5: u1 = 0,
/// OT6 [6:6]
/// Port x configuration bit 6
OT6: u1 = 0,
/// OT7 [7:7]
/// Port x configuration bit 7
OT7: u1 = 0,
/// OT8 [8:8]
/// Port x configuration bit 8
OT8: u1 = 0,
/// OT9 [9:9]
/// Port x configuration bit 9
OT9: u1 = 0,
/// OT10 [10:10]
/// Port x configuration bit 10
OT10: u1 = 0,
/// OT11 [11:11]
/// Port x configuration bit 11
OT11: u1 = 0,
/// OT12 [12:12]
/// Port x configuration bit 12
OT12: u1 = 0,
/// OT13 [13:13]
/// Port x configuration bit 13
OT13: u1 = 0,
/// OT14 [14:14]
/// Port x configuration bit 14
OT14: u1 = 0,
/// OT15 [15:15]
/// Port x configuration bit 15
OT15: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// GPIO port output type register
pub const OTYPER = Register(OTYPER_val).init(base_address + 0x4);
/// OSPEEDR
const OSPEEDR_val = packed struct {
/// OSPEEDR0 [0:1]
/// Port x configuration bits (y = 0..15)
OSPEEDR0: u2 = 0,
/// OSPEEDR1 [2:3]
/// Port x configuration bits (y = 0..15)
OSPEEDR1: u2 = 0,
/// OSPEEDR2 [4:5]
/// Port x configuration bits (y = 0..15)
OSPEEDR2: u2 = 0,
/// OSPEEDR3 [6:7]
/// Port x configuration bits (y = 0..15)
OSPEEDR3: u2 = 0,
/// OSPEEDR4 [8:9]
/// Port x configuration bits (y = 0..15)
OSPEEDR4: u2 = 0,
/// OSPEEDR5 [10:11]
/// Port x configuration bits (y = 0..15)
OSPEEDR5: u2 = 0,
/// OSPEEDR6 [12:13]
/// Port x configuration bits (y = 0..15)
OSPEEDR6: u2 = 0,
/// OSPEEDR7 [14:15]
/// Port x configuration bits (y = 0..15)
OSPEEDR7: u2 = 0,
/// OSPEEDR8 [16:17]
/// Port x configuration bits (y = 0..15)
OSPEEDR8: u2 = 0,
/// OSPEEDR9 [18:19]
/// Port x configuration bits (y = 0..15)
OSPEEDR9: u2 = 0,
/// OSPEEDR10 [20:21]
/// Port x configuration bits (y = 0..15)
OSPEEDR10: u2 = 0,
/// OSPEEDR11 [22:23]
/// Port x configuration bits (y = 0..15)
OSPEEDR11: u2 = 0,
/// OSPEEDR12 [24:25]
/// Port x configuration bits (y = 0..15)
OSPEEDR12: u2 = 0,
/// OSPEEDR13 [26:27]
/// Port x configuration bits (y = 0..15)
OSPEEDR13: u2 = 0,
/// OSPEEDR14 [28:29]
/// Port x configuration bits (y = 0..15)
OSPEEDR14: u2 = 0,
/// OSPEEDR15 [30:31]
/// Port x configuration bits (y = 0..15)
OSPEEDR15: u2 = 0,
};
/// GPIO port output speed register
pub const OSPEEDR = Register(OSPEEDR_val).init(base_address + 0x8);
/// PUPDR
const PUPDR_val = packed struct {
/// PUPDR0 [0:1]
/// Port x configuration bits (y = 0..15)
PUPDR0: u2 = 0,
/// PUPDR1 [2:3]
/// Port x configuration bits (y = 0..15)
PUPDR1: u2 = 0,
/// PUPDR2 [4:5]
/// Port x configuration bits (y = 0..15)
PUPDR2: u2 = 0,
/// PUPDR3 [6:7]
/// Port x configuration bits (y = 0..15)
PUPDR3: u2 = 0,
/// PUPDR4 [8:9]
/// Port x configuration bits (y = 0..15)
PUPDR4: u2 = 0,
/// PUPDR5 [10:11]
/// Port x configuration bits (y = 0..15)
PUPDR5: u2 = 0,
/// PUPDR6 [12:13]
/// Port x configuration bits (y = 0..15)
PUPDR6: u2 = 0,
/// PUPDR7 [14:15]
/// Port x configuration bits (y = 0..15)
PUPDR7: u2 = 0,
/// PUPDR8 [16:17]
/// Port x configuration bits (y = 0..15)
PUPDR8: u2 = 0,
/// PUPDR9 [18:19]
/// Port x configuration bits (y = 0..15)
PUPDR9: u2 = 0,
/// PUPDR10 [20:21]
/// Port x configuration bits (y = 0..15)
PUPDR10: u2 = 0,
/// PUPDR11 [22:23]
/// Port x configuration bits (y = 0..15)
PUPDR11: u2 = 0,
/// PUPDR12 [24:25]
/// Port x configuration bits (y = 0..15)
PUPDR12: u2 = 0,
/// PUPDR13 [26:27]
/// Port x configuration bits (y = 0..15)
PUPDR13: u2 = 0,
/// PUPDR14 [28:29]
/// Port x configuration bits (y = 0..15)
PUPDR14: u2 = 0,
/// PUPDR15 [30:31]
/// Port x configuration bits (y = 0..15)
PUPDR15: u2 = 0,
};
/// GPIO port pull-up/pull-down register
pub const PUPDR = Register(PUPDR_val).init(base_address + 0xc);
/// IDR
const IDR_val = packed struct {
/// IDR0 [0:0]
/// Port input data (y = 0..15)
IDR0: u1 = 0,
/// IDR1 [1:1]
/// Port input data (y = 0..15)
IDR1: u1 = 0,
/// IDR2 [2:2]
/// Port input data (y = 0..15)
IDR2: u1 = 0,
/// IDR3 [3:3]
/// Port input data (y = 0..15)
IDR3: u1 = 0,
/// IDR4 [4:4]
/// Port input data (y = 0..15)
IDR4: u1 = 0,
/// IDR5 [5:5]
/// Port input data (y = 0..15)
IDR5: u1 = 0,
/// IDR6 [6:6]
/// Port input data (y = 0..15)
IDR6: u1 = 0,
/// IDR7 [7:7]
/// Port input data (y = 0..15)
IDR7: u1 = 0,
/// IDR8 [8:8]
/// Port input data (y = 0..15)
IDR8: u1 = 0,
/// IDR9 [9:9]
/// Port input data (y = 0..15)
IDR9: u1 = 0,
/// IDR10 [10:10]
/// Port input data (y = 0..15)
IDR10: u1 = 0,
/// IDR11 [11:11]
/// Port input data (y = 0..15)
IDR11: u1 = 0,
/// IDR12 [12:12]
/// Port input data (y = 0..15)
IDR12: u1 = 0,
/// IDR13 [13:13]
/// Port input data (y = 0..15)
IDR13: u1 = 0,
/// IDR14 [14:14]
/// Port input data (y = 0..15)
IDR14: u1 = 0,
/// IDR15 [15:15]
/// Port input data (y = 0..15)
IDR15: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// GPIO port input data register
pub const IDR = Register(IDR_val).init(base_address + 0x10);
/// ODR
const ODR_val = packed struct {
/// ODR0 [0:0]
/// Port output data (y = 0..15)
ODR0: u1 = 0,
/// ODR1 [1:1]
/// Port output data (y = 0..15)
ODR1: u1 = 0,
/// ODR2 [2:2]
/// Port output data (y = 0..15)
ODR2: u1 = 0,
/// ODR3 [3:3]
/// Port output data (y = 0..15)
ODR3: u1 = 0,
/// ODR4 [4:4]
/// Port output data (y = 0..15)
ODR4: u1 = 0,
/// ODR5 [5:5]
/// Port output data (y = 0..15)
ODR5: u1 = 0,
/// ODR6 [6:6]
/// Port output data (y = 0..15)
ODR6: u1 = 0,
/// ODR7 [7:7]
/// Port output data (y = 0..15)
ODR7: u1 = 0,
/// ODR8 [8:8]
/// Port output data (y = 0..15)
ODR8: u1 = 0,
/// ODR9 [9:9]
/// Port output data (y = 0..15)
ODR9: u1 = 0,
/// ODR10 [10:10]
/// Port output data (y = 0..15)
ODR10: u1 = 0,
/// ODR11 [11:11]
/// Port output data (y = 0..15)
ODR11: u1 = 0,
/// ODR12 [12:12]
/// Port output data (y = 0..15)
ODR12: u1 = 0,
/// ODR13 [13:13]
/// Port output data (y = 0..15)
ODR13: u1 = 0,
/// ODR14 [14:14]
/// Port output data (y = 0..15)
ODR14: u1 = 0,
/// ODR15 [15:15]
/// Port output data (y = 0..15)
ODR15: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// GPIO port output data register
pub const ODR = Register(ODR_val).init(base_address + 0x14);
/// BSRR
const BSRR_val = packed struct {
/// BS0 [0:0]
/// Port x set bit y (y= 0..15)
BS0: u1 = 0,
/// BS1 [1:1]
/// Port x set bit y (y= 0..15)
BS1: u1 = 0,
/// BS2 [2:2]
/// Port x set bit y (y= 0..15)
BS2: u1 = 0,
/// BS3 [3:3]
/// Port x set bit y (y= 0..15)
BS3: u1 = 0,
/// BS4 [4:4]
/// Port x set bit y (y= 0..15)
BS4: u1 = 0,
/// BS5 [5:5]
/// Port x set bit y (y= 0..15)
BS5: u1 = 0,
/// BS6 [6:6]
/// Port x set bit y (y= 0..15)
BS6: u1 = 0,
/// BS7 [7:7]
/// Port x set bit y (y= 0..15)
BS7: u1 = 0,
/// BS8 [8:8]
/// Port x set bit y (y= 0..15)
BS8: u1 = 0,
/// BS9 [9:9]
/// Port x set bit y (y= 0..15)
BS9: u1 = 0,
/// BS10 [10:10]
/// Port x set bit y (y= 0..15)
BS10: u1 = 0,
/// BS11 [11:11]
/// Port x set bit y (y= 0..15)
BS11: u1 = 0,
/// BS12 [12:12]
/// Port x set bit y (y= 0..15)
BS12: u1 = 0,
/// BS13 [13:13]
/// Port x set bit y (y= 0..15)
BS13: u1 = 0,
/// BS14 [14:14]
/// Port x set bit y (y= 0..15)
BS14: u1 = 0,
/// BS15 [15:15]
/// Port x set bit y (y= 0..15)
BS15: u1 = 0,
/// BR0 [16:16]
/// Port x set bit y (y= 0..15)
BR0: u1 = 0,
/// BR1 [17:17]
/// Port x reset bit y (y = 0..15)
BR1: u1 = 0,
/// BR2 [18:18]
/// Port x reset bit y (y = 0..15)
BR2: u1 = 0,
/// BR3 [19:19]
/// Port x reset bit y (y = 0..15)
BR3: u1 = 0,
/// BR4 [20:20]
/// Port x reset bit y (y = 0..15)
BR4: u1 = 0,
/// BR5 [21:21]
/// Port x reset bit y (y = 0..15)
BR5: u1 = 0,
/// BR6 [22:22]
/// Port x reset bit y (y = 0..15)
BR6: u1 = 0,
/// BR7 [23:23]
/// Port x reset bit y (y = 0..15)
BR7: u1 = 0,
/// BR8 [24:24]
/// Port x reset bit y (y = 0..15)
BR8: u1 = 0,
/// BR9 [25:25]
/// Port x reset bit y (y = 0..15)
BR9: u1 = 0,
/// BR10 [26:26]
/// Port x reset bit y (y = 0..15)
BR10: u1 = 0,
/// BR11 [27:27]
/// Port x reset bit y (y = 0..15)
BR11: u1 = 0,
/// BR12 [28:28]
/// Port x reset bit y (y = 0..15)
BR12: u1 = 0,
/// BR13 [29:29]
/// Port x reset bit y (y = 0..15)
BR13: u1 = 0,
/// BR14 [30:30]
/// Port x reset bit y (y = 0..15)
BR14: u1 = 0,
/// BR15 [31:31]
/// Port x reset bit y (y = 0..15)
BR15: u1 = 0,
};
/// GPIO port bit set/reset register
pub const BSRR = Register(BSRR_val).init(base_address + 0x18);
/// LCKR
const LCKR_val = packed struct {
/// LCK0 [0:0]
/// Port x lock bit y (y= 0..15)
LCK0: u1 = 0,
/// LCK1 [1:1]
/// Port x lock bit y (y= 0..15)
LCK1: u1 = 0,
/// LCK2 [2:2]
/// Port x lock bit y (y= 0..15)
LCK2: u1 = 0,
/// LCK3 [3:3]
/// Port x lock bit y (y= 0..15)
LCK3: u1 = 0,
/// LCK4 [4:4]
/// Port x lock bit y (y= 0..15)
LCK4: u1 = 0,
/// LCK5 [5:5]
/// Port x lock bit y (y= 0..15)
LCK5: u1 = 0,
/// LCK6 [6:6]
/// Port x lock bit y (y= 0..15)
LCK6: u1 = 0,
/// LCK7 [7:7]
/// Port x lock bit y (y= 0..15)
LCK7: u1 = 0,
/// LCK8 [8:8]
/// Port x lock bit y (y= 0..15)
LCK8: u1 = 0,
/// LCK9 [9:9]
/// Port x lock bit y (y= 0..15)
LCK9: u1 = 0,
/// LCK10 [10:10]
/// Port x lock bit y (y= 0..15)
LCK10: u1 = 0,
/// LCK11 [11:11]
/// Port x lock bit y (y= 0..15)
LCK11: u1 = 0,
/// LCK12 [12:12]
/// Port x lock bit y (y= 0..15)
LCK12: u1 = 0,
/// LCK13 [13:13]
/// Port x lock bit y (y= 0..15)
LCK13: u1 = 0,
/// LCK14 [14:14]
/// Port x lock bit y (y= 0..15)
LCK14: u1 = 0,
/// LCK15 [15:15]
/// Port x lock bit y (y= 0..15)
LCK15: u1 = 0,
/// LCKK [16:16]
/// Lok Key
LCKK: u1 = 0,
/// unused [17:31]
_unused17: u7 = 0,
_unused24: u8 = 0,
};
/// GPIO port configuration lock register
pub const LCKR = Register(LCKR_val).init(base_address + 0x1c);
/// AFRL
const AFRL_val = packed struct {
/// AFRL0 [0:3]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL0: u4 = 0,
/// AFRL1 [4:7]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL1: u4 = 0,
/// AFRL2 [8:11]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL2: u4 = 0,
/// AFRL3 [12:15]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL3: u4 = 0,
/// AFRL4 [16:19]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL4: u4 = 0,
/// AFRL5 [20:23]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL5: u4 = 0,
/// AFRL6 [24:27]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL6: u4 = 0,
/// AFRL7 [28:31]
/// Alternate function selection for port x bit y (y = 0..7)
AFRL7: u4 = 0,
};
/// GPIO alternate function low register
pub const AFRL = Register(AFRL_val).init(base_address + 0x20);
/// AFRH
const AFRH_val = packed struct {
/// AFRH8 [0:3]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH8: u4 = 0,
/// AFRH9 [4:7]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH9: u4 = 0,
/// AFRH10 [8:11]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH10: u4 = 0,
/// AFRH11 [12:15]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH11: u4 = 0,
/// AFRH12 [16:19]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH12: u4 = 0,
/// AFRH13 [20:23]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH13: u4 = 0,
/// AFRH14 [24:27]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH14: u4 = 0,
/// AFRH15 [28:31]
/// Alternate function selection for port x bit y (y = 8..15)
AFRH15: u4 = 0,
};
/// GPIO alternate function high register
pub const AFRH = Register(AFRH_val).init(base_address + 0x24);
/// BRR
const BRR_val = packed struct {
/// BR0 [0:0]
/// Port x Reset bit y
BR0: u1 = 0,
/// BR1 [1:1]
/// Port x Reset bit y
BR1: u1 = 0,
/// BR2 [2:2]
/// Port x Reset bit y
BR2: u1 = 0,
/// BR3 [3:3]
/// Port x Reset bit y
BR3: u1 = 0,
/// BR4 [4:4]
/// Port x Reset bit y
BR4: u1 = 0,
/// BR5 [5:5]
/// Port x Reset bit y
BR5: u1 = 0,
/// BR6 [6:6]
/// Port x Reset bit y
BR6: u1 = 0,
/// BR7 [7:7]
/// Port x Reset bit y
BR7: u1 = 0,
/// BR8 [8:8]
/// Port x Reset bit y
BR8: u1 = 0,
/// BR9 [9:9]
/// Port x Reset bit y
BR9: u1 = 0,
/// BR10 [10:10]
/// Port x Reset bit y
BR10: u1 = 0,
/// BR11 [11:11]
/// Port x Reset bit y
BR11: u1 = 0,
/// BR12 [12:12]
/// Port x Reset bit y
BR12: u1 = 0,
/// BR13 [13:13]
/// Port x Reset bit y
BR13: u1 = 0,
/// BR14 [14:14]
/// Port x Reset bit y
BR14: u1 = 0,
/// BR15 [15:15]
/// Port x Reset bit y
BR15: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Port bit reset register
pub const BRR = Register(BRR_val).init(base_address + 0x28);
};
/// Touch sensing controller
pub const TSC = struct {
const base_address = 0x40024000;
/// CR
const CR_val = packed struct {
/// TSCE [0:0]
/// Touch sensing controller enable
TSCE: u1 = 0,
/// START [1:1]
/// Start a new acquisition
START: u1 = 0,
/// AM [2:2]
/// Acquisition mode
AM: u1 = 0,
/// SYNCPOL [3:3]
/// Synchronization pin polarity
SYNCPOL: u1 = 0,
/// IODEF [4:4]
/// I/O Default mode
IODEF: u1 = 0,
/// MCV [5:7]
/// Max count value
MCV: u3 = 0,
/// unused [8:11]
_unused8: u4 = 0,
/// PGPSC [12:14]
/// pulse generator prescaler
PGPSC: u3 = 0,
/// SSPSC [15:15]
/// Spread spectrum prescaler
SSPSC: u1 = 0,
/// SSE [16:16]
/// Spread spectrum enable
SSE: u1 = 0,
/// SSD [17:23]
/// Spread spectrum deviation
SSD: u7 = 0,
/// CTPL [24:27]
/// Charge transfer pulse low
CTPL: u4 = 0,
/// CTPH [28:31]
/// Charge transfer pulse high
CTPH: u4 = 0,
};
/// control register
pub const CR = Register(CR_val).init(base_address + 0x0);
/// IER
const IER_val = packed struct {
/// EOAIE [0:0]
/// End of acquisition interrupt enable
EOAIE: u1 = 0,
/// MCEIE [1:1]
/// Max count error interrupt enable
MCEIE: u1 = 0,
/// unused [2:31]
_unused2: u6 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// interrupt enable register
pub const IER = Register(IER_val).init(base_address + 0x4);
/// ICR
const ICR_val = packed struct {
/// EOAIC [0:0]
/// End of acquisition interrupt clear
EOAIC: u1 = 0,
/// MCEIC [1:1]
/// Max count error interrupt clear
MCEIC: u1 = 0,
/// unused [2:31]
_unused2: u6 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// interrupt clear register
pub const ICR = Register(ICR_val).init(base_address + 0x8);
/// ISR
const ISR_val = packed struct {
/// EOAF [0:0]
/// End of acquisition flag
EOAF: u1 = 0,
/// MCEF [1:1]
/// Max count error flag
MCEF: u1 = 0,
/// unused [2:31]
_unused2: u6 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// interrupt status register
pub const ISR = Register(ISR_val).init(base_address + 0xc);
/// IOHCR
const IOHCR_val = packed struct {
/// G1_IO1 [0:0]
/// G1_IO1 Schmitt trigger hysteresis mode
G1_IO1: u1 = 1,
/// G1_IO2 [1:1]
/// G1_IO2 Schmitt trigger hysteresis mode
G1_IO2: u1 = 1,
/// G1_IO3 [2:2]
/// G1_IO3 Schmitt trigger hysteresis mode
G1_IO3: u1 = 1,
/// G1_IO4 [3:3]
/// G1_IO4 Schmitt trigger hysteresis mode
G1_IO4: u1 = 1,
/// G2_IO1 [4:4]
/// G2_IO1 Schmitt trigger hysteresis mode
G2_IO1: u1 = 1,
/// G2_IO2 [5:5]
/// G2_IO2 Schmitt trigger hysteresis mode
G2_IO2: u1 = 1,
/// G2_IO3 [6:6]
/// G2_IO3 Schmitt trigger hysteresis mode
G2_IO3: u1 = 1,
/// G2_IO4 [7:7]
/// G2_IO4 Schmitt trigger hysteresis mode
G2_IO4: u1 = 1,
/// G3_IO1 [8:8]
/// G3_IO1 Schmitt trigger hysteresis mode
G3_IO1: u1 = 1,
/// G3_IO2 [9:9]
/// G3_IO2 Schmitt trigger hysteresis mode
G3_IO2: u1 = 1,
/// G3_IO3 [10:10]
/// G3_IO3 Schmitt trigger hysteresis mode
G3_IO3: u1 = 1,
/// G3_IO4 [11:11]
/// G3_IO4 Schmitt trigger hysteresis mode
G3_IO4: u1 = 1,
/// G4_IO1 [12:12]
/// G4_IO1 Schmitt trigger hysteresis mode
G4_IO1: u1 = 1,
/// G4_IO2 [13:13]
/// G4_IO2 Schmitt trigger hysteresis mode
G4_IO2: u1 = 1,
/// G4_IO3 [14:14]
/// G4_IO3 Schmitt trigger hysteresis mode
G4_IO3: u1 = 1,
/// G4_IO4 [15:15]
/// G4_IO4 Schmitt trigger hysteresis mode
G4_IO4: u1 = 1,
/// G5_IO1 [16:16]
/// G5_IO1 Schmitt trigger hysteresis mode
G5_IO1: u1 = 1,
/// G5_IO2 [17:17]
/// G5_IO2 Schmitt trigger hysteresis mode
G5_IO2: u1 = 1,
/// G5_IO3 [18:18]
/// G5_IO3 Schmitt trigger hysteresis mode
G5_IO3: u1 = 1,
/// G5_IO4 [19:19]
/// G5_IO4 Schmitt trigger hysteresis mode
G5_IO4: u1 = 1,
/// G6_IO1 [20:20]
/// G6_IO1 Schmitt trigger hysteresis mode
G6_IO1: u1 = 1,
/// G6_IO2 [21:21]
/// G6_IO2 Schmitt trigger hysteresis mode
G6_IO2: u1 = 1,
/// G6_IO3 [22:22]
/// G6_IO3 Schmitt trigger hysteresis mode
G6_IO3: u1 = 1,
/// G6_IO4 [23:23]
/// G6_IO4 Schmitt trigger hysteresis mode
G6_IO4: u1 = 1,
/// G7_IO1 [24:24]
/// G7_IO1 Schmitt trigger hysteresis mode
G7_IO1: u1 = 1,
/// G7_IO2 [25:25]
/// G7_IO2 Schmitt trigger hysteresis mode
G7_IO2: u1 = 1,
/// G7_IO3 [26:26]
/// G7_IO3 Schmitt trigger hysteresis mode
G7_IO3: u1 = 1,
/// G7_IO4 [27:27]
/// G7_IO4 Schmitt trigger hysteresis mode
G7_IO4: u1 = 1,
/// G8_IO1 [28:28]
/// G8_IO1 Schmitt trigger hysteresis mode
G8_IO1: u1 = 1,
/// G8_IO2 [29:29]
/// G8_IO2 Schmitt trigger hysteresis mode
G8_IO2: u1 = 1,
/// G8_IO3 [30:30]
/// G8_IO3 Schmitt trigger hysteresis mode
G8_IO3: u1 = 1,
/// G8_IO4 [31:31]
/// G8_IO4 Schmitt trigger hysteresis mode
G8_IO4: u1 = 1,
};
/// I/O hysteresis control register
pub const IOHCR = Register(IOHCR_val).init(base_address + 0x10);
/// IOASCR
const IOASCR_val = packed struct {
/// G1_IO1 [0:0]
/// G1_IO1 analog switch enable
G1_IO1: u1 = 0,
/// G1_IO2 [1:1]
/// G1_IO2 analog switch enable
G1_IO2: u1 = 0,
/// G1_IO3 [2:2]
/// G1_IO3 analog switch enable
G1_IO3: u1 = 0,
/// G1_IO4 [3:3]
/// G1_IO4 analog switch enable
G1_IO4: u1 = 0,
/// G2_IO1 [4:4]
/// G2_IO1 analog switch enable
G2_IO1: u1 = 0,
/// G2_IO2 [5:5]
/// G2_IO2 analog switch enable
G2_IO2: u1 = 0,
/// G2_IO3 [6:6]
/// G2_IO3 analog switch enable
G2_IO3: u1 = 0,
/// G2_IO4 [7:7]
/// G2_IO4 analog switch enable
G2_IO4: u1 = 0,
/// G3_IO1 [8:8]
/// G3_IO1 analog switch enable
G3_IO1: u1 = 0,
/// G3_IO2 [9:9]
/// G3_IO2 analog switch enable
G3_IO2: u1 = 0,
/// G3_IO3 [10:10]
/// G3_IO3 analog switch enable
G3_IO3: u1 = 0,
/// G3_IO4 [11:11]
/// G3_IO4 analog switch enable
G3_IO4: u1 = 0,
/// G4_IO1 [12:12]
/// G4_IO1 analog switch enable
G4_IO1: u1 = 0,
/// G4_IO2 [13:13]
/// G4_IO2 analog switch enable
G4_IO2: u1 = 0,
/// G4_IO3 [14:14]
/// G4_IO3 analog switch enable
G4_IO3: u1 = 0,
/// G4_IO4 [15:15]
/// G4_IO4 analog switch enable
G4_IO4: u1 = 0,
/// G5_IO1 [16:16]
/// G5_IO1 analog switch enable
G5_IO1: u1 = 0,
/// G5_IO2 [17:17]
/// G5_IO2 analog switch enable
G5_IO2: u1 = 0,
/// G5_IO3 [18:18]
/// G5_IO3 analog switch enable
G5_IO3: u1 = 0,
/// G5_IO4 [19:19]
/// G5_IO4 analog switch enable
G5_IO4: u1 = 0,
/// G6_IO1 [20:20]
/// G6_IO1 analog switch enable
G6_IO1: u1 = 0,
/// G6_IO2 [21:21]
/// G6_IO2 analog switch enable
G6_IO2: u1 = 0,
/// G6_IO3 [22:22]
/// G6_IO3 analog switch enable
G6_IO3: u1 = 0,
/// G6_IO4 [23:23]
/// G6_IO4 analog switch enable
G6_IO4: u1 = 0,
/// G7_IO1 [24:24]
/// G7_IO1 analog switch enable
G7_IO1: u1 = 0,
/// G7_IO2 [25:25]
/// G7_IO2 analog switch enable
G7_IO2: u1 = 0,
/// G7_IO3 [26:26]
/// G7_IO3 analog switch enable
G7_IO3: u1 = 0,
/// G7_IO4 [27:27]
/// G7_IO4 analog switch enable
G7_IO4: u1 = 0,
/// G8_IO1 [28:28]
/// G8_IO1 analog switch enable
G8_IO1: u1 = 0,
/// G8_IO2 [29:29]
/// G8_IO2 analog switch enable
G8_IO2: u1 = 0,
/// G8_IO3 [30:30]
/// G8_IO3 analog switch enable
G8_IO3: u1 = 0,
/// G8_IO4 [31:31]
/// G8_IO4 analog switch enable
G8_IO4: u1 = 0,
};
/// I/O analog switch control register
pub const IOASCR = Register(IOASCR_val).init(base_address + 0x18);
/// IOSCR
const IOSCR_val = packed struct {
/// G1_IO1 [0:0]
/// G1_IO1 sampling mode
G1_IO1: u1 = 0,
/// G1_IO2 [1:1]
/// G1_IO2 sampling mode
G1_IO2: u1 = 0,
/// G1_IO3 [2:2]
/// G1_IO3 sampling mode
G1_IO3: u1 = 0,
/// G1_IO4 [3:3]
/// G1_IO4 sampling mode
G1_IO4: u1 = 0,
/// G2_IO1 [4:4]
/// G2_IO1 sampling mode
G2_IO1: u1 = 0,
/// G2_IO2 [5:5]
/// G2_IO2 sampling mode
G2_IO2: u1 = 0,
/// G2_IO3 [6:6]
/// G2_IO3 sampling mode
G2_IO3: u1 = 0,
/// G2_IO4 [7:7]
/// G2_IO4 sampling mode
G2_IO4: u1 = 0,
/// G3_IO1 [8:8]
/// G3_IO1 sampling mode
G3_IO1: u1 = 0,
/// G3_IO2 [9:9]
/// G3_IO2 sampling mode
G3_IO2: u1 = 0,
/// G3_IO3 [10:10]
/// G3_IO3 sampling mode
G3_IO3: u1 = 0,
/// G3_IO4 [11:11]
/// G3_IO4 sampling mode
G3_IO4: u1 = 0,
/// G4_IO1 [12:12]
/// G4_IO1 sampling mode
G4_IO1: u1 = 0,
/// G4_IO2 [13:13]
/// G4_IO2 sampling mode
G4_IO2: u1 = 0,
/// G4_IO3 [14:14]
/// G4_IO3 sampling mode
G4_IO3: u1 = 0,
/// G4_IO4 [15:15]
/// G4_IO4 sampling mode
G4_IO4: u1 = 0,
/// G5_IO1 [16:16]
/// G5_IO1 sampling mode
G5_IO1: u1 = 0,
/// G5_IO2 [17:17]
/// G5_IO2 sampling mode
G5_IO2: u1 = 0,
/// G5_IO3 [18:18]
/// G5_IO3 sampling mode
G5_IO3: u1 = 0,
/// G5_IO4 [19:19]
/// G5_IO4 sampling mode
G5_IO4: u1 = 0,
/// G6_IO1 [20:20]
/// G6_IO1 sampling mode
G6_IO1: u1 = 0,
/// G6_IO2 [21:21]
/// G6_IO2 sampling mode
G6_IO2: u1 = 0,
/// G6_IO3 [22:22]
/// G6_IO3 sampling mode
G6_IO3: u1 = 0,
/// G6_IO4 [23:23]
/// G6_IO4 sampling mode
G6_IO4: u1 = 0,
/// G7_IO1 [24:24]
/// G7_IO1 sampling mode
G7_IO1: u1 = 0,
/// G7_IO2 [25:25]
/// G7_IO2 sampling mode
G7_IO2: u1 = 0,
/// G7_IO3 [26:26]
/// G7_IO3 sampling mode
G7_IO3: u1 = 0,
/// G7_IO4 [27:27]
/// G7_IO4 sampling mode
G7_IO4: u1 = 0,
/// G8_IO1 [28:28]
/// G8_IO1 sampling mode
G8_IO1: u1 = 0,
/// G8_IO2 [29:29]
/// G8_IO2 sampling mode
G8_IO2: u1 = 0,
/// G8_IO3 [30:30]
/// G8_IO3 sampling mode
G8_IO3: u1 = 0,
/// G8_IO4 [31:31]
/// G8_IO4 sampling mode
G8_IO4: u1 = 0,
};
/// I/O sampling control register
pub const IOSCR = Register(IOSCR_val).init(base_address + 0x20);
/// IOCCR
const IOCCR_val = packed struct {
/// G1_IO1 [0:0]
/// G1_IO1 channel mode
G1_IO1: u1 = 0,
/// G1_IO2 [1:1]
/// G1_IO2 channel mode
G1_IO2: u1 = 0,
/// G1_IO3 [2:2]
/// G1_IO3 channel mode
G1_IO3: u1 = 0,
/// G1_IO4 [3:3]
/// G1_IO4 channel mode
G1_IO4: u1 = 0,
/// G2_IO1 [4:4]
/// G2_IO1 channel mode
G2_IO1: u1 = 0,
/// G2_IO2 [5:5]
/// G2_IO2 channel mode
G2_IO2: u1 = 0,
/// G2_IO3 [6:6]
/// G2_IO3 channel mode
G2_IO3: u1 = 0,
/// G2_IO4 [7:7]
/// G2_IO4 channel mode
G2_IO4: u1 = 0,
/// G3_IO1 [8:8]
/// G3_IO1 channel mode
G3_IO1: u1 = 0,
/// G3_IO2 [9:9]
/// G3_IO2 channel mode
G3_IO2: u1 = 0,
/// G3_IO3 [10:10]
/// G3_IO3 channel mode
G3_IO3: u1 = 0,
/// G3_IO4 [11:11]
/// G3_IO4 channel mode
G3_IO4: u1 = 0,
/// G4_IO1 [12:12]
/// G4_IO1 channel mode
G4_IO1: u1 = 0,
/// G4_IO2 [13:13]
/// G4_IO2 channel mode
G4_IO2: u1 = 0,
/// G4_IO3 [14:14]
/// G4_IO3 channel mode
G4_IO3: u1 = 0,
/// G4_IO4 [15:15]
/// G4_IO4 channel mode
G4_IO4: u1 = 0,
/// G5_IO1 [16:16]
/// G5_IO1 channel mode
G5_IO1: u1 = 0,
/// G5_IO2 [17:17]
/// G5_IO2 channel mode
G5_IO2: u1 = 0,
/// G5_IO3 [18:18]
/// G5_IO3 channel mode
G5_IO3: u1 = 0,
/// G5_IO4 [19:19]
/// G5_IO4 channel mode
G5_IO4: u1 = 0,
/// G6_IO1 [20:20]
/// G6_IO1 channel mode
G6_IO1: u1 = 0,
/// G6_IO2 [21:21]
/// G6_IO2 channel mode
G6_IO2: u1 = 0,
/// G6_IO3 [22:22]
/// G6_IO3 channel mode
G6_IO3: u1 = 0,
/// G6_IO4 [23:23]
/// G6_IO4 channel mode
G6_IO4: u1 = 0,
/// G7_IO1 [24:24]
/// G7_IO1 channel mode
G7_IO1: u1 = 0,
/// G7_IO2 [25:25]
/// G7_IO2 channel mode
G7_IO2: u1 = 0,
/// G7_IO3 [26:26]
/// G7_IO3 channel mode
G7_IO3: u1 = 0,
/// G7_IO4 [27:27]
/// G7_IO4 channel mode
G7_IO4: u1 = 0,
/// G8_IO1 [28:28]
/// G8_IO1 channel mode
G8_IO1: u1 = 0,
/// G8_IO2 [29:29]
/// G8_IO2 channel mode
G8_IO2: u1 = 0,
/// G8_IO3 [30:30]
/// G8_IO3 channel mode
G8_IO3: u1 = 0,
/// G8_IO4 [31:31]
/// G8_IO4 channel mode
G8_IO4: u1 = 0,
};
/// I/O channel control register
pub const IOCCR = Register(IOCCR_val).init(base_address + 0x28);
/// IOGCSR
const IOGCSR_val = packed struct {
/// G1E [0:0]
/// Analog I/O group x enable
G1E: u1 = 0,
/// G2E [1:1]
/// Analog I/O group x enable
G2E: u1 = 0,
/// G3E [2:2]
/// Analog I/O group x enable
G3E: u1 = 0,
/// G4E [3:3]
/// Analog I/O group x enable
G4E: u1 = 0,
/// G5E [4:4]
/// Analog I/O group x enable
G5E: u1 = 0,
/// G6E [5:5]
/// Analog I/O group x enable
G6E: u1 = 0,
/// G7E [6:6]
/// Analog I/O group x enable
G7E: u1 = 0,
/// G8E [7:7]
/// Analog I/O group x enable
G8E: u1 = 0,
/// unused [8:15]
_unused8: u8 = 0,
/// G1S [16:16]
/// Analog I/O group x status
G1S: u1 = 0,
/// G2S [17:17]
/// Analog I/O group x status
G2S: u1 = 0,
/// G3S [18:18]
/// Analog I/O group x status
G3S: u1 = 0,
/// G4S [19:19]
/// Analog I/O group x status
G4S: u1 = 0,
/// G5S [20:20]
/// Analog I/O group x status
G5S: u1 = 0,
/// G6S [21:21]
/// Analog I/O group x status
G6S: u1 = 0,
/// G7S [22:22]
/// Analog I/O group x status
G7S: u1 = 0,
/// G8S [23:23]
/// Analog I/O group x status
G8S: u1 = 0,
/// unused [24:31]
_unused24: u8 = 0,
};
/// I/O group control status register
pub const IOGCSR = Register(IOGCSR_val).init(base_address + 0x30);
/// IOG1CR
const IOG1CR_val = packed struct {
/// CNT [0:13]
/// Counter value
CNT: u14 = 0,
/// unused [14:31]
_unused14: u2 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// I/O group x counter register
pub const IOG1CR = Register(IOG1CR_val).init(base_address + 0x34);
/// IOG2CR
const IOG2CR_val = packed struct {
/// CNT [0:13]
/// Counter value
CNT: u14 = 0,
/// unused [14:31]
_unused14: u2 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// I/O group x counter register
pub const IOG2CR = Register(IOG2CR_val).init(base_address + 0x38);
/// IOG3CR
const IOG3CR_val = packed struct {
/// CNT [0:13]
/// Counter value
CNT: u14 = 0,
/// unused [14:31]
_unused14: u2 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// I/O group x counter register
pub const IOG3CR = Register(IOG3CR_val).init(base_address + 0x3c);
/// IOG4CR
const IOG4CR_val = packed struct {
/// CNT [0:13]
/// Counter value
CNT: u14 = 0,
/// unused [14:31]
_unused14: u2 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// I/O group x counter register
pub const IOG4CR = Register(IOG4CR_val).init(base_address + 0x40);
/// IOG5CR
const IOG5CR_val = packed struct {
/// CNT [0:13]
/// Counter value
CNT: u14 = 0,
/// unused [14:31]
_unused14: u2 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// I/O group x counter register
pub const IOG5CR = Register(IOG5CR_val).init(base_address + 0x44);
/// IOG6CR
const IOG6CR_val = packed struct {
/// CNT [0:13]
/// Counter value
CNT: u14 = 0,
/// unused [14:31]
_unused14: u2 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// I/O group x counter register
pub const IOG6CR = Register(IOG6CR_val).init(base_address + 0x48);
/// IOG7CR
const IOG7CR_val = packed struct {
/// CNT [0:13]
/// Counter value
CNT: u14 = 0,
/// unused [14:31]
_unused14: u2 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// I/O group x counter register
pub const IOG7CR = Register(IOG7CR_val).init(base_address + 0x4c);
/// IOG8CR
const IOG8CR_val = packed struct {
/// CNT [0:13]
/// Counter value
CNT: u14 = 0,
/// unused [14:31]
_unused14: u2 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// I/O group x counter register
pub const IOG8CR = Register(IOG8CR_val).init(base_address + 0x50);
};
/// cyclic redundancy check calculation unit
pub const CRC = struct {
const base_address = 0x40023000;
/// DR
const DR_val = packed struct {
/// DR [0:31]
/// Data register bits
DR: u32 = 4294967295,
};
/// Data register
pub const DR = Register(DR_val).init(base_address + 0x0);
/// IDR
const IDR_val = packed struct {
/// IDR [0:7]
/// General-purpose 8-bit data register bits
IDR: u8 = 0,
/// unused [8:31]
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Independent data register
pub const IDR = Register(IDR_val).init(base_address + 0x4);
/// CR
const CR_val = packed struct {
/// RESET [0:0]
/// reset bit
RESET: u1 = 0,
/// unused [1:2]
_unused1: u2 = 0,
/// POLYSIZE [3:4]
/// Polynomial size
POLYSIZE: u2 = 0,
/// REV_IN [5:6]
/// Reverse input data
REV_IN: u2 = 0,
/// REV_OUT [7:7]
/// Reverse output data
REV_OUT: u1 = 0,
/// unused [8:31]
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Control register
pub const CR = Register(CR_val).init(base_address + 0x8);
/// INIT
const INIT_val = packed struct {
/// INIT [0:31]
/// Programmable initial CRC value
INIT: u32 = 4294967295,
};
/// Initial CRC value
pub const INIT = Register(INIT_val).init(base_address + 0x10);
/// POL
const POL_val = packed struct {
/// POL [0:31]
/// Programmable polynomial
POL: u32 = 79764919,
};
/// CRC polynomial
pub const POL = Register(POL_val).init(base_address + 0x14);
};
/// Flash
pub const Flash = struct {
const base_address = 0x40022000;
/// ACR
const ACR_val = packed struct {
/// LATENCY [0:2]
/// LATENCY
LATENCY: u3 = 0,
/// unused [3:3]
_unused3: u1 = 0,
/// PRFTBE [4:4]
/// PRFTBE
PRFTBE: u1 = 1,
/// PRFTBS [5:5]
/// PRFTBS
PRFTBS: u1 = 1,
/// unused [6:31]
_unused6: u2 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Flash access control register
pub const ACR = Register(ACR_val).init(base_address + 0x0);
/// KEYR
const KEYR_val = packed struct {
/// FKEYR [0:31]
/// Flash Key
FKEYR: u32 = 0,
};
/// Flash key register
pub const KEYR = Register(KEYR_val).init(base_address + 0x4);
/// OPTKEYR
const OPTKEYR_val = packed struct {
/// OPTKEYR [0:31]
/// Option byte key
OPTKEYR: u32 = 0,
};
/// Flash option key register
pub const OPTKEYR = Register(OPTKEYR_val).init(base_address + 0x8);
/// SR
const SR_val = packed struct {
/// BSY [0:0]
/// Busy
BSY: u1 = 0,
/// unused [1:1]
_unused1: u1 = 0,
/// PGERR [2:2]
/// Programming error
PGERR: u1 = 0,
/// unused [3:3]
_unused3: u1 = 0,
/// WRPRT [4:4]
/// Write protection error
WRPRT: u1 = 0,
/// EOP [5:5]
/// End of operation
EOP: u1 = 0,
/// unused [6:31]
_unused6: u2 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Flash status register
pub const SR = Register(SR_val).init(base_address + 0xc);
/// CR
const CR_val = packed struct {
/// PG [0:0]
/// Programming
PG: u1 = 0,
/// PER [1:1]
/// Page erase
PER: u1 = 0,
/// MER [2:2]
/// Mass erase
MER: u1 = 0,
/// unused [3:3]
_unused3: u1 = 0,
/// OPTPG [4:4]
/// Option byte programming
OPTPG: u1 = 0,
/// OPTER [5:5]
/// Option byte erase
OPTER: u1 = 0,
/// STRT [6:6]
/// Start
STRT: u1 = 0,
/// LOCK [7:7]
/// Lock
LOCK: u1 = 1,
/// unused [8:8]
_unused8: u1 = 0,
/// OPTWRE [9:9]
/// Option bytes write enable
OPTWRE: u1 = 0,
/// ERRIE [10:10]
/// Error interrupt enable
ERRIE: u1 = 0,
/// unused [11:11]
_unused11: u1 = 0,
/// EOPIE [12:12]
/// End of operation interrupt enable
EOPIE: u1 = 0,
/// FORCE_OPTLOAD [13:13]
/// Force option byte loading
FORCE_OPTLOAD: u1 = 0,
/// unused [14:31]
_unused14: u2 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Flash control register
pub const CR = Register(CR_val).init(base_address + 0x10);
/// AR
const AR_val = packed struct {
/// FAR [0:31]
/// Flash address
FAR: u32 = 0,
};
/// Flash address register
pub const AR = Register(AR_val).init(base_address + 0x14);
/// OBR
const OBR_val = packed struct {
/// OPTERR [0:0]
/// Option byte error
OPTERR: u1 = 0,
/// LEVEL1_PROT [1:1]
/// Level 1 protection status
LEVEL1_PROT: u1 = 1,
/// LEVEL2_PROT [2:2]
/// Level 2 protection status
LEVEL2_PROT: u1 = 0,
/// unused [3:7]
_unused3: u5 = 0,
/// WDG_SW [8:8]
/// WDG_SW
WDG_SW: u1 = 1,
/// nRST_STOP [9:9]
/// nRST_STOP
nRST_STOP: u1 = 1,
/// nRST_STDBY [10:10]
/// nRST_STDBY
nRST_STDBY: u1 = 1,
/// unused [11:11]
_unused11: u1 = 1,
/// BOOT1 [12:12]
/// BOOT1
BOOT1: u1 = 1,
/// VDDA_MONITOR [13:13]
/// VDDA_MONITOR
VDDA_MONITOR: u1 = 1,
/// SRAM_PARITY_CHECK [14:14]
/// SRAM_PARITY_CHECK
SRAM_PARITY_CHECK: u1 = 1,
/// unused [15:15]
_unused15: u1 = 1,
/// Data0 [16:23]
/// Data0
Data0: u8 = 255,
/// Data1 [24:31]
/// Data1
Data1: u8 = 255,
};
/// Option byte register
pub const OBR = Register(OBR_val).init(base_address + 0x1c);
/// WRPR
const WRPR_val = packed struct {
/// WRP [0:31]
/// Write protect
WRP: u32 = 4294967295,
};
/// Write protection register
pub const WRPR = Register(WRPR_val).init(base_address + 0x20);
};
/// Reset and clock control
pub const RCC = struct {
const base_address = 0x40021000;
/// CR
const CR_val = packed struct {
/// HSION [0:0]
/// Internal High Speed clock enable
HSION: u1 = 1,
/// HSIRDY [1:1]
/// Internal High Speed clock ready flag
HSIRDY: u1 = 1,
/// unused [2:2]
_unused2: u1 = 0,
/// HSITRIM [3:7]
/// Internal High Speed clock trimming
HSITRIM: u5 = 16,
/// HSICAL [8:15]
/// Internal High Speed clock Calibration
HSICAL: u8 = 0,
/// HSEON [16:16]
/// External High Speed clock enable
HSEON: u1 = 0,
/// HSERDY [17:17]
/// External High Speed clock ready flag
HSERDY: u1 = 0,
/// HSEBYP [18:18]
/// External High Speed clock Bypass
HSEBYP: u1 = 0,
/// CSSON [19:19]
/// Clock Security System enable
CSSON: u1 = 0,
/// unused [20:23]
_unused20: u4 = 0,
/// PLLON [24:24]
/// PLL enable
PLLON: u1 = 0,
/// PLLRDY [25:25]
/// PLL clock ready flag
PLLRDY: u1 = 0,
/// unused [26:31]
_unused26: u6 = 0,
};
/// Clock control register
pub const CR = Register(CR_val).init(base_address + 0x0);
/// CFGR
const CFGR_val = packed struct {
/// SW [0:1]
/// System clock Switch
SW: u2 = 0,
/// SWS [2:3]
/// System Clock Switch Status
SWS: u2 = 0,
/// HPRE [4:7]
/// AHB prescaler
HPRE: u4 = 0,
/// PPRE1 [8:10]
/// APB Low speed prescaler (APB1)
PPRE1: u3 = 0,
/// PPRE2 [11:13]
/// APB high speed prescaler (APB2)
PPRE2: u3 = 0,
/// unused [14:14]
_unused14: u1 = 0,
/// PLLSRC [15:16]
/// PLL entry clock source
PLLSRC: u2 = 0,
/// PLLXTPRE [17:17]
/// HSE divider for PLL entry
PLLXTPRE: u1 = 0,
/// PLLMUL [18:21]
/// PLL Multiplication Factor
PLLMUL: u4 = 0,
/// USBPRES [22:22]
/// USB prescaler
USBPRES: u1 = 0,
/// I2SSRC [23:23]
/// I2S external clock source selection
I2SSRC: u1 = 0,
/// MCO [24:26]
/// Microcontroller clock output
MCO: u3 = 0,
/// unused [27:27]
_unused27: u1 = 0,
/// MCOF [28:28]
/// Microcontroller Clock Output Flag
MCOF: u1 = 0,
/// unused [29:31]
_unused29: u3 = 0,
};
/// Clock configuration register (RCC_CFGR)
pub const CFGR = Register(CFGR_val).init(base_address + 0x4);
/// CIR
const CIR_val = packed struct {
/// LSIRDYF [0:0]
/// LSI Ready Interrupt flag
LSIRDYF: u1 = 0,
/// LSERDYF [1:1]
/// LSE Ready Interrupt flag
LSERDYF: u1 = 0,
/// HSIRDYF [2:2]
/// HSI Ready Interrupt flag
HSIRDYF: u1 = 0,
/// HSERDYF [3:3]
/// HSE Ready Interrupt flag
HSERDYF: u1 = 0,
/// PLLRDYF [4:4]
/// PLL Ready Interrupt flag
PLLRDYF: u1 = 0,
/// unused [5:6]
_unused5: u2 = 0,
/// CSSF [7:7]
/// Clock Security System Interrupt flag
CSSF: u1 = 0,
/// LSIRDYIE [8:8]
/// LSI Ready Interrupt Enable
LSIRDYIE: u1 = 0,
/// LSERDYIE [9:9]
/// LSE Ready Interrupt Enable
LSERDYIE: u1 = 0,
/// HSIRDYIE [10:10]
/// HSI Ready Interrupt Enable
HSIRDYIE: u1 = 0,
/// HSERDYIE [11:11]
/// HSE Ready Interrupt Enable
HSERDYIE: u1 = 0,
/// PLLRDYIE [12:12]
/// PLL Ready Interrupt Enable
PLLRDYIE: u1 = 0,
/// unused [13:15]
_unused13: u3 = 0,
/// LSIRDYC [16:16]
/// LSI Ready Interrupt Clear
LSIRDYC: u1 = 0,
/// LSERDYC [17:17]
/// LSE Ready Interrupt Clear
LSERDYC: u1 = 0,
/// HSIRDYC [18:18]
/// HSI Ready Interrupt Clear
HSIRDYC: u1 = 0,
/// HSERDYC [19:19]
/// HSE Ready Interrupt Clear
HSERDYC: u1 = 0,
/// PLLRDYC [20:20]
/// PLL Ready Interrupt Clear
PLLRDYC: u1 = 0,
/// unused [21:22]
_unused21: u2 = 0,
/// CSSC [23:23]
/// Clock security system interrupt clear
CSSC: u1 = 0,
/// unused [24:31]
_unused24: u8 = 0,
};
/// Clock interrupt register (RCC_CIR)
pub const CIR = Register(CIR_val).init(base_address + 0x8);
/// APB2RSTR
const APB2RSTR_val = packed struct {
/// SYSCFGRST [0:0]
/// SYSCFG and COMP reset
SYSCFGRST: u1 = 0,
/// unused [1:10]
_unused1: u7 = 0,
_unused8: u3 = 0,
/// TIM1RST [11:11]
/// TIM1 timer reset
TIM1RST: u1 = 0,
/// SPI1RST [12:12]
/// SPI 1 reset
SPI1RST: u1 = 0,
/// TIM8RST [13:13]
/// TIM8 timer reset
TIM8RST: u1 = 0,
/// USART1RST [14:14]
/// USART1 reset
USART1RST: u1 = 0,
/// unused [15:15]
_unused15: u1 = 0,
/// TIM15RST [16:16]
/// TIM15 timer reset
TIM15RST: u1 = 0,
/// TIM16RST [17:17]
/// TIM16 timer reset
TIM16RST: u1 = 0,
/// TIM17RST [18:18]
/// TIM17 timer reset
TIM17RST: u1 = 0,
/// unused [19:31]
_unused19: u5 = 0,
_unused24: u8 = 0,
};
/// APB2 peripheral reset register (RCC_APB2RSTR)
pub const APB2RSTR = Register(APB2RSTR_val).init(base_address + 0xc);
/// APB1RSTR
const APB1RSTR_val = packed struct {
/// TIM2RST [0:0]
/// Timer 2 reset
TIM2RST: u1 = 0,
/// TIM3RST [1:1]
/// Timer 3 reset
TIM3RST: u1 = 0,
/// TIM4RST [2:2]
/// Timer 14 reset
TIM4RST: u1 = 0,
/// unused [3:3]
_unused3: u1 = 0,
/// TIM6RST [4:4]
/// Timer 6 reset
TIM6RST: u1 = 0,
/// TIM7RST [5:5]
/// Timer 7 reset
TIM7RST: u1 = 0,
/// unused [6:10]
_unused6: u2 = 0,
_unused8: u3 = 0,
/// WWDGRST [11:11]
/// Window watchdog reset
WWDGRST: u1 = 0,
/// unused [12:13]
_unused12: u2 = 0,
/// SPI2RST [14:14]
/// SPI2 reset
SPI2RST: u1 = 0,
/// SPI3RST [15:15]
/// SPI3 reset
SPI3RST: u1 = 0,
/// unused [16:16]
_unused16: u1 = 0,
/// USART2RST [17:17]
/// USART 2 reset
USART2RST: u1 = 0,
/// USART3RST [18:18]
/// USART3 reset
USART3RST: u1 = 0,
/// UART4RST [19:19]
/// UART 4 reset
UART4RST: u1 = 0,
/// UART5RST [20:20]
/// UART 5 reset
UART5RST: u1 = 0,
/// I2C1RST [21:21]
/// I2C1 reset
I2C1RST: u1 = 0,
/// I2C2RST [22:22]
/// I2C2 reset
I2C2RST: u1 = 0,
/// USBRST [23:23]
/// USB reset
USBRST: u1 = 0,
/// unused [24:24]
_unused24: u1 = 0,
/// CANRST [25:25]
/// CAN reset
CANRST: u1 = 0,
/// unused [26:27]
_unused26: u2 = 0,
/// PWRRST [28:28]
/// Power interface reset
PWRRST: u1 = 0,
/// DACRST [29:29]
/// DAC interface reset
DACRST: u1 = 0,
/// I2C3RST [30:30]
/// I2C3 reset
I2C3RST: u1 = 0,
/// unused [31:31]
_unused31: u1 = 0,
};
/// APB1 peripheral reset register (RCC_APB1RSTR)
pub const APB1RSTR = Register(APB1RSTR_val).init(base_address + 0x10);
/// AHBENR
const AHBENR_val = packed struct {
/// DMAEN [0:0]
/// DMA1 clock enable
DMAEN: u1 = 0,
/// DMA2EN [1:1]
/// DMA2 clock enable
DMA2EN: u1 = 0,
/// SRAMEN [2:2]
/// SRAM interface clock enable
SRAMEN: u1 = 1,
/// unused [3:3]
_unused3: u1 = 0,
/// FLITFEN [4:4]
/// FLITF clock enable
FLITFEN: u1 = 1,
/// unused [5:5]
_unused5: u1 = 0,
/// CRCEN [6:6]
/// CRC clock enable
CRCEN: u1 = 0,
/// unused [7:15]
_unused7: u1 = 0,
_unused8: u8 = 0,
/// IOPHEN [16:16]
/// I/O port H clock enable
IOPHEN: u1 = 0,
/// IOPAEN [17:17]
/// I/O port A clock enable
IOPAEN: u1 = 0,
/// IOPBEN [18:18]
/// I/O port B clock enable
IOPBEN: u1 = 0,
/// IOPCEN [19:19]
/// I/O port C clock enable
IOPCEN: u1 = 0,
/// IOPDEN [20:20]
/// I/O port D clock enable
IOPDEN: u1 = 0,
/// IOPEEN [21:21]
/// I/O port E clock enable
IOPEEN: u1 = 0,
/// IOPFEN [22:22]
/// I/O port F clock enable
IOPFEN: u1 = 0,
/// IOPGEN [23:23]
/// I/O port G clock enable
IOPGEN: u1 = 0,
/// TSCEN [24:24]
/// Touch sensing controller clock enable
TSCEN: u1 = 0,
/// unused [25:27]
_unused25: u3 = 0,
/// ADC12EN [28:28]
/// ADC1 and ADC2 clock enable
ADC12EN: u1 = 0,
/// ADC34EN [29:29]
/// ADC3 and ADC4 clock enable
ADC34EN: u1 = 0,
/// unused [30:31]
_unused30: u2 = 0,
};
/// AHB Peripheral Clock enable register (RCC_AHBENR)
pub const AHBENR = Register(AHBENR_val).init(base_address + 0x14);
/// APB2ENR
const APB2ENR_val = packed struct {
/// SYSCFGEN [0:0]
/// SYSCFG clock enable
SYSCFGEN: u1 = 0,
/// unused [1:10]
_unused1: u7 = 0,
_unused8: u3 = 0,
/// TIM1EN [11:11]
/// TIM1 Timer clock enable
TIM1EN: u1 = 0,
/// SPI1EN [12:12]
/// SPI 1 clock enable
SPI1EN: u1 = 0,
/// TIM8EN [13:13]
/// TIM8 Timer clock enable
TIM8EN: u1 = 0,
/// USART1EN [14:14]
/// USART1 clock enable
USART1EN: u1 = 0,
/// unused [15:15]
_unused15: u1 = 0,
/// TIM15EN [16:16]
/// TIM15 timer clock enable
TIM15EN: u1 = 0,
/// TIM16EN [17:17]
/// TIM16 timer clock enable
TIM16EN: u1 = 0,
/// TIM17EN [18:18]
/// TIM17 timer clock enable
TIM17EN: u1 = 0,
/// unused [19:31]
_unused19: u5 = 0,
_unused24: u8 = 0,
};
/// APB2 peripheral clock enable register (RCC_APB2ENR)
pub const APB2ENR = Register(APB2ENR_val).init(base_address + 0x18);
/// APB1ENR
const APB1ENR_val = packed struct {
/// TIM2EN [0:0]
/// Timer 2 clock enable
TIM2EN: u1 = 0,
/// TIM3EN [1:1]
/// Timer 3 clock enable
TIM3EN: u1 = 0,
/// TIM4EN [2:2]
/// Timer 4 clock enable
TIM4EN: u1 = 0,
/// unused [3:3]
_unused3: u1 = 0,
/// TIM6EN [4:4]
/// Timer 6 clock enable
TIM6EN: u1 = 0,
/// TIM7EN [5:5]
/// Timer 7 clock enable
TIM7EN: u1 = 0,
/// unused [6:10]
_unused6: u2 = 0,
_unused8: u3 = 0,
/// WWDGEN [11:11]
/// Window watchdog clock enable
WWDGEN: u1 = 0,
/// unused [12:13]
_unused12: u2 = 0,
/// SPI2EN [14:14]
/// SPI 2 clock enable
SPI2EN: u1 = 0,
/// SPI3EN [15:15]
/// SPI 3 clock enable
SPI3EN: u1 = 0,
/// unused [16:16]
_unused16: u1 = 0,
/// USART2EN [17:17]
/// USART 2 clock enable
USART2EN: u1 = 0,
/// USART3EN [18:18]
/// USART 3 clock enable
USART3EN: u1 = 0,
/// UART4EN [19:19]
/// UART 4 clock enable
UART4EN: u1 = 0,
/// UART5EN [20:20]
/// UART 5 clock enable
UART5EN: u1 = 0,
/// I2C1EN [21:21]
/// I2C 1 clock enable
I2C1EN: u1 = 0,
/// I2C2EN [22:22]
/// I2C 2 clock enable
I2C2EN: u1 = 0,
/// USBEN [23:23]
/// USB clock enable
USBEN: u1 = 0,
/// unused [24:24]
_unused24: u1 = 0,
/// CANEN [25:25]
/// CAN clock enable
CANEN: u1 = 0,
/// unused [26:27]
_unused26: u2 = 0,
/// PWREN [28:28]
/// Power interface clock enable
PWREN: u1 = 0,
/// DACEN [29:29]
/// DAC interface clock enable
DACEN: u1 = 0,
/// I2C3EN [30:30]
/// I2C 3 clock enable
I2C3EN: u1 = 0,
/// unused [31:31]
_unused31: u1 = 0,
};
/// APB1 peripheral clock enable register (RCC_APB1ENR)
pub const APB1ENR = Register(APB1ENR_val).init(base_address + 0x1c);
/// BDCR
const BDCR_val = packed struct {
/// LSEON [0:0]
/// External Low Speed oscillator enable
LSEON: u1 = 0,
/// LSERDY [1:1]
/// External Low Speed oscillator ready
LSERDY: u1 = 0,
/// LSEBYP [2:2]
/// External Low Speed oscillator bypass
LSEBYP: u1 = 0,
/// LSEDRV [3:4]
/// LSE oscillator drive capability
LSEDRV: u2 = 0,
/// unused [5:7]
_unused5: u3 = 0,
/// RTCSEL [8:9]
/// RTC clock source selection
RTCSEL: u2 = 0,
/// unused [10:14]
_unused10: u5 = 0,
/// RTCEN [15:15]
/// RTC clock enable
RTCEN: u1 = 0,
/// BDRST [16:16]
/// Backup domain software reset
BDRST: u1 = 0,
/// unused [17:31]
_unused17: u7 = 0,
_unused24: u8 = 0,
};
/// Backup domain control register (RCC_BDCR)
pub const BDCR = Register(BDCR_val).init(base_address + 0x20);
/// CSR
const CSR_val = packed struct {
/// LSION [0:0]
/// Internal low speed oscillator enable
LSION: u1 = 0,
/// LSIRDY [1:1]
/// Internal low speed oscillator ready
LSIRDY: u1 = 0,
/// unused [2:23]
_unused2: u6 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
/// RMVF [24:24]
/// Remove reset flag
RMVF: u1 = 0,
/// OBLRSTF [25:25]
/// Option byte loader reset flag
OBLRSTF: u1 = 0,
/// PINRSTF [26:26]
/// PIN reset flag
PINRSTF: u1 = 1,
/// PORRSTF [27:27]
/// POR/PDR reset flag
PORRSTF: u1 = 1,
/// SFTRSTF [28:28]
/// Software reset flag
SFTRSTF: u1 = 0,
/// IWDGRSTF [29:29]
/// Independent watchdog reset flag
IWDGRSTF: u1 = 0,
/// WWDGRSTF [30:30]
/// Window watchdog reset flag
WWDGRSTF: u1 = 0,
/// LPWRRSTF [31:31]
/// Low-power reset flag
LPWRRSTF: u1 = 0,
};
/// Control/status register (RCC_CSR)
pub const CSR = Register(CSR_val).init(base_address + 0x24);
/// AHBRSTR
const AHBRSTR_val = packed struct {
/// unused [0:15]
_unused0: u8 = 0,
_unused8: u8 = 0,
/// IOPHRST [16:16]
/// I/O port H reset
IOPHRST: u1 = 0,
/// IOPARST [17:17]
/// I/O port A reset
IOPARST: u1 = 0,
/// IOPBRST [18:18]
/// I/O port B reset
IOPBRST: u1 = 0,
/// IOPCRST [19:19]
/// I/O port C reset
IOPCRST: u1 = 0,
/// IOPDRST [20:20]
/// I/O port D reset
IOPDRST: u1 = 0,
/// IOPERST [21:21]
/// I/O port E reset
IOPERST: u1 = 0,
/// IOPFRST [22:22]
/// I/O port F reset
IOPFRST: u1 = 0,
/// IOPGRST [23:23]
/// I/O port G reset
IOPGRST: u1 = 0,
/// TSCRST [24:24]
/// Touch sensing controller reset
TSCRST: u1 = 0,
/// unused [25:27]
_unused25: u3 = 0,
/// ADC12RST [28:28]
/// ADC1 and ADC2 reset
ADC12RST: u1 = 0,
/// ADC34RST [29:29]
/// ADC3 and ADC4 reset
ADC34RST: u1 = 0,
/// unused [30:31]
_unused30: u2 = 0,
};
/// AHB peripheral reset register
pub const AHBRSTR = Register(AHBRSTR_val).init(base_address + 0x28);
/// CFGR2
const CFGR2_val = packed struct {
/// PREDIV [0:3]
/// PREDIV division factor
PREDIV: u4 = 0,
/// ADC12PRES [4:8]
/// ADC1 and ADC2 prescaler
ADC12PRES: u5 = 0,
/// ADC34PRES [9:13]
/// ADC3 and ADC4 prescaler
ADC34PRES: u5 = 0,
/// unused [14:31]
_unused14: u2 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Clock configuration register 2
pub const CFGR2 = Register(CFGR2_val).init(base_address + 0x2c);
/// CFGR3
const CFGR3_val = packed struct {
/// USART1SW [0:1]
/// USART1 clock source selection
USART1SW: u2 = 0,
/// unused [2:3]
_unused2: u2 = 0,
/// I2C1SW [4:4]
/// I2C1 clock source selection
I2C1SW: u1 = 0,
/// I2C2SW [5:5]
/// I2C2 clock source selection
I2C2SW: u1 = 0,
/// I2C3SW [6:6]
/// I2C3 clock source selection
I2C3SW: u1 = 0,
/// unused [7:7]
_unused7: u1 = 0,
/// TIM1SW [8:8]
/// Timer1 clock source selection
TIM1SW: u1 = 0,
/// TIM8SW [9:9]
/// Timer8 clock source selection
TIM8SW: u1 = 0,
/// unused [10:15]
_unused10: u6 = 0,
/// USART2SW [16:17]
/// USART2 clock source selection
USART2SW: u2 = 0,
/// USART3SW [18:19]
/// USART3 clock source selection
USART3SW: u2 = 0,
/// UART4SW [20:21]
/// UART4 clock source selection
UART4SW: u2 = 0,
/// UART5SW [22:23]
/// UART5 clock source selection
UART5SW: u2 = 0,
/// unused [24:31]
_unused24: u8 = 0,
};
/// Clock configuration register 3
pub const CFGR3 = Register(CFGR3_val).init(base_address + 0x30);
};
/// DMA controller 1
pub const DMA1 = struct {
const base_address = 0x40020000;
/// ISR
const ISR_val = packed struct {
/// GIF1 [0:0]
/// Channel 1 Global interrupt flag
GIF1: u1 = 0,
/// TCIF1 [1:1]
/// Channel 1 Transfer Complete flag
TCIF1: u1 = 0,
/// HTIF1 [2:2]
/// Channel 1 Half Transfer Complete flag
HTIF1: u1 = 0,
/// TEIF1 [3:3]
/// Channel 1 Transfer Error flag
TEIF1: u1 = 0,
/// GIF2 [4:4]
/// Channel 2 Global interrupt flag
GIF2: u1 = 0,
/// TCIF2 [5:5]
/// Channel 2 Transfer Complete flag
TCIF2: u1 = 0,
/// HTIF2 [6:6]
/// Channel 2 Half Transfer Complete flag
HTIF2: u1 = 0,
/// TEIF2 [7:7]
/// Channel 2 Transfer Error flag
TEIF2: u1 = 0,
/// GIF3 [8:8]
/// Channel 3 Global interrupt flag
GIF3: u1 = 0,
/// TCIF3 [9:9]
/// Channel 3 Transfer Complete flag
TCIF3: u1 = 0,
/// HTIF3 [10:10]
/// Channel 3 Half Transfer Complete flag
HTIF3: u1 = 0,
/// TEIF3 [11:11]
/// Channel 3 Transfer Error flag
TEIF3: u1 = 0,
/// GIF4 [12:12]
/// Channel 4 Global interrupt flag
GIF4: u1 = 0,
/// TCIF4 [13:13]
/// Channel 4 Transfer Complete flag
TCIF4: u1 = 0,
/// HTIF4 [14:14]
/// Channel 4 Half Transfer Complete flag
HTIF4: u1 = 0,
/// TEIF4 [15:15]
/// Channel 4 Transfer Error flag
TEIF4: u1 = 0,
/// GIF5 [16:16]
/// Channel 5 Global interrupt flag
GIF5: u1 = 0,
/// TCIF5 [17:17]
/// Channel 5 Transfer Complete flag
TCIF5: u1 = 0,
/// HTIF5 [18:18]
/// Channel 5 Half Transfer Complete flag
HTIF5: u1 = 0,
/// TEIF5 [19:19]
/// Channel 5 Transfer Error flag
TEIF5: u1 = 0,
/// GIF6 [20:20]
/// Channel 6 Global interrupt flag
GIF6: u1 = 0,
/// TCIF6 [21:21]
/// Channel 6 Transfer Complete flag
TCIF6: u1 = 0,
/// HTIF6 [22:22]
/// Channel 6 Half Transfer Complete flag
HTIF6: u1 = 0,
/// TEIF6 [23:23]
/// Channel 6 Transfer Error flag
TEIF6: u1 = 0,
/// GIF7 [24:24]
/// Channel 7 Global interrupt flag
GIF7: u1 = 0,
/// TCIF7 [25:25]
/// Channel 7 Transfer Complete flag
TCIF7: u1 = 0,
/// HTIF7 [26:26]
/// Channel 7 Half Transfer Complete flag
HTIF7: u1 = 0,
/// TEIF7 [27:27]
/// Channel 7 Transfer Error flag
TEIF7: u1 = 0,
/// unused [28:31]
_unused28: u4 = 0,
};
/// DMA interrupt status register (DMA_ISR)
pub const ISR = Register(ISR_val).init(base_address + 0x0);
/// IFCR
const IFCR_val = packed struct {
/// CGIF1 [0:0]
/// Channel 1 Global interrupt clear
CGIF1: u1 = 0,
/// CTCIF1 [1:1]
/// Channel 1 Transfer Complete clear
CTCIF1: u1 = 0,
/// CHTIF1 [2:2]
/// Channel 1 Half Transfer clear
CHTIF1: u1 = 0,
/// CTEIF1 [3:3]
/// Channel 1 Transfer Error clear
CTEIF1: u1 = 0,
/// CGIF2 [4:4]
/// Channel 2 Global interrupt clear
CGIF2: u1 = 0,
/// CTCIF2 [5:5]
/// Channel 2 Transfer Complete clear
CTCIF2: u1 = 0,
/// CHTIF2 [6:6]
/// Channel 2 Half Transfer clear
CHTIF2: u1 = 0,
/// CTEIF2 [7:7]
/// Channel 2 Transfer Error clear
CTEIF2: u1 = 0,
/// CGIF3 [8:8]
/// Channel 3 Global interrupt clear
CGIF3: u1 = 0,
/// CTCIF3 [9:9]
/// Channel 3 Transfer Complete clear
CTCIF3: u1 = 0,
/// CHTIF3 [10:10]
/// Channel 3 Half Transfer clear
CHTIF3: u1 = 0,
/// CTEIF3 [11:11]
/// Channel 3 Transfer Error clear
CTEIF3: u1 = 0,
/// CGIF4 [12:12]
/// Channel 4 Global interrupt clear
CGIF4: u1 = 0,
/// CTCIF4 [13:13]
/// Channel 4 Transfer Complete clear
CTCIF4: u1 = 0,
/// CHTIF4 [14:14]
/// Channel 4 Half Transfer clear
CHTIF4: u1 = 0,
/// CTEIF4 [15:15]
/// Channel 4 Transfer Error clear
CTEIF4: u1 = 0,
/// CGIF5 [16:16]
/// Channel 5 Global interrupt clear
CGIF5: u1 = 0,
/// CTCIF5 [17:17]
/// Channel 5 Transfer Complete clear
CTCIF5: u1 = 0,
/// CHTIF5 [18:18]
/// Channel 5 Half Transfer clear
CHTIF5: u1 = 0,
/// CTEIF5 [19:19]
/// Channel 5 Transfer Error clear
CTEIF5: u1 = 0,
/// CGIF6 [20:20]
/// Channel 6 Global interrupt clear
CGIF6: u1 = 0,
/// CTCIF6 [21:21]
/// Channel 6 Transfer Complete clear
CTCIF6: u1 = 0,
/// CHTIF6 [22:22]
/// Channel 6 Half Transfer clear
CHTIF6: u1 = 0,
/// CTEIF6 [23:23]
/// Channel 6 Transfer Error clear
CTEIF6: u1 = 0,
/// CGIF7 [24:24]
/// Channel 7 Global interrupt clear
CGIF7: u1 = 0,
/// CTCIF7 [25:25]
/// Channel 7 Transfer Complete clear
CTCIF7: u1 = 0,
/// CHTIF7 [26:26]
/// Channel 7 Half Transfer clear
CHTIF7: u1 = 0,
/// CTEIF7 [27:27]
/// Channel 7 Transfer Error clear
CTEIF7: u1 = 0,
/// unused [28:31]
_unused28: u4 = 0,
};
/// DMA interrupt flag clear register (DMA_IFCR)
pub const IFCR = Register(IFCR_val).init(base_address + 0x4);
/// CCR1
const CCR1_val = packed struct {
/// EN [0:0]
/// Channel enable
EN: u1 = 0,
/// TCIE [1:1]
/// Transfer complete interrupt enable
TCIE: u1 = 0,
/// HTIE [2:2]
/// Half Transfer interrupt enable
HTIE: u1 = 0,
/// TEIE [3:3]
/// Transfer error interrupt enable
TEIE: u1 = 0,
/// DIR [4:4]
/// Data transfer direction
DIR: u1 = 0,
/// CIRC [5:5]
/// Circular mode
CIRC: u1 = 0,
/// PINC [6:6]
/// Peripheral increment mode
PINC: u1 = 0,
/// MINC [7:7]
/// Memory increment mode
MINC: u1 = 0,
/// PSIZE [8:9]
/// Peripheral size
PSIZE: u2 = 0,
/// MSIZE [10:11]
/// Memory size
MSIZE: u2 = 0,
/// PL [12:13]
/// Channel Priority level
PL: u2 = 0,
/// MEM2MEM [14:14]
/// Memory to memory mode
MEM2MEM: u1 = 0,
/// unused [15:31]
_unused15: u1 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA channel configuration register (DMA_CCR)
pub const CCR1 = Register(CCR1_val).init(base_address + 0x8);
/// CNDTR1
const CNDTR1_val = packed struct {
/// NDT [0:15]
/// Number of data to transfer
NDT: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA channel 1 number of data register
pub const CNDTR1 = Register(CNDTR1_val).init(base_address + 0xc);
/// CPAR1
const CPAR1_val = packed struct {
/// PA [0:31]
/// Peripheral address
PA: u32 = 0,
};
/// DMA channel 1 peripheral address register
pub const CPAR1 = Register(CPAR1_val).init(base_address + 0x10);
/// CMAR1
const CMAR1_val = packed struct {
/// MA [0:31]
/// Memory address
MA: u32 = 0,
};
/// DMA channel 1 memory address register
pub const CMAR1 = Register(CMAR1_val).init(base_address + 0x14);
/// CCR2
const CCR2_val = packed struct {
/// EN [0:0]
/// Channel enable
EN: u1 = 0,
/// TCIE [1:1]
/// Transfer complete interrupt enable
TCIE: u1 = 0,
/// HTIE [2:2]
/// Half Transfer interrupt enable
HTIE: u1 = 0,
/// TEIE [3:3]
/// Transfer error interrupt enable
TEIE: u1 = 0,
/// DIR [4:4]
/// Data transfer direction
DIR: u1 = 0,
/// CIRC [5:5]
/// Circular mode
CIRC: u1 = 0,
/// PINC [6:6]
/// Peripheral increment mode
PINC: u1 = 0,
/// MINC [7:7]
/// Memory increment mode
MINC: u1 = 0,
/// PSIZE [8:9]
/// Peripheral size
PSIZE: u2 = 0,
/// MSIZE [10:11]
/// Memory size
MSIZE: u2 = 0,
/// PL [12:13]
/// Channel Priority level
PL: u2 = 0,
/// MEM2MEM [14:14]
/// Memory to memory mode
MEM2MEM: u1 = 0,
/// unused [15:31]
_unused15: u1 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA channel configuration register (DMA_CCR)
pub const CCR2 = Register(CCR2_val).init(base_address + 0x1c);
/// CNDTR2
const CNDTR2_val = packed struct {
/// NDT [0:15]
/// Number of data to transfer
NDT: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA channel 2 number of data register
pub const CNDTR2 = Register(CNDTR2_val).init(base_address + 0x20);
/// CPAR2
const CPAR2_val = packed struct {
/// PA [0:31]
/// Peripheral address
PA: u32 = 0,
};
/// DMA channel 2 peripheral address register
pub const CPAR2 = Register(CPAR2_val).init(base_address + 0x24);
/// CMAR2
const CMAR2_val = packed struct {
/// MA [0:31]
/// Memory address
MA: u32 = 0,
};
/// DMA channel 2 memory address register
pub const CMAR2 = Register(CMAR2_val).init(base_address + 0x28);
/// CCR3
const CCR3_val = packed struct {
/// EN [0:0]
/// Channel enable
EN: u1 = 0,
/// TCIE [1:1]
/// Transfer complete interrupt enable
TCIE: u1 = 0,
/// HTIE [2:2]
/// Half Transfer interrupt enable
HTIE: u1 = 0,
/// TEIE [3:3]
/// Transfer error interrupt enable
TEIE: u1 = 0,
/// DIR [4:4]
/// Data transfer direction
DIR: u1 = 0,
/// CIRC [5:5]
/// Circular mode
CIRC: u1 = 0,
/// PINC [6:6]
/// Peripheral increment mode
PINC: u1 = 0,
/// MINC [7:7]
/// Memory increment mode
MINC: u1 = 0,
/// PSIZE [8:9]
/// Peripheral size
PSIZE: u2 = 0,
/// MSIZE [10:11]
/// Memory size
MSIZE: u2 = 0,
/// PL [12:13]
/// Channel Priority level
PL: u2 = 0,
/// MEM2MEM [14:14]
/// Memory to memory mode
MEM2MEM: u1 = 0,
/// unused [15:31]
_unused15: u1 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA channel configuration register (DMA_CCR)
pub const CCR3 = Register(CCR3_val).init(base_address + 0x30);
/// CNDTR3
const CNDTR3_val = packed struct {
/// NDT [0:15]
/// Number of data to transfer
NDT: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA channel 3 number of data register
pub const CNDTR3 = Register(CNDTR3_val).init(base_address + 0x34);
/// CPAR3
const CPAR3_val = packed struct {
/// PA [0:31]
/// Peripheral address
PA: u32 = 0,
};
/// DMA channel 3 peripheral address register
pub const CPAR3 = Register(CPAR3_val).init(base_address + 0x38);
/// CMAR3
const CMAR3_val = packed struct {
/// MA [0:31]
/// Memory address
MA: u32 = 0,
};
/// DMA channel 3 memory address register
pub const CMAR3 = Register(CMAR3_val).init(base_address + 0x3c);
/// CCR4
const CCR4_val = packed struct {
/// EN [0:0]
/// Channel enable
EN: u1 = 0,
/// TCIE [1:1]
/// Transfer complete interrupt enable
TCIE: u1 = 0,
/// HTIE [2:2]
/// Half Transfer interrupt enable
HTIE: u1 = 0,
/// TEIE [3:3]
/// Transfer error interrupt enable
TEIE: u1 = 0,
/// DIR [4:4]
/// Data transfer direction
DIR: u1 = 0,
/// CIRC [5:5]
/// Circular mode
CIRC: u1 = 0,
/// PINC [6:6]
/// Peripheral increment mode
PINC: u1 = 0,
/// MINC [7:7]
/// Memory increment mode
MINC: u1 = 0,
/// PSIZE [8:9]
/// Peripheral size
PSIZE: u2 = 0,
/// MSIZE [10:11]
/// Memory size
MSIZE: u2 = 0,
/// PL [12:13]
/// Channel Priority level
PL: u2 = 0,
/// MEM2MEM [14:14]
/// Memory to memory mode
MEM2MEM: u1 = 0,
/// unused [15:31]
_unused15: u1 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA channel configuration register (DMA_CCR)
pub const CCR4 = Register(CCR4_val).init(base_address + 0x44);
/// CNDTR4
const CNDTR4_val = packed struct {
/// NDT [0:15]
/// Number of data to transfer
NDT: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA channel 4 number of data register
pub const CNDTR4 = Register(CNDTR4_val).init(base_address + 0x48);
/// CPAR4
const CPAR4_val = packed struct {
/// PA [0:31]
/// Peripheral address
PA: u32 = 0,
};
/// DMA channel 4 peripheral address register
pub const CPAR4 = Register(CPAR4_val).init(base_address + 0x4c);
/// CMAR4
const CMAR4_val = packed struct {
/// MA [0:31]
/// Memory address
MA: u32 = 0,
};
/// DMA channel 4 memory address register
pub const CMAR4 = Register(CMAR4_val).init(base_address + 0x50);
/// CCR5
const CCR5_val = packed struct {
/// EN [0:0]
/// Channel enable
EN: u1 = 0,
/// TCIE [1:1]
/// Transfer complete interrupt enable
TCIE: u1 = 0,
/// HTIE [2:2]
/// Half Transfer interrupt enable
HTIE: u1 = 0,
/// TEIE [3:3]
/// Transfer error interrupt enable
TEIE: u1 = 0,
/// DIR [4:4]
/// Data transfer direction
DIR: u1 = 0,
/// CIRC [5:5]
/// Circular mode
CIRC: u1 = 0,
/// PINC [6:6]
/// Peripheral increment mode
PINC: u1 = 0,
/// MINC [7:7]
/// Memory increment mode
MINC: u1 = 0,
/// PSIZE [8:9]
/// Peripheral size
PSIZE: u2 = 0,
/// MSIZE [10:11]
/// Memory size
MSIZE: u2 = 0,
/// PL [12:13]
/// Channel Priority level
PL: u2 = 0,
/// MEM2MEM [14:14]
/// Memory to memory mode
MEM2MEM: u1 = 0,
/// unused [15:31]
_unused15: u1 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA channel configuration register (DMA_CCR)
pub const CCR5 = Register(CCR5_val).init(base_address + 0x58);
/// CNDTR5
const CNDTR5_val = packed struct {
/// NDT [0:15]
/// Number of data to transfer
NDT: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA channel 5 number of data register
pub const CNDTR5 = Register(CNDTR5_val).init(base_address + 0x5c);
/// CPAR5
const CPAR5_val = packed struct {
/// PA [0:31]
/// Peripheral address
PA: u32 = 0,
};
/// DMA channel 5 peripheral address register
pub const CPAR5 = Register(CPAR5_val).init(base_address + 0x60);
/// CMAR5
const CMAR5_val = packed struct {
/// MA [0:31]
/// Memory address
MA: u32 = 0,
};
/// DMA channel 5 memory address register
pub const CMAR5 = Register(CMAR5_val).init(base_address + 0x64);
/// CCR6
const CCR6_val = packed struct {
/// EN [0:0]
/// Channel enable
EN: u1 = 0,
/// TCIE [1:1]
/// Transfer complete interrupt enable
TCIE: u1 = 0,
/// HTIE [2:2]
/// Half Transfer interrupt enable
HTIE: u1 = 0,
/// TEIE [3:3]
/// Transfer error interrupt enable
TEIE: u1 = 0,
/// DIR [4:4]
/// Data transfer direction
DIR: u1 = 0,
/// CIRC [5:5]
/// Circular mode
CIRC: u1 = 0,
/// PINC [6:6]
/// Peripheral increment mode
PINC: u1 = 0,
/// MINC [7:7]
/// Memory increment mode
MINC: u1 = 0,
/// PSIZE [8:9]
/// Peripheral size
PSIZE: u2 = 0,
/// MSIZE [10:11]
/// Memory size
MSIZE: u2 = 0,
/// PL [12:13]
/// Channel Priority level
PL: u2 = 0,
/// MEM2MEM [14:14]
/// Memory to memory mode
MEM2MEM: u1 = 0,
/// unused [15:31]
_unused15: u1 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA channel configuration register (DMA_CCR)
pub const CCR6 = Register(CCR6_val).init(base_address + 0x6c);
/// CNDTR6
const CNDTR6_val = packed struct {
/// NDT [0:15]
/// Number of data to transfer
NDT: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA channel 6 number of data register
pub const CNDTR6 = Register(CNDTR6_val).init(base_address + 0x70);
/// CPAR6
const CPAR6_val = packed struct {
/// PA [0:31]
/// Peripheral address
PA: u32 = 0,
};
/// DMA channel 6 peripheral address register
pub const CPAR6 = Register(CPAR6_val).init(base_address + 0x74);
/// CMAR6
const CMAR6_val = packed struct {
/// MA [0:31]
/// Memory address
MA: u32 = 0,
};
/// DMA channel 6 memory address register
pub const CMAR6 = Register(CMAR6_val).init(base_address + 0x78);
/// CCR7
const CCR7_val = packed struct {
/// EN [0:0]
/// Channel enable
EN: u1 = 0,
/// TCIE [1:1]
/// Transfer complete interrupt enable
TCIE: u1 = 0,
/// HTIE [2:2]
/// Half Transfer interrupt enable
HTIE: u1 = 0,
/// TEIE [3:3]
/// Transfer error interrupt enable
TEIE: u1 = 0,
/// DIR [4:4]
/// Data transfer direction
DIR: u1 = 0,
/// CIRC [5:5]
/// Circular mode
CIRC: u1 = 0,
/// PINC [6:6]
/// Peripheral increment mode
PINC: u1 = 0,
/// MINC [7:7]
/// Memory increment mode
MINC: u1 = 0,
/// PSIZE [8:9]
/// Peripheral size
PSIZE: u2 = 0,
/// MSIZE [10:11]
/// Memory size
MSIZE: u2 = 0,
/// PL [12:13]
/// Channel Priority level
PL: u2 = 0,
/// MEM2MEM [14:14]
/// Memory to memory mode
MEM2MEM: u1 = 0,
/// unused [15:31]
_unused15: u1 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA channel configuration register (DMA_CCR)
pub const CCR7 = Register(CCR7_val).init(base_address + 0x80);
/// CNDTR7
const CNDTR7_val = packed struct {
/// NDT [0:15]
/// Number of data to transfer
NDT: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA channel 7 number of data register
pub const CNDTR7 = Register(CNDTR7_val).init(base_address + 0x84);
/// CPAR7
const CPAR7_val = packed struct {
/// PA [0:31]
/// Peripheral address
PA: u32 = 0,
};
/// DMA channel 7 peripheral address register
pub const CPAR7 = Register(CPAR7_val).init(base_address + 0x88);
/// CMAR7
const CMAR7_val = packed struct {
/// MA [0:31]
/// Memory address
MA: u32 = 0,
};
/// DMA channel 7 memory address register
pub const CMAR7 = Register(CMAR7_val).init(base_address + 0x8c);
};
/// DMA controller 1
pub const DMA2 = struct {
const base_address = 0x40020400;
/// ISR
const ISR_val = packed struct {
/// GIF1 [0:0]
/// Channel 1 Global interrupt flag
GIF1: u1 = 0,
/// TCIF1 [1:1]
/// Channel 1 Transfer Complete flag
TCIF1: u1 = 0,
/// HTIF1 [2:2]
/// Channel 1 Half Transfer Complete flag
HTIF1: u1 = 0,
/// TEIF1 [3:3]
/// Channel 1 Transfer Error flag
TEIF1: u1 = 0,
/// GIF2 [4:4]
/// Channel 2 Global interrupt flag
GIF2: u1 = 0,
/// TCIF2 [5:5]
/// Channel 2 Transfer Complete flag
TCIF2: u1 = 0,
/// HTIF2 [6:6]
/// Channel 2 Half Transfer Complete flag
HTIF2: u1 = 0,
/// TEIF2 [7:7]
/// Channel 2 Transfer Error flag
TEIF2: u1 = 0,
/// GIF3 [8:8]
/// Channel 3 Global interrupt flag
GIF3: u1 = 0,
/// TCIF3 [9:9]
/// Channel 3 Transfer Complete flag
TCIF3: u1 = 0,
/// HTIF3 [10:10]
/// Channel 3 Half Transfer Complete flag
HTIF3: u1 = 0,
/// TEIF3 [11:11]
/// Channel 3 Transfer Error flag
TEIF3: u1 = 0,
/// GIF4 [12:12]
/// Channel 4 Global interrupt flag
GIF4: u1 = 0,
/// TCIF4 [13:13]
/// Channel 4 Transfer Complete flag
TCIF4: u1 = 0,
/// HTIF4 [14:14]
/// Channel 4 Half Transfer Complete flag
HTIF4: u1 = 0,
/// TEIF4 [15:15]
/// Channel 4 Transfer Error flag
TEIF4: u1 = 0,
/// GIF5 [16:16]
/// Channel 5 Global interrupt flag
GIF5: u1 = 0,
/// TCIF5 [17:17]
/// Channel 5 Transfer Complete flag
TCIF5: u1 = 0,
/// HTIF5 [18:18]
/// Channel 5 Half Transfer Complete flag
HTIF5: u1 = 0,
/// TEIF5 [19:19]
/// Channel 5 Transfer Error flag
TEIF5: u1 = 0,
/// GIF6 [20:20]
/// Channel 6 Global interrupt flag
GIF6: u1 = 0,
/// TCIF6 [21:21]
/// Channel 6 Transfer Complete flag
TCIF6: u1 = 0,
/// HTIF6 [22:22]
/// Channel 6 Half Transfer Complete flag
HTIF6: u1 = 0,
/// TEIF6 [23:23]
/// Channel 6 Transfer Error flag
TEIF6: u1 = 0,
/// GIF7 [24:24]
/// Channel 7 Global interrupt flag
GIF7: u1 = 0,
/// TCIF7 [25:25]
/// Channel 7 Transfer Complete flag
TCIF7: u1 = 0,
/// HTIF7 [26:26]
/// Channel 7 Half Transfer Complete flag
HTIF7: u1 = 0,
/// TEIF7 [27:27]
/// Channel 7 Transfer Error flag
TEIF7: u1 = 0,
/// unused [28:31]
_unused28: u4 = 0,
};
/// DMA interrupt status register (DMA_ISR)
pub const ISR = Register(ISR_val).init(base_address + 0x0);
/// IFCR
const IFCR_val = packed struct {
/// CGIF1 [0:0]
/// Channel 1 Global interrupt clear
CGIF1: u1 = 0,
/// CTCIF1 [1:1]
/// Channel 1 Transfer Complete clear
CTCIF1: u1 = 0,
/// CHTIF1 [2:2]
/// Channel 1 Half Transfer clear
CHTIF1: u1 = 0,
/// CTEIF1 [3:3]
/// Channel 1 Transfer Error clear
CTEIF1: u1 = 0,
/// CGIF2 [4:4]
/// Channel 2 Global interrupt clear
CGIF2: u1 = 0,
/// CTCIF2 [5:5]
/// Channel 2 Transfer Complete clear
CTCIF2: u1 = 0,
/// CHTIF2 [6:6]
/// Channel 2 Half Transfer clear
CHTIF2: u1 = 0,
/// CTEIF2 [7:7]
/// Channel 2 Transfer Error clear
CTEIF2: u1 = 0,
/// CGIF3 [8:8]
/// Channel 3 Global interrupt clear
CGIF3: u1 = 0,
/// CTCIF3 [9:9]
/// Channel 3 Transfer Complete clear
CTCIF3: u1 = 0,
/// CHTIF3 [10:10]
/// Channel 3 Half Transfer clear
CHTIF3: u1 = 0,
/// CTEIF3 [11:11]
/// Channel 3 Transfer Error clear
CTEIF3: u1 = 0,
/// CGIF4 [12:12]
/// Channel 4 Global interrupt clear
CGIF4: u1 = 0,
/// CTCIF4 [13:13]
/// Channel 4 Transfer Complete clear
CTCIF4: u1 = 0,
/// CHTIF4 [14:14]
/// Channel 4 Half Transfer clear
CHTIF4: u1 = 0,
/// CTEIF4 [15:15]
/// Channel 4 Transfer Error clear
CTEIF4: u1 = 0,
/// CGIF5 [16:16]
/// Channel 5 Global interrupt clear
CGIF5: u1 = 0,
/// CTCIF5 [17:17]
/// Channel 5 Transfer Complete clear
CTCIF5: u1 = 0,
/// CHTIF5 [18:18]
/// Channel 5 Half Transfer clear
CHTIF5: u1 = 0,
/// CTEIF5 [19:19]
/// Channel 5 Transfer Error clear
CTEIF5: u1 = 0,
/// CGIF6 [20:20]
/// Channel 6 Global interrupt clear
CGIF6: u1 = 0,
/// CTCIF6 [21:21]
/// Channel 6 Transfer Complete clear
CTCIF6: u1 = 0,
/// CHTIF6 [22:22]
/// Channel 6 Half Transfer clear
CHTIF6: u1 = 0,
/// CTEIF6 [23:23]
/// Channel 6 Transfer Error clear
CTEIF6: u1 = 0,
/// CGIF7 [24:24]
/// Channel 7 Global interrupt clear
CGIF7: u1 = 0,
/// CTCIF7 [25:25]
/// Channel 7 Transfer Complete clear
CTCIF7: u1 = 0,
/// CHTIF7 [26:26]
/// Channel 7 Half Transfer clear
CHTIF7: u1 = 0,
/// CTEIF7 [27:27]
/// Channel 7 Transfer Error clear
CTEIF7: u1 = 0,
/// unused [28:31]
_unused28: u4 = 0,
};
/// DMA interrupt flag clear register (DMA_IFCR)
pub const IFCR = Register(IFCR_val).init(base_address + 0x4);
/// CCR1
const CCR1_val = packed struct {
/// EN [0:0]
/// Channel enable
EN: u1 = 0,
/// TCIE [1:1]
/// Transfer complete interrupt enable
TCIE: u1 = 0,
/// HTIE [2:2]
/// Half Transfer interrupt enable
HTIE: u1 = 0,
/// TEIE [3:3]
/// Transfer error interrupt enable
TEIE: u1 = 0,
/// DIR [4:4]
/// Data transfer direction
DIR: u1 = 0,
/// CIRC [5:5]
/// Circular mode
CIRC: u1 = 0,
/// PINC [6:6]
/// Peripheral increment mode
PINC: u1 = 0,
/// MINC [7:7]
/// Memory increment mode
MINC: u1 = 0,
/// PSIZE [8:9]
/// Peripheral size
PSIZE: u2 = 0,
/// MSIZE [10:11]
/// Memory size
MSIZE: u2 = 0,
/// PL [12:13]
/// Channel Priority level
PL: u2 = 0,
/// MEM2MEM [14:14]
/// Memory to memory mode
MEM2MEM: u1 = 0,
/// unused [15:31]
_unused15: u1 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA channel configuration register (DMA_CCR)
pub const CCR1 = Register(CCR1_val).init(base_address + 0x8);
/// CNDTR1
const CNDTR1_val = packed struct {
/// NDT [0:15]
/// Number of data to transfer
NDT: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA channel 1 number of data register
pub const CNDTR1 = Register(CNDTR1_val).init(base_address + 0xc);
/// CPAR1
const CPAR1_val = packed struct {
/// PA [0:31]
/// Peripheral address
PA: u32 = 0,
};
/// DMA channel 1 peripheral address register
pub const CPAR1 = Register(CPAR1_val).init(base_address + 0x10);
/// CMAR1
const CMAR1_val = packed struct {
/// MA [0:31]
/// Memory address
MA: u32 = 0,
};
/// DMA channel 1 memory address register
pub const CMAR1 = Register(CMAR1_val).init(base_address + 0x14);
/// CCR2
const CCR2_val = packed struct {
/// EN [0:0]
/// Channel enable
EN: u1 = 0,
/// TCIE [1:1]
/// Transfer complete interrupt enable
TCIE: u1 = 0,
/// HTIE [2:2]
/// Half Transfer interrupt enable
HTIE: u1 = 0,
/// TEIE [3:3]
/// Transfer error interrupt enable
TEIE: u1 = 0,
/// DIR [4:4]
/// Data transfer direction
DIR: u1 = 0,
/// CIRC [5:5]
/// Circular mode
CIRC: u1 = 0,
/// PINC [6:6]
/// Peripheral increment mode
PINC: u1 = 0,
/// MINC [7:7]
/// Memory increment mode
MINC: u1 = 0,
/// PSIZE [8:9]
/// Peripheral size
PSIZE: u2 = 0,
/// MSIZE [10:11]
/// Memory size
MSIZE: u2 = 0,
/// PL [12:13]
/// Channel Priority level
PL: u2 = 0,
/// MEM2MEM [14:14]
/// Memory to memory mode
MEM2MEM: u1 = 0,
/// unused [15:31]
_unused15: u1 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA channel configuration register (DMA_CCR)
pub const CCR2 = Register(CCR2_val).init(base_address + 0x1c);
/// CNDTR2
const CNDTR2_val = packed struct {
/// NDT [0:15]
/// Number of data to transfer
NDT: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA channel 2 number of data register
pub const CNDTR2 = Register(CNDTR2_val).init(base_address + 0x20);
/// CPAR2
const CPAR2_val = packed struct {
/// PA [0:31]
/// Peripheral address
PA: u32 = 0,
};
/// DMA channel 2 peripheral address register
pub const CPAR2 = Register(CPAR2_val).init(base_address + 0x24);
/// CMAR2
const CMAR2_val = packed struct {
/// MA [0:31]
/// Memory address
MA: u32 = 0,
};
/// DMA channel 2 memory address register
pub const CMAR2 = Register(CMAR2_val).init(base_address + 0x28);
/// CCR3
const CCR3_val = packed struct {
/// EN [0:0]
/// Channel enable
EN: u1 = 0,
/// TCIE [1:1]
/// Transfer complete interrupt enable
TCIE: u1 = 0,
/// HTIE [2:2]
/// Half Transfer interrupt enable
HTIE: u1 = 0,
/// TEIE [3:3]
/// Transfer error interrupt enable
TEIE: u1 = 0,
/// DIR [4:4]
/// Data transfer direction
DIR: u1 = 0,
/// CIRC [5:5]
/// Circular mode
CIRC: u1 = 0,
/// PINC [6:6]
/// Peripheral increment mode
PINC: u1 = 0,
/// MINC [7:7]
/// Memory increment mode
MINC: u1 = 0,
/// PSIZE [8:9]
/// Peripheral size
PSIZE: u2 = 0,
/// MSIZE [10:11]
/// Memory size
MSIZE: u2 = 0,
/// PL [12:13]
/// Channel Priority level
PL: u2 = 0,
/// MEM2MEM [14:14]
/// Memory to memory mode
MEM2MEM: u1 = 0,
/// unused [15:31]
_unused15: u1 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA channel configuration register (DMA_CCR)
pub const CCR3 = Register(CCR3_val).init(base_address + 0x30);
/// CNDTR3
const CNDTR3_val = packed struct {
/// NDT [0:15]
/// Number of data to transfer
NDT: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA channel 3 number of data register
pub const CNDTR3 = Register(CNDTR3_val).init(base_address + 0x34);
/// CPAR3
const CPAR3_val = packed struct {
/// PA [0:31]
/// Peripheral address
PA: u32 = 0,
};
/// DMA channel 3 peripheral address register
pub const CPAR3 = Register(CPAR3_val).init(base_address + 0x38);
/// CMAR3
const CMAR3_val = packed struct {
/// MA [0:31]
/// Memory address
MA: u32 = 0,
};
/// DMA channel 3 memory address register
pub const CMAR3 = Register(CMAR3_val).init(base_address + 0x3c);
/// CCR4
const CCR4_val = packed struct {
/// EN [0:0]
/// Channel enable
EN: u1 = 0,
/// TCIE [1:1]
/// Transfer complete interrupt enable
TCIE: u1 = 0,
/// HTIE [2:2]
/// Half Transfer interrupt enable
HTIE: u1 = 0,
/// TEIE [3:3]
/// Transfer error interrupt enable
TEIE: u1 = 0,
/// DIR [4:4]
/// Data transfer direction
DIR: u1 = 0,
/// CIRC [5:5]
/// Circular mode
CIRC: u1 = 0,
/// PINC [6:6]
/// Peripheral increment mode
PINC: u1 = 0,
/// MINC [7:7]
/// Memory increment mode
MINC: u1 = 0,
/// PSIZE [8:9]
/// Peripheral size
PSIZE: u2 = 0,
/// MSIZE [10:11]
/// Memory size
MSIZE: u2 = 0,
/// PL [12:13]
/// Channel Priority level
PL: u2 = 0,
/// MEM2MEM [14:14]
/// Memory to memory mode
MEM2MEM: u1 = 0,
/// unused [15:31]
_unused15: u1 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA channel configuration register (DMA_CCR)
pub const CCR4 = Register(CCR4_val).init(base_address + 0x44);
/// CNDTR4
const CNDTR4_val = packed struct {
/// NDT [0:15]
/// Number of data to transfer
NDT: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA channel 4 number of data register
pub const CNDTR4 = Register(CNDTR4_val).init(base_address + 0x48);
/// CPAR4
const CPAR4_val = packed struct {
/// PA [0:31]
/// Peripheral address
PA: u32 = 0,
};
/// DMA channel 4 peripheral address register
pub const CPAR4 = Register(CPAR4_val).init(base_address + 0x4c);
/// CMAR4
const CMAR4_val = packed struct {
/// MA [0:31]
/// Memory address
MA: u32 = 0,
};
/// DMA channel 4 memory address register
pub const CMAR4 = Register(CMAR4_val).init(base_address + 0x50);
/// CCR5
const CCR5_val = packed struct {
/// EN [0:0]
/// Channel enable
EN: u1 = 0,
/// TCIE [1:1]
/// Transfer complete interrupt enable
TCIE: u1 = 0,
/// HTIE [2:2]
/// Half Transfer interrupt enable
HTIE: u1 = 0,
/// TEIE [3:3]
/// Transfer error interrupt enable
TEIE: u1 = 0,
/// DIR [4:4]
/// Data transfer direction
DIR: u1 = 0,
/// CIRC [5:5]
/// Circular mode
CIRC: u1 = 0,
/// PINC [6:6]
/// Peripheral increment mode
PINC: u1 = 0,
/// MINC [7:7]
/// Memory increment mode
MINC: u1 = 0,
/// PSIZE [8:9]
/// Peripheral size
PSIZE: u2 = 0,
/// MSIZE [10:11]
/// Memory size
MSIZE: u2 = 0,
/// PL [12:13]
/// Channel Priority level
PL: u2 = 0,
/// MEM2MEM [14:14]
/// Memory to memory mode
MEM2MEM: u1 = 0,
/// unused [15:31]
_unused15: u1 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA channel configuration register (DMA_CCR)
pub const CCR5 = Register(CCR5_val).init(base_address + 0x58);
/// CNDTR5
const CNDTR5_val = packed struct {
/// NDT [0:15]
/// Number of data to transfer
NDT: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA channel 5 number of data register
pub const CNDTR5 = Register(CNDTR5_val).init(base_address + 0x5c);
/// CPAR5
const CPAR5_val = packed struct {
/// PA [0:31]
/// Peripheral address
PA: u32 = 0,
};
/// DMA channel 5 peripheral address register
pub const CPAR5 = Register(CPAR5_val).init(base_address + 0x60);
/// CMAR5
const CMAR5_val = packed struct {
/// MA [0:31]
/// Memory address
MA: u32 = 0,
};
/// DMA channel 5 memory address register
pub const CMAR5 = Register(CMAR5_val).init(base_address + 0x64);
/// CCR6
const CCR6_val = packed struct {
/// EN [0:0]
/// Channel enable
EN: u1 = 0,
/// TCIE [1:1]
/// Transfer complete interrupt enable
TCIE: u1 = 0,
/// HTIE [2:2]
/// Half Transfer interrupt enable
HTIE: u1 = 0,
/// TEIE [3:3]
/// Transfer error interrupt enable
TEIE: u1 = 0,
/// DIR [4:4]
/// Data transfer direction
DIR: u1 = 0,
/// CIRC [5:5]
/// Circular mode
CIRC: u1 = 0,
/// PINC [6:6]
/// Peripheral increment mode
PINC: u1 = 0,
/// MINC [7:7]
/// Memory increment mode
MINC: u1 = 0,
/// PSIZE [8:9]
/// Peripheral size
PSIZE: u2 = 0,
/// MSIZE [10:11]
/// Memory size
MSIZE: u2 = 0,
/// PL [12:13]
/// Channel Priority level
PL: u2 = 0,
/// MEM2MEM [14:14]
/// Memory to memory mode
MEM2MEM: u1 = 0,
/// unused [15:31]
_unused15: u1 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA channel configuration register (DMA_CCR)
pub const CCR6 = Register(CCR6_val).init(base_address + 0x6c);
/// CNDTR6
const CNDTR6_val = packed struct {
/// NDT [0:15]
/// Number of data to transfer
NDT: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA channel 6 number of data register
pub const CNDTR6 = Register(CNDTR6_val).init(base_address + 0x70);
/// CPAR6
const CPAR6_val = packed struct {
/// PA [0:31]
/// Peripheral address
PA: u32 = 0,
};
/// DMA channel 6 peripheral address register
pub const CPAR6 = Register(CPAR6_val).init(base_address + 0x74);
/// CMAR6
const CMAR6_val = packed struct {
/// MA [0:31]
/// Memory address
MA: u32 = 0,
};
/// DMA channel 6 memory address register
pub const CMAR6 = Register(CMAR6_val).init(base_address + 0x78);
/// CCR7
const CCR7_val = packed struct {
/// EN [0:0]
/// Channel enable
EN: u1 = 0,
/// TCIE [1:1]
/// Transfer complete interrupt enable
TCIE: u1 = 0,
/// HTIE [2:2]
/// Half Transfer interrupt enable
HTIE: u1 = 0,
/// TEIE [3:3]
/// Transfer error interrupt enable
TEIE: u1 = 0,
/// DIR [4:4]
/// Data transfer direction
DIR: u1 = 0,
/// CIRC [5:5]
/// Circular mode
CIRC: u1 = 0,
/// PINC [6:6]
/// Peripheral increment mode
PINC: u1 = 0,
/// MINC [7:7]
/// Memory increment mode
MINC: u1 = 0,
/// PSIZE [8:9]
/// Peripheral size
PSIZE: u2 = 0,
/// MSIZE [10:11]
/// Memory size
MSIZE: u2 = 0,
/// PL [12:13]
/// Channel Priority level
PL: u2 = 0,
/// MEM2MEM [14:14]
/// Memory to memory mode
MEM2MEM: u1 = 0,
/// unused [15:31]
_unused15: u1 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA channel configuration register (DMA_CCR)
pub const CCR7 = Register(CCR7_val).init(base_address + 0x80);
/// CNDTR7
const CNDTR7_val = packed struct {
/// NDT [0:15]
/// Number of data to transfer
NDT: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA channel 7 number of data register
pub const CNDTR7 = Register(CNDTR7_val).init(base_address + 0x84);
/// CPAR7
const CPAR7_val = packed struct {
/// PA [0:31]
/// Peripheral address
PA: u32 = 0,
};
/// DMA channel 7 peripheral address register
pub const CPAR7 = Register(CPAR7_val).init(base_address + 0x88);
/// CMAR7
const CMAR7_val = packed struct {
/// MA [0:31]
/// Memory address
MA: u32 = 0,
};
/// DMA channel 7 memory address register
pub const CMAR7 = Register(CMAR7_val).init(base_address + 0x8c);
};
/// General purpose timer
pub const TIM2 = struct {
const base_address = 0x40000000;
/// CR1
const CR1_val = packed struct {
/// CEN [0:0]
/// Counter enable
CEN: u1 = 0,
/// UDIS [1:1]
/// Update disable
UDIS: u1 = 0,
/// URS [2:2]
/// Update request source
URS: u1 = 0,
/// OPM [3:3]
/// One-pulse mode
OPM: u1 = 0,
/// DIR [4:4]
/// Direction
DIR: u1 = 0,
/// CMS [5:6]
/// Center-aligned mode selection
CMS: u2 = 0,
/// ARPE [7:7]
/// Auto-reload preload enable
ARPE: u1 = 0,
/// CKD [8:9]
/// Clock division
CKD: u2 = 0,
/// unused [10:10]
_unused10: u1 = 0,
/// UIFREMAP [11:11]
/// UIF status bit remapping
UIFREMAP: u1 = 0,
/// unused [12:31]
_unused12: u4 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// control register 1
pub const CR1 = Register(CR1_val).init(base_address + 0x0);
/// CR2
const CR2_val = packed struct {
/// unused [0:2]
_unused0: u3 = 0,
/// CCDS [3:3]
/// Capture/compare DMA selection
CCDS: u1 = 0,
/// MMS [4:6]
/// Master mode selection
MMS: u3 = 0,
/// TI1S [7:7]
/// TI1 selection
TI1S: u1 = 0,
/// unused [8:31]
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// control register 2
pub const CR2 = Register(CR2_val).init(base_address + 0x4);
/// SMCR
const SMCR_val = packed struct {
/// SMS [0:2]
/// Slave mode selection
SMS: u3 = 0,
/// OCCS [3:3]
/// OCREF clear selection
OCCS: u1 = 0,
/// TS [4:6]
/// Trigger selection
TS: u3 = 0,
/// MSM [7:7]
/// Master/Slave mode
MSM: u1 = 0,
/// ETF [8:11]
/// External trigger filter
ETF: u4 = 0,
/// ETPS [12:13]
/// External trigger prescaler
ETPS: u2 = 0,
/// ECE [14:14]
/// External clock enable
ECE: u1 = 0,
/// ETP [15:15]
/// External trigger polarity
ETP: u1 = 0,
/// SMS_3 [16:16]
/// Slave mode selection bit3
SMS_3: u1 = 0,
/// unused [17:31]
_unused17: u7 = 0,
_unused24: u8 = 0,
};
/// slave mode control register
pub const SMCR = Register(SMCR_val).init(base_address + 0x8);
/// DIER
const DIER_val = packed struct {
/// UIE [0:0]
/// Update interrupt enable
UIE: u1 = 0,
/// CC1IE [1:1]
/// Capture/Compare 1 interrupt enable
CC1IE: u1 = 0,
/// CC2IE [2:2]
/// Capture/Compare 2 interrupt enable
CC2IE: u1 = 0,
/// CC3IE [3:3]
/// Capture/Compare 3 interrupt enable
CC3IE: u1 = 0,
/// CC4IE [4:4]
/// Capture/Compare 4 interrupt enable
CC4IE: u1 = 0,
/// unused [5:5]
_unused5: u1 = 0,
/// TIE [6:6]
/// Trigger interrupt enable
TIE: u1 = 0,
/// unused [7:7]
_unused7: u1 = 0,
/// UDE [8:8]
/// Update DMA request enable
UDE: u1 = 0,
/// CC1DE [9:9]
/// Capture/Compare 1 DMA request enable
CC1DE: u1 = 0,
/// CC2DE [10:10]
/// Capture/Compare 2 DMA request enable
CC2DE: u1 = 0,
/// CC3DE [11:11]
/// Capture/Compare 3 DMA request enable
CC3DE: u1 = 0,
/// CC4DE [12:12]
/// Capture/Compare 4 DMA request enable
CC4DE: u1 = 0,
/// unused [13:13]
_unused13: u1 = 0,
/// TDE [14:14]
/// Trigger DMA request enable
TDE: u1 = 0,
/// unused [15:31]
_unused15: u1 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA/Interrupt enable register
pub const DIER = Register(DIER_val).init(base_address + 0xc);
/// SR
const SR_val = packed struct {
/// UIF [0:0]
/// Update interrupt flag
UIF: u1 = 0,
/// CC1IF [1:1]
/// Capture/compare 1 interrupt flag
CC1IF: u1 = 0,
/// CC2IF [2:2]
/// Capture/Compare 2 interrupt flag
CC2IF: u1 = 0,
/// CC3IF [3:3]
/// Capture/Compare 3 interrupt flag
CC3IF: u1 = 0,
/// CC4IF [4:4]
/// Capture/Compare 4 interrupt flag
CC4IF: u1 = 0,
/// unused [5:5]
_unused5: u1 = 0,
/// TIF [6:6]
/// Trigger interrupt flag
TIF: u1 = 0,
/// unused [7:8]
_unused7: u1 = 0,
_unused8: u1 = 0,
/// CC1OF [9:9]
/// Capture/Compare 1 overcapture flag
CC1OF: u1 = 0,
/// CC2OF [10:10]
/// Capture/compare 2 overcapture flag
CC2OF: u1 = 0,
/// CC3OF [11:11]
/// Capture/Compare 3 overcapture flag
CC3OF: u1 = 0,
/// CC4OF [12:12]
/// Capture/Compare 4 overcapture flag
CC4OF: u1 = 0,
/// unused [13:31]
_unused13: u3 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// status register
pub const SR = Register(SR_val).init(base_address + 0x10);
/// EGR
const EGR_val = packed struct {
/// UG [0:0]
/// Update generation
UG: u1 = 0,
/// CC1G [1:1]
/// Capture/compare 1 generation
CC1G: u1 = 0,
/// CC2G [2:2]
/// Capture/compare 2 generation
CC2G: u1 = 0,
/// CC3G [3:3]
/// Capture/compare 3 generation
CC3G: u1 = 0,
/// CC4G [4:4]
/// Capture/compare 4 generation
CC4G: u1 = 0,
/// unused [5:5]
_unused5: u1 = 0,
/// TG [6:6]
/// Trigger generation
TG: u1 = 0,
/// unused [7:31]
_unused7: u1 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// event generation register
pub const EGR = Register(EGR_val).init(base_address + 0x14);
/// CCMR1_Output
const CCMR1_Output_val = packed struct {
/// CC1S [0:1]
/// Capture/Compare 1 selection
CC1S: u2 = 0,
/// OC1FE [2:2]
/// Output compare 1 fast enable
OC1FE: u1 = 0,
/// OC1PE [3:3]
/// Output compare 1 preload enable
OC1PE: u1 = 0,
/// OC1M [4:6]
/// Output compare 1 mode
OC1M: u3 = 0,
/// OC1CE [7:7]
/// Output compare 1 clear enable
OC1CE: u1 = 0,
/// CC2S [8:9]
/// Capture/Compare 2 selection
CC2S: u2 = 0,
/// OC2FE [10:10]
/// Output compare 2 fast enable
OC2FE: u1 = 0,
/// OC2PE [11:11]
/// Output compare 2 preload enable
OC2PE: u1 = 0,
/// OC2M [12:14]
/// Output compare 2 mode
OC2M: u3 = 0,
/// OC2CE [15:15]
/// Output compare 2 clear enable
OC2CE: u1 = 0,
/// OC1M_3 [16:16]
/// Output compare 1 mode bit 3
OC1M_3: u1 = 0,
/// unused [17:23]
_unused17: u7 = 0,
/// OC2M_3 [24:24]
/// Output compare 2 mode bit 3
OC2M_3: u1 = 0,
/// unused [25:31]
_unused25: u7 = 0,
};
/// capture/compare mode register 1 (output mode)
pub const CCMR1_Output = Register(CCMR1_Output_val).init(base_address + 0x18);
/// CCMR1_Input
const CCMR1_Input_val = packed struct {
/// CC1S [0:1]
/// Capture/Compare 1 selection
CC1S: u2 = 0,
/// IC1PSC [2:3]
/// Input capture 1 prescaler
IC1PSC: u2 = 0,
/// IC1F [4:7]
/// Input capture 1 filter
IC1F: u4 = 0,
/// CC2S [8:9]
/// Capture/compare 2 selection
CC2S: u2 = 0,
/// IC2PSC [10:11]
/// Input capture 2 prescaler
IC2PSC: u2 = 0,
/// IC2F [12:15]
/// Input capture 2 filter
IC2F: u4 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// capture/compare mode register 1 (input mode)
pub const CCMR1_Input = Register(CCMR1_Input_val).init(base_address + 0x18);
/// CCMR2_Output
const CCMR2_Output_val = packed struct {
/// CC3S [0:1]
/// Capture/Compare 3 selection
CC3S: u2 = 0,
/// OC3FE [2:2]
/// Output compare 3 fast enable
OC3FE: u1 = 0,
/// OC3PE [3:3]
/// Output compare 3 preload enable
OC3PE: u1 = 0,
/// OC3M [4:6]
/// Output compare 3 mode
OC3M: u3 = 0,
/// OC3CE [7:7]
/// Output compare 3 clear enable
OC3CE: u1 = 0,
/// CC4S [8:9]
/// Capture/Compare 4 selection
CC4S: u2 = 0,
/// OC4FE [10:10]
/// Output compare 4 fast enable
OC4FE: u1 = 0,
/// OC4PE [11:11]
/// Output compare 4 preload enable
OC4PE: u1 = 0,
/// OC4M [12:14]
/// Output compare 4 mode
OC4M: u3 = 0,
/// O24CE [15:15]
/// Output compare 4 clear enable
O24CE: u1 = 0,
/// OC3M_3 [16:16]
/// Output compare 3 mode bit3
OC3M_3: u1 = 0,
/// unused [17:23]
_unused17: u7 = 0,
/// OC4M_3 [24:24]
/// Output compare 4 mode bit3
OC4M_3: u1 = 0,
/// unused [25:31]
_unused25: u7 = 0,
};
/// capture/compare mode register 2 (output mode)
pub const CCMR2_Output = Register(CCMR2_Output_val).init(base_address + 0x1c);
/// CCMR2_Input
const CCMR2_Input_val = packed struct {
/// CC3S [0:1]
/// Capture/Compare 3 selection
CC3S: u2 = 0,
/// IC3PSC [2:3]
/// Input capture 3 prescaler
IC3PSC: u2 = 0,
/// IC3F [4:7]
/// Input capture 3 filter
IC3F: u4 = 0,
/// CC4S [8:9]
/// Capture/Compare 4 selection
CC4S: u2 = 0,
/// IC4PSC [10:11]
/// Input capture 4 prescaler
IC4PSC: u2 = 0,
/// IC4F [12:15]
/// Input capture 4 filter
IC4F: u4 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// capture/compare mode register 2 (input mode)
pub const CCMR2_Input = Register(CCMR2_Input_val).init(base_address + 0x1c);
/// CCER
const CCER_val = packed struct {
/// CC1E [0:0]
/// Capture/Compare 1 output enable
CC1E: u1 = 0,
/// CC1P [1:1]
/// Capture/Compare 1 output Polarity
CC1P: u1 = 0,
/// unused [2:2]
_unused2: u1 = 0,
/// CC1NP [3:3]
/// Capture/Compare 1 output Polarity
CC1NP: u1 = 0,
/// CC2E [4:4]
/// Capture/Compare 2 output enable
CC2E: u1 = 0,
/// CC2P [5:5]
/// Capture/Compare 2 output Polarity
CC2P: u1 = 0,
/// unused [6:6]
_unused6: u1 = 0,
/// CC2NP [7:7]
/// Capture/Compare 2 output Polarity
CC2NP: u1 = 0,
/// CC3E [8:8]
/// Capture/Compare 3 output enable
CC3E: u1 = 0,
/// CC3P [9:9]
/// Capture/Compare 3 output Polarity
CC3P: u1 = 0,
/// unused [10:10]
_unused10: u1 = 0,
/// CC3NP [11:11]
/// Capture/Compare 3 output Polarity
CC3NP: u1 = 0,
/// CC4E [12:12]
/// Capture/Compare 4 output enable
CC4E: u1 = 0,
/// CC4P [13:13]
/// Capture/Compare 3 output Polarity
CC4P: u1 = 0,
/// unused [14:14]
_unused14: u1 = 0,
/// CC4NP [15:15]
/// Capture/Compare 3 output Polarity
CC4NP: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// capture/compare enable register
pub const CCER = Register(CCER_val).init(base_address + 0x20);
/// CNT
const CNT_val = packed struct {
/// CNTL [0:15]
/// Low counter value
CNTL: u16 = 0,
/// CNTH [16:30]
/// High counter value
CNTH: u15 = 0,
/// CNT_or_UIFCPY [31:31]
/// if IUFREMAP=0 than CNT with read write access else UIFCPY with read only access
CNT_or_UIFCPY: u1 = 0,
};
/// counter
pub const CNT = Register(CNT_val).init(base_address + 0x24);
/// PSC
const PSC_val = packed struct {
/// PSC [0:15]
/// Prescaler value
PSC: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// prescaler
pub const PSC = Register(PSC_val).init(base_address + 0x28);
/// ARR
const ARR_val = packed struct {
/// ARRL [0:15]
/// Low Auto-reload value
ARRL: u16 = 0,
/// ARRH [16:31]
/// High Auto-reload value
ARRH: u16 = 0,
};
/// auto-reload register
pub const ARR = Register(ARR_val).init(base_address + 0x2c);
/// CCR1
const CCR1_val = packed struct {
/// CCR1L [0:15]
/// Low Capture/Compare 1 value
CCR1L: u16 = 0,
/// CCR1H [16:31]
/// High Capture/Compare 1 value (on TIM2)
CCR1H: u16 = 0,
};
/// capture/compare register 1
pub const CCR1 = Register(CCR1_val).init(base_address + 0x34);
/// CCR2
const CCR2_val = packed struct {
/// CCR2L [0:15]
/// Low Capture/Compare 2 value
CCR2L: u16 = 0,
/// CCR2H [16:31]
/// High Capture/Compare 2 value (on TIM2)
CCR2H: u16 = 0,
};
/// capture/compare register 2
pub const CCR2 = Register(CCR2_val).init(base_address + 0x38);
/// CCR3
const CCR3_val = packed struct {
/// CCR3L [0:15]
/// Low Capture/Compare value
CCR3L: u16 = 0,
/// CCR3H [16:31]
/// High Capture/Compare value (on TIM2)
CCR3H: u16 = 0,
};
/// capture/compare register 3
pub const CCR3 = Register(CCR3_val).init(base_address + 0x3c);
/// CCR4
const CCR4_val = packed struct {
/// CCR4L [0:15]
/// Low Capture/Compare value
CCR4L: u16 = 0,
/// CCR4H [16:31]
/// High Capture/Compare value (on TIM2)
CCR4H: u16 = 0,
};
/// capture/compare register 4
pub const CCR4 = Register(CCR4_val).init(base_address + 0x40);
/// DCR
const DCR_val = packed struct {
/// DBA [0:4]
/// DMA base address
DBA: u5 = 0,
/// unused [5:7]
_unused5: u3 = 0,
/// DBL [8:12]
/// DMA burst length
DBL: u5 = 0,
/// unused [13:31]
_unused13: u3 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA control register
pub const DCR = Register(DCR_val).init(base_address + 0x48);
/// DMAR
const DMAR_val = packed struct {
/// DMAB [0:15]
/// DMA register for burst accesses
DMAB: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA address for full transfer
pub const DMAR = Register(DMAR_val).init(base_address + 0x4c);
};
/// General purpose timer
pub const TIM3 = struct {
const base_address = 0x40000400;
/// CR1
const CR1_val = packed struct {
/// CEN [0:0]
/// Counter enable
CEN: u1 = 0,
/// UDIS [1:1]
/// Update disable
UDIS: u1 = 0,
/// URS [2:2]
/// Update request source
URS: u1 = 0,
/// OPM [3:3]
/// One-pulse mode
OPM: u1 = 0,
/// DIR [4:4]
/// Direction
DIR: u1 = 0,
/// CMS [5:6]
/// Center-aligned mode selection
CMS: u2 = 0,
/// ARPE [7:7]
/// Auto-reload preload enable
ARPE: u1 = 0,
/// CKD [8:9]
/// Clock division
CKD: u2 = 0,
/// unused [10:10]
_unused10: u1 = 0,
/// UIFREMAP [11:11]
/// UIF status bit remapping
UIFREMAP: u1 = 0,
/// unused [12:31]
_unused12: u4 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// control register 1
pub const CR1 = Register(CR1_val).init(base_address + 0x0);
/// CR2
const CR2_val = packed struct {
/// unused [0:2]
_unused0: u3 = 0,
/// CCDS [3:3]
/// Capture/compare DMA selection
CCDS: u1 = 0,
/// MMS [4:6]
/// Master mode selection
MMS: u3 = 0,
/// TI1S [7:7]
/// TI1 selection
TI1S: u1 = 0,
/// unused [8:31]
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// control register 2
pub const CR2 = Register(CR2_val).init(base_address + 0x4);
/// SMCR
const SMCR_val = packed struct {
/// SMS [0:2]
/// Slave mode selection
SMS: u3 = 0,
/// OCCS [3:3]
/// OCREF clear selection
OCCS: u1 = 0,
/// TS [4:6]
/// Trigger selection
TS: u3 = 0,
/// MSM [7:7]
/// Master/Slave mode
MSM: u1 = 0,
/// ETF [8:11]
/// External trigger filter
ETF: u4 = 0,
/// ETPS [12:13]
/// External trigger prescaler
ETPS: u2 = 0,
/// ECE [14:14]
/// External clock enable
ECE: u1 = 0,
/// ETP [15:15]
/// External trigger polarity
ETP: u1 = 0,
/// SMS_3 [16:16]
/// Slave mode selection bit3
SMS_3: u1 = 0,
/// unused [17:31]
_unused17: u7 = 0,
_unused24: u8 = 0,
};
/// slave mode control register
pub const SMCR = Register(SMCR_val).init(base_address + 0x8);
/// DIER
const DIER_val = packed struct {
/// UIE [0:0]
/// Update interrupt enable
UIE: u1 = 0,
/// CC1IE [1:1]
/// Capture/Compare 1 interrupt enable
CC1IE: u1 = 0,
/// CC2IE [2:2]
/// Capture/Compare 2 interrupt enable
CC2IE: u1 = 0,
/// CC3IE [3:3]
/// Capture/Compare 3 interrupt enable
CC3IE: u1 = 0,
/// CC4IE [4:4]
/// Capture/Compare 4 interrupt enable
CC4IE: u1 = 0,
/// unused [5:5]
_unused5: u1 = 0,
/// TIE [6:6]
/// Trigger interrupt enable
TIE: u1 = 0,
/// unused [7:7]
_unused7: u1 = 0,
/// UDE [8:8]
/// Update DMA request enable
UDE: u1 = 0,
/// CC1DE [9:9]
/// Capture/Compare 1 DMA request enable
CC1DE: u1 = 0,
/// CC2DE [10:10]
/// Capture/Compare 2 DMA request enable
CC2DE: u1 = 0,
/// CC3DE [11:11]
/// Capture/Compare 3 DMA request enable
CC3DE: u1 = 0,
/// CC4DE [12:12]
/// Capture/Compare 4 DMA request enable
CC4DE: u1 = 0,
/// unused [13:13]
_unused13: u1 = 0,
/// TDE [14:14]
/// Trigger DMA request enable
TDE: u1 = 0,
/// unused [15:31]
_unused15: u1 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA/Interrupt enable register
pub const DIER = Register(DIER_val).init(base_address + 0xc);
/// SR
const SR_val = packed struct {
/// UIF [0:0]
/// Update interrupt flag
UIF: u1 = 0,
/// CC1IF [1:1]
/// Capture/compare 1 interrupt flag
CC1IF: u1 = 0,
/// CC2IF [2:2]
/// Capture/Compare 2 interrupt flag
CC2IF: u1 = 0,
/// CC3IF [3:3]
/// Capture/Compare 3 interrupt flag
CC3IF: u1 = 0,
/// CC4IF [4:4]
/// Capture/Compare 4 interrupt flag
CC4IF: u1 = 0,
/// unused [5:5]
_unused5: u1 = 0,
/// TIF [6:6]
/// Trigger interrupt flag
TIF: u1 = 0,
/// unused [7:8]
_unused7: u1 = 0,
_unused8: u1 = 0,
/// CC1OF [9:9]
/// Capture/Compare 1 overcapture flag
CC1OF: u1 = 0,
/// CC2OF [10:10]
/// Capture/compare 2 overcapture flag
CC2OF: u1 = 0,
/// CC3OF [11:11]
/// Capture/Compare 3 overcapture flag
CC3OF: u1 = 0,
/// CC4OF [12:12]
/// Capture/Compare 4 overcapture flag
CC4OF: u1 = 0,
/// unused [13:31]
_unused13: u3 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// status register
pub const SR = Register(SR_val).init(base_address + 0x10);
/// EGR
const EGR_val = packed struct {
/// UG [0:0]
/// Update generation
UG: u1 = 0,
/// CC1G [1:1]
/// Capture/compare 1 generation
CC1G: u1 = 0,
/// CC2G [2:2]
/// Capture/compare 2 generation
CC2G: u1 = 0,
/// CC3G [3:3]
/// Capture/compare 3 generation
CC3G: u1 = 0,
/// CC4G [4:4]
/// Capture/compare 4 generation
CC4G: u1 = 0,
/// unused [5:5]
_unused5: u1 = 0,
/// TG [6:6]
/// Trigger generation
TG: u1 = 0,
/// unused [7:31]
_unused7: u1 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// event generation register
pub const EGR = Register(EGR_val).init(base_address + 0x14);
/// CCMR1_Output
const CCMR1_Output_val = packed struct {
/// CC1S [0:1]
/// Capture/Compare 1 selection
CC1S: u2 = 0,
/// OC1FE [2:2]
/// Output compare 1 fast enable
OC1FE: u1 = 0,
/// OC1PE [3:3]
/// Output compare 1 preload enable
OC1PE: u1 = 0,
/// OC1M [4:6]
/// Output compare 1 mode
OC1M: u3 = 0,
/// OC1CE [7:7]
/// Output compare 1 clear enable
OC1CE: u1 = 0,
/// CC2S [8:9]
/// Capture/Compare 2 selection
CC2S: u2 = 0,
/// OC2FE [10:10]
/// Output compare 2 fast enable
OC2FE: u1 = 0,
/// OC2PE [11:11]
/// Output compare 2 preload enable
OC2PE: u1 = 0,
/// OC2M [12:14]
/// Output compare 2 mode
OC2M: u3 = 0,
/// OC2CE [15:15]
/// Output compare 2 clear enable
OC2CE: u1 = 0,
/// OC1M_3 [16:16]
/// Output compare 1 mode bit 3
OC1M_3: u1 = 0,
/// unused [17:23]
_unused17: u7 = 0,
/// OC2M_3 [24:24]
/// Output compare 2 mode bit 3
OC2M_3: u1 = 0,
/// unused [25:31]
_unused25: u7 = 0,
};
/// capture/compare mode register 1 (output mode)
pub const CCMR1_Output = Register(CCMR1_Output_val).init(base_address + 0x18);
/// CCMR1_Input
const CCMR1_Input_val = packed struct {
/// CC1S [0:1]
/// Capture/Compare 1 selection
CC1S: u2 = 0,
/// IC1PSC [2:3]
/// Input capture 1 prescaler
IC1PSC: u2 = 0,
/// IC1F [4:7]
/// Input capture 1 filter
IC1F: u4 = 0,
/// CC2S [8:9]
/// Capture/compare 2 selection
CC2S: u2 = 0,
/// IC2PSC [10:11]
/// Input capture 2 prescaler
IC2PSC: u2 = 0,
/// IC2F [12:15]
/// Input capture 2 filter
IC2F: u4 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// capture/compare mode register 1 (input mode)
pub const CCMR1_Input = Register(CCMR1_Input_val).init(base_address + 0x18);
/// CCMR2_Output
const CCMR2_Output_val = packed struct {
/// CC3S [0:1]
/// Capture/Compare 3 selection
CC3S: u2 = 0,
/// OC3FE [2:2]
/// Output compare 3 fast enable
OC3FE: u1 = 0,
/// OC3PE [3:3]
/// Output compare 3 preload enable
OC3PE: u1 = 0,
/// OC3M [4:6]
/// Output compare 3 mode
OC3M: u3 = 0,
/// OC3CE [7:7]
/// Output compare 3 clear enable
OC3CE: u1 = 0,
/// CC4S [8:9]
/// Capture/Compare 4 selection
CC4S: u2 = 0,
/// OC4FE [10:10]
/// Output compare 4 fast enable
OC4FE: u1 = 0,
/// OC4PE [11:11]
/// Output compare 4 preload enable
OC4PE: u1 = 0,
/// OC4M [12:14]
/// Output compare 4 mode
OC4M: u3 = 0,
/// O24CE [15:15]
/// Output compare 4 clear enable
O24CE: u1 = 0,
/// OC3M_3 [16:16]
/// Output compare 3 mode bit3
OC3M_3: u1 = 0,
/// unused [17:23]
_unused17: u7 = 0,
/// OC4M_3 [24:24]
/// Output compare 4 mode bit3
OC4M_3: u1 = 0,
/// unused [25:31]
_unused25: u7 = 0,
};
/// capture/compare mode register 2 (output mode)
pub const CCMR2_Output = Register(CCMR2_Output_val).init(base_address + 0x1c);
/// CCMR2_Input
const CCMR2_Input_val = packed struct {
/// CC3S [0:1]
/// Capture/Compare 3 selection
CC3S: u2 = 0,
/// IC3PSC [2:3]
/// Input capture 3 prescaler
IC3PSC: u2 = 0,
/// IC3F [4:7]
/// Input capture 3 filter
IC3F: u4 = 0,
/// CC4S [8:9]
/// Capture/Compare 4 selection
CC4S: u2 = 0,
/// IC4PSC [10:11]
/// Input capture 4 prescaler
IC4PSC: u2 = 0,
/// IC4F [12:15]
/// Input capture 4 filter
IC4F: u4 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// capture/compare mode register 2 (input mode)
pub const CCMR2_Input = Register(CCMR2_Input_val).init(base_address + 0x1c);
/// CCER
const CCER_val = packed struct {
/// CC1E [0:0]
/// Capture/Compare 1 output enable
CC1E: u1 = 0,
/// CC1P [1:1]
/// Capture/Compare 1 output Polarity
CC1P: u1 = 0,
/// unused [2:2]
_unused2: u1 = 0,
/// CC1NP [3:3]
/// Capture/Compare 1 output Polarity
CC1NP: u1 = 0,
/// CC2E [4:4]
/// Capture/Compare 2 output enable
CC2E: u1 = 0,
/// CC2P [5:5]
/// Capture/Compare 2 output Polarity
CC2P: u1 = 0,
/// unused [6:6]
_unused6: u1 = 0,
/// CC2NP [7:7]
/// Capture/Compare 2 output Polarity
CC2NP: u1 = 0,
/// CC3E [8:8]
/// Capture/Compare 3 output enable
CC3E: u1 = 0,
/// CC3P [9:9]
/// Capture/Compare 3 output Polarity
CC3P: u1 = 0,
/// unused [10:10]
_unused10: u1 = 0,
/// CC3NP [11:11]
/// Capture/Compare 3 output Polarity
CC3NP: u1 = 0,
/// CC4E [12:12]
/// Capture/Compare 4 output enable
CC4E: u1 = 0,
/// CC4P [13:13]
/// Capture/Compare 3 output Polarity
CC4P: u1 = 0,
/// unused [14:14]
_unused14: u1 = 0,
/// CC4NP [15:15]
/// Capture/Compare 3 output Polarity
CC4NP: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// capture/compare enable register
pub const CCER = Register(CCER_val).init(base_address + 0x20);
/// CNT
const CNT_val = packed struct {
/// CNTL [0:15]
/// Low counter value
CNTL: u16 = 0,
/// CNTH [16:30]
/// High counter value
CNTH: u15 = 0,
/// CNT_or_UIFCPY [31:31]
/// if IUFREMAP=0 than CNT with read write access else UIFCPY with read only access
CNT_or_UIFCPY: u1 = 0,
};
/// counter
pub const CNT = Register(CNT_val).init(base_address + 0x24);
/// PSC
const PSC_val = packed struct {
/// PSC [0:15]
/// Prescaler value
PSC: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// prescaler
pub const PSC = Register(PSC_val).init(base_address + 0x28);
/// ARR
const ARR_val = packed struct {
/// ARRL [0:15]
/// Low Auto-reload value
ARRL: u16 = 0,
/// ARRH [16:31]
/// High Auto-reload value
ARRH: u16 = 0,
};
/// auto-reload register
pub const ARR = Register(ARR_val).init(base_address + 0x2c);
/// CCR1
const CCR1_val = packed struct {
/// CCR1L [0:15]
/// Low Capture/Compare 1 value
CCR1L: u16 = 0,
/// CCR1H [16:31]
/// High Capture/Compare 1 value (on TIM2)
CCR1H: u16 = 0,
};
/// capture/compare register 1
pub const CCR1 = Register(CCR1_val).init(base_address + 0x34);
/// CCR2
const CCR2_val = packed struct {
/// CCR2L [0:15]
/// Low Capture/Compare 2 value
CCR2L: u16 = 0,
/// CCR2H [16:31]
/// High Capture/Compare 2 value (on TIM2)
CCR2H: u16 = 0,
};
/// capture/compare register 2
pub const CCR2 = Register(CCR2_val).init(base_address + 0x38);
/// CCR3
const CCR3_val = packed struct {
/// CCR3L [0:15]
/// Low Capture/Compare value
CCR3L: u16 = 0,
/// CCR3H [16:31]
/// High Capture/Compare value (on TIM2)
CCR3H: u16 = 0,
};
/// capture/compare register 3
pub const CCR3 = Register(CCR3_val).init(base_address + 0x3c);
/// CCR4
const CCR4_val = packed struct {
/// CCR4L [0:15]
/// Low Capture/Compare value
CCR4L: u16 = 0,
/// CCR4H [16:31]
/// High Capture/Compare value (on TIM2)
CCR4H: u16 = 0,
};
/// capture/compare register 4
pub const CCR4 = Register(CCR4_val).init(base_address + 0x40);
/// DCR
const DCR_val = packed struct {
/// DBA [0:4]
/// DMA base address
DBA: u5 = 0,
/// unused [5:7]
_unused5: u3 = 0,
/// DBL [8:12]
/// DMA burst length
DBL: u5 = 0,
/// unused [13:31]
_unused13: u3 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA control register
pub const DCR = Register(DCR_val).init(base_address + 0x48);
/// DMAR
const DMAR_val = packed struct {
/// DMAB [0:15]
/// DMA register for burst accesses
DMAB: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA address for full transfer
pub const DMAR = Register(DMAR_val).init(base_address + 0x4c);
};
/// General purpose timer
pub const TIM4 = struct {
const base_address = 0x40000800;
/// CR1
const CR1_val = packed struct {
/// CEN [0:0]
/// Counter enable
CEN: u1 = 0,
/// UDIS [1:1]
/// Update disable
UDIS: u1 = 0,
/// URS [2:2]
/// Update request source
URS: u1 = 0,
/// OPM [3:3]
/// One-pulse mode
OPM: u1 = 0,
/// DIR [4:4]
/// Direction
DIR: u1 = 0,
/// CMS [5:6]
/// Center-aligned mode selection
CMS: u2 = 0,
/// ARPE [7:7]
/// Auto-reload preload enable
ARPE: u1 = 0,
/// CKD [8:9]
/// Clock division
CKD: u2 = 0,
/// unused [10:10]
_unused10: u1 = 0,
/// UIFREMAP [11:11]
/// UIF status bit remapping
UIFREMAP: u1 = 0,
/// unused [12:31]
_unused12: u4 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// control register 1
pub const CR1 = Register(CR1_val).init(base_address + 0x0);
/// CR2
const CR2_val = packed struct {
/// unused [0:2]
_unused0: u3 = 0,
/// CCDS [3:3]
/// Capture/compare DMA selection
CCDS: u1 = 0,
/// MMS [4:6]
/// Master mode selection
MMS: u3 = 0,
/// TI1S [7:7]
/// TI1 selection
TI1S: u1 = 0,
/// unused [8:31]
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// control register 2
pub const CR2 = Register(CR2_val).init(base_address + 0x4);
/// SMCR
const SMCR_val = packed struct {
/// SMS [0:2]
/// Slave mode selection
SMS: u3 = 0,
/// OCCS [3:3]
/// OCREF clear selection
OCCS: u1 = 0,
/// TS [4:6]
/// Trigger selection
TS: u3 = 0,
/// MSM [7:7]
/// Master/Slave mode
MSM: u1 = 0,
/// ETF [8:11]
/// External trigger filter
ETF: u4 = 0,
/// ETPS [12:13]
/// External trigger prescaler
ETPS: u2 = 0,
/// ECE [14:14]
/// External clock enable
ECE: u1 = 0,
/// ETP [15:15]
/// External trigger polarity
ETP: u1 = 0,
/// SMS_3 [16:16]
/// Slave mode selection bit3
SMS_3: u1 = 0,
/// unused [17:31]
_unused17: u7 = 0,
_unused24: u8 = 0,
};
/// slave mode control register
pub const SMCR = Register(SMCR_val).init(base_address + 0x8);
/// DIER
const DIER_val = packed struct {
/// UIE [0:0]
/// Update interrupt enable
UIE: u1 = 0,
/// CC1IE [1:1]
/// Capture/Compare 1 interrupt enable
CC1IE: u1 = 0,
/// CC2IE [2:2]
/// Capture/Compare 2 interrupt enable
CC2IE: u1 = 0,
/// CC3IE [3:3]
/// Capture/Compare 3 interrupt enable
CC3IE: u1 = 0,
/// CC4IE [4:4]
/// Capture/Compare 4 interrupt enable
CC4IE: u1 = 0,
/// unused [5:5]
_unused5: u1 = 0,
/// TIE [6:6]
/// Trigger interrupt enable
TIE: u1 = 0,
/// unused [7:7]
_unused7: u1 = 0,
/// UDE [8:8]
/// Update DMA request enable
UDE: u1 = 0,
/// CC1DE [9:9]
/// Capture/Compare 1 DMA request enable
CC1DE: u1 = 0,
/// CC2DE [10:10]
/// Capture/Compare 2 DMA request enable
CC2DE: u1 = 0,
/// CC3DE [11:11]
/// Capture/Compare 3 DMA request enable
CC3DE: u1 = 0,
/// CC4DE [12:12]
/// Capture/Compare 4 DMA request enable
CC4DE: u1 = 0,
/// unused [13:13]
_unused13: u1 = 0,
/// TDE [14:14]
/// Trigger DMA request enable
TDE: u1 = 0,
/// unused [15:31]
_unused15: u1 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA/Interrupt enable register
pub const DIER = Register(DIER_val).init(base_address + 0xc);
/// SR
const SR_val = packed struct {
/// UIF [0:0]
/// Update interrupt flag
UIF: u1 = 0,
/// CC1IF [1:1]
/// Capture/compare 1 interrupt flag
CC1IF: u1 = 0,
/// CC2IF [2:2]
/// Capture/Compare 2 interrupt flag
CC2IF: u1 = 0,
/// CC3IF [3:3]
/// Capture/Compare 3 interrupt flag
CC3IF: u1 = 0,
/// CC4IF [4:4]
/// Capture/Compare 4 interrupt flag
CC4IF: u1 = 0,
/// unused [5:5]
_unused5: u1 = 0,
/// TIF [6:6]
/// Trigger interrupt flag
TIF: u1 = 0,
/// unused [7:8]
_unused7: u1 = 0,
_unused8: u1 = 0,
/// CC1OF [9:9]
/// Capture/Compare 1 overcapture flag
CC1OF: u1 = 0,
/// CC2OF [10:10]
/// Capture/compare 2 overcapture flag
CC2OF: u1 = 0,
/// CC3OF [11:11]
/// Capture/Compare 3 overcapture flag
CC3OF: u1 = 0,
/// CC4OF [12:12]
/// Capture/Compare 4 overcapture flag
CC4OF: u1 = 0,
/// unused [13:31]
_unused13: u3 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// status register
pub const SR = Register(SR_val).init(base_address + 0x10);
/// EGR
const EGR_val = packed struct {
/// UG [0:0]
/// Update generation
UG: u1 = 0,
/// CC1G [1:1]
/// Capture/compare 1 generation
CC1G: u1 = 0,
/// CC2G [2:2]
/// Capture/compare 2 generation
CC2G: u1 = 0,
/// CC3G [3:3]
/// Capture/compare 3 generation
CC3G: u1 = 0,
/// CC4G [4:4]
/// Capture/compare 4 generation
CC4G: u1 = 0,
/// unused [5:5]
_unused5: u1 = 0,
/// TG [6:6]
/// Trigger generation
TG: u1 = 0,
/// unused [7:31]
_unused7: u1 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// event generation register
pub const EGR = Register(EGR_val).init(base_address + 0x14);
/// CCMR1_Output
const CCMR1_Output_val = packed struct {
/// CC1S [0:1]
/// Capture/Compare 1 selection
CC1S: u2 = 0,
/// OC1FE [2:2]
/// Output compare 1 fast enable
OC1FE: u1 = 0,
/// OC1PE [3:3]
/// Output compare 1 preload enable
OC1PE: u1 = 0,
/// OC1M [4:6]
/// Output compare 1 mode
OC1M: u3 = 0,
/// OC1CE [7:7]
/// Output compare 1 clear enable
OC1CE: u1 = 0,
/// CC2S [8:9]
/// Capture/Compare 2 selection
CC2S: u2 = 0,
/// OC2FE [10:10]
/// Output compare 2 fast enable
OC2FE: u1 = 0,
/// OC2PE [11:11]
/// Output compare 2 preload enable
OC2PE: u1 = 0,
/// OC2M [12:14]
/// Output compare 2 mode
OC2M: u3 = 0,
/// OC2CE [15:15]
/// Output compare 2 clear enable
OC2CE: u1 = 0,
/// OC1M_3 [16:16]
/// Output compare 1 mode bit 3
OC1M_3: u1 = 0,
/// unused [17:23]
_unused17: u7 = 0,
/// OC2M_3 [24:24]
/// Output compare 2 mode bit 3
OC2M_3: u1 = 0,
/// unused [25:31]
_unused25: u7 = 0,
};
/// capture/compare mode register 1 (output mode)
pub const CCMR1_Output = Register(CCMR1_Output_val).init(base_address + 0x18);
/// CCMR1_Input
const CCMR1_Input_val = packed struct {
/// CC1S [0:1]
/// Capture/Compare 1 selection
CC1S: u2 = 0,
/// IC1PSC [2:3]
/// Input capture 1 prescaler
IC1PSC: u2 = 0,
/// IC1F [4:7]
/// Input capture 1 filter
IC1F: u4 = 0,
/// CC2S [8:9]
/// Capture/compare 2 selection
CC2S: u2 = 0,
/// IC2PSC [10:11]
/// Input capture 2 prescaler
IC2PSC: u2 = 0,
/// IC2F [12:15]
/// Input capture 2 filter
IC2F: u4 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// capture/compare mode register 1 (input mode)
pub const CCMR1_Input = Register(CCMR1_Input_val).init(base_address + 0x18);
/// CCMR2_Output
const CCMR2_Output_val = packed struct {
/// CC3S [0:1]
/// Capture/Compare 3 selection
CC3S: u2 = 0,
/// OC3FE [2:2]
/// Output compare 3 fast enable
OC3FE: u1 = 0,
/// OC3PE [3:3]
/// Output compare 3 preload enable
OC3PE: u1 = 0,
/// OC3M [4:6]
/// Output compare 3 mode
OC3M: u3 = 0,
/// OC3CE [7:7]
/// Output compare 3 clear enable
OC3CE: u1 = 0,
/// CC4S [8:9]
/// Capture/Compare 4 selection
CC4S: u2 = 0,
/// OC4FE [10:10]
/// Output compare 4 fast enable
OC4FE: u1 = 0,
/// OC4PE [11:11]
/// Output compare 4 preload enable
OC4PE: u1 = 0,
/// OC4M [12:14]
/// Output compare 4 mode
OC4M: u3 = 0,
/// O24CE [15:15]
/// Output compare 4 clear enable
O24CE: u1 = 0,
/// OC3M_3 [16:16]
/// Output compare 3 mode bit3
OC3M_3: u1 = 0,
/// unused [17:23]
_unused17: u7 = 0,
/// OC4M_3 [24:24]
/// Output compare 4 mode bit3
OC4M_3: u1 = 0,
/// unused [25:31]
_unused25: u7 = 0,
};
/// capture/compare mode register 2 (output mode)
pub const CCMR2_Output = Register(CCMR2_Output_val).init(base_address + 0x1c);
/// CCMR2_Input
const CCMR2_Input_val = packed struct {
/// CC3S [0:1]
/// Capture/Compare 3 selection
CC3S: u2 = 0,
/// IC3PSC [2:3]
/// Input capture 3 prescaler
IC3PSC: u2 = 0,
/// IC3F [4:7]
/// Input capture 3 filter
IC3F: u4 = 0,
/// CC4S [8:9]
/// Capture/Compare 4 selection
CC4S: u2 = 0,
/// IC4PSC [10:11]
/// Input capture 4 prescaler
IC4PSC: u2 = 0,
/// IC4F [12:15]
/// Input capture 4 filter
IC4F: u4 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// capture/compare mode register 2 (input mode)
pub const CCMR2_Input = Register(CCMR2_Input_val).init(base_address + 0x1c);
/// CCER
const CCER_val = packed struct {
/// CC1E [0:0]
/// Capture/Compare 1 output enable
CC1E: u1 = 0,
/// CC1P [1:1]
/// Capture/Compare 1 output Polarity
CC1P: u1 = 0,
/// unused [2:2]
_unused2: u1 = 0,
/// CC1NP [3:3]
/// Capture/Compare 1 output Polarity
CC1NP: u1 = 0,
/// CC2E [4:4]
/// Capture/Compare 2 output enable
CC2E: u1 = 0,
/// CC2P [5:5]
/// Capture/Compare 2 output Polarity
CC2P: u1 = 0,
/// unused [6:6]
_unused6: u1 = 0,
/// CC2NP [7:7]
/// Capture/Compare 2 output Polarity
CC2NP: u1 = 0,
/// CC3E [8:8]
/// Capture/Compare 3 output enable
CC3E: u1 = 0,
/// CC3P [9:9]
/// Capture/Compare 3 output Polarity
CC3P: u1 = 0,
/// unused [10:10]
_unused10: u1 = 0,
/// CC3NP [11:11]
/// Capture/Compare 3 output Polarity
CC3NP: u1 = 0,
/// CC4E [12:12]
/// Capture/Compare 4 output enable
CC4E: u1 = 0,
/// CC4P [13:13]
/// Capture/Compare 3 output Polarity
CC4P: u1 = 0,
/// unused [14:14]
_unused14: u1 = 0,
/// CC4NP [15:15]
/// Capture/Compare 3 output Polarity
CC4NP: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// capture/compare enable register
pub const CCER = Register(CCER_val).init(base_address + 0x20);
/// CNT
const CNT_val = packed struct {
/// CNTL [0:15]
/// Low counter value
CNTL: u16 = 0,
/// CNTH [16:30]
/// High counter value
CNTH: u15 = 0,
/// CNT_or_UIFCPY [31:31]
/// if IUFREMAP=0 than CNT with read write access else UIFCPY with read only access
CNT_or_UIFCPY: u1 = 0,
};
/// counter
pub const CNT = Register(CNT_val).init(base_address + 0x24);
/// PSC
const PSC_val = packed struct {
/// PSC [0:15]
/// Prescaler value
PSC: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// prescaler
pub const PSC = Register(PSC_val).init(base_address + 0x28);
/// ARR
const ARR_val = packed struct {
/// ARRL [0:15]
/// Low Auto-reload value
ARRL: u16 = 0,
/// ARRH [16:31]
/// High Auto-reload value
ARRH: u16 = 0,
};
/// auto-reload register
pub const ARR = Register(ARR_val).init(base_address + 0x2c);
/// CCR1
const CCR1_val = packed struct {
/// CCR1L [0:15]
/// Low Capture/Compare 1 value
CCR1L: u16 = 0,
/// CCR1H [16:31]
/// High Capture/Compare 1 value (on TIM2)
CCR1H: u16 = 0,
};
/// capture/compare register 1
pub const CCR1 = Register(CCR1_val).init(base_address + 0x34);
/// CCR2
const CCR2_val = packed struct {
/// CCR2L [0:15]
/// Low Capture/Compare 2 value
CCR2L: u16 = 0,
/// CCR2H [16:31]
/// High Capture/Compare 2 value (on TIM2)
CCR2H: u16 = 0,
};
/// capture/compare register 2
pub const CCR2 = Register(CCR2_val).init(base_address + 0x38);
/// CCR3
const CCR3_val = packed struct {
/// CCR3L [0:15]
/// Low Capture/Compare value
CCR3L: u16 = 0,
/// CCR3H [16:31]
/// High Capture/Compare value (on TIM2)
CCR3H: u16 = 0,
};
/// capture/compare register 3
pub const CCR3 = Register(CCR3_val).init(base_address + 0x3c);
/// CCR4
const CCR4_val = packed struct {
/// CCR4L [0:15]
/// Low Capture/Compare value
CCR4L: u16 = 0,
/// CCR4H [16:31]
/// High Capture/Compare value (on TIM2)
CCR4H: u16 = 0,
};
/// capture/compare register 4
pub const CCR4 = Register(CCR4_val).init(base_address + 0x40);
/// DCR
const DCR_val = packed struct {
/// DBA [0:4]
/// DMA base address
DBA: u5 = 0,
/// unused [5:7]
_unused5: u3 = 0,
/// DBL [8:12]
/// DMA burst length
DBL: u5 = 0,
/// unused [13:31]
_unused13: u3 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA control register
pub const DCR = Register(DCR_val).init(base_address + 0x48);
/// DMAR
const DMAR_val = packed struct {
/// DMAB [0:15]
/// DMA register for burst accesses
DMAB: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA address for full transfer
pub const DMAR = Register(DMAR_val).init(base_address + 0x4c);
};
/// General purpose timers
pub const TIM15 = struct {
const base_address = 0x40014000;
/// CR1
const CR1_val = packed struct {
/// CEN [0:0]
/// Counter enable
CEN: u1 = 0,
/// UDIS [1:1]
/// Update disable
UDIS: u1 = 0,
/// URS [2:2]
/// Update request source
URS: u1 = 0,
/// OPM [3:3]
/// One-pulse mode
OPM: u1 = 0,
/// unused [4:6]
_unused4: u3 = 0,
/// ARPE [7:7]
/// Auto-reload preload enable
ARPE: u1 = 0,
/// CKD [8:9]
/// Clock division
CKD: u2 = 0,
/// unused [10:10]
_unused10: u1 = 0,
/// UIFREMAP [11:11]
/// UIF status bit remapping
UIFREMAP: u1 = 0,
/// unused [12:31]
_unused12: u4 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// control register 1
pub const CR1 = Register(CR1_val).init(base_address + 0x0);
/// CR2
const CR2_val = packed struct {
/// CCPC [0:0]
/// Capture/compare preloaded control
CCPC: u1 = 0,
/// unused [1:1]
_unused1: u1 = 0,
/// CCUS [2:2]
/// Capture/compare control update selection
CCUS: u1 = 0,
/// CCDS [3:3]
/// Capture/compare DMA selection
CCDS: u1 = 0,
/// MMS [4:6]
/// Master mode selection
MMS: u3 = 0,
/// TI1S [7:7]
/// TI1 selection
TI1S: u1 = 0,
/// OIS1 [8:8]
/// Output Idle state 1
OIS1: u1 = 0,
/// OIS1N [9:9]
/// Output Idle state 1
OIS1N: u1 = 0,
/// OIS2 [10:10]
/// Output Idle state 2
OIS2: u1 = 0,
/// unused [11:31]
_unused11: u5 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// control register 2
pub const CR2 = Register(CR2_val).init(base_address + 0x4);
/// SMCR
const SMCR_val = packed struct {
/// SMS [0:2]
/// Slave mode selection
SMS: u3 = 0,
/// unused [3:3]
_unused3: u1 = 0,
/// TS [4:6]
/// Trigger selection
TS: u3 = 0,
/// MSM [7:7]
/// Master/Slave mode
MSM: u1 = 0,
/// unused [8:15]
_unused8: u8 = 0,
/// SMS_3 [16:16]
/// Slave mode selection bit 3
SMS_3: u1 = 0,
/// unused [17:31]
_unused17: u7 = 0,
_unused24: u8 = 0,
};
/// slave mode control register
pub const SMCR = Register(SMCR_val).init(base_address + 0x8);
/// DIER
const DIER_val = packed struct {
/// UIE [0:0]
/// Update interrupt enable
UIE: u1 = 0,
/// CC1IE [1:1]
/// Capture/Compare 1 interrupt enable
CC1IE: u1 = 0,
/// CC2IE [2:2]
/// Capture/Compare 2 interrupt enable
CC2IE: u1 = 0,
/// unused [3:4]
_unused3: u2 = 0,
/// COMIE [5:5]
/// COM interrupt enable
COMIE: u1 = 0,
/// TIE [6:6]
/// Trigger interrupt enable
TIE: u1 = 0,
/// BIE [7:7]
/// Break interrupt enable
BIE: u1 = 0,
/// UDE [8:8]
/// Update DMA request enable
UDE: u1 = 0,
/// CC1DE [9:9]
/// Capture/Compare 1 DMA request enable
CC1DE: u1 = 0,
/// CC2DE [10:10]
/// Capture/Compare 2 DMA request enable
CC2DE: u1 = 0,
/// unused [11:12]
_unused11: u2 = 0,
/// COMDE [13:13]
/// COM DMA request enable
COMDE: u1 = 0,
/// TDE [14:14]
/// Trigger DMA request enable
TDE: u1 = 0,
/// unused [15:31]
_unused15: u1 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA/Interrupt enable register
pub const DIER = Register(DIER_val).init(base_address + 0xc);
/// SR
const SR_val = packed struct {
/// UIF [0:0]
/// Update interrupt flag
UIF: u1 = 0,
/// CC1IF [1:1]
/// Capture/compare 1 interrupt flag
CC1IF: u1 = 0,
/// CC2IF [2:2]
/// Capture/Compare 2 interrupt flag
CC2IF: u1 = 0,
/// unused [3:4]
_unused3: u2 = 0,
/// COMIF [5:5]
/// COM interrupt flag
COMIF: u1 = 0,
/// TIF [6:6]
/// Trigger interrupt flag
TIF: u1 = 0,
/// BIF [7:7]
/// Break interrupt flag
BIF: u1 = 0,
/// unused [8:8]
_unused8: u1 = 0,
/// CC1OF [9:9]
/// Capture/Compare 1 overcapture flag
CC1OF: u1 = 0,
/// CC2OF [10:10]
/// Capture/compare 2 overcapture flag
CC2OF: u1 = 0,
/// unused [11:31]
_unused11: u5 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// status register
pub const SR = Register(SR_val).init(base_address + 0x10);
/// EGR
const EGR_val = packed struct {
/// UG [0:0]
/// Update generation
UG: u1 = 0,
/// CC1G [1:1]
/// Capture/compare 1 generation
CC1G: u1 = 0,
/// CC2G [2:2]
/// Capture/compare 2 generation
CC2G: u1 = 0,
/// unused [3:4]
_unused3: u2 = 0,
/// COMG [5:5]
/// Capture/Compare control update generation
COMG: u1 = 0,
/// TG [6:6]
/// Trigger generation
TG: u1 = 0,
/// BG [7:7]
/// Break generation
BG: u1 = 0,
/// unused [8:31]
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// event generation register
pub const EGR = Register(EGR_val).init(base_address + 0x14);
/// CCMR1_Output
const CCMR1_Output_val = packed struct {
/// CC1S [0:1]
/// Capture/Compare 1 selection
CC1S: u2 = 0,
/// OC1FE [2:2]
/// Output Compare 1 fast enable
OC1FE: u1 = 0,
/// OC1PE [3:3]
/// Output Compare 1 preload enable
OC1PE: u1 = 0,
/// OC1M [4:6]
/// Output Compare 1 mode
OC1M: u3 = 0,
/// unused [7:7]
_unused7: u1 = 0,
/// CC2S [8:9]
/// Capture/Compare 2 selection
CC2S: u2 = 0,
/// OC2FE [10:10]
/// Output Compare 2 fast enable
OC2FE: u1 = 0,
/// OC2PE [11:11]
/// Output Compare 2 preload enable
OC2PE: u1 = 0,
/// OC2M [12:14]
/// Output Compare 2 mode
OC2M: u3 = 0,
/// unused [15:15]
_unused15: u1 = 0,
/// OC1M_3 [16:16]
/// Output Compare 1 mode bit 3
OC1M_3: u1 = 0,
/// unused [17:23]
_unused17: u7 = 0,
/// OC2M_3 [24:24]
/// Output Compare 2 mode bit 3
OC2M_3: u1 = 0,
/// unused [25:31]
_unused25: u7 = 0,
};
/// capture/compare mode register (output mode)
pub const CCMR1_Output = Register(CCMR1_Output_val).init(base_address + 0x18);
/// CCMR1_Input
const CCMR1_Input_val = packed struct {
/// CC1S [0:1]
/// Capture/Compare 1 selection
CC1S: u2 = 0,
/// IC1PSC [2:3]
/// Input capture 1 prescaler
IC1PSC: u2 = 0,
/// IC1F [4:7]
/// Input capture 1 filter
IC1F: u4 = 0,
/// CC2S [8:9]
/// Capture/Compare 2 selection
CC2S: u2 = 0,
/// IC2PSC [10:11]
/// Input capture 2 prescaler
IC2PSC: u2 = 0,
/// IC2F [12:15]
/// Input capture 2 filter
IC2F: u4 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// capture/compare mode register 1 (input mode)
pub const CCMR1_Input = Register(CCMR1_Input_val).init(base_address + 0x18);
/// CCER
const CCER_val = packed struct {
/// CC1E [0:0]
/// Capture/Compare 1 output enable
CC1E: u1 = 0,
/// CC1P [1:1]
/// Capture/Compare 1 output Polarity
CC1P: u1 = 0,
/// CC1NE [2:2]
/// Capture/Compare 1 complementary output enable
CC1NE: u1 = 0,
/// CC1NP [3:3]
/// Capture/Compare 1 output Polarity
CC1NP: u1 = 0,
/// CC2E [4:4]
/// Capture/Compare 2 output enable
CC2E: u1 = 0,
/// CC2P [5:5]
/// Capture/Compare 2 output Polarity
CC2P: u1 = 0,
/// unused [6:6]
_unused6: u1 = 0,
/// CC2NP [7:7]
/// Capture/Compare 2 output Polarity
CC2NP: u1 = 0,
/// unused [8:31]
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// capture/compare enable register
pub const CCER = Register(CCER_val).init(base_address + 0x20);
/// CNT
const CNT_val = packed struct {
/// CNT [0:15]
/// counter value
CNT: u16 = 0,
/// unused [16:30]
_unused16: u8 = 0,
_unused24: u7 = 0,
/// UIFCPY [31:31]
/// UIF copy
UIFCPY: u1 = 0,
};
/// counter
pub const CNT = Register(CNT_val).init(base_address + 0x24);
/// PSC
const PSC_val = packed struct {
/// PSC [0:15]
/// Prescaler value
PSC: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// prescaler
pub const PSC = Register(PSC_val).init(base_address + 0x28);
/// ARR
const ARR_val = packed struct {
/// ARR [0:15]
/// Auto-reload value
ARR: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// auto-reload register
pub const ARR = Register(ARR_val).init(base_address + 0x2c);
/// RCR
const RCR_val = packed struct {
/// REP [0:7]
/// Repetition counter value
REP: u8 = 0,
/// unused [8:31]
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// repetition counter register
pub const RCR = Register(RCR_val).init(base_address + 0x30);
/// CCR1
const CCR1_val = packed struct {
/// CCR1 [0:15]
/// Capture/Compare 1 value
CCR1: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// capture/compare register 1
pub const CCR1 = Register(CCR1_val).init(base_address + 0x34);
/// CCR2
const CCR2_val = packed struct {
/// CCR2 [0:15]
/// Capture/Compare 2 value
CCR2: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// capture/compare register 2
pub const CCR2 = Register(CCR2_val).init(base_address + 0x38);
/// BDTR
const BDTR_val = packed struct {
/// DTG [0:7]
/// Dead-time generator setup
DTG: u8 = 0,
/// LOCK [8:9]
/// Lock configuration
LOCK: u2 = 0,
/// OSSI [10:10]
/// Off-state selection for Idle mode
OSSI: u1 = 0,
/// OSSR [11:11]
/// Off-state selection for Run mode
OSSR: u1 = 0,
/// BKE [12:12]
/// Break enable
BKE: u1 = 0,
/// BKP [13:13]
/// Break polarity
BKP: u1 = 0,
/// AOE [14:14]
/// Automatic output enable
AOE: u1 = 0,
/// MOE [15:15]
/// Main output enable
MOE: u1 = 0,
/// BKF [16:19]
/// Break filter
BKF: u4 = 0,
/// unused [20:31]
_unused20: u4 = 0,
_unused24: u8 = 0,
};
/// break and dead-time register
pub const BDTR = Register(BDTR_val).init(base_address + 0x44);
/// DCR
const DCR_val = packed struct {
/// DBA [0:4]
/// DMA base address
DBA: u5 = 0,
/// unused [5:7]
_unused5: u3 = 0,
/// DBL [8:12]
/// DMA burst length
DBL: u5 = 0,
/// unused [13:31]
_unused13: u3 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA control register
pub const DCR = Register(DCR_val).init(base_address + 0x48);
/// DMAR
const DMAR_val = packed struct {
/// DMAB [0:15]
/// DMA register for burst accesses
DMAB: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA address for full transfer
pub const DMAR = Register(DMAR_val).init(base_address + 0x4c);
};
/// General-purpose-timers
pub const TIM16 = struct {
const base_address = 0x40014400;
/// CR1
const CR1_val = packed struct {
/// CEN [0:0]
/// Counter enable
CEN: u1 = 0,
/// UDIS [1:1]
/// Update disable
UDIS: u1 = 0,
/// URS [2:2]
/// Update request source
URS: u1 = 0,
/// OPM [3:3]
/// One-pulse mode
OPM: u1 = 0,
/// unused [4:6]
_unused4: u3 = 0,
/// ARPE [7:7]
/// Auto-reload preload enable
ARPE: u1 = 0,
/// CKD [8:9]
/// Clock division
CKD: u2 = 0,
/// unused [10:10]
_unused10: u1 = 0,
/// UIFREMAP [11:11]
/// UIF status bit remapping
UIFREMAP: u1 = 0,
/// unused [12:31]
_unused12: u4 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// control register 1
pub const CR1 = Register(CR1_val).init(base_address + 0x0);
/// CR2
const CR2_val = packed struct {
/// CCPC [0:0]
/// Capture/compare preloaded control
CCPC: u1 = 0,
/// unused [1:1]
_unused1: u1 = 0,
/// CCUS [2:2]
/// Capture/compare control update selection
CCUS: u1 = 0,
/// CCDS [3:3]
/// Capture/compare DMA selection
CCDS: u1 = 0,
/// unused [4:7]
_unused4: u4 = 0,
/// OIS1 [8:8]
/// Output Idle state 1
OIS1: u1 = 0,
/// OIS1N [9:9]
/// Output Idle state 1
OIS1N: u1 = 0,
/// unused [10:31]
_unused10: u6 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// control register 2
pub const CR2 = Register(CR2_val).init(base_address + 0x4);
/// DIER
const DIER_val = packed struct {
/// UIE [0:0]
/// Update interrupt enable
UIE: u1 = 0,
/// CC1IE [1:1]
/// Capture/Compare 1 interrupt enable
CC1IE: u1 = 0,
/// unused [2:4]
_unused2: u3 = 0,
/// COMIE [5:5]
/// COM interrupt enable
COMIE: u1 = 0,
/// TIE [6:6]
/// Trigger interrupt enable
TIE: u1 = 0,
/// BIE [7:7]
/// Break interrupt enable
BIE: u1 = 0,
/// UDE [8:8]
/// Update DMA request enable
UDE: u1 = 0,
/// CC1DE [9:9]
/// Capture/Compare 1 DMA request enable
CC1DE: u1 = 0,
/// unused [10:12]
_unused10: u3 = 0,
/// COMDE [13:13]
/// COM DMA request enable
COMDE: u1 = 0,
/// TDE [14:14]
/// Trigger DMA request enable
TDE: u1 = 0,
/// unused [15:31]
_unused15: u1 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA/Interrupt enable register
pub const DIER = Register(DIER_val).init(base_address + 0xc);
/// SR
const SR_val = packed struct {
/// UIF [0:0]
/// Update interrupt flag
UIF: u1 = 0,
/// CC1IF [1:1]
/// Capture/compare 1 interrupt flag
CC1IF: u1 = 0,
/// unused [2:4]
_unused2: u3 = 0,
/// COMIF [5:5]
/// COM interrupt flag
COMIF: u1 = 0,
/// TIF [6:6]
/// Trigger interrupt flag
TIF: u1 = 0,
/// BIF [7:7]
/// Break interrupt flag
BIF: u1 = 0,
/// unused [8:8]
_unused8: u1 = 0,
/// CC1OF [9:9]
/// Capture/Compare 1 overcapture flag
CC1OF: u1 = 0,
/// unused [10:31]
_unused10: u6 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// status register
pub const SR = Register(SR_val).init(base_address + 0x10);
/// EGR
const EGR_val = packed struct {
/// UG [0:0]
/// Update generation
UG: u1 = 0,
/// CC1G [1:1]
/// Capture/compare 1 generation
CC1G: u1 = 0,
/// unused [2:4]
_unused2: u3 = 0,
/// COMG [5:5]
/// Capture/Compare control update generation
COMG: u1 = 0,
/// TG [6:6]
/// Trigger generation
TG: u1 = 0,
/// BG [7:7]
/// Break generation
BG: u1 = 0,
/// unused [8:31]
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// event generation register
pub const EGR = Register(EGR_val).init(base_address + 0x14);
/// CCMR1_Output
const CCMR1_Output_val = packed struct {
/// CC1S [0:1]
/// Capture/Compare 1 selection
CC1S: u2 = 0,
/// OC1FE [2:2]
/// Output Compare 1 fast enable
OC1FE: u1 = 0,
/// OC1PE [3:3]
/// Output Compare 1 preload enable
OC1PE: u1 = 0,
/// OC1M [4:6]
/// Output Compare 1 mode
OC1M: u3 = 0,
/// unused [7:15]
_unused7: u1 = 0,
_unused8: u8 = 0,
/// OC1M_3 [16:16]
/// Output Compare 1 mode
OC1M_3: u1 = 0,
/// unused [17:31]
_unused17: u7 = 0,
_unused24: u8 = 0,
};
/// capture/compare mode register (output mode)
pub const CCMR1_Output = Register(CCMR1_Output_val).init(base_address + 0x18);
/// CCMR1_Input
const CCMR1_Input_val = packed struct {
/// CC1S [0:1]
/// Capture/Compare 1 selection
CC1S: u2 = 0,
/// IC1PSC [2:3]
/// Input capture 1 prescaler
IC1PSC: u2 = 0,
/// IC1F [4:7]
/// Input capture 1 filter
IC1F: u4 = 0,
/// unused [8:31]
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// capture/compare mode register 1 (input mode)
pub const CCMR1_Input = Register(CCMR1_Input_val).init(base_address + 0x18);
/// CCER
const CCER_val = packed struct {
/// CC1E [0:0]
/// Capture/Compare 1 output enable
CC1E: u1 = 0,
/// CC1P [1:1]
/// Capture/Compare 1 output Polarity
CC1P: u1 = 0,
/// CC1NE [2:2]
/// Capture/Compare 1 complementary output enable
CC1NE: u1 = 0,
/// CC1NP [3:3]
/// Capture/Compare 1 output Polarity
CC1NP: u1 = 0,
/// unused [4:31]
_unused4: u4 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// capture/compare enable register
pub const CCER = Register(CCER_val).init(base_address + 0x20);
/// CNT
const CNT_val = packed struct {
/// CNT [0:15]
/// counter value
CNT: u16 = 0,
/// unused [16:30]
_unused16: u8 = 0,
_unused24: u7 = 0,
/// UIFCPY [31:31]
/// UIF Copy
UIFCPY: u1 = 0,
};
/// counter
pub const CNT = Register(CNT_val).init(base_address + 0x24);
/// PSC
const PSC_val = packed struct {
/// PSC [0:15]
/// Prescaler value
PSC: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// prescaler
pub const PSC = Register(PSC_val).init(base_address + 0x28);
/// ARR
const ARR_val = packed struct {
/// ARR [0:15]
/// Auto-reload value
ARR: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// auto-reload register
pub const ARR = Register(ARR_val).init(base_address + 0x2c);
/// RCR
const RCR_val = packed struct {
/// REP [0:7]
/// Repetition counter value
REP: u8 = 0,
/// unused [8:31]
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// repetition counter register
pub const RCR = Register(RCR_val).init(base_address + 0x30);
/// CCR1
const CCR1_val = packed struct {
/// CCR1 [0:15]
/// Capture/Compare 1 value
CCR1: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// capture/compare register 1
pub const CCR1 = Register(CCR1_val).init(base_address + 0x34);
/// BDTR
const BDTR_val = packed struct {
/// DTG [0:7]
/// Dead-time generator setup
DTG: u8 = 0,
/// LOCK [8:9]
/// Lock configuration
LOCK: u2 = 0,
/// OSSI [10:10]
/// Off-state selection for Idle mode
OSSI: u1 = 0,
/// OSSR [11:11]
/// Off-state selection for Run mode
OSSR: u1 = 0,
/// BKE [12:12]
/// Break enable
BKE: u1 = 0,
/// BKP [13:13]
/// Break polarity
BKP: u1 = 0,
/// AOE [14:14]
/// Automatic output enable
AOE: u1 = 0,
/// MOE [15:15]
/// Main output enable
MOE: u1 = 0,
/// BKF [16:19]
/// Break filter
BKF: u4 = 0,
/// unused [20:31]
_unused20: u4 = 0,
_unused24: u8 = 0,
};
/// break and dead-time register
pub const BDTR = Register(BDTR_val).init(base_address + 0x44);
/// DCR
const DCR_val = packed struct {
/// DBA [0:4]
/// DMA base address
DBA: u5 = 0,
/// unused [5:7]
_unused5: u3 = 0,
/// DBL [8:12]
/// DMA burst length
DBL: u5 = 0,
/// unused [13:31]
_unused13: u3 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA control register
pub const DCR = Register(DCR_val).init(base_address + 0x48);
/// DMAR
const DMAR_val = packed struct {
/// DMAB [0:15]
/// DMA register for burst accesses
DMAB: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA address for full transfer
pub const DMAR = Register(DMAR_val).init(base_address + 0x4c);
/// OR
const OR_val = packed struct {
/// unused [0:31]
_unused0: u8 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// option register
pub const OR = Register(OR_val).init(base_address + 0x50);
};
/// General purpose timer
pub const TIM17 = struct {
const base_address = 0x40014800;
/// CR1
const CR1_val = packed struct {
/// CEN [0:0]
/// Counter enable
CEN: u1 = 0,
/// UDIS [1:1]
/// Update disable
UDIS: u1 = 0,
/// URS [2:2]
/// Update request source
URS: u1 = 0,
/// OPM [3:3]
/// One-pulse mode
OPM: u1 = 0,
/// unused [4:6]
_unused4: u3 = 0,
/// ARPE [7:7]
/// Auto-reload preload enable
ARPE: u1 = 0,
/// CKD [8:9]
/// Clock division
CKD: u2 = 0,
/// unused [10:10]
_unused10: u1 = 0,
/// UIFREMAP [11:11]
/// UIF status bit remapping
UIFREMAP: u1 = 0,
/// unused [12:31]
_unused12: u4 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// control register 1
pub const CR1 = Register(CR1_val).init(base_address + 0x0);
/// CR2
const CR2_val = packed struct {
/// CCPC [0:0]
/// Capture/compare preloaded control
CCPC: u1 = 0,
/// unused [1:1]
_unused1: u1 = 0,
/// CCUS [2:2]
/// Capture/compare control update selection
CCUS: u1 = 0,
/// CCDS [3:3]
/// Capture/compare DMA selection
CCDS: u1 = 0,
/// unused [4:7]
_unused4: u4 = 0,
/// OIS1 [8:8]
/// Output Idle state 1
OIS1: u1 = 0,
/// OIS1N [9:9]
/// Output Idle state 1
OIS1N: u1 = 0,
/// unused [10:31]
_unused10: u6 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// control register 2
pub const CR2 = Register(CR2_val).init(base_address + 0x4);
/// DIER
const DIER_val = packed struct {
/// UIE [0:0]
/// Update interrupt enable
UIE: u1 = 0,
/// CC1IE [1:1]
/// Capture/Compare 1 interrupt enable
CC1IE: u1 = 0,
/// unused [2:4]
_unused2: u3 = 0,
/// COMIE [5:5]
/// COM interrupt enable
COMIE: u1 = 0,
/// TIE [6:6]
/// Trigger interrupt enable
TIE: u1 = 0,
/// BIE [7:7]
/// Break interrupt enable
BIE: u1 = 0,
/// UDE [8:8]
/// Update DMA request enable
UDE: u1 = 0,
/// CC1DE [9:9]
/// Capture/Compare 1 DMA request enable
CC1DE: u1 = 0,
/// unused [10:12]
_unused10: u3 = 0,
/// COMDE [13:13]
/// COM DMA request enable
COMDE: u1 = 0,
/// TDE [14:14]
/// Trigger DMA request enable
TDE: u1 = 0,
/// unused [15:31]
_unused15: u1 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA/Interrupt enable register
pub const DIER = Register(DIER_val).init(base_address + 0xc);
/// SR
const SR_val = packed struct {
/// UIF [0:0]
/// Update interrupt flag
UIF: u1 = 0,
/// CC1IF [1:1]
/// Capture/compare 1 interrupt flag
CC1IF: u1 = 0,
/// unused [2:4]
_unused2: u3 = 0,
/// COMIF [5:5]
/// COM interrupt flag
COMIF: u1 = 0,
/// TIF [6:6]
/// Trigger interrupt flag
TIF: u1 = 0,
/// BIF [7:7]
/// Break interrupt flag
BIF: u1 = 0,
/// unused [8:8]
_unused8: u1 = 0,
/// CC1OF [9:9]
/// Capture/Compare 1 overcapture flag
CC1OF: u1 = 0,
/// unused [10:31]
_unused10: u6 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// status register
pub const SR = Register(SR_val).init(base_address + 0x10);
/// EGR
const EGR_val = packed struct {
/// UG [0:0]
/// Update generation
UG: u1 = 0,
/// CC1G [1:1]
/// Capture/compare 1 generation
CC1G: u1 = 0,
/// unused [2:4]
_unused2: u3 = 0,
/// COMG [5:5]
/// Capture/Compare control update generation
COMG: u1 = 0,
/// TG [6:6]
/// Trigger generation
TG: u1 = 0,
/// BG [7:7]
/// Break generation
BG: u1 = 0,
/// unused [8:31]
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// event generation register
pub const EGR = Register(EGR_val).init(base_address + 0x14);
/// CCMR1_Output
const CCMR1_Output_val = packed struct {
/// CC1S [0:1]
/// Capture/Compare 1 selection
CC1S: u2 = 0,
/// OC1FE [2:2]
/// Output Compare 1 fast enable
OC1FE: u1 = 0,
/// OC1PE [3:3]
/// Output Compare 1 preload enable
OC1PE: u1 = 0,
/// OC1M [4:6]
/// Output Compare 1 mode
OC1M: u3 = 0,
/// unused [7:15]
_unused7: u1 = 0,
_unused8: u8 = 0,
/// OC1M_3 [16:16]
/// Output Compare 1 mode
OC1M_3: u1 = 0,
/// unused [17:31]
_unused17: u7 = 0,
_unused24: u8 = 0,
};
/// capture/compare mode register (output mode)
pub const CCMR1_Output = Register(CCMR1_Output_val).init(base_address + 0x18);
/// CCMR1_Input
const CCMR1_Input_val = packed struct {
/// CC1S [0:1]
/// Capture/Compare 1 selection
CC1S: u2 = 0,
/// IC1PSC [2:3]
/// Input capture 1 prescaler
IC1PSC: u2 = 0,
/// IC1F [4:7]
/// Input capture 1 filter
IC1F: u4 = 0,
/// unused [8:31]
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// capture/compare mode register 1 (input mode)
pub const CCMR1_Input = Register(CCMR1_Input_val).init(base_address + 0x18);
/// CCER
const CCER_val = packed struct {
/// CC1E [0:0]
/// Capture/Compare 1 output enable
CC1E: u1 = 0,
/// CC1P [1:1]
/// Capture/Compare 1 output Polarity
CC1P: u1 = 0,
/// CC1NE [2:2]
/// Capture/Compare 1 complementary output enable
CC1NE: u1 = 0,
/// CC1NP [3:3]
/// Capture/Compare 1 output Polarity
CC1NP: u1 = 0,
/// unused [4:31]
_unused4: u4 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// capture/compare enable register
pub const CCER = Register(CCER_val).init(base_address + 0x20);
/// CNT
const CNT_val = packed struct {
/// CNT [0:15]
/// counter value
CNT: u16 = 0,
/// unused [16:30]
_unused16: u8 = 0,
_unused24: u7 = 0,
/// UIFCPY [31:31]
/// UIF Copy
UIFCPY: u1 = 0,
};
/// counter
pub const CNT = Register(CNT_val).init(base_address + 0x24);
/// PSC
const PSC_val = packed struct {
/// PSC [0:15]
/// Prescaler value
PSC: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// prescaler
pub const PSC = Register(PSC_val).init(base_address + 0x28);
/// ARR
const ARR_val = packed struct {
/// ARR [0:15]
/// Auto-reload value
ARR: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// auto-reload register
pub const ARR = Register(ARR_val).init(base_address + 0x2c);
/// RCR
const RCR_val = packed struct {
/// REP [0:7]
/// Repetition counter value
REP: u8 = 0,
/// unused [8:31]
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// repetition counter register
pub const RCR = Register(RCR_val).init(base_address + 0x30);
/// CCR1
const CCR1_val = packed struct {
/// CCR1 [0:15]
/// Capture/Compare 1 value
CCR1: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// capture/compare register 1
pub const CCR1 = Register(CCR1_val).init(base_address + 0x34);
/// BDTR
const BDTR_val = packed struct {
/// DTG [0:7]
/// Dead-time generator setup
DTG: u8 = 0,
/// LOCK [8:9]
/// Lock configuration
LOCK: u2 = 0,
/// OSSI [10:10]
/// Off-state selection for Idle mode
OSSI: u1 = 0,
/// OSSR [11:11]
/// Off-state selection for Run mode
OSSR: u1 = 0,
/// BKE [12:12]
/// Break enable
BKE: u1 = 0,
/// BKP [13:13]
/// Break polarity
BKP: u1 = 0,
/// AOE [14:14]
/// Automatic output enable
AOE: u1 = 0,
/// MOE [15:15]
/// Main output enable
MOE: u1 = 0,
/// BKF [16:19]
/// Break filter
BKF: u4 = 0,
/// unused [20:31]
_unused20: u4 = 0,
_unused24: u8 = 0,
};
/// break and dead-time register
pub const BDTR = Register(BDTR_val).init(base_address + 0x44);
/// DCR
const DCR_val = packed struct {
/// DBA [0:4]
/// DMA base address
DBA: u5 = 0,
/// unused [5:7]
_unused5: u3 = 0,
/// DBL [8:12]
/// DMA burst length
DBL: u5 = 0,
/// unused [13:31]
_unused13: u3 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA control register
pub const DCR = Register(DCR_val).init(base_address + 0x48);
/// DMAR
const DMAR_val = packed struct {
/// DMAB [0:15]
/// DMA register for burst accesses
DMAB: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA address for full transfer
pub const DMAR = Register(DMAR_val).init(base_address + 0x4c);
};
/// Universal synchronous asynchronous receiver transmitter
pub const USART1 = struct {
const base_address = 0x40013800;
/// CR1
const CR1_val = packed struct {
/// UE [0:0]
/// USART enable
UE: u1 = 0,
/// UESM [1:1]
/// USART enable in Stop mode
UESM: u1 = 0,
/// RE [2:2]
/// Receiver enable
RE: u1 = 0,
/// TE [3:3]
/// Transmitter enable
TE: u1 = 0,
/// IDLEIE [4:4]
/// IDLE interrupt enable
IDLEIE: u1 = 0,
/// RXNEIE [5:5]
/// RXNE interrupt enable
RXNEIE: u1 = 0,
/// TCIE [6:6]
/// Transmission complete interrupt enable
TCIE: u1 = 0,
/// TXEIE [7:7]
/// interrupt enable
TXEIE: u1 = 0,
/// PEIE [8:8]
/// PE interrupt enable
PEIE: u1 = 0,
/// PS [9:9]
/// Parity selection
PS: u1 = 0,
/// PCE [10:10]
/// Parity control enable
PCE: u1 = 0,
/// WAKE [11:11]
/// Receiver wakeup method
WAKE: u1 = 0,
/// M [12:12]
/// Word length
M: u1 = 0,
/// MME [13:13]
/// Mute mode enable
MME: u1 = 0,
/// CMIE [14:14]
/// Character match interrupt enable
CMIE: u1 = 0,
/// OVER8 [15:15]
/// Oversampling mode
OVER8: u1 = 0,
/// DEDT [16:20]
/// Driver Enable deassertion time
DEDT: u5 = 0,
/// DEAT [21:25]
/// Driver Enable assertion time
DEAT: u5 = 0,
/// RTOIE [26:26]
/// Receiver timeout interrupt enable
RTOIE: u1 = 0,
/// EOBIE [27:27]
/// End of Block interrupt enable
EOBIE: u1 = 0,
/// unused [28:31]
_unused28: u4 = 0,
};
/// Control register 1
pub const CR1 = Register(CR1_val).init(base_address + 0x0);
/// CR2
const CR2_val = packed struct {
/// unused [0:3]
_unused0: u4 = 0,
/// ADDM7 [4:4]
/// 7-bit Address Detection/4-bit Address Detection
ADDM7: u1 = 0,
/// LBDL [5:5]
/// LIN break detection length
LBDL: u1 = 0,
/// LBDIE [6:6]
/// LIN break detection interrupt enable
LBDIE: u1 = 0,
/// unused [7:7]
_unused7: u1 = 0,
/// LBCL [8:8]
/// Last bit clock pulse
LBCL: u1 = 0,
/// CPHA [9:9]
/// Clock phase
CPHA: u1 = 0,
/// CPOL [10:10]
/// Clock polarity
CPOL: u1 = 0,
/// CLKEN [11:11]
/// Clock enable
CLKEN: u1 = 0,
/// STOP [12:13]
/// STOP bits
STOP: u2 = 0,
/// LINEN [14:14]
/// LIN mode enable
LINEN: u1 = 0,
/// SWAP [15:15]
/// Swap TX/RX pins
SWAP: u1 = 0,
/// RXINV [16:16]
/// RX pin active level inversion
RXINV: u1 = 0,
/// TXINV [17:17]
/// TX pin active level inversion
TXINV: u1 = 0,
/// DATAINV [18:18]
/// Binary data inversion
DATAINV: u1 = 0,
/// MSBFIRST [19:19]
/// Most significant bit first
MSBFIRST: u1 = 0,
/// ABREN [20:20]
/// Auto baud rate enable
ABREN: u1 = 0,
/// ABRMOD [21:22]
/// Auto baud rate mode
ABRMOD: u2 = 0,
/// RTOEN [23:23]
/// Receiver timeout enable
RTOEN: u1 = 0,
/// ADD0 [24:27]
/// Address of the USART node
ADD0: u4 = 0,
/// ADD4 [28:31]
/// Address of the USART node
ADD4: u4 = 0,
};
/// Control register 2
pub const CR2 = Register(CR2_val).init(base_address + 0x4);
/// CR3
const CR3_val = packed struct {
/// EIE [0:0]
/// Error interrupt enable
EIE: u1 = 0,
/// IREN [1:1]
/// IrDA mode enable
IREN: u1 = 0,
/// IRLP [2:2]
/// IrDA low-power
IRLP: u1 = 0,
/// HDSEL [3:3]
/// Half-duplex selection
HDSEL: u1 = 0,
/// NACK [4:4]
/// Smartcard NACK enable
NACK: u1 = 0,
/// SCEN [5:5]
/// Smartcard mode enable
SCEN: u1 = 0,
/// DMAR [6:6]
/// DMA enable receiver
DMAR: u1 = 0,
/// DMAT [7:7]
/// DMA enable transmitter
DMAT: u1 = 0,
/// RTSE [8:8]
/// RTS enable
RTSE: u1 = 0,
/// CTSE [9:9]
/// CTS enable
CTSE: u1 = 0,
/// CTSIE [10:10]
/// CTS interrupt enable
CTSIE: u1 = 0,
/// ONEBIT [11:11]
/// One sample bit method enable
ONEBIT: u1 = 0,
/// OVRDIS [12:12]
/// Overrun Disable
OVRDIS: u1 = 0,
/// DDRE [13:13]
/// DMA Disable on Reception Error
DDRE: u1 = 0,
/// DEM [14:14]
/// Driver enable mode
DEM: u1 = 0,
/// DEP [15:15]
/// Driver enable polarity selection
DEP: u1 = 0,
/// unused [16:16]
_unused16: u1 = 0,
/// SCARCNT [17:19]
/// Smartcard auto-retry count
SCARCNT: u3 = 0,
/// WUS [20:21]
/// Wakeup from Stop mode interrupt flag selection
WUS: u2 = 0,
/// WUFIE [22:22]
/// Wakeup from Stop mode interrupt enable
WUFIE: u1 = 0,
/// unused [23:31]
_unused23: u1 = 0,
_unused24: u8 = 0,
};
/// Control register 3
pub const CR3 = Register(CR3_val).init(base_address + 0x8);
/// BRR
const BRR_val = packed struct {
/// DIV_Fraction [0:3]
/// fraction of USARTDIV
DIV_Fraction: u4 = 0,
/// DIV_Mantissa [4:15]
/// mantissa of USARTDIV
DIV_Mantissa: u12 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Baud rate register
pub const BRR = Register(BRR_val).init(base_address + 0xc);
/// GTPR
const GTPR_val = packed struct {
/// PSC [0:7]
/// Prescaler value
PSC: u8 = 0,
/// GT [8:15]
/// Guard time value
GT: u8 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Guard time and prescaler register
pub const GTPR = Register(GTPR_val).init(base_address + 0x10);
/// RTOR
const RTOR_val = packed struct {
/// RTO [0:23]
/// Receiver timeout value
RTO: u24 = 0,
/// BLEN [24:31]
/// Block Length
BLEN: u8 = 0,
};
/// Receiver timeout register
pub const RTOR = Register(RTOR_val).init(base_address + 0x14);
/// RQR
const RQR_val = packed struct {
/// ABRRQ [0:0]
/// Auto baud rate request
ABRRQ: u1 = 0,
/// SBKRQ [1:1]
/// Send break request
SBKRQ: u1 = 0,
/// MMRQ [2:2]
/// Mute mode request
MMRQ: u1 = 0,
/// RXFRQ [3:3]
/// Receive data flush request
RXFRQ: u1 = 0,
/// TXFRQ [4:4]
/// Transmit data flush request
TXFRQ: u1 = 0,
/// unused [5:31]
_unused5: u3 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Request register
pub const RQR = Register(RQR_val).init(base_address + 0x18);
/// ISR
const ISR_val = packed struct {
/// PE [0:0]
/// Parity error
PE: u1 = 0,
/// FE [1:1]
/// Framing error
FE: u1 = 0,
/// NF [2:2]
/// Noise detected flag
NF: u1 = 0,
/// ORE [3:3]
/// Overrun error
ORE: u1 = 0,
/// IDLE [4:4]
/// Idle line detected
IDLE: u1 = 0,
/// RXNE [5:5]
/// Read data register not empty
RXNE: u1 = 0,
/// TC [6:6]
/// Transmission complete
TC: u1 = 1,
/// TXE [7:7]
/// Transmit data register empty
TXE: u1 = 1,
/// LBDF [8:8]
/// LIN break detection flag
LBDF: u1 = 0,
/// CTSIF [9:9]
/// CTS interrupt flag
CTSIF: u1 = 0,
/// CTS [10:10]
/// CTS flag
CTS: u1 = 0,
/// RTOF [11:11]
/// Receiver timeout
RTOF: u1 = 0,
/// EOBF [12:12]
/// End of block flag
EOBF: u1 = 0,
/// unused [13:13]
_unused13: u1 = 0,
/// ABRE [14:14]
/// Auto baud rate error
ABRE: u1 = 0,
/// ABRF [15:15]
/// Auto baud rate flag
ABRF: u1 = 0,
/// BUSY [16:16]
/// Busy flag
BUSY: u1 = 0,
/// CMF [17:17]
/// character match flag
CMF: u1 = 0,
/// SBKF [18:18]
/// Send break flag
SBKF: u1 = 0,
/// RWU [19:19]
/// Receiver wakeup from Mute mode
RWU: u1 = 0,
/// WUF [20:20]
/// Wakeup from Stop mode flag
WUF: u1 = 0,
/// TEACK [21:21]
/// Transmit enable acknowledge flag
TEACK: u1 = 0,
/// REACK [22:22]
/// Receive enable acknowledge flag
REACK: u1 = 0,
/// unused [23:31]
_unused23: u1 = 0,
_unused24: u8 = 0,
};
/// Interrupt & status register
pub const ISR = Register(ISR_val).init(base_address + 0x1c);
/// ICR
const ICR_val = packed struct {
/// PECF [0:0]
/// Parity error clear flag
PECF: u1 = 0,
/// FECF [1:1]
/// Framing error clear flag
FECF: u1 = 0,
/// NCF [2:2]
/// Noise detected clear flag
NCF: u1 = 0,
/// ORECF [3:3]
/// Overrun error clear flag
ORECF: u1 = 0,
/// IDLECF [4:4]
/// Idle line detected clear flag
IDLECF: u1 = 0,
/// unused [5:5]
_unused5: u1 = 0,
/// TCCF [6:6]
/// Transmission complete clear flag
TCCF: u1 = 0,
/// unused [7:7]
_unused7: u1 = 0,
/// LBDCF [8:8]
/// LIN break detection clear flag
LBDCF: u1 = 0,
/// CTSCF [9:9]
/// CTS clear flag
CTSCF: u1 = 0,
/// unused [10:10]
_unused10: u1 = 0,
/// RTOCF [11:11]
/// Receiver timeout clear flag
RTOCF: u1 = 0,
/// EOBCF [12:12]
/// End of timeout clear flag
EOBCF: u1 = 0,
/// unused [13:16]
_unused13: u3 = 0,
_unused16: u1 = 0,
/// CMCF [17:17]
/// Character match clear flag
CMCF: u1 = 0,
/// unused [18:19]
_unused18: u2 = 0,
/// WUCF [20:20]
/// Wakeup from Stop mode clear flag
WUCF: u1 = 0,
/// unused [21:31]
_unused21: u3 = 0,
_unused24: u8 = 0,
};
/// Interrupt flag clear register
pub const ICR = Register(ICR_val).init(base_address + 0x20);
/// RDR
const RDR_val = packed struct {
/// RDR [0:8]
/// Receive data value
RDR: u9 = 0,
/// unused [9:31]
_unused9: u7 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Receive data register
pub const RDR = Register(RDR_val).init(base_address + 0x24);
/// TDR
const TDR_val = packed struct {
/// TDR [0:8]
/// Transmit data value
TDR: u9 = 0,
/// unused [9:31]
_unused9: u7 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Transmit data register
pub const TDR = Register(TDR_val).init(base_address + 0x28);
};
/// Universal synchronous asynchronous receiver transmitter
pub const USART2 = struct {
const base_address = 0x40004400;
/// CR1
const CR1_val = packed struct {
/// UE [0:0]
/// USART enable
UE: u1 = 0,
/// UESM [1:1]
/// USART enable in Stop mode
UESM: u1 = 0,
/// RE [2:2]
/// Receiver enable
RE: u1 = 0,
/// TE [3:3]
/// Transmitter enable
TE: u1 = 0,
/// IDLEIE [4:4]
/// IDLE interrupt enable
IDLEIE: u1 = 0,
/// RXNEIE [5:5]
/// RXNE interrupt enable
RXNEIE: u1 = 0,
/// TCIE [6:6]
/// Transmission complete interrupt enable
TCIE: u1 = 0,
/// TXEIE [7:7]
/// interrupt enable
TXEIE: u1 = 0,
/// PEIE [8:8]
/// PE interrupt enable
PEIE: u1 = 0,
/// PS [9:9]
/// Parity selection
PS: u1 = 0,
/// PCE [10:10]
/// Parity control enable
PCE: u1 = 0,
/// WAKE [11:11]
/// Receiver wakeup method
WAKE: u1 = 0,
/// M [12:12]
/// Word length
M: u1 = 0,
/// MME [13:13]
/// Mute mode enable
MME: u1 = 0,
/// CMIE [14:14]
/// Character match interrupt enable
CMIE: u1 = 0,
/// OVER8 [15:15]
/// Oversampling mode
OVER8: u1 = 0,
/// DEDT [16:20]
/// Driver Enable deassertion time
DEDT: u5 = 0,
/// DEAT [21:25]
/// Driver Enable assertion time
DEAT: u5 = 0,
/// RTOIE [26:26]
/// Receiver timeout interrupt enable
RTOIE: u1 = 0,
/// EOBIE [27:27]
/// End of Block interrupt enable
EOBIE: u1 = 0,
/// unused [28:31]
_unused28: u4 = 0,
};
/// Control register 1
pub const CR1 = Register(CR1_val).init(base_address + 0x0);
/// CR2
const CR2_val = packed struct {
/// unused [0:3]
_unused0: u4 = 0,
/// ADDM7 [4:4]
/// 7-bit Address Detection/4-bit Address Detection
ADDM7: u1 = 0,
/// LBDL [5:5]
/// LIN break detection length
LBDL: u1 = 0,
/// LBDIE [6:6]
/// LIN break detection interrupt enable
LBDIE: u1 = 0,
/// unused [7:7]
_unused7: u1 = 0,
/// LBCL [8:8]
/// Last bit clock pulse
LBCL: u1 = 0,
/// CPHA [9:9]
/// Clock phase
CPHA: u1 = 0,
/// CPOL [10:10]
/// Clock polarity
CPOL: u1 = 0,
/// CLKEN [11:11]
/// Clock enable
CLKEN: u1 = 0,
/// STOP [12:13]
/// STOP bits
STOP: u2 = 0,
/// LINEN [14:14]
/// LIN mode enable
LINEN: u1 = 0,
/// SWAP [15:15]
/// Swap TX/RX pins
SWAP: u1 = 0,
/// RXINV [16:16]
/// RX pin active level inversion
RXINV: u1 = 0,
/// TXINV [17:17]
/// TX pin active level inversion
TXINV: u1 = 0,
/// DATAINV [18:18]
/// Binary data inversion
DATAINV: u1 = 0,
/// MSBFIRST [19:19]
/// Most significant bit first
MSBFIRST: u1 = 0,
/// ABREN [20:20]
/// Auto baud rate enable
ABREN: u1 = 0,
/// ABRMOD [21:22]
/// Auto baud rate mode
ABRMOD: u2 = 0,
/// RTOEN [23:23]
/// Receiver timeout enable
RTOEN: u1 = 0,
/// ADD0 [24:27]
/// Address of the USART node
ADD0: u4 = 0,
/// ADD4 [28:31]
/// Address of the USART node
ADD4: u4 = 0,
};
/// Control register 2
pub const CR2 = Register(CR2_val).init(base_address + 0x4);
/// CR3
const CR3_val = packed struct {
/// EIE [0:0]
/// Error interrupt enable
EIE: u1 = 0,
/// IREN [1:1]
/// IrDA mode enable
IREN: u1 = 0,
/// IRLP [2:2]
/// IrDA low-power
IRLP: u1 = 0,
/// HDSEL [3:3]
/// Half-duplex selection
HDSEL: u1 = 0,
/// NACK [4:4]
/// Smartcard NACK enable
NACK: u1 = 0,
/// SCEN [5:5]
/// Smartcard mode enable
SCEN: u1 = 0,
/// DMAR [6:6]
/// DMA enable receiver
DMAR: u1 = 0,
/// DMAT [7:7]
/// DMA enable transmitter
DMAT: u1 = 0,
/// RTSE [8:8]
/// RTS enable
RTSE: u1 = 0,
/// CTSE [9:9]
/// CTS enable
CTSE: u1 = 0,
/// CTSIE [10:10]
/// CTS interrupt enable
CTSIE: u1 = 0,
/// ONEBIT [11:11]
/// One sample bit method enable
ONEBIT: u1 = 0,
/// OVRDIS [12:12]
/// Overrun Disable
OVRDIS: u1 = 0,
/// DDRE [13:13]
/// DMA Disable on Reception Error
DDRE: u1 = 0,
/// DEM [14:14]
/// Driver enable mode
DEM: u1 = 0,
/// DEP [15:15]
/// Driver enable polarity selection
DEP: u1 = 0,
/// unused [16:16]
_unused16: u1 = 0,
/// SCARCNT [17:19]
/// Smartcard auto-retry count
SCARCNT: u3 = 0,
/// WUS [20:21]
/// Wakeup from Stop mode interrupt flag selection
WUS: u2 = 0,
/// WUFIE [22:22]
/// Wakeup from Stop mode interrupt enable
WUFIE: u1 = 0,
/// unused [23:31]
_unused23: u1 = 0,
_unused24: u8 = 0,
};
/// Control register 3
pub const CR3 = Register(CR3_val).init(base_address + 0x8);
/// BRR
const BRR_val = packed struct {
/// DIV_Fraction [0:3]
/// fraction of USARTDIV
DIV_Fraction: u4 = 0,
/// DIV_Mantissa [4:15]
/// mantissa of USARTDIV
DIV_Mantissa: u12 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Baud rate register
pub const BRR = Register(BRR_val).init(base_address + 0xc);
/// GTPR
const GTPR_val = packed struct {
/// PSC [0:7]
/// Prescaler value
PSC: u8 = 0,
/// GT [8:15]
/// Guard time value
GT: u8 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Guard time and prescaler register
pub const GTPR = Register(GTPR_val).init(base_address + 0x10);
/// RTOR
const RTOR_val = packed struct {
/// RTO [0:23]
/// Receiver timeout value
RTO: u24 = 0,
/// BLEN [24:31]
/// Block Length
BLEN: u8 = 0,
};
/// Receiver timeout register
pub const RTOR = Register(RTOR_val).init(base_address + 0x14);
/// RQR
const RQR_val = packed struct {
/// ABRRQ [0:0]
/// Auto baud rate request
ABRRQ: u1 = 0,
/// SBKRQ [1:1]
/// Send break request
SBKRQ: u1 = 0,
/// MMRQ [2:2]
/// Mute mode request
MMRQ: u1 = 0,
/// RXFRQ [3:3]
/// Receive data flush request
RXFRQ: u1 = 0,
/// TXFRQ [4:4]
/// Transmit data flush request
TXFRQ: u1 = 0,
/// unused [5:31]
_unused5: u3 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Request register
pub const RQR = Register(RQR_val).init(base_address + 0x18);
/// ISR
const ISR_val = packed struct {
/// PE [0:0]
/// Parity error
PE: u1 = 0,
/// FE [1:1]
/// Framing error
FE: u1 = 0,
/// NF [2:2]
/// Noise detected flag
NF: u1 = 0,
/// ORE [3:3]
/// Overrun error
ORE: u1 = 0,
/// IDLE [4:4]
/// Idle line detected
IDLE: u1 = 0,
/// RXNE [5:5]
/// Read data register not empty
RXNE: u1 = 0,
/// TC [6:6]
/// Transmission complete
TC: u1 = 1,
/// TXE [7:7]
/// Transmit data register empty
TXE: u1 = 1,
/// LBDF [8:8]
/// LIN break detection flag
LBDF: u1 = 0,
/// CTSIF [9:9]
/// CTS interrupt flag
CTSIF: u1 = 0,
/// CTS [10:10]
/// CTS flag
CTS: u1 = 0,
/// RTOF [11:11]
/// Receiver timeout
RTOF: u1 = 0,
/// EOBF [12:12]
/// End of block flag
EOBF: u1 = 0,
/// unused [13:13]
_unused13: u1 = 0,
/// ABRE [14:14]
/// Auto baud rate error
ABRE: u1 = 0,
/// ABRF [15:15]
/// Auto baud rate flag
ABRF: u1 = 0,
/// BUSY [16:16]
/// Busy flag
BUSY: u1 = 0,
/// CMF [17:17]
/// character match flag
CMF: u1 = 0,
/// SBKF [18:18]
/// Send break flag
SBKF: u1 = 0,
/// RWU [19:19]
/// Receiver wakeup from Mute mode
RWU: u1 = 0,
/// WUF [20:20]
/// Wakeup from Stop mode flag
WUF: u1 = 0,
/// TEACK [21:21]
/// Transmit enable acknowledge flag
TEACK: u1 = 0,
/// REACK [22:22]
/// Receive enable acknowledge flag
REACK: u1 = 0,
/// unused [23:31]
_unused23: u1 = 0,
_unused24: u8 = 0,
};
/// Interrupt & status register
pub const ISR = Register(ISR_val).init(base_address + 0x1c);
/// ICR
const ICR_val = packed struct {
/// PECF [0:0]
/// Parity error clear flag
PECF: u1 = 0,
/// FECF [1:1]
/// Framing error clear flag
FECF: u1 = 0,
/// NCF [2:2]
/// Noise detected clear flag
NCF: u1 = 0,
/// ORECF [3:3]
/// Overrun error clear flag
ORECF: u1 = 0,
/// IDLECF [4:4]
/// Idle line detected clear flag
IDLECF: u1 = 0,
/// unused [5:5]
_unused5: u1 = 0,
/// TCCF [6:6]
/// Transmission complete clear flag
TCCF: u1 = 0,
/// unused [7:7]
_unused7: u1 = 0,
/// LBDCF [8:8]
/// LIN break detection clear flag
LBDCF: u1 = 0,
/// CTSCF [9:9]
/// CTS clear flag
CTSCF: u1 = 0,
/// unused [10:10]
_unused10: u1 = 0,
/// RTOCF [11:11]
/// Receiver timeout clear flag
RTOCF: u1 = 0,
/// EOBCF [12:12]
/// End of timeout clear flag
EOBCF: u1 = 0,
/// unused [13:16]
_unused13: u3 = 0,
_unused16: u1 = 0,
/// CMCF [17:17]
/// Character match clear flag
CMCF: u1 = 0,
/// unused [18:19]
_unused18: u2 = 0,
/// WUCF [20:20]
/// Wakeup from Stop mode clear flag
WUCF: u1 = 0,
/// unused [21:31]
_unused21: u3 = 0,
_unused24: u8 = 0,
};
/// Interrupt flag clear register
pub const ICR = Register(ICR_val).init(base_address + 0x20);
/// RDR
const RDR_val = packed struct {
/// RDR [0:8]
/// Receive data value
RDR: u9 = 0,
/// unused [9:31]
_unused9: u7 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Receive data register
pub const RDR = Register(RDR_val).init(base_address + 0x24);
/// TDR
const TDR_val = packed struct {
/// TDR [0:8]
/// Transmit data value
TDR: u9 = 0,
/// unused [9:31]
_unused9: u7 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Transmit data register
pub const TDR = Register(TDR_val).init(base_address + 0x28);
};
/// Universal synchronous asynchronous receiver transmitter
pub const USART3 = struct {
const base_address = 0x40004800;
/// CR1
const CR1_val = packed struct {
/// UE [0:0]
/// USART enable
UE: u1 = 0,
/// UESM [1:1]
/// USART enable in Stop mode
UESM: u1 = 0,
/// RE [2:2]
/// Receiver enable
RE: u1 = 0,
/// TE [3:3]
/// Transmitter enable
TE: u1 = 0,
/// IDLEIE [4:4]
/// IDLE interrupt enable
IDLEIE: u1 = 0,
/// RXNEIE [5:5]
/// RXNE interrupt enable
RXNEIE: u1 = 0,
/// TCIE [6:6]
/// Transmission complete interrupt enable
TCIE: u1 = 0,
/// TXEIE [7:7]
/// interrupt enable
TXEIE: u1 = 0,
/// PEIE [8:8]
/// PE interrupt enable
PEIE: u1 = 0,
/// PS [9:9]
/// Parity selection
PS: u1 = 0,
/// PCE [10:10]
/// Parity control enable
PCE: u1 = 0,
/// WAKE [11:11]
/// Receiver wakeup method
WAKE: u1 = 0,
/// M [12:12]
/// Word length
M: u1 = 0,
/// MME [13:13]
/// Mute mode enable
MME: u1 = 0,
/// CMIE [14:14]
/// Character match interrupt enable
CMIE: u1 = 0,
/// OVER8 [15:15]
/// Oversampling mode
OVER8: u1 = 0,
/// DEDT [16:20]
/// Driver Enable deassertion time
DEDT: u5 = 0,
/// DEAT [21:25]
/// Driver Enable assertion time
DEAT: u5 = 0,
/// RTOIE [26:26]
/// Receiver timeout interrupt enable
RTOIE: u1 = 0,
/// EOBIE [27:27]
/// End of Block interrupt enable
EOBIE: u1 = 0,
/// unused [28:31]
_unused28: u4 = 0,
};
/// Control register 1
pub const CR1 = Register(CR1_val).init(base_address + 0x0);
/// CR2
const CR2_val = packed struct {
/// unused [0:3]
_unused0: u4 = 0,
/// ADDM7 [4:4]
/// 7-bit Address Detection/4-bit Address Detection
ADDM7: u1 = 0,
/// LBDL [5:5]
/// LIN break detection length
LBDL: u1 = 0,
/// LBDIE [6:6]
/// LIN break detection interrupt enable
LBDIE: u1 = 0,
/// unused [7:7]
_unused7: u1 = 0,
/// LBCL [8:8]
/// Last bit clock pulse
LBCL: u1 = 0,
/// CPHA [9:9]
/// Clock phase
CPHA: u1 = 0,
/// CPOL [10:10]
/// Clock polarity
CPOL: u1 = 0,
/// CLKEN [11:11]
/// Clock enable
CLKEN: u1 = 0,
/// STOP [12:13]
/// STOP bits
STOP: u2 = 0,
/// LINEN [14:14]
/// LIN mode enable
LINEN: u1 = 0,
/// SWAP [15:15]
/// Swap TX/RX pins
SWAP: u1 = 0,
/// RXINV [16:16]
/// RX pin active level inversion
RXINV: u1 = 0,
/// TXINV [17:17]
/// TX pin active level inversion
TXINV: u1 = 0,
/// DATAINV [18:18]
/// Binary data inversion
DATAINV: u1 = 0,
/// MSBFIRST [19:19]
/// Most significant bit first
MSBFIRST: u1 = 0,
/// ABREN [20:20]
/// Auto baud rate enable
ABREN: u1 = 0,
/// ABRMOD [21:22]
/// Auto baud rate mode
ABRMOD: u2 = 0,
/// RTOEN [23:23]
/// Receiver timeout enable
RTOEN: u1 = 0,
/// ADD0 [24:27]
/// Address of the USART node
ADD0: u4 = 0,
/// ADD4 [28:31]
/// Address of the USART node
ADD4: u4 = 0,
};
/// Control register 2
pub const CR2 = Register(CR2_val).init(base_address + 0x4);
/// CR3
const CR3_val = packed struct {
/// EIE [0:0]
/// Error interrupt enable
EIE: u1 = 0,
/// IREN [1:1]
/// IrDA mode enable
IREN: u1 = 0,
/// IRLP [2:2]
/// IrDA low-power
IRLP: u1 = 0,
/// HDSEL [3:3]
/// Half-duplex selection
HDSEL: u1 = 0,
/// NACK [4:4]
/// Smartcard NACK enable
NACK: u1 = 0,
/// SCEN [5:5]
/// Smartcard mode enable
SCEN: u1 = 0,
/// DMAR [6:6]
/// DMA enable receiver
DMAR: u1 = 0,
/// DMAT [7:7]
/// DMA enable transmitter
DMAT: u1 = 0,
/// RTSE [8:8]
/// RTS enable
RTSE: u1 = 0,
/// CTSE [9:9]
/// CTS enable
CTSE: u1 = 0,
/// CTSIE [10:10]
/// CTS interrupt enable
CTSIE: u1 = 0,
/// ONEBIT [11:11]
/// One sample bit method enable
ONEBIT: u1 = 0,
/// OVRDIS [12:12]
/// Overrun Disable
OVRDIS: u1 = 0,
/// DDRE [13:13]
/// DMA Disable on Reception Error
DDRE: u1 = 0,
/// DEM [14:14]
/// Driver enable mode
DEM: u1 = 0,
/// DEP [15:15]
/// Driver enable polarity selection
DEP: u1 = 0,
/// unused [16:16]
_unused16: u1 = 0,
/// SCARCNT [17:19]
/// Smartcard auto-retry count
SCARCNT: u3 = 0,
/// WUS [20:21]
/// Wakeup from Stop mode interrupt flag selection
WUS: u2 = 0,
/// WUFIE [22:22]
/// Wakeup from Stop mode interrupt enable
WUFIE: u1 = 0,
/// unused [23:31]
_unused23: u1 = 0,
_unused24: u8 = 0,
};
/// Control register 3
pub const CR3 = Register(CR3_val).init(base_address + 0x8);
/// BRR
const BRR_val = packed struct {
/// DIV_Fraction [0:3]
/// fraction of USARTDIV
DIV_Fraction: u4 = 0,
/// DIV_Mantissa [4:15]
/// mantissa of USARTDIV
DIV_Mantissa: u12 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Baud rate register
pub const BRR = Register(BRR_val).init(base_address + 0xc);
/// GTPR
const GTPR_val = packed struct {
/// PSC [0:7]
/// Prescaler value
PSC: u8 = 0,
/// GT [8:15]
/// Guard time value
GT: u8 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Guard time and prescaler register
pub const GTPR = Register(GTPR_val).init(base_address + 0x10);
/// RTOR
const RTOR_val = packed struct {
/// RTO [0:23]
/// Receiver timeout value
RTO: u24 = 0,
/// BLEN [24:31]
/// Block Length
BLEN: u8 = 0,
};
/// Receiver timeout register
pub const RTOR = Register(RTOR_val).init(base_address + 0x14);
/// RQR
const RQR_val = packed struct {
/// ABRRQ [0:0]
/// Auto baud rate request
ABRRQ: u1 = 0,
/// SBKRQ [1:1]
/// Send break request
SBKRQ: u1 = 0,
/// MMRQ [2:2]
/// Mute mode request
MMRQ: u1 = 0,
/// RXFRQ [3:3]
/// Receive data flush request
RXFRQ: u1 = 0,
/// TXFRQ [4:4]
/// Transmit data flush request
TXFRQ: u1 = 0,
/// unused [5:31]
_unused5: u3 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Request register
pub const RQR = Register(RQR_val).init(base_address + 0x18);
/// ISR
const ISR_val = packed struct {
/// PE [0:0]
/// Parity error
PE: u1 = 0,
/// FE [1:1]
/// Framing error
FE: u1 = 0,
/// NF [2:2]
/// Noise detected flag
NF: u1 = 0,
/// ORE [3:3]
/// Overrun error
ORE: u1 = 0,
/// IDLE [4:4]
/// Idle line detected
IDLE: u1 = 0,
/// RXNE [5:5]
/// Read data register not empty
RXNE: u1 = 0,
/// TC [6:6]
/// Transmission complete
TC: u1 = 1,
/// TXE [7:7]
/// Transmit data register empty
TXE: u1 = 1,
/// LBDF [8:8]
/// LIN break detection flag
LBDF: u1 = 0,
/// CTSIF [9:9]
/// CTS interrupt flag
CTSIF: u1 = 0,
/// CTS [10:10]
/// CTS flag
CTS: u1 = 0,
/// RTOF [11:11]
/// Receiver timeout
RTOF: u1 = 0,
/// EOBF [12:12]
/// End of block flag
EOBF: u1 = 0,
/// unused [13:13]
_unused13: u1 = 0,
/// ABRE [14:14]
/// Auto baud rate error
ABRE: u1 = 0,
/// ABRF [15:15]
/// Auto baud rate flag
ABRF: u1 = 0,
/// BUSY [16:16]
/// Busy flag
BUSY: u1 = 0,
/// CMF [17:17]
/// character match flag
CMF: u1 = 0,
/// SBKF [18:18]
/// Send break flag
SBKF: u1 = 0,
/// RWU [19:19]
/// Receiver wakeup from Mute mode
RWU: u1 = 0,
/// WUF [20:20]
/// Wakeup from Stop mode flag
WUF: u1 = 0,
/// TEACK [21:21]
/// Transmit enable acknowledge flag
TEACK: u1 = 0,
/// REACK [22:22]
/// Receive enable acknowledge flag
REACK: u1 = 0,
/// unused [23:31]
_unused23: u1 = 0,
_unused24: u8 = 0,
};
/// Interrupt & status register
pub const ISR = Register(ISR_val).init(base_address + 0x1c);
/// ICR
const ICR_val = packed struct {
/// PECF [0:0]
/// Parity error clear flag
PECF: u1 = 0,
/// FECF [1:1]
/// Framing error clear flag
FECF: u1 = 0,
/// NCF [2:2]
/// Noise detected clear flag
NCF: u1 = 0,
/// ORECF [3:3]
/// Overrun error clear flag
ORECF: u1 = 0,
/// IDLECF [4:4]
/// Idle line detected clear flag
IDLECF: u1 = 0,
/// unused [5:5]
_unused5: u1 = 0,
/// TCCF [6:6]
/// Transmission complete clear flag
TCCF: u1 = 0,
/// unused [7:7]
_unused7: u1 = 0,
/// LBDCF [8:8]
/// LIN break detection clear flag
LBDCF: u1 = 0,
/// CTSCF [9:9]
/// CTS clear flag
CTSCF: u1 = 0,
/// unused [10:10]
_unused10: u1 = 0,
/// RTOCF [11:11]
/// Receiver timeout clear flag
RTOCF: u1 = 0,
/// EOBCF [12:12]
/// End of timeout clear flag
EOBCF: u1 = 0,
/// unused [13:16]
_unused13: u3 = 0,
_unused16: u1 = 0,
/// CMCF [17:17]
/// Character match clear flag
CMCF: u1 = 0,
/// unused [18:19]
_unused18: u2 = 0,
/// WUCF [20:20]
/// Wakeup from Stop mode clear flag
WUCF: u1 = 0,
/// unused [21:31]
_unused21: u3 = 0,
_unused24: u8 = 0,
};
/// Interrupt flag clear register
pub const ICR = Register(ICR_val).init(base_address + 0x20);
/// RDR
const RDR_val = packed struct {
/// RDR [0:8]
/// Receive data value
RDR: u9 = 0,
/// unused [9:31]
_unused9: u7 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Receive data register
pub const RDR = Register(RDR_val).init(base_address + 0x24);
/// TDR
const TDR_val = packed struct {
/// TDR [0:8]
/// Transmit data value
TDR: u9 = 0,
/// unused [9:31]
_unused9: u7 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Transmit data register
pub const TDR = Register(TDR_val).init(base_address + 0x28);
};
/// Universal synchronous asynchronous receiver transmitter
pub const UART4 = struct {
const base_address = 0x40004c00;
/// CR1
const CR1_val = packed struct {
/// UE [0:0]
/// USART enable
UE: u1 = 0,
/// UESM [1:1]
/// USART enable in Stop mode
UESM: u1 = 0,
/// RE [2:2]
/// Receiver enable
RE: u1 = 0,
/// TE [3:3]
/// Transmitter enable
TE: u1 = 0,
/// IDLEIE [4:4]
/// IDLE interrupt enable
IDLEIE: u1 = 0,
/// RXNEIE [5:5]
/// RXNE interrupt enable
RXNEIE: u1 = 0,
/// TCIE [6:6]
/// Transmission complete interrupt enable
TCIE: u1 = 0,
/// TXEIE [7:7]
/// interrupt enable
TXEIE: u1 = 0,
/// PEIE [8:8]
/// PE interrupt enable
PEIE: u1 = 0,
/// PS [9:9]
/// Parity selection
PS: u1 = 0,
/// PCE [10:10]
/// Parity control enable
PCE: u1 = 0,
/// WAKE [11:11]
/// Receiver wakeup method
WAKE: u1 = 0,
/// M [12:12]
/// Word length
M: u1 = 0,
/// MME [13:13]
/// Mute mode enable
MME: u1 = 0,
/// CMIE [14:14]
/// Character match interrupt enable
CMIE: u1 = 0,
/// OVER8 [15:15]
/// Oversampling mode
OVER8: u1 = 0,
/// DEDT [16:20]
/// Driver Enable deassertion time
DEDT: u5 = 0,
/// DEAT [21:25]
/// Driver Enable assertion time
DEAT: u5 = 0,
/// RTOIE [26:26]
/// Receiver timeout interrupt enable
RTOIE: u1 = 0,
/// EOBIE [27:27]
/// End of Block interrupt enable
EOBIE: u1 = 0,
/// unused [28:31]
_unused28: u4 = 0,
};
/// Control register 1
pub const CR1 = Register(CR1_val).init(base_address + 0x0);
/// CR2
const CR2_val = packed struct {
/// unused [0:3]
_unused0: u4 = 0,
/// ADDM7 [4:4]
/// 7-bit Address Detection/4-bit Address Detection
ADDM7: u1 = 0,
/// LBDL [5:5]
/// LIN break detection length
LBDL: u1 = 0,
/// LBDIE [6:6]
/// LIN break detection interrupt enable
LBDIE: u1 = 0,
/// unused [7:7]
_unused7: u1 = 0,
/// LBCL [8:8]
/// Last bit clock pulse
LBCL: u1 = 0,
/// CPHA [9:9]
/// Clock phase
CPHA: u1 = 0,
/// CPOL [10:10]
/// Clock polarity
CPOL: u1 = 0,
/// CLKEN [11:11]
/// Clock enable
CLKEN: u1 = 0,
/// STOP [12:13]
/// STOP bits
STOP: u2 = 0,
/// LINEN [14:14]
/// LIN mode enable
LINEN: u1 = 0,
/// SWAP [15:15]
/// Swap TX/RX pins
SWAP: u1 = 0,
/// RXINV [16:16]
/// RX pin active level inversion
RXINV: u1 = 0,
/// TXINV [17:17]
/// TX pin active level inversion
TXINV: u1 = 0,
/// DATAINV [18:18]
/// Binary data inversion
DATAINV: u1 = 0,
/// MSBFIRST [19:19]
/// Most significant bit first
MSBFIRST: u1 = 0,
/// ABREN [20:20]
/// Auto baud rate enable
ABREN: u1 = 0,
/// ABRMOD [21:22]
/// Auto baud rate mode
ABRMOD: u2 = 0,
/// RTOEN [23:23]
/// Receiver timeout enable
RTOEN: u1 = 0,
/// ADD0 [24:27]
/// Address of the USART node
ADD0: u4 = 0,
/// ADD4 [28:31]
/// Address of the USART node
ADD4: u4 = 0,
};
/// Control register 2
pub const CR2 = Register(CR2_val).init(base_address + 0x4);
/// CR3
const CR3_val = packed struct {
/// EIE [0:0]
/// Error interrupt enable
EIE: u1 = 0,
/// IREN [1:1]
/// IrDA mode enable
IREN: u1 = 0,
/// IRLP [2:2]
/// IrDA low-power
IRLP: u1 = 0,
/// HDSEL [3:3]
/// Half-duplex selection
HDSEL: u1 = 0,
/// NACK [4:4]
/// Smartcard NACK enable
NACK: u1 = 0,
/// SCEN [5:5]
/// Smartcard mode enable
SCEN: u1 = 0,
/// DMAR [6:6]
/// DMA enable receiver
DMAR: u1 = 0,
/// DMAT [7:7]
/// DMA enable transmitter
DMAT: u1 = 0,
/// RTSE [8:8]
/// RTS enable
RTSE: u1 = 0,
/// CTSE [9:9]
/// CTS enable
CTSE: u1 = 0,
/// CTSIE [10:10]
/// CTS interrupt enable
CTSIE: u1 = 0,
/// ONEBIT [11:11]
/// One sample bit method enable
ONEBIT: u1 = 0,
/// OVRDIS [12:12]
/// Overrun Disable
OVRDIS: u1 = 0,
/// DDRE [13:13]
/// DMA Disable on Reception Error
DDRE: u1 = 0,
/// DEM [14:14]
/// Driver enable mode
DEM: u1 = 0,
/// DEP [15:15]
/// Driver enable polarity selection
DEP: u1 = 0,
/// unused [16:16]
_unused16: u1 = 0,
/// SCARCNT [17:19]
/// Smartcard auto-retry count
SCARCNT: u3 = 0,
/// WUS [20:21]
/// Wakeup from Stop mode interrupt flag selection
WUS: u2 = 0,
/// WUFIE [22:22]
/// Wakeup from Stop mode interrupt enable
WUFIE: u1 = 0,
/// unused [23:31]
_unused23: u1 = 0,
_unused24: u8 = 0,
};
/// Control register 3
pub const CR3 = Register(CR3_val).init(base_address + 0x8);
/// BRR
const BRR_val = packed struct {
/// DIV_Fraction [0:3]
/// fraction of USARTDIV
DIV_Fraction: u4 = 0,
/// DIV_Mantissa [4:15]
/// mantissa of USARTDIV
DIV_Mantissa: u12 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Baud rate register
pub const BRR = Register(BRR_val).init(base_address + 0xc);
/// GTPR
const GTPR_val = packed struct {
/// PSC [0:7]
/// Prescaler value
PSC: u8 = 0,
/// GT [8:15]
/// Guard time value
GT: u8 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Guard time and prescaler register
pub const GTPR = Register(GTPR_val).init(base_address + 0x10);
/// RTOR
const RTOR_val = packed struct {
/// RTO [0:23]
/// Receiver timeout value
RTO: u24 = 0,
/// BLEN [24:31]
/// Block Length
BLEN: u8 = 0,
};
/// Receiver timeout register
pub const RTOR = Register(RTOR_val).init(base_address + 0x14);
/// RQR
const RQR_val = packed struct {
/// ABRRQ [0:0]
/// Auto baud rate request
ABRRQ: u1 = 0,
/// SBKRQ [1:1]
/// Send break request
SBKRQ: u1 = 0,
/// MMRQ [2:2]
/// Mute mode request
MMRQ: u1 = 0,
/// RXFRQ [3:3]
/// Receive data flush request
RXFRQ: u1 = 0,
/// TXFRQ [4:4]
/// Transmit data flush request
TXFRQ: u1 = 0,
/// unused [5:31]
_unused5: u3 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Request register
pub const RQR = Register(RQR_val).init(base_address + 0x18);
/// ISR
const ISR_val = packed struct {
/// PE [0:0]
/// Parity error
PE: u1 = 0,
/// FE [1:1]
/// Framing error
FE: u1 = 0,
/// NF [2:2]
/// Noise detected flag
NF: u1 = 0,
/// ORE [3:3]
/// Overrun error
ORE: u1 = 0,
/// IDLE [4:4]
/// Idle line detected
IDLE: u1 = 0,
/// RXNE [5:5]
/// Read data register not empty
RXNE: u1 = 0,
/// TC [6:6]
/// Transmission complete
TC: u1 = 1,
/// TXE [7:7]
/// Transmit data register empty
TXE: u1 = 1,
/// LBDF [8:8]
/// LIN break detection flag
LBDF: u1 = 0,
/// CTSIF [9:9]
/// CTS interrupt flag
CTSIF: u1 = 0,
/// CTS [10:10]
/// CTS flag
CTS: u1 = 0,
/// RTOF [11:11]
/// Receiver timeout
RTOF: u1 = 0,
/// EOBF [12:12]
/// End of block flag
EOBF: u1 = 0,
/// unused [13:13]
_unused13: u1 = 0,
/// ABRE [14:14]
/// Auto baud rate error
ABRE: u1 = 0,
/// ABRF [15:15]
/// Auto baud rate flag
ABRF: u1 = 0,
/// BUSY [16:16]
/// Busy flag
BUSY: u1 = 0,
/// CMF [17:17]
/// character match flag
CMF: u1 = 0,
/// SBKF [18:18]
/// Send break flag
SBKF: u1 = 0,
/// RWU [19:19]
/// Receiver wakeup from Mute mode
RWU: u1 = 0,
/// WUF [20:20]
/// Wakeup from Stop mode flag
WUF: u1 = 0,
/// TEACK [21:21]
/// Transmit enable acknowledge flag
TEACK: u1 = 0,
/// REACK [22:22]
/// Receive enable acknowledge flag
REACK: u1 = 0,
/// unused [23:31]
_unused23: u1 = 0,
_unused24: u8 = 0,
};
/// Interrupt & status register
pub const ISR = Register(ISR_val).init(base_address + 0x1c);
/// ICR
const ICR_val = packed struct {
/// PECF [0:0]
/// Parity error clear flag
PECF: u1 = 0,
/// FECF [1:1]
/// Framing error clear flag
FECF: u1 = 0,
/// NCF [2:2]
/// Noise detected clear flag
NCF: u1 = 0,
/// ORECF [3:3]
/// Overrun error clear flag
ORECF: u1 = 0,
/// IDLECF [4:4]
/// Idle line detected clear flag
IDLECF: u1 = 0,
/// unused [5:5]
_unused5: u1 = 0,
/// TCCF [6:6]
/// Transmission complete clear flag
TCCF: u1 = 0,
/// unused [7:7]
_unused7: u1 = 0,
/// LBDCF [8:8]
/// LIN break detection clear flag
LBDCF: u1 = 0,
/// CTSCF [9:9]
/// CTS clear flag
CTSCF: u1 = 0,
/// unused [10:10]
_unused10: u1 = 0,
/// RTOCF [11:11]
/// Receiver timeout clear flag
RTOCF: u1 = 0,
/// EOBCF [12:12]
/// End of timeout clear flag
EOBCF: u1 = 0,
/// unused [13:16]
_unused13: u3 = 0,
_unused16: u1 = 0,
/// CMCF [17:17]
/// Character match clear flag
CMCF: u1 = 0,
/// unused [18:19]
_unused18: u2 = 0,
/// WUCF [20:20]
/// Wakeup from Stop mode clear flag
WUCF: u1 = 0,
/// unused [21:31]
_unused21: u3 = 0,
_unused24: u8 = 0,
};
/// Interrupt flag clear register
pub const ICR = Register(ICR_val).init(base_address + 0x20);
/// RDR
const RDR_val = packed struct {
/// RDR [0:8]
/// Receive data value
RDR: u9 = 0,
/// unused [9:31]
_unused9: u7 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Receive data register
pub const RDR = Register(RDR_val).init(base_address + 0x24);
/// TDR
const TDR_val = packed struct {
/// TDR [0:8]
/// Transmit data value
TDR: u9 = 0,
/// unused [9:31]
_unused9: u7 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Transmit data register
pub const TDR = Register(TDR_val).init(base_address + 0x28);
};
/// Universal synchronous asynchronous receiver transmitter
pub const UART5 = struct {
const base_address = 0x40005000;
/// CR1
const CR1_val = packed struct {
/// UE [0:0]
/// USART enable
UE: u1 = 0,
/// UESM [1:1]
/// USART enable in Stop mode
UESM: u1 = 0,
/// RE [2:2]
/// Receiver enable
RE: u1 = 0,
/// TE [3:3]
/// Transmitter enable
TE: u1 = 0,
/// IDLEIE [4:4]
/// IDLE interrupt enable
IDLEIE: u1 = 0,
/// RXNEIE [5:5]
/// RXNE interrupt enable
RXNEIE: u1 = 0,
/// TCIE [6:6]
/// Transmission complete interrupt enable
TCIE: u1 = 0,
/// TXEIE [7:7]
/// interrupt enable
TXEIE: u1 = 0,
/// PEIE [8:8]
/// PE interrupt enable
PEIE: u1 = 0,
/// PS [9:9]
/// Parity selection
PS: u1 = 0,
/// PCE [10:10]
/// Parity control enable
PCE: u1 = 0,
/// WAKE [11:11]
/// Receiver wakeup method
WAKE: u1 = 0,
/// M [12:12]
/// Word length
M: u1 = 0,
/// MME [13:13]
/// Mute mode enable
MME: u1 = 0,
/// CMIE [14:14]
/// Character match interrupt enable
CMIE: u1 = 0,
/// OVER8 [15:15]
/// Oversampling mode
OVER8: u1 = 0,
/// DEDT [16:20]
/// Driver Enable deassertion time
DEDT: u5 = 0,
/// DEAT [21:25]
/// Driver Enable assertion time
DEAT: u5 = 0,
/// RTOIE [26:26]
/// Receiver timeout interrupt enable
RTOIE: u1 = 0,
/// EOBIE [27:27]
/// End of Block interrupt enable
EOBIE: u1 = 0,
/// unused [28:31]
_unused28: u4 = 0,
};
/// Control register 1
pub const CR1 = Register(CR1_val).init(base_address + 0x0);
/// CR2
const CR2_val = packed struct {
/// unused [0:3]
_unused0: u4 = 0,
/// ADDM7 [4:4]
/// 7-bit Address Detection/4-bit Address Detection
ADDM7: u1 = 0,
/// LBDL [5:5]
/// LIN break detection length
LBDL: u1 = 0,
/// LBDIE [6:6]
/// LIN break detection interrupt enable
LBDIE: u1 = 0,
/// unused [7:7]
_unused7: u1 = 0,
/// LBCL [8:8]
/// Last bit clock pulse
LBCL: u1 = 0,
/// CPHA [9:9]
/// Clock phase
CPHA: u1 = 0,
/// CPOL [10:10]
/// Clock polarity
CPOL: u1 = 0,
/// CLKEN [11:11]
/// Clock enable
CLKEN: u1 = 0,
/// STOP [12:13]
/// STOP bits
STOP: u2 = 0,
/// LINEN [14:14]
/// LIN mode enable
LINEN: u1 = 0,
/// SWAP [15:15]
/// Swap TX/RX pins
SWAP: u1 = 0,
/// RXINV [16:16]
/// RX pin active level inversion
RXINV: u1 = 0,
/// TXINV [17:17]
/// TX pin active level inversion
TXINV: u1 = 0,
/// DATAINV [18:18]
/// Binary data inversion
DATAINV: u1 = 0,
/// MSBFIRST [19:19]
/// Most significant bit first
MSBFIRST: u1 = 0,
/// ABREN [20:20]
/// Auto baud rate enable
ABREN: u1 = 0,
/// ABRMOD [21:22]
/// Auto baud rate mode
ABRMOD: u2 = 0,
/// RTOEN [23:23]
/// Receiver timeout enable
RTOEN: u1 = 0,
/// ADD0 [24:27]
/// Address of the USART node
ADD0: u4 = 0,
/// ADD4 [28:31]
/// Address of the USART node
ADD4: u4 = 0,
};
/// Control register 2
pub const CR2 = Register(CR2_val).init(base_address + 0x4);
/// CR3
const CR3_val = packed struct {
/// EIE [0:0]
/// Error interrupt enable
EIE: u1 = 0,
/// IREN [1:1]
/// IrDA mode enable
IREN: u1 = 0,
/// IRLP [2:2]
/// IrDA low-power
IRLP: u1 = 0,
/// HDSEL [3:3]
/// Half-duplex selection
HDSEL: u1 = 0,
/// NACK [4:4]
/// Smartcard NACK enable
NACK: u1 = 0,
/// SCEN [5:5]
/// Smartcard mode enable
SCEN: u1 = 0,
/// DMAR [6:6]
/// DMA enable receiver
DMAR: u1 = 0,
/// DMAT [7:7]
/// DMA enable transmitter
DMAT: u1 = 0,
/// RTSE [8:8]
/// RTS enable
RTSE: u1 = 0,
/// CTSE [9:9]
/// CTS enable
CTSE: u1 = 0,
/// CTSIE [10:10]
/// CTS interrupt enable
CTSIE: u1 = 0,
/// ONEBIT [11:11]
/// One sample bit method enable
ONEBIT: u1 = 0,
/// OVRDIS [12:12]
/// Overrun Disable
OVRDIS: u1 = 0,
/// DDRE [13:13]
/// DMA Disable on Reception Error
DDRE: u1 = 0,
/// DEM [14:14]
/// Driver enable mode
DEM: u1 = 0,
/// DEP [15:15]
/// Driver enable polarity selection
DEP: u1 = 0,
/// unused [16:16]
_unused16: u1 = 0,
/// SCARCNT [17:19]
/// Smartcard auto-retry count
SCARCNT: u3 = 0,
/// WUS [20:21]
/// Wakeup from Stop mode interrupt flag selection
WUS: u2 = 0,
/// WUFIE [22:22]
/// Wakeup from Stop mode interrupt enable
WUFIE: u1 = 0,
/// unused [23:31]
_unused23: u1 = 0,
_unused24: u8 = 0,
};
/// Control register 3
pub const CR3 = Register(CR3_val).init(base_address + 0x8);
/// BRR
const BRR_val = packed struct {
/// DIV_Fraction [0:3]
/// fraction of USARTDIV
DIV_Fraction: u4 = 0,
/// DIV_Mantissa [4:15]
/// mantissa of USARTDIV
DIV_Mantissa: u12 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Baud rate register
pub const BRR = Register(BRR_val).init(base_address + 0xc);
/// GTPR
const GTPR_val = packed struct {
/// PSC [0:7]
/// Prescaler value
PSC: u8 = 0,
/// GT [8:15]
/// Guard time value
GT: u8 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Guard time and prescaler register
pub const GTPR = Register(GTPR_val).init(base_address + 0x10);
/// RTOR
const RTOR_val = packed struct {
/// RTO [0:23]
/// Receiver timeout value
RTO: u24 = 0,
/// BLEN [24:31]
/// Block Length
BLEN: u8 = 0,
};
/// Receiver timeout register
pub const RTOR = Register(RTOR_val).init(base_address + 0x14);
/// RQR
const RQR_val = packed struct {
/// ABRRQ [0:0]
/// Auto baud rate request
ABRRQ: u1 = 0,
/// SBKRQ [1:1]
/// Send break request
SBKRQ: u1 = 0,
/// MMRQ [2:2]
/// Mute mode request
MMRQ: u1 = 0,
/// RXFRQ [3:3]
/// Receive data flush request
RXFRQ: u1 = 0,
/// TXFRQ [4:4]
/// Transmit data flush request
TXFRQ: u1 = 0,
/// unused [5:31]
_unused5: u3 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Request register
pub const RQR = Register(RQR_val).init(base_address + 0x18);
/// ISR
const ISR_val = packed struct {
/// PE [0:0]
/// Parity error
PE: u1 = 0,
/// FE [1:1]
/// Framing error
FE: u1 = 0,
/// NF [2:2]
/// Noise detected flag
NF: u1 = 0,
/// ORE [3:3]
/// Overrun error
ORE: u1 = 0,
/// IDLE [4:4]
/// Idle line detected
IDLE: u1 = 0,
/// RXNE [5:5]
/// Read data register not empty
RXNE: u1 = 0,
/// TC [6:6]
/// Transmission complete
TC: u1 = 1,
/// TXE [7:7]
/// Transmit data register empty
TXE: u1 = 1,
/// LBDF [8:8]
/// LIN break detection flag
LBDF: u1 = 0,
/// CTSIF [9:9]
/// CTS interrupt flag
CTSIF: u1 = 0,
/// CTS [10:10]
/// CTS flag
CTS: u1 = 0,
/// RTOF [11:11]
/// Receiver timeout
RTOF: u1 = 0,
/// EOBF [12:12]
/// End of block flag
EOBF: u1 = 0,
/// unused [13:13]
_unused13: u1 = 0,
/// ABRE [14:14]
/// Auto baud rate error
ABRE: u1 = 0,
/// ABRF [15:15]
/// Auto baud rate flag
ABRF: u1 = 0,
/// BUSY [16:16]
/// Busy flag
BUSY: u1 = 0,
/// CMF [17:17]
/// character match flag
CMF: u1 = 0,
/// SBKF [18:18]
/// Send break flag
SBKF: u1 = 0,
/// RWU [19:19]
/// Receiver wakeup from Mute mode
RWU: u1 = 0,
/// WUF [20:20]
/// Wakeup from Stop mode flag
WUF: u1 = 0,
/// TEACK [21:21]
/// Transmit enable acknowledge flag
TEACK: u1 = 0,
/// REACK [22:22]
/// Receive enable acknowledge flag
REACK: u1 = 0,
/// unused [23:31]
_unused23: u1 = 0,
_unused24: u8 = 0,
};
/// Interrupt & status register
pub const ISR = Register(ISR_val).init(base_address + 0x1c);
/// ICR
const ICR_val = packed struct {
/// PECF [0:0]
/// Parity error clear flag
PECF: u1 = 0,
/// FECF [1:1]
/// Framing error clear flag
FECF: u1 = 0,
/// NCF [2:2]
/// Noise detected clear flag
NCF: u1 = 0,
/// ORECF [3:3]
/// Overrun error clear flag
ORECF: u1 = 0,
/// IDLECF [4:4]
/// Idle line detected clear flag
IDLECF: u1 = 0,
/// unused [5:5]
_unused5: u1 = 0,
/// TCCF [6:6]
/// Transmission complete clear flag
TCCF: u1 = 0,
/// unused [7:7]
_unused7: u1 = 0,
/// LBDCF [8:8]
/// LIN break detection clear flag
LBDCF: u1 = 0,
/// CTSCF [9:9]
/// CTS clear flag
CTSCF: u1 = 0,
/// unused [10:10]
_unused10: u1 = 0,
/// RTOCF [11:11]
/// Receiver timeout clear flag
RTOCF: u1 = 0,
/// EOBCF [12:12]
/// End of timeout clear flag
EOBCF: u1 = 0,
/// unused [13:16]
_unused13: u3 = 0,
_unused16: u1 = 0,
/// CMCF [17:17]
/// Character match clear flag
CMCF: u1 = 0,
/// unused [18:19]
_unused18: u2 = 0,
/// WUCF [20:20]
/// Wakeup from Stop mode clear flag
WUCF: u1 = 0,
/// unused [21:31]
_unused21: u3 = 0,
_unused24: u8 = 0,
};
/// Interrupt flag clear register
pub const ICR = Register(ICR_val).init(base_address + 0x20);
/// RDR
const RDR_val = packed struct {
/// RDR [0:8]
/// Receive data value
RDR: u9 = 0,
/// unused [9:31]
_unused9: u7 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Receive data register
pub const RDR = Register(RDR_val).init(base_address + 0x24);
/// TDR
const TDR_val = packed struct {
/// TDR [0:8]
/// Transmit data value
TDR: u9 = 0,
/// unused [9:31]
_unused9: u7 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Transmit data register
pub const TDR = Register(TDR_val).init(base_address + 0x28);
};
/// Serial peripheral interface/Inter-IC sound
pub const SPI1 = struct {
const base_address = 0x40013000;
/// CR1
const CR1_val = packed struct {
/// CPHA [0:0]
/// Clock phase
CPHA: u1 = 0,
/// CPOL [1:1]
/// Clock polarity
CPOL: u1 = 0,
/// MSTR [2:2]
/// Master selection
MSTR: u1 = 0,
/// BR [3:5]
/// Baud rate control
BR: u3 = 0,
/// SPE [6:6]
/// SPI enable
SPE: u1 = 0,
/// LSBFIRST [7:7]
/// Frame format
LSBFIRST: u1 = 0,
/// SSI [8:8]
/// Internal slave select
SSI: u1 = 0,
/// SSM [9:9]
/// Software slave management
SSM: u1 = 0,
/// RXONLY [10:10]
/// Receive only
RXONLY: u1 = 0,
/// DFF [11:11]
/// Data frame format
DFF: u1 = 0,
/// CRCNEXT [12:12]
/// CRC transfer next
CRCNEXT: u1 = 0,
/// CRCEN [13:13]
/// Hardware CRC calculation enable
CRCEN: u1 = 0,
/// BIDIOE [14:14]
/// Output enable in bidirectional mode
BIDIOE: u1 = 0,
/// BIDIMODE [15:15]
/// Bidirectional data mode enable
BIDIMODE: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// control register 1
pub const CR1 = Register(CR1_val).init(base_address + 0x0);
/// CR2
const CR2_val = packed struct {
/// RXDMAEN [0:0]
/// Rx buffer DMA enable
RXDMAEN: u1 = 0,
/// TXDMAEN [1:1]
/// Tx buffer DMA enable
TXDMAEN: u1 = 0,
/// SSOE [2:2]
/// SS output enable
SSOE: u1 = 0,
/// NSSP [3:3]
/// NSS pulse management
NSSP: u1 = 0,
/// FRF [4:4]
/// Frame format
FRF: u1 = 0,
/// ERRIE [5:5]
/// Error interrupt enable
ERRIE: u1 = 0,
/// RXNEIE [6:6]
/// RX buffer not empty interrupt enable
RXNEIE: u1 = 0,
/// TXEIE [7:7]
/// Tx buffer empty interrupt enable
TXEIE: u1 = 0,
/// DS [8:11]
/// Data size
DS: u4 = 0,
/// FRXTH [12:12]
/// FIFO reception threshold
FRXTH: u1 = 0,
/// LDMA_RX [13:13]
/// Last DMA transfer for reception
LDMA_RX: u1 = 0,
/// LDMA_TX [14:14]
/// Last DMA transfer for transmission
LDMA_TX: u1 = 0,
/// unused [15:31]
_unused15: u1 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// control register 2
pub const CR2 = Register(CR2_val).init(base_address + 0x4);
/// SR
const SR_val = packed struct {
/// RXNE [0:0]
/// Receive buffer not empty
RXNE: u1 = 0,
/// TXE [1:1]
/// Transmit buffer empty
TXE: u1 = 1,
/// CHSIDE [2:2]
/// Channel side
CHSIDE: u1 = 0,
/// UDR [3:3]
/// Underrun flag
UDR: u1 = 0,
/// CRCERR [4:4]
/// CRC error flag
CRCERR: u1 = 0,
/// MODF [5:5]
/// Mode fault
MODF: u1 = 0,
/// OVR [6:6]
/// Overrun flag
OVR: u1 = 0,
/// BSY [7:7]
/// Busy flag
BSY: u1 = 0,
/// TIFRFE [8:8]
/// TI frame format error
TIFRFE: u1 = 0,
/// FRLVL [9:10]
/// FIFO reception level
FRLVL: u2 = 0,
/// FTLVL [11:12]
/// FIFO transmission level
FTLVL: u2 = 0,
/// unused [13:31]
_unused13: u3 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// status register
pub const SR = Register(SR_val).init(base_address + 0x8);
/// DR
const DR_val = packed struct {
/// DR [0:15]
/// Data register
DR: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// data register
pub const DR = Register(DR_val).init(base_address + 0xc);
/// CRCPR
const CRCPR_val = packed struct {
/// CRCPOLY [0:15]
/// CRC polynomial register
CRCPOLY: u16 = 7,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// CRC polynomial register
pub const CRCPR = Register(CRCPR_val).init(base_address + 0x10);
/// RXCRCR
const RXCRCR_val = packed struct {
/// RxCRC [0:15]
/// Rx CRC register
RxCRC: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// RX CRC register
pub const RXCRCR = Register(RXCRCR_val).init(base_address + 0x14);
/// TXCRCR
const TXCRCR_val = packed struct {
/// TxCRC [0:15]
/// Tx CRC register
TxCRC: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// TX CRC register
pub const TXCRCR = Register(TXCRCR_val).init(base_address + 0x18);
/// I2SCFGR
const I2SCFGR_val = packed struct {
/// CHLEN [0:0]
/// Channel length (number of bits per audio channel)
CHLEN: u1 = 0,
/// DATLEN [1:2]
/// Data length to be transferred
DATLEN: u2 = 0,
/// CKPOL [3:3]
/// Steady state clock polarity
CKPOL: u1 = 0,
/// I2SSTD [4:5]
/// I2S standard selection
I2SSTD: u2 = 0,
/// unused [6:6]
_unused6: u1 = 0,
/// PCMSYNC [7:7]
/// PCM frame synchronization
PCMSYNC: u1 = 0,
/// I2SCFG [8:9]
/// I2S configuration mode
I2SCFG: u2 = 0,
/// I2SE [10:10]
/// I2S Enable
I2SE: u1 = 0,
/// I2SMOD [11:11]
/// I2S mode selection
I2SMOD: u1 = 0,
/// unused [12:31]
_unused12: u4 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// I2S configuration register
pub const I2SCFGR = Register(I2SCFGR_val).init(base_address + 0x1c);
/// I2SPR
const I2SPR_val = packed struct {
/// I2SDIV [0:7]
/// I2S Linear prescaler
I2SDIV: u8 = 16,
/// ODD [8:8]
/// Odd factor for the prescaler
ODD: u1 = 0,
/// MCKOE [9:9]
/// Master clock output enable
MCKOE: u1 = 0,
/// unused [10:31]
_unused10: u6 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// I2S prescaler register
pub const I2SPR = Register(I2SPR_val).init(base_address + 0x20);
};
/// Serial peripheral interface/Inter-IC sound
pub const SPI2 = struct {
const base_address = 0x40003800;
/// CR1
const CR1_val = packed struct {
/// CPHA [0:0]
/// Clock phase
CPHA: u1 = 0,
/// CPOL [1:1]
/// Clock polarity
CPOL: u1 = 0,
/// MSTR [2:2]
/// Master selection
MSTR: u1 = 0,
/// BR [3:5]
/// Baud rate control
BR: u3 = 0,
/// SPE [6:6]
/// SPI enable
SPE: u1 = 0,
/// LSBFIRST [7:7]
/// Frame format
LSBFIRST: u1 = 0,
/// SSI [8:8]
/// Internal slave select
SSI: u1 = 0,
/// SSM [9:9]
/// Software slave management
SSM: u1 = 0,
/// RXONLY [10:10]
/// Receive only
RXONLY: u1 = 0,
/// DFF [11:11]
/// Data frame format
DFF: u1 = 0,
/// CRCNEXT [12:12]
/// CRC transfer next
CRCNEXT: u1 = 0,
/// CRCEN [13:13]
/// Hardware CRC calculation enable
CRCEN: u1 = 0,
/// BIDIOE [14:14]
/// Output enable in bidirectional mode
BIDIOE: u1 = 0,
/// BIDIMODE [15:15]
/// Bidirectional data mode enable
BIDIMODE: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// control register 1
pub const CR1 = Register(CR1_val).init(base_address + 0x0);
/// CR2
const CR2_val = packed struct {
/// RXDMAEN [0:0]
/// Rx buffer DMA enable
RXDMAEN: u1 = 0,
/// TXDMAEN [1:1]
/// Tx buffer DMA enable
TXDMAEN: u1 = 0,
/// SSOE [2:2]
/// SS output enable
SSOE: u1 = 0,
/// NSSP [3:3]
/// NSS pulse management
NSSP: u1 = 0,
/// FRF [4:4]
/// Frame format
FRF: u1 = 0,
/// ERRIE [5:5]
/// Error interrupt enable
ERRIE: u1 = 0,
/// RXNEIE [6:6]
/// RX buffer not empty interrupt enable
RXNEIE: u1 = 0,
/// TXEIE [7:7]
/// Tx buffer empty interrupt enable
TXEIE: u1 = 0,
/// DS [8:11]
/// Data size
DS: u4 = 0,
/// FRXTH [12:12]
/// FIFO reception threshold
FRXTH: u1 = 0,
/// LDMA_RX [13:13]
/// Last DMA transfer for reception
LDMA_RX: u1 = 0,
/// LDMA_TX [14:14]
/// Last DMA transfer for transmission
LDMA_TX: u1 = 0,
/// unused [15:31]
_unused15: u1 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// control register 2
pub const CR2 = Register(CR2_val).init(base_address + 0x4);
/// SR
const SR_val = packed struct {
/// RXNE [0:0]
/// Receive buffer not empty
RXNE: u1 = 0,
/// TXE [1:1]
/// Transmit buffer empty
TXE: u1 = 1,
/// CHSIDE [2:2]
/// Channel side
CHSIDE: u1 = 0,
/// UDR [3:3]
/// Underrun flag
UDR: u1 = 0,
/// CRCERR [4:4]
/// CRC error flag
CRCERR: u1 = 0,
/// MODF [5:5]
/// Mode fault
MODF: u1 = 0,
/// OVR [6:6]
/// Overrun flag
OVR: u1 = 0,
/// BSY [7:7]
/// Busy flag
BSY: u1 = 0,
/// TIFRFE [8:8]
/// TI frame format error
TIFRFE: u1 = 0,
/// FRLVL [9:10]
/// FIFO reception level
FRLVL: u2 = 0,
/// FTLVL [11:12]
/// FIFO transmission level
FTLVL: u2 = 0,
/// unused [13:31]
_unused13: u3 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// status register
pub const SR = Register(SR_val).init(base_address + 0x8);
/// DR
const DR_val = packed struct {
/// DR [0:15]
/// Data register
DR: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// data register
pub const DR = Register(DR_val).init(base_address + 0xc);
/// CRCPR
const CRCPR_val = packed struct {
/// CRCPOLY [0:15]
/// CRC polynomial register
CRCPOLY: u16 = 7,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// CRC polynomial register
pub const CRCPR = Register(CRCPR_val).init(base_address + 0x10);
/// RXCRCR
const RXCRCR_val = packed struct {
/// RxCRC [0:15]
/// Rx CRC register
RxCRC: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// RX CRC register
pub const RXCRCR = Register(RXCRCR_val).init(base_address + 0x14);
/// TXCRCR
const TXCRCR_val = packed struct {
/// TxCRC [0:15]
/// Tx CRC register
TxCRC: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// TX CRC register
pub const TXCRCR = Register(TXCRCR_val).init(base_address + 0x18);
/// I2SCFGR
const I2SCFGR_val = packed struct {
/// CHLEN [0:0]
/// Channel length (number of bits per audio channel)
CHLEN: u1 = 0,
/// DATLEN [1:2]
/// Data length to be transferred
DATLEN: u2 = 0,
/// CKPOL [3:3]
/// Steady state clock polarity
CKPOL: u1 = 0,
/// I2SSTD [4:5]
/// I2S standard selection
I2SSTD: u2 = 0,
/// unused [6:6]
_unused6: u1 = 0,
/// PCMSYNC [7:7]
/// PCM frame synchronization
PCMSYNC: u1 = 0,
/// I2SCFG [8:9]
/// I2S configuration mode
I2SCFG: u2 = 0,
/// I2SE [10:10]
/// I2S Enable
I2SE: u1 = 0,
/// I2SMOD [11:11]
/// I2S mode selection
I2SMOD: u1 = 0,
/// unused [12:31]
_unused12: u4 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// I2S configuration register
pub const I2SCFGR = Register(I2SCFGR_val).init(base_address + 0x1c);
/// I2SPR
const I2SPR_val = packed struct {
/// I2SDIV [0:7]
/// I2S Linear prescaler
I2SDIV: u8 = 16,
/// ODD [8:8]
/// Odd factor for the prescaler
ODD: u1 = 0,
/// MCKOE [9:9]
/// Master clock output enable
MCKOE: u1 = 0,
/// unused [10:31]
_unused10: u6 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// I2S prescaler register
pub const I2SPR = Register(I2SPR_val).init(base_address + 0x20);
};
/// Serial peripheral interface/Inter-IC sound
pub const SPI3 = struct {
const base_address = 0x40003c00;
/// CR1
const CR1_val = packed struct {
/// CPHA [0:0]
/// Clock phase
CPHA: u1 = 0,
/// CPOL [1:1]
/// Clock polarity
CPOL: u1 = 0,
/// MSTR [2:2]
/// Master selection
MSTR: u1 = 0,
/// BR [3:5]
/// Baud rate control
BR: u3 = 0,
/// SPE [6:6]
/// SPI enable
SPE: u1 = 0,
/// LSBFIRST [7:7]
/// Frame format
LSBFIRST: u1 = 0,
/// SSI [8:8]
/// Internal slave select
SSI: u1 = 0,
/// SSM [9:9]
/// Software slave management
SSM: u1 = 0,
/// RXONLY [10:10]
/// Receive only
RXONLY: u1 = 0,
/// DFF [11:11]
/// Data frame format
DFF: u1 = 0,
/// CRCNEXT [12:12]
/// CRC transfer next
CRCNEXT: u1 = 0,
/// CRCEN [13:13]
/// Hardware CRC calculation enable
CRCEN: u1 = 0,
/// BIDIOE [14:14]
/// Output enable in bidirectional mode
BIDIOE: u1 = 0,
/// BIDIMODE [15:15]
/// Bidirectional data mode enable
BIDIMODE: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// control register 1
pub const CR1 = Register(CR1_val).init(base_address + 0x0);
/// CR2
const CR2_val = packed struct {
/// RXDMAEN [0:0]
/// Rx buffer DMA enable
RXDMAEN: u1 = 0,
/// TXDMAEN [1:1]
/// Tx buffer DMA enable
TXDMAEN: u1 = 0,
/// SSOE [2:2]
/// SS output enable
SSOE: u1 = 0,
/// NSSP [3:3]
/// NSS pulse management
NSSP: u1 = 0,
/// FRF [4:4]
/// Frame format
FRF: u1 = 0,
/// ERRIE [5:5]
/// Error interrupt enable
ERRIE: u1 = 0,
/// RXNEIE [6:6]
/// RX buffer not empty interrupt enable
RXNEIE: u1 = 0,
/// TXEIE [7:7]
/// Tx buffer empty interrupt enable
TXEIE: u1 = 0,
/// DS [8:11]
/// Data size
DS: u4 = 0,
/// FRXTH [12:12]
/// FIFO reception threshold
FRXTH: u1 = 0,
/// LDMA_RX [13:13]
/// Last DMA transfer for reception
LDMA_RX: u1 = 0,
/// LDMA_TX [14:14]
/// Last DMA transfer for transmission
LDMA_TX: u1 = 0,
/// unused [15:31]
_unused15: u1 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// control register 2
pub const CR2 = Register(CR2_val).init(base_address + 0x4);
/// SR
const SR_val = packed struct {
/// RXNE [0:0]
/// Receive buffer not empty
RXNE: u1 = 0,
/// TXE [1:1]
/// Transmit buffer empty
TXE: u1 = 1,
/// CHSIDE [2:2]
/// Channel side
CHSIDE: u1 = 0,
/// UDR [3:3]
/// Underrun flag
UDR: u1 = 0,
/// CRCERR [4:4]
/// CRC error flag
CRCERR: u1 = 0,
/// MODF [5:5]
/// Mode fault
MODF: u1 = 0,
/// OVR [6:6]
/// Overrun flag
OVR: u1 = 0,
/// BSY [7:7]
/// Busy flag
BSY: u1 = 0,
/// TIFRFE [8:8]
/// TI frame format error
TIFRFE: u1 = 0,
/// FRLVL [9:10]
/// FIFO reception level
FRLVL: u2 = 0,
/// FTLVL [11:12]
/// FIFO transmission level
FTLVL: u2 = 0,
/// unused [13:31]
_unused13: u3 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// status register
pub const SR = Register(SR_val).init(base_address + 0x8);
/// DR
const DR_val = packed struct {
/// DR [0:15]
/// Data register
DR: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// data register
pub const DR = Register(DR_val).init(base_address + 0xc);
/// CRCPR
const CRCPR_val = packed struct {
/// CRCPOLY [0:15]
/// CRC polynomial register
CRCPOLY: u16 = 7,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// CRC polynomial register
pub const CRCPR = Register(CRCPR_val).init(base_address + 0x10);
/// RXCRCR
const RXCRCR_val = packed struct {
/// RxCRC [0:15]
/// Rx CRC register
RxCRC: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// RX CRC register
pub const RXCRCR = Register(RXCRCR_val).init(base_address + 0x14);
/// TXCRCR
const TXCRCR_val = packed struct {
/// TxCRC [0:15]
/// Tx CRC register
TxCRC: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// TX CRC register
pub const TXCRCR = Register(TXCRCR_val).init(base_address + 0x18);
/// I2SCFGR
const I2SCFGR_val = packed struct {
/// CHLEN [0:0]
/// Channel length (number of bits per audio channel)
CHLEN: u1 = 0,
/// DATLEN [1:2]
/// Data length to be transferred
DATLEN: u2 = 0,
/// CKPOL [3:3]
/// Steady state clock polarity
CKPOL: u1 = 0,
/// I2SSTD [4:5]
/// I2S standard selection
I2SSTD: u2 = 0,
/// unused [6:6]
_unused6: u1 = 0,
/// PCMSYNC [7:7]
/// PCM frame synchronization
PCMSYNC: u1 = 0,
/// I2SCFG [8:9]
/// I2S configuration mode
I2SCFG: u2 = 0,
/// I2SE [10:10]
/// I2S Enable
I2SE: u1 = 0,
/// I2SMOD [11:11]
/// I2S mode selection
I2SMOD: u1 = 0,
/// unused [12:31]
_unused12: u4 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// I2S configuration register
pub const I2SCFGR = Register(I2SCFGR_val).init(base_address + 0x1c);
/// I2SPR
const I2SPR_val = packed struct {
/// I2SDIV [0:7]
/// I2S Linear prescaler
I2SDIV: u8 = 16,
/// ODD [8:8]
/// Odd factor for the prescaler
ODD: u1 = 0,
/// MCKOE [9:9]
/// Master clock output enable
MCKOE: u1 = 0,
/// unused [10:31]
_unused10: u6 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// I2S prescaler register
pub const I2SPR = Register(I2SPR_val).init(base_address + 0x20);
};
/// Serial peripheral interface/Inter-IC sound
pub const I2S2ext = struct {
const base_address = 0x40003400;
/// CR1
const CR1_val = packed struct {
/// CPHA [0:0]
/// Clock phase
CPHA: u1 = 0,
/// CPOL [1:1]
/// Clock polarity
CPOL: u1 = 0,
/// MSTR [2:2]
/// Master selection
MSTR: u1 = 0,
/// BR [3:5]
/// Baud rate control
BR: u3 = 0,
/// SPE [6:6]
/// SPI enable
SPE: u1 = 0,
/// LSBFIRST [7:7]
/// Frame format
LSBFIRST: u1 = 0,
/// SSI [8:8]
/// Internal slave select
SSI: u1 = 0,
/// SSM [9:9]
/// Software slave management
SSM: u1 = 0,
/// RXONLY [10:10]
/// Receive only
RXONLY: u1 = 0,
/// DFF [11:11]
/// Data frame format
DFF: u1 = 0,
/// CRCNEXT [12:12]
/// CRC transfer next
CRCNEXT: u1 = 0,
/// CRCEN [13:13]
/// Hardware CRC calculation enable
CRCEN: u1 = 0,
/// BIDIOE [14:14]
/// Output enable in bidirectional mode
BIDIOE: u1 = 0,
/// BIDIMODE [15:15]
/// Bidirectional data mode enable
BIDIMODE: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// control register 1
pub const CR1 = Register(CR1_val).init(base_address + 0x0);
/// CR2
const CR2_val = packed struct {
/// RXDMAEN [0:0]
/// Rx buffer DMA enable
RXDMAEN: u1 = 0,
/// TXDMAEN [1:1]
/// Tx buffer DMA enable
TXDMAEN: u1 = 0,
/// SSOE [2:2]
/// SS output enable
SSOE: u1 = 0,
/// NSSP [3:3]
/// NSS pulse management
NSSP: u1 = 0,
/// FRF [4:4]
/// Frame format
FRF: u1 = 0,
/// ERRIE [5:5]
/// Error interrupt enable
ERRIE: u1 = 0,
/// RXNEIE [6:6]
/// RX buffer not empty interrupt enable
RXNEIE: u1 = 0,
/// TXEIE [7:7]
/// Tx buffer empty interrupt enable
TXEIE: u1 = 0,
/// DS [8:11]
/// Data size
DS: u4 = 0,
/// FRXTH [12:12]
/// FIFO reception threshold
FRXTH: u1 = 0,
/// LDMA_RX [13:13]
/// Last DMA transfer for reception
LDMA_RX: u1 = 0,
/// LDMA_TX [14:14]
/// Last DMA transfer for transmission
LDMA_TX: u1 = 0,
/// unused [15:31]
_unused15: u1 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// control register 2
pub const CR2 = Register(CR2_val).init(base_address + 0x4);
/// SR
const SR_val = packed struct {
/// RXNE [0:0]
/// Receive buffer not empty
RXNE: u1 = 0,
/// TXE [1:1]
/// Transmit buffer empty
TXE: u1 = 1,
/// CHSIDE [2:2]
/// Channel side
CHSIDE: u1 = 0,
/// UDR [3:3]
/// Underrun flag
UDR: u1 = 0,
/// CRCERR [4:4]
/// CRC error flag
CRCERR: u1 = 0,
/// MODF [5:5]
/// Mode fault
MODF: u1 = 0,
/// OVR [6:6]
/// Overrun flag
OVR: u1 = 0,
/// BSY [7:7]
/// Busy flag
BSY: u1 = 0,
/// TIFRFE [8:8]
/// TI frame format error
TIFRFE: u1 = 0,
/// FRLVL [9:10]
/// FIFO reception level
FRLVL: u2 = 0,
/// FTLVL [11:12]
/// FIFO transmission level
FTLVL: u2 = 0,
/// unused [13:31]
_unused13: u3 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// status register
pub const SR = Register(SR_val).init(base_address + 0x8);
/// DR
const DR_val = packed struct {
/// DR [0:15]
/// Data register
DR: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// data register
pub const DR = Register(DR_val).init(base_address + 0xc);
/// CRCPR
const CRCPR_val = packed struct {
/// CRCPOLY [0:15]
/// CRC polynomial register
CRCPOLY: u16 = 7,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// CRC polynomial register
pub const CRCPR = Register(CRCPR_val).init(base_address + 0x10);
/// RXCRCR
const RXCRCR_val = packed struct {
/// RxCRC [0:15]
/// Rx CRC register
RxCRC: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// RX CRC register
pub const RXCRCR = Register(RXCRCR_val).init(base_address + 0x14);
/// TXCRCR
const TXCRCR_val = packed struct {
/// TxCRC [0:15]
/// Tx CRC register
TxCRC: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// TX CRC register
pub const TXCRCR = Register(TXCRCR_val).init(base_address + 0x18);
/// I2SCFGR
const I2SCFGR_val = packed struct {
/// CHLEN [0:0]
/// Channel length (number of bits per audio channel)
CHLEN: u1 = 0,
/// DATLEN [1:2]
/// Data length to be transferred
DATLEN: u2 = 0,
/// CKPOL [3:3]
/// Steady state clock polarity
CKPOL: u1 = 0,
/// I2SSTD [4:5]
/// I2S standard selection
I2SSTD: u2 = 0,
/// unused [6:6]
_unused6: u1 = 0,
/// PCMSYNC [7:7]
/// PCM frame synchronization
PCMSYNC: u1 = 0,
/// I2SCFG [8:9]
/// I2S configuration mode
I2SCFG: u2 = 0,
/// I2SE [10:10]
/// I2S Enable
I2SE: u1 = 0,
/// I2SMOD [11:11]
/// I2S mode selection
I2SMOD: u1 = 0,
/// unused [12:31]
_unused12: u4 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// I2S configuration register
pub const I2SCFGR = Register(I2SCFGR_val).init(base_address + 0x1c);
/// I2SPR
const I2SPR_val = packed struct {
/// I2SDIV [0:7]
/// I2S Linear prescaler
I2SDIV: u8 = 16,
/// ODD [8:8]
/// Odd factor for the prescaler
ODD: u1 = 0,
/// MCKOE [9:9]
/// Master clock output enable
MCKOE: u1 = 0,
/// unused [10:31]
_unused10: u6 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// I2S prescaler register
pub const I2SPR = Register(I2SPR_val).init(base_address + 0x20);
};
/// Serial peripheral interface/Inter-IC sound
pub const I2S3ext = struct {
const base_address = 0x40004000;
/// CR1
const CR1_val = packed struct {
/// CPHA [0:0]
/// Clock phase
CPHA: u1 = 0,
/// CPOL [1:1]
/// Clock polarity
CPOL: u1 = 0,
/// MSTR [2:2]
/// Master selection
MSTR: u1 = 0,
/// BR [3:5]
/// Baud rate control
BR: u3 = 0,
/// SPE [6:6]
/// SPI enable
SPE: u1 = 0,
/// LSBFIRST [7:7]
/// Frame format
LSBFIRST: u1 = 0,
/// SSI [8:8]
/// Internal slave select
SSI: u1 = 0,
/// SSM [9:9]
/// Software slave management
SSM: u1 = 0,
/// RXONLY [10:10]
/// Receive only
RXONLY: u1 = 0,
/// DFF [11:11]
/// Data frame format
DFF: u1 = 0,
/// CRCNEXT [12:12]
/// CRC transfer next
CRCNEXT: u1 = 0,
/// CRCEN [13:13]
/// Hardware CRC calculation enable
CRCEN: u1 = 0,
/// BIDIOE [14:14]
/// Output enable in bidirectional mode
BIDIOE: u1 = 0,
/// BIDIMODE [15:15]
/// Bidirectional data mode enable
BIDIMODE: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// control register 1
pub const CR1 = Register(CR1_val).init(base_address + 0x0);
/// CR2
const CR2_val = packed struct {
/// RXDMAEN [0:0]
/// Rx buffer DMA enable
RXDMAEN: u1 = 0,
/// TXDMAEN [1:1]
/// Tx buffer DMA enable
TXDMAEN: u1 = 0,
/// SSOE [2:2]
/// SS output enable
SSOE: u1 = 0,
/// NSSP [3:3]
/// NSS pulse management
NSSP: u1 = 0,
/// FRF [4:4]
/// Frame format
FRF: u1 = 0,
/// ERRIE [5:5]
/// Error interrupt enable
ERRIE: u1 = 0,
/// RXNEIE [6:6]
/// RX buffer not empty interrupt enable
RXNEIE: u1 = 0,
/// TXEIE [7:7]
/// Tx buffer empty interrupt enable
TXEIE: u1 = 0,
/// DS [8:11]
/// Data size
DS: u4 = 0,
/// FRXTH [12:12]
/// FIFO reception threshold
FRXTH: u1 = 0,
/// LDMA_RX [13:13]
/// Last DMA transfer for reception
LDMA_RX: u1 = 0,
/// LDMA_TX [14:14]
/// Last DMA transfer for transmission
LDMA_TX: u1 = 0,
/// unused [15:31]
_unused15: u1 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// control register 2
pub const CR2 = Register(CR2_val).init(base_address + 0x4);
/// SR
const SR_val = packed struct {
/// RXNE [0:0]
/// Receive buffer not empty
RXNE: u1 = 0,
/// TXE [1:1]
/// Transmit buffer empty
TXE: u1 = 1,
/// CHSIDE [2:2]
/// Channel side
CHSIDE: u1 = 0,
/// UDR [3:3]
/// Underrun flag
UDR: u1 = 0,
/// CRCERR [4:4]
/// CRC error flag
CRCERR: u1 = 0,
/// MODF [5:5]
/// Mode fault
MODF: u1 = 0,
/// OVR [6:6]
/// Overrun flag
OVR: u1 = 0,
/// BSY [7:7]
/// Busy flag
BSY: u1 = 0,
/// TIFRFE [8:8]
/// TI frame format error
TIFRFE: u1 = 0,
/// FRLVL [9:10]
/// FIFO reception level
FRLVL: u2 = 0,
/// FTLVL [11:12]
/// FIFO transmission level
FTLVL: u2 = 0,
/// unused [13:31]
_unused13: u3 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// status register
pub const SR = Register(SR_val).init(base_address + 0x8);
/// DR
const DR_val = packed struct {
/// DR [0:15]
/// Data register
DR: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// data register
pub const DR = Register(DR_val).init(base_address + 0xc);
/// CRCPR
const CRCPR_val = packed struct {
/// CRCPOLY [0:15]
/// CRC polynomial register
CRCPOLY: u16 = 7,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// CRC polynomial register
pub const CRCPR = Register(CRCPR_val).init(base_address + 0x10);
/// RXCRCR
const RXCRCR_val = packed struct {
/// RxCRC [0:15]
/// Rx CRC register
RxCRC: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// RX CRC register
pub const RXCRCR = Register(RXCRCR_val).init(base_address + 0x14);
/// TXCRCR
const TXCRCR_val = packed struct {
/// TxCRC [0:15]
/// Tx CRC register
TxCRC: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// TX CRC register
pub const TXCRCR = Register(TXCRCR_val).init(base_address + 0x18);
/// I2SCFGR
const I2SCFGR_val = packed struct {
/// CHLEN [0:0]
/// Channel length (number of bits per audio channel)
CHLEN: u1 = 0,
/// DATLEN [1:2]
/// Data length to be transferred
DATLEN: u2 = 0,
/// CKPOL [3:3]
/// Steady state clock polarity
CKPOL: u1 = 0,
/// I2SSTD [4:5]
/// I2S standard selection
I2SSTD: u2 = 0,
/// unused [6:6]
_unused6: u1 = 0,
/// PCMSYNC [7:7]
/// PCM frame synchronization
PCMSYNC: u1 = 0,
/// I2SCFG [8:9]
/// I2S configuration mode
I2SCFG: u2 = 0,
/// I2SE [10:10]
/// I2S Enable
I2SE: u1 = 0,
/// I2SMOD [11:11]
/// I2S mode selection
I2SMOD: u1 = 0,
/// unused [12:31]
_unused12: u4 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// I2S configuration register
pub const I2SCFGR = Register(I2SCFGR_val).init(base_address + 0x1c);
/// I2SPR
const I2SPR_val = packed struct {
/// I2SDIV [0:7]
/// I2S Linear prescaler
I2SDIV: u8 = 16,
/// ODD [8:8]
/// Odd factor for the prescaler
ODD: u1 = 0,
/// MCKOE [9:9]
/// Master clock output enable
MCKOE: u1 = 0,
/// unused [10:31]
_unused10: u6 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// I2S prescaler register
pub const I2SPR = Register(I2SPR_val).init(base_address + 0x20);
};
/// Serial peripheral interface/Inter-IC sound
pub const SPI4 = struct {
const base_address = 0x40013c00;
/// CR1
const CR1_val = packed struct {
/// CPHA [0:0]
/// Clock phase
CPHA: u1 = 0,
/// CPOL [1:1]
/// Clock polarity
CPOL: u1 = 0,
/// MSTR [2:2]
/// Master selection
MSTR: u1 = 0,
/// BR [3:5]
/// Baud rate control
BR: u3 = 0,
/// SPE [6:6]
/// SPI enable
SPE: u1 = 0,
/// LSBFIRST [7:7]
/// Frame format
LSBFIRST: u1 = 0,
/// SSI [8:8]
/// Internal slave select
SSI: u1 = 0,
/// SSM [9:9]
/// Software slave management
SSM: u1 = 0,
/// RXONLY [10:10]
/// Receive only
RXONLY: u1 = 0,
/// DFF [11:11]
/// Data frame format
DFF: u1 = 0,
/// CRCNEXT [12:12]
/// CRC transfer next
CRCNEXT: u1 = 0,
/// CRCEN [13:13]
/// Hardware CRC calculation enable
CRCEN: u1 = 0,
/// BIDIOE [14:14]
/// Output enable in bidirectional mode
BIDIOE: u1 = 0,
/// BIDIMODE [15:15]
/// Bidirectional data mode enable
BIDIMODE: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// control register 1
pub const CR1 = Register(CR1_val).init(base_address + 0x0);
/// CR2
const CR2_val = packed struct {
/// RXDMAEN [0:0]
/// Rx buffer DMA enable
RXDMAEN: u1 = 0,
/// TXDMAEN [1:1]
/// Tx buffer DMA enable
TXDMAEN: u1 = 0,
/// SSOE [2:2]
/// SS output enable
SSOE: u1 = 0,
/// NSSP [3:3]
/// NSS pulse management
NSSP: u1 = 0,
/// FRF [4:4]
/// Frame format
FRF: u1 = 0,
/// ERRIE [5:5]
/// Error interrupt enable
ERRIE: u1 = 0,
/// RXNEIE [6:6]
/// RX buffer not empty interrupt enable
RXNEIE: u1 = 0,
/// TXEIE [7:7]
/// Tx buffer empty interrupt enable
TXEIE: u1 = 0,
/// DS [8:11]
/// Data size
DS: u4 = 0,
/// FRXTH [12:12]
/// FIFO reception threshold
FRXTH: u1 = 0,
/// LDMA_RX [13:13]
/// Last DMA transfer for reception
LDMA_RX: u1 = 0,
/// LDMA_TX [14:14]
/// Last DMA transfer for transmission
LDMA_TX: u1 = 0,
/// unused [15:31]
_unused15: u1 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// control register 2
pub const CR2 = Register(CR2_val).init(base_address + 0x4);
/// SR
const SR_val = packed struct {
/// RXNE [0:0]
/// Receive buffer not empty
RXNE: u1 = 0,
/// TXE [1:1]
/// Transmit buffer empty
TXE: u1 = 1,
/// CHSIDE [2:2]
/// Channel side
CHSIDE: u1 = 0,
/// UDR [3:3]
/// Underrun flag
UDR: u1 = 0,
/// CRCERR [4:4]
/// CRC error flag
CRCERR: u1 = 0,
/// MODF [5:5]
/// Mode fault
MODF: u1 = 0,
/// OVR [6:6]
/// Overrun flag
OVR: u1 = 0,
/// BSY [7:7]
/// Busy flag
BSY: u1 = 0,
/// TIFRFE [8:8]
/// TI frame format error
TIFRFE: u1 = 0,
/// FRLVL [9:10]
/// FIFO reception level
FRLVL: u2 = 0,
/// FTLVL [11:12]
/// FIFO transmission level
FTLVL: u2 = 0,
/// unused [13:31]
_unused13: u3 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// status register
pub const SR = Register(SR_val).init(base_address + 0x8);
/// DR
const DR_val = packed struct {
/// DR [0:15]
/// Data register
DR: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// data register
pub const DR = Register(DR_val).init(base_address + 0xc);
/// CRCPR
const CRCPR_val = packed struct {
/// CRCPOLY [0:15]
/// CRC polynomial register
CRCPOLY: u16 = 7,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// CRC polynomial register
pub const CRCPR = Register(CRCPR_val).init(base_address + 0x10);
/// RXCRCR
const RXCRCR_val = packed struct {
/// RxCRC [0:15]
/// Rx CRC register
RxCRC: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// RX CRC register
pub const RXCRCR = Register(RXCRCR_val).init(base_address + 0x14);
/// TXCRCR
const TXCRCR_val = packed struct {
/// TxCRC [0:15]
/// Tx CRC register
TxCRC: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// TX CRC register
pub const TXCRCR = Register(TXCRCR_val).init(base_address + 0x18);
/// I2SCFGR
const I2SCFGR_val = packed struct {
/// CHLEN [0:0]
/// Channel length (number of bits per audio channel)
CHLEN: u1 = 0,
/// DATLEN [1:2]
/// Data length to be transferred
DATLEN: u2 = 0,
/// CKPOL [3:3]
/// Steady state clock polarity
CKPOL: u1 = 0,
/// I2SSTD [4:5]
/// I2S standard selection
I2SSTD: u2 = 0,
/// unused [6:6]
_unused6: u1 = 0,
/// PCMSYNC [7:7]
/// PCM frame synchronization
PCMSYNC: u1 = 0,
/// I2SCFG [8:9]
/// I2S configuration mode
I2SCFG: u2 = 0,
/// I2SE [10:10]
/// I2S Enable
I2SE: u1 = 0,
/// I2SMOD [11:11]
/// I2S mode selection
I2SMOD: u1 = 0,
/// unused [12:31]
_unused12: u4 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// I2S configuration register
pub const I2SCFGR = Register(I2SCFGR_val).init(base_address + 0x1c);
/// I2SPR
const I2SPR_val = packed struct {
/// I2SDIV [0:7]
/// I2S Linear prescaler
I2SDIV: u8 = 16,
/// ODD [8:8]
/// Odd factor for the prescaler
ODD: u1 = 0,
/// MCKOE [9:9]
/// Master clock output enable
MCKOE: u1 = 0,
/// unused [10:31]
_unused10: u6 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// I2S prescaler register
pub const I2SPR = Register(I2SPR_val).init(base_address + 0x20);
};
/// External interrupt/event controller
pub const EXTI = struct {
const base_address = 0x40010400;
/// IMR1
const IMR1_val = packed struct {
/// MR0 [0:0]
/// Interrupt Mask on line 0
MR0: u1 = 0,
/// MR1 [1:1]
/// Interrupt Mask on line 1
MR1: u1 = 0,
/// MR2 [2:2]
/// Interrupt Mask on line 2
MR2: u1 = 0,
/// MR3 [3:3]
/// Interrupt Mask on line 3
MR3: u1 = 0,
/// MR4 [4:4]
/// Interrupt Mask on line 4
MR4: u1 = 0,
/// MR5 [5:5]
/// Interrupt Mask on line 5
MR5: u1 = 0,
/// MR6 [6:6]
/// Interrupt Mask on line 6
MR6: u1 = 0,
/// MR7 [7:7]
/// Interrupt Mask on line 7
MR7: u1 = 0,
/// MR8 [8:8]
/// Interrupt Mask on line 8
MR8: u1 = 0,
/// MR9 [9:9]
/// Interrupt Mask on line 9
MR9: u1 = 0,
/// MR10 [10:10]
/// Interrupt Mask on line 10
MR10: u1 = 0,
/// MR11 [11:11]
/// Interrupt Mask on line 11
MR11: u1 = 0,
/// MR12 [12:12]
/// Interrupt Mask on line 12
MR12: u1 = 0,
/// MR13 [13:13]
/// Interrupt Mask on line 13
MR13: u1 = 0,
/// MR14 [14:14]
/// Interrupt Mask on line 14
MR14: u1 = 0,
/// MR15 [15:15]
/// Interrupt Mask on line 15
MR15: u1 = 0,
/// MR16 [16:16]
/// Interrupt Mask on line 16
MR16: u1 = 0,
/// MR17 [17:17]
/// Interrupt Mask on line 17
MR17: u1 = 0,
/// MR18 [18:18]
/// Interrupt Mask on line 18
MR18: u1 = 0,
/// MR19 [19:19]
/// Interrupt Mask on line 19
MR19: u1 = 0,
/// MR20 [20:20]
/// Interrupt Mask on line 20
MR20: u1 = 0,
/// MR21 [21:21]
/// Interrupt Mask on line 21
MR21: u1 = 0,
/// MR22 [22:22]
/// Interrupt Mask on line 22
MR22: u1 = 0,
/// MR23 [23:23]
/// Interrupt Mask on line 23
MR23: u1 = 1,
/// MR24 [24:24]
/// Interrupt Mask on line 24
MR24: u1 = 1,
/// MR25 [25:25]
/// Interrupt Mask on line 25
MR25: u1 = 1,
/// MR26 [26:26]
/// Interrupt Mask on line 26
MR26: u1 = 1,
/// MR27 [27:27]
/// Interrupt Mask on line 27
MR27: u1 = 1,
/// MR28 [28:28]
/// Interrupt Mask on line 28
MR28: u1 = 1,
/// MR29 [29:29]
/// Interrupt Mask on line 29
MR29: u1 = 0,
/// MR30 [30:30]
/// Interrupt Mask on line 30
MR30: u1 = 0,
/// MR31 [31:31]
/// Interrupt Mask on line 31
MR31: u1 = 0,
};
/// Interrupt mask register
pub const IMR1 = Register(IMR1_val).init(base_address + 0x0);
/// EMR1
const EMR1_val = packed struct {
/// MR0 [0:0]
/// Event Mask on line 0
MR0: u1 = 0,
/// MR1 [1:1]
/// Event Mask on line 1
MR1: u1 = 0,
/// MR2 [2:2]
/// Event Mask on line 2
MR2: u1 = 0,
/// MR3 [3:3]
/// Event Mask on line 3
MR3: u1 = 0,
/// MR4 [4:4]
/// Event Mask on line 4
MR4: u1 = 0,
/// MR5 [5:5]
/// Event Mask on line 5
MR5: u1 = 0,
/// MR6 [6:6]
/// Event Mask on line 6
MR6: u1 = 0,
/// MR7 [7:7]
/// Event Mask on line 7
MR7: u1 = 0,
/// MR8 [8:8]
/// Event Mask on line 8
MR8: u1 = 0,
/// MR9 [9:9]
/// Event Mask on line 9
MR9: u1 = 0,
/// MR10 [10:10]
/// Event Mask on line 10
MR10: u1 = 0,
/// MR11 [11:11]
/// Event Mask on line 11
MR11: u1 = 0,
/// MR12 [12:12]
/// Event Mask on line 12
MR12: u1 = 0,
/// MR13 [13:13]
/// Event Mask on line 13
MR13: u1 = 0,
/// MR14 [14:14]
/// Event Mask on line 14
MR14: u1 = 0,
/// MR15 [15:15]
/// Event Mask on line 15
MR15: u1 = 0,
/// MR16 [16:16]
/// Event Mask on line 16
MR16: u1 = 0,
/// MR17 [17:17]
/// Event Mask on line 17
MR17: u1 = 0,
/// MR18 [18:18]
/// Event Mask on line 18
MR18: u1 = 0,
/// MR19 [19:19]
/// Event Mask on line 19
MR19: u1 = 0,
/// MR20 [20:20]
/// Event Mask on line 20
MR20: u1 = 0,
/// MR21 [21:21]
/// Event Mask on line 21
MR21: u1 = 0,
/// MR22 [22:22]
/// Event Mask on line 22
MR22: u1 = 0,
/// MR23 [23:23]
/// Event Mask on line 23
MR23: u1 = 0,
/// MR24 [24:24]
/// Event Mask on line 24
MR24: u1 = 0,
/// MR25 [25:25]
/// Event Mask on line 25
MR25: u1 = 0,
/// MR26 [26:26]
/// Event Mask on line 26
MR26: u1 = 0,
/// MR27 [27:27]
/// Event Mask on line 27
MR27: u1 = 0,
/// MR28 [28:28]
/// Event Mask on line 28
MR28: u1 = 0,
/// MR29 [29:29]
/// Event Mask on line 29
MR29: u1 = 0,
/// MR30 [30:30]
/// Event Mask on line 30
MR30: u1 = 0,
/// MR31 [31:31]
/// Event Mask on line 31
MR31: u1 = 0,
};
/// Event mask register
pub const EMR1 = Register(EMR1_val).init(base_address + 0x4);
/// RTSR1
const RTSR1_val = packed struct {
/// TR0 [0:0]
/// Rising trigger event configuration of line 0
TR0: u1 = 0,
/// TR1 [1:1]
/// Rising trigger event configuration of line 1
TR1: u1 = 0,
/// TR2 [2:2]
/// Rising trigger event configuration of line 2
TR2: u1 = 0,
/// TR3 [3:3]
/// Rising trigger event configuration of line 3
TR3: u1 = 0,
/// TR4 [4:4]
/// Rising trigger event configuration of line 4
TR4: u1 = 0,
/// TR5 [5:5]
/// Rising trigger event configuration of line 5
TR5: u1 = 0,
/// TR6 [6:6]
/// Rising trigger event configuration of line 6
TR6: u1 = 0,
/// TR7 [7:7]
/// Rising trigger event configuration of line 7
TR7: u1 = 0,
/// TR8 [8:8]
/// Rising trigger event configuration of line 8
TR8: u1 = 0,
/// TR9 [9:9]
/// Rising trigger event configuration of line 9
TR9: u1 = 0,
/// TR10 [10:10]
/// Rising trigger event configuration of line 10
TR10: u1 = 0,
/// TR11 [11:11]
/// Rising trigger event configuration of line 11
TR11: u1 = 0,
/// TR12 [12:12]
/// Rising trigger event configuration of line 12
TR12: u1 = 0,
/// TR13 [13:13]
/// Rising trigger event configuration of line 13
TR13: u1 = 0,
/// TR14 [14:14]
/// Rising trigger event configuration of line 14
TR14: u1 = 0,
/// TR15 [15:15]
/// Rising trigger event configuration of line 15
TR15: u1 = 0,
/// TR16 [16:16]
/// Rising trigger event configuration of line 16
TR16: u1 = 0,
/// TR17 [17:17]
/// Rising trigger event configuration of line 17
TR17: u1 = 0,
/// TR18 [18:18]
/// Rising trigger event configuration of line 18
TR18: u1 = 0,
/// TR19 [19:19]
/// Rising trigger event configuration of line 19
TR19: u1 = 0,
/// TR20 [20:20]
/// Rising trigger event configuration of line 20
TR20: u1 = 0,
/// TR21 [21:21]
/// Rising trigger event configuration of line 21
TR21: u1 = 0,
/// TR22 [22:22]
/// Rising trigger event configuration of line 22
TR22: u1 = 0,
/// unused [23:28]
_unused23: u1 = 0,
_unused24: u5 = 0,
/// TR29 [29:29]
/// Rising trigger event configuration of line 29
TR29: u1 = 0,
/// TR30 [30:30]
/// Rising trigger event configuration of line 30
TR30: u1 = 0,
/// TR31 [31:31]
/// Rising trigger event configuration of line 31
TR31: u1 = 0,
};
/// Rising Trigger selection register
pub const RTSR1 = Register(RTSR1_val).init(base_address + 0x8);
/// FTSR1
const FTSR1_val = packed struct {
/// TR0 [0:0]
/// Falling trigger event configuration of line 0
TR0: u1 = 0,
/// TR1 [1:1]
/// Falling trigger event configuration of line 1
TR1: u1 = 0,
/// TR2 [2:2]
/// Falling trigger event configuration of line 2
TR2: u1 = 0,
/// TR3 [3:3]
/// Falling trigger event configuration of line 3
TR3: u1 = 0,
/// TR4 [4:4]
/// Falling trigger event configuration of line 4
TR4: u1 = 0,
/// TR5 [5:5]
/// Falling trigger event configuration of line 5
TR5: u1 = 0,
/// TR6 [6:6]
/// Falling trigger event configuration of line 6
TR6: u1 = 0,
/// TR7 [7:7]
/// Falling trigger event configuration of line 7
TR7: u1 = 0,
/// TR8 [8:8]
/// Falling trigger event configuration of line 8
TR8: u1 = 0,
/// TR9 [9:9]
/// Falling trigger event configuration of line 9
TR9: u1 = 0,
/// TR10 [10:10]
/// Falling trigger event configuration of line 10
TR10: u1 = 0,
/// TR11 [11:11]
/// Falling trigger event configuration of line 11
TR11: u1 = 0,
/// TR12 [12:12]
/// Falling trigger event configuration of line 12
TR12: u1 = 0,
/// TR13 [13:13]
/// Falling trigger event configuration of line 13
TR13: u1 = 0,
/// TR14 [14:14]
/// Falling trigger event configuration of line 14
TR14: u1 = 0,
/// TR15 [15:15]
/// Falling trigger event configuration of line 15
TR15: u1 = 0,
/// TR16 [16:16]
/// Falling trigger event configuration of line 16
TR16: u1 = 0,
/// TR17 [17:17]
/// Falling trigger event configuration of line 17
TR17: u1 = 0,
/// TR18 [18:18]
/// Falling trigger event configuration of line 18
TR18: u1 = 0,
/// TR19 [19:19]
/// Falling trigger event configuration of line 19
TR19: u1 = 0,
/// TR20 [20:20]
/// Falling trigger event configuration of line 20
TR20: u1 = 0,
/// TR21 [21:21]
/// Falling trigger event configuration of line 21
TR21: u1 = 0,
/// TR22 [22:22]
/// Falling trigger event configuration of line 22
TR22: u1 = 0,
/// unused [23:28]
_unused23: u1 = 0,
_unused24: u5 = 0,
/// TR29 [29:29]
/// Falling trigger event configuration of line 29
TR29: u1 = 0,
/// TR30 [30:30]
/// Falling trigger event configuration of line 30.
TR30: u1 = 0,
/// TR31 [31:31]
/// Falling trigger event configuration of line 31
TR31: u1 = 0,
};
/// Falling Trigger selection register
pub const FTSR1 = Register(FTSR1_val).init(base_address + 0xc);
/// SWIER1
const SWIER1_val = packed struct {
/// SWIER0 [0:0]
/// Software Interrupt on line 0
SWIER0: u1 = 0,
/// SWIER1 [1:1]
/// Software Interrupt on line 1
SWIER1: u1 = 0,
/// SWIER2 [2:2]
/// Software Interrupt on line 2
SWIER2: u1 = 0,
/// SWIER3 [3:3]
/// Software Interrupt on line 3
SWIER3: u1 = 0,
/// SWIER4 [4:4]
/// Software Interrupt on line 4
SWIER4: u1 = 0,
/// SWIER5 [5:5]
/// Software Interrupt on line 5
SWIER5: u1 = 0,
/// SWIER6 [6:6]
/// Software Interrupt on line 6
SWIER6: u1 = 0,
/// SWIER7 [7:7]
/// Software Interrupt on line 7
SWIER7: u1 = 0,
/// SWIER8 [8:8]
/// Software Interrupt on line 8
SWIER8: u1 = 0,
/// SWIER9 [9:9]
/// Software Interrupt on line 9
SWIER9: u1 = 0,
/// SWIER10 [10:10]
/// Software Interrupt on line 10
SWIER10: u1 = 0,
/// SWIER11 [11:11]
/// Software Interrupt on line 11
SWIER11: u1 = 0,
/// SWIER12 [12:12]
/// Software Interrupt on line 12
SWIER12: u1 = 0,
/// SWIER13 [13:13]
/// Software Interrupt on line 13
SWIER13: u1 = 0,
/// SWIER14 [14:14]
/// Software Interrupt on line 14
SWIER14: u1 = 0,
/// SWIER15 [15:15]
/// Software Interrupt on line 15
SWIER15: u1 = 0,
/// SWIER16 [16:16]
/// Software Interrupt on line 16
SWIER16: u1 = 0,
/// SWIER17 [17:17]
/// Software Interrupt on line 17
SWIER17: u1 = 0,
/// SWIER18 [18:18]
/// Software Interrupt on line 18
SWIER18: u1 = 0,
/// SWIER19 [19:19]
/// Software Interrupt on line 19
SWIER19: u1 = 0,
/// SWIER20 [20:20]
/// Software Interrupt on line 20
SWIER20: u1 = 0,
/// SWIER21 [21:21]
/// Software Interrupt on line 21
SWIER21: u1 = 0,
/// SWIER22 [22:22]
/// Software Interrupt on line 22
SWIER22: u1 = 0,
/// unused [23:28]
_unused23: u1 = 0,
_unused24: u5 = 0,
/// SWIER29 [29:29]
/// Software Interrupt on line 29
SWIER29: u1 = 0,
/// SWIER30 [30:30]
/// Software Interrupt on line 309
SWIER30: u1 = 0,
/// SWIER31 [31:31]
/// Software Interrupt on line 319
SWIER31: u1 = 0,
};
/// Software interrupt event register
pub const SWIER1 = Register(SWIER1_val).init(base_address + 0x10);
/// PR1
const PR1_val = packed struct {
/// PR0 [0:0]
/// Pending bit 0
PR0: u1 = 0,
/// PR1 [1:1]
/// Pending bit 1
PR1: u1 = 0,
/// PR2 [2:2]
/// Pending bit 2
PR2: u1 = 0,
/// PR3 [3:3]
/// Pending bit 3
PR3: u1 = 0,
/// PR4 [4:4]
/// Pending bit 4
PR4: u1 = 0,
/// PR5 [5:5]
/// Pending bit 5
PR5: u1 = 0,
/// PR6 [6:6]
/// Pending bit 6
PR6: u1 = 0,
/// PR7 [7:7]
/// Pending bit 7
PR7: u1 = 0,
/// PR8 [8:8]
/// Pending bit 8
PR8: u1 = 0,
/// PR9 [9:9]
/// Pending bit 9
PR9: u1 = 0,
/// PR10 [10:10]
/// Pending bit 10
PR10: u1 = 0,
/// PR11 [11:11]
/// Pending bit 11
PR11: u1 = 0,
/// PR12 [12:12]
/// Pending bit 12
PR12: u1 = 0,
/// PR13 [13:13]
/// Pending bit 13
PR13: u1 = 0,
/// PR14 [14:14]
/// Pending bit 14
PR14: u1 = 0,
/// PR15 [15:15]
/// Pending bit 15
PR15: u1 = 0,
/// PR16 [16:16]
/// Pending bit 16
PR16: u1 = 0,
/// PR17 [17:17]
/// Pending bit 17
PR17: u1 = 0,
/// PR18 [18:18]
/// Pending bit 18
PR18: u1 = 0,
/// PR19 [19:19]
/// Pending bit 19
PR19: u1 = 0,
/// PR20 [20:20]
/// Pending bit 20
PR20: u1 = 0,
/// PR21 [21:21]
/// Pending bit 21
PR21: u1 = 0,
/// PR22 [22:22]
/// Pending bit 22
PR22: u1 = 0,
/// unused [23:28]
_unused23: u1 = 0,
_unused24: u5 = 0,
/// PR29 [29:29]
/// Pending bit 29
PR29: u1 = 0,
/// PR30 [30:30]
/// Pending bit 30
PR30: u1 = 0,
/// PR31 [31:31]
/// Pending bit 31
PR31: u1 = 0,
};
/// Pending register
pub const PR1 = Register(PR1_val).init(base_address + 0x14);
/// IMR2
const IMR2_val = packed struct {
/// MR32 [0:0]
/// Interrupt Mask on external/internal line 32
MR32: u1 = 0,
/// MR33 [1:1]
/// Interrupt Mask on external/internal line 33
MR33: u1 = 0,
/// MR34 [2:2]
/// Interrupt Mask on external/internal line 34
MR34: u1 = 1,
/// MR35 [3:3]
/// Interrupt Mask on external/internal line 35
MR35: u1 = 1,
/// unused [4:31]
_unused4: u4 = 15,
_unused8: u8 = 255,
_unused16: u8 = 255,
_unused24: u8 = 255,
};
/// Interrupt mask register
pub const IMR2 = Register(IMR2_val).init(base_address + 0x18);
/// EMR2
const EMR2_val = packed struct {
/// MR32 [0:0]
/// Event mask on external/internal line 32
MR32: u1 = 0,
/// MR33 [1:1]
/// Event mask on external/internal line 33
MR33: u1 = 0,
/// MR34 [2:2]
/// Event mask on external/internal line 34
MR34: u1 = 0,
/// MR35 [3:3]
/// Event mask on external/internal line 35
MR35: u1 = 0,
/// unused [4:31]
_unused4: u4 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Event mask register
pub const EMR2 = Register(EMR2_val).init(base_address + 0x1c);
/// RTSR2
const RTSR2_val = packed struct {
/// TR32 [0:0]
/// Rising trigger event configuration bit of line 32
TR32: u1 = 0,
/// TR33 [1:1]
/// Rising trigger event configuration bit of line 33
TR33: u1 = 0,
/// unused [2:31]
_unused2: u6 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Rising Trigger selection register
pub const RTSR2 = Register(RTSR2_val).init(base_address + 0x20);
/// FTSR2
const FTSR2_val = packed struct {
/// TR32 [0:0]
/// Falling trigger event configuration bit of line 32
TR32: u1 = 0,
/// TR33 [1:1]
/// Falling trigger event configuration bit of line 33
TR33: u1 = 0,
/// unused [2:31]
_unused2: u6 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Falling Trigger selection register
pub const FTSR2 = Register(FTSR2_val).init(base_address + 0x24);
/// SWIER2
const SWIER2_val = packed struct {
/// SWIER32 [0:0]
/// Software interrupt on line 32
SWIER32: u1 = 0,
/// SWIER33 [1:1]
/// Software interrupt on line 33
SWIER33: u1 = 0,
/// unused [2:31]
_unused2: u6 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Software interrupt event register
pub const SWIER2 = Register(SWIER2_val).init(base_address + 0x28);
/// PR2
const PR2_val = packed struct {
/// PR32 [0:0]
/// Pending bit on line 32
PR32: u1 = 0,
/// PR33 [1:1]
/// Pending bit on line 33
PR33: u1 = 0,
/// unused [2:31]
_unused2: u6 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Pending register
pub const PR2 = Register(PR2_val).init(base_address + 0x2c);
};
/// Comparator
pub const COMP = struct {
const base_address = 0x4001001c;
/// COMP1_CSR
const COMP1_CSR_val = packed struct {
/// COMP1EN [0:0]
/// Comparator 1 enable
COMP1EN: u1 = 0,
/// COMP1_INP_DAC [1:1]
/// COMP1_INP_DAC
COMP1_INP_DAC: u1 = 0,
/// COMP1MODE [2:3]
/// Comparator 1 mode
COMP1MODE: u2 = 0,
/// COMP1INSEL [4:6]
/// Comparator 1 inverting input selection
COMP1INSEL: u3 = 0,
/// unused [7:9]
_unused7: u1 = 0,
_unused8: u2 = 0,
/// COMP1_OUT_SEL [10:13]
/// Comparator 1 output selection
COMP1_OUT_SEL: u4 = 0,
/// unused [14:14]
_unused14: u1 = 0,
/// COMP1POL [15:15]
/// Comparator 1 output polarity
COMP1POL: u1 = 0,
/// COMP1HYST [16:17]
/// Comparator 1 hysteresis
COMP1HYST: u2 = 0,
/// COMP1_BLANKING [18:20]
/// Comparator 1 blanking source
COMP1_BLANKING: u3 = 0,
/// unused [21:29]
_unused21: u3 = 0,
_unused24: u6 = 0,
/// COMP1OUT [30:30]
/// Comparator 1 output
COMP1OUT: u1 = 0,
/// COMP1LOCK [31:31]
/// Comparator 1 lock
COMP1LOCK: u1 = 0,
};
/// control and status register
pub const COMP1_CSR = Register(COMP1_CSR_val).init(base_address + 0x0);
/// COMP2_CSR
const COMP2_CSR_val = packed struct {
/// COMP2EN [0:0]
/// Comparator 2 enable
COMP2EN: u1 = 0,
/// unused [1:1]
_unused1: u1 = 0,
/// COMP2MODE [2:3]
/// Comparator 2 mode
COMP2MODE: u2 = 0,
/// COMP2INSEL [4:6]
/// Comparator 2 inverting input selection
COMP2INSEL: u3 = 0,
/// COMP2INPSEL [7:7]
/// Comparator 2 non inverted input selection
COMP2INPSEL: u1 = 0,
/// unused [8:8]
_unused8: u1 = 0,
/// COMP2INMSEL [9:9]
/// Comparator 1inverting input selection
COMP2INMSEL: u1 = 0,
/// COMP2_OUT_SEL [10:13]
/// Comparator 2 output selection
COMP2_OUT_SEL: u4 = 0,
/// unused [14:14]
_unused14: u1 = 0,
/// COMP2POL [15:15]
/// Comparator 2 output polarity
COMP2POL: u1 = 0,
/// COMP2HYST [16:17]
/// Comparator 2 hysteresis
COMP2HYST: u2 = 0,
/// COMP2_BLANKING [18:20]
/// Comparator 2 blanking source
COMP2_BLANKING: u3 = 0,
/// unused [21:30]
_unused21: u3 = 0,
_unused24: u7 = 0,
/// COMP2LOCK [31:31]
/// Comparator 2 lock
COMP2LOCK: u1 = 0,
};
/// control and status register
pub const COMP2_CSR = Register(COMP2_CSR_val).init(base_address + 0x4);
/// COMP3_CSR
const COMP3_CSR_val = packed struct {
/// COMP3EN [0:0]
/// Comparator 3 enable
COMP3EN: u1 = 0,
/// unused [1:1]
_unused1: u1 = 0,
/// COMP3MODE [2:3]
/// Comparator 3 mode
COMP3MODE: u2 = 0,
/// COMP3INSEL [4:6]
/// Comparator 3 inverting input selection
COMP3INSEL: u3 = 0,
/// COMP3INPSEL [7:7]
/// Comparator 3 non inverted input selection
COMP3INPSEL: u1 = 0,
/// unused [8:9]
_unused8: u2 = 0,
/// COMP3_OUT_SEL [10:13]
/// Comparator 3 output selection
COMP3_OUT_SEL: u4 = 0,
/// unused [14:14]
_unused14: u1 = 0,
/// COMP3POL [15:15]
/// Comparator 3 output polarity
COMP3POL: u1 = 0,
/// COMP3HYST [16:17]
/// Comparator 3 hysteresis
COMP3HYST: u2 = 0,
/// COMP3_BLANKING [18:20]
/// Comparator 3 blanking source
COMP3_BLANKING: u3 = 0,
/// unused [21:29]
_unused21: u3 = 0,
_unused24: u6 = 0,
/// COMP3OUT [30:30]
/// Comparator 3 output
COMP3OUT: u1 = 0,
/// COMP3LOCK [31:31]
/// Comparator 3 lock
COMP3LOCK: u1 = 0,
};
/// control and status register
pub const COMP3_CSR = Register(COMP3_CSR_val).init(base_address + 0x8);
/// COMP4_CSR
const COMP4_CSR_val = packed struct {
/// COMP4EN [0:0]
/// Comparator 4 enable
COMP4EN: u1 = 0,
/// unused [1:1]
_unused1: u1 = 0,
/// COMP4MODE [2:3]
/// Comparator 4 mode
COMP4MODE: u2 = 0,
/// COMP4INSEL [4:6]
/// Comparator 4 inverting input selection
COMP4INSEL: u3 = 0,
/// COMP4INPSEL [7:7]
/// Comparator 4 non inverted input selection
COMP4INPSEL: u1 = 0,
/// unused [8:8]
_unused8: u1 = 0,
/// COM4WINMODE [9:9]
/// Comparator 4 window mode
COM4WINMODE: u1 = 0,
/// COMP4_OUT_SEL [10:13]
/// Comparator 4 output selection
COMP4_OUT_SEL: u4 = 0,
/// unused [14:14]
_unused14: u1 = 0,
/// COMP4POL [15:15]
/// Comparator 4 output polarity
COMP4POL: u1 = 0,
/// COMP4HYST [16:17]
/// Comparator 4 hysteresis
COMP4HYST: u2 = 0,
/// COMP4_BLANKING [18:20]
/// Comparator 4 blanking source
COMP4_BLANKING: u3 = 0,
/// unused [21:29]
_unused21: u3 = 0,
_unused24: u6 = 0,
/// COMP4OUT [30:30]
/// Comparator 4 output
COMP4OUT: u1 = 0,
/// COMP4LOCK [31:31]
/// Comparator 4 lock
COMP4LOCK: u1 = 0,
};
/// control and status register
pub const COMP4_CSR = Register(COMP4_CSR_val).init(base_address + 0xc);
/// COMP5_CSR
const COMP5_CSR_val = packed struct {
/// COMP5EN [0:0]
/// Comparator 5 enable
COMP5EN: u1 = 0,
/// unused [1:1]
_unused1: u1 = 0,
/// COMP5MODE [2:3]
/// Comparator 5 mode
COMP5MODE: u2 = 0,
/// COMP5INSEL [4:6]
/// Comparator 5 inverting input selection
COMP5INSEL: u3 = 0,
/// COMP5INPSEL [7:7]
/// Comparator 5 non inverted input selection
COMP5INPSEL: u1 = 0,
/// unused [8:9]
_unused8: u2 = 0,
/// COMP5_OUT_SEL [10:13]
/// Comparator 5 output selection
COMP5_OUT_SEL: u4 = 0,
/// unused [14:14]
_unused14: u1 = 0,
/// COMP5POL [15:15]
/// Comparator 5 output polarity
COMP5POL: u1 = 0,
/// COMP5HYST [16:17]
/// Comparator 5 hysteresis
COMP5HYST: u2 = 0,
/// COMP5_BLANKING [18:20]
/// Comparator 5 blanking source
COMP5_BLANKING: u3 = 0,
/// unused [21:29]
_unused21: u3 = 0,
_unused24: u6 = 0,
/// COMP5OUT [30:30]
/// Comparator51 output
COMP5OUT: u1 = 0,
/// COMP5LOCK [31:31]
/// Comparator 5 lock
COMP5LOCK: u1 = 0,
};
/// control and status register
pub const COMP5_CSR = Register(COMP5_CSR_val).init(base_address + 0x10);
/// COMP6_CSR
const COMP6_CSR_val = packed struct {
/// COMP6EN [0:0]
/// Comparator 6 enable
COMP6EN: u1 = 0,
/// unused [1:1]
_unused1: u1 = 0,
/// COMP6MODE [2:3]
/// Comparator 6 mode
COMP6MODE: u2 = 0,
/// COMP6INSEL [4:6]
/// Comparator 6 inverting input selection
COMP6INSEL: u3 = 0,
/// COMP6INPSEL [7:7]
/// Comparator 6 non inverted input selection
COMP6INPSEL: u1 = 0,
/// unused [8:8]
_unused8: u1 = 0,
/// COM6WINMODE [9:9]
/// Comparator 6 window mode
COM6WINMODE: u1 = 0,
/// COMP6_OUT_SEL [10:13]
/// Comparator 6 output selection
COMP6_OUT_SEL: u4 = 0,
/// unused [14:14]
_unused14: u1 = 0,
/// COMP6POL [15:15]
/// Comparator 6 output polarity
COMP6POL: u1 = 0,
/// COMP6HYST [16:17]
/// Comparator 6 hysteresis
COMP6HYST: u2 = 0,
/// COMP6_BLANKING [18:20]
/// Comparator 6 blanking source
COMP6_BLANKING: u3 = 0,
/// unused [21:29]
_unused21: u3 = 0,
_unused24: u6 = 0,
/// COMP6OUT [30:30]
/// Comparator 6 output
COMP6OUT: u1 = 0,
/// COMP6LOCK [31:31]
/// Comparator 6 lock
COMP6LOCK: u1 = 0,
};
/// control and status register
pub const COMP6_CSR = Register(COMP6_CSR_val).init(base_address + 0x14);
/// COMP7_CSR
const COMP7_CSR_val = packed struct {
/// COMP7EN [0:0]
/// Comparator 7 enable
COMP7EN: u1 = 0,
/// unused [1:1]
_unused1: u1 = 0,
/// COMP7MODE [2:3]
/// Comparator 7 mode
COMP7MODE: u2 = 0,
/// COMP7INSEL [4:6]
/// Comparator 7 inverting input selection
COMP7INSEL: u3 = 0,
/// COMP7INPSEL [7:7]
/// Comparator 7 non inverted input selection
COMP7INPSEL: u1 = 0,
/// unused [8:9]
_unused8: u2 = 0,
/// COMP7_OUT_SEL [10:13]
/// Comparator 7 output selection
COMP7_OUT_SEL: u4 = 0,
/// unused [14:14]
_unused14: u1 = 0,
/// COMP7POL [15:15]
/// Comparator 7 output polarity
COMP7POL: u1 = 0,
/// COMP7HYST [16:17]
/// Comparator 7 hysteresis
COMP7HYST: u2 = 0,
/// COMP7_BLANKING [18:20]
/// Comparator 7 blanking source
COMP7_BLANKING: u3 = 0,
/// unused [21:29]
_unused21: u3 = 0,
_unused24: u6 = 0,
/// COMP7OUT [30:30]
/// Comparator 7 output
COMP7OUT: u1 = 0,
/// COMP7LOCK [31:31]
/// Comparator 7 lock
COMP7LOCK: u1 = 0,
};
/// control and status register
pub const COMP7_CSR = Register(COMP7_CSR_val).init(base_address + 0x18);
};
/// Power control
pub const PWR = struct {
const base_address = 0x40007000;
/// CR
const CR_val = packed struct {
/// LPDS [0:0]
/// Low-power deep sleep
LPDS: u1 = 0,
/// PDDS [1:1]
/// Power down deepsleep
PDDS: u1 = 0,
/// CWUF [2:2]
/// Clear wakeup flag
CWUF: u1 = 0,
/// CSBF [3:3]
/// Clear standby flag
CSBF: u1 = 0,
/// PVDE [4:4]
/// Power voltage detector enable
PVDE: u1 = 0,
/// PLS [5:7]
/// PVD level selection
PLS: u3 = 0,
/// DBP [8:8]
/// Disable backup domain write protection
DBP: u1 = 0,
/// unused [9:31]
_unused9: u7 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// power control register
pub const CR = Register(CR_val).init(base_address + 0x0);
/// CSR
const CSR_val = packed struct {
/// WUF [0:0]
/// Wakeup flag
WUF: u1 = 0,
/// SBF [1:1]
/// Standby flag
SBF: u1 = 0,
/// PVDO [2:2]
/// PVD output
PVDO: u1 = 0,
/// unused [3:7]
_unused3: u5 = 0,
/// EWUP1 [8:8]
/// Enable WKUP1 pin
EWUP1: u1 = 0,
/// EWUP2 [9:9]
/// Enable WKUP2 pin
EWUP2: u1 = 0,
/// unused [10:31]
_unused10: u6 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// power control/status register
pub const CSR = Register(CSR_val).init(base_address + 0x4);
};
/// Controller area network
pub const CAN = struct {
const base_address = 0x40006400;
/// MCR
const MCR_val = packed struct {
/// INRQ [0:0]
/// INRQ
INRQ: u1 = 0,
/// SLEEP [1:1]
/// SLEEP
SLEEP: u1 = 1,
/// TXFP [2:2]
/// TXFP
TXFP: u1 = 0,
/// RFLM [3:3]
/// RFLM
RFLM: u1 = 0,
/// NART [4:4]
/// NART
NART: u1 = 0,
/// AWUM [5:5]
/// AWUM
AWUM: u1 = 0,
/// ABOM [6:6]
/// ABOM
ABOM: u1 = 0,
/// TTCM [7:7]
/// TTCM
TTCM: u1 = 0,
/// unused [8:14]
_unused8: u7 = 0,
/// RESET [15:15]
/// RESET
RESET: u1 = 0,
/// DBF [16:16]
/// DBF
DBF: u1 = 1,
/// unused [17:31]
_unused17: u7 = 0,
_unused24: u8 = 0,
};
/// master control register
pub const MCR = Register(MCR_val).init(base_address + 0x0);
/// MSR
const MSR_val = packed struct {
/// INAK [0:0]
/// INAK
INAK: u1 = 0,
/// SLAK [1:1]
/// SLAK
SLAK: u1 = 1,
/// ERRI [2:2]
/// ERRI
ERRI: u1 = 0,
/// WKUI [3:3]
/// WKUI
WKUI: u1 = 0,
/// SLAKI [4:4]
/// SLAKI
SLAKI: u1 = 0,
/// unused [5:7]
_unused5: u3 = 0,
/// TXM [8:8]
/// TXM
TXM: u1 = 0,
/// RXM [9:9]
/// RXM
RXM: u1 = 0,
/// SAMP [10:10]
/// SAMP
SAMP: u1 = 1,
/// RX [11:11]
/// RX
RX: u1 = 1,
/// unused [12:31]
_unused12: u4 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// master status register
pub const MSR = Register(MSR_val).init(base_address + 0x4);
/// TSR
const TSR_val = packed struct {
/// RQCP0 [0:0]
/// RQCP0
RQCP0: u1 = 0,
/// TXOK0 [1:1]
/// TXOK0
TXOK0: u1 = 0,
/// ALST0 [2:2]
/// ALST0
ALST0: u1 = 0,
/// TERR0 [3:3]
/// TERR0
TERR0: u1 = 0,
/// unused [4:6]
_unused4: u3 = 0,
/// ABRQ0 [7:7]
/// ABRQ0
ABRQ0: u1 = 0,
/// RQCP1 [8:8]
/// RQCP1
RQCP1: u1 = 0,
/// TXOK1 [9:9]
/// TXOK1
TXOK1: u1 = 0,
/// ALST1 [10:10]
/// ALST1
ALST1: u1 = 0,
/// TERR1 [11:11]
/// TERR1
TERR1: u1 = 0,
/// unused [12:14]
_unused12: u3 = 0,
/// ABRQ1 [15:15]
/// ABRQ1
ABRQ1: u1 = 0,
/// RQCP2 [16:16]
/// RQCP2
RQCP2: u1 = 0,
/// TXOK2 [17:17]
/// TXOK2
TXOK2: u1 = 0,
/// ALST2 [18:18]
/// ALST2
ALST2: u1 = 0,
/// TERR2 [19:19]
/// TERR2
TERR2: u1 = 0,
/// unused [20:22]
_unused20: u3 = 0,
/// ABRQ2 [23:23]
/// ABRQ2
ABRQ2: u1 = 0,
/// CODE [24:25]
/// CODE
CODE: u2 = 0,
/// TME0 [26:26]
/// Lowest priority flag for mailbox 0
TME0: u1 = 1,
/// TME1 [27:27]
/// Lowest priority flag for mailbox 1
TME1: u1 = 1,
/// TME2 [28:28]
/// Lowest priority flag for mailbox 2
TME2: u1 = 1,
/// LOW0 [29:29]
/// Lowest priority flag for mailbox 0
LOW0: u1 = 0,
/// LOW1 [30:30]
/// Lowest priority flag for mailbox 1
LOW1: u1 = 0,
/// LOW2 [31:31]
/// Lowest priority flag for mailbox 2
LOW2: u1 = 0,
};
/// transmit status register
pub const TSR = Register(TSR_val).init(base_address + 0x8);
/// RF0R
const RF0R_val = packed struct {
/// FMP0 [0:1]
/// FMP0
FMP0: u2 = 0,
/// unused [2:2]
_unused2: u1 = 0,
/// FULL0 [3:3]
/// FULL0
FULL0: u1 = 0,
/// FOVR0 [4:4]
/// FOVR0
FOVR0: u1 = 0,
/// RFOM0 [5:5]
/// RFOM0
RFOM0: u1 = 0,
/// unused [6:31]
_unused6: u2 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// receive FIFO 0 register
pub const RF0R = Register(RF0R_val).init(base_address + 0xc);
/// RF1R
const RF1R_val = packed struct {
/// FMP1 [0:1]
/// FMP1
FMP1: u2 = 0,
/// unused [2:2]
_unused2: u1 = 0,
/// FULL1 [3:3]
/// FULL1
FULL1: u1 = 0,
/// FOVR1 [4:4]
/// FOVR1
FOVR1: u1 = 0,
/// RFOM1 [5:5]
/// RFOM1
RFOM1: u1 = 0,
/// unused [6:31]
_unused6: u2 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// receive FIFO 1 register
pub const RF1R = Register(RF1R_val).init(base_address + 0x10);
/// IER
const IER_val = packed struct {
/// TMEIE [0:0]
/// TMEIE
TMEIE: u1 = 0,
/// FMPIE0 [1:1]
/// FMPIE0
FMPIE0: u1 = 0,
/// FFIE0 [2:2]
/// FFIE0
FFIE0: u1 = 0,
/// FOVIE0 [3:3]
/// FOVIE0
FOVIE0: u1 = 0,
/// FMPIE1 [4:4]
/// FMPIE1
FMPIE1: u1 = 0,
/// FFIE1 [5:5]
/// FFIE1
FFIE1: u1 = 0,
/// FOVIE1 [6:6]
/// FOVIE1
FOVIE1: u1 = 0,
/// unused [7:7]
_unused7: u1 = 0,
/// EWGIE [8:8]
/// EWGIE
EWGIE: u1 = 0,
/// EPVIE [9:9]
/// EPVIE
EPVIE: u1 = 0,
/// BOFIE [10:10]
/// BOFIE
BOFIE: u1 = 0,
/// LECIE [11:11]
/// LECIE
LECIE: u1 = 0,
/// unused [12:14]
_unused12: u3 = 0,
/// ERRIE [15:15]
/// ERRIE
ERRIE: u1 = 0,
/// WKUIE [16:16]
/// WKUIE
WKUIE: u1 = 0,
/// SLKIE [17:17]
/// SLKIE
SLKIE: u1 = 0,
/// unused [18:31]
_unused18: u6 = 0,
_unused24: u8 = 0,
};
/// interrupt enable register
pub const IER = Register(IER_val).init(base_address + 0x14);
/// ESR
const ESR_val = packed struct {
/// EWGF [0:0]
/// EWGF
EWGF: u1 = 0,
/// EPVF [1:1]
/// EPVF
EPVF: u1 = 0,
/// BOFF [2:2]
/// BOFF
BOFF: u1 = 0,
/// unused [3:3]
_unused3: u1 = 0,
/// LEC [4:6]
/// LEC
LEC: u3 = 0,
/// unused [7:15]
_unused7: u1 = 0,
_unused8: u8 = 0,
/// TEC [16:23]
/// TEC
TEC: u8 = 0,
/// REC [24:31]
/// REC
REC: u8 = 0,
};
/// error status register
pub const ESR = Register(ESR_val).init(base_address + 0x18);
/// BTR
const BTR_val = packed struct {
/// BRP [0:9]
/// BRP
BRP: u10 = 0,
/// unused [10:15]
_unused10: u6 = 0,
/// TS1 [16:19]
/// TS1
TS1: u4 = 3,
/// TS2 [20:22]
/// TS2
TS2: u3 = 2,
/// unused [23:23]
_unused23: u1 = 0,
/// SJW [24:25]
/// SJW
SJW: u2 = 1,
/// unused [26:29]
_unused26: u4 = 0,
/// LBKM [30:30]
/// LBKM
LBKM: u1 = 0,
/// SILM [31:31]
/// SILM
SILM: u1 = 0,
};
/// bit timing register
pub const BTR = Register(BTR_val).init(base_address + 0x1c);
/// TI0R
const TI0R_val = packed struct {
/// TXRQ [0:0]
/// TXRQ
TXRQ: u1 = 0,
/// RTR [1:1]
/// RTR
RTR: u1 = 0,
/// IDE [2:2]
/// IDE
IDE: u1 = 0,
/// EXID [3:20]
/// EXID
EXID: u18 = 0,
/// STID [21:31]
/// STID
STID: u11 = 0,
};
/// TX mailbox identifier register
pub const TI0R = Register(TI0R_val).init(base_address + 0x180);
/// TDT0R
const TDT0R_val = packed struct {
/// DLC [0:3]
/// DLC
DLC: u4 = 0,
/// unused [4:7]
_unused4: u4 = 0,
/// TGT [8:8]
/// TGT
TGT: u1 = 0,
/// unused [9:15]
_unused9: u7 = 0,
/// TIME [16:31]
/// TIME
TIME: u16 = 0,
};
/// mailbox data length control and time stamp register
pub const TDT0R = Register(TDT0R_val).init(base_address + 0x184);
/// TDL0R
const TDL0R_val = packed struct {
/// DATA0 [0:7]
/// DATA0
DATA0: u8 = 0,
/// DATA1 [8:15]
/// DATA1
DATA1: u8 = 0,
/// DATA2 [16:23]
/// DATA2
DATA2: u8 = 0,
/// DATA3 [24:31]
/// DATA3
DATA3: u8 = 0,
};
/// mailbox data low register
pub const TDL0R = Register(TDL0R_val).init(base_address + 0x188);
/// TDH0R
const TDH0R_val = packed struct {
/// DATA4 [0:7]
/// DATA4
DATA4: u8 = 0,
/// DATA5 [8:15]
/// DATA5
DATA5: u8 = 0,
/// DATA6 [16:23]
/// DATA6
DATA6: u8 = 0,
/// DATA7 [24:31]
/// DATA7
DATA7: u8 = 0,
};
/// mailbox data high register
pub const TDH0R = Register(TDH0R_val).init(base_address + 0x18c);
/// TI1R
const TI1R_val = packed struct {
/// TXRQ [0:0]
/// TXRQ
TXRQ: u1 = 0,
/// RTR [1:1]
/// RTR
RTR: u1 = 0,
/// IDE [2:2]
/// IDE
IDE: u1 = 0,
/// EXID [3:20]
/// EXID
EXID: u18 = 0,
/// STID [21:31]
/// STID
STID: u11 = 0,
};
/// TX mailbox identifier register
pub const TI1R = Register(TI1R_val).init(base_address + 0x190);
/// TDT1R
const TDT1R_val = packed struct {
/// DLC [0:3]
/// DLC
DLC: u4 = 0,
/// unused [4:7]
_unused4: u4 = 0,
/// TGT [8:8]
/// TGT
TGT: u1 = 0,
/// unused [9:15]
_unused9: u7 = 0,
/// TIME [16:31]
/// TIME
TIME: u16 = 0,
};
/// mailbox data length control and time stamp register
pub const TDT1R = Register(TDT1R_val).init(base_address + 0x194);
/// TDL1R
const TDL1R_val = packed struct {
/// DATA0 [0:7]
/// DATA0
DATA0: u8 = 0,
/// DATA1 [8:15]
/// DATA1
DATA1: u8 = 0,
/// DATA2 [16:23]
/// DATA2
DATA2: u8 = 0,
/// DATA3 [24:31]
/// DATA3
DATA3: u8 = 0,
};
/// mailbox data low register
pub const TDL1R = Register(TDL1R_val).init(base_address + 0x198);
/// TDH1R
const TDH1R_val = packed struct {
/// DATA4 [0:7]
/// DATA4
DATA4: u8 = 0,
/// DATA5 [8:15]
/// DATA5
DATA5: u8 = 0,
/// DATA6 [16:23]
/// DATA6
DATA6: u8 = 0,
/// DATA7 [24:31]
/// DATA7
DATA7: u8 = 0,
};
/// mailbox data high register
pub const TDH1R = Register(TDH1R_val).init(base_address + 0x19c);
/// TI2R
const TI2R_val = packed struct {
/// TXRQ [0:0]
/// TXRQ
TXRQ: u1 = 0,
/// RTR [1:1]
/// RTR
RTR: u1 = 0,
/// IDE [2:2]
/// IDE
IDE: u1 = 0,
/// EXID [3:20]
/// EXID
EXID: u18 = 0,
/// STID [21:31]
/// STID
STID: u11 = 0,
};
/// TX mailbox identifier register
pub const TI2R = Register(TI2R_val).init(base_address + 0x1a0);
/// TDT2R
const TDT2R_val = packed struct {
/// DLC [0:3]
/// DLC
DLC: u4 = 0,
/// unused [4:7]
_unused4: u4 = 0,
/// TGT [8:8]
/// TGT
TGT: u1 = 0,
/// unused [9:15]
_unused9: u7 = 0,
/// TIME [16:31]
/// TIME
TIME: u16 = 0,
};
/// mailbox data length control and time stamp register
pub const TDT2R = Register(TDT2R_val).init(base_address + 0x1a4);
/// TDL2R
const TDL2R_val = packed struct {
/// DATA0 [0:7]
/// DATA0
DATA0: u8 = 0,
/// DATA1 [8:15]
/// DATA1
DATA1: u8 = 0,
/// DATA2 [16:23]
/// DATA2
DATA2: u8 = 0,
/// DATA3 [24:31]
/// DATA3
DATA3: u8 = 0,
};
/// mailbox data low register
pub const TDL2R = Register(TDL2R_val).init(base_address + 0x1a8);
/// TDH2R
const TDH2R_val = packed struct {
/// DATA4 [0:7]
/// DATA4
DATA4: u8 = 0,
/// DATA5 [8:15]
/// DATA5
DATA5: u8 = 0,
/// DATA6 [16:23]
/// DATA6
DATA6: u8 = 0,
/// DATA7 [24:31]
/// DATA7
DATA7: u8 = 0,
};
/// mailbox data high register
pub const TDH2R = Register(TDH2R_val).init(base_address + 0x1ac);
/// RI0R
const RI0R_val = packed struct {
/// unused [0:0]
_unused0: u1 = 0,
/// RTR [1:1]
/// RTR
RTR: u1 = 0,
/// IDE [2:2]
/// IDE
IDE: u1 = 0,
/// EXID [3:20]
/// EXID
EXID: u18 = 0,
/// STID [21:31]
/// STID
STID: u11 = 0,
};
/// receive FIFO mailbox identifier register
pub const RI0R = Register(RI0R_val).init(base_address + 0x1b0);
/// RDT0R
const RDT0R_val = packed struct {
/// DLC [0:3]
/// DLC
DLC: u4 = 0,
/// unused [4:7]
_unused4: u4 = 0,
/// FMI [8:15]
/// FMI
FMI: u8 = 0,
/// TIME [16:31]
/// TIME
TIME: u16 = 0,
};
/// receive FIFO mailbox data length control and time stamp register
pub const RDT0R = Register(RDT0R_val).init(base_address + 0x1b4);
/// RDL0R
const RDL0R_val = packed struct {
/// DATA0 [0:7]
/// DATA0
DATA0: u8 = 0,
/// DATA1 [8:15]
/// DATA1
DATA1: u8 = 0,
/// DATA2 [16:23]
/// DATA2
DATA2: u8 = 0,
/// DATA3 [24:31]
/// DATA3
DATA3: u8 = 0,
};
/// receive FIFO mailbox data low register
pub const RDL0R = Register(RDL0R_val).init(base_address + 0x1b8);
/// RDH0R
const RDH0R_val = packed struct {
/// DATA4 [0:7]
/// DATA4
DATA4: u8 = 0,
/// DATA5 [8:15]
/// DATA5
DATA5: u8 = 0,
/// DATA6 [16:23]
/// DATA6
DATA6: u8 = 0,
/// DATA7 [24:31]
/// DATA7
DATA7: u8 = 0,
};
/// receive FIFO mailbox data high register
pub const RDH0R = Register(RDH0R_val).init(base_address + 0x1bc);
/// RI1R
const RI1R_val = packed struct {
/// unused [0:0]
_unused0: u1 = 0,
/// RTR [1:1]
/// RTR
RTR: u1 = 0,
/// IDE [2:2]
/// IDE
IDE: u1 = 0,
/// EXID [3:20]
/// EXID
EXID: u18 = 0,
/// STID [21:31]
/// STID
STID: u11 = 0,
};
/// receive FIFO mailbox identifier register
pub const RI1R = Register(RI1R_val).init(base_address + 0x1c0);
/// RDT1R
const RDT1R_val = packed struct {
/// DLC [0:3]
/// DLC
DLC: u4 = 0,
/// unused [4:7]
_unused4: u4 = 0,
/// FMI [8:15]
/// FMI
FMI: u8 = 0,
/// TIME [16:31]
/// TIME
TIME: u16 = 0,
};
/// receive FIFO mailbox data length control and time stamp register
pub const RDT1R = Register(RDT1R_val).init(base_address + 0x1c4);
/// RDL1R
const RDL1R_val = packed struct {
/// DATA0 [0:7]
/// DATA0
DATA0: u8 = 0,
/// DATA1 [8:15]
/// DATA1
DATA1: u8 = 0,
/// DATA2 [16:23]
/// DATA2
DATA2: u8 = 0,
/// DATA3 [24:31]
/// DATA3
DATA3: u8 = 0,
};
/// receive FIFO mailbox data low register
pub const RDL1R = Register(RDL1R_val).init(base_address + 0x1c8);
/// RDH1R
const RDH1R_val = packed struct {
/// DATA4 [0:7]
/// DATA4
DATA4: u8 = 0,
/// DATA5 [8:15]
/// DATA5
DATA5: u8 = 0,
/// DATA6 [16:23]
/// DATA6
DATA6: u8 = 0,
/// DATA7 [24:31]
/// DATA7
DATA7: u8 = 0,
};
/// receive FIFO mailbox data high register
pub const RDH1R = Register(RDH1R_val).init(base_address + 0x1cc);
/// FMR
const FMR_val = packed struct {
/// FINIT [0:0]
/// Filter init mode
FINIT: u1 = 1,
/// unused [1:7]
_unused1: u7 = 0,
/// CAN2SB [8:13]
/// CAN2 start bank
CAN2SB: u6 = 14,
/// unused [14:31]
_unused14: u2 = 0,
_unused16: u8 = 28,
_unused24: u8 = 42,
};
/// filter master register
pub const FMR = Register(FMR_val).init(base_address + 0x200);
/// FM1R
const FM1R_val = packed struct {
/// FBM0 [0:0]
/// Filter mode
FBM0: u1 = 0,
/// FBM1 [1:1]
/// Filter mode
FBM1: u1 = 0,
/// FBM2 [2:2]
/// Filter mode
FBM2: u1 = 0,
/// FBM3 [3:3]
/// Filter mode
FBM3: u1 = 0,
/// FBM4 [4:4]
/// Filter mode
FBM4: u1 = 0,
/// FBM5 [5:5]
/// Filter mode
FBM5: u1 = 0,
/// FBM6 [6:6]
/// Filter mode
FBM6: u1 = 0,
/// FBM7 [7:7]
/// Filter mode
FBM7: u1 = 0,
/// FBM8 [8:8]
/// Filter mode
FBM8: u1 = 0,
/// FBM9 [9:9]
/// Filter mode
FBM9: u1 = 0,
/// FBM10 [10:10]
/// Filter mode
FBM10: u1 = 0,
/// FBM11 [11:11]
/// Filter mode
FBM11: u1 = 0,
/// FBM12 [12:12]
/// Filter mode
FBM12: u1 = 0,
/// FBM13 [13:13]
/// Filter mode
FBM13: u1 = 0,
/// FBM14 [14:14]
/// Filter mode
FBM14: u1 = 0,
/// FBM15 [15:15]
/// Filter mode
FBM15: u1 = 0,
/// FBM16 [16:16]
/// Filter mode
FBM16: u1 = 0,
/// FBM17 [17:17]
/// Filter mode
FBM17: u1 = 0,
/// FBM18 [18:18]
/// Filter mode
FBM18: u1 = 0,
/// FBM19 [19:19]
/// Filter mode
FBM19: u1 = 0,
/// FBM20 [20:20]
/// Filter mode
FBM20: u1 = 0,
/// FBM21 [21:21]
/// Filter mode
FBM21: u1 = 0,
/// FBM22 [22:22]
/// Filter mode
FBM22: u1 = 0,
/// FBM23 [23:23]
/// Filter mode
FBM23: u1 = 0,
/// FBM24 [24:24]
/// Filter mode
FBM24: u1 = 0,
/// FBM25 [25:25]
/// Filter mode
FBM25: u1 = 0,
/// FBM26 [26:26]
/// Filter mode
FBM26: u1 = 0,
/// FBM27 [27:27]
/// Filter mode
FBM27: u1 = 0,
/// unused [28:31]
_unused28: u4 = 0,
};
/// filter mode register
pub const FM1R = Register(FM1R_val).init(base_address + 0x204);
/// FS1R
const FS1R_val = packed struct {
/// FSC0 [0:0]
/// Filter scale configuration
FSC0: u1 = 0,
/// FSC1 [1:1]
/// Filter scale configuration
FSC1: u1 = 0,
/// FSC2 [2:2]
/// Filter scale configuration
FSC2: u1 = 0,
/// FSC3 [3:3]
/// Filter scale configuration
FSC3: u1 = 0,
/// FSC4 [4:4]
/// Filter scale configuration
FSC4: u1 = 0,
/// FSC5 [5:5]
/// Filter scale configuration
FSC5: u1 = 0,
/// FSC6 [6:6]
/// Filter scale configuration
FSC6: u1 = 0,
/// FSC7 [7:7]
/// Filter scale configuration
FSC7: u1 = 0,
/// FSC8 [8:8]
/// Filter scale configuration
FSC8: u1 = 0,
/// FSC9 [9:9]
/// Filter scale configuration
FSC9: u1 = 0,
/// FSC10 [10:10]
/// Filter scale configuration
FSC10: u1 = 0,
/// FSC11 [11:11]
/// Filter scale configuration
FSC11: u1 = 0,
/// FSC12 [12:12]
/// Filter scale configuration
FSC12: u1 = 0,
/// FSC13 [13:13]
/// Filter scale configuration
FSC13: u1 = 0,
/// FSC14 [14:14]
/// Filter scale configuration
FSC14: u1 = 0,
/// FSC15 [15:15]
/// Filter scale configuration
FSC15: u1 = 0,
/// FSC16 [16:16]
/// Filter scale configuration
FSC16: u1 = 0,
/// FSC17 [17:17]
/// Filter scale configuration
FSC17: u1 = 0,
/// FSC18 [18:18]
/// Filter scale configuration
FSC18: u1 = 0,
/// FSC19 [19:19]
/// Filter scale configuration
FSC19: u1 = 0,
/// FSC20 [20:20]
/// Filter scale configuration
FSC20: u1 = 0,
/// FSC21 [21:21]
/// Filter scale configuration
FSC21: u1 = 0,
/// FSC22 [22:22]
/// Filter scale configuration
FSC22: u1 = 0,
/// FSC23 [23:23]
/// Filter scale configuration
FSC23: u1 = 0,
/// FSC24 [24:24]
/// Filter scale configuration
FSC24: u1 = 0,
/// FSC25 [25:25]
/// Filter scale configuration
FSC25: u1 = 0,
/// FSC26 [26:26]
/// Filter scale configuration
FSC26: u1 = 0,
/// FSC27 [27:27]
/// Filter scale configuration
FSC27: u1 = 0,
/// unused [28:31]
_unused28: u4 = 0,
};
/// filter scale register
pub const FS1R = Register(FS1R_val).init(base_address + 0x20c);
/// FFA1R
const FFA1R_val = packed struct {
/// FFA0 [0:0]
/// Filter FIFO assignment for filter 0
FFA0: u1 = 0,
/// FFA1 [1:1]
/// Filter FIFO assignment for filter 1
FFA1: u1 = 0,
/// FFA2 [2:2]
/// Filter FIFO assignment for filter 2
FFA2: u1 = 0,
/// FFA3 [3:3]
/// Filter FIFO assignment for filter 3
FFA3: u1 = 0,
/// FFA4 [4:4]
/// Filter FIFO assignment for filter 4
FFA4: u1 = 0,
/// FFA5 [5:5]
/// Filter FIFO assignment for filter 5
FFA5: u1 = 0,
/// FFA6 [6:6]
/// Filter FIFO assignment for filter 6
FFA6: u1 = 0,
/// FFA7 [7:7]
/// Filter FIFO assignment for filter 7
FFA7: u1 = 0,
/// FFA8 [8:8]
/// Filter FIFO assignment for filter 8
FFA8: u1 = 0,
/// FFA9 [9:9]
/// Filter FIFO assignment for filter 9
FFA9: u1 = 0,
/// FFA10 [10:10]
/// Filter FIFO assignment for filter 10
FFA10: u1 = 0,
/// FFA11 [11:11]
/// Filter FIFO assignment for filter 11
FFA11: u1 = 0,
/// FFA12 [12:12]
/// Filter FIFO assignment for filter 12
FFA12: u1 = 0,
/// FFA13 [13:13]
/// Filter FIFO assignment for filter 13
FFA13: u1 = 0,
/// FFA14 [14:14]
/// Filter FIFO assignment for filter 14
FFA14: u1 = 0,
/// FFA15 [15:15]
/// Filter FIFO assignment for filter 15
FFA15: u1 = 0,
/// FFA16 [16:16]
/// Filter FIFO assignment for filter 16
FFA16: u1 = 0,
/// FFA17 [17:17]
/// Filter FIFO assignment for filter 17
FFA17: u1 = 0,
/// FFA18 [18:18]
/// Filter FIFO assignment for filter 18
FFA18: u1 = 0,
/// FFA19 [19:19]
/// Filter FIFO assignment for filter 19
FFA19: u1 = 0,
/// FFA20 [20:20]
/// Filter FIFO assignment for filter 20
FFA20: u1 = 0,
/// FFA21 [21:21]
/// Filter FIFO assignment for filter 21
FFA21: u1 = 0,
/// FFA22 [22:22]
/// Filter FIFO assignment for filter 22
FFA22: u1 = 0,
/// FFA23 [23:23]
/// Filter FIFO assignment for filter 23
FFA23: u1 = 0,
/// FFA24 [24:24]
/// Filter FIFO assignment for filter 24
FFA24: u1 = 0,
/// FFA25 [25:25]
/// Filter FIFO assignment for filter 25
FFA25: u1 = 0,
/// FFA26 [26:26]
/// Filter FIFO assignment for filter 26
FFA26: u1 = 0,
/// FFA27 [27:27]
/// Filter FIFO assignment for filter 27
FFA27: u1 = 0,
/// unused [28:31]
_unused28: u4 = 0,
};
/// filter FIFO assignment register
pub const FFA1R = Register(FFA1R_val).init(base_address + 0x214);
/// FA1R
const FA1R_val = packed struct {
/// FACT0 [0:0]
/// Filter active
FACT0: u1 = 0,
/// FACT1 [1:1]
/// Filter active
FACT1: u1 = 0,
/// FACT2 [2:2]
/// Filter active
FACT2: u1 = 0,
/// FACT3 [3:3]
/// Filter active
FACT3: u1 = 0,
/// FACT4 [4:4]
/// Filter active
FACT4: u1 = 0,
/// FACT5 [5:5]
/// Filter active
FACT5: u1 = 0,
/// FACT6 [6:6]
/// Filter active
FACT6: u1 = 0,
/// FACT7 [7:7]
/// Filter active
FACT7: u1 = 0,
/// FACT8 [8:8]
/// Filter active
FACT8: u1 = 0,
/// FACT9 [9:9]
/// Filter active
FACT9: u1 = 0,
/// FACT10 [10:10]
/// Filter active
FACT10: u1 = 0,
/// FACT11 [11:11]
/// Filter active
FACT11: u1 = 0,
/// FACT12 [12:12]
/// Filter active
FACT12: u1 = 0,
/// FACT13 [13:13]
/// Filter active
FACT13: u1 = 0,
/// FACT14 [14:14]
/// Filter active
FACT14: u1 = 0,
/// FACT15 [15:15]
/// Filter active
FACT15: u1 = 0,
/// FACT16 [16:16]
/// Filter active
FACT16: u1 = 0,
/// FACT17 [17:17]
/// Filter active
FACT17: u1 = 0,
/// FACT18 [18:18]
/// Filter active
FACT18: u1 = 0,
/// FACT19 [19:19]
/// Filter active
FACT19: u1 = 0,
/// FACT20 [20:20]
/// Filter active
FACT20: u1 = 0,
/// FACT21 [21:21]
/// Filter active
FACT21: u1 = 0,
/// FACT22 [22:22]
/// Filter active
FACT22: u1 = 0,
/// FACT23 [23:23]
/// Filter active
FACT23: u1 = 0,
/// FACT24 [24:24]
/// Filter active
FACT24: u1 = 0,
/// FACT25 [25:25]
/// Filter active
FACT25: u1 = 0,
/// FACT26 [26:26]
/// Filter active
FACT26: u1 = 0,
/// FACT27 [27:27]
/// Filter active
FACT27: u1 = 0,
/// unused [28:31]
_unused28: u4 = 0,
};
/// CAN filter activation register
pub const FA1R = Register(FA1R_val).init(base_address + 0x21c);
/// F0R1
const F0R1_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 0 register 1
pub const F0R1 = Register(F0R1_val).init(base_address + 0x240);
/// F0R2
const F0R2_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 0 register 2
pub const F0R2 = Register(F0R2_val).init(base_address + 0x244);
/// F1R1
const F1R1_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 1 register 1
pub const F1R1 = Register(F1R1_val).init(base_address + 0x248);
/// F1R2
const F1R2_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 1 register 2
pub const F1R2 = Register(F1R2_val).init(base_address + 0x24c);
/// F2R1
const F2R1_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 2 register 1
pub const F2R1 = Register(F2R1_val).init(base_address + 0x250);
/// F2R2
const F2R2_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 2 register 2
pub const F2R2 = Register(F2R2_val).init(base_address + 0x254);
/// F3R1
const F3R1_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 3 register 1
pub const F3R1 = Register(F3R1_val).init(base_address + 0x258);
/// F3R2
const F3R2_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 3 register 2
pub const F3R2 = Register(F3R2_val).init(base_address + 0x25c);
/// F4R1
const F4R1_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 4 register 1
pub const F4R1 = Register(F4R1_val).init(base_address + 0x260);
/// F4R2
const F4R2_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 4 register 2
pub const F4R2 = Register(F4R2_val).init(base_address + 0x264);
/// F5R1
const F5R1_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 5 register 1
pub const F5R1 = Register(F5R1_val).init(base_address + 0x268);
/// F5R2
const F5R2_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 5 register 2
pub const F5R2 = Register(F5R2_val).init(base_address + 0x26c);
/// F6R1
const F6R1_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 6 register 1
pub const F6R1 = Register(F6R1_val).init(base_address + 0x270);
/// F6R2
const F6R2_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 6 register 2
pub const F6R2 = Register(F6R2_val).init(base_address + 0x274);
/// F7R1
const F7R1_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 7 register 1
pub const F7R1 = Register(F7R1_val).init(base_address + 0x278);
/// F7R2
const F7R2_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 7 register 2
pub const F7R2 = Register(F7R2_val).init(base_address + 0x27c);
/// F8R1
const F8R1_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 8 register 1
pub const F8R1 = Register(F8R1_val).init(base_address + 0x280);
/// F8R2
const F8R2_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 8 register 2
pub const F8R2 = Register(F8R2_val).init(base_address + 0x284);
/// F9R1
const F9R1_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 9 register 1
pub const F9R1 = Register(F9R1_val).init(base_address + 0x288);
/// F9R2
const F9R2_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 9 register 2
pub const F9R2 = Register(F9R2_val).init(base_address + 0x28c);
/// F10R1
const F10R1_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 10 register 1
pub const F10R1 = Register(F10R1_val).init(base_address + 0x290);
/// F10R2
const F10R2_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 10 register 2
pub const F10R2 = Register(F10R2_val).init(base_address + 0x294);
/// F11R1
const F11R1_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 11 register 1
pub const F11R1 = Register(F11R1_val).init(base_address + 0x298);
/// F11R2
const F11R2_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 11 register 2
pub const F11R2 = Register(F11R2_val).init(base_address + 0x29c);
/// F12R1
const F12R1_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 4 register 1
pub const F12R1 = Register(F12R1_val).init(base_address + 0x2a0);
/// F12R2
const F12R2_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 12 register 2
pub const F12R2 = Register(F12R2_val).init(base_address + 0x2a4);
/// F13R1
const F13R1_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 13 register 1
pub const F13R1 = Register(F13R1_val).init(base_address + 0x2a8);
/// F13R2
const F13R2_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 13 register 2
pub const F13R2 = Register(F13R2_val).init(base_address + 0x2ac);
/// F14R1
const F14R1_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 14 register 1
pub const F14R1 = Register(F14R1_val).init(base_address + 0x2b0);
/// F14R2
const F14R2_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 14 register 2
pub const F14R2 = Register(F14R2_val).init(base_address + 0x2b4);
/// F15R1
const F15R1_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 15 register 1
pub const F15R1 = Register(F15R1_val).init(base_address + 0x2b8);
/// F15R2
const F15R2_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 15 register 2
pub const F15R2 = Register(F15R2_val).init(base_address + 0x2bc);
/// F16R1
const F16R1_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 16 register 1
pub const F16R1 = Register(F16R1_val).init(base_address + 0x2c0);
/// F16R2
const F16R2_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 16 register 2
pub const F16R2 = Register(F16R2_val).init(base_address + 0x2c4);
/// F17R1
const F17R1_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 17 register 1
pub const F17R1 = Register(F17R1_val).init(base_address + 0x2c8);
/// F17R2
const F17R2_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 17 register 2
pub const F17R2 = Register(F17R2_val).init(base_address + 0x2cc);
/// F18R1
const F18R1_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 18 register 1
pub const F18R1 = Register(F18R1_val).init(base_address + 0x2d0);
/// F18R2
const F18R2_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 18 register 2
pub const F18R2 = Register(F18R2_val).init(base_address + 0x2d4);
/// F19R1
const F19R1_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 19 register 1
pub const F19R1 = Register(F19R1_val).init(base_address + 0x2d8);
/// F19R2
const F19R2_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 19 register 2
pub const F19R2 = Register(F19R2_val).init(base_address + 0x2dc);
/// F20R1
const F20R1_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 20 register 1
pub const F20R1 = Register(F20R1_val).init(base_address + 0x2e0);
/// F20R2
const F20R2_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 20 register 2
pub const F20R2 = Register(F20R2_val).init(base_address + 0x2e4);
/// F21R1
const F21R1_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 21 register 1
pub const F21R1 = Register(F21R1_val).init(base_address + 0x2e8);
/// F21R2
const F21R2_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 21 register 2
pub const F21R2 = Register(F21R2_val).init(base_address + 0x2ec);
/// F22R1
const F22R1_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 22 register 1
pub const F22R1 = Register(F22R1_val).init(base_address + 0x2f0);
/// F22R2
const F22R2_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 22 register 2
pub const F22R2 = Register(F22R2_val).init(base_address + 0x2f4);
/// F23R1
const F23R1_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 23 register 1
pub const F23R1 = Register(F23R1_val).init(base_address + 0x2f8);
/// F23R2
const F23R2_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 23 register 2
pub const F23R2 = Register(F23R2_val).init(base_address + 0x2fc);
/// F24R1
const F24R1_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 24 register 1
pub const F24R1 = Register(F24R1_val).init(base_address + 0x300);
/// F24R2
const F24R2_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 24 register 2
pub const F24R2 = Register(F24R2_val).init(base_address + 0x304);
/// F25R1
const F25R1_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 25 register 1
pub const F25R1 = Register(F25R1_val).init(base_address + 0x308);
/// F25R2
const F25R2_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 25 register 2
pub const F25R2 = Register(F25R2_val).init(base_address + 0x30c);
/// F26R1
const F26R1_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 26 register 1
pub const F26R1 = Register(F26R1_val).init(base_address + 0x310);
/// F26R2
const F26R2_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 26 register 2
pub const F26R2 = Register(F26R2_val).init(base_address + 0x314);
/// F27R1
const F27R1_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 27 register 1
pub const F27R1 = Register(F27R1_val).init(base_address + 0x318);
/// F27R2
const F27R2_val = packed struct {
/// FB0 [0:0]
/// Filter bits
FB0: u1 = 0,
/// FB1 [1:1]
/// Filter bits
FB1: u1 = 0,
/// FB2 [2:2]
/// Filter bits
FB2: u1 = 0,
/// FB3 [3:3]
/// Filter bits
FB3: u1 = 0,
/// FB4 [4:4]
/// Filter bits
FB4: u1 = 0,
/// FB5 [5:5]
/// Filter bits
FB5: u1 = 0,
/// FB6 [6:6]
/// Filter bits
FB6: u1 = 0,
/// FB7 [7:7]
/// Filter bits
FB7: u1 = 0,
/// FB8 [8:8]
/// Filter bits
FB8: u1 = 0,
/// FB9 [9:9]
/// Filter bits
FB9: u1 = 0,
/// FB10 [10:10]
/// Filter bits
FB10: u1 = 0,
/// FB11 [11:11]
/// Filter bits
FB11: u1 = 0,
/// FB12 [12:12]
/// Filter bits
FB12: u1 = 0,
/// FB13 [13:13]
/// Filter bits
FB13: u1 = 0,
/// FB14 [14:14]
/// Filter bits
FB14: u1 = 0,
/// FB15 [15:15]
/// Filter bits
FB15: u1 = 0,
/// FB16 [16:16]
/// Filter bits
FB16: u1 = 0,
/// FB17 [17:17]
/// Filter bits
FB17: u1 = 0,
/// FB18 [18:18]
/// Filter bits
FB18: u1 = 0,
/// FB19 [19:19]
/// Filter bits
FB19: u1 = 0,
/// FB20 [20:20]
/// Filter bits
FB20: u1 = 0,
/// FB21 [21:21]
/// Filter bits
FB21: u1 = 0,
/// FB22 [22:22]
/// Filter bits
FB22: u1 = 0,
/// FB23 [23:23]
/// Filter bits
FB23: u1 = 0,
/// FB24 [24:24]
/// Filter bits
FB24: u1 = 0,
/// FB25 [25:25]
/// Filter bits
FB25: u1 = 0,
/// FB26 [26:26]
/// Filter bits
FB26: u1 = 0,
/// FB27 [27:27]
/// Filter bits
FB27: u1 = 0,
/// FB28 [28:28]
/// Filter bits
FB28: u1 = 0,
/// FB29 [29:29]
/// Filter bits
FB29: u1 = 0,
/// FB30 [30:30]
/// Filter bits
FB30: u1 = 0,
/// FB31 [31:31]
/// Filter bits
FB31: u1 = 0,
};
/// Filter bank 27 register 2
pub const F27R2 = Register(F27R2_val).init(base_address + 0x31c);
};
/// Universal serial bus full-speed device interface
pub const USB_FS = struct {
const base_address = 0x40005c00;
/// USB_EP0R
const USB_EP0R_val = packed struct {
/// EA [0:3]
/// Endpoint address
EA: u4 = 0,
/// STAT_TX [4:5]
/// Status bits, for transmission transfers
STAT_TX: u2 = 0,
/// DTOG_TX [6:6]
/// Data Toggle, for transmission transfers
DTOG_TX: u1 = 0,
/// CTR_TX [7:7]
/// Correct Transfer for transmission
CTR_TX: u1 = 0,
/// EP_KIND [8:8]
/// Endpoint kind
EP_KIND: u1 = 0,
/// EP_TYPE [9:10]
/// Endpoint type
EP_TYPE: u2 = 0,
/// SETUP [11:11]
/// Setup transaction completed
SETUP: u1 = 0,
/// STAT_RX [12:13]
/// Status bits, for reception transfers
STAT_RX: u2 = 0,
/// DTOG_RX [14:14]
/// Data Toggle, for reception transfers
DTOG_RX: u1 = 0,
/// CTR_RX [15:15]
/// Correct transfer for reception
CTR_RX: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// endpoint 0 register
pub const USB_EP0R = Register(USB_EP0R_val).init(base_address + 0x0);
/// USB_EP1R
const USB_EP1R_val = packed struct {
/// EA [0:3]
/// Endpoint address
EA: u4 = 0,
/// STAT_TX [4:5]
/// Status bits, for transmission transfers
STAT_TX: u2 = 0,
/// DTOG_TX [6:6]
/// Data Toggle, for transmission transfers
DTOG_TX: u1 = 0,
/// CTR_TX [7:7]
/// Correct Transfer for transmission
CTR_TX: u1 = 0,
/// EP_KIND [8:8]
/// Endpoint kind
EP_KIND: u1 = 0,
/// EP_TYPE [9:10]
/// Endpoint type
EP_TYPE: u2 = 0,
/// SETUP [11:11]
/// Setup transaction completed
SETUP: u1 = 0,
/// STAT_RX [12:13]
/// Status bits, for reception transfers
STAT_RX: u2 = 0,
/// DTOG_RX [14:14]
/// Data Toggle, for reception transfers
DTOG_RX: u1 = 0,
/// CTR_RX [15:15]
/// Correct transfer for reception
CTR_RX: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// endpoint 1 register
pub const USB_EP1R = Register(USB_EP1R_val).init(base_address + 0x4);
/// USB_EP2R
const USB_EP2R_val = packed struct {
/// EA [0:3]
/// Endpoint address
EA: u4 = 0,
/// STAT_TX [4:5]
/// Status bits, for transmission transfers
STAT_TX: u2 = 0,
/// DTOG_TX [6:6]
/// Data Toggle, for transmission transfers
DTOG_TX: u1 = 0,
/// CTR_TX [7:7]
/// Correct Transfer for transmission
CTR_TX: u1 = 0,
/// EP_KIND [8:8]
/// Endpoint kind
EP_KIND: u1 = 0,
/// EP_TYPE [9:10]
/// Endpoint type
EP_TYPE: u2 = 0,
/// SETUP [11:11]
/// Setup transaction completed
SETUP: u1 = 0,
/// STAT_RX [12:13]
/// Status bits, for reception transfers
STAT_RX: u2 = 0,
/// DTOG_RX [14:14]
/// Data Toggle, for reception transfers
DTOG_RX: u1 = 0,
/// CTR_RX [15:15]
/// Correct transfer for reception
CTR_RX: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// endpoint 2 register
pub const USB_EP2R = Register(USB_EP2R_val).init(base_address + 0x8);
/// USB_EP3R
const USB_EP3R_val = packed struct {
/// EA [0:3]
/// Endpoint address
EA: u4 = 0,
/// STAT_TX [4:5]
/// Status bits, for transmission transfers
STAT_TX: u2 = 0,
/// DTOG_TX [6:6]
/// Data Toggle, for transmission transfers
DTOG_TX: u1 = 0,
/// CTR_TX [7:7]
/// Correct Transfer for transmission
CTR_TX: u1 = 0,
/// EP_KIND [8:8]
/// Endpoint kind
EP_KIND: u1 = 0,
/// EP_TYPE [9:10]
/// Endpoint type
EP_TYPE: u2 = 0,
/// SETUP [11:11]
/// Setup transaction completed
SETUP: u1 = 0,
/// STAT_RX [12:13]
/// Status bits, for reception transfers
STAT_RX: u2 = 0,
/// DTOG_RX [14:14]
/// Data Toggle, for reception transfers
DTOG_RX: u1 = 0,
/// CTR_RX [15:15]
/// Correct transfer for reception
CTR_RX: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// endpoint 3 register
pub const USB_EP3R = Register(USB_EP3R_val).init(base_address + 0xc);
/// USB_EP4R
const USB_EP4R_val = packed struct {
/// EA [0:3]
/// Endpoint address
EA: u4 = 0,
/// STAT_TX [4:5]
/// Status bits, for transmission transfers
STAT_TX: u2 = 0,
/// DTOG_TX [6:6]
/// Data Toggle, for transmission transfers
DTOG_TX: u1 = 0,
/// CTR_TX [7:7]
/// Correct Transfer for transmission
CTR_TX: u1 = 0,
/// EP_KIND [8:8]
/// Endpoint kind
EP_KIND: u1 = 0,
/// EP_TYPE [9:10]
/// Endpoint type
EP_TYPE: u2 = 0,
/// SETUP [11:11]
/// Setup transaction completed
SETUP: u1 = 0,
/// STAT_RX [12:13]
/// Status bits, for reception transfers
STAT_RX: u2 = 0,
/// DTOG_RX [14:14]
/// Data Toggle, for reception transfers
DTOG_RX: u1 = 0,
/// CTR_RX [15:15]
/// Correct transfer for reception
CTR_RX: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// endpoint 4 register
pub const USB_EP4R = Register(USB_EP4R_val).init(base_address + 0x10);
/// USB_EP5R
const USB_EP5R_val = packed struct {
/// EA [0:3]
/// Endpoint address
EA: u4 = 0,
/// STAT_TX [4:5]
/// Status bits, for transmission transfers
STAT_TX: u2 = 0,
/// DTOG_TX [6:6]
/// Data Toggle, for transmission transfers
DTOG_TX: u1 = 0,
/// CTR_TX [7:7]
/// Correct Transfer for transmission
CTR_TX: u1 = 0,
/// EP_KIND [8:8]
/// Endpoint kind
EP_KIND: u1 = 0,
/// EP_TYPE [9:10]
/// Endpoint type
EP_TYPE: u2 = 0,
/// SETUP [11:11]
/// Setup transaction completed
SETUP: u1 = 0,
/// STAT_RX [12:13]
/// Status bits, for reception transfers
STAT_RX: u2 = 0,
/// DTOG_RX [14:14]
/// Data Toggle, for reception transfers
DTOG_RX: u1 = 0,
/// CTR_RX [15:15]
/// Correct transfer for reception
CTR_RX: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// endpoint 5 register
pub const USB_EP5R = Register(USB_EP5R_val).init(base_address + 0x14);
/// USB_EP6R
const USB_EP6R_val = packed struct {
/// EA [0:3]
/// Endpoint address
EA: u4 = 0,
/// STAT_TX [4:5]
/// Status bits, for transmission transfers
STAT_TX: u2 = 0,
/// DTOG_TX [6:6]
/// Data Toggle, for transmission transfers
DTOG_TX: u1 = 0,
/// CTR_TX [7:7]
/// Correct Transfer for transmission
CTR_TX: u1 = 0,
/// EP_KIND [8:8]
/// Endpoint kind
EP_KIND: u1 = 0,
/// EP_TYPE [9:10]
/// Endpoint type
EP_TYPE: u2 = 0,
/// SETUP [11:11]
/// Setup transaction completed
SETUP: u1 = 0,
/// STAT_RX [12:13]
/// Status bits, for reception transfers
STAT_RX: u2 = 0,
/// DTOG_RX [14:14]
/// Data Toggle, for reception transfers
DTOG_RX: u1 = 0,
/// CTR_RX [15:15]
/// Correct transfer for reception
CTR_RX: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// endpoint 6 register
pub const USB_EP6R = Register(USB_EP6R_val).init(base_address + 0x18);
/// USB_EP7R
const USB_EP7R_val = packed struct {
/// EA [0:3]
/// Endpoint address
EA: u4 = 0,
/// STAT_TX [4:5]
/// Status bits, for transmission transfers
STAT_TX: u2 = 0,
/// DTOG_TX [6:6]
/// Data Toggle, for transmission transfers
DTOG_TX: u1 = 0,
/// CTR_TX [7:7]
/// Correct Transfer for transmission
CTR_TX: u1 = 0,
/// EP_KIND [8:8]
/// Endpoint kind
EP_KIND: u1 = 0,
/// EP_TYPE [9:10]
/// Endpoint type
EP_TYPE: u2 = 0,
/// SETUP [11:11]
/// Setup transaction completed
SETUP: u1 = 0,
/// STAT_RX [12:13]
/// Status bits, for reception transfers
STAT_RX: u2 = 0,
/// DTOG_RX [14:14]
/// Data Toggle, for reception transfers
DTOG_RX: u1 = 0,
/// CTR_RX [15:15]
/// Correct transfer for reception
CTR_RX: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// endpoint 7 register
pub const USB_EP7R = Register(USB_EP7R_val).init(base_address + 0x1c);
/// USB_CNTR
const USB_CNTR_val = packed struct {
/// FRES [0:0]
/// Force USB Reset
FRES: u1 = 1,
/// PDWN [1:1]
/// Power down
PDWN: u1 = 1,
/// LPMODE [2:2]
/// Low-power mode
LPMODE: u1 = 0,
/// FSUSP [3:3]
/// Force suspend
FSUSP: u1 = 0,
/// RESUME [4:4]
/// Resume request
RESUME: u1 = 0,
/// unused [5:7]
_unused5: u3 = 0,
/// ESOFM [8:8]
/// Expected start of frame interrupt mask
ESOFM: u1 = 0,
/// SOFM [9:9]
/// Start of frame interrupt mask
SOFM: u1 = 0,
/// RESETM [10:10]
/// USB reset interrupt mask
RESETM: u1 = 0,
/// SUSPM [11:11]
/// Suspend mode interrupt mask
SUSPM: u1 = 0,
/// WKUPM [12:12]
/// Wakeup interrupt mask
WKUPM: u1 = 0,
/// ERRM [13:13]
/// Error interrupt mask
ERRM: u1 = 0,
/// PMAOVRM [14:14]
/// Packet memory area over / underrun interrupt mask
PMAOVRM: u1 = 0,
/// CTRM [15:15]
/// Correct transfer interrupt mask
CTRM: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// control register
pub const USB_CNTR = Register(USB_CNTR_val).init(base_address + 0x40);
/// ISTR
const ISTR_val = packed struct {
/// EP_ID [0:3]
/// Endpoint Identifier
EP_ID: u4 = 0,
/// DIR [4:4]
/// Direction of transaction
DIR: u1 = 0,
/// unused [5:7]
_unused5: u3 = 0,
/// ESOF [8:8]
/// Expected start frame
ESOF: u1 = 0,
/// SOF [9:9]
/// start of frame
SOF: u1 = 0,
/// RESET [10:10]
/// reset request
RESET: u1 = 0,
/// SUSP [11:11]
/// Suspend mode request
SUSP: u1 = 0,
/// WKUP [12:12]
/// Wakeup
WKUP: u1 = 0,
/// ERR [13:13]
/// Error
ERR: u1 = 0,
/// PMAOVR [14:14]
/// Packet memory area over / underrun
PMAOVR: u1 = 0,
/// CTR [15:15]
/// Correct transfer
CTR: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// interrupt status register
pub const ISTR = Register(ISTR_val).init(base_address + 0x44);
/// FNR
const FNR_val = packed struct {
/// FN [0:10]
/// Frame number
FN: u11 = 0,
/// LSOF [11:12]
/// Lost SOF
LSOF: u2 = 0,
/// LCK [13:13]
/// Locked
LCK: u1 = 0,
/// RXDM [14:14]
/// Receive data - line status
RXDM: u1 = 0,
/// RXDP [15:15]
/// Receive data + line status
RXDP: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// frame number register
pub const FNR = Register(FNR_val).init(base_address + 0x48);
/// DADDR
const DADDR_val = packed struct {
/// ADD [0:0]
/// Device address
ADD: u1 = 0,
/// ADD1 [1:1]
/// Device address
ADD1: u1 = 0,
/// ADD2 [2:2]
/// Device address
ADD2: u1 = 0,
/// ADD3 [3:3]
/// Device address
ADD3: u1 = 0,
/// ADD4 [4:4]
/// Device address
ADD4: u1 = 0,
/// ADD5 [5:5]
/// Device address
ADD5: u1 = 0,
/// ADD6 [6:6]
/// Device address
ADD6: u1 = 0,
/// EF [7:7]
/// Enable function
EF: u1 = 0,
/// unused [8:31]
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// device address
pub const DADDR = Register(DADDR_val).init(base_address + 0x4c);
/// BTABLE
const BTABLE_val = packed struct {
/// unused [0:2]
_unused0: u3 = 0,
/// BTABLE [3:15]
/// Buffer table
BTABLE: u13 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Buffer table address
pub const BTABLE = Register(BTABLE_val).init(base_address + 0x50);
};
/// Inter-integrated circuit
pub const I2C1 = struct {
const base_address = 0x40005400;
/// CR1
const CR1_val = packed struct {
/// PE [0:0]
/// Peripheral enable
PE: u1 = 0,
/// TXIE [1:1]
/// TX Interrupt enable
TXIE: u1 = 0,
/// RXIE [2:2]
/// RX Interrupt enable
RXIE: u1 = 0,
/// ADDRIE [3:3]
/// Address match interrupt enable (slave only)
ADDRIE: u1 = 0,
/// NACKIE [4:4]
/// Not acknowledge received interrupt enable
NACKIE: u1 = 0,
/// STOPIE [5:5]
/// STOP detection Interrupt enable
STOPIE: u1 = 0,
/// TCIE [6:6]
/// Transfer Complete interrupt enable
TCIE: u1 = 0,
/// ERRIE [7:7]
/// Error interrupts enable
ERRIE: u1 = 0,
/// DNF [8:11]
/// Digital noise filter
DNF: u4 = 0,
/// ANFOFF [12:12]
/// Analog noise filter OFF
ANFOFF: u1 = 0,
/// SWRST [13:13]
/// Software reset
SWRST: u1 = 0,
/// TXDMAEN [14:14]
/// DMA transmission requests enable
TXDMAEN: u1 = 0,
/// RXDMAEN [15:15]
/// DMA reception requests enable
RXDMAEN: u1 = 0,
/// SBC [16:16]
/// Slave byte control
SBC: u1 = 0,
/// NOSTRETCH [17:17]
/// Clock stretching disable
NOSTRETCH: u1 = 0,
/// WUPEN [18:18]
/// Wakeup from STOP enable
WUPEN: u1 = 0,
/// GCEN [19:19]
/// General call enable
GCEN: u1 = 0,
/// SMBHEN [20:20]
/// SMBus Host address enable
SMBHEN: u1 = 0,
/// SMBDEN [21:21]
/// SMBus Device Default address enable
SMBDEN: u1 = 0,
/// ALERTEN [22:22]
/// SMBUS alert enable
ALERTEN: u1 = 0,
/// PECEN [23:23]
/// PEC enable
PECEN: u1 = 0,
/// unused [24:31]
_unused24: u8 = 0,
};
/// Control register 1
pub const CR1 = Register(CR1_val).init(base_address + 0x0);
/// CR2
const CR2_val = packed struct {
/// SADD0 [0:0]
/// Slave address bit 0 (master mode)
SADD0: u1 = 0,
/// SADD1 [1:7]
/// Slave address bit 7:1 (master mode)
SADD1: u7 = 0,
/// SADD8 [8:9]
/// Slave address bit 9:8 (master mode)
SADD8: u2 = 0,
/// RD_WRN [10:10]
/// Transfer direction (master mode)
RD_WRN: u1 = 0,
/// ADD10 [11:11]
/// 10-bit addressing mode (master mode)
ADD10: u1 = 0,
/// HEAD10R [12:12]
/// 10-bit address header only read direction (master receiver mode)
HEAD10R: u1 = 0,
/// START [13:13]
/// Start generation
START: u1 = 0,
/// STOP [14:14]
/// Stop generation (master mode)
STOP: u1 = 0,
/// NACK [15:15]
/// NACK generation (slave mode)
NACK: u1 = 0,
/// NBYTES [16:23]
/// Number of bytes
NBYTES: u8 = 0,
/// RELOAD [24:24]
/// NBYTES reload mode
RELOAD: u1 = 0,
/// AUTOEND [25:25]
/// Automatic end mode (master mode)
AUTOEND: u1 = 0,
/// PECBYTE [26:26]
/// Packet error checking byte
PECBYTE: u1 = 0,
/// unused [27:31]
_unused27: u5 = 0,
};
/// Control register 2
pub const CR2 = Register(CR2_val).init(base_address + 0x4);
/// OAR1
const OAR1_val = packed struct {
/// OA1_0 [0:0]
/// Interface address
OA1_0: u1 = 0,
/// OA1_1 [1:7]
/// Interface address
OA1_1: u7 = 0,
/// OA1_8 [8:9]
/// Interface address
OA1_8: u2 = 0,
/// OA1MODE [10:10]
/// Own Address 1 10-bit mode
OA1MODE: u1 = 0,
/// unused [11:14]
_unused11: u4 = 0,
/// OA1EN [15:15]
/// Own Address 1 enable
OA1EN: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Own address register 1
pub const OAR1 = Register(OAR1_val).init(base_address + 0x8);
/// OAR2
const OAR2_val = packed struct {
/// unused [0:0]
_unused0: u1 = 0,
/// OA2 [1:7]
/// Interface address
OA2: u7 = 0,
/// OA2MSK [8:10]
/// Own Address 2 masks
OA2MSK: u3 = 0,
/// unused [11:14]
_unused11: u4 = 0,
/// OA2EN [15:15]
/// Own Address 2 enable
OA2EN: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Own address register 2
pub const OAR2 = Register(OAR2_val).init(base_address + 0xc);
/// TIMINGR
const TIMINGR_val = packed struct {
/// SCLL [0:7]
/// SCL low period (master mode)
SCLL: u8 = 0,
/// SCLH [8:15]
/// SCL high period (master mode)
SCLH: u8 = 0,
/// SDADEL [16:19]
/// Data hold time
SDADEL: u4 = 0,
/// SCLDEL [20:23]
/// Data setup time
SCLDEL: u4 = 0,
/// unused [24:27]
_unused24: u4 = 0,
/// PRESC [28:31]
/// Timing prescaler
PRESC: u4 = 0,
};
/// Timing register
pub const TIMINGR = Register(TIMINGR_val).init(base_address + 0x10);
/// TIMEOUTR
const TIMEOUTR_val = packed struct {
/// TIMEOUTA [0:11]
/// Bus timeout A
TIMEOUTA: u12 = 0,
/// TIDLE [12:12]
/// Idle clock timeout detection
TIDLE: u1 = 0,
/// unused [13:14]
_unused13: u2 = 0,
/// TIMOUTEN [15:15]
/// Clock timeout enable
TIMOUTEN: u1 = 0,
/// TIMEOUTB [16:27]
/// Bus timeout B
TIMEOUTB: u12 = 0,
/// unused [28:30]
_unused28: u3 = 0,
/// TEXTEN [31:31]
/// Extended clock timeout enable
TEXTEN: u1 = 0,
};
/// Status register 1
pub const TIMEOUTR = Register(TIMEOUTR_val).init(base_address + 0x14);
/// ISR
const ISR_val = packed struct {
/// TXE [0:0]
/// Transmit data register empty (transmitters)
TXE: u1 = 1,
/// TXIS [1:1]
/// Transmit interrupt status (transmitters)
TXIS: u1 = 0,
/// RXNE [2:2]
/// Receive data register not empty (receivers)
RXNE: u1 = 0,
/// ADDR [3:3]
/// Address matched (slave mode)
ADDR: u1 = 0,
/// NACKF [4:4]
/// Not acknowledge received flag
NACKF: u1 = 0,
/// STOPF [5:5]
/// Stop detection flag
STOPF: u1 = 0,
/// TC [6:6]
/// Transfer Complete (master mode)
TC: u1 = 0,
/// TCR [7:7]
/// Transfer Complete Reload
TCR: u1 = 0,
/// BERR [8:8]
/// Bus error
BERR: u1 = 0,
/// ARLO [9:9]
/// Arbitration lost
ARLO: u1 = 0,
/// OVR [10:10]
/// Overrun/Underrun (slave mode)
OVR: u1 = 0,
/// PECERR [11:11]
/// PEC Error in reception
PECERR: u1 = 0,
/// TIMEOUT [12:12]
/// Timeout or t_low detection flag
TIMEOUT: u1 = 0,
/// ALERT [13:13]
/// SMBus alert
ALERT: u1 = 0,
/// unused [14:14]
_unused14: u1 = 0,
/// BUSY [15:15]
/// Bus busy
BUSY: u1 = 0,
/// DIR [16:16]
/// Transfer direction (Slave mode)
DIR: u1 = 0,
/// ADDCODE [17:23]
/// Address match code (Slave mode)
ADDCODE: u7 = 0,
/// unused [24:31]
_unused24: u8 = 0,
};
/// Interrupt and Status register
pub const ISR = Register(ISR_val).init(base_address + 0x18);
/// ICR
const ICR_val = packed struct {
/// unused [0:2]
_unused0: u3 = 0,
/// ADDRCF [3:3]
/// Address Matched flag clear
ADDRCF: u1 = 0,
/// NACKCF [4:4]
/// Not Acknowledge flag clear
NACKCF: u1 = 0,
/// STOPCF [5:5]
/// Stop detection flag clear
STOPCF: u1 = 0,
/// unused [6:7]
_unused6: u2 = 0,
/// BERRCF [8:8]
/// Bus error flag clear
BERRCF: u1 = 0,
/// ARLOCF [9:9]
/// Arbitration lost flag clear
ARLOCF: u1 = 0,
/// OVRCF [10:10]
/// Overrun/Underrun flag clear
OVRCF: u1 = 0,
/// PECCF [11:11]
/// PEC Error flag clear
PECCF: u1 = 0,
/// TIMOUTCF [12:12]
/// Timeout detection flag clear
TIMOUTCF: u1 = 0,
/// ALERTCF [13:13]
/// Alert flag clear
ALERTCF: u1 = 0,
/// unused [14:31]
_unused14: u2 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Interrupt clear register
pub const ICR = Register(ICR_val).init(base_address + 0x1c);
/// PECR
const PECR_val = packed struct {
/// PEC [0:7]
/// Packet error checking register
PEC: u8 = 0,
/// unused [8:31]
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// PEC register
pub const PECR = Register(PECR_val).init(base_address + 0x20);
/// RXDR
const RXDR_val = packed struct {
/// RXDATA [0:7]
/// 8-bit receive data
RXDATA: u8 = 0,
/// unused [8:31]
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Receive data register
pub const RXDR = Register(RXDR_val).init(base_address + 0x24);
/// TXDR
const TXDR_val = packed struct {
/// TXDATA [0:7]
/// 8-bit transmit data
TXDATA: u8 = 0,
/// unused [8:31]
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Transmit data register
pub const TXDR = Register(TXDR_val).init(base_address + 0x28);
};
/// Inter-integrated circuit
pub const I2C2 = struct {
const base_address = 0x40005800;
/// CR1
const CR1_val = packed struct {
/// PE [0:0]
/// Peripheral enable
PE: u1 = 0,
/// TXIE [1:1]
/// TX Interrupt enable
TXIE: u1 = 0,
/// RXIE [2:2]
/// RX Interrupt enable
RXIE: u1 = 0,
/// ADDRIE [3:3]
/// Address match interrupt enable (slave only)
ADDRIE: u1 = 0,
/// NACKIE [4:4]
/// Not acknowledge received interrupt enable
NACKIE: u1 = 0,
/// STOPIE [5:5]
/// STOP detection Interrupt enable
STOPIE: u1 = 0,
/// TCIE [6:6]
/// Transfer Complete interrupt enable
TCIE: u1 = 0,
/// ERRIE [7:7]
/// Error interrupts enable
ERRIE: u1 = 0,
/// DNF [8:11]
/// Digital noise filter
DNF: u4 = 0,
/// ANFOFF [12:12]
/// Analog noise filter OFF
ANFOFF: u1 = 0,
/// SWRST [13:13]
/// Software reset
SWRST: u1 = 0,
/// TXDMAEN [14:14]
/// DMA transmission requests enable
TXDMAEN: u1 = 0,
/// RXDMAEN [15:15]
/// DMA reception requests enable
RXDMAEN: u1 = 0,
/// SBC [16:16]
/// Slave byte control
SBC: u1 = 0,
/// NOSTRETCH [17:17]
/// Clock stretching disable
NOSTRETCH: u1 = 0,
/// WUPEN [18:18]
/// Wakeup from STOP enable
WUPEN: u1 = 0,
/// GCEN [19:19]
/// General call enable
GCEN: u1 = 0,
/// SMBHEN [20:20]
/// SMBus Host address enable
SMBHEN: u1 = 0,
/// SMBDEN [21:21]
/// SMBus Device Default address enable
SMBDEN: u1 = 0,
/// ALERTEN [22:22]
/// SMBUS alert enable
ALERTEN: u1 = 0,
/// PECEN [23:23]
/// PEC enable
PECEN: u1 = 0,
/// unused [24:31]
_unused24: u8 = 0,
};
/// Control register 1
pub const CR1 = Register(CR1_val).init(base_address + 0x0);
/// CR2
const CR2_val = packed struct {
/// SADD0 [0:0]
/// Slave address bit 0 (master mode)
SADD0: u1 = 0,
/// SADD1 [1:7]
/// Slave address bit 7:1 (master mode)
SADD1: u7 = 0,
/// SADD8 [8:9]
/// Slave address bit 9:8 (master mode)
SADD8: u2 = 0,
/// RD_WRN [10:10]
/// Transfer direction (master mode)
RD_WRN: u1 = 0,
/// ADD10 [11:11]
/// 10-bit addressing mode (master mode)
ADD10: u1 = 0,
/// HEAD10R [12:12]
/// 10-bit address header only read direction (master receiver mode)
HEAD10R: u1 = 0,
/// START [13:13]
/// Start generation
START: u1 = 0,
/// STOP [14:14]
/// Stop generation (master mode)
STOP: u1 = 0,
/// NACK [15:15]
/// NACK generation (slave mode)
NACK: u1 = 0,
/// NBYTES [16:23]
/// Number of bytes
NBYTES: u8 = 0,
/// RELOAD [24:24]
/// NBYTES reload mode
RELOAD: u1 = 0,
/// AUTOEND [25:25]
/// Automatic end mode (master mode)
AUTOEND: u1 = 0,
/// PECBYTE [26:26]
/// Packet error checking byte
PECBYTE: u1 = 0,
/// unused [27:31]
_unused27: u5 = 0,
};
/// Control register 2
pub const CR2 = Register(CR2_val).init(base_address + 0x4);
/// OAR1
const OAR1_val = packed struct {
/// OA1_0 [0:0]
/// Interface address
OA1_0: u1 = 0,
/// OA1_1 [1:7]
/// Interface address
OA1_1: u7 = 0,
/// OA1_8 [8:9]
/// Interface address
OA1_8: u2 = 0,
/// OA1MODE [10:10]
/// Own Address 1 10-bit mode
OA1MODE: u1 = 0,
/// unused [11:14]
_unused11: u4 = 0,
/// OA1EN [15:15]
/// Own Address 1 enable
OA1EN: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Own address register 1
pub const OAR1 = Register(OAR1_val).init(base_address + 0x8);
/// OAR2
const OAR2_val = packed struct {
/// unused [0:0]
_unused0: u1 = 0,
/// OA2 [1:7]
/// Interface address
OA2: u7 = 0,
/// OA2MSK [8:10]
/// Own Address 2 masks
OA2MSK: u3 = 0,
/// unused [11:14]
_unused11: u4 = 0,
/// OA2EN [15:15]
/// Own Address 2 enable
OA2EN: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Own address register 2
pub const OAR2 = Register(OAR2_val).init(base_address + 0xc);
/// TIMINGR
const TIMINGR_val = packed struct {
/// SCLL [0:7]
/// SCL low period (master mode)
SCLL: u8 = 0,
/// SCLH [8:15]
/// SCL high period (master mode)
SCLH: u8 = 0,
/// SDADEL [16:19]
/// Data hold time
SDADEL: u4 = 0,
/// SCLDEL [20:23]
/// Data setup time
SCLDEL: u4 = 0,
/// unused [24:27]
_unused24: u4 = 0,
/// PRESC [28:31]
/// Timing prescaler
PRESC: u4 = 0,
};
/// Timing register
pub const TIMINGR = Register(TIMINGR_val).init(base_address + 0x10);
/// TIMEOUTR
const TIMEOUTR_val = packed struct {
/// TIMEOUTA [0:11]
/// Bus timeout A
TIMEOUTA: u12 = 0,
/// TIDLE [12:12]
/// Idle clock timeout detection
TIDLE: u1 = 0,
/// unused [13:14]
_unused13: u2 = 0,
/// TIMOUTEN [15:15]
/// Clock timeout enable
TIMOUTEN: u1 = 0,
/// TIMEOUTB [16:27]
/// Bus timeout B
TIMEOUTB: u12 = 0,
/// unused [28:30]
_unused28: u3 = 0,
/// TEXTEN [31:31]
/// Extended clock timeout enable
TEXTEN: u1 = 0,
};
/// Status register 1
pub const TIMEOUTR = Register(TIMEOUTR_val).init(base_address + 0x14);
/// ISR
const ISR_val = packed struct {
/// TXE [0:0]
/// Transmit data register empty (transmitters)
TXE: u1 = 1,
/// TXIS [1:1]
/// Transmit interrupt status (transmitters)
TXIS: u1 = 0,
/// RXNE [2:2]
/// Receive data register not empty (receivers)
RXNE: u1 = 0,
/// ADDR [3:3]
/// Address matched (slave mode)
ADDR: u1 = 0,
/// NACKF [4:4]
/// Not acknowledge received flag
NACKF: u1 = 0,
/// STOPF [5:5]
/// Stop detection flag
STOPF: u1 = 0,
/// TC [6:6]
/// Transfer Complete (master mode)
TC: u1 = 0,
/// TCR [7:7]
/// Transfer Complete Reload
TCR: u1 = 0,
/// BERR [8:8]
/// Bus error
BERR: u1 = 0,
/// ARLO [9:9]
/// Arbitration lost
ARLO: u1 = 0,
/// OVR [10:10]
/// Overrun/Underrun (slave mode)
OVR: u1 = 0,
/// PECERR [11:11]
/// PEC Error in reception
PECERR: u1 = 0,
/// TIMEOUT [12:12]
/// Timeout or t_low detection flag
TIMEOUT: u1 = 0,
/// ALERT [13:13]
/// SMBus alert
ALERT: u1 = 0,
/// unused [14:14]
_unused14: u1 = 0,
/// BUSY [15:15]
/// Bus busy
BUSY: u1 = 0,
/// DIR [16:16]
/// Transfer direction (Slave mode)
DIR: u1 = 0,
/// ADDCODE [17:23]
/// Address match code (Slave mode)
ADDCODE: u7 = 0,
/// unused [24:31]
_unused24: u8 = 0,
};
/// Interrupt and Status register
pub const ISR = Register(ISR_val).init(base_address + 0x18);
/// ICR
const ICR_val = packed struct {
/// unused [0:2]
_unused0: u3 = 0,
/// ADDRCF [3:3]
/// Address Matched flag clear
ADDRCF: u1 = 0,
/// NACKCF [4:4]
/// Not Acknowledge flag clear
NACKCF: u1 = 0,
/// STOPCF [5:5]
/// Stop detection flag clear
STOPCF: u1 = 0,
/// unused [6:7]
_unused6: u2 = 0,
/// BERRCF [8:8]
/// Bus error flag clear
BERRCF: u1 = 0,
/// ARLOCF [9:9]
/// Arbitration lost flag clear
ARLOCF: u1 = 0,
/// OVRCF [10:10]
/// Overrun/Underrun flag clear
OVRCF: u1 = 0,
/// PECCF [11:11]
/// PEC Error flag clear
PECCF: u1 = 0,
/// TIMOUTCF [12:12]
/// Timeout detection flag clear
TIMOUTCF: u1 = 0,
/// ALERTCF [13:13]
/// Alert flag clear
ALERTCF: u1 = 0,
/// unused [14:31]
_unused14: u2 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Interrupt clear register
pub const ICR = Register(ICR_val).init(base_address + 0x1c);
/// PECR
const PECR_val = packed struct {
/// PEC [0:7]
/// Packet error checking register
PEC: u8 = 0,
/// unused [8:31]
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// PEC register
pub const PECR = Register(PECR_val).init(base_address + 0x20);
/// RXDR
const RXDR_val = packed struct {
/// RXDATA [0:7]
/// 8-bit receive data
RXDATA: u8 = 0,
/// unused [8:31]
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Receive data register
pub const RXDR = Register(RXDR_val).init(base_address + 0x24);
/// TXDR
const TXDR_val = packed struct {
/// TXDATA [0:7]
/// 8-bit transmit data
TXDATA: u8 = 0,
/// unused [8:31]
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Transmit data register
pub const TXDR = Register(TXDR_val).init(base_address + 0x28);
};
/// Inter-integrated circuit
pub const I2C3 = struct {
const base_address = 0x40007800;
/// CR1
const CR1_val = packed struct {
/// PE [0:0]
/// Peripheral enable
PE: u1 = 0,
/// TXIE [1:1]
/// TX Interrupt enable
TXIE: u1 = 0,
/// RXIE [2:2]
/// RX Interrupt enable
RXIE: u1 = 0,
/// ADDRIE [3:3]
/// Address match interrupt enable (slave only)
ADDRIE: u1 = 0,
/// NACKIE [4:4]
/// Not acknowledge received interrupt enable
NACKIE: u1 = 0,
/// STOPIE [5:5]
/// STOP detection Interrupt enable
STOPIE: u1 = 0,
/// TCIE [6:6]
/// Transfer Complete interrupt enable
TCIE: u1 = 0,
/// ERRIE [7:7]
/// Error interrupts enable
ERRIE: u1 = 0,
/// DNF [8:11]
/// Digital noise filter
DNF: u4 = 0,
/// ANFOFF [12:12]
/// Analog noise filter OFF
ANFOFF: u1 = 0,
/// SWRST [13:13]
/// Software reset
SWRST: u1 = 0,
/// TXDMAEN [14:14]
/// DMA transmission requests enable
TXDMAEN: u1 = 0,
/// RXDMAEN [15:15]
/// DMA reception requests enable
RXDMAEN: u1 = 0,
/// SBC [16:16]
/// Slave byte control
SBC: u1 = 0,
/// NOSTRETCH [17:17]
/// Clock stretching disable
NOSTRETCH: u1 = 0,
/// WUPEN [18:18]
/// Wakeup from STOP enable
WUPEN: u1 = 0,
/// GCEN [19:19]
/// General call enable
GCEN: u1 = 0,
/// SMBHEN [20:20]
/// SMBus Host address enable
SMBHEN: u1 = 0,
/// SMBDEN [21:21]
/// SMBus Device Default address enable
SMBDEN: u1 = 0,
/// ALERTEN [22:22]
/// SMBUS alert enable
ALERTEN: u1 = 0,
/// PECEN [23:23]
/// PEC enable
PECEN: u1 = 0,
/// unused [24:31]
_unused24: u8 = 0,
};
/// Control register 1
pub const CR1 = Register(CR1_val).init(base_address + 0x0);
/// CR2
const CR2_val = packed struct {
/// SADD0 [0:0]
/// Slave address bit 0 (master mode)
SADD0: u1 = 0,
/// SADD1 [1:7]
/// Slave address bit 7:1 (master mode)
SADD1: u7 = 0,
/// SADD8 [8:9]
/// Slave address bit 9:8 (master mode)
SADD8: u2 = 0,
/// RD_WRN [10:10]
/// Transfer direction (master mode)
RD_WRN: u1 = 0,
/// ADD10 [11:11]
/// 10-bit addressing mode (master mode)
ADD10: u1 = 0,
/// HEAD10R [12:12]
/// 10-bit address header only read direction (master receiver mode)
HEAD10R: u1 = 0,
/// START [13:13]
/// Start generation
START: u1 = 0,
/// STOP [14:14]
/// Stop generation (master mode)
STOP: u1 = 0,
/// NACK [15:15]
/// NACK generation (slave mode)
NACK: u1 = 0,
/// NBYTES [16:23]
/// Number of bytes
NBYTES: u8 = 0,
/// RELOAD [24:24]
/// NBYTES reload mode
RELOAD: u1 = 0,
/// AUTOEND [25:25]
/// Automatic end mode (master mode)
AUTOEND: u1 = 0,
/// PECBYTE [26:26]
/// Packet error checking byte
PECBYTE: u1 = 0,
/// unused [27:31]
_unused27: u5 = 0,
};
/// Control register 2
pub const CR2 = Register(CR2_val).init(base_address + 0x4);
/// OAR1
const OAR1_val = packed struct {
/// OA1_0 [0:0]
/// Interface address
OA1_0: u1 = 0,
/// OA1_1 [1:7]
/// Interface address
OA1_1: u7 = 0,
/// OA1_8 [8:9]
/// Interface address
OA1_8: u2 = 0,
/// OA1MODE [10:10]
/// Own Address 1 10-bit mode
OA1MODE: u1 = 0,
/// unused [11:14]
_unused11: u4 = 0,
/// OA1EN [15:15]
/// Own Address 1 enable
OA1EN: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Own address register 1
pub const OAR1 = Register(OAR1_val).init(base_address + 0x8);
/// OAR2
const OAR2_val = packed struct {
/// unused [0:0]
_unused0: u1 = 0,
/// OA2 [1:7]
/// Interface address
OA2: u7 = 0,
/// OA2MSK [8:10]
/// Own Address 2 masks
OA2MSK: u3 = 0,
/// unused [11:14]
_unused11: u4 = 0,
/// OA2EN [15:15]
/// Own Address 2 enable
OA2EN: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Own address register 2
pub const OAR2 = Register(OAR2_val).init(base_address + 0xc);
/// TIMINGR
const TIMINGR_val = packed struct {
/// SCLL [0:7]
/// SCL low period (master mode)
SCLL: u8 = 0,
/// SCLH [8:15]
/// SCL high period (master mode)
SCLH: u8 = 0,
/// SDADEL [16:19]
/// Data hold time
SDADEL: u4 = 0,
/// SCLDEL [20:23]
/// Data setup time
SCLDEL: u4 = 0,
/// unused [24:27]
_unused24: u4 = 0,
/// PRESC [28:31]
/// Timing prescaler
PRESC: u4 = 0,
};
/// Timing register
pub const TIMINGR = Register(TIMINGR_val).init(base_address + 0x10);
/// TIMEOUTR
const TIMEOUTR_val = packed struct {
/// TIMEOUTA [0:11]
/// Bus timeout A
TIMEOUTA: u12 = 0,
/// TIDLE [12:12]
/// Idle clock timeout detection
TIDLE: u1 = 0,
/// unused [13:14]
_unused13: u2 = 0,
/// TIMOUTEN [15:15]
/// Clock timeout enable
TIMOUTEN: u1 = 0,
/// TIMEOUTB [16:27]
/// Bus timeout B
TIMEOUTB: u12 = 0,
/// unused [28:30]
_unused28: u3 = 0,
/// TEXTEN [31:31]
/// Extended clock timeout enable
TEXTEN: u1 = 0,
};
/// Status register 1
pub const TIMEOUTR = Register(TIMEOUTR_val).init(base_address + 0x14);
/// ISR
const ISR_val = packed struct {
/// TXE [0:0]
/// Transmit data register empty (transmitters)
TXE: u1 = 1,
/// TXIS [1:1]
/// Transmit interrupt status (transmitters)
TXIS: u1 = 0,
/// RXNE [2:2]
/// Receive data register not empty (receivers)
RXNE: u1 = 0,
/// ADDR [3:3]
/// Address matched (slave mode)
ADDR: u1 = 0,
/// NACKF [4:4]
/// Not acknowledge received flag
NACKF: u1 = 0,
/// STOPF [5:5]
/// Stop detection flag
STOPF: u1 = 0,
/// TC [6:6]
/// Transfer Complete (master mode)
TC: u1 = 0,
/// TCR [7:7]
/// Transfer Complete Reload
TCR: u1 = 0,
/// BERR [8:8]
/// Bus error
BERR: u1 = 0,
/// ARLO [9:9]
/// Arbitration lost
ARLO: u1 = 0,
/// OVR [10:10]
/// Overrun/Underrun (slave mode)
OVR: u1 = 0,
/// PECERR [11:11]
/// PEC Error in reception
PECERR: u1 = 0,
/// TIMEOUT [12:12]
/// Timeout or t_low detection flag
TIMEOUT: u1 = 0,
/// ALERT [13:13]
/// SMBus alert
ALERT: u1 = 0,
/// unused [14:14]
_unused14: u1 = 0,
/// BUSY [15:15]
/// Bus busy
BUSY: u1 = 0,
/// DIR [16:16]
/// Transfer direction (Slave mode)
DIR: u1 = 0,
/// ADDCODE [17:23]
/// Address match code (Slave mode)
ADDCODE: u7 = 0,
/// unused [24:31]
_unused24: u8 = 0,
};
/// Interrupt and Status register
pub const ISR = Register(ISR_val).init(base_address + 0x18);
/// ICR
const ICR_val = packed struct {
/// unused [0:2]
_unused0: u3 = 0,
/// ADDRCF [3:3]
/// Address Matched flag clear
ADDRCF: u1 = 0,
/// NACKCF [4:4]
/// Not Acknowledge flag clear
NACKCF: u1 = 0,
/// STOPCF [5:5]
/// Stop detection flag clear
STOPCF: u1 = 0,
/// unused [6:7]
_unused6: u2 = 0,
/// BERRCF [8:8]
/// Bus error flag clear
BERRCF: u1 = 0,
/// ARLOCF [9:9]
/// Arbitration lost flag clear
ARLOCF: u1 = 0,
/// OVRCF [10:10]
/// Overrun/Underrun flag clear
OVRCF: u1 = 0,
/// PECCF [11:11]
/// PEC Error flag clear
PECCF: u1 = 0,
/// TIMOUTCF [12:12]
/// Timeout detection flag clear
TIMOUTCF: u1 = 0,
/// ALERTCF [13:13]
/// Alert flag clear
ALERTCF: u1 = 0,
/// unused [14:31]
_unused14: u2 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Interrupt clear register
pub const ICR = Register(ICR_val).init(base_address + 0x1c);
/// PECR
const PECR_val = packed struct {
/// PEC [0:7]
/// Packet error checking register
PEC: u8 = 0,
/// unused [8:31]
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// PEC register
pub const PECR = Register(PECR_val).init(base_address + 0x20);
/// RXDR
const RXDR_val = packed struct {
/// RXDATA [0:7]
/// 8-bit receive data
RXDATA: u8 = 0,
/// unused [8:31]
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Receive data register
pub const RXDR = Register(RXDR_val).init(base_address + 0x24);
/// TXDR
const TXDR_val = packed struct {
/// TXDATA [0:7]
/// 8-bit transmit data
TXDATA: u8 = 0,
/// unused [8:31]
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Transmit data register
pub const TXDR = Register(TXDR_val).init(base_address + 0x28);
};
/// Independent watchdog
pub const IWDG = struct {
const base_address = 0x40003000;
/// KR
const KR_val = packed struct {
/// KEY [0:15]
/// Key value
KEY: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Key register
pub const KR = Register(KR_val).init(base_address + 0x0);
/// PR
const PR_val = packed struct {
/// PR [0:2]
/// Prescaler divider
PR: u3 = 0,
/// unused [3:31]
_unused3: u5 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Prescaler register
pub const PR = Register(PR_val).init(base_address + 0x4);
/// RLR
const RLR_val = packed struct {
/// RL [0:11]
/// Watchdog counter reload value
RL: u12 = 4095,
/// unused [12:31]
_unused12: u4 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Reload register
pub const RLR = Register(RLR_val).init(base_address + 0x8);
/// SR
const SR_val = packed struct {
/// PVU [0:0]
/// Watchdog prescaler value update
PVU: u1 = 0,
/// RVU [1:1]
/// Watchdog counter reload value update
RVU: u1 = 0,
/// WVU [2:2]
/// Watchdog counter window value update
WVU: u1 = 0,
/// unused [3:31]
_unused3: u5 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Status register
pub const SR = Register(SR_val).init(base_address + 0xc);
/// WINR
const WINR_val = packed struct {
/// WIN [0:11]
/// Watchdog counter window value
WIN: u12 = 4095,
/// unused [12:31]
_unused12: u4 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Window register
pub const WINR = Register(WINR_val).init(base_address + 0x10);
};
/// Window watchdog
pub const WWDG = struct {
const base_address = 0x40002c00;
/// CR
const CR_val = packed struct {
/// T [0:6]
/// 7-bit counter
T: u7 = 127,
/// WDGA [7:7]
/// Activation bit
WDGA: u1 = 0,
/// unused [8:31]
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Control register
pub const CR = Register(CR_val).init(base_address + 0x0);
/// CFR
const CFR_val = packed struct {
/// W [0:6]
/// 7-bit window value
W: u7 = 127,
/// WDGTB [7:8]
/// Timer base
WDGTB: u2 = 0,
/// EWI [9:9]
/// Early wakeup interrupt
EWI: u1 = 0,
/// unused [10:31]
_unused10: u6 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Configuration register
pub const CFR = Register(CFR_val).init(base_address + 0x4);
/// SR
const SR_val = packed struct {
/// EWIF [0:0]
/// Early wakeup interrupt flag
EWIF: u1 = 0,
/// unused [1:31]
_unused1: u7 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Status register
pub const SR = Register(SR_val).init(base_address + 0x8);
};
/// Real-time clock
pub const RTC = struct {
const base_address = 0x40002800;
/// TR
const TR_val = packed struct {
/// SU [0:3]
/// Second units in BCD format
SU: u4 = 0,
/// ST [4:6]
/// Second tens in BCD format
ST: u3 = 0,
/// unused [7:7]
_unused7: u1 = 0,
/// MNU [8:11]
/// Minute units in BCD format
MNU: u4 = 0,
/// MNT [12:14]
/// Minute tens in BCD format
MNT: u3 = 0,
/// unused [15:15]
_unused15: u1 = 0,
/// HU [16:19]
/// Hour units in BCD format
HU: u4 = 0,
/// HT [20:21]
/// Hour tens in BCD format
HT: u2 = 0,
/// PM [22:22]
/// AM/PM notation
PM: u1 = 0,
/// unused [23:31]
_unused23: u1 = 0,
_unused24: u8 = 0,
};
/// time register
pub const TR = Register(TR_val).init(base_address + 0x0);
/// DR
const DR_val = packed struct {
/// DU [0:3]
/// Date units in BCD format
DU: u4 = 1,
/// DT [4:5]
/// Date tens in BCD format
DT: u2 = 0,
/// unused [6:7]
_unused6: u2 = 0,
/// MU [8:11]
/// Month units in BCD format
MU: u4 = 1,
/// MT [12:12]
/// Month tens in BCD format
MT: u1 = 0,
/// WDU [13:15]
/// Week day units
WDU: u3 = 1,
/// YU [16:19]
/// Year units in BCD format
YU: u4 = 0,
/// YT [20:23]
/// Year tens in BCD format
YT: u4 = 0,
/// unused [24:31]
_unused24: u8 = 0,
};
/// date register
pub const DR = Register(DR_val).init(base_address + 0x4);
/// CR
const CR_val = packed struct {
/// WCKSEL [0:2]
/// Wakeup clock selection
WCKSEL: u3 = 0,
/// TSEDGE [3:3]
/// Time-stamp event active edge
TSEDGE: u1 = 0,
/// REFCKON [4:4]
/// Reference clock detection enable (50 or 60 Hz)
REFCKON: u1 = 0,
/// BYPSHAD [5:5]
/// Bypass the shadow registers
BYPSHAD: u1 = 0,
/// FMT [6:6]
/// Hour format
FMT: u1 = 0,
/// unused [7:7]
_unused7: u1 = 0,
/// ALRAE [8:8]
/// Alarm A enable
ALRAE: u1 = 0,
/// ALRBE [9:9]
/// Alarm B enable
ALRBE: u1 = 0,
/// WUTE [10:10]
/// Wakeup timer enable
WUTE: u1 = 0,
/// TSE [11:11]
/// Time stamp enable
TSE: u1 = 0,
/// ALRAIE [12:12]
/// Alarm A interrupt enable
ALRAIE: u1 = 0,
/// ALRBIE [13:13]
/// Alarm B interrupt enable
ALRBIE: u1 = 0,
/// WUTIE [14:14]
/// Wakeup timer interrupt enable
WUTIE: u1 = 0,
/// TSIE [15:15]
/// Time-stamp interrupt enable
TSIE: u1 = 0,
/// ADD1H [16:16]
/// Add 1 hour (summer time change)
ADD1H: u1 = 0,
/// SUB1H [17:17]
/// Subtract 1 hour (winter time change)
SUB1H: u1 = 0,
/// BKP [18:18]
/// Backup
BKP: u1 = 0,
/// COSEL [19:19]
/// Calibration output selection
COSEL: u1 = 0,
/// POL [20:20]
/// Output polarity
POL: u1 = 0,
/// OSEL [21:22]
/// Output selection
OSEL: u2 = 0,
/// COE [23:23]
/// Calibration output enable
COE: u1 = 0,
/// unused [24:31]
_unused24: u8 = 0,
};
/// control register
pub const CR = Register(CR_val).init(base_address + 0x8);
/// ISR
const ISR_val = packed struct {
/// ALRAWF [0:0]
/// Alarm A write flag
ALRAWF: u1 = 1,
/// ALRBWF [1:1]
/// Alarm B write flag
ALRBWF: u1 = 1,
/// WUTWF [2:2]
/// Wakeup timer write flag
WUTWF: u1 = 1,
/// SHPF [3:3]
/// Shift operation pending
SHPF: u1 = 0,
/// INITS [4:4]
/// Initialization status flag
INITS: u1 = 0,
/// RSF [5:5]
/// Registers synchronization flag
RSF: u1 = 0,
/// INITF [6:6]
/// Initialization flag
INITF: u1 = 0,
/// INIT [7:7]
/// Initialization mode
INIT: u1 = 0,
/// ALRAF [8:8]
/// Alarm A flag
ALRAF: u1 = 0,
/// ALRBF [9:9]
/// Alarm B flag
ALRBF: u1 = 0,
/// WUTF [10:10]
/// Wakeup timer flag
WUTF: u1 = 0,
/// TSF [11:11]
/// Time-stamp flag
TSF: u1 = 0,
/// TSOVF [12:12]
/// Time-stamp overflow flag
TSOVF: u1 = 0,
/// TAMP1F [13:13]
/// Tamper detection flag
TAMP1F: u1 = 0,
/// TAMP2F [14:14]
/// RTC_TAMP2 detection flag
TAMP2F: u1 = 0,
/// TAMP3F [15:15]
/// RTC_TAMP3 detection flag
TAMP3F: u1 = 0,
/// RECALPF [16:16]
/// Recalibration pending Flag
RECALPF: u1 = 0,
/// unused [17:31]
_unused17: u7 = 0,
_unused24: u8 = 0,
};
/// initialization and status register
pub const ISR = Register(ISR_val).init(base_address + 0xc);
/// PRER
const PRER_val = packed struct {
/// PREDIV_S [0:14]
/// Synchronous prescaler factor
PREDIV_S: u15 = 255,
/// unused [15:15]
_unused15: u1 = 0,
/// PREDIV_A [16:22]
/// Asynchronous prescaler factor
PREDIV_A: u7 = 127,
/// unused [23:31]
_unused23: u1 = 0,
_unused24: u8 = 0,
};
/// prescaler register
pub const PRER = Register(PRER_val).init(base_address + 0x10);
/// WUTR
const WUTR_val = packed struct {
/// WUT [0:15]
/// Wakeup auto-reload value bits
WUT: u16 = 65535,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// wakeup timer register
pub const WUTR = Register(WUTR_val).init(base_address + 0x14);
/// ALRMAR
const ALRMAR_val = packed struct {
/// SU [0:3]
/// Second units in BCD format
SU: u4 = 0,
/// ST [4:6]
/// Second tens in BCD format
ST: u3 = 0,
/// MSK1 [7:7]
/// Alarm A seconds mask
MSK1: u1 = 0,
/// MNU [8:11]
/// Minute units in BCD format
MNU: u4 = 0,
/// MNT [12:14]
/// Minute tens in BCD format
MNT: u3 = 0,
/// MSK2 [15:15]
/// Alarm A minutes mask
MSK2: u1 = 0,
/// HU [16:19]
/// Hour units in BCD format
HU: u4 = 0,
/// HT [20:21]
/// Hour tens in BCD format
HT: u2 = 0,
/// PM [22:22]
/// AM/PM notation
PM: u1 = 0,
/// MSK3 [23:23]
/// Alarm A hours mask
MSK3: u1 = 0,
/// DU [24:27]
/// Date units or day in BCD format
DU: u4 = 0,
/// DT [28:29]
/// Date tens in BCD format
DT: u2 = 0,
/// WDSEL [30:30]
/// Week day selection
WDSEL: u1 = 0,
/// MSK4 [31:31]
/// Alarm A date mask
MSK4: u1 = 0,
};
/// alarm A register
pub const ALRMAR = Register(ALRMAR_val).init(base_address + 0x1c);
/// ALRMBR
const ALRMBR_val = packed struct {
/// SU [0:3]
/// Second units in BCD format
SU: u4 = 0,
/// ST [4:6]
/// Second tens in BCD format
ST: u3 = 0,
/// MSK1 [7:7]
/// Alarm B seconds mask
MSK1: u1 = 0,
/// MNU [8:11]
/// Minute units in BCD format
MNU: u4 = 0,
/// MNT [12:14]
/// Minute tens in BCD format
MNT: u3 = 0,
/// MSK2 [15:15]
/// Alarm B minutes mask
MSK2: u1 = 0,
/// HU [16:19]
/// Hour units in BCD format
HU: u4 = 0,
/// HT [20:21]
/// Hour tens in BCD format
HT: u2 = 0,
/// PM [22:22]
/// AM/PM notation
PM: u1 = 0,
/// MSK3 [23:23]
/// Alarm B hours mask
MSK3: u1 = 0,
/// DU [24:27]
/// Date units or day in BCD format
DU: u4 = 0,
/// DT [28:29]
/// Date tens in BCD format
DT: u2 = 0,
/// WDSEL [30:30]
/// Week day selection
WDSEL: u1 = 0,
/// MSK4 [31:31]
/// Alarm B date mask
MSK4: u1 = 0,
};
/// alarm B register
pub const ALRMBR = Register(ALRMBR_val).init(base_address + 0x20);
/// WPR
const WPR_val = packed struct {
/// KEY [0:7]
/// Write protection key
KEY: u8 = 0,
/// unused [8:31]
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// write protection register
pub const WPR = Register(WPR_val).init(base_address + 0x24);
/// SSR
const SSR_val = packed struct {
/// SS [0:15]
/// Sub second value
SS: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// sub second register
pub const SSR = Register(SSR_val).init(base_address + 0x28);
/// SHIFTR
const SHIFTR_val = packed struct {
/// SUBFS [0:14]
/// Subtract a fraction of a second
SUBFS: u15 = 0,
/// unused [15:30]
_unused15: u1 = 0,
_unused16: u8 = 0,
_unused24: u7 = 0,
/// ADD1S [31:31]
/// Add one second
ADD1S: u1 = 0,
};
/// shift control register
pub const SHIFTR = Register(SHIFTR_val).init(base_address + 0x2c);
/// TSTR
const TSTR_val = packed struct {
/// SU [0:3]
/// Second units in BCD format
SU: u4 = 0,
/// ST [4:6]
/// Second tens in BCD format
ST: u3 = 0,
/// unused [7:7]
_unused7: u1 = 0,
/// MNU [8:11]
/// Minute units in BCD format
MNU: u4 = 0,
/// MNT [12:14]
/// Minute tens in BCD format
MNT: u3 = 0,
/// unused [15:15]
_unused15: u1 = 0,
/// HU [16:19]
/// Hour units in BCD format
HU: u4 = 0,
/// HT [20:21]
/// Hour tens in BCD format
HT: u2 = 0,
/// PM [22:22]
/// AM/PM notation
PM: u1 = 0,
/// unused [23:31]
_unused23: u1 = 0,
_unused24: u8 = 0,
};
/// time stamp time register
pub const TSTR = Register(TSTR_val).init(base_address + 0x30);
/// TSDR
const TSDR_val = packed struct {
/// DU [0:3]
/// Date units in BCD format
DU: u4 = 0,
/// DT [4:5]
/// Date tens in BCD format
DT: u2 = 0,
/// unused [6:7]
_unused6: u2 = 0,
/// MU [8:11]
/// Month units in BCD format
MU: u4 = 0,
/// MT [12:12]
/// Month tens in BCD format
MT: u1 = 0,
/// WDU [13:15]
/// Week day units
WDU: u3 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// time stamp date register
pub const TSDR = Register(TSDR_val).init(base_address + 0x34);
/// TSSSR
const TSSSR_val = packed struct {
/// SS [0:15]
/// Sub second value
SS: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// timestamp sub second register
pub const TSSSR = Register(TSSSR_val).init(base_address + 0x38);
/// CALR
const CALR_val = packed struct {
/// CALM [0:8]
/// Calibration minus
CALM: u9 = 0,
/// unused [9:12]
_unused9: u4 = 0,
/// CALW16 [13:13]
/// Use a 16-second calibration cycle period
CALW16: u1 = 0,
/// CALW8 [14:14]
/// Use an 8-second calibration cycle period
CALW8: u1 = 0,
/// CALP [15:15]
/// Increase frequency of RTC by 488.5 ppm
CALP: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// calibration register
pub const CALR = Register(CALR_val).init(base_address + 0x3c);
/// TAFCR
const TAFCR_val = packed struct {
/// TAMP1E [0:0]
/// Tamper 1 detection enable
TAMP1E: u1 = 0,
/// TAMP1TRG [1:1]
/// Active level for tamper 1
TAMP1TRG: u1 = 0,
/// TAMPIE [2:2]
/// Tamper interrupt enable
TAMPIE: u1 = 0,
/// TAMP2E [3:3]
/// Tamper 2 detection enable
TAMP2E: u1 = 0,
/// TAMP2TRG [4:4]
/// Active level for tamper 2
TAMP2TRG: u1 = 0,
/// TAMP3E [5:5]
/// Tamper 3 detection enable
TAMP3E: u1 = 0,
/// TAMP3TRG [6:6]
/// Active level for tamper 3
TAMP3TRG: u1 = 0,
/// TAMPTS [7:7]
/// Activate timestamp on tamper detection event
TAMPTS: u1 = 0,
/// TAMPFREQ [8:10]
/// Tamper sampling frequency
TAMPFREQ: u3 = 0,
/// TAMPFLT [11:12]
/// Tamper filter count
TAMPFLT: u2 = 0,
/// TAMPPRCH [13:14]
/// Tamper precharge duration
TAMPPRCH: u2 = 0,
/// TAMPPUDIS [15:15]
/// TAMPER pull-up disable
TAMPPUDIS: u1 = 0,
/// unused [16:17]
_unused16: u2 = 0,
/// PC13VALUE [18:18]
/// PC13 value
PC13VALUE: u1 = 0,
/// PC13MODE [19:19]
/// PC13 mode
PC13MODE: u1 = 0,
/// PC14VALUE [20:20]
/// PC14 value
PC14VALUE: u1 = 0,
/// PC14MODE [21:21]
/// PC 14 mode
PC14MODE: u1 = 0,
/// PC15VALUE [22:22]
/// PC15 value
PC15VALUE: u1 = 0,
/// PC15MODE [23:23]
/// PC15 mode
PC15MODE: u1 = 0,
/// unused [24:31]
_unused24: u8 = 0,
};
/// tamper and alternate function configuration register
pub const TAFCR = Register(TAFCR_val).init(base_address + 0x40);
/// ALRMASSR
const ALRMASSR_val = packed struct {
/// SS [0:14]
/// Sub seconds value
SS: u15 = 0,
/// unused [15:23]
_unused15: u1 = 0,
_unused16: u8 = 0,
/// MASKSS [24:27]
/// Mask the most-significant bits starting at this bit
MASKSS: u4 = 0,
/// unused [28:31]
_unused28: u4 = 0,
};
/// alarm A sub second register
pub const ALRMASSR = Register(ALRMASSR_val).init(base_address + 0x44);
/// ALRMBSSR
const ALRMBSSR_val = packed struct {
/// SS [0:14]
/// Sub seconds value
SS: u15 = 0,
/// unused [15:23]
_unused15: u1 = 0,
_unused16: u8 = 0,
/// MASKSS [24:27]
/// Mask the most-significant bits starting at this bit
MASKSS: u4 = 0,
/// unused [28:31]
_unused28: u4 = 0,
};
/// alarm B sub second register
pub const ALRMBSSR = Register(ALRMBSSR_val).init(base_address + 0x48);
/// BKP0R
const BKP0R_val = packed struct {
/// BKP [0:31]
/// BKP
BKP: u32 = 0,
};
/// backup register
pub const BKP0R = Register(BKP0R_val).init(base_address + 0x50);
/// BKP1R
const BKP1R_val = packed struct {
/// BKP [0:31]
/// BKP
BKP: u32 = 0,
};
/// backup register
pub const BKP1R = Register(BKP1R_val).init(base_address + 0x54);
/// BKP2R
const BKP2R_val = packed struct {
/// BKP [0:31]
/// BKP
BKP: u32 = 0,
};
/// backup register
pub const BKP2R = Register(BKP2R_val).init(base_address + 0x58);
/// BKP3R
const BKP3R_val = packed struct {
/// BKP [0:31]
/// BKP
BKP: u32 = 0,
};
/// backup register
pub const BKP3R = Register(BKP3R_val).init(base_address + 0x5c);
/// BKP4R
const BKP4R_val = packed struct {
/// BKP [0:31]
/// BKP
BKP: u32 = 0,
};
/// backup register
pub const BKP4R = Register(BKP4R_val).init(base_address + 0x60);
/// BKP5R
const BKP5R_val = packed struct {
/// BKP [0:31]
/// BKP
BKP: u32 = 0,
};
/// backup register
pub const BKP5R = Register(BKP5R_val).init(base_address + 0x64);
/// BKP6R
const BKP6R_val = packed struct {
/// BKP [0:31]
/// BKP
BKP: u32 = 0,
};
/// backup register
pub const BKP6R = Register(BKP6R_val).init(base_address + 0x68);
/// BKP7R
const BKP7R_val = packed struct {
/// BKP [0:31]
/// BKP
BKP: u32 = 0,
};
/// backup register
pub const BKP7R = Register(BKP7R_val).init(base_address + 0x6c);
/// BKP8R
const BKP8R_val = packed struct {
/// BKP [0:31]
/// BKP
BKP: u32 = 0,
};
/// backup register
pub const BKP8R = Register(BKP8R_val).init(base_address + 0x70);
/// BKP9R
const BKP9R_val = packed struct {
/// BKP [0:31]
/// BKP
BKP: u32 = 0,
};
/// backup register
pub const BKP9R = Register(BKP9R_val).init(base_address + 0x74);
/// BKP10R
const BKP10R_val = packed struct {
/// BKP [0:31]
/// BKP
BKP: u32 = 0,
};
/// backup register
pub const BKP10R = Register(BKP10R_val).init(base_address + 0x78);
/// BKP11R
const BKP11R_val = packed struct {
/// BKP [0:31]
/// BKP
BKP: u32 = 0,
};
/// backup register
pub const BKP11R = Register(BKP11R_val).init(base_address + 0x7c);
/// BKP12R
const BKP12R_val = packed struct {
/// BKP [0:31]
/// BKP
BKP: u32 = 0,
};
/// backup register
pub const BKP12R = Register(BKP12R_val).init(base_address + 0x80);
/// BKP13R
const BKP13R_val = packed struct {
/// BKP [0:31]
/// BKP
BKP: u32 = 0,
};
/// backup register
pub const BKP13R = Register(BKP13R_val).init(base_address + 0x84);
/// BKP14R
const BKP14R_val = packed struct {
/// BKP [0:31]
/// BKP
BKP: u32 = 0,
};
/// backup register
pub const BKP14R = Register(BKP14R_val).init(base_address + 0x88);
/// BKP15R
const BKP15R_val = packed struct {
/// BKP [0:31]
/// BKP
BKP: u32 = 0,
};
/// backup register
pub const BKP15R = Register(BKP15R_val).init(base_address + 0x8c);
/// BKP16R
const BKP16R_val = packed struct {
/// BKP [0:31]
/// BKP
BKP: u32 = 0,
};
/// backup register
pub const BKP16R = Register(BKP16R_val).init(base_address + 0x90);
/// BKP17R
const BKP17R_val = packed struct {
/// BKP [0:31]
/// BKP
BKP: u32 = 0,
};
/// backup register
pub const BKP17R = Register(BKP17R_val).init(base_address + 0x94);
/// BKP18R
const BKP18R_val = packed struct {
/// BKP [0:31]
/// BKP
BKP: u32 = 0,
};
/// backup register
pub const BKP18R = Register(BKP18R_val).init(base_address + 0x98);
/// BKP19R
const BKP19R_val = packed struct {
/// BKP [0:31]
/// BKP
BKP: u32 = 0,
};
/// backup register
pub const BKP19R = Register(BKP19R_val).init(base_address + 0x9c);
/// BKP20R
const BKP20R_val = packed struct {
/// BKP [0:31]
/// BKP
BKP: u32 = 0,
};
/// backup register
pub const BKP20R = Register(BKP20R_val).init(base_address + 0xa0);
/// BKP21R
const BKP21R_val = packed struct {
/// BKP [0:31]
/// BKP
BKP: u32 = 0,
};
/// backup register
pub const BKP21R = Register(BKP21R_val).init(base_address + 0xa4);
/// BKP22R
const BKP22R_val = packed struct {
/// BKP [0:31]
/// BKP
BKP: u32 = 0,
};
/// backup register
pub const BKP22R = Register(BKP22R_val).init(base_address + 0xa8);
/// BKP23R
const BKP23R_val = packed struct {
/// BKP [0:31]
/// BKP
BKP: u32 = 0,
};
/// backup register
pub const BKP23R = Register(BKP23R_val).init(base_address + 0xac);
/// BKP24R
const BKP24R_val = packed struct {
/// BKP [0:31]
/// BKP
BKP: u32 = 0,
};
/// backup register
pub const BKP24R = Register(BKP24R_val).init(base_address + 0xb0);
/// BKP25R
const BKP25R_val = packed struct {
/// BKP [0:31]
/// BKP
BKP: u32 = 0,
};
/// backup register
pub const BKP25R = Register(BKP25R_val).init(base_address + 0xb4);
/// BKP26R
const BKP26R_val = packed struct {
/// BKP [0:31]
/// BKP
BKP: u32 = 0,
};
/// backup register
pub const BKP26R = Register(BKP26R_val).init(base_address + 0xb8);
/// BKP27R
const BKP27R_val = packed struct {
/// BKP [0:31]
/// BKP
BKP: u32 = 0,
};
/// backup register
pub const BKP27R = Register(BKP27R_val).init(base_address + 0xbc);
/// BKP28R
const BKP28R_val = packed struct {
/// BKP [0:31]
/// BKP
BKP: u32 = 0,
};
/// backup register
pub const BKP28R = Register(BKP28R_val).init(base_address + 0xc0);
/// BKP29R
const BKP29R_val = packed struct {
/// BKP [0:31]
/// BKP
BKP: u32 = 0,
};
/// backup register
pub const BKP29R = Register(BKP29R_val).init(base_address + 0xc4);
/// BKP30R
const BKP30R_val = packed struct {
/// BKP [0:31]
/// BKP
BKP: u32 = 0,
};
/// backup register
pub const BKP30R = Register(BKP30R_val).init(base_address + 0xc8);
/// BKP31R
const BKP31R_val = packed struct {
/// BKP [0:31]
/// BKP
BKP: u32 = 0,
};
/// backup register
pub const BKP31R = Register(BKP31R_val).init(base_address + 0xcc);
};
/// Basic timers
pub const TIM6 = struct {
const base_address = 0x40001000;
/// CR1
const CR1_val = packed struct {
/// CEN [0:0]
/// Counter enable
CEN: u1 = 0,
/// UDIS [1:1]
/// Update disable
UDIS: u1 = 0,
/// URS [2:2]
/// Update request source
URS: u1 = 0,
/// OPM [3:3]
/// One-pulse mode
OPM: u1 = 0,
/// unused [4:6]
_unused4: u3 = 0,
/// ARPE [7:7]
/// Auto-reload preload enable
ARPE: u1 = 0,
/// unused [8:10]
_unused8: u3 = 0,
/// UIFREMAP [11:11]
/// UIF status bit remapping
UIFREMAP: u1 = 0,
/// unused [12:31]
_unused12: u4 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// control register 1
pub const CR1 = Register(CR1_val).init(base_address + 0x0);
/// CR2
const CR2_val = packed struct {
/// unused [0:3]
_unused0: u4 = 0,
/// MMS [4:6]
/// Master mode selection
MMS: u3 = 0,
/// unused [7:31]
_unused7: u1 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// control register 2
pub const CR2 = Register(CR2_val).init(base_address + 0x4);
/// DIER
const DIER_val = packed struct {
/// UIE [0:0]
/// Update interrupt enable
UIE: u1 = 0,
/// unused [1:7]
_unused1: u7 = 0,
/// UDE [8:8]
/// Update DMA request enable
UDE: u1 = 0,
/// unused [9:31]
_unused9: u7 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA/Interrupt enable register
pub const DIER = Register(DIER_val).init(base_address + 0xc);
/// SR
const SR_val = packed struct {
/// UIF [0:0]
/// Update interrupt flag
UIF: u1 = 0,
/// unused [1:31]
_unused1: u7 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// status register
pub const SR = Register(SR_val).init(base_address + 0x10);
/// EGR
const EGR_val = packed struct {
/// UG [0:0]
/// Update generation
UG: u1 = 0,
/// unused [1:31]
_unused1: u7 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// event generation register
pub const EGR = Register(EGR_val).init(base_address + 0x14);
/// CNT
const CNT_val = packed struct {
/// CNT [0:15]
/// Low counter value
CNT: u16 = 0,
/// unused [16:30]
_unused16: u8 = 0,
_unused24: u7 = 0,
/// UIFCPY [31:31]
/// UIF Copy
UIFCPY: u1 = 0,
};
/// counter
pub const CNT = Register(CNT_val).init(base_address + 0x24);
/// PSC
const PSC_val = packed struct {
/// PSC [0:15]
/// Prescaler value
PSC: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// prescaler
pub const PSC = Register(PSC_val).init(base_address + 0x28);
/// ARR
const ARR_val = packed struct {
/// ARR [0:15]
/// Low Auto-reload value
ARR: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// auto-reload register
pub const ARR = Register(ARR_val).init(base_address + 0x2c);
};
/// Basic timers
pub const TIM7 = struct {
const base_address = 0x40001400;
/// CR1
const CR1_val = packed struct {
/// CEN [0:0]
/// Counter enable
CEN: u1 = 0,
/// UDIS [1:1]
/// Update disable
UDIS: u1 = 0,
/// URS [2:2]
/// Update request source
URS: u1 = 0,
/// OPM [3:3]
/// One-pulse mode
OPM: u1 = 0,
/// unused [4:6]
_unused4: u3 = 0,
/// ARPE [7:7]
/// Auto-reload preload enable
ARPE: u1 = 0,
/// unused [8:10]
_unused8: u3 = 0,
/// UIFREMAP [11:11]
/// UIF status bit remapping
UIFREMAP: u1 = 0,
/// unused [12:31]
_unused12: u4 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// control register 1
pub const CR1 = Register(CR1_val).init(base_address + 0x0);
/// CR2
const CR2_val = packed struct {
/// unused [0:3]
_unused0: u4 = 0,
/// MMS [4:6]
/// Master mode selection
MMS: u3 = 0,
/// unused [7:31]
_unused7: u1 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// control register 2
pub const CR2 = Register(CR2_val).init(base_address + 0x4);
/// DIER
const DIER_val = packed struct {
/// UIE [0:0]
/// Update interrupt enable
UIE: u1 = 0,
/// unused [1:7]
_unused1: u7 = 0,
/// UDE [8:8]
/// Update DMA request enable
UDE: u1 = 0,
/// unused [9:31]
_unused9: u7 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA/Interrupt enable register
pub const DIER = Register(DIER_val).init(base_address + 0xc);
/// SR
const SR_val = packed struct {
/// UIF [0:0]
/// Update interrupt flag
UIF: u1 = 0,
/// unused [1:31]
_unused1: u7 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// status register
pub const SR = Register(SR_val).init(base_address + 0x10);
/// EGR
const EGR_val = packed struct {
/// UG [0:0]
/// Update generation
UG: u1 = 0,
/// unused [1:31]
_unused1: u7 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// event generation register
pub const EGR = Register(EGR_val).init(base_address + 0x14);
/// CNT
const CNT_val = packed struct {
/// CNT [0:15]
/// Low counter value
CNT: u16 = 0,
/// unused [16:30]
_unused16: u8 = 0,
_unused24: u7 = 0,
/// UIFCPY [31:31]
/// UIF Copy
UIFCPY: u1 = 0,
};
/// counter
pub const CNT = Register(CNT_val).init(base_address + 0x24);
/// PSC
const PSC_val = packed struct {
/// PSC [0:15]
/// Prescaler value
PSC: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// prescaler
pub const PSC = Register(PSC_val).init(base_address + 0x28);
/// ARR
const ARR_val = packed struct {
/// ARR [0:15]
/// Low Auto-reload value
ARR: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// auto-reload register
pub const ARR = Register(ARR_val).init(base_address + 0x2c);
};
/// Digital-to-analog converter
pub const DAC = struct {
const base_address = 0x40007400;
/// CR
const CR_val = packed struct {
/// EN1 [0:0]
/// DAC channel1 enable
EN1: u1 = 0,
/// BOFF1 [1:1]
/// DAC channel1 output buffer disable
BOFF1: u1 = 0,
/// TEN1 [2:2]
/// DAC channel1 trigger enable
TEN1: u1 = 0,
/// TSEL1 [3:5]
/// DAC channel1 trigger selection
TSEL1: u3 = 0,
/// WAVE1 [6:7]
/// DAC channel1 noise/triangle wave generation enable
WAVE1: u2 = 0,
/// MAMP1 [8:11]
/// DAC channel1 mask/amplitude selector
MAMP1: u4 = 0,
/// DMAEN1 [12:12]
/// DAC channel1 DMA enable
DMAEN1: u1 = 0,
/// DMAUDRIE1 [13:13]
/// DAC channel1 DMA Underrun Interrupt enable
DMAUDRIE1: u1 = 0,
/// unused [14:15]
_unused14: u2 = 0,
/// EN2 [16:16]
/// DAC channel2 enable
EN2: u1 = 0,
/// BOFF2 [17:17]
/// DAC channel2 output buffer disable
BOFF2: u1 = 0,
/// TEN2 [18:18]
/// DAC channel2 trigger enable
TEN2: u1 = 0,
/// TSEL2 [19:21]
/// DAC channel2 trigger selection
TSEL2: u3 = 0,
/// WAVE2 [22:23]
/// DAC channel2 noise/triangle wave generation enable
WAVE2: u2 = 0,
/// MAMP2 [24:27]
/// DAC channel2 mask/amplitude selector
MAMP2: u4 = 0,
/// DMAEN2 [28:28]
/// DAC channel2 DMA enable
DMAEN2: u1 = 0,
/// DMAUDRIE2 [29:29]
/// DAC channel2 DMA underrun interrupt enable
DMAUDRIE2: u1 = 0,
/// unused [30:31]
_unused30: u2 = 0,
};
/// control register
pub const CR = Register(CR_val).init(base_address + 0x0);
/// SWTRIGR
const SWTRIGR_val = packed struct {
/// SWTRIG1 [0:0]
/// DAC channel1 software trigger
SWTRIG1: u1 = 0,
/// SWTRIG2 [1:1]
/// DAC channel2 software trigger
SWTRIG2: u1 = 0,
/// unused [2:31]
_unused2: u6 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// software trigger register
pub const SWTRIGR = Register(SWTRIGR_val).init(base_address + 0x4);
/// DHR12R1
const DHR12R1_val = packed struct {
/// DACC1DHR [0:11]
/// DAC channel1 12-bit right-aligned data
DACC1DHR: u12 = 0,
/// unused [12:31]
_unused12: u4 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// channel1 12-bit right-aligned data holding register
pub const DHR12R1 = Register(DHR12R1_val).init(base_address + 0x8);
/// DHR12L1
const DHR12L1_val = packed struct {
/// unused [0:3]
_unused0: u4 = 0,
/// DACC1DHR [4:15]
/// DAC channel1 12-bit left-aligned data
DACC1DHR: u12 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// channel1 12-bit left aligned data holding register
pub const DHR12L1 = Register(DHR12L1_val).init(base_address + 0xc);
/// DHR8R1
const DHR8R1_val = packed struct {
/// DACC1DHR [0:7]
/// DAC channel1 8-bit right-aligned data
DACC1DHR: u8 = 0,
/// unused [8:31]
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// channel1 8-bit right aligned data holding register
pub const DHR8R1 = Register(DHR8R1_val).init(base_address + 0x10);
/// DHR12R2
const DHR12R2_val = packed struct {
/// DACC2DHR [0:11]
/// DAC channel2 12-bit right-aligned data
DACC2DHR: u12 = 0,
/// unused [12:31]
_unused12: u4 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// channel2 12-bit right aligned data holding register
pub const DHR12R2 = Register(DHR12R2_val).init(base_address + 0x14);
/// DHR12L2
const DHR12L2_val = packed struct {
/// unused [0:3]
_unused0: u4 = 0,
/// DACC2DHR [4:15]
/// DAC channel2 12-bit left-aligned data
DACC2DHR: u12 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// channel2 12-bit left aligned data holding register
pub const DHR12L2 = Register(DHR12L2_val).init(base_address + 0x18);
/// DHR8R2
const DHR8R2_val = packed struct {
/// DACC2DHR [0:7]
/// DAC channel2 8-bit right-aligned data
DACC2DHR: u8 = 0,
/// unused [8:31]
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// channel2 8-bit right-aligned data holding register
pub const DHR8R2 = Register(DHR8R2_val).init(base_address + 0x1c);
/// DHR12RD
const DHR12RD_val = packed struct {
/// DACC1DHR [0:11]
/// DAC channel1 12-bit right-aligned data
DACC1DHR: u12 = 0,
/// unused [12:15]
_unused12: u4 = 0,
/// DACC2DHR [16:27]
/// DAC channel2 12-bit right-aligned data
DACC2DHR: u12 = 0,
/// unused [28:31]
_unused28: u4 = 0,
};
/// Dual DAC 12-bit right-aligned data holding register
pub const DHR12RD = Register(DHR12RD_val).init(base_address + 0x20);
/// DHR12LD
const DHR12LD_val = packed struct {
/// unused [0:3]
_unused0: u4 = 0,
/// DACC1DHR [4:15]
/// DAC channel1 12-bit left-aligned data
DACC1DHR: u12 = 0,
/// unused [16:19]
_unused16: u4 = 0,
/// DACC2DHR [20:31]
/// DAC channel2 12-bit left-aligned data
DACC2DHR: u12 = 0,
};
/// DUAL DAC 12-bit left aligned data holding register
pub const DHR12LD = Register(DHR12LD_val).init(base_address + 0x24);
/// DHR8RD
const DHR8RD_val = packed struct {
/// DACC1DHR [0:7]
/// DAC channel1 8-bit right-aligned data
DACC1DHR: u8 = 0,
/// DACC2DHR [8:15]
/// DAC channel2 8-bit right-aligned data
DACC2DHR: u8 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DUAL DAC 8-bit right aligned data holding register
pub const DHR8RD = Register(DHR8RD_val).init(base_address + 0x28);
/// DOR1
const DOR1_val = packed struct {
/// DACC1DOR [0:11]
/// DAC channel1 data output
DACC1DOR: u12 = 0,
/// unused [12:31]
_unused12: u4 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// channel1 data output register
pub const DOR1 = Register(DOR1_val).init(base_address + 0x2c);
/// DOR2
const DOR2_val = packed struct {
/// DACC2DOR [0:11]
/// DAC channel2 data output
DACC2DOR: u12 = 0,
/// unused [12:31]
_unused12: u4 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// channel2 data output register
pub const DOR2 = Register(DOR2_val).init(base_address + 0x30);
/// SR
const SR_val = packed struct {
/// unused [0:12]
_unused0: u8 = 0,
_unused8: u5 = 0,
/// DMAUDR1 [13:13]
/// DAC channel1 DMA underrun flag
DMAUDR1: u1 = 0,
/// unused [14:28]
_unused14: u2 = 0,
_unused16: u8 = 0,
_unused24: u5 = 0,
/// DMAUDR2 [29:29]
/// DAC channel2 DMA underrun flag
DMAUDR2: u1 = 0,
/// unused [30:31]
_unused30: u2 = 0,
};
/// status register
pub const SR = Register(SR_val).init(base_address + 0x34);
};
/// Nested Vectored Interrupt Controller
pub const NVIC = struct {
const base_address = 0xe000e000;
/// ICTR
const ICTR_val = packed struct {
/// INTLINESNUM [0:3]
/// Total number of interrupt lines in groups
INTLINESNUM: u4 = 0,
/// unused [4:31]
_unused4: u4 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Interrupt Controller Type Register
pub const ICTR = Register(ICTR_val).init(base_address + 0x4);
/// STIR
const STIR_val = packed struct {
/// INTID [0:8]
/// interrupt to be triggered
INTID: u9 = 0,
/// unused [9:31]
_unused9: u7 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Software Triggered Interrupt Register
pub const STIR = Register(STIR_val).init(base_address + 0xf00);
/// ISER0
const ISER0_val = packed struct {
/// SETENA [0:31]
/// SETENA
SETENA: u32 = 0,
};
/// Interrupt Set-Enable Register
pub const ISER0 = Register(ISER0_val).init(base_address + 0x100);
/// ISER1
const ISER1_val = packed struct {
/// SETENA [0:31]
/// SETENA
SETENA: u32 = 0,
};
/// Interrupt Set-Enable Register
pub const ISER1 = Register(ISER1_val).init(base_address + 0x104);
/// ISER2
const ISER2_val = packed struct {
/// SETENA [0:31]
/// SETENA
SETENA: u32 = 0,
};
/// Interrupt Set-Enable Register
pub const ISER2 = Register(ISER2_val).init(base_address + 0x108);
/// ICER0
const ICER0_val = packed struct {
/// CLRENA [0:31]
/// CLRENA
CLRENA: u32 = 0,
};
/// Interrupt Clear-Enable Register
pub const ICER0 = Register(ICER0_val).init(base_address + 0x180);
/// ICER1
const ICER1_val = packed struct {
/// CLRENA [0:31]
/// CLRENA
CLRENA: u32 = 0,
};
/// Interrupt Clear-Enable Register
pub const ICER1 = Register(ICER1_val).init(base_address + 0x184);
/// ICER2
const ICER2_val = packed struct {
/// CLRENA [0:31]
/// CLRENA
CLRENA: u32 = 0,
};
/// Interrupt Clear-Enable Register
pub const ICER2 = Register(ICER2_val).init(base_address + 0x188);
/// ISPR0
const ISPR0_val = packed struct {
/// SETPEND [0:31]
/// SETPEND
SETPEND: u32 = 0,
};
/// Interrupt Set-Pending Register
pub const ISPR0 = Register(ISPR0_val).init(base_address + 0x200);
/// ISPR1
const ISPR1_val = packed struct {
/// SETPEND [0:31]
/// SETPEND
SETPEND: u32 = 0,
};
/// Interrupt Set-Pending Register
pub const ISPR1 = Register(ISPR1_val).init(base_address + 0x204);
/// ISPR2
const ISPR2_val = packed struct {
/// SETPEND [0:31]
/// SETPEND
SETPEND: u32 = 0,
};
/// Interrupt Set-Pending Register
pub const ISPR2 = Register(ISPR2_val).init(base_address + 0x208);
/// ICPR0
const ICPR0_val = packed struct {
/// CLRPEND [0:31]
/// CLRPEND
CLRPEND: u32 = 0,
};
/// Interrupt Clear-Pending Register
pub const ICPR0 = Register(ICPR0_val).init(base_address + 0x280);
/// ICPR1
const ICPR1_val = packed struct {
/// CLRPEND [0:31]
/// CLRPEND
CLRPEND: u32 = 0,
};
/// Interrupt Clear-Pending Register
pub const ICPR1 = Register(ICPR1_val).init(base_address + 0x284);
/// ICPR2
const ICPR2_val = packed struct {
/// CLRPEND [0:31]
/// CLRPEND
CLRPEND: u32 = 0,
};
/// Interrupt Clear-Pending Register
pub const ICPR2 = Register(ICPR2_val).init(base_address + 0x288);
/// IABR0
const IABR0_val = packed struct {
/// ACTIVE [0:31]
/// ACTIVE
ACTIVE: u32 = 0,
};
/// Interrupt Active Bit Register
pub const IABR0 = Register(IABR0_val).init(base_address + 0x300);
/// IABR1
const IABR1_val = packed struct {
/// ACTIVE [0:31]
/// ACTIVE
ACTIVE: u32 = 0,
};
/// Interrupt Active Bit Register
pub const IABR1 = Register(IABR1_val).init(base_address + 0x304);
/// IABR2
const IABR2_val = packed struct {
/// ACTIVE [0:31]
/// ACTIVE
ACTIVE: u32 = 0,
};
/// Interrupt Active Bit Register
pub const IABR2 = Register(IABR2_val).init(base_address + 0x308);
/// IPR0
const IPR0_val = packed struct {
/// IPR_N0 [0:7]
/// IPR_N0
IPR_N0: u8 = 0,
/// IPR_N1 [8:15]
/// IPR_N1
IPR_N1: u8 = 0,
/// IPR_N2 [16:23]
/// IPR_N2
IPR_N2: u8 = 0,
/// IPR_N3 [24:31]
/// IPR_N3
IPR_N3: u8 = 0,
};
/// Interrupt Priority Register
pub const IPR0 = Register(IPR0_val).init(base_address + 0x400);
/// IPR1
const IPR1_val = packed struct {
/// IPR_N0 [0:7]
/// IPR_N0
IPR_N0: u8 = 0,
/// IPR_N1 [8:15]
/// IPR_N1
IPR_N1: u8 = 0,
/// IPR_N2 [16:23]
/// IPR_N2
IPR_N2: u8 = 0,
/// IPR_N3 [24:31]
/// IPR_N3
IPR_N3: u8 = 0,
};
/// Interrupt Priority Register
pub const IPR1 = Register(IPR1_val).init(base_address + 0x404);
/// IPR2
const IPR2_val = packed struct {
/// IPR_N0 [0:7]
/// IPR_N0
IPR_N0: u8 = 0,
/// IPR_N1 [8:15]
/// IPR_N1
IPR_N1: u8 = 0,
/// IPR_N2 [16:23]
/// IPR_N2
IPR_N2: u8 = 0,
/// IPR_N3 [24:31]
/// IPR_N3
IPR_N3: u8 = 0,
};
/// Interrupt Priority Register
pub const IPR2 = Register(IPR2_val).init(base_address + 0x408);
/// IPR3
const IPR3_val = packed struct {
/// IPR_N0 [0:7]
/// IPR_N0
IPR_N0: u8 = 0,
/// IPR_N1 [8:15]
/// IPR_N1
IPR_N1: u8 = 0,
/// IPR_N2 [16:23]
/// IPR_N2
IPR_N2: u8 = 0,
/// IPR_N3 [24:31]
/// IPR_N3
IPR_N3: u8 = 0,
};
/// Interrupt Priority Register
pub const IPR3 = Register(IPR3_val).init(base_address + 0x40c);
/// IPR4
const IPR4_val = packed struct {
/// IPR_N0 [0:7]
/// IPR_N0
IPR_N0: u8 = 0,
/// IPR_N1 [8:15]
/// IPR_N1
IPR_N1: u8 = 0,
/// IPR_N2 [16:23]
/// IPR_N2
IPR_N2: u8 = 0,
/// IPR_N3 [24:31]
/// IPR_N3
IPR_N3: u8 = 0,
};
/// Interrupt Priority Register
pub const IPR4 = Register(IPR4_val).init(base_address + 0x410);
/// IPR5
const IPR5_val = packed struct {
/// IPR_N0 [0:7]
/// IPR_N0
IPR_N0: u8 = 0,
/// IPR_N1 [8:15]
/// IPR_N1
IPR_N1: u8 = 0,
/// IPR_N2 [16:23]
/// IPR_N2
IPR_N2: u8 = 0,
/// IPR_N3 [24:31]
/// IPR_N3
IPR_N3: u8 = 0,
};
/// Interrupt Priority Register
pub const IPR5 = Register(IPR5_val).init(base_address + 0x414);
/// IPR6
const IPR6_val = packed struct {
/// IPR_N0 [0:7]
/// IPR_N0
IPR_N0: u8 = 0,
/// IPR_N1 [8:15]
/// IPR_N1
IPR_N1: u8 = 0,
/// IPR_N2 [16:23]
/// IPR_N2
IPR_N2: u8 = 0,
/// IPR_N3 [24:31]
/// IPR_N3
IPR_N3: u8 = 0,
};
/// Interrupt Priority Register
pub const IPR6 = Register(IPR6_val).init(base_address + 0x418);
/// IPR7
const IPR7_val = packed struct {
/// IPR_N0 [0:7]
/// IPR_N0
IPR_N0: u8 = 0,
/// IPR_N1 [8:15]
/// IPR_N1
IPR_N1: u8 = 0,
/// IPR_N2 [16:23]
/// IPR_N2
IPR_N2: u8 = 0,
/// IPR_N3 [24:31]
/// IPR_N3
IPR_N3: u8 = 0,
};
/// Interrupt Priority Register
pub const IPR7 = Register(IPR7_val).init(base_address + 0x41c);
/// IPR8
const IPR8_val = packed struct {
/// IPR_N0 [0:7]
/// IPR_N0
IPR_N0: u8 = 0,
/// IPR_N1 [8:15]
/// IPR_N1
IPR_N1: u8 = 0,
/// IPR_N2 [16:23]
/// IPR_N2
IPR_N2: u8 = 0,
/// IPR_N3 [24:31]
/// IPR_N3
IPR_N3: u8 = 0,
};
/// Interrupt Priority Register
pub const IPR8 = Register(IPR8_val).init(base_address + 0x420);
/// IPR9
const IPR9_val = packed struct {
/// IPR_N0 [0:7]
/// IPR_N0
IPR_N0: u8 = 0,
/// IPR_N1 [8:15]
/// IPR_N1
IPR_N1: u8 = 0,
/// IPR_N2 [16:23]
/// IPR_N2
IPR_N2: u8 = 0,
/// IPR_N3 [24:31]
/// IPR_N3
IPR_N3: u8 = 0,
};
/// Interrupt Priority Register
pub const IPR9 = Register(IPR9_val).init(base_address + 0x424);
/// IPR10
const IPR10_val = packed struct {
/// IPR_N0 [0:7]
/// IPR_N0
IPR_N0: u8 = 0,
/// IPR_N1 [8:15]
/// IPR_N1
IPR_N1: u8 = 0,
/// IPR_N2 [16:23]
/// IPR_N2
IPR_N2: u8 = 0,
/// IPR_N3 [24:31]
/// IPR_N3
IPR_N3: u8 = 0,
};
/// Interrupt Priority Register
pub const IPR10 = Register(IPR10_val).init(base_address + 0x428);
/// IPR11
const IPR11_val = packed struct {
/// IPR_N0 [0:7]
/// IPR_N0
IPR_N0: u8 = 0,
/// IPR_N1 [8:15]
/// IPR_N1
IPR_N1: u8 = 0,
/// IPR_N2 [16:23]
/// IPR_N2
IPR_N2: u8 = 0,
/// IPR_N3 [24:31]
/// IPR_N3
IPR_N3: u8 = 0,
};
/// Interrupt Priority Register
pub const IPR11 = Register(IPR11_val).init(base_address + 0x42c);
/// IPR12
const IPR12_val = packed struct {
/// IPR_N0 [0:7]
/// IPR_N0
IPR_N0: u8 = 0,
/// IPR_N1 [8:15]
/// IPR_N1
IPR_N1: u8 = 0,
/// IPR_N2 [16:23]
/// IPR_N2
IPR_N2: u8 = 0,
/// IPR_N3 [24:31]
/// IPR_N3
IPR_N3: u8 = 0,
};
/// Interrupt Priority Register
pub const IPR12 = Register(IPR12_val).init(base_address + 0x430);
/// IPR13
const IPR13_val = packed struct {
/// IPR_N0 [0:7]
/// IPR_N0
IPR_N0: u8 = 0,
/// IPR_N1 [8:15]
/// IPR_N1
IPR_N1: u8 = 0,
/// IPR_N2 [16:23]
/// IPR_N2
IPR_N2: u8 = 0,
/// IPR_N3 [24:31]
/// IPR_N3
IPR_N3: u8 = 0,
};
/// Interrupt Priority Register
pub const IPR13 = Register(IPR13_val).init(base_address + 0x434);
/// IPR14
const IPR14_val = packed struct {
/// IPR_N0 [0:7]
/// IPR_N0
IPR_N0: u8 = 0,
/// IPR_N1 [8:15]
/// IPR_N1
IPR_N1: u8 = 0,
/// IPR_N2 [16:23]
/// IPR_N2
IPR_N2: u8 = 0,
/// IPR_N3 [24:31]
/// IPR_N3
IPR_N3: u8 = 0,
};
/// Interrupt Priority Register
pub const IPR14 = Register(IPR14_val).init(base_address + 0x438);
/// IPR15
const IPR15_val = packed struct {
/// IPR_N0 [0:7]
/// IPR_N0
IPR_N0: u8 = 0,
/// IPR_N1 [8:15]
/// IPR_N1
IPR_N1: u8 = 0,
/// IPR_N2 [16:23]
/// IPR_N2
IPR_N2: u8 = 0,
/// IPR_N3 [24:31]
/// IPR_N3
IPR_N3: u8 = 0,
};
/// Interrupt Priority Register
pub const IPR15 = Register(IPR15_val).init(base_address + 0x43c);
/// IPR16
const IPR16_val = packed struct {
/// IPR_N0 [0:7]
/// IPR_N0
IPR_N0: u8 = 0,
/// IPR_N1 [8:15]
/// IPR_N1
IPR_N1: u8 = 0,
/// IPR_N2 [16:23]
/// IPR_N2
IPR_N2: u8 = 0,
/// IPR_N3 [24:31]
/// IPR_N3
IPR_N3: u8 = 0,
};
/// Interrupt Priority Register
pub const IPR16 = Register(IPR16_val).init(base_address + 0x440);
/// IPR17
const IPR17_val = packed struct {
/// IPR_N0 [0:7]
/// IPR_N0
IPR_N0: u8 = 0,
/// IPR_N1 [8:15]
/// IPR_N1
IPR_N1: u8 = 0,
/// IPR_N2 [16:23]
/// IPR_N2
IPR_N2: u8 = 0,
/// IPR_N3 [24:31]
/// IPR_N3
IPR_N3: u8 = 0,
};
/// Interrupt Priority Register
pub const IPR17 = Register(IPR17_val).init(base_address + 0x444);
/// IPR18
const IPR18_val = packed struct {
/// IPR_N0 [0:7]
/// IPR_N0
IPR_N0: u8 = 0,
/// IPR_N1 [8:15]
/// IPR_N1
IPR_N1: u8 = 0,
/// IPR_N2 [16:23]
/// IPR_N2
IPR_N2: u8 = 0,
/// IPR_N3 [24:31]
/// IPR_N3
IPR_N3: u8 = 0,
};
/// Interrupt Priority Register
pub const IPR18 = Register(IPR18_val).init(base_address + 0x448);
/// IPR19
const IPR19_val = packed struct {
/// IPR_N0 [0:7]
/// IPR_N0
IPR_N0: u8 = 0,
/// IPR_N1 [8:15]
/// IPR_N1
IPR_N1: u8 = 0,
/// IPR_N2 [16:23]
/// IPR_N2
IPR_N2: u8 = 0,
/// IPR_N3 [24:31]
/// IPR_N3
IPR_N3: u8 = 0,
};
/// Interrupt Priority Register
pub const IPR19 = Register(IPR19_val).init(base_address + 0x44c);
/// IPR20
const IPR20_val = packed struct {
/// IPR_N0 [0:7]
/// IPR_N0
IPR_N0: u8 = 0,
/// IPR_N1 [8:15]
/// IPR_N1
IPR_N1: u8 = 0,
/// IPR_N2 [16:23]
/// IPR_N2
IPR_N2: u8 = 0,
/// IPR_N3 [24:31]
/// IPR_N3
IPR_N3: u8 = 0,
};
/// Interrupt Priority Register
pub const IPR20 = Register(IPR20_val).init(base_address + 0x450);
};
/// Floting point unit
pub const FPU = struct {
const base_address = 0xe000ed88;
/// CPACR
const CPACR_val = packed struct {
/// CP0 [0:0]
/// Access privileges for coprocessor 0
CP0: u1 = 0,
/// unused [1:1]
_unused1: u1 = 0,
/// CP1 [2:2]
/// Access privileges for coprocessor 1
CP1: u1 = 0,
/// unused [3:3]
_unused3: u1 = 0,
/// CP2 [4:4]
/// Access privileges for coprocessor 2
CP2: u1 = 0,
/// unused [5:5]
_unused5: u1 = 0,
/// CP3 [6:6]
/// Access privileges for coprocessor 3
CP3: u1 = 0,
/// unused [7:7]
_unused7: u1 = 0,
/// CP4 [8:8]
/// Access privileges for coprocessor 4
CP4: u1 = 0,
/// unused [9:9]
_unused9: u1 = 0,
/// CP5 [10:10]
/// Access privileges for coprocessor 5
CP5: u1 = 0,
/// unused [11:11]
_unused11: u1 = 0,
/// CP6 [12:13]
/// Access privileges for coprocessor 6
CP6: u2 = 0,
/// CP7 [14:14]
/// Access privileges for coprocessor 7
CP7: u1 = 0,
/// unused [15:19]
_unused15: u1 = 0,
_unused16: u4 = 0,
/// CP10 [20:20]
/// Access privileges for coprocessor 10
CP10: u1 = 0,
/// unused [21:21]
_unused21: u1 = 0,
/// CP11 [22:22]
/// Access privileges for coprocessor 11
CP11: u1 = 0,
/// unused [23:31]
_unused23: u1 = 0,
_unused24: u8 = 0,
};
/// Coprocessor Access Control Register
pub const CPACR = Register(CPACR_val).init(base_address + 0x0);
/// FPCCR
const FPCCR_val = packed struct {
/// LSPACT [0:0]
/// LSPACT
LSPACT: u1 = 0,
/// USER [1:1]
/// USER
USER: u1 = 0,
/// unused [2:2]
_unused2: u1 = 0,
/// THREAD [3:3]
/// THREAD
THREAD: u1 = 0,
/// HFRDY [4:4]
/// HFRDY
HFRDY: u1 = 0,
/// MMRDY [5:5]
/// MMRDY
MMRDY: u1 = 0,
/// BFRDY [6:6]
/// BFRDY
BFRDY: u1 = 0,
/// unused [7:7]
_unused7: u1 = 0,
/// MONRDY [8:8]
/// MONRDY
MONRDY: u1 = 0,
/// unused [9:29]
_unused9: u7 = 0,
_unused16: u8 = 0,
_unused24: u6 = 0,
/// LSPEN [30:30]
/// LSPEN
LSPEN: u1 = 1,
/// ASPEN [31:31]
/// ASPEN
ASPEN: u1 = 1,
};
/// FP Context Control Register
pub const FPCCR = Register(FPCCR_val).init(base_address + 0x1ac);
/// FPCAR
const FPCAR_val = packed struct {
/// unused [0:2]
_unused0: u3 = 0,
/// ADDRESS [3:31]
/// ADDRESS
ADDRESS: u29 = 0,
};
/// FP Context Address Register
pub const FPCAR = Register(FPCAR_val).init(base_address + 0x1b0);
/// FPDSCR
const FPDSCR_val = packed struct {
/// unused [0:21]
_unused0: u8 = 0,
_unused8: u8 = 0,
_unused16: u6 = 0,
/// RMode [22:23]
/// RMode
RMode: u2 = 0,
/// FZ [24:24]
/// FZ
FZ: u1 = 0,
/// DN [25:25]
/// DN
DN: u1 = 0,
/// AHP [26:26]
/// AHP
AHP: u1 = 0,
/// unused [27:31]
_unused27: u5 = 0,
};
/// FP Default Status Control Register
pub const FPDSCR = Register(FPDSCR_val).init(base_address + 0x1b4);
/// MVFR0
const MVFR0_val = packed struct {
/// A_SIMD [0:3]
/// A_SIMD registers
A_SIMD: u4 = 1,
/// Single_precision [4:7]
/// Single_precision
Single_precision: u4 = 2,
/// Double_precision [8:11]
/// Double_precision
Double_precision: u4 = 0,
/// FP_exception_trapping [12:15]
/// FP exception trapping
FP_exception_trapping: u4 = 0,
/// Divide [16:19]
/// Divide
Divide: u4 = 1,
/// Square_root [20:23]
/// Square root
Square_root: u4 = 1,
/// Short_vectors [24:27]
/// Short vectors
Short_vectors: u4 = 0,
/// FP_rounding_modes [28:31]
/// FP rounding modes
FP_rounding_modes: u4 = 1,
};
/// Media and VFP Feature Register 0
pub const MVFR0 = Register(MVFR0_val).init(base_address + 0x1b8);
/// MVFR1
const MVFR1_val = packed struct {
/// FtZ_mode [0:3]
/// FtZ mode
FtZ_mode: u4 = 1,
/// D_NaN_mode [4:7]
/// D_NaN mode
D_NaN_mode: u4 = 1,
/// unused [8:23]
_unused8: u8 = 0,
_unused16: u8 = 0,
/// FP_HPFP [24:27]
/// FP HPFP
FP_HPFP: u4 = 1,
/// FP_fused_MAC [28:31]
/// FP fused MAC
FP_fused_MAC: u4 = 1,
};
/// Media and VFP Feature Register 1
pub const MVFR1 = Register(MVFR1_val).init(base_address + 0x1bc);
};
/// Debug support
pub const DBGMCU = struct {
const base_address = 0xe0042000;
/// IDCODE
const IDCODE_val = packed struct {
/// DEV_ID [0:11]
/// Device Identifier
DEV_ID: u12 = 0,
/// unused [12:15]
_unused12: u4 = 0,
/// REV_ID [16:31]
/// Revision Identifier
REV_ID: u16 = 0,
};
/// MCU Device ID Code Register
pub const IDCODE = Register(IDCODE_val).init(base_address + 0x0);
/// CR
const CR_val = packed struct {
/// DBG_SLEEP [0:0]
/// Debug Sleep mode
DBG_SLEEP: u1 = 0,
/// DBG_STOP [1:1]
/// Debug Stop Mode
DBG_STOP: u1 = 0,
/// DBG_STANDBY [2:2]
/// Debug Standby Mode
DBG_STANDBY: u1 = 0,
/// unused [3:4]
_unused3: u2 = 0,
/// TRACE_IOEN [5:5]
/// Trace pin assignment control
TRACE_IOEN: u1 = 0,
/// TRACE_MODE [6:7]
/// Trace pin assignment control
TRACE_MODE: u2 = 0,
/// unused [8:31]
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// Debug MCU Configuration Register
pub const CR = Register(CR_val).init(base_address + 0x4);
/// APB1FZ
const APB1FZ_val = packed struct {
/// DBG_TIM2_STOP [0:0]
/// Debug Timer 2 stopped when Core is halted
DBG_TIM2_STOP: u1 = 0,
/// DBG_TIM3_STOP [1:1]
/// Debug Timer 3 stopped when Core is halted
DBG_TIM3_STOP: u1 = 0,
/// DBG_TIM4_STOP [2:2]
/// Debug Timer 4 stopped when Core is halted
DBG_TIM4_STOP: u1 = 0,
/// DBG_TIM5_STOP [3:3]
/// Debug Timer 5 stopped when Core is halted
DBG_TIM5_STOP: u1 = 0,
/// DBG_TIM6_STOP [4:4]
/// Debug Timer 6 stopped when Core is halted
DBG_TIM6_STOP: u1 = 0,
/// DBG_TIM7_STOP [5:5]
/// Debug Timer 7 stopped when Core is halted
DBG_TIM7_STOP: u1 = 0,
/// DBG_TIM12_STOP [6:6]
/// Debug Timer 12 stopped when Core is halted
DBG_TIM12_STOP: u1 = 0,
/// DBG_TIM13_STOP [7:7]
/// Debug Timer 13 stopped when Core is halted
DBG_TIM13_STOP: u1 = 0,
/// DBG_TIMER14_STOP [8:8]
/// Debug Timer 14 stopped when Core is halted
DBG_TIMER14_STOP: u1 = 0,
/// DBG_TIM18_STOP [9:9]
/// Debug Timer 18 stopped when Core is halted
DBG_TIM18_STOP: u1 = 0,
/// DBG_RTC_STOP [10:10]
/// Debug RTC stopped when Core is halted
DBG_RTC_STOP: u1 = 0,
/// DBG_WWDG_STOP [11:11]
/// Debug Window Wachdog stopped when Core is halted
DBG_WWDG_STOP: u1 = 0,
/// DBG_IWDG_STOP [12:12]
/// Debug Independent Wachdog stopped when Core is halted
DBG_IWDG_STOP: u1 = 0,
/// unused [13:20]
_unused13: u3 = 0,
_unused16: u5 = 0,
/// I2C1_SMBUS_TIMEOUT [21:21]
/// SMBUS timeout mode stopped when Core is halted
I2C1_SMBUS_TIMEOUT: u1 = 0,
/// I2C2_SMBUS_TIMEOUT [22:22]
/// SMBUS timeout mode stopped when Core is halted
I2C2_SMBUS_TIMEOUT: u1 = 0,
/// unused [23:24]
_unused23: u1 = 0,
_unused24: u1 = 0,
/// DBG_CAN_STOP [25:25]
/// Debug CAN stopped when core is halted
DBG_CAN_STOP: u1 = 0,
/// unused [26:31]
_unused26: u6 = 0,
};
/// APB Low Freeze Register
pub const APB1FZ = Register(APB1FZ_val).init(base_address + 0x8);
/// APB2FZ
const APB2FZ_val = packed struct {
/// unused [0:1]
_unused0: u2 = 0,
/// DBG_TIM15_STOP [2:2]
/// Debug Timer 15 stopped when Core is halted
DBG_TIM15_STOP: u1 = 0,
/// DBG_TIM16_STOP [3:3]
/// Debug Timer 16 stopped when Core is halted
DBG_TIM16_STOP: u1 = 0,
/// DBG_TIM17_STO [4:4]
/// Debug Timer 17 stopped when Core is halted
DBG_TIM17_STO: u1 = 0,
/// DBG_TIM19_STOP [5:5]
/// Debug Timer 19 stopped when Core is halted
DBG_TIM19_STOP: u1 = 0,
/// unused [6:31]
_unused6: u2 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// APB High Freeze Register
pub const APB2FZ = Register(APB2FZ_val).init(base_address + 0xc);
};
/// Advanced timer
pub const TIM1 = struct {
const base_address = 0x40012c00;
/// CR1
const CR1_val = packed struct {
/// CEN [0:0]
/// Counter enable
CEN: u1 = 0,
/// UDIS [1:1]
/// Update disable
UDIS: u1 = 0,
/// URS [2:2]
/// Update request source
URS: u1 = 0,
/// OPM [3:3]
/// One-pulse mode
OPM: u1 = 0,
/// DIR [4:4]
/// Direction
DIR: u1 = 0,
/// CMS [5:6]
/// Center-aligned mode selection
CMS: u2 = 0,
/// ARPE [7:7]
/// Auto-reload preload enable
ARPE: u1 = 0,
/// CKD [8:9]
/// Clock division
CKD: u2 = 0,
/// unused [10:10]
_unused10: u1 = 0,
/// UIFREMAP [11:11]
/// UIF status bit remapping
UIFREMAP: u1 = 0,
/// unused [12:31]
_unused12: u4 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// control register 1
pub const CR1 = Register(CR1_val).init(base_address + 0x0);
/// CR2
const CR2_val = packed struct {
/// CCPC [0:0]
/// Capture/compare preloaded control
CCPC: u1 = 0,
/// unused [1:1]
_unused1: u1 = 0,
/// CCUS [2:2]
/// Capture/compare control update selection
CCUS: u1 = 0,
/// CCDS [3:3]
/// Capture/compare DMA selection
CCDS: u1 = 0,
/// MMS [4:6]
/// Master mode selection
MMS: u3 = 0,
/// TI1S [7:7]
/// TI1 selection
TI1S: u1 = 0,
/// OIS1 [8:8]
/// Output Idle state 1
OIS1: u1 = 0,
/// OIS1N [9:9]
/// Output Idle state 1
OIS1N: u1 = 0,
/// OIS2 [10:10]
/// Output Idle state 2
OIS2: u1 = 0,
/// OIS2N [11:11]
/// Output Idle state 2
OIS2N: u1 = 0,
/// OIS3 [12:12]
/// Output Idle state 3
OIS3: u1 = 0,
/// OIS3N [13:13]
/// Output Idle state 3
OIS3N: u1 = 0,
/// OIS4 [14:14]
/// Output Idle state 4
OIS4: u1 = 0,
/// unused [15:15]
_unused15: u1 = 0,
/// OIS5 [16:16]
/// Output Idle state 5
OIS5: u1 = 0,
/// unused [17:17]
_unused17: u1 = 0,
/// OIS6 [18:18]
/// Output Idle state 6
OIS6: u1 = 0,
/// unused [19:19]
_unused19: u1 = 0,
/// MMS2 [20:23]
/// Master mode selection 2
MMS2: u4 = 0,
/// unused [24:31]
_unused24: u8 = 0,
};
/// control register 2
pub const CR2 = Register(CR2_val).init(base_address + 0x4);
/// SMCR
const SMCR_val = packed struct {
/// SMS [0:2]
/// Slave mode selection
SMS: u3 = 0,
/// OCCS [3:3]
/// OCREF clear selection
OCCS: u1 = 0,
/// TS [4:6]
/// Trigger selection
TS: u3 = 0,
/// MSM [7:7]
/// Master/Slave mode
MSM: u1 = 0,
/// ETF [8:11]
/// External trigger filter
ETF: u4 = 0,
/// ETPS [12:13]
/// External trigger prescaler
ETPS: u2 = 0,
/// ECE [14:14]
/// External clock enable
ECE: u1 = 0,
/// ETP [15:15]
/// External trigger polarity
ETP: u1 = 0,
/// SMS3 [16:16]
/// Slave mode selection bit 3
SMS3: u1 = 0,
/// unused [17:31]
_unused17: u7 = 0,
_unused24: u8 = 0,
};
/// slave mode control register
pub const SMCR = Register(SMCR_val).init(base_address + 0x8);
/// DIER
const DIER_val = packed struct {
/// UIE [0:0]
/// Update interrupt enable
UIE: u1 = 0,
/// CC1IE [1:1]
/// Capture/Compare 1 interrupt enable
CC1IE: u1 = 0,
/// CC2IE [2:2]
/// Capture/Compare 2 interrupt enable
CC2IE: u1 = 0,
/// CC3IE [3:3]
/// Capture/Compare 3 interrupt enable
CC3IE: u1 = 0,
/// CC4IE [4:4]
/// Capture/Compare 4 interrupt enable
CC4IE: u1 = 0,
/// COMIE [5:5]
/// COM interrupt enable
COMIE: u1 = 0,
/// TIE [6:6]
/// Trigger interrupt enable
TIE: u1 = 0,
/// BIE [7:7]
/// Break interrupt enable
BIE: u1 = 0,
/// UDE [8:8]
/// Update DMA request enable
UDE: u1 = 0,
/// CC1DE [9:9]
/// Capture/Compare 1 DMA request enable
CC1DE: u1 = 0,
/// CC2DE [10:10]
/// Capture/Compare 2 DMA request enable
CC2DE: u1 = 0,
/// CC3DE [11:11]
/// Capture/Compare 3 DMA request enable
CC3DE: u1 = 0,
/// CC4DE [12:12]
/// Capture/Compare 4 DMA request enable
CC4DE: u1 = 0,
/// COMDE [13:13]
/// Reserved
COMDE: u1 = 0,
/// TDE [14:14]
/// Trigger DMA request enable
TDE: u1 = 0,
/// unused [15:31]
_unused15: u1 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA/Interrupt enable register
pub const DIER = Register(DIER_val).init(base_address + 0xc);
/// SR
const SR_val = packed struct {
/// UIF [0:0]
/// Update interrupt flag
UIF: u1 = 0,
/// CC1IF [1:1]
/// Capture/compare 1 interrupt flag
CC1IF: u1 = 0,
/// CC2IF [2:2]
/// Capture/Compare 2 interrupt flag
CC2IF: u1 = 0,
/// CC3IF [3:3]
/// Capture/Compare 3 interrupt flag
CC3IF: u1 = 0,
/// CC4IF [4:4]
/// Capture/Compare 4 interrupt flag
CC4IF: u1 = 0,
/// COMIF [5:5]
/// COM interrupt flag
COMIF: u1 = 0,
/// TIF [6:6]
/// Trigger interrupt flag
TIF: u1 = 0,
/// BIF [7:7]
/// Break interrupt flag
BIF: u1 = 0,
/// B2IF [8:8]
/// Break 2 interrupt flag
B2IF: u1 = 0,
/// CC1OF [9:9]
/// Capture/Compare 1 overcapture flag
CC1OF: u1 = 0,
/// CC2OF [10:10]
/// Capture/compare 2 overcapture flag
CC2OF: u1 = 0,
/// CC3OF [11:11]
/// Capture/Compare 3 overcapture flag
CC3OF: u1 = 0,
/// CC4OF [12:12]
/// Capture/Compare 4 overcapture flag
CC4OF: u1 = 0,
/// unused [13:15]
_unused13: u3 = 0,
/// C5IF [16:16]
/// Capture/Compare 5 interrupt flag
C5IF: u1 = 0,
/// C6IF [17:17]
/// Capture/Compare 6 interrupt flag
C6IF: u1 = 0,
/// unused [18:31]
_unused18: u6 = 0,
_unused24: u8 = 0,
};
/// status register
pub const SR = Register(SR_val).init(base_address + 0x10);
/// EGR
const EGR_val = packed struct {
/// UG [0:0]
/// Update generation
UG: u1 = 0,
/// CC1G [1:1]
/// Capture/compare 1 generation
CC1G: u1 = 0,
/// CC2G [2:2]
/// Capture/compare 2 generation
CC2G: u1 = 0,
/// CC3G [3:3]
/// Capture/compare 3 generation
CC3G: u1 = 0,
/// CC4G [4:4]
/// Capture/compare 4 generation
CC4G: u1 = 0,
/// COMG [5:5]
/// Capture/Compare control update generation
COMG: u1 = 0,
/// TG [6:6]
/// Trigger generation
TG: u1 = 0,
/// BG [7:7]
/// Break generation
BG: u1 = 0,
/// B2G [8:8]
/// Break 2 generation
B2G: u1 = 0,
/// unused [9:31]
_unused9: u7 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// event generation register
pub const EGR = Register(EGR_val).init(base_address + 0x14);
/// CCMR1_Output
const CCMR1_Output_val = packed struct {
/// CC1S [0:1]
/// Capture/Compare 1 selection
CC1S: u2 = 0,
/// OC1FE [2:2]
/// Output Compare 1 fast enable
OC1FE: u1 = 0,
/// OC1PE [3:3]
/// Output Compare 1 preload enable
OC1PE: u1 = 0,
/// OC1M [4:6]
/// Output Compare 1 mode
OC1M: u3 = 0,
/// OC1CE [7:7]
/// Output Compare 1 clear enable
OC1CE: u1 = 0,
/// CC2S [8:9]
/// Capture/Compare 2 selection
CC2S: u2 = 0,
/// OC2FE [10:10]
/// Output Compare 2 fast enable
OC2FE: u1 = 0,
/// OC2PE [11:11]
/// Output Compare 2 preload enable
OC2PE: u1 = 0,
/// OC2M [12:14]
/// Output Compare 2 mode
OC2M: u3 = 0,
/// OC2CE [15:15]
/// Output Compare 2 clear enable
OC2CE: u1 = 0,
/// OC1M_3 [16:16]
/// Output Compare 1 mode bit 3
OC1M_3: u1 = 0,
/// unused [17:23]
_unused17: u7 = 0,
/// OC2M_3 [24:24]
/// Output Compare 2 mode bit 3
OC2M_3: u1 = 0,
/// unused [25:31]
_unused25: u7 = 0,
};
/// capture/compare mode register (output mode)
pub const CCMR1_Output = Register(CCMR1_Output_val).init(base_address + 0x18);
/// CCMR1_Input
const CCMR1_Input_val = packed struct {
/// CC1S [0:1]
/// Capture/Compare 1 selection
CC1S: u2 = 0,
/// IC1PCS [2:3]
/// Input capture 1 prescaler
IC1PCS: u2 = 0,
/// IC1F [4:7]
/// Input capture 1 filter
IC1F: u4 = 0,
/// CC2S [8:9]
/// Capture/Compare 2 selection
CC2S: u2 = 0,
/// IC2PCS [10:11]
/// Input capture 2 prescaler
IC2PCS: u2 = 0,
/// IC2F [12:15]
/// Input capture 2 filter
IC2F: u4 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// capture/compare mode register 1 (input mode)
pub const CCMR1_Input = Register(CCMR1_Input_val).init(base_address + 0x18);
/// CCMR2_Output
const CCMR2_Output_val = packed struct {
/// CC3S [0:1]
/// Capture/Compare 3 selection
CC3S: u2 = 0,
/// OC3FE [2:2]
/// Output compare 3 fast enable
OC3FE: u1 = 0,
/// OC3PE [3:3]
/// Output compare 3 preload enable
OC3PE: u1 = 0,
/// OC3M [4:6]
/// Output compare 3 mode
OC3M: u3 = 0,
/// OC3CE [7:7]
/// Output compare 3 clear enable
OC3CE: u1 = 0,
/// CC4S [8:9]
/// Capture/Compare 4 selection
CC4S: u2 = 0,
/// OC4FE [10:10]
/// Output compare 4 fast enable
OC4FE: u1 = 0,
/// OC4PE [11:11]
/// Output compare 4 preload enable
OC4PE: u1 = 0,
/// OC4M [12:14]
/// Output compare 4 mode
OC4M: u3 = 0,
/// OC4CE [15:15]
/// Output compare 4 clear enable
OC4CE: u1 = 0,
/// OC3M_3 [16:16]
/// Output Compare 3 mode bit 3
OC3M_3: u1 = 0,
/// unused [17:23]
_unused17: u7 = 0,
/// OC4M_3 [24:24]
/// Output Compare 4 mode bit 3
OC4M_3: u1 = 0,
/// unused [25:31]
_unused25: u7 = 0,
};
/// capture/compare mode register (output mode)
pub const CCMR2_Output = Register(CCMR2_Output_val).init(base_address + 0x1c);
/// CCMR2_Input
const CCMR2_Input_val = packed struct {
/// CC3S [0:1]
/// Capture/compare 3 selection
CC3S: u2 = 0,
/// IC3PSC [2:3]
/// Input capture 3 prescaler
IC3PSC: u2 = 0,
/// IC3F [4:7]
/// Input capture 3 filter
IC3F: u4 = 0,
/// CC4S [8:9]
/// Capture/Compare 4 selection
CC4S: u2 = 0,
/// IC4PSC [10:11]
/// Input capture 4 prescaler
IC4PSC: u2 = 0,
/// IC4F [12:15]
/// Input capture 4 filter
IC4F: u4 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// capture/compare mode register 2 (input mode)
pub const CCMR2_Input = Register(CCMR2_Input_val).init(base_address + 0x1c);
/// CCER
const CCER_val = packed struct {
/// CC1E [0:0]
/// Capture/Compare 1 output enable
CC1E: u1 = 0,
/// CC1P [1:1]
/// Capture/Compare 1 output Polarity
CC1P: u1 = 0,
/// CC1NE [2:2]
/// Capture/Compare 1 complementary output enable
CC1NE: u1 = 0,
/// CC1NP [3:3]
/// Capture/Compare 1 output Polarity
CC1NP: u1 = 0,
/// CC2E [4:4]
/// Capture/Compare 2 output enable
CC2E: u1 = 0,
/// CC2P [5:5]
/// Capture/Compare 2 output Polarity
CC2P: u1 = 0,
/// CC2NE [6:6]
/// Capture/Compare 2 complementary output enable
CC2NE: u1 = 0,
/// CC2NP [7:7]
/// Capture/Compare 2 output Polarity
CC2NP: u1 = 0,
/// CC3E [8:8]
/// Capture/Compare 3 output enable
CC3E: u1 = 0,
/// CC3P [9:9]
/// Capture/Compare 3 output Polarity
CC3P: u1 = 0,
/// CC3NE [10:10]
/// Capture/Compare 3 complementary output enable
CC3NE: u1 = 0,
/// CC3NP [11:11]
/// Capture/Compare 3 output Polarity
CC3NP: u1 = 0,
/// CC4E [12:12]
/// Capture/Compare 4 output enable
CC4E: u1 = 0,
/// CC4P [13:13]
/// Capture/Compare 3 output Polarity
CC4P: u1 = 0,
/// unused [14:14]
_unused14: u1 = 0,
/// CC4NP [15:15]
/// Capture/Compare 4 output Polarity
CC4NP: u1 = 0,
/// CC5E [16:16]
/// Capture/Compare 5 output enable
CC5E: u1 = 0,
/// CC5P [17:17]
/// Capture/Compare 5 output Polarity
CC5P: u1 = 0,
/// unused [18:19]
_unused18: u2 = 0,
/// CC6E [20:20]
/// Capture/Compare 6 output enable
CC6E: u1 = 0,
/// CC6P [21:21]
/// Capture/Compare 6 output Polarity
CC6P: u1 = 0,
/// unused [22:31]
_unused22: u2 = 0,
_unused24: u8 = 0,
};
/// capture/compare enable register
pub const CCER = Register(CCER_val).init(base_address + 0x20);
/// CNT
const CNT_val = packed struct {
/// CNT [0:15]
/// counter value
CNT: u16 = 0,
/// unused [16:30]
_unused16: u8 = 0,
_unused24: u7 = 0,
/// UIFCPY [31:31]
/// UIF copy
UIFCPY: u1 = 0,
};
/// counter
pub const CNT = Register(CNT_val).init(base_address + 0x24);
/// PSC
const PSC_val = packed struct {
/// PSC [0:15]
/// Prescaler value
PSC: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// prescaler
pub const PSC = Register(PSC_val).init(base_address + 0x28);
/// ARR
const ARR_val = packed struct {
/// ARR [0:15]
/// Auto-reload value
ARR: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// auto-reload register
pub const ARR = Register(ARR_val).init(base_address + 0x2c);
/// RCR
const RCR_val = packed struct {
/// REP [0:15]
/// Repetition counter value
REP: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// repetition counter register
pub const RCR = Register(RCR_val).init(base_address + 0x30);
/// CCR1
const CCR1_val = packed struct {
/// CCR1 [0:15]
/// Capture/Compare 1 value
CCR1: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// capture/compare register 1
pub const CCR1 = Register(CCR1_val).init(base_address + 0x34);
/// CCR2
const CCR2_val = packed struct {
/// CCR2 [0:15]
/// Capture/Compare 2 value
CCR2: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// capture/compare register 2
pub const CCR2 = Register(CCR2_val).init(base_address + 0x38);
/// CCR3
const CCR3_val = packed struct {
/// CCR3 [0:15]
/// Capture/Compare 3 value
CCR3: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// capture/compare register 3
pub const CCR3 = Register(CCR3_val).init(base_address + 0x3c);
/// CCR4
const CCR4_val = packed struct {
/// CCR4 [0:15]
/// Capture/Compare 3 value
CCR4: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// capture/compare register 4
pub const CCR4 = Register(CCR4_val).init(base_address + 0x40);
/// BDTR
const BDTR_val = packed struct {
/// DTG [0:7]
/// Dead-time generator setup
DTG: u8 = 0,
/// LOCK [8:9]
/// Lock configuration
LOCK: u2 = 0,
/// OSSI [10:10]
/// Off-state selection for Idle mode
OSSI: u1 = 0,
/// OSSR [11:11]
/// Off-state selection for Run mode
OSSR: u1 = 0,
/// BKE [12:12]
/// Break enable
BKE: u1 = 0,
/// BKP [13:13]
/// Break polarity
BKP: u1 = 0,
/// AOE [14:14]
/// Automatic output enable
AOE: u1 = 0,
/// MOE [15:15]
/// Main output enable
MOE: u1 = 0,
/// BKF [16:19]
/// Break filter
BKF: u4 = 0,
/// BK2F [20:23]
/// Break 2 filter
BK2F: u4 = 0,
/// BK2E [24:24]
/// Break 2 enable
BK2E: u1 = 0,
/// BK2P [25:25]
/// Break 2 polarity
BK2P: u1 = 0,
/// unused [26:31]
_unused26: u6 = 0,
};
/// break and dead-time register
pub const BDTR = Register(BDTR_val).init(base_address + 0x44);
/// DCR
const DCR_val = packed struct {
/// DBA [0:4]
/// DMA base address
DBA: u5 = 0,
/// unused [5:7]
_unused5: u3 = 0,
/// DBL [8:12]
/// DMA burst length
DBL: u5 = 0,
/// unused [13:31]
_unused13: u3 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA control register
pub const DCR = Register(DCR_val).init(base_address + 0x48);
/// DMAR
const DMAR_val = packed struct {
/// DMAB [0:15]
/// DMA register for burst accesses
DMAB: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA address for full transfer
pub const DMAR = Register(DMAR_val).init(base_address + 0x4c);
/// CCMR3_Output
const CCMR3_Output_val = packed struct {
/// unused [0:1]
_unused0: u2 = 0,
/// OC5FE [2:2]
/// Output compare 5 fast enable
OC5FE: u1 = 0,
/// OC5PE [3:3]
/// Output compare 5 preload enable
OC5PE: u1 = 0,
/// OC5M [4:6]
/// Output compare 5 mode
OC5M: u3 = 0,
/// OC5CE [7:7]
/// Output compare 5 clear enable
OC5CE: u1 = 0,
/// unused [8:9]
_unused8: u2 = 0,
/// OC6FE [10:10]
/// Output compare 6 fast enable
OC6FE: u1 = 0,
/// OC6PE [11:11]
/// Output compare 6 preload enable
OC6PE: u1 = 0,
/// OC6M [12:14]
/// Output compare 6 mode
OC6M: u3 = 0,
/// OC6CE [15:15]
/// Output compare 6 clear enable
OC6CE: u1 = 0,
/// OC5M_3 [16:16]
/// Outout Compare 5 mode bit 3
OC5M_3: u1 = 0,
/// unused [17:23]
_unused17: u7 = 0,
/// OC6M_3 [24:24]
/// Outout Compare 6 mode bit 3
OC6M_3: u1 = 0,
/// unused [25:31]
_unused25: u7 = 0,
};
/// capture/compare mode register 3 (output mode)
pub const CCMR3_Output = Register(CCMR3_Output_val).init(base_address + 0x54);
/// CCR5
const CCR5_val = packed struct {
/// CCR5 [0:15]
/// Capture/Compare 5 value
CCR5: u16 = 0,
/// unused [16:28]
_unused16: u8 = 0,
_unused24: u5 = 0,
/// GC5C1 [29:29]
/// Group Channel 5 and Channel 1
GC5C1: u1 = 0,
/// GC5C2 [30:30]
/// Group Channel 5 and Channel 2
GC5C2: u1 = 0,
/// GC5C3 [31:31]
/// Group Channel 5 and Channel 3
GC5C3: u1 = 0,
};
/// capture/compare register 5
pub const CCR5 = Register(CCR5_val).init(base_address + 0x58);
/// CCR6
const CCR6_val = packed struct {
/// CCR6 [0:15]
/// Capture/Compare 6 value
CCR6: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// capture/compare register 6
pub const CCR6 = Register(CCR6_val).init(base_address + 0x5c);
/// OR
const OR_val = packed struct {
/// TIM1_ETR_ADC1_RMP [0:1]
/// TIM1_ETR_ADC1 remapping capability
TIM1_ETR_ADC1_RMP: u2 = 0,
/// TIM1_ETR_ADC4_RMP [2:3]
/// TIM1_ETR_ADC4 remapping capability
TIM1_ETR_ADC4_RMP: u2 = 0,
/// unused [4:31]
_unused4: u4 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// option registers
pub const OR = Register(OR_val).init(base_address + 0x60);
};
/// Advanced timer
pub const TIM20 = struct {
const base_address = 0x40015000;
/// CR1
const CR1_val = packed struct {
/// CEN [0:0]
/// Counter enable
CEN: u1 = 0,
/// UDIS [1:1]
/// Update disable
UDIS: u1 = 0,
/// URS [2:2]
/// Update request source
URS: u1 = 0,
/// OPM [3:3]
/// One-pulse mode
OPM: u1 = 0,
/// DIR [4:4]
/// Direction
DIR: u1 = 0,
/// CMS [5:6]
/// Center-aligned mode selection
CMS: u2 = 0,
/// ARPE [7:7]
/// Auto-reload preload enable
ARPE: u1 = 0,
/// CKD [8:9]
/// Clock division
CKD: u2 = 0,
/// unused [10:10]
_unused10: u1 = 0,
/// UIFREMAP [11:11]
/// UIF status bit remapping
UIFREMAP: u1 = 0,
/// unused [12:31]
_unused12: u4 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// control register 1
pub const CR1 = Register(CR1_val).init(base_address + 0x0);
/// CR2
const CR2_val = packed struct {
/// CCPC [0:0]
/// Capture/compare preloaded control
CCPC: u1 = 0,
/// unused [1:1]
_unused1: u1 = 0,
/// CCUS [2:2]
/// Capture/compare control update selection
CCUS: u1 = 0,
/// CCDS [3:3]
/// Capture/compare DMA selection
CCDS: u1 = 0,
/// MMS [4:6]
/// Master mode selection
MMS: u3 = 0,
/// TI1S [7:7]
/// TI1 selection
TI1S: u1 = 0,
/// OIS1 [8:8]
/// Output Idle state 1
OIS1: u1 = 0,
/// OIS1N [9:9]
/// Output Idle state 1
OIS1N: u1 = 0,
/// OIS2 [10:10]
/// Output Idle state 2
OIS2: u1 = 0,
/// OIS2N [11:11]
/// Output Idle state 2
OIS2N: u1 = 0,
/// OIS3 [12:12]
/// Output Idle state 3
OIS3: u1 = 0,
/// OIS3N [13:13]
/// Output Idle state 3
OIS3N: u1 = 0,
/// OIS4 [14:14]
/// Output Idle state 4
OIS4: u1 = 0,
/// unused [15:15]
_unused15: u1 = 0,
/// OIS5 [16:16]
/// Output Idle state 5
OIS5: u1 = 0,
/// unused [17:17]
_unused17: u1 = 0,
/// OIS6 [18:18]
/// Output Idle state 6
OIS6: u1 = 0,
/// unused [19:19]
_unused19: u1 = 0,
/// MMS2 [20:23]
/// Master mode selection 2
MMS2: u4 = 0,
/// unused [24:31]
_unused24: u8 = 0,
};
/// control register 2
pub const CR2 = Register(CR2_val).init(base_address + 0x4);
/// SMCR
const SMCR_val = packed struct {
/// SMS [0:2]
/// Slave mode selection
SMS: u3 = 0,
/// OCCS [3:3]
/// OCREF clear selection
OCCS: u1 = 0,
/// TS [4:6]
/// Trigger selection
TS: u3 = 0,
/// MSM [7:7]
/// Master/Slave mode
MSM: u1 = 0,
/// ETF [8:11]
/// External trigger filter
ETF: u4 = 0,
/// ETPS [12:13]
/// External trigger prescaler
ETPS: u2 = 0,
/// ECE [14:14]
/// External clock enable
ECE: u1 = 0,
/// ETP [15:15]
/// External trigger polarity
ETP: u1 = 0,
/// SMS3 [16:16]
/// Slave mode selection bit 3
SMS3: u1 = 0,
/// unused [17:31]
_unused17: u7 = 0,
_unused24: u8 = 0,
};
/// slave mode control register
pub const SMCR = Register(SMCR_val).init(base_address + 0x8);
/// DIER
const DIER_val = packed struct {
/// UIE [0:0]
/// Update interrupt enable
UIE: u1 = 0,
/// CC1IE [1:1]
/// Capture/Compare 1 interrupt enable
CC1IE: u1 = 0,
/// CC2IE [2:2]
/// Capture/Compare 2 interrupt enable
CC2IE: u1 = 0,
/// CC3IE [3:3]
/// Capture/Compare 3 interrupt enable
CC3IE: u1 = 0,
/// CC4IE [4:4]
/// Capture/Compare 4 interrupt enable
CC4IE: u1 = 0,
/// COMIE [5:5]
/// COM interrupt enable
COMIE: u1 = 0,
/// TIE [6:6]
/// Trigger interrupt enable
TIE: u1 = 0,
/// BIE [7:7]
/// Break interrupt enable
BIE: u1 = 0,
/// UDE [8:8]
/// Update DMA request enable
UDE: u1 = 0,
/// CC1DE [9:9]
/// Capture/Compare 1 DMA request enable
CC1DE: u1 = 0,
/// CC2DE [10:10]
/// Capture/Compare 2 DMA request enable
CC2DE: u1 = 0,
/// CC3DE [11:11]
/// Capture/Compare 3 DMA request enable
CC3DE: u1 = 0,
/// CC4DE [12:12]
/// Capture/Compare 4 DMA request enable
CC4DE: u1 = 0,
/// COMDE [13:13]
/// Reserved
COMDE: u1 = 0,
/// TDE [14:14]
/// Trigger DMA request enable
TDE: u1 = 0,
/// unused [15:31]
_unused15: u1 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA/Interrupt enable register
pub const DIER = Register(DIER_val).init(base_address + 0xc);
/// SR
const SR_val = packed struct {
/// UIF [0:0]
/// Update interrupt flag
UIF: u1 = 0,
/// CC1IF [1:1]
/// Capture/compare 1 interrupt flag
CC1IF: u1 = 0,
/// CC2IF [2:2]
/// Capture/Compare 2 interrupt flag
CC2IF: u1 = 0,
/// CC3IF [3:3]
/// Capture/Compare 3 interrupt flag
CC3IF: u1 = 0,
/// CC4IF [4:4]
/// Capture/Compare 4 interrupt flag
CC4IF: u1 = 0,
/// COMIF [5:5]
/// COM interrupt flag
COMIF: u1 = 0,
/// TIF [6:6]
/// Trigger interrupt flag
TIF: u1 = 0,
/// BIF [7:7]
/// Break interrupt flag
BIF: u1 = 0,
/// B2IF [8:8]
/// Break 2 interrupt flag
B2IF: u1 = 0,
/// CC1OF [9:9]
/// Capture/Compare 1 overcapture flag
CC1OF: u1 = 0,
/// CC2OF [10:10]
/// Capture/compare 2 overcapture flag
CC2OF: u1 = 0,
/// CC3OF [11:11]
/// Capture/Compare 3 overcapture flag
CC3OF: u1 = 0,
/// CC4OF [12:12]
/// Capture/Compare 4 overcapture flag
CC4OF: u1 = 0,
/// unused [13:15]
_unused13: u3 = 0,
/// C5IF [16:16]
/// Capture/Compare 5 interrupt flag
C5IF: u1 = 0,
/// C6IF [17:17]
/// Capture/Compare 6 interrupt flag
C6IF: u1 = 0,
/// unused [18:31]
_unused18: u6 = 0,
_unused24: u8 = 0,
};
/// status register
pub const SR = Register(SR_val).init(base_address + 0x10);
/// EGR
const EGR_val = packed struct {
/// UG [0:0]
/// Update generation
UG: u1 = 0,
/// CC1G [1:1]
/// Capture/compare 1 generation
CC1G: u1 = 0,
/// CC2G [2:2]
/// Capture/compare 2 generation
CC2G: u1 = 0,
/// CC3G [3:3]
/// Capture/compare 3 generation
CC3G: u1 = 0,
/// CC4G [4:4]
/// Capture/compare 4 generation
CC4G: u1 = 0,
/// COMG [5:5]
/// Capture/Compare control update generation
COMG: u1 = 0,
/// TG [6:6]
/// Trigger generation
TG: u1 = 0,
/// BG [7:7]
/// Break generation
BG: u1 = 0,
/// B2G [8:8]
/// Break 2 generation
B2G: u1 = 0,
/// unused [9:31]
_unused9: u7 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// event generation register
pub const EGR = Register(EGR_val).init(base_address + 0x14);
/// CCMR1_Output
const CCMR1_Output_val = packed struct {
/// CC1S [0:1]
/// Capture/Compare 1 selection
CC1S: u2 = 0,
/// OC1FE [2:2]
/// Output Compare 1 fast enable
OC1FE: u1 = 0,
/// OC1PE [3:3]
/// Output Compare 1 preload enable
OC1PE: u1 = 0,
/// OC1M [4:6]
/// Output Compare 1 mode
OC1M: u3 = 0,
/// OC1CE [7:7]
/// Output Compare 1 clear enable
OC1CE: u1 = 0,
/// CC2S [8:9]
/// Capture/Compare 2 selection
CC2S: u2 = 0,
/// OC2FE [10:10]
/// Output Compare 2 fast enable
OC2FE: u1 = 0,
/// OC2PE [11:11]
/// Output Compare 2 preload enable
OC2PE: u1 = 0,
/// OC2M [12:14]
/// Output Compare 2 mode
OC2M: u3 = 0,
/// OC2CE [15:15]
/// Output Compare 2 clear enable
OC2CE: u1 = 0,
/// OC1M_3 [16:16]
/// Output Compare 1 mode bit 3
OC1M_3: u1 = 0,
/// unused [17:23]
_unused17: u7 = 0,
/// OC2M_3 [24:24]
/// Output Compare 2 mode bit 3
OC2M_3: u1 = 0,
/// unused [25:31]
_unused25: u7 = 0,
};
/// capture/compare mode register (output mode)
pub const CCMR1_Output = Register(CCMR1_Output_val).init(base_address + 0x18);
/// CCMR1_Input
const CCMR1_Input_val = packed struct {
/// CC1S [0:1]
/// Capture/Compare 1 selection
CC1S: u2 = 0,
/// IC1PCS [2:3]
/// Input capture 1 prescaler
IC1PCS: u2 = 0,
/// IC1F [4:7]
/// Input capture 1 filter
IC1F: u4 = 0,
/// CC2S [8:9]
/// Capture/Compare 2 selection
CC2S: u2 = 0,
/// IC2PCS [10:11]
/// Input capture 2 prescaler
IC2PCS: u2 = 0,
/// IC2F [12:15]
/// Input capture 2 filter
IC2F: u4 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// capture/compare mode register 1 (input mode)
pub const CCMR1_Input = Register(CCMR1_Input_val).init(base_address + 0x18);
/// CCMR2_Output
const CCMR2_Output_val = packed struct {
/// CC3S [0:1]
/// Capture/Compare 3 selection
CC3S: u2 = 0,
/// OC3FE [2:2]
/// Output compare 3 fast enable
OC3FE: u1 = 0,
/// OC3PE [3:3]
/// Output compare 3 preload enable
OC3PE: u1 = 0,
/// OC3M [4:6]
/// Output compare 3 mode
OC3M: u3 = 0,
/// OC3CE [7:7]
/// Output compare 3 clear enable
OC3CE: u1 = 0,
/// CC4S [8:9]
/// Capture/Compare 4 selection
CC4S: u2 = 0,
/// OC4FE [10:10]
/// Output compare 4 fast enable
OC4FE: u1 = 0,
/// OC4PE [11:11]
/// Output compare 4 preload enable
OC4PE: u1 = 0,
/// OC4M [12:14]
/// Output compare 4 mode
OC4M: u3 = 0,
/// OC4CE [15:15]
/// Output compare 4 clear enable
OC4CE: u1 = 0,
/// OC3M_3 [16:16]
/// Output Compare 3 mode bit 3
OC3M_3: u1 = 0,
/// unused [17:23]
_unused17: u7 = 0,
/// OC4M_3 [24:24]
/// Output Compare 4 mode bit 3
OC4M_3: u1 = 0,
/// unused [25:31]
_unused25: u7 = 0,
};
/// capture/compare mode register (output mode)
pub const CCMR2_Output = Register(CCMR2_Output_val).init(base_address + 0x1c);
/// CCMR2_Input
const CCMR2_Input_val = packed struct {
/// CC3S [0:1]
/// Capture/compare 3 selection
CC3S: u2 = 0,
/// IC3PSC [2:3]
/// Input capture 3 prescaler
IC3PSC: u2 = 0,
/// IC3F [4:7]
/// Input capture 3 filter
IC3F: u4 = 0,
/// CC4S [8:9]
/// Capture/Compare 4 selection
CC4S: u2 = 0,
/// IC4PSC [10:11]
/// Input capture 4 prescaler
IC4PSC: u2 = 0,
/// IC4F [12:15]
/// Input capture 4 filter
IC4F: u4 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// capture/compare mode register 2 (input mode)
pub const CCMR2_Input = Register(CCMR2_Input_val).init(base_address + 0x1c);
/// CCER
const CCER_val = packed struct {
/// CC1E [0:0]
/// Capture/Compare 1 output enable
CC1E: u1 = 0,
/// CC1P [1:1]
/// Capture/Compare 1 output Polarity
CC1P: u1 = 0,
/// CC1NE [2:2]
/// Capture/Compare 1 complementary output enable
CC1NE: u1 = 0,
/// CC1NP [3:3]
/// Capture/Compare 1 output Polarity
CC1NP: u1 = 0,
/// CC2E [4:4]
/// Capture/Compare 2 output enable
CC2E: u1 = 0,
/// CC2P [5:5]
/// Capture/Compare 2 output Polarity
CC2P: u1 = 0,
/// CC2NE [6:6]
/// Capture/Compare 2 complementary output enable
CC2NE: u1 = 0,
/// CC2NP [7:7]
/// Capture/Compare 2 output Polarity
CC2NP: u1 = 0,
/// CC3E [8:8]
/// Capture/Compare 3 output enable
CC3E: u1 = 0,
/// CC3P [9:9]
/// Capture/Compare 3 output Polarity
CC3P: u1 = 0,
/// CC3NE [10:10]
/// Capture/Compare 3 complementary output enable
CC3NE: u1 = 0,
/// CC3NP [11:11]
/// Capture/Compare 3 output Polarity
CC3NP: u1 = 0,
/// CC4E [12:12]
/// Capture/Compare 4 output enable
CC4E: u1 = 0,
/// CC4P [13:13]
/// Capture/Compare 3 output Polarity
CC4P: u1 = 0,
/// unused [14:14]
_unused14: u1 = 0,
/// CC4NP [15:15]
/// Capture/Compare 4 output Polarity
CC4NP: u1 = 0,
/// CC5E [16:16]
/// Capture/Compare 5 output enable
CC5E: u1 = 0,
/// CC5P [17:17]
/// Capture/Compare 5 output Polarity
CC5P: u1 = 0,
/// unused [18:19]
_unused18: u2 = 0,
/// CC6E [20:20]
/// Capture/Compare 6 output enable
CC6E: u1 = 0,
/// CC6P [21:21]
/// Capture/Compare 6 output Polarity
CC6P: u1 = 0,
/// unused [22:31]
_unused22: u2 = 0,
_unused24: u8 = 0,
};
/// capture/compare enable register
pub const CCER = Register(CCER_val).init(base_address + 0x20);
/// CNT
const CNT_val = packed struct {
/// CNT [0:15]
/// counter value
CNT: u16 = 0,
/// unused [16:30]
_unused16: u8 = 0,
_unused24: u7 = 0,
/// UIFCPY [31:31]
/// UIF copy
UIFCPY: u1 = 0,
};
/// counter
pub const CNT = Register(CNT_val).init(base_address + 0x24);
/// PSC
const PSC_val = packed struct {
/// PSC [0:15]
/// Prescaler value
PSC: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// prescaler
pub const PSC = Register(PSC_val).init(base_address + 0x28);
/// ARR
const ARR_val = packed struct {
/// ARR [0:15]
/// Auto-reload value
ARR: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// auto-reload register
pub const ARR = Register(ARR_val).init(base_address + 0x2c);
/// RCR
const RCR_val = packed struct {
/// REP [0:15]
/// Repetition counter value
REP: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// repetition counter register
pub const RCR = Register(RCR_val).init(base_address + 0x30);
/// CCR1
const CCR1_val = packed struct {
/// CCR1 [0:15]
/// Capture/Compare 1 value
CCR1: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// capture/compare register 1
pub const CCR1 = Register(CCR1_val).init(base_address + 0x34);
/// CCR2
const CCR2_val = packed struct {
/// CCR2 [0:15]
/// Capture/Compare 2 value
CCR2: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// capture/compare register 2
pub const CCR2 = Register(CCR2_val).init(base_address + 0x38);
/// CCR3
const CCR3_val = packed struct {
/// CCR3 [0:15]
/// Capture/Compare 3 value
CCR3: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// capture/compare register 3
pub const CCR3 = Register(CCR3_val).init(base_address + 0x3c);
/// CCR4
const CCR4_val = packed struct {
/// CCR4 [0:15]
/// Capture/Compare 3 value
CCR4: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// capture/compare register 4
pub const CCR4 = Register(CCR4_val).init(base_address + 0x40);
/// BDTR
const BDTR_val = packed struct {
/// DTG [0:7]
/// Dead-time generator setup
DTG: u8 = 0,
/// LOCK [8:9]
/// Lock configuration
LOCK: u2 = 0,
/// OSSI [10:10]
/// Off-state selection for Idle mode
OSSI: u1 = 0,
/// OSSR [11:11]
/// Off-state selection for Run mode
OSSR: u1 = 0,
/// BKE [12:12]
/// Break enable
BKE: u1 = 0,
/// BKP [13:13]
/// Break polarity
BKP: u1 = 0,
/// AOE [14:14]
/// Automatic output enable
AOE: u1 = 0,
/// MOE [15:15]
/// Main output enable
MOE: u1 = 0,
/// BKF [16:19]
/// Break filter
BKF: u4 = 0,
/// BK2F [20:23]
/// Break 2 filter
BK2F: u4 = 0,
/// BK2E [24:24]
/// Break 2 enable
BK2E: u1 = 0,
/// BK2P [25:25]
/// Break 2 polarity
BK2P: u1 = 0,
/// unused [26:31]
_unused26: u6 = 0,
};
/// break and dead-time register
pub const BDTR = Register(BDTR_val).init(base_address + 0x44);
/// DCR
const DCR_val = packed struct {
/// DBA [0:4]
/// DMA base address
DBA: u5 = 0,
/// unused [5:7]
_unused5: u3 = 0,
/// DBL [8:12]
/// DMA burst length
DBL: u5 = 0,
/// unused [13:31]
_unused13: u3 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA control register
pub const DCR = Register(DCR_val).init(base_address + 0x48);
/// DMAR
const DMAR_val = packed struct {
/// DMAB [0:15]
/// DMA register for burst accesses
DMAB: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA address for full transfer
pub const DMAR = Register(DMAR_val).init(base_address + 0x4c);
/// CCMR3_Output
const CCMR3_Output_val = packed struct {
/// unused [0:1]
_unused0: u2 = 0,
/// OC5FE [2:2]
/// Output compare 5 fast enable
OC5FE: u1 = 0,
/// OC5PE [3:3]
/// Output compare 5 preload enable
OC5PE: u1 = 0,
/// OC5M [4:6]
/// Output compare 5 mode
OC5M: u3 = 0,
/// OC5CE [7:7]
/// Output compare 5 clear enable
OC5CE: u1 = 0,
/// unused [8:9]
_unused8: u2 = 0,
/// OC6FE [10:10]
/// Output compare 6 fast enable
OC6FE: u1 = 0,
/// OC6PE [11:11]
/// Output compare 6 preload enable
OC6PE: u1 = 0,
/// OC6M [12:14]
/// Output compare 6 mode
OC6M: u3 = 0,
/// OC6CE [15:15]
/// Output compare 6 clear enable
OC6CE: u1 = 0,
/// OC5M_3 [16:16]
/// Outout Compare 5 mode bit 3
OC5M_3: u1 = 0,
/// unused [17:23]
_unused17: u7 = 0,
/// OC6M_3 [24:24]
/// Outout Compare 6 mode bit 3
OC6M_3: u1 = 0,
/// unused [25:31]
_unused25: u7 = 0,
};
/// capture/compare mode register 3 (output mode)
pub const CCMR3_Output = Register(CCMR3_Output_val).init(base_address + 0x54);
/// CCR5
const CCR5_val = packed struct {
/// CCR5 [0:15]
/// Capture/Compare 5 value
CCR5: u16 = 0,
/// unused [16:28]
_unused16: u8 = 0,
_unused24: u5 = 0,
/// GC5C1 [29:29]
/// Group Channel 5 and Channel 1
GC5C1: u1 = 0,
/// GC5C2 [30:30]
/// Group Channel 5 and Channel 2
GC5C2: u1 = 0,
/// GC5C3 [31:31]
/// Group Channel 5 and Channel 3
GC5C3: u1 = 0,
};
/// capture/compare register 5
pub const CCR5 = Register(CCR5_val).init(base_address + 0x58);
/// CCR6
const CCR6_val = packed struct {
/// CCR6 [0:15]
/// Capture/Compare 6 value
CCR6: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// capture/compare register 6
pub const CCR6 = Register(CCR6_val).init(base_address + 0x5c);
/// OR
const OR_val = packed struct {
/// TIM1_ETR_ADC1_RMP [0:1]
/// TIM1_ETR_ADC1 remapping capability
TIM1_ETR_ADC1_RMP: u2 = 0,
/// TIM1_ETR_ADC4_RMP [2:3]
/// TIM1_ETR_ADC4 remapping capability
TIM1_ETR_ADC4_RMP: u2 = 0,
/// unused [4:31]
_unused4: u4 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// option registers
pub const OR = Register(OR_val).init(base_address + 0x60);
};
/// Advanced-timers
pub const TIM8 = struct {
const base_address = 0x40013400;
/// CR1
const CR1_val = packed struct {
/// CEN [0:0]
/// Counter enable
CEN: u1 = 0,
/// UDIS [1:1]
/// Update disable
UDIS: u1 = 0,
/// URS [2:2]
/// Update request source
URS: u1 = 0,
/// OPM [3:3]
/// One-pulse mode
OPM: u1 = 0,
/// DIR [4:4]
/// Direction
DIR: u1 = 0,
/// CMS [5:6]
/// Center-aligned mode selection
CMS: u2 = 0,
/// ARPE [7:7]
/// Auto-reload preload enable
ARPE: u1 = 0,
/// CKD [8:9]
/// Clock division
CKD: u2 = 0,
/// unused [10:10]
_unused10: u1 = 0,
/// UIFREMAP [11:11]
/// UIF status bit remapping
UIFREMAP: u1 = 0,
/// unused [12:31]
_unused12: u4 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// control register 1
pub const CR1 = Register(CR1_val).init(base_address + 0x0);
/// CR2
const CR2_val = packed struct {
/// CCPC [0:0]
/// Capture/compare preloaded control
CCPC: u1 = 0,
/// unused [1:1]
_unused1: u1 = 0,
/// CCUS [2:2]
/// Capture/compare control update selection
CCUS: u1 = 0,
/// CCDS [3:3]
/// Capture/compare DMA selection
CCDS: u1 = 0,
/// MMS [4:6]
/// Master mode selection
MMS: u3 = 0,
/// TI1S [7:7]
/// TI1 selection
TI1S: u1 = 0,
/// OIS1 [8:8]
/// Output Idle state 1
OIS1: u1 = 0,
/// OIS1N [9:9]
/// Output Idle state 1
OIS1N: u1 = 0,
/// OIS2 [10:10]
/// Output Idle state 2
OIS2: u1 = 0,
/// OIS2N [11:11]
/// Output Idle state 2
OIS2N: u1 = 0,
/// OIS3 [12:12]
/// Output Idle state 3
OIS3: u1 = 0,
/// OIS3N [13:13]
/// Output Idle state 3
OIS3N: u1 = 0,
/// OIS4 [14:14]
/// Output Idle state 4
OIS4: u1 = 0,
/// unused [15:15]
_unused15: u1 = 0,
/// OIS5 [16:16]
/// Output Idle state 5
OIS5: u1 = 0,
/// unused [17:17]
_unused17: u1 = 0,
/// OIS6 [18:18]
/// Output Idle state 6
OIS6: u1 = 0,
/// unused [19:19]
_unused19: u1 = 0,
/// MMS2 [20:23]
/// Master mode selection 2
MMS2: u4 = 0,
/// unused [24:31]
_unused24: u8 = 0,
};
/// control register 2
pub const CR2 = Register(CR2_val).init(base_address + 0x4);
/// SMCR
const SMCR_val = packed struct {
/// SMS [0:2]
/// Slave mode selection
SMS: u3 = 0,
/// OCCS [3:3]
/// OCREF clear selection
OCCS: u1 = 0,
/// TS [4:6]
/// Trigger selection
TS: u3 = 0,
/// MSM [7:7]
/// Master/Slave mode
MSM: u1 = 0,
/// ETF [8:11]
/// External trigger filter
ETF: u4 = 0,
/// ETPS [12:13]
/// External trigger prescaler
ETPS: u2 = 0,
/// ECE [14:14]
/// External clock enable
ECE: u1 = 0,
/// ETP [15:15]
/// External trigger polarity
ETP: u1 = 0,
/// SMS3 [16:16]
/// Slave mode selection bit 3
SMS3: u1 = 0,
/// unused [17:31]
_unused17: u7 = 0,
_unused24: u8 = 0,
};
/// slave mode control register
pub const SMCR = Register(SMCR_val).init(base_address + 0x8);
/// DIER
const DIER_val = packed struct {
/// UIE [0:0]
/// Update interrupt enable
UIE: u1 = 0,
/// CC1IE [1:1]
/// Capture/Compare 1 interrupt enable
CC1IE: u1 = 0,
/// CC2IE [2:2]
/// Capture/Compare 2 interrupt enable
CC2IE: u1 = 0,
/// CC3IE [3:3]
/// Capture/Compare 3 interrupt enable
CC3IE: u1 = 0,
/// CC4IE [4:4]
/// Capture/Compare 4 interrupt enable
CC4IE: u1 = 0,
/// COMIE [5:5]
/// COM interrupt enable
COMIE: u1 = 0,
/// TIE [6:6]
/// Trigger interrupt enable
TIE: u1 = 0,
/// BIE [7:7]
/// Break interrupt enable
BIE: u1 = 0,
/// UDE [8:8]
/// Update DMA request enable
UDE: u1 = 0,
/// CC1DE [9:9]
/// Capture/Compare 1 DMA request enable
CC1DE: u1 = 0,
/// CC2DE [10:10]
/// Capture/Compare 2 DMA request enable
CC2DE: u1 = 0,
/// CC3DE [11:11]
/// Capture/Compare 3 DMA request enable
CC3DE: u1 = 0,
/// CC4DE [12:12]
/// Capture/Compare 4 DMA request enable
CC4DE: u1 = 0,
/// COMDE [13:13]
/// Reserved
COMDE: u1 = 0,
/// TDE [14:14]
/// Trigger DMA request enable
TDE: u1 = 0,
/// unused [15:31]
_unused15: u1 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA/Interrupt enable register
pub const DIER = Register(DIER_val).init(base_address + 0xc);
/// SR
const SR_val = packed struct {
/// UIF [0:0]
/// Update interrupt flag
UIF: u1 = 0,
/// CC1IF [1:1]
/// Capture/compare 1 interrupt flag
CC1IF: u1 = 0,
/// CC2IF [2:2]
/// Capture/Compare 2 interrupt flag
CC2IF: u1 = 0,
/// CC3IF [3:3]
/// Capture/Compare 3 interrupt flag
CC3IF: u1 = 0,
/// CC4IF [4:4]
/// Capture/Compare 4 interrupt flag
CC4IF: u1 = 0,
/// COMIF [5:5]
/// COM interrupt flag
COMIF: u1 = 0,
/// TIF [6:6]
/// Trigger interrupt flag
TIF: u1 = 0,
/// BIF [7:7]
/// Break interrupt flag
BIF: u1 = 0,
/// B2IF [8:8]
/// Break 2 interrupt flag
B2IF: u1 = 0,
/// CC1OF [9:9]
/// Capture/Compare 1 overcapture flag
CC1OF: u1 = 0,
/// CC2OF [10:10]
/// Capture/compare 2 overcapture flag
CC2OF: u1 = 0,
/// CC3OF [11:11]
/// Capture/Compare 3 overcapture flag
CC3OF: u1 = 0,
/// CC4OF [12:12]
/// Capture/Compare 4 overcapture flag
CC4OF: u1 = 0,
/// unused [13:15]
_unused13: u3 = 0,
/// C5IF [16:16]
/// Capture/Compare 5 interrupt flag
C5IF: u1 = 0,
/// C6IF [17:17]
/// Capture/Compare 6 interrupt flag
C6IF: u1 = 0,
/// unused [18:31]
_unused18: u6 = 0,
_unused24: u8 = 0,
};
/// status register
pub const SR = Register(SR_val).init(base_address + 0x10);
/// EGR
const EGR_val = packed struct {
/// UG [0:0]
/// Update generation
UG: u1 = 0,
/// CC1G [1:1]
/// Capture/compare 1 generation
CC1G: u1 = 0,
/// CC2G [2:2]
/// Capture/compare 2 generation
CC2G: u1 = 0,
/// CC3G [3:3]
/// Capture/compare 3 generation
CC3G: u1 = 0,
/// CC4G [4:4]
/// Capture/compare 4 generation
CC4G: u1 = 0,
/// COMG [5:5]
/// Capture/Compare control update generation
COMG: u1 = 0,
/// TG [6:6]
/// Trigger generation
TG: u1 = 0,
/// BG [7:7]
/// Break generation
BG: u1 = 0,
/// B2G [8:8]
/// Break 2 generation
B2G: u1 = 0,
/// unused [9:31]
_unused9: u7 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// event generation register
pub const EGR = Register(EGR_val).init(base_address + 0x14);
/// CCMR1_Output
const CCMR1_Output_val = packed struct {
/// CC1S [0:1]
/// Capture/Compare 1 selection
CC1S: u2 = 0,
/// OC1FE [2:2]
/// Output Compare 1 fast enable
OC1FE: u1 = 0,
/// OC1PE [3:3]
/// Output Compare 1 preload enable
OC1PE: u1 = 0,
/// OC1M [4:6]
/// Output Compare 1 mode
OC1M: u3 = 0,
/// OC1CE [7:7]
/// Output Compare 1 clear enable
OC1CE: u1 = 0,
/// CC2S [8:9]
/// Capture/Compare 2 selection
CC2S: u2 = 0,
/// OC2FE [10:10]
/// Output Compare 2 fast enable
OC2FE: u1 = 0,
/// OC2PE [11:11]
/// Output Compare 2 preload enable
OC2PE: u1 = 0,
/// OC2M [12:14]
/// Output Compare 2 mode
OC2M: u3 = 0,
/// OC2CE [15:15]
/// Output Compare 2 clear enable
OC2CE: u1 = 0,
/// OC1M_3 [16:16]
/// Output Compare 1 mode bit 3
OC1M_3: u1 = 0,
/// unused [17:23]
_unused17: u7 = 0,
/// OC2M_3 [24:24]
/// Output Compare 2 mode bit 3
OC2M_3: u1 = 0,
/// unused [25:31]
_unused25: u7 = 0,
};
/// capture/compare mode register (output mode)
pub const CCMR1_Output = Register(CCMR1_Output_val).init(base_address + 0x18);
/// CCMR1_Input
const CCMR1_Input_val = packed struct {
/// CC1S [0:1]
/// Capture/Compare 1 selection
CC1S: u2 = 0,
/// IC1PCS [2:3]
/// Input capture 1 prescaler
IC1PCS: u2 = 0,
/// IC1F [4:7]
/// Input capture 1 filter
IC1F: u4 = 0,
/// CC2S [8:9]
/// Capture/Compare 2 selection
CC2S: u2 = 0,
/// IC2PCS [10:11]
/// Input capture 2 prescaler
IC2PCS: u2 = 0,
/// IC2F [12:15]
/// Input capture 2 filter
IC2F: u4 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// capture/compare mode register 1 (input mode)
pub const CCMR1_Input = Register(CCMR1_Input_val).init(base_address + 0x18);
/// CCMR2_Output
const CCMR2_Output_val = packed struct {
/// CC3S [0:1]
/// Capture/Compare 3 selection
CC3S: u2 = 0,
/// OC3FE [2:2]
/// Output compare 3 fast enable
OC3FE: u1 = 0,
/// OC3PE [3:3]
/// Output compare 3 preload enable
OC3PE: u1 = 0,
/// OC3M [4:6]
/// Output compare 3 mode
OC3M: u3 = 0,
/// OC3CE [7:7]
/// Output compare 3 clear enable
OC3CE: u1 = 0,
/// CC4S [8:9]
/// Capture/Compare 4 selection
CC4S: u2 = 0,
/// OC4FE [10:10]
/// Output compare 4 fast enable
OC4FE: u1 = 0,
/// OC4PE [11:11]
/// Output compare 4 preload enable
OC4PE: u1 = 0,
/// OC4M [12:14]
/// Output compare 4 mode
OC4M: u3 = 0,
/// OC4CE [15:15]
/// Output compare 4 clear enable
OC4CE: u1 = 0,
/// OC3M_3 [16:16]
/// Output Compare 3 mode bit 3
OC3M_3: u1 = 0,
/// unused [17:23]
_unused17: u7 = 0,
/// OC4M_3 [24:24]
/// Output Compare 4 mode bit 3
OC4M_3: u1 = 0,
/// unused [25:31]
_unused25: u7 = 0,
};
/// capture/compare mode register (output mode)
pub const CCMR2_Output = Register(CCMR2_Output_val).init(base_address + 0x1c);
/// CCMR2_Input
const CCMR2_Input_val = packed struct {
/// CC3S [0:1]
/// Capture/compare 3 selection
CC3S: u2 = 0,
/// IC3PSC [2:3]
/// Input capture 3 prescaler
IC3PSC: u2 = 0,
/// IC3F [4:7]
/// Input capture 3 filter
IC3F: u4 = 0,
/// CC4S [8:9]
/// Capture/Compare 4 selection
CC4S: u2 = 0,
/// IC4PSC [10:11]
/// Input capture 4 prescaler
IC4PSC: u2 = 0,
/// IC4F [12:15]
/// Input capture 4 filter
IC4F: u4 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// capture/compare mode register 2 (input mode)
pub const CCMR2_Input = Register(CCMR2_Input_val).init(base_address + 0x1c);
/// CCER
const CCER_val = packed struct {
/// CC1E [0:0]
/// Capture/Compare 1 output enable
CC1E: u1 = 0,
/// CC1P [1:1]
/// Capture/Compare 1 output Polarity
CC1P: u1 = 0,
/// CC1NE [2:2]
/// Capture/Compare 1 complementary output enable
CC1NE: u1 = 0,
/// CC1NP [3:3]
/// Capture/Compare 1 output Polarity
CC1NP: u1 = 0,
/// CC2E [4:4]
/// Capture/Compare 2 output enable
CC2E: u1 = 0,
/// CC2P [5:5]
/// Capture/Compare 2 output Polarity
CC2P: u1 = 0,
/// CC2NE [6:6]
/// Capture/Compare 2 complementary output enable
CC2NE: u1 = 0,
/// CC2NP [7:7]
/// Capture/Compare 2 output Polarity
CC2NP: u1 = 0,
/// CC3E [8:8]
/// Capture/Compare 3 output enable
CC3E: u1 = 0,
/// CC3P [9:9]
/// Capture/Compare 3 output Polarity
CC3P: u1 = 0,
/// CC3NE [10:10]
/// Capture/Compare 3 complementary output enable
CC3NE: u1 = 0,
/// CC3NP [11:11]
/// Capture/Compare 3 output Polarity
CC3NP: u1 = 0,
/// CC4E [12:12]
/// Capture/Compare 4 output enable
CC4E: u1 = 0,
/// CC4P [13:13]
/// Capture/Compare 3 output Polarity
CC4P: u1 = 0,
/// unused [14:14]
_unused14: u1 = 0,
/// CC4NP [15:15]
/// Capture/Compare 4 output Polarity
CC4NP: u1 = 0,
/// CC5E [16:16]
/// Capture/Compare 5 output enable
CC5E: u1 = 0,
/// CC5P [17:17]
/// Capture/Compare 5 output Polarity
CC5P: u1 = 0,
/// unused [18:19]
_unused18: u2 = 0,
/// CC6E [20:20]
/// Capture/Compare 6 output enable
CC6E: u1 = 0,
/// CC6P [21:21]
/// Capture/Compare 6 output Polarity
CC6P: u1 = 0,
/// unused [22:31]
_unused22: u2 = 0,
_unused24: u8 = 0,
};
/// capture/compare enable register
pub const CCER = Register(CCER_val).init(base_address + 0x20);
/// CNT
const CNT_val = packed struct {
/// CNT [0:15]
/// counter value
CNT: u16 = 0,
/// unused [16:30]
_unused16: u8 = 0,
_unused24: u7 = 0,
/// UIFCPY [31:31]
/// UIF copy
UIFCPY: u1 = 0,
};
/// counter
pub const CNT = Register(CNT_val).init(base_address + 0x24);
/// PSC
const PSC_val = packed struct {
/// PSC [0:15]
/// Prescaler value
PSC: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// prescaler
pub const PSC = Register(PSC_val).init(base_address + 0x28);
/// ARR
const ARR_val = packed struct {
/// ARR [0:15]
/// Auto-reload value
ARR: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// auto-reload register
pub const ARR = Register(ARR_val).init(base_address + 0x2c);
/// RCR
const RCR_val = packed struct {
/// REP [0:15]
/// Repetition counter value
REP: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// repetition counter register
pub const RCR = Register(RCR_val).init(base_address + 0x30);
/// CCR1
const CCR1_val = packed struct {
/// CCR1 [0:15]
/// Capture/Compare 1 value
CCR1: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// capture/compare register 1
pub const CCR1 = Register(CCR1_val).init(base_address + 0x34);
/// CCR2
const CCR2_val = packed struct {
/// CCR2 [0:15]
/// Capture/Compare 2 value
CCR2: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// capture/compare register 2
pub const CCR2 = Register(CCR2_val).init(base_address + 0x38);
/// CCR3
const CCR3_val = packed struct {
/// CCR3 [0:15]
/// Capture/Compare 3 value
CCR3: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// capture/compare register 3
pub const CCR3 = Register(CCR3_val).init(base_address + 0x3c);
/// CCR4
const CCR4_val = packed struct {
/// CCR4 [0:15]
/// Capture/Compare 3 value
CCR4: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// capture/compare register 4
pub const CCR4 = Register(CCR4_val).init(base_address + 0x40);
/// BDTR
const BDTR_val = packed struct {
/// DTG [0:7]
/// Dead-time generator setup
DTG: u8 = 0,
/// LOCK [8:9]
/// Lock configuration
LOCK: u2 = 0,
/// OSSI [10:10]
/// Off-state selection for Idle mode
OSSI: u1 = 0,
/// OSSR [11:11]
/// Off-state selection for Run mode
OSSR: u1 = 0,
/// BKE [12:12]
/// Break enable
BKE: u1 = 0,
/// BKP [13:13]
/// Break polarity
BKP: u1 = 0,
/// AOE [14:14]
/// Automatic output enable
AOE: u1 = 0,
/// MOE [15:15]
/// Main output enable
MOE: u1 = 0,
/// BKF [16:19]
/// Break filter
BKF: u4 = 0,
/// BK2F [20:23]
/// Break 2 filter
BK2F: u4 = 0,
/// BK2E [24:24]
/// Break 2 enable
BK2E: u1 = 0,
/// BK2P [25:25]
/// Break 2 polarity
BK2P: u1 = 0,
/// unused [26:31]
_unused26: u6 = 0,
};
/// break and dead-time register
pub const BDTR = Register(BDTR_val).init(base_address + 0x44);
/// DCR
const DCR_val = packed struct {
/// DBA [0:4]
/// DMA base address
DBA: u5 = 0,
/// unused [5:7]
_unused5: u3 = 0,
/// DBL [8:12]
/// DMA burst length
DBL: u5 = 0,
/// unused [13:31]
_unused13: u3 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA control register
pub const DCR = Register(DCR_val).init(base_address + 0x48);
/// DMAR
const DMAR_val = packed struct {
/// DMAB [0:15]
/// DMA register for burst accesses
DMAB: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// DMA address for full transfer
pub const DMAR = Register(DMAR_val).init(base_address + 0x4c);
/// CCMR3_Output
const CCMR3_Output_val = packed struct {
/// unused [0:1]
_unused0: u2 = 0,
/// OC5FE [2:2]
/// Output compare 5 fast enable
OC5FE: u1 = 0,
/// OC5PE [3:3]
/// Output compare 5 preload enable
OC5PE: u1 = 0,
/// OC5M [4:6]
/// Output compare 5 mode
OC5M: u3 = 0,
/// OC5CE [7:7]
/// Output compare 5 clear enable
OC5CE: u1 = 0,
/// unused [8:9]
_unused8: u2 = 0,
/// OC6FE [10:10]
/// Output compare 6 fast enable
OC6FE: u1 = 0,
/// OC6PE [11:11]
/// Output compare 6 preload enable
OC6PE: u1 = 0,
/// OC6M [12:14]
/// Output compare 6 mode
OC6M: u3 = 0,
/// OC6CE [15:15]
/// Output compare 6 clear enable
OC6CE: u1 = 0,
/// OC5M_3 [16:16]
/// Outout Compare 5 mode bit 3
OC5M_3: u1 = 0,
/// unused [17:23]
_unused17: u7 = 0,
/// OC6M_3 [24:24]
/// Outout Compare 6 mode bit 3
OC6M_3: u1 = 0,
/// unused [25:31]
_unused25: u7 = 0,
};
/// capture/compare mode register 3 (output mode)
pub const CCMR3_Output = Register(CCMR3_Output_val).init(base_address + 0x54);
/// CCR5
const CCR5_val = packed struct {
/// CCR5 [0:15]
/// Capture/Compare 5 value
CCR5: u16 = 0,
/// unused [16:28]
_unused16: u8 = 0,
_unused24: u5 = 0,
/// GC5C1 [29:29]
/// Group Channel 5 and Channel 1
GC5C1: u1 = 0,
/// GC5C2 [30:30]
/// Group Channel 5 and Channel 2
GC5C2: u1 = 0,
/// GC5C3 [31:31]
/// Group Channel 5 and Channel 3
GC5C3: u1 = 0,
};
/// capture/compare register 5
pub const CCR5 = Register(CCR5_val).init(base_address + 0x58);
/// CCR6
const CCR6_val = packed struct {
/// CCR6 [0:15]
/// Capture/Compare 6 value
CCR6: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// capture/compare register 6
pub const CCR6 = Register(CCR6_val).init(base_address + 0x5c);
/// OR
const OR_val = packed struct {
/// TIM8_ETR_ADC2_RMP [0:1]
/// TIM8_ETR_ADC2 remapping capability
TIM8_ETR_ADC2_RMP: u2 = 0,
/// TIM8_ETR_ADC3_RMP [2:3]
/// TIM8_ETR_ADC3 remapping capability
TIM8_ETR_ADC3_RMP: u2 = 0,
/// unused [4:31]
_unused4: u4 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// option registers
pub const OR = Register(OR_val).init(base_address + 0x60);
};
/// Analog-to-Digital Converter
pub const ADC1 = struct {
const base_address = 0x50000000;
/// ISR
const ISR_val = packed struct {
/// ADRDY [0:0]
/// ADRDY
ADRDY: u1 = 0,
/// EOSMP [1:1]
/// EOSMP
EOSMP: u1 = 0,
/// EOC [2:2]
/// EOC
EOC: u1 = 0,
/// EOS [3:3]
/// EOS
EOS: u1 = 0,
/// OVR [4:4]
/// OVR
OVR: u1 = 0,
/// JEOC [5:5]
/// JEOC
JEOC: u1 = 0,
/// JEOS [6:6]
/// JEOS
JEOS: u1 = 0,
/// AWD1 [7:7]
/// AWD1
AWD1: u1 = 0,
/// AWD2 [8:8]
/// AWD2
AWD2: u1 = 0,
/// AWD3 [9:9]
/// AWD3
AWD3: u1 = 0,
/// JQOVF [10:10]
/// JQOVF
JQOVF: u1 = 0,
/// unused [11:31]
_unused11: u5 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// interrupt and status register
pub const ISR = Register(ISR_val).init(base_address + 0x0);
/// IER
const IER_val = packed struct {
/// ADRDYIE [0:0]
/// ADRDYIE
ADRDYIE: u1 = 0,
/// EOSMPIE [1:1]
/// EOSMPIE
EOSMPIE: u1 = 0,
/// EOCIE [2:2]
/// EOCIE
EOCIE: u1 = 0,
/// EOSIE [3:3]
/// EOSIE
EOSIE: u1 = 0,
/// OVRIE [4:4]
/// OVRIE
OVRIE: u1 = 0,
/// JEOCIE [5:5]
/// JEOCIE
JEOCIE: u1 = 0,
/// JEOSIE [6:6]
/// JEOSIE
JEOSIE: u1 = 0,
/// AWD1IE [7:7]
/// AWD1IE
AWD1IE: u1 = 0,
/// AWD2IE [8:8]
/// AWD2IE
AWD2IE: u1 = 0,
/// AWD3IE [9:9]
/// AWD3IE
AWD3IE: u1 = 0,
/// JQOVFIE [10:10]
/// JQOVFIE
JQOVFIE: u1 = 0,
/// unused [11:31]
_unused11: u5 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// interrupt enable register
pub const IER = Register(IER_val).init(base_address + 0x4);
/// CR
const CR_val = packed struct {
/// ADEN [0:0]
/// ADEN
ADEN: u1 = 0,
/// ADDIS [1:1]
/// ADDIS
ADDIS: u1 = 0,
/// ADSTART [2:2]
/// ADSTART
ADSTART: u1 = 0,
/// JADSTART [3:3]
/// JADSTART
JADSTART: u1 = 0,
/// ADSTP [4:4]
/// ADSTP
ADSTP: u1 = 0,
/// JADSTP [5:5]
/// JADSTP
JADSTP: u1 = 0,
/// unused [6:27]
_unused6: u2 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u4 = 0,
/// ADVREGEN [28:28]
/// ADVREGEN
ADVREGEN: u1 = 0,
/// DEEPPWD [29:29]
/// DEEPPWD
DEEPPWD: u1 = 0,
/// ADCALDIF [30:30]
/// ADCALDIF
ADCALDIF: u1 = 0,
/// ADCAL [31:31]
/// ADCAL
ADCAL: u1 = 0,
};
/// control register
pub const CR = Register(CR_val).init(base_address + 0x8);
/// CFGR
const CFGR_val = packed struct {
/// DMAEN [0:0]
/// DMAEN
DMAEN: u1 = 0,
/// DMACFG [1:1]
/// DMACFG
DMACFG: u1 = 0,
/// unused [2:2]
_unused2: u1 = 0,
/// RES [3:4]
/// RES
RES: u2 = 0,
/// ALIGN [5:5]
/// ALIGN
ALIGN: u1 = 0,
/// EXTSEL [6:9]
/// EXTSEL
EXTSEL: u4 = 0,
/// EXTEN [10:11]
/// EXTEN
EXTEN: u2 = 0,
/// OVRMOD [12:12]
/// OVRMOD
OVRMOD: u1 = 0,
/// CONT [13:13]
/// CONT
CONT: u1 = 0,
/// AUTDLY [14:14]
/// AUTDLY
AUTDLY: u1 = 0,
/// AUTOFF [15:15]
/// AUTOFF
AUTOFF: u1 = 0,
/// DISCEN [16:16]
/// DISCEN
DISCEN: u1 = 0,
/// DISCNUM [17:19]
/// DISCNUM
DISCNUM: u3 = 0,
/// JDISCEN [20:20]
/// JDISCEN
JDISCEN: u1 = 0,
/// JQM [21:21]
/// JQM
JQM: u1 = 0,
/// AWD1SGL [22:22]
/// AWD1SGL
AWD1SGL: u1 = 0,
/// AWD1EN [23:23]
/// AWD1EN
AWD1EN: u1 = 0,
/// JAWD1EN [24:24]
/// JAWD1EN
JAWD1EN: u1 = 0,
/// JAUTO [25:25]
/// JAUTO
JAUTO: u1 = 0,
/// AWDCH1CH [26:30]
/// AWDCH1CH
AWDCH1CH: u5 = 0,
/// unused [31:31]
_unused31: u1 = 0,
};
/// configuration register
pub const CFGR = Register(CFGR_val).init(base_address + 0xc);
/// SMPR1
const SMPR1_val = packed struct {
/// unused [0:2]
_unused0: u3 = 0,
/// SMP1 [3:5]
/// SMP1
SMP1: u3 = 0,
/// SMP2 [6:8]
/// SMP2
SMP2: u3 = 0,
/// SMP3 [9:11]
/// SMP3
SMP3: u3 = 0,
/// SMP4 [12:14]
/// SMP4
SMP4: u3 = 0,
/// SMP5 [15:17]
/// SMP5
SMP5: u3 = 0,
/// SMP6 [18:20]
/// SMP6
SMP6: u3 = 0,
/// SMP7 [21:23]
/// SMP7
SMP7: u3 = 0,
/// SMP8 [24:26]
/// SMP8
SMP8: u3 = 0,
/// SMP9 [27:29]
/// SMP9
SMP9: u3 = 0,
/// unused [30:31]
_unused30: u2 = 0,
};
/// sample time register 1
pub const SMPR1 = Register(SMPR1_val).init(base_address + 0x14);
/// SMPR2
const SMPR2_val = packed struct {
/// SMP10 [0:2]
/// SMP10
SMP10: u3 = 0,
/// SMP11 [3:5]
/// SMP11
SMP11: u3 = 0,
/// SMP12 [6:8]
/// SMP12
SMP12: u3 = 0,
/// SMP13 [9:11]
/// SMP13
SMP13: u3 = 0,
/// SMP14 [12:14]
/// SMP14
SMP14: u3 = 0,
/// SMP15 [15:17]
/// SMP15
SMP15: u3 = 0,
/// SMP16 [18:20]
/// SMP16
SMP16: u3 = 0,
/// SMP17 [21:23]
/// SMP17
SMP17: u3 = 0,
/// SMP18 [24:26]
/// SMP18
SMP18: u3 = 0,
/// unused [27:31]
_unused27: u5 = 0,
};
/// sample time register 2
pub const SMPR2 = Register(SMPR2_val).init(base_address + 0x18);
/// TR1
const TR1_val = packed struct {
/// LT1 [0:11]
/// LT1
LT1: u12 = 0,
/// unused [12:15]
_unused12: u4 = 0,
/// HT1 [16:27]
/// HT1
HT1: u12 = 4095,
/// unused [28:31]
_unused28: u4 = 0,
};
/// watchdog threshold register 1
pub const TR1 = Register(TR1_val).init(base_address + 0x20);
/// TR2
const TR2_val = packed struct {
/// LT2 [0:7]
/// LT2
LT2: u8 = 0,
/// unused [8:15]
_unused8: u8 = 0,
/// HT2 [16:23]
/// HT2
HT2: u8 = 255,
/// unused [24:31]
_unused24: u8 = 15,
};
/// watchdog threshold register
pub const TR2 = Register(TR2_val).init(base_address + 0x24);
/// TR3
const TR3_val = packed struct {
/// LT3 [0:7]
/// LT3
LT3: u8 = 0,
/// unused [8:15]
_unused8: u8 = 0,
/// HT3 [16:23]
/// HT3
HT3: u8 = 255,
/// unused [24:31]
_unused24: u8 = 15,
};
/// watchdog threshold register 3
pub const TR3 = Register(TR3_val).init(base_address + 0x28);
/// SQR1
const SQR1_val = packed struct {
/// L3 [0:3]
/// L3
L3: u4 = 0,
/// unused [4:5]
_unused4: u2 = 0,
/// SQ1 [6:10]
/// SQ1
SQ1: u5 = 0,
/// unused [11:11]
_unused11: u1 = 0,
/// SQ2 [12:16]
/// SQ2
SQ2: u5 = 0,
/// unused [17:17]
_unused17: u1 = 0,
/// SQ3 [18:22]
/// SQ3
SQ3: u5 = 0,
/// unused [23:23]
_unused23: u1 = 0,
/// SQ4 [24:28]
/// SQ4
SQ4: u5 = 0,
/// unused [29:31]
_unused29: u3 = 0,
};
/// regular sequence register 1
pub const SQR1 = Register(SQR1_val).init(base_address + 0x30);
/// SQR2
const SQR2_val = packed struct {
/// SQ5 [0:4]
/// SQ5
SQ5: u5 = 0,
/// unused [5:5]
_unused5: u1 = 0,
/// SQ6 [6:10]
/// SQ6
SQ6: u5 = 0,
/// unused [11:11]
_unused11: u1 = 0,
/// SQ7 [12:16]
/// SQ7
SQ7: u5 = 0,
/// unused [17:17]
_unused17: u1 = 0,
/// SQ8 [18:22]
/// SQ8
SQ8: u5 = 0,
/// unused [23:23]
_unused23: u1 = 0,
/// SQ9 [24:28]
/// SQ9
SQ9: u5 = 0,
/// unused [29:31]
_unused29: u3 = 0,
};
/// regular sequence register 2
pub const SQR2 = Register(SQR2_val).init(base_address + 0x34);
/// SQR3
const SQR3_val = packed struct {
/// SQ10 [0:4]
/// SQ10
SQ10: u5 = 0,
/// unused [5:5]
_unused5: u1 = 0,
/// SQ11 [6:10]
/// SQ11
SQ11: u5 = 0,
/// unused [11:11]
_unused11: u1 = 0,
/// SQ12 [12:16]
/// SQ12
SQ12: u5 = 0,
/// unused [17:17]
_unused17: u1 = 0,
/// SQ13 [18:22]
/// SQ13
SQ13: u5 = 0,
/// unused [23:23]
_unused23: u1 = 0,
/// SQ14 [24:28]
/// SQ14
SQ14: u5 = 0,
/// unused [29:31]
_unused29: u3 = 0,
};
/// regular sequence register 3
pub const SQR3 = Register(SQR3_val).init(base_address + 0x38);
/// SQR4
const SQR4_val = packed struct {
/// SQ15 [0:4]
/// SQ15
SQ15: u5 = 0,
/// unused [5:5]
_unused5: u1 = 0,
/// SQ16 [6:10]
/// SQ16
SQ16: u5 = 0,
/// unused [11:31]
_unused11: u5 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// regular sequence register 4
pub const SQR4 = Register(SQR4_val).init(base_address + 0x3c);
/// DR
const DR_val = packed struct {
/// regularDATA [0:15]
/// regularDATA
regularDATA: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// regular Data Register
pub const DR = Register(DR_val).init(base_address + 0x40);
/// JSQR
const JSQR_val = packed struct {
/// JL [0:1]
/// JL
JL: u2 = 0,
/// JEXTSEL [2:5]
/// JEXTSEL
JEXTSEL: u4 = 0,
/// JEXTEN [6:7]
/// JEXTEN
JEXTEN: u2 = 0,
/// JSQ1 [8:12]
/// JSQ1
JSQ1: u5 = 0,
/// unused [13:13]
_unused13: u1 = 0,
/// JSQ2 [14:18]
/// JSQ2
JSQ2: u5 = 0,
/// unused [19:19]
_unused19: u1 = 0,
/// JSQ3 [20:24]
/// JSQ3
JSQ3: u5 = 0,
/// unused [25:25]
_unused25: u1 = 0,
/// JSQ4 [26:30]
/// JSQ4
JSQ4: u5 = 0,
/// unused [31:31]
_unused31: u1 = 0,
};
/// injected sequence register
pub const JSQR = Register(JSQR_val).init(base_address + 0x4c);
/// OFR1
const OFR1_val = packed struct {
/// OFFSET1 [0:11]
/// OFFSET1
OFFSET1: u12 = 0,
/// unused [12:25]
_unused12: u4 = 0,
_unused16: u8 = 0,
_unused24: u2 = 0,
/// OFFSET1_CH [26:30]
/// OFFSET1_CH
OFFSET1_CH: u5 = 0,
/// OFFSET1_EN [31:31]
/// OFFSET1_EN
OFFSET1_EN: u1 = 0,
};
/// offset register 1
pub const OFR1 = Register(OFR1_val).init(base_address + 0x60);
/// OFR2
const OFR2_val = packed struct {
/// OFFSET2 [0:11]
/// OFFSET2
OFFSET2: u12 = 0,
/// unused [12:25]
_unused12: u4 = 0,
_unused16: u8 = 0,
_unused24: u2 = 0,
/// OFFSET2_CH [26:30]
/// OFFSET2_CH
OFFSET2_CH: u5 = 0,
/// OFFSET2_EN [31:31]
/// OFFSET2_EN
OFFSET2_EN: u1 = 0,
};
/// offset register 2
pub const OFR2 = Register(OFR2_val).init(base_address + 0x64);
/// OFR3
const OFR3_val = packed struct {
/// OFFSET3 [0:11]
/// OFFSET3
OFFSET3: u12 = 0,
/// unused [12:25]
_unused12: u4 = 0,
_unused16: u8 = 0,
_unused24: u2 = 0,
/// OFFSET3_CH [26:30]
/// OFFSET3_CH
OFFSET3_CH: u5 = 0,
/// OFFSET3_EN [31:31]
/// OFFSET3_EN
OFFSET3_EN: u1 = 0,
};
/// offset register 3
pub const OFR3 = Register(OFR3_val).init(base_address + 0x68);
/// OFR4
const OFR4_val = packed struct {
/// OFFSET4 [0:11]
/// OFFSET4
OFFSET4: u12 = 0,
/// unused [12:25]
_unused12: u4 = 0,
_unused16: u8 = 0,
_unused24: u2 = 0,
/// OFFSET4_CH [26:30]
/// OFFSET4_CH
OFFSET4_CH: u5 = 0,
/// OFFSET4_EN [31:31]
/// OFFSET4_EN
OFFSET4_EN: u1 = 0,
};
/// offset register 4
pub const OFR4 = Register(OFR4_val).init(base_address + 0x6c);
/// JDR1
const JDR1_val = packed struct {
/// JDATA1 [0:15]
/// JDATA1
JDATA1: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// injected data register 1
pub const JDR1 = Register(JDR1_val).init(base_address + 0x80);
/// JDR2
const JDR2_val = packed struct {
/// JDATA2 [0:15]
/// JDATA2
JDATA2: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// injected data register 2
pub const JDR2 = Register(JDR2_val).init(base_address + 0x84);
/// JDR3
const JDR3_val = packed struct {
/// JDATA3 [0:15]
/// JDATA3
JDATA3: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// injected data register 3
pub const JDR3 = Register(JDR3_val).init(base_address + 0x88);
/// JDR4
const JDR4_val = packed struct {
/// JDATA4 [0:15]
/// JDATA4
JDATA4: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// injected data register 4
pub const JDR4 = Register(JDR4_val).init(base_address + 0x8c);
/// AWD2CR
const AWD2CR_val = packed struct {
/// unused [0:0]
_unused0: u1 = 0,
/// AWD2CH [1:18]
/// AWD2CH
AWD2CH: u18 = 0,
/// unused [19:31]
_unused19: u5 = 0,
_unused24: u8 = 0,
};
/// Analog Watchdog 2 Configuration Register
pub const AWD2CR = Register(AWD2CR_val).init(base_address + 0xa0);
/// AWD3CR
const AWD3CR_val = packed struct {
/// unused [0:0]
_unused0: u1 = 0,
/// AWD3CH [1:18]
/// AWD3CH
AWD3CH: u18 = 0,
/// unused [19:31]
_unused19: u5 = 0,
_unused24: u8 = 0,
};
/// Analog Watchdog 3 Configuration Register
pub const AWD3CR = Register(AWD3CR_val).init(base_address + 0xa4);
/// DIFSEL
const DIFSEL_val = packed struct {
/// unused [0:0]
_unused0: u1 = 0,
/// DIFSEL_1_15 [1:15]
/// Differential mode for channels 15 to 1
DIFSEL_1_15: u15 = 0,
/// DIFSEL_16_18 [16:18]
/// Differential mode for channels 18 to 16
DIFSEL_16_18: u3 = 0,
/// unused [19:31]
_unused19: u5 = 0,
_unused24: u8 = 0,
};
/// Differential Mode Selection Register 2
pub const DIFSEL = Register(DIFSEL_val).init(base_address + 0xb0);
/// CALFACT
const CALFACT_val = packed struct {
/// CALFACT_S [0:6]
/// CALFACT_S
CALFACT_S: u7 = 0,
/// unused [7:15]
_unused7: u1 = 0,
_unused8: u8 = 0,
/// CALFACT_D [16:22]
/// CALFACT_D
CALFACT_D: u7 = 0,
/// unused [23:31]
_unused23: u1 = 0,
_unused24: u8 = 0,
};
/// Calibration Factors
pub const CALFACT = Register(CALFACT_val).init(base_address + 0xb4);
};
/// Analog-to-Digital Converter
pub const ADC2 = struct {
const base_address = 0x50000100;
/// ISR
const ISR_val = packed struct {
/// ADRDY [0:0]
/// ADRDY
ADRDY: u1 = 0,
/// EOSMP [1:1]
/// EOSMP
EOSMP: u1 = 0,
/// EOC [2:2]
/// EOC
EOC: u1 = 0,
/// EOS [3:3]
/// EOS
EOS: u1 = 0,
/// OVR [4:4]
/// OVR
OVR: u1 = 0,
/// JEOC [5:5]
/// JEOC
JEOC: u1 = 0,
/// JEOS [6:6]
/// JEOS
JEOS: u1 = 0,
/// AWD1 [7:7]
/// AWD1
AWD1: u1 = 0,
/// AWD2 [8:8]
/// AWD2
AWD2: u1 = 0,
/// AWD3 [9:9]
/// AWD3
AWD3: u1 = 0,
/// JQOVF [10:10]
/// JQOVF
JQOVF: u1 = 0,
/// unused [11:31]
_unused11: u5 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// interrupt and status register
pub const ISR = Register(ISR_val).init(base_address + 0x0);
/// IER
const IER_val = packed struct {
/// ADRDYIE [0:0]
/// ADRDYIE
ADRDYIE: u1 = 0,
/// EOSMPIE [1:1]
/// EOSMPIE
EOSMPIE: u1 = 0,
/// EOCIE [2:2]
/// EOCIE
EOCIE: u1 = 0,
/// EOSIE [3:3]
/// EOSIE
EOSIE: u1 = 0,
/// OVRIE [4:4]
/// OVRIE
OVRIE: u1 = 0,
/// JEOCIE [5:5]
/// JEOCIE
JEOCIE: u1 = 0,
/// JEOSIE [6:6]
/// JEOSIE
JEOSIE: u1 = 0,
/// AWD1IE [7:7]
/// AWD1IE
AWD1IE: u1 = 0,
/// AWD2IE [8:8]
/// AWD2IE
AWD2IE: u1 = 0,
/// AWD3IE [9:9]
/// AWD3IE
AWD3IE: u1 = 0,
/// JQOVFIE [10:10]
/// JQOVFIE
JQOVFIE: u1 = 0,
/// unused [11:31]
_unused11: u5 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// interrupt enable register
pub const IER = Register(IER_val).init(base_address + 0x4);
/// CR
const CR_val = packed struct {
/// ADEN [0:0]
/// ADEN
ADEN: u1 = 0,
/// ADDIS [1:1]
/// ADDIS
ADDIS: u1 = 0,
/// ADSTART [2:2]
/// ADSTART
ADSTART: u1 = 0,
/// JADSTART [3:3]
/// JADSTART
JADSTART: u1 = 0,
/// ADSTP [4:4]
/// ADSTP
ADSTP: u1 = 0,
/// JADSTP [5:5]
/// JADSTP
JADSTP: u1 = 0,
/// unused [6:27]
_unused6: u2 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u4 = 0,
/// ADVREGEN [28:28]
/// ADVREGEN
ADVREGEN: u1 = 0,
/// DEEPPWD [29:29]
/// DEEPPWD
DEEPPWD: u1 = 0,
/// ADCALDIF [30:30]
/// ADCALDIF
ADCALDIF: u1 = 0,
/// ADCAL [31:31]
/// ADCAL
ADCAL: u1 = 0,
};
/// control register
pub const CR = Register(CR_val).init(base_address + 0x8);
/// CFGR
const CFGR_val = packed struct {
/// DMAEN [0:0]
/// DMAEN
DMAEN: u1 = 0,
/// DMACFG [1:1]
/// DMACFG
DMACFG: u1 = 0,
/// unused [2:2]
_unused2: u1 = 0,
/// RES [3:4]
/// RES
RES: u2 = 0,
/// ALIGN [5:5]
/// ALIGN
ALIGN: u1 = 0,
/// EXTSEL [6:9]
/// EXTSEL
EXTSEL: u4 = 0,
/// EXTEN [10:11]
/// EXTEN
EXTEN: u2 = 0,
/// OVRMOD [12:12]
/// OVRMOD
OVRMOD: u1 = 0,
/// CONT [13:13]
/// CONT
CONT: u1 = 0,
/// AUTDLY [14:14]
/// AUTDLY
AUTDLY: u1 = 0,
/// AUTOFF [15:15]
/// AUTOFF
AUTOFF: u1 = 0,
/// DISCEN [16:16]
/// DISCEN
DISCEN: u1 = 0,
/// DISCNUM [17:19]
/// DISCNUM
DISCNUM: u3 = 0,
/// JDISCEN [20:20]
/// JDISCEN
JDISCEN: u1 = 0,
/// JQM [21:21]
/// JQM
JQM: u1 = 0,
/// AWD1SGL [22:22]
/// AWD1SGL
AWD1SGL: u1 = 0,
/// AWD1EN [23:23]
/// AWD1EN
AWD1EN: u1 = 0,
/// JAWD1EN [24:24]
/// JAWD1EN
JAWD1EN: u1 = 0,
/// JAUTO [25:25]
/// JAUTO
JAUTO: u1 = 0,
/// AWDCH1CH [26:30]
/// AWDCH1CH
AWDCH1CH: u5 = 0,
/// unused [31:31]
_unused31: u1 = 0,
};
/// configuration register
pub const CFGR = Register(CFGR_val).init(base_address + 0xc);
/// SMPR1
const SMPR1_val = packed struct {
/// unused [0:2]
_unused0: u3 = 0,
/// SMP1 [3:5]
/// SMP1
SMP1: u3 = 0,
/// SMP2 [6:8]
/// SMP2
SMP2: u3 = 0,
/// SMP3 [9:11]
/// SMP3
SMP3: u3 = 0,
/// SMP4 [12:14]
/// SMP4
SMP4: u3 = 0,
/// SMP5 [15:17]
/// SMP5
SMP5: u3 = 0,
/// SMP6 [18:20]
/// SMP6
SMP6: u3 = 0,
/// SMP7 [21:23]
/// SMP7
SMP7: u3 = 0,
/// SMP8 [24:26]
/// SMP8
SMP8: u3 = 0,
/// SMP9 [27:29]
/// SMP9
SMP9: u3 = 0,
/// unused [30:31]
_unused30: u2 = 0,
};
/// sample time register 1
pub const SMPR1 = Register(SMPR1_val).init(base_address + 0x14);
/// SMPR2
const SMPR2_val = packed struct {
/// SMP10 [0:2]
/// SMP10
SMP10: u3 = 0,
/// SMP11 [3:5]
/// SMP11
SMP11: u3 = 0,
/// SMP12 [6:8]
/// SMP12
SMP12: u3 = 0,
/// SMP13 [9:11]
/// SMP13
SMP13: u3 = 0,
/// SMP14 [12:14]
/// SMP14
SMP14: u3 = 0,
/// SMP15 [15:17]
/// SMP15
SMP15: u3 = 0,
/// SMP16 [18:20]
/// SMP16
SMP16: u3 = 0,
/// SMP17 [21:23]
/// SMP17
SMP17: u3 = 0,
/// SMP18 [24:26]
/// SMP18
SMP18: u3 = 0,
/// unused [27:31]
_unused27: u5 = 0,
};
/// sample time register 2
pub const SMPR2 = Register(SMPR2_val).init(base_address + 0x18);
/// TR1
const TR1_val = packed struct {
/// LT1 [0:11]
/// LT1
LT1: u12 = 0,
/// unused [12:15]
_unused12: u4 = 0,
/// HT1 [16:27]
/// HT1
HT1: u12 = 4095,
/// unused [28:31]
_unused28: u4 = 0,
};
/// watchdog threshold register 1
pub const TR1 = Register(TR1_val).init(base_address + 0x20);
/// TR2
const TR2_val = packed struct {
/// LT2 [0:7]
/// LT2
LT2: u8 = 0,
/// unused [8:15]
_unused8: u8 = 0,
/// HT2 [16:23]
/// HT2
HT2: u8 = 255,
/// unused [24:31]
_unused24: u8 = 15,
};
/// watchdog threshold register
pub const TR2 = Register(TR2_val).init(base_address + 0x24);
/// TR3
const TR3_val = packed struct {
/// LT3 [0:7]
/// LT3
LT3: u8 = 0,
/// unused [8:15]
_unused8: u8 = 0,
/// HT3 [16:23]
/// HT3
HT3: u8 = 255,
/// unused [24:31]
_unused24: u8 = 15,
};
/// watchdog threshold register 3
pub const TR3 = Register(TR3_val).init(base_address + 0x28);
/// SQR1
const SQR1_val = packed struct {
/// L3 [0:3]
/// L3
L3: u4 = 0,
/// unused [4:5]
_unused4: u2 = 0,
/// SQ1 [6:10]
/// SQ1
SQ1: u5 = 0,
/// unused [11:11]
_unused11: u1 = 0,
/// SQ2 [12:16]
/// SQ2
SQ2: u5 = 0,
/// unused [17:17]
_unused17: u1 = 0,
/// SQ3 [18:22]
/// SQ3
SQ3: u5 = 0,
/// unused [23:23]
_unused23: u1 = 0,
/// SQ4 [24:28]
/// SQ4
SQ4: u5 = 0,
/// unused [29:31]
_unused29: u3 = 0,
};
/// regular sequence register 1
pub const SQR1 = Register(SQR1_val).init(base_address + 0x30);
/// SQR2
const SQR2_val = packed struct {
/// SQ5 [0:4]
/// SQ5
SQ5: u5 = 0,
/// unused [5:5]
_unused5: u1 = 0,
/// SQ6 [6:10]
/// SQ6
SQ6: u5 = 0,
/// unused [11:11]
_unused11: u1 = 0,
/// SQ7 [12:16]
/// SQ7
SQ7: u5 = 0,
/// unused [17:17]
_unused17: u1 = 0,
/// SQ8 [18:22]
/// SQ8
SQ8: u5 = 0,
/// unused [23:23]
_unused23: u1 = 0,
/// SQ9 [24:28]
/// SQ9
SQ9: u5 = 0,
/// unused [29:31]
_unused29: u3 = 0,
};
/// regular sequence register 2
pub const SQR2 = Register(SQR2_val).init(base_address + 0x34);
/// SQR3
const SQR3_val = packed struct {
/// SQ10 [0:4]
/// SQ10
SQ10: u5 = 0,
/// unused [5:5]
_unused5: u1 = 0,
/// SQ11 [6:10]
/// SQ11
SQ11: u5 = 0,
/// unused [11:11]
_unused11: u1 = 0,
/// SQ12 [12:16]
/// SQ12
SQ12: u5 = 0,
/// unused [17:17]
_unused17: u1 = 0,
/// SQ13 [18:22]
/// SQ13
SQ13: u5 = 0,
/// unused [23:23]
_unused23: u1 = 0,
/// SQ14 [24:28]
/// SQ14
SQ14: u5 = 0,
/// unused [29:31]
_unused29: u3 = 0,
};
/// regular sequence register 3
pub const SQR3 = Register(SQR3_val).init(base_address + 0x38);
/// SQR4
const SQR4_val = packed struct {
/// SQ15 [0:4]
/// SQ15
SQ15: u5 = 0,
/// unused [5:5]
_unused5: u1 = 0,
/// SQ16 [6:10]
/// SQ16
SQ16: u5 = 0,
/// unused [11:31]
_unused11: u5 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// regular sequence register 4
pub const SQR4 = Register(SQR4_val).init(base_address + 0x3c);
/// DR
const DR_val = packed struct {
/// regularDATA [0:15]
/// regularDATA
regularDATA: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// regular Data Register
pub const DR = Register(DR_val).init(base_address + 0x40);
/// JSQR
const JSQR_val = packed struct {
/// JL [0:1]
/// JL
JL: u2 = 0,
/// JEXTSEL [2:5]
/// JEXTSEL
JEXTSEL: u4 = 0,
/// JEXTEN [6:7]
/// JEXTEN
JEXTEN: u2 = 0,
/// JSQ1 [8:12]
/// JSQ1
JSQ1: u5 = 0,
/// unused [13:13]
_unused13: u1 = 0,
/// JSQ2 [14:18]
/// JSQ2
JSQ2: u5 = 0,
/// unused [19:19]
_unused19: u1 = 0,
/// JSQ3 [20:24]
/// JSQ3
JSQ3: u5 = 0,
/// unused [25:25]
_unused25: u1 = 0,
/// JSQ4 [26:30]
/// JSQ4
JSQ4: u5 = 0,
/// unused [31:31]
_unused31: u1 = 0,
};
/// injected sequence register
pub const JSQR = Register(JSQR_val).init(base_address + 0x4c);
/// OFR1
const OFR1_val = packed struct {
/// OFFSET1 [0:11]
/// OFFSET1
OFFSET1: u12 = 0,
/// unused [12:25]
_unused12: u4 = 0,
_unused16: u8 = 0,
_unused24: u2 = 0,
/// OFFSET1_CH [26:30]
/// OFFSET1_CH
OFFSET1_CH: u5 = 0,
/// OFFSET1_EN [31:31]
/// OFFSET1_EN
OFFSET1_EN: u1 = 0,
};
/// offset register 1
pub const OFR1 = Register(OFR1_val).init(base_address + 0x60);
/// OFR2
const OFR2_val = packed struct {
/// OFFSET2 [0:11]
/// OFFSET2
OFFSET2: u12 = 0,
/// unused [12:25]
_unused12: u4 = 0,
_unused16: u8 = 0,
_unused24: u2 = 0,
/// OFFSET2_CH [26:30]
/// OFFSET2_CH
OFFSET2_CH: u5 = 0,
/// OFFSET2_EN [31:31]
/// OFFSET2_EN
OFFSET2_EN: u1 = 0,
};
/// offset register 2
pub const OFR2 = Register(OFR2_val).init(base_address + 0x64);
/// OFR3
const OFR3_val = packed struct {
/// OFFSET3 [0:11]
/// OFFSET3
OFFSET3: u12 = 0,
/// unused [12:25]
_unused12: u4 = 0,
_unused16: u8 = 0,
_unused24: u2 = 0,
/// OFFSET3_CH [26:30]
/// OFFSET3_CH
OFFSET3_CH: u5 = 0,
/// OFFSET3_EN [31:31]
/// OFFSET3_EN
OFFSET3_EN: u1 = 0,
};
/// offset register 3
pub const OFR3 = Register(OFR3_val).init(base_address + 0x68);
/// OFR4
const OFR4_val = packed struct {
/// OFFSET4 [0:11]
/// OFFSET4
OFFSET4: u12 = 0,
/// unused [12:25]
_unused12: u4 = 0,
_unused16: u8 = 0,
_unused24: u2 = 0,
/// OFFSET4_CH [26:30]
/// OFFSET4_CH
OFFSET4_CH: u5 = 0,
/// OFFSET4_EN [31:31]
/// OFFSET4_EN
OFFSET4_EN: u1 = 0,
};
/// offset register 4
pub const OFR4 = Register(OFR4_val).init(base_address + 0x6c);
/// JDR1
const JDR1_val = packed struct {
/// JDATA1 [0:15]
/// JDATA1
JDATA1: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// injected data register 1
pub const JDR1 = Register(JDR1_val).init(base_address + 0x80);
/// JDR2
const JDR2_val = packed struct {
/// JDATA2 [0:15]
/// JDATA2
JDATA2: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// injected data register 2
pub const JDR2 = Register(JDR2_val).init(base_address + 0x84);
/// JDR3
const JDR3_val = packed struct {
/// JDATA3 [0:15]
/// JDATA3
JDATA3: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// injected data register 3
pub const JDR3 = Register(JDR3_val).init(base_address + 0x88);
/// JDR4
const JDR4_val = packed struct {
/// JDATA4 [0:15]
/// JDATA4
JDATA4: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// injected data register 4
pub const JDR4 = Register(JDR4_val).init(base_address + 0x8c);
/// AWD2CR
const AWD2CR_val = packed struct {
/// unused [0:0]
_unused0: u1 = 0,
/// AWD2CH [1:18]
/// AWD2CH
AWD2CH: u18 = 0,
/// unused [19:31]
_unused19: u5 = 0,
_unused24: u8 = 0,
};
/// Analog Watchdog 2 Configuration Register
pub const AWD2CR = Register(AWD2CR_val).init(base_address + 0xa0);
/// AWD3CR
const AWD3CR_val = packed struct {
/// unused [0:0]
_unused0: u1 = 0,
/// AWD3CH [1:18]
/// AWD3CH
AWD3CH: u18 = 0,
/// unused [19:31]
_unused19: u5 = 0,
_unused24: u8 = 0,
};
/// Analog Watchdog 3 Configuration Register
pub const AWD3CR = Register(AWD3CR_val).init(base_address + 0xa4);
/// DIFSEL
const DIFSEL_val = packed struct {
/// unused [0:0]
_unused0: u1 = 0,
/// DIFSEL_1_15 [1:15]
/// Differential mode for channels 15 to 1
DIFSEL_1_15: u15 = 0,
/// DIFSEL_16_18 [16:18]
/// Differential mode for channels 18 to 16
DIFSEL_16_18: u3 = 0,
/// unused [19:31]
_unused19: u5 = 0,
_unused24: u8 = 0,
};
/// Differential Mode Selection Register 2
pub const DIFSEL = Register(DIFSEL_val).init(base_address + 0xb0);
/// CALFACT
const CALFACT_val = packed struct {
/// CALFACT_S [0:6]
/// CALFACT_S
CALFACT_S: u7 = 0,
/// unused [7:15]
_unused7: u1 = 0,
_unused8: u8 = 0,
/// CALFACT_D [16:22]
/// CALFACT_D
CALFACT_D: u7 = 0,
/// unused [23:31]
_unused23: u1 = 0,
_unused24: u8 = 0,
};
/// Calibration Factors
pub const CALFACT = Register(CALFACT_val).init(base_address + 0xb4);
};
/// Analog-to-Digital Converter
pub const ADC3 = struct {
const base_address = 0x50000400;
/// ISR
const ISR_val = packed struct {
/// ADRDY [0:0]
/// ADRDY
ADRDY: u1 = 0,
/// EOSMP [1:1]
/// EOSMP
EOSMP: u1 = 0,
/// EOC [2:2]
/// EOC
EOC: u1 = 0,
/// EOS [3:3]
/// EOS
EOS: u1 = 0,
/// OVR [4:4]
/// OVR
OVR: u1 = 0,
/// JEOC [5:5]
/// JEOC
JEOC: u1 = 0,
/// JEOS [6:6]
/// JEOS
JEOS: u1 = 0,
/// AWD1 [7:7]
/// AWD1
AWD1: u1 = 0,
/// AWD2 [8:8]
/// AWD2
AWD2: u1 = 0,
/// AWD3 [9:9]
/// AWD3
AWD3: u1 = 0,
/// JQOVF [10:10]
/// JQOVF
JQOVF: u1 = 0,
/// unused [11:31]
_unused11: u5 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// interrupt and status register
pub const ISR = Register(ISR_val).init(base_address + 0x0);
/// IER
const IER_val = packed struct {
/// ADRDYIE [0:0]
/// ADRDYIE
ADRDYIE: u1 = 0,
/// EOSMPIE [1:1]
/// EOSMPIE
EOSMPIE: u1 = 0,
/// EOCIE [2:2]
/// EOCIE
EOCIE: u1 = 0,
/// EOSIE [3:3]
/// EOSIE
EOSIE: u1 = 0,
/// OVRIE [4:4]
/// OVRIE
OVRIE: u1 = 0,
/// JEOCIE [5:5]
/// JEOCIE
JEOCIE: u1 = 0,
/// JEOSIE [6:6]
/// JEOSIE
JEOSIE: u1 = 0,
/// AWD1IE [7:7]
/// AWD1IE
AWD1IE: u1 = 0,
/// AWD2IE [8:8]
/// AWD2IE
AWD2IE: u1 = 0,
/// AWD3IE [9:9]
/// AWD3IE
AWD3IE: u1 = 0,
/// JQOVFIE [10:10]
/// JQOVFIE
JQOVFIE: u1 = 0,
/// unused [11:31]
_unused11: u5 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// interrupt enable register
pub const IER = Register(IER_val).init(base_address + 0x4);
/// CR
const CR_val = packed struct {
/// ADEN [0:0]
/// ADEN
ADEN: u1 = 0,
/// ADDIS [1:1]
/// ADDIS
ADDIS: u1 = 0,
/// ADSTART [2:2]
/// ADSTART
ADSTART: u1 = 0,
/// JADSTART [3:3]
/// JADSTART
JADSTART: u1 = 0,
/// ADSTP [4:4]
/// ADSTP
ADSTP: u1 = 0,
/// JADSTP [5:5]
/// JADSTP
JADSTP: u1 = 0,
/// unused [6:27]
_unused6: u2 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u4 = 0,
/// ADVREGEN [28:28]
/// ADVREGEN
ADVREGEN: u1 = 0,
/// DEEPPWD [29:29]
/// DEEPPWD
DEEPPWD: u1 = 0,
/// ADCALDIF [30:30]
/// ADCALDIF
ADCALDIF: u1 = 0,
/// ADCAL [31:31]
/// ADCAL
ADCAL: u1 = 0,
};
/// control register
pub const CR = Register(CR_val).init(base_address + 0x8);
/// CFGR
const CFGR_val = packed struct {
/// DMAEN [0:0]
/// DMAEN
DMAEN: u1 = 0,
/// DMACFG [1:1]
/// DMACFG
DMACFG: u1 = 0,
/// unused [2:2]
_unused2: u1 = 0,
/// RES [3:4]
/// RES
RES: u2 = 0,
/// ALIGN [5:5]
/// ALIGN
ALIGN: u1 = 0,
/// EXTSEL [6:9]
/// EXTSEL
EXTSEL: u4 = 0,
/// EXTEN [10:11]
/// EXTEN
EXTEN: u2 = 0,
/// OVRMOD [12:12]
/// OVRMOD
OVRMOD: u1 = 0,
/// CONT [13:13]
/// CONT
CONT: u1 = 0,
/// AUTDLY [14:14]
/// AUTDLY
AUTDLY: u1 = 0,
/// AUTOFF [15:15]
/// AUTOFF
AUTOFF: u1 = 0,
/// DISCEN [16:16]
/// DISCEN
DISCEN: u1 = 0,
/// DISCNUM [17:19]
/// DISCNUM
DISCNUM: u3 = 0,
/// JDISCEN [20:20]
/// JDISCEN
JDISCEN: u1 = 0,
/// JQM [21:21]
/// JQM
JQM: u1 = 0,
/// AWD1SGL [22:22]
/// AWD1SGL
AWD1SGL: u1 = 0,
/// AWD1EN [23:23]
/// AWD1EN
AWD1EN: u1 = 0,
/// JAWD1EN [24:24]
/// JAWD1EN
JAWD1EN: u1 = 0,
/// JAUTO [25:25]
/// JAUTO
JAUTO: u1 = 0,
/// AWDCH1CH [26:30]
/// AWDCH1CH
AWDCH1CH: u5 = 0,
/// unused [31:31]
_unused31: u1 = 0,
};
/// configuration register
pub const CFGR = Register(CFGR_val).init(base_address + 0xc);
/// SMPR1
const SMPR1_val = packed struct {
/// unused [0:2]
_unused0: u3 = 0,
/// SMP1 [3:5]
/// SMP1
SMP1: u3 = 0,
/// SMP2 [6:8]
/// SMP2
SMP2: u3 = 0,
/// SMP3 [9:11]
/// SMP3
SMP3: u3 = 0,
/// SMP4 [12:14]
/// SMP4
SMP4: u3 = 0,
/// SMP5 [15:17]
/// SMP5
SMP5: u3 = 0,
/// SMP6 [18:20]
/// SMP6
SMP6: u3 = 0,
/// SMP7 [21:23]
/// SMP7
SMP7: u3 = 0,
/// SMP8 [24:26]
/// SMP8
SMP8: u3 = 0,
/// SMP9 [27:29]
/// SMP9
SMP9: u3 = 0,
/// unused [30:31]
_unused30: u2 = 0,
};
/// sample time register 1
pub const SMPR1 = Register(SMPR1_val).init(base_address + 0x14);
/// SMPR2
const SMPR2_val = packed struct {
/// SMP10 [0:2]
/// SMP10
SMP10: u3 = 0,
/// SMP11 [3:5]
/// SMP11
SMP11: u3 = 0,
/// SMP12 [6:8]
/// SMP12
SMP12: u3 = 0,
/// SMP13 [9:11]
/// SMP13
SMP13: u3 = 0,
/// SMP14 [12:14]
/// SMP14
SMP14: u3 = 0,
/// SMP15 [15:17]
/// SMP15
SMP15: u3 = 0,
/// SMP16 [18:20]
/// SMP16
SMP16: u3 = 0,
/// SMP17 [21:23]
/// SMP17
SMP17: u3 = 0,
/// SMP18 [24:26]
/// SMP18
SMP18: u3 = 0,
/// unused [27:31]
_unused27: u5 = 0,
};
/// sample time register 2
pub const SMPR2 = Register(SMPR2_val).init(base_address + 0x18);
/// TR1
const TR1_val = packed struct {
/// LT1 [0:11]
/// LT1
LT1: u12 = 0,
/// unused [12:15]
_unused12: u4 = 0,
/// HT1 [16:27]
/// HT1
HT1: u12 = 4095,
/// unused [28:31]
_unused28: u4 = 0,
};
/// watchdog threshold register 1
pub const TR1 = Register(TR1_val).init(base_address + 0x20);
/// TR2
const TR2_val = packed struct {
/// LT2 [0:7]
/// LT2
LT2: u8 = 0,
/// unused [8:15]
_unused8: u8 = 0,
/// HT2 [16:23]
/// HT2
HT2: u8 = 255,
/// unused [24:31]
_unused24: u8 = 15,
};
/// watchdog threshold register
pub const TR2 = Register(TR2_val).init(base_address + 0x24);
/// TR3
const TR3_val = packed struct {
/// LT3 [0:7]
/// LT3
LT3: u8 = 0,
/// unused [8:15]
_unused8: u8 = 0,
/// HT3 [16:23]
/// HT3
HT3: u8 = 255,
/// unused [24:31]
_unused24: u8 = 15,
};
/// watchdog threshold register 3
pub const TR3 = Register(TR3_val).init(base_address + 0x28);
/// SQR1
const SQR1_val = packed struct {
/// L3 [0:3]
/// L3
L3: u4 = 0,
/// unused [4:5]
_unused4: u2 = 0,
/// SQ1 [6:10]
/// SQ1
SQ1: u5 = 0,
/// unused [11:11]
_unused11: u1 = 0,
/// SQ2 [12:16]
/// SQ2
SQ2: u5 = 0,
/// unused [17:17]
_unused17: u1 = 0,
/// SQ3 [18:22]
/// SQ3
SQ3: u5 = 0,
/// unused [23:23]
_unused23: u1 = 0,
/// SQ4 [24:28]
/// SQ4
SQ4: u5 = 0,
/// unused [29:31]
_unused29: u3 = 0,
};
/// regular sequence register 1
pub const SQR1 = Register(SQR1_val).init(base_address + 0x30);
/// SQR2
const SQR2_val = packed struct {
/// SQ5 [0:4]
/// SQ5
SQ5: u5 = 0,
/// unused [5:5]
_unused5: u1 = 0,
/// SQ6 [6:10]
/// SQ6
SQ6: u5 = 0,
/// unused [11:11]
_unused11: u1 = 0,
/// SQ7 [12:16]
/// SQ7
SQ7: u5 = 0,
/// unused [17:17]
_unused17: u1 = 0,
/// SQ8 [18:22]
/// SQ8
SQ8: u5 = 0,
/// unused [23:23]
_unused23: u1 = 0,
/// SQ9 [24:28]
/// SQ9
SQ9: u5 = 0,
/// unused [29:31]
_unused29: u3 = 0,
};
/// regular sequence register 2
pub const SQR2 = Register(SQR2_val).init(base_address + 0x34);
/// SQR3
const SQR3_val = packed struct {
/// SQ10 [0:4]
/// SQ10
SQ10: u5 = 0,
/// unused [5:5]
_unused5: u1 = 0,
/// SQ11 [6:10]
/// SQ11
SQ11: u5 = 0,
/// unused [11:11]
_unused11: u1 = 0,
/// SQ12 [12:16]
/// SQ12
SQ12: u5 = 0,
/// unused [17:17]
_unused17: u1 = 0,
/// SQ13 [18:22]
/// SQ13
SQ13: u5 = 0,
/// unused [23:23]
_unused23: u1 = 0,
/// SQ14 [24:28]
/// SQ14
SQ14: u5 = 0,
/// unused [29:31]
_unused29: u3 = 0,
};
/// regular sequence register 3
pub const SQR3 = Register(SQR3_val).init(base_address + 0x38);
/// SQR4
const SQR4_val = packed struct {
/// SQ15 [0:4]
/// SQ15
SQ15: u5 = 0,
/// unused [5:5]
_unused5: u1 = 0,
/// SQ16 [6:10]
/// SQ16
SQ16: u5 = 0,
/// unused [11:31]
_unused11: u5 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// regular sequence register 4
pub const SQR4 = Register(SQR4_val).init(base_address + 0x3c);
/// DR
const DR_val = packed struct {
/// regularDATA [0:15]
/// regularDATA
regularDATA: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// regular Data Register
pub const DR = Register(DR_val).init(base_address + 0x40);
/// JSQR
const JSQR_val = packed struct {
/// JL [0:1]
/// JL
JL: u2 = 0,
/// JEXTSEL [2:5]
/// JEXTSEL
JEXTSEL: u4 = 0,
/// JEXTEN [6:7]
/// JEXTEN
JEXTEN: u2 = 0,
/// JSQ1 [8:12]
/// JSQ1
JSQ1: u5 = 0,
/// unused [13:13]
_unused13: u1 = 0,
/// JSQ2 [14:18]
/// JSQ2
JSQ2: u5 = 0,
/// unused [19:19]
_unused19: u1 = 0,
/// JSQ3 [20:24]
/// JSQ3
JSQ3: u5 = 0,
/// unused [25:25]
_unused25: u1 = 0,
/// JSQ4 [26:30]
/// JSQ4
JSQ4: u5 = 0,
/// unused [31:31]
_unused31: u1 = 0,
};
/// injected sequence register
pub const JSQR = Register(JSQR_val).init(base_address + 0x4c);
/// OFR1
const OFR1_val = packed struct {
/// OFFSET1 [0:11]
/// OFFSET1
OFFSET1: u12 = 0,
/// unused [12:25]
_unused12: u4 = 0,
_unused16: u8 = 0,
_unused24: u2 = 0,
/// OFFSET1_CH [26:30]
/// OFFSET1_CH
OFFSET1_CH: u5 = 0,
/// OFFSET1_EN [31:31]
/// OFFSET1_EN
OFFSET1_EN: u1 = 0,
};
/// offset register 1
pub const OFR1 = Register(OFR1_val).init(base_address + 0x60);
/// OFR2
const OFR2_val = packed struct {
/// OFFSET2 [0:11]
/// OFFSET2
OFFSET2: u12 = 0,
/// unused [12:25]
_unused12: u4 = 0,
_unused16: u8 = 0,
_unused24: u2 = 0,
/// OFFSET2_CH [26:30]
/// OFFSET2_CH
OFFSET2_CH: u5 = 0,
/// OFFSET2_EN [31:31]
/// OFFSET2_EN
OFFSET2_EN: u1 = 0,
};
/// offset register 2
pub const OFR2 = Register(OFR2_val).init(base_address + 0x64);
/// OFR3
const OFR3_val = packed struct {
/// OFFSET3 [0:11]
/// OFFSET3
OFFSET3: u12 = 0,
/// unused [12:25]
_unused12: u4 = 0,
_unused16: u8 = 0,
_unused24: u2 = 0,
/// OFFSET3_CH [26:30]
/// OFFSET3_CH
OFFSET3_CH: u5 = 0,
/// OFFSET3_EN [31:31]
/// OFFSET3_EN
OFFSET3_EN: u1 = 0,
};
/// offset register 3
pub const OFR3 = Register(OFR3_val).init(base_address + 0x68);
/// OFR4
const OFR4_val = packed struct {
/// OFFSET4 [0:11]
/// OFFSET4
OFFSET4: u12 = 0,
/// unused [12:25]
_unused12: u4 = 0,
_unused16: u8 = 0,
_unused24: u2 = 0,
/// OFFSET4_CH [26:30]
/// OFFSET4_CH
OFFSET4_CH: u5 = 0,
/// OFFSET4_EN [31:31]
/// OFFSET4_EN
OFFSET4_EN: u1 = 0,
};
/// offset register 4
pub const OFR4 = Register(OFR4_val).init(base_address + 0x6c);
/// JDR1
const JDR1_val = packed struct {
/// JDATA1 [0:15]
/// JDATA1
JDATA1: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// injected data register 1
pub const JDR1 = Register(JDR1_val).init(base_address + 0x80);
/// JDR2
const JDR2_val = packed struct {
/// JDATA2 [0:15]
/// JDATA2
JDATA2: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// injected data register 2
pub const JDR2 = Register(JDR2_val).init(base_address + 0x84);
/// JDR3
const JDR3_val = packed struct {
/// JDATA3 [0:15]
/// JDATA3
JDATA3: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// injected data register 3
pub const JDR3 = Register(JDR3_val).init(base_address + 0x88);
/// JDR4
const JDR4_val = packed struct {
/// JDATA4 [0:15]
/// JDATA4
JDATA4: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// injected data register 4
pub const JDR4 = Register(JDR4_val).init(base_address + 0x8c);
/// AWD2CR
const AWD2CR_val = packed struct {
/// unused [0:0]
_unused0: u1 = 0,
/// AWD2CH [1:18]
/// AWD2CH
AWD2CH: u18 = 0,
/// unused [19:31]
_unused19: u5 = 0,
_unused24: u8 = 0,
};
/// Analog Watchdog 2 Configuration Register
pub const AWD2CR = Register(AWD2CR_val).init(base_address + 0xa0);
/// AWD3CR
const AWD3CR_val = packed struct {
/// unused [0:0]
_unused0: u1 = 0,
/// AWD3CH [1:18]
/// AWD3CH
AWD3CH: u18 = 0,
/// unused [19:31]
_unused19: u5 = 0,
_unused24: u8 = 0,
};
/// Analog Watchdog 3 Configuration Register
pub const AWD3CR = Register(AWD3CR_val).init(base_address + 0xa4);
/// DIFSEL
const DIFSEL_val = packed struct {
/// unused [0:0]
_unused0: u1 = 0,
/// DIFSEL_1_15 [1:15]
/// Differential mode for channels 15 to 1
DIFSEL_1_15: u15 = 0,
/// DIFSEL_16_18 [16:18]
/// Differential mode for channels 18 to 16
DIFSEL_16_18: u3 = 0,
/// unused [19:31]
_unused19: u5 = 0,
_unused24: u8 = 0,
};
/// Differential Mode Selection Register 2
pub const DIFSEL = Register(DIFSEL_val).init(base_address + 0xb0);
/// CALFACT
const CALFACT_val = packed struct {
/// CALFACT_S [0:6]
/// CALFACT_S
CALFACT_S: u7 = 0,
/// unused [7:15]
_unused7: u1 = 0,
_unused8: u8 = 0,
/// CALFACT_D [16:22]
/// CALFACT_D
CALFACT_D: u7 = 0,
/// unused [23:31]
_unused23: u1 = 0,
_unused24: u8 = 0,
};
/// Calibration Factors
pub const CALFACT = Register(CALFACT_val).init(base_address + 0xb4);
};
/// Analog-to-Digital Converter
pub const ADC4 = struct {
const base_address = 0x50000500;
/// ISR
const ISR_val = packed struct {
/// ADRDY [0:0]
/// ADRDY
ADRDY: u1 = 0,
/// EOSMP [1:1]
/// EOSMP
EOSMP: u1 = 0,
/// EOC [2:2]
/// EOC
EOC: u1 = 0,
/// EOS [3:3]
/// EOS
EOS: u1 = 0,
/// OVR [4:4]
/// OVR
OVR: u1 = 0,
/// JEOC [5:5]
/// JEOC
JEOC: u1 = 0,
/// JEOS [6:6]
/// JEOS
JEOS: u1 = 0,
/// AWD1 [7:7]
/// AWD1
AWD1: u1 = 0,
/// AWD2 [8:8]
/// AWD2
AWD2: u1 = 0,
/// AWD3 [9:9]
/// AWD3
AWD3: u1 = 0,
/// JQOVF [10:10]
/// JQOVF
JQOVF: u1 = 0,
/// unused [11:31]
_unused11: u5 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// interrupt and status register
pub const ISR = Register(ISR_val).init(base_address + 0x0);
/// IER
const IER_val = packed struct {
/// ADRDYIE [0:0]
/// ADRDYIE
ADRDYIE: u1 = 0,
/// EOSMPIE [1:1]
/// EOSMPIE
EOSMPIE: u1 = 0,
/// EOCIE [2:2]
/// EOCIE
EOCIE: u1 = 0,
/// EOSIE [3:3]
/// EOSIE
EOSIE: u1 = 0,
/// OVRIE [4:4]
/// OVRIE
OVRIE: u1 = 0,
/// JEOCIE [5:5]
/// JEOCIE
JEOCIE: u1 = 0,
/// JEOSIE [6:6]
/// JEOSIE
JEOSIE: u1 = 0,
/// AWD1IE [7:7]
/// AWD1IE
AWD1IE: u1 = 0,
/// AWD2IE [8:8]
/// AWD2IE
AWD2IE: u1 = 0,
/// AWD3IE [9:9]
/// AWD3IE
AWD3IE: u1 = 0,
/// JQOVFIE [10:10]
/// JQOVFIE
JQOVFIE: u1 = 0,
/// unused [11:31]
_unused11: u5 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// interrupt enable register
pub const IER = Register(IER_val).init(base_address + 0x4);
/// CR
const CR_val = packed struct {
/// ADEN [0:0]
/// ADEN
ADEN: u1 = 0,
/// ADDIS [1:1]
/// ADDIS
ADDIS: u1 = 0,
/// ADSTART [2:2]
/// ADSTART
ADSTART: u1 = 0,
/// JADSTART [3:3]
/// JADSTART
JADSTART: u1 = 0,
/// ADSTP [4:4]
/// ADSTP
ADSTP: u1 = 0,
/// JADSTP [5:5]
/// JADSTP
JADSTP: u1 = 0,
/// unused [6:27]
_unused6: u2 = 0,
_unused8: u8 = 0,
_unused16: u8 = 0,
_unused24: u4 = 0,
/// ADVREGEN [28:28]
/// ADVREGEN
ADVREGEN: u1 = 0,
/// DEEPPWD [29:29]
/// DEEPPWD
DEEPPWD: u1 = 0,
/// ADCALDIF [30:30]
/// ADCALDIF
ADCALDIF: u1 = 0,
/// ADCAL [31:31]
/// ADCAL
ADCAL: u1 = 0,
};
/// control register
pub const CR = Register(CR_val).init(base_address + 0x8);
/// CFGR
const CFGR_val = packed struct {
/// DMAEN [0:0]
/// DMAEN
DMAEN: u1 = 0,
/// DMACFG [1:1]
/// DMACFG
DMACFG: u1 = 0,
/// unused [2:2]
_unused2: u1 = 0,
/// RES [3:4]
/// RES
RES: u2 = 0,
/// ALIGN [5:5]
/// ALIGN
ALIGN: u1 = 0,
/// EXTSEL [6:9]
/// EXTSEL
EXTSEL: u4 = 0,
/// EXTEN [10:11]
/// EXTEN
EXTEN: u2 = 0,
/// OVRMOD [12:12]
/// OVRMOD
OVRMOD: u1 = 0,
/// CONT [13:13]
/// CONT
CONT: u1 = 0,
/// AUTDLY [14:14]
/// AUTDLY
AUTDLY: u1 = 0,
/// AUTOFF [15:15]
/// AUTOFF
AUTOFF: u1 = 0,
/// DISCEN [16:16]
/// DISCEN
DISCEN: u1 = 0,
/// DISCNUM [17:19]
/// DISCNUM
DISCNUM: u3 = 0,
/// JDISCEN [20:20]
/// JDISCEN
JDISCEN: u1 = 0,
/// JQM [21:21]
/// JQM
JQM: u1 = 0,
/// AWD1SGL [22:22]
/// AWD1SGL
AWD1SGL: u1 = 0,
/// AWD1EN [23:23]
/// AWD1EN
AWD1EN: u1 = 0,
/// JAWD1EN [24:24]
/// JAWD1EN
JAWD1EN: u1 = 0,
/// JAUTO [25:25]
/// JAUTO
JAUTO: u1 = 0,
/// AWDCH1CH [26:30]
/// AWDCH1CH
AWDCH1CH: u5 = 0,
/// unused [31:31]
_unused31: u1 = 0,
};
/// configuration register
pub const CFGR = Register(CFGR_val).init(base_address + 0xc);
/// SMPR1
const SMPR1_val = packed struct {
/// unused [0:2]
_unused0: u3 = 0,
/// SMP1 [3:5]
/// SMP1
SMP1: u3 = 0,
/// SMP2 [6:8]
/// SMP2
SMP2: u3 = 0,
/// SMP3 [9:11]
/// SMP3
SMP3: u3 = 0,
/// SMP4 [12:14]
/// SMP4
SMP4: u3 = 0,
/// SMP5 [15:17]
/// SMP5
SMP5: u3 = 0,
/// SMP6 [18:20]
/// SMP6
SMP6: u3 = 0,
/// SMP7 [21:23]
/// SMP7
SMP7: u3 = 0,
/// SMP8 [24:26]
/// SMP8
SMP8: u3 = 0,
/// SMP9 [27:29]
/// SMP9
SMP9: u3 = 0,
/// unused [30:31]
_unused30: u2 = 0,
};
/// sample time register 1
pub const SMPR1 = Register(SMPR1_val).init(base_address + 0x14);
/// SMPR2
const SMPR2_val = packed struct {
/// SMP10 [0:2]
/// SMP10
SMP10: u3 = 0,
/// SMP11 [3:5]
/// SMP11
SMP11: u3 = 0,
/// SMP12 [6:8]
/// SMP12
SMP12: u3 = 0,
/// SMP13 [9:11]
/// SMP13
SMP13: u3 = 0,
/// SMP14 [12:14]
/// SMP14
SMP14: u3 = 0,
/// SMP15 [15:17]
/// SMP15
SMP15: u3 = 0,
/// SMP16 [18:20]
/// SMP16
SMP16: u3 = 0,
/// SMP17 [21:23]
/// SMP17
SMP17: u3 = 0,
/// SMP18 [24:26]
/// SMP18
SMP18: u3 = 0,
/// unused [27:31]
_unused27: u5 = 0,
};
/// sample time register 2
pub const SMPR2 = Register(SMPR2_val).init(base_address + 0x18);
/// TR1
const TR1_val = packed struct {
/// LT1 [0:11]
/// LT1
LT1: u12 = 0,
/// unused [12:15]
_unused12: u4 = 0,
/// HT1 [16:27]
/// HT1
HT1: u12 = 4095,
/// unused [28:31]
_unused28: u4 = 0,
};
/// watchdog threshold register 1
pub const TR1 = Register(TR1_val).init(base_address + 0x20);
/// TR2
const TR2_val = packed struct {
/// LT2 [0:7]
/// LT2
LT2: u8 = 0,
/// unused [8:15]
_unused8: u8 = 0,
/// HT2 [16:23]
/// HT2
HT2: u8 = 255,
/// unused [24:31]
_unused24: u8 = 15,
};
/// watchdog threshold register
pub const TR2 = Register(TR2_val).init(base_address + 0x24);
/// TR3
const TR3_val = packed struct {
/// LT3 [0:7]
/// LT3
LT3: u8 = 0,
/// unused [8:15]
_unused8: u8 = 0,
/// HT3 [16:23]
/// HT3
HT3: u8 = 255,
/// unused [24:31]
_unused24: u8 = 15,
};
/// watchdog threshold register 3
pub const TR3 = Register(TR3_val).init(base_address + 0x28);
/// SQR1
const SQR1_val = packed struct {
/// L3 [0:3]
/// L3
L3: u4 = 0,
/// unused [4:5]
_unused4: u2 = 0,
/// SQ1 [6:10]
/// SQ1
SQ1: u5 = 0,
/// unused [11:11]
_unused11: u1 = 0,
/// SQ2 [12:16]
/// SQ2
SQ2: u5 = 0,
/// unused [17:17]
_unused17: u1 = 0,
/// SQ3 [18:22]
/// SQ3
SQ3: u5 = 0,
/// unused [23:23]
_unused23: u1 = 0,
/// SQ4 [24:28]
/// SQ4
SQ4: u5 = 0,
/// unused [29:31]
_unused29: u3 = 0,
};
/// regular sequence register 1
pub const SQR1 = Register(SQR1_val).init(base_address + 0x30);
/// SQR2
const SQR2_val = packed struct {
/// SQ5 [0:4]
/// SQ5
SQ5: u5 = 0,
/// unused [5:5]
_unused5: u1 = 0,
/// SQ6 [6:10]
/// SQ6
SQ6: u5 = 0,
/// unused [11:11]
_unused11: u1 = 0,
/// SQ7 [12:16]
/// SQ7
SQ7: u5 = 0,
/// unused [17:17]
_unused17: u1 = 0,
/// SQ8 [18:22]
/// SQ8
SQ8: u5 = 0,
/// unused [23:23]
_unused23: u1 = 0,
/// SQ9 [24:28]
/// SQ9
SQ9: u5 = 0,
/// unused [29:31]
_unused29: u3 = 0,
};
/// regular sequence register 2
pub const SQR2 = Register(SQR2_val).init(base_address + 0x34);
/// SQR3
const SQR3_val = packed struct {
/// SQ10 [0:4]
/// SQ10
SQ10: u5 = 0,
/// unused [5:5]
_unused5: u1 = 0,
/// SQ11 [6:10]
/// SQ11
SQ11: u5 = 0,
/// unused [11:11]
_unused11: u1 = 0,
/// SQ12 [12:16]
/// SQ12
SQ12: u5 = 0,
/// unused [17:17]
_unused17: u1 = 0,
/// SQ13 [18:22]
/// SQ13
SQ13: u5 = 0,
/// unused [23:23]
_unused23: u1 = 0,
/// SQ14 [24:28]
/// SQ14
SQ14: u5 = 0,
/// unused [29:31]
_unused29: u3 = 0,
};
/// regular sequence register 3
pub const SQR3 = Register(SQR3_val).init(base_address + 0x38);
/// SQR4
const SQR4_val = packed struct {
/// SQ15 [0:4]
/// SQ15
SQ15: u5 = 0,
/// unused [5:5]
_unused5: u1 = 0,
/// SQ16 [6:10]
/// SQ16
SQ16: u5 = 0,
/// unused [11:31]
_unused11: u5 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// regular sequence register 4
pub const SQR4 = Register(SQR4_val).init(base_address + 0x3c);
/// DR
const DR_val = packed struct {
/// regularDATA [0:15]
/// regularDATA
regularDATA: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// regular Data Register
pub const DR = Register(DR_val).init(base_address + 0x40);
/// JSQR
const JSQR_val = packed struct {
/// JL [0:1]
/// JL
JL: u2 = 0,
/// JEXTSEL [2:5]
/// JEXTSEL
JEXTSEL: u4 = 0,
/// JEXTEN [6:7]
/// JEXTEN
JEXTEN: u2 = 0,
/// JSQ1 [8:12]
/// JSQ1
JSQ1: u5 = 0,
/// unused [13:13]
_unused13: u1 = 0,
/// JSQ2 [14:18]
/// JSQ2
JSQ2: u5 = 0,
/// unused [19:19]
_unused19: u1 = 0,
/// JSQ3 [20:24]
/// JSQ3
JSQ3: u5 = 0,
/// unused [25:25]
_unused25: u1 = 0,
/// JSQ4 [26:30]
/// JSQ4
JSQ4: u5 = 0,
/// unused [31:31]
_unused31: u1 = 0,
};
/// injected sequence register
pub const JSQR = Register(JSQR_val).init(base_address + 0x4c);
/// OFR1
const OFR1_val = packed struct {
/// OFFSET1 [0:11]
/// OFFSET1
OFFSET1: u12 = 0,
/// unused [12:25]
_unused12: u4 = 0,
_unused16: u8 = 0,
_unused24: u2 = 0,
/// OFFSET1_CH [26:30]
/// OFFSET1_CH
OFFSET1_CH: u5 = 0,
/// OFFSET1_EN [31:31]
/// OFFSET1_EN
OFFSET1_EN: u1 = 0,
};
/// offset register 1
pub const OFR1 = Register(OFR1_val).init(base_address + 0x60);
/// OFR2
const OFR2_val = packed struct {
/// OFFSET2 [0:11]
/// OFFSET2
OFFSET2: u12 = 0,
/// unused [12:25]
_unused12: u4 = 0,
_unused16: u8 = 0,
_unused24: u2 = 0,
/// OFFSET2_CH [26:30]
/// OFFSET2_CH
OFFSET2_CH: u5 = 0,
/// OFFSET2_EN [31:31]
/// OFFSET2_EN
OFFSET2_EN: u1 = 0,
};
/// offset register 2
pub const OFR2 = Register(OFR2_val).init(base_address + 0x64);
/// OFR3
const OFR3_val = packed struct {
/// OFFSET3 [0:11]
/// OFFSET3
OFFSET3: u12 = 0,
/// unused [12:25]
_unused12: u4 = 0,
_unused16: u8 = 0,
_unused24: u2 = 0,
/// OFFSET3_CH [26:30]
/// OFFSET3_CH
OFFSET3_CH: u5 = 0,
/// OFFSET3_EN [31:31]
/// OFFSET3_EN
OFFSET3_EN: u1 = 0,
};
/// offset register 3
pub const OFR3 = Register(OFR3_val).init(base_address + 0x68);
/// OFR4
const OFR4_val = packed struct {
/// OFFSET4 [0:11]
/// OFFSET4
OFFSET4: u12 = 0,
/// unused [12:25]
_unused12: u4 = 0,
_unused16: u8 = 0,
_unused24: u2 = 0,
/// OFFSET4_CH [26:30]
/// OFFSET4_CH
OFFSET4_CH: u5 = 0,
/// OFFSET4_EN [31:31]
/// OFFSET4_EN
OFFSET4_EN: u1 = 0,
};
/// offset register 4
pub const OFR4 = Register(OFR4_val).init(base_address + 0x6c);
/// JDR1
const JDR1_val = packed struct {
/// JDATA1 [0:15]
/// JDATA1
JDATA1: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// injected data register 1
pub const JDR1 = Register(JDR1_val).init(base_address + 0x80);
/// JDR2
const JDR2_val = packed struct {
/// JDATA2 [0:15]
/// JDATA2
JDATA2: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// injected data register 2
pub const JDR2 = Register(JDR2_val).init(base_address + 0x84);
/// JDR3
const JDR3_val = packed struct {
/// JDATA3 [0:15]
/// JDATA3
JDATA3: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// injected data register 3
pub const JDR3 = Register(JDR3_val).init(base_address + 0x88);
/// JDR4
const JDR4_val = packed struct {
/// JDATA4 [0:15]
/// JDATA4
JDATA4: u16 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// injected data register 4
pub const JDR4 = Register(JDR4_val).init(base_address + 0x8c);
/// AWD2CR
const AWD2CR_val = packed struct {
/// unused [0:0]
_unused0: u1 = 0,
/// AWD2CH [1:18]
/// AWD2CH
AWD2CH: u18 = 0,
/// unused [19:31]
_unused19: u5 = 0,
_unused24: u8 = 0,
};
/// Analog Watchdog 2 Configuration Register
pub const AWD2CR = Register(AWD2CR_val).init(base_address + 0xa0);
/// AWD3CR
const AWD3CR_val = packed struct {
/// unused [0:0]
_unused0: u1 = 0,
/// AWD3CH [1:18]
/// AWD3CH
AWD3CH: u18 = 0,
/// unused [19:31]
_unused19: u5 = 0,
_unused24: u8 = 0,
};
/// Analog Watchdog 3 Configuration Register
pub const AWD3CR = Register(AWD3CR_val).init(base_address + 0xa4);
/// DIFSEL
const DIFSEL_val = packed struct {
/// unused [0:0]
_unused0: u1 = 0,
/// DIFSEL_1_15 [1:15]
/// Differential mode for channels 15 to 1
DIFSEL_1_15: u15 = 0,
/// DIFSEL_16_18 [16:18]
/// Differential mode for channels 18 to 16
DIFSEL_16_18: u3 = 0,
/// unused [19:31]
_unused19: u5 = 0,
_unused24: u8 = 0,
};
/// Differential Mode Selection Register 2
pub const DIFSEL = Register(DIFSEL_val).init(base_address + 0xb0);
/// CALFACT
const CALFACT_val = packed struct {
/// CALFACT_S [0:6]
/// CALFACT_S
CALFACT_S: u7 = 0,
/// unused [7:15]
_unused7: u1 = 0,
_unused8: u8 = 0,
/// CALFACT_D [16:22]
/// CALFACT_D
CALFACT_D: u7 = 0,
/// unused [23:31]
_unused23: u1 = 0,
_unused24: u8 = 0,
};
/// Calibration Factors
pub const CALFACT = Register(CALFACT_val).init(base_address + 0xb4);
};
/// Analog-to-Digital Converter
pub const ADC1_2 = struct {
const base_address = 0x50000300;
/// CSR
const CSR_val = packed struct {
/// ADDRDY_MST [0:0]
/// ADDRDY_MST
ADDRDY_MST: u1 = 0,
/// EOSMP_MST [1:1]
/// EOSMP_MST
EOSMP_MST: u1 = 0,
/// EOC_MST [2:2]
/// EOC_MST
EOC_MST: u1 = 0,
/// EOS_MST [3:3]
/// EOS_MST
EOS_MST: u1 = 0,
/// OVR_MST [4:4]
/// OVR_MST
OVR_MST: u1 = 0,
/// JEOC_MST [5:5]
/// JEOC_MST
JEOC_MST: u1 = 0,
/// JEOS_MST [6:6]
/// JEOS_MST
JEOS_MST: u1 = 0,
/// AWD1_MST [7:7]
/// AWD1_MST
AWD1_MST: u1 = 0,
/// AWD2_MST [8:8]
/// AWD2_MST
AWD2_MST: u1 = 0,
/// AWD3_MST [9:9]
/// AWD3_MST
AWD3_MST: u1 = 0,
/// JQOVF_MST [10:10]
/// JQOVF_MST
JQOVF_MST: u1 = 0,
/// unused [11:15]
_unused11: u5 = 0,
/// ADRDY_SLV [16:16]
/// ADRDY_SLV
ADRDY_SLV: u1 = 0,
/// EOSMP_SLV [17:17]
/// EOSMP_SLV
EOSMP_SLV: u1 = 0,
/// EOC_SLV [18:18]
/// End of regular conversion of the slave ADC
EOC_SLV: u1 = 0,
/// EOS_SLV [19:19]
/// End of regular sequence flag of the slave ADC
EOS_SLV: u1 = 0,
/// OVR_SLV [20:20]
/// Overrun flag of the slave ADC
OVR_SLV: u1 = 0,
/// JEOC_SLV [21:21]
/// End of injected conversion flag of the slave ADC
JEOC_SLV: u1 = 0,
/// JEOS_SLV [22:22]
/// End of injected sequence flag of the slave ADC
JEOS_SLV: u1 = 0,
/// AWD1_SLV [23:23]
/// Analog watchdog 1 flag of the slave ADC
AWD1_SLV: u1 = 0,
/// AWD2_SLV [24:24]
/// Analog watchdog 2 flag of the slave ADC
AWD2_SLV: u1 = 0,
/// AWD3_SLV [25:25]
/// Analog watchdog 3 flag of the slave ADC
AWD3_SLV: u1 = 0,
/// JQOVF_SLV [26:26]
/// Injected Context Queue Overflow flag of the slave ADC
JQOVF_SLV: u1 = 0,
/// unused [27:31]
_unused27: u5 = 0,
};
/// ADC Common status register
pub const CSR = Register(CSR_val).init(base_address + 0x0);
/// CCR
const CCR_val = packed struct {
/// MULT [0:4]
/// Multi ADC mode selection
MULT: u5 = 0,
/// unused [5:7]
_unused5: u3 = 0,
/// DELAY [8:11]
/// Delay between 2 sampling phases
DELAY: u4 = 0,
/// unused [12:12]
_unused12: u1 = 0,
/// DMACFG [13:13]
/// DMA configuration (for multi-ADC mode)
DMACFG: u1 = 0,
/// MDMA [14:15]
/// Direct memory access mode for multi ADC mode
MDMA: u2 = 0,
/// CKMODE [16:17]
/// ADC clock mode
CKMODE: u2 = 0,
/// unused [18:21]
_unused18: u4 = 0,
/// VREFEN [22:22]
/// VREFINT enable
VREFEN: u1 = 0,
/// TSEN [23:23]
/// Temperature sensor enable
TSEN: u1 = 0,
/// VBATEN [24:24]
/// VBAT enable
VBATEN: u1 = 0,
/// unused [25:31]
_unused25: u7 = 0,
};
/// ADC common control register
pub const CCR = Register(CCR_val).init(base_address + 0x8);
/// CDR
const CDR_val = packed struct {
/// RDATA_MST [0:15]
/// Regular data of the master ADC
RDATA_MST: u16 = 0,
/// RDATA_SLV [16:31]
/// Regular data of the slave ADC
RDATA_SLV: u16 = 0,
};
/// ADC common regular data register for dual and triple modes
pub const CDR = Register(CDR_val).init(base_address + 0xc);
};
/// Analog-to-Digital Converter
pub const ADC3_4 = struct {
const base_address = 0x50000700;
/// CSR
const CSR_val = packed struct {
/// ADDRDY_MST [0:0]
/// ADDRDY_MST
ADDRDY_MST: u1 = 0,
/// EOSMP_MST [1:1]
/// EOSMP_MST
EOSMP_MST: u1 = 0,
/// EOC_MST [2:2]
/// EOC_MST
EOC_MST: u1 = 0,
/// EOS_MST [3:3]
/// EOS_MST
EOS_MST: u1 = 0,
/// OVR_MST [4:4]
/// OVR_MST
OVR_MST: u1 = 0,
/// JEOC_MST [5:5]
/// JEOC_MST
JEOC_MST: u1 = 0,
/// JEOS_MST [6:6]
/// JEOS_MST
JEOS_MST: u1 = 0,
/// AWD1_MST [7:7]
/// AWD1_MST
AWD1_MST: u1 = 0,
/// AWD2_MST [8:8]
/// AWD2_MST
AWD2_MST: u1 = 0,
/// AWD3_MST [9:9]
/// AWD3_MST
AWD3_MST: u1 = 0,
/// JQOVF_MST [10:10]
/// JQOVF_MST
JQOVF_MST: u1 = 0,
/// unused [11:15]
_unused11: u5 = 0,
/// ADRDY_SLV [16:16]
/// ADRDY_SLV
ADRDY_SLV: u1 = 0,
/// EOSMP_SLV [17:17]
/// EOSMP_SLV
EOSMP_SLV: u1 = 0,
/// EOC_SLV [18:18]
/// End of regular conversion of the slave ADC
EOC_SLV: u1 = 0,
/// EOS_SLV [19:19]
/// End of regular sequence flag of the slave ADC
EOS_SLV: u1 = 0,
/// OVR_SLV [20:20]
/// Overrun flag of the slave ADC
OVR_SLV: u1 = 0,
/// JEOC_SLV [21:21]
/// End of injected conversion flag of the slave ADC
JEOC_SLV: u1 = 0,
/// JEOS_SLV [22:22]
/// End of injected sequence flag of the slave ADC
JEOS_SLV: u1 = 0,
/// AWD1_SLV [23:23]
/// Analog watchdog 1 flag of the slave ADC
AWD1_SLV: u1 = 0,
/// AWD2_SLV [24:24]
/// Analog watchdog 2 flag of the slave ADC
AWD2_SLV: u1 = 0,
/// AWD3_SLV [25:25]
/// Analog watchdog 3 flag of the slave ADC
AWD3_SLV: u1 = 0,
/// JQOVF_SLV [26:26]
/// Injected Context Queue Overflow flag of the slave ADC
JQOVF_SLV: u1 = 0,
/// unused [27:31]
_unused27: u5 = 0,
};
/// ADC Common status register
pub const CSR = Register(CSR_val).init(base_address + 0x0);
/// CCR
const CCR_val = packed struct {
/// MULT [0:4]
/// Multi ADC mode selection
MULT: u5 = 0,
/// unused [5:7]
_unused5: u3 = 0,
/// DELAY [8:11]
/// Delay between 2 sampling phases
DELAY: u4 = 0,
/// unused [12:12]
_unused12: u1 = 0,
/// DMACFG [13:13]
/// DMA configuration (for multi-ADC mode)
DMACFG: u1 = 0,
/// MDMA [14:15]
/// Direct memory access mode for multi ADC mode
MDMA: u2 = 0,
/// CKMODE [16:17]
/// ADC clock mode
CKMODE: u2 = 0,
/// unused [18:21]
_unused18: u4 = 0,
/// VREFEN [22:22]
/// VREFINT enable
VREFEN: u1 = 0,
/// TSEN [23:23]
/// Temperature sensor enable
TSEN: u1 = 0,
/// VBATEN [24:24]
/// VBAT enable
VBATEN: u1 = 0,
/// unused [25:31]
_unused25: u7 = 0,
};
/// ADC common control register
pub const CCR = Register(CCR_val).init(base_address + 0x8);
/// CDR
const CDR_val = packed struct {
/// RDATA_MST [0:15]
/// Regular data of the master ADC
RDATA_MST: u16 = 0,
/// RDATA_SLV [16:31]
/// Regular data of the slave ADC
RDATA_SLV: u16 = 0,
};
/// ADC common regular data register for dual and triple modes
pub const CDR = Register(CDR_val).init(base_address + 0xc);
};
/// System configuration controller
pub const SYSCFG = struct {
const base_address = 0x40010000;
/// CFGR1
const CFGR1_val = packed struct {
/// MEM_MODE [0:1]
/// Memory mapping selection bits
MEM_MODE: u2 = 0,
/// unused [2:4]
_unused2: u3 = 0,
/// USB_IT_RMP [5:5]
/// USB interrupt remap
USB_IT_RMP: u1 = 0,
/// TIM1_ITR_RMP [6:6]
/// Timer 1 ITR3 selection
TIM1_ITR_RMP: u1 = 0,
/// DAC_TRIG_RMP [7:7]
/// DAC trigger remap (when TSEL = 001)
DAC_TRIG_RMP: u1 = 0,
/// ADC24_DMA_RMP [8:8]
/// ADC24 DMA remapping bit
ADC24_DMA_RMP: u1 = 0,
/// unused [9:10]
_unused9: u2 = 0,
/// TIM16_DMA_RMP [11:11]
/// TIM16 DMA request remapping bit
TIM16_DMA_RMP: u1 = 0,
/// TIM17_DMA_RMP [12:12]
/// TIM17 DMA request remapping bit
TIM17_DMA_RMP: u1 = 0,
/// TIM6_DAC1_DMA_RMP [13:13]
/// TIM6 and DAC1 DMA request remapping bit
TIM6_DAC1_DMA_RMP: u1 = 0,
/// TIM7_DAC2_DMA_RMP [14:14]
/// TIM7 and DAC2 DMA request remapping bit
TIM7_DAC2_DMA_RMP: u1 = 0,
/// unused [15:15]
_unused15: u1 = 0,
/// I2C_PB6_FM [16:16]
/// Fast Mode Plus (FM+) driving capability activation bits.
I2C_PB6_FM: u1 = 0,
/// I2C_PB7_FM [17:17]
/// Fast Mode Plus (FM+) driving capability activation bits.
I2C_PB7_FM: u1 = 0,
/// I2C_PB8_FM [18:18]
/// Fast Mode Plus (FM+) driving capability activation bits.
I2C_PB8_FM: u1 = 0,
/// I2C_PB9_FM [19:19]
/// Fast Mode Plus (FM+) driving capability activation bits.
I2C_PB9_FM: u1 = 0,
/// I2C1_FM [20:20]
/// I2C1 Fast Mode Plus
I2C1_FM: u1 = 0,
/// I2C2_FM [21:21]
/// I2C2 Fast Mode Plus
I2C2_FM: u1 = 0,
/// ENCODER_MODE [22:23]
/// Encoder mode
ENCODER_MODE: u2 = 0,
/// unused [24:25]
_unused24: u2 = 0,
/// FPU_IT [26:31]
/// Interrupt enable bits from FPU
FPU_IT: u6 = 0,
};
/// configuration register 1
pub const CFGR1 = Register(CFGR1_val).init(base_address + 0x0);
/// EXTICR1
const EXTICR1_val = packed struct {
/// EXTI0 [0:3]
/// EXTI 0 configuration bits
EXTI0: u4 = 0,
/// EXTI1 [4:7]
/// EXTI 1 configuration bits
EXTI1: u4 = 0,
/// EXTI2 [8:11]
/// EXTI 2 configuration bits
EXTI2: u4 = 0,
/// EXTI3 [12:15]
/// EXTI 3 configuration bits
EXTI3: u4 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// external interrupt configuration register 1
pub const EXTICR1 = Register(EXTICR1_val).init(base_address + 0x8);
/// EXTICR2
const EXTICR2_val = packed struct {
/// EXTI4 [0:3]
/// EXTI 4 configuration bits
EXTI4: u4 = 0,
/// EXTI5 [4:7]
/// EXTI 5 configuration bits
EXTI5: u4 = 0,
/// EXTI6 [8:11]
/// EXTI 6 configuration bits
EXTI6: u4 = 0,
/// EXTI7 [12:15]
/// EXTI 7 configuration bits
EXTI7: u4 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// external interrupt configuration register 2
pub const EXTICR2 = Register(EXTICR2_val).init(base_address + 0xc);
/// EXTICR3
const EXTICR3_val = packed struct {
/// EXTI8 [0:3]
/// EXTI 8 configuration bits
EXTI8: u4 = 0,
/// EXTI9 [4:7]
/// EXTI 9 configuration bits
EXTI9: u4 = 0,
/// EXTI10 [8:11]
/// EXTI 10 configuration bits
EXTI10: u4 = 0,
/// EXTI11 [12:15]
/// EXTI 11 configuration bits
EXTI11: u4 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// external interrupt configuration register 3
pub const EXTICR3 = Register(EXTICR3_val).init(base_address + 0x10);
/// EXTICR4
const EXTICR4_val = packed struct {
/// EXTI12 [0:3]
/// EXTI 12 configuration bits
EXTI12: u4 = 0,
/// EXTI13 [4:7]
/// EXTI 13 configuration bits
EXTI13: u4 = 0,
/// EXTI14 [8:11]
/// EXTI 14 configuration bits
EXTI14: u4 = 0,
/// EXTI15 [12:15]
/// EXTI 15 configuration bits
EXTI15: u4 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// external interrupt configuration register 4
pub const EXTICR4 = Register(EXTICR4_val).init(base_address + 0x14);
/// CFGR2
const CFGR2_val = packed struct {
/// LOCUP_LOCK [0:0]
/// Cortex-M0 LOCKUP bit enable bit
LOCUP_LOCK: u1 = 0,
/// SRAM_PARITY_LOCK [1:1]
/// SRAM parity lock bit
SRAM_PARITY_LOCK: u1 = 0,
/// PVD_LOCK [2:2]
/// PVD lock enable bit
PVD_LOCK: u1 = 0,
/// unused [3:3]
_unused3: u1 = 0,
/// BYP_ADD_PAR [4:4]
/// Bypass address bit 29 in parity calculation
BYP_ADD_PAR: u1 = 0,
/// unused [5:7]
_unused5: u3 = 0,
/// SRAM_PEF [8:8]
/// SRAM parity flag
SRAM_PEF: u1 = 0,
/// unused [9:31]
_unused9: u7 = 0,
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// configuration register 2
pub const CFGR2 = Register(CFGR2_val).init(base_address + 0x18);
/// RCR
const RCR_val = packed struct {
/// PAGE0_WP [0:0]
/// CCM SRAM page write protection bit
PAGE0_WP: u1 = 0,
/// PAGE1_WP [1:1]
/// CCM SRAM page write protection bit
PAGE1_WP: u1 = 0,
/// PAGE2_WP [2:2]
/// CCM SRAM page write protection bit
PAGE2_WP: u1 = 0,
/// PAGE3_WP [3:3]
/// CCM SRAM page write protection bit
PAGE3_WP: u1 = 0,
/// PAGE4_WP [4:4]
/// CCM SRAM page write protection bit
PAGE4_WP: u1 = 0,
/// PAGE5_WP [5:5]
/// CCM SRAM page write protection bit
PAGE5_WP: u1 = 0,
/// PAGE6_WP [6:6]
/// CCM SRAM page write protection bit
PAGE6_WP: u1 = 0,
/// PAGE7_WP [7:7]
/// CCM SRAM page write protection bit
PAGE7_WP: u1 = 0,
/// PAGE8_WP [8:8]
/// CCM SRAM page write protection
PAGE8_WP: u1 = 0,
/// PAGE9_WP [9:9]
/// CCM SRAM page write protection
PAGE9_WP: u1 = 0,
/// PAGE10_WP [10:10]
/// CCM SRAM page write protection
PAGE10_WP: u1 = 0,
/// PAGE11_WP [11:11]
/// CCM SRAM page write protection
PAGE11_WP: u1 = 0,
/// PAGE12_WP [12:12]
/// CCM SRAM page write protection
PAGE12_WP: u1 = 0,
/// PAGE13_WP [13:13]
/// CCM SRAM page write protection
PAGE13_WP: u1 = 0,
/// PAGE14_WP [14:14]
/// CCM SRAM page write protection
PAGE14_WP: u1 = 0,
/// PAGE15_WP [15:15]
/// CCM SRAM page write protection
PAGE15_WP: u1 = 0,
/// unused [16:31]
_unused16: u8 = 0,
_unused24: u8 = 0,
};
/// CCM SRAM protection register
pub const RCR = Register(RCR_val).init(base_address + 0x4);
};
/// Operational amplifier
pub const OPAMP = struct {
const base_address = 0x40010038;
/// OPAMP1_CR
const OPAMP1_CR_val = packed struct {
/// OPAMP1_EN [0:0]
/// OPAMP1 enable
OPAMP1_EN: u1 = 0,
/// FORCE_VP [1:1]
/// FORCE_VP
FORCE_VP: u1 = 0,
/// VP_SEL [2:3]
/// OPAMP1 Non inverting input selection
VP_SEL: u2 = 0,
/// unused [4:4]
_unused4: u1 = 0,
/// VM_SEL [5:6]
/// OPAMP1 inverting input selection
VM_SEL: u2 = 0,
/// TCM_EN [7:7]
/// Timer controlled Mux mode enable
TCM_EN: u1 = 0,
/// VMS_SEL [8:8]
/// OPAMP1 inverting input secondary selection
VMS_SEL: u1 = 0,
/// VPS_SEL [9:10]
/// OPAMP1 Non inverting input secondary selection
VPS_SEL: u2 = 0,
/// CALON [11:11]
/// Calibration mode enable
CALON: u1 = 0,
/// CALSEL [12:13]
/// Calibration selection
CALSEL: u2 = 0,
/// PGA_GAIN [14:17]
/// Gain in PGA mode
PGA_GAIN: u4 = 0,
/// USER_TRIM [18:18]
/// User trimming enable
USER_TRIM: u1 = 0,
/// TRIMOFFSETP [19:23]
/// Offset trimming value (PMOS)
TRIMOFFSETP: u5 = 0,
/// TRIMOFFSETN [24:28]
/// Offset trimming value (NMOS)
TRIMOFFSETN: u5 = 0,
/// TSTREF [29:29]
/// TSTREF
TSTREF: u1 = 0,
/// OUTCAL [30:30]
/// OPAMP 1 ouput status flag
OUTCAL: u1 = 0,
/// LOCK [31:31]
/// OPAMP 1 lock
LOCK: u1 = 0,
};
/// OPAMP1 control register
pub const OPAMP1_CR = Register(OPAMP1_CR_val).init(base_address + 0x0);
/// OPAMP2_CR
const OPAMP2_CR_val = packed struct {
/// OPAMP2EN [0:0]
/// OPAMP2 enable
OPAMP2EN: u1 = 0,
/// FORCE_VP [1:1]
/// FORCE_VP
FORCE_VP: u1 = 0,
/// VP_SEL [2:3]
/// OPAMP2 Non inverting input selection
VP_SEL: u2 = 0,
/// unused [4:4]
_unused4: u1 = 0,
/// VM_SEL [5:6]
/// OPAMP2 inverting input selection
VM_SEL: u2 = 0,
/// TCM_EN [7:7]
/// Timer controlled Mux mode enable
TCM_EN: u1 = 0,
/// VMS_SEL [8:8]
/// OPAMP2 inverting input secondary selection
VMS_SEL: u1 = 0,
/// VPS_SEL [9:10]
/// OPAMP2 Non inverting input secondary selection
VPS_SEL: u2 = 0,
/// CALON [11:11]
/// Calibration mode enable
CALON: u1 = 0,
/// CAL_SEL [12:13]
/// Calibration selection
CAL_SEL: u2 = 0,
/// PGA_GAIN [14:17]
/// Gain in PGA mode
PGA_GAIN: u4 = 0,
/// USER_TRIM [18:18]
/// User trimming enable
USER_TRIM: u1 = 0,
/// TRIMOFFSETP [19:23]
/// Offset trimming value (PMOS)
TRIMOFFSETP: u5 = 0,
/// TRIMOFFSETN [24:28]
/// Offset trimming value (NMOS)
TRIMOFFSETN: u5 = 0,
/// TSTREF [29:29]
/// TSTREF
TSTREF: u1 = 0,
/// OUTCAL [30:30]
/// OPAMP 2 ouput status flag
OUTCAL: u1 = 0,
/// LOCK [31:31]
/// OPAMP 2 lock
LOCK: u1 = 0,
};
/// OPAMP2 control register
pub const OPAMP2_CR = Register(OPAMP2_CR_val).init(base_address + 0x4);
/// OPAMP3_CR
const OPAMP3_CR_val = packed struct {
/// OPAMP3EN [0:0]
/// OPAMP3 enable
OPAMP3EN: u1 = 0,
/// FORCE_VP [1:1]
/// FORCE_VP
FORCE_VP: u1 = 0,
/// VP_SEL [2:3]
/// OPAMP3 Non inverting input selection
VP_SEL: u2 = 0,
/// unused [4:4]
_unused4: u1 = 0,
/// VM_SEL [5:6]
/// OPAMP3 inverting input selection
VM_SEL: u2 = 0,
/// TCM_EN [7:7]
/// Timer controlled Mux mode enable
TCM_EN: u1 = 0,
/// VMS_SEL [8:8]
/// OPAMP3 inverting input secondary selection
VMS_SEL: u1 = 0,
/// VPS_SEL [9:10]
/// OPAMP3 Non inverting input secondary selection
VPS_SEL: u2 = 0,
/// CALON [11:11]
/// Calibration mode enable
CALON: u1 = 0,
/// CALSEL [12:13]
/// Calibration selection
CALSEL: u2 = 0,
/// PGA_GAIN [14:17]
/// Gain in PGA mode
PGA_GAIN: u4 = 0,
/// USER_TRIM [18:18]
/// User trimming enable
USER_TRIM: u1 = 0,
/// TRIMOFFSETP [19:23]
/// Offset trimming value (PMOS)
TRIMOFFSETP: u5 = 0,
/// TRIMOFFSETN [24:28]
/// Offset trimming value (NMOS)
TRIMOFFSETN: u5 = 0,
/// TSTREF [29:29]
/// TSTREF
TSTREF: u1 = 0,
/// OUTCAL [30:30]
/// OPAMP 3 ouput status flag
OUTCAL: u1 = 0,
/// LOCK [31:31]
/// OPAMP 3 lock
LOCK: u1 = 0,
};
/// OPAMP3 control register
pub const OPAMP3_CR = Register(OPAMP3_CR_val).init(base_address + 0x8);
/// OPAMP4_CR
const OPAMP4_CR_val = packed struct {
/// OPAMP4EN [0:0]
/// OPAMP4 enable
OPAMP4EN: u1 = 0,
/// FORCE_VP [1:1]
/// FORCE_VP
FORCE_VP: u1 = 0,
/// VP_SEL [2:3]
/// OPAMP4 Non inverting input selection
VP_SEL: u2 = 0,
/// unused [4:4]
_unused4: u1 = 0,
/// VM_SEL [5:6]
/// OPAMP4 inverting input selection
VM_SEL: u2 = 0,
/// TCM_EN [7:7]
/// Timer controlled Mux mode enable
TCM_EN: u1 = 0,
/// VMS_SEL [8:8]
/// OPAMP4 inverting input secondary selection
VMS_SEL: u1 = 0,
/// VPS_SEL [9:10]
/// OPAMP4 Non inverting input secondary selection
VPS_SEL: u2 = 0,
/// CALON [11:11]
/// Calibration mode enable
CALON: u1 = 0,
/// CALSEL [12:13]
/// Calibration selection
CALSEL: u2 = 0,
/// PGA_GAIN [14:17]
/// Gain in PGA mode
PGA_GAIN: u4 = 0,
/// USER_TRIM [18:18]
/// User trimming enable
USER_TRIM: u1 = 0,
/// TRIMOFFSETP [19:23]
/// Offset trimming value (PMOS)
TRIMOFFSETP: u5 = 0,
/// TRIMOFFSETN [24:28]
/// Offset trimming value (NMOS)
TRIMOFFSETN: u5 = 0,
/// TSTREF [29:29]
/// TSTREF
TSTREF: u1 = 0,
/// OUTCAL [30:30]
/// OPAMP 4 ouput status flag
OUTCAL: u1 = 0,
/// LOCK [31:31]
/// OPAMP 4 lock
LOCK: u1 = 0,
};
/// OPAMP4 control register
pub const OPAMP4_CR = Register(OPAMP4_CR_val).init(base_address + 0xc);
};
pub const interrupts = struct {
pub const TIM1_TRG_COM_TIM17 = 26;
pub const TIM6_DACUNDER = 54;
pub const DMA2_CH5 = 60;
pub const USB_WKUP_EXTI = 76;
pub const CAN_SCE = 22;
pub const ADC4 = 61;
pub const I2C2_ER = 34;
pub const DMA2_CH1 = 56;
pub const SPI2 = 36;
pub const EXTI3 = 9;
pub const COMP123 = 64;
pub const RTCAlarm = 41;
pub const USART2_EXTI26 = 38;
pub const EXTI0 = 6;
pub const I2C2_EV_EXTI24 = 33;
pub const TAMP_STAMP = 2;
pub const COMP456 = 65;
pub const EXTI1 = 7;
pub const COMP7 = 66;
pub const CAN_RX1 = 21;
pub const TIM8_BRK = 43;
pub const TIM2 = 28;
pub const EXTI15_10 = 40;
pub const RCC = 5;
pub const USART1_EXTI25 = 37;
pub const DMA1_CH6 = 16;
pub const DMA2_CH3 = 58;
pub const USB_LP_CAN_RX0 = 20;
pub const USB_HP = 74;
pub const TIM7 = 55;
pub const DMA1_CH3 = 13;
pub const TIM1_BRK_TIM15 = 24;
pub const DMA1_CH1 = 11;
pub const USB_LP = 75;
pub const ADC3 = 47;
pub const DMA2_CH4 = 59;
pub const RTC_WKUP = 3;
pub const DMA1_CH7 = 17;
pub const TIM8_TRG_COM = 45;
pub const SPI3 = 51;
pub const EXTI9_5 = 23;
pub const TIM1_CC = 27;
pub const I2C1_EV_EXTI23 = 31;
pub const TIM4 = 30;
pub const DMA1_CH2 = 12;
pub const WWDG = 0;
pub const DMA1_CH4 = 14;
pub const EXTI2_TSC = 8;
pub const UART4_EXTI34 = 52;
pub const USB_WKUP = 42;
pub const TIM8_UP = 44;
pub const TIM1_UP_TIM16 = 25;
pub const USART3_EXTI28 = 39;
pub const TIM8_CC = 46;
pub const ADC1_2 = 18;
pub const DMA2_CH2 = 57;
pub const I2C1_ER = 32;
pub const USB_HP_CAN_TX = 19;
pub const FLASH = 4;
pub const TIM3 = 29;
pub const PVD = 1;
pub const UART5_EXTI35 = 53;
pub const DMA1_CH5 = 15;
pub const SPI1 = 35;
pub const EXTI4 = 10;
pub const FPU = 81;
}; | src/f303re.zig |
usingnamespace @import("raylib");
pub fn main() anyerror!void
{
// Initialization
//--------------------------------------------------------------------------------------
const screenWidth = 800;
const screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib-zig [core] example - basic window");
var ballPosition = Vector2 { .x = -100.0, .y = -100.0 };
var ballColor = BEIGE;
var touchCounter: f32 = 0;
var touchPosition = Vector2 { .x = 0.0, .y = 0.0 };
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
ballPosition = GetMousePosition();
ballColor = BEIGE;
if (IsMouseButtonDown(MouseButton.MOUSE_LEFT_BUTTON)) { ballColor = MAROON; }
if (IsMouseButtonDown(MouseButton.MOUSE_MIDDLE_BUTTON)) { ballColor = LIME; }
if (IsMouseButtonDown(MouseButton.MOUSE_RIGHT_BUTTON)) { ballColor = DARKBLUE; }
if (IsMouseButtonPressed(MouseButton.MOUSE_LEFT_BUTTON)) { touchCounter = 10; }
if (IsMouseButtonPressed(MouseButton.MOUSE_MIDDLE_BUTTON)) { touchCounter = 10; }
if (IsMouseButtonPressed(MouseButton.MOUSE_RIGHT_BUTTON)) { touchCounter = 10; }
if (touchCounter > 0) { touchCounter -= 1; }
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
const nums = [_]i32{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
for (nums) |i|
{
touchPosition = GetTouchPosition(i); // Get the touch point
if ((touchPosition.x >= 0) and (touchPosition.y >= 0)) // Make sure point is not (-1,-1) as this means there is no touch for it
{
// Draw circle and touch index number
DrawCircle(@floatToInt(c_int, touchPosition.x), @floatToInt(c_int, touchPosition.y), 34, ORANGE);
//DrawCircleV(touchPosition, 34, ORANGE);
DrawText(FormatText("%d", i), @floatToInt(c_int, touchPosition.x) - 10, @floatToInt(c_int, touchPosition.y) - 70, 40, BLACK);
}
}
// Draw the normal mouse location
DrawCircle(@floatToInt(c_int, ballPosition.x), @floatToInt(c_int, ballPosition.y), 30 + (touchCounter*3), ballColor);
//DrawCircleV(ballPosition, 30 + (touchCounter*3), ballColor);
DrawText("move ball with mouse and click mouse button to change color", 10, 10, 20, DARKGRAY);
DrawText("touch the screen at multiple locations to get multiple balls", 10, 30, 20, DARKGRAY);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
} | examples/core/input_multitouch.zig |
const os = @import("root").os;
const std = @import("std");
const assert = std.debug.assert;
const platform = os.platform;
const lalign = os.lib.libalign;
const page_sizes = platform.paging.page_sizes;
var free_roots = [_]usize{0} ** page_sizes.len;
var pmm_mutex = os.thread.Mutex{};
const reverse_sizes = {
var result: [page_sizes.len]usize = undefined;
for(page_sizes) |psz, i|
result[page_sizes.len - i - 1] = psz;
return result;
};
pub fn consume(phys: usize, size: usize) void {
pmm_mutex.lock();
defer pmm_mutex.unlock();
var sz = size;
var pp = phys;
outer: while(sz != 0) {
inline for(reverse_sizes) |psz, ri| {
const i = page_sizes.len - ri - 1;
if(sz >= psz and lalign.is_aligned(usize, psz, pp)) {
free_impl(pp, i);
sz -= psz;
pp += psz;
continue :outer;
}
}
unreachable;
}
}
pub fn good_size(size: usize) usize {
unreachable;
}
fn alloc_impl(ind: usize) error{OutOfMemory}!usize {
if(free_roots[ind] == 0) {
if(ind + 1 >= page_sizes.len)
return error.OutOfMemory;
var next = try alloc_impl(ind + 1);
var next_size = page_sizes[ind + 1];
const current_size = page_sizes[ind];
while(next_size > current_size) {
free_impl(next, ind);
next += current_size;
next_size -= current_size;
}
return next;
}
else {
const retval = free_roots[ind];
free_roots[ind] = os.platform.phys_ptr(*usize).from_int(retval).get_writeback().*;
return retval;
}
}
pub fn alloc_phys(size: usize) !usize {
inline for(page_sizes) |psz, i| {
if(size <= psz) {
pmm_mutex.lock();
defer pmm_mutex.unlock();
return alloc_impl(i);
}
}
return error.PhysAllocTooSmall;
}
fn free_impl(phys: usize, ind: usize) void {
const last = free_roots[ind];
free_roots[ind] = phys;
os.platform.phys_ptr(*usize).from_int(phys).get_writeback().* = last;
}
pub fn free_phys(phys: usize, size: usize) void {
pmm_mutex.lock();
defer pmm_mutex.unlock();
inline for(reverse_sizes) |psz, ri| {
const i = page_sizes.len - ri - 1;
if(size <= psz and lalign.is_aligned(usize, psz, phys)) {
return free_impl(phys, i);
}
}
unreachable;
}
pub fn phys_to_uncached_virt(phys: usize) usize {
return os.memory.paging.kernel_context.phys_to_uncached_virt(phys);
}
pub fn phys_to_write_combining_virt(phys: usize) usize {
return os.memory.paging.kernel_context.phys_to_write_combining_virt(phys);
}
pub fn phys_to_write_back_virt(phys: usize) usize {
return os.memory.paging.kernel_context.phys_to_write_back_virt(phys);
}
pub fn init() void {
pmm_mutex.init();
} | src/memory/pmm.zig |
const std = @import("std");
const WriteFileStep = std.build.WriteFileStep;
const LibExeObjStep = std.build.LibExeObjStep;
const CSourceFile = std.build.CSourceFile;
const LogStep = std.build.LogStep;
const Builder = std.build.Builder;
const Step = std.build.Step;
pub fn build(b: *Builder) !void {
// Standard release mode and cross target options.
const mode = b.standardReleaseOptions();
const target = b.standardTargetOptions(.{});
const strip = b.option(bool, "strip", "Strip debug symbols from executable") orelse false;
// Config struct to pass to other methods.
const config = JanetConfig.options(b, mode);
// Build the amalgamate source file.
const generated_src = amalgamate(b, config);
// Resolve the directory of the main client source file.
const mainclient_src = std.fs.path.join(
b.allocator,
&[_][]const u8{ config.root_dir, "src", "mainclient", "shell.c" },
) catch unreachable;
// Build a Janet standalone interpreter.
const exe = b.addExecutable("janet", null);
exe.step.dependOn(&generated_src.source.write_file.step.step);
config.apply(exe);
exe.strip = strip;
exe.addCSourceFileSource(generated_src);
exe.addCSourceFile(mainclient_src, &[_][]const u8{});
exe.setBuildMode(mode);
exe.setTarget(target);
exe.linkLibC();
exe.install();
// Build and run Janet standalone interpreter.
const run_step = exe.run();
if (b.args) |args|
run_step.addArgs(args);
run_step.step.dependOn(b.getInstallStep());
b.step("run", "Build and run the Janet interpreter").dependOn(&run_step.step);
// Build the Janet standalone interpreter and use it to run the test suite.
const test_step = b.step("test", "Build and execute the Janet test suite");
{
const test_path = std.fs.path.join(
b.allocator,
&[_][]const u8{ config.root_dir, "test" },
) catch unreachable;
var test_dir = std.fs.cwd().openDir(test_path, .{ .iterate = true }) catch unreachable;
defer test_dir.close();
var iter = test_dir.iterate();
while (iter.next() catch unreachable) |file| {
if (std.mem.startsWith(u8, file.name, "suite") and std.mem.endsWith(u8, file.name, ".janet")) {
const run_tests = exe.run();
run_tests.stderr_action = .ignore;
run_tests.addArg(file.name);
run_tests.cwd = test_path;
const test_success = b.addLog("Janet test suite {s} successful.\n", .{file.name[5..9]});
test_success.step.dependOn(&run_tests.step);
test_step.dependOn(&test_success.step);
}
}
}
}
/// Janet configuration (corresponds to options available in janet_conf.h).
pub const JanetConfig = struct {
/// The path in which the Janet repository is checked out.
root_dir: []const u8,
/// The path of the directory containing janet.h.
include_dir: []const u8,
/// The path of the directory containing janetconf.h.
conf_dir: []const u8,
// ===[Linking-related options]===
single_threaded: bool = false,
dynamic_modules: bool = true,
nanbox: bool = true,
// ===[Non-standard options]===
reduced_os: bool = false,
docstrings: bool = true,
sourcemaps: bool = true,
assembler: bool = true,
typed_array: bool = true,
int_types: bool = true,
process_api: bool = true,
peg_api: bool = true,
net_api: bool = true,
event_loop: bool = true,
realpath: bool = true,
symlinks: bool = true,
umask: bool = true,
// ===[Miscellaneous options]===
debug: bool = false,
prf: bool = false,
utc_mktime: bool = true,
ev_epoll: bool = false,
recursion_guard: ?u32 = null,
max_proto_depth: ?u32 = null,
max_macro_expand: ?u32 = null,
top_level_signal_macro: ?[]const u8 = null,
out_of_memory_macro: ?[]const u8 = null,
exit_macro: ?[]const u8 = null,
stack_max: ?u32 = null,
os_name: ?[]const u8 = null,
arch_name: ?[]const u8 = null,
// ===[Main client options]===
simple_getline: bool = false,
pub fn options(b: *Builder, mode: std.builtin.Mode) JanetConfig {
return .{
.root_dir = b.pathFromRoot("deps/janet"),
.include_dir = b.pathFromRoot("deps/janet/src/include"),
.conf_dir = b.pathFromRoot("deps/janet/src/conf"),
.single_threaded = b.option(bool, "single-threaded", "Create a single threaded build") orelse false,
.reduced_os = b.option(bool, "reduced-os", "Reduce reliance on OS-specific APIs") orelse false,
.nanbox = !(b.option(bool, "no-nanbox", "Disable nanboxing for Janet values") orelse false),
.dynamic_modules = !(b.option(bool, "no-dynamic-modules", "Do not include support for loading dynamic modules") orelse false),
.docstrings = !(b.option(bool, "no-docstrings", "Do not include docstrings in the core image") orelse false),
.sourcemaps = !(b.option(bool, "no-sourcemaps", "Do not include sourcemaps in the core image") orelse false),
.assembler = !(b.option(bool, "no-assembler", "Do not include the Janet bytecode assembly API") orelse false),
.typed_array = !(b.option(bool, "no-typed-array", "Do not include the Janet typed array API") orelse false),
.int_types = !(b.option(bool, "no-int-types", "Do not include the Janet integer types") orelse false),
.process_api = !(b.option(bool, "no-process-api", "Do not include the Janet process API") orelse false),
.peg_api = !(b.option(bool, "no-peg-api", "Do not include the Janet PEG API") orelse false),
.net_api = !(b.option(bool, "no-net-api", "Do not include the Janet network API") orelse false),
.event_loop = !(b.option(bool, "no-event-loop", "Do not include the Janet event loop") orelse false),
.realpath = !(b.option(bool, "no-realpath", "Do not support realpath system call") orelse false),
.symlinks = !(b.option(bool, "no-symlinks", "Do not support symlinks") orelse false),
.umask = !(b.option(bool, "no-umask", "Do not support setting umask") orelse false),
.utc_mktime = !(b.option(bool, "no-utc-mktime", "Do not use UTC with mktime") orelse false),
.prf = b.option(bool, "prf-hash", "Enable PRF hash function") orelse false,
.ev_epoll = b.option(bool, "use-epoll", "Use epoll in the event loop") orelse false,
.simple_getline = b.option(bool, "simple-getline", "Use simple getline API in the main client") orelse false,
.recursion_guard = b.option(u32, "recursion-guard", "Max recursion (default: 1024)"),
.max_proto_depth = b.option(u32, "max-proto-depth", "Max prototype depth (default: 200)"),
.max_macro_expand = b.option(u32, "max-macro-expand", "Maximum macro expansion (default: 200)"),
.stack_max = b.option(u32, "stack-max", "Maximum number of Janet values in stack (default: 16384)"),
.os_name = b.option([]const u8, "os-name", "Override OS name (default: based on target)"),
.arch_name = b.option([]const u8, "arch-name", "Override arch name (default: based on target)"),
.top_level_signal_macro = b.option([]const u8, "top-level-signal-macro", "Macro used to process top level signals"),
.out_of_memory_macro = b.option([]const u8, "out-of-memory-macro", "Macro used on out-of-memory condition"),
.exit_macro = b.option([]const u8, "assert-fail-macro", "Macro used to exit on assertion failure"),
.debug = if (mode == .Debug) true else false,
};
}
const MacroDef = union(enum) {
opt_in: []const u8,
opt_out: []const u8,
value: []const u8,
};
fn macroDef(comptime field: std.builtin.TypeInfo.StructField) MacroDef {
return struct {
const value: MacroDef = result: {
@setEvalBranchQuota(field.name.len * 200);
const name: []const u8 = if (std.mem.eql(u8, field.name, "event_loop"))
"EV"
else if (std.mem.eql(u8, field.name, "process_api"))
"PROCESSES"
else if (std.mem.eql(u8, field.name, "top_level_signal_macro"))
"JANET_TOP_LEVEL_SIGNAL(msg)"
else if (std.mem.eql(u8, field.name, "exit_macro"))
"JANET_EXIT(msg)"
else blk: {
var name_buf: [field.name.len]u8 = field.name[0..field.name.len].*;
for (name_buf) |*c|
c.* = std.ascii.toUpper(c.*);
break :blk if (std.mem.endsWith(u8, &name_buf, "_API"))
name_buf[0..(name_buf.len - "_API".len)]
else if (std.mem.endsWith(u8, &name_buf, "_MACRO"))
name_buf[0..(name_buf.len - "_MACRO".len)]
else
name_buf[0..];
};
break :result switch (field.field_type) {
bool => if (field.default_value.?)
.{ .opt_out = "JANET_NO_" ++ name ++ "=1" }
else
.{ .opt_in = "JANET_" ++ name ++ "=1" },
?[]const u8 => .{ .value = "JANET_" ++ name ++ "={s}" },
else => .{ .value = "JANET_" ++ name ++ "={}" },
};
};
}.value;
}
pub fn apply(config: JanetConfig, artifact: *LibExeObjStep) void {
const b = artifact.builder;
var buf = std.ArrayList(u8).init(b.allocator);
defer buf.deinit();
artifact.addIncludeDir(config.include_dir);
artifact.addIncludeDir(config.conf_dir);
inline for (std.meta.fields(JanetConfig)) |field| {
if (comptime !std.mem.endsWith(u8, field.name, "_dir")) {
switch (comptime macroDef(field)) {
.opt_in => |def| if (@field(config, field.name))
artifact.defineCMacro(def),
.opt_out => |def| if (!@field(config, field.name))
artifact.defineCMacro(def),
.value => |def| if (@field(config, field.name)) |value| {
buf.writer().print(def, .{value}) catch unreachable;
artifact.defineCMacro(buf.items);
buf.shrinkRetainingCapacity(0);
},
}
}
}
}
};
/// Return a `CSourceFile` that can be passed to `LibExeObjStep.addCSourceFileSource`.
pub fn amalgamate(b: *Builder, config: JanetConfig) CSourceFile {
const write_file = WriteFileBridge.init(bootstrap(b, config), config);
return .{
.source = .{
.write_file = .{
.step = write_file,
.basename = "janet.c",
},
},
.args = &[_][]const u8{"-fno-sanitize=undefined"},
};
}
/// Return a `LibExeObjStep` corresponding to `janet_boot` in traditional Janet.
pub fn bootstrap(b: *Builder, config: JanetConfig) *LibExeObjStep {
const exe = b.addExecutable("janet_boot", null);
config.apply(exe);
exe.defineCMacro("JANET_BOOTSTRAP=1");
exe.linkLibC();
const boot_path = std.fs.path.join(
b.allocator,
&[_][]const u8{ config.root_dir, "src", "boot" },
) catch unreachable;
const core_path = std.fs.path.join(
b.allocator,
&[_][]const u8{ config.root_dir, "src", "core" },
) catch unreachable;
for ([_][]const u8{ boot_path, core_path }) |path| {
var dir = std.fs.cwd().openDir(path, .{ .iterate = true }) catch unreachable;
defer dir.close();
var iter = dir.iterate();
while (iter.next() catch unreachable) |entry| {
if (std.mem.endsWith(u8, entry.name, ".c")) {
exe.addCSourceFile(
std.fs.path.join(
b.allocator,
&[_][]const u8{ path, entry.name },
) catch unreachable,
&[_][]const u8{"-fno-sanitize=undefined"},
);
}
}
}
return exe;
}
/// A step that bridges LibExeObjStep and WriteFileStep by capturing the bytes
/// of LibExeObjStep and injecting them into WriteFileStep. Used for generating
/// the amalgamate source file.
const WriteFileBridge = struct {
write_file: WriteFileStep,
config: JanetConfig,
step: Step,
/// Create a `WriteFileStep` from a `LibExeObjStep`. The `WriteFileStep` will
/// write the contents of the executable stdout to file named `.janet.c`.
fn init(boot: *LibExeObjStep, config: JanetConfig) *WriteFileStep {
const b = boot.builder;
const self = b.allocator.create(WriteFileBridge) catch unreachable;
self.step = Step.init(.Custom, "WriteFileBridge", b.allocator, make);
self.step.dependOn(&boot.step);
self.write_file = WriteFileStep.init(b);
self.write_file.add("janet.c", &[_]u8{});
self.write_file.step.dependOn(&self.step);
self.config = config;
return &self.write_file;
}
/// After the executable is built, run it and pipe output into the WriteFileStep.
fn make(step: *Step) !void {
const self = @fieldParentPtr(WriteFileBridge, "step", step);
const boot = @fieldParentPtr(LibExeObjStep, "step", step.dependencies.items[0]);
const child = try std.ChildProcess.init(
&[_][]const u8{ boot.getOutputPath(), self.config.root_dir },
boot.builder.allocator,
);
child.stdin_behavior = .Close;
child.stdout_behavior = .Pipe;
defer child.deinit();
try child.spawn();
if (child.stdout.?.reader().readAllAlloc(boot.builder.allocator, 10_000_000)) |output| {
const result = try child.wait();
if (result != .Exited or result.Exited != 0) {
std.log.err("janet_boot exit: {}", .{result});
std.os.exit(1);
}
self.write_file.files.items[0].bytes = output;
} else |err| {
_ = child.kill() catch {};
return err;
}
}
}; | build.zig |
const std = @import("std");
const assert = std.debug.assert;
pub fn Rc(comptime T: type) type {
return struct {
const refSize = u16;
refs: std.atomic.Int(refSize),
ptr: ?*T,
allocator: *std.mem.Allocator,
pub const Self = @This();
pub fn init(alloc: *std.mem.Allocator) !Self {
var data = try alloc.create(T);
return Self{
.refs = std.atomic.Int(refSize).init(1),
.ptr = data,
.allocator = alloc,
};
}
pub fn incRef(self: *Self) *Self {
if (self.ptr != null) {
_ = self.refs.incr();
}
return self;
}
pub fn decRef(self: *Self) void {
if (self.ptr != null) {
const val = self.refs.decr();
if (val == 1) {
self.deinit();
}
}
}
pub fn deinit(self: *Self) void {
self.refs.set(0);
// pointer may want to do its own stuff
if (self.ptr) |ptr| {
// TODO only call if @hasDecl(T, "deinit") returns true
ptr.deinit();
self.allocator.destroy(self.ptr);
}
self.ptr = null;
}
pub fn countRef(self: *Self) refSize {
return self.refs.get();
}
};
}
test "Rc all functions" {
var all = std.heap.page_allocator;
var rcint = try Rc(i32).init(all);
assert(rcint.ptr != null);
// reference adjustments
_ = rcint.incRef();
assert(rcint.countRef() == 2);
rcint.decRef();
// assignment
rcint.ptr.?.* = 0;
assert(rcint.ptr.?.* == 0);
// auto free
rcint.decRef();
assert(rcint.ptr == null);
}
test "Rc auto-free" {
var all = std.heap.page_allocator;
var rcint = try Rc(u32).init(all);
assert(rcint.ptr != null);
rcint.ptr.?.* = 1;
assert(freefn(&rcint) == 1);
assert(rcint.ptr == null);
}
fn freefn(data: *Rc(u32)) u32 {
defer data.decRef();
return data.ptr.?.*;
}
test "Threaded Rc" {
var all = std.heap.page_allocator;
var context = try Rc(Ctx).init(all);
context.ptr.?.val = 5;
var threads: [10]*std.Thread = undefined;
for (threads) |*t| {
t.* = try std.Thread.spawn(context.incRef(), worker);
}
context.decRef();
for (threads) |t|
t.wait();
assert(context.ptr == null);
}
const Ctx = struct {
val: u32,
};
fn worker(ctx: *Rc(Ctx)) void {
defer ctx.decRef();
if (ctx.ptr.?.val != 5) {
@panic("Nope");
}
}
// This is an extension from the original zRc.
/// Heap-aware Rc. Will destroy itself when the counter hits 1.
pub fn HeapRc(comptime T: type) type {
return struct {
const refSize = u16;
refs: std.atomic.Int(refSize),
ptr: ?*T,
allocator: *std.mem.Allocator,
pub const Self = @This();
pub fn init(alloc: *std.mem.Allocator) !*Self {
var self = try alloc.create(Self);
var data = try alloc.create(T);
self.* = Self{
.refs = std.atomic.Int(refSize).init(1),
.ptr = data,
.allocator = alloc,
};
return self;
}
pub fn incRef(self: *Self) *Self {
if (self.ptr != null) {
_ = self.refs.incr();
}
return self;
}
pub fn decRef(self: *Self) void {
if (self.ptr != null) {
_ = self.refs.decr();
const val = self.refs.get();
if (val == 1) {
self.deinit();
}
}
}
pub fn deinit(self: *Self) void {
self.refs.set(0);
// pointer may want to do its own stuff
if (self.ptr) |ptr| {
// TODO only call if @hasDecl(T, "deinit") returns true
ptr.deinit();
self.allocator.destroy(self.ptr);
}
self.ptr = null;
self.allocator.destroy(self);
}
pub fn countRef(self: *Self) refSize {
return self.refs.get();
}
};
} | src/rc.zig |
const std = @import("std");
const testing = std.testing;
const minInt = std.math.minInt;
const maxInt = std.math.maxInt;
pub fn encodeStrLen(len: u32, writer: anytype) @TypeOf(writer).Error!void {
if (len <= std.math.maxInt(u5)) {
return writer.writeIntBig(u8, 0xa0 | @truncate(u8, len));
}
if (len <= std.math.maxInt(u8)) {
try writer.writeIntBig(u8, 0xd9);
return writer.writeIntBig(u8, @truncate(u8, len));
}
if (len <= std.math.maxInt(u16)) {
try writer.writeIntBig(u8, 0xda);
return writer.writeIntBig(u16, @truncate(u16, len));
}
if (len <= std.math.maxInt(u32)) {
try writer.writeIntBig(u8, 0xdb);
return writer.writeIntBig(u32, len);
}
unreachable;
}
test "encode string length" {
try testEncode(encodeStrLen, "\xa0", .{@as(u32, 0x00)});
try testEncode(encodeStrLen, "\xa1", .{@as(u32, 0x01)});
try testEncode(encodeStrLen, "\xbe", .{@as(u32, 0x1e)});
try testEncode(encodeStrLen, "\xbf", .{@as(u32, 0x1f)});
try testEncode(encodeStrLen, "\xd9\x20", .{@as(u32, 0x20)});
try testEncode(encodeStrLen, "\xd9\xfe", .{@as(u32, 0xfe)});
try testEncode(encodeStrLen, "\xd9\xff", .{@as(u32, 0xff)});
try testEncode(encodeStrLen, "\xda\x01\x00", .{@as(u32, 0x0100)});
try testEncode(encodeStrLen, "\xda\xff\xfe", .{@as(u32, 0xfffe)});
try testEncode(encodeStrLen, "\xda\xff\xff", .{@as(u32, 0xffff)});
try testEncode(encodeStrLen, "\xdb\x00\x01\x00\x00", .{@as(u32, 0x00010000)});
try testEncode(encodeStrLen, "\xdb\xff\xff\xff\xfe", .{@as(u32, 0xfffffffe)});
try testEncode(encodeStrLen, "\xdb\xff\xff\xff\xff", .{@as(u32, 0xffffffff)});
try testEncode(encodeStrLen, "\xa0", .{@as(comptime_int, 0x00)});
try testEncode(encodeStrLen, "\xa1", .{@as(comptime_int, 0x01)});
try testEncode(encodeStrLen, "\xbe", .{@as(comptime_int, 0x1e)});
try testEncode(encodeStrLen, "\xbf", .{@as(comptime_int, 0x1f)});
try testEncode(encodeStrLen, "\xd9\x20", .{@as(comptime_int, 0x20)});
try testEncode(encodeStrLen, "\xd9\xfe", .{@as(comptime_int, 0xfe)});
try testEncode(encodeStrLen, "\xd9\xff", .{@as(comptime_int, 0xff)});
try testEncode(encodeStrLen, "\xda\x01\x00", .{@as(comptime_int, 0x0100)});
try testEncode(encodeStrLen, "\xda\xff\xfe", .{@as(comptime_int, 0xfffe)});
try testEncode(encodeStrLen, "\xda\xff\xff", .{@as(comptime_int, 0xffff)});
try testEncode(encodeStrLen, "\xdb\x00\x01\x00\x00", .{@as(comptime_int, 0x00010000)});
try testEncode(encodeStrLen, "\xdb\xff\xff\xff\xfe", .{@as(comptime_int, 0xfffffffe)});
try testEncode(encodeStrLen, "\xdb\xff\xff\xff\xff", .{@as(comptime_int, 0xffffffff)});
}
pub inline fn encodeStr(str: []const u8, writer: anytype) @TypeOf(writer).Error!void {
try encodeStrLen(@truncate(u32, str.len), writer);
return writer.writeAll(str);
}
test "encode string" {
try testEncode(encodeStr, "\xa6string", .{"string"});
}
pub fn encodeBinLen(len: u32, writer: anytype) @TypeOf(writer).Error!void {
if (len <= std.math.maxInt(u8)) {
try writer.writeIntBig(u8, 0xc4);
return writer.writeIntBig(u8, @truncate(u8, len));
}
if (len <= std.math.maxInt(u16)) {
try writer.writeIntBig(u8, 0xc5);
return writer.writeIntBig(u16, @truncate(u16, len));
}
if (len <= std.math.maxInt(u32)) {
try writer.writeIntBig(u8, 0xc6);
return writer.writeIntBig(u32, @truncate(u32, len));
}
unreachable;
}
test "encode bin length" {
try testEncode(encodeBinLen, "\xc4\x00", .{@as(u32, 0x00)});
try testEncode(encodeBinLen, "\xc4\x01", .{@as(u32, 0x01)});
try testEncode(encodeBinLen, "\xc4\x1e", .{@as(u32, 0x1e)});
try testEncode(encodeBinLen, "\xc4\x1f", .{@as(u32, 0x1f)});
try testEncode(encodeBinLen, "\xc4\x20", .{@as(u32, 0x20)});
try testEncode(encodeBinLen, "\xc4\xfe", .{@as(u32, 0xfe)});
try testEncode(encodeBinLen, "\xc4\xff", .{@as(u32, 0xff)});
try testEncode(encodeBinLen, "\xc5\x01\x00", .{@as(u32, 0x0100)});
try testEncode(encodeBinLen, "\xc5\xff\xfe", .{@as(u32, 0xfffe)});
try testEncode(encodeBinLen, "\xc5\xff\xff", .{@as(u32, 0xffff)});
try testEncode(encodeBinLen, "\xc6\x00\x01\x00\x00", .{@as(u32, 0x00010000)});
try testEncode(encodeBinLen, "\xc6\xff\xff\xff\xfe", .{@as(u32, 0xfffffffe)});
try testEncode(encodeBinLen, "\xc6\xff\xff\xff\xff", .{@as(u32, 0xffffffff)});
try testEncode(encodeBinLen, "\xc4\x00", .{@as(comptime_int, 0x00)});
try testEncode(encodeBinLen, "\xc4\x01", .{@as(comptime_int, 0x01)});
try testEncode(encodeBinLen, "\xc4\x1e", .{@as(comptime_int, 0x1e)});
try testEncode(encodeBinLen, "\xc4\x1f", .{@as(comptime_int, 0x1f)});
try testEncode(encodeBinLen, "\xc4\x20", .{@as(comptime_int, 0x20)});
try testEncode(encodeBinLen, "\xc4\xfe", .{@as(comptime_int, 0xfe)});
try testEncode(encodeBinLen, "\xc4\xff", .{@as(comptime_int, 0xff)});
try testEncode(encodeBinLen, "\xc5\x01\x00", .{@as(comptime_int, 0x0100)});
try testEncode(encodeBinLen, "\xc5\xff\xfe", .{@as(comptime_int, 0xfffe)});
try testEncode(encodeBinLen, "\xc5\xff\xff", .{@as(comptime_int, 0xffff)});
try testEncode(encodeBinLen, "\xc6\x00\x01\x00\x00", .{@as(comptime_int, 0x00010000)});
try testEncode(encodeBinLen, "\xc6\xff\xff\xff\xfe", .{@as(comptime_int, 0xfffffffe)});
try testEncode(encodeBinLen, "\xc6\xff\xff\xff\xff", .{@as(comptime_int, 0xffffffff)});
}
pub inline fn encodeBin(bin: []const u8, writer: anytype) @TypeOf(writer).Error!void {
try encodeBinLen(@truncate(u32, bin.len), writer);
return writer.writeAll(bin);
}
pub fn encodeExtLen(ext_type: i8, len: u32, writer: anytype) @TypeOf(writer).Error!void {
switch (len) {
1 => try writer.writeIntBig(u8, 0xd4),
2 => try writer.writeIntBig(u8, 0xd5),
4 => try writer.writeIntBig(u8, 0xd6),
8 => try writer.writeIntBig(u8, 0xd7),
16 => try writer.writeIntBig(u8, 0xd8),
else => if (len <= std.math.maxInt(u8)) {
try writer.writeIntBig(u8, 0xc7);
try writer.writeIntBig(u8, @truncate(u8, len));
} else if (len <= std.math.maxInt(u16)) {
try writer.writeIntBig(u8, 0xc8);
try writer.writeIntBig(u16, @truncate(u16, len));
} else if (len <= std.math.maxInt(u32)) {
try writer.writeIntBig(u8, 0xc9);
try writer.writeIntBig(u32, len);
} else {
unreachable;
},
}
return writer.writeIntBig(i8, ext_type);
}
test "encode extension length" {
try testEncode(encodeExtLen, "\xd4\x00", .{ @as(i8, 0), @as(u32, 0x01) });
try testEncode(encodeExtLen, "\xd5\x00", .{ @as(i8, 0), @as(u32, 0x02) });
try testEncode(encodeExtLen, "\xd6\x00", .{ @as(i8, 0), @as(u32, 0x04) });
try testEncode(encodeExtLen, "\xd7\x00", .{ @as(i8, 0), @as(u32, 0x08) });
try testEncode(encodeExtLen, "\xd8\x00", .{ @as(i8, 0), @as(u32, 0x10) });
// ext 8
try testEncode(encodeExtLen, "\xc7\x11\x00", .{ @as(i8, 0), @as(u32, 0x11) });
try testEncode(encodeExtLen, "\xc7\xfe\x00", .{ @as(i8, 0), @as(u32, 0xfe) });
try testEncode(encodeExtLen, "\xc7\xff\x00", .{ @as(i8, 0), @as(u32, 0xff) });
try testEncode(encodeExtLen, "\xc7\x00\x00", .{ @as(i8, 0), @as(u32, 0x00) });
try testEncode(encodeExtLen, "\xc7\x03\x00", .{ @as(i8, 0), @as(u32, 0x03) });
try testEncode(encodeExtLen, "\xc7\x05\x00", .{ @as(i8, 0), @as(u32, 0x05) });
try testEncode(encodeExtLen, "\xc7\x06\x00", .{ @as(i8, 0), @as(u32, 0x06) });
try testEncode(encodeExtLen, "\xc7\x07\x00", .{ @as(i8, 0), @as(u32, 0x07) });
try testEncode(encodeExtLen, "\xc7\x09\x00", .{ @as(i8, 0), @as(u32, 0x09) });
try testEncode(encodeExtLen, "\xc7\x0a\x00", .{ @as(i8, 0), @as(u32, 0x0a) });
try testEncode(encodeExtLen, "\xc7\x0b\x00", .{ @as(i8, 0), @as(u32, 0x0b) });
try testEncode(encodeExtLen, "\xc7\x0c\x00", .{ @as(i8, 0), @as(u32, 0x0c) });
try testEncode(encodeExtLen, "\xc7\x0d\x00", .{ @as(i8, 0), @as(u32, 0x0d) });
try testEncode(encodeExtLen, "\xc7\x0e\x00", .{ @as(i8, 0), @as(u32, 0x0e) });
try testEncode(encodeExtLen, "\xc7\x0f\x00", .{ @as(i8, 0), @as(u32, 0x0f) });
// ext 16
try testEncode(encodeExtLen, "\xc8\x01\x00\x00", .{ @as(i8, 0), @as(u32, 0x0100) });
try testEncode(encodeExtLen, "\xc8\x01\x01\x00", .{ @as(i8, 0), @as(u32, 0x0101) });
try testEncode(encodeExtLen, "\xc8\xff\xfe\x00", .{ @as(i8, 0), @as(u32, 0xfffe) });
try testEncode(encodeExtLen, "\xc8\xff\xff\x00", .{ @as(i8, 0), @as(u32, 0xffff) });
// ext 32
try testEncode(encodeExtLen, "\xc9\x00\x01\x00\x00\x00", .{ @as(i8, 0), @as(u32, 0x00010000) });
try testEncode(encodeExtLen, "\xc9\x00\x01\x00\x01\x00", .{ @as(i8, 0), @as(u32, 0x00010001) });
try testEncode(encodeExtLen, "\xc9\xff\xff\xff\xfe\x00", .{ @as(i8, 0), @as(u32, 0xfffffffe) });
try testEncode(encodeExtLen, "\xc9\xff\xff\xff\xff\x00", .{ @as(i8, 0), @as(u32, 0xffffffff) });
try testEncode(encodeExtLen, "\xd4\x00", .{ @as(i8, 0), @as(comptime_int, 0x01) });
try testEncode(encodeExtLen, "\xd5\x00", .{ @as(i8, 0), @as(comptime_int, 0x02) });
try testEncode(encodeExtLen, "\xd6\x00", .{ @as(i8, 0), @as(comptime_int, 0x04) });
try testEncode(encodeExtLen, "\xd7\x00", .{ @as(i8, 0), @as(comptime_int, 0x08) });
try testEncode(encodeExtLen, "\xd8\x00", .{ @as(i8, 0), @as(comptime_int, 0x10) });
// ext 8
try testEncode(encodeExtLen, "\xc7\x11\x00", .{ @as(i8, 0), @as(comptime_int, 0x11) });
try testEncode(encodeExtLen, "\xc7\xfe\x00", .{ @as(i8, 0), @as(comptime_int, 0xfe) });
try testEncode(encodeExtLen, "\xc7\xff\x00", .{ @as(i8, 0), @as(comptime_int, 0xff) });
try testEncode(encodeExtLen, "\xc7\x00\x00", .{ @as(i8, 0), @as(comptime_int, 0x00) });
try testEncode(encodeExtLen, "\xc7\x03\x00", .{ @as(i8, 0), @as(comptime_int, 0x03) });
try testEncode(encodeExtLen, "\xc7\x05\x00", .{ @as(i8, 0), @as(comptime_int, 0x05) });
try testEncode(encodeExtLen, "\xc7\x06\x00", .{ @as(i8, 0), @as(comptime_int, 0x06) });
try testEncode(encodeExtLen, "\xc7\x07\x00", .{ @as(i8, 0), @as(comptime_int, 0x07) });
try testEncode(encodeExtLen, "\xc7\x09\x00", .{ @as(i8, 0), @as(comptime_int, 0x09) });
try testEncode(encodeExtLen, "\xc7\x0a\x00", .{ @as(i8, 0), @as(comptime_int, 0x0a) });
try testEncode(encodeExtLen, "\xc7\x0b\x00", .{ @as(i8, 0), @as(comptime_int, 0x0b) });
try testEncode(encodeExtLen, "\xc7\x0c\x00", .{ @as(i8, 0), @as(comptime_int, 0x0c) });
try testEncode(encodeExtLen, "\xc7\x0d\x00", .{ @as(i8, 0), @as(comptime_int, 0x0d) });
try testEncode(encodeExtLen, "\xc7\x0e\x00", .{ @as(i8, 0), @as(comptime_int, 0x0e) });
try testEncode(encodeExtLen, "\xc7\x0f\x00", .{ @as(i8, 0), @as(comptime_int, 0x0f) });
// ext 16
try testEncode(encodeExtLen, "\xc8\x01\x00\x00", .{ @as(i8, 0), @as(comptime_int, 0x0100) });
try testEncode(encodeExtLen, "\xc8\x01\x01\x00", .{ @as(i8, 0), @as(comptime_int, 0x0101) });
try testEncode(encodeExtLen, "\xc8\xff\xfe\x00", .{ @as(i8, 0), @as(comptime_int, 0xfffe) });
try testEncode(encodeExtLen, "\xc8\xff\xff\x00", .{ @as(i8, 0), @as(comptime_int, 0xffff) });
// ext 32
try testEncode(encodeExtLen, "\xc9\x00\x01\x00\x00\x00", .{ @as(i8, 0), @as(comptime_int, 0x00010000) });
try testEncode(encodeExtLen, "\xc9\x00\x01\x00\x01\x00", .{ @as(i8, 0), @as(comptime_int, 0x00010001) });
try testEncode(encodeExtLen, "\xc9\xff\xff\xff\xfe\x00", .{ @as(i8, 0), @as(comptime_int, 0xfffffffe) });
try testEncode(encodeExtLen, "\xc9\xff\xff\xff\xff\x00", .{ @as(i8, 0), @as(comptime_int, 0xffffffff) });
}
pub inline fn encodeExt(ext_type: i8, bin: []const u8, writer: anytype) @TypeOf(writer).Error!void {
try encodeExtLen(ext_type, @truncate(u32, bin.len), writer);
return writer.writeAll(bin);
}
pub inline fn encodeNil(writer: anytype) @TypeOf(writer).Error!void {
return writer.writeIntBig(u8, 0xc0);
}
test "encode nil" {
try testEncode(encodeNil, "\xc0", .{});
}
pub inline fn encodeFloat(num: anytype, writer: anytype) @TypeOf(writer).Error!void {
comptime const T = @TypeOf(num);
comptime const bits = switch (@typeInfo(T)) {
.Float => |floatTypeInfo| floatTypeInfo.bits,
.ComptimeFloat => 64,
else => @compileError("Unable to encode type '" ++ @typeName(T) ++ "'"),
};
if (bits <= 32) {
try writer.writeIntBig(u8, 0xca);
const casted = @bitCast(u32, @floatCast(f32, num));
return writer.writeIntBig(u32, casted);
}
if (bits <= 64) {
try writer.writeIntBig(u8, 0xcb);
const casted = @bitCast(u64, @floatCast(f64, num));
return writer.writeIntBig(u64, casted);
}
@compileError("Unable to encode type '" ++ @typeName(T) ++ "'");
}
test "test float and double" {
try testEncode(encodeFloat, "\xca\x3f\x80\x00\x00", .{@as(f32, 1.0)});
try testEncode(encodeFloat, "\xca\x40\x49\x0f\xdc", .{@as(f32, 3.141593)});
try testEncode(encodeFloat, "\xca\xfe\x96\x76\x99", .{@as(f32, -1e+38)});
try testEncode(encodeFloat, "\xcb\x3f\xf0\x00\x00\x00\x00\x00\x00", .{@as(f64, 1.0)});
try testEncode(encodeFloat, "\xcb\x40\x09\x21\xfb\x54\x44\x2d\x18", .{@as(f64, 3.141592653589793)});
try testEncode(encodeFloat, "\xcb\xd4\x7d\x42\xae\xa2\x87\x9f\x2e", .{@as(f64, -1e+99)});
try testEncode(encodeFloat, "\xcb\x3f\xf0\x00\x00\x00\x00\x00\x00", .{@as(comptime_float, 1.0)});
try testEncode(encodeFloat, "\xcb\x40\x09\x21\xfb\x54\x44\x2d\x18", .{@as(comptime_float, 3.141592653589793)});
try testEncode(encodeFloat, "\xcb\xd4\x7d\x42\xae\xa2\x87\x9f\x2e", .{@as(comptime_float, -1e+99)});
}
pub fn encodeInt(num: anytype, writer: anytype) @TypeOf(writer).Error!void {
comptime const T = @TypeOf(num);
comptime const intInfo = switch (@typeInfo(T)) {
.Int => |intInfo| intInfo,
.ComptimeInt => @typeInfo(std.math.IntFittingRange(num, num)).Int,
else => @compileError("Unable to encode type '" ++ @typeName(T) ++ "'"),
};
comptime var bits = intInfo.bits;
if (intInfo.is_signed) {
if (num < 0) {
if (bits <= 6 or num >= minInt(i6)) {
const casted = @truncate(i8, num);
return writer.writeIntBig(u8, 0xe0 | @bitCast(u8, casted));
}
if (bits <= 8 or num >= minInt(i8)) {
const casted = @truncate(i8, num);
try writer.writeIntBig(u8, 0xd0);
return writer.writeIntBig(i8, casted);
}
if (bits <= 16 or num >= minInt(i16)) {
const casted = @truncate(i16, num);
try writer.writeIntBig(u8, 0xd1);
return writer.writeIntBig(i16, casted);
}
if (bits <= 32 or num >= minInt(i32)) {
const casted = @truncate(i32, num);
try writer.writeIntBig(u8, 0xd2);
return writer.writeIntBig(i32, casted);
}
if (bits <= 64 or num >= minInt(i64)) {
const casted = @truncate(i64, num);
try writer.writeIntBig(u8, 0xd3);
return writer.writeIntBig(i64, casted);
}
@compileError("Unable to encode type '" ++ @typeName(T) ++ "'");
}
bits -= 1;
}
if (bits <= 7 or num <= maxInt(u7)) {
return writer.writeIntBig(u8, @intCast(u8, num));
}
if (bits <= 8 or num <= maxInt(u8)) {
try writer.writeIntBig(u8, 0xcc);
return writer.writeIntBig(u8, @intCast(u8, num));
}
if (bits <= 16 or num <= maxInt(u16)) {
try writer.writeIntBig(u8, 0xcd);
return writer.writeIntBig(u16, @intCast(u16, num));
}
if (bits <= 32 or num <= maxInt(u32)) {
try writer.writeIntBig(u8, 0xce);
return writer.writeIntBig(u32, @intCast(u32, num));
}
if (bits <= 64 or num <= maxInt(u64)) {
try writer.writeIntBig(u8, 0xcf);
return writer.writeIntBig(u64, @intCast(u64, num));
}
@compileError("Unable to encode type '" ++ @typeName(T) ++ "'");
}
test "encode int and uint" {
try testEncode(encodeInt, "\xff", .{@as(i8, -0x01)});
try testEncode(encodeInt, "\xe2", .{@as(i8, -0x1e)});
try testEncode(encodeInt, "\xe1", .{@as(i8, -0x1f)});
try testEncode(encodeInt, "\xe0", .{@as(i8, -0x20)});
try testEncode(encodeInt, "\xd0\xdf", .{@as(i8, -0x21)});
try testEncode(encodeInt, "\xd0\x81", .{@as(i8, -0x7f)});
try testEncode(encodeInt, "\xd0\x80", .{@as(i8, -0x80)});
try testEncode(encodeInt, "\xd1\xff\x7f", .{@as(i16, -0x81)});
try testEncode(encodeInt, "\xd1\x80\x01", .{@as(i16, -0x7fff)});
try testEncode(encodeInt, "\xd1\x80\x00", .{@as(i16, -0x8000)});
try testEncode(encodeInt, "\xd2\xff\xff\x7f\xff", .{@as(i32, -0x8001)});
try testEncode(encodeInt, "\xd2\x80\x00\x00\x01", .{@as(i32, -0x7fffffff)});
try testEncode(encodeInt, "\xd2\x80\x00\x00\x00", .{@as(i32, -0x80000000)});
try testEncode(encodeInt, "\xd3\xff\xff\xff\xff\x7f\xff\xff\xff", .{@as(i64, -0x80000001)});
try testEncode(encodeInt, "\xd3\x80\x00\x00\x00\x00\x00\x00\x01", .{@as(i64, -0x7fffffffffffffff)});
try testEncode(encodeInt, "\xd3\x80\x00\x00\x00\x00\x00\x00\x00", .{@as(i64, -0x8000000000000000)});
try testEncode(encodeInt, "\x00", .{@as(u8, 0)});
try testEncode(encodeInt, "\x01", .{@as(u8, 1)});
try testEncode(encodeInt, "\x7e", .{@as(u8, 0x7e)});
try testEncode(encodeInt, "\x7f", .{@as(u8, 0x7f)});
try testEncode(encodeInt, "\xcc\x80", .{@as(u16, 0x80)});
try testEncode(encodeInt, "\xcc\xfe", .{@as(u16, 0xfe)});
try testEncode(encodeInt, "\xcc\xff", .{@as(u16, 0xff)});
try testEncode(encodeInt, "\xcd\xff\xfe", .{@as(u32, 0xfffe)});
try testEncode(encodeInt, "\xcd\xff\xff", .{@as(u32, 0xffff)});
try testEncode(encodeInt, "\xce\x00\x01\x00\x00", .{@as(u64, 0x10000)});
try testEncode(encodeInt, "\xce\xff\xff\xff\xfe", .{@as(u64, 0xfffffffe)});
try testEncode(encodeInt, "\xce\xff\xff\xff\xff", .{@as(u64, 0xffffffff)});
try testEncode(encodeInt, "\xff", .{@as(comptime_int, -0x01)});
try testEncode(encodeInt, "\xe2", .{@as(comptime_int, -0x1e)});
try testEncode(encodeInt, "\xe1", .{@as(comptime_int, -0x1f)});
try testEncode(encodeInt, "\xe0", .{@as(comptime_int, -0x20)});
try testEncode(encodeInt, "\xd0\xdf", .{@as(comptime_int, -0x21)});
try testEncode(encodeInt, "\xd0\x81", .{@as(comptime_int, -0x7f)});
try testEncode(encodeInt, "\xd0\x80", .{@as(comptime_int, -0x80)});
try testEncode(encodeInt, "\xd1\xff\x7f", .{@as(comptime_int, -0x81)});
try testEncode(encodeInt, "\xd1\x80\x01", .{@as(comptime_int, -0x7fff)});
try testEncode(encodeInt, "\xd1\x80\x00", .{@as(comptime_int, -0x8000)});
try testEncode(encodeInt, "\xd2\xff\xff\x7f\xff", .{@as(comptime_int, -0x8001)});
try testEncode(encodeInt, "\xd2\x80\x00\x00\x01", .{@as(comptime_int, -0x7fffffff)});
try testEncode(encodeInt, "\xd2\x80\x00\x00\x00", .{@as(comptime_int, -0x80000000)});
try testEncode(encodeInt, "\xd3\xff\xff\xff\xff\x7f\xff\xff\xff", .{@as(comptime_int, -0x80000001)});
try testEncode(encodeInt, "\xd3\x80\x00\x00\x00\x00\x00\x00\x01", .{@as(comptime_int, -0x7fffffffffffffff)});
try testEncode(encodeInt, "\xd3\x80\x00\x00\x00\x00\x00\x00\x00", .{@as(comptime_int, -0x8000000000000000)});
try testEncode(encodeInt, "\x00", .{@as(comptime_int, 0)});
try testEncode(encodeInt, "\x01", .{@as(comptime_int, 1)});
try testEncode(encodeInt, "\x7e", .{@as(comptime_int, 0x7e)});
try testEncode(encodeInt, "\x7f", .{@as(comptime_int, 0x7f)});
try testEncode(encodeInt, "\xcc\x80", .{@as(comptime_int, 0x80)});
try testEncode(encodeInt, "\xcc\xfe", .{@as(comptime_int, 0xfe)});
try testEncode(encodeInt, "\xcc\xff", .{@as(comptime_int, 0xff)});
try testEncode(encodeInt, "\xcd\xff\xfe", .{@as(comptime_int, 0xfffe)});
try testEncode(encodeInt, "\xcd\xff\xff", .{@as(comptime_int, 0xffff)});
try testEncode(encodeInt, "\xce\x00\x01\x00\x00", .{@as(comptime_int, 0x10000)});
try testEncode(encodeInt, "\xce\xff\xff\xff\xfe", .{@as(comptime_int, 0xfffffffe)});
try testEncode(encodeInt, "\xce\xff\xff\xff\xff", .{@as(comptime_int, 0xffffffff)});
}
pub inline fn encodeBool(val: bool, writer: anytype) @TypeOf(writer).Error!void {
return writer.writeIntBig(u8, @as(u8, if (val) 0xc3 else 0xc2));
}
test "encode bool" {
try testEncode(encodeBool, "\xc3", .{true});
try testEncode(encodeBool, "\xc2", .{false});
}
pub fn encodeArrayLen(len: u32, writer: anytype) @TypeOf(writer).Error!void {
if (len <= std.math.maxInt(u4)) {
return writer.writeIntBig(u8, 0x90 | @truncate(u8, len));
}
if (len <= std.math.maxInt(u16)) {
try writer.writeIntBig(u8, 0xdc);
return writer.writeIntBig(u16, @truncate(u16, len));
}
try writer.writeIntBig(u8, 0xdd);
return writer.writeIntBig(u32, @truncate(u32, len));
}
test "encode array length" {
try testEncode(encodeArrayLen, "\x90", .{@as(u32, 0)});
try testEncode(encodeArrayLen, "\x91", .{@as(u32, 1)});
try testEncode(encodeArrayLen, "\x9f", .{@as(u32, 15)});
try testEncode(encodeArrayLen, "\xdc\x00\x10", .{@as(u32, 16)});
try testEncode(encodeArrayLen, "\xdc\xff\xfe", .{@as(u32, 0xfffe)});
try testEncode(encodeArrayLen, "\xdc\xff\xff", .{@as(u32, 0xffff)});
try testEncode(encodeArrayLen, "\xdd\x00\x01\x00\x00", .{@as(u32, 0x10000)});
try testEncode(encodeArrayLen, "\xdd\xff\xff\xff\xfe", .{@as(u32, 0xfffffffe)});
try testEncode(encodeArrayLen, "\xdd\xff\xff\xff\xff", .{@as(u32, 0xffffffff)});
try testEncode(encodeArrayLen, "\x90", .{@as(comptime_int, 0)});
try testEncode(encodeArrayLen, "\x91", .{@as(comptime_int, 1)});
try testEncode(encodeArrayLen, "\x9f", .{@as(comptime_int, 15)});
try testEncode(encodeArrayLen, "\xdc\x00\x10", .{@as(comptime_int, 16)});
try testEncode(encodeArrayLen, "\xdc\xff\xfe", .{@as(comptime_int, 0xfffe)});
try testEncode(encodeArrayLen, "\xdc\xff\xff", .{@as(comptime_int, 0xffff)});
try testEncode(encodeArrayLen, "\xdd\x00\x01\x00\x00", .{@as(comptime_int, 0x10000)});
try testEncode(encodeArrayLen, "\xdd\xff\xff\xff\xfe", .{@as(comptime_int, 0xfffffffe)});
try testEncode(encodeArrayLen, "\xdd\xff\xff\xff\xff", .{@as(comptime_int, 0xffffffff)});
}
pub inline fn encodeArray(arr: anytype, options: EncodingOptions, writer: anytype) @TypeOf(writer).Error!void {
comptime const T = @TypeOf(arr);
switch (@typeInfo(T)) {
.Pointer => |ptr_info| switch (ptr_info.size) {
.One => switch (@typeInfo(ptr_info.child)) {
.Array => {
const Slice = []const std.meta.Elem(ptr_info.child);
return encodeArray(@as(Slice, arr), options, writer);
},
else => @compileError("Unable to encode type '" ++ @typeName(T) ++ "'"),
},
.Many, .Slice => {
try encodeArrayLen(@truncate(u32, arr.len), writer);
for (arr) |value| {
try encode(value, options, writer);
}
},
else => @compileError("Unable to encode type '" ++ @typeName(T) ++ "'"),
},
.Array => {
return encodeArray(&arr, options, writer);
},
else => @compileError("Unable to encode type '" ++ @typeName(T) ++ "'"),
}
}
test "encode array" {
var testArray = [_]i32{ 1, 2, 3, 4 };
try testEncode(encodeArray, "\x94\x01\x02\x03\x04", .{ testArray, .{} });
try testEncode(encodeArray, "\x94\x01\x02\x03\x04", .{ &testArray, .{} });
try testEncode(encodeArray, "\x94\x01\x02\x03\x04", .{ testArray[0..testArray.len], .{} });
}
pub fn encodeMapLen(len: u32, writer: anytype) @TypeOf(writer).Error!void {
if (len <= std.math.maxInt(u4)) {
return writer.writeIntBig(u8, 0x80 | @truncate(u8, len));
}
if (len <= std.math.maxInt(u16)) {
try writer.writeIntBig(u8, 0xde);
return writer.writeIntBig(u16, @truncate(u16, len));
}
if (len <= std.math.maxInt(u32)) {
try writer.writeIntBig(u8, 0xdf);
return writer.writeIntBig(u32, @truncate(u32, len));
}
unreachable;
}
test "encode map length" {
try testEncode(encodeMapLen, "\x80", .{@as(u32, 0)});
try testEncode(encodeMapLen, "\x81", .{@as(u32, 1)});
try testEncode(encodeMapLen, "\x8f", .{@as(u32, 15)});
try testEncode(encodeMapLen, "\xde\x00\x10", .{@as(u32, 16)});
try testEncode(encodeMapLen, "\xde\xff\xfe", .{@as(u32, 0xfffe)});
try testEncode(encodeMapLen, "\xde\xff\xff", .{@as(u32, 0xffff)});
try testEncode(encodeMapLen, "\xdf\x00\x01\x00\x00", .{@as(u32, 0x10000)});
try testEncode(encodeMapLen, "\xdf\xff\xff\xff\xfe", .{@as(u32, 0xfffffffe)});
try testEncode(encodeMapLen, "\xdf\xff\xff\xff\xff", .{@as(u32, 0xffffffff)});
try testEncode(encodeMapLen, "\x80", .{@as(comptime_int, 0)});
try testEncode(encodeMapLen, "\x81", .{@as(comptime_int, 1)});
try testEncode(encodeMapLen, "\x8f", .{@as(comptime_int, 15)});
try testEncode(encodeMapLen, "\xde\x00\x10", .{@as(comptime_int, 16)});
try testEncode(encodeMapLen, "\xde\xff\xfe", .{@as(comptime_int, 0xfffe)});
try testEncode(encodeMapLen, "\xde\xff\xff", .{@as(comptime_int, 0xffff)});
try testEncode(encodeMapLen, "\xdf\x00\x01\x00\x00", .{@as(comptime_int, 0x10000)});
try testEncode(encodeMapLen, "\xdf\xff\xff\xff\xfe", .{@as(comptime_int, 0xfffffffe)});
try testEncode(encodeMapLen, "\xdf\xff\xff\xff\xff", .{@as(comptime_int, 0xffffffff)});
}
pub inline fn encodeStruct(
structure: anytype,
options: EncodingOptions,
writer: anytype,
) @TypeOf(writer).Error!void {
const T = @TypeOf(structure);
if (comptime std.meta.trait.hasFn("encodeMsgPack")(T)) {
return structure.encodeMsgPack(options, writer);
}
comptime const fields = @typeInfo(T).Struct.fields;
try switch (options.struct_encoding) {
.array => encodeArrayLen(fields.len, writer),
.map => encodeMapLen(fields.len, writer),
};
inline for (fields) |Field| {
if (Field.field_type == void) {
continue;
}
if (options.struct_encoding == StructEncoding.map) {
try encode(Field.name, options, writer);
}
try encode(@field(structure, Field.name), options, writer);
}
}
test "encode struct" {
const testingStruct = .{
.int = @as(i32, 65534),
.float = @as(f64, 3.141592653589793),
.boolean = true,
.nil = null,
.string = "string",
.array = @as([4]i16, .{ 11, 22, 33, 44 }),
};
try testEncode(
encodeStruct,
"\x96\xCD\xFF\xFE\xCB\x40\x09\x21\xFB\x54\x44\x2D\x18\xC3\xC0\xA6\x73\x74\x72\x69\x6E\x67\x94\x0B\x16\x21\x2C",
.{ testingStruct, .{ .struct_encoding = .array, .u8_array_encoding = .string } },
);
try testEncode(
encodeStruct,
"\x86\xA3\x69\x6E\x74\xCD\xFF\xFE\xA5\x66\x6C\x6F\x61\x74\xCB\x40\x09\x21\xFB\x54\x44\x2D\x18\xA7\x62\x6F\x6F\x6C\x65\x61\x6E\xC3\xA3\x6E\x69\x6C\xC0\xA6\x73\x74\x72\x69\x6E\x67\xA6\x73\x74\x72\x69\x6E\x67\xA5\x61\x72\x72\x61\x79\x94\x0B\x16\x21\x2C",
.{ testingStruct, .{ .struct_encoding = .map, .u8_array_encoding = .string } },
);
const CustomStruct = struct {
int: i64 = 0,
float: f64 = 0,
boolean: bool = false,
const Self = @This();
pub fn encodeMsgPack(value: Self, options: EncodingOptions, writer: anytype) @TypeOf(writer).Error!void {
return encodeBool(true, writer);
}
};
try testEncode(encodeStruct, "\xc3", .{
CustomStruct{},
.{},
});
}
pub inline fn encodeOptional(
value: anytype,
options: EncodingOptions,
writer: anytype,
) @TypeOf(writer).Error!void {
return if (value) |payload| encode(payload, options, writer) else encodeNil(writer);
}
test "encode optional" {
try testEncode(encodeOptional, "\xc0", .{ @as(?i32, null), .{} });
try testEncode(encodeOptional, "\xcd\xff\xfe", .{ @as(?i32, 65534), .{} });
}
pub fn encodeUnion(
value: anytype,
options: EncodingOptions,
writer: anytype,
) @TypeOf(writer).Error!void {
comptime const T = @TypeOf(value);
if (comptime std.meta.trait.hasFn("encodeMsgPack")(T)) {
return value.encodeMsgPack(options, writer);
}
comptime const info = switch (@typeInfo(T)) {
.Union => |unionInfo| unionInfo,
else => @compileError("Unable to encode type '" ++ @typeName(T) ++ "'"),
};
if (info.tag_type) |TagType| {
inline for (info.fields) |field| {
if (value == @field(TagType, field.name)) {
return encode(@field(value, field.name), options, writer);
}
}
} else {
@compileError("Unable to encode untagged union '" ++ @typeName(T) ++ "'");
}
}
test "encode tagged union" {
const TaggedUnion = union(enum) {
int: i64,
float: f64,
boolean: bool,
};
try testEncode(encodeUnion, "\xd3\xff\xff\xff\xff\x7f\xff\xff\xff", .{
TaggedUnion{ .int = -0x80000001 },
.{},
});
try testEncode(encodeUnion, "\xcb\x3f\xf0\x00\x00\x00\x00\x00\x00", .{
TaggedUnion{ .float = 1.0 },
.{},
});
try testEncode(encodeUnion, "\xc3", .{
TaggedUnion{ .boolean = true },
.{},
});
const TaggedUnionCustom = union(enum) {
int: i64,
float: f64,
boolean: bool,
const Self = @This();
pub fn encodeMsgPack(value: Self, options: EncodingOptions, writer: anytype) @TypeOf(writer).Error!void {
return encodeBool(true, writer);
}
};
try testEncode(encodeUnion, "\xc3", .{
TaggedUnionCustom{ .boolean = false },
.{},
});
const EnumCustom = enum {
a,
b,
c,
const Self = @This();
pub fn encodeMsgPack(value: Self, options: EncodingOptions, writer: anytype) @TypeOf(writer).Error!void {
return encodeBool(true, writer);
}
};
try testEncode(encode, "\xc3", .{
EnumCustom.a,
.{},
});
}
const U8ArrayEncoding = enum {
auto, // encodes as string if valid utf8 string, otherwise encodes as binary
array,
string,
binary,
};
const StructEncoding = enum {
array,
map,
};
pub const EncodingOptions = struct {
u8_array_encoding: U8ArrayEncoding = .auto,
struct_encoding: StructEncoding = .array,
};
pub inline fn encode(
value: anytype,
options: EncodingOptions,
writer: anytype,
) @TypeOf(writer).Error!void {
const T = @TypeOf(value);
return switch (@typeInfo(T)) {
.Float, .ComptimeFloat => encodeFloat(value, writer),
.Int, .ComptimeInt => encodeInt(value, writer),
.Bool => encodeBool(value, writer),
.Optional => encodeOptional(value, options, writer),
.Struct => encodeStruct(value, options, writer),
.Pointer => |ptr_info| switch (ptr_info.size) {
.One => switch (@typeInfo(ptr_info.child)) {
.Array => blk: {
const Slice = []const std.meta.Elem(ptr_info.child);
break :blk encode(@as(Slice, value), options, writer);
},
else => encode(value.*, options, writer),
},
.Many, .Slice => blk: {
if (ptr_info.child == u8) {
break :blk switch (options.u8_array_encoding) {
.array => encodeArray(value, options, writer),
.auto => {
if (std.unicode.utf8ValidateSlice(value)) {
break :blk encodeStr(value, writer);
} else {
break :blk encodeBin(value, writer);
}
},
.string => encodeStr(value, writer),
.binary => encodeBin(value, writer),
};
}
break :blk encodeArray(value, options, writer);
},
else => @compileError("Unable to encode type '" ++ @typeName(T) ++ "'"),
},
.Array => encodeArray(&value, options, writer),
.ErrorSet => encodeStr(@errorName(value), writer),
.Enum => {
if (comptime std.meta.trait.hasFn("encodeMsgPack")(T)) {
return value.encodeMsgPack(options, writer);
}
@compileError("Unable to encode enum '" ++ @typeName(T) ++ "'");
},
.Union => encodeUnion(value, options, writer),
.Null => encodeNil(writer),
else => @compileError("Unable to encode type '" ++ @typeName(T) ++ "'"),
};
}
test "encode" {
const opts = .{};
try testEncode(encode, "\xca\x40\x49\x0f\xdc", .{ @as(f32, 3.141593), opts });
try testEncode(encode, "\xcb\x40\x09\x21\xfb\x54\x44\x2d\x18", .{ @as(f64, 3.141592653589793), opts });
try testEncode(encode, "\xd2\xff\xff\x7f\xff", .{ @as(i32, -0x8001), opts });
try testEncode(encode, "\xcd\xff\xfe", .{ @as(u32, 0xfffe), opts });
try testEncode(encode, "\xc0", .{ null, opts });
try testEncode(encode, "\xc3", .{ true, opts });
try testEncode(encode, "\xc2", .{ false, opts });
try testEncode(encode, "\xa6string", .{ "string", opts });
try testEncode(encode, "\xc0", .{ @as(?i32, null), opts });
try testEncode(encode, "\xcd\xff\xfe", .{ @as(?i32, 65534), opts });
const testingStruct = .{
.int = @as(i32, 65534),
.float = @as(f64, 3.141592653589793),
.boolean = true,
.nil = null,
.string = "string",
.array = @as([4]i16, .{ 11, 22, 33, 44 }),
};
try testEncode(
encode,
"\x96\xCD\xFF\xFE\xCB\x40\x09\x21\xFB\x54\x44\x2D\x18\xC3\xC0\xA6\x73\x74\x72\x69\x6E\x67\x94\x0B\x16\x21\x2C",
.{ testingStruct, .{ .struct_encoding = .array, .u8_array_encoding = .string } },
);
try testEncode(
encode,
"\x86\xA3\x69\x6E\x74\xCD\xFF\xFE\xA5\x66\x6C\x6F\x61\x74\xCB\x40\x09\x21\xFB\x54\x44\x2D\x18\xA7\x62\x6F\x6F\x6C\x65\x61\x6E\xC3\xA3\x6E\x69\x6C\xC0\xA6\x73\x74\x72\x69\x6E\x67\xA6\x73\x74\x72\x69\x6E\x67\xA5\x61\x72\x72\x61\x79\x94\x0B\x16\x21\x2C",
.{ testingStruct, .{ .struct_encoding = .map, .u8_array_encoding = .string } },
);
var testArray = [_]i32{ 1, 2, 3, 4 };
try testEncode(encode, "\x94\x01\x02\x03\x04", .{ testArray, opts });
try testEncode(encode, "\x94\x01\x02\x03\x04", .{ &testArray, opts });
try testEncode(encode, "\x94\x01\x02\x03\x04", .{ testArray[0..testArray.len], opts });
const TaggedUnionCustom = union(enum) {
int: i64,
float: f64,
boolean: bool,
const Self = @This();
pub fn encodeMsgPack(value: Self, options: EncodingOptions, writer: anytype) @TypeOf(writer).Error!void {
return encodeBool(true, writer);
}
};
try testEncode(encode, "\xc3", .{
TaggedUnionCustom{ .boolean = false },
.{},
});
const test_string_non_utf8 = "\xff\xff\xff\xff";
try testEncode(encode, "\xC4\x04" ++ test_string_non_utf8, .{
test_string_non_utf8,
.{ .u8_array_encoding = .auto },
});
const test_string_utf8 = "some string";
try testEncode(encode, "\xAB" ++ test_string_utf8, .{
test_string_utf8,
.{ .u8_array_encoding = .auto },
});
try testEncode(encode, "\x9B" ++ test_string_utf8, .{
test_string_utf8,
.{ .u8_array_encoding = .array },
});
try testEncode(encode, "\xAB" ++ test_string_utf8, .{
test_string_utf8,
.{ .u8_array_encoding = .string },
});
try testEncode(encode, "\xC4\x0B" ++ test_string_utf8, .{
test_string_utf8,
.{ .u8_array_encoding = .binary },
});
}
fn testEncode(func: anytype, comptime expected: []const u8, input: anytype) !void {
var buf: [255]u8 = undefined;
var fbs = std.io.fixedBufferStream(&buf);
const writer = fbs.writer();
const args = input ++ .{writer};
try @call(.{}, func, args);
const result = fbs.getWritten();
testing.expectEqualSlices(u8, expected, result);
} | src/encoder.zig |
const std = @import("std");
const Allocator = std.mem.Allocator;
const vk = @import("../include/vk.zig");
const Render = @import("../lib.zig").Render;
const Context = @import("../backend/context.zig").Context;
const Framebuffer = @import("../backend/framebuffer.zig").Framebuffer;
pub const IObject = struct {
executeFn: fn (self: *const IObject, cb: vk.CommandBuffer, fb: Framebuffer) anyerror!void,
executePostFn: fn (self: *const IObject, cb: vk.CommandBuffer, fb: Framebuffer) anyerror!void,
renderpassFn: fn (self: *const IObject) vk.RenderPass,
pub fn execute(self: *const IObject, cb: vk.CommandBuffer, fb: Framebuffer) !void {
try self.executeFn(self, cb, fb);
}
pub fn executePost(self: *const IObject, cb: vk.CommandBuffer, fb: Framebuffer) !void {
try self.executePostFn(self, cb, fb);
}
pub fn renderpass(self: *const IObject) vk.RenderPass {
return self.renderpassFn(self);
}
};
pub const State = struct {
attachments: []const Attachment,
subpasses: []const SubPass,
/// Creates a new state with the specified overrides
pub fn override(comptime self: *const State, comptime Override: anytype) State {
comptime var new = State{
.attachments = self.attachments,
.subpasses = self.subpasses,
};
comptime for (@typeInfo(@TypeOf(Override)).Struct.fields) |field, i| {
if (@hasField(State, field.name)) {
if (std.mem.startsWith(u8, @typeName(field.field_type), "struct")) {
for (@typeInfo(field.field_type).Struct.fields) |inner_field, j| {
if (@hasField(@TypeOf(@field(new, field.name)), inner_field.name)) {
@field(@field(new, field.name), inner_field.name) = @field(@field(Override, field.name), inner_field.name);
}
}
} else {
@field(new, field.name) = @field(Override, field.name);
}
}
};
return new;
}
};
pub fn Object(comptime state: State) type {
return struct {
const Self = @This();
base: IObject = .{
.executeFn = execute,
.executePostFn = executePost,
.renderpassFn = renderpass,
},
context: *const Context,
clear_value: ?*const vk.ClearValue,
render_pass: vk.RenderPass,
pub fn build(render: *Render, clear_value: ?*const vk.ClearValue) !Self {
const context = &render.backend.context;
// create ColorAttachments
var color_attachments: [state.attachments.len]vk.AttachmentDescription = undefined;
for (state.attachments) |attachment, i| {
color_attachments[i] = .{
.format = if (attachment.format) |f| f else render.backend.swapchain.image_format,
.samples = attachment.samples,
.load_op = attachment.load_op,
.store_op = attachment.store_op,
.stencil_load_op = attachment.stencil_load_op,
.stencil_store_op = attachment.stencil_store_op,
.initial_layout = attachment.initial_layout,
.final_layout = attachment.final_layout,
.flags = .{},
};
}
// create Subpasses
comptime var subpasses: [state.subpasses.len]vk.SubpassDescription = undefined;
comptime for (state.subpasses) |subpass, i| {
var color_refs: [subpass.color_attachments.len]vk.AttachmentReference = undefined;
for (subpass.color_attachments) |attachment, j| {
color_refs[j] = vk.AttachmentReference{
.attachment = attachment.index,
.layout = attachment.layout,
};
}
subpasses[i] = vk.SubpassDescription{
.pipeline_bind_point = subpass.bind_point,
.input_attachment_count = 0,
.p_input_attachments = undefined,
.color_attachment_count = subpass.color_attachments.len,
.p_color_attachments = &color_refs,
.preserve_attachment_count = 0,
.p_preserve_attachments = undefined,
.p_resolve_attachments = undefined,
.p_depth_stencil_attachment = undefined,
.flags = .{},
};
};
// create RenderPass
const create_info = vk.RenderPassCreateInfo{
.attachment_count = color_attachments.len,
.p_attachments = &color_attachments,
.subpass_count = subpasses.len,
.p_subpasses = &subpasses,
.dependency_count = 0,
.p_dependencies = undefined,
.flags = .{},
};
const render_pass = try context.vkd.createRenderPass(context.device, create_info, null);
return Self{
.context = context,
.clear_value = clear_value,
.render_pass = render_pass,
};
}
pub fn deinit(self: Self) void {
self.context.vkd.destroyRenderPass(self.context.device, self.render_pass, null);
}
pub fn execute(base: *const IObject, cb: vk.CommandBuffer, fb: Framebuffer) !void {
const self = @fieldParentPtr(Self, "base", base);
const clear_value = if (self.clear_value) |cv| cv else &vk.ClearValue{ .color = .{ .float_32 = [4]f32{ 0.0, 0.0, 0.0, 1.0 } } };
self.context.vkd.cmdBeginRenderPass(cb, .{
.render_pass = self.render_pass,
.framebuffer = fb.framebuffer,
.render_area = vk.Rect2D{
.offset = vk.Offset2D{ .x = 0, .y = 0 },
.extent = fb.size,
},
.clear_value_count = 1,
.p_clear_values = @ptrCast([*]const vk.ClearValue, clear_value),
}, .@"inline");
}
pub fn executePost(base: *const IObject, cb: vk.CommandBuffer, fb: Framebuffer) !void {
const self = @fieldParentPtr(Self, "base", base);
self.context.vkd.cmdEndRenderPass(cb);
}
pub fn renderpass(base: *const IObject) vk.RenderPass {
return @fieldParentPtr(Self, "base", base).render_pass;
}
};
}
pub const Attachment = struct {
/// if null will use swapchain format
format: ?vk.Format,
samples: vk.SampleCountFlags,
load_op: vk.AttachmentLoadOp,
store_op: vk.AttachmentStoreOp,
stencil_load_op: vk.AttachmentLoadOp,
stencil_store_op: vk.AttachmentStoreOp,
initial_layout: vk.ImageLayout,
final_layout: vk.ImageLayout,
};
pub const SubPass = struct {
pub const Dependency = struct {
index: usize,
layout: vk.ImageLayout,
};
bind_point: vk.PipelineBindPoint,
color_attachments: []const Dependency,
// resolve_attachments: []const Dependency,
}; | render/src/program/renderpass.zig |
pub const IMAPI_SECTOR_SIZE = @as(u32, 2048);
pub const IMAPI2_DEFAULT_COMMAND_TIMEOUT = @as(u32, 10);
pub const DISPID_DDISCMASTER2EVENTS_DEVICEADDED = @as(u32, 256);
pub const DISPID_DDISCMASTER2EVENTS_DEVICEREMOVED = @as(u32, 257);
pub const DISPID_IDISCRECORDER2_EJECTMEDIA = @as(u32, 256);
pub const DISPID_IDISCRECORDER2_CLOSETRAY = @as(u32, 257);
pub const DISPID_IDISCRECORDER2_ACQUIREEXCLUSIVEACCESS = @as(u32, 258);
pub const DISPID_IDISCRECORDER2_RELEASEEXCLUSIVEACCESS = @as(u32, 259);
pub const DISPID_IDISCRECORDER2_DISABLEMCN = @as(u32, 260);
pub const DISPID_IDISCRECORDER2_ENABLEMCN = @as(u32, 261);
pub const DISPID_IDISCRECORDER2_INITIALIZEDISCRECORDER = @as(u32, 262);
pub const DISPID_IDISCRECORDER2_VENDORID = @as(u32, 513);
pub const DISPID_IDISCRECORDER2_PRODUCTID = @as(u32, 514);
pub const DISPID_IDISCRECORDER2_PRODUCTREVISION = @as(u32, 515);
pub const DISPID_IDISCRECORDER2_VOLUMENAME = @as(u32, 516);
pub const DISPID_IDISCRECORDER2_VOLUMEPATHNAMES = @as(u32, 517);
pub const DISPID_IDISCRECORDER2_DEVICECANLOADMEDIA = @as(u32, 518);
pub const DISPID_IDISCRECORDER2_LEGACYDEVICENUMBER = @as(u32, 519);
pub const DISPID_IDISCRECORDER2_SUPPORTEDFEATUREPAGES = @as(u32, 520);
pub const DISPID_IDISCRECORDER2_CURRENTFEATUREPAGES = @as(u32, 521);
pub const DISPID_IDISCRECORDER2_SUPPORTEDPROFILES = @as(u32, 522);
pub const DISPID_IDISCRECORDER2_CURRENTPROFILES = @as(u32, 523);
pub const DISPID_IDISCRECORDER2_SUPPORTEDMODEPAGES = @as(u32, 524);
pub const DISPID_IDISCRECORDER2_EXCLUSIVEACCESSOWNER = @as(u32, 525);
pub const DISPID_IWRITEENGINE2_WRITESECTION = @as(u32, 512);
pub const DISPID_IWRITEENGINE2_CANCELWRITE = @as(u32, 513);
pub const DISPID_IWRITEENGINE2_DISCRECORDER = @as(u32, 256);
pub const DISPID_IWRITEENGINE2_USESTREAMINGWRITE12 = @as(u32, 257);
pub const DISPID_IWRITEENGINE2_STARTINGSECTORSPERSECOND = @as(u32, 258);
pub const DISPID_IWRITEENGINE2_ENDINGSECTORSPERSECOND = @as(u32, 259);
pub const DISPID_IWRITEENGINE2_BYTESPERSECTOR = @as(u32, 260);
pub const DISPID_IWRITEENGINE2_WRITEINPROGRESS = @as(u32, 261);
pub const DISPID_IWRITEENGINE2EVENTARGS_STARTLBA = @as(u32, 256);
pub const DISPID_IWRITEENGINE2EVENTARGS_SECTORCOUNT = @as(u32, 257);
pub const DISPID_IWRITEENGINE2EVENTARGS_LASTREADLBA = @as(u32, 258);
pub const DISPID_IWRITEENGINE2EVENTARGS_LASTWRITTENLBA = @as(u32, 259);
pub const DISPID_IWRITEENGINE2EVENTARGS_TOTALDEVICEBUFFER = @as(u32, 260);
pub const DISPID_IWRITEENGINE2EVENTARGS_USEDDEVICEBUFFER = @as(u32, 261);
pub const DISPID_IWRITEENGINE2EVENTARGS_TOTALSYSTEMBUFFER = @as(u32, 262);
pub const DISPID_IWRITEENGINE2EVENTARGS_USEDSYSTEMBUFFER = @as(u32, 263);
pub const DISPID_IWRITEENGINE2EVENTARGS_FREESYSTEMBUFFER = @as(u32, 264);
pub const DISPID_DWRITEENGINE2EVENTS_UPDATE = @as(u32, 256);
pub const DISPID_IDISCFORMAT2_RECORDERSUPPORTED = @as(u32, 2048);
pub const DISPID_IDISCFORMAT2_MEDIASUPPORTED = @as(u32, 2049);
pub const DISPID_IDISCFORMAT2_MEDIAPHYSICALLYBLANK = @as(u32, 1792);
pub const DISPID_IDISCFORMAT2_MEDIAHEURISTICALLYBLANK = @as(u32, 1793);
pub const DISPID_IDISCFORMAT2_SUPPORTEDMEDIATYPES = @as(u32, 1794);
pub const DISPID_IDISCFORMAT2ERASE_RECORDER = @as(u32, 256);
pub const DISPID_IDISCFORMAT2ERASE_FULLERASE = @as(u32, 257);
pub const DISPID_IDISCFORMAT2ERASE_MEDIATYPE = @as(u32, 258);
pub const DISPID_IDISCFORMAT2ERASE_CLIENTNAME = @as(u32, 259);
pub const DISPID_IDISCFORMAT2ERASE_ERASEMEDIA = @as(u32, 513);
pub const DISPID_IDISCFORMAT2ERASEEVENTS_UPDATE = @as(u32, 512);
pub const DISPID_IDISCFORMAT2DATA_RECORDER = @as(u32, 256);
pub const DISPID_IDISCFORMAT2DATA_BUFFERUNDERRUNFREEDISABLED = @as(u32, 257);
pub const DISPID_IDISCFORMAT2DATA_POSTGAPALREADYINIMAGE = @as(u32, 260);
pub const DISPID_IDISCFORMAT2DATA_CURRENTMEDIASTATUS = @as(u32, 262);
pub const DISPID_IDISCFORMAT2DATA_WRITEPROTECTSTATUS = @as(u32, 263);
pub const DISPID_IDISCFORMAT2DATA_TOTALSECTORS = @as(u32, 264);
pub const DISPID_IDISCFORMAT2DATA_FREESECTORS = @as(u32, 265);
pub const DISPID_IDISCFORMAT2DATA_NEXTWRITABLEADDRESS = @as(u32, 266);
pub const DISPID_IDISCFORMAT2DATA_STARTSECTOROFPREVIOUSSESSION = @as(u32, 267);
pub const DISPID_IDISCFORMAT2DATA_LASTSECTOROFPREVIOUSSESSION = @as(u32, 268);
pub const DISPID_IDISCFORMAT2DATA_FORCEMEDIATOBECLOSED = @as(u32, 269);
pub const DISPID_IDISCFORMAT2DATA_DISABLEDVDCOMPATIBILITYMODE = @as(u32, 270);
pub const DISPID_IDISCFORMAT2DATA_CURRENTMEDIATYPE = @as(u32, 271);
pub const DISPID_IDISCFORMAT2DATA_CLIENTNAME = @as(u32, 272);
pub const DISPID_IDISCFORMAT2DATA_REQUESTEDWRITESPEED = @as(u32, 273);
pub const DISPID_IDISCFORMAT2DATA_REQUESTEDROTATIONTYPEISPURECAV = @as(u32, 274);
pub const DISPID_IDISCFORMAT2DATA_CURRENTWRITESPEED = @as(u32, 275);
pub const DISPID_IDISCFORMAT2DATA_CURRENTROTATIONTYPEISPURECAV = @as(u32, 276);
pub const DISPID_IDISCFORMAT2DATA_SUPPORTEDWRITESPEEDS = @as(u32, 277);
pub const DISPID_IDISCFORMAT2DATA_SUPPORTEDWRITESPEEDDESCRIPTORS = @as(u32, 278);
pub const DISPID_IDISCFORMAT2DATA_FORCEOVERWRITE = @as(u32, 279);
pub const DISPID_IDISCFORMAT2DATA_MUTLISESSIONINTERFACES = @as(u32, 280);
pub const DISPID_IDISCFORMAT2DATA_WRITE = @as(u32, 512);
pub const DISPID_IDISCFORMAT2DATA_CANCELWRITE = @as(u32, 513);
pub const DISPID_IDISCFORMAT2DATA_SETWRITESPEED = @as(u32, 514);
pub const DISPID_DDISCFORMAT2DATAEVENTS_UPDATE = @as(u32, 512);
pub const DISPID_IDISCFORMAT2DATAEVENTARGS_ELAPSEDTIME = @as(u32, 768);
pub const DISPID_IDISCFORMAT2DATAEVENTARGS_ESTIMATEDREMAININGTIME = @as(u32, 769);
pub const DISPID_IDISCFORMAT2DATAEVENTARGS_ESTIMATEDTOTALTIME = @as(u32, 770);
pub const DISPID_IDISCFORMAT2DATAEVENTARGS_CURRENTACTION = @as(u32, 771);
pub const DISPID_IDISCFORMAT2TAO_RECORDER = @as(u32, 256);
pub const DISPID_IDISCFORMAT2TAO_BUFFERUNDERRUNFREEDISABLED = @as(u32, 258);
pub const DISPID_IDISCFORMAT2TAO_NUMBEROFEXISTINGTRACKS = @as(u32, 259);
pub const DISPID_IDISCFORMAT2TAO_TOTALSECTORSONMEDIA = @as(u32, 260);
pub const DISPID_IDISCFORMAT2TAO_FREESECTORSONMEDIA = @as(u32, 261);
pub const DISPID_IDISCFORMAT2TAO_USEDSECTORSONMEDIA = @as(u32, 262);
pub const DISPID_IDISCFORMAT2TAO_DONOTFINALIZEMEDIA = @as(u32, 263);
pub const DISPID_IDISCFORMAT2TAO_EXPECTEDTABLEOFCONTENTS = @as(u32, 266);
pub const DISPID_IDISCFORMAT2TAO_CURRENTMEDIATYPE = @as(u32, 267);
pub const DISPID_IDISCFORMAT2TAO_CLIENTNAME = @as(u32, 270);
pub const DISPID_IDISCFORMAT2TAO_REQUESTEDWRITESPEED = @as(u32, 271);
pub const DISPID_IDISCFORMAT2TAO_REQUESTEDROTATIONTYPEISPURECAV = @as(u32, 272);
pub const DISPID_IDISCFORMAT2TAO_CURRENTWRITESPEED = @as(u32, 273);
pub const DISPID_IDISCFORMAT2TAO_CURRENTROTATIONTYPEISPURECAV = @as(u32, 274);
pub const DISPID_IDISCFORMAT2TAO_SUPPORTEDWRITESPEEDS = @as(u32, 275);
pub const DISPID_IDISCFORMAT2TAO_SUPPORTEDWRITESPEEDDESCRIPTORS = @as(u32, 276);
pub const DISPID_IDISCFORMAT2TAO_PREPAREMEDIA = @as(u32, 512);
pub const DISPID_IDISCFORMAT2TAO_ADDAUDIOTRACK = @as(u32, 513);
pub const DISPID_IDISCFORMAT2TAO_CANCELADDTRACK = @as(u32, 514);
pub const DISPID_IDISCFORMAT2TAO_FINISHMEDIA = @as(u32, 515);
pub const DISPID_IDISCFORMAT2TAO_SETWRITESPEED = @as(u32, 516);
pub const DISPID_DDISCFORMAT2TAOEVENTS_UPDATE = @as(u32, 512);
pub const DISPID_IDISCFORMAT2TAOEVENTARGS_CURRENTTRACKNUMBER = @as(u32, 768);
pub const DISPID_IDISCFORMAT2TAOEVENTARGS_CURRENTACTION = @as(u32, 769);
pub const DISPID_IDISCFORMAT2TAOEVENTARGS_ELAPSEDTIME = @as(u32, 770);
pub const DISPID_IDISCFORMAT2TAOEVENTARGS_ESTIMATEDREMAININGTIME = @as(u32, 771);
pub const DISPID_IDISCFORMAT2TAOEVENTARGS_ESTIMATEDTOTALTIME = @as(u32, 772);
pub const DISPID_IDISCFORMAT2RAWCD_RECORDER = @as(u32, 256);
pub const DISPID_IDISCFORMAT2RAWCD_BUFFERUNDERRUNFREEDISABLED = @as(u32, 258);
pub const DISPID_IDISCFORMAT2RAWCD_STARTOFNEXTSESSION = @as(u32, 259);
pub const DISPID_IDISCFORMAT2RAWCD_LASTPOSSIBLESTARTOFLEADOUT = @as(u32, 260);
pub const DISPID_IDISCFORMAT2RAWCD_CURRENTMEDIATYPE = @as(u32, 261);
pub const DISPID_IDISCFORMAT2RAWCD_SUPPORTEDDATASECTORTYPES = @as(u32, 264);
pub const DISPID_IDISCFORMAT2RAWCD_REQUESTEDDATASECTORTYPE = @as(u32, 265);
pub const DISPID_IDISCFORMAT2RAWCD_CLIENTNAME = @as(u32, 266);
pub const DISPID_IDISCFORMAT2RAWCD_REQUESTEDWRITESPEED = @as(u32, 267);
pub const DISPID_IDISCFORMAT2RAWCD_REQUESTEDROTATIONTYPEISPURECAV = @as(u32, 268);
pub const DISPID_IDISCFORMAT2RAWCD_CURRENTWRITESPEED = @as(u32, 269);
pub const DISPID_IDISCFORMAT2RAWCD_CURRENTROTATIONTYPEISPURECAV = @as(u32, 270);
pub const DISPID_IDISCFORMAT2RAWCD_SUPPORTEDWRITESPEEDS = @as(u32, 271);
pub const DISPID_IDISCFORMAT2RAWCD_SUPPORTEDWRITESPEEDDESCRIPTORS = @as(u32, 272);
pub const DISPID_IDISCFORMAT2RAWCD_PREPAREMEDIA = @as(u32, 512);
pub const DISPID_IDISCFORMAT2RAWCD_WRITEMEDIA = @as(u32, 513);
pub const DISPID_IDISCFORMAT2RAWCD_WRITEMEDIAWITHVALIDATION = @as(u32, 514);
pub const DISPID_IDISCFORMAT2RAWCD_CANCELWRITE = @as(u32, 515);
pub const DISPID_IDISCFORMAT2RAWCD_RELEASEMEDIA = @as(u32, 516);
pub const DISPID_IDISCFORMAT2RAWCD_SETWRITESPEED = @as(u32, 517);
pub const DISPID_DDISCFORMAT2RAWCDEVENTS_UPDATE = @as(u32, 512);
pub const DISPID_IDISCFORMAT2RAWCDEVENTARGS_CURRENTTRACKNUMBER = @as(u32, 768);
pub const DISPID_IDISCFORMAT2RAWCDEVENTARGS_CURRENTACTION = @as(u32, 769);
pub const DISPID_IDISCFORMAT2RAWCDEVENTARGS_ELAPSEDTIME = @as(u32, 768);
pub const DISPID_IDISCFORMAT2RAWCDEVENTARGS_ESTIMATEDREMAININGTIME = @as(u32, 769);
pub const DISPID_IDISCFORMAT2RAWCDEVENTARGS_ESTIMATEDTOTALTIME = @as(u32, 770);
pub const IMAPI_SECTORS_PER_SECOND_AT_1X_CD = @as(u32, 75);
pub const IMAPI_SECTORS_PER_SECOND_AT_1X_DVD = @as(u32, 680);
pub const IMAPI_SECTORS_PER_SECOND_AT_1X_BD = @as(u32, 2195);
pub const IMAPI_SECTORS_PER_SECOND_AT_1X_HD_DVD = @as(u32, 4568);
pub const DISPID_IMULTISESSION_SUPPORTEDONCURRENTMEDIA = @as(u32, 256);
pub const DISPID_IMULTISESSION_INUSE = @as(u32, 257);
pub const DISPID_IMULTISESSION_IMPORTRECORDER = @as(u32, 258);
pub const DISPID_IMULTISESSION_FIRSTDATASESSION = @as(u32, 512);
pub const DISPID_IMULTISESSION_STARTSECTOROFPREVIOUSSESSION = @as(u32, 513);
pub const DISPID_IMULTISESSION_LASTSECTOROFPREVIOUSSESSION = @as(u32, 514);
pub const DISPID_IMULTISESSION_NEXTWRITABLEADDRESS = @as(u32, 515);
pub const DISPID_IMULTISESSION_FREESECTORS = @as(u32, 516);
pub const DISPID_IMULTISESSION_WRITEUNITSIZE = @as(u32, 517);
pub const DISPID_IMULTISESSION_LASTWRITTENADDRESS = @as(u32, 518);
pub const DISPID_IMULTISESSION_SECTORSONMEDIA = @as(u32, 519);
pub const DISPID_IRAWCDIMAGECREATOR_CREATERESULTIMAGE = @as(u32, 512);
pub const DISPID_IRAWCDIMAGECREATOR_ADDTRACK = @as(u32, 513);
pub const DISPID_IRAWCDIMAGECREATOR_ADDSPECIALPREGAP = @as(u32, 514);
pub const DISPID_IRAWCDIMAGECREATOR_ADDSUBCODERWGENERATOR = @as(u32, 515);
pub const DISPID_IRAWCDIMAGECREATOR_RESULTINGIMAGETYPE = @as(u32, 256);
pub const DISPID_IRAWCDIMAGECREATOR_STARTOFLEADOUT = @as(u32, 257);
pub const DISPID_IRAWCDIMAGECREATOR_STARTOFLEADOUTLIMIT = @as(u32, 258);
pub const DISPID_IRAWCDIMAGECREATOR_DISABLEGAPLESSAUDIO = @as(u32, 259);
pub const DISPID_IRAWCDIMAGECREATOR_MEDIACATALOGNUMBER = @as(u32, 260);
pub const DISPID_IRAWCDIMAGECREATOR_STARTINGTRACKNUMBER = @as(u32, 261);
pub const DISPID_IRAWCDIMAGECREATOR_TRACKINFO = @as(u32, 262);
pub const DISPID_IRAWCDIMAGECREATOR_NUMBEROFEXISTINGTRACKS = @as(u32, 263);
pub const DISPID_IRAWCDIMAGECREATOR_USEDSECTORSONDISC = @as(u32, 264);
pub const DISPID_IRAWCDIMAGECREATOR_EXPECTEDTABLEOFCONTENTS = @as(u32, 265);
pub const DISPID_IRAWCDTRACKINFO_STARTINGLBA = @as(u32, 256);
pub const DISPID_IRAWCDTRACKINFO_SECTORCOUNT = @as(u32, 257);
pub const DISPID_IRAWCDTRACKINFO_TRACKNUMBER = @as(u32, 258);
pub const DISPID_IRAWCDTRACKINFO_SECTORTYPE = @as(u32, 259);
pub const DISPID_IRAWCDTRACKINFO_ISRC = @as(u32, 260);
pub const DISPID_IRAWCDTRACKINFO_DIGITALAUDIOCOPYSETTING = @as(u32, 261);
pub const DISPID_IRAWCDTRACKINFO_AUDIOHASPREEMPHASIS = @as(u32, 262);
pub const DISPID_IBLOCKRANGE_STARTLBA = @as(u32, 256);
pub const DISPID_IBLOCKRANGE_ENDLBA = @as(u32, 257);
pub const DISPID_IBLOCKRANGELIST_BLOCKRANGES = @as(u32, 256);
pub const IMAPILib2_MajorVersion = @as(u32, 1);
pub const IMAPILib2_MinorVersion = @as(u32, 0);
pub const IMAPI2FS_BOOT_ENTRY_COUNT_MAX = @as(u32, 32);
pub const DISPID_DFILESYSTEMIMAGEEVENTS_UPDATE = @as(u32, 256);
pub const DISPID_DFILESYSTEMIMAGEIMPORTEVENTS_UPDATEIMPORT = @as(u32, 257);
pub const IMAPI2FS_MajorVersion = @as(u32, 1);
pub const IMAPI2FS_MinorVersion = @as(u32, 0);
pub const IMAPI_S_PROPERTIESIGNORED = @import("../zig.zig").typedConst(HRESULT, @as(i32, 262656));
pub const IMAPI_S_BUFFER_TO_SMALL = @import("../zig.zig").typedConst(HRESULT, @as(i32, 262657));
pub const IMAPI_E_NOTOPENED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147220981));
pub const IMAPI_E_NOTINITIALIZED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147220980));
pub const IMAPI_E_USERABORT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147220979));
pub const IMAPI_E_GENERIC = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147220978));
pub const IMAPI_E_MEDIUM_NOTPRESENT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147220977));
pub const IMAPI_E_MEDIUM_INVALIDTYPE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147220976));
pub const IMAPI_E_DEVICE_NOPROPERTIES = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147220975));
pub const IMAPI_E_DEVICE_NOTACCESSIBLE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147220974));
pub const IMAPI_E_DEVICE_NOTPRESENT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147220973));
pub const IMAPI_E_DEVICE_INVALIDTYPE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147220972));
pub const IMAPI_E_INITIALIZE_WRITE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147220971));
pub const IMAPI_E_INITIALIZE_ENDWRITE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147220970));
pub const IMAPI_E_FILESYSTEM = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147220969));
pub const IMAPI_E_FILEACCESS = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147220968));
pub const IMAPI_E_DISCINFO = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147220967));
pub const IMAPI_E_TRACKNOTOPEN = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147220966));
pub const IMAPI_E_TRACKOPEN = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147220965));
pub const IMAPI_E_DISCFULL = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147220964));
pub const IMAPI_E_BADJOLIETNAME = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147220963));
pub const IMAPI_E_INVALIDIMAGE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147220962));
pub const IMAPI_E_NOACTIVEFORMAT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147220961));
pub const IMAPI_E_NOACTIVERECORDER = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147220960));
pub const IMAPI_E_WRONGFORMAT = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147220959));
pub const IMAPI_E_ALREADYOPEN = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147220958));
pub const IMAPI_E_WRONGDISC = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147220957));
pub const IMAPI_E_FILEEXISTS = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147220956));
pub const IMAPI_E_STASHINUSE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147220955));
pub const IMAPI_E_DEVICE_STILL_IN_USE = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147220954));
pub const IMAPI_E_LOSS_OF_STREAMING = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147220953));
pub const IMAPI_E_COMPRESSEDSTASH = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147220952));
pub const IMAPI_E_ENCRYPTEDSTASH = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147220951));
pub const IMAPI_E_NOTENOUGHDISKFORSTASH = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147220950));
pub const IMAPI_E_REMOVABLESTASH = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147220949));
pub const IMAPI_E_CANNOT_WRITE_TO_MEDIA = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147220948));
pub const IMAPI_E_TRACK_NOT_BIG_ENOUGH = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147220947));
pub const IMAPI_E_BOOTIMAGE_AND_NONBLANK_DISC = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147220946));
//--------------------------------------------------------------------------------
// Section: Types (113)
//--------------------------------------------------------------------------------
pub const DISC_RECORDER_STATE_FLAGS = enum(u32) {
BURNING = 2,
DOING_NOTHING = 0,
OPENED = 1,
};
pub const RECORDER_BURNING = DISC_RECORDER_STATE_FLAGS.BURNING;
pub const RECORDER_DOING_NOTHING = DISC_RECORDER_STATE_FLAGS.DOING_NOTHING;
pub const RECORDER_OPENED = DISC_RECORDER_STATE_FLAGS.OPENED;
const CLSID_MsftDiscMaster2_Value = @import("../zig.zig").Guid.initString("2735412e-7f64-5b0f-8f00-5d77afbe261e");
pub const CLSID_MsftDiscMaster2 = &CLSID_MsftDiscMaster2_Value;
const CLSID_MsftDiscRecorder2_Value = @import("../zig.zig").Guid.initString("2735412d-7f64-5b0f-8f00-5d77afbe261e");
pub const CLSID_MsftDiscRecorder2 = &CLSID_MsftDiscRecorder2_Value;
const CLSID_MsftWriteEngine2_Value = @import("../zig.zig").Guid.initString("2735412c-7f64-5b0f-8f00-5d77afbe261e");
pub const CLSID_MsftWriteEngine2 = &CLSID_MsftWriteEngine2_Value;
const CLSID_MsftDiscFormat2Erase_Value = @import("../zig.zig").Guid.initString("2735412b-7f64-5b0f-8f00-5d77afbe261e");
pub const CLSID_MsftDiscFormat2Erase = &CLSID_MsftDiscFormat2Erase_Value;
const CLSID_MsftDiscFormat2Data_Value = @import("../zig.zig").Guid.initString("2735412a-7f64-5b0f-8f00-5d77afbe261e");
pub const CLSID_MsftDiscFormat2Data = &CLSID_MsftDiscFormat2Data_Value;
const CLSID_MsftDiscFormat2TrackAtOnce_Value = @import("../zig.zig").Guid.initString("27354129-7f64-5b0f-8f00-5d77afbe261e");
pub const CLSID_MsftDiscFormat2TrackAtOnce = &CLSID_MsftDiscFormat2TrackAtOnce_Value;
const CLSID_MsftDiscFormat2RawCD_Value = @import("../zig.zig").Guid.initString("27354128-7f64-5b0f-8f00-5d77afbe261e");
pub const CLSID_MsftDiscFormat2RawCD = &CLSID_MsftDiscFormat2RawCD_Value;
const CLSID_MsftStreamZero_Value = @import("../zig.zig").Guid.initString("27354127-7f64-5b0f-8f00-5d77afbe261e");
pub const CLSID_MsftStreamZero = &CLSID_MsftStreamZero_Value;
const CLSID_MsftStreamPrng001_Value = @import("../zig.zig").Guid.initString("27354126-7f64-5b0f-8f00-5d77afbe261e");
pub const CLSID_MsftStreamPrng001 = &CLSID_MsftStreamPrng001_Value;
const CLSID_MsftStreamConcatenate_Value = @import("../zig.zig").Guid.initString("27354125-7f64-5b0f-8f00-5d77afbe261e");
pub const CLSID_MsftStreamConcatenate = &CLSID_MsftStreamConcatenate_Value;
const CLSID_MsftStreamInterleave_Value = @import("../zig.zig").Guid.initString("27354124-7f64-5b0f-8f00-5d77afbe261e");
pub const CLSID_MsftStreamInterleave = &CLSID_MsftStreamInterleave_Value;
const CLSID_MsftWriteSpeedDescriptor_Value = @import("../zig.zig").Guid.initString("27354123-7f64-5b0f-8f00-5d77afbe261e");
pub const CLSID_MsftWriteSpeedDescriptor = &CLSID_MsftWriteSpeedDescriptor_Value;
const CLSID_MsftMultisessionSequential_Value = @import("../zig.zig").Guid.initString("27354122-7f64-5b0f-8f00-5d77afbe261e");
pub const CLSID_MsftMultisessionSequential = &CLSID_MsftMultisessionSequential_Value;
const CLSID_MsftMultisessionRandomWrite_Value = @import("../zig.zig").Guid.initString("b507ca24-2204-11dd-966a-001aa01bbc58");
pub const CLSID_MsftMultisessionRandomWrite = &CLSID_MsftMultisessionRandomWrite_Value;
const CLSID_MsftRawCDImageCreator_Value = @import("../zig.zig").Guid.initString("25983561-9d65-49ce-b335-40630d901227");
pub const CLSID_MsftRawCDImageCreator = &CLSID_MsftRawCDImageCreator_Value;
pub const IMAPI_MEDIA_PHYSICAL_TYPE = enum(i32) {
UNKNOWN = 0,
CDROM = 1,
CDR = 2,
CDRW = 3,
DVDROM = 4,
DVDRAM = 5,
DVDPLUSR = 6,
DVDPLUSRW = 7,
DVDPLUSR_DUALLAYER = 8,
DVDDASHR = 9,
DVDDASHRW = 10,
DVDDASHR_DUALLAYER = 11,
DISK = 12,
DVDPLUSRW_DUALLAYER = 13,
HDDVDROM = 14,
HDDVDR = 15,
HDDVDRAM = 16,
BDROM = 17,
BDR = 18,
BDRE = 19,
// MAX = 19, this enum value conflicts with BDRE
};
pub const IMAPI_MEDIA_TYPE_UNKNOWN = IMAPI_MEDIA_PHYSICAL_TYPE.UNKNOWN;
pub const IMAPI_MEDIA_TYPE_CDROM = IMAPI_MEDIA_PHYSICAL_TYPE.CDROM;
pub const IMAPI_MEDIA_TYPE_CDR = IMAPI_MEDIA_PHYSICAL_TYPE.CDR;
pub const IMAPI_MEDIA_TYPE_CDRW = IMAPI_MEDIA_PHYSICAL_TYPE.CDRW;
pub const IMAPI_MEDIA_TYPE_DVDROM = IMAPI_MEDIA_PHYSICAL_TYPE.DVDROM;
pub const IMAPI_MEDIA_TYPE_DVDRAM = IMAPI_MEDIA_PHYSICAL_TYPE.DVDRAM;
pub const IMAPI_MEDIA_TYPE_DVDPLUSR = IMAPI_MEDIA_PHYSICAL_TYPE.DVDPLUSR;
pub const IMAPI_MEDIA_TYPE_DVDPLUSRW = IMAPI_MEDIA_PHYSICAL_TYPE.DVDPLUSRW;
pub const IMAPI_MEDIA_TYPE_DVDPLUSR_DUALLAYER = IMAPI_MEDIA_PHYSICAL_TYPE.DVDPLUSR_DUALLAYER;
pub const IMAPI_MEDIA_TYPE_DVDDASHR = IMAPI_MEDIA_PHYSICAL_TYPE.DVDDASHR;
pub const IMAPI_MEDIA_TYPE_DVDDASHRW = IMAPI_MEDIA_PHYSICAL_TYPE.DVDDASHRW;
pub const IMAPI_MEDIA_TYPE_DVDDASHR_DUALLAYER = IMAPI_MEDIA_PHYSICAL_TYPE.DVDDASHR_DUALLAYER;
pub const IMAPI_MEDIA_TYPE_DISK = IMAPI_MEDIA_PHYSICAL_TYPE.DISK;
pub const IMAPI_MEDIA_TYPE_DVDPLUSRW_DUALLAYER = IMAPI_MEDIA_PHYSICAL_TYPE.DVDPLUSRW_DUALLAYER;
pub const IMAPI_MEDIA_TYPE_HDDVDROM = IMAPI_MEDIA_PHYSICAL_TYPE.HDDVDROM;
pub const IMAPI_MEDIA_TYPE_HDDVDR = IMAPI_MEDIA_PHYSICAL_TYPE.HDDVDR;
pub const IMAPI_MEDIA_TYPE_HDDVDRAM = IMAPI_MEDIA_PHYSICAL_TYPE.HDDVDRAM;
pub const IMAPI_MEDIA_TYPE_BDROM = IMAPI_MEDIA_PHYSICAL_TYPE.BDROM;
pub const IMAPI_MEDIA_TYPE_BDR = IMAPI_MEDIA_PHYSICAL_TYPE.BDR;
pub const IMAPI_MEDIA_TYPE_BDRE = IMAPI_MEDIA_PHYSICAL_TYPE.BDRE;
pub const IMAPI_MEDIA_TYPE_MAX = IMAPI_MEDIA_PHYSICAL_TYPE.BDRE;
pub const IMAPI_MEDIA_WRITE_PROTECT_STATE = enum(i32) {
UNTIL_POWERDOWN = 1,
BY_CARTRIDGE = 2,
BY_MEDIA_SPECIFIC_REASON = 4,
BY_SOFTWARE_WRITE_PROTECT = 8,
BY_DISC_CONTROL_BLOCK = 16,
READ_ONLY_MEDIA = 16384,
};
pub const IMAPI_WRITEPROTECTED_UNTIL_POWERDOWN = IMAPI_MEDIA_WRITE_PROTECT_STATE.UNTIL_POWERDOWN;
pub const IMAPI_WRITEPROTECTED_BY_CARTRIDGE = IMAPI_MEDIA_WRITE_PROTECT_STATE.BY_CARTRIDGE;
pub const IMAPI_WRITEPROTECTED_BY_MEDIA_SPECIFIC_REASON = IMAPI_MEDIA_WRITE_PROTECT_STATE.BY_MEDIA_SPECIFIC_REASON;
pub const IMAPI_WRITEPROTECTED_BY_SOFTWARE_WRITE_PROTECT = IMAPI_MEDIA_WRITE_PROTECT_STATE.BY_SOFTWARE_WRITE_PROTECT;
pub const IMAPI_WRITEPROTECTED_BY_DISC_CONTROL_BLOCK = IMAPI_MEDIA_WRITE_PROTECT_STATE.BY_DISC_CONTROL_BLOCK;
pub const IMAPI_WRITEPROTECTED_READ_ONLY_MEDIA = IMAPI_MEDIA_WRITE_PROTECT_STATE.READ_ONLY_MEDIA;
pub const IMAPI_READ_TRACK_ADDRESS_TYPE = enum(i32) {
LBA = 0,
TRACK = 1,
SESSION = 2,
};
pub const IMAPI_READ_TRACK_ADDRESS_TYPE_LBA = IMAPI_READ_TRACK_ADDRESS_TYPE.LBA;
pub const IMAPI_READ_TRACK_ADDRESS_TYPE_TRACK = IMAPI_READ_TRACK_ADDRESS_TYPE.TRACK;
pub const IMAPI_READ_TRACK_ADDRESS_TYPE_SESSION = IMAPI_READ_TRACK_ADDRESS_TYPE.SESSION;
pub const IMAPI_MODE_PAGE_REQUEST_TYPE = enum(i32) {
CURRENT_VALUES = 0,
CHANGEABLE_VALUES = 1,
DEFAULT_VALUES = 2,
SAVED_VALUES = 3,
};
pub const IMAPI_MODE_PAGE_REQUEST_TYPE_CURRENT_VALUES = IMAPI_MODE_PAGE_REQUEST_TYPE.CURRENT_VALUES;
pub const IMAPI_MODE_PAGE_REQUEST_TYPE_CHANGEABLE_VALUES = IMAPI_MODE_PAGE_REQUEST_TYPE.CHANGEABLE_VALUES;
pub const IMAPI_MODE_PAGE_REQUEST_TYPE_DEFAULT_VALUES = IMAPI_MODE_PAGE_REQUEST_TYPE.DEFAULT_VALUES;
pub const IMAPI_MODE_PAGE_REQUEST_TYPE_SAVED_VALUES = IMAPI_MODE_PAGE_REQUEST_TYPE.SAVED_VALUES;
pub const IMAPI_MODE_PAGE_TYPE = enum(i32) {
READ_WRITE_ERROR_RECOVERY = 1,
MRW = 3,
WRITE_PARAMETERS = 5,
CACHING = 8,
INFORMATIONAL_EXCEPTIONS = 28,
TIMEOUT_AND_PROTECT = 29,
POWER_CONDITION = 26,
LEGACY_CAPABILITIES = 42,
};
pub const IMAPI_MODE_PAGE_TYPE_READ_WRITE_ERROR_RECOVERY = IMAPI_MODE_PAGE_TYPE.READ_WRITE_ERROR_RECOVERY;
pub const IMAPI_MODE_PAGE_TYPE_MRW = IMAPI_MODE_PAGE_TYPE.MRW;
pub const IMAPI_MODE_PAGE_TYPE_WRITE_PARAMETERS = IMAPI_MODE_PAGE_TYPE.WRITE_PARAMETERS;
pub const IMAPI_MODE_PAGE_TYPE_CACHING = IMAPI_MODE_PAGE_TYPE.CACHING;
pub const IMAPI_MODE_PAGE_TYPE_INFORMATIONAL_EXCEPTIONS = IMAPI_MODE_PAGE_TYPE.INFORMATIONAL_EXCEPTIONS;
pub const IMAPI_MODE_PAGE_TYPE_TIMEOUT_AND_PROTECT = IMAPI_MODE_PAGE_TYPE.TIMEOUT_AND_PROTECT;
pub const IMAPI_MODE_PAGE_TYPE_POWER_CONDITION = IMAPI_MODE_PAGE_TYPE.POWER_CONDITION;
pub const IMAPI_MODE_PAGE_TYPE_LEGACY_CAPABILITIES = IMAPI_MODE_PAGE_TYPE.LEGACY_CAPABILITIES;
pub const IMAPI_FEATURE_PAGE_TYPE = enum(i32) {
PROFILE_LIST = 0,
CORE = 1,
MORPHING = 2,
REMOVABLE_MEDIUM = 3,
WRITE_PROTECT = 4,
RANDOMLY_READABLE = 16,
CD_MULTIREAD = 29,
CD_READ = 30,
DVD_READ = 31,
RANDOMLY_WRITABLE = 32,
INCREMENTAL_STREAMING_WRITABLE = 33,
SECTOR_ERASABLE = 34,
FORMATTABLE = 35,
HARDWARE_DEFECT_MANAGEMENT = 36,
WRITE_ONCE = 37,
RESTRICTED_OVERWRITE = 38,
CDRW_CAV_WRITE = 39,
MRW = 40,
ENHANCED_DEFECT_REPORTING = 41,
DVD_PLUS_RW = 42,
DVD_PLUS_R = 43,
RIGID_RESTRICTED_OVERWRITE = 44,
CD_TRACK_AT_ONCE = 45,
CD_MASTERING = 46,
DVD_DASH_WRITE = 47,
DOUBLE_DENSITY_CD_READ = 48,
DOUBLE_DENSITY_CD_R_WRITE = 49,
DOUBLE_DENSITY_CD_RW_WRITE = 50,
LAYER_JUMP_RECORDING = 51,
CD_RW_MEDIA_WRITE_SUPPORT = 55,
BD_PSEUDO_OVERWRITE = 56,
DVD_PLUS_R_DUAL_LAYER = 59,
BD_READ = 64,
BD_WRITE = 65,
HD_DVD_READ = 80,
HD_DVD_WRITE = 81,
POWER_MANAGEMENT = 256,
SMART = 257,
EMBEDDED_CHANGER = 258,
CD_ANALOG_PLAY = 259,
MICROCODE_UPDATE = 260,
TIMEOUT = 261,
DVD_CSS = 262,
REAL_TIME_STREAMING = 263,
LOGICAL_UNIT_SERIAL_NUMBER = 264,
MEDIA_SERIAL_NUMBER = 265,
DISC_CONTROL_BLOCKS = 266,
DVD_CPRM = 267,
FIRMWARE_INFORMATION = 268,
AACS = 269,
VCPS = 272,
};
pub const IMAPI_FEATURE_PAGE_TYPE_PROFILE_LIST = IMAPI_FEATURE_PAGE_TYPE.PROFILE_LIST;
pub const IMAPI_FEATURE_PAGE_TYPE_CORE = IMAPI_FEATURE_PAGE_TYPE.CORE;
pub const IMAPI_FEATURE_PAGE_TYPE_MORPHING = IMAPI_FEATURE_PAGE_TYPE.MORPHING;
pub const IMAPI_FEATURE_PAGE_TYPE_REMOVABLE_MEDIUM = IMAPI_FEATURE_PAGE_TYPE.REMOVABLE_MEDIUM;
pub const IMAPI_FEATURE_PAGE_TYPE_WRITE_PROTECT = IMAPI_FEATURE_PAGE_TYPE.WRITE_PROTECT;
pub const IMAPI_FEATURE_PAGE_TYPE_RANDOMLY_READABLE = IMAPI_FEATURE_PAGE_TYPE.RANDOMLY_READABLE;
pub const IMAPI_FEATURE_PAGE_TYPE_CD_MULTIREAD = IMAPI_FEATURE_PAGE_TYPE.CD_MULTIREAD;
pub const IMAPI_FEATURE_PAGE_TYPE_CD_READ = IMAPI_FEATURE_PAGE_TYPE.CD_READ;
pub const IMAPI_FEATURE_PAGE_TYPE_DVD_READ = IMAPI_FEATURE_PAGE_TYPE.DVD_READ;
pub const IMAPI_FEATURE_PAGE_TYPE_RANDOMLY_WRITABLE = IMAPI_FEATURE_PAGE_TYPE.RANDOMLY_WRITABLE;
pub const IMAPI_FEATURE_PAGE_TYPE_INCREMENTAL_STREAMING_WRITABLE = IMAPI_FEATURE_PAGE_TYPE.INCREMENTAL_STREAMING_WRITABLE;
pub const IMAPI_FEATURE_PAGE_TYPE_SECTOR_ERASABLE = IMAPI_FEATURE_PAGE_TYPE.SECTOR_ERASABLE;
pub const IMAPI_FEATURE_PAGE_TYPE_FORMATTABLE = IMAPI_FEATURE_PAGE_TYPE.FORMATTABLE;
pub const IMAPI_FEATURE_PAGE_TYPE_HARDWARE_DEFECT_MANAGEMENT = IMAPI_FEATURE_PAGE_TYPE.HARDWARE_DEFECT_MANAGEMENT;
pub const IMAPI_FEATURE_PAGE_TYPE_WRITE_ONCE = IMAPI_FEATURE_PAGE_TYPE.WRITE_ONCE;
pub const IMAPI_FEATURE_PAGE_TYPE_RESTRICTED_OVERWRITE = IMAPI_FEATURE_PAGE_TYPE.RESTRICTED_OVERWRITE;
pub const IMAPI_FEATURE_PAGE_TYPE_CDRW_CAV_WRITE = IMAPI_FEATURE_PAGE_TYPE.CDRW_CAV_WRITE;
pub const IMAPI_FEATURE_PAGE_TYPE_MRW = IMAPI_FEATURE_PAGE_TYPE.MRW;
pub const IMAPI_FEATURE_PAGE_TYPE_ENHANCED_DEFECT_REPORTING = IMAPI_FEATURE_PAGE_TYPE.ENHANCED_DEFECT_REPORTING;
pub const IMAPI_FEATURE_PAGE_TYPE_DVD_PLUS_RW = IMAPI_FEATURE_PAGE_TYPE.DVD_PLUS_RW;
pub const IMAPI_FEATURE_PAGE_TYPE_DVD_PLUS_R = IMAPI_FEATURE_PAGE_TYPE.DVD_PLUS_R;
pub const IMAPI_FEATURE_PAGE_TYPE_RIGID_RESTRICTED_OVERWRITE = IMAPI_FEATURE_PAGE_TYPE.RIGID_RESTRICTED_OVERWRITE;
pub const IMAPI_FEATURE_PAGE_TYPE_CD_TRACK_AT_ONCE = IMAPI_FEATURE_PAGE_TYPE.CD_TRACK_AT_ONCE;
pub const IMAPI_FEATURE_PAGE_TYPE_CD_MASTERING = IMAPI_FEATURE_PAGE_TYPE.CD_MASTERING;
pub const IMAPI_FEATURE_PAGE_TYPE_DVD_DASH_WRITE = IMAPI_FEATURE_PAGE_TYPE.DVD_DASH_WRITE;
pub const IMAPI_FEATURE_PAGE_TYPE_DOUBLE_DENSITY_CD_READ = IMAPI_FEATURE_PAGE_TYPE.DOUBLE_DENSITY_CD_READ;
pub const IMAPI_FEATURE_PAGE_TYPE_DOUBLE_DENSITY_CD_R_WRITE = IMAPI_FEATURE_PAGE_TYPE.DOUBLE_DENSITY_CD_R_WRITE;
pub const IMAPI_FEATURE_PAGE_TYPE_DOUBLE_DENSITY_CD_RW_WRITE = IMAPI_FEATURE_PAGE_TYPE.DOUBLE_DENSITY_CD_RW_WRITE;
pub const IMAPI_FEATURE_PAGE_TYPE_LAYER_JUMP_RECORDING = IMAPI_FEATURE_PAGE_TYPE.LAYER_JUMP_RECORDING;
pub const IMAPI_FEATURE_PAGE_TYPE_CD_RW_MEDIA_WRITE_SUPPORT = IMAPI_FEATURE_PAGE_TYPE.CD_RW_MEDIA_WRITE_SUPPORT;
pub const IMAPI_FEATURE_PAGE_TYPE_BD_PSEUDO_OVERWRITE = IMAPI_FEATURE_PAGE_TYPE.BD_PSEUDO_OVERWRITE;
pub const IMAPI_FEATURE_PAGE_TYPE_DVD_PLUS_R_DUAL_LAYER = IMAPI_FEATURE_PAGE_TYPE.DVD_PLUS_R_DUAL_LAYER;
pub const IMAPI_FEATURE_PAGE_TYPE_BD_READ = IMAPI_FEATURE_PAGE_TYPE.BD_READ;
pub const IMAPI_FEATURE_PAGE_TYPE_BD_WRITE = IMAPI_FEATURE_PAGE_TYPE.BD_WRITE;
pub const IMAPI_FEATURE_PAGE_TYPE_HD_DVD_READ = IMAPI_FEATURE_PAGE_TYPE.HD_DVD_READ;
pub const IMAPI_FEATURE_PAGE_TYPE_HD_DVD_WRITE = IMAPI_FEATURE_PAGE_TYPE.HD_DVD_WRITE;
pub const IMAPI_FEATURE_PAGE_TYPE_POWER_MANAGEMENT = IMAPI_FEATURE_PAGE_TYPE.POWER_MANAGEMENT;
pub const IMAPI_FEATURE_PAGE_TYPE_SMART = IMAPI_FEATURE_PAGE_TYPE.SMART;
pub const IMAPI_FEATURE_PAGE_TYPE_EMBEDDED_CHANGER = IMAPI_FEATURE_PAGE_TYPE.EMBEDDED_CHANGER;
pub const IMAPI_FEATURE_PAGE_TYPE_CD_ANALOG_PLAY = IMAPI_FEATURE_PAGE_TYPE.CD_ANALOG_PLAY;
pub const IMAPI_FEATURE_PAGE_TYPE_MICROCODE_UPDATE = IMAPI_FEATURE_PAGE_TYPE.MICROCODE_UPDATE;
pub const IMAPI_FEATURE_PAGE_TYPE_TIMEOUT = IMAPI_FEATURE_PAGE_TYPE.TIMEOUT;
pub const IMAPI_FEATURE_PAGE_TYPE_DVD_CSS = IMAPI_FEATURE_PAGE_TYPE.DVD_CSS;
pub const IMAPI_FEATURE_PAGE_TYPE_REAL_TIME_STREAMING = IMAPI_FEATURE_PAGE_TYPE.REAL_TIME_STREAMING;
pub const IMAPI_FEATURE_PAGE_TYPE_LOGICAL_UNIT_SERIAL_NUMBER = IMAPI_FEATURE_PAGE_TYPE.LOGICAL_UNIT_SERIAL_NUMBER;
pub const IMAPI_FEATURE_PAGE_TYPE_MEDIA_SERIAL_NUMBER = IMAPI_FEATURE_PAGE_TYPE.MEDIA_SERIAL_NUMBER;
pub const IMAPI_FEATURE_PAGE_TYPE_DISC_CONTROL_BLOCKS = IMAPI_FEATURE_PAGE_TYPE.DISC_CONTROL_BLOCKS;
pub const IMAPI_FEATURE_PAGE_TYPE_DVD_CPRM = IMAPI_FEATURE_PAGE_TYPE.DVD_CPRM;
pub const IMAPI_FEATURE_PAGE_TYPE_FIRMWARE_INFORMATION = IMAPI_FEATURE_PAGE_TYPE.FIRMWARE_INFORMATION;
pub const IMAPI_FEATURE_PAGE_TYPE_AACS = IMAPI_FEATURE_PAGE_TYPE.AACS;
pub const IMAPI_FEATURE_PAGE_TYPE_VCPS = IMAPI_FEATURE_PAGE_TYPE.VCPS;
pub const IMAPI_PROFILE_TYPE = enum(i32) {
INVALID = 0,
NON_REMOVABLE_DISK = 1,
REMOVABLE_DISK = 2,
MO_ERASABLE = 3,
MO_WRITE_ONCE = 4,
AS_MO = 5,
CDROM = 8,
CD_RECORDABLE = 9,
CD_REWRITABLE = 10,
DVDROM = 16,
DVD_DASH_RECORDABLE = 17,
DVD_RAM = 18,
DVD_DASH_REWRITABLE = 19,
DVD_DASH_RW_SEQUENTIAL = 20,
DVD_DASH_R_DUAL_SEQUENTIAL = 21,
DVD_DASH_R_DUAL_LAYER_JUMP = 22,
DVD_PLUS_RW = 26,
DVD_PLUS_R = 27,
DDCDROM = 32,
DDCD_RECORDABLE = 33,
DDCD_REWRITABLE = 34,
DVD_PLUS_RW_DUAL = 42,
DVD_PLUS_R_DUAL = 43,
BD_ROM = 64,
BD_R_SEQUENTIAL = 65,
BD_R_RANDOM_RECORDING = 66,
BD_REWRITABLE = 67,
HD_DVD_ROM = 80,
HD_DVD_RECORDABLE = 81,
HD_DVD_RAM = 82,
NON_STANDARD = 65535,
};
pub const IMAPI_PROFILE_TYPE_INVALID = IMAPI_PROFILE_TYPE.INVALID;
pub const IMAPI_PROFILE_TYPE_NON_REMOVABLE_DISK = IMAPI_PROFILE_TYPE.NON_REMOVABLE_DISK;
pub const IMAPI_PROFILE_TYPE_REMOVABLE_DISK = IMAPI_PROFILE_TYPE.REMOVABLE_DISK;
pub const IMAPI_PROFILE_TYPE_MO_ERASABLE = IMAPI_PROFILE_TYPE.MO_ERASABLE;
pub const IMAPI_PROFILE_TYPE_MO_WRITE_ONCE = IMAPI_PROFILE_TYPE.MO_WRITE_ONCE;
pub const IMAPI_PROFILE_TYPE_AS_MO = IMAPI_PROFILE_TYPE.AS_MO;
pub const IMAPI_PROFILE_TYPE_CDROM = IMAPI_PROFILE_TYPE.CDROM;
pub const IMAPI_PROFILE_TYPE_CD_RECORDABLE = IMAPI_PROFILE_TYPE.CD_RECORDABLE;
pub const IMAPI_PROFILE_TYPE_CD_REWRITABLE = IMAPI_PROFILE_TYPE.CD_REWRITABLE;
pub const IMAPI_PROFILE_TYPE_DVDROM = IMAPI_PROFILE_TYPE.DVDROM;
pub const IMAPI_PROFILE_TYPE_DVD_DASH_RECORDABLE = IMAPI_PROFILE_TYPE.DVD_DASH_RECORDABLE;
pub const IMAPI_PROFILE_TYPE_DVD_RAM = IMAPI_PROFILE_TYPE.DVD_RAM;
pub const IMAPI_PROFILE_TYPE_DVD_DASH_REWRITABLE = IMAPI_PROFILE_TYPE.DVD_DASH_REWRITABLE;
pub const IMAPI_PROFILE_TYPE_DVD_DASH_RW_SEQUENTIAL = IMAPI_PROFILE_TYPE.DVD_DASH_RW_SEQUENTIAL;
pub const IMAPI_PROFILE_TYPE_DVD_DASH_R_DUAL_SEQUENTIAL = IMAPI_PROFILE_TYPE.DVD_DASH_R_DUAL_SEQUENTIAL;
pub const IMAPI_PROFILE_TYPE_DVD_DASH_R_DUAL_LAYER_JUMP = IMAPI_PROFILE_TYPE.DVD_DASH_R_DUAL_LAYER_JUMP;
pub const IMAPI_PROFILE_TYPE_DVD_PLUS_RW = IMAPI_PROFILE_TYPE.DVD_PLUS_RW;
pub const IMAPI_PROFILE_TYPE_DVD_PLUS_R = IMAPI_PROFILE_TYPE.DVD_PLUS_R;
pub const IMAPI_PROFILE_TYPE_DDCDROM = IMAPI_PROFILE_TYPE.DDCDROM;
pub const IMAPI_PROFILE_TYPE_DDCD_RECORDABLE = IMAPI_PROFILE_TYPE.DDCD_RECORDABLE;
pub const IMAPI_PROFILE_TYPE_DDCD_REWRITABLE = IMAPI_PROFILE_TYPE.DDCD_REWRITABLE;
pub const IMAPI_PROFILE_TYPE_DVD_PLUS_RW_DUAL = IMAPI_PROFILE_TYPE.DVD_PLUS_RW_DUAL;
pub const IMAPI_PROFILE_TYPE_DVD_PLUS_R_DUAL = IMAPI_PROFILE_TYPE.DVD_PLUS_R_DUAL;
pub const IMAPI_PROFILE_TYPE_BD_ROM = IMAPI_PROFILE_TYPE.BD_ROM;
pub const IMAPI_PROFILE_TYPE_BD_R_SEQUENTIAL = IMAPI_PROFILE_TYPE.BD_R_SEQUENTIAL;
pub const IMAPI_PROFILE_TYPE_BD_R_RANDOM_RECORDING = IMAPI_PROFILE_TYPE.BD_R_RANDOM_RECORDING;
pub const IMAPI_PROFILE_TYPE_BD_REWRITABLE = IMAPI_PROFILE_TYPE.BD_REWRITABLE;
pub const IMAPI_PROFILE_TYPE_HD_DVD_ROM = IMAPI_PROFILE_TYPE.HD_DVD_ROM;
pub const IMAPI_PROFILE_TYPE_HD_DVD_RECORDABLE = IMAPI_PROFILE_TYPE.HD_DVD_RECORDABLE;
pub const IMAPI_PROFILE_TYPE_HD_DVD_RAM = IMAPI_PROFILE_TYPE.HD_DVD_RAM;
pub const IMAPI_PROFILE_TYPE_NON_STANDARD = IMAPI_PROFILE_TYPE.NON_STANDARD;
pub const IMAPI_FORMAT2_DATA_WRITE_ACTION = enum(i32) {
VALIDATING_MEDIA = 0,
FORMATTING_MEDIA = 1,
INITIALIZING_HARDWARE = 2,
CALIBRATING_POWER = 3,
WRITING_DATA = 4,
FINALIZATION = 5,
COMPLETED = 6,
VERIFYING = 7,
};
pub const IMAPI_FORMAT2_DATA_WRITE_ACTION_VALIDATING_MEDIA = IMAPI_FORMAT2_DATA_WRITE_ACTION.VALIDATING_MEDIA;
pub const IMAPI_FORMAT2_DATA_WRITE_ACTION_FORMATTING_MEDIA = IMAPI_FORMAT2_DATA_WRITE_ACTION.FORMATTING_MEDIA;
pub const IMAPI_FORMAT2_DATA_WRITE_ACTION_INITIALIZING_HARDWARE = IMAPI_FORMAT2_DATA_WRITE_ACTION.INITIALIZING_HARDWARE;
pub const IMAPI_FORMAT2_DATA_WRITE_ACTION_CALIBRATING_POWER = IMAPI_FORMAT2_DATA_WRITE_ACTION.CALIBRATING_POWER;
pub const IMAPI_FORMAT2_DATA_WRITE_ACTION_WRITING_DATA = IMAPI_FORMAT2_DATA_WRITE_ACTION.WRITING_DATA;
pub const IMAPI_FORMAT2_DATA_WRITE_ACTION_FINALIZATION = IMAPI_FORMAT2_DATA_WRITE_ACTION.FINALIZATION;
pub const IMAPI_FORMAT2_DATA_WRITE_ACTION_COMPLETED = IMAPI_FORMAT2_DATA_WRITE_ACTION.COMPLETED;
pub const IMAPI_FORMAT2_DATA_WRITE_ACTION_VERIFYING = IMAPI_FORMAT2_DATA_WRITE_ACTION.VERIFYING;
pub const IMAPI_FORMAT2_DATA_MEDIA_STATE = enum(i32) {
UNKNOWN = 0,
INFORMATIONAL_MASK = 15,
UNSUPPORTED_MASK = 64512,
OVERWRITE_ONLY = 1,
// RANDOMLY_WRITABLE = 1, this enum value conflicts with OVERWRITE_ONLY
BLANK = 2,
APPENDABLE = 4,
FINAL_SESSION = 8,
DAMAGED = 1024,
ERASE_REQUIRED = 2048,
NON_EMPTY_SESSION = 4096,
WRITE_PROTECTED = 8192,
FINALIZED = 16384,
UNSUPPORTED_MEDIA = 32768,
};
pub const IMAPI_FORMAT2_DATA_MEDIA_STATE_UNKNOWN = IMAPI_FORMAT2_DATA_MEDIA_STATE.UNKNOWN;
pub const IMAPI_FORMAT2_DATA_MEDIA_STATE_INFORMATIONAL_MASK = IMAPI_FORMAT2_DATA_MEDIA_STATE.INFORMATIONAL_MASK;
pub const IMAPI_FORMAT2_DATA_MEDIA_STATE_UNSUPPORTED_MASK = IMAPI_FORMAT2_DATA_MEDIA_STATE.UNSUPPORTED_MASK;
pub const IMAPI_FORMAT2_DATA_MEDIA_STATE_OVERWRITE_ONLY = IMAPI_FORMAT2_DATA_MEDIA_STATE.OVERWRITE_ONLY;
pub const IMAPI_FORMAT2_DATA_MEDIA_STATE_RANDOMLY_WRITABLE = IMAPI_FORMAT2_DATA_MEDIA_STATE.OVERWRITE_ONLY;
pub const IMAPI_FORMAT2_DATA_MEDIA_STATE_BLANK = IMAPI_FORMAT2_DATA_MEDIA_STATE.BLANK;
pub const IMAPI_FORMAT2_DATA_MEDIA_STATE_APPENDABLE = IMAPI_FORMAT2_DATA_MEDIA_STATE.APPENDABLE;
pub const IMAPI_FORMAT2_DATA_MEDIA_STATE_FINAL_SESSION = IMAPI_FORMAT2_DATA_MEDIA_STATE.FINAL_SESSION;
pub const IMAPI_FORMAT2_DATA_MEDIA_STATE_DAMAGED = IMAPI_FORMAT2_DATA_MEDIA_STATE.DAMAGED;
pub const IMAPI_FORMAT2_DATA_MEDIA_STATE_ERASE_REQUIRED = IMAPI_FORMAT2_DATA_MEDIA_STATE.ERASE_REQUIRED;
pub const IMAPI_FORMAT2_DATA_MEDIA_STATE_NON_EMPTY_SESSION = IMAPI_FORMAT2_DATA_MEDIA_STATE.NON_EMPTY_SESSION;
pub const IMAPI_FORMAT2_DATA_MEDIA_STATE_WRITE_PROTECTED = IMAPI_FORMAT2_DATA_MEDIA_STATE.WRITE_PROTECTED;
pub const IMAPI_FORMAT2_DATA_MEDIA_STATE_FINALIZED = IMAPI_FORMAT2_DATA_MEDIA_STATE.FINALIZED;
pub const IMAPI_FORMAT2_DATA_MEDIA_STATE_UNSUPPORTED_MEDIA = IMAPI_FORMAT2_DATA_MEDIA_STATE.UNSUPPORTED_MEDIA;
pub const IMAPI_FORMAT2_TAO_WRITE_ACTION = enum(i32) {
UNKNOWN = 0,
PREPARING = 1,
WRITING = 2,
FINISHING = 3,
VERIFYING = 4,
};
pub const IMAPI_FORMAT2_TAO_WRITE_ACTION_UNKNOWN = IMAPI_FORMAT2_TAO_WRITE_ACTION.UNKNOWN;
pub const IMAPI_FORMAT2_TAO_WRITE_ACTION_PREPARING = IMAPI_FORMAT2_TAO_WRITE_ACTION.PREPARING;
pub const IMAPI_FORMAT2_TAO_WRITE_ACTION_WRITING = IMAPI_FORMAT2_TAO_WRITE_ACTION.WRITING;
pub const IMAPI_FORMAT2_TAO_WRITE_ACTION_FINISHING = IMAPI_FORMAT2_TAO_WRITE_ACTION.FINISHING;
pub const IMAPI_FORMAT2_TAO_WRITE_ACTION_VERIFYING = IMAPI_FORMAT2_TAO_WRITE_ACTION.VERIFYING;
pub const IMAPI_FORMAT2_RAW_CD_DATA_SECTOR_TYPE = enum(i32) {
PQ_ONLY = 1,
IS_COOKED = 2,
IS_RAW = 3,
};
pub const IMAPI_FORMAT2_RAW_CD_SUBCODE_PQ_ONLY = IMAPI_FORMAT2_RAW_CD_DATA_SECTOR_TYPE.PQ_ONLY;
pub const IMAPI_FORMAT2_RAW_CD_SUBCODE_IS_COOKED = IMAPI_FORMAT2_RAW_CD_DATA_SECTOR_TYPE.IS_COOKED;
pub const IMAPI_FORMAT2_RAW_CD_SUBCODE_IS_RAW = IMAPI_FORMAT2_RAW_CD_DATA_SECTOR_TYPE.IS_RAW;
pub const IMAPI_FORMAT2_RAW_CD_WRITE_ACTION = enum(i32) {
UNKNOWN = 0,
PREPARING = 1,
WRITING = 2,
FINISHING = 3,
};
pub const IMAPI_FORMAT2_RAW_CD_WRITE_ACTION_UNKNOWN = IMAPI_FORMAT2_RAW_CD_WRITE_ACTION.UNKNOWN;
pub const IMAPI_FORMAT2_RAW_CD_WRITE_ACTION_PREPARING = IMAPI_FORMAT2_RAW_CD_WRITE_ACTION.PREPARING;
pub const IMAPI_FORMAT2_RAW_CD_WRITE_ACTION_WRITING = IMAPI_FORMAT2_RAW_CD_WRITE_ACTION.WRITING;
pub const IMAPI_FORMAT2_RAW_CD_WRITE_ACTION_FINISHING = IMAPI_FORMAT2_RAW_CD_WRITE_ACTION.FINISHING;
pub const IMAPI_CD_SECTOR_TYPE = enum(i32) {
AUDIO = 0,
MODE_ZERO = 1,
MODE1 = 2,
MODE2FORM0 = 3,
MODE2FORM1 = 4,
MODE2FORM2 = 5,
MODE1RAW = 6,
MODE2FORM0RAW = 7,
MODE2FORM1RAW = 8,
MODE2FORM2RAW = 9,
};
pub const IMAPI_CD_SECTOR_AUDIO = IMAPI_CD_SECTOR_TYPE.AUDIO;
pub const IMAPI_CD_SECTOR_MODE_ZERO = IMAPI_CD_SECTOR_TYPE.MODE_ZERO;
pub const IMAPI_CD_SECTOR_MODE1 = IMAPI_CD_SECTOR_TYPE.MODE1;
pub const IMAPI_CD_SECTOR_MODE2FORM0 = IMAPI_CD_SECTOR_TYPE.MODE2FORM0;
pub const IMAPI_CD_SECTOR_MODE2FORM1 = IMAPI_CD_SECTOR_TYPE.MODE2FORM1;
pub const IMAPI_CD_SECTOR_MODE2FORM2 = IMAPI_CD_SECTOR_TYPE.MODE2FORM2;
pub const IMAPI_CD_SECTOR_MODE1RAW = IMAPI_CD_SECTOR_TYPE.MODE1RAW;
pub const IMAPI_CD_SECTOR_MODE2FORM0RAW = IMAPI_CD_SECTOR_TYPE.MODE2FORM0RAW;
pub const IMAPI_CD_SECTOR_MODE2FORM1RAW = IMAPI_CD_SECTOR_TYPE.MODE2FORM1RAW;
pub const IMAPI_CD_SECTOR_MODE2FORM2RAW = IMAPI_CD_SECTOR_TYPE.MODE2FORM2RAW;
pub const IMAPI_CD_TRACK_DIGITAL_COPY_SETTING = enum(i32) {
PERMITTED = 0,
PROHIBITED = 1,
SCMS = 2,
};
pub const IMAPI_CD_TRACK_DIGITAL_COPY_PERMITTED = IMAPI_CD_TRACK_DIGITAL_COPY_SETTING.PERMITTED;
pub const IMAPI_CD_TRACK_DIGITAL_COPY_PROHIBITED = IMAPI_CD_TRACK_DIGITAL_COPY_SETTING.PROHIBITED;
pub const IMAPI_CD_TRACK_DIGITAL_COPY_SCMS = IMAPI_CD_TRACK_DIGITAL_COPY_SETTING.SCMS;
pub const IMAPI_BURN_VERIFICATION_LEVEL = enum(i32) {
NONE = 0,
QUICK = 1,
FULL = 2,
};
pub const IMAPI_BURN_VERIFICATION_NONE = IMAPI_BURN_VERIFICATION_LEVEL.NONE;
pub const IMAPI_BURN_VERIFICATION_QUICK = IMAPI_BURN_VERIFICATION_LEVEL.QUICK;
pub const IMAPI_BURN_VERIFICATION_FULL = IMAPI_BURN_VERIFICATION_LEVEL.FULL;
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IDiscMaster2_Value = @import("../zig.zig").Guid.initString("27354130-7f64-5b0f-8f00-5d77afbe261e");
pub const IID_IDiscMaster2 = &IID_IDiscMaster2_Value;
pub const IDiscMaster2 = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get__NewEnum: fn(
self: *const IDiscMaster2,
ppunk: ?*?*IEnumVARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Item: fn(
self: *const IDiscMaster2,
index: i32,
value: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Count: fn(
self: *const IDiscMaster2,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IsSupportedEnvironment: fn(
self: *const IDiscMaster2,
value: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IDispatch.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscMaster2_get__NewEnum(self: *const T, ppunk: ?*?*IEnumVARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscMaster2.VTable, self.vtable).get__NewEnum(@ptrCast(*const IDiscMaster2, self), ppunk);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscMaster2_get_Item(self: *const T, index: i32, value: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscMaster2.VTable, self.vtable).get_Item(@ptrCast(*const IDiscMaster2, self), index, value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscMaster2_get_Count(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscMaster2.VTable, self.vtable).get_Count(@ptrCast(*const IDiscMaster2, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscMaster2_get_IsSupportedEnvironment(self: *const T, value: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscMaster2.VTable, self.vtable).get_IsSupportedEnvironment(@ptrCast(*const IDiscMaster2, self), value);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_DDiscMaster2Events_Value = @import("../zig.zig").Guid.initString("27354131-7f64-5b0f-8f00-5d77afbe261e");
pub const IID_DDiscMaster2Events = &IID_DDiscMaster2Events_Value;
pub const DDiscMaster2Events = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
NotifyDeviceAdded: fn(
self: *const DDiscMaster2Events,
object: ?*IDispatch,
uniqueId: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
NotifyDeviceRemoved: fn(
self: *const DDiscMaster2Events,
object: ?*IDispatch,
uniqueId: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IDispatch.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn DDiscMaster2Events_NotifyDeviceAdded(self: *const T, object: ?*IDispatch, uniqueId: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const DDiscMaster2Events.VTable, self.vtable).NotifyDeviceAdded(@ptrCast(*const DDiscMaster2Events, self), object, uniqueId);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn DDiscMaster2Events_NotifyDeviceRemoved(self: *const T, object: ?*IDispatch, uniqueId: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const DDiscMaster2Events.VTable, self.vtable).NotifyDeviceRemoved(@ptrCast(*const DDiscMaster2Events, self), object, uniqueId);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IDiscRecorder2Ex_Value = @import("../zig.zig").Guid.initString("27354132-7f64-5b0f-8f00-5d77afbe261e");
pub const IID_IDiscRecorder2Ex = &IID_IDiscRecorder2Ex_Value;
pub const IDiscRecorder2Ex = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
SendCommandNoData: fn(
self: *const IDiscRecorder2Ex,
Cdb: [*:0]u8,
CdbSize: u32,
SenseBuffer: *[18]u8,
Timeout: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SendCommandSendDataToDevice: fn(
self: *const IDiscRecorder2Ex,
Cdb: [*:0]u8,
CdbSize: u32,
SenseBuffer: *[18]u8,
Timeout: u32,
Buffer: [*:0]u8,
BufferSize: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SendCommandGetDataFromDevice: fn(
self: *const IDiscRecorder2Ex,
Cdb: [*:0]u8,
CdbSize: u32,
SenseBuffer: *[18]u8,
Timeout: u32,
Buffer: [*:0]u8,
BufferSize: u32,
BufferFetched: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ReadDvdStructure: fn(
self: *const IDiscRecorder2Ex,
format: u32,
address: u32,
layer: u32,
agid: u32,
data: ?[*]?*u8,
count: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SendDvdStructure: fn(
self: *const IDiscRecorder2Ex,
format: u32,
data: [*:0]u8,
count: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetAdapterDescriptor: fn(
self: *const IDiscRecorder2Ex,
data: ?[*]?*u8,
byteSize: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetDeviceDescriptor: fn(
self: *const IDiscRecorder2Ex,
data: ?[*]?*u8,
byteSize: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetDiscInformation: fn(
self: *const IDiscRecorder2Ex,
discInformation: ?[*]?*u8,
byteSize: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetTrackInformation: fn(
self: *const IDiscRecorder2Ex,
address: u32,
addressType: IMAPI_READ_TRACK_ADDRESS_TYPE,
trackInformation: ?[*]?*u8,
byteSize: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetFeaturePage: fn(
self: *const IDiscRecorder2Ex,
requestedFeature: IMAPI_FEATURE_PAGE_TYPE,
currentFeatureOnly: BOOLEAN,
featureData: ?[*]?*u8,
byteSize: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetModePage: fn(
self: *const IDiscRecorder2Ex,
requestedModePage: IMAPI_MODE_PAGE_TYPE,
requestType: IMAPI_MODE_PAGE_REQUEST_TYPE,
modePageData: ?[*]?*u8,
byteSize: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetModePage: fn(
self: *const IDiscRecorder2Ex,
requestType: IMAPI_MODE_PAGE_REQUEST_TYPE,
data: [*:0]u8,
byteSize: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetSupportedFeaturePages: fn(
self: *const IDiscRecorder2Ex,
currentFeatureOnly: BOOLEAN,
featureData: ?[*]?*IMAPI_FEATURE_PAGE_TYPE,
byteSize: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetSupportedProfiles: fn(
self: *const IDiscRecorder2Ex,
currentOnly: BOOLEAN,
profileTypes: ?[*]?*IMAPI_PROFILE_TYPE,
validProfiles: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetSupportedModePages: fn(
self: *const IDiscRecorder2Ex,
requestType: IMAPI_MODE_PAGE_REQUEST_TYPE,
modePageTypes: ?[*]?*IMAPI_MODE_PAGE_TYPE,
validPages: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetByteAlignmentMask: fn(
self: *const IDiscRecorder2Ex,
value: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetMaximumNonPageAlignedTransferSize: fn(
self: *const IDiscRecorder2Ex,
value: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetMaximumPageAlignedTransferSize: fn(
self: *const IDiscRecorder2Ex,
value: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder2Ex_SendCommandNoData(self: *const T, Cdb: [*:0]u8, CdbSize: u32, SenseBuffer: *[18]u8, Timeout: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder2Ex.VTable, self.vtable).SendCommandNoData(@ptrCast(*const IDiscRecorder2Ex, self), Cdb, CdbSize, SenseBuffer, Timeout);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder2Ex_SendCommandSendDataToDevice(self: *const T, Cdb: [*:0]u8, CdbSize: u32, SenseBuffer: *[18]u8, Timeout: u32, Buffer: [*:0]u8, BufferSize: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder2Ex.VTable, self.vtable).SendCommandSendDataToDevice(@ptrCast(*const IDiscRecorder2Ex, self), Cdb, CdbSize, SenseBuffer, Timeout, Buffer, BufferSize);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder2Ex_SendCommandGetDataFromDevice(self: *const T, Cdb: [*:0]u8, CdbSize: u32, SenseBuffer: *[18]u8, Timeout: u32, Buffer: [*:0]u8, BufferSize: u32, BufferFetched: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder2Ex.VTable, self.vtable).SendCommandGetDataFromDevice(@ptrCast(*const IDiscRecorder2Ex, self), Cdb, CdbSize, SenseBuffer, Timeout, Buffer, BufferSize, BufferFetched);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder2Ex_ReadDvdStructure(self: *const T, format: u32, address: u32, layer: u32, agid: u32, data: ?[*]?*u8, count: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder2Ex.VTable, self.vtable).ReadDvdStructure(@ptrCast(*const IDiscRecorder2Ex, self), format, address, layer, agid, data, count);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder2Ex_SendDvdStructure(self: *const T, format: u32, data: [*:0]u8, count: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder2Ex.VTable, self.vtable).SendDvdStructure(@ptrCast(*const IDiscRecorder2Ex, self), format, data, count);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder2Ex_GetAdapterDescriptor(self: *const T, data: ?[*]?*u8, byteSize: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder2Ex.VTable, self.vtable).GetAdapterDescriptor(@ptrCast(*const IDiscRecorder2Ex, self), data, byteSize);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder2Ex_GetDeviceDescriptor(self: *const T, data: ?[*]?*u8, byteSize: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder2Ex.VTable, self.vtable).GetDeviceDescriptor(@ptrCast(*const IDiscRecorder2Ex, self), data, byteSize);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder2Ex_GetDiscInformation(self: *const T, discInformation: ?[*]?*u8, byteSize: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder2Ex.VTable, self.vtable).GetDiscInformation(@ptrCast(*const IDiscRecorder2Ex, self), discInformation, byteSize);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder2Ex_GetTrackInformation(self: *const T, address: u32, addressType: IMAPI_READ_TRACK_ADDRESS_TYPE, trackInformation: ?[*]?*u8, byteSize: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder2Ex.VTable, self.vtable).GetTrackInformation(@ptrCast(*const IDiscRecorder2Ex, self), address, addressType, trackInformation, byteSize);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder2Ex_GetFeaturePage(self: *const T, requestedFeature: IMAPI_FEATURE_PAGE_TYPE, currentFeatureOnly: BOOLEAN, featureData: ?[*]?*u8, byteSize: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder2Ex.VTable, self.vtable).GetFeaturePage(@ptrCast(*const IDiscRecorder2Ex, self), requestedFeature, currentFeatureOnly, featureData, byteSize);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder2Ex_GetModePage(self: *const T, requestedModePage: IMAPI_MODE_PAGE_TYPE, requestType: IMAPI_MODE_PAGE_REQUEST_TYPE, modePageData: ?[*]?*u8, byteSize: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder2Ex.VTable, self.vtable).GetModePage(@ptrCast(*const IDiscRecorder2Ex, self), requestedModePage, requestType, modePageData, byteSize);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder2Ex_SetModePage(self: *const T, requestType: IMAPI_MODE_PAGE_REQUEST_TYPE, data: [*:0]u8, byteSize: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder2Ex.VTable, self.vtable).SetModePage(@ptrCast(*const IDiscRecorder2Ex, self), requestType, data, byteSize);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder2Ex_GetSupportedFeaturePages(self: *const T, currentFeatureOnly: BOOLEAN, featureData: ?[*]?*IMAPI_FEATURE_PAGE_TYPE, byteSize: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder2Ex.VTable, self.vtable).GetSupportedFeaturePages(@ptrCast(*const IDiscRecorder2Ex, self), currentFeatureOnly, featureData, byteSize);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder2Ex_GetSupportedProfiles(self: *const T, currentOnly: BOOLEAN, profileTypes: ?[*]?*IMAPI_PROFILE_TYPE, validProfiles: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder2Ex.VTable, self.vtable).GetSupportedProfiles(@ptrCast(*const IDiscRecorder2Ex, self), currentOnly, profileTypes, validProfiles);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder2Ex_GetSupportedModePages(self: *const T, requestType: IMAPI_MODE_PAGE_REQUEST_TYPE, modePageTypes: ?[*]?*IMAPI_MODE_PAGE_TYPE, validPages: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder2Ex.VTable, self.vtable).GetSupportedModePages(@ptrCast(*const IDiscRecorder2Ex, self), requestType, modePageTypes, validPages);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder2Ex_GetByteAlignmentMask(self: *const T, value: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder2Ex.VTable, self.vtable).GetByteAlignmentMask(@ptrCast(*const IDiscRecorder2Ex, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder2Ex_GetMaximumNonPageAlignedTransferSize(self: *const T, value: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder2Ex.VTable, self.vtable).GetMaximumNonPageAlignedTransferSize(@ptrCast(*const IDiscRecorder2Ex, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder2Ex_GetMaximumPageAlignedTransferSize(self: *const T, value: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder2Ex.VTable, self.vtable).GetMaximumPageAlignedTransferSize(@ptrCast(*const IDiscRecorder2Ex, self), value);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IDiscRecorder2_Value = @import("../zig.zig").Guid.initString("27354133-7f64-5b0f-8f00-5d77afbe261e");
pub const IID_IDiscRecorder2 = &IID_IDiscRecorder2_Value;
pub const IDiscRecorder2 = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
EjectMedia: fn(
self: *const IDiscRecorder2,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
CloseTray: fn(
self: *const IDiscRecorder2,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
AcquireExclusiveAccess: fn(
self: *const IDiscRecorder2,
force: i16,
__MIDL__IDiscRecorder20000: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ReleaseExclusiveAccess: fn(
self: *const IDiscRecorder2,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
DisableMcn: fn(
self: *const IDiscRecorder2,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EnableMcn: fn(
self: *const IDiscRecorder2,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeDiscRecorder: fn(
self: *const IDiscRecorder2,
recorderUniqueId: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ActiveDiscRecorder: fn(
self: *const IDiscRecorder2,
value: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_VendorId: fn(
self: *const IDiscRecorder2,
value: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ProductId: fn(
self: *const IDiscRecorder2,
value: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ProductRevision: fn(
self: *const IDiscRecorder2,
value: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_VolumeName: fn(
self: *const IDiscRecorder2,
value: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_VolumePathNames: fn(
self: *const IDiscRecorder2,
value: ?*?*SAFEARRAY,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_DeviceCanLoadMedia: fn(
self: *const IDiscRecorder2,
value: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_LegacyDeviceNumber: fn(
self: *const IDiscRecorder2,
legacyDeviceNumber: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SupportedFeaturePages: fn(
self: *const IDiscRecorder2,
value: ?*?*SAFEARRAY,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CurrentFeaturePages: fn(
self: *const IDiscRecorder2,
value: ?*?*SAFEARRAY,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SupportedProfiles: fn(
self: *const IDiscRecorder2,
value: ?*?*SAFEARRAY,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CurrentProfiles: fn(
self: *const IDiscRecorder2,
value: ?*?*SAFEARRAY,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SupportedModePages: fn(
self: *const IDiscRecorder2,
value: ?*?*SAFEARRAY,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ExclusiveAccessOwner: fn(
self: *const IDiscRecorder2,
value: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IDispatch.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder2_EjectMedia(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder2.VTable, self.vtable).EjectMedia(@ptrCast(*const IDiscRecorder2, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder2_CloseTray(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder2.VTable, self.vtable).CloseTray(@ptrCast(*const IDiscRecorder2, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder2_AcquireExclusiveAccess(self: *const T, force: i16, __MIDL__IDiscRecorder20000: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder2.VTable, self.vtable).AcquireExclusiveAccess(@ptrCast(*const IDiscRecorder2, self), force, __MIDL__IDiscRecorder20000);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder2_ReleaseExclusiveAccess(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder2.VTable, self.vtable).ReleaseExclusiveAccess(@ptrCast(*const IDiscRecorder2, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder2_DisableMcn(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder2.VTable, self.vtable).DisableMcn(@ptrCast(*const IDiscRecorder2, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder2_EnableMcn(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder2.VTable, self.vtable).EnableMcn(@ptrCast(*const IDiscRecorder2, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder2_InitializeDiscRecorder(self: *const T, recorderUniqueId: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder2.VTable, self.vtable).InitializeDiscRecorder(@ptrCast(*const IDiscRecorder2, self), recorderUniqueId);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder2_get_ActiveDiscRecorder(self: *const T, value: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder2.VTable, self.vtable).get_ActiveDiscRecorder(@ptrCast(*const IDiscRecorder2, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder2_get_VendorId(self: *const T, value: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder2.VTable, self.vtable).get_VendorId(@ptrCast(*const IDiscRecorder2, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder2_get_ProductId(self: *const T, value: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder2.VTable, self.vtable).get_ProductId(@ptrCast(*const IDiscRecorder2, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder2_get_ProductRevision(self: *const T, value: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder2.VTable, self.vtable).get_ProductRevision(@ptrCast(*const IDiscRecorder2, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder2_get_VolumeName(self: *const T, value: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder2.VTable, self.vtable).get_VolumeName(@ptrCast(*const IDiscRecorder2, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder2_get_VolumePathNames(self: *const T, value: ?*?*SAFEARRAY) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder2.VTable, self.vtable).get_VolumePathNames(@ptrCast(*const IDiscRecorder2, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder2_get_DeviceCanLoadMedia(self: *const T, value: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder2.VTable, self.vtable).get_DeviceCanLoadMedia(@ptrCast(*const IDiscRecorder2, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder2_get_LegacyDeviceNumber(self: *const T, legacyDeviceNumber: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder2.VTable, self.vtable).get_LegacyDeviceNumber(@ptrCast(*const IDiscRecorder2, self), legacyDeviceNumber);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder2_get_SupportedFeaturePages(self: *const T, value: ?*?*SAFEARRAY) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder2.VTable, self.vtable).get_SupportedFeaturePages(@ptrCast(*const IDiscRecorder2, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder2_get_CurrentFeaturePages(self: *const T, value: ?*?*SAFEARRAY) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder2.VTable, self.vtable).get_CurrentFeaturePages(@ptrCast(*const IDiscRecorder2, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder2_get_SupportedProfiles(self: *const T, value: ?*?*SAFEARRAY) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder2.VTable, self.vtable).get_SupportedProfiles(@ptrCast(*const IDiscRecorder2, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder2_get_CurrentProfiles(self: *const T, value: ?*?*SAFEARRAY) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder2.VTable, self.vtable).get_CurrentProfiles(@ptrCast(*const IDiscRecorder2, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder2_get_SupportedModePages(self: *const T, value: ?*?*SAFEARRAY) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder2.VTable, self.vtable).get_SupportedModePages(@ptrCast(*const IDiscRecorder2, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder2_get_ExclusiveAccessOwner(self: *const T, value: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder2.VTable, self.vtable).get_ExclusiveAccessOwner(@ptrCast(*const IDiscRecorder2, self), value);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IWriteEngine2_Value = @import("../zig.zig").Guid.initString("27354135-7f64-5b0f-8f00-5d77afbe261e");
pub const IID_IWriteEngine2 = &IID_IWriteEngine2_Value;
pub const IWriteEngine2 = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
WriteSection: fn(
self: *const IWriteEngine2,
data: ?*IStream,
startingBlockAddress: i32,
numberOfBlocks: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
CancelWrite: fn(
self: *const IWriteEngine2,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_Recorder: fn(
self: *const IWriteEngine2,
value: ?*IDiscRecorder2Ex,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Recorder: fn(
self: *const IWriteEngine2,
value: ?*?*IDiscRecorder2Ex,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_UseStreamingWrite12: fn(
self: *const IWriteEngine2,
value: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_UseStreamingWrite12: fn(
self: *const IWriteEngine2,
value: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_StartingSectorsPerSecond: fn(
self: *const IWriteEngine2,
value: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_StartingSectorsPerSecond: fn(
self: *const IWriteEngine2,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_EndingSectorsPerSecond: fn(
self: *const IWriteEngine2,
value: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_EndingSectorsPerSecond: fn(
self: *const IWriteEngine2,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_BytesPerSector: fn(
self: *const IWriteEngine2,
value: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_BytesPerSector: fn(
self: *const IWriteEngine2,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_WriteInProgress: fn(
self: *const IWriteEngine2,
value: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IDispatch.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IWriteEngine2_WriteSection(self: *const T, data: ?*IStream, startingBlockAddress: i32, numberOfBlocks: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IWriteEngine2.VTable, self.vtable).WriteSection(@ptrCast(*const IWriteEngine2, self), data, startingBlockAddress, numberOfBlocks);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IWriteEngine2_CancelWrite(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IWriteEngine2.VTable, self.vtable).CancelWrite(@ptrCast(*const IWriteEngine2, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IWriteEngine2_put_Recorder(self: *const T, value: ?*IDiscRecorder2Ex) callconv(.Inline) HRESULT {
return @ptrCast(*const IWriteEngine2.VTable, self.vtable).put_Recorder(@ptrCast(*const IWriteEngine2, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IWriteEngine2_get_Recorder(self: *const T, value: ?*?*IDiscRecorder2Ex) callconv(.Inline) HRESULT {
return @ptrCast(*const IWriteEngine2.VTable, self.vtable).get_Recorder(@ptrCast(*const IWriteEngine2, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IWriteEngine2_put_UseStreamingWrite12(self: *const T, value: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IWriteEngine2.VTable, self.vtable).put_UseStreamingWrite12(@ptrCast(*const IWriteEngine2, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IWriteEngine2_get_UseStreamingWrite12(self: *const T, value: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IWriteEngine2.VTable, self.vtable).get_UseStreamingWrite12(@ptrCast(*const IWriteEngine2, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IWriteEngine2_put_StartingSectorsPerSecond(self: *const T, value: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IWriteEngine2.VTable, self.vtable).put_StartingSectorsPerSecond(@ptrCast(*const IWriteEngine2, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IWriteEngine2_get_StartingSectorsPerSecond(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IWriteEngine2.VTable, self.vtable).get_StartingSectorsPerSecond(@ptrCast(*const IWriteEngine2, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IWriteEngine2_put_EndingSectorsPerSecond(self: *const T, value: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IWriteEngine2.VTable, self.vtable).put_EndingSectorsPerSecond(@ptrCast(*const IWriteEngine2, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IWriteEngine2_get_EndingSectorsPerSecond(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IWriteEngine2.VTable, self.vtable).get_EndingSectorsPerSecond(@ptrCast(*const IWriteEngine2, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IWriteEngine2_put_BytesPerSector(self: *const T, value: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IWriteEngine2.VTable, self.vtable).put_BytesPerSector(@ptrCast(*const IWriteEngine2, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IWriteEngine2_get_BytesPerSector(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IWriteEngine2.VTable, self.vtable).get_BytesPerSector(@ptrCast(*const IWriteEngine2, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IWriteEngine2_get_WriteInProgress(self: *const T, value: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IWriteEngine2.VTable, self.vtable).get_WriteInProgress(@ptrCast(*const IWriteEngine2, self), value);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IWriteEngine2EventArgs_Value = @import("../zig.zig").Guid.initString("27354136-7f64-5b0f-8f00-5d77afbe261e");
pub const IID_IWriteEngine2EventArgs = &IID_IWriteEngine2EventArgs_Value;
pub const IWriteEngine2EventArgs = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_StartLba: fn(
self: *const IWriteEngine2EventArgs,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SectorCount: fn(
self: *const IWriteEngine2EventArgs,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_LastReadLba: fn(
self: *const IWriteEngine2EventArgs,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_LastWrittenLba: fn(
self: *const IWriteEngine2EventArgs,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_TotalSystemBuffer: fn(
self: *const IWriteEngine2EventArgs,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_UsedSystemBuffer: fn(
self: *const IWriteEngine2EventArgs,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_FreeSystemBuffer: fn(
self: *const IWriteEngine2EventArgs,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IDispatch.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IWriteEngine2EventArgs_get_StartLba(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IWriteEngine2EventArgs.VTable, self.vtable).get_StartLba(@ptrCast(*const IWriteEngine2EventArgs, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IWriteEngine2EventArgs_get_SectorCount(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IWriteEngine2EventArgs.VTable, self.vtable).get_SectorCount(@ptrCast(*const IWriteEngine2EventArgs, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IWriteEngine2EventArgs_get_LastReadLba(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IWriteEngine2EventArgs.VTable, self.vtable).get_LastReadLba(@ptrCast(*const IWriteEngine2EventArgs, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IWriteEngine2EventArgs_get_LastWrittenLba(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IWriteEngine2EventArgs.VTable, self.vtable).get_LastWrittenLba(@ptrCast(*const IWriteEngine2EventArgs, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IWriteEngine2EventArgs_get_TotalSystemBuffer(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IWriteEngine2EventArgs.VTable, self.vtable).get_TotalSystemBuffer(@ptrCast(*const IWriteEngine2EventArgs, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IWriteEngine2EventArgs_get_UsedSystemBuffer(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IWriteEngine2EventArgs.VTable, self.vtable).get_UsedSystemBuffer(@ptrCast(*const IWriteEngine2EventArgs, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IWriteEngine2EventArgs_get_FreeSystemBuffer(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IWriteEngine2EventArgs.VTable, self.vtable).get_FreeSystemBuffer(@ptrCast(*const IWriteEngine2EventArgs, self), value);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_DWriteEngine2Events_Value = @import("../zig.zig").Guid.initString("27354137-7f64-5b0f-8f00-5d77afbe261e");
pub const IID_DWriteEngine2Events = &IID_DWriteEngine2Events_Value;
pub const DWriteEngine2Events = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
Update: fn(
self: *const DWriteEngine2Events,
object: ?*IDispatch,
progress: ?*IDispatch,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IDispatch.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn DWriteEngine2Events_Update(self: *const T, object: ?*IDispatch, progress: ?*IDispatch) callconv(.Inline) HRESULT {
return @ptrCast(*const DWriteEngine2Events.VTable, self.vtable).Update(@ptrCast(*const DWriteEngine2Events, self), object, progress);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IDiscFormat2_Value = @import("../zig.zig").Guid.initString("27354152-8f64-5b0f-8f00-5d77afbe261e");
pub const IID_IDiscFormat2 = &IID_IDiscFormat2_Value;
pub const IDiscFormat2 = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
IsRecorderSupported: fn(
self: *const IDiscFormat2,
recorder: ?*IDiscRecorder2,
value: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
IsCurrentMediaSupported: fn(
self: *const IDiscFormat2,
recorder: ?*IDiscRecorder2,
value: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_MediaPhysicallyBlank: fn(
self: *const IDiscFormat2,
value: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_MediaHeuristicallyBlank: fn(
self: *const IDiscFormat2,
value: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SupportedMediaTypes: fn(
self: *const IDiscFormat2,
value: ?*?*SAFEARRAY,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IDispatch.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2_IsRecorderSupported(self: *const T, recorder: ?*IDiscRecorder2, value: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2.VTable, self.vtable).IsRecorderSupported(@ptrCast(*const IDiscFormat2, self), recorder, value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2_IsCurrentMediaSupported(self: *const T, recorder: ?*IDiscRecorder2, value: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2.VTable, self.vtable).IsCurrentMediaSupported(@ptrCast(*const IDiscFormat2, self), recorder, value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2_get_MediaPhysicallyBlank(self: *const T, value: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2.VTable, self.vtable).get_MediaPhysicallyBlank(@ptrCast(*const IDiscFormat2, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2_get_MediaHeuristicallyBlank(self: *const T, value: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2.VTable, self.vtable).get_MediaHeuristicallyBlank(@ptrCast(*const IDiscFormat2, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2_get_SupportedMediaTypes(self: *const T, value: ?*?*SAFEARRAY) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2.VTable, self.vtable).get_SupportedMediaTypes(@ptrCast(*const IDiscFormat2, self), value);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IDiscFormat2Erase_Value = @import("../zig.zig").Guid.initString("27354156-8f64-5b0f-8f00-5d77afbe261e");
pub const IID_IDiscFormat2Erase = &IID_IDiscFormat2Erase_Value;
pub const IDiscFormat2Erase = extern struct {
pub const VTable = extern struct {
base: IDiscFormat2.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_Recorder: fn(
self: *const IDiscFormat2Erase,
value: ?*IDiscRecorder2,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Recorder: fn(
self: *const IDiscFormat2Erase,
value: ?*?*IDiscRecorder2,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_FullErase: fn(
self: *const IDiscFormat2Erase,
value: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_FullErase: fn(
self: *const IDiscFormat2Erase,
value: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CurrentPhysicalMediaType: fn(
self: *const IDiscFormat2Erase,
value: ?*IMAPI_MEDIA_PHYSICAL_TYPE,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ClientName: fn(
self: *const IDiscFormat2Erase,
value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ClientName: fn(
self: *const IDiscFormat2Erase,
value: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EraseMedia: fn(
self: *const IDiscFormat2Erase,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IDiscFormat2.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2Erase_put_Recorder(self: *const T, value: ?*IDiscRecorder2) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2Erase.VTable, self.vtable).put_Recorder(@ptrCast(*const IDiscFormat2Erase, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2Erase_get_Recorder(self: *const T, value: ?*?*IDiscRecorder2) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2Erase.VTable, self.vtable).get_Recorder(@ptrCast(*const IDiscFormat2Erase, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2Erase_put_FullErase(self: *const T, value: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2Erase.VTable, self.vtable).put_FullErase(@ptrCast(*const IDiscFormat2Erase, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2Erase_get_FullErase(self: *const T, value: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2Erase.VTable, self.vtable).get_FullErase(@ptrCast(*const IDiscFormat2Erase, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2Erase_get_CurrentPhysicalMediaType(self: *const T, value: ?*IMAPI_MEDIA_PHYSICAL_TYPE) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2Erase.VTable, self.vtable).get_CurrentPhysicalMediaType(@ptrCast(*const IDiscFormat2Erase, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2Erase_put_ClientName(self: *const T, value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2Erase.VTable, self.vtable).put_ClientName(@ptrCast(*const IDiscFormat2Erase, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2Erase_get_ClientName(self: *const T, value: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2Erase.VTable, self.vtable).get_ClientName(@ptrCast(*const IDiscFormat2Erase, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2Erase_EraseMedia(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2Erase.VTable, self.vtable).EraseMedia(@ptrCast(*const IDiscFormat2Erase, self));
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_DDiscFormat2EraseEvents_Value = @import("../zig.zig").Guid.initString("2735413a-7f64-5b0f-8f00-5d77afbe261e");
pub const IID_DDiscFormat2EraseEvents = &IID_DDiscFormat2EraseEvents_Value;
pub const DDiscFormat2EraseEvents = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
Update: fn(
self: *const DDiscFormat2EraseEvents,
object: ?*IDispatch,
elapsedSeconds: i32,
estimatedTotalSeconds: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IDispatch.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn DDiscFormat2EraseEvents_Update(self: *const T, object: ?*IDispatch, elapsedSeconds: i32, estimatedTotalSeconds: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const DDiscFormat2EraseEvents.VTable, self.vtable).Update(@ptrCast(*const DDiscFormat2EraseEvents, self), object, elapsedSeconds, estimatedTotalSeconds);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IDiscFormat2Data_Value = @import("../zig.zig").Guid.initString("27354153-9f64-5b0f-8f00-5d77afbe261e");
pub const IID_IDiscFormat2Data = &IID_IDiscFormat2Data_Value;
pub const IDiscFormat2Data = extern struct {
pub const VTable = extern struct {
base: IDiscFormat2.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_Recorder: fn(
self: *const IDiscFormat2Data,
value: ?*IDiscRecorder2,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Recorder: fn(
self: *const IDiscFormat2Data,
value: ?*?*IDiscRecorder2,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_BufferUnderrunFreeDisabled: fn(
self: *const IDiscFormat2Data,
value: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_BufferUnderrunFreeDisabled: fn(
self: *const IDiscFormat2Data,
value: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_PostgapAlreadyInImage: fn(
self: *const IDiscFormat2Data,
value: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_PostgapAlreadyInImage: fn(
self: *const IDiscFormat2Data,
value: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CurrentMediaStatus: fn(
self: *const IDiscFormat2Data,
value: ?*IMAPI_FORMAT2_DATA_MEDIA_STATE,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_WriteProtectStatus: fn(
self: *const IDiscFormat2Data,
value: ?*IMAPI_MEDIA_WRITE_PROTECT_STATE,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_TotalSectorsOnMedia: fn(
self: *const IDiscFormat2Data,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_FreeSectorsOnMedia: fn(
self: *const IDiscFormat2Data,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_NextWritableAddress: fn(
self: *const IDiscFormat2Data,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_StartAddressOfPreviousSession: fn(
self: *const IDiscFormat2Data,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_LastWrittenAddressOfPreviousSession: fn(
self: *const IDiscFormat2Data,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ForceMediaToBeClosed: fn(
self: *const IDiscFormat2Data,
value: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ForceMediaToBeClosed: fn(
self: *const IDiscFormat2Data,
value: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_DisableConsumerDvdCompatibilityMode: fn(
self: *const IDiscFormat2Data,
value: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_DisableConsumerDvdCompatibilityMode: fn(
self: *const IDiscFormat2Data,
value: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CurrentPhysicalMediaType: fn(
self: *const IDiscFormat2Data,
value: ?*IMAPI_MEDIA_PHYSICAL_TYPE,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ClientName: fn(
self: *const IDiscFormat2Data,
value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ClientName: fn(
self: *const IDiscFormat2Data,
value: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RequestedWriteSpeed: fn(
self: *const IDiscFormat2Data,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RequestedRotationTypeIsPureCAV: fn(
self: *const IDiscFormat2Data,
value: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CurrentWriteSpeed: fn(
self: *const IDiscFormat2Data,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CurrentRotationTypeIsPureCAV: fn(
self: *const IDiscFormat2Data,
value: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SupportedWriteSpeeds: fn(
self: *const IDiscFormat2Data,
supportedSpeeds: ?*?*SAFEARRAY,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SupportedWriteSpeedDescriptors: fn(
self: *const IDiscFormat2Data,
supportedSpeedDescriptors: ?*?*SAFEARRAY,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ForceOverwrite: fn(
self: *const IDiscFormat2Data,
value: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ForceOverwrite: fn(
self: *const IDiscFormat2Data,
value: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_MultisessionInterfaces: fn(
self: *const IDiscFormat2Data,
value: ?*?*SAFEARRAY,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Write: fn(
self: *const IDiscFormat2Data,
data: ?*IStream,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
CancelWrite: fn(
self: *const IDiscFormat2Data,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetWriteSpeed: fn(
self: *const IDiscFormat2Data,
RequestedSectorsPerSecond: i32,
RotationTypeIsPureCAV: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IDiscFormat2.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2Data_put_Recorder(self: *const T, value: ?*IDiscRecorder2) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2Data.VTable, self.vtable).put_Recorder(@ptrCast(*const IDiscFormat2Data, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2Data_get_Recorder(self: *const T, value: ?*?*IDiscRecorder2) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2Data.VTable, self.vtable).get_Recorder(@ptrCast(*const IDiscFormat2Data, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2Data_put_BufferUnderrunFreeDisabled(self: *const T, value: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2Data.VTable, self.vtable).put_BufferUnderrunFreeDisabled(@ptrCast(*const IDiscFormat2Data, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2Data_get_BufferUnderrunFreeDisabled(self: *const T, value: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2Data.VTable, self.vtable).get_BufferUnderrunFreeDisabled(@ptrCast(*const IDiscFormat2Data, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2Data_put_PostgapAlreadyInImage(self: *const T, value: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2Data.VTable, self.vtable).put_PostgapAlreadyInImage(@ptrCast(*const IDiscFormat2Data, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2Data_get_PostgapAlreadyInImage(self: *const T, value: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2Data.VTable, self.vtable).get_PostgapAlreadyInImage(@ptrCast(*const IDiscFormat2Data, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2Data_get_CurrentMediaStatus(self: *const T, value: ?*IMAPI_FORMAT2_DATA_MEDIA_STATE) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2Data.VTable, self.vtable).get_CurrentMediaStatus(@ptrCast(*const IDiscFormat2Data, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2Data_get_WriteProtectStatus(self: *const T, value: ?*IMAPI_MEDIA_WRITE_PROTECT_STATE) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2Data.VTable, self.vtable).get_WriteProtectStatus(@ptrCast(*const IDiscFormat2Data, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2Data_get_TotalSectorsOnMedia(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2Data.VTable, self.vtable).get_TotalSectorsOnMedia(@ptrCast(*const IDiscFormat2Data, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2Data_get_FreeSectorsOnMedia(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2Data.VTable, self.vtable).get_FreeSectorsOnMedia(@ptrCast(*const IDiscFormat2Data, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2Data_get_NextWritableAddress(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2Data.VTable, self.vtable).get_NextWritableAddress(@ptrCast(*const IDiscFormat2Data, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2Data_get_StartAddressOfPreviousSession(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2Data.VTable, self.vtable).get_StartAddressOfPreviousSession(@ptrCast(*const IDiscFormat2Data, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2Data_get_LastWrittenAddressOfPreviousSession(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2Data.VTable, self.vtable).get_LastWrittenAddressOfPreviousSession(@ptrCast(*const IDiscFormat2Data, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2Data_put_ForceMediaToBeClosed(self: *const T, value: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2Data.VTable, self.vtable).put_ForceMediaToBeClosed(@ptrCast(*const IDiscFormat2Data, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2Data_get_ForceMediaToBeClosed(self: *const T, value: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2Data.VTable, self.vtable).get_ForceMediaToBeClosed(@ptrCast(*const IDiscFormat2Data, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2Data_put_DisableConsumerDvdCompatibilityMode(self: *const T, value: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2Data.VTable, self.vtable).put_DisableConsumerDvdCompatibilityMode(@ptrCast(*const IDiscFormat2Data, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2Data_get_DisableConsumerDvdCompatibilityMode(self: *const T, value: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2Data.VTable, self.vtable).get_DisableConsumerDvdCompatibilityMode(@ptrCast(*const IDiscFormat2Data, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2Data_get_CurrentPhysicalMediaType(self: *const T, value: ?*IMAPI_MEDIA_PHYSICAL_TYPE) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2Data.VTable, self.vtable).get_CurrentPhysicalMediaType(@ptrCast(*const IDiscFormat2Data, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2Data_put_ClientName(self: *const T, value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2Data.VTable, self.vtable).put_ClientName(@ptrCast(*const IDiscFormat2Data, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2Data_get_ClientName(self: *const T, value: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2Data.VTable, self.vtable).get_ClientName(@ptrCast(*const IDiscFormat2Data, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2Data_get_RequestedWriteSpeed(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2Data.VTable, self.vtable).get_RequestedWriteSpeed(@ptrCast(*const IDiscFormat2Data, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2Data_get_RequestedRotationTypeIsPureCAV(self: *const T, value: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2Data.VTable, self.vtable).get_RequestedRotationTypeIsPureCAV(@ptrCast(*const IDiscFormat2Data, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2Data_get_CurrentWriteSpeed(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2Data.VTable, self.vtable).get_CurrentWriteSpeed(@ptrCast(*const IDiscFormat2Data, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2Data_get_CurrentRotationTypeIsPureCAV(self: *const T, value: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2Data.VTable, self.vtable).get_CurrentRotationTypeIsPureCAV(@ptrCast(*const IDiscFormat2Data, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2Data_get_SupportedWriteSpeeds(self: *const T, supportedSpeeds: ?*?*SAFEARRAY) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2Data.VTable, self.vtable).get_SupportedWriteSpeeds(@ptrCast(*const IDiscFormat2Data, self), supportedSpeeds);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2Data_get_SupportedWriteSpeedDescriptors(self: *const T, supportedSpeedDescriptors: ?*?*SAFEARRAY) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2Data.VTable, self.vtable).get_SupportedWriteSpeedDescriptors(@ptrCast(*const IDiscFormat2Data, self), supportedSpeedDescriptors);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2Data_put_ForceOverwrite(self: *const T, value: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2Data.VTable, self.vtable).put_ForceOverwrite(@ptrCast(*const IDiscFormat2Data, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2Data_get_ForceOverwrite(self: *const T, value: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2Data.VTable, self.vtable).get_ForceOverwrite(@ptrCast(*const IDiscFormat2Data, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2Data_get_MultisessionInterfaces(self: *const T, value: ?*?*SAFEARRAY) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2Data.VTable, self.vtable).get_MultisessionInterfaces(@ptrCast(*const IDiscFormat2Data, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2Data_Write(self: *const T, data: ?*IStream) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2Data.VTable, self.vtable).Write(@ptrCast(*const IDiscFormat2Data, self), data);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2Data_CancelWrite(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2Data.VTable, self.vtable).CancelWrite(@ptrCast(*const IDiscFormat2Data, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2Data_SetWriteSpeed(self: *const T, RequestedSectorsPerSecond: i32, RotationTypeIsPureCAV: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2Data.VTable, self.vtable).SetWriteSpeed(@ptrCast(*const IDiscFormat2Data, self), RequestedSectorsPerSecond, RotationTypeIsPureCAV);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_DDiscFormat2DataEvents_Value = @import("../zig.zig").Guid.initString("2735413c-7f64-5b0f-8f00-5d77afbe261e");
pub const IID_DDiscFormat2DataEvents = &IID_DDiscFormat2DataEvents_Value;
pub const DDiscFormat2DataEvents = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
Update: fn(
self: *const DDiscFormat2DataEvents,
object: ?*IDispatch,
progress: ?*IDispatch,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IDispatch.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn DDiscFormat2DataEvents_Update(self: *const T, object: ?*IDispatch, progress: ?*IDispatch) callconv(.Inline) HRESULT {
return @ptrCast(*const DDiscFormat2DataEvents.VTable, self.vtable).Update(@ptrCast(*const DDiscFormat2DataEvents, self), object, progress);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IDiscFormat2DataEventArgs_Value = @import("../zig.zig").Guid.initString("2735413d-7f64-5b0f-8f00-5d77afbe261e");
pub const IID_IDiscFormat2DataEventArgs = &IID_IDiscFormat2DataEventArgs_Value;
pub const IDiscFormat2DataEventArgs = extern struct {
pub const VTable = extern struct {
base: IWriteEngine2EventArgs.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ElapsedTime: fn(
self: *const IDiscFormat2DataEventArgs,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RemainingTime: fn(
self: *const IDiscFormat2DataEventArgs,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_TotalTime: fn(
self: *const IDiscFormat2DataEventArgs,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CurrentAction: fn(
self: *const IDiscFormat2DataEventArgs,
value: ?*IMAPI_FORMAT2_DATA_WRITE_ACTION,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IWriteEngine2EventArgs.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2DataEventArgs_get_ElapsedTime(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2DataEventArgs.VTable, self.vtable).get_ElapsedTime(@ptrCast(*const IDiscFormat2DataEventArgs, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2DataEventArgs_get_RemainingTime(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2DataEventArgs.VTable, self.vtable).get_RemainingTime(@ptrCast(*const IDiscFormat2DataEventArgs, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2DataEventArgs_get_TotalTime(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2DataEventArgs.VTable, self.vtable).get_TotalTime(@ptrCast(*const IDiscFormat2DataEventArgs, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2DataEventArgs_get_CurrentAction(self: *const T, value: ?*IMAPI_FORMAT2_DATA_WRITE_ACTION) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2DataEventArgs.VTable, self.vtable).get_CurrentAction(@ptrCast(*const IDiscFormat2DataEventArgs, self), value);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IDiscFormat2TrackAtOnce_Value = @import("../zig.zig").Guid.initString("27354154-8f64-5b0f-8f00-5d77afbe261e");
pub const IID_IDiscFormat2TrackAtOnce = &IID_IDiscFormat2TrackAtOnce_Value;
pub const IDiscFormat2TrackAtOnce = extern struct {
pub const VTable = extern struct {
base: IDiscFormat2.VTable,
PrepareMedia: fn(
self: *const IDiscFormat2TrackAtOnce,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
AddAudioTrack: fn(
self: *const IDiscFormat2TrackAtOnce,
data: ?*IStream,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
CancelAddTrack: fn(
self: *const IDiscFormat2TrackAtOnce,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ReleaseMedia: fn(
self: *const IDiscFormat2TrackAtOnce,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetWriteSpeed: fn(
self: *const IDiscFormat2TrackAtOnce,
RequestedSectorsPerSecond: i32,
RotationTypeIsPureCAV: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_Recorder: fn(
self: *const IDiscFormat2TrackAtOnce,
value: ?*IDiscRecorder2,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Recorder: fn(
self: *const IDiscFormat2TrackAtOnce,
value: ?*?*IDiscRecorder2,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_BufferUnderrunFreeDisabled: fn(
self: *const IDiscFormat2TrackAtOnce,
value: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_BufferUnderrunFreeDisabled: fn(
self: *const IDiscFormat2TrackAtOnce,
value: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_NumberOfExistingTracks: fn(
self: *const IDiscFormat2TrackAtOnce,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_TotalSectorsOnMedia: fn(
self: *const IDiscFormat2TrackAtOnce,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_FreeSectorsOnMedia: fn(
self: *const IDiscFormat2TrackAtOnce,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_UsedSectorsOnMedia: fn(
self: *const IDiscFormat2TrackAtOnce,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_DoNotFinalizeMedia: fn(
self: *const IDiscFormat2TrackAtOnce,
value: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_DoNotFinalizeMedia: fn(
self: *const IDiscFormat2TrackAtOnce,
value: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ExpectedTableOfContents: fn(
self: *const IDiscFormat2TrackAtOnce,
value: ?*?*SAFEARRAY,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CurrentPhysicalMediaType: fn(
self: *const IDiscFormat2TrackAtOnce,
value: ?*IMAPI_MEDIA_PHYSICAL_TYPE,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ClientName: fn(
self: *const IDiscFormat2TrackAtOnce,
value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ClientName: fn(
self: *const IDiscFormat2TrackAtOnce,
value: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RequestedWriteSpeed: fn(
self: *const IDiscFormat2TrackAtOnce,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RequestedRotationTypeIsPureCAV: fn(
self: *const IDiscFormat2TrackAtOnce,
value: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CurrentWriteSpeed: fn(
self: *const IDiscFormat2TrackAtOnce,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CurrentRotationTypeIsPureCAV: fn(
self: *const IDiscFormat2TrackAtOnce,
value: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SupportedWriteSpeeds: fn(
self: *const IDiscFormat2TrackAtOnce,
supportedSpeeds: ?*?*SAFEARRAY,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SupportedWriteSpeedDescriptors: fn(
self: *const IDiscFormat2TrackAtOnce,
supportedSpeedDescriptors: ?*?*SAFEARRAY,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IDiscFormat2.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2TrackAtOnce_PrepareMedia(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2TrackAtOnce.VTable, self.vtable).PrepareMedia(@ptrCast(*const IDiscFormat2TrackAtOnce, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2TrackAtOnce_AddAudioTrack(self: *const T, data: ?*IStream) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2TrackAtOnce.VTable, self.vtable).AddAudioTrack(@ptrCast(*const IDiscFormat2TrackAtOnce, self), data);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2TrackAtOnce_CancelAddTrack(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2TrackAtOnce.VTable, self.vtable).CancelAddTrack(@ptrCast(*const IDiscFormat2TrackAtOnce, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2TrackAtOnce_ReleaseMedia(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2TrackAtOnce.VTable, self.vtable).ReleaseMedia(@ptrCast(*const IDiscFormat2TrackAtOnce, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2TrackAtOnce_SetWriteSpeed(self: *const T, RequestedSectorsPerSecond: i32, RotationTypeIsPureCAV: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2TrackAtOnce.VTable, self.vtable).SetWriteSpeed(@ptrCast(*const IDiscFormat2TrackAtOnce, self), RequestedSectorsPerSecond, RotationTypeIsPureCAV);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2TrackAtOnce_put_Recorder(self: *const T, value: ?*IDiscRecorder2) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2TrackAtOnce.VTable, self.vtable).put_Recorder(@ptrCast(*const IDiscFormat2TrackAtOnce, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2TrackAtOnce_get_Recorder(self: *const T, value: ?*?*IDiscRecorder2) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2TrackAtOnce.VTable, self.vtable).get_Recorder(@ptrCast(*const IDiscFormat2TrackAtOnce, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2TrackAtOnce_put_BufferUnderrunFreeDisabled(self: *const T, value: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2TrackAtOnce.VTable, self.vtable).put_BufferUnderrunFreeDisabled(@ptrCast(*const IDiscFormat2TrackAtOnce, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2TrackAtOnce_get_BufferUnderrunFreeDisabled(self: *const T, value: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2TrackAtOnce.VTable, self.vtable).get_BufferUnderrunFreeDisabled(@ptrCast(*const IDiscFormat2TrackAtOnce, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2TrackAtOnce_get_NumberOfExistingTracks(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2TrackAtOnce.VTable, self.vtable).get_NumberOfExistingTracks(@ptrCast(*const IDiscFormat2TrackAtOnce, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2TrackAtOnce_get_TotalSectorsOnMedia(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2TrackAtOnce.VTable, self.vtable).get_TotalSectorsOnMedia(@ptrCast(*const IDiscFormat2TrackAtOnce, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2TrackAtOnce_get_FreeSectorsOnMedia(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2TrackAtOnce.VTable, self.vtable).get_FreeSectorsOnMedia(@ptrCast(*const IDiscFormat2TrackAtOnce, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2TrackAtOnce_get_UsedSectorsOnMedia(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2TrackAtOnce.VTable, self.vtable).get_UsedSectorsOnMedia(@ptrCast(*const IDiscFormat2TrackAtOnce, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2TrackAtOnce_put_DoNotFinalizeMedia(self: *const T, value: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2TrackAtOnce.VTable, self.vtable).put_DoNotFinalizeMedia(@ptrCast(*const IDiscFormat2TrackAtOnce, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2TrackAtOnce_get_DoNotFinalizeMedia(self: *const T, value: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2TrackAtOnce.VTable, self.vtable).get_DoNotFinalizeMedia(@ptrCast(*const IDiscFormat2TrackAtOnce, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2TrackAtOnce_get_ExpectedTableOfContents(self: *const T, value: ?*?*SAFEARRAY) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2TrackAtOnce.VTable, self.vtable).get_ExpectedTableOfContents(@ptrCast(*const IDiscFormat2TrackAtOnce, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2TrackAtOnce_get_CurrentPhysicalMediaType(self: *const T, value: ?*IMAPI_MEDIA_PHYSICAL_TYPE) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2TrackAtOnce.VTable, self.vtable).get_CurrentPhysicalMediaType(@ptrCast(*const IDiscFormat2TrackAtOnce, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2TrackAtOnce_put_ClientName(self: *const T, value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2TrackAtOnce.VTable, self.vtable).put_ClientName(@ptrCast(*const IDiscFormat2TrackAtOnce, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2TrackAtOnce_get_ClientName(self: *const T, value: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2TrackAtOnce.VTable, self.vtable).get_ClientName(@ptrCast(*const IDiscFormat2TrackAtOnce, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2TrackAtOnce_get_RequestedWriteSpeed(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2TrackAtOnce.VTable, self.vtable).get_RequestedWriteSpeed(@ptrCast(*const IDiscFormat2TrackAtOnce, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2TrackAtOnce_get_RequestedRotationTypeIsPureCAV(self: *const T, value: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2TrackAtOnce.VTable, self.vtable).get_RequestedRotationTypeIsPureCAV(@ptrCast(*const IDiscFormat2TrackAtOnce, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2TrackAtOnce_get_CurrentWriteSpeed(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2TrackAtOnce.VTable, self.vtable).get_CurrentWriteSpeed(@ptrCast(*const IDiscFormat2TrackAtOnce, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2TrackAtOnce_get_CurrentRotationTypeIsPureCAV(self: *const T, value: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2TrackAtOnce.VTable, self.vtable).get_CurrentRotationTypeIsPureCAV(@ptrCast(*const IDiscFormat2TrackAtOnce, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2TrackAtOnce_get_SupportedWriteSpeeds(self: *const T, supportedSpeeds: ?*?*SAFEARRAY) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2TrackAtOnce.VTable, self.vtable).get_SupportedWriteSpeeds(@ptrCast(*const IDiscFormat2TrackAtOnce, self), supportedSpeeds);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2TrackAtOnce_get_SupportedWriteSpeedDescriptors(self: *const T, supportedSpeedDescriptors: ?*?*SAFEARRAY) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2TrackAtOnce.VTable, self.vtable).get_SupportedWriteSpeedDescriptors(@ptrCast(*const IDiscFormat2TrackAtOnce, self), supportedSpeedDescriptors);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_DDiscFormat2TrackAtOnceEvents_Value = @import("../zig.zig").Guid.initString("2735413f-7f64-5b0f-8f00-5d77afbe261e");
pub const IID_DDiscFormat2TrackAtOnceEvents = &IID_DDiscFormat2TrackAtOnceEvents_Value;
pub const DDiscFormat2TrackAtOnceEvents = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
Update: fn(
self: *const DDiscFormat2TrackAtOnceEvents,
object: ?*IDispatch,
progress: ?*IDispatch,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IDispatch.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn DDiscFormat2TrackAtOnceEvents_Update(self: *const T, object: ?*IDispatch, progress: ?*IDispatch) callconv(.Inline) HRESULT {
return @ptrCast(*const DDiscFormat2TrackAtOnceEvents.VTable, self.vtable).Update(@ptrCast(*const DDiscFormat2TrackAtOnceEvents, self), object, progress);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IDiscFormat2TrackAtOnceEventArgs_Value = @import("../zig.zig").Guid.initString("27354140-7f64-5b0f-8f00-5d77afbe261e");
pub const IID_IDiscFormat2TrackAtOnceEventArgs = &IID_IDiscFormat2TrackAtOnceEventArgs_Value;
pub const IDiscFormat2TrackAtOnceEventArgs = extern struct {
pub const VTable = extern struct {
base: IWriteEngine2EventArgs.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CurrentTrackNumber: fn(
self: *const IDiscFormat2TrackAtOnceEventArgs,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CurrentAction: fn(
self: *const IDiscFormat2TrackAtOnceEventArgs,
value: ?*IMAPI_FORMAT2_TAO_WRITE_ACTION,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ElapsedTime: fn(
self: *const IDiscFormat2TrackAtOnceEventArgs,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RemainingTime: fn(
self: *const IDiscFormat2TrackAtOnceEventArgs,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IWriteEngine2EventArgs.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2TrackAtOnceEventArgs_get_CurrentTrackNumber(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2TrackAtOnceEventArgs.VTable, self.vtable).get_CurrentTrackNumber(@ptrCast(*const IDiscFormat2TrackAtOnceEventArgs, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2TrackAtOnceEventArgs_get_CurrentAction(self: *const T, value: ?*IMAPI_FORMAT2_TAO_WRITE_ACTION) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2TrackAtOnceEventArgs.VTable, self.vtable).get_CurrentAction(@ptrCast(*const IDiscFormat2TrackAtOnceEventArgs, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2TrackAtOnceEventArgs_get_ElapsedTime(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2TrackAtOnceEventArgs.VTable, self.vtable).get_ElapsedTime(@ptrCast(*const IDiscFormat2TrackAtOnceEventArgs, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2TrackAtOnceEventArgs_get_RemainingTime(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2TrackAtOnceEventArgs.VTable, self.vtable).get_RemainingTime(@ptrCast(*const IDiscFormat2TrackAtOnceEventArgs, self), value);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IDiscFormat2RawCD_Value = @import("../zig.zig").Guid.initString("27354155-8f64-5b0f-8f00-5d77afbe261e");
pub const IID_IDiscFormat2RawCD = &IID_IDiscFormat2RawCD_Value;
pub const IDiscFormat2RawCD = extern struct {
pub const VTable = extern struct {
base: IDiscFormat2.VTable,
PrepareMedia: fn(
self: *const IDiscFormat2RawCD,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
WriteMedia: fn(
self: *const IDiscFormat2RawCD,
data: ?*IStream,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
WriteMedia2: fn(
self: *const IDiscFormat2RawCD,
data: ?*IStream,
streamLeadInSectors: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
CancelWrite: fn(
self: *const IDiscFormat2RawCD,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ReleaseMedia: fn(
self: *const IDiscFormat2RawCD,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetWriteSpeed: fn(
self: *const IDiscFormat2RawCD,
RequestedSectorsPerSecond: i32,
RotationTypeIsPureCAV: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_Recorder: fn(
self: *const IDiscFormat2RawCD,
value: ?*IDiscRecorder2,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Recorder: fn(
self: *const IDiscFormat2RawCD,
value: ?*?*IDiscRecorder2,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_BufferUnderrunFreeDisabled: fn(
self: *const IDiscFormat2RawCD,
value: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_BufferUnderrunFreeDisabled: fn(
self: *const IDiscFormat2RawCD,
value: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_StartOfNextSession: fn(
self: *const IDiscFormat2RawCD,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_LastPossibleStartOfLeadout: fn(
self: *const IDiscFormat2RawCD,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CurrentPhysicalMediaType: fn(
self: *const IDiscFormat2RawCD,
value: ?*IMAPI_MEDIA_PHYSICAL_TYPE,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SupportedSectorTypes: fn(
self: *const IDiscFormat2RawCD,
value: ?*?*SAFEARRAY,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_RequestedSectorType: fn(
self: *const IDiscFormat2RawCD,
value: IMAPI_FORMAT2_RAW_CD_DATA_SECTOR_TYPE,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RequestedSectorType: fn(
self: *const IDiscFormat2RawCD,
value: ?*IMAPI_FORMAT2_RAW_CD_DATA_SECTOR_TYPE,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ClientName: fn(
self: *const IDiscFormat2RawCD,
value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ClientName: fn(
self: *const IDiscFormat2RawCD,
value: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RequestedWriteSpeed: fn(
self: *const IDiscFormat2RawCD,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RequestedRotationTypeIsPureCAV: fn(
self: *const IDiscFormat2RawCD,
value: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CurrentWriteSpeed: fn(
self: *const IDiscFormat2RawCD,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CurrentRotationTypeIsPureCAV: fn(
self: *const IDiscFormat2RawCD,
value: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SupportedWriteSpeeds: fn(
self: *const IDiscFormat2RawCD,
supportedSpeeds: ?*?*SAFEARRAY,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SupportedWriteSpeedDescriptors: fn(
self: *const IDiscFormat2RawCD,
supportedSpeedDescriptors: ?*?*SAFEARRAY,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IDiscFormat2.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2RawCD_PrepareMedia(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2RawCD.VTable, self.vtable).PrepareMedia(@ptrCast(*const IDiscFormat2RawCD, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2RawCD_WriteMedia(self: *const T, data: ?*IStream) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2RawCD.VTable, self.vtable).WriteMedia(@ptrCast(*const IDiscFormat2RawCD, self), data);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2RawCD_WriteMedia2(self: *const T, data: ?*IStream, streamLeadInSectors: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2RawCD.VTable, self.vtable).WriteMedia2(@ptrCast(*const IDiscFormat2RawCD, self), data, streamLeadInSectors);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2RawCD_CancelWrite(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2RawCD.VTable, self.vtable).CancelWrite(@ptrCast(*const IDiscFormat2RawCD, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2RawCD_ReleaseMedia(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2RawCD.VTable, self.vtable).ReleaseMedia(@ptrCast(*const IDiscFormat2RawCD, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2RawCD_SetWriteSpeed(self: *const T, RequestedSectorsPerSecond: i32, RotationTypeIsPureCAV: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2RawCD.VTable, self.vtable).SetWriteSpeed(@ptrCast(*const IDiscFormat2RawCD, self), RequestedSectorsPerSecond, RotationTypeIsPureCAV);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2RawCD_put_Recorder(self: *const T, value: ?*IDiscRecorder2) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2RawCD.VTable, self.vtable).put_Recorder(@ptrCast(*const IDiscFormat2RawCD, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2RawCD_get_Recorder(self: *const T, value: ?*?*IDiscRecorder2) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2RawCD.VTable, self.vtable).get_Recorder(@ptrCast(*const IDiscFormat2RawCD, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2RawCD_put_BufferUnderrunFreeDisabled(self: *const T, value: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2RawCD.VTable, self.vtable).put_BufferUnderrunFreeDisabled(@ptrCast(*const IDiscFormat2RawCD, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2RawCD_get_BufferUnderrunFreeDisabled(self: *const T, value: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2RawCD.VTable, self.vtable).get_BufferUnderrunFreeDisabled(@ptrCast(*const IDiscFormat2RawCD, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2RawCD_get_StartOfNextSession(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2RawCD.VTable, self.vtable).get_StartOfNextSession(@ptrCast(*const IDiscFormat2RawCD, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2RawCD_get_LastPossibleStartOfLeadout(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2RawCD.VTable, self.vtable).get_LastPossibleStartOfLeadout(@ptrCast(*const IDiscFormat2RawCD, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2RawCD_get_CurrentPhysicalMediaType(self: *const T, value: ?*IMAPI_MEDIA_PHYSICAL_TYPE) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2RawCD.VTable, self.vtable).get_CurrentPhysicalMediaType(@ptrCast(*const IDiscFormat2RawCD, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2RawCD_get_SupportedSectorTypes(self: *const T, value: ?*?*SAFEARRAY) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2RawCD.VTable, self.vtable).get_SupportedSectorTypes(@ptrCast(*const IDiscFormat2RawCD, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2RawCD_put_RequestedSectorType(self: *const T, value: IMAPI_FORMAT2_RAW_CD_DATA_SECTOR_TYPE) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2RawCD.VTable, self.vtable).put_RequestedSectorType(@ptrCast(*const IDiscFormat2RawCD, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2RawCD_get_RequestedSectorType(self: *const T, value: ?*IMAPI_FORMAT2_RAW_CD_DATA_SECTOR_TYPE) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2RawCD.VTable, self.vtable).get_RequestedSectorType(@ptrCast(*const IDiscFormat2RawCD, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2RawCD_put_ClientName(self: *const T, value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2RawCD.VTable, self.vtable).put_ClientName(@ptrCast(*const IDiscFormat2RawCD, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2RawCD_get_ClientName(self: *const T, value: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2RawCD.VTable, self.vtable).get_ClientName(@ptrCast(*const IDiscFormat2RawCD, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2RawCD_get_RequestedWriteSpeed(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2RawCD.VTable, self.vtable).get_RequestedWriteSpeed(@ptrCast(*const IDiscFormat2RawCD, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2RawCD_get_RequestedRotationTypeIsPureCAV(self: *const T, value: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2RawCD.VTable, self.vtable).get_RequestedRotationTypeIsPureCAV(@ptrCast(*const IDiscFormat2RawCD, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2RawCD_get_CurrentWriteSpeed(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2RawCD.VTable, self.vtable).get_CurrentWriteSpeed(@ptrCast(*const IDiscFormat2RawCD, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2RawCD_get_CurrentRotationTypeIsPureCAV(self: *const T, value: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2RawCD.VTable, self.vtable).get_CurrentRotationTypeIsPureCAV(@ptrCast(*const IDiscFormat2RawCD, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2RawCD_get_SupportedWriteSpeeds(self: *const T, supportedSpeeds: ?*?*SAFEARRAY) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2RawCD.VTable, self.vtable).get_SupportedWriteSpeeds(@ptrCast(*const IDiscFormat2RawCD, self), supportedSpeeds);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2RawCD_get_SupportedWriteSpeedDescriptors(self: *const T, supportedSpeedDescriptors: ?*?*SAFEARRAY) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2RawCD.VTable, self.vtable).get_SupportedWriteSpeedDescriptors(@ptrCast(*const IDiscFormat2RawCD, self), supportedSpeedDescriptors);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_DDiscFormat2RawCDEvents_Value = @import("../zig.zig").Guid.initString("27354142-7f64-5b0f-8f00-5d77afbe261e");
pub const IID_DDiscFormat2RawCDEvents = &IID_DDiscFormat2RawCDEvents_Value;
pub const DDiscFormat2RawCDEvents = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
Update: fn(
self: *const DDiscFormat2RawCDEvents,
object: ?*IDispatch,
progress: ?*IDispatch,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IDispatch.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn DDiscFormat2RawCDEvents_Update(self: *const T, object: ?*IDispatch, progress: ?*IDispatch) callconv(.Inline) HRESULT {
return @ptrCast(*const DDiscFormat2RawCDEvents.VTable, self.vtable).Update(@ptrCast(*const DDiscFormat2RawCDEvents, self), object, progress);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IDiscFormat2RawCDEventArgs_Value = @import("../zig.zig").Guid.initString("27354143-7f64-5b0f-8f00-5d77afbe261e");
pub const IID_IDiscFormat2RawCDEventArgs = &IID_IDiscFormat2RawCDEventArgs_Value;
pub const IDiscFormat2RawCDEventArgs = extern struct {
pub const VTable = extern struct {
base: IWriteEngine2EventArgs.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CurrentAction: fn(
self: *const IDiscFormat2RawCDEventArgs,
value: ?*IMAPI_FORMAT2_RAW_CD_WRITE_ACTION,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ElapsedTime: fn(
self: *const IDiscFormat2RawCDEventArgs,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RemainingTime: fn(
self: *const IDiscFormat2RawCDEventArgs,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IWriteEngine2EventArgs.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2RawCDEventArgs_get_CurrentAction(self: *const T, value: ?*IMAPI_FORMAT2_RAW_CD_WRITE_ACTION) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2RawCDEventArgs.VTable, self.vtable).get_CurrentAction(@ptrCast(*const IDiscFormat2RawCDEventArgs, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2RawCDEventArgs_get_ElapsedTime(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2RawCDEventArgs.VTable, self.vtable).get_ElapsedTime(@ptrCast(*const IDiscFormat2RawCDEventArgs, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscFormat2RawCDEventArgs_get_RemainingTime(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscFormat2RawCDEventArgs.VTable, self.vtable).get_RemainingTime(@ptrCast(*const IDiscFormat2RawCDEventArgs, self), value);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IBurnVerification_Value = @import("../zig.zig").Guid.initString("d2ffd834-958b-426d-8470-2a13879c6a91");
pub const IID_IBurnVerification = &IID_IBurnVerification_Value;
pub const IBurnVerification = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_BurnVerificationLevel: fn(
self: *const IBurnVerification,
value: IMAPI_BURN_VERIFICATION_LEVEL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_BurnVerificationLevel: fn(
self: *const IBurnVerification,
value: ?*IMAPI_BURN_VERIFICATION_LEVEL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IBurnVerification_put_BurnVerificationLevel(self: *const T, value: IMAPI_BURN_VERIFICATION_LEVEL) callconv(.Inline) HRESULT {
return @ptrCast(*const IBurnVerification.VTable, self.vtable).put_BurnVerificationLevel(@ptrCast(*const IBurnVerification, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IBurnVerification_get_BurnVerificationLevel(self: *const T, value: ?*IMAPI_BURN_VERIFICATION_LEVEL) callconv(.Inline) HRESULT {
return @ptrCast(*const IBurnVerification.VTable, self.vtable).get_BurnVerificationLevel(@ptrCast(*const IBurnVerification, self), value);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IWriteSpeedDescriptor_Value = @import("../zig.zig").Guid.initString("27354144-7f64-5b0f-8f00-5d77afbe261e");
pub const IID_IWriteSpeedDescriptor = &IID_IWriteSpeedDescriptor_Value;
pub const IWriteSpeedDescriptor = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_MediaType: fn(
self: *const IWriteSpeedDescriptor,
value: ?*IMAPI_MEDIA_PHYSICAL_TYPE,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_RotationTypeIsPureCAV: fn(
self: *const IWriteSpeedDescriptor,
value: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_WriteSpeed: fn(
self: *const IWriteSpeedDescriptor,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IDispatch.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IWriteSpeedDescriptor_get_MediaType(self: *const T, value: ?*IMAPI_MEDIA_PHYSICAL_TYPE) callconv(.Inline) HRESULT {
return @ptrCast(*const IWriteSpeedDescriptor.VTable, self.vtable).get_MediaType(@ptrCast(*const IWriteSpeedDescriptor, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IWriteSpeedDescriptor_get_RotationTypeIsPureCAV(self: *const T, value: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IWriteSpeedDescriptor.VTable, self.vtable).get_RotationTypeIsPureCAV(@ptrCast(*const IWriteSpeedDescriptor, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IWriteSpeedDescriptor_get_WriteSpeed(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IWriteSpeedDescriptor.VTable, self.vtable).get_WriteSpeed(@ptrCast(*const IWriteSpeedDescriptor, self), value);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IMultisession_Value = @import("../zig.zig").Guid.initString("27354150-7f64-5b0f-8f00-5d77afbe261e");
pub const IID_IMultisession = &IID_IMultisession_Value;
pub const IMultisession = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IsSupportedOnCurrentMediaState: fn(
self: *const IMultisession,
value: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_InUse: fn(
self: *const IMultisession,
value: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_InUse: fn(
self: *const IMultisession,
value: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ImportRecorder: fn(
self: *const IMultisession,
value: ?*?*IDiscRecorder2,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IDispatch.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMultisession_get_IsSupportedOnCurrentMediaState(self: *const T, value: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IMultisession.VTable, self.vtable).get_IsSupportedOnCurrentMediaState(@ptrCast(*const IMultisession, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMultisession_put_InUse(self: *const T, value: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IMultisession.VTable, self.vtable).put_InUse(@ptrCast(*const IMultisession, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMultisession_get_InUse(self: *const T, value: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IMultisession.VTable, self.vtable).get_InUse(@ptrCast(*const IMultisession, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMultisession_get_ImportRecorder(self: *const T, value: ?*?*IDiscRecorder2) callconv(.Inline) HRESULT {
return @ptrCast(*const IMultisession.VTable, self.vtable).get_ImportRecorder(@ptrCast(*const IMultisession, self), value);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IMultisessionSequential_Value = @import("../zig.zig").Guid.initString("27354151-7f64-5b0f-8f00-5d77afbe261e");
pub const IID_IMultisessionSequential = &IID_IMultisessionSequential_Value;
pub const IMultisessionSequential = extern struct {
pub const VTable = extern struct {
base: IMultisession.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IsFirstDataSession: fn(
self: *const IMultisessionSequential,
value: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_StartAddressOfPreviousSession: fn(
self: *const IMultisessionSequential,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_LastWrittenAddressOfPreviousSession: fn(
self: *const IMultisessionSequential,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_NextWritableAddress: fn(
self: *const IMultisessionSequential,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_FreeSectorsOnMedia: fn(
self: *const IMultisessionSequential,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IMultisession.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMultisessionSequential_get_IsFirstDataSession(self: *const T, value: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IMultisessionSequential.VTable, self.vtable).get_IsFirstDataSession(@ptrCast(*const IMultisessionSequential, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMultisessionSequential_get_StartAddressOfPreviousSession(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMultisessionSequential.VTable, self.vtable).get_StartAddressOfPreviousSession(@ptrCast(*const IMultisessionSequential, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMultisessionSequential_get_LastWrittenAddressOfPreviousSession(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMultisessionSequential.VTable, self.vtable).get_LastWrittenAddressOfPreviousSession(@ptrCast(*const IMultisessionSequential, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMultisessionSequential_get_NextWritableAddress(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMultisessionSequential.VTable, self.vtable).get_NextWritableAddress(@ptrCast(*const IMultisessionSequential, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMultisessionSequential_get_FreeSectorsOnMedia(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMultisessionSequential.VTable, self.vtable).get_FreeSectorsOnMedia(@ptrCast(*const IMultisessionSequential, self), value);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.1'
const IID_IMultisessionSequential2_Value = @import("../zig.zig").Guid.initString("b507ca22-2204-11dd-966a-001aa01bbc58");
pub const IID_IMultisessionSequential2 = &IID_IMultisessionSequential2_Value;
pub const IMultisessionSequential2 = extern struct {
pub const VTable = extern struct {
base: IMultisessionSequential.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_WriteUnitSize: fn(
self: *const IMultisessionSequential2,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IMultisessionSequential.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMultisessionSequential2_get_WriteUnitSize(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMultisessionSequential2.VTable, self.vtable).get_WriteUnitSize(@ptrCast(*const IMultisessionSequential2, self), value);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.1'
const IID_IMultisessionRandomWrite_Value = @import("../zig.zig").Guid.initString("b507ca23-2204-11dd-966a-001aa01bbc58");
pub const IID_IMultisessionRandomWrite = &IID_IMultisessionRandomWrite_Value;
pub const IMultisessionRandomWrite = extern struct {
pub const VTable = extern struct {
base: IMultisession.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_WriteUnitSize: fn(
self: *const IMultisessionRandomWrite,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_LastWrittenAddress: fn(
self: *const IMultisessionRandomWrite,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_TotalSectorsOnMedia: fn(
self: *const IMultisessionRandomWrite,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IMultisession.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMultisessionRandomWrite_get_WriteUnitSize(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMultisessionRandomWrite.VTable, self.vtable).get_WriteUnitSize(@ptrCast(*const IMultisessionRandomWrite, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMultisessionRandomWrite_get_LastWrittenAddress(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMultisessionRandomWrite.VTable, self.vtable).get_LastWrittenAddress(@ptrCast(*const IMultisessionRandomWrite, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IMultisessionRandomWrite_get_TotalSectorsOnMedia(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IMultisessionRandomWrite.VTable, self.vtable).get_TotalSectorsOnMedia(@ptrCast(*const IMultisessionRandomWrite, self), value);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IStreamPseudoRandomBased_Value = @import("../zig.zig").Guid.initString("27354145-7f64-5b0f-8f00-5d77afbe261e");
pub const IID_IStreamPseudoRandomBased = &IID_IStreamPseudoRandomBased_Value;
pub const IStreamPseudoRandomBased = extern struct {
pub const VTable = extern struct {
base: IStream.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_Seed: fn(
self: *const IStreamPseudoRandomBased,
value: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Seed: fn(
self: *const IStreamPseudoRandomBased,
value: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ExtendedSeed: fn(
self: *const IStreamPseudoRandomBased,
values: [*]u32,
eCount: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ExtendedSeed: fn(
self: *const IStreamPseudoRandomBased,
values: [*]?*u32,
eCount: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IStream.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IStreamPseudoRandomBased_put_Seed(self: *const T, value: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IStreamPseudoRandomBased.VTable, self.vtable).put_Seed(@ptrCast(*const IStreamPseudoRandomBased, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IStreamPseudoRandomBased_get_Seed(self: *const T, value: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IStreamPseudoRandomBased.VTable, self.vtable).get_Seed(@ptrCast(*const IStreamPseudoRandomBased, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IStreamPseudoRandomBased_put_ExtendedSeed(self: *const T, values: [*]u32, eCount: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IStreamPseudoRandomBased.VTable, self.vtable).put_ExtendedSeed(@ptrCast(*const IStreamPseudoRandomBased, self), values, eCount);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IStreamPseudoRandomBased_get_ExtendedSeed(self: *const T, values: [*]?*u32, eCount: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IStreamPseudoRandomBased.VTable, self.vtable).get_ExtendedSeed(@ptrCast(*const IStreamPseudoRandomBased, self), values, eCount);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IStreamConcatenate_Value = @import("../zig.zig").Guid.initString("27354146-7f64-5b0f-8f00-5d77afbe261e");
pub const IID_IStreamConcatenate = &IID_IStreamConcatenate_Value;
pub const IStreamConcatenate = extern struct {
pub const VTable = extern struct {
base: IStream.VTable,
Initialize: fn(
self: *const IStreamConcatenate,
stream1: ?*IStream,
stream2: ?*IStream,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Initialize2: fn(
self: *const IStreamConcatenate,
streams: [*]?*IStream,
streamCount: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Append: fn(
self: *const IStreamConcatenate,
stream: ?*IStream,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Append2: fn(
self: *const IStreamConcatenate,
streams: [*]?*IStream,
streamCount: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IStream.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IStreamConcatenate_Initialize(self: *const T, stream1: ?*IStream, stream2: ?*IStream) callconv(.Inline) HRESULT {
return @ptrCast(*const IStreamConcatenate.VTable, self.vtable).Initialize(@ptrCast(*const IStreamConcatenate, self), stream1, stream2);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IStreamConcatenate_Initialize2(self: *const T, streams: [*]?*IStream, streamCount: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IStreamConcatenate.VTable, self.vtable).Initialize2(@ptrCast(*const IStreamConcatenate, self), streams, streamCount);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IStreamConcatenate_Append(self: *const T, stream: ?*IStream) callconv(.Inline) HRESULT {
return @ptrCast(*const IStreamConcatenate.VTable, self.vtable).Append(@ptrCast(*const IStreamConcatenate, self), stream);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IStreamConcatenate_Append2(self: *const T, streams: [*]?*IStream, streamCount: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IStreamConcatenate.VTable, self.vtable).Append2(@ptrCast(*const IStreamConcatenate, self), streams, streamCount);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IStreamInterleave_Value = @import("../zig.zig").Guid.initString("27354147-7f64-5b0f-8f00-5d77afbe261e");
pub const IID_IStreamInterleave = &IID_IStreamInterleave_Value;
pub const IStreamInterleave = extern struct {
pub const VTable = extern struct {
base: IStream.VTable,
Initialize: fn(
self: *const IStreamInterleave,
streams: [*]?*IStream,
interleaveSizes: [*]u32,
streamCount: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IStream.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IStreamInterleave_Initialize(self: *const T, streams: [*]?*IStream, interleaveSizes: [*]u32, streamCount: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IStreamInterleave.VTable, self.vtable).Initialize(@ptrCast(*const IStreamInterleave, self), streams, interleaveSizes, streamCount);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IRawCDImageCreator_Value = @import("../zig.zig").Guid.initString("25983550-9d65-49ce-b335-40630d901227");
pub const IID_IRawCDImageCreator = &IID_IRawCDImageCreator_Value;
pub const IRawCDImageCreator = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
CreateResultImage: fn(
self: *const IRawCDImageCreator,
resultStream: ?*?*IStream,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
AddTrack: fn(
self: *const IRawCDImageCreator,
dataType: IMAPI_CD_SECTOR_TYPE,
data: ?*IStream,
trackIndex: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
AddSpecialPregap: fn(
self: *const IRawCDImageCreator,
data: ?*IStream,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
AddSubcodeRWGenerator: fn(
self: *const IRawCDImageCreator,
subcode: ?*IStream,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ResultingImageType: fn(
self: *const IRawCDImageCreator,
value: IMAPI_FORMAT2_RAW_CD_DATA_SECTOR_TYPE,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ResultingImageType: fn(
self: *const IRawCDImageCreator,
value: ?*IMAPI_FORMAT2_RAW_CD_DATA_SECTOR_TYPE,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_StartOfLeadout: fn(
self: *const IRawCDImageCreator,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_StartOfLeadoutLimit: fn(
self: *const IRawCDImageCreator,
value: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_StartOfLeadoutLimit: fn(
self: *const IRawCDImageCreator,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_DisableGaplessAudio: fn(
self: *const IRawCDImageCreator,
value: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_DisableGaplessAudio: fn(
self: *const IRawCDImageCreator,
value: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_MediaCatalogNumber: fn(
self: *const IRawCDImageCreator,
value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_MediaCatalogNumber: fn(
self: *const IRawCDImageCreator,
value: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_StartingTrackNumber: fn(
self: *const IRawCDImageCreator,
value: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_StartingTrackNumber: fn(
self: *const IRawCDImageCreator,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_TrackInfo: fn(
self: *const IRawCDImageCreator,
trackIndex: i32,
value: ?*?*IRawCDImageTrackInfo,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_NumberOfExistingTracks: fn(
self: *const IRawCDImageCreator,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_LastUsedUserSectorInImage: fn(
self: *const IRawCDImageCreator,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ExpectedTableOfContents: fn(
self: *const IRawCDImageCreator,
value: ?*?*SAFEARRAY,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IDispatch.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRawCDImageCreator_CreateResultImage(self: *const T, resultStream: ?*?*IStream) callconv(.Inline) HRESULT {
return @ptrCast(*const IRawCDImageCreator.VTable, self.vtable).CreateResultImage(@ptrCast(*const IRawCDImageCreator, self), resultStream);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRawCDImageCreator_AddTrack(self: *const T, dataType: IMAPI_CD_SECTOR_TYPE, data: ?*IStream, trackIndex: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IRawCDImageCreator.VTable, self.vtable).AddTrack(@ptrCast(*const IRawCDImageCreator, self), dataType, data, trackIndex);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRawCDImageCreator_AddSpecialPregap(self: *const T, data: ?*IStream) callconv(.Inline) HRESULT {
return @ptrCast(*const IRawCDImageCreator.VTable, self.vtable).AddSpecialPregap(@ptrCast(*const IRawCDImageCreator, self), data);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRawCDImageCreator_AddSubcodeRWGenerator(self: *const T, subcode: ?*IStream) callconv(.Inline) HRESULT {
return @ptrCast(*const IRawCDImageCreator.VTable, self.vtable).AddSubcodeRWGenerator(@ptrCast(*const IRawCDImageCreator, self), subcode);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRawCDImageCreator_put_ResultingImageType(self: *const T, value: IMAPI_FORMAT2_RAW_CD_DATA_SECTOR_TYPE) callconv(.Inline) HRESULT {
return @ptrCast(*const IRawCDImageCreator.VTable, self.vtable).put_ResultingImageType(@ptrCast(*const IRawCDImageCreator, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRawCDImageCreator_get_ResultingImageType(self: *const T, value: ?*IMAPI_FORMAT2_RAW_CD_DATA_SECTOR_TYPE) callconv(.Inline) HRESULT {
return @ptrCast(*const IRawCDImageCreator.VTable, self.vtable).get_ResultingImageType(@ptrCast(*const IRawCDImageCreator, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRawCDImageCreator_get_StartOfLeadout(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IRawCDImageCreator.VTable, self.vtable).get_StartOfLeadout(@ptrCast(*const IRawCDImageCreator, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRawCDImageCreator_put_StartOfLeadoutLimit(self: *const T, value: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IRawCDImageCreator.VTable, self.vtable).put_StartOfLeadoutLimit(@ptrCast(*const IRawCDImageCreator, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRawCDImageCreator_get_StartOfLeadoutLimit(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IRawCDImageCreator.VTable, self.vtable).get_StartOfLeadoutLimit(@ptrCast(*const IRawCDImageCreator, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRawCDImageCreator_put_DisableGaplessAudio(self: *const T, value: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IRawCDImageCreator.VTable, self.vtable).put_DisableGaplessAudio(@ptrCast(*const IRawCDImageCreator, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRawCDImageCreator_get_DisableGaplessAudio(self: *const T, value: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IRawCDImageCreator.VTable, self.vtable).get_DisableGaplessAudio(@ptrCast(*const IRawCDImageCreator, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRawCDImageCreator_put_MediaCatalogNumber(self: *const T, value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IRawCDImageCreator.VTable, self.vtable).put_MediaCatalogNumber(@ptrCast(*const IRawCDImageCreator, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRawCDImageCreator_get_MediaCatalogNumber(self: *const T, value: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IRawCDImageCreator.VTable, self.vtable).get_MediaCatalogNumber(@ptrCast(*const IRawCDImageCreator, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRawCDImageCreator_put_StartingTrackNumber(self: *const T, value: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IRawCDImageCreator.VTable, self.vtable).put_StartingTrackNumber(@ptrCast(*const IRawCDImageCreator, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRawCDImageCreator_get_StartingTrackNumber(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IRawCDImageCreator.VTable, self.vtable).get_StartingTrackNumber(@ptrCast(*const IRawCDImageCreator, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRawCDImageCreator_get_TrackInfo(self: *const T, trackIndex: i32, value: ?*?*IRawCDImageTrackInfo) callconv(.Inline) HRESULT {
return @ptrCast(*const IRawCDImageCreator.VTable, self.vtable).get_TrackInfo(@ptrCast(*const IRawCDImageCreator, self), trackIndex, value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRawCDImageCreator_get_NumberOfExistingTracks(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IRawCDImageCreator.VTable, self.vtable).get_NumberOfExistingTracks(@ptrCast(*const IRawCDImageCreator, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRawCDImageCreator_get_LastUsedUserSectorInImage(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IRawCDImageCreator.VTable, self.vtable).get_LastUsedUserSectorInImage(@ptrCast(*const IRawCDImageCreator, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRawCDImageCreator_get_ExpectedTableOfContents(self: *const T, value: ?*?*SAFEARRAY) callconv(.Inline) HRESULT {
return @ptrCast(*const IRawCDImageCreator.VTable, self.vtable).get_ExpectedTableOfContents(@ptrCast(*const IRawCDImageCreator, self), value);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IRawCDImageTrackInfo_Value = @import("../zig.zig").Guid.initString("25983551-9d65-49ce-b335-40630d901227");
pub const IID_IRawCDImageTrackInfo = &IID_IRawCDImageTrackInfo_Value;
pub const IRawCDImageTrackInfo = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_StartingLba: fn(
self: *const IRawCDImageTrackInfo,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SectorCount: fn(
self: *const IRawCDImageTrackInfo,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_TrackNumber: fn(
self: *const IRawCDImageTrackInfo,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SectorType: fn(
self: *const IRawCDImageTrackInfo,
value: ?*IMAPI_CD_SECTOR_TYPE,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ISRC: fn(
self: *const IRawCDImageTrackInfo,
value: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ISRC: fn(
self: *const IRawCDImageTrackInfo,
value: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_DigitalAudioCopySetting: fn(
self: *const IRawCDImageTrackInfo,
value: ?*IMAPI_CD_TRACK_DIGITAL_COPY_SETTING,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_DigitalAudioCopySetting: fn(
self: *const IRawCDImageTrackInfo,
value: IMAPI_CD_TRACK_DIGITAL_COPY_SETTING,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_AudioHasPreemphasis: fn(
self: *const IRawCDImageTrackInfo,
value: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_AudioHasPreemphasis: fn(
self: *const IRawCDImageTrackInfo,
value: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_TrackIndexes: fn(
self: *const IRawCDImageTrackInfo,
value: ?*?*SAFEARRAY,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
AddTrackIndex: fn(
self: *const IRawCDImageTrackInfo,
lbaOffset: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ClearTrackIndex: fn(
self: *const IRawCDImageTrackInfo,
lbaOffset: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IDispatch.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRawCDImageTrackInfo_get_StartingLba(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IRawCDImageTrackInfo.VTable, self.vtable).get_StartingLba(@ptrCast(*const IRawCDImageTrackInfo, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRawCDImageTrackInfo_get_SectorCount(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IRawCDImageTrackInfo.VTable, self.vtable).get_SectorCount(@ptrCast(*const IRawCDImageTrackInfo, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRawCDImageTrackInfo_get_TrackNumber(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IRawCDImageTrackInfo.VTable, self.vtable).get_TrackNumber(@ptrCast(*const IRawCDImageTrackInfo, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRawCDImageTrackInfo_get_SectorType(self: *const T, value: ?*IMAPI_CD_SECTOR_TYPE) callconv(.Inline) HRESULT {
return @ptrCast(*const IRawCDImageTrackInfo.VTable, self.vtable).get_SectorType(@ptrCast(*const IRawCDImageTrackInfo, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRawCDImageTrackInfo_get_ISRC(self: *const T, value: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IRawCDImageTrackInfo.VTable, self.vtable).get_ISRC(@ptrCast(*const IRawCDImageTrackInfo, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRawCDImageTrackInfo_put_ISRC(self: *const T, value: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IRawCDImageTrackInfo.VTable, self.vtable).put_ISRC(@ptrCast(*const IRawCDImageTrackInfo, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRawCDImageTrackInfo_get_DigitalAudioCopySetting(self: *const T, value: ?*IMAPI_CD_TRACK_DIGITAL_COPY_SETTING) callconv(.Inline) HRESULT {
return @ptrCast(*const IRawCDImageTrackInfo.VTable, self.vtable).get_DigitalAudioCopySetting(@ptrCast(*const IRawCDImageTrackInfo, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRawCDImageTrackInfo_put_DigitalAudioCopySetting(self: *const T, value: IMAPI_CD_TRACK_DIGITAL_COPY_SETTING) callconv(.Inline) HRESULT {
return @ptrCast(*const IRawCDImageTrackInfo.VTable, self.vtable).put_DigitalAudioCopySetting(@ptrCast(*const IRawCDImageTrackInfo, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRawCDImageTrackInfo_get_AudioHasPreemphasis(self: *const T, value: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IRawCDImageTrackInfo.VTable, self.vtable).get_AudioHasPreemphasis(@ptrCast(*const IRawCDImageTrackInfo, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRawCDImageTrackInfo_put_AudioHasPreemphasis(self: *const T, value: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IRawCDImageTrackInfo.VTable, self.vtable).put_AudioHasPreemphasis(@ptrCast(*const IRawCDImageTrackInfo, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRawCDImageTrackInfo_get_TrackIndexes(self: *const T, value: ?*?*SAFEARRAY) callconv(.Inline) HRESULT {
return @ptrCast(*const IRawCDImageTrackInfo.VTable, self.vtable).get_TrackIndexes(@ptrCast(*const IRawCDImageTrackInfo, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRawCDImageTrackInfo_AddTrackIndex(self: *const T, lbaOffset: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IRawCDImageTrackInfo.VTable, self.vtable).AddTrackIndex(@ptrCast(*const IRawCDImageTrackInfo, self), lbaOffset);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRawCDImageTrackInfo_ClearTrackIndex(self: *const T, lbaOffset: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IRawCDImageTrackInfo.VTable, self.vtable).ClearTrackIndex(@ptrCast(*const IRawCDImageTrackInfo, self), lbaOffset);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.1'
const IID_IBlockRange_Value = @import("../zig.zig").Guid.initString("b507ca25-2204-11dd-966a-001aa01bbc58");
pub const IID_IBlockRange = &IID_IBlockRange_Value;
pub const IBlockRange = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_StartLba: fn(
self: *const IBlockRange,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_EndLba: fn(
self: *const IBlockRange,
value: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IDispatch.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IBlockRange_get_StartLba(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IBlockRange.VTable, self.vtable).get_StartLba(@ptrCast(*const IBlockRange, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IBlockRange_get_EndLba(self: *const T, value: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IBlockRange.VTable, self.vtable).get_EndLba(@ptrCast(*const IBlockRange, self), value);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.1'
const IID_IBlockRangeList_Value = @import("../zig.zig").Guid.initString("b507ca26-2204-11dd-966a-001aa01bbc58");
pub const IID_IBlockRangeList = &IID_IBlockRangeList_Value;
pub const IBlockRangeList = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_BlockRanges: fn(
self: *const IBlockRangeList,
value: ?*?*SAFEARRAY,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IDispatch.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IBlockRangeList_get_BlockRanges(self: *const T, value: ?*?*SAFEARRAY) callconv(.Inline) HRESULT {
return @ptrCast(*const IBlockRangeList.VTable, self.vtable).get_BlockRanges(@ptrCast(*const IBlockRangeList, self), value);
}
};}
pub usingnamespace MethodMixin(@This());
};
const CLSID_BootOptions_Value = @import("../zig.zig").Guid.initString("2c941fce-975b-59be-a960-9a2a262853a5");
pub const CLSID_BootOptions = &CLSID_BootOptions_Value;
const CLSID_FsiStream_Value = @import("../zig.zig").Guid.initString("2c941fcd-975b-59be-a960-9a2a262853a5");
pub const CLSID_FsiStream = &CLSID_FsiStream_Value;
const CLSID_FileSystemImageResult_Value = @import("../zig.zig").Guid.initString("2c941fcc-975b-59be-a960-9a2a262853a5");
pub const CLSID_FileSystemImageResult = &CLSID_FileSystemImageResult_Value;
const CLSID_ProgressItem_Value = @import("../zig.zig").Guid.initString("2c941fcb-975b-59be-a960-9a2a262853a5");
pub const CLSID_ProgressItem = &CLSID_ProgressItem_Value;
const CLSID_EnumProgressItems_Value = @import("../zig.zig").Guid.initString("2c941fca-975b-59be-a960-9a2a262853a5");
pub const CLSID_EnumProgressItems = &CLSID_EnumProgressItems_Value;
const CLSID_ProgressItems_Value = @import("../zig.zig").Guid.initString("2c941fc9-975b-59be-a960-9a2a262853a5");
pub const CLSID_ProgressItems = &CLSID_ProgressItems_Value;
const CLSID_FsiDirectoryItem_Value = @import("../zig.zig").Guid.initString("2c941fc8-975b-59be-a960-9a2a262853a5");
pub const CLSID_FsiDirectoryItem = &CLSID_FsiDirectoryItem_Value;
const CLSID_FsiFileItem_Value = @import("../zig.zig").Guid.initString("2c941fc7-975b-59be-a960-9a2a262853a5");
pub const CLSID_FsiFileItem = &CLSID_FsiFileItem_Value;
const CLSID_EnumFsiItems_Value = @import("../zig.zig").Guid.initString("2c941fc6-975b-59be-a960-9a2a262853a5");
pub const CLSID_EnumFsiItems = &CLSID_EnumFsiItems_Value;
const CLSID_FsiNamedStreams_Value = @import("../zig.zig").Guid.initString("c6b6f8ed-6d19-44b4-b539-b159b793a32d");
pub const CLSID_FsiNamedStreams = &CLSID_FsiNamedStreams_Value;
const CLSID_MsftFileSystemImage_Value = @import("../zig.zig").Guid.initString("2c941fc5-975b-59be-a960-9a2a262853a5");
pub const CLSID_MsftFileSystemImage = &CLSID_MsftFileSystemImage_Value;
const CLSID_MsftIsoImageManager_Value = @import("../zig.zig").Guid.initString("ceee3b62-8f56-4056-869b-ef16917e3efc");
pub const CLSID_MsftIsoImageManager = &CLSID_MsftIsoImageManager_Value;
const CLSID_BlockRange_Value = @import("../zig.zig").Guid.initString("b507ca27-2204-11dd-966a-001aa01bbc58");
pub const CLSID_BlockRange = &CLSID_BlockRange_Value;
const CLSID_BlockRangeList_Value = @import("../zig.zig").Guid.initString("b507ca28-2204-11dd-966a-001aa01bbc58");
pub const CLSID_BlockRangeList = &CLSID_BlockRangeList_Value;
pub const FsiItemType = enum(i32) {
NotFound = 0,
Directory = 1,
File = 2,
};
pub const FsiItemNotFound = FsiItemType.NotFound;
pub const FsiItemDirectory = FsiItemType.Directory;
pub const FsiItemFile = FsiItemType.File;
pub const FsiFileSystems = enum(i32) {
None = 0,
ISO9660 = 1,
Joliet = 2,
UDF = 4,
Unknown = 1073741824,
};
pub const FsiFileSystemNone = FsiFileSystems.None;
pub const FsiFileSystemISO9660 = FsiFileSystems.ISO9660;
pub const FsiFileSystemJoliet = FsiFileSystems.Joliet;
pub const FsiFileSystemUDF = FsiFileSystems.UDF;
pub const FsiFileSystemUnknown = FsiFileSystems.Unknown;
pub const EmulationType = enum(i32) {
None = 0,
@"12MFloppy" = 1,
@"144MFloppy" = 2,
@"288MFloppy" = 3,
HardDisk = 4,
};
pub const EmulationNone = EmulationType.None;
pub const Emulation12MFloppy = EmulationType.@"12MFloppy";
pub const Emulation144MFloppy = EmulationType.@"144MFloppy";
pub const Emulation288MFloppy = EmulationType.@"288MFloppy";
pub const EmulationHardDisk = EmulationType.HardDisk;
pub const PlatformId = enum(i32) {
X86 = 0,
PowerPC = 1,
Mac = 2,
EFI = 239,
};
pub const PlatformX86 = PlatformId.X86;
pub const PlatformPowerPC = PlatformId.PowerPC;
pub const PlatformMac = PlatformId.Mac;
pub const PlatformEFI = PlatformId.EFI;
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IBootOptions_Value = @import("../zig.zig").Guid.initString("2c941fd4-975b-59be-a960-9a2a262853a5");
pub const IID_IBootOptions = &IID_IBootOptions_Value;
pub const IBootOptions = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_BootImage: fn(
self: *const IBootOptions,
pVal: ?*?*IStream,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Manufacturer: fn(
self: *const IBootOptions,
pVal: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_Manufacturer: fn(
self: *const IBootOptions,
newVal: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_PlatformId: fn(
self: *const IBootOptions,
pVal: ?*PlatformId,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_PlatformId: fn(
self: *const IBootOptions,
newVal: PlatformId,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Emulation: fn(
self: *const IBootOptions,
pVal: ?*EmulationType,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_Emulation: fn(
self: *const IBootOptions,
newVal: EmulationType,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ImageSize: fn(
self: *const IBootOptions,
pVal: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
AssignBootImage: fn(
self: *const IBootOptions,
newVal: ?*IStream,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IDispatch.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IBootOptions_get_BootImage(self: *const T, pVal: ?*?*IStream) callconv(.Inline) HRESULT {
return @ptrCast(*const IBootOptions.VTable, self.vtable).get_BootImage(@ptrCast(*const IBootOptions, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IBootOptions_get_Manufacturer(self: *const T, pVal: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IBootOptions.VTable, self.vtable).get_Manufacturer(@ptrCast(*const IBootOptions, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IBootOptions_put_Manufacturer(self: *const T, newVal: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IBootOptions.VTable, self.vtable).put_Manufacturer(@ptrCast(*const IBootOptions, self), newVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IBootOptions_get_PlatformId(self: *const T, pVal: ?*PlatformId) callconv(.Inline) HRESULT {
return @ptrCast(*const IBootOptions.VTable, self.vtable).get_PlatformId(@ptrCast(*const IBootOptions, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IBootOptions_put_PlatformId(self: *const T, newVal: PlatformId) callconv(.Inline) HRESULT {
return @ptrCast(*const IBootOptions.VTable, self.vtable).put_PlatformId(@ptrCast(*const IBootOptions, self), newVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IBootOptions_get_Emulation(self: *const T, pVal: ?*EmulationType) callconv(.Inline) HRESULT {
return @ptrCast(*const IBootOptions.VTable, self.vtable).get_Emulation(@ptrCast(*const IBootOptions, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IBootOptions_put_Emulation(self: *const T, newVal: EmulationType) callconv(.Inline) HRESULT {
return @ptrCast(*const IBootOptions.VTable, self.vtable).put_Emulation(@ptrCast(*const IBootOptions, self), newVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IBootOptions_get_ImageSize(self: *const T, pVal: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IBootOptions.VTable, self.vtable).get_ImageSize(@ptrCast(*const IBootOptions, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IBootOptions_AssignBootImage(self: *const T, newVal: ?*IStream) callconv(.Inline) HRESULT {
return @ptrCast(*const IBootOptions.VTable, self.vtable).AssignBootImage(@ptrCast(*const IBootOptions, self), newVal);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IProgressItem_Value = @import("../zig.zig").Guid.initString("2c941fd5-975b-59be-a960-9a2a262853a5");
pub const IID_IProgressItem = &IID_IProgressItem_Value;
pub const IProgressItem = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Description: fn(
self: *const IProgressItem,
desc: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_FirstBlock: fn(
self: *const IProgressItem,
block: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_LastBlock: fn(
self: *const IProgressItem,
block: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_BlockCount: fn(
self: *const IProgressItem,
blocks: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IDispatch.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IProgressItem_get_Description(self: *const T, desc: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IProgressItem.VTable, self.vtable).get_Description(@ptrCast(*const IProgressItem, self), desc);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IProgressItem_get_FirstBlock(self: *const T, block: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IProgressItem.VTable, self.vtable).get_FirstBlock(@ptrCast(*const IProgressItem, self), block);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IProgressItem_get_LastBlock(self: *const T, block: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IProgressItem.VTable, self.vtable).get_LastBlock(@ptrCast(*const IProgressItem, self), block);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IProgressItem_get_BlockCount(self: *const T, blocks: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IProgressItem.VTable, self.vtable).get_BlockCount(@ptrCast(*const IProgressItem, self), blocks);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IEnumProgressItems_Value = @import("../zig.zig").Guid.initString("2c941fd6-975b-59be-a960-9a2a262853a5");
pub const IID_IEnumProgressItems = &IID_IEnumProgressItems_Value;
pub const IEnumProgressItems = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
Next: fn(
self: *const IEnumProgressItems,
celt: u32,
rgelt: [*]?*IProgressItem,
pceltFetched: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Skip: fn(
self: *const IEnumProgressItems,
celt: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Reset: fn(
self: *const IEnumProgressItems,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Clone: fn(
self: *const IEnumProgressItems,
ppEnum: ?*?*IEnumProgressItems,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumProgressItems_Next(self: *const T, celt: u32, rgelt: [*]?*IProgressItem, pceltFetched: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumProgressItems.VTable, self.vtable).Next(@ptrCast(*const IEnumProgressItems, self), celt, rgelt, pceltFetched);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumProgressItems_Skip(self: *const T, celt: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumProgressItems.VTable, self.vtable).Skip(@ptrCast(*const IEnumProgressItems, self), celt);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumProgressItems_Reset(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumProgressItems.VTable, self.vtable).Reset(@ptrCast(*const IEnumProgressItems, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumProgressItems_Clone(self: *const T, ppEnum: ?*?*IEnumProgressItems) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumProgressItems.VTable, self.vtable).Clone(@ptrCast(*const IEnumProgressItems, self), ppEnum);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IProgressItems_Value = @import("../zig.zig").Guid.initString("2c941fd7-975b-59be-a960-9a2a262853a5");
pub const IID_IProgressItems = &IID_IProgressItems_Value;
pub const IProgressItems = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get__NewEnum: fn(
self: *const IProgressItems,
NewEnum: ?*?*IEnumVARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Item: fn(
self: *const IProgressItems,
Index: i32,
item: ?*?*IProgressItem,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Count: fn(
self: *const IProgressItems,
Count: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ProgressItemFromBlock: fn(
self: *const IProgressItems,
block: u32,
item: ?*?*IProgressItem,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ProgressItemFromDescription: fn(
self: *const IProgressItems,
description: ?BSTR,
item: ?*?*IProgressItem,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_EnumProgressItems: fn(
self: *const IProgressItems,
NewEnum: ?*?*IEnumProgressItems,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IDispatch.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IProgressItems_get__NewEnum(self: *const T, NewEnum: ?*?*IEnumVARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const IProgressItems.VTable, self.vtable).get__NewEnum(@ptrCast(*const IProgressItems, self), NewEnum);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IProgressItems_get_Item(self: *const T, Index: i32, item: ?*?*IProgressItem) callconv(.Inline) HRESULT {
return @ptrCast(*const IProgressItems.VTable, self.vtable).get_Item(@ptrCast(*const IProgressItems, self), Index, item);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IProgressItems_get_Count(self: *const T, Count: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IProgressItems.VTable, self.vtable).get_Count(@ptrCast(*const IProgressItems, self), Count);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IProgressItems_ProgressItemFromBlock(self: *const T, block: u32, item: ?*?*IProgressItem) callconv(.Inline) HRESULT {
return @ptrCast(*const IProgressItems.VTable, self.vtable).ProgressItemFromBlock(@ptrCast(*const IProgressItems, self), block, item);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IProgressItems_ProgressItemFromDescription(self: *const T, description: ?BSTR, item: ?*?*IProgressItem) callconv(.Inline) HRESULT {
return @ptrCast(*const IProgressItems.VTable, self.vtable).ProgressItemFromDescription(@ptrCast(*const IProgressItems, self), description, item);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IProgressItems_get_EnumProgressItems(self: *const T, NewEnum: ?*?*IEnumProgressItems) callconv(.Inline) HRESULT {
return @ptrCast(*const IProgressItems.VTable, self.vtable).get_EnumProgressItems(@ptrCast(*const IProgressItems, self), NewEnum);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IFileSystemImageResult_Value = @import("../zig.zig").Guid.initString("2c941fd8-975b-59be-a960-9a2a262853a5");
pub const IID_IFileSystemImageResult = &IID_IFileSystemImageResult_Value;
pub const IFileSystemImageResult = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ImageStream: fn(
self: *const IFileSystemImageResult,
pVal: ?*?*IStream,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ProgressItems: fn(
self: *const IFileSystemImageResult,
pVal: ?*?*IProgressItems,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_TotalBlocks: fn(
self: *const IFileSystemImageResult,
pVal: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_BlockSize: fn(
self: *const IFileSystemImageResult,
pVal: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_DiscId: fn(
self: *const IFileSystemImageResult,
pVal: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IDispatch.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImageResult_get_ImageStream(self: *const T, pVal: ?*?*IStream) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImageResult.VTable, self.vtable).get_ImageStream(@ptrCast(*const IFileSystemImageResult, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImageResult_get_ProgressItems(self: *const T, pVal: ?*?*IProgressItems) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImageResult.VTable, self.vtable).get_ProgressItems(@ptrCast(*const IFileSystemImageResult, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImageResult_get_TotalBlocks(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImageResult.VTable, self.vtable).get_TotalBlocks(@ptrCast(*const IFileSystemImageResult, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImageResult_get_BlockSize(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImageResult.VTable, self.vtable).get_BlockSize(@ptrCast(*const IFileSystemImageResult, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImageResult_get_DiscId(self: *const T, pVal: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImageResult.VTable, self.vtable).get_DiscId(@ptrCast(*const IFileSystemImageResult, self), pVal);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.1'
const IID_IFileSystemImageResult2_Value = @import("../zig.zig").Guid.initString("b507ca29-2204-11dd-966a-001aa01bbc58");
pub const IID_IFileSystemImageResult2 = &IID_IFileSystemImageResult2_Value;
pub const IFileSystemImageResult2 = extern struct {
pub const VTable = extern struct {
base: IFileSystemImageResult.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ModifiedBlocks: fn(
self: *const IFileSystemImageResult2,
pVal: ?*?*IBlockRangeList,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IFileSystemImageResult.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImageResult2_get_ModifiedBlocks(self: *const T, pVal: ?*?*IBlockRangeList) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImageResult2.VTable, self.vtable).get_ModifiedBlocks(@ptrCast(*const IFileSystemImageResult2, self), pVal);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IFsiItem_Value = @import("../zig.zig").Guid.initString("2c941fd9-975b-59be-a960-9a2a262853a5");
pub const IID_IFsiItem = &IID_IFsiItem_Value;
pub const IFsiItem = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Name: fn(
self: *const IFsiItem,
pVal: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_FullPath: fn(
self: *const IFsiItem,
pVal: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CreationTime: fn(
self: *const IFsiItem,
pVal: ?*f64,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_CreationTime: fn(
self: *const IFsiItem,
newVal: f64,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_LastAccessedTime: fn(
self: *const IFsiItem,
pVal: ?*f64,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_LastAccessedTime: fn(
self: *const IFsiItem,
newVal: f64,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_LastModifiedTime: fn(
self: *const IFsiItem,
pVal: ?*f64,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_LastModifiedTime: fn(
self: *const IFsiItem,
newVal: f64,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IsHidden: fn(
self: *const IFsiItem,
pVal: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_IsHidden: fn(
self: *const IFsiItem,
newVal: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
FileSystemName: fn(
self: *const IFsiItem,
fileSystem: FsiFileSystems,
pVal: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
FileSystemPath: fn(
self: *const IFsiItem,
fileSystem: FsiFileSystems,
pVal: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IDispatch.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFsiItem_get_Name(self: *const T, pVal: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IFsiItem.VTable, self.vtable).get_Name(@ptrCast(*const IFsiItem, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFsiItem_get_FullPath(self: *const T, pVal: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IFsiItem.VTable, self.vtable).get_FullPath(@ptrCast(*const IFsiItem, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFsiItem_get_CreationTime(self: *const T, pVal: ?*f64) callconv(.Inline) HRESULT {
return @ptrCast(*const IFsiItem.VTable, self.vtable).get_CreationTime(@ptrCast(*const IFsiItem, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFsiItem_put_CreationTime(self: *const T, newVal: f64) callconv(.Inline) HRESULT {
return @ptrCast(*const IFsiItem.VTable, self.vtable).put_CreationTime(@ptrCast(*const IFsiItem, self), newVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFsiItem_get_LastAccessedTime(self: *const T, pVal: ?*f64) callconv(.Inline) HRESULT {
return @ptrCast(*const IFsiItem.VTable, self.vtable).get_LastAccessedTime(@ptrCast(*const IFsiItem, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFsiItem_put_LastAccessedTime(self: *const T, newVal: f64) callconv(.Inline) HRESULT {
return @ptrCast(*const IFsiItem.VTable, self.vtable).put_LastAccessedTime(@ptrCast(*const IFsiItem, self), newVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFsiItem_get_LastModifiedTime(self: *const T, pVal: ?*f64) callconv(.Inline) HRESULT {
return @ptrCast(*const IFsiItem.VTable, self.vtable).get_LastModifiedTime(@ptrCast(*const IFsiItem, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFsiItem_put_LastModifiedTime(self: *const T, newVal: f64) callconv(.Inline) HRESULT {
return @ptrCast(*const IFsiItem.VTable, self.vtable).put_LastModifiedTime(@ptrCast(*const IFsiItem, self), newVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFsiItem_get_IsHidden(self: *const T, pVal: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IFsiItem.VTable, self.vtable).get_IsHidden(@ptrCast(*const IFsiItem, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFsiItem_put_IsHidden(self: *const T, newVal: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IFsiItem.VTable, self.vtable).put_IsHidden(@ptrCast(*const IFsiItem, self), newVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFsiItem_FileSystemName(self: *const T, fileSystem: FsiFileSystems, pVal: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IFsiItem.VTable, self.vtable).FileSystemName(@ptrCast(*const IFsiItem, self), fileSystem, pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFsiItem_FileSystemPath(self: *const T, fileSystem: FsiFileSystems, pVal: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IFsiItem.VTable, self.vtable).FileSystemPath(@ptrCast(*const IFsiItem, self), fileSystem, pVal);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IEnumFsiItems_Value = @import("../zig.zig").Guid.initString("2c941fda-975b-59be-a960-9a2a262853a5");
pub const IID_IEnumFsiItems = &IID_IEnumFsiItems_Value;
pub const IEnumFsiItems = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
Next: fn(
self: *const IEnumFsiItems,
celt: u32,
rgelt: [*]?*IFsiItem,
pceltFetched: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Skip: fn(
self: *const IEnumFsiItems,
celt: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Reset: fn(
self: *const IEnumFsiItems,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Clone: fn(
self: *const IEnumFsiItems,
ppEnum: ?*?*IEnumFsiItems,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumFsiItems_Next(self: *const T, celt: u32, rgelt: [*]?*IFsiItem, pceltFetched: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumFsiItems.VTable, self.vtable).Next(@ptrCast(*const IEnumFsiItems, self), celt, rgelt, pceltFetched);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumFsiItems_Skip(self: *const T, celt: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumFsiItems.VTable, self.vtable).Skip(@ptrCast(*const IEnumFsiItems, self), celt);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumFsiItems_Reset(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumFsiItems.VTable, self.vtable).Reset(@ptrCast(*const IEnumFsiItems, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumFsiItems_Clone(self: *const T, ppEnum: ?*?*IEnumFsiItems) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumFsiItems.VTable, self.vtable).Clone(@ptrCast(*const IEnumFsiItems, self), ppEnum);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IFsiFileItem_Value = @import("../zig.zig").Guid.initString("2c941fdb-975b-59be-a960-9a2a262853a5");
pub const IID_IFsiFileItem = &IID_IFsiFileItem_Value;
pub const IFsiFileItem = extern struct {
pub const VTable = extern struct {
base: IFsiItem.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_DataSize: fn(
self: *const IFsiFileItem,
pVal: ?*i64,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_DataSize32BitLow: fn(
self: *const IFsiFileItem,
pVal: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_DataSize32BitHigh: fn(
self: *const IFsiFileItem,
pVal: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Data: fn(
self: *const IFsiFileItem,
pVal: ?*?*IStream,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_Data: fn(
self: *const IFsiFileItem,
newVal: ?*IStream,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IFsiItem.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFsiFileItem_get_DataSize(self: *const T, pVal: ?*i64) callconv(.Inline) HRESULT {
return @ptrCast(*const IFsiFileItem.VTable, self.vtable).get_DataSize(@ptrCast(*const IFsiFileItem, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFsiFileItem_get_DataSize32BitLow(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IFsiFileItem.VTable, self.vtable).get_DataSize32BitLow(@ptrCast(*const IFsiFileItem, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFsiFileItem_get_DataSize32BitHigh(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IFsiFileItem.VTable, self.vtable).get_DataSize32BitHigh(@ptrCast(*const IFsiFileItem, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFsiFileItem_get_Data(self: *const T, pVal: ?*?*IStream) callconv(.Inline) HRESULT {
return @ptrCast(*const IFsiFileItem.VTable, self.vtable).get_Data(@ptrCast(*const IFsiFileItem, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFsiFileItem_put_Data(self: *const T, newVal: ?*IStream) callconv(.Inline) HRESULT {
return @ptrCast(*const IFsiFileItem.VTable, self.vtable).put_Data(@ptrCast(*const IFsiFileItem, self), newVal);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IFsiFileItem2_Value = @import("../zig.zig").Guid.initString("199d0c19-11e1-40eb-8ec2-c8c822a07792");
pub const IID_IFsiFileItem2 = &IID_IFsiFileItem2_Value;
pub const IFsiFileItem2 = extern struct {
pub const VTable = extern struct {
base: IFsiFileItem.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_FsiNamedStreams: fn(
self: *const IFsiFileItem2,
streams: ?*?*IFsiNamedStreams,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IsNamedStream: fn(
self: *const IFsiFileItem2,
pVal: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
AddStream: fn(
self: *const IFsiFileItem2,
name: ?BSTR,
streamData: ?*IStream,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
RemoveStream: fn(
self: *const IFsiFileItem2,
name: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_IsRealTime: fn(
self: *const IFsiFileItem2,
pVal: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_IsRealTime: fn(
self: *const IFsiFileItem2,
newVal: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IFsiFileItem.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFsiFileItem2_get_FsiNamedStreams(self: *const T, streams: ?*?*IFsiNamedStreams) callconv(.Inline) HRESULT {
return @ptrCast(*const IFsiFileItem2.VTable, self.vtable).get_FsiNamedStreams(@ptrCast(*const IFsiFileItem2, self), streams);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFsiFileItem2_get_IsNamedStream(self: *const T, pVal: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IFsiFileItem2.VTable, self.vtable).get_IsNamedStream(@ptrCast(*const IFsiFileItem2, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFsiFileItem2_AddStream(self: *const T, name: ?BSTR, streamData: ?*IStream) callconv(.Inline) HRESULT {
return @ptrCast(*const IFsiFileItem2.VTable, self.vtable).AddStream(@ptrCast(*const IFsiFileItem2, self), name, streamData);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFsiFileItem2_RemoveStream(self: *const T, name: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IFsiFileItem2.VTable, self.vtable).RemoveStream(@ptrCast(*const IFsiFileItem2, self), name);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFsiFileItem2_get_IsRealTime(self: *const T, pVal: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IFsiFileItem2.VTable, self.vtable).get_IsRealTime(@ptrCast(*const IFsiFileItem2, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFsiFileItem2_put_IsRealTime(self: *const T, newVal: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IFsiFileItem2.VTable, self.vtable).put_IsRealTime(@ptrCast(*const IFsiFileItem2, self), newVal);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IFsiNamedStreams_Value = @import("../zig.zig").Guid.initString("ed79ba56-5294-4250-8d46-f9aecee23459");
pub const IID_IFsiNamedStreams = &IID_IFsiNamedStreams_Value;
pub const IFsiNamedStreams = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get__NewEnum: fn(
self: *const IFsiNamedStreams,
NewEnum: ?*?*IEnumVARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Item: fn(
self: *const IFsiNamedStreams,
index: i32,
item: ?*?*IFsiFileItem2,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Count: fn(
self: *const IFsiNamedStreams,
count: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_EnumNamedStreams: fn(
self: *const IFsiNamedStreams,
NewEnum: ?*?*IEnumFsiItems,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IDispatch.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFsiNamedStreams_get__NewEnum(self: *const T, NewEnum: ?*?*IEnumVARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const IFsiNamedStreams.VTable, self.vtable).get__NewEnum(@ptrCast(*const IFsiNamedStreams, self), NewEnum);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFsiNamedStreams_get_Item(self: *const T, index: i32, item: ?*?*IFsiFileItem2) callconv(.Inline) HRESULT {
return @ptrCast(*const IFsiNamedStreams.VTable, self.vtable).get_Item(@ptrCast(*const IFsiNamedStreams, self), index, item);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFsiNamedStreams_get_Count(self: *const T, count: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IFsiNamedStreams.VTable, self.vtable).get_Count(@ptrCast(*const IFsiNamedStreams, self), count);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFsiNamedStreams_get_EnumNamedStreams(self: *const T, NewEnum: ?*?*IEnumFsiItems) callconv(.Inline) HRESULT {
return @ptrCast(*const IFsiNamedStreams.VTable, self.vtable).get_EnumNamedStreams(@ptrCast(*const IFsiNamedStreams, self), NewEnum);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IFsiDirectoryItem_Value = @import("../zig.zig").Guid.initString("2c941fdc-975b-59be-a960-9a2a262853a5");
pub const IID_IFsiDirectoryItem = &IID_IFsiDirectoryItem_Value;
pub const IFsiDirectoryItem = extern struct {
pub const VTable = extern struct {
base: IFsiItem.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get__NewEnum: fn(
self: *const IFsiDirectoryItem,
NewEnum: ?*?*IEnumVARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Item: fn(
self: *const IFsiDirectoryItem,
path: ?BSTR,
item: ?*?*IFsiItem,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Count: fn(
self: *const IFsiDirectoryItem,
Count: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_EnumFsiItems: fn(
self: *const IFsiDirectoryItem,
NewEnum: ?*?*IEnumFsiItems,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
AddDirectory: fn(
self: *const IFsiDirectoryItem,
path: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
AddFile: fn(
self: *const IFsiDirectoryItem,
path: ?BSTR,
fileData: ?*IStream,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
AddTree: fn(
self: *const IFsiDirectoryItem,
sourceDirectory: ?BSTR,
includeBaseDirectory: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Add: fn(
self: *const IFsiDirectoryItem,
item: ?*IFsiItem,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Remove: fn(
self: *const IFsiDirectoryItem,
path: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
RemoveTree: fn(
self: *const IFsiDirectoryItem,
path: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IFsiItem.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFsiDirectoryItem_get__NewEnum(self: *const T, NewEnum: ?*?*IEnumVARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const IFsiDirectoryItem.VTable, self.vtable).get__NewEnum(@ptrCast(*const IFsiDirectoryItem, self), NewEnum);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFsiDirectoryItem_get_Item(self: *const T, path: ?BSTR, item: ?*?*IFsiItem) callconv(.Inline) HRESULT {
return @ptrCast(*const IFsiDirectoryItem.VTable, self.vtable).get_Item(@ptrCast(*const IFsiDirectoryItem, self), path, item);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFsiDirectoryItem_get_Count(self: *const T, Count: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IFsiDirectoryItem.VTable, self.vtable).get_Count(@ptrCast(*const IFsiDirectoryItem, self), Count);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFsiDirectoryItem_get_EnumFsiItems(self: *const T, NewEnum: ?*?*IEnumFsiItems) callconv(.Inline) HRESULT {
return @ptrCast(*const IFsiDirectoryItem.VTable, self.vtable).get_EnumFsiItems(@ptrCast(*const IFsiDirectoryItem, self), NewEnum);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFsiDirectoryItem_AddDirectory(self: *const T, path: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IFsiDirectoryItem.VTable, self.vtable).AddDirectory(@ptrCast(*const IFsiDirectoryItem, self), path);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFsiDirectoryItem_AddFile(self: *const T, path: ?BSTR, fileData: ?*IStream) callconv(.Inline) HRESULT {
return @ptrCast(*const IFsiDirectoryItem.VTable, self.vtable).AddFile(@ptrCast(*const IFsiDirectoryItem, self), path, fileData);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFsiDirectoryItem_AddTree(self: *const T, sourceDirectory: ?BSTR, includeBaseDirectory: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IFsiDirectoryItem.VTable, self.vtable).AddTree(@ptrCast(*const IFsiDirectoryItem, self), sourceDirectory, includeBaseDirectory);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFsiDirectoryItem_Add(self: *const T, item: ?*IFsiItem) callconv(.Inline) HRESULT {
return @ptrCast(*const IFsiDirectoryItem.VTable, self.vtable).Add(@ptrCast(*const IFsiDirectoryItem, self), item);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFsiDirectoryItem_Remove(self: *const T, path: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IFsiDirectoryItem.VTable, self.vtable).Remove(@ptrCast(*const IFsiDirectoryItem, self), path);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFsiDirectoryItem_RemoveTree(self: *const T, path: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IFsiDirectoryItem.VTable, self.vtable).RemoveTree(@ptrCast(*const IFsiDirectoryItem, self), path);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IFsiDirectoryItem2_Value = @import("../zig.zig").Guid.initString("f7fb4b9b-6d96-4d7b-9115-201b144811ef");
pub const IID_IFsiDirectoryItem2 = &IID_IFsiDirectoryItem2_Value;
pub const IFsiDirectoryItem2 = extern struct {
pub const VTable = extern struct {
base: IFsiDirectoryItem.VTable,
AddTreeWithNamedStreams: fn(
self: *const IFsiDirectoryItem2,
sourceDirectory: ?BSTR,
includeBaseDirectory: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IFsiDirectoryItem.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFsiDirectoryItem2_AddTreeWithNamedStreams(self: *const T, sourceDirectory: ?BSTR, includeBaseDirectory: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IFsiDirectoryItem2.VTable, self.vtable).AddTreeWithNamedStreams(@ptrCast(*const IFsiDirectoryItem2, self), sourceDirectory, includeBaseDirectory);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IFileSystemImage_Value = @import("../zig.zig").Guid.initString("2c941fe1-975b-59be-a960-9a2a262853a5");
pub const IID_IFileSystemImage = &IID_IFileSystemImage_Value;
pub const IFileSystemImage = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Root: fn(
self: *const IFileSystemImage,
pVal: ?*?*IFsiDirectoryItem,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_SessionStartBlock: fn(
self: *const IFileSystemImage,
pVal: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_SessionStartBlock: fn(
self: *const IFileSystemImage,
newVal: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_FreeMediaBlocks: fn(
self: *const IFileSystemImage,
pVal: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_FreeMediaBlocks: fn(
self: *const IFileSystemImage,
newVal: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetMaxMediaBlocksFromDevice: fn(
self: *const IFileSystemImage,
discRecorder: ?*IDiscRecorder2,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_UsedBlocks: fn(
self: *const IFileSystemImage,
pVal: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_VolumeName: fn(
self: *const IFileSystemImage,
pVal: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_VolumeName: fn(
self: *const IFileSystemImage,
newVal: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ImportedVolumeName: fn(
self: *const IFileSystemImage,
pVal: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_BootImageOptions: fn(
self: *const IFileSystemImage,
pVal: ?*?*IBootOptions,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_BootImageOptions: fn(
self: *const IFileSystemImage,
newVal: ?*IBootOptions,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_FileCount: fn(
self: *const IFileSystemImage,
pVal: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_DirectoryCount: fn(
self: *const IFileSystemImage,
pVal: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_WorkingDirectory: fn(
self: *const IFileSystemImage,
pVal: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_WorkingDirectory: fn(
self: *const IFileSystemImage,
newVal: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ChangePoint: fn(
self: *const IFileSystemImage,
pVal: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_StrictFileSystemCompliance: fn(
self: *const IFileSystemImage,
pVal: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_StrictFileSystemCompliance: fn(
self: *const IFileSystemImage,
newVal: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_UseRestrictedCharacterSet: fn(
self: *const IFileSystemImage,
pVal: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_UseRestrictedCharacterSet: fn(
self: *const IFileSystemImage,
newVal: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_FileSystemsToCreate: fn(
self: *const IFileSystemImage,
pVal: ?*FsiFileSystems,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_FileSystemsToCreate: fn(
self: *const IFileSystemImage,
newVal: FsiFileSystems,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_FileSystemsSupported: fn(
self: *const IFileSystemImage,
pVal: ?*FsiFileSystems,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_UDFRevision: fn(
self: *const IFileSystemImage,
newVal: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_UDFRevision: fn(
self: *const IFileSystemImage,
pVal: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_UDFRevisionsSupported: fn(
self: *const IFileSystemImage,
pVal: ?*?*SAFEARRAY,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ChooseImageDefaults: fn(
self: *const IFileSystemImage,
discRecorder: ?*IDiscRecorder2,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ChooseImageDefaultsForMediaType: fn(
self: *const IFileSystemImage,
value: IMAPI_MEDIA_PHYSICAL_TYPE,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_ISO9660InterchangeLevel: fn(
self: *const IFileSystemImage,
newVal: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ISO9660InterchangeLevel: fn(
self: *const IFileSystemImage,
pVal: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_ISO9660InterchangeLevelsSupported: fn(
self: *const IFileSystemImage,
pVal: ?*?*SAFEARRAY,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
CreateResultImage: fn(
self: *const IFileSystemImage,
resultStream: ?*?*IFileSystemImageResult,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Exists: fn(
self: *const IFileSystemImage,
fullPath: ?BSTR,
itemType: ?*FsiItemType,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
CalculateDiscIdentifier: fn(
self: *const IFileSystemImage,
discIdentifier: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
IdentifyFileSystemsOnDisc: fn(
self: *const IFileSystemImage,
discRecorder: ?*IDiscRecorder2,
fileSystems: ?*FsiFileSystems,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetDefaultFileSystemForImport: fn(
self: *const IFileSystemImage,
fileSystems: FsiFileSystems,
importDefault: ?*FsiFileSystems,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ImportFileSystem: fn(
self: *const IFileSystemImage,
importedFileSystem: ?*FsiFileSystems,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ImportSpecificFileSystem: fn(
self: *const IFileSystemImage,
fileSystemToUse: FsiFileSystems,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
RollbackToChangePoint: fn(
self: *const IFileSystemImage,
changePoint: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
LockInChangePoint: fn(
self: *const IFileSystemImage,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
CreateDirectoryItem: fn(
self: *const IFileSystemImage,
name: ?BSTR,
newItem: ?*?*IFsiDirectoryItem,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
CreateFileItem: fn(
self: *const IFileSystemImage,
name: ?BSTR,
newItem: ?*?*IFsiFileItem,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_VolumeNameUDF: fn(
self: *const IFileSystemImage,
pVal: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_VolumeNameJoliet: fn(
self: *const IFileSystemImage,
pVal: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_VolumeNameISO9660: fn(
self: *const IFileSystemImage,
pVal: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_StageFiles: fn(
self: *const IFileSystemImage,
pVal: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_StageFiles: fn(
self: *const IFileSystemImage,
newVal: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_MultisessionInterfaces: fn(
self: *const IFileSystemImage,
pVal: ?*?*SAFEARRAY,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_MultisessionInterfaces: fn(
self: *const IFileSystemImage,
newVal: ?*SAFEARRAY,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IDispatch.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_get_Root(self: *const T, pVal: ?*?*IFsiDirectoryItem) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).get_Root(@ptrCast(*const IFileSystemImage, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_get_SessionStartBlock(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).get_SessionStartBlock(@ptrCast(*const IFileSystemImage, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_put_SessionStartBlock(self: *const T, newVal: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).put_SessionStartBlock(@ptrCast(*const IFileSystemImage, self), newVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_get_FreeMediaBlocks(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).get_FreeMediaBlocks(@ptrCast(*const IFileSystemImage, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_put_FreeMediaBlocks(self: *const T, newVal: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).put_FreeMediaBlocks(@ptrCast(*const IFileSystemImage, self), newVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_SetMaxMediaBlocksFromDevice(self: *const T, discRecorder: ?*IDiscRecorder2) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).SetMaxMediaBlocksFromDevice(@ptrCast(*const IFileSystemImage, self), discRecorder);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_get_UsedBlocks(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).get_UsedBlocks(@ptrCast(*const IFileSystemImage, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_get_VolumeName(self: *const T, pVal: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).get_VolumeName(@ptrCast(*const IFileSystemImage, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_put_VolumeName(self: *const T, newVal: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).put_VolumeName(@ptrCast(*const IFileSystemImage, self), newVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_get_ImportedVolumeName(self: *const T, pVal: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).get_ImportedVolumeName(@ptrCast(*const IFileSystemImage, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_get_BootImageOptions(self: *const T, pVal: ?*?*IBootOptions) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).get_BootImageOptions(@ptrCast(*const IFileSystemImage, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_put_BootImageOptions(self: *const T, newVal: ?*IBootOptions) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).put_BootImageOptions(@ptrCast(*const IFileSystemImage, self), newVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_get_FileCount(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).get_FileCount(@ptrCast(*const IFileSystemImage, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_get_DirectoryCount(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).get_DirectoryCount(@ptrCast(*const IFileSystemImage, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_get_WorkingDirectory(self: *const T, pVal: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).get_WorkingDirectory(@ptrCast(*const IFileSystemImage, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_put_WorkingDirectory(self: *const T, newVal: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).put_WorkingDirectory(@ptrCast(*const IFileSystemImage, self), newVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_get_ChangePoint(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).get_ChangePoint(@ptrCast(*const IFileSystemImage, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_get_StrictFileSystemCompliance(self: *const T, pVal: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).get_StrictFileSystemCompliance(@ptrCast(*const IFileSystemImage, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_put_StrictFileSystemCompliance(self: *const T, newVal: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).put_StrictFileSystemCompliance(@ptrCast(*const IFileSystemImage, self), newVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_get_UseRestrictedCharacterSet(self: *const T, pVal: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).get_UseRestrictedCharacterSet(@ptrCast(*const IFileSystemImage, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_put_UseRestrictedCharacterSet(self: *const T, newVal: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).put_UseRestrictedCharacterSet(@ptrCast(*const IFileSystemImage, self), newVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_get_FileSystemsToCreate(self: *const T, pVal: ?*FsiFileSystems) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).get_FileSystemsToCreate(@ptrCast(*const IFileSystemImage, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_put_FileSystemsToCreate(self: *const T, newVal: FsiFileSystems) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).put_FileSystemsToCreate(@ptrCast(*const IFileSystemImage, self), newVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_get_FileSystemsSupported(self: *const T, pVal: ?*FsiFileSystems) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).get_FileSystemsSupported(@ptrCast(*const IFileSystemImage, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_put_UDFRevision(self: *const T, newVal: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).put_UDFRevision(@ptrCast(*const IFileSystemImage, self), newVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_get_UDFRevision(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).get_UDFRevision(@ptrCast(*const IFileSystemImage, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_get_UDFRevisionsSupported(self: *const T, pVal: ?*?*SAFEARRAY) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).get_UDFRevisionsSupported(@ptrCast(*const IFileSystemImage, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_ChooseImageDefaults(self: *const T, discRecorder: ?*IDiscRecorder2) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).ChooseImageDefaults(@ptrCast(*const IFileSystemImage, self), discRecorder);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_ChooseImageDefaultsForMediaType(self: *const T, value: IMAPI_MEDIA_PHYSICAL_TYPE) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).ChooseImageDefaultsForMediaType(@ptrCast(*const IFileSystemImage, self), value);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_put_ISO9660InterchangeLevel(self: *const T, newVal: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).put_ISO9660InterchangeLevel(@ptrCast(*const IFileSystemImage, self), newVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_get_ISO9660InterchangeLevel(self: *const T, pVal: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).get_ISO9660InterchangeLevel(@ptrCast(*const IFileSystemImage, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_get_ISO9660InterchangeLevelsSupported(self: *const T, pVal: ?*?*SAFEARRAY) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).get_ISO9660InterchangeLevelsSupported(@ptrCast(*const IFileSystemImage, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_CreateResultImage(self: *const T, resultStream: ?*?*IFileSystemImageResult) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).CreateResultImage(@ptrCast(*const IFileSystemImage, self), resultStream);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_Exists(self: *const T, fullPath: ?BSTR, itemType: ?*FsiItemType) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).Exists(@ptrCast(*const IFileSystemImage, self), fullPath, itemType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_CalculateDiscIdentifier(self: *const T, discIdentifier: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).CalculateDiscIdentifier(@ptrCast(*const IFileSystemImage, self), discIdentifier);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_IdentifyFileSystemsOnDisc(self: *const T, discRecorder: ?*IDiscRecorder2, fileSystems: ?*FsiFileSystems) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).IdentifyFileSystemsOnDisc(@ptrCast(*const IFileSystemImage, self), discRecorder, fileSystems);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_GetDefaultFileSystemForImport(self: *const T, fileSystems: FsiFileSystems, importDefault: ?*FsiFileSystems) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).GetDefaultFileSystemForImport(@ptrCast(*const IFileSystemImage, self), fileSystems, importDefault);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_ImportFileSystem(self: *const T, importedFileSystem: ?*FsiFileSystems) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).ImportFileSystem(@ptrCast(*const IFileSystemImage, self), importedFileSystem);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_ImportSpecificFileSystem(self: *const T, fileSystemToUse: FsiFileSystems) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).ImportSpecificFileSystem(@ptrCast(*const IFileSystemImage, self), fileSystemToUse);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_RollbackToChangePoint(self: *const T, changePoint: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).RollbackToChangePoint(@ptrCast(*const IFileSystemImage, self), changePoint);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_LockInChangePoint(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).LockInChangePoint(@ptrCast(*const IFileSystemImage, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_CreateDirectoryItem(self: *const T, name: ?BSTR, newItem: ?*?*IFsiDirectoryItem) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).CreateDirectoryItem(@ptrCast(*const IFileSystemImage, self), name, newItem);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_CreateFileItem(self: *const T, name: ?BSTR, newItem: ?*?*IFsiFileItem) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).CreateFileItem(@ptrCast(*const IFileSystemImage, self), name, newItem);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_get_VolumeNameUDF(self: *const T, pVal: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).get_VolumeNameUDF(@ptrCast(*const IFileSystemImage, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_get_VolumeNameJoliet(self: *const T, pVal: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).get_VolumeNameJoliet(@ptrCast(*const IFileSystemImage, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_get_VolumeNameISO9660(self: *const T, pVal: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).get_VolumeNameISO9660(@ptrCast(*const IFileSystemImage, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_get_StageFiles(self: *const T, pVal: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).get_StageFiles(@ptrCast(*const IFileSystemImage, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_put_StageFiles(self: *const T, newVal: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).put_StageFiles(@ptrCast(*const IFileSystemImage, self), newVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_get_MultisessionInterfaces(self: *const T, pVal: ?*?*SAFEARRAY) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).get_MultisessionInterfaces(@ptrCast(*const IFileSystemImage, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage_put_MultisessionInterfaces(self: *const T, newVal: ?*SAFEARRAY) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage.VTable, self.vtable).put_MultisessionInterfaces(@ptrCast(*const IFileSystemImage, self), newVal);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IFileSystemImage2_Value = @import("../zig.zig").Guid.initString("d7644b2c-1537-4767-b62f-f1387b02ddfd");
pub const IID_IFileSystemImage2 = &IID_IFileSystemImage2_Value;
pub const IFileSystemImage2 = extern struct {
pub const VTable = extern struct {
base: IFileSystemImage.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_BootImageOptionsArray: fn(
self: *const IFileSystemImage2,
pVal: ?*?*SAFEARRAY,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_BootImageOptionsArray: fn(
self: *const IFileSystemImage2,
newVal: ?*SAFEARRAY,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IFileSystemImage.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage2_get_BootImageOptionsArray(self: *const T, pVal: ?*?*SAFEARRAY) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage2.VTable, self.vtable).get_BootImageOptionsArray(@ptrCast(*const IFileSystemImage2, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage2_put_BootImageOptionsArray(self: *const T, newVal: ?*SAFEARRAY) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage2.VTable, self.vtable).put_BootImageOptionsArray(@ptrCast(*const IFileSystemImage2, self), newVal);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IFileSystemImage3_Value = @import("../zig.zig").Guid.initString("7cff842c-7e97-4807-8304-910dd8f7c051");
pub const IID_IFileSystemImage3 = &IID_IFileSystemImage3_Value;
pub const IFileSystemImage3 = extern struct {
pub const VTable = extern struct {
base: IFileSystemImage2.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_CreateRedundantUdfMetadataFiles: fn(
self: *const IFileSystemImage3,
pVal: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
put_CreateRedundantUdfMetadataFiles: fn(
self: *const IFileSystemImage3,
newVal: i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ProbeSpecificFileSystem: fn(
self: *const IFileSystemImage3,
fileSystemToProbe: FsiFileSystems,
isAppendable: ?*i16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IFileSystemImage2.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage3_get_CreateRedundantUdfMetadataFiles(self: *const T, pVal: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage3.VTable, self.vtable).get_CreateRedundantUdfMetadataFiles(@ptrCast(*const IFileSystemImage3, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage3_put_CreateRedundantUdfMetadataFiles(self: *const T, newVal: i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage3.VTable, self.vtable).put_CreateRedundantUdfMetadataFiles(@ptrCast(*const IFileSystemImage3, self), newVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IFileSystemImage3_ProbeSpecificFileSystem(self: *const T, fileSystemToProbe: FsiFileSystems, isAppendable: ?*i16) callconv(.Inline) HRESULT {
return @ptrCast(*const IFileSystemImage3.VTable, self.vtable).ProbeSpecificFileSystem(@ptrCast(*const IFileSystemImage3, self), fileSystemToProbe, isAppendable);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_DFileSystemImageEvents_Value = @import("../zig.zig").Guid.initString("2c941fdf-975b-59be-a960-9a2a262853a5");
pub const IID_DFileSystemImageEvents = &IID_DFileSystemImageEvents_Value;
pub const DFileSystemImageEvents = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
Update: fn(
self: *const DFileSystemImageEvents,
object: ?*IDispatch,
currentFile: ?BSTR,
copiedSectors: i32,
totalSectors: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IDispatch.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn DFileSystemImageEvents_Update(self: *const T, object: ?*IDispatch, currentFile: ?BSTR, copiedSectors: i32, totalSectors: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const DFileSystemImageEvents.VTable, self.vtable).Update(@ptrCast(*const DFileSystemImageEvents, self), object, currentFile, copiedSectors, totalSectors);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_DFileSystemImageImportEvents_Value = @import("../zig.zig").Guid.initString("d25c30f9-4087-4366-9e24-e55be286424b");
pub const IID_DFileSystemImageImportEvents = &IID_DFileSystemImageImportEvents_Value;
pub const DFileSystemImageImportEvents = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
UpdateImport: fn(
self: *const DFileSystemImageImportEvents,
object: ?*IDispatch,
fileSystem: FsiFileSystems,
currentItem: ?BSTR,
importedDirectoryItems: i32,
totalDirectoryItems: i32,
importedFileItems: i32,
totalFileItems: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IDispatch.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn DFileSystemImageImportEvents_UpdateImport(self: *const T, object: ?*IDispatch, fileSystem: FsiFileSystems, currentItem: ?BSTR, importedDirectoryItems: i32, totalDirectoryItems: i32, importedFileItems: i32, totalFileItems: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const DFileSystemImageImportEvents.VTable, self.vtable).UpdateImport(@ptrCast(*const DFileSystemImageImportEvents, self), object, fileSystem, currentItem, importedDirectoryItems, totalDirectoryItems, importedFileItems, totalFileItems);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows6.0.6000'
const IID_IIsoImageManager_Value = @import("../zig.zig").Guid.initString("6ca38be5-fbbb-4800-95a1-a438865eb0d4");
pub const IID_IIsoImageManager = &IID_IIsoImageManager_Value;
pub const IIsoImageManager = extern struct {
pub const VTable = extern struct {
base: IDispatch.VTable,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Path: fn(
self: *const IIsoImageManager,
pVal: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
// TODO: this function has a "SpecialName", should Zig do anything with this?
get_Stream: fn(
self: *const IIsoImageManager,
data: ?*?*IStream,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetPath: fn(
self: *const IIsoImageManager,
Val: ?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetStream: fn(
self: *const IIsoImageManager,
data: ?*IStream,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Validate: fn(
self: *const IIsoImageManager,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IDispatch.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IIsoImageManager_get_Path(self: *const T, pVal: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IIsoImageManager.VTable, self.vtable).get_Path(@ptrCast(*const IIsoImageManager, self), pVal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IIsoImageManager_get_Stream(self: *const T, data: ?*?*IStream) callconv(.Inline) HRESULT {
return @ptrCast(*const IIsoImageManager.VTable, self.vtable).get_Stream(@ptrCast(*const IIsoImageManager, self), data);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IIsoImageManager_SetPath(self: *const T, Val: ?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IIsoImageManager.VTable, self.vtable).SetPath(@ptrCast(*const IIsoImageManager, self), Val);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IIsoImageManager_SetStream(self: *const T, data: ?*IStream) callconv(.Inline) HRESULT {
return @ptrCast(*const IIsoImageManager.VTable, self.vtable).SetStream(@ptrCast(*const IIsoImageManager, self), data);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IIsoImageManager_Validate(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IIsoImageManager.VTable, self.vtable).Validate(@ptrCast(*const IIsoImageManager, self));
}
};}
pub usingnamespace MethodMixin(@This());
};
const CLSID_MSDiscRecorderObj_Value = @import("../zig.zig").Guid.initString("520cca61-51a5-11d3-9144-00104ba11c5e");
pub const CLSID_MSDiscRecorderObj = &CLSID_MSDiscRecorderObj_Value;
const CLSID_MSDiscMasterObj_Value = @import("../zig.zig").Guid.initString("520cca63-51a5-11d3-9144-00104ba11c5e");
pub const CLSID_MSDiscMasterObj = &CLSID_MSDiscMasterObj_Value;
const CLSID_MSEnumDiscRecordersObj_Value = @import("../zig.zig").Guid.initString("8a03567a-63cb-4ba8-baf6-52119816d1ef");
pub const CLSID_MSEnumDiscRecordersObj = &CLSID_MSEnumDiscRecordersObj_Value;
pub const MEDIA_TYPES = enum(i32) {
CDDA_CDROM = 1,
CD_ROM_XA = 2,
CD_I = 3,
CD_EXTRA = 4,
CD_OTHER = 5,
SPECIAL = 6,
};
pub const MEDIA_CDDA_CDROM = MEDIA_TYPES.CDDA_CDROM;
pub const MEDIA_CD_ROM_XA = MEDIA_TYPES.CD_ROM_XA;
pub const MEDIA_CD_I = MEDIA_TYPES.CD_I;
pub const MEDIA_CD_EXTRA = MEDIA_TYPES.CD_EXTRA;
pub const MEDIA_CD_OTHER = MEDIA_TYPES.CD_OTHER;
pub const MEDIA_SPECIAL = MEDIA_TYPES.SPECIAL;
pub const MEDIA_FLAGS = enum(i32) {
BLANK = 1,
RW = 2,
WRITABLE = 4,
FORMAT_UNUSABLE_BY_IMAPI = 8,
};
pub const MEDIA_BLANK = MEDIA_FLAGS.BLANK;
pub const MEDIA_RW = MEDIA_FLAGS.RW;
pub const MEDIA_WRITABLE = MEDIA_FLAGS.WRITABLE;
pub const MEDIA_FORMAT_UNUSABLE_BY_IMAPI = MEDIA_FLAGS.FORMAT_UNUSABLE_BY_IMAPI;
pub const RECORDER_TYPES = enum(i32) {
R = 1,
W = 2,
};
pub const RECORDER_CDR = RECORDER_TYPES.R;
pub const RECORDER_CDRW = RECORDER_TYPES.W;
// TODO: this type is limited to platform 'windows5.1.2600'
const IID_IDiscRecorder_Value = @import("../zig.zig").Guid.initString("85ac9776-ca88-4cf2-894e-09598c078a41");
pub const IID_IDiscRecorder = &IID_IDiscRecorder_Value;
pub const IDiscRecorder = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
Init: fn(
self: *const IDiscRecorder,
pbyUniqueID: [*:0]u8,
nulIDSize: u32,
nulDriveNumber: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetRecorderGUID: fn(
self: *const IDiscRecorder,
pbyUniqueID: ?[*:0]u8,
ulBufferSize: u32,
pulReturnSizeRequired: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetRecorderType: fn(
self: *const IDiscRecorder,
fTypeCode: ?*RECORDER_TYPES,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetDisplayNames: fn(
self: *const IDiscRecorder,
pbstrVendorID: ?*?BSTR,
pbstrProductID: ?*?BSTR,
pbstrRevision: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetBasePnPID: fn(
self: *const IDiscRecorder,
pbstrBasePnPID: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetPath: fn(
self: *const IDiscRecorder,
pbstrPath: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetRecorderProperties: fn(
self: *const IDiscRecorder,
ppPropStg: ?*?*IPropertyStorage,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetRecorderProperties: fn(
self: *const IDiscRecorder,
pPropStg: ?*IPropertyStorage,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetRecorderState: fn(
self: *const IDiscRecorder,
pulDevStateFlags: ?*DISC_RECORDER_STATE_FLAGS,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
OpenExclusive: fn(
self: *const IDiscRecorder,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
QueryMediaType: fn(
self: *const IDiscRecorder,
fMediaType: ?*MEDIA_TYPES,
fMediaFlags: ?*MEDIA_FLAGS,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
QueryMediaInfo: fn(
self: *const IDiscRecorder,
pbSessions: ?*u8,
pbLastTrack: ?*u8,
ulStartAddress: ?*u32,
ulNextWritable: ?*u32,
ulFreeBlocks: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Eject: fn(
self: *const IDiscRecorder,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Erase: fn(
self: *const IDiscRecorder,
bFullErase: u8,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Close: fn(
self: *const IDiscRecorder,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder_Init(self: *const T, pbyUniqueID: [*:0]u8, nulIDSize: u32, nulDriveNumber: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder.VTable, self.vtable).Init(@ptrCast(*const IDiscRecorder, self), pbyUniqueID, nulIDSize, nulDriveNumber);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder_GetRecorderGUID(self: *const T, pbyUniqueID: ?[*:0]u8, ulBufferSize: u32, pulReturnSizeRequired: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder.VTable, self.vtable).GetRecorderGUID(@ptrCast(*const IDiscRecorder, self), pbyUniqueID, ulBufferSize, pulReturnSizeRequired);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder_GetRecorderType(self: *const T, fTypeCode: ?*RECORDER_TYPES) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder.VTable, self.vtable).GetRecorderType(@ptrCast(*const IDiscRecorder, self), fTypeCode);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder_GetDisplayNames(self: *const T, pbstrVendorID: ?*?BSTR, pbstrProductID: ?*?BSTR, pbstrRevision: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder.VTable, self.vtable).GetDisplayNames(@ptrCast(*const IDiscRecorder, self), pbstrVendorID, pbstrProductID, pbstrRevision);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder_GetBasePnPID(self: *const T, pbstrBasePnPID: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder.VTable, self.vtable).GetBasePnPID(@ptrCast(*const IDiscRecorder, self), pbstrBasePnPID);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder_GetPath(self: *const T, pbstrPath: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder.VTable, self.vtable).GetPath(@ptrCast(*const IDiscRecorder, self), pbstrPath);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder_GetRecorderProperties(self: *const T, ppPropStg: ?*?*IPropertyStorage) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder.VTable, self.vtable).GetRecorderProperties(@ptrCast(*const IDiscRecorder, self), ppPropStg);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder_SetRecorderProperties(self: *const T, pPropStg: ?*IPropertyStorage) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder.VTable, self.vtable).SetRecorderProperties(@ptrCast(*const IDiscRecorder, self), pPropStg);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder_GetRecorderState(self: *const T, pulDevStateFlags: ?*DISC_RECORDER_STATE_FLAGS) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder.VTable, self.vtable).GetRecorderState(@ptrCast(*const IDiscRecorder, self), pulDevStateFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder_OpenExclusive(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder.VTable, self.vtable).OpenExclusive(@ptrCast(*const IDiscRecorder, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder_QueryMediaType(self: *const T, fMediaType: ?*MEDIA_TYPES, fMediaFlags: ?*MEDIA_FLAGS) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder.VTable, self.vtable).QueryMediaType(@ptrCast(*const IDiscRecorder, self), fMediaType, fMediaFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder_QueryMediaInfo(self: *const T, pbSessions: ?*u8, pbLastTrack: ?*u8, ulStartAddress: ?*u32, ulNextWritable: ?*u32, ulFreeBlocks: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder.VTable, self.vtable).QueryMediaInfo(@ptrCast(*const IDiscRecorder, self), pbSessions, pbLastTrack, ulStartAddress, ulNextWritable, ulFreeBlocks);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder_Eject(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder.VTable, self.vtable).Eject(@ptrCast(*const IDiscRecorder, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder_Erase(self: *const T, bFullErase: u8) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder.VTable, self.vtable).Erase(@ptrCast(*const IDiscRecorder, self), bFullErase);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscRecorder_Close(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscRecorder.VTable, self.vtable).Close(@ptrCast(*const IDiscRecorder, self));
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IEnumDiscRecorders_Value = @import("../zig.zig").Guid.initString("9b1921e1-54ac-11d3-9144-00104ba11c5e");
pub const IID_IEnumDiscRecorders = &IID_IEnumDiscRecorders_Value;
pub const IEnumDiscRecorders = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
Next: fn(
self: *const IEnumDiscRecorders,
cRecorders: u32,
ppRecorder: [*]?*IDiscRecorder,
pcFetched: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Skip: fn(
self: *const IEnumDiscRecorders,
cRecorders: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Reset: fn(
self: *const IEnumDiscRecorders,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Clone: fn(
self: *const IEnumDiscRecorders,
ppEnum: ?*?*IEnumDiscRecorders,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumDiscRecorders_Next(self: *const T, cRecorders: u32, ppRecorder: [*]?*IDiscRecorder, pcFetched: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumDiscRecorders.VTable, self.vtable).Next(@ptrCast(*const IEnumDiscRecorders, self), cRecorders, ppRecorder, pcFetched);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumDiscRecorders_Skip(self: *const T, cRecorders: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumDiscRecorders.VTable, self.vtable).Skip(@ptrCast(*const IEnumDiscRecorders, self), cRecorders);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumDiscRecorders_Reset(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumDiscRecorders.VTable, self.vtable).Reset(@ptrCast(*const IEnumDiscRecorders, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumDiscRecorders_Clone(self: *const T, ppEnum: ?*?*IEnumDiscRecorders) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumDiscRecorders.VTable, self.vtable).Clone(@ptrCast(*const IEnumDiscRecorders, self), ppEnum);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IEnumDiscMasterFormats_Value = @import("../zig.zig").Guid.initString("ddf445e1-54ba-11d3-9144-00104ba11c5e");
pub const IID_IEnumDiscMasterFormats = &IID_IEnumDiscMasterFormats_Value;
pub const IEnumDiscMasterFormats = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
Next: fn(
self: *const IEnumDiscMasterFormats,
cFormats: u32,
lpiidFormatID: [*]Guid,
pcFetched: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Skip: fn(
self: *const IEnumDiscMasterFormats,
cFormats: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Reset: fn(
self: *const IEnumDiscMasterFormats,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Clone: fn(
self: *const IEnumDiscMasterFormats,
ppEnum: ?*?*IEnumDiscMasterFormats,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumDiscMasterFormats_Next(self: *const T, cFormats: u32, lpiidFormatID: [*]Guid, pcFetched: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumDiscMasterFormats.VTable, self.vtable).Next(@ptrCast(*const IEnumDiscMasterFormats, self), cFormats, lpiidFormatID, pcFetched);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumDiscMasterFormats_Skip(self: *const T, cFormats: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumDiscMasterFormats.VTable, self.vtable).Skip(@ptrCast(*const IEnumDiscMasterFormats, self), cFormats);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumDiscMasterFormats_Reset(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumDiscMasterFormats.VTable, self.vtable).Reset(@ptrCast(*const IEnumDiscMasterFormats, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IEnumDiscMasterFormats_Clone(self: *const T, ppEnum: ?*?*IEnumDiscMasterFormats) callconv(.Inline) HRESULT {
return @ptrCast(*const IEnumDiscMasterFormats.VTable, self.vtable).Clone(@ptrCast(*const IEnumDiscMasterFormats, self), ppEnum);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows5.1.2600'
const IID_IRedbookDiscMaster_Value = @import("../zig.zig").Guid.initString("e3bc42cd-4e5c-11d3-9144-00104ba11c5e");
pub const IID_IRedbookDiscMaster = &IID_IRedbookDiscMaster_Value;
pub const IRedbookDiscMaster = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
GetTotalAudioTracks: fn(
self: *const IRedbookDiscMaster,
pnTracks: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetTotalAudioBlocks: fn(
self: *const IRedbookDiscMaster,
pnBlocks: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetUsedAudioBlocks: fn(
self: *const IRedbookDiscMaster,
pnBlocks: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetAvailableAudioTrackBlocks: fn(
self: *const IRedbookDiscMaster,
pnBlocks: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetAudioBlockSize: fn(
self: *const IRedbookDiscMaster,
pnBlockBytes: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
CreateAudioTrack: fn(
self: *const IRedbookDiscMaster,
nBlocks: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
AddAudioTrackBlocks: fn(
self: *const IRedbookDiscMaster,
pby: [*:0]u8,
cb: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
CloseAudioTrack: fn(
self: *const IRedbookDiscMaster,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRedbookDiscMaster_GetTotalAudioTracks(self: *const T, pnTracks: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IRedbookDiscMaster.VTable, self.vtable).GetTotalAudioTracks(@ptrCast(*const IRedbookDiscMaster, self), pnTracks);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRedbookDiscMaster_GetTotalAudioBlocks(self: *const T, pnBlocks: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IRedbookDiscMaster.VTable, self.vtable).GetTotalAudioBlocks(@ptrCast(*const IRedbookDiscMaster, self), pnBlocks);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRedbookDiscMaster_GetUsedAudioBlocks(self: *const T, pnBlocks: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IRedbookDiscMaster.VTable, self.vtable).GetUsedAudioBlocks(@ptrCast(*const IRedbookDiscMaster, self), pnBlocks);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRedbookDiscMaster_GetAvailableAudioTrackBlocks(self: *const T, pnBlocks: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IRedbookDiscMaster.VTable, self.vtable).GetAvailableAudioTrackBlocks(@ptrCast(*const IRedbookDiscMaster, self), pnBlocks);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRedbookDiscMaster_GetAudioBlockSize(self: *const T, pnBlockBytes: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IRedbookDiscMaster.VTable, self.vtable).GetAudioBlockSize(@ptrCast(*const IRedbookDiscMaster, self), pnBlockBytes);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRedbookDiscMaster_CreateAudioTrack(self: *const T, nBlocks: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IRedbookDiscMaster.VTable, self.vtable).CreateAudioTrack(@ptrCast(*const IRedbookDiscMaster, self), nBlocks);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRedbookDiscMaster_AddAudioTrackBlocks(self: *const T, pby: [*:0]u8, cb: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IRedbookDiscMaster.VTable, self.vtable).AddAudioTrackBlocks(@ptrCast(*const IRedbookDiscMaster, self), pby, cb);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IRedbookDiscMaster_CloseAudioTrack(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IRedbookDiscMaster.VTable, self.vtable).CloseAudioTrack(@ptrCast(*const IRedbookDiscMaster, self));
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows5.1.2600'
const IID_IJolietDiscMaster_Value = @import("../zig.zig").Guid.initString("e3bc42ce-4e5c-11d3-9144-00104ba11c5e");
pub const IID_IJolietDiscMaster = &IID_IJolietDiscMaster_Value;
pub const IJolietDiscMaster = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
GetTotalDataBlocks: fn(
self: *const IJolietDiscMaster,
pnBlocks: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetUsedDataBlocks: fn(
self: *const IJolietDiscMaster,
pnBlocks: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetDataBlockSize: fn(
self: *const IJolietDiscMaster,
pnBlockBytes: ?*i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
AddData: fn(
self: *const IJolietDiscMaster,
pStorage: ?*IStorage,
lFileOverwrite: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetJolietProperties: fn(
self: *const IJolietDiscMaster,
ppPropStg: ?*?*IPropertyStorage,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetJolietProperties: fn(
self: *const IJolietDiscMaster,
pPropStg: ?*IPropertyStorage,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IJolietDiscMaster_GetTotalDataBlocks(self: *const T, pnBlocks: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IJolietDiscMaster.VTable, self.vtable).GetTotalDataBlocks(@ptrCast(*const IJolietDiscMaster, self), pnBlocks);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IJolietDiscMaster_GetUsedDataBlocks(self: *const T, pnBlocks: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IJolietDiscMaster.VTable, self.vtable).GetUsedDataBlocks(@ptrCast(*const IJolietDiscMaster, self), pnBlocks);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IJolietDiscMaster_GetDataBlockSize(self: *const T, pnBlockBytes: ?*i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IJolietDiscMaster.VTable, self.vtable).GetDataBlockSize(@ptrCast(*const IJolietDiscMaster, self), pnBlockBytes);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IJolietDiscMaster_AddData(self: *const T, pStorage: ?*IStorage, lFileOverwrite: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IJolietDiscMaster.VTable, self.vtable).AddData(@ptrCast(*const IJolietDiscMaster, self), pStorage, lFileOverwrite);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IJolietDiscMaster_GetJolietProperties(self: *const T, ppPropStg: ?*?*IPropertyStorage) callconv(.Inline) HRESULT {
return @ptrCast(*const IJolietDiscMaster.VTable, self.vtable).GetJolietProperties(@ptrCast(*const IJolietDiscMaster, self), ppPropStg);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IJolietDiscMaster_SetJolietProperties(self: *const T, pPropStg: ?*IPropertyStorage) callconv(.Inline) HRESULT {
return @ptrCast(*const IJolietDiscMaster.VTable, self.vtable).SetJolietProperties(@ptrCast(*const IJolietDiscMaster, self), pPropStg);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows5.1.2600'
const IID_IDiscMasterProgressEvents_Value = @import("../zig.zig").Guid.initString("ec9e51c1-4e5d-11d3-9144-00104ba11c5e");
pub const IID_IDiscMasterProgressEvents = &IID_IDiscMasterProgressEvents_Value;
pub const IDiscMasterProgressEvents = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
QueryCancel: fn(
self: *const IDiscMasterProgressEvents,
pbCancel: ?*u8,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
NotifyPnPActivity: fn(
self: *const IDiscMasterProgressEvents,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
NotifyAddProgress: fn(
self: *const IDiscMasterProgressEvents,
nCompletedSteps: i32,
nTotalSteps: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
NotifyBlockProgress: fn(
self: *const IDiscMasterProgressEvents,
nCompleted: i32,
nTotal: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
NotifyTrackProgress: fn(
self: *const IDiscMasterProgressEvents,
nCurrentTrack: i32,
nTotalTracks: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
NotifyPreparingBurn: fn(
self: *const IDiscMasterProgressEvents,
nEstimatedSeconds: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
NotifyClosingDisc: fn(
self: *const IDiscMasterProgressEvents,
nEstimatedSeconds: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
NotifyBurnComplete: fn(
self: *const IDiscMasterProgressEvents,
status: HRESULT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
NotifyEraseComplete: fn(
self: *const IDiscMasterProgressEvents,
status: HRESULT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscMasterProgressEvents_QueryCancel(self: *const T, pbCancel: ?*u8) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscMasterProgressEvents.VTable, self.vtable).QueryCancel(@ptrCast(*const IDiscMasterProgressEvents, self), pbCancel);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscMasterProgressEvents_NotifyPnPActivity(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscMasterProgressEvents.VTable, self.vtable).NotifyPnPActivity(@ptrCast(*const IDiscMasterProgressEvents, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscMasterProgressEvents_NotifyAddProgress(self: *const T, nCompletedSteps: i32, nTotalSteps: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscMasterProgressEvents.VTable, self.vtable).NotifyAddProgress(@ptrCast(*const IDiscMasterProgressEvents, self), nCompletedSteps, nTotalSteps);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscMasterProgressEvents_NotifyBlockProgress(self: *const T, nCompleted: i32, nTotal: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscMasterProgressEvents.VTable, self.vtable).NotifyBlockProgress(@ptrCast(*const IDiscMasterProgressEvents, self), nCompleted, nTotal);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscMasterProgressEvents_NotifyTrackProgress(self: *const T, nCurrentTrack: i32, nTotalTracks: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscMasterProgressEvents.VTable, self.vtable).NotifyTrackProgress(@ptrCast(*const IDiscMasterProgressEvents, self), nCurrentTrack, nTotalTracks);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscMasterProgressEvents_NotifyPreparingBurn(self: *const T, nEstimatedSeconds: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscMasterProgressEvents.VTable, self.vtable).NotifyPreparingBurn(@ptrCast(*const IDiscMasterProgressEvents, self), nEstimatedSeconds);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscMasterProgressEvents_NotifyClosingDisc(self: *const T, nEstimatedSeconds: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscMasterProgressEvents.VTable, self.vtable).NotifyClosingDisc(@ptrCast(*const IDiscMasterProgressEvents, self), nEstimatedSeconds);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscMasterProgressEvents_NotifyBurnComplete(self: *const T, status: HRESULT) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscMasterProgressEvents.VTable, self.vtable).NotifyBurnComplete(@ptrCast(*const IDiscMasterProgressEvents, self), status);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscMasterProgressEvents_NotifyEraseComplete(self: *const T, status: HRESULT) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscMasterProgressEvents.VTable, self.vtable).NotifyEraseComplete(@ptrCast(*const IDiscMasterProgressEvents, self), status);
}
};}
pub usingnamespace MethodMixin(@This());
};
// TODO: this type is limited to platform 'windows5.1.2600'
const IID_IDiscMaster_Value = @import("../zig.zig").Guid.initString("520cca62-51a5-11d3-9144-00104ba11c5e");
pub const IID_IDiscMaster = &IID_IDiscMaster_Value;
pub const IDiscMaster = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
Open: fn(
self: *const IDiscMaster,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EnumDiscMasterFormats: fn(
self: *const IDiscMaster,
ppEnum: ?*?*IEnumDiscMasterFormats,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetActiveDiscMasterFormat: fn(
self: *const IDiscMaster,
lpiid: ?*Guid,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetActiveDiscMasterFormat: fn(
self: *const IDiscMaster,
riid: ?*const Guid,
ppUnk: ?*?*c_void,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EnumDiscRecorders: fn(
self: *const IDiscMaster,
ppEnum: ?*?*IEnumDiscRecorders,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetActiveDiscRecorder: fn(
self: *const IDiscMaster,
ppRecorder: ?*?*IDiscRecorder,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetActiveDiscRecorder: fn(
self: *const IDiscMaster,
pRecorder: ?*IDiscRecorder,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ClearFormatContent: fn(
self: *const IDiscMaster,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ProgressAdvise: fn(
self: *const IDiscMaster,
pEvents: ?*IDiscMasterProgressEvents,
pvCookie: ?*usize,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ProgressUnadvise: fn(
self: *const IDiscMaster,
vCookie: usize,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
RecordDisc: fn(
self: *const IDiscMaster,
bSimulate: u8,
bEjectAfterBurn: u8,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Close: fn(
self: *const IDiscMaster,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscMaster_Open(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscMaster.VTable, self.vtable).Open(@ptrCast(*const IDiscMaster, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscMaster_EnumDiscMasterFormats(self: *const T, ppEnum: ?*?*IEnumDiscMasterFormats) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscMaster.VTable, self.vtable).EnumDiscMasterFormats(@ptrCast(*const IDiscMaster, self), ppEnum);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscMaster_GetActiveDiscMasterFormat(self: *const T, lpiid: ?*Guid) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscMaster.VTable, self.vtable).GetActiveDiscMasterFormat(@ptrCast(*const IDiscMaster, self), lpiid);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscMaster_SetActiveDiscMasterFormat(self: *const T, riid: ?*const Guid, ppUnk: ?*?*c_void) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscMaster.VTable, self.vtable).SetActiveDiscMasterFormat(@ptrCast(*const IDiscMaster, self), riid, ppUnk);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscMaster_EnumDiscRecorders(self: *const T, ppEnum: ?*?*IEnumDiscRecorders) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscMaster.VTable, self.vtable).EnumDiscRecorders(@ptrCast(*const IDiscMaster, self), ppEnum);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscMaster_GetActiveDiscRecorder(self: *const T, ppRecorder: ?*?*IDiscRecorder) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscMaster.VTable, self.vtable).GetActiveDiscRecorder(@ptrCast(*const IDiscMaster, self), ppRecorder);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscMaster_SetActiveDiscRecorder(self: *const T, pRecorder: ?*IDiscRecorder) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscMaster.VTable, self.vtable).SetActiveDiscRecorder(@ptrCast(*const IDiscMaster, self), pRecorder);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscMaster_ClearFormatContent(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscMaster.VTable, self.vtable).ClearFormatContent(@ptrCast(*const IDiscMaster, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscMaster_ProgressAdvise(self: *const T, pEvents: ?*IDiscMasterProgressEvents, pvCookie: ?*usize) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscMaster.VTable, self.vtable).ProgressAdvise(@ptrCast(*const IDiscMaster, self), pEvents, pvCookie);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscMaster_ProgressUnadvise(self: *const T, vCookie: usize) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscMaster.VTable, self.vtable).ProgressUnadvise(@ptrCast(*const IDiscMaster, self), vCookie);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscMaster_RecordDisc(self: *const T, bSimulate: u8, bEjectAfterBurn: u8) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscMaster.VTable, self.vtable).RecordDisc(@ptrCast(*const IDiscMaster, self), bSimulate, bEjectAfterBurn);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IDiscMaster_Close(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IDiscMaster.VTable, self.vtable).Close(@ptrCast(*const IDiscMaster, self));
}
};}
pub usingnamespace MethodMixin(@This());
};
//--------------------------------------------------------------------------------
// Section: Functions (0)
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
// Section: Unicode Aliases (0)
//--------------------------------------------------------------------------------
const thismodule = @This();
pub usingnamespace switch (@import("../zig.zig").unicode_mode) {
.ansi => struct {
},
.wide => struct {
},
.unspecified => if (@import("builtin").is_test) struct {
} else struct {
},
};
//--------------------------------------------------------------------------------
// Section: Imports (11)
//--------------------------------------------------------------------------------
const Guid = @import("../zig.zig").Guid;
const BOOLEAN = @import("../foundation.zig").BOOLEAN;
const BSTR = @import("../foundation.zig").BSTR;
const HRESULT = @import("../foundation.zig").HRESULT;
const IDispatch = @import("../system/ole_automation.zig").IDispatch;
const IEnumVARIANT = @import("../system/ole_automation.zig").IEnumVARIANT;
const IPropertyStorage = @import("../storage/structured_storage.zig").IPropertyStorage;
const IStorage = @import("../storage/structured_storage.zig").IStorage;
const IStream = @import("../storage/structured_storage.zig").IStream;
const IUnknown = @import("../system/com.zig").IUnknown;
const SAFEARRAY = @import("../system/ole_automation.zig").SAFEARRAY;
test {
@setEvalBranchQuota(
@import("std").meta.declarations(@This()).len * 3
);
// reference all the pub declarations
if (!@import("builtin").is_test) return;
inline for (@import("std").meta.declarations(@This())) |decl| {
if (decl.is_pub) {
_ = decl;
}
}
} | deps/zigwin32/win32/storage/imapi.zig |
const std = @import("std");
const ast = @import("ast.zig");
const Expr = ast.Expr;
const Env = ast.Env;
const ExprType = ast.ExprType;
pub var gpa = std.heap.GeneralPurposeAllocator(.{ .safety = true }){};
pub var allocator = gpa.allocator();
pub var interned_syms: std.StringArrayHashMapUnmanaged(void) = .{};
pub var interned_nums: std.AutoHashMapUnmanaged(i16, *Expr) = .{};
pub var interned_intrinsics: std.StringArrayHashMapUnmanaged(*Expr) = .{};
/// Mark and sweep garbage collector
pub const GC = struct {
const stdout = std.io.getStdOut().writer();
allocations: usize,
registered_expr: std.ArrayList(*Expr) = undefined,
registered_envs: std.ArrayList(*Env) = undefined,
pub fn init() !GC {
return GC{
.allocations = 0,
.registered_expr = std.ArrayList(*Expr).init(allocator),
.registered_envs = std.ArrayList(*Env).init(allocator),
};
}
/// Update stats, which counts towards running the garbage collector
pub fn inc(self: *GC) void {
self.allocations += 1;
}
pub fn runIfNeeded(self: *GC) !void {
if (self.allocations % 100_000 == 0) {
try self.run(false);
}
}
/// Do a full sweep regardless of reachability
pub fn deinit(self: *GC) void {
var marked = std.AutoArrayHashMap(*Expr, void).init(allocator);
defer marked.deinit();
self.sweep(&marked, false) catch unreachable;
for (self.registered_envs.items) |env| {
env.deinit();
allocator.destroy(env);
}
self.registered_envs.deinit();
self.registered_expr.deinit();
interned_intrinsics.deinit(allocator);
for (interned_syms.keys()) |key| {
allocator.free(key);
}
interned_syms.deinit(allocator);
var it = interned_nums.iterator();
while (it.next()) |entry| {
allocator.destroy(entry.value_ptr.*);
}
interned_nums.deinit(allocator);
}
/// Run mark and sweep over expressions and environments
pub fn run(self: *GC, print_stats: bool) !void {
const sweep_count = try self.sweepEnvironments();
if (print_stats) {
try std.io.getStdOut().writer().print("Garbage collected {d} environments\n", .{sweep_count});
}
var marked = std.AutoArrayHashMap(*Expr, void).init(allocator);
defer marked.deinit();
// Start marking reachable objects
for (self.registered_envs.items) |e| {
var iter = e.map.iterator();
while (iter.next()) |entry| {
try self.mark(entry.key_ptr.*, &marked);
try self.mark(entry.value_ptr.*, &marked);
}
}
// Sweep unreachable objects
try self.sweep(&marked, print_stats);
}
/// Recursively mark environments
fn markEnvironment(self: *GC, env: *Env, marked: *std.AutoArrayHashMap(*Env, void)) anyerror!void {
if (!marked.contains(env)) {
try marked.put(env, {});
for (env.map.values()) |env_entry_value| {
if (env_entry_value.val == ExprType.env) {
try self.markEnvironment(env_entry_value.val.env, marked);
} else if (env_entry_value.env) |actual_env| {
try self.markEnvironment(actual_env, marked);
}
}
if (env.parent) |parent_env| {
try self.markEnvironment(parent_env, marked);
}
}
}
/// Sweep unmarked environments
fn sweepEnvironments(self: *GC) !usize {
var sweep_count: usize = 0;
if (self.registered_envs.items.len > 1) {
var root_env = self.registered_envs.items[0];
var marked = std.AutoArrayHashMap(*Env, void).init(allocator);
defer marked.deinit();
try self.markEnvironment(root_env, &marked);
var idx: usize = 0;
while (idx < self.registered_envs.items.len) {
const current_env = self.registered_envs.items[idx];
if (!marked.contains(current_env)) {
_ = self.registered_envs.swapRemove(idx);
current_env.deinit();
allocator.destroy(current_env);
sweep_count += 1;
} else {
idx += 1;
}
}
}
return sweep_count;
}
/// Recursively mark expressions
fn mark(self: *GC, expr: *Expr, marked: *std.AutoArrayHashMap(*Expr, void)) anyerror!void {
if (!marked.contains(expr)) {
try marked.put(expr, {});
if (expr.val == ExprType.err) {
try self.mark(expr.val.err, marked);
} else if (expr.val == ExprType.lst) {
for (expr.val.lst.items) |item| {
try self.mark(item, marked);
}
} else if (expr.val == ExprType.map) {
var it = expr.val.map.iterator();
while (it.next()) |entry| {
try self.mark(entry.key_ptr.*, marked);
try self.mark(entry.value_ptr.*, marked);
}
} else if (expr.val == ExprType.lam) {
for (expr.val.lam.items) |item| {
try self.mark(item, marked);
}
} else if (expr.val == ExprType.mac) {
for (expr.val.mac.items) |item| {
try self.mark(item, marked);
}
}
}
}
/// Sweep unmarked expressions
fn sweep(self: *GC, marked: *std.AutoArrayHashMap(*Expr, void), print_stats: bool) !void {
var collected: usize = 0;
var idx: usize = 0;
while (idx < self.registered_expr.items.len) {
const expr = self.registered_expr.items[idx];
if (!marked.contains(expr)) {
_ = self.registered_expr.swapRemove(idx);
expr.deinit();
allocator.destroy(expr);
collected += 1;
} else {
idx += 1;
}
}
if (print_stats) {
try std.io.getStdOut().writer().print("Garbage collected {d} items, there's been {d} total allocations\n", .{ collected, self.allocations });
}
}
};
pub var gc: GC = undefined; | src/gc.zig |
const Span = @import("basics.zig").Span;
const addScalarInto = @import("basics.zig").addScalarInto;
// this is a struct to be used temporarily within a paint call.
pub const PaintState = struct {
buf: []f32,
i: usize,
sample_rate: f32,
pub inline fn init(buf: []f32, sample_rate: f32) PaintState {
return .{
.buf = buf,
.i = 0,
.sample_rate = sample_rate,
};
}
};
pub const PaintCurve = union(enum) {
instantaneous,
linear: f32, // duration (must be > 0)
squared: f32, // ditto
cubed: f32, // ditto
};
// this is a long-lived struct, which remembers progress between paints
pub const Painter = struct {
t: f32,
last_value: f32,
start: f32,
pub fn init() Painter {
return .{
.t = 0.0,
.last_value = 0.0,
.start = 0.0,
};
}
// reset curve timer
pub fn newCurve(self: *Painter) void {
self.start = self.last_value;
self.t = 0.0;
}
// paint a constant value until the end of the buffer
pub fn paintFlat(self: *Painter, state: *PaintState, value: f32) void {
const buf = state.buf;
addScalarInto(Span.init(state.i, buf.len), buf, value);
state.i = buf.len;
}
// paint samples, approaching `goal` as we go. stop when we hit `goal` or
// when we hit the end of the buffer, whichever comes first. return true
// if we reached the `goal` before hitting the end of the buffer.
pub fn paintToward(
self: *Painter,
state: *PaintState,
curve: PaintCurve,
goal: f32,
) bool {
if (self.t >= 1.0) {
return true;
}
var curve_func: enum { linear, squared, cubed } = undefined;
var duration: f32 = undefined;
switch (curve) {
.instantaneous => {
self.t = 1.0;
self.last_value = goal;
return true;
},
.linear => |dur| {
curve_func = .linear;
duration = dur;
},
.squared => |dur| {
curve_func = .squared;
duration = dur;
},
.cubed => |dur| {
curve_func = .cubed;
duration = dur;
},
}
var i = state.i;
const t_step = 1.0 / (duration * state.sample_rate);
var finished = false;
// TODO - this can be optimized
const buf = state.buf;
while (!finished and i < buf.len) : (i += 1) {
self.t += t_step;
if (self.t >= 1.0) {
self.t = 1.0;
finished = true;
}
const it = 1.0 - self.t;
const tp = switch (curve_func) {
.linear => self.t,
.squared => 1.0 - it * it,
.cubed => 1.0 - it * it * it,
};
self.last_value = self.start + tp * (goal - self.start);
buf[i] += self.last_value;
}
state.i = i;
return finished;
}
}; | src/zang/painter.zig |
//--------------------------------------------------------------------------------
// Section: Types (19)
//--------------------------------------------------------------------------------
pub const RAW_INPUT_DATA_COMMAND_FLAGS = enum(u32) {
HEADER = 268435461,
INPUT = 268435459,
};
pub const RID_HEADER = RAW_INPUT_DATA_COMMAND_FLAGS.HEADER;
pub const RID_INPUT = RAW_INPUT_DATA_COMMAND_FLAGS.INPUT;
pub const RAW_INPUT_DEVICE_INFO_COMMAND = enum(u32) {
PREPARSEDDATA = 536870917,
DEVICENAME = 536870919,
DEVICEINFO = 536870923,
};
pub const RIDI_PREPARSEDDATA = RAW_INPUT_DEVICE_INFO_COMMAND.PREPARSEDDATA;
pub const RIDI_DEVICENAME = RAW_INPUT_DEVICE_INFO_COMMAND.DEVICENAME;
pub const RIDI_DEVICEINFO = RAW_INPUT_DEVICE_INFO_COMMAND.DEVICEINFO;
pub const RID_DEVICE_INFO_TYPE = enum(u32) {
MOUSE = 0,
KEYBOARD = 1,
HID = 2,
};
pub const RIM_TYPEMOUSE = RID_DEVICE_INFO_TYPE.MOUSE;
pub const RIM_TYPEKEYBOARD = RID_DEVICE_INFO_TYPE.KEYBOARD;
pub const RIM_TYPEHID = RID_DEVICE_INFO_TYPE.HID;
pub const RAWINPUTDEVICE_FLAGS = enum(u32) {
REMOVE = 1,
EXCLUDE = 16,
PAGEONLY = 32,
NOLEGACY = 48,
INPUTSINK = 256,
CAPTUREMOUSE = 512,
// NOHOTKEYS = 512, this enum value conflicts with CAPTUREMOUSE
APPKEYS = 1024,
EXINPUTSINK = 4096,
DEVNOTIFY = 8192,
};
pub const RIDEV_REMOVE = RAWINPUTDEVICE_FLAGS.REMOVE;
pub const RIDEV_EXCLUDE = RAWINPUTDEVICE_FLAGS.EXCLUDE;
pub const RIDEV_PAGEONLY = RAWINPUTDEVICE_FLAGS.PAGEONLY;
pub const RIDEV_NOLEGACY = RAWINPUTDEVICE_FLAGS.NOLEGACY;
pub const RIDEV_INPUTSINK = RAWINPUTDEVICE_FLAGS.INPUTSINK;
pub const RIDEV_CAPTUREMOUSE = RAWINPUTDEVICE_FLAGS.CAPTUREMOUSE;
pub const RIDEV_NOHOTKEYS = RAWINPUTDEVICE_FLAGS.CAPTUREMOUSE;
pub const RIDEV_APPKEYS = RAWINPUTDEVICE_FLAGS.APPKEYS;
pub const RIDEV_EXINPUTSINK = RAWINPUTDEVICE_FLAGS.EXINPUTSINK;
pub const RIDEV_DEVNOTIFY = RAWINPUTDEVICE_FLAGS.DEVNOTIFY;
pub const HRAWINPUT = *opaque{};
pub const RAWINPUTHEADER = extern struct {
dwType: u32,
dwSize: u32,
hDevice: ?HANDLE,
wParam: WPARAM,
};
pub const RAWMOUSE = extern struct {
usFlags: u16,
Anonymous: extern union {
ulButtons: u32,
Anonymous: extern struct {
usButtonFlags: u16,
usButtonData: u16,
},
},
ulRawButtons: u32,
lLastX: i32,
lLastY: i32,
ulExtraInformation: u32,
};
pub const RAWKEYBOARD = extern struct {
MakeCode: u16,
Flags: u16,
Reserved: u16,
VKey: u16,
Message: u32,
ExtraInformation: u32,
};
pub const RAWHID = extern struct {
dwSizeHid: u32,
dwCount: u32,
bRawData: [1]u8,
};
pub const RAWINPUT = extern struct {
header: RAWINPUTHEADER,
data: extern union {
mouse: RAWMOUSE,
keyboard: RAWKEYBOARD,
hid: RAWHID,
},
};
pub const RID_DEVICE_INFO_MOUSE = extern struct {
dwId: u32,
dwNumberOfButtons: u32,
dwSampleRate: u32,
fHasHorizontalWheel: BOOL,
};
pub const RID_DEVICE_INFO_KEYBOARD = extern struct {
dwType: u32,
dwSubType: u32,
dwKeyboardMode: u32,
dwNumberOfFunctionKeys: u32,
dwNumberOfIndicators: u32,
dwNumberOfKeysTotal: u32,
};
pub const RID_DEVICE_INFO_HID = extern struct {
dwVendorId: u32,
dwProductId: u32,
dwVersionNumber: u32,
usUsagePage: u16,
usUsage: u16,
};
pub const RID_DEVICE_INFO = extern struct {
cbSize: u32,
dwType: RID_DEVICE_INFO_TYPE,
Anonymous: extern union {
mouse: RID_DEVICE_INFO_MOUSE,
keyboard: RID_DEVICE_INFO_KEYBOARD,
hid: RID_DEVICE_INFO_HID,
},
};
pub const RAWINPUTDEVICE = extern struct {
usUsagePage: u16,
usUsage: u16,
dwFlags: RAWINPUTDEVICE_FLAGS,
hwndTarget: ?HWND,
};
pub const RAWINPUTDEVICELIST = extern struct {
hDevice: ?HANDLE,
dwType: RID_DEVICE_INFO_TYPE,
};
pub const INPUT_MESSAGE_DEVICE_TYPE = enum(i32) {
UNAVAILABLE = 0,
KEYBOARD = 1,
MOUSE = 2,
TOUCH = 4,
PEN = 8,
TOUCHPAD = 16,
};
pub const IMDT_UNAVAILABLE = INPUT_MESSAGE_DEVICE_TYPE.UNAVAILABLE;
pub const IMDT_KEYBOARD = INPUT_MESSAGE_DEVICE_TYPE.KEYBOARD;
pub const IMDT_MOUSE = INPUT_MESSAGE_DEVICE_TYPE.MOUSE;
pub const IMDT_TOUCH = INPUT_MESSAGE_DEVICE_TYPE.TOUCH;
pub const IMDT_PEN = INPUT_MESSAGE_DEVICE_TYPE.PEN;
pub const IMDT_TOUCHPAD = INPUT_MESSAGE_DEVICE_TYPE.TOUCHPAD;
pub const INPUT_MESSAGE_ORIGIN_ID = enum(i32) {
UNAVAILABLE = 0,
HARDWARE = 1,
INJECTED = 2,
SYSTEM = 4,
};
pub const IMO_UNAVAILABLE = INPUT_MESSAGE_ORIGIN_ID.UNAVAILABLE;
pub const IMO_HARDWARE = INPUT_MESSAGE_ORIGIN_ID.HARDWARE;
pub const IMO_INJECTED = INPUT_MESSAGE_ORIGIN_ID.INJECTED;
pub const IMO_SYSTEM = INPUT_MESSAGE_ORIGIN_ID.SYSTEM;
pub const INPUT_MESSAGE_SOURCE = extern struct {
deviceType: INPUT_MESSAGE_DEVICE_TYPE,
originId: INPUT_MESSAGE_ORIGIN_ID,
};
//--------------------------------------------------------------------------------
// Section: Functions (10)
//--------------------------------------------------------------------------------
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "USER32" fn GetRawInputData(
hRawInput: ?HRAWINPUT,
uiCommand: RAW_INPUT_DATA_COMMAND_FLAGS,
// TODO: what to do with BytesParamIndex 3?
pData: ?*anyopaque,
pcbSize: ?*u32,
cbSizeHeader: u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "USER32" fn GetRawInputDeviceInfoA(
hDevice: ?HANDLE,
uiCommand: RAW_INPUT_DEVICE_INFO_COMMAND,
// TODO: what to do with BytesParamIndex 3?
pData: ?*anyopaque,
pcbSize: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "USER32" fn GetRawInputDeviceInfoW(
hDevice: ?HANDLE,
uiCommand: RAW_INPUT_DEVICE_INFO_COMMAND,
// TODO: what to do with BytesParamIndex 3?
pData: ?*anyopaque,
pcbSize: ?*u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "USER32" fn GetRawInputBuffer(
// TODO: what to do with BytesParamIndex 1?
pData: ?*RAWINPUT,
pcbSize: ?*u32,
cbSizeHeader: u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "USER32" fn RegisterRawInputDevices(
pRawInputDevices: [*]RAWINPUTDEVICE,
uiNumDevices: u32,
cbSize: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "USER32" fn GetRegisteredRawInputDevices(
pRawInputDevices: ?[*]RAWINPUTDEVICE,
puiNumDevices: ?*u32,
cbSize: u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "USER32" fn GetRawInputDeviceList(
pRawInputDeviceList: ?[*]RAWINPUTDEVICELIST,
puiNumDevices: ?*u32,
cbSize: u32,
) callconv(@import("std").os.windows.WINAPI) u32;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "USER32" fn DefRawInputProc(
paRawInput: [*]?*RAWINPUT,
nInput: i32,
cbSizeHeader: u32,
) callconv(@import("std").os.windows.WINAPI) LRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "USER32" fn GetCurrentInputMessageSource(
inputMessageSource: ?*INPUT_MESSAGE_SOURCE,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows8.0'
pub extern "USER32" fn GetCIMSSM(
inputMessageSource: ?*INPUT_MESSAGE_SOURCE,
) callconv(@import("std").os.windows.WINAPI) BOOL;
//--------------------------------------------------------------------------------
// Section: Unicode Aliases (1)
//--------------------------------------------------------------------------------
const thismodule = @This();
pub usingnamespace switch (@import("../zig.zig").unicode_mode) {
.ansi => struct {
pub const GetRawInputDeviceInfo = thismodule.GetRawInputDeviceInfoA;
},
.wide => struct {
pub const GetRawInputDeviceInfo = thismodule.GetRawInputDeviceInfoW;
},
.unspecified => if (@import("builtin").is_test) struct {
pub const GetRawInputDeviceInfo = *opaque{};
} else struct {
pub const GetRawInputDeviceInfo = @compileError("'GetRawInputDeviceInfo' requires that UNICODE be set to true or false in the root module");
},
};
//--------------------------------------------------------------------------------
// Section: Imports (5)
//--------------------------------------------------------------------------------
const BOOL = @import("../foundation.zig").BOOL;
const HANDLE = @import("../foundation.zig").HANDLE;
const HWND = @import("../foundation.zig").HWND;
const LRESULT = @import("../foundation.zig").LRESULT;
const WPARAM = @import("../foundation.zig").WPARAM;
test {
@setEvalBranchQuota(
@import("std").meta.declarations(@This()).len * 3
);
// reference all the pub declarations
if (!@import("builtin").is_test) return;
inline for (@import("std").meta.declarations(@This())) |decl| {
if (decl.is_pub) {
_ = decl;
}
}
}
//--------------------------------------------------------------------------------
// Section: SubModules (7)
//--------------------------------------------------------------------------------
pub const ime = @import("input/ime.zig");
pub const ink = @import("input/ink.zig");
pub const keyboard_and_mouse = @import("input/keyboard_and_mouse.zig");
pub const pointer = @import("input/pointer.zig");
pub const radial = @import("input/radial.zig");
pub const touch = @import("input/touch.zig");
pub const xbox_controller = @import("input/xbox_controller.zig"); | win32/ui/input.zig |
const std = @import("std");
const lex = @import("lexer.zig");
const Lexer = lex.Lexer;
const LexToken = lex.Token;
const Allocator = std.mem.Allocator;
const Label = []const u8;
const Constant = u16;
const Reference = struct {
symbol: Label,
indirect: bool,
};
const RefOrConst = union(enum) {
reference: Reference,
constant: Constant,
};
const OrgDirective = struct {
location: Constant,
};
const Instruction = union(enum) {
insn_and: RefOrConst,
insn_add: RefOrConst,
insn_lda: RefOrConst,
insn_sta: RefOrConst,
insn_bun: RefOrConst,
insn_bsa,
insn_isz,
insn_cla,
insn_cle,
insn_cma,
insn_cme,
insn_cir,
insn_cil,
insn_inc,
insn_spa,
insn_sna,
insn_sza,
insn_sze,
insn_hlt,
insn_inp,
insn_out,
insn_ski,
insn_sko,
insn_ion,
insn_iof,
keyword_dat: RefOrConst,
keyword_org: Constant,
unimpl,
};
const Line = struct {
label: ?Label,
instruction: Instruction,
};
/// Just a fun recursive descent parser
pub const Parser = struct {
lexer: *Lexer,
_next_tok: LexToken,
const Self = @This();
const Error = error {
UnexpectedToken,
InvalidToken,
Unimplemented,
EOF,
};
fn peekTok(self: *Self) LexToken {
return self._next_tok;
}
fn nextTok(self: *Self) LexToken {
// these two lines run in the opposite order, nice
defer self._next_tok = self.lexer.next();
return self._next_tok;
}
fn exactTok(self: *Self, tag: LexToken.Tag) !void {
if (self.nextTok().tag != tag)
return Error.UnexpectedToken;
}
pub fn init(lexer: *Lexer) Self {
return Self {
.lexer = lexer,
._next_tok = lexer.next(),
};
}
fn parseLabel(self: *Self) !Label {
if (self.peekTok().tag == .label) {
const tok = self.nextTok();
return self.lexer.buffer[tok.loc.start..tok.loc.end - 1];
}
return Error.UnexpectedToken;
}
fn parseIdentifier(self: *Self) !Label {
if (self.peekTok().tag != .identifier)
return Error.UnexpectedToken;
return self.lexer.getSlice(&self.nextTok());
}
fn parseIndirectRef(self: *Self) !Reference {
if (self.peekTok().tag != .l_bracket)
return Error.UnexpectedToken;
self.exactTok(.l_bracket) catch unreachable;
const res = Reference {
.symbol = try self.parseIdentifier(),
.indirect = true,
};
try self.exactTok(.r_bracket);
return res;
}
fn parseReference(self: *Self) !Reference {
switch (self.peekTok().tag) {
.l_bracket => {
return try self.parseIndirectRef();
},
.identifier => {
return Reference {
.symbol = try self.parseIdentifier(),
.indirect = false,
};
},
else => {
return Error.UnexpectedToken;
}
}
}
fn parseConstant(self: *Self) !Constant {
if (self.peekTok().tag == .number)
return std.fmt.parseInt(Constant, self.lexer.getSlice(&self.nextTok()), 0);
return Error.UnexpectedToken;
}
fn parseRefOrConst(self: *Self) !RefOrConst {
switch (self.peekTok().tag) {
.number => {
return RefOrConst {
.constant = try self.parseConstant(),
};
},
.l_bracket, .identifier => {
return RefOrConst {
.reference = try self.parseReference(),
};
},
else => { return Error.UnexpectedToken; },
}
}
fn parseInstruction(self: *Self) !Instruction {
if (self.peekTok().isDirective()) {
return switch (self.nextTok().tag) {
.keyword_dat => Instruction {
.keyword_dat = try self.parseRefOrConst(),
},
else => .unimpl,
};
}
return Error.UnexpectedToken;
}
fn parseLine(self: *Self) !Line {
if (self.peekTok().tag == .eof)
return Error.EOF;
if (self.peekTok().tag == .invalid)
return Error.InvalidToken;
return Line {
.label = self.parseLabel() catch null,
.instruction = try self.parseInstruction(),
};
}
pub fn parse(self: *Self, allocator: *Allocator) !void {
//var list = std.ArrayList(Line).initCapacity(30);
_ = allocator;
while (self.parseLine()) |line| {
std.log.debug("Label: {s}, Instruction: {s}\n", .{ line.label, @tagName(line.instruction) });
} else |err| {
std.log.debug("Completed due to {s}\n", .{ @errorName(err) });
if (err != Error.EOF)
return err;
}
}
};
test "parser - token peeking" {
var lexer = Lexer.init("label: directive");
var parser = Parser.init(&lexer);
try std.testing.expectEqual(LexToken.Tag.label, parser.peekTok().tag);
try std.testing.expectEqual(LexToken.Tag.label, parser.nextTok().tag);
try std.testing.expectEqual(LexToken.Tag.identifier, parser.nextTok().tag);
try std.testing.expectEqual(LexToken.Tag.eof, parser.peekTok().tag);
}
test "parser - parse simple" {
var lexer = Lexer.init("label: dat 0x1234\ndat [label]\n");
var parser = Parser.init(&lexer);
try parser.parse(std.testing.allocator);
} | src/parser.zig |
const std = @import("std");
const testing = std.testing;
pub fn LinkedList(comptime T: type) type {
return struct {
head: ?*Node,
tail: ?*Node,
len: usize,
allocator: *std.mem.Allocator,
const Self = @This();
pub const Node = struct {
prev: ?*Node,
next: ?*Node,
data: T,
pub fn init(value: T) Node {
return Node{
.prev = null,
.next = null,
.data = value,
};
}
};
pub fn init(allocator: *std.mem.Allocator) Self {
return Self{
.head = null,
.tail = null,
.len = 0,
.allocator = allocator,
};
}
pub fn deinit(self: *Self) void {
if (self.head == null and self.tail == null) return;
while (self.len > 0) {
var prev = self.tail.?.prev;
self.allocator.destroy(self.tail);
self.tail = prev;
self.len -= 1;
}
self.head = null;
}
pub fn insert(self: *Self, data: T) !void {
var newNode = try self.allocator.create(Node);
errdefer self.allocator.destroy(newNode);
newNode.* = Node.init(data);
if (self.head) |head| {
newNode.next = head;
head.prev = newNode;
} else {
self.tail = newNode;
}
self.head = newNode;
self.len += 1;
}
pub fn append(self: *Self, data: T) !void {
var newNode = try self.allocator.create(Node);
errdefer self.allocator.destroy(newNode);
newNode.* = Node.init(data);
if (self.tail) |tail| {
newNode.prev = tail;
tail.next = newNode;
} else {
self.head = newNode;
}
self.tail = newNode;
self.len += 1;
}
pub fn map(self: *Self, func: fn (T) T) void {
var iter = self.head;
while (iter) |node| {
node.data = func(node.data);
iter = node.next;
}
}
pub fn contains(self: *Self, data: T) bool {
var iter = self.head;
while (iter) |node| {
if (node.data == data) {
return true;
}
iter = node.next;
} else {
return false;
}
}
pub fn delete(self: *Self) ?T {
if (self.tail) |tail| {
var data = tail.data;
var prev = tail.prev;
self.allocator.destroy(tail);
self.len -= 1;
self.tail = prev;
if (prev == null) {
self.head = null;
}
return data;
} else {
return null;
}
}
};
}
test "LinkedList basic init" {
const list = LinkedList(i32){
.head = null,
.tail = null,
.len = 0,
.allocator = testing.allocator,
};
testing.expect(list.len == 0);
}
test "LinkedList.init method" {
const list = LinkedList(i32).init(testing.allocator);
testing.expectEqual(list.len, 0);
testing.expect(list.head == null);
testing.expect(list.tail == null);
}
test "LinkedList.insert method" {
var list = LinkedList(i32).init(testing.allocator);
defer list.deinit();
try list.insert(8);
testing.expectEqual(list.len, 1);
testing.expect(list.head != null);
testing.expect(list.tail != null);
testing.expectEqual(list.tail, list.head);
try list.insert(3);
testing.expectEqual(list.len, 2);
testing.expect(list.head != list.tail);
testing.expectEqual(list.head.?.data, 3);
testing.expectEqual(list.tail.?.data, 8);
}
test "LinkedList.append method" {
var list = LinkedList(i32).init(testing.allocator);
defer list.deinit();
try list.append(4);
testing.expectEqual(list.len, 1);
testing.expect(list.head != null);
testing.expect(list.tail != null);
testing.expectEqual(list.tail, list.head);
try list.append(7);
testing.expectEqual(list.len, 2);
testing.expect(list.head != list.tail);
testing.expectEqual(list.head.?.data, 4);
testing.expectEqual(list.tail.?.data, 7);
}
test "LinkedList.map method" {
var list = LinkedList(i32).init(testing.allocator);
defer list.deinit();
try list.insert(2);
try list.insert(3);
const multThree = struct {
fn function(data: i32) i32 {
return data * 3;
}
}.function;
list.map(multThree);
testing.expectEqual(list.len, 2);
testing.expectEqual(list.head.?.data, 9);
testing.expectEqual(list.tail.?.data, 6);
}
test "LinkedList.contains method" {
var list = LinkedList(i32).init(testing.allocator);
defer list.deinit();
try list.insert(11);
testing.expect(list.contains(11));
testing.expect(!list.contains(7));
}
test "LinkedList.deinit method" {
var list = LinkedList(i32).init(testing.allocator);
defer list.deinit();
try list.append(4);
try list.append(100);
testing.expectEqual(list.len, 2);
list.deinit();
testing.expectEqual(list.len, 0);
testing.expectEqual(list.head, list.tail);
}
test "LinkedList.delete method" {
var list = LinkedList(i32).init(testing.allocator);
defer list.deinit();
try list.append(5);
try list.insert(8);
try list.append(9);
testing.expectEqual(list.delete(), 9);
testing.expectEqual(list.delete(), 5);
testing.expectEqual(list.delete(), 8);
testing.expectEqual(list.len, 0);
} | src/linked_list.zig |
const std = @import("std");
const builtin = @import("builtin");
const nvg = @import("nanovg");
const Song = @import("Song.zig");
songs: []Song = undefined,
song_selected: usize = 0,
select_origin: f32 = 0,
select_target: f32 = 0,
select_time: f32 = 0,
progress_alpha: f32 = 0,
font_regular: i32 = undefined,
font_bold: i32 = undefined,
const Self = @This();
pub fn loadFonts(self: *Self) !void {
self.font_bold = nvg.createFont("regular", "data/fonts/Roboto-Bold.ttf");
if (self.font_bold == -1) return error.FileNotFound;
self.font_regular = nvg.createFont("bold", "data/fonts/Roboto-Regular.ttf");
if (self.font_regular == -1) return error.FileNotFound;
const font_emoji_path = if (builtin.os.tag == .windows) "C:\\Windows\\Fonts\\seguiemj.ttf" else "data/fonts/NotoEmoji-Regular.ttf";
const font_emoji = nvg.createFont("emoji", font_emoji_path);
if (font_emoji == -1) return error.FileNotFound;
const font_cjk_bold = nvg.createFont("cjk", "data/fonts/NotoSansCJKjp-Bold.otf");
_ = nvg.addFallbackFontId(self.font_regular, font_emoji);
_ = nvg.addFallbackFontId(self.font_bold, font_emoji);
_ = nvg.addFallbackFontId(self.font_bold, font_cjk_bold);
}
pub fn tick(self: *Self) void {
if (self.select_time < 1) {
self.select_time += 1.0 / 20.0;
} else {
self.select_time = 1;
}
if (self.progress_alpha > 0) self.progress_alpha -= 1.0 / 20.0;
}
pub fn prevSong(self: *Self) void {
if (self.song_selected > 0) {
self.song_selected -= 1;
const select_t = easeOutQuad(self.select_time);
self.select_origin = mix(self.select_origin, self.select_target, select_t);
self.select_target = @intToFloat(f32, self.song_selected);
self.select_time = 0;
}
}
pub fn nextSong(self: *Self) void {
if (self.song_selected + 1 < self.songs.len) {
self.song_selected += 1;
const select_t = easeOutQuad(self.select_time);
self.select_origin = mix(self.select_origin, self.select_target, select_t);
self.select_target = @intToFloat(f32, self.song_selected);
self.select_time = 0;
}
}
pub fn drawTitle(self: Self, width: f32, height: f32) void {
const center_x = 0.5 * width;
const center_y = 0.5 * height;
const text_h = 0.3 * height;
nvg.fontSize(text_h);
nvg.textAlign(.{ .horizontal = .center, .vertical = .middle });
nvg.fontFaceId(self.font_bold);
nvg.fillColor(nvg.rgbf(1, 1, 1));
_ = nvg.text(center_x, center_y, "カラオケ"); // カラオケ
}
pub fn drawUi(self: *Self, width: f32, height: f32) void {
const center_x = 0.5 * width;
const tile_h = 0.5 * height;
const y = 0.2 * height;
const text_y = 0.8 * height;
const text_h = 0.05 * height;
nvg.fontSize(text_h);
const select_t = easeOutQuad(self.select_time);
const select_x = mix(self.select_origin, self.select_target, select_t);
for (self.songs) |song, i| {
const x = center_x + (@intToFloat(f32, i) - select_x) * tile_h * 1.1 - 0.5 * tile_h;
nvg.beginPath();
nvg.rect(x, y, tile_h, tile_h);
const paint = nvg.imagePattern(x, y, tile_h, tile_h, 0, song.image.?, 1);
nvg.fillPaint(paint);
nvg.fill();
}
if (self.song_selected < self.songs.len) {
const song = self.songs[self.song_selected];
nvg.textAlign(.{ .horizontal = .center });
nvg.fontFaceId(self.font_bold);
nvg.fillColor(nvg.rgbf(0, 0, 0));
nvg.fontBlur(10);
_ = nvg.text(center_x, text_y, song.artist);
nvg.fontBlur(0);
nvg.fillColor(nvg.rgbf(1, 1, 1));
_ = nvg.text(center_x, text_y, song.artist);
nvg.fontFaceId(self.font_regular);
nvg.fillColor(nvg.rgbf(0, 0, 0));
nvg.fontBlur(10);
_ = nvg.text(center_x, text_y + 1.5 * text_h, song.title);
nvg.fontBlur(0);
nvg.fillColor(nvg.rgbf(1, 1, 1));
_ = nvg.text(center_x, text_y + 1.5 * text_h, song.title);
// _ = nvg.text(center_x, text_y + 3 * text_h, "Emojitest: 🎤🔇🔈🔉🔊🎵🎶⚙️🔧🛠️▶️");
}
if (self.songs.len == 0) {
const text = "(No songs found)";
nvg.textAlign(.{ .horizontal = .center });
nvg.fontFaceId(self.font_regular);
nvg.fillColor(nvg.rgbf(0, 0, 0));
nvg.fontBlur(10);
_ = nvg.text(center_x, text_y + 1.5 * text_h, text);
nvg.fontBlur(0);
nvg.fillColor(nvg.rgbf(1, 1, 1));
_ = nvg.text(center_x, text_y + 1.5 * text_h, text);
}
}
pub fn drawPauseUi(self: *Self, width: f32, height: f32) void {
_ = self;
nvg.beginPath();
nvg.rect(0, 0, width, height);
nvg.fillColor(nvg.rgbaf(0, 0, 0, 0.5));
nvg.fill();
const text_h = 0.05 * height;
nvg.fontSize(text_h);
const center_x = 0.5 * width;
const center_y = 0.5 * height;
nvg.textAlign(.{ .horizontal = .center });
nvg.fontFaceId(self.font_bold);
nvg.fillColor(nvg.rgbf(0, 0, 0));
nvg.fontBlur(10);
_ = nvg.text(center_x, center_y, "- Pause -");
nvg.fontBlur(0);
nvg.fillColor(nvg.rgbf(1, 1, 1));
_ = nvg.text(center_x, center_y, "- Pause -");
}
pub fn drawProgress(self: *Self, width: f32, height: f32, progress: f32) void {
const a = std.math.clamp(self.progress_alpha, 0, 1);
nvg.beginPath();
const f = 0.01 * height;
const x = 0.1 * width;
const y = 0.9 * height;
const w = 0.8 * width;
const h = 0.04 * height;
nvg.rect(x - f, y - f, w + 2 * f, h + 2 * f);
nvg.pathWinding(.cw);
nvg.roundedRect(x, y, w, h, 0.5 * h);
nvg.pathWinding(.ccw);
nvg.fillPaint(nvg.boxGradient(x - 0.5 * f, y - 0.5 * f, w + f, h + f, 0.5 * h, f, nvg.rgbaf(0, 0, 0, 0.25 * a), nvg.rgbaf(0, 0, 0, 0)));
nvg.fill();
{
nvg.scissor(x + w * progress, y, w * (1 - progress), h);
defer nvg.resetScissor();
nvg.beginPath();
nvg.roundedRect(x, y, w, h, 0.5 * h);
nvg.fillColor(nvg.rgbaf(0.5, 0.5, 0.5, a));
nvg.fill();
}
{
nvg.scissor(x, y, w * progress, h);
defer nvg.resetScissor();
nvg.beginPath();
nvg.roundedRect(x, y, w, h, 0.5 * h);
nvg.fillColor(nvg.rgbaf(1, 1, 1, a));
nvg.fill();
}
}
fn easeOutQuad(x: f32) f32 {
return 1 - (1 - x) * (1 - x);
}
fn mix(a: f32, b: f32, t: f32) f32 {
return (1 - t) * a + t * b;
} | src/Menu.zig |
pub usingnamespace @import("std").zig.c_builtins;
pub const ptrdiff_t = c_long;
pub const wchar_t = c_int;
pub const max_align_t = c_longdouble;
pub const __int8_t = i8;
pub const __uint8_t = u8;
pub const __int16_t = c_short;
pub const __uint16_t = c_ushort;
pub const __int32_t = c_int;
pub const __uint32_t = c_uint;
pub const __int64_t = c_longlong;
pub const __uint64_t = c_ulonglong;
pub const __darwin_intptr_t = c_long;
pub const __darwin_natural_t = c_uint;
pub const __darwin_ct_rune_t = c_int;
pub const __mbstate_t = extern union {
__mbstate8: [128]u8,
_mbstateL: c_longlong,
};
pub const __darwin_mbstate_t = __mbstate_t;
pub const __darwin_ptrdiff_t = c_long;
pub const __darwin_size_t = c_ulong;
pub const struct___va_list_tag = extern struct {
gp_offset: c_uint,
fp_offset: c_uint,
overflow_arg_area: ?*c_void,
reg_save_area: ?*c_void,
};
pub const __builtin_va_list = [1]struct___va_list_tag;
pub const __darwin_va_list = __builtin_va_list;
pub const __darwin_wchar_t = c_int;
pub const __darwin_rune_t = __darwin_wchar_t;
pub const __darwin_wint_t = c_int;
pub const __darwin_clock_t = c_ulong;
pub const __darwin_socklen_t = __uint32_t;
pub const __darwin_ssize_t = c_long;
pub const __darwin_time_t = c_long;
pub const __darwin_blkcnt_t = __int64_t;
pub const __darwin_blksize_t = __int32_t;
pub const __darwin_dev_t = __int32_t;
pub const __darwin_fsblkcnt_t = c_uint;
pub const __darwin_fsfilcnt_t = c_uint;
pub const __darwin_gid_t = __uint32_t;
pub const __darwin_id_t = __uint32_t;
pub const __darwin_ino64_t = __uint64_t;
pub const __darwin_ino_t = __darwin_ino64_t;
pub const __darwin_mach_port_name_t = __darwin_natural_t;
pub const __darwin_mach_port_t = __darwin_mach_port_name_t;
pub const __darwin_mode_t = __uint16_t;
pub const __darwin_off_t = __int64_t;
pub const __darwin_pid_t = __int32_t;
pub const __darwin_sigset_t = __uint32_t;
pub const __darwin_suseconds_t = __int32_t;
pub const __darwin_uid_t = __uint32_t;
pub const __darwin_useconds_t = __uint32_t;
pub const __darwin_uuid_t = [16]u8;
pub const __darwin_uuid_string_t = [37]u8;
pub const struct___darwin_pthread_handler_rec = extern struct {
__routine: ?fn (?*c_void) callconv(.C) void,
__arg: ?*c_void,
__next: [*c]struct___darwin_pthread_handler_rec,
};
pub const struct__opaque_pthread_attr_t = extern struct {
__sig: c_long,
__opaque: [56]u8,
};
pub const struct__opaque_pthread_cond_t = extern struct {
__sig: c_long,
__opaque: [40]u8,
};
pub const struct__opaque_pthread_condattr_t = extern struct {
__sig: c_long,
__opaque: [8]u8,
};
pub const struct__opaque_pthread_mutex_t = extern struct {
__sig: c_long,
__opaque: [56]u8,
};
pub const struct__opaque_pthread_mutexattr_t = extern struct {
__sig: c_long,
__opaque: [8]u8,
};
pub const struct__opaque_pthread_once_t = extern struct {
__sig: c_long,
__opaque: [8]u8,
};
pub const struct__opaque_pthread_rwlock_t = extern struct {
__sig: c_long,
__opaque: [192]u8,
};
pub const struct__opaque_pthread_rwlockattr_t = extern struct {
__sig: c_long,
__opaque: [16]u8,
};
pub const struct__opaque_pthread_t = extern struct {
__sig: c_long,
__cleanup_stack: [*c]struct___darwin_pthread_handler_rec,
__opaque: [8176]u8,
};
pub const __darwin_pthread_attr_t = struct__opaque_pthread_attr_t;
pub const __darwin_pthread_cond_t = struct__opaque_pthread_cond_t;
pub const __darwin_pthread_condattr_t = struct__opaque_pthread_condattr_t;
pub const __darwin_pthread_key_t = c_ulong;
pub const __darwin_pthread_mutex_t = struct__opaque_pthread_mutex_t;
pub const __darwin_pthread_mutexattr_t = struct__opaque_pthread_mutexattr_t;
pub const __darwin_pthread_once_t = struct__opaque_pthread_once_t;
pub const __darwin_pthread_rwlock_t = struct__opaque_pthread_rwlock_t;
pub const __darwin_pthread_rwlockattr_t = struct__opaque_pthread_rwlockattr_t;
pub const __darwin_pthread_t = [*c]struct__opaque_pthread_t;
pub const __darwin_nl_item = c_int;
pub const __darwin_wctrans_t = c_int;
pub const __darwin_wctype_t = __uint32_t;
pub extern fn memchr(__s: ?*const c_void, __c: c_int, __n: c_ulong) ?*c_void;
pub extern fn memcmp(__s1: ?*const c_void, __s2: ?*const c_void, __n: c_ulong) c_int;
pub extern fn memcpy(__dst: ?*c_void, __src: ?*const c_void, __n: c_ulong) ?*c_void;
pub extern fn memmove(__dst: ?*c_void, __src: ?*const c_void, __len: c_ulong) ?*c_void;
pub extern fn memset(__b: ?*c_void, __c: c_int, __len: c_ulong) ?*c_void;
pub extern fn strcat(__s1: [*c]u8, __s2: [*c]const u8) [*c]u8;
pub extern fn strchr(__s: [*c]const u8, __c: c_int) [*c]u8;
pub extern fn strcmp(__s1: [*c]const u8, __s2: [*c]const u8) c_int;
pub extern fn strcoll(__s1: [*c]const u8, __s2: [*c]const u8) c_int;
pub extern fn strcpy(__dst: [*c]u8, __src: [*c]const u8) [*c]u8;
pub extern fn strcspn(__s: [*c]const u8, __charset: [*c]const u8) c_ulong;
pub extern fn strerror(__errnum: c_int) [*c]u8;
pub extern fn strlen(__s: [*c]const u8) c_ulong;
pub extern fn strncat(__s1: [*c]u8, __s2: [*c]const u8, __n: c_ulong) [*c]u8;
pub extern fn strncmp(__s1: [*c]const u8, __s2: [*c]const u8, __n: c_ulong) c_int;
pub extern fn strncpy(__dst: [*c]u8, __src: [*c]const u8, __n: c_ulong) [*c]u8;
pub extern fn strpbrk(__s: [*c]const u8, __charset: [*c]const u8) [*c]u8;
pub extern fn strrchr(__s: [*c]const u8, __c: c_int) [*c]u8;
pub extern fn strspn(__s: [*c]const u8, __charset: [*c]const u8) c_ulong;
pub extern fn strstr(__big: [*c]const u8, __little: [*c]const u8) [*c]u8;
pub extern fn strtok(__str: [*c]u8, __sep: [*c]const u8) [*c]u8;
pub extern fn strxfrm(__s1: [*c]u8, __s2: [*c]const u8, __n: c_ulong) c_ulong;
pub extern fn strtok_r(__str: [*c]u8, __sep: [*c]const u8, __lasts: [*c][*c]u8) [*c]u8;
pub extern fn strerror_r(__errnum: c_int, __strerrbuf: [*c]u8, __buflen: usize) c_int;
pub extern fn strdup(__s1: [*c]const u8) [*c]u8;
pub extern fn memccpy(__dst: ?*c_void, __src: ?*const c_void, __c: c_int, __n: c_ulong) ?*c_void;
pub extern fn stpcpy(__dst: [*c]u8, __src: [*c]const u8) [*c]u8;
pub extern fn stpncpy(__dst: [*c]u8, __src: [*c]const u8, __n: c_ulong) [*c]u8;
pub extern fn strndup(__s1: [*c]const u8, __n: c_ulong) [*c]u8;
pub extern fn strnlen(__s1: [*c]const u8, __n: usize) usize;
pub extern fn strsignal(__sig: c_int) [*c]u8;
pub const u_int8_t = u8;
pub const u_int16_t = c_ushort;
pub const u_int32_t = c_uint;
pub const u_int64_t = c_ulonglong;
pub const register_t = i64;
pub const user_addr_t = u_int64_t;
pub const user_size_t = u_int64_t;
pub const user_ssize_t = i64;
pub const user_long_t = i64;
pub const user_ulong_t = u_int64_t;
pub const user_time_t = i64;
pub const user_off_t = i64;
pub const syscall_arg_t = u_int64_t;
pub const rsize_t = __darwin_size_t;
pub const errno_t = c_int;
pub extern fn memset_s(__s: ?*c_void, __smax: rsize_t, __c: c_int, __n: rsize_t) errno_t;
pub extern fn memmem(__big: ?*const c_void, __big_len: usize, __little: ?*const c_void, __little_len: usize) ?*c_void;
pub extern fn memset_pattern4(__b: ?*c_void, __pattern4: ?*const c_void, __len: usize) void;
pub extern fn memset_pattern8(__b: ?*c_void, __pattern8: ?*const c_void, __len: usize) void;
pub extern fn memset_pattern16(__b: ?*c_void, __pattern16: ?*const c_void, __len: usize) void;
pub extern fn strcasestr(__big: [*c]const u8, __little: [*c]const u8) [*c]u8;
pub extern fn strnstr(__big: [*c]const u8, __little: [*c]const u8, __len: usize) [*c]u8;
pub extern fn strlcat(__dst: [*c]u8, __source: [*c]const u8, __size: c_ulong) c_ulong;
pub extern fn strlcpy(__dst: [*c]u8, __source: [*c]const u8, __size: c_ulong) c_ulong;
pub extern fn strmode(__mode: c_int, __bp: [*c]u8) void;
pub extern fn strsep(__stringp: [*c][*c]u8, __delim: [*c]const u8) [*c]u8;
pub extern fn swab(noalias ?*const c_void, noalias ?*c_void, isize) void;
pub extern fn timingsafe_bcmp(__b1: ?*const c_void, __b2: ?*const c_void, __len: usize) c_int;
pub extern fn bcmp(?*const c_void, ?*const c_void, c_ulong) c_int;
pub extern fn bcopy(?*const c_void, ?*c_void, usize) void;
pub extern fn bzero(?*c_void, c_ulong) void;
pub extern fn index([*c]const u8, c_int) [*c]u8;
pub extern fn rindex([*c]const u8, c_int) [*c]u8;
pub extern fn ffs(c_int) c_int;
pub extern fn strcasecmp([*c]const u8, [*c]const u8) c_int;
pub extern fn strncasecmp([*c]const u8, [*c]const u8, c_ulong) c_int;
pub extern fn ffsl(c_long) c_int;
pub extern fn ffsll(c_longlong) c_int;
pub extern fn fls(c_int) c_int;
pub extern fn flsl(c_long) c_int;
pub extern fn flsll(c_longlong) c_int;
pub const va_list = __darwin_va_list;
pub extern fn renameat(c_int, [*c]const u8, c_int, [*c]const u8) c_int;
pub extern fn renamex_np([*c]const u8, [*c]const u8, c_uint) c_int;
pub extern fn renameatx_np(c_int, [*c]const u8, c_int, [*c]const u8, c_uint) c_int;
pub const fpos_t = __darwin_off_t;
pub const struct___sbuf = extern struct {
_base: [*c]u8,
_size: c_int,
};
pub const struct___sFILEX = opaque {};
pub const struct___sFILE = extern struct {
_p: [*c]u8,
_r: c_int,
_w: c_int,
_flags: c_short,
_file: c_short,
_bf: struct___sbuf,
_lbfsize: c_int,
_cookie: ?*c_void,
_close: ?fn (?*c_void) callconv(.C) c_int,
_read: ?fn (?*c_void, [*c]u8, c_int) callconv(.C) c_int,
_seek: ?fn (?*c_void, fpos_t, c_int) callconv(.C) fpos_t,
_write: ?fn (?*c_void, [*c]const u8, c_int) callconv(.C) c_int,
_ub: struct___sbuf,
_extra: ?*struct___sFILEX,
_ur: c_int,
_ubuf: [3]u8,
_nbuf: [1]u8,
_lb: struct___sbuf,
_blksize: c_int,
_offset: fpos_t,
};
pub const FILE = struct___sFILE;
pub extern var __stdinp: [*c]FILE;
pub extern var __stdoutp: [*c]FILE;
pub extern var __stderrp: [*c]FILE;
pub extern fn clearerr([*c]FILE) void;
pub extern fn fclose([*c]FILE) c_int;
pub extern fn feof([*c]FILE) c_int;
pub extern fn ferror([*c]FILE) c_int;
pub extern fn fflush([*c]FILE) c_int;
pub extern fn fgetc([*c]FILE) c_int;
pub extern fn fgetpos(noalias [*c]FILE, [*c]fpos_t) c_int;
pub extern fn fgets(noalias [*c]u8, c_int, [*c]FILE) [*c]u8;
pub extern fn fopen(__filename: [*c]const u8, __mode: [*c]const u8) [*c]FILE;
pub extern fn fprintf([*c]FILE, [*c]const u8, ...) c_int;
pub extern fn fputc(c_int, [*c]FILE) c_int;
pub extern fn fputs(noalias [*c]const u8, noalias [*c]FILE) c_int;
pub extern fn fread(__ptr: ?*c_void, __size: c_ulong, __nitems: c_ulong, __stream: [*c]FILE) c_ulong;
pub extern fn freopen(noalias [*c]const u8, noalias [*c]const u8, noalias [*c]FILE) [*c]FILE;
pub extern fn fscanf(noalias [*c]FILE, noalias [*c]const u8, ...) c_int;
pub extern fn fseek([*c]FILE, c_long, c_int) c_int;
pub extern fn fsetpos([*c]FILE, [*c]const fpos_t) c_int;
pub extern fn ftell([*c]FILE) c_long;
pub extern fn fwrite(__ptr: ?*const c_void, __size: c_ulong, __nitems: c_ulong, __stream: [*c]FILE) c_ulong;
pub extern fn getc([*c]FILE) c_int;
pub extern fn getchar() c_int;
pub extern fn gets([*c]u8) [*c]u8;
pub extern fn perror([*c]const u8) void;
pub extern fn printf([*c]const u8, ...) c_int;
pub extern fn putc(c_int, [*c]FILE) c_int;
pub extern fn putchar(c_int) c_int;
pub extern fn puts([*c]const u8) c_int;
pub extern fn remove([*c]const u8) c_int;
pub extern fn rename(__old: [*c]const u8, __new: [*c]const u8) c_int;
pub extern fn rewind([*c]FILE) void;
pub extern fn scanf(noalias [*c]const u8, ...) c_int;
pub extern fn setbuf(noalias [*c]FILE, noalias [*c]u8) void;
pub extern fn setvbuf(noalias [*c]FILE, noalias [*c]u8, c_int, usize) c_int;
pub extern fn sprintf([*c]u8, [*c]const u8, ...) c_int;
pub extern fn sscanf(noalias [*c]const u8, noalias [*c]const u8, ...) c_int;
pub extern fn tmpfile() [*c]FILE;
pub extern fn tmpnam([*c]u8) [*c]u8;
pub extern fn ungetc(c_int, [*c]FILE) c_int;
pub extern fn vfprintf([*c]FILE, [*c]const u8, [*c]struct___va_list_tag) c_int;
pub extern fn vprintf([*c]const u8, [*c]struct___va_list_tag) c_int;
pub extern fn vsprintf([*c]u8, [*c]const u8, [*c]struct___va_list_tag) c_int;
pub extern fn ctermid([*c]u8) [*c]u8;
pub extern fn fdopen(c_int, [*c]const u8) [*c]FILE;
pub extern fn fileno([*c]FILE) c_int;
pub extern fn pclose([*c]FILE) c_int;
pub extern fn popen([*c]const u8, [*c]const u8) [*c]FILE;
pub extern fn __srget([*c]FILE) c_int;
pub extern fn __svfscanf([*c]FILE, [*c]const u8, [*c]struct___va_list_tag) c_int;
pub extern fn __swbuf(c_int, [*c]FILE) c_int;
pub fn __sputc(arg__c: c_int, arg__p: [*c]FILE) callconv(.C) c_int {
var _c = arg__c;
var _p = arg__p;
if (((blk: {
const ref = &_p.*._w;
ref.* -= 1;
break :blk ref.*;
}) >= @as(c_int, 0)) or ((_p.*._w >= _p.*._lbfsize) and (@bitCast(c_int, @as(c_uint, @bitCast(u8, @truncate(i8, _c)))) != @as(c_int, '\n')))) return @bitCast(c_int, @as(c_uint, blk: {
const tmp = @bitCast(u8, @truncate(i8, _c));
(blk_1: {
const ref = &_p.*._p;
const tmp_2 = ref.*;
ref.* += 1;
break :blk_1 tmp_2;
}).* = tmp;
break :blk tmp;
})) else return __swbuf(_c, _p);
return 0;
}
pub extern fn flockfile([*c]FILE) void;
pub extern fn ftrylockfile([*c]FILE) c_int;
pub extern fn funlockfile([*c]FILE) void;
pub extern fn getc_unlocked([*c]FILE) c_int;
pub extern fn getchar_unlocked() c_int;
pub extern fn putc_unlocked(c_int, [*c]FILE) c_int;
pub extern fn putchar_unlocked(c_int) c_int;
pub extern fn getw([*c]FILE) c_int;
pub extern fn putw(c_int, [*c]FILE) c_int;
pub extern fn tempnam(__dir: [*c]const u8, __prefix: [*c]const u8) [*c]u8;
pub const off_t = __darwin_off_t;
pub extern fn fseeko(__stream: [*c]FILE, __offset: off_t, __whence: c_int) c_int;
pub extern fn ftello(__stream: [*c]FILE) off_t;
pub extern fn snprintf(__str: [*c]u8, __size: c_ulong, __format: [*c]const u8, ...) c_int;
pub extern fn vfscanf(noalias __stream: [*c]FILE, noalias __format: [*c]const u8, [*c]struct___va_list_tag) c_int;
pub extern fn vscanf(noalias __format: [*c]const u8, [*c]struct___va_list_tag) c_int;
pub extern fn vsnprintf(__str: [*c]u8, __size: c_ulong, __format: [*c]const u8, [*c]struct___va_list_tag) c_int;
pub extern fn vsscanf(noalias __str: [*c]const u8, noalias __format: [*c]const u8, [*c]struct___va_list_tag) c_int;
pub extern fn dprintf(c_int, noalias [*c]const u8, ...) c_int;
pub extern fn vdprintf(c_int, noalias [*c]const u8, [*c]struct___va_list_tag) c_int;
pub extern fn getdelim(noalias __linep: [*c][*c]u8, noalias __linecapp: [*c]usize, __delimiter: c_int, noalias __stream: [*c]FILE) isize;
pub extern fn getline(noalias __linep: [*c][*c]u8, noalias __linecapp: [*c]usize, noalias __stream: [*c]FILE) isize;
pub extern fn fmemopen(noalias __buf: ?*c_void, __size: usize, noalias __mode: [*c]const u8) [*c]FILE;
pub extern fn open_memstream(__bufp: [*c][*c]u8, __sizep: [*c]usize) [*c]FILE;
pub extern const sys_nerr: c_int;
pub extern const sys_errlist: [*c]const [*c]const u8;
pub extern fn asprintf(noalias [*c][*c]u8, noalias [*c]const u8, ...) c_int;
pub extern fn ctermid_r([*c]u8) [*c]u8;
pub extern fn fgetln([*c]FILE, [*c]usize) [*c]u8;
pub extern fn fmtcheck([*c]const u8, [*c]const u8) [*c]const u8;
pub extern fn fpurge([*c]FILE) c_int;
pub extern fn setbuffer([*c]FILE, [*c]u8, c_int) void;
pub extern fn setlinebuf([*c]FILE) c_int;
pub extern fn vasprintf(noalias [*c][*c]u8, noalias [*c]const u8, [*c]struct___va_list_tag) c_int;
pub extern fn zopen([*c]const u8, [*c]const u8, c_int) [*c]FILE;
pub extern fn funopen(?*const c_void, ?fn (?*c_void, [*c]u8, c_int) callconv(.C) c_int, ?fn (?*c_void, [*c]const u8, c_int) callconv(.C) c_int, ?fn (?*c_void, fpos_t, c_int) callconv(.C) fpos_t, ?fn (?*c_void) callconv(.C) c_int) [*c]FILE;
pub extern fn __sprintf_chk(noalias [*c]u8, c_int, usize, noalias [*c]const u8, ...) c_int;
pub extern fn __snprintf_chk(noalias [*c]u8, usize, c_int, usize, noalias [*c]const u8, ...) c_int;
pub extern fn __vsprintf_chk(noalias [*c]u8, c_int, usize, noalias [*c]const u8, [*c]struct___va_list_tag) c_int;
pub extern fn __vsnprintf_chk(noalias [*c]u8, usize, c_int, usize, noalias [*c]const u8, [*c]struct___va_list_tag) c_int;
pub const P_ALL: c_int = 0;
pub const P_PID: c_int = 1;
pub const P_PGID: c_int = 2;
pub const idtype_t = c_uint;
pub const pid_t = __darwin_pid_t;
pub const id_t = __darwin_id_t;
pub const sig_atomic_t = c_int;
pub const struct___darwin_i386_thread_state = extern struct {
__eax: c_uint,
__ebx: c_uint,
__ecx: c_uint,
__edx: c_uint,
__edi: c_uint,
__esi: c_uint,
__ebp: c_uint,
__esp: c_uint,
__ss: c_uint,
__eflags: c_uint,
__eip: c_uint,
__cs: c_uint,
__ds: c_uint,
__es: c_uint,
__fs: c_uint,
__gs: c_uint,
}; // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/mach/i386/_structs.h:94:21: warning: struct demoted to opaque type - has bitfield
pub const struct___darwin_fp_control = opaque {};
pub const __darwin_fp_control_t = struct___darwin_fp_control; // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/mach/i386/_structs.h:152:21: warning: struct demoted to opaque type - has bitfield
pub const struct___darwin_fp_status = opaque {};
pub const __darwin_fp_status_t = struct___darwin_fp_status;
pub const struct___darwin_mmst_reg = extern struct {
__mmst_reg: [10]u8,
__mmst_rsrv: [6]u8,
};
pub const struct___darwin_xmm_reg = extern struct {
__xmm_reg: [16]u8,
};
pub const struct___darwin_ymm_reg = extern struct {
__ymm_reg: [32]u8,
};
pub const struct___darwin_zmm_reg = extern struct {
__zmm_reg: [64]u8,
};
pub const struct___darwin_opmask_reg = extern struct {
__opmask_reg: [8]u8,
};
pub const struct___darwin_i386_float_state = extern struct {
__fpu_reserved: [2]c_int,
__fpu_fcw: struct___darwin_fp_control,
__fpu_fsw: struct___darwin_fp_status,
__fpu_ftw: __uint8_t,
__fpu_rsrv1: __uint8_t,
__fpu_fop: __uint16_t,
__fpu_ip: __uint32_t,
__fpu_cs: __uint16_t,
__fpu_rsrv2: __uint16_t,
__fpu_dp: __uint32_t,
__fpu_ds: __uint16_t,
__fpu_rsrv3: __uint16_t,
__fpu_mxcsr: __uint32_t,
__fpu_mxcsrmask: __uint32_t,
__fpu_stmm0: struct___darwin_mmst_reg,
__fpu_stmm1: struct___darwin_mmst_reg,
__fpu_stmm2: struct___darwin_mmst_reg,
__fpu_stmm3: struct___darwin_mmst_reg,
__fpu_stmm4: struct___darwin_mmst_reg,
__fpu_stmm5: struct___darwin_mmst_reg,
__fpu_stmm6: struct___darwin_mmst_reg,
__fpu_stmm7: struct___darwin_mmst_reg,
__fpu_xmm0: struct___darwin_xmm_reg,
__fpu_xmm1: struct___darwin_xmm_reg,
__fpu_xmm2: struct___darwin_xmm_reg,
__fpu_xmm3: struct___darwin_xmm_reg,
__fpu_xmm4: struct___darwin_xmm_reg,
__fpu_xmm5: struct___darwin_xmm_reg,
__fpu_xmm6: struct___darwin_xmm_reg,
__fpu_xmm7: struct___darwin_xmm_reg,
__fpu_rsrv4: [224]u8,
__fpu_reserved1: c_int,
};
pub const struct___darwin_i386_avx_state = extern struct {
__fpu_reserved: [2]c_int,
__fpu_fcw: struct___darwin_fp_control,
__fpu_fsw: struct___darwin_fp_status,
__fpu_ftw: __uint8_t,
__fpu_rsrv1: __uint8_t,
__fpu_fop: __uint16_t,
__fpu_ip: __uint32_t,
__fpu_cs: __uint16_t,
__fpu_rsrv2: __uint16_t,
__fpu_dp: __uint32_t,
__fpu_ds: __uint16_t,
__fpu_rsrv3: __uint16_t,
__fpu_mxcsr: __uint32_t,
__fpu_mxcsrmask: __uint32_t,
__fpu_stmm0: struct___darwin_mmst_reg,
__fpu_stmm1: struct___darwin_mmst_reg,
__fpu_stmm2: struct___darwin_mmst_reg,
__fpu_stmm3: struct___darwin_mmst_reg,
__fpu_stmm4: struct___darwin_mmst_reg,
__fpu_stmm5: struct___darwin_mmst_reg,
__fpu_stmm6: struct___darwin_mmst_reg,
__fpu_stmm7: struct___darwin_mmst_reg,
__fpu_xmm0: struct___darwin_xmm_reg,
__fpu_xmm1: struct___darwin_xmm_reg,
__fpu_xmm2: struct___darwin_xmm_reg,
__fpu_xmm3: struct___darwin_xmm_reg,
__fpu_xmm4: struct___darwin_xmm_reg,
__fpu_xmm5: struct___darwin_xmm_reg,
__fpu_xmm6: struct___darwin_xmm_reg,
__fpu_xmm7: struct___darwin_xmm_reg,
__fpu_rsrv4: [224]u8,
__fpu_reserved1: c_int,
__avx_reserved1: [64]u8,
__fpu_ymmh0: struct___darwin_xmm_reg,
__fpu_ymmh1: struct___darwin_xmm_reg,
__fpu_ymmh2: struct___darwin_xmm_reg,
__fpu_ymmh3: struct___darwin_xmm_reg,
__fpu_ymmh4: struct___darwin_xmm_reg,
__fpu_ymmh5: struct___darwin_xmm_reg,
__fpu_ymmh6: struct___darwin_xmm_reg,
__fpu_ymmh7: struct___darwin_xmm_reg,
};
pub const struct___darwin_i386_avx512_state = extern struct {
__fpu_reserved: [2]c_int,
__fpu_fcw: struct___darwin_fp_control,
__fpu_fsw: struct___darwin_fp_status,
__fpu_ftw: __uint8_t,
__fpu_rsrv1: __uint8_t,
__fpu_fop: __uint16_t,
__fpu_ip: __uint32_t,
__fpu_cs: __uint16_t,
__fpu_rsrv2: __uint16_t,
__fpu_dp: __uint32_t,
__fpu_ds: __uint16_t,
__fpu_rsrv3: __uint16_t,
__fpu_mxcsr: __uint32_t,
__fpu_mxcsrmask: __uint32_t,
__fpu_stmm0: struct___darwin_mmst_reg,
__fpu_stmm1: struct___darwin_mmst_reg,
__fpu_stmm2: struct___darwin_mmst_reg,
__fpu_stmm3: struct___darwin_mmst_reg,
__fpu_stmm4: struct___darwin_mmst_reg,
__fpu_stmm5: struct___darwin_mmst_reg,
__fpu_stmm6: struct___darwin_mmst_reg,
__fpu_stmm7: struct___darwin_mmst_reg,
__fpu_xmm0: struct___darwin_xmm_reg,
__fpu_xmm1: struct___darwin_xmm_reg,
__fpu_xmm2: struct___darwin_xmm_reg,
__fpu_xmm3: struct___darwin_xmm_reg,
__fpu_xmm4: struct___darwin_xmm_reg,
__fpu_xmm5: struct___darwin_xmm_reg,
__fpu_xmm6: struct___darwin_xmm_reg,
__fpu_xmm7: struct___darwin_xmm_reg,
__fpu_rsrv4: [224]u8,
__fpu_reserved1: c_int,
__avx_reserved1: [64]u8,
__fpu_ymmh0: struct___darwin_xmm_reg,
__fpu_ymmh1: struct___darwin_xmm_reg,
__fpu_ymmh2: struct___darwin_xmm_reg,
__fpu_ymmh3: struct___darwin_xmm_reg,
__fpu_ymmh4: struct___darwin_xmm_reg,
__fpu_ymmh5: struct___darwin_xmm_reg,
__fpu_ymmh6: struct___darwin_xmm_reg,
__fpu_ymmh7: struct___darwin_xmm_reg,
__fpu_k0: struct___darwin_opmask_reg,
__fpu_k1: struct___darwin_opmask_reg,
__fpu_k2: struct___darwin_opmask_reg,
__fpu_k3: struct___darwin_opmask_reg,
__fpu_k4: struct___darwin_opmask_reg,
__fpu_k5: struct___darwin_opmask_reg,
__fpu_k6: struct___darwin_opmask_reg,
__fpu_k7: struct___darwin_opmask_reg,
__fpu_zmmh0: struct___darwin_ymm_reg,
__fpu_zmmh1: struct___darwin_ymm_reg,
__fpu_zmmh2: struct___darwin_ymm_reg,
__fpu_zmmh3: struct___darwin_ymm_reg,
__fpu_zmmh4: struct___darwin_ymm_reg,
__fpu_zmmh5: struct___darwin_ymm_reg,
__fpu_zmmh6: struct___darwin_ymm_reg,
__fpu_zmmh7: struct___darwin_ymm_reg,
};
pub const struct___darwin_i386_exception_state = extern struct {
__trapno: __uint16_t,
__cpu: __uint16_t,
__err: __uint32_t,
__faultvaddr: __uint32_t,
};
pub const struct___darwin_x86_debug_state32 = extern struct {
__dr0: c_uint,
__dr1: c_uint,
__dr2: c_uint,
__dr3: c_uint,
__dr4: c_uint,
__dr5: c_uint,
__dr6: c_uint,
__dr7: c_uint,
};
pub const struct___x86_pagein_state = extern struct {
__pagein_error: c_int,
};
pub const struct___darwin_x86_thread_state64 = extern struct {
__rax: __uint64_t,
__rbx: __uint64_t,
__rcx: __uint64_t,
__rdx: __uint64_t,
__rdi: __uint64_t,
__rsi: __uint64_t,
__rbp: __uint64_t,
__rsp: __uint64_t,
__r8: __uint64_t,
__r9: __uint64_t,
__r10: __uint64_t,
__r11: __uint64_t,
__r12: __uint64_t,
__r13: __uint64_t,
__r14: __uint64_t,
__r15: __uint64_t,
__rip: __uint64_t,
__rflags: __uint64_t,
__cs: __uint64_t,
__fs: __uint64_t,
__gs: __uint64_t,
};
pub const struct___darwin_x86_thread_full_state64 = extern struct {
__ss64: struct___darwin_x86_thread_state64,
__ds: __uint64_t,
__es: __uint64_t,
__ss: __uint64_t,
__gsbase: __uint64_t,
};
pub const struct___darwin_x86_float_state64 = extern struct {
__fpu_reserved: [2]c_int,
__fpu_fcw: struct___darwin_fp_control,
__fpu_fsw: struct___darwin_fp_status,
__fpu_ftw: __uint8_t,
__fpu_rsrv1: __uint8_t,
__fpu_fop: __uint16_t,
__fpu_ip: __uint32_t,
__fpu_cs: __uint16_t,
__fpu_rsrv2: __uint16_t,
__fpu_dp: __uint32_t,
__fpu_ds: __uint16_t,
__fpu_rsrv3: __uint16_t,
__fpu_mxcsr: __uint32_t,
__fpu_mxcsrmask: __uint32_t,
__fpu_stmm0: struct___darwin_mmst_reg,
__fpu_stmm1: struct___darwin_mmst_reg,
__fpu_stmm2: struct___darwin_mmst_reg,
__fpu_stmm3: struct___darwin_mmst_reg,
__fpu_stmm4: struct___darwin_mmst_reg,
__fpu_stmm5: struct___darwin_mmst_reg,
__fpu_stmm6: struct___darwin_mmst_reg,
__fpu_stmm7: struct___darwin_mmst_reg,
__fpu_xmm0: struct___darwin_xmm_reg,
__fpu_xmm1: struct___darwin_xmm_reg,
__fpu_xmm2: struct___darwin_xmm_reg,
__fpu_xmm3: struct___darwin_xmm_reg,
__fpu_xmm4: struct___darwin_xmm_reg,
__fpu_xmm5: struct___darwin_xmm_reg,
__fpu_xmm6: struct___darwin_xmm_reg,
__fpu_xmm7: struct___darwin_xmm_reg,
__fpu_xmm8: struct___darwin_xmm_reg,
__fpu_xmm9: struct___darwin_xmm_reg,
__fpu_xmm10: struct___darwin_xmm_reg,
__fpu_xmm11: struct___darwin_xmm_reg,
__fpu_xmm12: struct___darwin_xmm_reg,
__fpu_xmm13: struct___darwin_xmm_reg,
__fpu_xmm14: struct___darwin_xmm_reg,
__fpu_xmm15: struct___darwin_xmm_reg,
__fpu_rsrv4: [96]u8,
__fpu_reserved1: c_int,
};
pub const struct___darwin_x86_avx_state64 = extern struct {
__fpu_reserved: [2]c_int,
__fpu_fcw: struct___darwin_fp_control,
__fpu_fsw: struct___darwin_fp_status,
__fpu_ftw: __uint8_t,
__fpu_rsrv1: __uint8_t,
__fpu_fop: __uint16_t,
__fpu_ip: __uint32_t,
__fpu_cs: __uint16_t,
__fpu_rsrv2: __uint16_t,
__fpu_dp: __uint32_t,
__fpu_ds: __uint16_t,
__fpu_rsrv3: __uint16_t,
__fpu_mxcsr: __uint32_t,
__fpu_mxcsrmask: __uint32_t,
__fpu_stmm0: struct___darwin_mmst_reg,
__fpu_stmm1: struct___darwin_mmst_reg,
__fpu_stmm2: struct___darwin_mmst_reg,
__fpu_stmm3: struct___darwin_mmst_reg,
__fpu_stmm4: struct___darwin_mmst_reg,
__fpu_stmm5: struct___darwin_mmst_reg,
__fpu_stmm6: struct___darwin_mmst_reg,
__fpu_stmm7: struct___darwin_mmst_reg,
__fpu_xmm0: struct___darwin_xmm_reg,
__fpu_xmm1: struct___darwin_xmm_reg,
__fpu_xmm2: struct___darwin_xmm_reg,
__fpu_xmm3: struct___darwin_xmm_reg,
__fpu_xmm4: struct___darwin_xmm_reg,
__fpu_xmm5: struct___darwin_xmm_reg,
__fpu_xmm6: struct___darwin_xmm_reg,
__fpu_xmm7: struct___darwin_xmm_reg,
__fpu_xmm8: struct___darwin_xmm_reg,
__fpu_xmm9: struct___darwin_xmm_reg,
__fpu_xmm10: struct___darwin_xmm_reg,
__fpu_xmm11: struct___darwin_xmm_reg,
__fpu_xmm12: struct___darwin_xmm_reg,
__fpu_xmm13: struct___darwin_xmm_reg,
__fpu_xmm14: struct___darwin_xmm_reg,
__fpu_xmm15: struct___darwin_xmm_reg,
__fpu_rsrv4: [96]u8,
__fpu_reserved1: c_int,
__avx_reserved1: [64]u8,
__fpu_ymmh0: struct___darwin_xmm_reg,
__fpu_ymmh1: struct___darwin_xmm_reg,
__fpu_ymmh2: struct___darwin_xmm_reg,
__fpu_ymmh3: struct___darwin_xmm_reg,
__fpu_ymmh4: struct___darwin_xmm_reg,
__fpu_ymmh5: struct___darwin_xmm_reg,
__fpu_ymmh6: struct___darwin_xmm_reg,
__fpu_ymmh7: struct___darwin_xmm_reg,
__fpu_ymmh8: struct___darwin_xmm_reg,
__fpu_ymmh9: struct___darwin_xmm_reg,
__fpu_ymmh10: struct___darwin_xmm_reg,
__fpu_ymmh11: struct___darwin_xmm_reg,
__fpu_ymmh12: struct___darwin_xmm_reg,
__fpu_ymmh13: struct___darwin_xmm_reg,
__fpu_ymmh14: struct___darwin_xmm_reg,
__fpu_ymmh15: struct___darwin_xmm_reg,
};
pub const struct___darwin_x86_avx512_state64 = extern struct {
__fpu_reserved: [2]c_int,
__fpu_fcw: struct___darwin_fp_control,
__fpu_fsw: struct___darwin_fp_status,
__fpu_ftw: __uint8_t,
__fpu_rsrv1: __uint8_t,
__fpu_fop: __uint16_t,
__fpu_ip: __uint32_t,
__fpu_cs: __uint16_t,
__fpu_rsrv2: __uint16_t,
__fpu_dp: __uint32_t,
__fpu_ds: __uint16_t,
__fpu_rsrv3: __uint16_t,
__fpu_mxcsr: __uint32_t,
__fpu_mxcsrmask: __uint32_t,
__fpu_stmm0: struct___darwin_mmst_reg,
__fpu_stmm1: struct___darwin_mmst_reg,
__fpu_stmm2: struct___darwin_mmst_reg,
__fpu_stmm3: struct___darwin_mmst_reg,
__fpu_stmm4: struct___darwin_mmst_reg,
__fpu_stmm5: struct___darwin_mmst_reg,
__fpu_stmm6: struct___darwin_mmst_reg,
__fpu_stmm7: struct___darwin_mmst_reg,
__fpu_xmm0: struct___darwin_xmm_reg,
__fpu_xmm1: struct___darwin_xmm_reg,
__fpu_xmm2: struct___darwin_xmm_reg,
__fpu_xmm3: struct___darwin_xmm_reg,
__fpu_xmm4: struct___darwin_xmm_reg,
__fpu_xmm5: struct___darwin_xmm_reg,
__fpu_xmm6: struct___darwin_xmm_reg,
__fpu_xmm7: struct___darwin_xmm_reg,
__fpu_xmm8: struct___darwin_xmm_reg,
__fpu_xmm9: struct___darwin_xmm_reg,
__fpu_xmm10: struct___darwin_xmm_reg,
__fpu_xmm11: struct___darwin_xmm_reg,
__fpu_xmm12: struct___darwin_xmm_reg,
__fpu_xmm13: struct___darwin_xmm_reg,
__fpu_xmm14: struct___darwin_xmm_reg,
__fpu_xmm15: struct___darwin_xmm_reg,
__fpu_rsrv4: [96]u8,
__fpu_reserved1: c_int,
__avx_reserved1: [64]u8,
__fpu_ymmh0: struct___darwin_xmm_reg,
__fpu_ymmh1: struct___darwin_xmm_reg,
__fpu_ymmh2: struct___darwin_xmm_reg,
__fpu_ymmh3: struct___darwin_xmm_reg,
__fpu_ymmh4: struct___darwin_xmm_reg,
__fpu_ymmh5: struct___darwin_xmm_reg,
__fpu_ymmh6: struct___darwin_xmm_reg,
__fpu_ymmh7: struct___darwin_xmm_reg,
__fpu_ymmh8: struct___darwin_xmm_reg,
__fpu_ymmh9: struct___darwin_xmm_reg,
__fpu_ymmh10: struct___darwin_xmm_reg,
__fpu_ymmh11: struct___darwin_xmm_reg,
__fpu_ymmh12: struct___darwin_xmm_reg,
__fpu_ymmh13: struct___darwin_xmm_reg,
__fpu_ymmh14: struct___darwin_xmm_reg,
__fpu_ymmh15: struct___darwin_xmm_reg,
__fpu_k0: struct___darwin_opmask_reg,
__fpu_k1: struct___darwin_opmask_reg,
__fpu_k2: struct___darwin_opmask_reg,
__fpu_k3: struct___darwin_opmask_reg,
__fpu_k4: struct___darwin_opmask_reg,
__fpu_k5: struct___darwin_opmask_reg,
__fpu_k6: struct___darwin_opmask_reg,
__fpu_k7: struct___darwin_opmask_reg,
__fpu_zmmh0: struct___darwin_ymm_reg,
__fpu_zmmh1: struct___darwin_ymm_reg,
__fpu_zmmh2: struct___darwin_ymm_reg,
__fpu_zmmh3: struct___darwin_ymm_reg,
__fpu_zmmh4: struct___darwin_ymm_reg,
__fpu_zmmh5: struct___darwin_ymm_reg,
__fpu_zmmh6: struct___darwin_ymm_reg,
__fpu_zmmh7: struct___darwin_ymm_reg,
__fpu_zmmh8: struct___darwin_ymm_reg,
__fpu_zmmh9: struct___darwin_ymm_reg,
__fpu_zmmh10: struct___darwin_ymm_reg,
__fpu_zmmh11: struct___darwin_ymm_reg,
__fpu_zmmh12: struct___darwin_ymm_reg,
__fpu_zmmh13: struct___darwin_ymm_reg,
__fpu_zmmh14: struct___darwin_ymm_reg,
__fpu_zmmh15: struct___darwin_ymm_reg,
__fpu_zmm16: struct___darwin_zmm_reg,
__fpu_zmm17: struct___darwin_zmm_reg,
__fpu_zmm18: struct___darwin_zmm_reg,
__fpu_zmm19: struct___darwin_zmm_reg,
__fpu_zmm20: struct___darwin_zmm_reg,
__fpu_zmm21: struct___darwin_zmm_reg,
__fpu_zmm22: struct___darwin_zmm_reg,
__fpu_zmm23: struct___darwin_zmm_reg,
__fpu_zmm24: struct___darwin_zmm_reg,
__fpu_zmm25: struct___darwin_zmm_reg,
__fpu_zmm26: struct___darwin_zmm_reg,
__fpu_zmm27: struct___darwin_zmm_reg,
__fpu_zmm28: struct___darwin_zmm_reg,
__fpu_zmm29: struct___darwin_zmm_reg,
__fpu_zmm30: struct___darwin_zmm_reg,
__fpu_zmm31: struct___darwin_zmm_reg,
};
pub const struct___darwin_x86_exception_state64 = extern struct {
__trapno: __uint16_t,
__cpu: __uint16_t,
__err: __uint32_t,
__faultvaddr: __uint64_t,
};
pub const struct___darwin_x86_debug_state64 = extern struct {
__dr0: __uint64_t,
__dr1: __uint64_t,
__dr2: __uint64_t,
__dr3: __uint64_t,
__dr4: __uint64_t,
__dr5: __uint64_t,
__dr6: __uint64_t,
__dr7: __uint64_t,
};
pub const struct___darwin_x86_cpmu_state64 = extern struct {
__ctrs: [16]__uint64_t,
};
pub const struct___darwin_mcontext32 = extern struct {
__es: struct___darwin_i386_exception_state,
__ss: struct___darwin_i386_thread_state,
__fs: struct___darwin_i386_float_state,
};
pub const struct___darwin_mcontext_avx32 = extern struct {
__es: struct___darwin_i386_exception_state,
__ss: struct___darwin_i386_thread_state,
__fs: struct___darwin_i386_avx_state,
};
pub const struct___darwin_mcontext_avx512_32 = extern struct {
__es: struct___darwin_i386_exception_state,
__ss: struct___darwin_i386_thread_state,
__fs: struct___darwin_i386_avx512_state,
};
pub const struct___darwin_mcontext64 = extern struct {
__es: struct___darwin_x86_exception_state64,
__ss: struct___darwin_x86_thread_state64,
__fs: struct___darwin_x86_float_state64,
};
pub const struct___darwin_mcontext64_full = extern struct {
__es: struct___darwin_x86_exception_state64,
__ss: struct___darwin_x86_thread_full_state64,
__fs: struct___darwin_x86_float_state64,
};
pub const struct___darwin_mcontext_avx64 = extern struct {
__es: struct___darwin_x86_exception_state64,
__ss: struct___darwin_x86_thread_state64,
__fs: struct___darwin_x86_avx_state64,
};
pub const struct___darwin_mcontext_avx64_full = extern struct {
__es: struct___darwin_x86_exception_state64,
__ss: struct___darwin_x86_thread_full_state64,
__fs: struct___darwin_x86_avx_state64,
};
pub const struct___darwin_mcontext_avx512_64 = extern struct {
__es: struct___darwin_x86_exception_state64,
__ss: struct___darwin_x86_thread_state64,
__fs: struct___darwin_x86_avx512_state64,
};
pub const struct___darwin_mcontext_avx512_64_full = extern struct {
__es: struct___darwin_x86_exception_state64,
__ss: struct___darwin_x86_thread_full_state64,
__fs: struct___darwin_x86_avx512_state64,
};
pub const mcontext_t = [*c]struct___darwin_mcontext64;
pub const pthread_attr_t = __darwin_pthread_attr_t;
pub const struct___darwin_sigaltstack = extern struct {
ss_sp: ?*c_void,
ss_size: __darwin_size_t,
ss_flags: c_int,
};
pub const stack_t = struct___darwin_sigaltstack;
pub const struct___darwin_ucontext = extern struct {
uc_onstack: c_int,
uc_sigmask: __darwin_sigset_t,
uc_stack: struct___darwin_sigaltstack,
uc_link: [*c]struct___darwin_ucontext,
uc_mcsize: __darwin_size_t,
uc_mcontext: [*c]struct___darwin_mcontext64,
};
pub const ucontext_t = struct___darwin_ucontext;
pub const sigset_t = __darwin_sigset_t;
pub const uid_t = __darwin_uid_t;
pub const union_sigval = extern union {
sival_int: c_int,
sival_ptr: ?*c_void,
};
pub const struct_sigevent = extern struct {
sigev_notify: c_int,
sigev_signo: c_int,
sigev_value: union_sigval,
sigev_notify_function: ?fn (union_sigval) callconv(.C) void,
sigev_notify_attributes: [*c]pthread_attr_t,
};
pub const struct___siginfo = extern struct {
si_signo: c_int,
si_errno: c_int,
si_code: c_int,
si_pid: pid_t,
si_uid: uid_t,
si_status: c_int,
si_addr: ?*c_void,
si_value: union_sigval,
si_band: c_long,
__pad: [7]c_ulong,
};
pub const siginfo_t = struct___siginfo;
pub const union___sigaction_u = extern union {
__sa_handler: ?fn (c_int) callconv(.C) void,
__sa_sigaction: ?fn (c_int, [*c]struct___siginfo, ?*c_void) callconv(.C) void,
};
pub const struct___sigaction = extern struct {
__sigaction_u: union___sigaction_u,
sa_tramp: ?fn (?*c_void, c_int, c_int, [*c]siginfo_t, ?*c_void) callconv(.C) void,
sa_mask: sigset_t,
sa_flags: c_int,
};
pub const struct_sigaction = extern struct {
__sigaction_u: union___sigaction_u,
sa_mask: sigset_t,
sa_flags: c_int,
};
pub const sig_t = ?fn (c_int) callconv(.C) void;
pub const struct_sigvec = extern struct {
sv_handler: ?fn (c_int) callconv(.C) void,
sv_mask: c_int,
sv_flags: c_int,
};
pub const struct_sigstack = extern struct {
ss_sp: [*c]u8,
ss_onstack: c_int,
};
pub extern fn signal(c_int, ?fn (c_int) callconv(.C) void) ?fn (c_int) callconv(.C) void;
pub const int_least8_t = i8;
pub const int_least16_t = i16;
pub const int_least32_t = i32;
pub const int_least64_t = i64;
pub const uint_least8_t = u8;
pub const uint_least16_t = u16;
pub const uint_least32_t = u32;
pub const uint_least64_t = u64;
pub const int_fast8_t = i8;
pub const int_fast16_t = i16;
pub const int_fast32_t = i32;
pub const int_fast64_t = i64;
pub const uint_fast8_t = u8;
pub const uint_fast16_t = u16;
pub const uint_fast32_t = u32;
pub const uint_fast64_t = u64;
pub const intmax_t = c_long;
pub const uintmax_t = c_ulong;
pub const struct_timeval = extern struct {
tv_sec: __darwin_time_t,
tv_usec: __darwin_suseconds_t,
};
pub const rlim_t = __uint64_t;
pub const struct_rusage = extern struct {
ru_utime: struct_timeval,
ru_stime: struct_timeval,
ru_maxrss: c_long,
ru_ixrss: c_long,
ru_idrss: c_long,
ru_isrss: c_long,
ru_minflt: c_long,
ru_majflt: c_long,
ru_nswap: c_long,
ru_inblock: c_long,
ru_oublock: c_long,
ru_msgsnd: c_long,
ru_msgrcv: c_long,
ru_nsignals: c_long,
ru_nvcsw: c_long,
ru_nivcsw: c_long,
};
pub const rusage_info_t = ?*c_void;
pub const struct_rusage_info_v0 = extern struct {
ri_uuid: [16]u8,
ri_user_time: u64,
ri_system_time: u64,
ri_pkg_idle_wkups: u64,
ri_interrupt_wkups: u64,
ri_pageins: u64,
ri_wired_size: u64,
ri_resident_size: u64,
ri_phys_footprint: u64,
ri_proc_start_abstime: u64,
ri_proc_exit_abstime: u64,
};
pub const struct_rusage_info_v1 = extern struct {
ri_uuid: [16]u8,
ri_user_time: u64,
ri_system_time: u64,
ri_pkg_idle_wkups: u64,
ri_interrupt_wkups: u64,
ri_pageins: u64,
ri_wired_size: u64,
ri_resident_size: u64,
ri_phys_footprint: u64,
ri_proc_start_abstime: u64,
ri_proc_exit_abstime: u64,
ri_child_user_time: u64,
ri_child_system_time: u64,
ri_child_pkg_idle_wkups: u64,
ri_child_interrupt_wkups: u64,
ri_child_pageins: u64,
ri_child_elapsed_abstime: u64,
};
pub const struct_rusage_info_v2 = extern struct {
ri_uuid: [16]u8,
ri_user_time: u64,
ri_system_time: u64,
ri_pkg_idle_wkups: u64,
ri_interrupt_wkups: u64,
ri_pageins: u64,
ri_wired_size: u64,
ri_resident_size: u64,
ri_phys_footprint: u64,
ri_proc_start_abstime: u64,
ri_proc_exit_abstime: u64,
ri_child_user_time: u64,
ri_child_system_time: u64,
ri_child_pkg_idle_wkups: u64,
ri_child_interrupt_wkups: u64,
ri_child_pageins: u64,
ri_child_elapsed_abstime: u64,
ri_diskio_bytesread: u64,
ri_diskio_byteswritten: u64,
};
pub const struct_rusage_info_v3 = extern struct {
ri_uuid: [16]u8,
ri_user_time: u64,
ri_system_time: u64,
ri_pkg_idle_wkups: u64,
ri_interrupt_wkups: u64,
ri_pageins: u64,
ri_wired_size: u64,
ri_resident_size: u64,
ri_phys_footprint: u64,
ri_proc_start_abstime: u64,
ri_proc_exit_abstime: u64,
ri_child_user_time: u64,
ri_child_system_time: u64,
ri_child_pkg_idle_wkups: u64,
ri_child_interrupt_wkups: u64,
ri_child_pageins: u64,
ri_child_elapsed_abstime: u64,
ri_diskio_bytesread: u64,
ri_diskio_byteswritten: u64,
ri_cpu_time_qos_default: u64,
ri_cpu_time_qos_maintenance: u64,
ri_cpu_time_qos_background: u64,
ri_cpu_time_qos_utility: u64,
ri_cpu_time_qos_legacy: u64,
ri_cpu_time_qos_user_initiated: u64,
ri_cpu_time_qos_user_interactive: u64,
ri_billed_system_time: u64,
ri_serviced_system_time: u64,
};
pub const struct_rusage_info_v4 = extern struct {
ri_uuid: [16]u8,
ri_user_time: u64,
ri_system_time: u64,
ri_pkg_idle_wkups: u64,
ri_interrupt_wkups: u64,
ri_pageins: u64,
ri_wired_size: u64,
ri_resident_size: u64,
ri_phys_footprint: u64,
ri_proc_start_abstime: u64,
ri_proc_exit_abstime: u64,
ri_child_user_time: u64,
ri_child_system_time: u64,
ri_child_pkg_idle_wkups: u64,
ri_child_interrupt_wkups: u64,
ri_child_pageins: u64,
ri_child_elapsed_abstime: u64,
ri_diskio_bytesread: u64,
ri_diskio_byteswritten: u64,
ri_cpu_time_qos_default: u64,
ri_cpu_time_qos_maintenance: u64,
ri_cpu_time_qos_background: u64,
ri_cpu_time_qos_utility: u64,
ri_cpu_time_qos_legacy: u64,
ri_cpu_time_qos_user_initiated: u64,
ri_cpu_time_qos_user_interactive: u64,
ri_billed_system_time: u64,
ri_serviced_system_time: u64,
ri_logical_writes: u64,
ri_lifetime_max_phys_footprint: u64,
ri_instructions: u64,
ri_cycles: u64,
ri_billed_energy: u64,
ri_serviced_energy: u64,
ri_interval_max_phys_footprint: u64,
ri_runnable_time: u64,
};
pub const rusage_info_current = struct_rusage_info_v4;
pub const struct_rlimit = extern struct {
rlim_cur: rlim_t,
rlim_max: rlim_t,
};
pub const struct_proc_rlimit_control_wakeupmon = extern struct {
wm_flags: u32,
wm_rate: i32,
};
pub extern fn getpriority(c_int, id_t) c_int;
pub extern fn getiopolicy_np(c_int, c_int) c_int;
pub extern fn getrlimit(c_int, [*c]struct_rlimit) c_int;
pub extern fn getrusage(c_int, [*c]struct_rusage) c_int;
pub extern fn setpriority(c_int, id_t, c_int) c_int;
pub extern fn setiopolicy_np(c_int, c_int, c_int) c_int;
pub extern fn setrlimit(c_int, [*c]const struct_rlimit) c_int;
pub fn _OSSwapInt16(arg__data: __uint16_t) callconv(.C) __uint16_t {
var _data = arg__data;
return @bitCast(__uint16_t, @truncate(c_short, (@bitCast(c_int, @as(c_uint, _data)) << @intCast(@import("std").math.Log2Int(c_int), 8)) | (@bitCast(c_int, @as(c_uint, _data)) >> @intCast(@import("std").math.Log2Int(c_int), 8))));
}
pub fn _OSSwapInt32(arg__data: __uint32_t) callconv(.C) __uint32_t {
var _data = arg__data;
return __builtin_bswap32(_data);
}
pub fn _OSSwapInt64(arg__data: __uint64_t) callconv(.C) __uint64_t {
var _data = arg__data;
return __builtin_bswap64(_data);
} // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/any-macos-any/sys/wait.h:201:19: warning: struct demoted to opaque type - has bitfield
const struct_unnamed_1 = opaque {}; // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/any-macos-any/sys/wait.h:220:19: warning: struct demoted to opaque type - has bitfield
const struct_unnamed_2 = opaque {};
pub const union_wait = extern union {
w_status: c_int,
w_T: struct_unnamed_1,
w_S: struct_unnamed_2,
};
pub extern fn wait([*c]c_int) pid_t;
pub extern fn waitpid(pid_t, [*c]c_int, c_int) pid_t;
pub extern fn waitid(idtype_t, id_t, [*c]siginfo_t, c_int) c_int;
pub extern fn wait3([*c]c_int, c_int, [*c]struct_rusage) pid_t;
pub extern fn wait4(pid_t, [*c]c_int, c_int, [*c]struct_rusage) pid_t;
pub extern fn alloca(c_ulong) ?*c_void;
pub const ct_rune_t = __darwin_ct_rune_t;
pub const rune_t = __darwin_rune_t;
pub const div_t = extern struct {
quot: c_int,
rem: c_int,
};
pub const ldiv_t = extern struct {
quot: c_long,
rem: c_long,
};
pub const lldiv_t = extern struct {
quot: c_longlong,
rem: c_longlong,
};
pub extern var __mb_cur_max: c_int;
pub extern fn malloc(__size: c_ulong) ?*c_void;
pub extern fn calloc(__count: c_ulong, __size: c_ulong) ?*c_void;
pub extern fn free(?*c_void) void;
pub extern fn realloc(__ptr: ?*c_void, __size: c_ulong) ?*c_void;
pub extern fn valloc(usize) ?*c_void;
pub extern fn aligned_alloc(__alignment: usize, __size: usize) ?*c_void;
pub extern fn posix_memalign(__memptr: [*c]?*c_void, __alignment: usize, __size: usize) c_int;
pub extern fn abort() noreturn;
pub extern fn abs(c_int) c_int;
pub extern fn atexit(?fn () callconv(.C) void) c_int;
pub extern fn atof([*c]const u8) f64;
pub extern fn atoi([*c]const u8) c_int;
pub extern fn atol([*c]const u8) c_long;
pub extern fn atoll([*c]const u8) c_longlong;
pub extern fn bsearch(__key: ?*const c_void, __base: ?*const c_void, __nel: usize, __width: usize, __compar: ?fn (?*const c_void, ?*const c_void) callconv(.C) c_int) ?*c_void;
pub extern fn div(c_int, c_int) div_t;
pub extern fn exit(c_int) noreturn;
pub extern fn getenv([*c]const u8) [*c]u8;
pub extern fn labs(c_long) c_long;
pub extern fn ldiv(c_long, c_long) ldiv_t;
pub extern fn llabs(c_longlong) c_longlong;
pub extern fn lldiv(c_longlong, c_longlong) lldiv_t;
pub extern fn mblen(__s: [*c]const u8, __n: usize) c_int;
pub extern fn mbstowcs(noalias [*c]wchar_t, noalias [*c]const u8, usize) usize;
pub extern fn mbtowc(noalias [*c]wchar_t, noalias [*c]const u8, usize) c_int;
pub extern fn qsort(__base: ?*c_void, __nel: usize, __width: usize, __compar: ?fn (?*const c_void, ?*const c_void) callconv(.C) c_int) void;
pub extern fn rand() c_int;
pub extern fn srand(c_uint) void;
pub extern fn strtod([*c]const u8, [*c][*c]u8) f64;
pub extern fn strtof([*c]const u8, [*c][*c]u8) f32;
pub extern fn strtol(__str: [*c]const u8, __endptr: [*c][*c]u8, __base: c_int) c_long;
pub extern fn strtold([*c]const u8, [*c][*c]u8) c_longdouble;
pub extern fn strtoll(__str: [*c]const u8, __endptr: [*c][*c]u8, __base: c_int) c_longlong;
pub extern fn strtoul(__str: [*c]const u8, __endptr: [*c][*c]u8, __base: c_int) c_ulong;
pub extern fn strtoull(__str: [*c]const u8, __endptr: [*c][*c]u8, __base: c_int) c_ulonglong;
pub extern fn system([*c]const u8) c_int;
pub extern fn wcstombs(noalias [*c]u8, noalias [*c]const wchar_t, usize) usize;
pub extern fn wctomb([*c]u8, wchar_t) c_int;
pub extern fn _Exit(c_int) noreturn;
pub extern fn a64l([*c]const u8) c_long;
pub extern fn drand48() f64;
pub extern fn ecvt(f64, c_int, noalias [*c]c_int, noalias [*c]c_int) [*c]u8;
pub extern fn erand48([*c]c_ushort) f64;
pub extern fn fcvt(f64, c_int, noalias [*c]c_int, noalias [*c]c_int) [*c]u8;
pub extern fn gcvt(f64, c_int, [*c]u8) [*c]u8;
pub extern fn getsubopt([*c][*c]u8, [*c]const [*c]u8, [*c][*c]u8) c_int;
pub extern fn grantpt(c_int) c_int;
pub extern fn initstate(c_uint, [*c]u8, usize) [*c]u8;
pub extern fn jrand48([*c]c_ushort) c_long;
pub extern fn l64a(c_long) [*c]u8;
pub extern fn lcong48([*c]c_ushort) void;
pub extern fn lrand48() c_long;
pub extern fn mktemp([*c]u8) [*c]u8;
pub extern fn mkstemp([*c]u8) c_int;
pub extern fn mrand48() c_long;
pub extern fn nrand48([*c]c_ushort) c_long;
pub extern fn posix_openpt(c_int) c_int;
pub extern fn ptsname(c_int) [*c]u8;
pub extern fn ptsname_r(fildes: c_int, buffer: [*c]u8, buflen: usize) c_int;
pub extern fn putenv([*c]u8) c_int;
pub extern fn random() c_long;
pub extern fn rand_r([*c]c_uint) c_int;
pub extern fn realpath(noalias [*c]const u8, noalias [*c]u8) [*c]u8;
pub extern fn seed48([*c]c_ushort) [*c]c_ushort;
pub extern fn setenv(__name: [*c]const u8, __value: [*c]const u8, __overwrite: c_int) c_int;
pub extern fn setkey([*c]const u8) void;
pub extern fn setstate([*c]const u8) [*c]u8;
pub extern fn srand48(c_long) void;
pub extern fn srandom(c_uint) void;
pub extern fn unlockpt(c_int) c_int;
pub extern fn unsetenv([*c]const u8) c_int;
pub const dev_t = __darwin_dev_t;
pub const mode_t = __darwin_mode_t;
pub extern fn arc4random() u32;
pub extern fn arc4random_addrandom([*c]u8, c_int) void;
pub extern fn arc4random_buf(__buf: ?*c_void, __nbytes: usize) void;
pub extern fn arc4random_stir() void;
pub extern fn arc4random_uniform(__upper_bound: u32) u32; // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/stdlib.h:275:6: warning: unsupported type: 'BlockPointer'
pub const atexit_b = @compileError("unable to resolve prototype of function"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/stdlib.h:275:6
// /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/stdlib.h:276:7: warning: unsupported type: 'BlockPointer'
pub const bsearch_b = @compileError("unable to resolve prototype of function"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/stdlib.h:276:7
pub extern fn cgetcap([*c]u8, [*c]const u8, c_int) [*c]u8;
pub extern fn cgetclose() c_int;
pub extern fn cgetent([*c][*c]u8, [*c][*c]u8, [*c]const u8) c_int;
pub extern fn cgetfirst([*c][*c]u8, [*c][*c]u8) c_int;
pub extern fn cgetmatch([*c]const u8, [*c]const u8) c_int;
pub extern fn cgetnext([*c][*c]u8, [*c][*c]u8) c_int;
pub extern fn cgetnum([*c]u8, [*c]const u8, [*c]c_long) c_int;
pub extern fn cgetset([*c]const u8) c_int;
pub extern fn cgetstr([*c]u8, [*c]const u8, [*c][*c]u8) c_int;
pub extern fn cgetustr([*c]u8, [*c]const u8, [*c][*c]u8) c_int;
pub extern fn daemon(c_int, c_int) c_int;
pub extern fn devname(dev_t, mode_t) [*c]u8;
pub extern fn devname_r(dev_t, mode_t, buf: [*c]u8, len: c_int) [*c]u8;
pub extern fn getbsize([*c]c_int, [*c]c_long) [*c]u8;
pub extern fn getloadavg([*c]f64, c_int) c_int;
pub extern fn getprogname() [*c]const u8;
pub extern fn setprogname([*c]const u8) void;
pub extern fn heapsort(__base: ?*c_void, __nel: usize, __width: usize, __compar: ?fn (?*const c_void, ?*const c_void) callconv(.C) c_int) c_int; // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/stdlib.h:312:6: warning: unsupported type: 'BlockPointer'
pub const heapsort_b = @compileError("unable to resolve prototype of function"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/stdlib.h:312:6
pub extern fn mergesort(__base: ?*c_void, __nel: usize, __width: usize, __compar: ?fn (?*const c_void, ?*const c_void) callconv(.C) c_int) c_int; // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/stdlib.h:319:6: warning: unsupported type: 'BlockPointer'
pub const mergesort_b = @compileError("unable to resolve prototype of function"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/stdlib.h:319:6
pub extern fn psort(__base: ?*c_void, __nel: usize, __width: usize, __compar: ?fn (?*const c_void, ?*const c_void) callconv(.C) c_int) void; // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/stdlib.h:327:7: warning: unsupported type: 'BlockPointer'
pub const psort_b = @compileError("unable to resolve prototype of function"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/stdlib.h:327:7
pub extern fn psort_r(__base: ?*c_void, __nel: usize, __width: usize, ?*c_void, __compar: ?fn (?*c_void, ?*const c_void, ?*const c_void) callconv(.C) c_int) void; // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/stdlib.h:335:7: warning: unsupported type: 'BlockPointer'
pub const qsort_b = @compileError("unable to resolve prototype of function"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/stdlib.h:335:7
pub extern fn qsort_r(__base: ?*c_void, __nel: usize, __width: usize, ?*c_void, __compar: ?fn (?*c_void, ?*const c_void, ?*const c_void) callconv(.C) c_int) void;
pub extern fn radixsort(__base: [*c][*c]const u8, __nel: c_int, __table: [*c]const u8, __endbyte: c_uint) c_int;
pub extern fn rpmatch([*c]const u8) c_int;
pub extern fn sradixsort(__base: [*c][*c]const u8, __nel: c_int, __table: [*c]const u8, __endbyte: c_uint) c_int;
pub extern fn sranddev() void;
pub extern fn srandomdev() void;
pub extern fn reallocf(__ptr: ?*c_void, __size: usize) ?*c_void;
pub extern fn strtoq(__str: [*c]const u8, __endptr: [*c][*c]u8, __base: c_int) c_longlong;
pub extern fn strtouq(__str: [*c]const u8, __endptr: [*c][*c]u8, __base: c_int) c_ulonglong;
pub extern var suboptarg: [*c]u8;
pub const jmp_buf = [37]c_int;
pub const sigjmp_buf = [38]c_int;
pub extern fn setjmp([*c]c_int) c_int;
pub extern fn longjmp([*c]c_int, c_int) noreturn;
pub extern fn _setjmp([*c]c_int) c_int;
pub extern fn _longjmp([*c]c_int, c_int) noreturn;
pub extern fn sigsetjmp([*c]c_int, c_int) c_int;
pub extern fn siglongjmp([*c]c_int, c_int) noreturn;
pub extern fn longjmperror() void;
pub const __gnuc_va_list = __builtin_va_list;
pub const FT_Int16 = c_short;
pub const FT_UInt16 = c_ushort;
pub const FT_Int32 = c_int;
pub const FT_UInt32 = c_uint;
pub const FT_Fast = c_int;
pub const FT_UFast = c_uint;
pub const FT_Int64 = c_long;
pub const FT_UInt64 = c_ulong;
pub extern fn __error() [*c]c_int;
pub const FT_Memory = [*c]struct_FT_MemoryRec_;
pub const FT_Alloc_Func = ?fn (FT_Memory, c_long) callconv(.C) ?*c_void;
pub const FT_Free_Func = ?fn (FT_Memory, ?*c_void) callconv(.C) void;
pub const FT_Realloc_Func = ?fn (FT_Memory, c_long, c_long, ?*c_void) callconv(.C) ?*c_void;
pub const struct_FT_MemoryRec_ = extern struct {
user: ?*c_void,
alloc: FT_Alloc_Func,
free: FT_Free_Func,
realloc: FT_Realloc_Func,
};
pub const union_FT_StreamDesc_ = extern union {
value: c_long,
pointer: ?*c_void,
};
pub const FT_StreamDesc = union_FT_StreamDesc_;
pub const FT_Stream = [*c]struct_FT_StreamRec_;
pub const FT_Stream_IoFunc = ?fn (FT_Stream, c_ulong, [*c]u8, c_ulong) callconv(.C) c_ulong;
pub const FT_Stream_CloseFunc = ?fn (FT_Stream) callconv(.C) void;
pub const struct_FT_StreamRec_ = extern struct {
base: [*c]u8,
size: c_ulong,
pos: c_ulong,
descriptor: FT_StreamDesc,
pathname: FT_StreamDesc,
read: FT_Stream_IoFunc,
close: FT_Stream_CloseFunc,
memory: FT_Memory,
cursor: [*c]u8,
limit: [*c]u8,
};
pub const FT_StreamRec = struct_FT_StreamRec_;
pub const FT_Pos = c_long;
pub const struct_FT_Vector_ = extern struct {
x: FT_Pos,
y: FT_Pos,
};
pub const FT_Vector = struct_FT_Vector_;
pub const struct_FT_BBox_ = extern struct {
xMin: FT_Pos,
yMin: FT_Pos,
xMax: FT_Pos,
yMax: FT_Pos,
};
pub const FT_BBox = struct_FT_BBox_;
pub const FT_PIXEL_MODE_NONE: c_int = 0;
pub const FT_PIXEL_MODE_MONO: c_int = 1;
pub const FT_PIXEL_MODE_GRAY: c_int = 2;
pub const FT_PIXEL_MODE_GRAY2: c_int = 3;
pub const FT_PIXEL_MODE_GRAY4: c_int = 4;
pub const FT_PIXEL_MODE_LCD: c_int = 5;
pub const FT_PIXEL_MODE_LCD_V: c_int = 6;
pub const FT_PIXEL_MODE_BGRA: c_int = 7;
pub const FT_PIXEL_MODE_MAX: c_int = 8;
pub const enum_FT_Pixel_Mode_ = c_uint;
pub const FT_Pixel_Mode = enum_FT_Pixel_Mode_;
pub const struct_FT_Bitmap_ = extern struct {
rows: c_uint,
width: c_uint,
pitch: c_int,
buffer: [*c]u8,
num_grays: c_ushort,
pixel_mode: u8,
palette_mode: u8,
palette: ?*c_void,
};
pub const FT_Bitmap = struct_FT_Bitmap_;
pub const struct_FT_Outline_ = extern struct {
n_contours: c_short,
n_points: c_short,
points: [*c]FT_Vector,
tags: [*c]u8,
contours: [*c]c_short,
flags: c_int,
};
pub const FT_Outline = struct_FT_Outline_;
pub const FT_Outline_MoveToFunc = ?fn ([*c]const FT_Vector, ?*c_void) callconv(.C) c_int;
pub const FT_Outline_LineToFunc = ?fn ([*c]const FT_Vector, ?*c_void) callconv(.C) c_int;
pub const FT_Outline_ConicToFunc = ?fn ([*c]const FT_Vector, [*c]const FT_Vector, ?*c_void) callconv(.C) c_int;
pub const FT_Outline_CubicToFunc = ?fn ([*c]const FT_Vector, [*c]const FT_Vector, [*c]const FT_Vector, ?*c_void) callconv(.C) c_int;
pub const struct_FT_Outline_Funcs_ = extern struct {
move_to: FT_Outline_MoveToFunc,
line_to: FT_Outline_LineToFunc,
conic_to: FT_Outline_ConicToFunc,
cubic_to: FT_Outline_CubicToFunc,
shift: c_int,
delta: FT_Pos,
};
pub const FT_Outline_Funcs = struct_FT_Outline_Funcs_;
pub const FT_GLYPH_FORMAT_NONE: c_int = 0;
pub const FT_GLYPH_FORMAT_COMPOSITE: c_int = 1668246896;
pub const FT_GLYPH_FORMAT_BITMAP: c_int = 1651078259;
pub const FT_GLYPH_FORMAT_OUTLINE: c_int = 1869968492;
pub const FT_GLYPH_FORMAT_PLOTTER: c_int = 1886154612;
pub const enum_FT_Glyph_Format_ = c_uint;
pub const FT_Glyph_Format = enum_FT_Glyph_Format_;
pub const struct_FT_Span_ = extern struct {
x: c_short,
len: c_ushort,
coverage: u8,
};
pub const FT_Span = struct_FT_Span_;
pub const FT_SpanFunc = ?fn (c_int, c_int, [*c]const FT_Span, ?*c_void) callconv(.C) void;
pub const FT_Raster_BitTest_Func = ?fn (c_int, c_int, ?*c_void) callconv(.C) c_int;
pub const FT_Raster_BitSet_Func = ?fn (c_int, c_int, ?*c_void) callconv(.C) void;
pub const struct_FT_Raster_Params_ = extern struct {
target: [*c]const FT_Bitmap,
source: ?*const c_void,
flags: c_int,
gray_spans: FT_SpanFunc,
black_spans: FT_SpanFunc,
bit_test: FT_Raster_BitTest_Func,
bit_set: FT_Raster_BitSet_Func,
user: ?*c_void,
clip_box: FT_BBox,
};
pub const FT_Raster_Params = struct_FT_Raster_Params_;
pub const struct_FT_RasterRec_ = opaque {};
pub const FT_Raster = ?*struct_FT_RasterRec_;
pub const FT_Raster_NewFunc = ?fn (?*c_void, [*c]FT_Raster) callconv(.C) c_int;
pub const FT_Raster_DoneFunc = ?fn (FT_Raster) callconv(.C) void;
pub const FT_Raster_ResetFunc = ?fn (FT_Raster, [*c]u8, c_ulong) callconv(.C) void;
pub const FT_Raster_SetModeFunc = ?fn (FT_Raster, c_ulong, ?*c_void) callconv(.C) c_int;
pub const FT_Raster_RenderFunc = ?fn (FT_Raster, [*c]const FT_Raster_Params) callconv(.C) c_int;
pub const struct_FT_Raster_Funcs_ = extern struct {
glyph_format: FT_Glyph_Format,
raster_new: FT_Raster_NewFunc,
raster_reset: FT_Raster_ResetFunc,
raster_set_mode: FT_Raster_SetModeFunc,
raster_render: FT_Raster_RenderFunc,
raster_done: FT_Raster_DoneFunc,
};
pub const FT_Raster_Funcs = struct_FT_Raster_Funcs_;
pub const FT_Bool = u8;
pub const FT_FWord = c_short;
pub const FT_UFWord = c_ushort;
pub const FT_Char = i8;
pub const FT_Byte = u8;
pub const FT_Bytes = [*c]const FT_Byte;
pub const FT_Tag = FT_UInt32;
pub const FT_String = u8;
pub const FT_Short = c_short;
pub const FT_UShort = c_ushort;
pub const FT_Int = c_int;
pub const FT_UInt = c_uint;
pub const FT_Long = c_long;
pub const FT_ULong = c_ulong;
pub const FT_F2Dot14 = c_short;
pub const FT_F26Dot6 = c_long;
pub const FT_Fixed = c_long;
pub const FT_Error = c_int;
pub const FT_Pointer = ?*c_void;
pub const FT_Offset = usize;
pub const FT_PtrDist = ptrdiff_t;
pub const struct_FT_UnitVector_ = extern struct {
x: FT_F2Dot14,
y: FT_F2Dot14,
};
pub const FT_UnitVector = struct_FT_UnitVector_;
pub const struct_FT_Matrix_ = extern struct {
xx: FT_Fixed,
xy: FT_Fixed,
yx: FT_Fixed,
yy: FT_Fixed,
};
pub const FT_Matrix = struct_FT_Matrix_;
pub const struct_FT_Data_ = extern struct {
pointer: [*c]const FT_Byte,
length: FT_Int,
};
pub const FT_Data = struct_FT_Data_;
pub const FT_Generic_Finalizer = ?fn (?*c_void) callconv(.C) void;
pub const struct_FT_Generic_ = extern struct {
data: ?*c_void,
finalizer: FT_Generic_Finalizer,
};
pub const FT_Generic = struct_FT_Generic_;
pub const FT_ListNode = [*c]struct_FT_ListNodeRec_;
pub const struct_FT_ListNodeRec_ = extern struct {
prev: FT_ListNode,
next: FT_ListNode,
data: ?*c_void,
};
pub const struct_FT_ListRec_ = extern struct {
head: FT_ListNode,
tail: FT_ListNode,
};
pub const FT_List = [*c]struct_FT_ListRec_;
pub const FT_ListNodeRec = struct_FT_ListNodeRec_;
pub const FT_ListRec = struct_FT_ListRec_;
pub const FT_Mod_Err_Base: c_int = 0;
pub const FT_Mod_Err_Autofit: c_int = 0;
pub const FT_Mod_Err_BDF: c_int = 0;
pub const FT_Mod_Err_Bzip2: c_int = 0;
pub const FT_Mod_Err_Cache: c_int = 0;
pub const FT_Mod_Err_CFF: c_int = 0;
pub const FT_Mod_Err_CID: c_int = 0;
pub const FT_Mod_Err_Gzip: c_int = 0;
pub const FT_Mod_Err_LZW: c_int = 0;
pub const FT_Mod_Err_OTvalid: c_int = 0;
pub const FT_Mod_Err_PCF: c_int = 0;
pub const FT_Mod_Err_PFR: c_int = 0;
pub const FT_Mod_Err_PSaux: c_int = 0;
pub const FT_Mod_Err_PShinter: c_int = 0;
pub const FT_Mod_Err_PSnames: c_int = 0;
pub const FT_Mod_Err_Raster: c_int = 0;
pub const FT_Mod_Err_SFNT: c_int = 0;
pub const FT_Mod_Err_Smooth: c_int = 0;
pub const FT_Mod_Err_TrueType: c_int = 0;
pub const FT_Mod_Err_Type1: c_int = 0;
pub const FT_Mod_Err_Type42: c_int = 0;
pub const FT_Mod_Err_Winfonts: c_int = 0;
pub const FT_Mod_Err_GXvalid: c_int = 0;
pub const FT_Mod_Err_Sdf: c_int = 0;
pub const FT_Mod_Err_Max: c_int = 1;
const enum_unnamed_3 = c_uint;
pub const FT_Err_Ok: c_int = 0;
pub const FT_Err_Cannot_Open_Resource: c_int = 1;
pub const FT_Err_Unknown_File_Format: c_int = 2;
pub const FT_Err_Invalid_File_Format: c_int = 3;
pub const FT_Err_Invalid_Version: c_int = 4;
pub const FT_Err_Lower_Module_Version: c_int = 5;
pub const FT_Err_Invalid_Argument: c_int = 6;
pub const FT_Err_Unimplemented_Feature: c_int = 7;
pub const FT_Err_Invalid_Table: c_int = 8;
pub const FT_Err_Invalid_Offset: c_int = 9;
pub const FT_Err_Array_Too_Large: c_int = 10;
pub const FT_Err_Missing_Module: c_int = 11;
pub const FT_Err_Missing_Property: c_int = 12;
pub const FT_Err_Invalid_Glyph_Index: c_int = 16;
pub const FT_Err_Invalid_Character_Code: c_int = 17;
pub const FT_Err_Invalid_Glyph_Format: c_int = 18;
pub const FT_Err_Cannot_Render_Glyph: c_int = 19;
pub const FT_Err_Invalid_Outline: c_int = 20;
pub const FT_Err_Invalid_Composite: c_int = 21;
pub const FT_Err_Too_Many_Hints: c_int = 22;
pub const FT_Err_Invalid_Pixel_Size: c_int = 23;
pub const FT_Err_Invalid_Handle: c_int = 32;
pub const FT_Err_Invalid_Library_Handle: c_int = 33;
pub const FT_Err_Invalid_Driver_Handle: c_int = 34;
pub const FT_Err_Invalid_Face_Handle: c_int = 35;
pub const FT_Err_Invalid_Size_Handle: c_int = 36;
pub const FT_Err_Invalid_Slot_Handle: c_int = 37;
pub const FT_Err_Invalid_CharMap_Handle: c_int = 38;
pub const FT_Err_Invalid_Cache_Handle: c_int = 39;
pub const FT_Err_Invalid_Stream_Handle: c_int = 40;
pub const FT_Err_Too_Many_Drivers: c_int = 48;
pub const FT_Err_Too_Many_Extensions: c_int = 49;
pub const FT_Err_Out_Of_Memory: c_int = 64;
pub const FT_Err_Unlisted_Object: c_int = 65;
pub const FT_Err_Cannot_Open_Stream: c_int = 81;
pub const FT_Err_Invalid_Stream_Seek: c_int = 82;
pub const FT_Err_Invalid_Stream_Skip: c_int = 83;
pub const FT_Err_Invalid_Stream_Read: c_int = 84;
pub const FT_Err_Invalid_Stream_Operation: c_int = 85;
pub const FT_Err_Invalid_Frame_Operation: c_int = 86;
pub const FT_Err_Nested_Frame_Access: c_int = 87;
pub const FT_Err_Invalid_Frame_Read: c_int = 88;
pub const FT_Err_Raster_Uninitialized: c_int = 96;
pub const FT_Err_Raster_Corrupted: c_int = 97;
pub const FT_Err_Raster_Overflow: c_int = 98;
pub const FT_Err_Raster_Negative_Height: c_int = 99;
pub const FT_Err_Too_Many_Caches: c_int = 112;
pub const FT_Err_Invalid_Opcode: c_int = 128;
pub const FT_Err_Too_Few_Arguments: c_int = 129;
pub const FT_Err_Stack_Overflow: c_int = 130;
pub const FT_Err_Code_Overflow: c_int = 131;
pub const FT_Err_Bad_Argument: c_int = 132;
pub const FT_Err_Divide_By_Zero: c_int = 133;
pub const FT_Err_Invalid_Reference: c_int = 134;
pub const FT_Err_Debug_OpCode: c_int = 135;
pub const FT_Err_ENDF_In_Exec_Stream: c_int = 136;
pub const FT_Err_Nested_DEFS: c_int = 137;
pub const FT_Err_Invalid_CodeRange: c_int = 138;
pub const FT_Err_Execution_Too_Long: c_int = 139;
pub const FT_Err_Too_Many_Function_Defs: c_int = 140;
pub const FT_Err_Too_Many_Instruction_Defs: c_int = 141;
pub const FT_Err_Table_Missing: c_int = 142;
pub const FT_Err_Horiz_Header_Missing: c_int = 143;
pub const FT_Err_Locations_Missing: c_int = 144;
pub const FT_Err_Name_Table_Missing: c_int = 145;
pub const FT_Err_CMap_Table_Missing: c_int = 146;
pub const FT_Err_Hmtx_Table_Missing: c_int = 147;
pub const FT_Err_Post_Table_Missing: c_int = 148;
pub const FT_Err_Invalid_Horiz_Metrics: c_int = 149;
pub const FT_Err_Invalid_CharMap_Format: c_int = 150;
pub const FT_Err_Invalid_PPem: c_int = 151;
pub const FT_Err_Invalid_Vert_Metrics: c_int = 152;
pub const FT_Err_Could_Not_Find_Context: c_int = 153;
pub const FT_Err_Invalid_Post_Table_Format: c_int = 154;
pub const FT_Err_Invalid_Post_Table: c_int = 155;
pub const FT_Err_DEF_In_Glyf_Bytecode: c_int = 156;
pub const FT_Err_Missing_Bitmap: c_int = 157;
pub const FT_Err_Syntax_Error: c_int = 160;
pub const FT_Err_Stack_Underflow: c_int = 161;
pub const FT_Err_Ignore: c_int = 162;
pub const FT_Err_No_Unicode_Glyph_Name: c_int = 163;
pub const FT_Err_Glyph_Too_Big: c_int = 164;
pub const FT_Err_Missing_Startfont_Field: c_int = 176;
pub const FT_Err_Missing_Font_Field: c_int = 177;
pub const FT_Err_Missing_Size_Field: c_int = 178;
pub const FT_Err_Missing_Fontboundingbox_Field: c_int = 179;
pub const FT_Err_Missing_Chars_Field: c_int = 180;
pub const FT_Err_Missing_Startchar_Field: c_int = 181;
pub const FT_Err_Missing_Encoding_Field: c_int = 182;
pub const FT_Err_Missing_Bbx_Field: c_int = 183;
pub const FT_Err_Bbx_Too_Big: c_int = 184;
pub const FT_Err_Corrupted_Font_Header: c_int = 185;
pub const FT_Err_Corrupted_Font_Glyphs: c_int = 186;
pub const FT_Err_Max: c_int = 187;
const enum_unnamed_4 = c_uint;
pub extern fn FT_Error_String(error_code: FT_Error) [*c]const u8;
pub const struct_FT_Glyph_Metrics_ = extern struct {
width: FT_Pos,
height: FT_Pos,
horiBearingX: FT_Pos,
horiBearingY: FT_Pos,
horiAdvance: FT_Pos,
vertBearingX: FT_Pos,
vertBearingY: FT_Pos,
vertAdvance: FT_Pos,
};
pub const FT_Glyph_Metrics = struct_FT_Glyph_Metrics_;
pub const struct_FT_Bitmap_Size_ = extern struct {
height: FT_Short,
width: FT_Short,
size: FT_Pos,
x_ppem: FT_Pos,
y_ppem: FT_Pos,
};
pub const FT_Bitmap_Size = struct_FT_Bitmap_Size_;
pub const struct_FT_LibraryRec_ = opaque {};
pub const FT_Library = ?*struct_FT_LibraryRec_;
pub const struct_FT_ModuleRec_ = opaque {};
pub const FT_Module = ?*struct_FT_ModuleRec_;
pub const struct_FT_DriverRec_ = opaque {};
pub const FT_Driver = ?*struct_FT_DriverRec_;
pub const struct_FT_RendererRec_ = opaque {};
pub const FT_Renderer = ?*struct_FT_RendererRec_;
pub const FT_Face = [*c]struct_FT_FaceRec_;
pub const FT_ENCODING_NONE: c_int = 0;
pub const FT_ENCODING_MS_SYMBOL: c_int = 1937337698;
pub const FT_ENCODING_UNICODE: c_int = 1970170211;
pub const FT_ENCODING_SJIS: c_int = 1936353651;
pub const FT_ENCODING_PRC: c_int = 1734484000;
pub const FT_ENCODING_BIG5: c_int = 1651074869;
pub const FT_ENCODING_WANSUNG: c_int = 2002873971;
pub const FT_ENCODING_JOHAB: c_int = 1785686113;
pub const FT_ENCODING_GB2312: c_int = 1734484000;
pub const FT_ENCODING_MS_SJIS: c_int = 1936353651;
pub const FT_ENCODING_MS_GB2312: c_int = 1734484000;
pub const FT_ENCODING_MS_BIG5: c_int = 1651074869;
pub const FT_ENCODING_MS_WANSUNG: c_int = 2002873971;
pub const FT_ENCODING_MS_JOHAB: c_int = 1785686113;
pub const FT_ENCODING_ADOBE_STANDARD: c_int = 1094995778;
pub const FT_ENCODING_ADOBE_EXPERT: c_int = 1094992453;
pub const FT_ENCODING_ADOBE_CUSTOM: c_int = 1094992451;
pub const FT_ENCODING_ADOBE_LATIN_1: c_int = 1818326065;
pub const FT_ENCODING_OLD_LATIN_2: c_int = 1818326066;
pub const FT_ENCODING_APPLE_ROMAN: c_int = 1634889070;
pub const enum_FT_Encoding_ = c_uint;
pub const FT_Encoding = enum_FT_Encoding_;
pub const struct_FT_CharMapRec_ = extern struct {
face: FT_Face,
encoding: FT_Encoding,
platform_id: FT_UShort,
encoding_id: FT_UShort,
};
pub const FT_CharMap = [*c]struct_FT_CharMapRec_;
pub const struct_FT_SubGlyphRec_ = opaque {};
pub const FT_SubGlyph = ?*struct_FT_SubGlyphRec_;
pub const struct_FT_Slot_InternalRec_ = opaque {};
pub const FT_Slot_Internal = ?*struct_FT_Slot_InternalRec_;
pub const struct_FT_GlyphSlotRec_ = extern struct {
library: FT_Library,
face: FT_Face,
next: FT_GlyphSlot,
glyph_index: FT_UInt,
generic: FT_Generic,
metrics: FT_Glyph_Metrics,
linearHoriAdvance: FT_Fixed,
linearVertAdvance: FT_Fixed,
advance: FT_Vector,
format: FT_Glyph_Format,
bitmap: FT_Bitmap,
bitmap_left: FT_Int,
bitmap_top: FT_Int,
outline: FT_Outline,
num_subglyphs: FT_UInt,
subglyphs: FT_SubGlyph,
control_data: ?*c_void,
control_len: c_long,
lsb_delta: FT_Pos,
rsb_delta: FT_Pos,
other: ?*c_void,
internal: FT_Slot_Internal,
};
pub const FT_GlyphSlot = [*c]struct_FT_GlyphSlotRec_;
pub const struct_FT_Size_Metrics_ = extern struct {
x_ppem: FT_UShort,
y_ppem: FT_UShort,
x_scale: FT_Fixed,
y_scale: FT_Fixed,
ascender: FT_Pos,
descender: FT_Pos,
height: FT_Pos,
max_advance: FT_Pos,
};
pub const FT_Size_Metrics = struct_FT_Size_Metrics_;
pub const struct_FT_Size_InternalRec_ = opaque {};
pub const FT_Size_Internal = ?*struct_FT_Size_InternalRec_;
pub const struct_FT_SizeRec_ = extern struct {
face: FT_Face,
generic: FT_Generic,
metrics: FT_Size_Metrics,
internal: FT_Size_Internal,
};
pub const FT_Size = [*c]struct_FT_SizeRec_;
pub const struct_FT_Face_InternalRec_ = opaque {};
pub const FT_Face_Internal = ?*struct_FT_Face_InternalRec_;
pub const struct_FT_FaceRec_ = extern struct {
num_faces: FT_Long,
face_index: FT_Long,
face_flags: FT_Long,
style_flags: FT_Long,
num_glyphs: FT_Long,
family_name: [*c]FT_String,
style_name: [*c]FT_String,
num_fixed_sizes: FT_Int,
available_sizes: [*c]FT_Bitmap_Size,
num_charmaps: FT_Int,
charmaps: [*c]FT_CharMap,
generic: FT_Generic,
bbox: FT_BBox,
units_per_EM: FT_UShort,
ascender: FT_Short,
descender: FT_Short,
height: FT_Short,
max_advance_width: FT_Short,
max_advance_height: FT_Short,
underline_position: FT_Short,
underline_thickness: FT_Short,
glyph: FT_GlyphSlot,
size: FT_Size,
charmap: FT_CharMap,
driver: FT_Driver,
memory: FT_Memory,
stream: FT_Stream,
sizes_list: FT_ListRec,
autohint: FT_Generic,
extensions: ?*c_void,
internal: FT_Face_Internal,
};
pub const FT_CharMapRec = struct_FT_CharMapRec_;
pub const FT_FaceRec = struct_FT_FaceRec_;
pub const FT_SizeRec = struct_FT_SizeRec_;
pub const FT_GlyphSlotRec = struct_FT_GlyphSlotRec_;
pub extern fn FT_Init_FreeType(alibrary: [*c]FT_Library) FT_Error;
pub extern fn FT_Done_FreeType(library: FT_Library) FT_Error;
pub const struct_FT_Parameter_ = extern struct {
tag: FT_ULong,
data: FT_Pointer,
};
pub const FT_Parameter = struct_FT_Parameter_;
pub const struct_FT_Open_Args_ = extern struct {
flags: FT_UInt,
memory_base: [*c]const FT_Byte,
memory_size: FT_Long,
pathname: [*c]FT_String,
stream: FT_Stream,
driver: FT_Module,
num_params: FT_Int,
params: [*c]FT_Parameter,
};
pub const FT_Open_Args = struct_FT_Open_Args_;
pub extern fn FT_New_Face(library: FT_Library, filepathname: [*c]const u8, face_index: FT_Long, aface: [*c]FT_Face) FT_Error;
pub extern fn FT_New_Memory_Face(library: FT_Library, file_base: [*c]const FT_Byte, file_size: FT_Long, face_index: FT_Long, aface: [*c]FT_Face) FT_Error;
pub extern fn FT_Open_Face(library: FT_Library, args: [*c]const FT_Open_Args, face_index: FT_Long, aface: [*c]FT_Face) FT_Error;
pub extern fn FT_Attach_File(face: FT_Face, filepathname: [*c]const u8) FT_Error;
pub extern fn FT_Attach_Stream(face: FT_Face, parameters: [*c]FT_Open_Args) FT_Error;
pub extern fn FT_Reference_Face(face: FT_Face) FT_Error;
pub extern fn FT_Done_Face(face: FT_Face) FT_Error;
pub extern fn FT_Select_Size(face: FT_Face, strike_index: FT_Int) FT_Error;
pub const FT_SIZE_REQUEST_TYPE_NOMINAL: c_int = 0;
pub const FT_SIZE_REQUEST_TYPE_REAL_DIM: c_int = 1;
pub const FT_SIZE_REQUEST_TYPE_BBOX: c_int = 2;
pub const FT_SIZE_REQUEST_TYPE_CELL: c_int = 3;
pub const FT_SIZE_REQUEST_TYPE_SCALES: c_int = 4;
pub const FT_SIZE_REQUEST_TYPE_MAX: c_int = 5;
pub const enum_FT_Size_Request_Type_ = c_uint;
pub const FT_Size_Request_Type = enum_FT_Size_Request_Type_;
pub const struct_FT_Size_RequestRec_ = extern struct {
type: FT_Size_Request_Type,
width: FT_Long,
height: FT_Long,
horiResolution: FT_UInt,
vertResolution: FT_UInt,
};
pub const FT_Size_RequestRec = struct_FT_Size_RequestRec_;
pub const FT_Size_Request = [*c]struct_FT_Size_RequestRec_;
pub extern fn FT_Request_Size(face: FT_Face, req: FT_Size_Request) FT_Error;
pub extern fn FT_Set_Char_Size(face: FT_Face, char_width: FT_F26Dot6, char_height: FT_F26Dot6, horz_resolution: FT_UInt, vert_resolution: FT_UInt) FT_Error;
pub extern fn FT_Set_Pixel_Sizes(face: FT_Face, pixel_width: FT_UInt, pixel_height: FT_UInt) FT_Error;
pub extern fn FT_Load_Glyph(face: FT_Face, glyph_index: FT_UInt, load_flags: FT_Int32) FT_Error;
pub extern fn FT_Load_Char(face: FT_Face, char_code: FT_ULong, load_flags: FT_Int32) FT_Error;
pub extern fn FT_Set_Transform(face: FT_Face, matrix: [*c]FT_Matrix, delta: [*c]FT_Vector) void;
pub extern fn FT_Get_Transform(face: FT_Face, matrix: [*c]FT_Matrix, delta: [*c]FT_Vector) void;
pub const FT_RENDER_MODE_NORMAL: c_int = 0;
pub const FT_RENDER_MODE_LIGHT: c_int = 1;
pub const FT_RENDER_MODE_MONO: c_int = 2;
pub const FT_RENDER_MODE_LCD: c_int = 3;
pub const FT_RENDER_MODE_LCD_V: c_int = 4;
pub const FT_RENDER_MODE_SDF: c_int = 5;
pub const FT_RENDER_MODE_MAX: c_int = 6;
pub const enum_FT_Render_Mode_ = c_uint;
pub const FT_Render_Mode = enum_FT_Render_Mode_;
pub extern fn FT_Render_Glyph(slot: FT_GlyphSlot, render_mode: FT_Render_Mode) FT_Error;
pub const FT_KERNING_DEFAULT: c_int = 0;
pub const FT_KERNING_UNFITTED: c_int = 1;
pub const FT_KERNING_UNSCALED: c_int = 2;
pub const enum_FT_Kerning_Mode_ = c_uint;
pub const FT_Kerning_Mode = enum_FT_Kerning_Mode_;
pub extern fn FT_Get_Kerning(face: FT_Face, left_glyph: FT_UInt, right_glyph: FT_UInt, kern_mode: FT_UInt, akerning: [*c]FT_Vector) FT_Error;
pub extern fn FT_Get_Track_Kerning(face: FT_Face, point_size: FT_Fixed, degree: FT_Int, akerning: [*c]FT_Fixed) FT_Error;
pub extern fn FT_Get_Glyph_Name(face: FT_Face, glyph_index: FT_UInt, buffer: FT_Pointer, buffer_max: FT_UInt) FT_Error;
pub extern fn FT_Get_Postscript_Name(face: FT_Face) [*c]const u8;
pub extern fn FT_Select_Charmap(face: FT_Face, encoding: FT_Encoding) FT_Error;
pub extern fn FT_Set_Charmap(face: FT_Face, charmap: FT_CharMap) FT_Error;
pub extern fn FT_Get_Charmap_Index(charmap: FT_CharMap) FT_Int;
pub extern fn FT_Get_Char_Index(face: FT_Face, charcode: FT_ULong) FT_UInt;
pub extern fn FT_Get_First_Char(face: FT_Face, agindex: [*c]FT_UInt) FT_ULong;
pub extern fn FT_Get_Next_Char(face: FT_Face, char_code: FT_ULong, agindex: [*c]FT_UInt) FT_ULong;
pub extern fn FT_Face_Properties(face: FT_Face, num_properties: FT_UInt, properties: [*c]FT_Parameter) FT_Error;
pub extern fn FT_Get_Name_Index(face: FT_Face, glyph_name: [*c]const FT_String) FT_UInt;
pub extern fn FT_Get_SubGlyph_Info(glyph: FT_GlyphSlot, sub_index: FT_UInt, p_index: [*c]FT_Int, p_flags: [*c]FT_UInt, p_arg1: [*c]FT_Int, p_arg2: [*c]FT_Int, p_transform: [*c]FT_Matrix) FT_Error;
pub extern fn FT_Get_FSType_Flags(face: FT_Face) FT_UShort;
pub extern fn FT_Face_GetCharVariantIndex(face: FT_Face, charcode: FT_ULong, variantSelector: FT_ULong) FT_UInt;
pub extern fn FT_Face_GetCharVariantIsDefault(face: FT_Face, charcode: FT_ULong, variantSelector: FT_ULong) FT_Int;
pub extern fn FT_Face_GetVariantSelectors(face: FT_Face) [*c]FT_UInt32;
pub extern fn FT_Face_GetVariantsOfChar(face: FT_Face, charcode: FT_ULong) [*c]FT_UInt32;
pub extern fn FT_Face_GetCharsOfVariant(face: FT_Face, variantSelector: FT_ULong) [*c]FT_UInt32;
pub extern fn FT_MulDiv(a: FT_Long, b: FT_Long, c: FT_Long) FT_Long;
pub extern fn FT_MulFix(a: FT_Long, b: FT_Long) FT_Long;
pub extern fn FT_DivFix(a: FT_Long, b: FT_Long) FT_Long;
pub extern fn FT_RoundFix(a: FT_Fixed) FT_Fixed;
pub extern fn FT_CeilFix(a: FT_Fixed) FT_Fixed;
pub extern fn FT_FloorFix(a: FT_Fixed) FT_Fixed;
pub extern fn FT_Vector_Transform(vector: [*c]FT_Vector, matrix: [*c]const FT_Matrix) void;
pub extern fn FT_Library_Version(library: FT_Library, amajor: [*c]FT_Int, aminor: [*c]FT_Int, apatch: [*c]FT_Int) void;
pub extern fn FT_Face_CheckTrueTypePatents(face: FT_Face) FT_Bool;
pub extern fn FT_Face_SetUnpatentedHinting(face: FT_Face, value: FT_Bool) FT_Bool;
pub const FT_CONFIG_CONFIG_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:117:9
pub const FT_CONFIG_STANDARD_LIBRARY_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:132:9
pub const FT_CONFIG_OPTIONS_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:147:9
pub const FT_CONFIG_MODULES_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:163:9
pub const FT_FREETYPE_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:180:9
pub const FT_ERRORS_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:195:9
pub const FT_MODULE_ERRORS_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:208:9
pub const FT_SYSTEM_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:224:9
pub const FT_IMAGE_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:240:9
pub const FT_TYPES_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:255:9
pub const FT_LIST_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:270:9
pub const FT_OUTLINE_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:283:9
pub const FT_SIZES_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:296:9
pub const FT_MODULE_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:309:9
pub const FT_RENDER_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:322:9
pub const FT_DRIVER_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:335:9
pub const FT_TYPE1_TABLES_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:408:9
pub const FT_TRUETYPE_IDS_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:423:9
pub const FT_TRUETYPE_TABLES_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:436:9
pub const FT_TRUETYPE_TAGS_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:450:9
pub const FT_BDF_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:463:9
pub const FT_CID_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:476:9
pub const FT_GZIP_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:489:9
pub const FT_LZW_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:502:9
pub const FT_BZIP2_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:515:9
pub const FT_WINFONTS_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:528:9
pub const FT_GLYPH_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:541:9
pub const FT_BITMAP_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:554:9
pub const FT_BBOX_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:567:9
pub const FT_CACHE_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:580:9
pub const FT_MAC_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:597:9
pub const FT_MULTIPLE_MASTERS_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:610:9
pub const FT_SFNT_NAMES_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:624:9
pub const FT_OPENTYPE_VALIDATE_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:638:9
pub const FT_GX_VALIDATE_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:652:9
pub const FT_PFR_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:665:9
pub const FT_STROKER_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:677:9
pub const FT_SYNTHESIS_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:689:9
pub const FT_FONT_FORMATS_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:701:9
pub const FT_TRIGONOMETRY_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:717:9
pub const FT_LCD_FILTER_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:729:9
pub const FT_INCREMENTAL_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:741:9
pub const FT_GASP_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:753:9
pub const FT_ADVANCES_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:765:9
pub const FT_COLOR_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:777:9
pub const FT_ERROR_DEFINITIONS_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:783:9
pub const FT_PARAMETER_TAGS_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:784:9
pub const FT_UNPATENTED_HINTING_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:787:9
pub const FT_TRUETYPE_UNPATENTED_H = @compileError("unable to translate C expr: unexpected token .AngleBracketLeft"); // /usr/local/include/freetype2/freetype/config/ftheader.h:788:9
pub const offsetof = @compileError("TODO implement function '__builtin_offsetof' in std.c.builtins"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/include/stddef.h:104:9
pub const __CONCAT = @compileError("unable to translate C expr: unexpected token .HashHash"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/cdefs.h:113:9
pub const __STRING = @compileError("unable to translate C expr: unexpected token .Hash"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/cdefs.h:114:9
pub const __const = @compileError("unable to translate C expr: unexpected token .Keyword_const"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/cdefs.h:116:9
pub const __volatile = @compileError("unable to translate C expr: unexpected token .Keyword_volatile"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/cdefs.h:118:9
pub const __kpi_deprecated = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/cdefs.h:202:9
pub const __restrict = @compileError("unable to translate C expr: unexpected token .Keyword_restrict"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/cdefs.h:222:9
pub const __swift_unavailable = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/cdefs.h:288:9
pub const __header_inline = @compileError("unable to translate C expr: unexpected token .Keyword_inline"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/cdefs.h:322:10
pub const __unreachable_ok_push = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/cdefs.h:348:10
pub const __IDSTRING = @compileError("unable to translate C expr: unexpected token .Keyword_static"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/cdefs.h:379:9
pub const __FBSDID = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/cdefs.h:399:9
pub const __DECONST = @compileError("unable to translate C expr: unexpected token .Keyword_const"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/cdefs.h:403:9
pub const __DEVOLATILE = @compileError("unable to translate C expr: unexpected token .Keyword_volatile"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/cdefs.h:407:9
pub const __DEQUALIFY = @compileError("unable to translate C expr: unexpected token .Keyword_const"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/cdefs.h:411:9
pub const __alloc_size = @compileError("unable to translate C expr: expected ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/cdefs.h:429:9
pub const __DARWIN_ALIAS = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/cdefs.h:612:9
pub const __DARWIN_ALIAS_C = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/cdefs.h:613:9
pub const __DARWIN_ALIAS_I = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/cdefs.h:614:9
pub const __DARWIN_NOCANCEL = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/cdefs.h:615:9
pub const __DARWIN_INODE64 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/cdefs.h:616:9
pub const __DARWIN_1050 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/cdefs.h:618:9
pub const __DARWIN_1050ALIAS = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/cdefs.h:619:9
pub const __DARWIN_1050ALIAS_C = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/cdefs.h:620:9
pub const __DARWIN_1050ALIAS_I = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/cdefs.h:621:9
pub const __DARWIN_1050INODE64 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/cdefs.h:622:9
pub const __DARWIN_EXTSN = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/cdefs.h:624:9
pub const __DARWIN_EXTSN_C = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/cdefs.h:625:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_2_0 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:35:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_2_1 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:41:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_2_2 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:47:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_3_0 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:53:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_3_1 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:59:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_3_2 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:65:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_4_0 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:71:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_4_1 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:77:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_4_2 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:83:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_4_3 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:89:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_5_0 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:95:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_5_1 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:101:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_6_0 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:107:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_6_1 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:113:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_7_0 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:119:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_7_1 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:125:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_8_0 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:131:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_8_1 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:137:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_8_2 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:143:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_8_3 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:149:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_8_4 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:155:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_9_0 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:161:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_9_1 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:167:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_9_2 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:173:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_9_3 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:179:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_10_0 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:185:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_10_1 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:191:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_10_2 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:197:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_10_3 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:203:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_11_0 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:209:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_11_1 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:215:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_11_2 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:221:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_11_3 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:227:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_11_4 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:233:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_12_0 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:239:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_12_1 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:245:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_12_2 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:251:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_12_3 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:257:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_12_4 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:263:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_13_0 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:269:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_13_1 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:275:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_13_2 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:281:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_13_3 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:287:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_13_4 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:293:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_13_5 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:299:9
pub const __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_13_6 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:305:9
pub const __DARWIN_ALIAS_STARTING_MAC___MAC_10_15 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:491:9
pub const __DARWIN_ALIAS_STARTING_MAC___MAC_10_15_1 = @compileError("unable to translate C expr: unexpected token .Eof"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h:497:9
pub const __DARWIN_ALIAS_STARTING = @compileError("unable to translate C expr: unexpected token .HashHash"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/cdefs.h:635:9
pub const __POSIX_C_DEPRECATED = @compileError("unable to translate C expr: unexpected token .HashHash"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/cdefs.h:698:9
pub const __compiler_barrier = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/cdefs.h:812:9
pub const __enum_decl = @compileError("unable to translate C expr: expected ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/cdefs.h:836:9
pub const __enum_closed_decl = @compileError("unable to translate C expr: expected ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/cdefs.h:838:9
pub const __options_decl = @compileError("unable to translate C expr: expected ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/cdefs.h:840:9
pub const __options_closed_decl = @compileError("unable to translate C expr: expected ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/sys/cdefs.h:842:9
pub const __offsetof = @compileError("TODO implement function '__builtin_offsetof' in std.c.builtins"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/any-macos-any/sys/_types.h:83:9
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_1 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:2919:21
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_10 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:2920:21
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_10_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:2921:21
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_10_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:2923:25
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_10_3 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:2927:21
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_10_3_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:2929:25
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_10_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:2934:25
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_11 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:2938:21
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_11_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:2939:21
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_11_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:2941:25
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_11_3 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:2945:21
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_11_3_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:2947:25
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_11_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:2951:21
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_11_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:2953:25
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_11_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:2958:25
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_12 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:2962:21
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_12_1 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:2963:21
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_12_1_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:2965:25
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_12_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:2969:21
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_12_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:2971:25
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_12_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:2975:21
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_12_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:2977:25
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_12_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:2982:25
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_1_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:2987:25
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:2991:21
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:2993:25
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_3 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:2997:21
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_3_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:2999:25
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3003:21
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3005:25
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_5 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3009:21
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_5_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3011:25
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_6 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3015:21
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_6_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3017:25
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_7 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3021:21
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_7_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3023:25
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_8 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3027:21
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_8_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3029:25
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_9 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3033:21
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_9_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3035:25
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_NA = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3039:21
pub const __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_NA_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3040:21
pub const __AVAILABILITY_INTERNAL__MAC_10_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3041:21
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_1 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3042:21
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_10 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3043:21
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_10_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3044:21
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_10_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3046:25
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_10_3 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3050:21
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_10_3_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3052:25
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_10_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3057:25
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_11 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3061:21
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_11_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3062:21
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_11_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3064:25
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_11_3 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3068:21
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_11_3_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3070:25
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_11_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3074:21
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_11_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3076:25
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_11_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3081:25
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_12 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3085:21
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_12_1 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3086:21
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_12_1_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3088:25
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_12_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3092:21
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_12_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3094:25
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_12_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3098:21
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_12_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3100:25
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_12_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3105:25
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_13 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3109:21
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3110:21
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3112:25
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_3 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3116:21
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_3_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3118:25
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3122:21
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3124:25
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_5 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3128:21
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_5_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3130:25
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_6 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3134:21
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_6_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3136:25
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_7 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3140:21
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_7_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3142:25
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_8 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3146:21
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_8_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3148:25
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_9 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3152:21
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_9_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3154:25
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_NA = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3158:21
pub const __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_NA_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3159:21
pub const __AVAILABILITY_INTERNAL__MAC_10_3 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3160:21
pub const __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_1 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3161:21
pub const __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_10 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3162:21
pub const __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_10_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3163:21
pub const __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_10_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3165:25
pub const __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_10_3 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3169:21
pub const __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_10_3_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3171:25
pub const __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_10_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3176:25
pub const __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_11 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3180:21
pub const __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_11_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3181:21
pub const __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_11_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3183:25
pub const __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_11_3 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3187:21
pub const __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_11_3_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3189:25
pub const __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_11_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3193:21
pub const __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_11_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3195:25
pub const __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_11_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3200:25
pub const __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_12 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3204:21
pub const __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_12_1 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3205:21
pub const __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_12_1_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3207:25
pub const __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_12_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3211:21
pub const __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_12_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3213:25
pub const __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_12_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3217:21
pub const __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_12_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3219:25
pub const __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_12_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3224:25
pub const __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_13 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3228:21
pub const __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_3 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3229:21
pub const __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_3_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3231:25
pub const __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3235:21
pub const __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3237:25
pub const __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_5 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3241:21
pub const __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_5_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3243:25
pub const __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_6 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3247:21
pub const __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_6_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3249:25
pub const __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_7 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3253:21
pub const __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_7_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3255:25
pub const __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_8 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3259:21
pub const __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_8_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3261:25
pub const __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_9 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3265:21
pub const __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_9_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3267:25
pub const __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_NA = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3271:21
pub const __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_NA_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3272:21
pub const __AVAILABILITY_INTERNAL__MAC_10_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3273:21
pub const __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_1 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3274:21
pub const __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_10 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3275:21
pub const __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_10_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3276:21
pub const __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_10_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3278:25
pub const __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_10_3 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3282:21
pub const __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_10_3_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3284:25
pub const __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_10_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3289:25
pub const __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_11 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3293:21
pub const __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_11_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3294:21
pub const __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_11_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3296:25
pub const __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_11_3 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3300:21
pub const __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_11_3_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3302:25
pub const __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_11_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3306:21
pub const __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_11_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3308:25
pub const __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_11_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3313:25
pub const __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_12 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3317:21
pub const __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_12_1 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3318:21
pub const __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_12_1_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3320:25
pub const __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_12_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3324:21
pub const __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_12_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3326:25
pub const __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_12_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3330:21
pub const __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_12_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3332:25
pub const __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_12_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3337:25
pub const __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_13 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3341:21
pub const __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3342:21
pub const __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3344:25
pub const __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_5 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3348:21
pub const __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_5_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3350:25
pub const __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_6 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3354:21
pub const __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_6_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3356:25
pub const __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_7 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3360:21
pub const __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_7_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3362:25
pub const __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_8 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3366:21
pub const __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_8_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3368:25
pub const __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_9 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3372:21
pub const __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_9_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3374:25
pub const __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_NA = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3378:21
pub const __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_NA_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3379:21
pub const __AVAILABILITY_INTERNAL__MAC_10_5 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3380:21
pub const __AVAILABILITY_INTERNAL__MAC_10_5_DEPRECATED__MAC_10_7 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3381:21
pub const __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_1 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3382:21
pub const __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_10 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3383:21
pub const __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_10_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3384:21
pub const __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_10_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3386:25
pub const __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_10_3 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3390:21
pub const __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_10_3_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3392:25
pub const __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_10_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3397:25
pub const __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_11 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3401:21
pub const __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_11_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3402:21
pub const __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_11_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3404:25
pub const __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_11_3 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3408:21
pub const __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_11_3_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3410:25
pub const __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_11_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3414:21
pub const __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_11_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3416:25
pub const __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_11_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3421:25
pub const __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_12 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3425:21
pub const __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_12_1 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3426:21
pub const __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_12_1_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3428:25
pub const __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_12_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3432:21
pub const __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_12_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3434:25
pub const __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_12_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3438:21
pub const __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_12_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3440:25
pub const __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_12_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3445:25
pub const __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_5 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3449:21
pub const __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_5_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3451:25
pub const __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_6 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3455:21
pub const __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_6_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3457:25
pub const __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_7 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3461:21
pub const __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_7_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3463:25
pub const __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_8 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3467:21
pub const __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_8_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3469:25
pub const __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_9 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3473:21
pub const __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_9_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3475:25
pub const __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_NA = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3479:21
pub const __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_NA_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3480:21
pub const __AVAILABILITY_INTERNAL__MAC_10_6 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3481:21
pub const __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_1 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3482:21
pub const __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_10 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3483:21
pub const __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_10_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3484:21
pub const __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_10_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3486:25
pub const __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_10_3 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3490:21
pub const __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_10_3_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3492:25
pub const __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_10_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3497:25
pub const __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_11 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3501:21
pub const __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_11_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3502:21
pub const __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_11_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3504:25
pub const __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_11_3 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3508:21
pub const __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_11_3_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3510:25
pub const __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_11_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3514:21
pub const __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_11_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3516:25
pub const __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_11_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3521:25
pub const __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_12 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3525:21
pub const __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_12_1 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3526:21
pub const __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_12_1_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3528:25
pub const __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_12_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3532:21
pub const __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_12_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3534:25
pub const __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_12_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3538:21
pub const __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_12_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3540:25
pub const __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_12_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3545:25
pub const __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_13 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3549:21
pub const __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_6 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3550:21
pub const __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_6_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3552:25
pub const __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_7 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3556:21
pub const __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_7_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3558:25
pub const __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_8 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3562:21
pub const __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_8_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3564:25
pub const __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_9 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3568:21
pub const __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_9_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3570:25
pub const __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_NA = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3574:21
pub const __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_NA_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3575:21
pub const __AVAILABILITY_INTERNAL__MAC_10_7 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3576:21
pub const __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_1 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3577:21
pub const __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_10 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3578:21
pub const __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_10_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3579:21
pub const __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_10_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3581:25
pub const __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_10_3 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3585:21
pub const __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_10_3_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3587:25
pub const __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_10_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3592:25
pub const __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_11 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3596:21
pub const __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_11_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3597:21
pub const __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_11_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3599:25
pub const __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_11_3 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3603:21
pub const __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_11_3_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3605:25
pub const __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_11_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3609:21
pub const __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_11_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3611:25
pub const __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_11_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3616:25
pub const __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_12 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3620:21
pub const __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_12_1 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3621:21
pub const __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_12_1_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3623:25
pub const __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_12_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3627:21
pub const __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_12_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3629:25
pub const __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_12_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3633:21
pub const __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_12_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3635:25
pub const __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_12_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3640:25
pub const __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_13_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3644:21
pub const __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_7 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3645:21
pub const __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_7_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3647:25
pub const __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_8 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3651:21
pub const __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_8_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3653:25
pub const __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_9 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3657:21
pub const __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_9_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3659:25
pub const __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_NA = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3663:21
pub const __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_NA_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3664:21
pub const __AVAILABILITY_INTERNAL__MAC_10_8 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3665:21
pub const __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_1 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3666:21
pub const __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_10 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3667:21
pub const __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_10_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3668:21
pub const __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_10_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3670:25
pub const __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_10_3 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3674:21
pub const __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_10_3_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3676:25
pub const __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_10_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3681:25
pub const __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_11 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3685:21
pub const __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_11_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3686:21
pub const __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_11_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3688:25
pub const __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_11_3 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3692:21
pub const __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_11_3_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3694:25
pub const __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_11_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3698:21
pub const __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_11_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3700:25
pub const __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_11_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3705:25
pub const __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_12 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3709:21
pub const __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_12_1 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3710:21
pub const __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_12_1_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3712:25
pub const __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_12_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3716:21
pub const __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_12_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3718:25
pub const __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_12_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3722:21
pub const __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_12_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3724:25
pub const __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_12_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3729:25
pub const __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_13 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3733:21
pub const __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_8 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3734:21
pub const __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_8_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3736:25
pub const __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_9 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3740:21
pub const __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_9_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3742:25
pub const __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_NA = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3746:21
pub const __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_NA_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3747:21
pub const __AVAILABILITY_INTERNAL__MAC_10_9 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3748:21
pub const __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_1 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3749:21
pub const __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_10 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3750:21
pub const __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_10_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3751:21
pub const __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_10_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3753:25
pub const __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_10_3 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3757:21
pub const __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_10_3_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3759:25
pub const __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_10_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3764:25
pub const __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_11 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3768:21
pub const __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_11_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3769:21
pub const __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_11_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3771:25
pub const __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_11_3 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3775:21
pub const __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_11_3_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3777:25
pub const __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_11_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3781:21
pub const __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_11_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3783:25
pub const __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_11_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3788:25
pub const __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_12 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3792:21
pub const __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_12_1 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3793:21
pub const __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_12_1_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3795:25
pub const __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_12_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3799:21
pub const __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_12_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3801:25
pub const __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_12_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3805:21
pub const __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_12_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3807:25
pub const __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_12_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3812:25
pub const __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_13 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3816:21
pub const __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_14 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3817:21
pub const __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_9 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3818:21
pub const __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_9_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3820:25
pub const __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_NA = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3824:21
pub const __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_NA_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3825:21
pub const __AVAILABILITY_INTERNAL__MAC_10_0 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3826:21
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_0 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3827:21
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_0_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3829:25
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_1 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3833:21
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_10 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3834:21
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_10_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3835:21
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_10_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3837:25
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_10_3 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3841:21
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_10_3_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3843:25
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_10_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3848:25
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_11 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3852:21
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_11_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3853:21
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_11_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3855:25
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_11_3 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3859:21
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_11_3_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3861:25
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_11_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3865:21
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_11_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3867:25
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_11_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3872:25
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_12 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3876:21
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_12_1 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3877:21
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_12_1_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3879:25
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_12_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3883:21
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_12_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3885:25
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_12_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3889:21
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_12_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3891:25
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_12_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3896:25
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_13 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3900:21
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_1_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3902:25
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3906:21
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3908:25
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_3 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3912:21
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_3_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3914:25
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3918:21
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3920:25
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_5 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3924:21
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_5_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3926:25
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_6 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3930:21
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_6_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3932:25
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_7 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3936:21
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_7_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3938:25
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_8 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3942:21
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_8_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3944:25
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_9 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3948:21
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_9_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3950:25
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_13_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3955:25
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_NA = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3959:21
pub const __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_NA_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3960:21
pub const __AVAILABILITY_INTERNAL__MAC_10_1 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3961:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3962:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3963:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_10_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3964:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_10_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3966:25
pub const __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_10_3 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3970:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_10_3_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3972:25
pub const __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_11 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3976:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_11_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3977:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_11_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3979:25
pub const __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_11_3 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3983:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_11_3_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3985:25
pub const __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_11_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3989:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_11_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3991:25
pub const __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_11_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:3996:25
pub const __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_12 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4000:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_12_1 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4001:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_12_1_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4003:25
pub const __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_12_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4007:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_12_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4009:25
pub const __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_12_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4013:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_12_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4015:25
pub const __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_12_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4020:25
pub const __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_NA = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4024:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_NA_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4025:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_3 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4026:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_10_3 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4027:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_10_3_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4029:25
pub const __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_11 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4033:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_11_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4034:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_11_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4036:25
pub const __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_11_3 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4040:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_11_3_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4042:25
pub const __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_11_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4046:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_11_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4048:25
pub const __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_11_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4053:25
pub const __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_12 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4057:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_12_1 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4058:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_12_1_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4060:25
pub const __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_12_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4064:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_12_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4066:25
pub const __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_12_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4070:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_12_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4072:25
pub const __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_12_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4077:25
pub const __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_NA = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4081:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_NA_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4082:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_1 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4083:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_10 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4084:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_10_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4085:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_10_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4087:25
pub const __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_10_3 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4091:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_10_3_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4093:25
pub const __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_10_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4098:25
pub const __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_11 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4102:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_11_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4103:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_11_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4105:25
pub const __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_11_3 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4109:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_11_3_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4111:25
pub const __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_11_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4115:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_11_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4117:25
pub const __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_11_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4122:25
pub const __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_12 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4126:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_12_1 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4127:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_12_1_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4129:25
pub const __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_12_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4133:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_12_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4135:25
pub const __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_12_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4139:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_12_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4141:25
pub const __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_12_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4146:25
pub const __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_13 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4150:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_13_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4152:25
pub const __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_13_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4156:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_NA = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4157:21
pub const __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_NA_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4158:21
pub const __AVAILABILITY_INTERNAL__MAC_10_11 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4159:21
pub const __AVAILABILITY_INTERNAL__MAC_10_11_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4160:21
pub const __AVAILABILITY_INTERNAL__MAC_10_11_2_DEP__MAC_10_11_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4161:21
pub const __AVAILABILITY_INTERNAL__MAC_10_11_2_DEP__MAC_10_11_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4163:25
pub const __AVAILABILITY_INTERNAL__MAC_10_11_2_DEP__MAC_10_11_3 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4167:21
pub const __AVAILABILITY_INTERNAL__MAC_10_11_2_DEP__MAC_10_11_3_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4169:25
pub const __AVAILABILITY_INTERNAL__MAC_10_11_2_DEP__MAC_10_11_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4173:21
pub const __AVAILABILITY_INTERNAL__MAC_10_11_2_DEP__MAC_10_11_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4175:25
pub const __AVAILABILITY_INTERNAL__MAC_10_11_2_DEP__MAC_10_12 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4179:21
pub const __AVAILABILITY_INTERNAL__MAC_10_11_2_DEP__MAC_10_12_1 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4180:21
pub const __AVAILABILITY_INTERNAL__MAC_10_11_2_DEP__MAC_10_12_1_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4182:25
pub const __AVAILABILITY_INTERNAL__MAC_10_11_2_DEP__MAC_10_12_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4186:21
pub const __AVAILABILITY_INTERNAL__MAC_10_11_2_DEP__MAC_10_12_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4188:25
pub const __AVAILABILITY_INTERNAL__MAC_10_11_2_DEP__MAC_10_12_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4192:21
pub const __AVAILABILITY_INTERNAL__MAC_10_11_2_DEP__MAC_10_12_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4194:25
pub const __AVAILABILITY_INTERNAL__MAC_10_11_2_DEP__MAC_10_12_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4199:25
pub const __AVAILABILITY_INTERNAL__MAC_10_11_2_DEP__MAC_NA = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4203:21
pub const __AVAILABILITY_INTERNAL__MAC_10_11_2_DEP__MAC_NA_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4204:21
pub const __AVAILABILITY_INTERNAL__MAC_10_11_3 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4205:21
pub const __AVAILABILITY_INTERNAL__MAC_10_11_3_DEP__MAC_10_11_3 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4206:21
pub const __AVAILABILITY_INTERNAL__MAC_10_11_3_DEP__MAC_10_11_3_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4208:25
pub const __AVAILABILITY_INTERNAL__MAC_10_11_3_DEP__MAC_10_11_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4212:21
pub const __AVAILABILITY_INTERNAL__MAC_10_11_3_DEP__MAC_10_11_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4214:25
pub const __AVAILABILITY_INTERNAL__MAC_10_11_3_DEP__MAC_10_12 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4218:21
pub const __AVAILABILITY_INTERNAL__MAC_10_11_3_DEP__MAC_10_12_1 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4219:21
pub const __AVAILABILITY_INTERNAL__MAC_10_11_3_DEP__MAC_10_12_1_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4221:25
pub const __AVAILABILITY_INTERNAL__MAC_10_11_3_DEP__MAC_10_12_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4225:21
pub const __AVAILABILITY_INTERNAL__MAC_10_11_3_DEP__MAC_10_12_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4227:25
pub const __AVAILABILITY_INTERNAL__MAC_10_11_3_DEP__MAC_10_12_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4231:21
pub const __AVAILABILITY_INTERNAL__MAC_10_11_3_DEP__MAC_10_12_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4233:25
pub const __AVAILABILITY_INTERNAL__MAC_10_11_3_DEP__MAC_10_12_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4238:25
pub const __AVAILABILITY_INTERNAL__MAC_10_11_3_DEP__MAC_NA = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4242:21
pub const __AVAILABILITY_INTERNAL__MAC_10_11_3_DEP__MAC_NA_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4243:21
pub const __AVAILABILITY_INTERNAL__MAC_10_11_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4244:21
pub const __AVAILABILITY_INTERNAL__MAC_10_11_4_DEP__MAC_10_11_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4245:21
pub const __AVAILABILITY_INTERNAL__MAC_10_11_4_DEP__MAC_10_11_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4247:25
pub const __AVAILABILITY_INTERNAL__MAC_10_11_4_DEP__MAC_10_12 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4251:21
pub const __AVAILABILITY_INTERNAL__MAC_10_11_4_DEP__MAC_10_12_1 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4252:21
pub const __AVAILABILITY_INTERNAL__MAC_10_11_4_DEP__MAC_10_12_1_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4254:25
pub const __AVAILABILITY_INTERNAL__MAC_10_11_4_DEP__MAC_10_12_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4258:21
pub const __AVAILABILITY_INTERNAL__MAC_10_11_4_DEP__MAC_10_12_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4260:25
pub const __AVAILABILITY_INTERNAL__MAC_10_11_4_DEP__MAC_10_12_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4264:21
pub const __AVAILABILITY_INTERNAL__MAC_10_11_4_DEP__MAC_10_12_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4266:25
pub const __AVAILABILITY_INTERNAL__MAC_10_11_4_DEP__MAC_10_12_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4271:25
pub const __AVAILABILITY_INTERNAL__MAC_10_11_4_DEP__MAC_NA = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4275:21
pub const __AVAILABILITY_INTERNAL__MAC_10_11_4_DEP__MAC_NA_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4276:21
pub const __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_1 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4277:21
pub const __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_11 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4278:21
pub const __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_11_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4279:21
pub const __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_11_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4281:25
pub const __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_11_3 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4285:21
pub const __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_11_3_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4287:25
pub const __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_11_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4291:21
pub const __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_11_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4293:25
pub const __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_11_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4298:25
pub const __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_12 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4302:21
pub const __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_12_1 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4303:21
pub const __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_12_1_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4305:25
pub const __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_12_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4309:21
pub const __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_12_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4311:25
pub const __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_12_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4315:21
pub const __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_12_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4317:25
pub const __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_12_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4322:25
pub const __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_NA = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4326:21
pub const __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_NA_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4327:21
pub const __AVAILABILITY_INTERNAL__MAC_10_12 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4328:21
pub const __AVAILABILITY_INTERNAL__MAC_10_12_1 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4329:21
pub const __AVAILABILITY_INTERNAL__MAC_10_12_1_DEP__MAC_10_12_1 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4330:21
pub const __AVAILABILITY_INTERNAL__MAC_10_12_1_DEP__MAC_10_12_1_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4332:25
pub const __AVAILABILITY_INTERNAL__MAC_10_12_1_DEP__MAC_10_12_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4336:21
pub const __AVAILABILITY_INTERNAL__MAC_10_12_1_DEP__MAC_10_12_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4338:25
pub const __AVAILABILITY_INTERNAL__MAC_10_12_1_DEP__MAC_10_12_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4342:21
pub const __AVAILABILITY_INTERNAL__MAC_10_12_1_DEP__MAC_10_12_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4344:25
pub const __AVAILABILITY_INTERNAL__MAC_10_12_1_DEP__MAC_NA = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4348:21
pub const __AVAILABILITY_INTERNAL__MAC_10_12_1_DEP__MAC_NA_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4349:21
pub const __AVAILABILITY_INTERNAL__MAC_10_12_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4350:21
pub const __AVAILABILITY_INTERNAL__MAC_10_12_2_DEP__MAC_10_12_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4351:21
pub const __AVAILABILITY_INTERNAL__MAC_10_12_2_DEP__MAC_10_12_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4353:25
pub const __AVAILABILITY_INTERNAL__MAC_10_12_2_DEP__MAC_10_12_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4357:21
pub const __AVAILABILITY_INTERNAL__MAC_10_12_2_DEP__MAC_10_12_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4359:25
pub const __AVAILABILITY_INTERNAL__MAC_10_12_2_DEP__MAC_NA = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4363:21
pub const __AVAILABILITY_INTERNAL__MAC_10_12_2_DEP__MAC_NA_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4364:21
pub const __AVAILABILITY_INTERNAL__MAC_10_12_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4365:21
pub const __AVAILABILITY_INTERNAL__MAC_10_12_4_DEP__MAC_10_12_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4366:21
pub const __AVAILABILITY_INTERNAL__MAC_10_12_4_DEP__MAC_10_12_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4368:25
pub const __AVAILABILITY_INTERNAL__MAC_10_12_4_DEP__MAC_NA = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4372:21
pub const __AVAILABILITY_INTERNAL__MAC_10_12_4_DEP__MAC_NA_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4373:21
pub const __AVAILABILITY_INTERNAL__MAC_10_12_DEP__MAC_10_12 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4374:21
pub const __AVAILABILITY_INTERNAL__MAC_10_12_DEP__MAC_10_12_1 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4375:21
pub const __AVAILABILITY_INTERNAL__MAC_10_12_DEP__MAC_10_12_1_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4377:25
pub const __AVAILABILITY_INTERNAL__MAC_10_12_DEP__MAC_10_12_2 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4381:21
pub const __AVAILABILITY_INTERNAL__MAC_10_12_DEP__MAC_10_12_2_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4383:25
pub const __AVAILABILITY_INTERNAL__MAC_10_12_DEP__MAC_10_12_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4387:21
pub const __AVAILABILITY_INTERNAL__MAC_10_12_DEP__MAC_10_12_4_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4389:25
pub const __AVAILABILITY_INTERNAL__MAC_10_12_DEP__MAC_10_12_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4394:25
pub const __AVAILABILITY_INTERNAL__MAC_10_12_DEP__MAC_10_13 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4398:21
pub const __AVAILABILITY_INTERNAL__MAC_10_12_DEP__MAC_10_13_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4400:25
pub const __AVAILABILITY_INTERNAL__MAC_10_12_DEP__MAC_10_13_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4404:21
pub const __AVAILABILITY_INTERNAL__MAC_10_12_DEP__MAC_10_14 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4405:21
pub const __AVAILABILITY_INTERNAL__MAC_10_12_DEP__MAC_NA = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4406:21
pub const __AVAILABILITY_INTERNAL__MAC_10_12_DEP__MAC_NA_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4407:21
pub const __AVAILABILITY_INTERNAL__MAC_10_13 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4408:21
pub const __AVAILABILITY_INTERNAL__MAC_10_13_4 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4409:21
pub const __AVAILABILITY_INTERNAL__MAC_10_14 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4410:21
pub const __AVAILABILITY_INTERNAL__MAC_10_14_DEP__MAC_10_14 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4411:21
pub const __AVAILABILITY_INTERNAL__MAC_10_15 = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4412:21
pub const __API_AVAILABLE_PLATFORM_macos = @compileError("unable to translate C expr: unexpected token .Equal"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4442:13
pub const __API_AVAILABLE_PLATFORM_macosx = @compileError("unable to translate C expr: unexpected token .Equal"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4443:13
pub const __API_AVAILABLE_PLATFORM_ios = @compileError("unable to translate C expr: unexpected token .Equal"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4444:13
pub const __API_AVAILABLE_PLATFORM_watchos = @compileError("unable to translate C expr: unexpected token .Equal"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4445:13
pub const __API_AVAILABLE_PLATFORM_tvos = @compileError("unable to translate C expr: unexpected token .Equal"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4446:13
pub const __API_AVAILABLE_PLATFORM_macCatalyst = @compileError("unable to translate C expr: unexpected token .Equal"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4448:13
pub const __API_AVAILABLE_PLATFORM_uikitformac = @compileError("unable to translate C expr: unexpected token .Equal"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4451:14
pub const __API_AVAILABLE_PLATFORM_driverkit = @compileError("unable to translate C expr: unexpected token .Equal"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4453:13
pub const __API_A = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4457:17
pub const __API_AVAILABLE2 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4466:13
pub const __API_AVAILABLE3 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4467:13
pub const __API_AVAILABLE4 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4468:13
pub const __API_AVAILABLE5 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4469:13
pub const __API_AVAILABLE6 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4470:13
pub const __API_AVAILABLE7 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4471:13
pub const __API_AVAILABLE_GET_MACRO = @compileError("unable to translate C expr: expected ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4472:13
pub const __API_APPLY_TO = @compileError("unable to translate C expr: expected Identifier instead got: Comma"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4474:13
pub const __API_RANGE_STRINGIFY2 = @compileError("unable to translate C expr: unexpected token .Hash"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4476:13
pub const __API_A_BEGIN = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4478:13
pub const __API_AVAILABLE_BEGIN2 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4481:13
pub const __API_AVAILABLE_BEGIN3 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4482:13
pub const __API_AVAILABLE_BEGIN4 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4483:13
pub const __API_AVAILABLE_BEGIN5 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4484:13
pub const __API_AVAILABLE_BEGIN6 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4485:13
pub const __API_AVAILABLE_BEGIN7 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4486:13
pub const __API_AVAILABLE_BEGIN_GET_MACRO = @compileError("unable to translate C expr: expected ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4487:13
pub const __API_DEPRECATED_PLATFORM_macos = @compileError("unable to translate C expr: unexpected token .Equal"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4490:13
pub const __API_DEPRECATED_PLATFORM_macosx = @compileError("unable to translate C expr: unexpected token .Equal"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4491:13
pub const __API_DEPRECATED_PLATFORM_ios = @compileError("unable to translate C expr: unexpected token .Equal"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4492:13
pub const __API_DEPRECATED_PLATFORM_watchos = @compileError("unable to translate C expr: unexpected token .Equal"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4493:13
pub const __API_DEPRECATED_PLATFORM_tvos = @compileError("unable to translate C expr: unexpected token .Equal"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4494:13
pub const __API_DEPRECATED_PLATFORM_macCatalyst = @compileError("unable to translate C expr: unexpected token .Equal"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4496:13
pub const __API_DEPRECATED_PLATFORM_uikitformac = @compileError("unable to translate C expr: unexpected token .Equal"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4499:14
pub const __API_DEPRECATED_PLATFORM_driverkit = @compileError("unable to translate C expr: unexpected token .Equal"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4501:13
pub const __API_D = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4505:17
pub const __API_DEPRECATED_MSG3 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4514:13
pub const __API_DEPRECATED_MSG4 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4515:13
pub const __API_DEPRECATED_MSG5 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4516:13
pub const __API_DEPRECATED_MSG6 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4517:13
pub const __API_DEPRECATED_MSG7 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4518:13
pub const __API_DEPRECATED_MSG8 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4519:13
pub const __API_DEPRECATED_MSG_GET_MACRO = @compileError("unable to translate C expr: expected ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4520:13
pub const __API_D_BEGIN = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4522:13
pub const __API_DEPRECATED_BEGIN_MSG3 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4525:13
pub const __API_DEPRECATED_BEGIN_MSG4 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4526:13
pub const __API_DEPRECATED_BEGIN_MSG5 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4527:13
pub const __API_DEPRECATED_BEGIN_MSG6 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4528:13
pub const __API_DEPRECATED_BEGIN_MSG7 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4529:13
pub const __API_DEPRECATED_BEGIN_MSG8 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4530:13
pub const __API_DEPRECATED_BEGIN_MSG_GET_MACRO = @compileError("unable to translate C expr: expected ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4531:13
pub const __API_R = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4534:17
pub const __API_DEPRECATED_REP3 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4540:13
pub const __API_DEPRECATED_REP4 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4541:13
pub const __API_DEPRECATED_REP5 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4542:13
pub const __API_DEPRECATED_REP6 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4543:13
pub const __API_DEPRECATED_REP7 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4544:13
pub const __API_DEPRECATED_REP8 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4545:13
pub const __API_DEPRECATED_REP_GET_MACRO = @compileError("unable to translate C expr: expected ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4546:13
pub const __API_R_BEGIN = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4549:17
pub const __API_DEPRECATED_BEGIN_REP3 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4555:13
pub const __API_DEPRECATED_BEGIN_REP4 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4556:13
pub const __API_DEPRECATED_BEGIN_REP5 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4557:13
pub const __API_DEPRECATED_BEGIN_REP6 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4558:13
pub const __API_DEPRECATED_BEGIN_REP7 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4559:13
pub const __API_DEPRECATED_BEGIN_REP8 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4560:13
pub const __API_DEPRECATED_BEGIN_REP_GET_MACRO = @compileError("unable to translate C expr: expected ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4561:13
pub const __API_U = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4586:17
pub const __API_UNAVAILABLE2 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4595:13
pub const __API_UNAVAILABLE3 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4596:13
pub const __API_UNAVAILABLE4 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4597:13
pub const __API_UNAVAILABLE5 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4598:13
pub const __API_UNAVAILABLE6 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4599:13
pub const __API_UNAVAILABLE7 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4600:13
pub const __API_UNAVAILABLE_GET_MACRO = @compileError("unable to translate C expr: expected ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4601:13
pub const __API_U_BEGIN = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4603:13
pub const __API_UNAVAILABLE_BEGIN2 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4606:13
pub const __API_UNAVAILABLE_BEGIN3 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4607:13
pub const __API_UNAVAILABLE_BEGIN4 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4608:13
pub const __API_UNAVAILABLE_BEGIN5 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4609:13
pub const __API_UNAVAILABLE_BEGIN6 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4610:13
pub const __API_UNAVAILABLE_BEGIN7 = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4611:13
pub const __API_UNAVAILABLE_BEGIN_GET_MACRO = @compileError("unable to translate C expr: expected ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4612:13
pub const __swift_compiler_version_at_least = @compileError("unable to translate C expr: expected ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4661:13
pub const __SPI_AVAILABLE = @compileError("unable to translate C expr: expected ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/AvailabilityInternal.h:4669:11
pub const __OSX_AVAILABLE_STARTING = @compileError("unable to translate C expr: unexpected token .HashHash"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/Availability.h:295:17
pub const __OSX_AVAILABLE_BUT_DEPRECATED = @compileError("unable to translate C expr: unexpected token .HashHash"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/Availability.h:296:17
pub const __OSX_AVAILABLE_BUT_DEPRECATED_MSG = @compileError("unable to translate C expr: unexpected token .HashHash"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/Availability.h:298:17
pub const __OS_AVAILABILITY_MSG = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/Availability.h:322:13
pub const __OS_EXTENSION_UNAVAILABLE = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/Availability.h:350:9
pub const __OSX_AVAILABLE = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/Availability.h:358:13
pub const __OSX_DEPRECATED = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/Availability.h:359:13
pub const __IOS_AVAILABLE = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/Availability.h:381:13
pub const __IOS_DEPRECATED = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/Availability.h:382:13
pub const __TVOS_AVAILABLE = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/Availability.h:408:13
pub const __TVOS_DEPRECATED = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/Availability.h:409:13
pub const __WATCHOS_AVAILABLE = @compileError("unable to translate C expr: expected ',' or ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/Availability.h:435:13
pub const __WATCHOS_DEPRECATED = @compileError("unable to translate C expr: unexpected token .Identifier"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/Availability.h:436:13
pub const __API_AVAILABLE = @compileError("unable to translate C expr: expected ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/Availability.h:504:13
pub const __API_AVAILABLE_BEGIN = @compileError("unable to translate C expr: expected ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/Availability.h:506:13
pub const __API_DEPRECATED = @compileError("unable to translate C expr: expected ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/Availability.h:525:13
pub const __API_DEPRECATED_WITH_REPLACEMENT = @compileError("unable to translate C expr: expected ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/Availability.h:526:13
pub const __API_DEPRECATED_BEGIN = @compileError("unable to translate C expr: expected ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/Availability.h:528:13
pub const __API_DEPRECATED_WITH_REPLACEMENT_BEGIN = @compileError("unable to translate C expr: expected ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/Availability.h:531:13
pub const __API_UNAVAILABLE = @compileError("unable to translate C expr: expected ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/Availability.h:542:13
pub const __API_UNAVAILABLE_BEGIN = @compileError("unable to translate C expr: expected ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/Availability.h:544:13
pub const __SPI_DEPRECATED = @compileError("unable to translate C expr: expected ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/Availability.h:598:11
pub const __SPI_DEPRECATED_WITH_REPLACEMENT = @compileError("unable to translate C expr: expected ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/Availability.h:602:11
pub const __sgetc = @compileError("TODO unary inc/dec expr"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/stdio.h:258:9
pub const __sclearerr = @compileError("unable to translate C expr: expected ')' instead got: AmpersandEqual"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/stdio.h:282:9
pub const SIG_DFL = @compileError("unable to translate C expr: expected ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/any-macos-any/sys/signal.h:131:9
pub const SIG_IGN = @compileError("unable to translate C expr: expected ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/any-macos-any/sys/signal.h:132:9
pub const SIG_HOLD = @compileError("unable to translate C expr: expected ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/any-macos-any/sys/signal.h:133:9
pub const SIG_ERR = @compileError("unable to translate C expr: expected ')'"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/any-macos-any/sys/signal.h:134:9
pub const __DARWIN_OS_INLINE = @compileError("unable to translate C expr: unexpected token .Keyword_static"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/libkern/i386/_OSByteOrder.h:34:17
pub const __DARWIN_OSSwapInt16 = @compileError("TODO implement function '__builtin_constant_p' in std.c.builtins"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/libkern/_OSByteOrder.h:71:9
pub const __DARWIN_OSSwapInt32 = @compileError("TODO implement function '__builtin_constant_p' in std.c.builtins"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/libkern/_OSByteOrder.h:74:9
pub const __DARWIN_OSSwapInt64 = @compileError("TODO implement function '__builtin_constant_p' in std.c.builtins"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/x86_64-macos-gnu/libkern/_OSByteOrder.h:77:9
pub const NTOHL = @compileError("unable to translate C expr: unexpected token .Equal"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/any-macos-any/sys/_endian.h:143:9
pub const NTOHS = @compileError("unable to translate C expr: unexpected token .Equal"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/any-macos-any/sys/_endian.h:144:9
pub const NTOHLL = @compileError("unable to translate C expr: unexpected token .Equal"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/any-macos-any/sys/_endian.h:145:9
pub const HTONL = @compileError("unable to translate C expr: unexpected token .Equal"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/any-macos-any/sys/_endian.h:146:9
pub const HTONS = @compileError("unable to translate C expr: unexpected token .Equal"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/any-macos-any/sys/_endian.h:147:9
pub const HTONLL = @compileError("unable to translate C expr: unexpected token .Equal"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/any-macos-any/sys/_endian.h:148:9
pub const __alloca = @compileError("TODO implement function '__builtin_alloca' in std.c.builtins"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/libc/include/any-macos-any/alloca.h:40:9
pub const ft_setjmp = @compileError("unable to translate C expr: unexpected token .RParen"); // /usr/local/include/freetype2/freetype/config/ftstdlib.h:163:9
pub const va_start = @compileError("TODO implement function '__builtin_va_start' in std.c.builtins"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/include/stdarg.h:17:9
pub const va_end = @compileError("TODO implement function '__builtin_va_end' in std.c.builtins"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/include/stdarg.h:18:9
pub const va_arg = @compileError("TODO implement function '__builtin_va_arg' in std.c.builtins"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/include/stdarg.h:19:9
pub const __va_copy = @compileError("TODO implement function '__builtin_va_copy' in std.c.builtins"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/include/stdarg.h:24:9
pub const va_copy = @compileError("TODO implement function '__builtin_va_copy' in std.c.builtins"); // /usr/local/Cellar/zig/HEAD-eb010ce_1/lib/zig/include/stdarg.h:27:9
pub const FT_EXPORT = @compileError("unable to translate C expr: unexpected token .Keyword_extern"); // /usr/local/include/freetype2/freetype/config/public-macros.h:104:9
pub const FT_UNUSED = @compileError("unable to translate C expr: expected ')' instead got: Equal"); // /usr/local/include/freetype2/freetype/config/public-macros.h:114:9
pub const FT_IMAGE_TAG = @compileError("unable to translate C expr: unexpected token .Equal"); // /usr/local/include/freetype2/freetype/ftimage.h:703:9
pub const FT_ERR_XCAT = @compileError("unable to translate C expr: unexpected token .HashHash"); // /usr/local/include/freetype2/freetype/fttypes.h:594:9
pub const FT_MODERRDEF = @compileError("unable to translate C expr: unexpected token .HashHash"); // /usr/local/include/freetype2/freetype/ftmoderr.h:123:9
pub const FT_MODERR_START_LIST = @compileError("unable to translate C expr: expected Identifier instead got: LBrace"); // /usr/local/include/freetype2/freetype/ftmoderr.h:126:9
pub const FT_MODERR_END_LIST = @compileError("unable to translate C expr: unexpected token .RBrace"); // /usr/local/include/freetype2/freetype/ftmoderr.h:127:9
pub const FT_ERRORDEF = @compileError("unable to translate C expr: unexpected token .Equal"); // /usr/local/include/freetype2/freetype/fterrors.h:173:9
pub const FT_ERROR_START_LIST = @compileError("unable to translate C expr: expected Identifier instead got: LBrace"); // /usr/local/include/freetype2/freetype/fterrors.h:174:9
pub const FT_ERROR_END_LIST = @compileError("unable to translate C expr: unexpected token .RBrace"); // /usr/local/include/freetype2/freetype/fterrors.h:175:9
pub const FT_ENC_TAG = @compileError("unable to translate C expr: unexpected token .Equal"); // /usr/local/include/freetype2/freetype/freetype.h:619:9
pub const __llvm__ = @as(c_int, 1);
pub const __clang__ = @as(c_int, 1);
pub const __clang_major__ = @as(c_int, 12);
pub const __clang_minor__ = @as(c_int, 0);
pub const __clang_patchlevel__ = @as(c_int, 1);
pub const __clang_version__ = "12.0.1 ";
pub const __GNUC__ = @as(c_int, 4);
pub const __GNUC_MINOR__ = @as(c_int, 2);
pub const __GNUC_PATCHLEVEL__ = @as(c_int, 1);
pub const __GXX_ABI_VERSION = @as(c_int, 1002);
pub const __ATOMIC_RELAXED = @as(c_int, 0);
pub const __ATOMIC_CONSUME = @as(c_int, 1);
pub const __ATOMIC_ACQUIRE = @as(c_int, 2);
pub const __ATOMIC_RELEASE = @as(c_int, 3);
pub const __ATOMIC_ACQ_REL = @as(c_int, 4);
pub const __ATOMIC_SEQ_CST = @as(c_int, 5);
pub const __OPENCL_MEMORY_SCOPE_WORK_ITEM = @as(c_int, 0);
pub const __OPENCL_MEMORY_SCOPE_WORK_GROUP = @as(c_int, 1);
pub const __OPENCL_MEMORY_SCOPE_DEVICE = @as(c_int, 2);
pub const __OPENCL_MEMORY_SCOPE_ALL_SVM_DEVICES = @as(c_int, 3);
pub const __OPENCL_MEMORY_SCOPE_SUB_GROUP = @as(c_int, 4);
pub const __PRAGMA_REDEFINE_EXTNAME = @as(c_int, 1);
pub const __VERSION__ = "Homebrew Clang 12.0.1";
pub const __OBJC_BOOL_IS_BOOL = @as(c_int, 0);
pub const __CONSTANT_CFSTRINGS__ = @as(c_int, 1);
pub const __block = __attribute__(__blocks__(byref));
pub const __BLOCKS__ = @as(c_int, 1);
pub const __OPTIMIZE__ = @as(c_int, 1);
pub const __ORDER_LITTLE_ENDIAN__ = @as(c_int, 1234);
pub const __ORDER_BIG_ENDIAN__ = @as(c_int, 4321);
pub const __ORDER_PDP_ENDIAN__ = @as(c_int, 3412);
pub const __BYTE_ORDER__ = __ORDER_LITTLE_ENDIAN__;
pub const __LITTLE_ENDIAN__ = @as(c_int, 1);
pub const _LP64 = @as(c_int, 1);
pub const __LP64__ = @as(c_int, 1);
pub const __CHAR_BIT__ = @as(c_int, 8);
pub const __SCHAR_MAX__ = @as(c_int, 127);
pub const __SHRT_MAX__ = @as(c_int, 32767);
pub const __INT_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal);
pub const __LONG_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_long, 9223372036854775807, .decimal);
pub const __LONG_LONG_MAX__ = @as(c_longlong, 9223372036854775807);
pub const __WCHAR_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal);
pub const __WINT_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal);
pub const __INTMAX_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_long, 9223372036854775807, .decimal);
pub const __SIZE_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_ulong, 18446744073709551615, .decimal);
pub const __UINTMAX_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_ulong, 18446744073709551615, .decimal);
pub const __PTRDIFF_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_long, 9223372036854775807, .decimal);
pub const __INTPTR_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_long, 9223372036854775807, .decimal);
pub const __UINTPTR_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_ulong, 18446744073709551615, .decimal);
pub const __SIZEOF_DOUBLE__ = @as(c_int, 8);
pub const __SIZEOF_FLOAT__ = @as(c_int, 4);
pub const __SIZEOF_INT__ = @as(c_int, 4);
pub const __SIZEOF_LONG__ = @as(c_int, 8);
pub const __SIZEOF_LONG_DOUBLE__ = @as(c_int, 16);
pub const __SIZEOF_LONG_LONG__ = @as(c_int, 8);
pub const __SIZEOF_POINTER__ = @as(c_int, 8);
pub const __SIZEOF_SHORT__ = @as(c_int, 2);
pub const __SIZEOF_PTRDIFF_T__ = @as(c_int, 8);
pub const __SIZEOF_SIZE_T__ = @as(c_int, 8);
pub const __SIZEOF_WCHAR_T__ = @as(c_int, 4);
pub const __SIZEOF_WINT_T__ = @as(c_int, 4);
pub const __SIZEOF_INT128__ = @as(c_int, 16);
pub const __INTMAX_TYPE__ = c_long;
pub const __INTMAX_FMTd__ = "ld";
pub const __INTMAX_FMTi__ = "li";
pub const __INTMAX_C_SUFFIX__ = L;
pub const __UINTMAX_TYPE__ = c_ulong;
pub const __UINTMAX_FMTo__ = "lo";
pub const __UINTMAX_FMTu__ = "lu";
pub const __UINTMAX_FMTx__ = "lx";
pub const __UINTMAX_FMTX__ = "lX";
pub const __UINTMAX_C_SUFFIX__ = UL;
pub const __INTMAX_WIDTH__ = @as(c_int, 64);
pub const __PTRDIFF_TYPE__ = c_long;
pub const __PTRDIFF_FMTd__ = "ld";
pub const __PTRDIFF_FMTi__ = "li";
pub const __PTRDIFF_WIDTH__ = @as(c_int, 64);
pub const __INTPTR_TYPE__ = c_long;
pub const __INTPTR_FMTd__ = "ld";
pub const __INTPTR_FMTi__ = "li";
pub const __INTPTR_WIDTH__ = @as(c_int, 64);
pub const __SIZE_TYPE__ = c_ulong;
pub const __SIZE_FMTo__ = "lo";
pub const __SIZE_FMTu__ = "lu";
pub const __SIZE_FMTx__ = "lx";
pub const __SIZE_FMTX__ = "lX";
pub const __SIZE_WIDTH__ = @as(c_int, 64);
pub const __WCHAR_TYPE__ = c_int;
pub const __WCHAR_WIDTH__ = @as(c_int, 32);
pub const __WINT_TYPE__ = c_int;
pub const __WINT_WIDTH__ = @as(c_int, 32);
pub const __SIG_ATOMIC_WIDTH__ = @as(c_int, 32);
pub const __SIG_ATOMIC_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal);
pub const __CHAR16_TYPE__ = c_ushort;
pub const __CHAR32_TYPE__ = c_uint;
pub const __UINTMAX_WIDTH__ = @as(c_int, 64);
pub const __UINTPTR_TYPE__ = c_ulong;
pub const __UINTPTR_FMTo__ = "lo";
pub const __UINTPTR_FMTu__ = "lu";
pub const __UINTPTR_FMTx__ = "lx";
pub const __UINTPTR_FMTX__ = "lX";
pub const __UINTPTR_WIDTH__ = @as(c_int, 64);
pub const __FLT_DENORM_MIN__ = @as(f32, 1.40129846e-45);
pub const __FLT_HAS_DENORM__ = @as(c_int, 1);
pub const __FLT_DIG__ = @as(c_int, 6);
pub const __FLT_DECIMAL_DIG__ = @as(c_int, 9);
pub const __FLT_EPSILON__ = @as(f32, 1.19209290e-7);
pub const __FLT_HAS_INFINITY__ = @as(c_int, 1);
pub const __FLT_HAS_QUIET_NAN__ = @as(c_int, 1);
pub const __FLT_MANT_DIG__ = @as(c_int, 24);
pub const __FLT_MAX_10_EXP__ = @as(c_int, 38);
pub const __FLT_MAX_EXP__ = @as(c_int, 128);
pub const __FLT_MAX__ = @as(f32, 3.40282347e+38);
pub const __FLT_MIN_10_EXP__ = -@as(c_int, 37);
pub const __FLT_MIN_EXP__ = -@as(c_int, 125);
pub const __FLT_MIN__ = @as(f32, 1.17549435e-38);
pub const __DBL_DENORM_MIN__ = 4.9406564584124654e-324;
pub const __DBL_HAS_DENORM__ = @as(c_int, 1);
pub const __DBL_DIG__ = @as(c_int, 15);
pub const __DBL_DECIMAL_DIG__ = @as(c_int, 17);
pub const __DBL_EPSILON__ = 2.2204460492503131e-16;
pub const __DBL_HAS_INFINITY__ = @as(c_int, 1);
pub const __DBL_HAS_QUIET_NAN__ = @as(c_int, 1);
pub const __DBL_MANT_DIG__ = @as(c_int, 53);
pub const __DBL_MAX_10_EXP__ = @as(c_int, 308);
pub const __DBL_MAX_EXP__ = @as(c_int, 1024);
pub const __DBL_MAX__ = 1.7976931348623157e+308;
pub const __DBL_MIN_10_EXP__ = -@as(c_int, 307);
pub const __DBL_MIN_EXP__ = -@as(c_int, 1021);
pub const __DBL_MIN__ = 2.2250738585072014e-308;
pub const __LDBL_DENORM_MIN__ = @as(c_longdouble, 3.64519953188247460253e-4951);
pub const __LDBL_HAS_DENORM__ = @as(c_int, 1);
pub const __LDBL_DIG__ = @as(c_int, 18);
pub const __LDBL_DECIMAL_DIG__ = @as(c_int, 21);
pub const __LDBL_EPSILON__ = @as(c_longdouble, 1.08420217248550443401e-19);
pub const __LDBL_HAS_INFINITY__ = @as(c_int, 1);
pub const __LDBL_HAS_QUIET_NAN__ = @as(c_int, 1);
pub const __LDBL_MANT_DIG__ = @as(c_int, 64);
pub const __LDBL_MAX_10_EXP__ = @as(c_int, 4932);
pub const __LDBL_MAX_EXP__ = @as(c_int, 16384);
pub const __LDBL_MAX__ = @as(c_longdouble, 1.18973149535723176502e+4932);
pub const __LDBL_MIN_10_EXP__ = -@as(c_int, 4931);
pub const __LDBL_MIN_EXP__ = -@as(c_int, 16381);
pub const __LDBL_MIN__ = @as(c_longdouble, 3.36210314311209350626e-4932);
pub const __POINTER_WIDTH__ = @as(c_int, 64);
pub const __BIGGEST_ALIGNMENT__ = @as(c_int, 16);
pub const __INT8_TYPE__ = i8;
pub const __INT8_FMTd__ = "hhd";
pub const __INT8_FMTi__ = "hhi";
pub const __INT16_TYPE__ = c_short;
pub const __INT16_FMTd__ = "hd";
pub const __INT16_FMTi__ = "hi";
pub const __INT32_TYPE__ = c_int;
pub const __INT32_FMTd__ = "d";
pub const __INT32_FMTi__ = "i";
pub const __INT64_TYPE__ = c_longlong;
pub const __INT64_FMTd__ = "lld";
pub const __INT64_FMTi__ = "lli";
pub const __INT64_C_SUFFIX__ = LL;
pub const __UINT8_TYPE__ = u8;
pub const __UINT8_FMTo__ = "hho";
pub const __UINT8_FMTu__ = "hhu";
pub const __UINT8_FMTx__ = "hhx";
pub const __UINT8_FMTX__ = "hhX";
pub const __UINT8_MAX__ = @as(c_int, 255);
pub const __INT8_MAX__ = @as(c_int, 127);
pub const __UINT16_TYPE__ = c_ushort;
pub const __UINT16_FMTo__ = "ho";
pub const __UINT16_FMTu__ = "hu";
pub const __UINT16_FMTx__ = "hx";
pub const __UINT16_FMTX__ = "hX";
pub const __UINT16_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 65535, .decimal);
pub const __INT16_MAX__ = @as(c_int, 32767);
pub const __UINT32_TYPE__ = c_uint;
pub const __UINT32_FMTo__ = "o";
pub const __UINT32_FMTu__ = "u";
pub const __UINT32_FMTx__ = "x";
pub const __UINT32_FMTX__ = "X";
pub const __UINT32_C_SUFFIX__ = U;
pub const __UINT32_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_uint, 4294967295, .decimal);
pub const __INT32_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal);
pub const __UINT64_TYPE__ = c_ulonglong;
pub const __UINT64_FMTo__ = "llo";
pub const __UINT64_FMTu__ = "llu";
pub const __UINT64_FMTx__ = "llx";
pub const __UINT64_FMTX__ = "llX";
pub const __UINT64_C_SUFFIX__ = ULL;
pub const __UINT64_MAX__ = @as(c_ulonglong, 18446744073709551615);
pub const __INT64_MAX__ = @as(c_longlong, 9223372036854775807);
pub const __INT_LEAST8_TYPE__ = i8;
pub const __INT_LEAST8_MAX__ = @as(c_int, 127);
pub const __INT_LEAST8_FMTd__ = "hhd";
pub const __INT_LEAST8_FMTi__ = "hhi";
pub const __UINT_LEAST8_TYPE__ = u8;
pub const __UINT_LEAST8_MAX__ = @as(c_int, 255);
pub const __UINT_LEAST8_FMTo__ = "hho";
pub const __UINT_LEAST8_FMTu__ = "hhu";
pub const __UINT_LEAST8_FMTx__ = "hhx";
pub const __UINT_LEAST8_FMTX__ = "hhX";
pub const __INT_LEAST16_TYPE__ = c_short;
pub const __INT_LEAST16_MAX__ = @as(c_int, 32767);
pub const __INT_LEAST16_FMTd__ = "hd";
pub const __INT_LEAST16_FMTi__ = "hi";
pub const __UINT_LEAST16_TYPE__ = c_ushort;
pub const __UINT_LEAST16_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 65535, .decimal);
pub const __UINT_LEAST16_FMTo__ = "ho";
pub const __UINT_LEAST16_FMTu__ = "hu";
pub const __UINT_LEAST16_FMTx__ = "hx";
pub const __UINT_LEAST16_FMTX__ = "hX";
pub const __INT_LEAST32_TYPE__ = c_int;
pub const __INT_LEAST32_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal);
pub const __INT_LEAST32_FMTd__ = "d";
pub const __INT_LEAST32_FMTi__ = "i";
pub const __UINT_LEAST32_TYPE__ = c_uint;
pub const __UINT_LEAST32_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_uint, 4294967295, .decimal);
pub const __UINT_LEAST32_FMTo__ = "o";
pub const __UINT_LEAST32_FMTu__ = "u";
pub const __UINT_LEAST32_FMTx__ = "x";
pub const __UINT_LEAST32_FMTX__ = "X";
pub const __INT_LEAST64_TYPE__ = c_longlong;
pub const __INT_LEAST64_MAX__ = @as(c_longlong, 9223372036854775807);
pub const __INT_LEAST64_FMTd__ = "lld";
pub const __INT_LEAST64_FMTi__ = "lli";
pub const __UINT_LEAST64_TYPE__ = c_ulonglong;
pub const __UINT_LEAST64_MAX__ = @as(c_ulonglong, 18446744073709551615);
pub const __UINT_LEAST64_FMTo__ = "llo";
pub const __UINT_LEAST64_FMTu__ = "llu";
pub const __UINT_LEAST64_FMTx__ = "llx";
pub const __UINT_LEAST64_FMTX__ = "llX";
pub const __INT_FAST8_TYPE__ = i8;
pub const __INT_FAST8_MAX__ = @as(c_int, 127);
pub const __INT_FAST8_FMTd__ = "hhd";
pub const __INT_FAST8_FMTi__ = "hhi";
pub const __UINT_FAST8_TYPE__ = u8;
pub const __UINT_FAST8_MAX__ = @as(c_int, 255);
pub const __UINT_FAST8_FMTo__ = "hho";
pub const __UINT_FAST8_FMTu__ = "hhu";
pub const __UINT_FAST8_FMTx__ = "hhx";
pub const __UINT_FAST8_FMTX__ = "hhX";
pub const __INT_FAST16_TYPE__ = c_short;
pub const __INT_FAST16_MAX__ = @as(c_int, 32767);
pub const __INT_FAST16_FMTd__ = "hd";
pub const __INT_FAST16_FMTi__ = "hi";
pub const __UINT_FAST16_TYPE__ = c_ushort;
pub const __UINT_FAST16_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 65535, .decimal);
pub const __UINT_FAST16_FMTo__ = "ho";
pub const __UINT_FAST16_FMTu__ = "hu";
pub const __UINT_FAST16_FMTx__ = "hx";
pub const __UINT_FAST16_FMTX__ = "hX";
pub const __INT_FAST32_TYPE__ = c_int;
pub const __INT_FAST32_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal);
pub const __INT_FAST32_FMTd__ = "d";
pub const __INT_FAST32_FMTi__ = "i";
pub const __UINT_FAST32_TYPE__ = c_uint;
pub const __UINT_FAST32_MAX__ = @import("std").zig.c_translation.promoteIntLiteral(c_uint, 4294967295, .decimal);
pub const __UINT_FAST32_FMTo__ = "o";
pub const __UINT_FAST32_FMTu__ = "u";
pub const __UINT_FAST32_FMTx__ = "x";
pub const __UINT_FAST32_FMTX__ = "X";
pub const __INT_FAST64_TYPE__ = c_longlong;
pub const __INT_FAST64_MAX__ = @as(c_longlong, 9223372036854775807);
pub const __INT_FAST64_FMTd__ = "lld";
pub const __INT_FAST64_FMTi__ = "lli";
pub const __UINT_FAST64_TYPE__ = c_ulonglong;
pub const __UINT_FAST64_MAX__ = @as(c_ulonglong, 18446744073709551615);
pub const __UINT_FAST64_FMTo__ = "llo";
pub const __UINT_FAST64_FMTu__ = "llu";
pub const __UINT_FAST64_FMTx__ = "llx";
pub const __UINT_FAST64_FMTX__ = "llX";
pub const __USER_LABEL_PREFIX__ = @"_";
pub const __FINITE_MATH_ONLY__ = @as(c_int, 0);
pub const __GNUC_STDC_INLINE__ = @as(c_int, 1);
pub const __GCC_ATOMIC_TEST_AND_SET_TRUEVAL = @as(c_int, 1);
pub const __CLANG_ATOMIC_BOOL_LOCK_FREE = @as(c_int, 2);
pub const __CLANG_ATOMIC_CHAR_LOCK_FREE = @as(c_int, 2);
pub const __CLANG_ATOMIC_CHAR16_T_LOCK_FREE = @as(c_int, 2);
pub const __CLANG_ATOMIC_CHAR32_T_LOCK_FREE = @as(c_int, 2);
pub const __CLANG_ATOMIC_WCHAR_T_LOCK_FREE = @as(c_int, 2);
pub const __CLANG_ATOMIC_SHORT_LOCK_FREE = @as(c_int, 2);
pub const __CLANG_ATOMIC_INT_LOCK_FREE = @as(c_int, 2);
pub const __CLANG_ATOMIC_LONG_LOCK_FREE = @as(c_int, 2);
pub const __CLANG_ATOMIC_LLONG_LOCK_FREE = @as(c_int, 2);
pub const __CLANG_ATOMIC_POINTER_LOCK_FREE = @as(c_int, 2);
pub const __GCC_ATOMIC_BOOL_LOCK_FREE = @as(c_int, 2);
pub const __GCC_ATOMIC_CHAR_LOCK_FREE = @as(c_int, 2);
pub const __GCC_ATOMIC_CHAR16_T_LOCK_FREE = @as(c_int, 2);
pub const __GCC_ATOMIC_CHAR32_T_LOCK_FREE = @as(c_int, 2);
pub const __GCC_ATOMIC_WCHAR_T_LOCK_FREE = @as(c_int, 2);
pub const __GCC_ATOMIC_SHORT_LOCK_FREE = @as(c_int, 2);
pub const __GCC_ATOMIC_INT_LOCK_FREE = @as(c_int, 2);
pub const __GCC_ATOMIC_LONG_LOCK_FREE = @as(c_int, 2);
pub const __GCC_ATOMIC_LLONG_LOCK_FREE = @as(c_int, 2);
pub const __GCC_ATOMIC_POINTER_LOCK_FREE = @as(c_int, 2);
pub const __PIC__ = @as(c_int, 2);
pub const __pic__ = @as(c_int, 2);
pub const __FLT_EVAL_METHOD__ = @as(c_int, 0);
pub const __FLT_RADIX__ = @as(c_int, 2);
pub const __DECIMAL_DIG__ = __LDBL_DECIMAL_DIG__;
pub const __SSP_STRONG__ = @as(c_int, 2);
pub const __nonnull = _Nonnull;
pub const __null_unspecified = _Null_unspecified;
pub const __nullable = _Nullable;
pub const __GCC_ASM_FLAG_OUTPUTS__ = @as(c_int, 1);
pub const __code_model_small__ = @as(c_int, 1);
pub const __amd64__ = @as(c_int, 1);
pub const __amd64 = @as(c_int, 1);
pub const __x86_64 = @as(c_int, 1);
pub const __x86_64__ = @as(c_int, 1);
pub const __SEG_GS = @as(c_int, 1);
pub const __SEG_FS = @as(c_int, 1);
pub const __seg_gs = __attribute__(address_space(@as(c_int, 256)));
pub const __seg_fs = __attribute__(address_space(@as(c_int, 257)));
pub const __corei7 = @as(c_int, 1);
pub const __corei7__ = @as(c_int, 1);
pub const __tune_corei7__ = @as(c_int, 1);
pub const __NO_MATH_INLINES = @as(c_int, 1);
pub const __AES__ = @as(c_int, 1);
pub const __PCLMUL__ = @as(c_int, 1);
pub const __LAHF_SAHF__ = @as(c_int, 1);
pub const __LZCNT__ = @as(c_int, 1);
pub const __RDRND__ = @as(c_int, 1);
pub const __FSGSBASE__ = @as(c_int, 1);
pub const __BMI__ = @as(c_int, 1);
pub const __BMI2__ = @as(c_int, 1);
pub const __POPCNT__ = @as(c_int, 1);
pub const __RTM__ = @as(c_int, 1);
pub const __PRFCHW__ = @as(c_int, 1);
pub const __RDSEED__ = @as(c_int, 1);
pub const __ADX__ = @as(c_int, 1);
pub const __MOVBE__ = @as(c_int, 1);
pub const __FMA__ = @as(c_int, 1);
pub const __F16C__ = @as(c_int, 1);
pub const __FXSR__ = @as(c_int, 1);
pub const __XSAVE__ = @as(c_int, 1);
pub const __XSAVEOPT__ = @as(c_int, 1);
pub const __XSAVEC__ = @as(c_int, 1);
pub const __XSAVES__ = @as(c_int, 1);
pub const __CLFLUSHOPT__ = @as(c_int, 1);
pub const __SGX__ = @as(c_int, 1);
pub const __INVPCID__ = @as(c_int, 1);
pub const __AVX2__ = @as(c_int, 1);
pub const __AVX__ = @as(c_int, 1);
pub const __SSE4_2__ = @as(c_int, 1);
pub const __SSE4_1__ = @as(c_int, 1);
pub const __SSSE3__ = @as(c_int, 1);
pub const __SSE3__ = @as(c_int, 1);
pub const __SSE2__ = @as(c_int, 1);
pub const __SSE2_MATH__ = @as(c_int, 1);
pub const __SSE__ = @as(c_int, 1);
pub const __SSE_MATH__ = @as(c_int, 1);
pub const __MMX__ = @as(c_int, 1);
pub const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 = @as(c_int, 1);
pub const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 = @as(c_int, 1);
pub const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 = @as(c_int, 1);
pub const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 = @as(c_int, 1);
pub const __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 = @as(c_int, 1);
pub const __APPLE_CC__ = @as(c_int, 6000);
pub const __APPLE__ = @as(c_int, 1);
pub const __STDC_NO_THREADS__ = @as(c_int, 1);
pub const __weak = __attribute__(objc_gc(weak));
pub const __DYNAMIC__ = @as(c_int, 1);
pub const __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101406, .decimal);
pub const __MACH__ = @as(c_int, 1);
pub const __STDC__ = @as(c_int, 1);
pub const __STDC_HOSTED__ = @as(c_int, 1);
pub const __STDC_VERSION__ = @as(c_long, 201710);
pub const __STDC_UTF_16__ = @as(c_int, 1);
pub const __STDC_UTF_32__ = @as(c_int, 1);
pub const _DEBUG = @as(c_int, 1);
pub const FT_AUTOHINTER_H = FT_DRIVER_H;
pub const FT_CFF_DRIVER_H = FT_DRIVER_H;
pub const FT_TRUETYPE_DRIVER_H = FT_DRIVER_H;
pub const FT_PCF_DRIVER_H = FT_DRIVER_H;
pub const FT_XFREE86_H = FT_FONT_FORMATS_H;
pub const FT_CACHE_IMAGE_H = FT_CACHE_H;
pub const FT_CACHE_SMALL_BITMAPS_H = FT_CACHE_H;
pub const FT_CACHE_CHARMAP_H = FT_CACHE_H;
pub const FT_CACHE_MANAGER_H = FT_CACHE_H;
pub const FT_CACHE_INTERNAL_MRU_H = FT_CACHE_H;
pub const FT_CACHE_INTERNAL_MANAGER_H = FT_CACHE_H;
pub const FT_CACHE_INTERNAL_CACHE_H = FT_CACHE_H;
pub const FT_CACHE_INTERNAL_GLYPH_H = FT_CACHE_H;
pub const FT_CACHE_INTERNAL_IMAGE_H = FT_CACHE_H;
pub const FT_CACHE_INTERNAL_SBITS_H = FT_CACHE_H;
pub const FT_RENDER_POOL_SIZE = @as(c_long, 16384);
pub const FT_MAX_MODULES = @as(c_int, 32);
pub const TT_CONFIG_OPTION_SUBPIXEL_HINTING = @as(c_int, 2);
pub const TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES = @as(c_long, 1000000);
pub const T1_MAX_DICT_DEPTH = @as(c_int, 5);
pub const T1_MAX_SUBRS_CALLS = @as(c_int, 16);
pub const T1_MAX_CHARSTRINGS_OPERANDS = @as(c_int, 256);
pub const CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1 = @as(c_int, 500);
pub const CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1 = @as(c_int, 400);
pub const CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 = @as(c_int, 1000);
pub const CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2 = @as(c_int, 275);
pub const CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 = @as(c_int, 1667);
pub const CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3 = @as(c_int, 275);
pub const CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4 = @as(c_int, 2333);
pub const CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4 = @as(c_int, 0);
pub const NULL = @import("std").zig.c_translation.cast(?*c_void, @as(c_int, 0));
pub const ft_ptrdiff_t = ptrdiff_t;
pub inline fn __P(protos: anytype) @TypeOf(protos) {
return protos;
}
pub const __signed = c_int;
pub const __dead2 = __attribute__(__noreturn__);
pub const __pure2 = __attribute__(__const__);
pub const __unused = __attribute__(__unused__);
pub const __used = __attribute__(__used__);
pub const __cold = __attribute__(__cold__);
pub const __deprecated = __attribute__(__deprecated__);
pub inline fn __deprecated_msg(_msg: anytype) @TypeOf(__attribute__(__deprecated__(_msg))) {
return __attribute__(__deprecated__(_msg));
}
pub inline fn __deprecated_enum_msg(_msg: anytype) @TypeOf(__deprecated_msg(_msg)) {
return __deprecated_msg(_msg);
}
pub const __unavailable = __attribute__(__unavailable__);
pub const __disable_tail_calls = __attribute__(__disable_tail_calls__);
pub const __not_tail_called = __attribute__(__not_tail_called__);
pub const __result_use_check = __attribute__(__warn_unused_result__);
pub const __abortlike = __dead2 ++ __cold ++ __not_tail_called;
pub const __header_always_inline = __header_inline ++ __attribute__(__always_inline__);
pub const __unreachable_ok_pop = _Pragma("clang diagnostic pop");
pub inline fn __printflike(fmtarg: anytype, firstvararg: anytype) @TypeOf(__attribute__(__format__(__printf__, fmtarg, firstvararg))) {
return __attribute__(__format__(__printf__, fmtarg, firstvararg));
}
pub inline fn __printf0like(fmtarg: anytype, firstvararg: anytype) @TypeOf(__attribute__(__format__(__printf0__, fmtarg, firstvararg))) {
return __attribute__(__format__(__printf0__, fmtarg, firstvararg));
}
pub inline fn __scanflike(fmtarg: anytype, firstvararg: anytype) @TypeOf(__attribute__(__format__(__scanf__, fmtarg, firstvararg))) {
return __attribute__(__format__(__scanf__, fmtarg, firstvararg));
}
pub inline fn __COPYRIGHT(s: anytype) @TypeOf(__IDSTRING(copyright, s)) {
return __IDSTRING(copyright, s);
}
pub inline fn __RCSID(s: anytype) @TypeOf(__IDSTRING(rcsid, s)) {
return __IDSTRING(rcsid, s);
}
pub inline fn __SCCSID(s: anytype) @TypeOf(__IDSTRING(sccsid, s)) {
return __IDSTRING(sccsid, s);
}
pub inline fn __PROJECT_VERSION(s: anytype) @TypeOf(__IDSTRING(project_version, s)) {
return __IDSTRING(project_version, s);
}
pub const __DARWIN_ONLY_64_BIT_INO_T = @as(c_int, 0);
pub const __DARWIN_ONLY_VERS_1050 = @as(c_int, 0);
pub const __DARWIN_ONLY_UNIX_CONFORMANCE = @as(c_int, 1);
pub const __DARWIN_UNIX03 = @as(c_int, 1);
pub const __DARWIN_64_BIT_INO_T = @as(c_int, 1);
pub const __DARWIN_VERS_1050 = @as(c_int, 1);
pub const __DARWIN_NON_CANCELABLE = @as(c_int, 0);
pub const __DARWIN_SUF_64_BIT_INO_T = "$INODE64";
pub const __DARWIN_SUF_1050 = "$1050";
pub const __DARWIN_SUF_EXTSN = "$DARWIN_EXTSN";
pub inline fn __DARWIN_ALIAS_STARTING_MAC___MAC_10_0(x: anytype) @TypeOf(x) {
return x;
}
pub inline fn __DARWIN_ALIAS_STARTING_MAC___MAC_10_1(x: anytype) @TypeOf(x) {
return x;
}
pub inline fn __DARWIN_ALIAS_STARTING_MAC___MAC_10_2(x: anytype) @TypeOf(x) {
return x;
}
pub inline fn __DARWIN_ALIAS_STARTING_MAC___MAC_10_3(x: anytype) @TypeOf(x) {
return x;
}
pub inline fn __DARWIN_ALIAS_STARTING_MAC___MAC_10_4(x: anytype) @TypeOf(x) {
return x;
}
pub inline fn __DARWIN_ALIAS_STARTING_MAC___MAC_10_5(x: anytype) @TypeOf(x) {
return x;
}
pub inline fn __DARWIN_ALIAS_STARTING_MAC___MAC_10_6(x: anytype) @TypeOf(x) {
return x;
}
pub inline fn __DARWIN_ALIAS_STARTING_MAC___MAC_10_7(x: anytype) @TypeOf(x) {
return x;
}
pub inline fn __DARWIN_ALIAS_STARTING_MAC___MAC_10_8(x: anytype) @TypeOf(x) {
return x;
}
pub inline fn __DARWIN_ALIAS_STARTING_MAC___MAC_10_9(x: anytype) @TypeOf(x) {
return x;
}
pub inline fn __DARWIN_ALIAS_STARTING_MAC___MAC_10_10(x: anytype) @TypeOf(x) {
return x;
}
pub inline fn __DARWIN_ALIAS_STARTING_MAC___MAC_10_10_2(x: anytype) @TypeOf(x) {
return x;
}
pub inline fn __DARWIN_ALIAS_STARTING_MAC___MAC_10_10_3(x: anytype) @TypeOf(x) {
return x;
}
pub inline fn __DARWIN_ALIAS_STARTING_MAC___MAC_10_11(x: anytype) @TypeOf(x) {
return x;
}
pub inline fn __DARWIN_ALIAS_STARTING_MAC___MAC_10_11_2(x: anytype) @TypeOf(x) {
return x;
}
pub inline fn __DARWIN_ALIAS_STARTING_MAC___MAC_10_11_3(x: anytype) @TypeOf(x) {
return x;
}
pub inline fn __DARWIN_ALIAS_STARTING_MAC___MAC_10_11_4(x: anytype) @TypeOf(x) {
return x;
}
pub inline fn __DARWIN_ALIAS_STARTING_MAC___MAC_10_12(x: anytype) @TypeOf(x) {
return x;
}
pub inline fn __DARWIN_ALIAS_STARTING_MAC___MAC_10_12_1(x: anytype) @TypeOf(x) {
return x;
}
pub inline fn __DARWIN_ALIAS_STARTING_MAC___MAC_10_12_2(x: anytype) @TypeOf(x) {
return x;
}
pub inline fn __DARWIN_ALIAS_STARTING_MAC___MAC_10_12_4(x: anytype) @TypeOf(x) {
return x;
}
pub inline fn __DARWIN_ALIAS_STARTING_MAC___MAC_10_13(x: anytype) @TypeOf(x) {
return x;
}
pub inline fn __DARWIN_ALIAS_STARTING_MAC___MAC_10_13_1(x: anytype) @TypeOf(x) {
return x;
}
pub inline fn __DARWIN_ALIAS_STARTING_MAC___MAC_10_13_2(x: anytype) @TypeOf(x) {
return x;
}
pub inline fn __DARWIN_ALIAS_STARTING_MAC___MAC_10_13_4(x: anytype) @TypeOf(x) {
return x;
}
pub inline fn __DARWIN_ALIAS_STARTING_MAC___MAC_10_14(x: anytype) @TypeOf(x) {
return x;
}
pub inline fn __DARWIN_ALIAS_STARTING_MAC___MAC_10_14_1(x: anytype) @TypeOf(x) {
return x;
}
pub inline fn __DARWIN_ALIAS_STARTING_MAC___MAC_10_14_4(x: anytype) @TypeOf(x) {
return x;
}
pub inline fn __DARWIN_ALIAS_STARTING_MAC___MAC_10_14_5(x: anytype) @TypeOf(x) {
return x;
}
pub inline fn __DARWIN_ALIAS_STARTING_MAC___MAC_10_14_6(x: anytype) @TypeOf(x) {
return x;
}
pub const __DARWIN_C_ANSI = @as(c_long, 0o10000);
pub const __DARWIN_C_FULL = @as(c_long, 900000);
pub const __DARWIN_C_LEVEL = __DARWIN_C_FULL;
pub const __STDC_WANT_LIB_EXT1__ = @as(c_int, 1);
pub const __DARWIN_NO_LONG_LONG = @as(c_int, 0);
pub const _DARWIN_FEATURE_64_BIT_INODE = @as(c_int, 1);
pub const _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = @as(c_int, 1);
pub const _DARWIN_FEATURE_UNIX_CONFORMANCE = @as(c_int, 3);
pub inline fn __CAST_AWAY_QUALIFIER(variable: anytype, qualifier: anytype, type_1: anytype) @TypeOf(type_1(c_long)(variable)) {
_ = qualifier;
return type_1(c_long)(variable);
}
pub const __XNU_PRIVATE_EXTERN = __attribute__(visibility("hidden"));
pub const __enum_open = __attribute__(__enum_extensibility__(open));
pub const __enum_closed = __attribute__(__enum_extensibility__(closed));
pub const __enum_options = __attribute__(__flag_enum__);
pub const __DARWIN_CLK_TCK = @as(c_int, 100);
pub const CHAR_BIT = @as(c_int, 8);
pub const MB_LEN_MAX = @as(c_int, 6);
pub const CLK_TCK = __DARWIN_CLK_TCK;
pub const SCHAR_MAX = @as(c_int, 127);
pub const SCHAR_MIN = -@as(c_int, 128);
pub const UCHAR_MAX = @as(c_int, 255);
pub const CHAR_MAX = @as(c_int, 127);
pub const CHAR_MIN = -@as(c_int, 128);
pub const USHRT_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_int, 65535, .decimal);
pub const SHRT_MAX = @as(c_int, 32767);
pub const SHRT_MIN = -@import("std").zig.c_translation.promoteIntLiteral(c_int, 32768, .decimal);
pub const UINT_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0xffffffff, .hexadecimal);
pub const INT_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal);
pub const INT_MIN = -@import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal) - @as(c_int, 1);
pub const ULONG_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_ulong, 0xffffffffffffffff, .hexadecimal);
pub const LONG_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_long, 0x7fffffffffffffff, .hexadecimal);
pub const LONG_MIN = -@import("std").zig.c_translation.promoteIntLiteral(c_long, 0x7fffffffffffffff, .hexadecimal) - @as(c_int, 1);
pub const ULLONG_MAX = @as(c_ulonglong, 0xffffffffffffffff);
pub const LLONG_MAX = @as(c_longlong, 0x7fffffffffffffff);
pub const LLONG_MIN = -@as(c_longlong, 0x7fffffffffffffff) - @as(c_int, 1);
pub const LONG_BIT = @as(c_int, 64);
pub const SSIZE_MAX = LONG_MAX;
pub const WORD_BIT = @as(c_int, 32);
pub const SIZE_T_MAX = ULONG_MAX;
pub const UQUAD_MAX = ULLONG_MAX;
pub const QUAD_MAX = LLONG_MAX;
pub const QUAD_MIN = LLONG_MIN;
pub const ARG_MAX = @as(c_int, 256) * @as(c_int, 1024);
pub const CHILD_MAX = @as(c_int, 266);
pub const GID_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_uint, 2147483647, .decimal);
pub const LINK_MAX = @as(c_int, 32767);
pub const MAX_CANON = @as(c_int, 1024);
pub const MAX_INPUT = @as(c_int, 1024);
pub const NAME_MAX = @as(c_int, 255);
pub const NGROUPS_MAX = @as(c_int, 16);
pub const UID_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_uint, 2147483647, .decimal);
pub const OPEN_MAX = @as(c_int, 10240);
pub const PATH_MAX = @as(c_int, 1024);
pub const PIPE_BUF = @as(c_int, 512);
pub const BC_BASE_MAX = @as(c_int, 99);
pub const BC_DIM_MAX = @as(c_int, 2048);
pub const BC_SCALE_MAX = @as(c_int, 99);
pub const BC_STRING_MAX = @as(c_int, 1000);
pub const CHARCLASS_NAME_MAX = @as(c_int, 14);
pub const COLL_WEIGHTS_MAX = @as(c_int, 2);
pub const EQUIV_CLASS_MAX = @as(c_int, 2);
pub const EXPR_NEST_MAX = @as(c_int, 32);
pub const LINE_MAX = @as(c_int, 2048);
pub const RE_DUP_MAX = @as(c_int, 255);
pub const NZERO = @as(c_int, 20);
pub const _POSIX_ARG_MAX = @as(c_int, 4096);
pub const _POSIX_CHILD_MAX = @as(c_int, 25);
pub const _POSIX_LINK_MAX = @as(c_int, 8);
pub const _POSIX_MAX_CANON = @as(c_int, 255);
pub const _POSIX_MAX_INPUT = @as(c_int, 255);
pub const _POSIX_NAME_MAX = @as(c_int, 14);
pub const _POSIX_NGROUPS_MAX = @as(c_int, 8);
pub const _POSIX_OPEN_MAX = @as(c_int, 20);
pub const _POSIX_PATH_MAX = @as(c_int, 256);
pub const _POSIX_PIPE_BUF = @as(c_int, 512);
pub const _POSIX_SSIZE_MAX = @as(c_int, 32767);
pub const _POSIX_STREAM_MAX = @as(c_int, 8);
pub const _POSIX_TZNAME_MAX = @as(c_int, 6);
pub const _POSIX2_BC_BASE_MAX = @as(c_int, 99);
pub const _POSIX2_BC_DIM_MAX = @as(c_int, 2048);
pub const _POSIX2_BC_SCALE_MAX = @as(c_int, 99);
pub const _POSIX2_BC_STRING_MAX = @as(c_int, 1000);
pub const _POSIX2_EQUIV_CLASS_MAX = @as(c_int, 2);
pub const _POSIX2_EXPR_NEST_MAX = @as(c_int, 32);
pub const _POSIX2_LINE_MAX = @as(c_int, 2048);
pub const _POSIX2_RE_DUP_MAX = @as(c_int, 255);
pub const _POSIX_AIO_LISTIO_MAX = @as(c_int, 2);
pub const _POSIX_AIO_MAX = @as(c_int, 1);
pub const _POSIX_DELAYTIMER_MAX = @as(c_int, 32);
pub const _POSIX_MQ_OPEN_MAX = @as(c_int, 8);
pub const _POSIX_MQ_PRIO_MAX = @as(c_int, 32);
pub const _POSIX_RTSIG_MAX = @as(c_int, 8);
pub const _POSIX_SEM_NSEMS_MAX = @as(c_int, 256);
pub const _POSIX_SEM_VALUE_MAX = @as(c_int, 32767);
pub const _POSIX_SIGQUEUE_MAX = @as(c_int, 32);
pub const _POSIX_TIMER_MAX = @as(c_int, 32);
pub const _POSIX_CLOCKRES_MIN = @import("std").zig.c_translation.promoteIntLiteral(c_int, 20000000, .decimal);
pub const _POSIX_THREAD_DESTRUCTOR_ITERATIONS = @as(c_int, 4);
pub const _POSIX_THREAD_KEYS_MAX = @as(c_int, 128);
pub const _POSIX_THREAD_THREADS_MAX = @as(c_int, 64);
pub const PTHREAD_DESTRUCTOR_ITERATIONS = @as(c_int, 4);
pub const PTHREAD_KEYS_MAX = @as(c_int, 512);
pub const PTHREAD_STACK_MIN = @as(c_int, 8192);
pub const _POSIX_HOST_NAME_MAX = @as(c_int, 255);
pub const _POSIX_LOGIN_NAME_MAX = @as(c_int, 9);
pub const _POSIX_SS_REPL_MAX = @as(c_int, 4);
pub const _POSIX_SYMLINK_MAX = @as(c_int, 255);
pub const _POSIX_SYMLOOP_MAX = @as(c_int, 8);
pub const _POSIX_TRACE_EVENT_NAME_MAX = @as(c_int, 30);
pub const _POSIX_TRACE_NAME_MAX = @as(c_int, 8);
pub const _POSIX_TRACE_SYS_MAX = @as(c_int, 8);
pub const _POSIX_TRACE_USER_EVENT_MAX = @as(c_int, 32);
pub const _POSIX_TTY_NAME_MAX = @as(c_int, 9);
pub const _POSIX2_CHARCLASS_NAME_MAX = @as(c_int, 14);
pub const _POSIX2_COLL_WEIGHTS_MAX = @as(c_int, 2);
pub const _POSIX_RE_DUP_MAX = _POSIX2_RE_DUP_MAX;
pub const OFF_MIN = LLONG_MIN;
pub const OFF_MAX = LLONG_MAX;
pub const PASS_MAX = @as(c_int, 128);
pub const NL_ARGMAX = @as(c_int, 9);
pub const NL_LANGMAX = @as(c_int, 14);
pub const NL_MSGMAX = @as(c_int, 32767);
pub const NL_NMAX = @as(c_int, 1);
pub const NL_SETMAX = @as(c_int, 255);
pub const NL_TEXTMAX = @as(c_int, 2048);
pub const _XOPEN_IOV_MAX = @as(c_int, 16);
pub const IOV_MAX = @as(c_int, 1024);
pub const _XOPEN_NAME_MAX = @as(c_int, 255);
pub const _XOPEN_PATH_MAX = @as(c_int, 1024);
pub const LONG_LONG_MAX = __LONG_LONG_MAX__;
pub const LONG_LONG_MIN = -__LONG_LONG_MAX__ - @as(c_longlong, 1);
pub const ULONG_LONG_MAX = (__LONG_LONG_MAX__ * @as(c_ulonglong, 2)) + @as(c_ulonglong, 1);
pub const FT_CHAR_BIT = CHAR_BIT;
pub const FT_USHORT_MAX = USHRT_MAX;
pub const FT_INT_MAX = INT_MAX;
pub const FT_INT_MIN = INT_MIN;
pub const FT_UINT_MAX = UINT_MAX;
pub const FT_LONG_MIN = LONG_MIN;
pub const FT_LONG_MAX = LONG_MAX;
pub const FT_ULONG_MAX = ULONG_MAX;
pub const __DARWIN_NULL = @import("std").zig.c_translation.cast(?*c_void, @as(c_int, 0));
pub const __PTHREAD_SIZE__ = @as(c_int, 8176);
pub const __PTHREAD_ATTR_SIZE__ = @as(c_int, 56);
pub const __PTHREAD_MUTEXATTR_SIZE__ = @as(c_int, 8);
pub const __PTHREAD_MUTEX_SIZE__ = @as(c_int, 56);
pub const __PTHREAD_CONDATTR_SIZE__ = @as(c_int, 8);
pub const __PTHREAD_COND_SIZE__ = @as(c_int, 40);
pub const __PTHREAD_ONCE_SIZE__ = @as(c_int, 8);
pub const __PTHREAD_RWLOCK_SIZE__ = @as(c_int, 192);
pub const __PTHREAD_RWLOCKATTR_SIZE__ = @as(c_int, 16);
pub inline fn __strfmonlike(fmtarg: anytype, firstvararg: anytype) @TypeOf(__attribute__(__format__(__strfmon__, fmtarg, firstvararg))) {
return __attribute__(__format__(__strfmon__, fmtarg, firstvararg));
}
pub inline fn __strftimelike(fmtarg: anytype) @TypeOf(__attribute__(__format__(__strftime__, fmtarg, @as(c_int, 0)))) {
return __attribute__(__format__(__strftime__, fmtarg, @as(c_int, 0)));
}
pub const __DARWIN_WCHAR_MAX = __WCHAR_MAX__;
pub const __DARWIN_WCHAR_MIN = -@import("std").zig.c_translation.promoteIntLiteral(c_int, 0x7fffffff, .hexadecimal) - @as(c_int, 1);
pub const __DARWIN_WEOF = @import("std").zig.c_translation.cast(__darwin_wint_t, -@as(c_int, 1));
pub const _FORTIFY_SOURCE = @as(c_int, 2);
pub const __API_TO_BE_DEPRECATED = @import("std").zig.c_translation.promoteIntLiteral(c_int, 100000, .decimal);
pub const __MAC_10_0 = @as(c_int, 1000);
pub const __MAC_10_1 = @as(c_int, 1010);
pub const __MAC_10_2 = @as(c_int, 1020);
pub const __MAC_10_3 = @as(c_int, 1030);
pub const __MAC_10_4 = @as(c_int, 1040);
pub const __MAC_10_5 = @as(c_int, 1050);
pub const __MAC_10_6 = @as(c_int, 1060);
pub const __MAC_10_7 = @as(c_int, 1070);
pub const __MAC_10_8 = @as(c_int, 1080);
pub const __MAC_10_9 = @as(c_int, 1090);
pub const __MAC_10_10 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101000, .decimal);
pub const __MAC_10_10_2 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101002, .decimal);
pub const __MAC_10_10_3 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101003, .decimal);
pub const __MAC_10_11 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101100, .decimal);
pub const __MAC_10_11_2 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101102, .decimal);
pub const __MAC_10_11_3 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101103, .decimal);
pub const __MAC_10_11_4 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101104, .decimal);
pub const __MAC_10_12 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101200, .decimal);
pub const __MAC_10_12_1 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101201, .decimal);
pub const __MAC_10_12_2 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101202, .decimal);
pub const __MAC_10_12_4 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101204, .decimal);
pub const __MAC_10_13 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101300, .decimal);
pub const __MAC_10_13_1 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101301, .decimal);
pub const __MAC_10_13_2 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101302, .decimal);
pub const __MAC_10_13_4 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101304, .decimal);
pub const __MAC_10_14 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101400, .decimal);
pub const __MAC_10_14_1 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101401, .decimal);
pub const __MAC_10_14_4 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101404, .decimal);
pub const __MAC_10_15 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101500, .decimal);
pub const __MAC_10_15_1 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101501, .decimal);
pub const __MAC_10_15_4 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101504, .decimal);
pub const __IPHONE_2_0 = @as(c_int, 20000);
pub const __IPHONE_2_1 = @as(c_int, 20100);
pub const __IPHONE_2_2 = @as(c_int, 20200);
pub const __IPHONE_3_0 = @as(c_int, 30000);
pub const __IPHONE_3_1 = @as(c_int, 30100);
pub const __IPHONE_3_2 = @as(c_int, 30200);
pub const __IPHONE_4_0 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 40000, .decimal);
pub const __IPHONE_4_1 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 40100, .decimal);
pub const __IPHONE_4_2 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 40200, .decimal);
pub const __IPHONE_4_3 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 40300, .decimal);
pub const __IPHONE_5_0 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 50000, .decimal);
pub const __IPHONE_5_1 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 50100, .decimal);
pub const __IPHONE_6_0 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 60000, .decimal);
pub const __IPHONE_6_1 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 60100, .decimal);
pub const __IPHONE_7_0 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 70000, .decimal);
pub const __IPHONE_7_1 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 70100, .decimal);
pub const __IPHONE_8_0 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 80000, .decimal);
pub const __IPHONE_8_1 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 80100, .decimal);
pub const __IPHONE_8_2 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 80200, .decimal);
pub const __IPHONE_8_3 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 80300, .decimal);
pub const __IPHONE_8_4 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 80400, .decimal);
pub const __IPHONE_9_0 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 90000, .decimal);
pub const __IPHONE_9_1 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 90100, .decimal);
pub const __IPHONE_9_2 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 90200, .decimal);
pub const __IPHONE_9_3 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 90300, .decimal);
pub const __IPHONE_10_0 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 100000, .decimal);
pub const __IPHONE_10_1 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 100100, .decimal);
pub const __IPHONE_10_2 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 100200, .decimal);
pub const __IPHONE_10_3 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 100300, .decimal);
pub const __IPHONE_11_0 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 110000, .decimal);
pub const __IPHONE_11_1 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 110100, .decimal);
pub const __IPHONE_11_2 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 110200, .decimal);
pub const __IPHONE_11_3 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 110300, .decimal);
pub const __IPHONE_11_4 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 110400, .decimal);
pub const __IPHONE_12_0 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 120000, .decimal);
pub const __IPHONE_12_1 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 120100, .decimal);
pub const __IPHONE_12_2 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 120200, .decimal);
pub const __IPHONE_12_3 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 120300, .decimal);
pub const __IPHONE_13_0 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 130000, .decimal);
pub const __IPHONE_13_1 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 130100, .decimal);
pub const __IPHONE_13_2 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 130200, .decimal);
pub const __IPHONE_13_3 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 130300, .decimal);
pub const __IPHONE_13_4 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 130400, .decimal);
pub const __IPHONE_13_5 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 130500, .decimal);
pub const __IPHONE_13_6 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 130600, .decimal);
pub const __TVOS_9_0 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 90000, .decimal);
pub const __TVOS_9_1 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 90100, .decimal);
pub const __TVOS_9_2 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 90200, .decimal);
pub const __TVOS_10_0 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 100000, .decimal);
pub const __TVOS_10_0_1 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 100001, .decimal);
pub const __TVOS_10_1 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 100100, .decimal);
pub const __TVOS_10_2 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 100200, .decimal);
pub const __TVOS_11_0 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 110000, .decimal);
pub const __TVOS_11_1 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 110100, .decimal);
pub const __TVOS_11_2 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 110200, .decimal);
pub const __TVOS_11_3 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 110300, .decimal);
pub const __TVOS_11_4 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 110400, .decimal);
pub const __TVOS_12_0 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 120000, .decimal);
pub const __TVOS_12_1 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 120100, .decimal);
pub const __TVOS_12_2 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 120200, .decimal);
pub const __TVOS_12_3 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 120300, .decimal);
pub const __TVOS_13_0 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 130000, .decimal);
pub const __TVOS_13_2 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 130200, .decimal);
pub const __TVOS_13_3 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 130300, .decimal);
pub const __TVOS_13_4 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 130400, .decimal);
pub const __WATCHOS_1_0 = @as(c_int, 10000);
pub const __WATCHOS_2_0 = @as(c_int, 20000);
pub const __WATCHOS_2_1 = @as(c_int, 20100);
pub const __WATCHOS_2_2 = @as(c_int, 20200);
pub const __WATCHOS_3_0 = @as(c_int, 30000);
pub const __WATCHOS_3_1 = @as(c_int, 30100);
pub const __WATCHOS_3_1_1 = @as(c_int, 30101);
pub const __WATCHOS_3_2 = @as(c_int, 30200);
pub const __WATCHOS_4_0 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 40000, .decimal);
pub const __WATCHOS_4_1 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 40100, .decimal);
pub const __WATCHOS_4_2 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 40200, .decimal);
pub const __WATCHOS_4_3 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 40300, .decimal);
pub const __WATCHOS_5_0 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 50000, .decimal);
pub const __WATCHOS_5_1 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 50100, .decimal);
pub const __WATCHOS_5_2 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 50200, .decimal);
pub const __WATCHOS_6_0 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 60000, .decimal);
pub const __WATCHOS_6_1 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 60100, .decimal);
pub const __WATCHOS_6_2 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 60200, .decimal);
pub const __DRIVERKIT_19_0 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 190000, .decimal);
pub const __MAC_OS_X_VERSION_MIN_REQUIRED = __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__;
pub const __MAC_OS_X_VERSION_MAX_ALLOWED = __MAC_10_15;
pub const __AVAILABILITY_INTERNAL_DEPRECATED = __attribute__(deprecated);
pub inline fn __AVAILABILITY_INTERNAL_DEPRECATED_MSG(_msg: anytype) @TypeOf(__attribute__(deprecated(_msg))) {
return __attribute__(deprecated(_msg));
}
pub const __AVAILABILITY_INTERNAL_UNAVAILABLE = __attribute__(unavailable);
pub const __AVAILABILITY_INTERNAL_WEAK_IMPORT = __attribute__(weak_import);
pub const __ENABLE_LEGACY_MAC_AVAILABILITY = @as(c_int, 1);
pub const __AVAILABILITY_INTERNAL__MAC_NA = __attribute__(availability(macosx, unavailable));
pub const __AVAILABILITY_INTERNAL__MAC_NA_DEP__MAC_NA = __attribute__(availability(macosx, unavailable));
pub inline fn __AVAILABILITY_INTERNAL__MAC_NA_DEP__MAC_NA_MSG(_msg: anytype) @TypeOf(__attribute__(availability(macosx, unavailable))) {
_ = _msg;
return __attribute__(availability(macosx, unavailable));
}
pub const __AVAILABILITY_INTERNAL__IPHONE_NA = __attribute__(availability(ios, unavailable));
pub const __AVAILABILITY_INTERNAL__IPHONE_NA__IPHONE_NA = __attribute__(availability(ios, unavailable));
pub const __AVAILABILITY_INTERNAL__IPHONE_NA_DEP__IPHONE_NA = __attribute__(availability(ios, unavailable));
pub inline fn __AVAILABILITY_INTERNAL__IPHONE_NA_DEP__IPHONE_NA_MSG(_msg: anytype) @TypeOf(__attribute__(availability(ios, unavailable))) {
_ = _msg;
return __attribute__(availability(ios, unavailable));
}
pub const __AVAILABILITY_INTERNAL__IPHONE_COMPAT_VERSION = __attribute__(availability(ios, unavailable));
pub const __AVAILABILITY_INTERNAL__IPHONE_COMPAT_VERSION_DEP__IPHONE_COMPAT_VERSION = __attribute__(availability(ios, unavailable));
pub inline fn __AVAILABILITY_INTERNAL__IPHONE_COMPAT_VERSION_DEP__IPHONE_COMPAT_VERSION_MSG(_msg: anytype) @TypeOf(__attribute__(availability(ios, unavailable))) {
_ = _msg;
return __attribute__(availability(ios, unavailable));
}
pub inline fn __API_AVAILABLE1(x: anytype) @TypeOf(__API_A(x)) {
return __API_A(x);
}
pub inline fn __API_RANGE_STRINGIFY(x: anytype) @TypeOf(__API_RANGE_STRINGIFY2(x)) {
return __API_RANGE_STRINGIFY2(x);
}
pub inline fn __API_AVAILABLE_BEGIN1(a: anytype) @TypeOf(__API_A_BEGIN(a)) {
return __API_A_BEGIN(a);
}
pub inline fn __API_DEPRECATED_MSG2(msg: anytype, x: anytype) @TypeOf(__API_D(msg, x)) {
return __API_D(msg, x);
}
pub inline fn __API_DEPRECATED_BEGIN_MSG2(msg: anytype, a: anytype) @TypeOf(__API_D_BEGIN(msg, a)) {
return __API_D_BEGIN(msg, a);
}
pub inline fn __API_DEPRECATED_REP2(rep: anytype, x: anytype) @TypeOf(__API_R(rep, x)) {
return __API_R(rep, x);
}
pub inline fn __API_DEPRECATED_BEGIN_REP2(rep: anytype, a: anytype) @TypeOf(__API_R_BEGIN(rep, a)) {
return __API_R_BEGIN(rep, a);
}
pub const __API_UNAVAILABLE_PLATFORM_macos = blk: {
_ = macos;
break :blk unavailable;
};
pub const __API_UNAVAILABLE_PLATFORM_macosx = blk: {
_ = macosx;
break :blk unavailable;
};
pub const __API_UNAVAILABLE_PLATFORM_ios = blk: {
_ = ios;
break :blk unavailable;
};
pub const __API_UNAVAILABLE_PLATFORM_watchos = blk: {
_ = watchos;
break :blk unavailable;
};
pub const __API_UNAVAILABLE_PLATFORM_tvos = blk: {
_ = tvos;
break :blk unavailable;
};
pub const __API_UNAVAILABLE_PLATFORM_macCatalyst = blk: {
_ = macCatalyst;
break :blk unavailable;
};
pub inline fn __API_UNAVAILABLE_PLATFORM_uikitformac(x: anytype) @TypeOf(unavailable) {
_ = x;
return blk: {
_ = uikitformac;
break :blk unavailable;
};
}
pub const __API_UNAVAILABLE_PLATFORM_driverkit = blk: {
_ = driverkit;
break :blk unavailable;
};
pub inline fn __API_UNAVAILABLE1(x: anytype) @TypeOf(__API_U(x)) {
return __API_U(x);
}
pub inline fn __API_UNAVAILABLE_BEGIN1(a: anytype) @TypeOf(__API_U_BEGIN(a)) {
return __API_U_BEGIN(a);
}
pub inline fn __OS_AVAILABILITY(_target: anytype, _availability: anytype) @TypeOf(__attribute__(availability(_target, _availability))) {
return __attribute__(availability(_target, _availability));
}
pub inline fn __OSX_EXTENSION_UNAVAILABLE(_msg: anytype) @TypeOf(__OS_AVAILABILITY_MSG(macosx_app_extension, unavailable, _msg)) {
return __OS_AVAILABILITY_MSG(macosx_app_extension, unavailable, _msg);
}
pub inline fn __IOS_EXTENSION_UNAVAILABLE(_msg: anytype) @TypeOf(__OS_AVAILABILITY_MSG(ios_app_extension, unavailable, _msg)) {
return __OS_AVAILABILITY_MSG(ios_app_extension, unavailable, _msg);
}
pub const __OSX_UNAVAILABLE = __OS_AVAILABILITY(macosx, unavailable);
pub const __IOS_UNAVAILABLE = __OS_AVAILABILITY(ios, unavailable);
pub const __IOS_PROHIBITED = __OS_AVAILABILITY(ios, unavailable);
pub const __TVOS_UNAVAILABLE = __OS_AVAILABILITY(tvos, unavailable);
pub const __TVOS_PROHIBITED = __OS_AVAILABILITY(tvos, unavailable);
pub const __WATCHOS_UNAVAILABLE = __OS_AVAILABILITY(watchos, unavailable);
pub const __WATCHOS_PROHIBITED = __OS_AVAILABILITY(watchos, unavailable);
pub const __SWIFT_UNAVAILABLE = __OS_AVAILABILITY(swift, unavailable);
pub inline fn __SWIFT_UNAVAILABLE_MSG(_msg: anytype) @TypeOf(__OS_AVAILABILITY_MSG(swift, unavailable, _msg)) {
return __OS_AVAILABILITY_MSG(swift, unavailable, _msg);
}
pub const __API_AVAILABLE_END = _Pragma("clang attribute pop");
pub const __API_DEPRECATED_END = _Pragma("clang attribute pop");
pub const __API_DEPRECATED_WITH_REPLACEMENT_END = _Pragma("clang attribute pop");
pub const __API_UNAVAILABLE_END = _Pragma("clang attribute pop");
pub const USER_ADDR_NULL = @import("std").zig.c_translation.cast(user_addr_t, @as(c_int, 0));
pub inline fn CAST_USER_ADDR_T(a_ptr: anytype) user_addr_t {
return @import("std").zig.c_translation.cast(user_addr_t, @import("std").zig.c_translation.cast(usize, a_ptr));
}
pub const _USE_FORTIFY_LEVEL = @as(c_int, 2);
pub inline fn __darwin_obsz0(object: anytype) @TypeOf(__builtin_object_size(object, @as(c_int, 0))) {
return __builtin_object_size(object, @as(c_int, 0));
}
pub inline fn __darwin_obsz(object: anytype) @TypeOf(__builtin_object_size(object, if (_USE_FORTIFY_LEVEL > @as(c_int, 1)) @as(c_int, 1) else @as(c_int, 0))) {
return __builtin_object_size(object, if (_USE_FORTIFY_LEVEL > @as(c_int, 1)) @as(c_int, 1) else @as(c_int, 0));
}
pub const __HAS_FIXED_CHK_PROTOTYPES = @as(c_int, 1);
pub const ft_memchr = memchr;
pub const ft_memcmp = memcmp;
pub const ft_memcpy = memcpy;
pub const ft_memmove = memmove;
pub const ft_memset = memset;
pub const ft_strcat = strcat;
pub const ft_strcmp = strcmp;
pub const ft_strcpy = strcpy;
pub const ft_strlen = strlen;
pub const ft_strncmp = strncmp;
pub const ft_strncpy = strncpy;
pub const ft_strrchr = strrchr;
pub const ft_strstr = strstr;
pub const RENAME_SECLUDE = @as(c_int, 0x00000001);
pub const RENAME_SWAP = @as(c_int, 0x00000002);
pub const RENAME_EXCL = @as(c_int, 0x00000004);
pub const __SLBF = @as(c_int, 0x0001);
pub const __SNBF = @as(c_int, 0x0002);
pub const __SRD = @as(c_int, 0x0004);
pub const __SWR = @as(c_int, 0x0008);
pub const __SRW = @as(c_int, 0x0010);
pub const __SEOF = @as(c_int, 0x0020);
pub const __SERR = @as(c_int, 0x0040);
pub const __SMBF = @as(c_int, 0x0080);
pub const __SAPP = @as(c_int, 0x0100);
pub const __SSTR = @as(c_int, 0x0200);
pub const __SOPT = @as(c_int, 0x0400);
pub const __SNPT = @as(c_int, 0x0800);
pub const __SOFF = @as(c_int, 0x1000);
pub const __SMOD = @as(c_int, 0x2000);
pub const __SALC = @as(c_int, 0x4000);
pub const __SIGN = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x8000, .hexadecimal);
pub const _IOFBF = @as(c_int, 0);
pub const _IOLBF = @as(c_int, 1);
pub const _IONBF = @as(c_int, 2);
pub const BUFSIZ = @as(c_int, 1024);
pub const EOF = -@as(c_int, 1);
pub const FOPEN_MAX = @as(c_int, 20);
pub const FILENAME_MAX = @as(c_int, 1024);
pub const P_tmpdir = "/var/tmp/";
pub const L_tmpnam = @as(c_int, 1024);
pub const TMP_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_int, 308915776, .decimal);
pub const SEEK_SET = @as(c_int, 0);
pub const SEEK_CUR = @as(c_int, 1);
pub const SEEK_END = @as(c_int, 2);
pub const stdin = __stdinp;
pub const stdout = __stdoutp;
pub const stderr = __stderrp;
pub const L_ctermid = @as(c_int, 1024);
pub inline fn __swift_unavailable_on(osx_msg: anytype, ios_msg: anytype) @TypeOf(__swift_unavailable(osx_msg)) {
_ = ios_msg;
return __swift_unavailable(osx_msg);
}
pub inline fn __sfeof(p: anytype) @TypeOf((p.*._flags & __SEOF) != @as(c_int, 0)) {
return (p.*._flags & __SEOF) != @as(c_int, 0);
}
pub inline fn __sferror(p: anytype) @TypeOf((p.*._flags & __SERR) != @as(c_int, 0)) {
return (p.*._flags & __SERR) != @as(c_int, 0);
}
pub inline fn __sfileno(p: anytype) @TypeOf(p.*._file) {
return p.*._file;
}
pub inline fn fropen(cookie: anytype, @"fn": anytype) @TypeOf(funopen(cookie, @"fn", @as(c_int, 0), @as(c_int, 0), @as(c_int, 0))) {
return funopen(cookie, @"fn", @as(c_int, 0), @as(c_int, 0), @as(c_int, 0));
}
pub inline fn fwopen(cookie: anytype, @"fn": anytype) @TypeOf(funopen(cookie, @as(c_int, 0), @"fn", @as(c_int, 0), @as(c_int, 0))) {
return funopen(cookie, @as(c_int, 0), @"fn", @as(c_int, 0), @as(c_int, 0));
}
pub inline fn feof_unlocked(p: anytype) @TypeOf(__sfeof(p)) {
return __sfeof(p);
}
pub inline fn ferror_unlocked(p: anytype) @TypeOf(__sferror(p)) {
return __sferror(p);
}
pub inline fn clearerr_unlocked(p: anytype) @TypeOf(__sclearerr(p)) {
return __sclearerr(p);
}
pub inline fn fileno_unlocked(p: anytype) @TypeOf(__sfileno(p)) {
return __sfileno(p);
}
pub const FT_FILE = FILE;
pub const ft_fclose = fclose;
pub const ft_fopen = fopen;
pub const ft_fread = fread;
pub const ft_fseek = fseek;
pub const ft_ftell = ftell;
pub const ft_sprintf = sprintf;
pub const __DARWIN_NSIG = @as(c_int, 32);
pub const NSIG = __DARWIN_NSIG;
pub const _I386_SIGNAL_H_ = @as(c_int, 1);
pub const SIGHUP = @as(c_int, 1);
pub const SIGINT = @as(c_int, 2);
pub const SIGQUIT = @as(c_int, 3);
pub const SIGILL = @as(c_int, 4);
pub const SIGTRAP = @as(c_int, 5);
pub const SIGABRT = @as(c_int, 6);
pub const SIGIOT = SIGABRT;
pub const SIGEMT = @as(c_int, 7);
pub const SIGFPE = @as(c_int, 8);
pub const SIGKILL = @as(c_int, 9);
pub const SIGBUS = @as(c_int, 10);
pub const SIGSEGV = @as(c_int, 11);
pub const SIGSYS = @as(c_int, 12);
pub const SIGPIPE = @as(c_int, 13);
pub const SIGALRM = @as(c_int, 14);
pub const SIGTERM = @as(c_int, 15);
pub const SIGURG = @as(c_int, 16);
pub const SIGSTOP = @as(c_int, 17);
pub const SIGTSTP = @as(c_int, 18);
pub const SIGCONT = @as(c_int, 19);
pub const SIGCHLD = @as(c_int, 20);
pub const SIGTTIN = @as(c_int, 21);
pub const SIGTTOU = @as(c_int, 22);
pub const SIGIO = @as(c_int, 23);
pub const SIGXCPU = @as(c_int, 24);
pub const SIGXFSZ = @as(c_int, 25);
pub const SIGVTALRM = @as(c_int, 26);
pub const SIGPROF = @as(c_int, 27);
pub const SIGWINCH = @as(c_int, 28);
pub const SIGINFO = @as(c_int, 29);
pub const SIGUSR1 = @as(c_int, 30);
pub const SIGUSR2 = @as(c_int, 31);
pub const _STRUCT_X86_THREAD_STATE32 = struct___darwin_i386_thread_state;
pub const _STRUCT_FP_CONTROL = struct___darwin_fp_control;
pub const FP_PREC_24B = @as(c_int, 0);
pub const FP_PREC_53B = @as(c_int, 2);
pub const FP_PREC_64B = @as(c_int, 3);
pub const FP_RND_NEAR = @as(c_int, 0);
pub const FP_RND_DOWN = @as(c_int, 1);
pub const FP_RND_UP = @as(c_int, 2);
pub const FP_CHOP = @as(c_int, 3);
pub const _STRUCT_FP_STATUS = struct___darwin_fp_status;
pub const _STRUCT_MMST_REG = struct___darwin_mmst_reg;
pub const _STRUCT_XMM_REG = struct___darwin_xmm_reg;
pub const _STRUCT_YMM_REG = struct___darwin_ymm_reg;
pub const _STRUCT_ZMM_REG = struct___darwin_zmm_reg;
pub const _STRUCT_OPMASK_REG = struct___darwin_opmask_reg;
pub const FP_STATE_BYTES = @as(c_int, 512);
pub const _STRUCT_X86_FLOAT_STATE32 = struct___darwin_i386_float_state;
pub const _STRUCT_X86_AVX_STATE32 = struct___darwin_i386_avx_state;
pub const _STRUCT_X86_AVX512_STATE32 = struct___darwin_i386_avx512_state;
pub const _STRUCT_X86_EXCEPTION_STATE32 = struct___darwin_i386_exception_state;
pub const _STRUCT_X86_DEBUG_STATE32 = struct___darwin_x86_debug_state32;
pub const _STRUCT_X86_PAGEIN_STATE = struct___x86_pagein_state;
pub const _STRUCT_X86_THREAD_STATE64 = struct___darwin_x86_thread_state64;
pub const _STRUCT_X86_THREAD_FULL_STATE64 = struct___darwin_x86_thread_full_state64;
pub const _STRUCT_X86_FLOAT_STATE64 = struct___darwin_x86_float_state64;
pub const _STRUCT_X86_AVX_STATE64 = struct___darwin_x86_avx_state64;
pub const _STRUCT_X86_AVX512_STATE64 = struct___darwin_x86_avx512_state64;
pub const _STRUCT_X86_EXCEPTION_STATE64 = struct___darwin_x86_exception_state64;
pub const _STRUCT_X86_DEBUG_STATE64 = struct___darwin_x86_debug_state64;
pub const _STRUCT_X86_CPMU_STATE64 = struct___darwin_x86_cpmu_state64;
pub const _STRUCT_MCONTEXT32 = struct___darwin_mcontext32;
pub const _STRUCT_MCONTEXT_AVX32 = struct___darwin_mcontext_avx32;
pub const _STRUCT_MCONTEXT_AVX512_32 = struct___darwin_mcontext_avx512_32;
pub const _STRUCT_MCONTEXT64 = struct___darwin_mcontext64;
pub const _STRUCT_MCONTEXT64_FULL = struct___darwin_mcontext64_full;
pub const _STRUCT_MCONTEXT_AVX64 = struct___darwin_mcontext_avx64;
pub const _STRUCT_MCONTEXT_AVX64_FULL = struct___darwin_mcontext_avx64_full;
pub const _STRUCT_MCONTEXT_AVX512_64 = struct___darwin_mcontext_avx512_64;
pub const _STRUCT_MCONTEXT_AVX512_64_FULL = struct___darwin_mcontext_avx512_64_full;
pub const _STRUCT_MCONTEXT = _STRUCT_MCONTEXT64;
pub const _STRUCT_SIGALTSTACK = struct___darwin_sigaltstack;
pub const _STRUCT_UCONTEXT = struct___darwin_ucontext;
pub const SIGEV_NONE = @as(c_int, 0);
pub const SIGEV_SIGNAL = @as(c_int, 1);
pub const SIGEV_THREAD = @as(c_int, 3);
pub const ILL_NOOP = @as(c_int, 0);
pub const ILL_ILLOPC = @as(c_int, 1);
pub const ILL_ILLTRP = @as(c_int, 2);
pub const ILL_PRVOPC = @as(c_int, 3);
pub const ILL_ILLOPN = @as(c_int, 4);
pub const ILL_ILLADR = @as(c_int, 5);
pub const ILL_PRVREG = @as(c_int, 6);
pub const ILL_COPROC = @as(c_int, 7);
pub const ILL_BADSTK = @as(c_int, 8);
pub const FPE_NOOP = @as(c_int, 0);
pub const FPE_FLTDIV = @as(c_int, 1);
pub const FPE_FLTOVF = @as(c_int, 2);
pub const FPE_FLTUND = @as(c_int, 3);
pub const FPE_FLTRES = @as(c_int, 4);
pub const FPE_FLTINV = @as(c_int, 5);
pub const FPE_FLTSUB = @as(c_int, 6);
pub const FPE_INTDIV = @as(c_int, 7);
pub const FPE_INTOVF = @as(c_int, 8);
pub const SEGV_NOOP = @as(c_int, 0);
pub const SEGV_MAPERR = @as(c_int, 1);
pub const SEGV_ACCERR = @as(c_int, 2);
pub const BUS_NOOP = @as(c_int, 0);
pub const BUS_ADRALN = @as(c_int, 1);
pub const BUS_ADRERR = @as(c_int, 2);
pub const BUS_OBJERR = @as(c_int, 3);
pub const TRAP_BRKPT = @as(c_int, 1);
pub const TRAP_TRACE = @as(c_int, 2);
pub const CLD_NOOP = @as(c_int, 0);
pub const CLD_EXITED = @as(c_int, 1);
pub const CLD_KILLED = @as(c_int, 2);
pub const CLD_DUMPED = @as(c_int, 3);
pub const CLD_TRAPPED = @as(c_int, 4);
pub const CLD_STOPPED = @as(c_int, 5);
pub const CLD_CONTINUED = @as(c_int, 6);
pub const POLL_IN = @as(c_int, 1);
pub const POLL_OUT = @as(c_int, 2);
pub const POLL_MSG = @as(c_int, 3);
pub const POLL_ERR = @as(c_int, 4);
pub const POLL_PRI = @as(c_int, 5);
pub const POLL_HUP = @as(c_int, 6);
pub const sa_handler = __sigaction_u.__sa_handler;
pub const sa_sigaction = __sigaction_u.__sa_sigaction;
pub const SA_ONSTACK = @as(c_int, 0x0001);
pub const SA_RESTART = @as(c_int, 0x0002);
pub const SA_RESETHAND = @as(c_int, 0x0004);
pub const SA_NOCLDSTOP = @as(c_int, 0x0008);
pub const SA_NODEFER = @as(c_int, 0x0010);
pub const SA_NOCLDWAIT = @as(c_int, 0x0020);
pub const SA_SIGINFO = @as(c_int, 0x0040);
pub const SA_USERTRAMP = @as(c_int, 0x0100);
pub const SA_64REGSET = @as(c_int, 0x0200);
pub const SA_USERSPACE_MASK = (((((SA_ONSTACK | SA_RESTART) | SA_RESETHAND) | SA_NOCLDSTOP) | SA_NODEFER) | SA_NOCLDWAIT) | SA_SIGINFO;
pub const SIG_BLOCK = @as(c_int, 1);
pub const SIG_UNBLOCK = @as(c_int, 2);
pub const SIG_SETMASK = @as(c_int, 3);
pub const SI_USER = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x10001, .hexadecimal);
pub const SI_QUEUE = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x10002, .hexadecimal);
pub const SI_TIMER = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x10003, .hexadecimal);
pub const SI_ASYNCIO = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x10004, .hexadecimal);
pub const SI_MESGQ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x10005, .hexadecimal);
pub const SS_ONSTACK = @as(c_int, 0x0001);
pub const SS_DISABLE = @as(c_int, 0x0004);
pub const MINSIGSTKSZ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 32768, .decimal);
pub const SIGSTKSZ = @import("std").zig.c_translation.promoteIntLiteral(c_int, 131072, .decimal);
pub const SV_ONSTACK = SA_ONSTACK;
pub const SV_INTERRUPT = SA_RESTART;
pub const SV_RESETHAND = SA_RESETHAND;
pub const SV_NODEFER = SA_NODEFER;
pub const SV_NOCLDSTOP = SA_NOCLDSTOP;
pub const SV_SIGINFO = SA_SIGINFO;
pub const sv_onstack = sv_flags;
pub inline fn sigmask(m: anytype) @TypeOf(@as(c_int, 1) << (m - @as(c_int, 1))) {
return @as(c_int, 1) << (m - @as(c_int, 1));
}
pub const BADSIG = SIG_ERR;
pub const __WORDSIZE = @as(c_int, 64);
pub inline fn INT8_C(v: anytype) @TypeOf(v) {
return v;
}
pub inline fn INT16_C(v: anytype) @TypeOf(v) {
return v;
}
pub inline fn INT32_C(v: anytype) @TypeOf(v) {
return v;
}
pub const INT64_C = @import("std").zig.c_translation.Macros.LL_SUFFIX;
pub inline fn UINT8_C(v: anytype) @TypeOf(v) {
return v;
}
pub inline fn UINT16_C(v: anytype) @TypeOf(v) {
return v;
}
pub const UINT32_C = @import("std").zig.c_translation.Macros.U_SUFFIX;
pub const UINT64_C = @import("std").zig.c_translation.Macros.ULL_SUFFIX;
pub const INTMAX_C = @import("std").zig.c_translation.Macros.L_SUFFIX;
pub const UINTMAX_C = @import("std").zig.c_translation.Macros.UL_SUFFIX;
pub const INT8_MAX = @as(c_int, 127);
pub const INT16_MAX = @as(c_int, 32767);
pub const INT32_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_int, 2147483647, .decimal);
pub const INT64_MAX = @as(c_longlong, 9223372036854775807);
pub const INT8_MIN = -@as(c_int, 128);
pub const INT16_MIN = -@import("std").zig.c_translation.promoteIntLiteral(c_int, 32768, .decimal);
pub const INT32_MIN = -INT32_MAX - @as(c_int, 1);
pub const INT64_MIN = -INT64_MAX - @as(c_int, 1);
pub const UINT8_MAX = @as(c_int, 255);
pub const UINT16_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_int, 65535, .decimal);
pub const UINT32_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_uint, 4294967295, .decimal);
pub const UINT64_MAX = @as(c_ulonglong, 18446744073709551615);
pub const INT_LEAST8_MIN = INT8_MIN;
pub const INT_LEAST16_MIN = INT16_MIN;
pub const INT_LEAST32_MIN = INT32_MIN;
pub const INT_LEAST64_MIN = INT64_MIN;
pub const INT_LEAST8_MAX = INT8_MAX;
pub const INT_LEAST16_MAX = INT16_MAX;
pub const INT_LEAST32_MAX = INT32_MAX;
pub const INT_LEAST64_MAX = INT64_MAX;
pub const UINT_LEAST8_MAX = UINT8_MAX;
pub const UINT_LEAST16_MAX = UINT16_MAX;
pub const UINT_LEAST32_MAX = UINT32_MAX;
pub const UINT_LEAST64_MAX = UINT64_MAX;
pub const INT_FAST8_MIN = INT8_MIN;
pub const INT_FAST16_MIN = INT16_MIN;
pub const INT_FAST32_MIN = INT32_MIN;
pub const INT_FAST64_MIN = INT64_MIN;
pub const INT_FAST8_MAX = INT8_MAX;
pub const INT_FAST16_MAX = INT16_MAX;
pub const INT_FAST32_MAX = INT32_MAX;
pub const INT_FAST64_MAX = INT64_MAX;
pub const UINT_FAST8_MAX = UINT8_MAX;
pub const UINT_FAST16_MAX = UINT16_MAX;
pub const UINT_FAST32_MAX = UINT32_MAX;
pub const UINT_FAST64_MAX = UINT64_MAX;
pub const INTPTR_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_long, 9223372036854775807, .decimal);
pub const INTPTR_MIN = -INTPTR_MAX - @as(c_int, 1);
pub const UINTPTR_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_ulong, 18446744073709551615, .decimal);
pub const INTMAX_MAX = INTMAX_C(@import("std").zig.c_translation.promoteIntLiteral(c_int, 9223372036854775807, .decimal));
pub const UINTMAX_MAX = UINTMAX_C(@import("std").zig.c_translation.promoteIntLiteral(c_int, 18446744073709551615, .decimal));
pub const INTMAX_MIN = -INTMAX_MAX - @as(c_int, 1);
pub const PTRDIFF_MIN = INTMAX_MIN;
pub const PTRDIFF_MAX = INTMAX_MAX;
pub const SIZE_MAX = UINTPTR_MAX;
pub const RSIZE_MAX = SIZE_MAX >> @as(c_int, 1);
pub const WCHAR_MAX = __WCHAR_MAX__;
pub const WCHAR_MIN = -WCHAR_MAX - @as(c_int, 1);
pub const WINT_MIN = INT32_MIN;
pub const WINT_MAX = INT32_MAX;
pub const SIG_ATOMIC_MIN = INT32_MIN;
pub const SIG_ATOMIC_MAX = INT32_MAX;
pub const _STRUCT_TIMEVAL = struct_timeval;
pub const PRIO_PROCESS = @as(c_int, 0);
pub const PRIO_PGRP = @as(c_int, 1);
pub const PRIO_USER = @as(c_int, 2);
pub const PRIO_DARWIN_THREAD = @as(c_int, 3);
pub const PRIO_DARWIN_PROCESS = @as(c_int, 4);
pub const PRIO_MIN = -@as(c_int, 20);
pub const PRIO_MAX = @as(c_int, 20);
pub const PRIO_DARWIN_BG = @as(c_int, 0x1000);
pub const PRIO_DARWIN_NONUI = @as(c_int, 0x1001);
pub const RUSAGE_SELF = @as(c_int, 0);
pub const RUSAGE_CHILDREN = -@as(c_int, 1);
pub const ru_first = ru_ixrss;
pub const ru_last = ru_nivcsw;
pub const RUSAGE_INFO_V0 = @as(c_int, 0);
pub const RUSAGE_INFO_V1 = @as(c_int, 1);
pub const RUSAGE_INFO_V2 = @as(c_int, 2);
pub const RUSAGE_INFO_V3 = @as(c_int, 3);
pub const RUSAGE_INFO_V4 = @as(c_int, 4);
pub const RUSAGE_INFO_CURRENT = RUSAGE_INFO_V4;
pub const RLIM_INFINITY = (@import("std").zig.c_translation.cast(__uint64_t, @as(c_int, 1)) << @as(c_int, 63)) - @as(c_int, 1);
pub const RLIM_SAVED_MAX = RLIM_INFINITY;
pub const RLIM_SAVED_CUR = RLIM_INFINITY;
pub const RLIMIT_CPU = @as(c_int, 0);
pub const RLIMIT_FSIZE = @as(c_int, 1);
pub const RLIMIT_DATA = @as(c_int, 2);
pub const RLIMIT_STACK = @as(c_int, 3);
pub const RLIMIT_CORE = @as(c_int, 4);
pub const RLIMIT_AS = @as(c_int, 5);
pub const RLIMIT_RSS = RLIMIT_AS;
pub const RLIMIT_MEMLOCK = @as(c_int, 6);
pub const RLIMIT_NPROC = @as(c_int, 7);
pub const RLIMIT_NOFILE = @as(c_int, 8);
pub const RLIM_NLIMITS = @as(c_int, 9);
pub const _RLIMIT_POSIX_FLAG = @as(c_int, 0x1000);
pub const RLIMIT_WAKEUPS_MONITOR = @as(c_int, 0x1);
pub const RLIMIT_CPU_USAGE_MONITOR = @as(c_int, 0x2);
pub const RLIMIT_THREAD_CPULIMITS = @as(c_int, 0x3);
pub const RLIMIT_FOOTPRINT_INTERVAL = @as(c_int, 0x4);
pub const WAKEMON_ENABLE = @as(c_int, 0x01);
pub const WAKEMON_DISABLE = @as(c_int, 0x02);
pub const WAKEMON_GET_PARAMS = @as(c_int, 0x04);
pub const WAKEMON_SET_DEFAULTS = @as(c_int, 0x08);
pub const WAKEMON_MAKE_FATAL = @as(c_int, 0x10);
pub const CPUMON_MAKE_FATAL = @as(c_int, 0x1000);
pub const FOOTPRINT_INTERVAL_RESET = @as(c_int, 0x1);
pub const IOPOL_TYPE_DISK = @as(c_int, 0);
pub const IOPOL_TYPE_VFS_ATIME_UPDATES = @as(c_int, 2);
pub const IOPOL_TYPE_VFS_MATERIALIZE_DATALESS_FILES = @as(c_int, 3);
pub const IOPOL_TYPE_VFS_STATFS_NO_DATA_VOLUME = @as(c_int, 4);
pub const IOPOL_SCOPE_PROCESS = @as(c_int, 0);
pub const IOPOL_SCOPE_THREAD = @as(c_int, 1);
pub const IOPOL_SCOPE_DARWIN_BG = @as(c_int, 2);
pub const IOPOL_DEFAULT = @as(c_int, 0);
pub const IOPOL_IMPORTANT = @as(c_int, 1);
pub const IOPOL_PASSIVE = @as(c_int, 2);
pub const IOPOL_THROTTLE = @as(c_int, 3);
pub const IOPOL_UTILITY = @as(c_int, 4);
pub const IOPOL_STANDARD = @as(c_int, 5);
pub const IOPOL_APPLICATION = IOPOL_STANDARD;
pub const IOPOL_NORMAL = IOPOL_IMPORTANT;
pub const IOPOL_ATIME_UPDATES_DEFAULT = @as(c_int, 0);
pub const IOPOL_ATIME_UPDATES_OFF = @as(c_int, 1);
pub const IOPOL_MATERIALIZE_DATALESS_FILES_DEFAULT = @as(c_int, 0);
pub const IOPOL_MATERIALIZE_DATALESS_FILES_OFF = @as(c_int, 1);
pub const IOPOL_MATERIALIZE_DATALESS_FILES_ON = @as(c_int, 2);
pub const IOPOL_VFS_STATFS_NO_DATA_VOLUME_DEFAULT = @as(c_int, 0);
pub const IOPOL_VFS_STATFS_FORCE_NO_DATA_VOLUME = @as(c_int, 1);
pub const WNOHANG = @as(c_int, 0x00000001);
pub const WUNTRACED = @as(c_int, 0x00000002);
pub inline fn _W_INT(w: anytype) @TypeOf(@import("std").zig.c_translation.cast([*c]c_int, &w).*) {
return @import("std").zig.c_translation.cast([*c]c_int, &w).*;
}
pub const WCOREFLAG = @as(c_int, 0o200);
pub inline fn _WSTATUS(x: anytype) @TypeOf(_W_INT(x) & @as(c_int, 0o177)) {
return _W_INT(x) & @as(c_int, 0o177);
}
pub const _WSTOPPED = @as(c_int, 0o177);
pub inline fn WEXITSTATUS(x: anytype) @TypeOf((_W_INT(x) >> @as(c_int, 8)) & @as(c_int, 0x000000ff)) {
return (_W_INT(x) >> @as(c_int, 8)) & @as(c_int, 0x000000ff);
}
pub inline fn WSTOPSIG(x: anytype) @TypeOf(_W_INT(x) >> @as(c_int, 8)) {
return _W_INT(x) >> @as(c_int, 8);
}
pub inline fn WIFCONTINUED(x: anytype) @TypeOf((_WSTATUS(x) == _WSTOPPED) and (WSTOPSIG(x) == @as(c_int, 0x13))) {
return (_WSTATUS(x) == _WSTOPPED) and (WSTOPSIG(x) == @as(c_int, 0x13));
}
pub inline fn WIFSTOPPED(x: anytype) @TypeOf((_WSTATUS(x) == _WSTOPPED) and (WSTOPSIG(x) != @as(c_int, 0x13))) {
return (_WSTATUS(x) == _WSTOPPED) and (WSTOPSIG(x) != @as(c_int, 0x13));
}
pub inline fn WIFEXITED(x: anytype) @TypeOf(_WSTATUS(x) == @as(c_int, 0)) {
return _WSTATUS(x) == @as(c_int, 0);
}
pub inline fn WIFSIGNALED(x: anytype) @TypeOf((_WSTATUS(x) != _WSTOPPED) and (_WSTATUS(x) != @as(c_int, 0))) {
return (_WSTATUS(x) != _WSTOPPED) and (_WSTATUS(x) != @as(c_int, 0));
}
pub inline fn WTERMSIG(x: anytype) @TypeOf(_WSTATUS(x)) {
return _WSTATUS(x);
}
pub inline fn WCOREDUMP(x: anytype) @TypeOf(_W_INT(x) & WCOREFLAG) {
return _W_INT(x) & WCOREFLAG;
}
pub inline fn W_EXITCODE(ret: anytype, sig: anytype) @TypeOf((ret << @as(c_int, 8)) | sig) {
return (ret << @as(c_int, 8)) | sig;
}
pub inline fn W_STOPCODE(sig: anytype) @TypeOf((sig << @as(c_int, 8)) | _WSTOPPED) {
return (sig << @as(c_int, 8)) | _WSTOPPED;
}
pub const WEXITED = @as(c_int, 0x00000004);
pub const WSTOPPED = @as(c_int, 0x00000008);
pub const WCONTINUED = @as(c_int, 0x00000010);
pub const WNOWAIT = @as(c_int, 0x00000020);
pub const WAIT_ANY = -@as(c_int, 1);
pub const WAIT_MYPGRP = @as(c_int, 0);
pub const _QUAD_HIGHWORD = @as(c_int, 1);
pub const _QUAD_LOWWORD = @as(c_int, 0);
pub const __DARWIN_LITTLE_ENDIAN = @as(c_int, 1234);
pub const __DARWIN_BIG_ENDIAN = @as(c_int, 4321);
pub const __DARWIN_PDP_ENDIAN = @as(c_int, 3412);
pub const __DARWIN_BYTE_ORDER = __DARWIN_LITTLE_ENDIAN;
pub const LITTLE_ENDIAN = __DARWIN_LITTLE_ENDIAN;
pub const BIG_ENDIAN = __DARWIN_BIG_ENDIAN;
pub const PDP_ENDIAN = __DARWIN_PDP_ENDIAN;
pub const BYTE_ORDER = __DARWIN_BYTE_ORDER;
pub inline fn __DARWIN_OSSwapConstInt16(x: anytype) __uint16_t {
return @import("std").zig.c_translation.cast(__uint16_t, ((@import("std").zig.c_translation.cast(__uint16_t, x) & @import("std").zig.c_translation.promoteIntLiteral(c_int, 0xff00, .hexadecimal)) >> @as(c_int, 8)) | ((@import("std").zig.c_translation.cast(__uint16_t, x) & @as(c_int, 0x00ff)) << @as(c_int, 8)));
}
pub inline fn __DARWIN_OSSwapConstInt32(x: anytype) __uint32_t {
return @import("std").zig.c_translation.cast(__uint32_t, ((((@import("std").zig.c_translation.cast(__uint32_t, x) & @import("std").zig.c_translation.promoteIntLiteral(c_int, 0xff000000, .hexadecimal)) >> @as(c_int, 24)) | ((@import("std").zig.c_translation.cast(__uint32_t, x) & @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x00ff0000, .hexadecimal)) >> @as(c_int, 8))) | ((@import("std").zig.c_translation.cast(__uint32_t, x) & @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x0000ff00, .hexadecimal)) << @as(c_int, 8))) | ((@import("std").zig.c_translation.cast(__uint32_t, x) & @as(c_int, 0x000000ff)) << @as(c_int, 24)));
}
pub inline fn __DARWIN_OSSwapConstInt64(x: anytype) __uint64_t {
return @import("std").zig.c_translation.cast(__uint64_t, ((((((((@import("std").zig.c_translation.cast(__uint64_t, x) & @as(c_ulonglong, 0xff00000000000000)) >> @as(c_int, 56)) | ((@import("std").zig.c_translation.cast(__uint64_t, x) & @as(c_ulonglong, 0x00ff000000000000)) >> @as(c_int, 40))) | ((@import("std").zig.c_translation.cast(__uint64_t, x) & @as(c_ulonglong, 0x0000ff0000000000)) >> @as(c_int, 24))) | ((@import("std").zig.c_translation.cast(__uint64_t, x) & @as(c_ulonglong, 0x000000ff00000000)) >> @as(c_int, 8))) | ((@import("std").zig.c_translation.cast(__uint64_t, x) & @as(c_ulonglong, 0x00000000ff000000)) << @as(c_int, 8))) | ((@import("std").zig.c_translation.cast(__uint64_t, x) & @as(c_ulonglong, 0x0000000000ff0000)) << @as(c_int, 24))) | ((@import("std").zig.c_translation.cast(__uint64_t, x) & @as(c_ulonglong, 0x000000000000ff00)) << @as(c_int, 40))) | ((@import("std").zig.c_translation.cast(__uint64_t, x) & @as(c_ulonglong, 0x00000000000000ff)) << @as(c_int, 56)));
}
pub inline fn ntohs(x: anytype) @TypeOf(__DARWIN_OSSwapInt16(x)) {
return __DARWIN_OSSwapInt16(x);
}
pub inline fn htons(x: anytype) @TypeOf(__DARWIN_OSSwapInt16(x)) {
return __DARWIN_OSSwapInt16(x);
}
pub inline fn ntohl(x: anytype) @TypeOf(__DARWIN_OSSwapInt32(x)) {
return __DARWIN_OSSwapInt32(x);
}
pub inline fn htonl(x: anytype) @TypeOf(__DARWIN_OSSwapInt32(x)) {
return __DARWIN_OSSwapInt32(x);
}
pub inline fn ntohll(x: anytype) @TypeOf(__DARWIN_OSSwapInt64(x)) {
return __DARWIN_OSSwapInt64(x);
}
pub inline fn htonll(x: anytype) @TypeOf(__DARWIN_OSSwapInt64(x)) {
return __DARWIN_OSSwapInt64(x);
}
pub const w_termsig = w_T.w_Termsig;
pub const w_coredump = w_T.w_Coredump;
pub const w_retcode = w_T.w_Retcode;
pub const w_stopval = w_S.w_Stopval;
pub const w_stopsig = w_S.w_Stopsig;
pub const EXIT_FAILURE = @as(c_int, 1);
pub const EXIT_SUCCESS = @as(c_int, 0);
pub const RAND_MAX = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0x7fffffff, .hexadecimal);
pub const MB_CUR_MAX = __mb_cur_max;
pub const __sort_noescape = __attribute__(__noescape__);
pub const ft_qsort = qsort;
pub const ft_scalloc = calloc;
pub const ft_sfree = free;
pub const ft_smalloc = malloc;
pub const ft_srealloc = realloc;
pub const ft_strtol = strtol;
pub const ft_getenv = getenv;
pub const _JBLEN = ((@as(c_int, 9) * @as(c_int, 2)) + @as(c_int, 3)) + @as(c_int, 16);
pub const ft_jmp_buf = jmp_buf;
pub const ft_longjmp = longjmp;
pub const __GNUC_VA_LIST = @as(c_int, 1);
pub const HAVE_UNISTD_H = @as(c_int, 1);
pub const HAVE_FCNTL_H = @as(c_int, 1);
pub const FT_SIZEOF_INT = @as(c_int, 32) / FT_CHAR_BIT;
pub const FT_SIZEOF_LONG = @as(c_int, 64) / FT_CHAR_BIT;
pub const FT_INT64 = c_long;
pub const FT_UINT64 = c_ulong;
pub const FT_PUBLIC_FUNCTION_ATTRIBUTE = __attribute__(visibility("default"));
pub const errno = __error().*;
pub const EPERM = @as(c_int, 1);
pub const ENOENT = @as(c_int, 2);
pub const ESRCH = @as(c_int, 3);
pub const EINTR = @as(c_int, 4);
pub const EIO = @as(c_int, 5);
pub const ENXIO = @as(c_int, 6);
pub const E2BIG = @as(c_int, 7);
pub const ENOEXEC = @as(c_int, 8);
pub const EBADF = @as(c_int, 9);
pub const ECHILD = @as(c_int, 10);
pub const EDEADLK = @as(c_int, 11);
pub const ENOMEM = @as(c_int, 12);
pub const EACCES = @as(c_int, 13);
pub const EFAULT = @as(c_int, 14);
pub const ENOTBLK = @as(c_int, 15);
pub const EBUSY = @as(c_int, 16);
pub const EEXIST = @as(c_int, 17);
pub const EXDEV = @as(c_int, 18);
pub const ENODEV = @as(c_int, 19);
pub const ENOTDIR = @as(c_int, 20);
pub const EISDIR = @as(c_int, 21);
pub const EINVAL = @as(c_int, 22);
pub const ENFILE = @as(c_int, 23);
pub const EMFILE = @as(c_int, 24);
pub const ENOTTY = @as(c_int, 25);
pub const ETXTBSY = @as(c_int, 26);
pub const EFBIG = @as(c_int, 27);
pub const ENOSPC = @as(c_int, 28);
pub const ESPIPE = @as(c_int, 29);
pub const EROFS = @as(c_int, 30);
pub const EMLINK = @as(c_int, 31);
pub const EPIPE = @as(c_int, 32);
pub const EDOM = @as(c_int, 33);
pub const ERANGE = @as(c_int, 34);
pub const EAGAIN = @as(c_int, 35);
pub const EWOULDBLOCK = EAGAIN;
pub const EINPROGRESS = @as(c_int, 36);
pub const EALREADY = @as(c_int, 37);
pub const ENOTSOCK = @as(c_int, 38);
pub const EDESTADDRREQ = @as(c_int, 39);
pub const EMSGSIZE = @as(c_int, 40);
pub const EPROTOTYPE = @as(c_int, 41);
pub const ENOPROTOOPT = @as(c_int, 42);
pub const EPROTONOSUPPORT = @as(c_int, 43);
pub const ESOCKTNOSUPPORT = @as(c_int, 44);
pub const ENOTSUP = @as(c_int, 45);
pub const EPFNOSUPPORT = @as(c_int, 46);
pub const EAFNOSUPPORT = @as(c_int, 47);
pub const EADDRINUSE = @as(c_int, 48);
pub const EADDRNOTAVAIL = @as(c_int, 49);
pub const ENETDOWN = @as(c_int, 50);
pub const ENETUNREACH = @as(c_int, 51);
pub const ENETRESET = @as(c_int, 52);
pub const ECONNABORTED = @as(c_int, 53);
pub const ECONNRESET = @as(c_int, 54);
pub const ENOBUFS = @as(c_int, 55);
pub const EISCONN = @as(c_int, 56);
pub const ENOTCONN = @as(c_int, 57);
pub const ESHUTDOWN = @as(c_int, 58);
pub const ETOOMANYREFS = @as(c_int, 59);
pub const ETIMEDOUT = @as(c_int, 60);
pub const ECONNREFUSED = @as(c_int, 61);
pub const ELOOP = @as(c_int, 62);
pub const ENAMETOOLONG = @as(c_int, 63);
pub const EHOSTDOWN = @as(c_int, 64);
pub const EHOSTUNREACH = @as(c_int, 65);
pub const ENOTEMPTY = @as(c_int, 66);
pub const EPROCLIM = @as(c_int, 67);
pub const EUSERS = @as(c_int, 68);
pub const EDQUOT = @as(c_int, 69);
pub const ESTALE = @as(c_int, 70);
pub const EREMOTE = @as(c_int, 71);
pub const EBADRPC = @as(c_int, 72);
pub const ERPCMISMATCH = @as(c_int, 73);
pub const EPROGUNAVAIL = @as(c_int, 74);
pub const EPROGMISMATCH = @as(c_int, 75);
pub const EPROCUNAVAIL = @as(c_int, 76);
pub const ENOLCK = @as(c_int, 77);
pub const ENOSYS = @as(c_int, 78);
pub const EFTYPE = @as(c_int, 79);
pub const EAUTH = @as(c_int, 80);
pub const ENEEDAUTH = @as(c_int, 81);
pub const EPWROFF = @as(c_int, 82);
pub const EDEVERR = @as(c_int, 83);
pub const EOVERFLOW = @as(c_int, 84);
pub const EBADEXEC = @as(c_int, 85);
pub const EBADARCH = @as(c_int, 86);
pub const ESHLIBVERS = @as(c_int, 87);
pub const EBADMACHO = @as(c_int, 88);
pub const ECANCELED = @as(c_int, 89);
pub const EIDRM = @as(c_int, 90);
pub const ENOMSG = @as(c_int, 91);
pub const EILSEQ = @as(c_int, 92);
pub const ENOATTR = @as(c_int, 93);
pub const EBADMSG = @as(c_int, 94);
pub const EMULTIHOP = @as(c_int, 95);
pub const ENODATA = @as(c_int, 96);
pub const ENOLINK = @as(c_int, 97);
pub const ENOSR = @as(c_int, 98);
pub const ENOSTR = @as(c_int, 99);
pub const EPROTO = @as(c_int, 100);
pub const ETIME = @as(c_int, 101);
pub const EOPNOTSUPP = @as(c_int, 102);
pub const ENOPOLICY = @as(c_int, 103);
pub const ENOTRECOVERABLE = @as(c_int, 104);
pub const EOWNERDEAD = @as(c_int, 105);
pub const EQFULL = @as(c_int, 106);
pub const ELAST = @as(c_int, 106);
pub const MAC_OS_X_VERSION_10_0 = @as(c_int, 1000);
pub const MAC_OS_X_VERSION_10_1 = @as(c_int, 1010);
pub const MAC_OS_X_VERSION_10_2 = @as(c_int, 1020);
pub const MAC_OS_X_VERSION_10_3 = @as(c_int, 1030);
pub const MAC_OS_X_VERSION_10_4 = @as(c_int, 1040);
pub const MAC_OS_X_VERSION_10_5 = @as(c_int, 1050);
pub const MAC_OS_X_VERSION_10_6 = @as(c_int, 1060);
pub const MAC_OS_X_VERSION_10_7 = @as(c_int, 1070);
pub const MAC_OS_X_VERSION_10_8 = @as(c_int, 1080);
pub const MAC_OS_X_VERSION_10_9 = @as(c_int, 1090);
pub const MAC_OS_X_VERSION_10_10 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101000, .decimal);
pub const MAC_OS_X_VERSION_10_10_2 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101002, .decimal);
pub const MAC_OS_X_VERSION_10_10_3 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101003, .decimal);
pub const MAC_OS_X_VERSION_10_11 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101100, .decimal);
pub const MAC_OS_X_VERSION_10_11_2 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101102, .decimal);
pub const MAC_OS_X_VERSION_10_11_3 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101103, .decimal);
pub const MAC_OS_X_VERSION_10_11_4 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101104, .decimal);
pub const MAC_OS_X_VERSION_10_12 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101200, .decimal);
pub const MAC_OS_X_VERSION_10_12_1 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101201, .decimal);
pub const MAC_OS_X_VERSION_10_12_2 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101202, .decimal);
pub const MAC_OS_X_VERSION_10_12_4 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101204, .decimal);
pub const MAC_OS_X_VERSION_10_13 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101300, .decimal);
pub const MAC_OS_X_VERSION_10_13_1 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101301, .decimal);
pub const MAC_OS_X_VERSION_10_13_2 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101302, .decimal);
pub const MAC_OS_X_VERSION_10_13_4 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101304, .decimal);
pub const MAC_OS_X_VERSION_10_14 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101400, .decimal);
pub const MAC_OS_X_VERSION_10_14_1 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101401, .decimal);
pub const MAC_OS_X_VERSION_10_14_4 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101404, .decimal);
pub const MAC_OS_X_VERSION_10_15 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101500, .decimal);
pub const MAC_OS_X_VERSION_10_15_1 = @import("std").zig.c_translation.promoteIntLiteral(c_int, 101501, .decimal);
pub const MAC_OS_X_VERSION_MIN_REQUIRED = __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__;
pub const MAC_OS_X_VERSION_MAX_ALLOWED = MAC_OS_X_VERSION_10_15;
pub const WEAK_IMPORT_ATTRIBUTE = __attribute__(weak_import);
pub const DEPRECATED_ATTRIBUTE = __attribute__(deprecated);
pub inline fn DEPRECATED_MSG_ATTRIBUTE(s: anytype) @TypeOf(__attribute__(deprecated(s))) {
return __attribute__(deprecated(s));
}
pub const UNAVAILABLE_ATTRIBUTE = __attribute__(unavailable);
pub const AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED = DEPRECATED_ATTRIBUTE;
pub const DEPRECATED_IN_MAC_OS_X_VERSION_10_0_AND_LATER = DEPRECATED_ATTRIBUTE;
pub const __AVAILABILITY_MACROS_USES_AVAILABILITY = @as(c_int, 1);
pub const __IPHONE_COMPAT_VERSION = __IPHONE_4_0;
pub const AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER = __OSX_AVAILABLE_STARTING(__MAC_10_1, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_1 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER = __OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER = __OSX_AVAILABLE_STARTING(__MAC_10_3, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER = __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER = __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_5, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_5, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_5, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_5, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_5, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_5, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER = __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_6, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_6, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_6, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_6, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_6, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_6, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER = __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_7, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_7, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_7, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_7, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_7, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_7, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_7, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_7, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_13 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_13, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER = __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_8, __MAC_10_8, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_8, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_8, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_8, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_8, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_8, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_8, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_8, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER = __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_9, __MAC_10_9, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_9, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_9, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_9, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_9, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_9, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_9, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_9, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_9, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_8, __MAC_10_9, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER = __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10, __MAC_10_10, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_10, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_10, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_10, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_10, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_10, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_10, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_10, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_8, __MAC_10_10, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_9, __MAC_10_10, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER = __OSX_AVAILABLE_STARTING(__MAC_10_10_2, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_2, __MAC_10_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_8, __MAC_10_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_9, __MAC_10_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10, __MAC_10_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER = __OSX_AVAILABLE_STARTING(__MAC_10_10_3, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_3, __MAC_10_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_8, __MAC_10_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_9, __MAC_10_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10, __MAC_10_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_2, __MAC_10_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER = __OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_8, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_9, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_2, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_3, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER = __OSX_AVAILABLE_STARTING(__MAC_10_11_2, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_2, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_8, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_9, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_2, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_3, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER = __OSX_AVAILABLE_STARTING(__MAC_10_11_3, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_3, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_8, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_9, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_2, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_3, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_2, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER = __OSX_AVAILABLE_STARTING(__MAC_10_11_4, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_4, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_8, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_9, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_2, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_3, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_2, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_3, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER = __OSX_AVAILABLE_STARTING(__MAC_10_12, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_12, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_8, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_9, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_2, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_3, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_2, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_3, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_4, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER = __OSX_AVAILABLE_STARTING(__MAC_10_12_1, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER_BUT_DEPRECATED = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_12_1, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_8, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_9, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_2, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_3, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_2, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_3, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_4, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_12, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER = __OSX_AVAILABLE_STARTING(__MAC_10_12_2, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER_BUT_DEPRECATED = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_12_2, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_8, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_9, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_2, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_3, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_2, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_3, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_4, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_12, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_12_1, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_12_4_AND_LATER = __OSX_AVAILABLE_STARTING(__MAC_10_12_4, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_12_4_AND_LATER_BUT_DEPRECATED = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_12_4, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_8, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_9, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_2, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_3, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_2, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_3, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_4, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_12, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_12_1, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_12_2, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_13_AND_LATER = __OSX_AVAILABLE_STARTING(__MAC_10_13, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_14_AND_LATER = __OSX_AVAILABLE_STARTING(__MAC_10_14, __IPHONE_COMPAT_VERSION);
pub const AVAILABLE_MAC_OS_X_VERSION_10_15_AND_LATER = __OSX_AVAILABLE_STARTING(__MAC_10_15, __IPHONE_COMPAT_VERSION);
pub const DEPRECATED_IN_MAC_OS_X_VERSION_10_1_AND_LATER = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const DEPRECATED_IN_MAC_OS_X_VERSION_10_2_AND_LATER = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const DEPRECATED_IN_MAC_OS_X_VERSION_10_3_AND_LATER = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const DEPRECATED_IN_MAC_OS_X_VERSION_10_4_AND_LATER = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const DEPRECATED_IN_MAC_OS_X_VERSION_10_5_AND_LATER = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_5, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const DEPRECATED_IN_MAC_OS_X_VERSION_10_6_AND_LATER = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_6, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_7, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const DEPRECATED_IN_MAC_OS_X_VERSION_10_8_AND_LATER = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const DEPRECATED_IN_MAC_OS_X_VERSION_10_9_AND_LATER = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_9, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const DEPRECATED_IN_MAC_OS_X_VERSION_10_10_AND_LATER = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_10, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const DEPRECATED_IN_MAC_OS_X_VERSION_10_11_AND_LATER = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const DEPRECATED_IN_MAC_OS_X_VERSION_10_12_AND_LATER = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const DEPRECATED_IN_MAC_OS_X_VERSION_10_13_AND_LATER = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_13, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const DEPRECATED_IN_MAC_OS_X_VERSION_10_14_4_AND_LATER = __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_14_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION);
pub const ft_pixel_mode_none = FT_PIXEL_MODE_NONE;
pub const ft_pixel_mode_mono = FT_PIXEL_MODE_MONO;
pub const ft_pixel_mode_grays = FT_PIXEL_MODE_GRAY;
pub const ft_pixel_mode_pal2 = FT_PIXEL_MODE_GRAY2;
pub const ft_pixel_mode_pal4 = FT_PIXEL_MODE_GRAY4;
pub const FT_OUTLINE_CONTOURS_MAX = SHRT_MAX;
pub const FT_OUTLINE_POINTS_MAX = SHRT_MAX;
pub const FT_OUTLINE_NONE = @as(c_int, 0x0);
pub const FT_OUTLINE_OWNER = @as(c_int, 0x1);
pub const FT_OUTLINE_EVEN_ODD_FILL = @as(c_int, 0x2);
pub const FT_OUTLINE_REVERSE_FILL = @as(c_int, 0x4);
pub const FT_OUTLINE_IGNORE_DROPOUTS = @as(c_int, 0x8);
pub const FT_OUTLINE_SMART_DROPOUTS = @as(c_int, 0x10);
pub const FT_OUTLINE_INCLUDE_STUBS = @as(c_int, 0x20);
pub const FT_OUTLINE_OVERLAP = @as(c_int, 0x40);
pub const FT_OUTLINE_HIGH_PRECISION = @as(c_int, 0x100);
pub const FT_OUTLINE_SINGLE_PASS = @as(c_int, 0x200);
pub const ft_outline_none = FT_OUTLINE_NONE;
pub const ft_outline_owner = FT_OUTLINE_OWNER;
pub const ft_outline_even_odd_fill = FT_OUTLINE_EVEN_ODD_FILL;
pub const ft_outline_reverse_fill = FT_OUTLINE_REVERSE_FILL;
pub const ft_outline_ignore_dropouts = FT_OUTLINE_IGNORE_DROPOUTS;
pub const ft_outline_high_precision = FT_OUTLINE_HIGH_PRECISION;
pub const ft_outline_single_pass = FT_OUTLINE_SINGLE_PASS;
pub inline fn FT_CURVE_TAG(flag: anytype) @TypeOf(flag & @as(c_int, 0x03)) {
return flag & @as(c_int, 0x03);
}
pub const FT_CURVE_TAG_ON = @as(c_int, 0x01);
pub const FT_CURVE_TAG_CONIC = @as(c_int, 0x00);
pub const FT_CURVE_TAG_CUBIC = @as(c_int, 0x02);
pub const FT_CURVE_TAG_HAS_SCANMODE = @as(c_int, 0x04);
pub const FT_CURVE_TAG_TOUCH_X = @as(c_int, 0x08);
pub const FT_CURVE_TAG_TOUCH_Y = @as(c_int, 0x10);
pub const FT_CURVE_TAG_TOUCH_BOTH = FT_CURVE_TAG_TOUCH_X | FT_CURVE_TAG_TOUCH_Y;
pub const FT_Curve_Tag_On = FT_CURVE_TAG_ON;
pub const FT_Curve_Tag_Conic = FT_CURVE_TAG_CONIC;
pub const FT_Curve_Tag_Cubic = FT_CURVE_TAG_CUBIC;
pub const FT_Curve_Tag_Touch_X = FT_CURVE_TAG_TOUCH_X;
pub const FT_Curve_Tag_Touch_Y = FT_CURVE_TAG_TOUCH_Y;
pub const FT_Outline_MoveTo_Func = FT_Outline_MoveToFunc;
pub const FT_Outline_LineTo_Func = FT_Outline_LineToFunc;
pub const FT_Outline_ConicTo_Func = FT_Outline_ConicToFunc;
pub const FT_Outline_CubicTo_Func = FT_Outline_CubicToFunc;
pub const ft_glyph_format_none = FT_GLYPH_FORMAT_NONE;
pub const ft_glyph_format_composite = FT_GLYPH_FORMAT_COMPOSITE;
pub const ft_glyph_format_bitmap = FT_GLYPH_FORMAT_BITMAP;
pub const ft_glyph_format_outline = FT_GLYPH_FORMAT_OUTLINE;
pub const ft_glyph_format_plotter = FT_GLYPH_FORMAT_PLOTTER;
pub const FT_Raster_Span_Func = FT_SpanFunc;
pub const FT_RASTER_FLAG_DEFAULT = @as(c_int, 0x0);
pub const FT_RASTER_FLAG_AA = @as(c_int, 0x1);
pub const FT_RASTER_FLAG_DIRECT = @as(c_int, 0x2);
pub const FT_RASTER_FLAG_CLIP = @as(c_int, 0x4);
pub const FT_RASTER_FLAG_SDF = @as(c_int, 0x8);
pub const ft_raster_flag_default = FT_RASTER_FLAG_DEFAULT;
pub const ft_raster_flag_aa = FT_RASTER_FLAG_AA;
pub const ft_raster_flag_direct = FT_RASTER_FLAG_DIRECT;
pub const ft_raster_flag_clip = FT_RASTER_FLAG_CLIP;
pub const FT_Raster_New_Func = FT_Raster_NewFunc;
pub const FT_Raster_Done_Func = FT_Raster_DoneFunc;
pub const FT_Raster_Reset_Func = FT_Raster_ResetFunc;
pub const FT_Raster_Set_Mode_Func = FT_Raster_SetModeFunc;
pub const FT_Raster_Render_Func = FT_Raster_RenderFunc;
pub inline fn FT_MAKE_TAG(_x1: anytype, _x2: anytype, _x3: anytype, _x4: anytype) FT_Tag {
return @import("std").zig.c_translation.cast(FT_Tag, (((@import("std").zig.c_translation.cast(FT_ULong, _x1) << @as(c_int, 24)) | (@import("std").zig.c_translation.cast(FT_ULong, _x2) << @as(c_int, 16))) | (@import("std").zig.c_translation.cast(FT_ULong, _x3) << @as(c_int, 8))) | @import("std").zig.c_translation.cast(FT_ULong, _x4));
}
pub inline fn FT_IS_EMPTY(list: anytype) @TypeOf(list.head == @as(c_int, 0)) {
return list.head == @as(c_int, 0);
}
pub inline fn FT_BOOL(x: anytype) FT_Bool {
return @import("std").zig.c_translation.cast(FT_Bool, x != @as(c_int, 0));
}
pub inline fn FT_ERR_CAT(x: anytype, y: anytype) @TypeOf(FT_ERR_XCAT(x, y)) {
return FT_ERR_XCAT(x, y);
}
pub inline fn FT_ERR(e: anytype) @TypeOf(FT_ERR_CAT(FT_ERR_PREFIX, e)) {
return FT_ERR_CAT(FT_ERR_PREFIX, e);
}
pub inline fn FT_ERROR_BASE(x: anytype) @TypeOf(x & @as(c_int, 0xFF)) {
return x & @as(c_int, 0xFF);
}
pub inline fn FT_ERROR_MODULE(x: anytype) @TypeOf(x & @as(c_uint, 0xFF00)) {
return x & @as(c_uint, 0xFF00);
}
pub inline fn FT_ERR_EQ(x: anytype, e: anytype) @TypeOf(FT_ERROR_BASE(x) == FT_ERROR_BASE(FT_ERR(e))) {
return FT_ERROR_BASE(x) == FT_ERROR_BASE(FT_ERR(e));
}
pub inline fn FT_ERR_NEQ(x: anytype, e: anytype) @TypeOf(FT_ERROR_BASE(x) != FT_ERROR_BASE(FT_ERR(e))) {
return FT_ERROR_BASE(x) != FT_ERROR_BASE(FT_ERR(e));
}
pub const FT_ERR_PREFIX = FT_Err_;
pub const FT_ERR_BASE = @as(c_int, 0);
pub inline fn FT_ERRORDEF_(e: anytype, v: anytype, s: anytype) @TypeOf(FT_ERRORDEF(FT_ERR_CAT(FT_ERR_PREFIX, e), v + FT_ERR_BASE, s)) {
return FT_ERRORDEF(FT_ERR_CAT(FT_ERR_PREFIX, e), v + FT_ERR_BASE, s);
}
pub inline fn FT_NOERRORDEF_(e: anytype, v: anytype, s: anytype) @TypeOf(FT_ERRORDEF(FT_ERR_CAT(FT_ERR_PREFIX, e), v, s)) {
return FT_ERRORDEF(FT_ERR_CAT(FT_ERR_PREFIX, e), v, s);
}
pub const ft_encoding_none = FT_ENCODING_NONE;
pub const ft_encoding_unicode = FT_ENCODING_UNICODE;
pub const ft_encoding_symbol = FT_ENCODING_MS_SYMBOL;
pub const ft_encoding_latin_1 = FT_ENCODING_ADOBE_LATIN_1;
pub const ft_encoding_latin_2 = FT_ENCODING_OLD_LATIN_2;
pub const ft_encoding_sjis = FT_ENCODING_SJIS;
pub const ft_encoding_gb2312 = FT_ENCODING_PRC;
pub const ft_encoding_big5 = FT_ENCODING_BIG5;
pub const ft_encoding_wansung = FT_ENCODING_WANSUNG;
pub const ft_encoding_johab = FT_ENCODING_JOHAB;
pub const ft_encoding_adobe_standard = FT_ENCODING_ADOBE_STANDARD;
pub const ft_encoding_adobe_expert = FT_ENCODING_ADOBE_EXPERT;
pub const ft_encoding_adobe_custom = FT_ENCODING_ADOBE_CUSTOM;
pub const ft_encoding_apple_roman = FT_ENCODING_APPLE_ROMAN;
pub const FT_FACE_FLAG_SCALABLE = @as(c_long, 1) << @as(c_int, 0);
pub const FT_FACE_FLAG_FIXED_SIZES = @as(c_long, 1) << @as(c_int, 1);
pub const FT_FACE_FLAG_FIXED_WIDTH = @as(c_long, 1) << @as(c_int, 2);
pub const FT_FACE_FLAG_SFNT = @as(c_long, 1) << @as(c_int, 3);
pub const FT_FACE_FLAG_HORIZONTAL = @as(c_long, 1) << @as(c_int, 4);
pub const FT_FACE_FLAG_VERTICAL = @as(c_long, 1) << @as(c_int, 5);
pub const FT_FACE_FLAG_KERNING = @as(c_long, 1) << @as(c_int, 6);
pub const FT_FACE_FLAG_FAST_GLYPHS = @as(c_long, 1) << @as(c_int, 7);
pub const FT_FACE_FLAG_MULTIPLE_MASTERS = @as(c_long, 1) << @as(c_int, 8);
pub const FT_FACE_FLAG_GLYPH_NAMES = @as(c_long, 1) << @as(c_int, 9);
pub const FT_FACE_FLAG_EXTERNAL_STREAM = @as(c_long, 1) << @as(c_int, 10);
pub const FT_FACE_FLAG_HINTER = @as(c_long, 1) << @as(c_int, 11);
pub const FT_FACE_FLAG_CID_KEYED = @as(c_long, 1) << @as(c_int, 12);
pub const FT_FACE_FLAG_TRICKY = @as(c_long, 1) << @as(c_int, 13);
pub const FT_FACE_FLAG_COLOR = @as(c_long, 1) << @as(c_int, 14);
pub const FT_FACE_FLAG_VARIATION = @as(c_long, 1) << @as(c_int, 15);
pub inline fn FT_HAS_HORIZONTAL(face: anytype) @TypeOf(!!((face.*.face_flags & FT_FACE_FLAG_HORIZONTAL) != 0)) {
return !!((face.*.face_flags & FT_FACE_FLAG_HORIZONTAL) != 0);
}
pub inline fn FT_HAS_VERTICAL(face: anytype) @TypeOf(!!((face.*.face_flags & FT_FACE_FLAG_VERTICAL) != 0)) {
return !!((face.*.face_flags & FT_FACE_FLAG_VERTICAL) != 0);
}
pub inline fn FT_HAS_KERNING(face: anytype) @TypeOf(!!((face.*.face_flags & FT_FACE_FLAG_KERNING) != 0)) {
return !!((face.*.face_flags & FT_FACE_FLAG_KERNING) != 0);
}
pub inline fn FT_IS_SCALABLE(face: anytype) @TypeOf(!!((face.*.face_flags & FT_FACE_FLAG_SCALABLE) != 0)) {
return !!((face.*.face_flags & FT_FACE_FLAG_SCALABLE) != 0);
}
pub inline fn FT_IS_SFNT(face: anytype) @TypeOf(!!((face.*.face_flags & FT_FACE_FLAG_SFNT) != 0)) {
return !!((face.*.face_flags & FT_FACE_FLAG_SFNT) != 0);
}
pub inline fn FT_IS_FIXED_WIDTH(face: anytype) @TypeOf(!!((face.*.face_flags & FT_FACE_FLAG_FIXED_WIDTH) != 0)) {
return !!((face.*.face_flags & FT_FACE_FLAG_FIXED_WIDTH) != 0);
}
pub inline fn FT_HAS_FIXED_SIZES(face: anytype) @TypeOf(!!((face.*.face_flags & FT_FACE_FLAG_FIXED_SIZES) != 0)) {
return !!((face.*.face_flags & FT_FACE_FLAG_FIXED_SIZES) != 0);
}
pub inline fn FT_HAS_FAST_GLYPHS(face: anytype) @TypeOf(@as(c_int, 0)) {
_ = face;
return @as(c_int, 0);
}
pub inline fn FT_HAS_GLYPH_NAMES(face: anytype) @TypeOf(!!((face.*.face_flags & FT_FACE_FLAG_GLYPH_NAMES) != 0)) {
return !!((face.*.face_flags & FT_FACE_FLAG_GLYPH_NAMES) != 0);
}
pub inline fn FT_HAS_MULTIPLE_MASTERS(face: anytype) @TypeOf(!!((face.*.face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS) != 0)) {
return !!((face.*.face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS) != 0);
}
pub inline fn FT_IS_NAMED_INSTANCE(face: anytype) @TypeOf(!!((face.*.face_index & @as(c_long, 0x7FFF0000)) != 0)) {
return !!((face.*.face_index & @as(c_long, 0x7FFF0000)) != 0);
}
pub inline fn FT_IS_VARIATION(face: anytype) @TypeOf(!!((face.*.face_flags & FT_FACE_FLAG_VARIATION) != 0)) {
return !!((face.*.face_flags & FT_FACE_FLAG_VARIATION) != 0);
}
pub inline fn FT_IS_CID_KEYED(face: anytype) @TypeOf(!!((face.*.face_flags & FT_FACE_FLAG_CID_KEYED) != 0)) {
return !!((face.*.face_flags & FT_FACE_FLAG_CID_KEYED) != 0);
}
pub inline fn FT_IS_TRICKY(face: anytype) @TypeOf(!!((face.*.face_flags & FT_FACE_FLAG_TRICKY) != 0)) {
return !!((face.*.face_flags & FT_FACE_FLAG_TRICKY) != 0);
}
pub inline fn FT_HAS_COLOR(face: anytype) @TypeOf(!!((face.*.face_flags & FT_FACE_FLAG_COLOR) != 0)) {
return !!((face.*.face_flags & FT_FACE_FLAG_COLOR) != 0);
}
pub const FT_STYLE_FLAG_ITALIC = @as(c_int, 1) << @as(c_int, 0);
pub const FT_STYLE_FLAG_BOLD = @as(c_int, 1) << @as(c_int, 1);
pub const FT_OPEN_MEMORY = @as(c_int, 0x1);
pub const FT_OPEN_STREAM = @as(c_int, 0x2);
pub const FT_OPEN_PATHNAME = @as(c_int, 0x4);
pub const FT_OPEN_DRIVER = @as(c_int, 0x8);
pub const FT_OPEN_PARAMS = @as(c_int, 0x10);
pub const ft_open_memory = FT_OPEN_MEMORY;
pub const ft_open_stream = FT_OPEN_STREAM;
pub const ft_open_pathname = FT_OPEN_PATHNAME;
pub const ft_open_driver = FT_OPEN_DRIVER;
pub const ft_open_params = FT_OPEN_PARAMS;
pub const FT_LOAD_DEFAULT = @as(c_int, 0x0);
pub const FT_LOAD_NO_SCALE = @as(c_long, 1) << @as(c_int, 0);
pub const FT_LOAD_NO_HINTING = @as(c_long, 1) << @as(c_int, 1);
pub const FT_LOAD_RENDER = @as(c_long, 1) << @as(c_int, 2);
pub const FT_LOAD_NO_BITMAP = @as(c_long, 1) << @as(c_int, 3);
pub const FT_LOAD_VERTICAL_LAYOUT = @as(c_long, 1) << @as(c_int, 4);
pub const FT_LOAD_FORCE_AUTOHINT = @as(c_long, 1) << @as(c_int, 5);
pub const FT_LOAD_CROP_BITMAP = @as(c_long, 1) << @as(c_int, 6);
pub const FT_LOAD_PEDANTIC = @as(c_long, 1) << @as(c_int, 7);
pub const FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH = @as(c_long, 1) << @as(c_int, 9);
pub const FT_LOAD_NO_RECURSE = @as(c_long, 1) << @as(c_int, 10);
pub const FT_LOAD_IGNORE_TRANSFORM = @as(c_long, 1) << @as(c_int, 11);
pub const FT_LOAD_MONOCHROME = @as(c_long, 1) << @as(c_int, 12);
pub const FT_LOAD_LINEAR_DESIGN = @as(c_long, 1) << @as(c_int, 13);
pub const FT_LOAD_NO_AUTOHINT = @as(c_long, 1) << @as(c_int, 15);
pub const FT_LOAD_COLOR = @as(c_long, 1) << @as(c_int, 20);
pub const FT_LOAD_COMPUTE_METRICS = @as(c_long, 1) << @as(c_int, 21);
pub const FT_LOAD_BITMAP_METRICS_ONLY = @as(c_long, 1) << @as(c_int, 22);
pub const FT_LOAD_ADVANCE_ONLY = @as(c_long, 1) << @as(c_int, 8);
pub const FT_LOAD_SBITS_ONLY = @as(c_long, 1) << @as(c_int, 14);
pub inline fn FT_LOAD_TARGET_(x: anytype) @TypeOf(@import("std").zig.c_translation.cast(FT_Int32, x & @as(c_int, 15)) << @as(c_int, 16)) {
return @import("std").zig.c_translation.cast(FT_Int32, x & @as(c_int, 15)) << @as(c_int, 16);
}
pub const FT_LOAD_TARGET_NORMAL = FT_LOAD_TARGET_(FT_RENDER_MODE_NORMAL);
pub const FT_LOAD_TARGET_LIGHT = FT_LOAD_TARGET_(FT_RENDER_MODE_LIGHT);
pub const FT_LOAD_TARGET_MONO = FT_LOAD_TARGET_(FT_RENDER_MODE_MONO);
pub const FT_LOAD_TARGET_LCD = FT_LOAD_TARGET_(FT_RENDER_MODE_LCD);
pub const FT_LOAD_TARGET_LCD_V = FT_LOAD_TARGET_(FT_RENDER_MODE_LCD_V);
pub inline fn FT_LOAD_TARGET_MODE(x: anytype) FT_Render_Mode {
return @import("std").zig.c_translation.cast(FT_Render_Mode, (x >> @as(c_int, 16)) & @as(c_int, 15));
}
pub const ft_render_mode_normal = FT_RENDER_MODE_NORMAL;
pub const ft_render_mode_mono = FT_RENDER_MODE_MONO;
pub const ft_kerning_default = FT_KERNING_DEFAULT;
pub const ft_kerning_unfitted = FT_KERNING_UNFITTED;
pub const ft_kerning_unscaled = FT_KERNING_UNSCALED;
pub const FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS = @as(c_int, 1);
pub const FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES = @as(c_int, 2);
pub const FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID = @as(c_int, 4);
pub const FT_SUBGLYPH_FLAG_SCALE = @as(c_int, 8);
pub const FT_SUBGLYPH_FLAG_XY_SCALE = @as(c_int, 0x40);
pub const FT_SUBGLYPH_FLAG_2X2 = @as(c_int, 0x80);
pub const FT_SUBGLYPH_FLAG_USE_MY_METRICS = @as(c_int, 0x200);
pub const FT_FSTYPE_INSTALLABLE_EMBEDDING = @as(c_int, 0x0000);
pub const FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING = @as(c_int, 0x0002);
pub const FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING = @as(c_int, 0x0004);
pub const FT_FSTYPE_EDITABLE_EMBEDDING = @as(c_int, 0x0008);
pub const FT_FSTYPE_NO_SUBSETTING = @as(c_int, 0x0100);
pub const FT_FSTYPE_BITMAP_EMBEDDING_ONLY = @as(c_int, 0x0200);
pub const FREETYPE_MAJOR = @as(c_int, 2);
pub const FREETYPE_MINOR = @as(c_int, 11);
pub const FREETYPE_PATCH = @as(c_int, 0);
pub const __va_list_tag = struct___va_list_tag;
pub const __darwin_pthread_handler_rec = struct___darwin_pthread_handler_rec;
pub const _opaque_pthread_attr_t = struct__opaque_pthread_attr_t;
pub const _opaque_pthread_cond_t = struct__opaque_pthread_cond_t;
pub const _opaque_pthread_condattr_t = struct__opaque_pthread_condattr_t;
pub const _opaque_pthread_mutex_t = struct__opaque_pthread_mutex_t;
pub const _opaque_pthread_mutexattr_t = struct__opaque_pthread_mutexattr_t;
pub const _opaque_pthread_once_t = struct__opaque_pthread_once_t;
pub const _opaque_pthread_rwlock_t = struct__opaque_pthread_rwlock_t;
pub const _opaque_pthread_rwlockattr_t = struct__opaque_pthread_rwlockattr_t;
pub const _opaque_pthread_t = struct__opaque_pthread_t;
pub const __sbuf = struct___sbuf;
pub const __sFILEX = struct___sFILEX;
pub const __sFILE = struct___sFILE;
pub const __darwin_i386_thread_state = struct___darwin_i386_thread_state;
pub const __darwin_fp_control = struct___darwin_fp_control;
pub const __darwin_fp_status = struct___darwin_fp_status;
pub const __darwin_mmst_reg = struct___darwin_mmst_reg;
pub const __darwin_xmm_reg = struct___darwin_xmm_reg;
pub const __darwin_ymm_reg = struct___darwin_ymm_reg;
pub const __darwin_zmm_reg = struct___darwin_zmm_reg;
pub const __darwin_opmask_reg = struct___darwin_opmask_reg;
pub const __darwin_i386_float_state = struct___darwin_i386_float_state;
pub const __darwin_i386_avx_state = struct___darwin_i386_avx_state;
pub const __darwin_i386_avx512_state = struct___darwin_i386_avx512_state;
pub const __darwin_i386_exception_state = struct___darwin_i386_exception_state;
pub const __darwin_x86_debug_state32 = struct___darwin_x86_debug_state32;
pub const __x86_pagein_state = struct___x86_pagein_state;
pub const __darwin_x86_thread_state64 = struct___darwin_x86_thread_state64;
pub const __darwin_x86_thread_full_state64 = struct___darwin_x86_thread_full_state64;
pub const __darwin_x86_float_state64 = struct___darwin_x86_float_state64;
pub const __darwin_x86_avx_state64 = struct___darwin_x86_avx_state64;
pub const __darwin_x86_avx512_state64 = struct___darwin_x86_avx512_state64;
pub const __darwin_x86_exception_state64 = struct___darwin_x86_exception_state64;
pub const __darwin_x86_debug_state64 = struct___darwin_x86_debug_state64;
pub const __darwin_x86_cpmu_state64 = struct___darwin_x86_cpmu_state64;
pub const __darwin_mcontext32 = struct___darwin_mcontext32;
pub const __darwin_mcontext_avx32 = struct___darwin_mcontext_avx32;
pub const __darwin_mcontext_avx512_32 = struct___darwin_mcontext_avx512_32;
pub const __darwin_mcontext64 = struct___darwin_mcontext64;
pub const __darwin_mcontext64_full = struct___darwin_mcontext64_full;
pub const __darwin_mcontext_avx64 = struct___darwin_mcontext_avx64;
pub const __darwin_mcontext_avx64_full = struct___darwin_mcontext_avx64_full;
pub const __darwin_mcontext_avx512_64 = struct___darwin_mcontext_avx512_64;
pub const __darwin_mcontext_avx512_64_full = struct___darwin_mcontext_avx512_64_full;
pub const __darwin_sigaltstack = struct___darwin_sigaltstack;
pub const __darwin_ucontext = struct___darwin_ucontext;
pub const sigval = union_sigval;
pub const sigevent = struct_sigevent;
pub const __siginfo = struct___siginfo;
pub const __sigaction_u = union___sigaction_u;
pub const __sigaction = struct___sigaction;
pub const sigaction = struct_sigaction;
pub const sigvec = struct_sigvec;
pub const sigstack = struct_sigstack;
pub const timeval = struct_timeval;
pub const rusage = struct_rusage;
pub const rusage_info_v0 = struct_rusage_info_v0;
pub const rusage_info_v1 = struct_rusage_info_v1;
pub const rusage_info_v2 = struct_rusage_info_v2;
pub const rusage_info_v3 = struct_rusage_info_v3;
pub const rusage_info_v4 = struct_rusage_info_v4;
pub const rlimit = struct_rlimit;
pub const proc_rlimit_control_wakeupmon = struct_proc_rlimit_control_wakeupmon;
pub const FT_MemoryRec_ = struct_FT_MemoryRec_;
pub const FT_StreamDesc_ = union_FT_StreamDesc_;
pub const FT_StreamRec_ = struct_FT_StreamRec_;
pub const FT_Vector_ = struct_FT_Vector_;
pub const FT_BBox_ = struct_FT_BBox_;
pub const FT_Pixel_Mode_ = enum_FT_Pixel_Mode_;
pub const FT_Bitmap_ = struct_FT_Bitmap_;
pub const FT_Outline_ = struct_FT_Outline_;
pub const FT_Outline_Funcs_ = struct_FT_Outline_Funcs_;
pub const FT_Glyph_Format_ = enum_FT_Glyph_Format_;
pub const FT_Span_ = struct_FT_Span_;
pub const FT_Raster_Params_ = struct_FT_Raster_Params_;
pub const FT_RasterRec_ = struct_FT_RasterRec_;
pub const FT_Raster_Funcs_ = struct_FT_Raster_Funcs_;
pub const FT_UnitVector_ = struct_FT_UnitVector_;
pub const FT_Matrix_ = struct_FT_Matrix_;
pub const FT_Data_ = struct_FT_Data_;
pub const FT_Generic_ = struct_FT_Generic_;
pub const FT_ListNodeRec_ = struct_FT_ListNodeRec_;
pub const FT_ListRec_ = struct_FT_ListRec_;
pub const FT_Glyph_Metrics_ = struct_FT_Glyph_Metrics_;
pub const FT_Bitmap_Size_ = struct_FT_Bitmap_Size_;
pub const FT_LibraryRec_ = struct_FT_LibraryRec_;
pub const FT_ModuleRec_ = struct_FT_ModuleRec_;
pub const FT_DriverRec_ = struct_FT_DriverRec_;
pub const FT_RendererRec_ = struct_FT_RendererRec_;
pub const FT_Encoding_ = enum_FT_Encoding_;
pub const FT_CharMapRec_ = struct_FT_CharMapRec_;
pub const FT_SubGlyphRec_ = struct_FT_SubGlyphRec_;
pub const FT_Slot_InternalRec_ = struct_FT_Slot_InternalRec_;
pub const FT_GlyphSlotRec_ = struct_FT_GlyphSlotRec_;
pub const FT_Size_Metrics_ = struct_FT_Size_Metrics_;
pub const FT_Size_InternalRec_ = struct_FT_Size_InternalRec_;
pub const FT_SizeRec_ = struct_FT_SizeRec_;
pub const FT_Face_InternalRec_ = struct_FT_Face_InternalRec_;
pub const FT_FaceRec_ = struct_FT_FaceRec_;
pub const FT_Parameter_ = struct_FT_Parameter_;
pub const FT_Open_Args_ = struct_FT_Open_Args_;
pub const FT_Size_Request_Type_ = enum_FT_Size_Request_Type_;
pub const FT_Size_RequestRec_ = struct_FT_Size_RequestRec_;
pub const FT_Render_Mode_ = enum_FT_Render_Mode_;
pub const FT_Kerning_Mode_ = enum_FT_Kerning_Mode_; | vendor/freetype.zig |
const std = @import("std");
usingnamespace @import("kiragine").kira.log;
const engine = @import("kiragine");
const windowWidth = 1024;
const windowHeight = 768;
const title = "Shapes";
const targetfps = 60;
fn draw() !void {
engine.clearScreen(0.1, 0.1, 0.1, 1.0);
// Push the pixel batch, it can't be mixed with any other
try engine.pushBatch2D(engine.Renderer2DBatchTag.pixels);
// Draw pixels
var i: u32 = 0;
while (i < 10) : (i += 1) {
try engine.drawPixel(.{ .x = 630 + @intToFloat(f32, i), .y = 100 + @intToFloat(f32, i * i) }, engine.Colour.rgba(240, 30, 30, 255));
try engine.drawPixel(.{ .x = 630 - @intToFloat(f32, i), .y = 100 + @intToFloat(f32, i * i) }, engine.Colour.rgba(240, 240, 240, 255));
}
// Pops the current batch
try engine.popBatch2D();
// Push the line batch, it can't be mixed with any other
try engine.pushBatch2D(engine.Renderer2DBatchTag.lines);
// Draw line
try engine.drawLine(.{ .x = 400, .y = 400 }, .{ .x = 400, .y = 500 }, engine.Colour.rgba(255, 255, 255, 255));
// Draws a circle lines
try engine.drawCircleLines(.{ .x = 700, .y = 200 }, 30, engine.Colour.rgba(200, 200, 200, 255));
// Pops the current batch
try engine.popBatch2D();
// Push the triangle batch, it can be mixed with quad batch
try engine.pushBatch2D(engine.Renderer2DBatchTag.triangles);
// or
// try engine.pushBatch2D(engine.Renderer2DBatchTag.quads);
const triangle = [3]engine.Vec2f{
.{ .x = 100, .y = 100 },
.{ .x = 125, .y = 75 },
.{ .x = 150, .y = 100 },
};
// Draw triangle
try engine.drawTriangle(triangle[0], triangle[1], triangle[2], engine.Colour.rgba(70, 200, 30, 255));
// Draw rectangle
try engine.drawRectangle(.{ .x = 300, .y = 300, .width = 32, .height = 32 }, engine.Colour.rgba(200, 70, 30, 255));
// Draw rectangle rotated
const origin = engine.Vec2f{ .x = 16, .y = 16 };
const rot = engine.kira.math.deg2radf(45);
try engine.drawRectangleRotated(.{ .x = 500, .y = 300, .width = 32, .height = 32 }, origin, rot, engine.Colour.rgba(30, 70, 200, 255));
// Draws a circle
try engine.drawCircle(.{ .x = 700, .y = 500 }, 30, engine.Colour.rgba(200, 200, 200, 255));
// Pops the current batch
try engine.popBatch2D();
}
pub fn main() !void {
const callbacks = engine.Callbacks{
.draw = draw,
};
try engine.init(callbacks, windowWidth, windowHeight, title, targetfps, std.heap.page_allocator);
try engine.open();
try engine.update();
try engine.deinit();
} | examples/shapedraw.zig |
const std = @import("std");
const kira = @import("kira");
const check = kira.utils.check;
usingnamespace kira.log;
const clap = @import("zig-clap/clap.zig");
const fallback_output = "testbuf";
const fallback_actual_output = "actual-testbuf";
pub fn main() !void {
// First we specify what parameters our program can take.
const params = [_]clap.Param(u8){
clap.Param(u8){
.id = 'f',
.takes_value = .One,
},
clap.Param(u8){
.id = 'h',
.names = clap.Names{ .short = 'h', .long = "help" },
.takes_value = .None,
},
clap.Param(u8){
.id = 'o',
.names = clap.Names{ .short = 'o', .long = "output" },
.takes_value = .One,
},
clap.Param(u8){
.id = 'a',
.names = clap.Names{ .short = 'a', .long = "actual-output" },
.takes_value = .One,
},
};
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
var alloc = &gpa.allocator;
var file: std.fs.File = undefined;
var output: ?[]const u8 = null;
var actual_output: ?[]const u8 = null;
var elements = std.ArrayList(kira.utils.DataPacker.Element).init(alloc);
// We then initialize an argument iterator. We will use the OsIterator as it nicely
// wraps iterating over arguments the most efficient way on each os.
var iter = try clap.args.OsIterator.init(alloc);
defer iter.deinit();
// Initialize our streaming parser.
var parser = clap.StreamingClap(u8, clap.args.OsIterator){
.params = ¶ms,
.iter = &iter,
};
// Pack the data into a file
{
var packer = try kira.utils.DataPacker.init(alloc, 1024);
defer packer.deinit();
// Because we use a streaming parser, we have to consume each argument parsed individually.
while (try parser.next()) |arg| {
// arg.param will point to the parameter which matched the argument.
switch (arg.param.id) {
'h' => {
std.debug.print("************ Asset packer help section *************\n", .{});
std.debug.print("-h, --help Display this help and exit.\n", .{});
std.debug.print("-o, --output Name of the data file.\n", .{});
std.debug.print("-a, --actual_output Name of the data locations file.\n", .{});
std.debug.print("<source-file> Path to a source file(can up to as many as you want).\n", .{});
std.debug.print("****************************************************\n", .{});
},
'o' => {
if (arg.value) |val| {
output.? = val;
} else {
output = fallback_output;
std.log.scoped(.assetpacker).err("Output file not found! Fallback to using '{}'!", .{output.?});
}
},
'a' => {
if (arg.value) |val| {
actual_output.? = val;
} else {
actual_output = fallback_actual_output;
std.log.scoped(.assetpacker).err("Actual output file not found! Fallback to using '{}'!", .{actual_output.?});
}
},
'f' => {
std.log.scoped(.assetpacker).info("Reading source: {}", .{arg.value.?});
file = try std.fs.cwd().openFile(arg.value.?, .{});
const len = try file.getEndPos();
const stream = file.reader();
const data = try stream.readAllAlloc(alloc, len);
file.close();
const res = try packer.append(data);
try elements.append(res);
alloc.free(data);
},
else => unreachable,
}
}
if (elements.items.len == 0) {
std.log.scoped(.assetpacker).emerg("Please specify atleast one source file. For more information use -h or --help flag.", .{});
return;
}
if (output == null) {
output = fallback_output;
std.log.scoped(.assetpacker).err("Output file not found! Fallback to using '{}'!", .{output.?});
}
if (actual_output == null) {
actual_output = fallback_actual_output;
std.log.scoped(.assetpacker).err("Actual output file not found! Fallback to using '{}'!", .{actual_output.?});
}
std.log.scoped(.assetpacker).info("Writing the data into '{}'!", .{output.?});
file = try std.fs.cwd().createFile(output.?, .{});
try file.writeAll(packer.buffer[0..packer.stack]);
file.close();
std.log.scoped(.assetpacker).info("Writing the data locations into '{}'!", .{actual_output.?});
{
file = try std.fs.cwd().createFile(actual_output.?, .{});
defer file.close();
var i: u32 = 0;
// Format the data
while (i < elements.items.len) : (i += 1) {
const data = elements.items[i];
// <id> <start position> <end position>
const buf = try std.fmt.allocPrint(alloc, "{} {} {}\n", .{ i, data.start, data.end });
try file.writeAll(buf);
alloc.free(buf);
}
}
elements.deinit();
}
std.log.scoped(.assetpacker).info("Done.", .{});
try check(gpa.deinit() == true, "Leak found!", .{});
} | tools/assetpacker.zig |
const std = @import("std");
// Depending on the length of the input, we can easily determine
// the digit for some inputs and which segments are active
// Length 2 => 1: c, f
// Length 3 => 7: a, c, f
// Length 4 => 4: b, c, d, f
// Length 7 => 8: a, b, c, d, e, f, g
// For the other two cases, it's trickier but we can deduce based on
// the inputs we always know
// Length 5 => 2, 3 or 5: a, d, g is always active; b, c, e, f differ
// If the segments overlap completely with 1 => 3
// If two segments overlap with 4 => 2
// If three segments overlap with 4 => 5
// Length 6 => 0, 6 or 9: a, b, f, g is always active; c, d, e differ
// If the segments don't overlap completely with 1 => 6
// If it completely overlaps with 4 => 9
// else => 0
test "example" {
const input = @embedFile("8_example.txt");
const result = run(input);
try std.testing.expectEqual(@as(usize, 61229), result);
}
pub fn main() void {
const input = @embedFile("8.txt");
const result = run(input);
std.debug.print("{}\n", .{result});
}
fn run(input: []const u8) usize {
var total: usize = 0;
var lines = std.mem.split(u8, input, "\n");
while (lines.next()) |line| {
var pipe_index = std.mem.indexOfScalar(u8, line, '|').?;
total += process(line[0 .. pipe_index - 1], line[pipe_index + 2 ..]);
}
return total;
}
fn process(segments: []const u8, numbers: []const u8) usize {
var digits: [10]?u7 = .{null} ** 10;
var remaining: usize = 10;
while (remaining > 0) {
var segment_tokens = std.mem.tokenize(u8, segments, " ");
while (segment_tokens.next()) |segment| {
var digit = wiresToDigit(segment);
switch (@popCount(u7, digit)) {
2 => { // 1
if (digits[1] == null) remaining -= 1;
digits[1] = digit;
},
3 => { // 7
if (digits[7] == null) remaining -= 1;
digits[7] = digit;
},
4 => { // 4
if (digits[4] == null) remaining -= 1;
digits[4] = digit;
},
7 => { // 8
if (digits[8] == null) remaining -= 1;
digits[8] = digit;
},
5 => { // 2,3,5
if (digits[1]) |one| {
if (digit & one == one) { // 3
if (digits[3] == null) remaining -= 1;
digits[3] = digit;
} else if (digits[4]) |four| {
const overlap = @popCount(u7, four & digit);
if (overlap == 2) { // 2
if (digits[2] == null) remaining -= 1;
digits[2] = digit;
} else if (overlap == 3) { // 5
if (digits[5] == null) remaining -= 1;
digits[5] = digit;
} else unreachable;
}
}
},
6 => { // 0, 6, 9
if (digits[1]) |one| {
if (digit & one != one) { // 6
if (digits[6] == null) remaining -= 1;
digits[6] = digit;
} else if (digits[4]) |four| {
if (digit & four == four) { // 9
if (digits[9] == null) remaining -= 1;
digits[9] = digit;
} else { // 0
if (digits[0] == null) remaining -= 1;
digits[0] = digit;
}
}
}
},
else => unreachable,
}
}
}
var number_tokens = std.mem.tokenize(u8, numbers, " ");
var result: usize = 0;
while (number_tokens.next()) |number| {
const n = wiresToDigit(number);
for (digits) |d, i| {
if (n == d.?) {
result = result * 10 + i;
break;
}
} else unreachable;
}
return result;
}
fn wiresToDigit(wires: []const u8) u7 {
var digit: u7 = 0;
for (wires) |c| {
if (c < 'a' or c > 'g') unreachable;
const mask = @as(u7, 1) << @intCast(u3, c - 'a');
digit |= mask;
}
return digit;
} | shritesh+zig/8b.zig |
const MachO = @This();
const std = @import("std");
const build_options = @import("build_options");
const builtin = @import("builtin");
const assert = std.debug.assert;
const fmt = std.fmt;
const fs = std.fs;
const log = std.log.scoped(.macho);
const macho = std.macho;
const math = std.math;
const mem = std.mem;
const meta = std.meta;
const aarch64 = @import("aarch64.zig");
const bind = @import("MachO/bind.zig");
const commands = @import("MachO/commands.zig");
const Allocator = mem.Allocator;
const Archive = @import("MachO/Archive.zig");
const Atom = @import("MachO/Atom.zig");
const CodeSignature = @import("MachO/CodeSignature.zig");
const Dylib = @import("MachO/Dylib.zig");
const Object = @import("MachO/Object.zig");
const LibStub = @import("tapi.zig").LibStub;
const LoadCommand = commands.LoadCommand;
const SegmentCommand = commands.SegmentCommand;
const StringIndexAdapter = std.hash_map.StringIndexAdapter;
const StringIndexContext = std.hash_map.StringIndexContext;
const Trie = @import("MachO/Trie.zig");
const Zld = @import("Zld.zig");
pub const base_tag = Zld.Tag.macho;
base: Zld,
/// Page size is dependent on the target cpu architecture.
/// For x86_64 that's 4KB, whereas for aarch64, that's 16KB.
page_size: u16,
/// TODO Should we figure out embedding code signatures for other Apple platforms as part of the linker?
/// Or should this be a separate tool?
/// https://github.com/ziglang/zig/issues/9567
requires_adhoc_codesig: bool,
/// We commit 0x1000 = 4096 bytes of space to the header and
/// the table of load commands. This should be plenty for any
/// potential future extensions.
header_pad: u16 = 0x1000,
objects: std.ArrayListUnmanaged(Object) = .{},
archives: std.ArrayListUnmanaged(Archive) = .{},
dylibs: std.ArrayListUnmanaged(Dylib) = .{},
dylibs_map: std.StringHashMapUnmanaged(u16) = .{},
referenced_dylibs: std.AutoArrayHashMapUnmanaged(u16, void) = .{},
load_commands: std.ArrayListUnmanaged(LoadCommand) = .{},
pagezero_segment_cmd_index: ?u16 = null,
text_segment_cmd_index: ?u16 = null,
data_const_segment_cmd_index: ?u16 = null,
data_segment_cmd_index: ?u16 = null,
linkedit_segment_cmd_index: ?u16 = null,
dyld_info_cmd_index: ?u16 = null,
symtab_cmd_index: ?u16 = null,
dysymtab_cmd_index: ?u16 = null,
dylinker_cmd_index: ?u16 = null,
data_in_code_cmd_index: ?u16 = null,
function_starts_cmd_index: ?u16 = null,
main_cmd_index: ?u16 = null,
dylib_id_cmd_index: ?u16 = null,
source_version_cmd_index: ?u16 = null,
build_version_cmd_index: ?u16 = null,
uuid_cmd_index: ?u16 = null,
code_signature_cmd_index: ?u16 = null,
// __TEXT segment sections
text_section_index: ?u16 = null,
stubs_section_index: ?u16 = null,
stub_helper_section_index: ?u16 = null,
text_const_section_index: ?u16 = null,
cstring_section_index: ?u16 = null,
ustring_section_index: ?u16 = null,
gcc_except_tab_section_index: ?u16 = null,
unwind_info_section_index: ?u16 = null,
eh_frame_section_index: ?u16 = null,
objc_methlist_section_index: ?u16 = null,
objc_methname_section_index: ?u16 = null,
objc_methtype_section_index: ?u16 = null,
objc_classname_section_index: ?u16 = null,
// __DATA_CONST segment sections
got_section_index: ?u16 = null,
mod_init_func_section_index: ?u16 = null,
mod_term_func_section_index: ?u16 = null,
data_const_section_index: ?u16 = null,
objc_cfstring_section_index: ?u16 = null,
objc_classlist_section_index: ?u16 = null,
objc_imageinfo_section_index: ?u16 = null,
// __DATA segment sections
tlv_section_index: ?u16 = null,
tlv_data_section_index: ?u16 = null,
tlv_bss_section_index: ?u16 = null,
la_symbol_ptr_section_index: ?u16 = null,
data_section_index: ?u16 = null,
bss_section_index: ?u16 = null,
objc_const_section_index: ?u16 = null,
objc_selrefs_section_index: ?u16 = null,
objc_classrefs_section_index: ?u16 = null,
objc_data_section_index: ?u16 = null,
locals: std.ArrayListUnmanaged(macho.nlist_64) = .{},
globals: std.ArrayListUnmanaged(macho.nlist_64) = .{},
undefs: std.ArrayListUnmanaged(macho.nlist_64) = .{},
symbol_resolver: std.AutoHashMapUnmanaged(u32, SymbolWithLoc) = .{},
unresolved: std.AutoArrayHashMapUnmanaged(u32, void) = .{},
tentatives: std.AutoArrayHashMapUnmanaged(u32, void) = .{},
mh_execute_header_index: ?u32 = null,
dyld_stub_binder_index: ?u32 = null,
dyld_private_atom: ?*Atom = null,
stub_helper_preamble_atom: ?*Atom = null,
strtab: std.ArrayListUnmanaged(u8) = .{},
strtab_dir: std.HashMapUnmanaged(u32, void, StringIndexContext, std.hash_map.default_max_load_percentage) = .{},
got_entries_map: std.AutoArrayHashMapUnmanaged(Atom.Relocation.Target, *Atom) = .{},
stubs_map: std.AutoArrayHashMapUnmanaged(u32, *Atom) = .{},
has_dices: bool = false,
has_stabs: bool = false,
section_ordinals: std.AutoArrayHashMapUnmanaged(MatchingSection, void) = .{},
/// Pointer to the last allocated atom
atoms: std.AutoHashMapUnmanaged(MatchingSection, *Atom) = .{},
/// List of atoms that are owned directly by the linker.
/// Currently these are only atoms that are the result of linking
/// object files. Atoms which take part in incremental linking are
/// at present owned by Module.Decl.
/// TODO consolidate this.
managed_atoms: std.ArrayListUnmanaged(*Atom) = .{},
const SymbolWithLoc = struct {
// Table where the symbol can be found.
where: enum {
global,
undef,
},
where_index: u32,
local_sym_index: u32 = 0,
file: ?u16 = null, // null means Zig module
};
/// Default path to dyld
const default_dyld_path: [*:0]const u8 = "/usr/lib/dyld";
/// Virtual memory offset corresponds to the size of __PAGEZERO segment and start of
/// __TEXT segment.
const pagezero_vmsize: u64 = 0x100000000;
pub fn openPath(allocator: Allocator, options: Zld.Options) !*MachO {
const file = try options.emit.directory.createFile(options.emit.sub_path, .{
.truncate = true,
.read = true,
.mode = if (builtin.os.tag == .windows) 0 else 0o777,
});
errdefer file.close();
const self = try createEmpty(allocator, options);
errdefer self.base.destroy();
self.base.file = file;
return self;
}
fn createEmpty(gpa: Allocator, options: Zld.Options) !*MachO {
const self = try gpa.create(MachO);
const cpu_arch = options.target.cpu.arch;
const os_tag = options.target.os.tag;
const abi = options.target.abi;
const page_size: u16 = if (cpu_arch == .aarch64) 0x4000 else 0x1000;
// Adhoc code signature is required when targeting aarch64-macos either directly or indirectly via the simulator
// ABI such as aarch64-ios-simulator, etc.
const requires_adhoc_codesig = cpu_arch == .aarch64 and (os_tag == .macos or abi == .simulator);
self.* = .{
.base = .{
.tag = .macho,
.options = options,
.allocator = gpa,
.file = undefined,
},
.page_size = page_size,
.requires_adhoc_codesig = requires_adhoc_codesig,
};
return self;
}
pub fn flush(self: *MachO) !void {
var arena_allocator = std.heap.ArenaAllocator.init(self.base.allocator);
defer arena_allocator.deinit();
const arena = arena_allocator.allocator();
const syslibroot = self.base.options.syslibroot;
var lib_dirs = std.ArrayList([]const u8).init(arena);
for (self.base.options.lib_dirs) |dir| {
if (try resolveSearchDir(arena, dir, syslibroot)) |search_dir| {
try lib_dirs.append(search_dir);
} else {
log.warn("directory not found for '-L{s}'", .{dir});
}
}
if (builtin.os.tag == .macos) {
if (try resolveSearchDir(arena, "/usr/lib", syslibroot)) |search_dir| {
try lib_dirs.append(search_dir);
}
}
var libs = std.ArrayList([]const u8).init(arena);
var lib_not_found = false;
for (self.base.options.libs) |lib_name| {
// Assume ld64 default: -search_paths_first
// Look in each directory for a dylib (stub first), and then for archive
// TODO implement alternative: -search_dylibs_first
for (&[_][]const u8{ ".tbd", ".dylib", ".a" }) |ext| {
if (try resolveLib(arena, lib_dirs.items, lib_name, ext)) |full_path| {
try libs.append(full_path);
break;
}
} else {
log.warn("library not found for '-l{s}'", .{lib_name});
lib_not_found = true;
}
}
if (lib_not_found) {
log.warn("Library search paths:", .{});
for (lib_dirs.items) |dir| {
log.warn(" {s}", .{dir});
}
}
if (builtin.os.tag == .macos) {
for (&[_][]const u8{ "System", "c" }) |lib_name| {
for (&[_][]const u8{ ".tbd", ".dylib", ".a" }) |ext| {
if (try resolveLib(arena, lib_dirs.items, lib_name, ext)) |full_path| {
try libs.append(full_path);
break;
}
}
}
}
// frameworks
var framework_dirs = std.ArrayList([]const u8).init(arena);
for (self.base.options.framework_dirs) |dir| {
if (try resolveSearchDir(arena, dir, syslibroot)) |search_dir| {
try framework_dirs.append(search_dir);
} else {
log.warn("directory not found for '-F{s}'", .{dir});
}
}
if (builtin.os.tag == .macos and self.base.options.frameworks.len > 0) {
if (try resolveSearchDir(arena, "/System/Library/Frameworks", syslibroot)) |search_dir| {
try framework_dirs.append(search_dir);
}
}
var framework_not_found = false;
for (self.base.options.frameworks) |framework| {
for (&[_][]const u8{ ".tbd", ".dylib", "" }) |ext| {
if (try resolveFramework(arena, framework_dirs.items, framework, ext)) |full_path| {
try libs.append(full_path);
break;
}
} else {
log.warn("framework not found for '-framework {s}'", .{framework});
framework_not_found = true;
}
}
if (framework_not_found) {
log.warn("Framework search paths:", .{});
for (framework_dirs.items) |dir| {
log.warn(" {s}", .{dir});
}
}
// rpaths
var rpath_table = std.StringArrayHashMap(void).init(arena);
for (self.base.options.rpath_list) |rpath| {
if (rpath_table.contains(rpath)) continue;
try rpath_table.putNoClobber(rpath, {});
}
try self.strtab.append(self.base.allocator, 0);
try self.populateMetadata();
var dependent_libs = std.fifo.LinearFifo(Dylib.Id, .Dynamic).init(self.base.allocator);
defer dependent_libs.deinit();
try self.parsePositionals(self.base.options.positionals, syslibroot, &dependent_libs);
try self.parseLibs(libs.items, syslibroot, &dependent_libs);
try self.parseDependentLibs(syslibroot, &dependent_libs);
try self.createMhExecuteHeaderAtom();
for (self.objects.items) |_, object_id| {
try self.resolveSymbolsInObject(@intCast(u16, object_id));
}
try self.resolveSymbolsInArchives();
try self.resolveDyldStubBinder();
try self.createDyldPrivateAtom();
try self.createStubHelperPreambleAtom();
try self.resolveSymbolsInDylibs();
try self.createDsoHandleAtom();
{
var next_sym: usize = 0;
while (next_sym < self.unresolved.count()) {
const sym = &self.undefs.items[self.unresolved.keys()[next_sym]];
const sym_name = self.getString(sym.n_strx);
const resolv = self.symbol_resolver.get(sym.n_strx) orelse unreachable;
if (sym.discarded()) {
sym.* = .{
.n_strx = 0,
.n_type = macho.N_UNDF,
.n_sect = 0,
.n_desc = 0,
.n_value = 0,
};
_ = self.unresolved.swapRemove(resolv.where_index);
continue;
}
log.err("undefined reference to symbol '{s}'", .{sym_name});
if (resolv.file) |file| {
log.err(" first referenced in '{s}'", .{self.objects.items[file].name});
}
next_sym += 1;
}
}
if (self.unresolved.count() > 0) {
return error.UndefinedSymbolReference;
}
try self.createTentativeDefAtoms();
for (self.objects.items) |*object| {
try object.parseIntoAtoms(self.base.allocator, self);
}
try self.sortSections();
try self.addRpathLCs(rpath_table.keys());
try self.addLoadDylibLCs();
try self.addDataInCodeLC();
try self.addCodeSignatureLC();
try self.allocateTextSegment();
try self.allocateDataConstSegment();
try self.allocateDataSegment();
self.allocateLinkeditSegment();
try self.allocateAtoms();
try self.writeAtoms();
if (self.bss_section_index) |idx| {
const seg = &self.load_commands.items[self.data_segment_cmd_index.?].Segment;
const sect = &seg.sections.items[idx];
sect.offset = 0;
}
if (self.tlv_bss_section_index) |idx| {
const seg = &self.load_commands.items[self.data_segment_cmd_index.?].Segment;
const sect = &seg.sections.items[idx];
sect.offset = 0;
}
try self.setEntryPoint();
try self.writeLinkeditSegment();
if (self.requires_adhoc_codesig) {
// Preallocate space for the code signature.
// We need to do this at this stage so that we have the load commands with proper values
// written out to the file.
// The most important here is to have the correct vm and filesize of the __LINKEDIT segment
// where the code signature goes into.
try self.writeCodeSignaturePadding();
}
try self.writeLoadCommands();
try self.writeHeader();
if (self.requires_adhoc_codesig) {
try self.writeCodeSignature(); // code signing always comes last
const dir = self.base.options.emit.directory;
const path = self.base.options.emit.sub_path;
try dir.copyFile(path, dir, path, .{});
}
}
fn resolveSearchDir(
arena: Allocator,
dir: []const u8,
syslibroot: ?[]const u8,
) !?[]const u8 {
var candidates = std.ArrayList([]const u8).init(arena);
if (fs.path.isAbsolute(dir)) {
if (syslibroot) |root| {
const common_dir = if (builtin.os.tag == .windows) blk: {
// We need to check for disk designator and strip it out from dir path so
// that we can concat dir with syslibroot.
// TODO we should backport this mechanism to 'MachO.Dylib.parseDependentLibs()'
const disk_designator = fs.path.diskDesignatorWindows(dir);
if (mem.indexOf(u8, dir, disk_designator)) |where| {
break :blk dir[where + disk_designator.len ..];
}
break :blk dir;
} else dir;
const full_path = try fs.path.join(arena, &[_][]const u8{ root, common_dir });
try candidates.append(full_path);
}
}
try candidates.append(dir);
for (candidates.items) |candidate| {
// Verify that search path actually exists
var tmp = fs.cwd().openDir(candidate, .{}) catch |err| switch (err) {
error.FileNotFound => continue,
else => |e| return e,
};
defer tmp.close();
return candidate;
}
return null;
}
fn resolveLib(
arena: Allocator,
search_dirs: []const []const u8,
name: []const u8,
ext: []const u8,
) !?[]const u8 {
const search_name = try std.fmt.allocPrint(arena, "lib{s}{s}", .{ name, ext });
for (search_dirs) |dir| {
const full_path = try fs.path.join(arena, &[_][]const u8{ dir, search_name });
// Check if the file exists.
const tmp = fs.cwd().openFile(full_path, .{}) catch |err| switch (err) {
error.FileNotFound => continue,
else => |e| return e,
};
defer tmp.close();
return full_path;
}
return null;
}
fn resolveFramework(
arena: Allocator,
search_dirs: []const []const u8,
name: []const u8,
ext: []const u8,
) !?[]const u8 {
const search_name = try std.fmt.allocPrint(arena, "{s}{s}", .{ name, ext });
const prefix_path = try std.fmt.allocPrint(arena, "{s}.framework", .{name});
for (search_dirs) |dir| {
const full_path = try fs.path.join(arena, &[_][]const u8{ dir, prefix_path, search_name });
// Check if the file exists.
const tmp = fs.cwd().openFile(full_path, .{}) catch |err| switch (err) {
error.FileNotFound => continue,
else => |e| return e,
};
defer tmp.close();
return full_path;
}
return null;
}
fn parseObject(self: *MachO, path: []const u8) !bool {
const file = fs.cwd().openFile(path, .{}) catch |err| switch (err) {
error.FileNotFound => return false,
else => |e| return e,
};
errdefer file.close();
const name = try self.base.allocator.dupe(u8, path);
errdefer self.base.allocator.free(name);
var object = Object{
.name = name,
.file = file,
};
object.parse(self.base.allocator, self.base.options.target) catch |err| switch (err) {
error.EndOfStream, error.NotObject => {
object.deinit(self.base.allocator);
return false;
},
else => |e| return e,
};
try self.objects.append(self.base.allocator, object);
return true;
}
fn parseArchive(self: *MachO, path: []const u8) !bool {
const file = fs.cwd().openFile(path, .{}) catch |err| switch (err) {
error.FileNotFound => return false,
else => |e| return e,
};
errdefer file.close();
const name = try self.base.allocator.dupe(u8, path);
errdefer self.base.allocator.free(name);
var archive = Archive{
.name = name,
.file = file,
};
archive.parse(self.base.allocator, self.base.options.target) catch |err| switch (err) {
error.EndOfStream, error.NotArchive => {
archive.deinit(self.base.allocator);
return false;
},
else => |e| return e,
};
try self.archives.append(self.base.allocator, archive);
return true;
}
const ParseDylibError = error{
OutOfMemory,
EmptyStubFile,
MismatchedCpuArchitecture,
UnsupportedCpuArchitecture,
} || fs.File.OpenError || std.os.PReadError || Dylib.Id.ParseError;
const DylibCreateOpts = struct {
syslibroot: ?[]const u8,
dependent_libs: *std.fifo.LinearFifo(Dylib.Id, .Dynamic),
id: ?Dylib.Id = null,
is_dependent: bool = false,
};
pub fn parseDylib(self: *MachO, path: []const u8, opts: DylibCreateOpts) ParseDylibError!bool {
const file = fs.cwd().openFile(path, .{}) catch |err| switch (err) {
error.FileNotFound => return false,
else => |e| return e,
};
errdefer file.close();
const name = try self.base.allocator.dupe(u8, path);
errdefer self.base.allocator.free(name);
var dylib = Dylib{
.name = name,
.file = file,
};
dylib.parse(self.base.allocator, self.base.options.target, opts.dependent_libs) catch |err| switch (err) {
error.EndOfStream, error.NotDylib => {
try file.seekTo(0);
var lib_stub = LibStub.loadFromFile(self.base.allocator, file) catch {
dylib.deinit(self.base.allocator);
return false;
};
defer lib_stub.deinit();
try dylib.parseFromStub(self.base.allocator, self.base.options.target, lib_stub, opts.dependent_libs);
},
else => |e| return e,
};
if (opts.id) |id| {
if (dylib.id.?.current_version < id.compatibility_version) {
log.warn("found dylib is incompatible with the required minimum version", .{});
log.warn(" dylib: {s}", .{id.name});
log.warn(" required minimum version: {}", .{id.compatibility_version});
log.warn(" dylib version: {}", .{dylib.id.?.current_version});
// TODO maybe this should be an error and facilitate auto-cleanup?
dylib.deinit(self.base.allocator);
return false;
}
}
if (self.dylibs_map.contains(dylib.id.?.name)) {
// Hmm, seems we already parsed this dylib.
return true;
}
const dylib_id = @intCast(u16, self.dylibs.items.len);
try self.dylibs.append(self.base.allocator, dylib);
try self.dylibs_map.putNoClobber(self.base.allocator, dylib.id.?.name, dylib_id);
if (!(opts.is_dependent or self.referenced_dylibs.contains(dylib_id))) {
try self.referenced_dylibs.putNoClobber(self.base.allocator, dylib_id, {});
}
return true;
}
fn parsePositionals(self: *MachO, files: []const []const u8, syslibroot: ?[]const u8, dependent_libs: anytype) !void {
for (files) |file_name| {
const full_path = full_path: {
var buffer: [fs.MAX_PATH_BYTES]u8 = undefined;
const path = try std.fs.realpath(file_name, &buffer);
break :full_path try self.base.allocator.dupe(u8, path);
};
defer self.base.allocator.free(full_path);
log.debug("parsing input file path '{s}'", .{full_path});
if (try self.parseObject(full_path)) continue;
if (try self.parseArchive(full_path)) continue;
if (try self.parseDylib(full_path, .{
.syslibroot = syslibroot,
.dependent_libs = dependent_libs,
})) continue;
log.warn("unknown filetype for positional input file: '{s}'", .{file_name});
}
}
fn parseLibs(self: *MachO, libs: []const []const u8, syslibroot: ?[]const u8, dependent_libs: anytype) !void {
for (libs) |lib| {
log.debug("parsing lib path '{s}'", .{lib});
if (try self.parseDylib(lib, .{
.syslibroot = syslibroot,
.dependent_libs = dependent_libs,
})) continue;
if (try self.parseArchive(lib)) continue;
log.warn("unknown filetype for a library: '{s}'", .{lib});
}
}
fn parseDependentLibs(self: *MachO, syslibroot: ?[]const u8, dependent_libs: anytype) !void {
// At this point, we can now parse dependents of dylibs preserving the inclusion order of:
// 1) anything on the linker line is parsed first
// 2) afterwards, we parse dependents of the included dylibs
// TODO this should not be performed if the user specifies `-flat_namespace` flag.
// See ld64 manpages.
var arena_alloc = std.heap.ArenaAllocator.init(self.base.allocator);
const arena = arena_alloc.allocator();
defer arena_alloc.deinit();
while (dependent_libs.readItem()) |*id| {
defer id.deinit(self.base.allocator);
if (self.dylibs_map.contains(id.name)) continue;
const has_ext = blk: {
const basename = fs.path.basename(id.name);
break :blk mem.lastIndexOfScalar(u8, basename, '.') != null;
};
const extension = if (has_ext) fs.path.extension(id.name) else "";
const without_ext = if (has_ext) blk: {
const index = mem.lastIndexOfScalar(u8, id.name, '.') orelse unreachable;
break :blk id.name[0..index];
} else id.name;
for (&[_][]const u8{ extension, ".tbd" }) |ext| {
const with_ext = try std.fmt.allocPrint(arena, "{s}{s}", .{ without_ext, ext });
const full_path = if (syslibroot) |root| try fs.path.join(arena, &.{ root, with_ext }) else with_ext;
log.debug("trying dependency at fully resolved path {s}", .{full_path});
const did_parse_successfully = try self.parseDylib(full_path, .{
.id = id.*,
.syslibroot = syslibroot,
.is_dependent = true,
.dependent_libs = dependent_libs,
});
if (did_parse_successfully) break;
} else {
log.warn("unable to resolve dependency {s}", .{id.name});
}
}
}
pub const MatchingSection = struct {
seg: u16,
sect: u16,
};
pub fn getMatchingSection(self: *MachO, sect: macho.section_64) !?MatchingSection {
const text_seg = &self.load_commands.items[self.text_segment_cmd_index.?].Segment;
const data_const_seg = &self.load_commands.items[self.data_const_segment_cmd_index.?].Segment;
const data_seg = &self.load_commands.items[self.data_segment_cmd_index.?].Segment;
const segname = commands.segmentName(sect);
const sectname = commands.sectionName(sect);
const res: ?MatchingSection = blk: {
switch (commands.sectionType(sect)) {
macho.S_4BYTE_LITERALS, macho.S_8BYTE_LITERALS, macho.S_16BYTE_LITERALS => {
if (self.text_const_section_index == null) {
self.text_const_section_index = @intCast(u16, text_seg.sections.items.len);
try text_seg.addSection(self.base.allocator, "__const", .{});
}
break :blk .{
.seg = self.text_segment_cmd_index.?,
.sect = self.text_const_section_index.?,
};
},
macho.S_CSTRING_LITERALS => {
if (mem.eql(u8, sectname, "__objc_methname")) {
// TODO it seems the common values within the sections in objects are deduplicated/merged
// on merging the sections' contents.
if (self.objc_methname_section_index == null) {
self.objc_methname_section_index = @intCast(u16, text_seg.sections.items.len);
try text_seg.addSection(self.base.allocator, "__objc_methname", .{
.flags = macho.S_CSTRING_LITERALS,
});
}
break :blk .{
.seg = self.text_segment_cmd_index.?,
.sect = self.objc_methname_section_index.?,
};
} else if (mem.eql(u8, sectname, "__objc_methtype")) {
if (self.objc_methtype_section_index == null) {
self.objc_methtype_section_index = @intCast(u16, text_seg.sections.items.len);
try text_seg.addSection(self.base.allocator, "__objc_methtype", .{
.flags = macho.S_CSTRING_LITERALS,
});
}
break :blk .{
.seg = self.text_segment_cmd_index.?,
.sect = self.objc_methtype_section_index.?,
};
} else if (mem.eql(u8, sectname, "__objc_classname")) {
if (self.objc_classname_section_index == null) {
self.objc_classname_section_index = @intCast(u16, text_seg.sections.items.len);
try text_seg.addSection(self.base.allocator, "__objc_classname", .{});
}
break :blk .{
.seg = self.text_segment_cmd_index.?,
.sect = self.objc_classname_section_index.?,
};
}
if (self.cstring_section_index == null) {
self.cstring_section_index = @intCast(u16, text_seg.sections.items.len);
try text_seg.addSection(self.base.allocator, "__cstring", .{
.flags = macho.S_CSTRING_LITERALS,
});
}
break :blk .{
.seg = self.text_segment_cmd_index.?,
.sect = self.cstring_section_index.?,
};
},
macho.S_LITERAL_POINTERS => {
if (mem.eql(u8, segname, "__DATA") and mem.eql(u8, sectname, "__objc_selrefs")) {
if (self.objc_selrefs_section_index == null) {
self.objc_selrefs_section_index = @intCast(u16, data_seg.sections.items.len);
try data_seg.addSection(self.base.allocator, "__objc_selrefs", .{
.flags = macho.S_LITERAL_POINTERS,
});
}
break :blk .{
.seg = self.data_segment_cmd_index.?,
.sect = self.objc_selrefs_section_index.?,
};
}
// TODO investigate
break :blk null;
},
macho.S_MOD_INIT_FUNC_POINTERS => {
if (self.mod_init_func_section_index == null) {
self.mod_init_func_section_index = @intCast(u16, data_const_seg.sections.items.len);
try data_const_seg.addSection(self.base.allocator, "__mod_init_func", .{
.flags = macho.S_MOD_INIT_FUNC_POINTERS,
});
}
break :blk .{
.seg = self.data_const_segment_cmd_index.?,
.sect = self.mod_init_func_section_index.?,
};
},
macho.S_MOD_TERM_FUNC_POINTERS => {
if (self.mod_term_func_section_index == null) {
self.mod_term_func_section_index = @intCast(u16, data_const_seg.sections.items.len);
try data_const_seg.addSection(self.base.allocator, "__mod_term_func", .{
.flags = macho.S_MOD_TERM_FUNC_POINTERS,
});
}
break :blk .{
.seg = self.data_const_segment_cmd_index.?,
.sect = self.mod_term_func_section_index.?,
};
},
macho.S_ZEROFILL => {
if (self.bss_section_index == null) {
self.bss_section_index = @intCast(u16, data_seg.sections.items.len);
try data_seg.addSection(self.base.allocator, "__bss", .{
.flags = macho.S_ZEROFILL,
});
}
break :blk .{
.seg = self.data_segment_cmd_index.?,
.sect = self.bss_section_index.?,
};
},
macho.S_THREAD_LOCAL_VARIABLES => {
if (self.tlv_section_index == null) {
self.tlv_section_index = @intCast(u16, data_seg.sections.items.len);
try data_seg.addSection(self.base.allocator, "__thread_vars", .{
.flags = macho.S_THREAD_LOCAL_VARIABLES,
});
}
break :blk .{
.seg = self.data_segment_cmd_index.?,
.sect = self.tlv_section_index.?,
};
},
macho.S_THREAD_LOCAL_REGULAR => {
if (self.tlv_data_section_index == null) {
self.tlv_data_section_index = @intCast(u16, data_seg.sections.items.len);
try data_seg.addSection(self.base.allocator, "__thread_data", .{
.flags = macho.S_THREAD_LOCAL_REGULAR,
});
}
break :blk .{
.seg = self.data_segment_cmd_index.?,
.sect = self.tlv_data_section_index.?,
};
},
macho.S_THREAD_LOCAL_ZEROFILL => {
if (self.tlv_bss_section_index == null) {
self.tlv_bss_section_index = @intCast(u16, data_seg.sections.items.len);
try data_seg.addSection(self.base.allocator, "__thread_bss", .{
.flags = macho.S_THREAD_LOCAL_ZEROFILL,
});
}
break :blk .{
.seg = self.data_segment_cmd_index.?,
.sect = self.tlv_bss_section_index.?,
};
},
macho.S_COALESCED => {
if (mem.eql(u8, "__TEXT", segname) and mem.eql(u8, "__eh_frame", sectname)) {
// TODO I believe __eh_frame is currently part of __unwind_info section
// in the latest ld64 output.
if (self.eh_frame_section_index == null) {
self.eh_frame_section_index = @intCast(u16, text_seg.sections.items.len);
try text_seg.addSection(self.base.allocator, "__eh_frame", .{});
}
break :blk .{
.seg = self.text_segment_cmd_index.?,
.sect = self.eh_frame_section_index.?,
};
}
// TODO audit this: is this the right mapping?
if (self.data_const_section_index == null) {
self.data_const_section_index = @intCast(u16, data_const_seg.sections.items.len);
try data_const_seg.addSection(self.base.allocator, "__const", .{});
}
break :blk .{
.seg = self.data_const_segment_cmd_index.?,
.sect = self.data_const_section_index.?,
};
},
macho.S_REGULAR => {
if (commands.sectionIsCode(sect)) {
if (self.text_section_index == null) {
self.text_section_index = @intCast(u16, text_seg.sections.items.len);
try text_seg.addSection(self.base.allocator, "__text", .{
.flags = macho.S_REGULAR | macho.S_ATTR_PURE_INSTRUCTIONS | macho.S_ATTR_SOME_INSTRUCTIONS,
});
}
break :blk .{
.seg = self.text_segment_cmd_index.?,
.sect = self.text_section_index.?,
};
}
if (commands.sectionIsDebug(sect)) {
// TODO debug attributes
if (mem.eql(u8, "__LD", segname) and mem.eql(u8, "__compact_unwind", sectname)) {
log.debug("TODO compact unwind section: type 0x{x}, name '{s},{s}'", .{
sect.flags, segname, sectname,
});
}
break :blk null;
}
if (mem.eql(u8, segname, "__TEXT")) {
if (mem.eql(u8, sectname, "__ustring")) {
if (self.ustring_section_index == null) {
self.ustring_section_index = @intCast(u16, text_seg.sections.items.len);
try text_seg.addSection(self.base.allocator, "__ustring", .{});
}
break :blk .{
.seg = self.text_segment_cmd_index.?,
.sect = self.ustring_section_index.?,
};
} else if (mem.eql(u8, sectname, "__gcc_except_tab")) {
if (self.gcc_except_tab_section_index == null) {
self.gcc_except_tab_section_index = @intCast(u16, text_seg.sections.items.len);
try text_seg.addSection(self.base.allocator, "__gcc_except_tab", .{});
}
break :blk .{
.seg = self.text_segment_cmd_index.?,
.sect = self.gcc_except_tab_section_index.?,
};
} else if (mem.eql(u8, sectname, "__objc_methlist")) {
if (self.objc_methlist_section_index == null) {
self.objc_methlist_section_index = @intCast(u16, text_seg.sections.items.len);
try text_seg.addSection(self.base.allocator, "__objc_methlist", .{});
}
break :blk .{
.seg = self.text_segment_cmd_index.?,
.sect = self.objc_methlist_section_index.?,
};
} else if (mem.eql(u8, sectname, "__rodata") or
mem.eql(u8, sectname, "__typelink") or
mem.eql(u8, sectname, "__itablink") or
mem.eql(u8, sectname, "__gosymtab") or
mem.eql(u8, sectname, "__gopclntab"))
{
if (self.data_const_section_index == null) {
self.data_const_section_index = @intCast(u16, data_const_seg.sections.items.len);
try data_const_seg.addSection(self.base.allocator, "__const", .{});
}
break :blk .{
.seg = self.data_const_segment_cmd_index.?,
.sect = self.data_const_section_index.?,
};
} else {
if (self.text_const_section_index == null) {
self.text_const_section_index = @intCast(u16, text_seg.sections.items.len);
try text_seg.addSection(self.base.allocator, "__const", .{});
}
break :blk .{
.seg = self.text_segment_cmd_index.?,
.sect = self.text_const_section_index.?,
};
}
}
if (mem.eql(u8, segname, "__DATA_CONST")) {
if (self.data_const_section_index == null) {
self.data_const_section_index = @intCast(u16, data_const_seg.sections.items.len);
try data_const_seg.addSection(self.base.allocator, "__const", .{});
}
break :blk .{
.seg = self.data_const_segment_cmd_index.?,
.sect = self.data_const_section_index.?,
};
}
if (mem.eql(u8, segname, "__DATA")) {
if (mem.eql(u8, sectname, "__const")) {
if (self.data_const_section_index == null) {
self.data_const_section_index = @intCast(u16, data_const_seg.sections.items.len);
try data_const_seg.addSection(self.base.allocator, "__const", .{});
}
break :blk .{
.seg = self.data_const_segment_cmd_index.?,
.sect = self.data_const_section_index.?,
};
} else if (mem.eql(u8, sectname, "__cfstring")) {
if (self.objc_cfstring_section_index == null) {
self.objc_cfstring_section_index = @intCast(u16, data_const_seg.sections.items.len);
try data_const_seg.addSection(self.base.allocator, "__cfstring", .{});
}
break :blk .{
.seg = self.data_const_segment_cmd_index.?,
.sect = self.objc_cfstring_section_index.?,
};
} else if (mem.eql(u8, sectname, "__objc_classlist")) {
if (self.objc_classlist_section_index == null) {
self.objc_classlist_section_index = @intCast(u16, data_const_seg.sections.items.len);
try data_const_seg.addSection(self.base.allocator, "__objc_classlist", .{});
}
break :blk .{
.seg = self.data_const_segment_cmd_index.?,
.sect = self.objc_classlist_section_index.?,
};
} else if (mem.eql(u8, sectname, "__objc_imageinfo")) {
if (self.objc_imageinfo_section_index == null) {
self.objc_imageinfo_section_index = @intCast(u16, data_const_seg.sections.items.len);
try data_const_seg.addSection(self.base.allocator, "__objc_imageinfo", .{});
}
break :blk .{
.seg = self.data_const_segment_cmd_index.?,
.sect = self.objc_imageinfo_section_index.?,
};
} else if (mem.eql(u8, sectname, "__objc_const")) {
if (self.objc_const_section_index == null) {
self.objc_const_section_index = @intCast(u16, data_seg.sections.items.len);
try data_seg.addSection(self.base.allocator, "__objc_const", .{});
}
break :blk .{
.seg = self.data_segment_cmd_index.?,
.sect = self.objc_const_section_index.?,
};
} else if (mem.eql(u8, sectname, "__objc_classrefs")) {
if (self.objc_classrefs_section_index == null) {
self.objc_classrefs_section_index = @intCast(u16, data_seg.sections.items.len);
try data_seg.addSection(self.base.allocator, "__objc_classrefs", .{});
}
break :blk .{
.seg = self.data_segment_cmd_index.?,
.sect = self.objc_classrefs_section_index.?,
};
} else if (mem.eql(u8, sectname, "__objc_data")) {
if (self.objc_data_section_index == null) {
self.objc_data_section_index = @intCast(u16, data_seg.sections.items.len);
try data_seg.addSection(self.base.allocator, "__objc_data", .{});
}
break :blk .{
.seg = self.data_segment_cmd_index.?,
.sect = self.objc_data_section_index.?,
};
} else {
if (self.data_section_index == null) {
self.data_section_index = @intCast(u16, data_seg.sections.items.len);
try data_seg.addSection(self.base.allocator, "__data", .{});
}
break :blk .{
.seg = self.data_segment_cmd_index.?,
.sect = self.data_section_index.?,
};
}
}
if (mem.eql(u8, "__LLVM", segname) and mem.eql(u8, "__asm", sectname)) {
log.debug("TODO LLVM asm section: type 0x{x}, name '{s},{s}'", .{
sect.flags, segname, sectname,
});
}
break :blk null;
},
else => break :blk null,
}
};
if (res) |match| {
_ = try self.section_ordinals.getOrPut(self.base.allocator, match);
}
return res;
}
fn sortSections(self: *MachO) !void {
var text_index_mapping = std.AutoHashMap(u16, u16).init(self.base.allocator);
defer text_index_mapping.deinit();
var data_const_index_mapping = std.AutoHashMap(u16, u16).init(self.base.allocator);
defer data_const_index_mapping.deinit();
var data_index_mapping = std.AutoHashMap(u16, u16).init(self.base.allocator);
defer data_index_mapping.deinit();
{
// __TEXT segment
const seg = &self.load_commands.items[self.text_segment_cmd_index.?].Segment;
var sections = seg.sections.toOwnedSlice(self.base.allocator);
defer self.base.allocator.free(sections);
try seg.sections.ensureTotalCapacity(self.base.allocator, sections.len);
const indices = &[_]*?u16{
&self.text_section_index,
&self.stubs_section_index,
&self.stub_helper_section_index,
&self.gcc_except_tab_section_index,
&self.cstring_section_index,
&self.ustring_section_index,
&self.text_const_section_index,
&self.objc_methlist_section_index,
&self.objc_methname_section_index,
&self.objc_methtype_section_index,
&self.objc_classname_section_index,
&self.eh_frame_section_index,
};
for (indices) |maybe_index| {
const new_index: u16 = if (maybe_index.*) |index| blk: {
const idx = @intCast(u16, seg.sections.items.len);
seg.sections.appendAssumeCapacity(sections[index]);
try text_index_mapping.putNoClobber(index, idx);
break :blk idx;
} else continue;
maybe_index.* = new_index;
}
}
{
// __DATA_CONST segment
const seg = &self.load_commands.items[self.data_const_segment_cmd_index.?].Segment;
var sections = seg.sections.toOwnedSlice(self.base.allocator);
defer self.base.allocator.free(sections);
try seg.sections.ensureTotalCapacity(self.base.allocator, sections.len);
const indices = &[_]*?u16{
&self.got_section_index,
&self.mod_init_func_section_index,
&self.mod_term_func_section_index,
&self.data_const_section_index,
&self.objc_cfstring_section_index,
&self.objc_classlist_section_index,
&self.objc_imageinfo_section_index,
};
for (indices) |maybe_index| {
const new_index: u16 = if (maybe_index.*) |index| blk: {
const idx = @intCast(u16, seg.sections.items.len);
seg.sections.appendAssumeCapacity(sections[index]);
try data_const_index_mapping.putNoClobber(index, idx);
break :blk idx;
} else continue;
maybe_index.* = new_index;
}
}
{
// __DATA segment
const seg = &self.load_commands.items[self.data_segment_cmd_index.?].Segment;
var sections = seg.sections.toOwnedSlice(self.base.allocator);
defer self.base.allocator.free(sections);
try seg.sections.ensureTotalCapacity(self.base.allocator, sections.len);
// __DATA segment
const indices = &[_]*?u16{
&self.la_symbol_ptr_section_index,
&self.objc_const_section_index,
&self.objc_selrefs_section_index,
&self.objc_classrefs_section_index,
&self.objc_data_section_index,
&self.data_section_index,
&self.tlv_section_index,
&self.tlv_data_section_index,
&self.tlv_bss_section_index,
&self.bss_section_index,
};
for (indices) |maybe_index| {
const new_index: u16 = if (maybe_index.*) |index| blk: {
const idx = @intCast(u16, seg.sections.items.len);
seg.sections.appendAssumeCapacity(sections[index]);
try data_index_mapping.putNoClobber(index, idx);
break :blk idx;
} else continue;
maybe_index.* = new_index;
}
}
{
var transient: std.AutoHashMapUnmanaged(MatchingSection, *Atom) = .{};
try transient.ensureTotalCapacity(self.base.allocator, self.atoms.count());
var it = self.atoms.iterator();
while (it.next()) |entry| {
const old = entry.key_ptr.*;
const sect = if (old.seg == self.text_segment_cmd_index.?)
text_index_mapping.get(old.sect).?
else if (old.seg == self.data_const_segment_cmd_index.?)
data_const_index_mapping.get(old.sect).?
else
data_index_mapping.get(old.sect).?;
transient.putAssumeCapacityNoClobber(.{
.seg = old.seg,
.sect = sect,
}, entry.value_ptr.*);
}
self.atoms.clearAndFree(self.base.allocator);
self.atoms.deinit(self.base.allocator);
self.atoms = transient;
}
{
// Create new section ordinals.
self.section_ordinals.clearRetainingCapacity();
const text_seg = self.load_commands.items[self.text_segment_cmd_index.?].Segment;
for (text_seg.sections.items) |_, sect_id| {
const res = self.section_ordinals.getOrPutAssumeCapacity(.{
.seg = self.text_segment_cmd_index.?,
.sect = @intCast(u16, sect_id),
});
assert(!res.found_existing);
}
const data_const_seg = self.load_commands.items[self.data_const_segment_cmd_index.?].Segment;
for (data_const_seg.sections.items) |_, sect_id| {
const res = self.section_ordinals.getOrPutAssumeCapacity(.{
.seg = self.data_const_segment_cmd_index.?,
.sect = @intCast(u16, sect_id),
});
assert(!res.found_existing);
}
const data_seg = self.load_commands.items[self.data_segment_cmd_index.?].Segment;
for (data_seg.sections.items) |_, sect_id| {
const res = self.section_ordinals.getOrPutAssumeCapacity(.{
.seg = self.data_segment_cmd_index.?,
.sect = @intCast(u16, sect_id),
});
assert(!res.found_existing);
}
}
}
fn allocateTextSegment(self: *MachO) !void {
const seg = &self.load_commands.items[self.text_segment_cmd_index.?].Segment;
const base_vmaddr = self.load_commands.items[self.pagezero_segment_cmd_index.?].Segment.inner.vmsize;
seg.inner.fileoff = 0;
seg.inner.vmaddr = base_vmaddr;
var sizeofcmds: u64 = 0;
for (self.load_commands.items) |lc| {
sizeofcmds += lc.cmdsize();
}
try self.allocateSegment(self.text_segment_cmd_index.?, @sizeOf(macho.mach_header_64) + sizeofcmds);
// Shift all sections to the back to minimize jump size between __TEXT and __DATA segments.
var min_alignment: u32 = 0;
for (seg.sections.items) |sect| {
const alignment = try math.powi(u32, 2, sect.@"align");
min_alignment = math.max(min_alignment, alignment);
}
assert(min_alignment > 0);
const last_sect_idx = seg.sections.items.len - 1;
const last_sect = seg.sections.items[last_sect_idx];
const shift: u32 = blk: {
const diff = seg.inner.filesize - last_sect.offset - last_sect.size;
const factor = @divTrunc(diff, min_alignment);
break :blk @intCast(u32, factor * min_alignment);
};
if (shift > 0) {
for (seg.sections.items) |*sect| {
sect.offset += shift;
sect.addr += shift;
}
}
}
fn allocateDataConstSegment(self: *MachO) !void {
const seg = &self.load_commands.items[self.data_const_segment_cmd_index.?].Segment;
const text_seg = self.load_commands.items[self.text_segment_cmd_index.?].Segment;
seg.inner.fileoff = text_seg.inner.fileoff + text_seg.inner.filesize;
seg.inner.vmaddr = text_seg.inner.vmaddr + text_seg.inner.vmsize;
try self.allocateSegment(self.data_const_segment_cmd_index.?, 0);
}
fn allocateDataSegment(self: *MachO) !void {
const seg = &self.load_commands.items[self.data_segment_cmd_index.?].Segment;
const data_const_seg = self.load_commands.items[self.data_const_segment_cmd_index.?].Segment;
seg.inner.fileoff = data_const_seg.inner.fileoff + data_const_seg.inner.filesize;
seg.inner.vmaddr = data_const_seg.inner.vmaddr + data_const_seg.inner.vmsize;
try self.allocateSegment(self.data_segment_cmd_index.?, 0);
}
fn allocateLinkeditSegment(self: *MachO) void {
const seg = &self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment;
const data_seg = self.load_commands.items[self.data_segment_cmd_index.?].Segment;
seg.inner.fileoff = data_seg.inner.fileoff + data_seg.inner.filesize;
seg.inner.vmaddr = data_seg.inner.vmaddr + data_seg.inner.vmsize;
}
fn allocateSegment(self: *MachO, index: u16, offset: u64) !void {
const seg = &self.load_commands.items[index].Segment;
// Allocate the sections according to their alignment at the beginning of the segment.
var start: u64 = offset;
for (seg.sections.items) |*sect| {
const alignment = try math.powi(u32, 2, sect.@"align");
const start_aligned = mem.alignForwardGeneric(u64, start, alignment);
const end_aligned = mem.alignForwardGeneric(u64, start_aligned + sect.size, alignment);
sect.offset = @intCast(u32, seg.inner.fileoff + start_aligned);
sect.addr = seg.inner.vmaddr + start_aligned;
start = end_aligned;
}
const seg_size_aligned = mem.alignForwardGeneric(u64, start, self.page_size);
seg.inner.filesize = seg_size_aligned;
seg.inner.vmsize = seg_size_aligned;
}
pub fn createEmptyAtom(self: *MachO, local_sym_index: u32, size: u64, alignment: u32, match: MatchingSection) !*Atom {
const atom_alignment = try math.powi(u32, 2, alignment);
const atom_size = mem.alignForwardGeneric(u64, size, atom_alignment);
const code = try self.base.allocator.alloc(u8, atom_size);
defer self.base.allocator.free(code);
mem.set(u8, code, 0);
const atom = try self.base.allocator.create(Atom);
errdefer self.base.allocator.destroy(atom);
atom.* = Atom.empty;
atom.local_sym_index = local_sym_index;
atom.size = atom_size;
atom.alignment = alignment;
try atom.code.appendSlice(self.base.allocator, code);
// Update target section's metadata
const tseg = &self.load_commands.items[match.seg].Segment;
const tsect = &tseg.sections.items[match.sect];
const new_size = mem.alignForwardGeneric(u64, tsect.size, atom_alignment) + atom_size;
tsect.size = new_size;
tsect.@"align" = math.max(tsect.@"align", atom.alignment);
if (self.atoms.getPtr(match)) |last| {
last.*.next = atom;
atom.prev = last.*;
last.* = atom;
} else {
try self.atoms.putNoClobber(self.base.allocator, match, atom);
}
try self.managed_atoms.append(self.base.allocator, atom);
return atom;
}
fn allocateAtoms(self: *MachO) !void {
var it = self.atoms.iterator();
while (it.next()) |entry| {
const match = entry.key_ptr.*;
var atom: *Atom = entry.value_ptr.*;
// Find the first atom
while (atom.prev) |prev| {
atom = prev;
}
const seg = self.load_commands.items[match.seg].Segment;
const sect = seg.sections.items[match.sect];
var base_addr: u64 = sect.addr;
const n_sect = @intCast(u8, self.section_ordinals.getIndex(match).? + 1);
log.debug("allocating atoms in {s},{s}", .{ commands.segmentName(sect), commands.sectionName(sect) });
while (true) {
const atom_alignment = try math.powi(u32, 2, atom.alignment);
base_addr = mem.alignForwardGeneric(u64, base_addr, atom_alignment);
const sym = &self.locals.items[atom.local_sym_index];
sym.n_value = base_addr;
sym.n_sect = n_sect;
log.debug(" (atom {s} allocated from 0x{x} to 0x{x})", .{
self.getString(sym.n_strx),
base_addr,
base_addr + atom.size,
});
// Update each alias (if any)
for (atom.aliases.items) |index| {
const alias_sym = &self.locals.items[index];
alias_sym.n_value = base_addr;
alias_sym.n_sect = n_sect;
}
// Update each symbol contained within the TextBlock
for (atom.contained.items) |sym_at_off| {
const contained_sym = &self.locals.items[sym_at_off.local_sym_index];
contained_sym.n_value = base_addr + sym_at_off.offset;
contained_sym.n_sect = n_sect;
}
base_addr += atom.size;
if (atom.next) |next| {
atom = next;
} else break;
}
}
// Update globals
{
var sym_it = self.symbol_resolver.valueIterator();
while (sym_it.next()) |resolv| {
if (resolv.where != .global) continue;
const local_sym = self.locals.items[resolv.local_sym_index];
const sym = &self.globals.items[resolv.where_index];
sym.n_value = local_sym.n_value;
sym.n_sect = local_sym.n_sect;
}
}
}
fn writeAtoms(self: *MachO) !void {
var it = self.atoms.iterator();
while (it.next()) |entry| {
const match = entry.key_ptr.*;
const seg = self.load_commands.items[match.seg].Segment;
const sect = seg.sections.items[match.sect];
var atom: *Atom = entry.value_ptr.*;
var buffer = std.ArrayList(u8).init(self.base.allocator);
defer buffer.deinit();
try buffer.ensureTotalCapacity(sect.size);
log.debug("writing atoms in {s},{s}", .{ commands.segmentName(sect), commands.sectionName(sect) });
while (atom.prev) |prev| {
atom = prev;
}
while (true) {
const atom_sym = self.locals.items[atom.local_sym_index];
const padding_size: u64 = if (atom.next) |next| blk: {
const next_sym = self.locals.items[next.local_sym_index];
const size = next_sym.n_value - (atom_sym.n_value + atom.size);
break :blk try math.cast(usize, size);
} else 0;
log.debug(" (adding atom {s} to buffer: {})", .{ self.getString(atom_sym.n_strx), atom_sym });
try atom.resolveRelocs(self);
buffer.appendSliceAssumeCapacity(atom.code.items);
var i: usize = 0;
while (i < padding_size) : (i += 1) {
buffer.appendAssumeCapacity(0);
}
if (atom.next) |next| {
atom = next;
} else {
assert(buffer.items.len == sect.size);
log.debug(" (writing at file offset 0x{x})", .{sect.offset});
try self.base.file.pwriteAll(buffer.items, sect.offset);
break;
}
}
}
}
pub fn createGotAtom(self: *MachO, target: Atom.Relocation.Target) !*Atom {
const local_sym_index = @intCast(u32, self.locals.items.len);
try self.locals.append(self.base.allocator, .{
.n_strx = 0,
.n_type = macho.N_SECT,
.n_sect = 0,
.n_desc = 0,
.n_value = 0,
});
const atom = try self.createEmptyAtom(local_sym_index, @sizeOf(u64), 3, .{
.seg = self.data_const_segment_cmd_index.?,
.sect = self.got_section_index.?,
});
try atom.relocs.append(self.base.allocator, .{
.offset = 0,
.target = target,
.addend = 0,
.subtractor = null,
.pcrel = false,
.length = 3,
.@"type" = switch (self.base.options.target.cpu.arch) {
.aarch64 => @enumToInt(macho.reloc_type_arm64.ARM64_RELOC_UNSIGNED),
.x86_64 => @enumToInt(macho.reloc_type_x86_64.X86_64_RELOC_UNSIGNED),
else => unreachable,
},
});
switch (target) {
.local => {
try atom.rebases.append(self.base.allocator, 0);
},
.global => |n_strx| {
try atom.bindings.append(self.base.allocator, .{
.n_strx = n_strx,
.offset = 0,
});
},
}
return atom;
}
fn createDyldPrivateAtom(self: *MachO) !void {
if (self.dyld_private_atom != null) return;
const local_sym_index = @intCast(u32, self.locals.items.len);
const sym = try self.locals.addOne(self.base.allocator);
sym.* = .{
.n_strx = 0,
.n_type = macho.N_SECT,
.n_sect = 0,
.n_desc = 0,
.n_value = 0,
};
const atom = try self.createEmptyAtom(local_sym_index, @sizeOf(u64), 3, .{
.seg = self.data_segment_cmd_index.?,
.sect = self.data_section_index.?,
});
self.dyld_private_atom = atom;
}
fn createStubHelperPreambleAtom(self: *MachO) !void {
if (self.stub_helper_preamble_atom != null) return;
const arch = self.base.options.target.cpu.arch;
const size: u64 = switch (arch) {
.x86_64 => 15,
.aarch64 => 6 * @sizeOf(u32),
else => unreachable,
};
const alignment: u32 = switch (arch) {
.x86_64 => 0,
.aarch64 => 2,
else => unreachable,
};
const local_sym_index = @intCast(u32, self.locals.items.len);
const sym = try self.locals.addOne(self.base.allocator);
sym.* = .{
.n_strx = 0,
.n_type = macho.N_SECT,
.n_sect = 0,
.n_desc = 0,
.n_value = 0,
};
const atom = try self.createEmptyAtom(local_sym_index, size, alignment, .{
.seg = self.text_segment_cmd_index.?,
.sect = self.stub_helper_section_index.?,
});
const dyld_private_sym_index = self.dyld_private_atom.?.local_sym_index;
switch (arch) {
.x86_64 => {
try atom.relocs.ensureUnusedCapacity(self.base.allocator, 2);
// lea %r11, [rip + disp]
atom.code.items[0] = 0x4c;
atom.code.items[1] = 0x8d;
atom.code.items[2] = 0x1d;
atom.relocs.appendAssumeCapacity(.{
.offset = 3,
.target = .{ .local = dyld_private_sym_index },
.addend = 0,
.subtractor = null,
.pcrel = true,
.length = 2,
.@"type" = @enumToInt(macho.reloc_type_x86_64.X86_64_RELOC_SIGNED),
});
// push %r11
atom.code.items[7] = 0x41;
atom.code.items[8] = 0x53;
// jmp [rip + disp]
atom.code.items[9] = 0xff;
atom.code.items[10] = 0x25;
atom.relocs.appendAssumeCapacity(.{
.offset = 11,
.target = .{ .global = self.undefs.items[self.dyld_stub_binder_index.?].n_strx },
.addend = 0,
.subtractor = null,
.pcrel = true,
.length = 2,
.@"type" = @enumToInt(macho.reloc_type_x86_64.X86_64_RELOC_GOT),
});
},
.aarch64 => {
try atom.relocs.ensureUnusedCapacity(self.base.allocator, 4);
// adrp x17, 0
mem.writeIntLittle(u32, atom.code.items[0..][0..4], aarch64.Instruction.adrp(.x17, 0).toU32());
atom.relocs.appendAssumeCapacity(.{
.offset = 0,
.target = .{ .local = dyld_private_sym_index },
.addend = 0,
.subtractor = null,
.pcrel = true,
.length = 2,
.@"type" = @enumToInt(macho.reloc_type_arm64.ARM64_RELOC_PAGE21),
});
// add x17, x17, 0
mem.writeIntLittle(u32, atom.code.items[4..][0..4], aarch64.Instruction.add(.x17, .x17, 0, false).toU32());
atom.relocs.appendAssumeCapacity(.{
.offset = 4,
.target = .{ .local = dyld_private_sym_index },
.addend = 0,
.subtractor = null,
.pcrel = false,
.length = 2,
.@"type" = @enumToInt(macho.reloc_type_arm64.ARM64_RELOC_PAGEOFF12),
});
// stp x16, x17, [sp, #-16]!
mem.writeIntLittle(u32, atom.code.items[8..][0..4], aarch64.Instruction.stp(
.x16,
.x17,
aarch64.Register.sp,
aarch64.Instruction.LoadStorePairOffset.pre_index(-16),
).toU32());
// adrp x16, 0
mem.writeIntLittle(u32, atom.code.items[12..][0..4], aarch64.Instruction.adrp(.x16, 0).toU32());
atom.relocs.appendAssumeCapacity(.{
.offset = 12,
.target = .{ .global = self.undefs.items[self.dyld_stub_binder_index.?].n_strx },
.addend = 0,
.subtractor = null,
.pcrel = true,
.length = 2,
.@"type" = @enumToInt(macho.reloc_type_arm64.ARM64_RELOC_GOT_LOAD_PAGE21),
});
// ldr x16, [x16, 0]
mem.writeIntLittle(u32, atom.code.items[16..][0..4], aarch64.Instruction.ldr(.x16, .{
.register = .{
.rn = .x16,
.offset = aarch64.Instruction.LoadStoreOffset.imm(0),
},
}).toU32());
atom.relocs.appendAssumeCapacity(.{
.offset = 16,
.target = .{ .global = self.undefs.items[self.dyld_stub_binder_index.?].n_strx },
.addend = 0,
.subtractor = null,
.pcrel = false,
.length = 2,
.@"type" = @enumToInt(macho.reloc_type_arm64.ARM64_RELOC_GOT_LOAD_PAGEOFF12),
});
// br x16
mem.writeIntLittle(u32, atom.code.items[20..][0..4], aarch64.Instruction.br(.x16).toU32());
},
else => unreachable,
}
self.stub_helper_preamble_atom = atom;
}
pub fn createStubHelperAtom(self: *MachO) !*Atom {
const arch = self.base.options.target.cpu.arch;
const stub_size: u4 = switch (arch) {
.x86_64 => 10,
.aarch64 => 3 * @sizeOf(u32),
else => unreachable,
};
const alignment: u2 = switch (arch) {
.x86_64 => 0,
.aarch64 => 2,
else => unreachable,
};
const local_sym_index = @intCast(u32, self.locals.items.len);
try self.locals.append(self.base.allocator, .{
.n_strx = 0,
.n_type = macho.N_SECT,
.n_sect = 0,
.n_desc = 0,
.n_value = 0,
});
const atom = try self.createEmptyAtom(local_sym_index, stub_size, alignment, .{
.seg = self.text_segment_cmd_index.?,
.sect = self.stub_helper_section_index.?,
});
try atom.relocs.ensureTotalCapacity(self.base.allocator, 1);
switch (arch) {
.x86_64 => {
// pushq
atom.code.items[0] = 0x68;
// Next 4 bytes 1..4 are just a placeholder populated in `populateLazyBindOffsetsInStubHelper`.
// jmpq
atom.code.items[5] = 0xe9;
atom.relocs.appendAssumeCapacity(.{
.offset = 6,
.target = .{ .local = self.stub_helper_preamble_atom.?.local_sym_index },
.addend = 0,
.subtractor = null,
.pcrel = true,
.length = 2,
.@"type" = @enumToInt(macho.reloc_type_x86_64.X86_64_RELOC_BRANCH),
});
},
.aarch64 => {
const literal = blk: {
const div_res = try math.divExact(u64, stub_size - @sizeOf(u32), 4);
break :blk try math.cast(u18, div_res);
};
// ldr w16, literal
mem.writeIntLittle(u32, atom.code.items[0..4], aarch64.Instruction.ldr(.w16, .{
.literal = literal,
}).toU32());
// b disp
mem.writeIntLittle(u32, atom.code.items[4..8], aarch64.Instruction.b(0).toU32());
atom.relocs.appendAssumeCapacity(.{
.offset = 4,
.target = .{ .local = self.stub_helper_preamble_atom.?.local_sym_index },
.addend = 0,
.subtractor = null,
.pcrel = true,
.length = 2,
.@"type" = @enumToInt(macho.reloc_type_arm64.ARM64_RELOC_BRANCH26),
});
// Next 4 bytes 8..12 are just a placeholder populated in `populateLazyBindOffsetsInStubHelper`.
},
else => unreachable,
}
return atom;
}
pub fn createLazyPointerAtom(self: *MachO, stub_sym_index: u32, n_strx: u32) !*Atom {
const local_sym_index = @intCast(u32, self.locals.items.len);
try self.locals.append(self.base.allocator, .{
.n_strx = 0,
.n_type = macho.N_SECT,
.n_sect = 0,
.n_desc = 0,
.n_value = 0,
});
const atom = try self.createEmptyAtom(local_sym_index, @sizeOf(u64), 3, .{
.seg = self.data_segment_cmd_index.?,
.sect = self.la_symbol_ptr_section_index.?,
});
try atom.relocs.append(self.base.allocator, .{
.offset = 0,
.target = .{ .local = stub_sym_index },
.addend = 0,
.subtractor = null,
.pcrel = false,
.length = 3,
.@"type" = switch (self.base.options.target.cpu.arch) {
.aarch64 => @enumToInt(macho.reloc_type_arm64.ARM64_RELOC_UNSIGNED),
.x86_64 => @enumToInt(macho.reloc_type_x86_64.X86_64_RELOC_UNSIGNED),
else => unreachable,
},
});
try atom.rebases.append(self.base.allocator, 0);
try atom.lazy_bindings.append(self.base.allocator, .{
.n_strx = n_strx,
.offset = 0,
});
return atom;
}
pub fn createStubAtom(self: *MachO, laptr_sym_index: u32) !*Atom {
const arch = self.base.options.target.cpu.arch;
const alignment: u2 = switch (arch) {
.x86_64 => 0,
.aarch64 => 2,
else => unreachable, // unhandled architecture type
};
const stub_size: u4 = switch (arch) {
.x86_64 => 6,
.aarch64 => 3 * @sizeOf(u32),
else => unreachable, // unhandled architecture type
};
const local_sym_index = @intCast(u32, self.locals.items.len);
try self.locals.append(self.base.allocator, .{
.n_strx = 0,
.n_type = macho.N_SECT,
.n_sect = 0,
.n_desc = 0,
.n_value = 0,
});
const atom = try self.createEmptyAtom(local_sym_index, stub_size, alignment, .{
.seg = self.text_segment_cmd_index.?,
.sect = self.stubs_section_index.?,
});
switch (arch) {
.x86_64 => {
// jmp
atom.code.items[0] = 0xff;
atom.code.items[1] = 0x25;
try atom.relocs.append(self.base.allocator, .{
.offset = 2,
.target = .{ .local = laptr_sym_index },
.addend = 0,
.subtractor = null,
.pcrel = true,
.length = 2,
.@"type" = @enumToInt(macho.reloc_type_x86_64.X86_64_RELOC_BRANCH),
});
},
.aarch64 => {
try atom.relocs.ensureTotalCapacity(self.base.allocator, 2);
// adrp x16, pages
mem.writeIntLittle(u32, atom.code.items[0..4], aarch64.Instruction.adrp(.x16, 0).toU32());
atom.relocs.appendAssumeCapacity(.{
.offset = 0,
.target = .{ .local = laptr_sym_index },
.addend = 0,
.subtractor = null,
.pcrel = true,
.length = 2,
.@"type" = @enumToInt(macho.reloc_type_arm64.ARM64_RELOC_PAGE21),
});
// ldr x16, x16, offset
mem.writeIntLittle(u32, atom.code.items[4..8], aarch64.Instruction.ldr(.x16, .{
.register = .{
.rn = .x16,
.offset = aarch64.Instruction.LoadStoreOffset.imm(0),
},
}).toU32());
atom.relocs.appendAssumeCapacity(.{
.offset = 4,
.target = .{ .local = laptr_sym_index },
.addend = 0,
.subtractor = null,
.pcrel = false,
.length = 2,
.@"type" = @enumToInt(macho.reloc_type_arm64.ARM64_RELOC_PAGEOFF12),
});
// br x16
mem.writeIntLittle(u32, atom.code.items[8..12], aarch64.Instruction.br(.x16).toU32());
},
else => unreachable,
}
return atom;
}
fn createTentativeDefAtoms(self: *MachO) !void {
if (self.tentatives.count() == 0) return;
// Convert any tentative definition into a regular symbol and allocate
// text blocks for each tentative defintion.
while (self.tentatives.popOrNull()) |entry| {
const match = MatchingSection{
.seg = self.data_segment_cmd_index.?,
.sect = self.bss_section_index.?,
};
_ = try self.section_ordinals.getOrPut(self.base.allocator, match);
const global_sym = &self.globals.items[entry.key];
const size = global_sym.n_value;
const alignment = (global_sym.n_desc >> 8) & 0x0f;
global_sym.n_value = 0;
global_sym.n_desc = 0;
global_sym.n_sect = @intCast(u8, self.section_ordinals.getIndex(match).? + 1);
const local_sym_index = @intCast(u32, self.locals.items.len);
const local_sym = try self.locals.addOne(self.base.allocator);
local_sym.* = .{
.n_strx = global_sym.n_strx,
.n_type = macho.N_SECT,
.n_sect = global_sym.n_sect,
.n_desc = 0,
.n_value = 0,
};
const resolv = self.symbol_resolver.getPtr(local_sym.n_strx) orelse unreachable;
resolv.local_sym_index = local_sym_index;
_ = try self.createEmptyAtom(local_sym_index, size, alignment, match);
}
}
fn createDsoHandleAtom(self: *MachO) !void {
if (self.strtab_dir.getKeyAdapted(@as([]const u8, "___dso_handle"), StringIndexAdapter{
.bytes = &self.strtab,
})) |n_strx| blk: {
const resolv = self.symbol_resolver.getPtr(n_strx) orelse break :blk;
if (resolv.where != .undef) break :blk;
const undef = &self.undefs.items[resolv.where_index];
const match: MatchingSection = .{
.seg = self.text_segment_cmd_index.?,
.sect = self.text_section_index.?,
};
const local_sym_index = @intCast(u32, self.locals.items.len);
var nlist = macho.nlist_64{
.n_strx = undef.n_strx,
.n_type = macho.N_SECT,
.n_sect = @intCast(u8, self.section_ordinals.getIndex(match).? + 1),
.n_desc = 0,
.n_value = 0,
};
try self.locals.append(self.base.allocator, nlist);
const global_sym_index = @intCast(u32, self.globals.items.len);
nlist.n_type |= macho.N_EXT;
nlist.n_desc = macho.N_WEAK_DEF;
try self.globals.append(self.base.allocator, nlist);
assert(self.unresolved.swapRemove(resolv.where_index));
undef.* = .{
.n_strx = 0,
.n_type = macho.N_UNDF,
.n_sect = 0,
.n_desc = 0,
.n_value = 0,
};
resolv.* = .{
.where = .global,
.where_index = global_sym_index,
.local_sym_index = local_sym_index,
};
// We create an empty atom for this symbol.
// TODO perhaps we should special-case special symbols? Create a separate
// linked list of atoms?
_ = try self.createEmptyAtom(local_sym_index, 0, 0, match);
}
}
fn resolveSymbolsInObject(self: *MachO, object_id: u16) !void {
const object = &self.objects.items[object_id];
log.debug("resolving symbols in '{s}'", .{object.name});
for (object.symtab.items) |sym, id| {
const sym_id = @intCast(u32, id);
const sym_name = object.getString(sym.n_strx);
if (sym.stab()) {
log.err("unhandled symbol type: stab", .{});
log.err(" symbol '{s}'", .{sym_name});
log.err(" first definition in '{s}'", .{object.name});
return error.UnhandledSymbolType;
}
if (sym.indr()) {
log.err("unhandled symbol type: indirect", .{});
log.err(" symbol '{s}'", .{sym_name});
log.err(" first definition in '{s}'", .{object.name});
return error.UnhandledSymbolType;
}
if (sym.abs()) {
log.err("unhandled symbol type: absolute", .{});
log.err(" symbol '{s}'", .{sym_name});
log.err(" first definition in '{s}'", .{object.name});
return error.UnhandledSymbolType;
}
if (sym.sect()) {
// Defined symbol regardless of scope lands in the locals symbol table.
const local_sym_index = @intCast(u32, self.locals.items.len);
try self.locals.append(self.base.allocator, .{
.n_strx = if (symbolIsTemp(sym, sym_name)) 0 else try self.makeString(sym_name),
.n_type = macho.N_SECT,
.n_sect = 0,
.n_desc = 0,
.n_value = sym.n_value,
});
try object.symbol_mapping.putNoClobber(self.base.allocator, sym_id, local_sym_index);
try object.reverse_symbol_mapping.putNoClobber(self.base.allocator, local_sym_index, sym_id);
// If the symbol's scope is not local aka translation unit, then we need work out
// if we should save the symbol as a global, or potentially flag the error.
if (!sym.ext()) continue;
const n_strx = try self.makeString(sym_name);
const local = self.locals.items[local_sym_index];
const resolv = self.symbol_resolver.getPtr(n_strx) orelse {
const global_sym_index = @intCast(u32, self.globals.items.len);
try self.globals.append(self.base.allocator, .{
.n_strx = n_strx,
.n_type = sym.n_type,
.n_sect = 0,
.n_desc = sym.n_desc,
.n_value = sym.n_value,
});
try self.symbol_resolver.putNoClobber(self.base.allocator, n_strx, .{
.where = .global,
.where_index = global_sym_index,
.local_sym_index = local_sym_index,
.file = object_id,
});
continue;
};
switch (resolv.where) {
.global => {
const global = &self.globals.items[resolv.where_index];
if (sym.tentative()) {
assert(self.tentatives.swapRemove(resolv.where_index));
} else if (!(sym.weakDef() or sym.pext()) and !(global.weakDef() or global.pext())) {
log.err("symbol '{s}' defined multiple times", .{sym_name});
if (resolv.file) |file| {
log.err(" first definition in '{s}'", .{self.objects.items[file].name});
}
log.err(" next definition in '{s}'", .{object.name});
return error.MultipleSymbolDefinitions;
} else if (sym.weakDef() or sym.pext()) continue; // Current symbol is weak, so skip it.
// Otherwise, update the resolver and the global symbol.
global.n_type = sym.n_type;
resolv.local_sym_index = local_sym_index;
resolv.file = object_id;
continue;
},
.undef => {
assert(self.unresolved.swapRemove(resolv.where_index));
},
}
const global_sym_index = @intCast(u32, self.globals.items.len);
try self.globals.append(self.base.allocator, .{
.n_strx = local.n_strx,
.n_type = sym.n_type,
.n_sect = 0,
.n_desc = sym.n_desc,
.n_value = sym.n_value,
});
resolv.* = .{
.where = .global,
.where_index = global_sym_index,
.local_sym_index = local_sym_index,
.file = object_id,
};
} else if (sym.tentative()) {
// Symbol is a tentative definition.
const n_strx = try self.makeString(sym_name);
const resolv = self.symbol_resolver.getPtr(n_strx) orelse {
const global_sym_index = @intCast(u32, self.globals.items.len);
try self.globals.append(self.base.allocator, .{
.n_strx = try self.makeString(sym_name),
.n_type = sym.n_type,
.n_sect = 0,
.n_desc = sym.n_desc,
.n_value = sym.n_value,
});
try self.symbol_resolver.putNoClobber(self.base.allocator, n_strx, .{
.where = .global,
.where_index = global_sym_index,
.file = object_id,
});
_ = try self.tentatives.getOrPut(self.base.allocator, global_sym_index);
continue;
};
switch (resolv.where) {
.global => {
const global = &self.globals.items[resolv.where_index];
if (!global.tentative()) continue;
if (global.n_value >= sym.n_value) continue;
global.n_desc = sym.n_desc;
global.n_value = sym.n_value;
resolv.file = object_id;
},
.undef => {
const undef = &self.undefs.items[resolv.where_index];
const global_sym_index = @intCast(u32, self.globals.items.len);
try self.globals.append(self.base.allocator, .{
.n_strx = undef.n_strx,
.n_type = sym.n_type,
.n_sect = 0,
.n_desc = sym.n_desc,
.n_value = sym.n_value,
});
_ = try self.tentatives.getOrPut(self.base.allocator, global_sym_index);
assert(self.unresolved.swapRemove(resolv.where_index));
resolv.* = .{
.where = .global,
.where_index = global_sym_index,
.file = object_id,
};
undef.* = .{
.n_strx = 0,
.n_type = macho.N_UNDF,
.n_sect = 0,
.n_desc = 0,
.n_value = 0,
};
},
}
} else {
// Symbol is undefined.
const n_strx = try self.makeString(sym_name);
if (self.symbol_resolver.contains(n_strx)) continue;
const undef_sym_index = @intCast(u32, self.undefs.items.len);
try self.undefs.append(self.base.allocator, .{
.n_strx = try self.makeString(sym_name),
.n_type = macho.N_UNDF,
.n_sect = 0,
.n_desc = sym.n_desc,
.n_value = 0,
});
try self.symbol_resolver.putNoClobber(self.base.allocator, n_strx, .{
.where = .undef,
.where_index = undef_sym_index,
.file = object_id,
});
try self.unresolved.putNoClobber(self.base.allocator, undef_sym_index, {});
}
}
}
fn resolveSymbolsInArchives(self: *MachO) !void {
if (self.archives.items.len == 0) return;
var next_sym: usize = 0;
loop: while (next_sym < self.unresolved.count()) {
const sym = self.undefs.items[self.unresolved.keys()[next_sym]];
const sym_name = self.getString(sym.n_strx);
for (self.archives.items) |archive| {
// Check if the entry exists in a static archive.
const offsets = archive.toc.get(sym_name) orelse {
// No hit.
continue;
};
assert(offsets.items.len > 0);
const object_id = @intCast(u16, self.objects.items.len);
const object = try self.objects.addOne(self.base.allocator);
object.* = try archive.parseObject(self.base.allocator, self.base.options.target, offsets.items[0]);
try self.resolveSymbolsInObject(object_id);
continue :loop;
}
next_sym += 1;
}
}
fn resolveSymbolsInDylibs(self: *MachO) !void {
if (self.dylibs.items.len == 0) return;
var next_sym: usize = 0;
loop: while (next_sym < self.unresolved.count()) {
const sym = self.undefs.items[self.unresolved.keys()[next_sym]];
const sym_name = self.getString(sym.n_strx);
for (self.dylibs.items) |dylib, id| {
if (!dylib.symbols.contains(sym_name)) continue;
const dylib_id = @intCast(u16, id);
if (!self.referenced_dylibs.contains(dylib_id)) {
try self.referenced_dylibs.putNoClobber(self.base.allocator, dylib_id, {});
}
const ordinal = self.referenced_dylibs.getIndex(dylib_id) orelse unreachable;
const resolv = self.symbol_resolver.getPtr(sym.n_strx) orelse unreachable;
const undef = &self.undefs.items[resolv.where_index];
undef.n_type |= macho.N_EXT;
undef.n_desc = @intCast(u16, ordinal + 1) * macho.N_SYMBOL_RESOLVER;
assert(self.unresolved.swapRemove(resolv.where_index));
continue :loop;
}
next_sym += 1;
}
}
fn createMhExecuteHeaderAtom(self: *MachO) !void {
if (self.mh_execute_header_index != null) return;
const match: MatchingSection = .{
.seg = self.text_segment_cmd_index.?,
.sect = self.text_section_index.?,
};
const n_strx = try self.makeString("__mh_execute_header");
const local_sym_index = @intCast(u32, self.locals.items.len);
var nlist = macho.nlist_64{
.n_strx = n_strx,
.n_type = macho.N_SECT,
.n_sect = @intCast(u8, self.section_ordinals.getIndex(match).? + 1),
.n_desc = 0,
.n_value = 0,
};
try self.locals.append(self.base.allocator, nlist);
nlist.n_type |= macho.N_EXT;
const global_sym_index = @intCast(u32, self.globals.items.len);
try self.globals.append(self.base.allocator, nlist);
try self.symbol_resolver.putNoClobber(self.base.allocator, n_strx, .{
.where = .global,
.where_index = global_sym_index,
.local_sym_index = local_sym_index,
.file = null,
});
_ = try self.createEmptyAtom(local_sym_index, 0, 0, match);
self.mh_execute_header_index = local_sym_index;
}
fn resolveDyldStubBinder(self: *MachO) !void {
if (self.dyld_stub_binder_index != null) return;
const n_strx = try self.makeString("dyld_stub_binder");
const sym_index = @intCast(u32, self.undefs.items.len);
try self.undefs.append(self.base.allocator, .{
.n_strx = n_strx,
.n_type = macho.N_UNDF,
.n_sect = 0,
.n_desc = 0,
.n_value = 0,
});
try self.symbol_resolver.putNoClobber(self.base.allocator, n_strx, .{
.where = .undef,
.where_index = sym_index,
});
const sym = &self.undefs.items[sym_index];
const sym_name = self.getString(n_strx);
for (self.dylibs.items) |dylib, id| {
if (!dylib.symbols.contains(sym_name)) continue;
const dylib_id = @intCast(u16, id);
if (!self.referenced_dylibs.contains(dylib_id)) {
try self.referenced_dylibs.putNoClobber(self.base.allocator, dylib_id, {});
}
const ordinal = self.referenced_dylibs.getIndex(dylib_id) orelse unreachable;
sym.n_type |= macho.N_EXT;
sym.n_desc = @intCast(u16, ordinal + 1) * macho.N_SYMBOL_RESOLVER;
self.dyld_stub_binder_index = sym_index;
break;
}
if (self.dyld_stub_binder_index == null) {
log.err("undefined reference to symbol '{s}'", .{sym_name});
return error.UndefinedSymbolReference;
}
// Add dyld_stub_binder as the final GOT entry.
const target = Atom.Relocation.Target{ .global = n_strx };
const atom = try self.createGotAtom(target);
try self.got_entries_map.putNoClobber(self.base.allocator, target, atom);
}
fn addDataInCodeLC(self: *MachO) !void {
if (self.data_in_code_cmd_index == null) {
self.data_in_code_cmd_index = @intCast(u16, self.load_commands.items.len);
try self.load_commands.append(self.base.allocator, .{
.LinkeditData = .{
.cmd = macho.LC_DATA_IN_CODE,
.cmdsize = @sizeOf(macho.linkedit_data_command),
.dataoff = 0,
.datasize = 0,
},
});
}
}
fn addCodeSignatureLC(self: *MachO) !void {
if (self.code_signature_cmd_index != null or !self.requires_adhoc_codesig) return;
self.code_signature_cmd_index = @intCast(u16, self.load_commands.items.len);
try self.load_commands.append(self.base.allocator, .{
.LinkeditData = .{
.cmd = macho.LC_CODE_SIGNATURE,
.cmdsize = @sizeOf(macho.linkedit_data_command),
.dataoff = 0,
.datasize = 0,
},
});
}
fn addRpathLCs(self: *MachO, rpaths: []const []const u8) !void {
for (rpaths) |rpath| {
const cmdsize = @intCast(u32, mem.alignForwardGeneric(
u64,
@sizeOf(macho.rpath_command) + rpath.len + 1,
@sizeOf(u64),
));
var rpath_cmd = commands.emptyGenericCommandWithData(macho.rpath_command{
.cmd = macho.LC_RPATH,
.cmdsize = cmdsize,
.path = @sizeOf(macho.rpath_command),
});
rpath_cmd.data = try self.base.allocator.alloc(u8, cmdsize - rpath_cmd.inner.path);
mem.set(u8, rpath_cmd.data, 0);
mem.copy(u8, rpath_cmd.data, rpath);
try self.load_commands.append(self.base.allocator, .{ .Rpath = rpath_cmd });
}
}
fn addLoadDylibLCs(self: *MachO) !void {
for (self.referenced_dylibs.keys()) |id| {
const dylib = self.dylibs.items[id];
const dylib_id = dylib.id orelse unreachable;
var dylib_cmd = try commands.createLoadDylibCommand(
self.base.allocator,
dylib_id.name,
dylib_id.timestamp,
dylib_id.current_version,
dylib_id.compatibility_version,
);
errdefer dylib_cmd.deinit(self.base.allocator);
try self.load_commands.append(self.base.allocator, .{ .Dylib = dylib_cmd });
}
}
fn setEntryPoint(self: *MachO) !void {
if (self.base.options.output_mode != .exe) return;
// TODO we should respect the -entry flag passed in by the user to set a custom
// entrypoint. For now, assume default of `_main`.
const seg = self.load_commands.items[self.text_segment_cmd_index.?].Segment;
const n_strx = self.strtab_dir.getKeyAdapted(@as([]const u8, "_main"), StringIndexAdapter{
.bytes = &self.strtab,
}) orelse {
log.err("'_main' export not found", .{});
return error.MissingMainEntrypoint;
};
const resolv = self.symbol_resolver.get(n_strx) orelse unreachable;
assert(resolv.where == .global);
const sym = self.globals.items[resolv.where_index];
const ec = &self.load_commands.items[self.main_cmd_index.?].Main;
ec.entryoff = @intCast(u32, sym.n_value - seg.inner.vmaddr);
ec.stacksize = self.base.options.stack_size_override orelse 0;
}
pub fn deinit(self: *MachO) void {
self.closeFiles();
self.section_ordinals.deinit(self.base.allocator);
self.got_entries_map.deinit(self.base.allocator);
self.stubs_map.deinit(self.base.allocator);
self.strtab_dir.deinit(self.base.allocator);
self.strtab.deinit(self.base.allocator);
self.undefs.deinit(self.base.allocator);
self.globals.deinit(self.base.allocator);
self.locals.deinit(self.base.allocator);
self.symbol_resolver.deinit(self.base.allocator);
self.unresolved.deinit(self.base.allocator);
self.tentatives.deinit(self.base.allocator);
for (self.objects.items) |*object| {
object.deinit(self.base.allocator);
}
self.objects.deinit(self.base.allocator);
for (self.archives.items) |*archive| {
archive.deinit(self.base.allocator);
}
self.archives.deinit(self.base.allocator);
for (self.dylibs.items) |*dylib| {
dylib.deinit(self.base.allocator);
}
self.dylibs.deinit(self.base.allocator);
self.dylibs_map.deinit(self.base.allocator);
self.referenced_dylibs.deinit(self.base.allocator);
for (self.load_commands.items) |*lc| {
lc.deinit(self.base.allocator);
}
self.load_commands.deinit(self.base.allocator);
for (self.managed_atoms.items) |atom| {
atom.deinit(self.base.allocator);
self.base.allocator.destroy(atom);
}
self.managed_atoms.deinit(self.base.allocator);
self.atoms.deinit(self.base.allocator);
}
fn closeFiles(self: MachO) void {
for (self.objects.items) |object| {
object.file.close();
}
for (self.archives.items) |archive| {
archive.file.close();
}
for (self.dylibs.items) |dylib| {
dylib.file.close();
}
}
fn populateMetadata(self: *MachO) !void {
if (self.pagezero_segment_cmd_index == null) {
self.pagezero_segment_cmd_index = @intCast(u16, self.load_commands.items.len);
try self.load_commands.append(self.base.allocator, .{
.Segment = SegmentCommand.empty("__PAGEZERO", .{
.vmsize = 0x100000000, // size always set to 4GB
}),
});
}
if (self.text_segment_cmd_index == null) {
self.text_segment_cmd_index = @intCast(u16, self.load_commands.items.len);
try self.load_commands.append(self.base.allocator, .{
.Segment = SegmentCommand.empty("__TEXT", .{
.vmaddr = 0x100000000, // always starts at 4GB
.maxprot = macho.VM_PROT_READ | macho.VM_PROT_EXECUTE,
.initprot = macho.VM_PROT_READ | macho.VM_PROT_EXECUTE,
}),
});
}
if (self.text_section_index == null) {
const text_seg = &self.load_commands.items[self.text_segment_cmd_index.?].Segment;
self.text_section_index = @intCast(u16, text_seg.sections.items.len);
const alignment: u2 = switch (self.base.options.target.cpu.arch) {
.x86_64 => 0,
.aarch64 => 2,
else => unreachable, // unhandled architecture type
};
try text_seg.addSection(self.base.allocator, "__text", .{
.@"align" = alignment,
.flags = macho.S_REGULAR | macho.S_ATTR_PURE_INSTRUCTIONS | macho.S_ATTR_SOME_INSTRUCTIONS,
});
_ = try self.section_ordinals.getOrPut(self.base.allocator, .{
.seg = self.text_segment_cmd_index.?,
.sect = self.text_section_index.?,
});
}
if (self.stubs_section_index == null) {
const text_seg = &self.load_commands.items[self.text_segment_cmd_index.?].Segment;
self.stubs_section_index = @intCast(u16, text_seg.sections.items.len);
const alignment: u2 = switch (self.base.options.target.cpu.arch) {
.x86_64 => 0,
.aarch64 => 2,
else => unreachable, // unhandled architecture type
};
const stub_size: u4 = switch (self.base.options.target.cpu.arch) {
.x86_64 => 6,
.aarch64 => 3 * @sizeOf(u32),
else => unreachable, // unhandled architecture type
};
try text_seg.addSection(self.base.allocator, "__stubs", .{
.@"align" = alignment,
.flags = macho.S_SYMBOL_STUBS | macho.S_ATTR_PURE_INSTRUCTIONS | macho.S_ATTR_SOME_INSTRUCTIONS,
.reserved2 = stub_size,
});
_ = try self.section_ordinals.getOrPut(self.base.allocator, .{
.seg = self.text_segment_cmd_index.?,
.sect = self.stubs_section_index.?,
});
}
if (self.stub_helper_section_index == null) {
const text_seg = &self.load_commands.items[self.text_segment_cmd_index.?].Segment;
self.stub_helper_section_index = @intCast(u16, text_seg.sections.items.len);
const alignment: u2 = switch (self.base.options.target.cpu.arch) {
.x86_64 => 0,
.aarch64 => 2,
else => unreachable, // unhandled architecture type
};
try text_seg.addSection(self.base.allocator, "__stub_helper", .{
.@"align" = alignment,
.flags = macho.S_REGULAR | macho.S_ATTR_PURE_INSTRUCTIONS | macho.S_ATTR_SOME_INSTRUCTIONS,
});
_ = try self.section_ordinals.getOrPut(self.base.allocator, .{
.seg = self.text_segment_cmd_index.?,
.sect = self.stub_helper_section_index.?,
});
}
if (self.data_const_segment_cmd_index == null) {
self.data_const_segment_cmd_index = @intCast(u16, self.load_commands.items.len);
try self.load_commands.append(self.base.allocator, .{
.Segment = SegmentCommand.empty("__DATA_CONST", .{
.maxprot = macho.VM_PROT_READ | macho.VM_PROT_WRITE,
.initprot = macho.VM_PROT_READ | macho.VM_PROT_WRITE,
}),
});
}
if (self.got_section_index == null) {
const data_const_seg = &self.load_commands.items[self.data_const_segment_cmd_index.?].Segment;
self.got_section_index = @intCast(u16, data_const_seg.sections.items.len);
try data_const_seg.addSection(self.base.allocator, "__got", .{
.@"align" = 3, // 2^3 = @sizeOf(u64)
.flags = macho.S_NON_LAZY_SYMBOL_POINTERS,
});
_ = try self.section_ordinals.getOrPut(self.base.allocator, .{
.seg = self.data_const_segment_cmd_index.?,
.sect = self.got_section_index.?,
});
}
if (self.data_segment_cmd_index == null) {
self.data_segment_cmd_index = @intCast(u16, self.load_commands.items.len);
try self.load_commands.append(self.base.allocator, .{
.Segment = SegmentCommand.empty("__DATA", .{
.maxprot = macho.VM_PROT_READ | macho.VM_PROT_WRITE,
.initprot = macho.VM_PROT_READ | macho.VM_PROT_WRITE,
}),
});
}
if (self.la_symbol_ptr_section_index == null) {
const data_seg = &self.load_commands.items[self.data_segment_cmd_index.?].Segment;
self.la_symbol_ptr_section_index = @intCast(u16, data_seg.sections.items.len);
try data_seg.addSection(self.base.allocator, "__la_symbol_ptr", .{
.@"align" = 3, // 2^3 = @sizeOf(u64)
.flags = macho.S_LAZY_SYMBOL_POINTERS,
});
_ = try self.section_ordinals.getOrPut(self.base.allocator, .{
.seg = self.data_segment_cmd_index.?,
.sect = self.la_symbol_ptr_section_index.?,
});
}
if (self.data_section_index == null) {
const data_seg = &self.load_commands.items[self.data_segment_cmd_index.?].Segment;
self.data_section_index = @intCast(u16, data_seg.sections.items.len);
try data_seg.addSection(self.base.allocator, "__data", .{
.@"align" = 3, // 2^3 = @sizeOf(u64)
});
_ = try self.section_ordinals.getOrPut(self.base.allocator, .{
.seg = self.data_segment_cmd_index.?,
.sect = self.data_section_index.?,
});
}
if (self.linkedit_segment_cmd_index == null) {
self.linkedit_segment_cmd_index = @intCast(u16, self.load_commands.items.len);
try self.load_commands.append(self.base.allocator, .{
.Segment = SegmentCommand.empty("__LINKEDIT", .{
.maxprot = macho.VM_PROT_READ,
.initprot = macho.VM_PROT_READ,
}),
});
}
if (self.dyld_info_cmd_index == null) {
self.dyld_info_cmd_index = @intCast(u16, self.load_commands.items.len);
try self.load_commands.append(self.base.allocator, .{
.DyldInfoOnly = .{
.cmd = macho.LC_DYLD_INFO_ONLY,
.cmdsize = @sizeOf(macho.dyld_info_command),
.rebase_off = 0,
.rebase_size = 0,
.bind_off = 0,
.bind_size = 0,
.weak_bind_off = 0,
.weak_bind_size = 0,
.lazy_bind_off = 0,
.lazy_bind_size = 0,
.export_off = 0,
.export_size = 0,
},
});
}
if (self.symtab_cmd_index == null) {
self.symtab_cmd_index = @intCast(u16, self.load_commands.items.len);
try self.load_commands.append(self.base.allocator, .{
.Symtab = .{
.cmd = macho.LC_SYMTAB,
.cmdsize = @sizeOf(macho.symtab_command),
.symoff = 0,
.nsyms = 0,
.stroff = 0,
.strsize = 0,
},
});
}
if (self.dysymtab_cmd_index == null) {
self.dysymtab_cmd_index = @intCast(u16, self.load_commands.items.len);
try self.load_commands.append(self.base.allocator, .{
.Dysymtab = .{
.cmd = macho.LC_DYSYMTAB,
.cmdsize = @sizeOf(macho.dysymtab_command),
.ilocalsym = 0,
.nlocalsym = 0,
.iextdefsym = 0,
.nextdefsym = 0,
.iundefsym = 0,
.nundefsym = 0,
.tocoff = 0,
.ntoc = 0,
.modtaboff = 0,
.nmodtab = 0,
.extrefsymoff = 0,
.nextrefsyms = 0,
.indirectsymoff = 0,
.nindirectsyms = 0,
.extreloff = 0,
.nextrel = 0,
.locreloff = 0,
.nlocrel = 0,
},
});
}
if (self.dylinker_cmd_index == null) {
self.dylinker_cmd_index = @intCast(u16, self.load_commands.items.len);
const cmdsize = @intCast(u32, mem.alignForwardGeneric(
u64,
@sizeOf(macho.dylinker_command) + mem.len(default_dyld_path),
@sizeOf(u64),
));
var dylinker_cmd = commands.emptyGenericCommandWithData(macho.dylinker_command{
.cmd = macho.LC_LOAD_DYLINKER,
.cmdsize = cmdsize,
.name = @sizeOf(macho.dylinker_command),
});
dylinker_cmd.data = try self.base.allocator.alloc(u8, cmdsize - dylinker_cmd.inner.name);
mem.set(u8, dylinker_cmd.data, 0);
mem.copy(u8, dylinker_cmd.data, mem.sliceTo(default_dyld_path, 0));
try self.load_commands.append(self.base.allocator, .{ .Dylinker = dylinker_cmd });
}
if (self.main_cmd_index == null and self.base.options.output_mode == .exe) {
self.main_cmd_index = @intCast(u16, self.load_commands.items.len);
try self.load_commands.append(self.base.allocator, .{
.Main = .{
.cmd = macho.LC_MAIN,
.cmdsize = @sizeOf(macho.entry_point_command),
.entryoff = 0x0,
.stacksize = 0,
},
});
}
if (self.dylib_id_cmd_index == null and self.base.options.output_mode == .lib) {
self.dylib_id_cmd_index = @intCast(u16, self.load_commands.items.len);
const install_name = try std.fmt.allocPrint(self.base.allocator, "@rpath/{s}", .{
self.base.options.emit.sub_path,
});
defer self.base.allocator.free(install_name);
const current_version = self.base.options.current_version orelse
std.builtin.Version{ .major = 1, .minor = 0, .patch = 0 };
const compat_version = self.base.options.compatibility_version orelse
std.builtin.Version{ .major = 1, .minor = 0, .patch = 0 };
var dylib_cmd = try commands.createLoadDylibCommand(
self.base.allocator,
install_name,
2,
current_version.major << 16 | current_version.minor << 8 | current_version.patch,
compat_version.major << 16 | compat_version.minor << 8 | compat_version.patch,
);
errdefer dylib_cmd.deinit(self.base.allocator);
dylib_cmd.inner.cmd = macho.LC_ID_DYLIB;
try self.load_commands.append(self.base.allocator, .{ .Dylib = dylib_cmd });
}
if (self.source_version_cmd_index == null) {
self.source_version_cmd_index = @intCast(u16, self.load_commands.items.len);
try self.load_commands.append(self.base.allocator, .{
.SourceVersion = .{
.cmd = macho.LC_SOURCE_VERSION,
.cmdsize = @sizeOf(macho.source_version_command),
.version = 0x0,
},
});
}
if (self.build_version_cmd_index == null) {
self.build_version_cmd_index = @intCast(u16, self.load_commands.items.len);
const cmdsize = @intCast(u32, mem.alignForwardGeneric(
u64,
@sizeOf(macho.build_version_command) + @sizeOf(macho.build_tool_version),
@sizeOf(u64),
));
// TODO versions should really be supplied with separate flags
// inspect man ld on macOS
const platform_version = blk: {
const ver = self.base.options.target.os.version_range.semver.min;
const platform_version = ver.major << 16 | ver.minor << 8;
break :blk platform_version;
};
// TODO inspect man ld on macOS
const sdk_version = platform_version;
const is_simulator_abi = self.base.options.target.abi == .simulator;
var cmd = commands.emptyGenericCommandWithData(macho.build_version_command{
.cmd = macho.LC_BUILD_VERSION,
.cmdsize = cmdsize,
.platform = switch (self.base.options.target.os.tag) {
.macos => macho.PLATFORM_MACOS,
.ios => if (is_simulator_abi) macho.PLATFORM_IOSSIMULATOR else macho.PLATFORM_IOS,
.watchos => if (is_simulator_abi) macho.PLATFORM_WATCHOSSIMULATOR else macho.PLATFORM_WATCHOS,
.tvos => if (is_simulator_abi) macho.PLATFORM_TVOSSIMULATOR else macho.PLATFORM_TVOS,
else => unreachable,
},
.minos = platform_version,
.sdk = sdk_version,
.ntools = 1,
});
const ld_ver = macho.build_tool_version{
.tool = macho.TOOL_LD,
.version = 0x0,
};
cmd.data = try self.base.allocator.alloc(u8, cmdsize - @sizeOf(macho.build_version_command));
mem.set(u8, cmd.data, 0);
mem.copy(u8, cmd.data, mem.asBytes(&ld_ver));
try self.load_commands.append(self.base.allocator, .{ .BuildVersion = cmd });
}
if (self.uuid_cmd_index == null) {
self.uuid_cmd_index = @intCast(u16, self.load_commands.items.len);
var uuid_cmd: macho.uuid_command = .{
.cmd = macho.LC_UUID,
.cmdsize = @sizeOf(macho.uuid_command),
.uuid = undefined,
};
std.crypto.random.bytes(&uuid_cmd.uuid);
try self.load_commands.append(self.base.allocator, .{ .Uuid = uuid_cmd });
}
}
fn writeDyldInfoData(self: *MachO) !void {
var rebase_pointers = std.ArrayList(bind.Pointer).init(self.base.allocator);
defer rebase_pointers.deinit();
var bind_pointers = std.ArrayList(bind.Pointer).init(self.base.allocator);
defer bind_pointers.deinit();
var lazy_bind_pointers = std.ArrayList(bind.Pointer).init(self.base.allocator);
defer lazy_bind_pointers.deinit();
{
var it = self.atoms.iterator();
while (it.next()) |entry| {
const match = entry.key_ptr.*;
var atom: *Atom = entry.value_ptr.*;
if (match.seg == self.text_segment_cmd_index.?) continue; // __TEXT is non-writable
const seg = self.load_commands.items[match.seg].Segment;
while (true) {
const sym = self.locals.items[atom.local_sym_index];
const base_offset = sym.n_value - seg.inner.vmaddr;
for (atom.rebases.items) |offset| {
try rebase_pointers.append(.{
.offset = base_offset + offset,
.segment_id = match.seg,
});
}
for (atom.bindings.items) |binding| {
const resolv = self.symbol_resolver.get(binding.n_strx).?;
switch (resolv.where) {
.global => {
// Turn into a rebase.
try rebase_pointers.append(.{
.offset = base_offset + binding.offset,
.segment_id = match.seg,
});
},
.undef => {
const bind_sym = self.undefs.items[resolv.where_index];
try bind_pointers.append(.{
.offset = binding.offset + base_offset,
.segment_id = match.seg,
.dylib_ordinal = @divExact(bind_sym.n_desc, macho.N_SYMBOL_RESOLVER),
.name = self.getString(bind_sym.n_strx),
});
},
}
}
for (atom.lazy_bindings.items) |binding| {
const resolv = self.symbol_resolver.get(binding.n_strx).?;
switch (resolv.where) {
.global => {
// Turn into a rebase.
try rebase_pointers.append(.{
.offset = base_offset + binding.offset,
.segment_id = match.seg,
});
},
.undef => {
const bind_sym = self.undefs.items[resolv.where_index];
try lazy_bind_pointers.append(.{
.offset = binding.offset + base_offset,
.segment_id = match.seg,
.dylib_ordinal = @divExact(bind_sym.n_desc, macho.N_SYMBOL_RESOLVER),
.name = self.getString(bind_sym.n_strx),
});
},
}
}
if (atom.prev) |prev| {
atom = prev;
} else break;
}
}
}
var trie: Trie = .{};
defer trie.deinit(self.base.allocator);
{
// TODO handle macho.EXPORT_SYMBOL_FLAGS_REEXPORT and macho.EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER.
log.debug("generating export trie", .{});
const text_segment = self.load_commands.items[self.text_segment_cmd_index.?].Segment;
const base_address = text_segment.inner.vmaddr;
for (self.globals.items) |sym| {
if (sym.n_type == 0) continue;
const sym_name = self.getString(sym.n_strx);
log.debug(" (putting '{s}' defined at 0x{x})", .{ sym_name, sym.n_value });
try trie.put(self.base.allocator, .{
.name = sym_name,
.vmaddr_offset = sym.n_value - base_address,
.export_flags = macho.EXPORT_SYMBOL_FLAGS_KIND_REGULAR,
});
}
try trie.finalize(self.base.allocator);
}
const seg = &self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment;
const dyld_info = &self.load_commands.items[self.dyld_info_cmd_index.?].DyldInfoOnly;
const rebase_size = try bind.rebaseInfoSize(rebase_pointers.items);
const bind_size = try bind.bindInfoSize(bind_pointers.items);
const lazy_bind_size = try bind.lazyBindInfoSize(lazy_bind_pointers.items);
const export_size = trie.size;
dyld_info.rebase_off = @intCast(u32, seg.inner.fileoff);
dyld_info.rebase_size = @intCast(u32, mem.alignForwardGeneric(u64, rebase_size, @alignOf(u64)));
seg.inner.filesize += dyld_info.rebase_size;
dyld_info.bind_off = dyld_info.rebase_off + dyld_info.rebase_size;
dyld_info.bind_size = @intCast(u32, mem.alignForwardGeneric(u64, bind_size, @alignOf(u64)));
seg.inner.filesize += dyld_info.bind_size;
dyld_info.lazy_bind_off = dyld_info.bind_off + dyld_info.bind_size;
dyld_info.lazy_bind_size = @intCast(u32, mem.alignForwardGeneric(u64, lazy_bind_size, @alignOf(u64)));
seg.inner.filesize += dyld_info.lazy_bind_size;
dyld_info.export_off = dyld_info.lazy_bind_off + dyld_info.lazy_bind_size;
dyld_info.export_size = @intCast(u32, mem.alignForwardGeneric(u64, export_size, @alignOf(u64)));
seg.inner.filesize += dyld_info.export_size;
const needed_size = dyld_info.rebase_size + dyld_info.bind_size + dyld_info.lazy_bind_size + dyld_info.export_size;
var buffer = try self.base.allocator.alloc(u8, needed_size);
defer self.base.allocator.free(buffer);
mem.set(u8, buffer, 0);
var stream = std.io.fixedBufferStream(buffer);
const writer = stream.writer();
try bind.writeRebaseInfo(rebase_pointers.items, writer);
try stream.seekBy(@intCast(i64, dyld_info.rebase_size) - @intCast(i64, rebase_size));
try bind.writeBindInfo(bind_pointers.items, writer);
try stream.seekBy(@intCast(i64, dyld_info.bind_size) - @intCast(i64, bind_size));
try bind.writeLazyBindInfo(lazy_bind_pointers.items, writer);
try stream.seekBy(@intCast(i64, dyld_info.lazy_bind_size) - @intCast(i64, lazy_bind_size));
_ = try trie.write(writer);
log.debug("writing dyld info from 0x{x} to 0x{x}", .{
dyld_info.rebase_off,
dyld_info.rebase_off + needed_size,
});
try self.base.file.pwriteAll(buffer, dyld_info.rebase_off);
try self.populateLazyBindOffsetsInStubHelper(
buffer[dyld_info.rebase_size + dyld_info.bind_size ..][0..dyld_info.lazy_bind_size],
);
}
fn populateLazyBindOffsetsInStubHelper(self: *MachO, buffer: []const u8) !void {
const last_atom = self.atoms.get(.{
.seg = self.text_segment_cmd_index.?,
.sect = self.stub_helper_section_index.?,
}) orelse return;
if (last_atom == self.stub_helper_preamble_atom.?) return;
// Because we insert lazy binding opcodes in reverse order (from last to the first atom),
// we need reverse the order of atom traversal here as well.
// TODO figure out a less error prone mechanims for this!
var table = std.AutoHashMap(i64, *Atom).init(self.base.allocator);
defer table.deinit();
{
var stub_atom = last_atom;
var laptr_atom = self.atoms.get(.{
.seg = self.data_segment_cmd_index.?,
.sect = self.la_symbol_ptr_section_index.?,
}).?;
const base_addr = blk: {
const seg = self.load_commands.items[self.data_segment_cmd_index.?].Segment;
break :blk seg.inner.vmaddr;
};
while (true) {
const laptr_off = blk: {
const sym = self.locals.items[laptr_atom.local_sym_index];
break :blk @intCast(i64, sym.n_value - base_addr);
};
try table.putNoClobber(laptr_off, stub_atom);
if (laptr_atom.prev) |prev| {
laptr_atom = prev;
stub_atom = stub_atom.prev.?;
} else break;
}
}
var stream = std.io.fixedBufferStream(buffer);
var reader = stream.reader();
var offsets = std.ArrayList(struct { sym_offset: i64, offset: u32 }).init(self.base.allocator);
try offsets.append(.{ .sym_offset = undefined, .offset = 0 });
defer offsets.deinit();
var valid_block = false;
while (true) {
const inst = reader.readByte() catch |err| switch (err) {
error.EndOfStream => break,
else => return err,
};
const opcode: u8 = inst & macho.BIND_OPCODE_MASK;
switch (opcode) {
macho.BIND_OPCODE_DO_BIND => {
valid_block = true;
},
macho.BIND_OPCODE_DONE => {
if (valid_block) {
const offset = try stream.getPos();
try offsets.append(.{ .sym_offset = undefined, .offset = @intCast(u32, offset) });
}
valid_block = false;
},
macho.BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM => {
var next = try reader.readByte();
while (next != @as(u8, 0)) {
next = try reader.readByte();
}
},
macho.BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB => {
var inserted = offsets.pop();
inserted.sym_offset = try std.leb.readILEB128(i64, reader);
try offsets.append(inserted);
},
macho.BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB => {
_ = try std.leb.readULEB128(u64, reader);
},
macho.BIND_OPCODE_SET_ADDEND_SLEB => {
_ = try std.leb.readILEB128(i64, reader);
},
else => {},
}
}
const sect = blk: {
const seg = self.load_commands.items[self.text_segment_cmd_index.?].Segment;
break :blk seg.sections.items[self.stub_helper_section_index.?];
};
const stub_offset: u4 = switch (self.base.options.target.cpu.arch) {
.x86_64 => 1,
.aarch64 => 2 * @sizeOf(u32),
else => unreachable,
};
var buf: [@sizeOf(u32)]u8 = undefined;
_ = offsets.pop();
while (offsets.popOrNull()) |bind_offset| {
const atom = table.get(bind_offset.sym_offset).?;
const sym = self.locals.items[atom.local_sym_index];
const file_offset = sect.offset + sym.n_value - sect.addr + stub_offset;
mem.writeIntLittle(u32, &buf, bind_offset.offset);
log.debug("writing lazy bind offset in stub helper of 0x{x} for symbol {s} at offset 0x{x}", .{
bind_offset.offset,
self.getString(sym.n_strx),
file_offset,
});
try self.base.file.pwriteAll(&buf, file_offset);
}
}
fn writeDices(self: *MachO) !void {
if (!self.has_dices) return;
var buf = std.ArrayList(u8).init(self.base.allocator);
defer buf.deinit();
var atom: *Atom = self.atoms.get(.{
.seg = self.text_segment_cmd_index orelse return,
.sect = self.text_section_index orelse return,
}) orelse return;
while (atom.prev) |prev| {
atom = prev;
}
const text_seg = self.load_commands.items[self.text_segment_cmd_index.?].Segment;
const text_sect = text_seg.sections.items[self.text_section_index.?];
while (true) {
if (atom.dices.items.len > 0) {
const sym = self.locals.items[atom.local_sym_index];
const base_off = try math.cast(u32, sym.n_value - text_sect.addr + text_sect.offset);
try buf.ensureUnusedCapacity(atom.dices.items.len * @sizeOf(macho.data_in_code_entry));
for (atom.dices.items) |dice| {
const rebased_dice = macho.data_in_code_entry{
.offset = base_off + dice.offset,
.length = dice.length,
.kind = dice.kind,
};
buf.appendSliceAssumeCapacity(mem.asBytes(&rebased_dice));
}
}
if (atom.next) |next| {
atom = next;
} else break;
}
const seg = &self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment;
const dice_cmd = &self.load_commands.items[self.data_in_code_cmd_index.?].LinkeditData;
const needed_size = @intCast(u32, buf.items.len);
dice_cmd.dataoff = @intCast(u32, seg.inner.fileoff + seg.inner.filesize);
dice_cmd.datasize = needed_size;
seg.inner.filesize += needed_size;
log.debug("writing data-in-code from 0x{x} to 0x{x}", .{
dice_cmd.dataoff,
dice_cmd.dataoff + dice_cmd.datasize,
});
try self.base.file.pwriteAll(buf.items, dice_cmd.dataoff);
}
fn writeSymbolTable(self: *MachO) !void {
const seg = &self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment;
const symtab = &self.load_commands.items[self.symtab_cmd_index.?].Symtab;
symtab.symoff = @intCast(u32, seg.inner.fileoff + seg.inner.filesize);
var locals = std.ArrayList(macho.nlist_64).init(self.base.allocator);
defer locals.deinit();
for (self.locals.items) |sym| {
if (sym.n_strx == 0) continue;
if (self.symbol_resolver.get(sym.n_strx)) |_| continue;
try locals.append(sym);
}
if (self.has_stabs) {
for (self.objects.items) |object| {
if (object.debug_info == null) continue;
// Open scope
try locals.ensureUnusedCapacity(3);
locals.appendAssumeCapacity(.{
.n_strx = try self.makeString(object.tu_comp_dir.?),
.n_type = macho.N_SO,
.n_sect = 0,
.n_desc = 0,
.n_value = 0,
});
locals.appendAssumeCapacity(.{
.n_strx = try self.makeString(object.tu_name.?),
.n_type = macho.N_SO,
.n_sect = 0,
.n_desc = 0,
.n_value = 0,
});
locals.appendAssumeCapacity(.{
.n_strx = try self.makeString(object.name),
.n_type = macho.N_OSO,
.n_sect = 0,
.n_desc = 1,
.n_value = object.mtime orelse 0,
});
for (object.contained_atoms.items) |atom| {
if (atom.stab) |stab| {
const nlists = try stab.asNlists(atom.local_sym_index, self);
defer self.base.allocator.free(nlists);
try locals.appendSlice(nlists);
} else {
for (atom.contained.items) |sym_at_off| {
const stab = sym_at_off.stab orelse continue;
const nlists = try stab.asNlists(sym_at_off.local_sym_index, self);
defer self.base.allocator.free(nlists);
try locals.appendSlice(nlists);
}
}
}
// Close scope
try locals.append(.{
.n_strx = 0,
.n_type = macho.N_SO,
.n_sect = 0,
.n_desc = 0,
.n_value = 0,
});
}
}
const nlocals = locals.items.len;
const nexports = self.globals.items.len;
const nundefs = self.undefs.items.len;
const locals_off = symtab.symoff;
const locals_size = nlocals * @sizeOf(macho.nlist_64);
log.debug("writing local symbols from 0x{x} to 0x{x}", .{ locals_off, locals_size + locals_off });
try self.base.file.pwriteAll(mem.sliceAsBytes(locals.items), locals_off);
const exports_off = locals_off + locals_size;
const exports_size = nexports * @sizeOf(macho.nlist_64);
log.debug("writing exported symbols from 0x{x} to 0x{x}", .{ exports_off, exports_size + exports_off });
try self.base.file.pwriteAll(mem.sliceAsBytes(self.globals.items), exports_off);
const undefs_off = exports_off + exports_size;
const undefs_size = nundefs * @sizeOf(macho.nlist_64);
log.debug("writing undefined symbols from 0x{x} to 0x{x}", .{ undefs_off, undefs_size + undefs_off });
try self.base.file.pwriteAll(mem.sliceAsBytes(self.undefs.items), undefs_off);
symtab.nsyms = @intCast(u32, nlocals + nexports + nundefs);
seg.inner.filesize += locals_size + exports_size + undefs_size;
// Update dynamic symbol table.
const dysymtab = &self.load_commands.items[self.dysymtab_cmd_index.?].Dysymtab;
dysymtab.nlocalsym = @intCast(u32, nlocals);
dysymtab.iextdefsym = dysymtab.nlocalsym;
dysymtab.nextdefsym = @intCast(u32, nexports);
dysymtab.iundefsym = dysymtab.nlocalsym + dysymtab.nextdefsym;
dysymtab.nundefsym = @intCast(u32, nundefs);
const text_segment = &self.load_commands.items[self.text_segment_cmd_index.?].Segment;
const stubs = &text_segment.sections.items[self.stubs_section_index.?];
const data_const_segment = &self.load_commands.items[self.data_const_segment_cmd_index.?].Segment;
const got = &data_const_segment.sections.items[self.got_section_index.?];
const data_segment = &self.load_commands.items[self.data_segment_cmd_index.?].Segment;
const la_symbol_ptr = &data_segment.sections.items[self.la_symbol_ptr_section_index.?];
const nstubs = @intCast(u32, self.stubs_map.keys().len);
const ngot_entries = @intCast(u32, self.got_entries_map.keys().len);
dysymtab.indirectsymoff = @intCast(u32, seg.inner.fileoff + seg.inner.filesize);
dysymtab.nindirectsyms = nstubs * 2 + ngot_entries;
const needed_size = dysymtab.nindirectsyms * @sizeOf(u32);
seg.inner.filesize += needed_size;
log.debug("writing indirect symbol table from 0x{x} to 0x{x}", .{
dysymtab.indirectsymoff,
dysymtab.indirectsymoff + needed_size,
});
var buf = try self.base.allocator.alloc(u8, needed_size);
defer self.base.allocator.free(buf);
var stream = std.io.fixedBufferStream(buf);
var writer = stream.writer();
stubs.reserved1 = 0;
for (self.stubs_map.keys()) |key| {
const resolv = self.symbol_resolver.get(key).?;
switch (resolv.where) {
.global => try writer.writeIntLittle(u32, macho.INDIRECT_SYMBOL_LOCAL),
.undef => try writer.writeIntLittle(u32, dysymtab.iundefsym + resolv.where_index),
}
}
got.reserved1 = nstubs;
for (self.got_entries_map.keys()) |key| {
switch (key) {
.local => try writer.writeIntLittle(u32, macho.INDIRECT_SYMBOL_LOCAL),
.global => |n_strx| {
const resolv = self.symbol_resolver.get(n_strx).?;
switch (resolv.where) {
.global => try writer.writeIntLittle(u32, macho.INDIRECT_SYMBOL_LOCAL),
.undef => try writer.writeIntLittle(u32, dysymtab.iundefsym + resolv.where_index),
}
},
}
}
la_symbol_ptr.reserved1 = got.reserved1 + ngot_entries;
for (self.stubs_map.keys()) |key| {
const resolv = self.symbol_resolver.get(key).?;
switch (resolv.where) {
.global => try writer.writeIntLittle(u32, macho.INDIRECT_SYMBOL_LOCAL),
.undef => try writer.writeIntLittle(u32, dysymtab.iundefsym + resolv.where_index),
}
}
try self.base.file.pwriteAll(buf, dysymtab.indirectsymoff);
}
fn writeStringTable(self: *MachO) !void {
const seg = &self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment;
const symtab = &self.load_commands.items[self.symtab_cmd_index.?].Symtab;
symtab.stroff = @intCast(u32, seg.inner.fileoff + seg.inner.filesize);
symtab.strsize = @intCast(u32, mem.alignForwardGeneric(u64, self.strtab.items.len, @alignOf(u64)));
seg.inner.filesize += symtab.strsize;
log.debug("writing string table from 0x{x} to 0x{x}", .{ symtab.stroff, symtab.stroff + symtab.strsize });
try self.base.file.pwriteAll(self.strtab.items, symtab.stroff);
if (symtab.strsize > self.strtab.items.len) {
// This is potentially the last section, so we need to pad it out.
try self.base.file.pwriteAll(&[_]u8{0}, seg.inner.fileoff + seg.inner.filesize - 1);
}
}
fn writeLinkeditSegment(self: *MachO) !void {
const seg = &self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment;
seg.inner.filesize = 0;
try self.writeDyldInfoData();
try self.writeDices();
try self.writeSymbolTable();
try self.writeStringTable();
seg.inner.vmsize = mem.alignForwardGeneric(u64, seg.inner.filesize, self.page_size);
}
fn writeCodeSignaturePadding(self: *MachO) !void {
const linkedit_segment = &self.load_commands.items[self.linkedit_segment_cmd_index.?].Segment;
const code_sig_cmd = &self.load_commands.items[self.code_signature_cmd_index.?].LinkeditData;
const fileoff = linkedit_segment.inner.fileoff + linkedit_segment.inner.filesize;
const needed_size = CodeSignature.calcCodeSignaturePaddingSize(
self.base.options.emit.sub_path,
fileoff,
self.page_size,
);
code_sig_cmd.dataoff = @intCast(u32, fileoff);
code_sig_cmd.datasize = needed_size;
// Advance size of __LINKEDIT segment
linkedit_segment.inner.filesize += needed_size;
if (linkedit_segment.inner.vmsize < linkedit_segment.inner.filesize) {
linkedit_segment.inner.vmsize = mem.alignForwardGeneric(u64, linkedit_segment.inner.filesize, self.page_size);
}
log.debug("writing code signature padding from 0x{x} to 0x{x}", .{ fileoff, fileoff + needed_size });
// Pad out the space. We need to do this to calculate valid hashes for everything in the file
// except for code signature data.
try self.base.file.pwriteAll(&[_]u8{0}, fileoff + needed_size - 1);
}
fn writeCodeSignature(self: *MachO) !void {
const text_segment = self.load_commands.items[self.text_segment_cmd_index.?].Segment;
const code_sig_cmd = self.load_commands.items[self.code_signature_cmd_index.?].LinkeditData;
var code_sig: CodeSignature = .{};
defer code_sig.deinit(self.base.allocator);
try code_sig.calcAdhocSignature(
self.base.allocator,
self.base.file,
self.base.options.emit.sub_path,
text_segment.inner,
code_sig_cmd,
self.base.options.output_mode,
self.page_size,
);
var buffer = try self.base.allocator.alloc(u8, code_sig.size());
defer self.base.allocator.free(buffer);
var stream = std.io.fixedBufferStream(buffer);
try code_sig.write(stream.writer());
log.debug("writing code signature from 0x{x} to 0x{x}", .{ code_sig_cmd.dataoff, code_sig_cmd.dataoff + buffer.len });
try self.base.file.pwriteAll(buffer, code_sig_cmd.dataoff);
}
/// Writes all load commands and section headers.
fn writeLoadCommands(self: *MachO) !void {
var sizeofcmds: u32 = 0;
for (self.load_commands.items) |lc| {
sizeofcmds += lc.cmdsize();
}
var buffer = try self.base.allocator.alloc(u8, sizeofcmds);
defer self.base.allocator.free(buffer);
var writer = std.io.fixedBufferStream(buffer).writer();
for (self.load_commands.items) |lc| {
try lc.write(writer);
}
const off = @sizeOf(macho.mach_header_64);
log.debug("writing {} load commands from 0x{x} to 0x{x}", .{ self.load_commands.items.len, off, off + sizeofcmds });
try self.base.file.pwriteAll(buffer, off);
}
/// Writes Mach-O file header.
fn writeHeader(self: *MachO) !void {
var header = commands.emptyHeader(.{
.flags = macho.MH_NOUNDEFS | macho.MH_DYLDLINK | macho.MH_PIE | macho.MH_TWOLEVEL,
});
switch (self.base.options.target.cpu.arch) {
.aarch64 => {
header.cputype = macho.CPU_TYPE_ARM64;
header.cpusubtype = macho.CPU_SUBTYPE_ARM_ALL;
},
.x86_64 => {
header.cputype = macho.CPU_TYPE_X86_64;
header.cpusubtype = macho.CPU_SUBTYPE_X86_64_ALL;
},
else => return error.UnsupportedCpuArchitecture,
}
switch (self.base.options.output_mode) {
.exe => {
header.filetype = macho.MH_EXECUTE;
},
.lib => {
// By this point, it can only be a dylib.
header.filetype = macho.MH_DYLIB;
header.flags |= macho.MH_NO_REEXPORTED_DYLIBS;
},
}
if (self.tlv_section_index) |_| {
header.flags |= macho.MH_HAS_TLV_DESCRIPTORS;
}
header.ncmds = @intCast(u32, self.load_commands.items.len);
header.sizeofcmds = 0;
for (self.load_commands.items) |cmd| {
header.sizeofcmds += cmd.cmdsize();
}
log.debug("writing Mach-O header {}", .{header});
try self.base.file.pwriteAll(mem.asBytes(&header), 0);
}
pub fn makeStaticString(bytes: []const u8) [16]u8 {
var buf = [_]u8{0} ** 16;
assert(bytes.len <= buf.len);
mem.copy(u8, &buf, bytes);
return buf;
}
pub fn makeString(self: *MachO, string: []const u8) !u32 {
const gop = try self.strtab_dir.getOrPutContextAdapted(self.base.allocator, @as([]const u8, string), StringIndexAdapter{
.bytes = &self.strtab,
}, StringIndexContext{
.bytes = &self.strtab,
});
if (gop.found_existing) {
const off = gop.key_ptr.*;
log.debug("reusing string '{s}' at offset 0x{x}", .{ string, off });
return off;
}
try self.strtab.ensureUnusedCapacity(self.base.allocator, string.len + 1);
const new_off = @intCast(u32, self.strtab.items.len);
log.debug("writing new string '{s}' at offset 0x{x}", .{ string, new_off });
self.strtab.appendSliceAssumeCapacity(string);
self.strtab.appendAssumeCapacity(0);
gop.key_ptr.* = new_off;
return new_off;
}
pub fn getString(self: *MachO, off: u32) []const u8 {
assert(off < self.strtab.items.len);
return mem.sliceTo(@ptrCast([*:0]const u8, self.strtab.items.ptr + off), 0);
}
pub fn symbolIsTemp(sym: macho.nlist_64, sym_name: []const u8) bool {
if (!sym.sect()) return false;
if (sym.ext()) return false;
return mem.startsWith(u8, sym_name, "l") or mem.startsWith(u8, sym_name, "L");
}
pub fn findFirst(comptime T: type, haystack: []T, start: usize, predicate: anytype) usize {
if (!@hasDecl(@TypeOf(predicate), "predicate"))
@compileError("Predicate is required to define fn predicate(@This(), T) bool");
if (start == haystack.len) return start;
var i = start;
while (i < haystack.len) : (i += 1) {
if (predicate.predicate(haystack[i])) break;
}
return i;
} | src/MachO.zig |
const windows = @import("windows.zig");
const BYTE = windows.BYTE;
const UINT = windows.UINT;
const UINT32 = windows.UINT32;
const IUnknown = windows.IUnknown;
const WINAPI = windows.WINAPI;
const GUID = windows.GUID;
const HRESULT = windows.HRESULT;
const DWORD = windows.DWORD;
const WORD = windows.WORD;
const PROPVARIANT = windows.PROPVARIANT;
const HANDLE = windows.HANDLE;
const REFERENCE_TIME = windows.REFERENCE_TIME;
const MAKE_HRESULT = windows.MAKE_HRESULT;
const SEVERITY_SUCCESS = windows.SEVERITY_SUCCESS;
const SEVERITY_ERROR = windows.SEVERITY_ERROR;
pub const EDataFlow = enum(UINT) {
eRender = 0,
eCapture = 1,
eAll = 2,
};
pub const ERole = enum(UINT) {
eConsole = 0,
eMultimedia = 1,
eCommunications = 2,
};
pub const IMMDevice = extern struct {
const Self = @This();
v: *const extern struct {
unknown: IUnknown.VTable(Self),
device: VTable(Self),
},
usingnamespace IUnknown.Methods(Self);
usingnamespace Methods(Self);
pub fn Methods(comptime T: type) type {
return extern struct {
pub inline fn Activate(
self: *T,
guid: *const GUID,
clsctx: DWORD,
params: ?*PROPVARIANT,
iface: *?*anyopaque,
) HRESULT {
return self.v.device.Activate(self, guid, clsctx, params, iface);
}
};
}
pub fn VTable(comptime T: type) type {
return extern struct {
Activate: fn (*T, *const GUID, DWORD, ?*PROPVARIANT, *?*anyopaque) callconv(WINAPI) HRESULT,
OpenPropertyStore: *anyopaque,
GetId: *anyopaque,
GetState: *anyopaque,
};
}
};
pub const IMMDeviceEnumerator = extern struct {
const Self = @This();
v: *const extern struct {
unknown: IUnknown.VTable(Self),
devenum: VTable(Self),
},
usingnamespace IUnknown.Methods(Self);
usingnamespace Methods(Self);
pub fn Methods(comptime T: type) type {
return extern struct {
pub inline fn GetDefaultAudioEndpoint(
self: *T,
flow: EDataFlow,
role: ERole,
endpoint: *?*IMMDevice,
) HRESULT {
return self.v.devenum.GetDefaultAudioEndpoint(self, flow, role, endpoint);
}
};
}
pub fn VTable(comptime T: type) type {
return extern struct {
EnumAudioEndpoints: *anyopaque,
GetDefaultAudioEndpoint: fn (*T, EDataFlow, ERole, *?*IMMDevice) callconv(WINAPI) HRESULT,
GetDevice: *anyopaque,
RegisterEndpointNotificationCallback: *anyopaque,
UnregisterEndpointNotificationCallback: *anyopaque,
};
}
};
pub const CLSID_MMDeviceEnumerator = GUID{
.Data1 = 0xBCDE0395,
.Data2 = 0xE52F,
.Data3 = 0x467C,
.Data4 = .{ 0x8E, 0x3D, 0xC4, 0x57, 0x92, 0x91, 0x69, 0x2E },
};
pub const IID_IMMDeviceEnumerator = GUID{
.Data1 = 0xA95664D2,
.Data2 = 0x9614,
.Data3 = 0x4F35,
.Data4 = .{ 0xA7, 0x46, 0xDE, 0x8D, 0xB6, 0x36, 0x17, 0xE6 },
};
pub const WAVEFORMATEX = extern struct {
wFormatTag: WORD,
nChannels: WORD,
nSamplesPerSec: DWORD,
nAvgBytesPerSec: DWORD,
nBlockAlign: WORD,
wBitsPerSample: WORD,
cbSize: WORD,
};
pub const WAVE_FORMAT_PCM: UINT = 1;
pub const WAVE_FORMAT_IEEE_FLOAT: UINT = 0x0003;
pub const AUDCLNT_SHAREMODE = enum(UINT) {
SHARED = 0,
EXCLUSIVE = 1,
};
pub const AUDCLNT_STREAMFLAGS_CROSSPROCESS: UINT = 0x00010000;
pub const AUDCLNT_STREAMFLAGS_LOOPBACK: UINT = 0x00020000;
pub const AUDCLNT_STREAMFLAGS_EVENTCALLBACK: UINT = 0x00040000;
pub const AUDCLNT_STREAMFLAGS_NOPERSIST: UINT = 0x00080000;
pub const AUDCLNT_STREAMFLAGS_RATEADJUST: UINT = 0x00100000;
pub const AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY: UINT = 0x08000000;
pub const AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM: UINT = 0x80000000;
pub const AUDCLNT_SESSIONFLAGS_EXPIREWHENUNOWNED: UINT = 0x10000000;
pub const AUDCLNT_SESSIONFLAGS_DISPLAY_HIDE: UINT = 0x20000000;
pub const AUDCLNT_SESSIONFLAGS_DISPLAY_HIDEWHENEXPIRED: UINT = 0x40000000;
pub const AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY: UINT = 0x1;
pub const AUDCLNT_BUFFERFLAGS_SILENT: UINT = 0x2;
pub const AUDCLNT_BUFFERFLAGS_TIMESTAMP_ERROR: UINT = 0x4;
pub const IAudioClient = extern struct {
const Self = @This();
v: *const extern struct {
unknown: IUnknown.VTable(Self),
audioclient: VTable(Self),
},
usingnamespace IUnknown.Methods(Self);
usingnamespace Methods(Self);
pub fn Methods(comptime T: type) type {
return extern struct {
pub inline fn Initialize(
self: *T,
mode: AUDCLNT_SHAREMODE,
stream_flags: DWORD,
buffer_duration: REFERENCE_TIME,
periodicity: REFERENCE_TIME,
format: *const WAVEFORMATEX,
audio_session: ?*?*GUID,
) HRESULT {
return self.v.audioclient.Initialize(
self,
mode,
stream_flags,
buffer_duration,
periodicity,
format,
audio_session,
);
}
pub inline fn GetBufferSize(self: *T, size: *UINT32) HRESULT {
return self.v.audioclient.GetBufferSize(self, size);
}
pub inline fn GetStreamLatency(self: *T, latency: *REFERENCE_TIME) HRESULT {
return self.v.audioclient.GetStreamLatency(self, latency);
}
pub inline fn GetCurrentPadding(self: *T, padding: *UINT32) HRESULT {
return self.v.audioclient.GetCurrentPadding(self, padding);
}
pub inline fn IsFormatSupported(
self: *T,
mode: AUDCLNT_SHAREMODE,
format: *const WAVEFORMATEX,
closest_format: ?*?*WAVEFORMATEX,
) HRESULT {
return self.v.audioclient.IsFormatSupported(self, mode, format, closest_format);
}
pub inline fn GetMixFormat(self: *T, format: **WAVEFORMATEX) HRESULT {
return self.v.audioclient.GetMixFormat(self, format);
}
pub inline fn GetDevicePeriod(self: *T, default: ?*REFERENCE_TIME, minimum: ?*REFERENCE_TIME) HRESULT {
return self.v.audioclient.GetDevicePeriod(self, default, minimum);
}
pub inline fn Start(self: *T) HRESULT {
return self.v.audioclient.Start(self);
}
pub inline fn Stop(self: *T) HRESULT {
return self.v.audioclient.Stop(self);
}
pub inline fn Reset(self: *T) HRESULT {
return self.v.audioclient.Reset(self);
}
pub inline fn SetEventHandle(self: *T, handle: HANDLE) HRESULT {
return self.v.audioclient.SetEventHandle(self, handle);
}
pub inline fn GetService(self: *T, guid: *const GUID, iface: *?*anyopaque) HRESULT {
return self.v.audioclient.GetService(self, guid, iface);
}
};
}
pub fn VTable(comptime T: type) type {
return extern struct {
Initialize: fn (
*T,
AUDCLNT_SHAREMODE,
DWORD,
REFERENCE_TIME,
REFERENCE_TIME,
*const WAVEFORMATEX,
?*?*GUID,
) callconv(WINAPI) HRESULT,
GetBufferSize: fn (*T, *UINT32) callconv(WINAPI) HRESULT,
GetStreamLatency: fn (*T, *REFERENCE_TIME) callconv(WINAPI) HRESULT,
GetCurrentPadding: fn (*T, *UINT32) callconv(WINAPI) HRESULT,
IsFormatSupported: fn (
*T,
AUDCLNT_SHAREMODE,
*const WAVEFORMATEX,
?*?*WAVEFORMATEX,
) callconv(WINAPI) HRESULT,
GetMixFormat: fn (*T, **WAVEFORMATEX) callconv(WINAPI) HRESULT,
GetDevicePeriod: fn (*T, ?*REFERENCE_TIME, ?*REFERENCE_TIME) callconv(WINAPI) HRESULT,
Start: fn (*T) callconv(WINAPI) HRESULT,
Stop: fn (*T) callconv(WINAPI) HRESULT,
Reset: fn (*T) callconv(WINAPI) HRESULT,
SetEventHandle: fn (*T, HANDLE) callconv(WINAPI) HRESULT,
GetService: fn (*T, *const GUID, *?*anyopaque) callconv(WINAPI) HRESULT,
};
}
};
pub const IAudioClient2 = extern struct {
const Self = @This();
v: *const extern struct {
unknown: IUnknown.VTable(Self),
audioclient: IAudioClient.VTable(Self),
audioclient2: VTable(Self),
},
usingnamespace IUnknown.Methods(Self);
usingnamespace IAudioClient.Methods(Self);
usingnamespace Methods(Self);
pub fn Methods(comptime T: type) type {
_ = T;
return extern struct {};
}
pub fn VTable(comptime T: type) type {
_ = T;
return extern struct {
IsOffloadCapable: *anyopaque,
SetClientProperties: *anyopaque,
GetBufferSizeLimits: *anyopaque,
};
}
};
// NOTE(mziulek): IAudioClient3 interface is available on Windows 10 and newer.
pub const IAudioClient3 = extern struct {
const Self = @This();
v: *const extern struct {
unknown: IUnknown.VTable(Self),
audioclient: IAudioClient.VTable(Self),
audioclient2: IAudioClient2.VTable(Self),
audioclient3: VTable(Self),
},
usingnamespace IUnknown.Methods(Self);
usingnamespace IAudioClient.Methods(Self);
usingnamespace IAudioClient2.Methods(Self);
usingnamespace Methods(Self);
pub fn Methods(comptime T: type) type {
_ = T;
return extern struct {};
}
pub fn VTable(comptime T: type) type {
_ = T;
return extern struct {
GetSharedModeEnginePeriod: *anyopaque,
GetCurrentSharedModeEnginePeriod: *anyopaque,
InitializeSharedAudioStream: *anyopaque,
};
}
};
pub const IAudioRenderClient = extern struct {
const Self = @This();
v: *const extern struct {
unknown: IUnknown.VTable(Self),
renderclient: VTable(Self),
},
usingnamespace IUnknown.Methods(Self);
usingnamespace Methods(Self);
pub fn Methods(comptime T: type) type {
return extern struct {
pub inline fn GetBuffer(self: *T, num_frames_requested: UINT32, data: ?*?[*]BYTE) HRESULT {
return self.v.renderclient.GetBuffer(self, num_frames_requested, data);
}
pub inline fn ReleaseBuffer(self: *T, num_frames_written: UINT32, flags: DWORD) HRESULT {
return self.v.renderclient.ReleaseBuffer(self, num_frames_written, flags);
}
};
}
pub fn VTable(comptime T: type) type {
return extern struct {
GetBuffer: fn (*T, UINT32, ?*?[*]BYTE) callconv(WINAPI) HRESULT,
ReleaseBuffer: fn (*T, UINT32, DWORD) callconv(WINAPI) HRESULT,
};
}
};
// NOTE(mziulek): IAudioClient3 interface is available on Windows 10 and newer.
pub const IID_IAudioClient3 = GUID{
.Data1 = 0x7ED4EE07,
.Data2 = 0x8E67,
.Data3 = 0x4CD4,
.Data4 = .{ 0x8C, 0x1A, 0x2B, 0x7A, 0x59, 0x87, 0xAD, 0x42 },
};
pub const IID_IAudioRenderClient = GUID{
.Data1 = 0xF294ACFC,
.Data2 = 0x3146,
.Data3 = 0x4483,
.Data4 = .{ 0xA7, 0xBF, 0xAD, 0xDC, 0xA7, 0xC2, 0x60, 0xE2 },
};
pub const FACILITY_AUDCLNT = 0x889;
pub inline fn AUDCLNT_SUCCESS(code: anytype) HRESULT {
return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_AUDCLNT, code);
}
pub inline fn AUDCLNT_ERR(code: anytype) HRESULT {
return MAKE_HRESULT(SEVERITY_ERROR, FACILITY_AUDCLNT, code);
}
// success return codes
pub const AUDCLNT_S_BUFFER_EMPTY = AUDCLNT_SUCCESS(0x001);
pub const AUDCLNT_S_THREAD_ALREADY_REGISTERED = AUDCLNT_SUCCESS(0x002);
pub const AUDCLNT_S_POSITION_STALLED = AUDCLNT_SUCCESS(0x003);
// error return codes
pub const AUDCLNT_E_NOT_INITIALIZED = AUDCLNT_ERR(0x001);
pub const AUDCLNT_E_ALREADY_INITIALIZED = AUDCLNT_ERR(0x002);
pub const AUDCLNT_E_WRONG_ENDPOINT_TYPE = AUDCLNT_ERR(0x003);
pub const AUDCLNT_E_DEVICE_INVALIDATED = AUDCLNT_ERR(0x004);
pub const AUDCLNT_E_NOT_STOPPED = AUDCLNT_ERR(0x005);
pub const AUDCLNT_E_BUFFER_TOO_LARGE = AUDCLNT_ERR(0x006);
pub const AUDCLNT_E_OUT_OF_ORDER = AUDCLNT_ERR(0x007);
pub const AUDCLNT_E_UNSUPPORTED_FORMAT = AUDCLNT_ERR(0x008);
pub const AUDCLNT_E_INVALID_SIZE = AUDCLNT_ERR(0x009);
pub const AUDCLNT_E_DEVICE_IN_USE = AUDCLNT_ERR(0x00a);
pub const AUDCLNT_E_BUFFER_OPERATION_PENDING = AUDCLNT_ERR(0x00b);
pub const AUDCLNT_E_THREAD_NOT_REGISTERED = AUDCLNT_ERR(0x00c);
pub const AUDCLNT_E_EXCLUSIVE_MODE_NOT_ALLOWED = AUDCLNT_ERR(0x00e);
pub const AUDCLNT_E_ENDPOINT_CREATE_FAILED = AUDCLNT_ERR(0x00f);
pub const AUDCLNT_E_SERVICE_NOT_RUNNING = AUDCLNT_ERR(0x010);
pub const AUDCLNT_E_EVENTHANDLE_NOT_EXPECTED = AUDCLNT_ERR(0x011);
pub const AUDCLNT_E_EXCLUSIVE_MODE_ONLY = AUDCLNT_ERR(0x012);
pub const AUDCLNT_E_BUFDURATION_PERIOD_NOT_EQUAL = AUDCLNT_ERR(0x013);
pub const AUDCLNT_E_EVENTHANDLE_NOT_SET = AUDCLNT_ERR(0x014);
pub const AUDCLNT_E_INCORRECT_BUFFER_SIZE = AUDCLNT_ERR(0x015);
pub const AUDCLNT_E_BUFFER_SIZE_ERROR = AUDCLNT_ERR(0x016);
pub const AUDCLNT_E_CPUUSAGE_EXCEEDED = AUDCLNT_ERR(0x017);
pub const AUDCLNT_E_BUFFER_ERROR = AUDCLNT_ERR(0x018);
pub const AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED = AUDCLNT_ERR(0x019);
pub const AUDCLNT_E_INVALID_DEVICE_PERIOD = AUDCLNT_ERR(0x020);
// error set corresponding to the above return codes
pub const Error = error{
NOT_INITIALIZED,
ALREADY_INITIALIZED,
WRONG_ENDPOINT_TYPE,
DEVICE_INVALIDATED,
NOT_STOPPED,
BUFFER_TOO_LARGE,
OUT_OF_ORDER,
UNSUPPORTED_FORMAT,
INVALID_SIZE,
DEVICE_IN_USE,
BUFFER_OPERATION_PENDING,
THREAD_NOT_REGISTERED,
EXCLUSIVE_MODE_NOT_ALLOWED,
ENDPOINT_CREATE_FAILED,
SERVICE_NOT_RUNNING,
EVENTHANDLE_NOT_EXPECTED,
EXCLUSIVE_MODE_ONLY,
BUFDURATION_PERIOD_NOT_EQUAL,
EVENTHANDLE_NOT_SET,
INCORRECT_BUFFER_SIZE,
BUFFER_SIZE_ERROR,
CPUUSAGE_EXCEEDED,
BUFFER_ERROR,
BUFFER_SIZE_NOT_ALIGNED,
INVALID_DEVICE_PERIOD,
}; | modules/platform/vendored/zwin32/src/wasapi.zig |
const std = @import("std");
const utils = @import("utils");
const Allocator = std.mem.Allocator;
const ArenaAllocator = std.heap.ArenaAllocator;
const sort = std.sort;
const print = utils.print;
const desc_i32 = sort.desc(i32);
const HeightMap = struct {
width: usize,
height: usize,
map: []i32,
visited: []bool,
};
fn readInput(arena: *ArenaAllocator, lines_it: *utils.FileLineIterator) anyerror!HeightMap {
var numbers = try std.ArrayList(i32).initCapacity(&arena.allocator, 4096 * 4);
var width: usize = 0;
while (lines_it.next()) |line| {
for (line) |h| {
try numbers.append(@intCast(i32, h - 48));
}
width = line.len;
}
print("File ok :) Number of inputs: {d}", .{numbers.items.len});
var visited = try arena.allocator.alloc(bool, numbers.items.len);
std.mem.set(bool, visited, false);
return HeightMap{
.width = width,
.height = numbers.items.len / width,
.map = numbers.items,
.visited = visited,
};
}
fn getHeight(hm: *const HeightMap, x: i32, y: i32, default: i32) i32 {
if (x < 0 or y < 0 or x >= hm.width or y >= hm.height) {
return default;
}
const offset = @intCast(usize, y) * hm.width + @intCast(usize, x);
return hm.map[offset];
}
fn isLowPoint(hm: *const HeightMap, x: i32, y: i32) bool {
var h = getHeight(hm, x, y, 0);
var h1 = getHeight(hm, x + 1, y, h + 1);
var h2 = getHeight(hm, x - 1, y, h + 1);
var h3 = getHeight(hm, x, y + 1, h + 1);
var h4 = getHeight(hm, x, y - 1, h + 1);
return h < h1 and h < h2 and h < h3 and h < h4;
}
fn calculateBasinSize(hm: *const HeightMap, x: i32, y: i32) i32 {
if (x < 0 or y < 0 or x >= hm.width or y >= hm.height) {
return 0;
}
const offset = @intCast(usize, y) * hm.width + @intCast(usize, x);
if (hm.visited[offset]) {
return 0;
}
hm.visited[offset] = true;
var h = getHeight(hm, x, y, 0);
if (h == 9) {
return 0;
}
var h1 = getHeight(hm, x + 1, y, h + 1);
var h2 = getHeight(hm, x - 1, y, h + 1);
var h3 = getHeight(hm, x, y + 1, h + 1);
var h4 = getHeight(hm, x, y - 1, h + 1);
var b1 = if (h1 >= h) calculateBasinSize(hm, x + 1, y) else 0;
var b2 = if (h2 >= h) calculateBasinSize(hm, x - 1, y) else 0;
var b3 = if (h3 >= h) calculateBasinSize(hm, x, y + 1) else 0;
var b4 = if (h4 >= h) calculateBasinSize(hm, x, y - 1) else 0;
return 1 + b1 + b2 + b3 + b4;
}
fn part1(heightMap: *const HeightMap) i32 {
var sum: i32 = 0;
var y: i32 = 0;
while (y < heightMap.height) : (y += 1) {
var x: i32 = 0;
while (x < heightMap.width) : (x += 1) {
if (isLowPoint(heightMap, x, y)) {
var h = getHeight(heightMap, x, y, 0);
sum += h + 1;
}
}
}
return sum;
}
fn part2(arena: *ArenaAllocator, heightMap: *const HeightMap) anyerror!i32 {
var basin_sizes = try std.ArrayList(i32).initCapacity(&arena.allocator, 4096);
var y: i32 = 0;
while (y < heightMap.height) : (y += 1) {
var x: i32 = 0;
while (x < heightMap.width) : (x += 1) {
if (isLowPoint(heightMap, x, y)) {
try basin_sizes.append(calculateBasinSize(heightMap, x, y));
}
}
}
sort.sort(i32, basin_sizes.items, {}, desc_i32);
return basin_sizes.items[0] * basin_sizes.items[1] * basin_sizes.items[2];
}
pub fn main() anyerror!void {
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena.deinit();
var lines_it = try utils.iterateLinesInFile(&arena.allocator, "input.txt");
defer lines_it.deinit();
const input = try readInput(&arena, &lines_it);
const part1_result = part1(&input);
print("Part 1: {d}", .{part1_result});
const part2_result = try part2(&arena, &input);
print("Part 2: {d}", .{part2_result});
} | day9/src/main.zig |
const std = @import("std");
const io = std.io;
const Allocator = std.mem.Allocator;
const BitSet = @import("nil").bits.BitSet;
const Part1 = struct {
const Self = @This();
bits: BitSet,
count: usize = 0,
last: u8 = 0,
fn init(allocator: *Allocator) !Self {
return Self{
.bits = BitSet.init(allocator),
};
}
fn deinit(self: *Self) void {
self.bits.deinit();
}
fn read(self: *Self, block: []const u8) !void {
for (block) |c| {
switch (c) {
'\n' => {
if (self.last == c) {
self.flush();
}
},
'a'...'z' => {
const i = @intCast(u64, c);
try self.bits.set(i, true);
},
else => {},
}
self.last = c;
}
}
fn flush(self: *Self) void {
self.count += self.bits.count();
self.bits.zero();
}
};
const Part2 = struct {
const Self = @This();
counts: [26]usize,
lines: usize = 0,
count: usize = 0,
last: u8 = 0,
fn init() Self {
return Self{
.counts = [1]usize{0} ** 26,
};
}
fn deinit(self: *Self) void {
self.bits.deinit();
}
fn read(self: *Self, block: []const u8) void {
for (block) |c| {
switch (c) {
'\n' => {
if (self.last == c) {
self.flush();
} else {
self.lines += 1;
}
},
'a'...'z' => {
const i = @intCast(u64, c - 'a');
self.counts[i] += 1;
},
else => {},
}
self.last = c;
}
}
fn flush(self: *Self) void {
switch (self.last) {
'a'...'z' => {
self.lines += 1;
},
else => {},
}
for (self.counts) |c| {
if (c == self.lines) {
self.count += 1;
}
}
self.lines = 0;
std.mem.set(usize, &self.counts, 0);
}
};
pub fn main() anyerror!void {
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena.deinit();
const alloc = &arena.allocator;
var buf: [4000]u8 = undefined;
var stream = io.bufferedReader(io.getStdIn().reader());
var rd = stream.reader();
var pt1 = try Part1.init(alloc);
defer pt1.deinit();
var pt2 = Part2.init();
while (try read(@TypeOf(rd), &rd, &buf)) |block| {
try pt1.read(block);
pt2.read(block);
}
pt1.flush();
pt2.flush();
std.log.info("Count 1 = {}", .{pt1.count});
std.log.info("Count 2 = {}", .{pt2.count});
}
fn read(comptime Reader: type, reader: *Reader, buf: []u8) !?[]u8 {
const n = try reader.read(buf);
if (n == 0) return null;
return buf[0..n];
} | day6/src/main.zig |
const std = @import("std");
const mem = std.mem;
const Diacritic = @This();
allocator: *mem.Allocator,
array: []bool,
lo: u21 = 94,
hi: u21 = 125258,
pub fn init(allocator: *mem.Allocator) !Diacritic {
var instance = Diacritic{
.allocator = allocator,
.array = try allocator.alloc(bool, 125165),
};
mem.set(bool, instance.array, false);
var index: u21 = 0;
instance.array[0] = true;
instance.array[2] = true;
instance.array[74] = true;
instance.array[81] = true;
instance.array[86] = true;
instance.array[89] = true;
instance.array[90] = true;
index = 594;
while (index <= 611) : (index += 1) {
instance.array[index] = true;
}
index = 612;
while (index <= 615) : (index += 1) {
instance.array[index] = true;
}
index = 616;
while (index <= 627) : (index += 1) {
instance.array[index] = true;
}
index = 628;
while (index <= 641) : (index += 1) {
instance.array[index] = true;
}
index = 642;
while (index <= 646) : (index += 1) {
instance.array[index] = true;
}
index = 647;
while (index <= 653) : (index += 1) {
instance.array[index] = true;
}
instance.array[654] = true;
instance.array[655] = true;
instance.array[656] = true;
index = 657;
while (index <= 673) : (index += 1) {
instance.array[index] = true;
}
index = 674;
while (index <= 752) : (index += 1) {
instance.array[index] = true;
}
index = 754;
while (index <= 761) : (index += 1) {
instance.array[index] = true;
}
index = 767;
while (index <= 772) : (index += 1) {
instance.array[index] = true;
}
instance.array[790] = true;
instance.array[791] = true;
instance.array[796] = true;
index = 806;
while (index <= 807) : (index += 1) {
instance.array[index] = true;
}
index = 1061;
while (index <= 1065) : (index += 1) {
instance.array[index] = true;
}
instance.array[1275] = true;
index = 1331;
while (index <= 1347) : (index += 1) {
instance.array[index] = true;
}
index = 1349;
while (index <= 1375) : (index += 1) {
instance.array[index] = true;
}
instance.array[1377] = true;
index = 1379;
while (index <= 1380) : (index += 1) {
instance.array[index] = true;
}
instance.array[1382] = true;
index = 1517;
while (index <= 1524) : (index += 1) {
instance.array[index] = true;
}
index = 1529;
while (index <= 1530) : (index += 1) {
instance.array[index] = true;
}
index = 1665;
while (index <= 1666) : (index += 1) {
instance.array[index] = true;
}
index = 1671;
while (index <= 1672) : (index += 1) {
instance.array[index] = true;
}
index = 1676;
while (index <= 1678) : (index += 1) {
instance.array[index] = true;
}
index = 1746;
while (index <= 1772) : (index += 1) {
instance.array[index] = true;
}
index = 1864;
while (index <= 1874) : (index += 1) {
instance.array[index] = true;
}
index = 1933;
while (index <= 1941) : (index += 1) {
instance.array[index] = true;
}
index = 1942;
while (index <= 1943) : (index += 1) {
instance.array[index] = true;
}
index = 1978;
while (index <= 1979) : (index += 1) {
instance.array[index] = true;
}
index = 2181;
while (index <= 2208) : (index += 1) {
instance.array[index] = true;
}
instance.array[2270] = true;
instance.array[2287] = true;
index = 2291;
while (index <= 2294) : (index += 1) {
instance.array[index] = true;
}
instance.array[2323] = true;
instance.array[2398] = true;
instance.array[2415] = true;
instance.array[2526] = true;
instance.array[2543] = true;
instance.array[2654] = true;
instance.array[2671] = true;
index = 2719;
while (index <= 2721) : (index += 1) {
instance.array[index] = true;
}
instance.array[2782] = true;
instance.array[2799] = true;
instance.array[2807] = true;
instance.array[2927] = true;
instance.array[3055] = true;
instance.array[3166] = true;
instance.array[3183] = true;
index = 3293;
while (index <= 3294) : (index += 1) {
instance.array[index] = true;
}
instance.array[3311] = true;
instance.array[3436] = true;
index = 3561;
while (index <= 3566) : (index += 1) {
instance.array[index] = true;
}
instance.array[3568] = true;
instance.array[3676] = true;
index = 3690;
while (index <= 3694) : (index += 1) {
instance.array[index] = true;
}
index = 3770;
while (index <= 3771) : (index += 1) {
instance.array[index] = true;
}
instance.array[3799] = true;
instance.array[3801] = true;
instance.array[3803] = true;
index = 3808;
while (index <= 3809) : (index += 1) {
instance.array[index] = true;
}
index = 3876;
while (index <= 3878) : (index += 1) {
instance.array[index] = true;
}
index = 3880;
while (index <= 3881) : (index += 1) {
instance.array[index] = true;
}
instance.array[3944] = true;
instance.array[4057] = true;
index = 4059;
while (index <= 4060) : (index += 1) {
instance.array[index] = true;
}
index = 4101;
while (index <= 4102) : (index += 1) {
instance.array[index] = true;
}
index = 4107;
while (index <= 4111) : (index += 1) {
instance.array[index] = true;
}
index = 4137;
while (index <= 4142) : (index += 1) {
instance.array[index] = true;
}
instance.array[4143] = true;
instance.array[4145] = true;
index = 4156;
while (index <= 4157) : (index += 1) {
instance.array[index] = true;
}
index = 4863;
while (index <= 4865) : (index += 1) {
instance.array[index] = true;
}
index = 5995;
while (index <= 6005) : (index += 1) {
instance.array[index] = true;
}
instance.array[6015] = true;
index = 6363;
while (index <= 6365) : (index += 1) {
instance.array[index] = true;
}
index = 6679;
while (index <= 6686) : (index += 1) {
instance.array[index] = true;
}
instance.array[6689] = true;
index = 6738;
while (index <= 6751) : (index += 1) {
instance.array[index] = true;
}
instance.array[6870] = true;
instance.array[6886] = true;
index = 6925;
while (index <= 6933) : (index += 1) {
instance.array[index] = true;
}
instance.array[6988] = true;
instance.array[6989] = true;
index = 7128;
while (index <= 7129) : (index += 1) {
instance.array[index] = true;
}
index = 7194;
while (index <= 7199) : (index += 1) {
instance.array[index] = true;
}
index = 7282;
while (index <= 7284) : (index += 1) {
instance.array[index] = true;
}
instance.array[7285] = true;
index = 7286;
while (index <= 7298) : (index += 1) {
instance.array[index] = true;
}
instance.array[7299] = true;
index = 7300;
while (index <= 7306) : (index += 1) {
instance.array[index] = true;
}
instance.array[7311] = true;
instance.array[7318] = true;
instance.array[7321] = true;
index = 7322;
while (index <= 7323) : (index += 1) {
instance.array[index] = true;
}
index = 7374;
while (index <= 7436) : (index += 1) {
instance.array[index] = true;
}
index = 7526;
while (index <= 7537) : (index += 1) {
instance.array[index] = true;
}
index = 7575;
while (index <= 7579) : (index += 1) {
instance.array[index] = true;
}
index = 7583;
while (index <= 7585) : (index += 1) {
instance.array[index] = true;
}
instance.array[8031] = true;
index = 8033;
while (index <= 8035) : (index += 1) {
instance.array[index] = true;
}
index = 8047;
while (index <= 8049) : (index += 1) {
instance.array[index] = true;
}
index = 8063;
while (index <= 8065) : (index += 1) {
instance.array[index] = true;
}
index = 8079;
while (index <= 8081) : (index += 1) {
instance.array[index] = true;
}
index = 8095;
while (index <= 8096) : (index += 1) {
instance.array[index] = true;
}
index = 11409;
while (index <= 11411) : (index += 1) {
instance.array[index] = true;
}
instance.array[11729] = true;
index = 12236;
while (index <= 12239) : (index += 1) {
instance.array[index] = true;
}
index = 12240;
while (index <= 12241) : (index += 1) {
instance.array[index] = true;
}
index = 12347;
while (index <= 12348) : (index += 1) {
instance.array[index] = true;
}
index = 12349;
while (index <= 12350) : (index += 1) {
instance.array[index] = true;
}
instance.array[12446] = true;
instance.array[42513] = true;
index = 42526;
while (index <= 42527) : (index += 1) {
instance.array[index] = true;
}
instance.array[42529] = true;
index = 42558;
while (index <= 42559) : (index += 1) {
instance.array[index] = true;
}
index = 42642;
while (index <= 42643) : (index += 1) {
instance.array[index] = true;
}
index = 42658;
while (index <= 42680) : (index += 1) {
instance.array[index] = true;
}
index = 42681;
while (index <= 42689) : (index += 1) {
instance.array[index] = true;
}
index = 42690;
while (index <= 42691) : (index += 1) {
instance.array[index] = true;
}
instance.array[42794] = true;
index = 42795;
while (index <= 42796) : (index += 1) {
instance.array[index] = true;
}
index = 42906;
while (index <= 42907) : (index += 1) {
instance.array[index] = true;
}
instance.array[43110] = true;
index = 43138;
while (index <= 43155) : (index += 1) {
instance.array[index] = true;
}
index = 43213;
while (index <= 43215) : (index += 1) {
instance.array[index] = true;
}
instance.array[43216] = true;
instance.array[43253] = true;
instance.array[43349] = true;
instance.array[43362] = true;
instance.array[43399] = true;
instance.array[43549] = true;
instance.array[43550] = true;
instance.array[43551] = true;
instance.array[43617] = true;
instance.array[43618] = true;
instance.array[43619] = true;
instance.array[43620] = true;
instance.array[43672] = true;
instance.array[43773] = true;
index = 43774;
while (index <= 43777) : (index += 1) {
instance.array[index] = true;
}
instance.array[43787] = true;
index = 43788;
while (index <= 43789) : (index += 1) {
instance.array[index] = true;
}
instance.array[43918] = true;
instance.array[43919] = true;
instance.array[64192] = true;
index = 64962;
while (index <= 64977) : (index += 1) {
instance.array[index] = true;
}
instance.array[65248] = true;
instance.array[65250] = true;
instance.array[65298] = true;
index = 65344;
while (index <= 65345) : (index += 1) {
instance.array[index] = true;
}
instance.array[65413] = true;
instance.array[66178] = true;
index = 68231;
while (index <= 68232) : (index += 1) {
instance.array[index] = true;
}
index = 68804;
while (index <= 68805) : (index += 1) {
instance.array[index] = true;
}
index = 68806;
while (index <= 68809) : (index += 1) {
instance.array[index] = true;
}
index = 69352;
while (index <= 69362) : (index += 1) {
instance.array[index] = true;
}
index = 69723;
while (index <= 69724) : (index += 1) {
instance.array[index] = true;
}
index = 69845;
while (index <= 69846) : (index += 1) {
instance.array[index] = true;
}
instance.array[69909] = true;
instance.array[69986] = true;
index = 69996;
while (index <= 69998) : (index += 1) {
instance.array[index] = true;
}
instance.array[70103] = true;
instance.array[70104] = true;
index = 70283;
while (index <= 70284) : (index += 1) {
instance.array[index] = true;
}
instance.array[70366] = true;
instance.array[70383] = true;
index = 70408;
while (index <= 70414) : (index += 1) {
instance.array[index] = true;
}
index = 70418;
while (index <= 70422) : (index += 1) {
instance.array[index] = true;
}
instance.array[70628] = true;
instance.array[70632] = true;
index = 70756;
while (index <= 70757) : (index += 1) {
instance.array[index] = true;
}
index = 71009;
while (index <= 71010) : (index += 1) {
instance.array[index] = true;
}
instance.array[71137] = true;
instance.array[71256] = true;
instance.array[71257] = true;
instance.array[71373] = true;
index = 71643;
while (index <= 71644) : (index += 1) {
instance.array[index] = true;
}
instance.array[71903] = true;
instance.array[71904] = true;
instance.array[71909] = true;
instance.array[72066] = true;
instance.array[72150] = true;
instance.array[72169] = true;
instance.array[72251] = true;
instance.array[72673] = true;
instance.array[72932] = true;
index = 72934;
while (index <= 72935) : (index += 1) {
instance.array[index] = true;
}
instance.array[73017] = true;
index = 92818;
while (index <= 92822) : (index += 1) {
instance.array[index] = true;
}
index = 92882;
while (index <= 92888) : (index += 1) {
instance.array[index] = true;
}
index = 94001;
while (index <= 94004) : (index += 1) {
instance.array[index] = true;
}
index = 94005;
while (index <= 94017) : (index += 1) {
instance.array[index] = true;
}
index = 94098;
while (index <= 94099) : (index += 1) {
instance.array[index] = true;
}
index = 119049;
while (index <= 119051) : (index += 1) {
instance.array[index] = true;
}
index = 119055;
while (index <= 119060) : (index += 1) {
instance.array[index] = true;
}
index = 119069;
while (index <= 119076) : (index += 1) {
instance.array[index] = true;
}
index = 119079;
while (index <= 119085) : (index += 1) {
instance.array[index] = true;
}
index = 119116;
while (index <= 119119) : (index += 1) {
instance.array[index] = true;
}
index = 123090;
while (index <= 123096) : (index += 1) {
instance.array[index] = true;
}
index = 123534;
while (index <= 123537) : (index += 1) {
instance.array[index] = true;
}
index = 125042;
while (index <= 125048) : (index += 1) {
instance.array[index] = true;
}
index = 125158;
while (index <= 125160) : (index += 1) {
instance.array[index] = true;
}
index = 125162;
while (index <= 125164) : (index += 1) {
instance.array[index] = true;
}
// Placeholder: 0. Struct name, 1. Code point kind
return instance;
}
pub fn deinit(self: *Diacritic) void {
self.allocator.free(self.array);
}
// isDiacritic checks if cp is of the kind Diacritic.
pub fn isDiacritic(self: Diacritic, cp: u21) bool {
if (cp < self.lo or cp > self.hi) return false;
const index = cp - self.lo;
return if (index >= self.array.len) false else self.array[index];
} | src/components/autogen/PropList/Diacritic.zig |
pub const MAX_MODULE_NAME32 = @as(u32, 255);
pub const HF32_DEFAULT = @as(u32, 1);
pub const HF32_SHARED = @as(u32, 2);
//--------------------------------------------------------------------------------
// Section: Types (9)
//--------------------------------------------------------------------------------
pub const CREATE_TOOLHELP_SNAPSHOT_FLAGS = enum(u32) {
INHERIT = 2147483648,
SNAPALL = 15,
SNAPHEAPLIST = 1,
SNAPMODULE = 8,
SNAPMODULE32 = 16,
SNAPPROCESS = 2,
SNAPTHREAD = 4,
_,
pub fn initFlags(o: struct {
INHERIT: u1 = 0,
SNAPALL: u1 = 0,
SNAPHEAPLIST: u1 = 0,
SNAPMODULE: u1 = 0,
SNAPMODULE32: u1 = 0,
SNAPPROCESS: u1 = 0,
SNAPTHREAD: u1 = 0,
}) CREATE_TOOLHELP_SNAPSHOT_FLAGS {
return @intToEnum(CREATE_TOOLHELP_SNAPSHOT_FLAGS,
(if (o.INHERIT == 1) @enumToInt(CREATE_TOOLHELP_SNAPSHOT_FLAGS.INHERIT) else 0)
| (if (o.SNAPALL == 1) @enumToInt(CREATE_TOOLHELP_SNAPSHOT_FLAGS.SNAPALL) else 0)
| (if (o.SNAPHEAPLIST == 1) @enumToInt(CREATE_TOOLHELP_SNAPSHOT_FLAGS.SNAPHEAPLIST) else 0)
| (if (o.SNAPMODULE == 1) @enumToInt(CREATE_TOOLHELP_SNAPSHOT_FLAGS.SNAPMODULE) else 0)
| (if (o.SNAPMODULE32 == 1) @enumToInt(CREATE_TOOLHELP_SNAPSHOT_FLAGS.SNAPMODULE32) else 0)
| (if (o.SNAPPROCESS == 1) @enumToInt(CREATE_TOOLHELP_SNAPSHOT_FLAGS.SNAPPROCESS) else 0)
| (if (o.SNAPTHREAD == 1) @enumToInt(CREATE_TOOLHELP_SNAPSHOT_FLAGS.SNAPTHREAD) else 0)
);
}
};
pub const TH32CS_INHERIT = CREATE_TOOLHELP_SNAPSHOT_FLAGS.INHERIT;
pub const TH32CS_SNAPALL = CREATE_TOOLHELP_SNAPSHOT_FLAGS.SNAPALL;
pub const TH32CS_SNAPHEAPLIST = CREATE_TOOLHELP_SNAPSHOT_FLAGS.SNAPHEAPLIST;
pub const TH32CS_SNAPMODULE = CREATE_TOOLHELP_SNAPSHOT_FLAGS.SNAPMODULE;
pub const TH32CS_SNAPMODULE32 = CREATE_TOOLHELP_SNAPSHOT_FLAGS.SNAPMODULE32;
pub const TH32CS_SNAPPROCESS = CREATE_TOOLHELP_SNAPSHOT_FLAGS.SNAPPROCESS;
pub const TH32CS_SNAPTHREAD = CREATE_TOOLHELP_SNAPSHOT_FLAGS.SNAPTHREAD;
pub const HEAPENTRY32_FLAGS = enum(u32) {
FIXED = 1,
FREE = 2,
MOVEABLE = 4,
};
pub const LF32_FIXED = HEAPENTRY32_FLAGS.FIXED;
pub const LF32_FREE = HEAPENTRY32_FLAGS.FREE;
pub const LF32_MOVEABLE = HEAPENTRY32_FLAGS.MOVEABLE;
pub const HEAPLIST32 = extern struct {
dwSize: usize,
th32ProcessID: u32,
th32HeapID: usize,
dwFlags: u32,
};
pub const HEAPENTRY32 = extern struct {
dwSize: usize,
hHandle: ?HANDLE,
dwAddress: usize,
dwBlockSize: usize,
dwFlags: HEAPENTRY32_FLAGS,
dwLockCount: u32,
dwResvd: u32,
th32ProcessID: u32,
th32HeapID: usize,
};
pub const PROCESSENTRY32W = extern struct {
dwSize: u32,
cntUsage: u32,
th32ProcessID: u32,
th32DefaultHeapID: usize,
th32ModuleID: u32,
cntThreads: u32,
th32ParentProcessID: u32,
pcPriClassBase: i32,
dwFlags: u32,
szExeFile: [260]u16,
};
pub const PROCESSENTRY32 = extern struct {
dwSize: u32,
cntUsage: u32,
th32ProcessID: u32,
th32DefaultHeapID: usize,
th32ModuleID: u32,
cntThreads: u32,
th32ParentProcessID: u32,
pcPriClassBase: i32,
dwFlags: u32,
szExeFile: [260]CHAR,
};
pub const THREADENTRY32 = extern struct {
dwSize: u32,
cntUsage: u32,
th32ThreadID: u32,
th32OwnerProcessID: u32,
tpBasePri: i32,
tpDeltaPri: i32,
dwFlags: u32,
};
pub const MODULEENTRY32W = extern struct {
dwSize: u32,
th32ModuleID: u32,
th32ProcessID: u32,
GlblcntUsage: u32,
ProccntUsage: u32,
modBaseAddr: ?*u8,
modBaseSize: u32,
hModule: ?HINSTANCE,
szModule: [256]u16,
szExePath: [260]u16,
};
pub const MODULEENTRY32 = extern struct {
dwSize: u32,
th32ModuleID: u32,
th32ProcessID: u32,
GlblcntUsage: u32,
ProccntUsage: u32,
modBaseAddr: ?*u8,
modBaseSize: u32,
hModule: ?HINSTANCE,
szModule: [256]CHAR,
szExePath: [260]CHAR,
};
//--------------------------------------------------------------------------------
// Section: Functions (16)
//--------------------------------------------------------------------------------
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "KERNEL32" fn CreateToolhelp32Snapshot(
dwFlags: CREATE_TOOLHELP_SNAPSHOT_FLAGS,
th32ProcessID: u32,
) callconv(@import("std").os.windows.WINAPI) ?HANDLE;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "KERNEL32" fn Heap32ListFirst(
hSnapshot: ?HANDLE,
lphl: ?*HEAPLIST32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "KERNEL32" fn Heap32ListNext(
hSnapshot: ?HANDLE,
lphl: ?*HEAPLIST32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "KERNEL32" fn Heap32First(
lphe: ?*HEAPENTRY32,
th32ProcessID: u32,
th32HeapID: usize,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "KERNEL32" fn Heap32Next(
lphe: ?*HEAPENTRY32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "KERNEL32" fn Toolhelp32ReadProcessMemory(
th32ProcessID: u32,
lpBaseAddress: ?*const anyopaque,
lpBuffer: ?*anyopaque,
cbRead: usize,
lpNumberOfBytesRead: ?*usize,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "KERNEL32" fn Process32FirstW(
hSnapshot: ?HANDLE,
lppe: ?*PROCESSENTRY32W,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "KERNEL32" fn Process32NextW(
hSnapshot: ?HANDLE,
lppe: ?*PROCESSENTRY32W,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "KERNEL32" fn Process32First(
hSnapshot: ?HANDLE,
lppe: ?*PROCESSENTRY32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "KERNEL32" fn Process32Next(
hSnapshot: ?HANDLE,
lppe: ?*PROCESSENTRY32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "KERNEL32" fn Thread32First(
hSnapshot: ?HANDLE,
lpte: ?*THREADENTRY32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "KERNEL32" fn Thread32Next(
hSnapshot: ?HANDLE,
lpte: ?*THREADENTRY32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "KERNEL32" fn Module32FirstW(
hSnapshot: ?HANDLE,
lpme: ?*MODULEENTRY32W,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "KERNEL32" fn Module32NextW(
hSnapshot: ?HANDLE,
lpme: ?*MODULEENTRY32W,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "KERNEL32" fn Module32First(
hSnapshot: ?HANDLE,
lpme: ?*MODULEENTRY32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "KERNEL32" fn Module32Next(
hSnapshot: ?HANDLE,
lpme: ?*MODULEENTRY32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
//--------------------------------------------------------------------------------
// Section: Unicode Aliases (0)
//--------------------------------------------------------------------------------
const thismodule = @This();
pub usingnamespace switch (@import("../../zig.zig").unicode_mode) {
.ansi => struct {
},
.wide => struct {
},
.unspecified => if (@import("builtin").is_test) struct {
} else struct {
},
};
//--------------------------------------------------------------------------------
// Section: Imports (4)
//--------------------------------------------------------------------------------
const BOOL = @import("../../foundation.zig").BOOL;
const CHAR = @import("../../foundation.zig").CHAR;
const HANDLE = @import("../../foundation.zig").HANDLE;
const HINSTANCE = @import("../../foundation.zig").HINSTANCE;
test {
@setEvalBranchQuota(
@import("std").meta.declarations(@This()).len * 3
);
// reference all the pub declarations
if (!@import("builtin").is_test) return;
inline for (@import("std").meta.declarations(@This())) |decl| {
if (decl.is_pub) {
_ = decl;
}
}
} | win32/system/diagnostics/tool_help.zig |
const ImageReader = zigimg.ImageReader;
const ImageSeekStream = zigimg.ImageSeekStream;
const PixelFormat = zigimg.PixelFormat;
const assert = std.debug.assert;
const qoi = zigimg.qoi;
const color = zigimg.color;
const errors = zigimg.errors;
const std = @import("std");
const testing = std.testing;
const zigimg = @import("zigimg");
const image = zigimg.image;
const helpers = @import("../helpers.zig");
const zero_raw_pixels = @embedFile("../fixtures/qoi/zero.raw");
const zero_qoi = @embedFile("../fixtures/qoi/zero.qoi");
test "Should error on non QOI images" {
const file = try helpers.testOpenFile(helpers.zigimg_test_allocator, "tests/fixtures/bmp/simple_v4.bmp");
defer file.close();
var stream_source = std.io.StreamSource{ .file = file };
var qoi_file = qoi.QOI{};
var pixels_opt: ?color.ColorStorage = null;
const invalid_file = qoi_file.read(helpers.zigimg_test_allocator, stream_source.reader(), stream_source.seekableStream(), &pixels_opt);
defer {
if (pixels_opt) |pixels| {
pixels.deinit(helpers.zigimg_test_allocator);
}
}
try helpers.expectError(invalid_file, errors.ImageError.InvalidMagicHeader);
}
test "Read zero.qoi file" {
const file = try helpers.testOpenFile(helpers.zigimg_test_allocator, "tests/fixtures/qoi/zero.qoi");
defer file.close();
var stream_source = std.io.StreamSource{ .file = file };
var qoi_file = qoi.QOI{};
var pixels_opt: ?color.ColorStorage = null;
try qoi_file.read(helpers.zigimg_test_allocator, stream_source.reader(), stream_source.seekableStream(), &pixels_opt);
defer {
if (pixels_opt) |pixels| {
pixels.deinit(helpers.zigimg_test_allocator);
}
}
try helpers.expectEq(qoi_file.width(), 512);
try helpers.expectEq(qoi_file.height(), 512);
try helpers.expectEq(try qoi_file.pixelFormat(), .Rgba32);
try testing.expect(qoi_file.header.colorspace == .sRGB);
try testing.expect(pixels_opt != null);
if (pixels_opt) |pixels| {
try testing.expect(pixels == .Rgba32);
try testing.expectEqualSlices(u8, zero_raw_pixels, std.mem.sliceAsBytes(pixels.Rgba32));
}
}
test "Write qoi file" {
const source_image = try image.Image.create(helpers.zigimg_test_allocator, 512, 512, PixelFormat.Rgba32, .Qoi);
defer source_image.deinit();
std.mem.copy(u8, std.mem.sliceAsBytes(source_image.pixels.?.Rgba32), std.mem.bytesAsSlice(u8, zero_raw_pixels));
var image_buffer: [std.mem.len(zero_qoi)]u8 = undefined;
const result_image = try source_image.writeToMemory(image_buffer[0..], .Qoi, image.ImageEncoderOptions.None);
try testing.expectEqualSlices(u8, zero_qoi[0..], result_image);
} | tests/formats/qoi_test.zig |
const std = @import("std");
pub const ir_visited_t = u64;
pub const ir_label_t = u64;
pub const dbg_info = opaque {};
pub const type_dbg_info = opaque {};
pub const ir_node = opaque {};
pub const ir_op = opaque {};
pub const ir_mode = opaque {};
pub const ir_edge_t = opaque {};
pub const ir_heights_t = opaque {};
pub const ir_tarval = opaque {};
pub const ir_type = opaque {};
pub const ir_graph = opaque {};
pub const ir_prog = opaque {};
pub const ir_loop = opaque {};
pub const ir_entity = opaque {};
pub const ir_cdep = opaque {};
pub const ir_initializer_t = opaque {};
pub const ir_machine_triple_t = opaque {};
pub const ir_switch_table = opaque {};
pub const ir_relation = enum(u32) {
False,
equal,
less,
less_equal,
greater,
greater_equal,
less_greater,
less_equal_greater,
unordered,
unordered_equal,
unordered_less,
unordered_less_equal,
unordered_greater,
unordered_greater_equal,
unordered_less_greater,
True,
};
pub const ir_cons_flags = enum(u32) { cons_none = 0, cons_volatile = 1, cons_unaligned = 2, cons_floats = 4, cons_throws_exceptions = 8 };
pub const op_pin_state = enum(u32) {
floats,
pinned,
exc_pinned,
};
pub const cond_jmp_predicate = enum(u32) {
none,
True,
False,
};
pub const mtp_additional_properties = enum(u32) {
no_property = 0,
pure = 1,
no_write = 2,
no_return = 4,
terminates = 8,
no_throw = 16,
naked = 32,
malloc = 64,
returns_twice = 128,
private = 256,
always_inline = 512,
no_inline = 1024,
inline_recommended = 2048,
temporary = 4096,
is_constructor = 8192,
};
pub const ir_asm_constraint = extern struct {
in_pos: i32,
out_pos: i32,
constraint: [*]const u8,
mode: ?*ir_mode,
};
pub const ir_builtin_kind = enum(u32) {
trap,
debug_break,
return_address,
frame_address,
prefetch,
ffs,
clz,
ctz,
popcount,
parity,
bswap,
inport,
outport,
saturating_increment,
compare_swap,
may_alias,
va_start,
va_arg,
};
pub const ir_volatility = enum(u32) {
non_volatile,
is_volatile,
};
pub const ir_align = enum(u32) {
is_aligned,
non_aligned,
};
pub const float_int_conversion_overflow_style_t = enum(u32) {
indefinite,
min_max,
};
pub const hook_entry_t = opaque {};
pub const ir_visibility = enum(u32) { external, external_private, external_protected, local, private };
pub const ir_linkage = enum(u32) {
default,
constant,
weak,
garbage_collect,
merge,
hidden_user,
no_codegen,
no_identity,
};
pub const ir_entity_usage = enum(u32) {
none = 0,
address_taken = 1,
write = 2,
read = 4,
reinterpret_cast = 8,
unknown = 15,
};
pub const ir_initializer_kind_t = enum(u32) { CONST, TARVAL, NULL, COMPOUND };
pub const ptr_access_kind = enum(u32) { none = 0, read = 1, write = 2, rw = 3, store = 4, all = 7 };
pub const tp_opcode = enum(u32) { uninitalized, Struct, Union, class, segment, method, array, pointer, primitive, code, unknown };
pub const inh_transitive_closure_state = enum(u32) { none, valid, invalid, max };
pub const ir_type_state = enum(u32) { Undefined, fixed };
pub const calling_convention_enum = enum(u32) {
reg_param = 0x01000000,
last_on_top = 0x02000000,
callee_clear_stk = 0x04000000,
this_call = 0x08000000,
compound_ret = 0x10000000,
frame_on_caller_stk = 0x20000000,
fpreg_param = 0x40000000,
pub const calling_helpers = enum(u32) {
decl_set = 0,
stdcall_set = @enumToInt(calling_convention_enum.callee_clear_stk),
fastcall_set = @enumToInt(calling_convention_enum.callee_clear_stk) | @enumToInt(calling_convention_enum.reg_param),
};
pub const cc_bits: u32 = (0xFF << 24);
pub fn isCallType(mask: u32, calling_help: calling_helpers) bool {
switch (calling_help) {
.decl_set => return (mask & cc_bits) == @enumToInt(calling_helpers.decl_set),
.stdcall_set => return (mask & cc_bits) == @enumToInt(calling_helpers.stdcall_set),
.fastcall_set => return (mask & cc_bits) == @enumToInt(calling_helpers.fastcall_set),
else => unreachable,
}
}
pub fn setCdecl(mask: u32, calling_help: calling_helpers) u32 {
return (((mask & ~cc_bits)) | @enumToInt(calling_help));
}
};
const convention = enum {
calling_convention,
calling_convention_special,
value,
};
pub const calling_convention = union(convention) { calling_convention: calling_convention_enum, calling_convention_special: calling_convention_enum.calling_helpers, value: u32 };
pub const ir_mode_arithmetic = enum(u32) {
none = 1,
twos_complement = 2,
ieee754 = 256,
x86_extended_float = 257,
};
pub const asm_constraint_flags_t = enum(u32) {
none = 0,
supports_register = 1,
supports_memop = 2,
Immediate = 4,
supports_any = 7,
no_support = 8,
modifier_write = 16,
modifier_read = 32,
modifier_early_clobber = 64,
modifier_commutative = 128,
invalid = 256,
};
pub const osr_flags = enum(u32) { none, lftr_with_ov_check, ignore_x86_shift, keep_reg_pressure = 4 };
pub const dwarf_source_language = enum(u32) { C89 = 1, C = 2, Ada83 = 3, C_plus_plus = 4, Cobol74 = 5, Cobol85 = 6, Fortran77 = 7, Fortran90 = 8, Pascal83 = 9, Modula2 = 10, Java = 11, C99 = 12, Ada95 = 13, Fortan95 = 14, PLI = 15, ObjC = 16, ObjC_plus_plus = 17, UPC = 18, D = 19, Python = 20, Go = 22 };
pub const dbg_action = enum(u32) {
err,
opt_ssa,
opt_auxnode,
const_eval,
opt_cse,
straightening,
if_simplifcation,
algebraic_simplification,
write_after_write,
write_after_read,
read_after_write,
read_after_read,
read_a_constant,
dead_code,
opt_confirm,
gvn_pre,
combo,
jumpthreading,
backend,
max,
};
pub const src_loc_t = extern struct {
file: [*]const u8,
line: i32,
column: i32,
};
pub const firm_kind = enum(u32) {
bad,
entity,
firm_type,
ir_graph,
ir_mode,
ir_tarval,
ir_loop,
ir_max,
};
pub const irp_callgraph_state = enum(u32) { none, consistent, inconsistent, and_calltree_consistent };
pub const loop_nesting_depth_state = enum(u32) { none, consistent, inconsistent };
pub const range_types = enum(u32) {
Undefined,
range,
antirange,
varying,
};
pub const op_arity = enum(u32) {
invalid,
binary,
dynamic,
any,
};
pub const irop_flags = enum(u32) {
none = 0,
commutative = 1,
cfopcode = 2,
fragile = 4,
forking = 8,
constlike = 32,
keep = 64,
start_block = 128,
uses_memory = 256,
dump_noblock = 512,
unknown_jump = 2048,
const_memory = 4096,
};
pub const dumb_node = enum(u32) {
opcode_txt,
mode_txt,
nodeattr_txt,
info_txt,
};
pub const ir_opcode = enum(u32) {
Asm,
Add,
Address,
Align,
Alloc,
Anchor,
And,
Bad,
Bitcast,
Block,
Builtin,
Call,
Cmp,
Cond,
Confirm,
Const,
Conv,
CopyB,
Deleted,
Div,
Dummy,
End,
Eor,
Free,
IJmp,
Id,
Jmp,
Load,
Member,
Minus,
Mod,
Mul,
Mulh,
Mux,
NoMem,
Not,
Offset,
Or,
Phi,
Pin,
Proj,
Raise,
Return,
Sel,
Shl,
Shr,
Shrs,
Size,
Start,
Store,
Sub,
Switch,
Sync,
Tuple,
Unknown,
};
pub const ir_verbosity = enum(u32) {
onlynames = 1,
fields = 2,
methods = 4,
nostatic = 64,
typeattrs = 8,
entattrs = 16,
entconsts = 32,
accessStats = 256,
max = 1341132734,
};
pub const input_number_ASM = enum(u32) {
mem,
};
pub const projection_input_ASM = enum(u32) {
M,
regular,
first_out,
};
pub const input_number_Add = enum(u32) {
left,
right,
};
pub const projection_input_Alloc = enum(u32) {
M,
res,
};
pub const input_number_Anchor = enum(u32) {
end_block,
start_block,
end,
start,
frame,
initial_mem,
args,
no_mem,
};
pub const projection_input_Bitcast = enum(u32) {
op,
};
pub const input_number_Builtin = enum(u32) {
mem,
};
pub const projection_input_Builtin = enum(u32) {
M,
};
pub const input_number_Call = enum(u32) {
mem,
ptr,
};
pub const projection_input_Call = enum(u32) {
M,
T_result,
X_regular,
X_except,
};
pub const inptu_number_Cmp = enum(u32) {
left,
right,
};
pub const input_number_Cond = enum(u32) {
selector,
};
pub const projection_input_Cond = enum(u32) {
False,
True,
};
pub const input_number_Confirm = enum(u32) {
value,
bound,
};
pub const input_number_Conv = enum(u32) {
op,
};
pub const input_number_CopyB = enum(u32) {
mem,
dst,
src,
};
pub const input_number_Div = enum(u32) {
mem,
left,
right,
};
pub const projection_input_Div = enum(u32) {
M,
res,
X_regular,
X_except,
};
pub const input_number_Eor = enum(u32) {
left,
right,
};
pub const input_number_Free = enum(u32) {
mem,
ptr,
};
pub const input_number_IJmp = enum(u32) {
target,
};
pub const input_number_Id = enum(u32) {
pred,
};
pub const input_number_Load = enum(u32) {
mem,
ptr,
};
pub const projection_input_Load = enum(u32) {
M,
res,
X_regular,
X_except,
};
pub const input_number_Member = enum(u32) {
ptr,
};
pub const input_number_Minus = enum(u32) {
op,
};
pub const input_number_Mod = enum(u32) {
mem,
left,
right,
};
pub const projection_input_Mod = enum(u32) {
M,
res,
X_regular,
X_except,
};
pub const input_number_Mul = enum(u32) {
left,
right,
};
pub const input_number_Mulh = enum(u32) {
left,
right,
};
pub const input_number_Mux = enum(u32) {
sel,
False,
True,
};
pub const input_number_Not = enum(u32) {
op,
};
pub const input_number_Or = enum(u32) {
left,
right,
};
pub const input_number_Pin = enum(u32) {
op,
};
pub const input_number_Proj = enum(u32) {
pred,
};
pub const input_number_Raise = enum(u32) {
mem,
exo_ptr,
};
pub const projection_input_Raise = enum(u32) {
M,
X,
};
pub const input_number_Return = enum(u32) {
mem,
};
pub const input_number_Sel = enum(u32) {
ptr,
index,
};
pub const input_number_Shl = enum(u32) {
left,
right,
};
pub const input_number_Shr = enum(u32) {
left,
right,
};
pub const input_number_Shrs = enum(u32) {
left,
right,
};
pub const projection_input_Start = enum(u32) {
M,
P_frame_base,
T_args,
};
pub const input_number_Store = enum(u32) {
mem,
ptr,
value,
};
pub const projection_input_Store = enum(u32) {
M,
X_regular,
X_except,
};
pub const input_number_Sub = enum(u32) {
left,
right,
};
pub const input_number_Switch = enum(u32) {
selector,
};
pub const ir_dump_flags_t = enum(u32) {
blocks_as_subgraphs = 1,
with_typegraph = 2,
disable_edge_labels = 4,
consts_local = 8,
idx_label = 16,
number_label = 32,
keepalive_edges = 64,
out_edges = 128,
dominance = 256,
loops = 512,
back_edges = 1024,
iredges = 2048,
all_anchors = 4096,
show_marks = 8192,
no_entity_values = 16384,
ld_names = 32768,
entities_in_hierarchy = 65536,
};
pub const ir_edge_kind_t = enum(u32) {
Normal = 0,
Block = 1,
};
pub const ir_resources_t = enum(u32) {
none = 0,
block_visited = 1,
block_mark = 2,
irn_visited = 4,
irn_link = 8,
loop_link = 16,
phi_list = 32,
};
pub const ir_graph_constraints_t = enum(u32) {
ARCH_DEP = 1,
MODEB_LOWERED = 2,
NORMALISATION2 = 4,
OPTIMIZE_UNREACHABLE_CODE = 8,
CONSTRUCTION = 16,
TARGET_LOWERED = 32,
BACKEND = 64,
};
pub const ir_graph_properties_t = enum(u32) {
none = 0,
no_critical_edges = 1,
no_bads = 2,
no_tuples = 4,
no_unreachable_code = 8,
one_return = 16,
consistent_dominance = 32,
consistent_postdominance = 64,
consistent_dominance_frontiers = 128,
consistent_out_edges = 256,
consistent_outs = 512,
consistent_loopinfo = 1024,
consistent_entity_usage = 2048,
many_returns = 4096,
control_flow = 1273,
all = 8191,
};
pub const ir_alias_relation = enum(u32) { no_alias, may_alias, sure_alias };
pub const ir_entity_usage_computed_state = enum(u32) {
not_computed,
computed,
};
pub const ir_disambiguator_options = enum(u32) {
none = 0,
always_alias = 1,
type_based = 2,
byte_type_may_alias = 4,
no_alias = 8,
inherited = 16,
};
pub const ir_segment_t = enum(u32) {
global,
thread_local,
constructors,
destructors,
jrc,
};
pub const irp_resources_t = enum(u32) {
none = 0,
irg_link = 1,
entity_link = 2,
type_visited = 4,
link = 8,
};
pub const ikind = enum(u32) {
intrinsic_call,
intrinsic_instruction,
};
pub const ir_platform_type_t = enum(u32) {
bool,
char,
short,
int,
long,
long_long,
float,
double,
long_double,
};
pub const vrp_attr = extern struct {
bits_set: ?*ir_tarval,
bits_not_set: ?*ir_tarval,
range_type: range_types,
range_bottom: ?*ir_tarval,
range_top: ?*ir_tarval,
};
pub const i_call_record = extern struct {
kind: ikind,
i_ent: ?*ir_entity,
i_mapper: ?i_mapper_func,
};
pub const i_instr_record = extern struct {
kind: ikind,
op: ?*ir_op,
i_mapper: ?i_mapper_func,
};
pub const i_record = extern union {
kind: ikind,
i_call: i_call_record,
i_instr: i_instr_record,
};
pub const ir_dump_verbosity_t = enum(u32) {
dump_verbosity_onlynames = 0x00000001,
dump_verbosity_fields = 0x00000002,
dump_verbosity_methods = 0x00000004,
dump_verbosity_nostatic = 0x00000040,
dump_verbosity_typeattrs = 0x00000008,
dump_verbosity_entattrs = 0x00000010,
dump_verbosity_entconsts = 0x00000020,
dump_verbosity_accessStats = 0x00000100,
dump_verbosity_max = 0x4FF00FBE,
};
pub const dump_reason_t = enum(u32) { dump_node_opcode_txt, dump_node_mode_txt, dump_node_nodeattr_txt, dump_node_info_txt };
pub extern var mode_M: ?*ir_mode;
pub extern var mode_F: ?*ir_mode;
pub extern var mode_D: ?*ir_mode;
pub extern var mode_Bs: ?*ir_mode;
pub extern var mode_Bu: ?*ir_mode;
pub extern var mode_Hs: ?*ir_mode;
pub extern var mode_Hu: ?*ir_mode;
pub extern var mode_Is: ?*ir_mode;
pub extern var mode_Iu: ?*ir_mode;
pub extern var mode_Ls: ?*ir_mode;
pub extern var mode_Lu: ?*ir_mode;
pub extern var mode_P: ?*ir_mode;
pub extern var mode_b: ?*ir_mode;
pub extern var mode_X: ?*ir_mode;
pub extern var mode_BB: ?*ir_mode;
pub extern var mode_T: ?*ir_mode;
pub extern var mode_ANY: ?*ir_mode;
pub extern var mode_BAD: ?*ir_mode;
pub extern var op_ASM: ?*ir_op;
pub extern var op_Add: ?*ir_op;
pub extern var op_Address: ?*ir_op;
pub extern var op_Align: ?*ir_op;
pub extern var op_Alloc: ?*ir_op;
pub extern var op_Anchor: ?*ir_op;
pub extern var op_And: ?*ir_op;
pub extern var op_Bad: ?*ir_op;
pub extern var op_Bitcast: ?*ir_op;
pub extern var op_Block: ?*ir_op;
pub extern var op_Builtin: ?*ir_op;
pub extern var op_Call: ?*ir_op;
pub extern var op_Cmp: ?*ir_op;
pub extern var op_Cond: ?*ir_op;
pub extern var op_Confirm: ?*ir_op;
pub extern var op_Const: ?*ir_op;
pub extern var op_Conv: ?*ir_op;
pub extern var op_CopyB: ?*ir_op;
pub extern var op_Deleted: ?*ir_op;
pub extern var op_Div: ?*ir_op;
pub extern var op_Dummy: ?*ir_op;
pub extern var op_End: ?*ir_op;
pub extern var Lop_Eor: ?*ir_op;
pub extern var op_Free: ?*ir_op;
pub extern var op_IJmp: ?*ir_op;
pub extern var op_Id: ?*ir_op;
pub extern var op_Jmp: ?*ir_op;
pub extern var op_Load: ?*ir_op;
pub extern var op_Member: ?*ir_op;
pub extern var op_Minus: ?*ir_op;
pub extern var op_Mod: ?*ir_op;
pub extern var op_Mul: ?*ir_op;
pub extern var op_Mulh: ?*ir_op;
pub extern var op_Mux: ?*ir_op;
pub extern var op_NoMem: ?*ir_op;
pub extern var op_Not: ?*ir_op;
pub extern var op_Offset: ?*ir_op;
pub extern var op_Or: ?*ir_op;
pub extern var op_Phi: ?*ir_op;
pub extern var op_Pin: ?*ir_op;
pub extern var op_Proj: ?*ir_op;
pub extern var op_Raise: ?*ir_op;
pub extern var op_Return: ?*ir_op;
pub extern var op_Sel: ?*ir_op;
pub extern var op_Shl: ?*ir_op;
pub const obstack = opaque {};
pub extern var op_Shr: ?*ir_op;
pub extern var op_Shrs: ?*ir_op;
pub extern var op_Size: ?*ir_op;
pub extern var op_Start: ?*ir_op;
pub extern var op_Store: ?*ir_op;
pub extern var op_Sub: ?*ir_op;
pub extern var op_Switch: ?*ir_op;
pub extern var op_Sync: ?*ir_op;
pub extern var op_Tuple: ?*ir_op;
pub extern var op_Unknown: ?*ir_op;
pub extern var current_ir_graph: ?*ir_graph;
pub const IrMode = enum {
M,
Is,
Iu,
F,
D,
P,
Hs,
Hu,
Ls,
Lu,
Bs,
Bu,
T,
BB,
X,
ANY,
BAD,
};
pub fn getMode(mode: IrMode) ?*ir_mode {
switch (mode) {
.M => return mode_M,
.Is => return mode_Is,
.Iu => return mode_Iu,
.F => return mode_F,
.D => return mode_D,
.P => return mode_P,
.Hs => return mode_Hs,
.Hu => return mode_Hu,
.Ls => return mode_Ls,
.Lu => return mode_Lu,
.Bs => return mode_Bs,
.Bu => return mode_Bu,
.T => return mode_T,
.BB => return mode_BB,
.X => return mode_X,
.ANY => return mode_ANY,
.BAD => return mode_BAD,
}
}
pub const optimization_state_t = u32;
pub const irg_callee_info_none: i32 = 0;
pub const irg_callee_info_consistent: i32 = 1;
pub const irg_callee_info_inconsistent: i32 = 2;
pub const irg_callee_info_state = u32;
pub const loop_element = extern union {
kind: [*]firm_kind,
node: ?*ir_node,
son: ?*ir_loop,
irg: ?*ir_graph,
};
pub extern var irp: ?*ir_prog;
pub const ir_intrinsics_map = opaque {};
pub const ir_platform_define_t = opaque {};
pub const ir_timer_t = opaque {};
pub extern const tarval_bad: ?*ir_tarval;
pub extern const tarval_unknown: ?*ir_tarval;
pub const check_alloc_entity_func = ?fn (?*ir_entity) callconv(.C) i32;
pub extern var tarval_b_false: ?*ir_tarval;
pub extern var tarval_b_true: ?*ir_tarval;
pub const arch_allow_ifconv_func = ?fn (?*const ir_node, ?*const ir_node, ?*const ir_node) callconv(.C) i32;
pub const opt_ptr = ?fn (?*ir_graph) callconv(.C) void;
pub const after_transform_func = ?fn (?*ir_graph, [*]const u8) callconv(.C) void;
pub const retrieve_dbg_func = ?fn (?*const dbg_info) callconv(.C) src_loc_t;
pub const retrieve_type_dbg_func = ?fn ([*]u8, usize, ?*const type_dbg_info) callconv(.C) void;
pub const op_func = ?fn () callconv(.C) void;
pub const hash_func = ?fn (?*const ir_node) callconv(.C) u32;
pub const computed_value_func = ?fn (?*const ir_node) callconv(.C) ?*ir_tarval;
pub const equivalent_node_func = ?fn (?*ir_node) callconv(.C) ?*ir_node;
pub const transform_node_func = ?fn (?*ir_node) callconv(.C) ?*ir_node;
pub const node_attrs_equal_func = ?fn (?*const ir_node, ?*const ir_node) callconv(.C) i32;
pub const reassociate_func = ?fn ([*]?*ir_node) callconv(.C) i32;
pub const copy_attr_func = ?fn (?*ir_graph, ?*const ir_node, ?*ir_node) callconv(.C) void;
pub const get_type_attr_func = ?fn (?*const ir_node) callconv(.C) ?*ir_type;
pub const get_entity_attr_func = ?fn (?*const ir_node) callconv(.C) ?*ir_entity;
pub const verify_node_func = ?fn (?*const ir_node) callconv(.C) i32;
pub const verify_proj_node_func = ?fn (?*const ir_node) callconv(.C) i32;
pub const dump_node_func = ?fn (*std.c.FILE, ?*const ir_node, dump_reason_t) callconv(.C) void;
pub const ir_prog_dump_func = ?fn (*std.c.FILE) callconv(.C) void;
pub const ir_graph_dump_func = ?fn (*std.c.FILE, ?*ir_graph) callconv(.C) void;
pub const dump_node_vcgattr_func = ?fn (*std.c.FILE, ?*const ir_node, ?*const ir_node) callconv(.C) i32;
pub const dump_edge_vcgattr_func = ?fn (*std.c.FILE, ?*const ir_node, i32) callconv(.C) i32;
pub const dump_node_edge_func = ?fn (*std.c.FILE, ?*const ir_node) callconv(.C) void;
pub const irg_walk_func = fn (?*ir_node, ?*anyopaque) callconv(.C) void;
pub const uninitialized_local_variable_func_t = fn (?*ir_graph, ?*ir_mode, i32) callconv(.C) ?*ir_node;
pub const compare_types_func_t = fn (?*const anyopaque, ?*const anyopaque) callconv(.C) i32;
pub const type_walk_func = fn (?*ir_type, ?*ir_entity, ?*anyopaque) callconv(.C) void;
pub const class_walk_func = fn (?*ir_type, ?*anyopaque) callconv(.C) void;
pub const entity_walk_func = fn (?*ir_entity, ?*anyopaque) callconv(.C) void;
pub const callgraph_walk_func = fn (?*ir_graph, ?*anyopaque) callconv(.C) void;
pub const merge_pair_func = fn (?*ir_node, ?*ir_node, dbg_action) callconv(.C) void;
pub const merge_sets_func = fn ([*]const ?*ir_node, i32, [*]const ?*ir_node, i32, dbg_action) callconv(.C) void;
pub const dump_node_info_cb_t = fn (?*anyopaque, *std.c.FILE, ?*const ir_node) callconv(.C) void;
pub const lower_mux_callback = fn (?*ir_node) callconv(.C) i32;
pub const i_mapper_func = fn (?*ir_node) callconv(.C) i32;
pub const low_level = struct {
pub extern fn get_entity_visibility(entity: ?*const ir_entity) ir_visibility;
pub extern fn set_entity_visibility(entity: ?*ir_entity, visibility: ir_visibility) void;
pub extern fn entity_is_externally_visible(entity: ?*const ir_entity) i32;
pub extern fn entity_has_definition(entity: ?*const ir_entity) i32;
pub extern fn new_entity(owner: ?*ir_type, name: [*]const u8, tp: ?*ir_type) ?*ir_entity;
pub extern fn new_global_entity(segment: ?*ir_type, ld_name: [*]const u8, @"type": ?*ir_type, visibility: ir_visibility, linkage: ir_linkage) ?*ir_entity;
pub extern fn new_parameter_entity(owner: ?*ir_type, pos: usize, @"type": ?*ir_type) ?*ir_entity;
pub extern fn new_alias_entity(owner: ?*ir_type, name: [*]const u8, alias: ?*ir_entity, @"type": ?*ir_type, visibility: ir_visibility) ?*ir_entity;
pub extern fn set_entity_alias(alias: ?*ir_entity, aliased: ?*ir_entity) void;
pub extern fn get_entity_alias(alias: ?*const ir_entity) ?*ir_entity;
pub extern fn check_entity(ent: ?*const ir_entity) i32;
pub extern fn clone_entity(old: ?*const ir_entity, name: [*]const u8, owner: ?*ir_type) ?*ir_entity;
pub extern fn free_entity(ent: ?*ir_entity) void;
pub extern fn get_entity_name(ent: ?*const ir_entity) [*]const u8;
pub extern fn get_entity_ident(ent: ?*const ir_entity) [*]const u8;
pub extern fn set_entity_ident(ent: ?*ir_entity, id: [*]const u8) void;
pub extern fn get_entity_ld_ident(ent: ?*const ir_entity) [*]const u8;
pub extern fn set_entity_ld_ident(ent: ?*ir_entity, ld_ident: [*]const u8) void;
pub extern fn get_entity_ld_name(ent: ?*const ir_entity) [*]const u8;
pub extern fn entity_has_ld_ident(entity: ?*const ir_entity) i32;
pub extern fn get_entity_owner(ent: ?*const ir_entity) ?*ir_type;
pub extern fn set_entity_owner(ent: ?*ir_entity, owner: ?*ir_type) void;
pub extern fn get_entity_type(ent: ?*const ir_entity) ?*ir_type;
pub extern fn set_entity_type(ent: ?*ir_entity, tp: ?*ir_type) void;
pub extern fn get_entity_linkage(entity: ?*const ir_entity) ir_linkage;
pub extern fn set_entity_linkage(entity: ?*ir_entity, linkage: ir_linkage) void;
pub extern fn add_entity_linkage(entity: ?*ir_entity, linkage: ir_linkage) void;
pub extern fn remove_entity_linkage(entity: ?*ir_entity, linkage: ir_linkage) void;
pub extern fn get_entity_volatility(ent: ?*const ir_entity) ir_volatility;
pub extern fn set_entity_volatility(ent: ?*ir_entity, vol: ir_volatility) void;
pub extern fn get_volatility_name(@"var": ir_volatility) [*]const u8;
pub extern fn get_entity_alignment(entity: ?*const ir_entity) u32;
pub extern fn set_entity_alignment(entity: ?*ir_entity, alignment: u32) void;
pub extern fn get_entity_aligned(ent: ?*const ir_entity) ir_align;
pub extern fn set_entity_aligned(ent: ?*ir_entity, a: ir_align) void;
pub extern fn get_align_name(a: ir_align) [*]const u8;
pub extern fn get_entity_offset(entity: ?*const ir_entity) i32;
pub extern fn set_entity_offset(entity: ?*ir_entity, offset: i32) void;
pub extern fn get_entity_bitfield_offset(entity: ?*const ir_entity) u32;
pub extern fn set_entity_bitfield_offset(entity: ?*ir_entity, offset: u32) void;
pub extern fn set_entity_bitfield_size(entity: ?*ir_entity, size: u32) void;
pub extern fn get_entity_bitfield_size(entity: ?*const ir_entity) u32;
pub extern fn get_entity_link(ent: ?*const ir_entity) ?*anyopaque;
pub extern fn set_entity_link(ent: ?*ir_entity, l: ?*anyopaque) void;
pub extern fn get_entity_irg(ent: ?*const ir_entity) ?*ir_graph;
pub extern fn get_entity_linktime_irg(ent: ?*const ir_entity) ?*ir_graph;
pub extern fn get_entity_vtable_number(ent: ?*const ir_entity) u32;
pub extern fn set_entity_vtable_number(ent: ?*ir_entity, vtable_number: u32) void;
pub extern fn set_entity_label(ent: ?*ir_entity, label: ir_label_t) void;
pub extern fn get_entity_label(ent: ?*const ir_entity) ir_label_t;
pub extern fn get_entity_usage(ent: ?*const ir_entity) ir_entity_usage;
pub extern fn set_entity_usage(ent: ?*ir_entity, flag: ir_entity_usage) void;
pub extern fn get_entity_dbg_info(ent: ?*const ir_entity) ?*dbg_info;
pub extern fn set_entity_dbg_info(ent: ?*ir_entity, db: ?*dbg_info) void;
pub extern fn is_parameter_entity(entity: ?*const ir_entity) i32;
pub extern fn get_entity_parameter_number(entity: ?*const ir_entity) usize;
pub extern fn set_entity_parameter_number(entity: ?*ir_entity, n: usize) void;
pub extern fn get_initializer_kind(initializer: ?*const ir_initializer_t) ir_initializer_kind_t;
pub extern fn get_initializer_kind_name(ini: ir_initializer_kind_t) [*]const u8;
pub extern fn get_initializer_null() ?*ir_initializer_t;
pub extern fn create_initializer_const(value: ?*ir_node) ?*ir_initializer_t;
pub extern fn create_initializer_tarval(tv: ?*ir_tarval) ?*ir_initializer_t;
pub extern fn get_initializer_const_value(initializer: ?*const ir_initializer_t) ?*ir_node;
pub extern fn get_initializer_tarval_value(initialzier: ?*const ir_initializer_t) ?*ir_tarval;
pub extern fn create_initializer_compound(n_entries: usize) ?*ir_initializer_t;
pub extern fn get_initializer_compound_n_entries(initializer: ?*const ir_initializer_t) usize;
pub extern fn set_initializer_compound_value(initializer: ?*ir_initializer_t, index: usize, value: ?*ir_initializer_t) void;
pub extern fn get_initializer_compound_value(initializer: ?*const ir_initializer_t, index: usize) ?*ir_initializer_t;
pub extern fn set_entity_initializer(entity: ?*ir_entity, initializer: ?*ir_initializer_t) void;
pub extern fn get_entity_initializer(entity: ?*const ir_entity) ?*ir_initializer_t;
pub extern fn add_entity_overwrites(ent: ?*ir_entity, overwritten: ?*ir_entity) void;
pub extern fn get_entity_n_overwrites(ent: ?*const ir_entity) usize;
pub extern fn get_entity_overwrites_index(ent: ?*const ir_entity, overwritten: ?*ir_entity) usize;
pub extern fn get_entity_overwrites(ent: ?*const ir_entity, pos: usize) ?*ir_entity;
pub extern fn set_entity_overwrites(ent: ?*ir_entity, pos: usize, overwritten: ?*ir_entity) void;
pub extern fn remove_entity_overwrites(ent: ?*ir_entity, overwritten: ?*ir_entity) void;
pub extern fn get_entity_n_overwrittenby(ent: ?*const ir_entity) usize;
pub extern fn get_entity_overwrittenby_index(ent: ?*const ir_entity, overwrites: ?*ir_entity) usize;
pub extern fn get_entity_overwrittenby(ent: ?*const ir_entity, pos: usize) ?*ir_entity;
pub extern fn set_entity_overwrittenby(ent: ?*ir_entity, pos: usize, overwrites: ?*ir_entity) void;
pub extern fn remove_entity_overwrittenby(ent: ?*ir_entity, overwrites: ?*ir_entity) void;
pub extern fn is_compound_entity(ent: ?*const ir_entity) i32;
pub extern fn is_method_entity(ent: ?*const ir_entity) i32;
pub extern fn is_alias_entity(ent: ?*const ir_entity) i32;
pub extern fn get_entity_nr(ent: ?*const ir_entity) i64;
pub extern fn get_entity_visited(ent: ?*const ir_entity) ir_visited_t;
pub extern fn set_entity_visited(ent: ?*ir_entity, num: ir_visited_t) void;
pub extern fn mark_entity_visited(ent: ?*ir_entity) void;
pub extern fn entity_visited(ent: ?*const ir_entity) i32;
pub extern fn entity_not_visited(ent: ?*const ir_entity) i32;
pub extern fn entity_has_additional_properties(entity: ?*const ir_entity) i32;
pub extern fn get_entity_additional_properties(ent: ?*const ir_entity) mtp_additional_properties;
pub extern fn set_entity_additional_properties(ent: ?*ir_entity, prop: mtp_additional_properties) void;
pub extern fn add_entity_additional_properties(ent: ?*ir_entity, flag: mtp_additional_properties) void;
pub extern fn get_unknown_entity() ?*ir_entity;
pub extern fn is_unknown_entity(entity: ?*const ir_entity) i32;
pub extern fn get_type_opcode_name(opcode: tp_opcode) [*]const u8;
pub extern fn is_SubClass_of(low: ?*const ir_type, high: ?*const ir_type) i32;
pub extern fn is_SubClass_ptr_of(low: ?*ir_type, high: ?*ir_type) i32;
pub extern fn is_overwritten_by(high: ?*ir_entity, low: ?*ir_entity) i32;
pub extern fn resolve_ent_polymorphy(dynamic_class: ?*ir_type, static_ent: ?*ir_entity) ?*ir_entity;
pub extern fn set_irp_inh_transitive_closure_state(s: inh_transitive_closure_state) void;
pub extern fn invalidate_irp_inh_transitive_closure_state() void;
pub extern fn get_irp_inh_transitive_closure_state() inh_transitive_closure_state;
pub extern fn compute_inh_transitive_closure() void;
pub extern fn free_inh_transitive_closure() void;
pub extern fn get_class_trans_subtype_first(tp: ?*const ir_type) ?*ir_type;
pub extern fn get_class_trans_subtype_next(tp: ?*const ir_type) ?*ir_type;
pub extern fn is_class_trans_subtype(tp: ?*const ir_type, subtp: ?*const ir_type) i32;
pub extern fn get_class_trans_supertype_first(tp: ?*const ir_type) ?*ir_type;
pub extern fn get_class_trans_supertype_next(tp: ?*const ir_type) ?*ir_type;
pub extern fn get_entity_trans_overwrittenby_first(ent: ?*const ir_entity) ?*ir_entity;
pub extern fn get_entity_trans_overwrittenby_next(ent: ?*const ir_entity) ?*ir_entity;
pub extern fn get_entity_trans_overwrites_first(ent: ?*const ir_entity) ?*ir_entity;
pub extern fn get_entity_trans_overwrites_next(ent: ?*const ir_entity) ?*ir_entity;
pub extern fn check_type(tp: ?*const ir_type) i32;
pub extern fn tr_verify() i32;
pub extern fn free_type(tp: ?*ir_type) void;
pub extern fn get_type_opcode(@"type": ?*const ir_type) tp_opcode;
pub extern fn ir_print_type(buffer: [*]u8, buffer_size: usize, tp: ?*const ir_type) void;
pub extern fn get_type_state_name(s: ir_type_state) [*]const u8;
pub extern fn get_type_state(tp: ?*const ir_type) ir_type_state;
pub extern fn set_type_state(tp: ?*ir_type, state: ir_type_state) void;
pub extern fn get_type_mode(tp: ?*const ir_type) ?*ir_mode;
pub extern fn get_type_size(tp: ?*const ir_type) u32;
pub extern fn set_type_size(tp: ?*ir_type, size: u32) void;
pub extern fn get_type_alignment(tp: ?*const ir_type) u32;
pub extern fn set_type_alignment(tp: ?*ir_type, @"align": u32) void;
pub extern fn get_type_visited(tp: ?*const ir_type) ir_visited_t;
pub extern fn set_type_visited(tp: ?*ir_type, num: ir_visited_t) void;
pub extern fn mark_type_visited(tp: ?*ir_type) void;
pub extern fn type_visited(tp: ?*const ir_type) i32;
pub extern fn get_type_link(tp: ?*const ir_type) ?*anyopaque;
pub extern fn set_type_link(tp: ?*ir_type, l: ?*anyopaque) void;
pub extern fn inc_master_type_visited() void;
pub extern fn set_master_type_visited(val: ir_visited_t) void;
pub extern fn get_master_type_visited() ir_visited_t;
pub extern fn set_type_dbg_info(tp: ?*ir_type, db: ?*type_dbg_info) void;
pub extern fn get_type_dbg_info(tp: ?*const ir_type) ?*type_dbg_info;
pub extern fn get_type_nr(tp: ?*const ir_type) i64;
pub extern fn new_type_class(name: [*]const u8) ?*ir_type;
pub extern fn get_class_n_members(clss: ?*const ir_type) usize;
pub extern fn get_class_member(clss: ?*const ir_type, pos: usize) ?*ir_entity;
pub extern fn get_class_member_index(clss: ?*const ir_type, mem: ?*const ir_entity) usize;
pub extern fn add_class_subtype(clss: ?*ir_type, subtype: ?*ir_type) void;
pub extern fn get_class_n_subtypes(clss: ?*const ir_type) usize;
pub extern fn get_class_subtype(clss: ?*const ir_type, pos: usize) ?*ir_type;
pub extern fn get_class_subtype_index(clss: ?*const ir_type, subclass: ?*const ir_type) usize;
pub extern fn set_class_subtype(clss: ?*ir_type, subtype: ?*ir_type, pos: usize) void;
pub extern fn remove_class_subtype(clss: ?*ir_type, subtype: ?*ir_type) void;
pub extern fn add_class_supertype(clss: ?*ir_type, supertype: ?*ir_type) void;
pub extern fn get_class_n_supertypes(clss: ?*const ir_type) usize;
pub extern fn get_class_supertype_index(clss: ?*const ir_type, super_clss: ?*const ir_type) usize;
pub extern fn get_class_supertype(clss: ?*const ir_type, pos: usize) ?*ir_type;
pub extern fn set_class_supertype(clss: ?*ir_type, supertype: ?*ir_type, pos: usize) void;
pub extern fn remove_class_supertype(clss: ?*ir_type, supertype: ?*ir_type) void;
pub extern fn is_Class_type(clss: ?*const ir_type) i32;
pub extern fn new_type_struct(name: [*]const u8) ?*ir_type;
pub extern fn get_struct_n_members(strct: ?*const ir_type) usize;
pub extern fn get_struct_member(strct: ?*const ir_type, pos: usize) ?*ir_entity;
pub extern fn get_struct_member_index(strct: ?*const ir_type, member: ?*const ir_entity) usize;
pub extern fn is_Struct_type(strct: ?*const ir_type) i32;
pub extern fn new_type_union(name: [*]const u8) ?*ir_type;
pub extern fn get_union_n_members(uni: ?*const ir_type) usize;
pub extern fn get_union_member(uni: ?*const ir_type, pos: usize) ?*ir_entity;
pub extern fn get_union_member_index(uni: ?*const ir_type, member: ?*const ir_entity) usize;
pub extern fn is_Union_type(uni: ?*const ir_type) i32;
pub extern fn new_type_method(n_param: usize, n_res: usize, is_variadic: i32, cc_mask: u32, property_mask: mtp_additional_properties) ?*ir_type;
pub extern fn get_method_n_params(method: ?*const ir_type) usize;
pub extern fn get_method_param_type(method: ?*const ir_type, pos: usize) ?*ir_type;
pub extern fn set_method_param_type(method: ?*ir_type, pos: usize, tp: ?*ir_type) void;
pub extern fn get_method_n_ress(method: ?*const ir_type) usize;
pub extern fn get_method_res_type(method: ?*const ir_type, pos: usize) ?*ir_type;
pub extern fn set_method_res_type(method: ?*ir_type, pos: usize, tp: ?*ir_type) void;
pub extern fn is_method_variadic(method: ?*const ir_type) i32;
pub extern fn get_method_additional_properties(method: ?*const ir_type) mtp_additional_properties;
pub extern fn get_method_calling_convention(method: ?*const ir_type) u32;
pub extern fn get_method_n_regparams(method: ?*ir_type) u32;
pub extern fn is_Method_type(method: ?*const ir_type) i32;
pub extern fn new_type_array(element_type: ?*ir_type, n_elements: u32) ?*ir_type;
pub extern fn get_array_size(array: ?*const ir_type) u32;
pub extern fn get_array_element_type(array: ?*const ir_type) ?*ir_type;
pub extern fn is_Array_type(array: ?*const ir_type) i32;
pub extern fn new_type_pointer(points_to: ?*ir_type) ?*ir_type;
pub extern fn set_pointer_points_to_type(pointer: ?*ir_type, tp: ?*ir_type) void;
pub extern fn get_pointer_points_to_type(pointer: ?*const ir_type) ?*ir_type;
pub extern fn is_Pointer_type(pointer: ?*const ir_type) i32;
pub extern fn new_type_primitive(mode: ?*ir_mode) ?*ir_type;
pub extern fn is_Primitive_type(primitive: ?*const ir_type) i32;
pub extern fn get_code_type() ?*ir_type;
pub extern fn is_code_type(tp: ?*const ir_type) i32;
pub extern fn get_unknown_type() ?*ir_type;
pub extern fn is_unknown_type(@"type": ?*const ir_type) i32;
pub extern fn is_atomic_type(tp: ?*const ir_type) i32;
pub extern fn get_compound_ident(tp: ?*const ir_type) [*]const u8;
pub extern fn get_compound_name(tp: ?*const ir_type) [*]const u8;
pub extern fn get_compound_n_members(tp: ?*const ir_type) usize;
pub extern fn get_compound_member(tp: ?*const ir_type, pos: usize) ?*ir_entity;
pub extern fn get_compound_member_index(tp: ?*const ir_type, member: ?*const ir_entity) usize;
pub extern fn remove_compound_member(compound: ?*ir_type, entity: ?*ir_entity) void;
pub extern fn default_layout_compound_type(tp: ?*ir_type) void;
pub extern fn is_compound_type(tp: ?*const ir_type) i32;
pub extern fn new_type_frame() ?*ir_type;
pub extern fn is_frame_type(tp: ?*const ir_type) i32;
pub extern fn clone_frame_type(@"type": ?*ir_type) ?*ir_type;
pub extern fn is_segment_type(tp: ?*const ir_type) i32;
pub extern fn type_walk(pre: ?type_walk_func, post: ?type_walk_func, env: ?*anyopaque) void;
pub extern fn type_walk_irg(irg: ?*ir_graph, pre: ?type_walk_func, post: ?type_walk_func, env: ?*anyopaque) void;
pub extern fn type_walk_super2sub(pre: ?type_walk_func, post: ?type_walk_func, env: ?*anyopaque) void;
pub extern fn type_walk_super(pre: ?type_walk_func, post: ?type_walk_func, env: ?*anyopaque) void;
pub extern fn class_walk_super2sub(pre: ?class_walk_func, post: ?class_walk_func, env: ?*anyopaque) void;
pub extern fn walk_types_entities(tp: ?*ir_type, doit: ?entity_walk_func, env: ?*anyopaque) void;
pub extern fn get_method_param_access(ent: ?*ir_entity, pos: usize) ptr_access_kind;
pub extern fn analyze_irg_args(irg: ?*ir_graph) void;
pub extern fn get_method_param_weight(ent: ?*ir_entity, pos: usize) u32;
pub extern fn analyze_irg_args_weight(irg: ?*ir_graph) void;
pub extern fn new_int_mode(name: [*]const u8, bit_size: u32, sign: i32, modulo_shift: u32) ?*ir_mode;
pub extern fn new_reference_mode(name: [*]const u8, bit_size: u32, modulo_shift: u32) ?*ir_mode;
pub extern fn new_float_mode(name: [*]const u8, arithmetic: ir_mode_arithmetic, exponent_size: u32, mantissa_size: u32, int_conv_overflow: float_int_conversion_overflow_style_t) ?*ir_mode;
pub extern fn new_non_arithmetic_mode(name: [*]const u8, bit_size: u32) ?*ir_mode;
pub extern fn get_mode_ident(mode: ?*const ir_mode) [*]const u8;
pub extern fn get_mode_name(mode: ?*const ir_mode) [*]const u8;
pub extern fn get_mode_size_bits(mode: ?*const ir_mode) u32;
pub extern fn get_mode_size_bytes(mode: ?*const ir_mode) u32;
pub extern fn get_mode_arithmetic(mode: ?*const ir_mode) ir_mode_arithmetic;
pub extern fn get_mode_modulo_shift(mode: ?*const ir_mode) u32;
pub extern fn get_mode_min(mode: ?*const ir_mode) ?*ir_tarval;
pub extern fn get_mode_max(mode: ?*const ir_mode) ?*ir_tarval;
pub extern fn get_mode_null(mode: ?*const ir_mode) ?*ir_tarval;
pub extern fn get_mode_one(mode: ?*const ir_mode) ?*ir_tarval;
pub extern fn get_mode_all_one(mode: ?*const ir_mode) ?*ir_tarval;
pub extern fn get_mode_infinite(mode: ?*const ir_mode) ?*ir_tarval;
pub extern fn get_modeF() ?*ir_mode;
pub extern fn get_modeD() ?*ir_mode;
pub extern fn get_modeBs() ?*ir_mode;
pub extern fn get_modeBu() ?*ir_mode;
pub extern fn get_modeHs() ?*ir_mode;
pub extern fn get_modeHu() ?*ir_mode;
pub extern fn get_modeIs() ?*ir_mode;
pub extern fn get_modeIu() ?*ir_mode;
pub extern fn get_modeLs() ?*ir_mode;
pub extern fn get_modeLu() ?*ir_mode;
pub extern fn get_modeP() ?*ir_mode;
pub extern fn get_modeb() ?*ir_mode;
pub extern fn get_modeX() ?*ir_mode;
pub extern fn get_modeBB() ?*ir_mode;
pub extern fn get_modeM() ?*ir_mode;
pub extern fn get_modeT() ?*ir_mode;
pub extern fn get_modeANY() ?*ir_mode;
pub extern fn get_modeBAD() ?*ir_mode;
pub extern fn set_modeP(p: ?*ir_mode) void;
pub extern fn mode_is_signed(mode: ?*const ir_mode) i32;
pub extern fn mode_is_float(mode: ?*const ir_mode) i32;
pub extern fn mode_is_int(mode: ?*const ir_mode) i32;
pub extern fn mode_is_reference(mode: ?*const ir_mode) i32;
pub extern fn mode_is_num(mode: ?*const ir_mode) i32;
pub extern fn mode_is_data(mode: ?*const ir_mode) i32;
pub extern fn smaller_mode(sm: ?*const ir_mode, lm: ?*const ir_mode) i32;
pub extern fn values_in_mode(sm: ?*const ir_mode, lm: ?*const ir_mode) i32;
pub extern fn find_unsigned_mode(mode: ?*const ir_mode) ?*ir_mode;
pub extern fn find_signed_mode(mode: ?*const ir_mode) ?*ir_mode;
pub extern fn find_double_bits_int_mode(mode: ?*const ir_mode) ?*ir_mode;
pub extern fn mode_has_signed_zero(mode: ?*const ir_mode) i32;
pub extern fn mode_overflow_on_unary_Minus(mode: ?*const ir_mode) i32;
pub extern fn mode_wrap_around(mode: ?*const ir_mode) i32;
pub extern fn get_reference_offset_mode(mode: ?*const ir_mode) ?*ir_mode;
pub extern fn set_reference_offset_mode(ref_mode: ?*ir_mode, int_mode: ?*ir_mode) void;
pub extern fn get_mode_mantissa_size(mode: ?*const ir_mode) u32;
pub extern fn get_mode_exponent_size(mode: ?*const ir_mode) u32;
pub extern fn get_mode_float_int_overflow(mode: ?*const ir_mode) float_int_conversion_overflow_style_t;
pub extern fn is_reinterpret_cast(src: ?*const ir_mode, dst: ?*const ir_mode) i32;
pub extern fn get_type_for_mode(mode: ?*const ir_mode) ?*ir_type;
pub extern fn ir_get_n_modes() usize;
pub extern fn ir_get_mode(num: usize) ?*ir_mode;
pub extern fn optimize_cf(irg: ?*ir_graph) void;
pub extern fn opt_jumpthreading(irg: ?*ir_graph) void;
pub extern fn opt_bool(irg: ?*ir_graph) void;
pub extern fn conv_opt(irg: ?*ir_graph) void;
pub extern fn optimize_funccalls() void;
pub extern fn do_gvn_pre(irg: ?*ir_graph) void;
pub extern fn opt_if_conv(irg: ?*ir_graph) void;
pub extern fn opt_if_conv_cb(irg: ?*ir_graph, callback: arch_allow_ifconv_func) void;
pub extern fn opt_parallelize_mem(irg: ?*ir_graph) void;
pub extern fn can_replace_load_by_const(load: ?*const ir_node, c: ?*ir_node) ?*ir_node;
pub extern fn optimize_load_store(irg: ?*ir_graph) void;
pub extern fn combine_memops(irg: ?*ir_graph) void;
pub extern fn opt_ldst(irg: ?*ir_graph) void;
pub extern fn opt_frame_irg(irg: ?*ir_graph) void;
pub extern fn opt_osr(irg: ?*ir_graph, flags: u32) void;
pub extern fn remove_phi_cycles(irg: ?*ir_graph) void;
pub extern fn proc_cloning(threshold: f32) void;
pub extern fn optimize_reassociation(irg: ?*ir_graph) void;
pub extern fn normalize_one_return(irg: ?*ir_graph) void;
pub extern fn normalize_n_returns(irg: ?*ir_graph) void;
pub extern fn scalar_replacement_opt(irg: ?*ir_graph) void;
pub extern fn opt_tail_rec_irg(irg: ?*ir_graph) void;
pub extern fn combo(irg: ?*ir_graph) void;
pub extern fn inline_functions(maxsize: u32, inline_threshold: i32, after_inline_opt: opt_ptr) void;
pub extern fn shape_blocks(irg: ?*ir_graph) void;
pub extern fn do_loop_inversion(irg: ?*ir_graph) void;
pub extern fn do_loop_unrolling(irg: ?*ir_graph) void;
pub extern fn unroll_loops(irg: ?*ir_graph, factor: u32, maxsize: u32) void;
pub extern fn do_loop_peeling(irg: ?*ir_graph) void;
pub extern fn garbage_collect_entities() void;
pub extern fn dead_node_elimination(irg: ?*ir_graph) void;
pub extern fn place_code(irg: ?*ir_graph) void;
pub extern fn occult_consts(irg: ?*ir_graph) void;
pub extern fn value_not_null(n: ?*const ir_node, confirm: [*]?*const ir_node) i32;
pub extern fn computed_value_Cmp_Confirm(left: ?*ir_node, right: ?*ir_node, relation: ir_relation) ?*ir_tarval;
pub extern fn create_compilerlib_entity(name: [*]const u8, mt: ?*ir_type) ?*ir_entity;
pub extern fn be_lower_for_target() void;
pub extern fn be_set_after_transform_func(func: after_transform_func) void;
pub extern fn be_main(output: *std.c.FILE, compilation_unit_name: [*]const u8) void;
pub extern fn be_parse_asm_constraints(constraints: [*]const u8) asm_constraint_flags_t;
pub extern fn be_is_valid_clobber(clobber: [*]const u8) i32;
pub extern fn be_dwarf_set_source_language(language: dwarf_source_language) void;
pub extern fn be_dwarf_set_compilation_directory(directory: [*]const u8) void;
pub extern fn get_irp_callgraph_state() irp_callgraph_state;
pub extern fn set_irp_callgraph_state(s: irp_callgraph_state) void;
pub extern fn get_irg_n_callers(irg: ?*const ir_graph) usize;
pub extern fn get_irg_caller(irg: ?*const ir_graph, pos: usize) ?*ir_graph;
pub extern fn is_irg_caller_backedge(irg: ?*const ir_graph, pos: usize) i32;
pub extern fn has_irg_caller_backedge(irg: ?*const ir_graph) i32;
pub extern fn get_irg_caller_loop_depth(irg: ?*const ir_graph, pos: usize) usize;
pub extern fn get_irg_n_callees(irg: ?*const ir_graph) usize;
pub extern fn get_irg_callee(irg: ?*const ir_graph, pos: usize) ?*ir_graph;
pub extern fn is_irg_callee_backedge(irg: ?*const ir_graph, pos: usize) i32;
pub extern fn has_irg_callee_backedge(irg: ?*const ir_graph) i32;
pub extern fn get_irg_callee_loop_depth(irg: ?*const ir_graph, pos: usize) usize;
pub extern fn get_irg_method_execution_frequency(irg: ?*const ir_graph) f64;
pub extern fn compute_callgraph() void;
pub extern fn free_callgraph() void;
pub extern fn callgraph_walk(pre: ?callgraph_walk_func, post: ?callgraph_walk_func, env: ?*anyopaque) void;
pub extern fn find_callgraph_recursions() void;
pub extern fn analyse_loop_nesting_depth() void;
pub extern fn get_irp_loop_nesting_depth_state() loop_nesting_depth_state;
pub extern fn set_irp_loop_nesting_depth_state(s: loop_nesting_depth_state) void;
pub extern fn set_irp_loop_nesting_depth_state_inconsistent() void;
pub extern fn compute_cdep(irg: ?*ir_graph) void;
pub extern fn free_cdep(irg: ?*ir_graph) void;
pub extern fn get_cdep_node(cdep: ?*const ir_cdep) ?*ir_node;
pub extern fn get_cdep_next(cdep: ?*const ir_cdep) ?*ir_cdep;
pub extern fn find_cdep(block: ?*const ir_node) ?*ir_cdep;
pub extern fn exchange_cdep(old: ?*ir_node, nw: ?*const ir_node) void;
pub extern fn is_cdep_on(dependee: ?*const ir_node, candidate: ?*const ir_node) i32;
pub extern fn get_unique_cdep(block: ?*const ir_node) ?*ir_node;
pub extern fn has_multiple_cdep(block: ?*const ir_node) i32;
pub extern fn cgana(free_methods: [*][*]?*ir_entity) usize;
pub extern fn free_callee_info(irg: ?*ir_graph) void;
pub extern fn free_irp_callee_info() void;
pub extern fn opt_call_addrs() void;
pub extern fn cg_call_has_callees(node: ?*const ir_node) i32;
pub extern fn cg_get_call_n_callees(node: ?*const ir_node) usize;
pub extern fn cg_get_call_callee(node: ?*const ir_node, pos: usize) ?*ir_entity;
pub extern fn cg_set_call_callee_arr(node: ?*ir_node, n: usize, arr: [*]?*ir_entity) void;
pub extern fn cg_remove_call_callee_arr(node: ?*ir_node) void;
pub extern fn dbg_action_2_str(a: dbg_action) [*]const u8;
pub extern fn dbg_init(dbg_info_merge_pair: ?merge_pair_func, dbg_info_merge_sets: ?merge_sets_func) void;
pub extern fn ir_set_debug_retrieve(func: retrieve_dbg_func) void;
pub extern fn ir_set_type_debug_retrieve(func: retrieve_type_dbg_func) void;
pub extern fn ir_retrieve_dbg_info(dbg: ?*const dbg_info) src_loc_t;
pub extern fn ir_retrieve_type_dbg_info(buffer: [*]u8, buffer_size: usize, tdbgi: ?*const type_dbg_info) void;
pub extern fn ir_estimate_execfreq(irg: ?*ir_graph) void;
pub extern fn get_block_execfreq(block: ?*const ir_node) f64;
pub extern fn ir_init() void;
pub extern fn ir_init_library() void;
pub extern fn ir_finish() void;
pub extern fn ir_get_version_major() u32;
pub extern fn ir_get_version_minor() u32;
pub extern fn ir_get_version_micro() u32;
pub extern fn ir_get_version_revision() [*]const u8;
pub extern fn ir_get_version_build() [*]const u8;
pub extern fn get_kind(firm_thing: ?*const anyopaque) firm_kind;
pub extern fn get_irn_height(h: ?*const ir_heights_t, irn: ?*const ir_node) u32;
pub extern fn heights_reachable_in_block(h: ?*ir_heights_t, src: ?*const ir_node, tgt: ?*const ir_node) i32;
pub extern fn heights_recompute_block(h: ?*ir_heights_t, block: ?*ir_node) u32;
pub extern fn heights_new(irg: ?*ir_graph) ?*ir_heights_t;
pub extern fn heights_free(h: ?*ir_heights_t) void;
pub extern fn new_id_from_str(str: [*]const u8) [*]const u8;
pub extern fn new_id_from_chars(str: [*]const u8, len: usize) [*]const u8;
pub extern fn new_id_fmt(fmt: [*]const u8, ...) [*]const u8;
pub extern fn get_id_str(id: [*]const u8) [*]const u8;
pub extern fn id_unique(tag: [*]const u8) [*]const u8;
pub extern fn gc_irgs(n_keep: usize, keep_arr: [*]?*ir_entity) void;
pub extern fn get_op_name(op: ?*const ir_op) [*]const u8;
pub extern fn get_op_code(op: ?*const ir_op) u32;
pub extern fn get_op_pin_state_name(s: op_pin_state) [*]const u8;
pub extern fn get_op_pinned(op: ?*const ir_op) op_pin_state;
pub extern fn get_next_ir_opcode() u32;
pub extern fn get_next_ir_opcodes(num: u32) u32;
pub extern fn get_generic_function_ptr(op: ?*const ir_op) op_func;
pub extern fn set_generic_function_ptr(op: ?*ir_op, func: op_func) void;
pub extern fn get_op_flags(op: ?*const ir_op) irop_flags;
pub extern fn set_op_hash(op: ?*ir_op, func: hash_func) void;
pub extern fn set_op_computed_value(op: ?*ir_op, func: computed_value_func) void;
pub extern fn set_op_computed_value_proj(op: ?*ir_op, func: computed_value_func) void;
pub extern fn set_op_equivalent_node(op: ?*ir_op, func: equivalent_node_func) void;
pub extern fn set_op_equivalent_node_proj(op: ?*ir_op, func: equivalent_node_func) void;
pub extern fn set_op_transform_node(op: ?*ir_op, func: transform_node_func) void;
pub extern fn set_op_transform_node_proj(op: ?*ir_op, func: transform_node_func) void;
pub extern fn set_op_attrs_equal(op: ?*ir_op, func: node_attrs_equal_func) void;
pub extern fn set_op_reassociate(op: ?*ir_op, func: reassociate_func) void;
pub extern fn set_op_copy_attr(op: ?*ir_op, func: copy_attr_func) void;
pub extern fn set_op_get_type_attr(op: ?*ir_op, func: get_type_attr_func) void;
pub extern fn set_op_get_entity_attr(op: ?*ir_op, func: get_entity_attr_func) void;
pub extern fn set_op_verify(op: ?*ir_op, func: verify_node_func) void;
pub extern fn set_op_verify_proj(op: ?*ir_op, func: verify_proj_node_func) void;
pub extern fn set_op_dump(op: ?*ir_op, func: dump_node_func) void;
pub extern fn new_ir_op(code: u32, name: [*]const u8, p: op_pin_state, flags: irop_flags, opar: op_arity, op_index: i32, attr_size: usize) ?*ir_op;
pub extern fn free_ir_op(code: ?*ir_op) void;
pub extern fn ir_get_n_opcodes() u32;
pub extern fn ir_get_opcode(code: u32) ?*ir_op;
pub extern fn ir_clear_opcodes_generic_func() void;
pub extern fn ir_op_set_memory_index(op: ?*ir_op, memory_index: i32) void;
pub extern fn ir_op_set_fragile_indices(op: ?*ir_op, pn_x_regular: u32, pn_x_except: u32) void;
pub extern fn new_rd_ASM(dbgi: ?*dbg_info, block: ?*ir_node, irn_mem: ?*ir_node, arity: i32, in: [*]const ?*ir_node, text: [*]const u8, n_constraints: usize, constraints: [*]ir_asm_constraint, n_clobbers: usize, clobbers: [*][*]const u8, flags: ir_cons_flags) ?*ir_node;
pub extern fn new_r_ASM(block: ?*ir_node, irn_mem: ?*ir_node, arity: i32, in: [*]const ?*ir_node, text: [*]const u8, n_constraints: usize, constraints: [*]ir_asm_constraint, n_clobbers: usize, clobbers: [*][*]const u8, flags: ir_cons_flags) ?*ir_node;
pub extern fn new_d_ASM(dbgi: ?*dbg_info, irn_mem: ?*ir_node, arity: i32, in: [*]const ?*ir_node, text: [*]const u8, n_constraints: usize, constraints: [*]ir_asm_constraint, n_clobbers: usize, clobbers: [*][*]const u8, flags: ir_cons_flags) ?*ir_node;
pub extern fn new_ASM(irn_mem: ?*ir_node, arity: i32, in: [*]const ?*ir_node, text: [*]const u8, n_constraints: usize, constraints: [*]ir_asm_constraint, n_clobbers: usize, clobbers: [*][*]const u8, flags: ir_cons_flags) ?*ir_node;
pub extern fn is_ASM(node: ?*const ir_node) i32;
pub extern fn get_ASM_mem(node: ?*const ir_node) ?*ir_node;
pub extern fn set_ASM_mem(node: ?*ir_node, mem: ?*ir_node) void;
pub extern fn get_ASM_n_inputs(node: ?*const ir_node) i32;
pub extern fn get_ASM_input(node: ?*const ir_node, pos: i32) ?*ir_node;
pub extern fn set_ASM_input(node: ?*ir_node, pos: i32, input: ?*ir_node) void;
pub extern fn get_ASM_input_arr(node: ?*ir_node) [*]?*ir_node;
pub extern fn get_ASM_constraints(node: ?*const ir_node) [*]ir_asm_constraint;
pub extern fn set_ASM_constraints(node: ?*ir_node, constraints: [*]ir_asm_constraint) void;
pub extern fn get_ASM_clobbers(node: ?*const ir_node) [*][*]const u8;
pub extern fn set_ASM_clobbers(node: ?*ir_node, clobbers: [*][*]const u8) void;
pub extern fn get_ASM_text(node: ?*const ir_node) [*]const u8;
pub extern fn set_ASM_text(node: ?*ir_node, text: [*]const u8) void;
pub extern fn get_op_ASM() ?*ir_op;
pub extern fn new_rd_Add(dbgi: ?*dbg_info, block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node;
pub extern fn new_r_Add(block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node;
pub extern fn new_d_Add(dbgi: ?*dbg_info, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node;
pub extern fn new_Add(irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node;
pub extern fn is_Add(node: ?*const ir_node) i32;
pub extern fn get_Add_left(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Add_left(node: ?*ir_node, left: ?*ir_node) void;
pub extern fn get_Add_right(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Add_right(node: ?*ir_node, right: ?*ir_node) void;
pub extern fn get_op_Add() ?*ir_op;
pub extern fn new_rd_Address(dbgi: ?*dbg_info, irg: ?*ir_graph, entity: ?*ir_entity) ?*ir_node;
pub extern fn new_r_Address(irg: ?*ir_graph, entity: ?*ir_entity) ?*ir_node;
pub extern fn new_d_Address(dbgi: ?*dbg_info, entity: ?*ir_entity) ?*ir_node;
pub extern fn new_Address(entity: ?*ir_entity) ?*ir_node;
pub extern fn is_Address(node: ?*const ir_node) i32;
pub extern fn get_Address_entity(node: ?*const ir_node) ?*ir_entity;
pub extern fn set_Address_entity(node: ?*ir_node, entity: ?*ir_entity) void;
pub extern fn get_op_Address() ?*ir_op;
pub extern fn new_rd_Align(dbgi: ?*dbg_info, irg: ?*ir_graph, mode: ?*ir_mode, @"type": ?*ir_type) ?*ir_node;
pub extern fn new_r_Align(irg: ?*ir_graph, mode: ?*ir_mode, @"type": ?*ir_type) ?*ir_node;
pub extern fn new_d_Align(dbgi: ?*dbg_info, mode: ?*ir_mode, @"type": ?*ir_type) ?*ir_node;
pub extern fn new_Align(mode: ?*ir_mode, @"type": ?*ir_type) ?*ir_node;
pub extern fn is_Align(node: ?*const ir_node) i32;
pub extern fn get_Align_type(node: ?*const ir_node) ?*ir_type;
pub extern fn set_Align_type(node: ?*ir_node, @"type": ?*ir_type) void;
pub extern fn get_op_Align() ?*ir_op;
pub extern fn new_rd_Alloc(dbgi: ?*dbg_info, block: ?*ir_node, irn_mem: ?*ir_node, irn_size: ?*ir_node, alignment: u32) ?*ir_node;
pub extern fn new_r_Alloc(block: ?*ir_node, irn_mem: ?*ir_node, irn_size: ?*ir_node, alignment: u32) ?*ir_node;
pub extern fn new_d_Alloc(dbgi: ?*dbg_info, irn_mem: ?*ir_node, irn_size: ?*ir_node, alignment: u32) ?*ir_node;
pub extern fn new_Alloc(irn_mem: ?*ir_node, irn_size: ?*ir_node, alignment: u32) ?*ir_node;
pub extern fn is_Alloc(node: ?*const ir_node) i32;
pub extern fn get_Alloc_mem(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Alloc_mem(node: ?*ir_node, mem: ?*ir_node) void;
pub extern fn get_Alloc_size(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Alloc_size(node: ?*ir_node, size: ?*ir_node) void;
pub extern fn get_Alloc_alignment(node: ?*const ir_node) u32;
pub extern fn set_Alloc_alignment(node: ?*ir_node, alignment: u32) void;
pub extern fn get_op_Alloc() ?*ir_op;
pub extern fn is_Anchor(node: ?*const ir_node) i32;
pub extern fn get_Anchor_end_block(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Anchor_end_block(node: ?*ir_node, end_block: ?*ir_node) void;
pub extern fn get_Anchor_start_block(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Anchor_start_block(node: ?*ir_node, start_block: ?*ir_node) void;
pub extern fn get_Anchor_end(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Anchor_end(node: ?*ir_node, end: ?*ir_node) void;
pub extern fn get_Anchor_start(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Anchor_start(node: ?*ir_node, start: ?*ir_node) void;
pub extern fn get_Anchor_frame(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Anchor_frame(node: ?*ir_node, frame: ?*ir_node) void;
pub extern fn get_Anchor_initial_mem(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Anchor_initial_mem(node: ?*ir_node, initial_mem: ?*ir_node) void;
pub extern fn get_Anchor_args(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Anchor_args(node: ?*ir_node, args: ?*ir_node) void;
pub extern fn get_Anchor_no_mem(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Anchor_no_mem(node: ?*ir_node, no_mem: ?*ir_node) void;
pub extern fn get_op_Anchor() ?*ir_op;
pub extern fn new_rd_And(dbgi: ?*dbg_info, block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node;
pub extern fn new_r_And(block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node;
pub extern fn new_d_And(dbgi: ?*dbg_info, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node;
pub extern fn new_And(irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node;
pub extern fn is_And(node: ?*const ir_node) i32;
pub extern fn get_And_left(node: ?*const ir_node) ?*ir_node;
pub extern fn set_And_left(node: ?*ir_node, left: ?*ir_node) void;
pub extern fn get_And_right(node: ?*const ir_node) ?*ir_node;
pub extern fn set_And_right(node: ?*ir_node, right: ?*ir_node) void;
pub extern fn get_op_And() ?*ir_op;
pub extern fn new_rd_Bad(dbgi: ?*dbg_info, irg: ?*ir_graph, mode: ?*ir_mode) ?*ir_node;
pub extern fn new_r_Bad(irg: ?*ir_graph, mode: ?*ir_mode) ?*ir_node;
pub extern fn new_d_Bad(dbgi: ?*dbg_info, mode: ?*ir_mode) ?*ir_node;
pub extern fn new_Bad(mode: ?*ir_mode) ?*ir_node;
pub extern fn is_Bad(node: ?*const ir_node) i32;
pub extern fn get_op_Bad() ?*ir_op;
pub extern fn new_rd_Bitcast(dbgi: ?*dbg_info, block: ?*ir_node, irn_op: ?*ir_node, mode: ?*ir_mode) ?*ir_node;
pub extern fn new_r_Bitcast(block: ?*ir_node, irn_op: ?*ir_node, mode: ?*ir_mode) ?*ir_node;
pub extern fn new_d_Bitcast(dbgi: ?*dbg_info, irn_op: ?*ir_node, mode: ?*ir_mode) ?*ir_node;
pub extern fn new_Bitcast(irn_op: ?*ir_node, mode: ?*ir_mode) ?*ir_node;
pub extern fn is_Bitcast(node: ?*const ir_node) i32;
pub extern fn get_Bitcast_op(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Bitcast_op(node: ?*ir_node, op: ?*ir_node) void;
pub extern fn get_op_Bitcast() ?*ir_op;
pub extern fn new_rd_Block(dbgi: ?*dbg_info, irg: ?*ir_graph, arity: i32, in: [*]const ?*ir_node) ?*ir_node;
pub extern fn new_r_Block(irg: ?*ir_graph, arity: i32, in: [*]const ?*ir_node) ?*ir_node;
pub extern fn new_d_Block(dbgi: ?*dbg_info, arity: i32, in: [*]const ?*ir_node) ?*ir_node;
pub extern fn new_Block(arity: i32, in: [*]const ?*ir_node) ?*ir_node;
pub extern fn is_Block(node: ?*const ir_node) i32;
pub extern fn get_Block_n_cfgpreds(node: ?*const ir_node) i32;
pub extern fn get_Block_cfgpred(node: ?*const ir_node, pos: i32) ?*ir_node;
pub extern fn set_Block_cfgpred(node: ?*ir_node, pos: i32, cfgpred: ?*ir_node) void;
pub extern fn get_Block_cfgpred_arr(node: ?*ir_node) [*]?*ir_node;
pub extern fn get_Block_entity(node: ?*const ir_node) ?*ir_entity;
pub extern fn set_Block_entity(node: ?*ir_node, entity: ?*ir_entity) void;
pub extern fn get_op_Block() ?*ir_op;
pub extern fn new_rd_Builtin(dbgi: ?*dbg_info, block: ?*ir_node, irn_mem: ?*ir_node, arity: i32, in: [*]const ?*ir_node, kind: ir_builtin_kind, @"type": ?*ir_type) ?*ir_node;
pub extern fn new_r_Builtin(block: ?*ir_node, irn_mem: ?*ir_node, arity: i32, in: [*]const ?*ir_node, kind: ir_builtin_kind, @"type": ?*ir_type) ?*ir_node;
pub extern fn new_d_Builtin(dbgi: ?*dbg_info, irn_mem: ?*ir_node, arity: i32, in: [*]const ?*ir_node, kind: ir_builtin_kind, @"type": ?*ir_type) ?*ir_node;
pub extern fn new_Builtin(irn_mem: ?*ir_node, arity: i32, in: [*]const ?*ir_node, kind: ir_builtin_kind, @"type": ?*ir_type) ?*ir_node;
pub extern fn is_Builtin(node: ?*const ir_node) i32;
pub extern fn get_Builtin_mem(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Builtin_mem(node: ?*ir_node, mem: ?*ir_node) void;
pub extern fn get_Builtin_n_params(node: ?*const ir_node) i32;
pub extern fn get_Builtin_param(node: ?*const ir_node, pos: i32) ?*ir_node;
pub extern fn set_Builtin_param(node: ?*ir_node, pos: i32, param: ?*ir_node) void;
pub extern fn get_Builtin_param_arr(node: ?*ir_node) [*]?*ir_node;
pub extern fn get_Builtin_kind(node: ?*const ir_node) ir_builtin_kind;
pub extern fn set_Builtin_kind(node: ?*ir_node, kind: ir_builtin_kind) void;
pub extern fn get_Builtin_type(node: ?*const ir_node) ?*ir_type;
pub extern fn set_Builtin_type(node: ?*ir_node, @"type": ?*ir_type) void;
pub extern fn get_op_Builtin() ?*ir_op;
pub extern fn new_rd_Call(dbgi: ?*dbg_info, block: ?*ir_node, irn_mem: ?*ir_node, irn_ptr: ?*ir_node, arity: i32, in: ?[*]const ?*ir_node, @"type": ?*ir_type) ?*ir_node;
pub extern fn new_r_Call(block: ?*ir_node, irn_mem: ?*ir_node, irn_ptr: ?*ir_node, arity: i32, in: ?[*]const ?*ir_node, @"type": ?*ir_type) ?*ir_node;
pub extern fn new_d_Call(dbgi: ?*dbg_info, irn_mem: ?*ir_node, irn_ptr: ?*ir_node, arity: i32, in: ?[*]const ?*ir_node, @"type": ?*ir_type) ?*ir_node;
pub extern fn new_Call(irn_mem: ?*ir_node, irn_ptr: ?*ir_node, arity: i32, in: ?[*]const ?*ir_node, @"type": ?*ir_type) ?*ir_node;
pub extern fn is_Call(node: ?*const ir_node) i32;
pub extern fn get_Call_mem(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Call_mem(node: ?*ir_node, mem: ?*ir_node) void;
pub extern fn get_Call_ptr(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Call_ptr(node: ?*ir_node, ptr: ?*ir_node) void;
pub extern fn get_Call_n_params(node: ?*const ir_node) i32;
pub extern fn get_Call_param(node: ?*const ir_node, pos: i32) ?*ir_node;
pub extern fn set_Call_param(node: ?*ir_node, pos: i32, param: ?*ir_node) void;
pub extern fn get_Call_param_arr(node: ?*ir_node) [*]?*ir_node;
pub extern fn get_Call_type(node: ?*const ir_node) ?*ir_type;
pub extern fn set_Call_type(node: ?*ir_node, @"type": ?*ir_type) void;
pub extern fn get_op_Call() ?*ir_op;
pub extern fn new_rd_Cmp(dbgi: ?*dbg_info, block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node, relation: ir_relation) ?*ir_node;
pub extern fn new_r_Cmp(block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node, relation: ir_relation) ?*ir_node;
pub extern fn new_d_Cmp(dbgi: ?*dbg_info, irn_left: ?*ir_node, irn_right: ?*ir_node, relation: ir_relation) ?*ir_node;
pub extern fn new_Cmp(irn_left: ?*ir_node, irn_right: ?*ir_node, relation: ir_relation) ?*ir_node;
pub extern fn is_Cmp(node: ?*const ir_node) i32;
pub extern fn get_Cmp_left(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Cmp_left(node: ?*ir_node, left: ?*ir_node) void;
pub extern fn get_Cmp_right(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Cmp_right(node: ?*ir_node, right: ?*ir_node) void;
pub extern fn get_Cmp_relation(node: ?*const ir_node) ir_relation;
pub extern fn set_Cmp_relation(node: ?*ir_node, relation: ir_relation) void;
pub extern fn get_op_Cmp() ?*ir_op;
pub extern fn new_rd_Cond(dbgi: ?*dbg_info, block: ?*ir_node, irn_selector: ?*ir_node) ?*ir_node;
pub extern fn new_r_Cond(block: ?*ir_node, irn_selector: ?*ir_node) ?*ir_node;
pub extern fn new_d_Cond(dbgi: ?*dbg_info, irn_selector: ?*ir_node) ?*ir_node;
pub extern fn new_Cond(irn_selector: ?*ir_node) ?*ir_node;
pub extern fn is_Cond(node: ?*const ir_node) i32;
pub extern fn get_Cond_selector(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Cond_selector(node: ?*ir_node, selector: ?*ir_node) void;
pub extern fn get_Cond_jmp_pred(node: ?*const ir_node) cond_jmp_predicate;
pub extern fn set_Cond_jmp_pred(node: ?*ir_node, jmp_pred: cond_jmp_predicate) void;
pub extern fn get_op_Cond() ?*ir_op;
pub extern fn new_rd_Confirm(dbgi: ?*dbg_info, block: ?*ir_node, irn_value: ?*ir_node, irn_bound: ?*ir_node, relation: ir_relation) ?*ir_node;
pub extern fn new_r_Confirm(block: ?*ir_node, irn_value: ?*ir_node, irn_bound: ?*ir_node, relation: ir_relation) ?*ir_node;
pub extern fn new_d_Confirm(dbgi: ?*dbg_info, irn_value: ?*ir_node, irn_bound: ?*ir_node, relation: ir_relation) ?*ir_node;
pub extern fn new_Confirm(irn_value: ?*ir_node, irn_bound: ?*ir_node, relation: ir_relation) ?*ir_node;
pub extern fn is_Confirm(node: ?*const ir_node) i32;
pub extern fn get_Confirm_value(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Confirm_value(node: ?*ir_node, value: ?*ir_node) void;
pub extern fn get_Confirm_bound(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Confirm_bound(node: ?*ir_node, bound: ?*ir_node) void;
pub extern fn get_Confirm_relation(node: ?*const ir_node) ir_relation;
pub extern fn set_Confirm_relation(node: ?*ir_node, relation: ir_relation) void;
pub extern fn get_op_Confirm() ?*ir_op;
pub extern fn new_rd_Const(dbgi: ?*dbg_info, irg: ?*ir_graph, tarval: ?*ir_tarval) ?*ir_node;
pub extern fn new_r_Const(irg: ?*ir_graph, tarval: ?*ir_tarval) ?*ir_node;
pub extern fn new_d_Const(dbgi: ?*dbg_info, tarval: ?*ir_tarval) ?*ir_node;
pub extern fn new_Const(tarval: ?*ir_tarval) ?*ir_node;
pub extern fn is_Const(node: ?*const ir_node) i32;
pub extern fn get_Const_tarval(node: ?*const ir_node) ?*ir_tarval;
pub extern fn set_Const_tarval(node: ?*ir_node, tarval: ?*ir_tarval) void;
pub extern fn get_op_Const() ?*ir_op;
pub extern fn new_rd_Conv(dbgi: ?*dbg_info, block: ?*ir_node, irn_op: ?*ir_node, mode: ?*ir_mode) ?*ir_node;
pub extern fn new_r_Conv(block: ?*ir_node, irn_op: ?*ir_node, mode: ?*ir_mode) ?*ir_node;
pub extern fn new_d_Conv(dbgi: ?*dbg_info, irn_op: ?*ir_node, mode: ?*ir_mode) ?*ir_node;
pub extern fn new_Conv(irn_op: ?*ir_node, mode: ?*ir_mode) ?*ir_node;
pub extern fn is_Conv(node: ?*const ir_node) i32;
pub extern fn get_Conv_op(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Conv_op(node: ?*ir_node, op: ?*ir_node) void;
pub extern fn get_op_Conv() ?*ir_op;
pub extern fn new_rd_CopyB(dbgi: ?*dbg_info, block: ?*ir_node, irn_mem: ?*ir_node, irn_dst: ?*ir_node, irn_src: ?*ir_node, @"type": ?*ir_type, flags: ir_cons_flags) ?*ir_node;
pub extern fn new_r_CopyB(block: ?*ir_node, irn_mem: ?*ir_node, irn_dst: ?*ir_node, irn_src: ?*ir_node, @"type": ?*ir_type, flags: ir_cons_flags) ?*ir_node;
pub extern fn new_d_CopyB(dbgi: ?*dbg_info, irn_mem: ?*ir_node, irn_dst: ?*ir_node, irn_src: ?*ir_node, @"type": ?*ir_type, flags: ir_cons_flags) ?*ir_node;
pub extern fn new_CopyB(irn_mem: ?*ir_node, irn_dst: ?*ir_node, irn_src: ?*ir_node, @"type": ?*ir_type, flags: ir_cons_flags) ?*ir_node;
pub extern fn is_CopyB(node: ?*const ir_node) i32;
pub extern fn get_CopyB_mem(node: ?*const ir_node) ?*ir_node;
pub extern fn set_CopyB_mem(node: ?*ir_node, mem: ?*ir_node) void;
pub extern fn get_CopyB_dst(node: ?*const ir_node) ?*ir_node;
pub extern fn set_CopyB_dst(node: ?*ir_node, dst: ?*ir_node) void;
pub extern fn get_CopyB_src(node: ?*const ir_node) ?*ir_node;
pub extern fn set_CopyB_src(node: ?*ir_node, src: ?*ir_node) void;
pub extern fn get_CopyB_type(node: ?*const ir_node) ?*ir_type;
pub extern fn set_CopyB_type(node: ?*ir_node, @"type": ?*ir_type) void;
pub extern fn get_CopyB_volatility(node: ?*const ir_node) ir_volatility;
pub extern fn set_CopyB_volatility(node: ?*ir_node, volatility: ir_volatility) void;
pub extern fn get_op_CopyB() ?*ir_op;
pub extern fn is_Deleted(node: ?*const ir_node) i32;
pub extern fn get_op_Deleted() ?*ir_op;
pub extern fn new_rd_Div(dbgi: ?*dbg_info, block: ?*ir_node, irn_mem: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node, pinned: i32) ?*ir_node;
pub extern fn new_r_Div(block: ?*ir_node, irn_mem: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node, pinned: i32) ?*ir_node;
pub extern fn new_d_Div(dbgi: ?*dbg_info, irn_mem: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node, pinned: i32) ?*ir_node;
pub extern fn new_Div(irn_mem: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node, pinned: i32) ?*ir_node;
pub extern fn is_Div(node: ?*const ir_node) i32;
pub extern fn get_Div_mem(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Div_mem(node: ?*ir_node, mem: ?*ir_node) void;
pub extern fn get_Div_left(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Div_left(node: ?*ir_node, left: ?*ir_node) void;
pub extern fn get_Div_right(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Div_right(node: ?*ir_node, right: ?*ir_node) void;
pub extern fn get_Div_resmode(node: ?*const ir_node) ?*ir_mode;
pub extern fn set_Div_resmode(node: ?*ir_node, resmode: ?*ir_mode) void;
pub extern fn get_Div_no_remainder(node: ?*const ir_node) i32;
pub extern fn set_Div_no_remainder(node: ?*ir_node, no_remainder: i32) void;
pub extern fn get_op_Div() ?*ir_op;
pub extern fn new_rd_Dummy(dbgi: ?*dbg_info, irg: ?*ir_graph, mode: ?*ir_mode) ?*ir_node;
pub extern fn new_r_Dummy(irg: ?*ir_graph, mode: ?*ir_mode) ?*ir_node;
pub extern fn new_d_Dummy(dbgi: ?*dbg_info, mode: ?*ir_mode) ?*ir_node;
pub extern fn new_Dummy(mode: ?*ir_mode) ?*ir_node;
pub extern fn is_Dummy(node: ?*const ir_node) i32;
pub extern fn get_op_Dummy() ?*ir_op;
pub extern fn new_rd_End(dbgi: ?*dbg_info, irg: ?*ir_graph, arity: i32, in: [*]const ?*ir_node) ?*ir_node;
pub extern fn new_r_End(irg: ?*ir_graph, arity: i32, in: [*]const ?*ir_node) ?*ir_node;
pub extern fn new_d_End(dbgi: ?*dbg_info, arity: i32, in: [*]const ?*ir_node) ?*ir_node;
pub extern fn new_End(arity: i32, in: [*]const ?*ir_node) ?*ir_node;
pub extern fn is_End(node: ?*const ir_node) i32;
pub extern fn get_End_n_keepalives(node: ?*const ir_node) i32;
pub extern fn get_End_keepalive(node: ?*const ir_node, pos: i32) ?*ir_node;
pub extern fn set_End_keepalive(node: ?*ir_node, pos: i32, keepalive: ?*ir_node) void;
pub extern fn get_End_keepalive_arr(node: ?*ir_node) [*]?*ir_node;
pub extern fn get_op_End() ?*ir_op;
pub extern fn new_rd_Eor(dbgi: ?*dbg_info, block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node;
pub extern fn new_r_Eor(block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node;
pub extern fn new_d_Eor(dbgi: ?*dbg_info, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node;
pub extern fn new_Eor(irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node;
pub extern fn is_Eor(node: ?*const ir_node) i32;
pub extern fn get_Eor_left(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Eor_left(node: ?*ir_node, left: ?*ir_node) void;
pub extern fn get_Eor_right(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Eor_right(node: ?*ir_node, right: ?*ir_node) void;
pub extern fn get_op_Eor() ?*ir_op;
pub extern fn new_rd_Free(dbgi: ?*dbg_info, block: ?*ir_node, irn_mem: ?*ir_node, irn_ptr: ?*ir_node) ?*ir_node;
pub extern fn new_r_Free(block: ?*ir_node, irn_mem: ?*ir_node, irn_ptr: ?*ir_node) ?*ir_node;
pub extern fn new_d_Free(dbgi: ?*dbg_info, irn_mem: ?*ir_node, irn_ptr: ?*ir_node) ?*ir_node;
pub extern fn new_Free(irn_mem: ?*ir_node, irn_ptr: ?*ir_node) ?*ir_node;
pub extern fn is_Free(node: ?*const ir_node) i32;
pub extern fn get_Free_mem(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Free_mem(node: ?*ir_node, mem: ?*ir_node) void;
pub extern fn get_Free_ptr(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Free_ptr(node: ?*ir_node, ptr: ?*ir_node) void;
pub extern fn get_op_Free() ?*ir_op;
pub extern fn new_rd_IJmp(dbgi: ?*dbg_info, block: ?*ir_node, irn_target: ?*ir_node) ?*ir_node;
pub extern fn new_r_IJmp(block: ?*ir_node, irn_target: ?*ir_node) ?*ir_node;
pub extern fn new_d_IJmp(dbgi: ?*dbg_info, irn_target: ?*ir_node) ?*ir_node;
pub extern fn new_IJmp(irn_target: ?*ir_node) ?*ir_node;
pub extern fn is_IJmp(node: ?*const ir_node) i32;
pub extern fn get_IJmp_target(node: ?*const ir_node) ?*ir_node;
pub extern fn set_IJmp_target(node: ?*ir_node, target: ?*ir_node) void;
pub extern fn get_op_IJmp() ?*ir_op;
pub extern fn is_Id(node: ?*const ir_node) i32;
pub extern fn get_Id_pred(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Id_pred(node: ?*ir_node, pred: ?*ir_node) void;
pub extern fn get_op_Id() ?*ir_op;
pub extern fn new_rd_Jmp(dbgi: ?*dbg_info, block: ?*ir_node) ?*ir_node;
pub extern fn new_r_Jmp(block: ?*ir_node) ?*ir_node;
pub extern fn new_d_Jmp(dbgi: ?*dbg_info) ?*ir_node;
pub extern fn new_Jmp() ?*ir_node;
pub extern fn is_Jmp(node: ?*const ir_node) i32;
pub extern fn get_op_Jmp() ?*ir_op;
pub extern fn new_rd_Load(dbgi: ?*dbg_info, block: ?*ir_node, irn_mem: ?*ir_node, irn_ptr: ?*ir_node, mode: ?*ir_mode, @"type": ?*ir_type, flags: ir_cons_flags) ?*ir_node;
pub extern fn new_r_Load(block: ?*ir_node, irn_mem: ?*ir_node, irn_ptr: ?*ir_node, mode: ?*ir_mode, @"type": ?*ir_type, flags: ir_cons_flags) ?*ir_node;
pub extern fn new_d_Load(dbgi: ?*dbg_info, irn_mem: ?*ir_node, irn_ptr: ?*ir_node, mode: ?*ir_mode, @"type": ?*ir_type, flags: ir_cons_flags) ?*ir_node;
pub extern fn new_Load(irn_mem: ?*ir_node, irn_ptr: ?*ir_node, mode: ?*ir_mode, @"type": ?*ir_type, flags: ir_cons_flags) ?*ir_node;
pub extern fn is_Load(node: ?*const ir_node) i32;
pub extern fn get_Load_mem(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Load_mem(node: ?*ir_node, mem: ?*ir_node) void;
pub extern fn get_Load_ptr(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Load_ptr(node: ?*ir_node, ptr: ?*ir_node) void;
pub extern fn get_Load_mode(node: ?*const ir_node) ?*ir_mode;
pub extern fn set_Load_mode(node: ?*ir_node, mode: ?*ir_mode) void;
pub extern fn get_Load_type(node: ?*const ir_node) ?*ir_type;
pub extern fn set_Load_type(node: ?*ir_node, @"type": ?*ir_type) void;
pub extern fn get_Load_volatility(node: ?*const ir_node) ir_volatility;
pub extern fn set_Load_volatility(node: ?*ir_node, volatility: ir_volatility) void;
pub extern fn get_Load_unaligned(node: ?*const ir_node) ir_align;
pub extern fn set_Load_unaligned(node: ?*ir_node, unaligned: ir_align) void;
pub extern fn get_op_Load() ?*ir_op;
pub extern fn new_rd_Member(dbgi: ?*dbg_info, block: ?*ir_node, irn_ptr: ?*ir_node, entity: ?*ir_entity) ?*ir_node;
pub extern fn new_r_Member(block: ?*ir_node, irn_ptr: ?*ir_node, entity: ?*ir_entity) ?*ir_node;
pub extern fn new_d_Member(dbgi: ?*dbg_info, irn_ptr: ?*ir_node, entity: ?*ir_entity) ?*ir_node;
pub extern fn new_Member(irn_ptr: ?*ir_node, entity: ?*ir_entity) ?*ir_node;
pub extern fn is_Member(node: ?*const ir_node) i32;
pub extern fn get_Member_ptr(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Member_ptr(node: ?*ir_node, ptr: ?*ir_node) void;
pub extern fn get_Member_entity(node: ?*const ir_node) ?*ir_entity;
pub extern fn set_Member_entity(node: ?*ir_node, entity: ?*ir_entity) void;
pub extern fn get_op_Member() ?*ir_op;
pub extern fn new_rd_Minus(dbgi: ?*dbg_info, block: ?*ir_node, irn_op: ?*ir_node) ?*ir_node;
pub extern fn new_r_Minus(block: ?*ir_node, irn_op: ?*ir_node) ?*ir_node;
pub extern fn new_d_Minus(dbgi: ?*dbg_info, irn_op: ?*ir_node) ?*ir_node;
pub extern fn new_Minus(irn_op: ?*ir_node) ?*ir_node;
pub extern fn is_Minus(node: ?*const ir_node) i32;
pub extern fn get_Minus_op(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Minus_op(node: ?*ir_node, op: ?*ir_node) void;
pub extern fn get_op_Minus() ?*ir_op;
pub extern fn new_rd_Mod(dbgi: ?*dbg_info, block: ?*ir_node, irn_mem: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node, pinned: i32) ?*ir_node;
pub extern fn new_r_Mod(block: ?*ir_node, irn_mem: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node, pinned: i32) ?*ir_node;
pub extern fn new_d_Mod(dbgi: ?*dbg_info, irn_mem: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node, pinned: i32) ?*ir_node;
pub extern fn new_Mod(irn_mem: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node, pinned: i32) ?*ir_node;
pub extern fn is_Mod(node: ?*const ir_node) i32;
pub extern fn get_Mod_mem(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Mod_mem(node: ?*ir_node, mem: ?*ir_node) void;
pub extern fn get_Mod_left(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Mod_left(node: ?*ir_node, left: ?*ir_node) void;
pub extern fn get_Mod_right(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Mod_right(node: ?*ir_node, right: ?*ir_node) void;
pub extern fn get_Mod_resmode(node: ?*const ir_node) ?*ir_mode;
pub extern fn set_Mod_resmode(node: ?*ir_node, resmode: ?*ir_mode) void;
pub extern fn get_op_Mod() ?*ir_op;
pub extern fn new_rd_Mul(dbgi: ?*dbg_info, block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node;
pub extern fn new_r_Mul(block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node;
pub extern fn new_d_Mul(dbgi: ?*dbg_info, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node;
pub extern fn new_Mul(irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node;
pub extern fn is_Mul(node: ?*const ir_node) i32;
pub extern fn get_Mul_left(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Mul_left(node: ?*ir_node, left: ?*ir_node) void;
pub extern fn get_Mul_right(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Mul_right(node: ?*ir_node, right: ?*ir_node) void;
pub extern fn get_op_Mul() ?*ir_op;
pub extern fn new_rd_Mulh(dbgi: ?*dbg_info, block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node;
pub extern fn new_r_Mulh(block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node;
pub extern fn new_d_Mulh(dbgi: ?*dbg_info, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node;
pub extern fn new_Mulh(irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node;
pub extern fn is_Mulh(node: ?*const ir_node) i32;
pub extern fn get_Mulh_left(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Mulh_left(node: ?*ir_node, left: ?*ir_node) void;
pub extern fn get_Mulh_right(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Mulh_right(node: ?*ir_node, right: ?*ir_node) void;
pub extern fn get_op_Mulh() ?*ir_op;
pub extern fn new_rd_Mux(dbgi: ?*dbg_info, block: ?*ir_node, irn_sel: ?*ir_node, irn_false: ?*ir_node, irn_true: ?*ir_node) ?*ir_node;
pub extern fn new_r_Mux(block: ?*ir_node, irn_sel: ?*ir_node, irn_false: ?*ir_node, irn_true: ?*ir_node) ?*ir_node;
pub extern fn new_d_Mux(dbgi: ?*dbg_info, irn_sel: ?*ir_node, irn_false: ?*ir_node, irn_true: ?*ir_node) ?*ir_node;
pub extern fn new_Mux(irn_sel: ?*ir_node, irn_false: ?*ir_node, irn_true: ?*ir_node) ?*ir_node;
pub extern fn is_Mux(node: ?*const ir_node) i32;
pub extern fn get_Mux_sel(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Mux_sel(node: ?*ir_node, sel: ?*ir_node) void;
pub extern fn get_Mux_false(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Mux_false(node: ?*ir_node, false_: ?*ir_node) void;
pub extern fn get_Mux_true(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Mux_true(node: ?*ir_node, true_: ?*ir_node) void;
pub extern fn get_op_Mux() ?*ir_op;
pub extern fn new_rd_NoMem(dbgi: ?*dbg_info, irg: ?*ir_graph) ?*ir_node;
pub extern fn new_r_NoMem(irg: ?*ir_graph) ?*ir_node;
pub extern fn new_d_NoMem(dbgi: ?*dbg_info) ?*ir_node;
pub extern fn new_NoMem() ?*ir_node;
pub extern fn is_NoMem(node: ?*const ir_node) i32;
pub extern fn get_op_NoMem() ?*ir_op;
pub extern fn new_rd_Not(dbgi: ?*dbg_info, block: ?*ir_node, irn_op: ?*ir_node) ?*ir_node;
pub extern fn new_r_Not(block: ?*ir_node, irn_op: ?*ir_node) ?*ir_node;
pub extern fn new_d_Not(dbgi: ?*dbg_info, irn_op: ?*ir_node) ?*ir_node;
pub extern fn new_Not(irn_op: ?*ir_node) ?*ir_node;
pub extern fn is_Not(node: ?*const ir_node) i32;
pub extern fn get_Not_op(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Not_op(node: ?*ir_node, op: ?*ir_node) void;
pub extern fn get_op_Not() ?*ir_op;
pub extern fn new_rd_Offset(dbgi: ?*dbg_info, irg: ?*ir_graph, mode: ?*ir_mode, entity: ?*ir_entity) ?*ir_node;
pub extern fn new_r_Offset(irg: ?*ir_graph, mode: ?*ir_mode, entity: ?*ir_entity) ?*ir_node;
pub extern fn new_d_Offset(dbgi: ?*dbg_info, mode: ?*ir_mode, entity: ?*ir_entity) ?*ir_node;
pub extern fn new_Offset(mode: ?*ir_mode, entity: ?*ir_entity) ?*ir_node;
pub extern fn is_Offset(node: ?*const ir_node) i32;
pub extern fn get_Offset_entity(node: ?*const ir_node) ?*ir_entity;
pub extern fn set_Offset_entity(node: ?*ir_node, entity: ?*ir_entity) void;
pub extern fn get_op_Offset() ?*ir_op;
pub extern fn new_rd_Or(dbgi: ?*dbg_info, block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node;
pub extern fn new_r_Or(block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node;
pub extern fn new_d_Or(dbgi: ?*dbg_info, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node;
pub extern fn new_Or(irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node;
pub extern fn is_Or(node: ?*const ir_node) i32;
pub extern fn get_Or_left(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Or_left(node: ?*ir_node, left: ?*ir_node) void;
pub extern fn get_Or_right(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Or_right(node: ?*ir_node, right: ?*ir_node) void;
pub extern fn get_op_Or() ?*ir_op;
pub extern fn new_rd_Phi(dbgi: ?*dbg_info, block: ?*ir_node, arity: i32, in: [*]const ?*ir_node, mode: ?*ir_mode) ?*ir_node;
pub extern fn new_r_Phi(block: ?*ir_node, arity: i32, in: [*]const ?*ir_node, mode: ?*ir_mode) ?*ir_node;
pub extern fn new_d_Phi(dbgi: ?*dbg_info, arity: i32, in: [*]const ?*ir_node, mode: ?*ir_mode) ?*ir_node;
pub extern fn new_Phi(arity: i32, in: [*]const ?*ir_node, mode: ?*ir_mode) ?*ir_node;
pub extern fn is_Phi(node: ?*const ir_node) i32;
pub extern fn get_Phi_n_preds(node: ?*const ir_node) i32;
pub extern fn get_Phi_pred(node: ?*const ir_node, pos: i32) ?*ir_node;
pub extern fn set_Phi_pred(node: ?*ir_node, pos: i32, pred: ?*ir_node) void;
pub extern fn get_Phi_pred_arr(node: ?*ir_node) [*]?*ir_node;
pub extern fn get_Phi_loop(node: ?*const ir_node) i32;
pub extern fn set_Phi_loop(node: ?*ir_node, loop: i32) void;
pub extern fn get_op_Phi() ?*ir_op;
pub extern fn new_rd_Pin(dbgi: ?*dbg_info, block: ?*ir_node, irn_op: ?*ir_node) ?*ir_node;
pub extern fn new_r_Pin(block: ?*ir_node, irn_op: ?*ir_node) ?*ir_node;
pub extern fn new_d_Pin(dbgi: ?*dbg_info, irn_op: ?*ir_node) ?*ir_node;
pub extern fn new_Pin(irn_op: ?*ir_node) ?*ir_node;
pub extern fn is_Pin(node: ?*const ir_node) i32;
pub extern fn get_Pin_op(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Pin_op(node: ?*ir_node, op: ?*ir_node) void;
pub extern fn get_op_Pin() ?*ir_op;
pub extern fn new_rd_Proj(dbgi: ?*dbg_info, irn_pred: ?*ir_node, mode: ?*ir_mode, num: u32) ?*ir_node;
pub extern fn new_r_Proj(irn_pred: ?*ir_node, mode: ?*ir_mode, num: u32) ?*ir_node;
pub extern fn new_d_Proj(dbgi: ?*dbg_info, irn_pred: ?*ir_node, mode: ?*ir_mode, num: u32) ?*ir_node;
pub extern fn new_Proj(irn_pred: ?*ir_node, mode: ?*ir_mode, num: u32) ?*ir_node;
pub extern fn is_Proj(node: ?*const ir_node) i32;
pub extern fn get_Proj_pred(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Proj_pred(node: ?*ir_node, pred: ?*ir_node) void;
pub extern fn get_Proj_num(node: ?*const ir_node) u32;
pub extern fn set_Proj_num(node: ?*ir_node, num: u32) void;
pub extern fn get_op_Proj() ?*ir_op;
pub extern fn new_rd_Raise(dbgi: ?*dbg_info, block: ?*ir_node, irn_mem: ?*ir_node, irn_exo_ptr: ?*ir_node) ?*ir_node;
pub extern fn new_r_Raise(block: ?*ir_node, irn_mem: ?*ir_node, irn_exo_ptr: ?*ir_node) ?*ir_node;
pub extern fn new_d_Raise(dbgi: ?*dbg_info, irn_mem: ?*ir_node, irn_exo_ptr: ?*ir_node) ?*ir_node;
pub extern fn new_Raise(irn_mem: ?*ir_node, irn_exo_ptr: ?*ir_node) ?*ir_node;
pub extern fn is_Raise(node: ?*const ir_node) i32;
pub extern fn get_Raise_mem(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Raise_mem(node: ?*ir_node, mem: ?*ir_node) void;
pub extern fn get_Raise_exo_ptr(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Raise_exo_ptr(node: ?*ir_node, exo_ptr: ?*ir_node) void;
pub extern fn get_op_Raise() ?*ir_op;
pub extern fn new_rd_Return(dbgi: ?*dbg_info, block: ?*ir_node, irn_mem: ?*ir_node, arity: i32, in: *?*ir_node) ?*ir_node;
pub extern fn new_r_Return(block: ?*ir_node, irn_mem: ?*ir_node, arity: i32, in: *?*ir_node) ?*ir_node;
pub extern fn new_d_Return(dbgi: ?*dbg_info, irn_mem: ?*ir_node, arity: i32, in: *?*ir_node) ?*ir_node;
pub extern fn new_Return(irn_mem: ?*ir_node, arity: i32, in: *?*ir_node) ?*ir_node;
pub extern fn is_Return(node: ?*const ir_node) i32;
pub extern fn get_Return_mem(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Return_mem(node: ?*ir_node, mem: ?*ir_node) void;
pub extern fn get_Return_n_ress(node: ?*const ir_node) i32;
pub extern fn get_Return_res(node: ?*const ir_node, pos: i32) ?*ir_node;
pub extern fn set_Return_res(node: ?*ir_node, pos: i32, res: ?*ir_node) void;
pub extern fn get_Return_res_arr(node: ?*ir_node) [*]?*ir_node;
pub extern fn get_op_Return() ?*ir_op;
pub extern fn new_rd_Sel(dbgi: ?*dbg_info, block: ?*ir_node, irn_ptr: ?*ir_node, irn_index: ?*ir_node, @"type": ?*ir_type) ?*ir_node;
pub extern fn new_r_Sel(block: ?*ir_node, irn_ptr: ?*ir_node, irn_index: ?*ir_node, @"type": ?*ir_type) ?*ir_node;
pub extern fn new_d_Sel(dbgi: ?*dbg_info, irn_ptr: ?*ir_node, irn_index: ?*ir_node, @"type": ?*ir_type) ?*ir_node;
pub extern fn new_Sel(irn_ptr: ?*ir_node, irn_index: ?*ir_node, @"type": ?*ir_type) ?*ir_node;
pub extern fn is_Sel(node: ?*const ir_node) i32;
pub extern fn get_Sel_ptr(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Sel_ptr(node: ?*ir_node, ptr: ?*ir_node) void;
pub extern fn get_Sel_index(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Sel_index(node: ?*ir_node, index: ?*ir_node) void;
pub extern fn get_Sel_type(node: ?*const ir_node) ?*ir_type;
pub extern fn set_Sel_type(node: ?*ir_node, @"type": ?*ir_type) void;
pub extern fn get_op_Sel() ?*ir_op;
pub extern fn new_rd_Shl(dbgi: ?*dbg_info, block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node;
pub extern fn new_r_Shl(block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node;
pub extern fn new_d_Shl(dbgi: ?*dbg_info, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node;
pub extern fn new_Shl(irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node;
pub extern fn is_Shl(node: ?*const ir_node) i32;
pub extern fn get_Shl_left(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Shl_left(node: ?*ir_node, left: ?*ir_node) void;
pub extern fn get_Shl_right(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Shl_right(node: ?*ir_node, right: ?*ir_node) void;
pub extern fn get_op_Shl() ?*ir_op;
pub extern fn ir_printf(fmt: [*]const u8, ...) i32;
pub extern fn ir_fprintf(f: *std.c.FILE, fmt: [*]const u8, ...) i32;
pub extern fn ir_snprintf(buf: [*]u8, n: usize, fmt: [*]const u8, ...) i32;
pub extern fn ir_vprintf(fmt: [*]const u8, ...) i32;
pub extern fn ir_vfprintf(f: *std.c.FILE, fmt: [*]const u8, ...) i32;
pub extern fn ir_vsnprintf(buf: [*]u8, len: usize, fmt: [*]const u8, ...) i32;
pub extern fn ir_obst_vprintf(obst: ?*obstack, fmt: [*]const u8, ...) i32;
pub extern fn tarval_snprintf(buf: [*]u8, buflen: usize, tv: ?*const ir_tarval) i32;
pub extern fn new_rd_Shr(dbgi: ?*dbg_info, block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node;
pub extern fn new_r_Shr(block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node;
pub extern fn new_d_Shr(dbgi: ?*dbg_info, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node;
pub extern fn new_Shr(irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node;
pub extern fn is_Shr(node: ?*const ir_node) i32;
pub extern fn get_Shr_left(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Shr_left(node: ?*ir_node, left: ?*ir_node) void;
pub extern fn get_Shr_right(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Shr_right(node: ?*ir_node, right: ?*ir_node) void;
pub extern fn get_op_Shr() ?*ir_op;
pub extern fn new_rd_Shrs(dbgi: ?*dbg_info, block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node;
pub extern fn new_r_Shrs(block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node;
pub extern fn new_d_Shrs(dbgi: ?*dbg_info, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node;
pub extern fn new_Shrs(irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node;
pub extern fn is_Shrs(node: ?*const ir_node) i32;
pub extern fn get_Shrs_left(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Shrs_left(node: ?*ir_node, left: ?*ir_node) void;
pub extern fn get_Shrs_right(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Shrs_right(node: ?*ir_node, right: ?*ir_node) void;
pub extern fn get_op_Shrs() ?*ir_op;
pub extern fn new_rd_Size(dbgi: ?*dbg_info, irg: ?*ir_graph, mode: ?*ir_mode, @"type": ?*ir_type) ?*ir_node;
pub extern fn new_r_Size(irg: ?*ir_graph, mode: ?*ir_mode, @"type": ?*ir_type) ?*ir_node;
pub extern fn new_d_Size(dbgi: ?*dbg_info, mode: ?*ir_mode, @"type": ?*ir_type) ?*ir_node;
pub extern fn new_Size(mode: ?*ir_mode, @"type": ?*ir_type) ?*ir_node;
pub extern fn is_Size(node: ?*const ir_node) i32;
pub extern fn get_Size_type(node: ?*const ir_node) ?*ir_type;
pub extern fn set_Size_type(node: ?*ir_node, @"type": ?*ir_type) void;
pub extern fn get_op_Size() ?*ir_op;
pub extern fn new_rd_Start(dbgi: ?*dbg_info, irg: ?*ir_graph) ?*ir_node;
pub extern fn new_r_Start(irg: ?*ir_graph) ?*ir_node;
pub extern fn new_d_Start(dbgi: ?*dbg_info) ?*ir_node;
pub extern fn new_Start() ?*ir_node;
pub extern fn is_Start(node: ?*const ir_node) i32;
pub extern fn get_op_Start() ?*ir_op;
pub extern fn new_rd_Store(dbgi: ?*dbg_info, block: ?*ir_node, irn_mem: ?*ir_node, irn_ptr: ?*ir_node, irn_value: ?*ir_node, @"type": ?*ir_type, flags: ir_cons_flags) ?*ir_node;
pub extern fn new_r_Store(block: ?*ir_node, irn_mem: ?*ir_node, irn_ptr: ?*ir_node, irn_value: ?*ir_node, @"type": ?*ir_type, flags: ir_cons_flags) ?*ir_node;
pub extern fn new_d_Store(dbgi: ?*dbg_info, irn_mem: ?*ir_node, irn_ptr: ?*ir_node, irn_value: ?*ir_node, @"type": ?*ir_type, flags: ir_cons_flags) ?*ir_node;
pub extern fn new_Store(irn_mem: ?*ir_node, irn_ptr: ?*ir_node, irn_value: ?*ir_node, @"type": ?*ir_type, flags: ir_cons_flags) ?*ir_node;
pub extern fn is_Store(node: ?*const ir_node) i32;
pub extern fn get_Store_mem(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Store_mem(node: ?*ir_node, mem: ?*ir_node) void;
pub extern fn get_Store_ptr(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Store_ptr(node: ?*ir_node, ptr: ?*ir_node) void;
pub extern fn get_Store_value(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Store_value(node: ?*ir_node, value: ?*ir_node) void;
pub extern fn get_Store_type(node: ?*const ir_node) ?*ir_type;
pub extern fn set_Store_type(node: ?*ir_node, @"type": ?*ir_type) void;
pub extern fn get_Store_volatility(node: ?*const ir_node) ir_volatility;
pub extern fn set_Store_volatility(node: ?*ir_node, volatility: ir_volatility) void;
pub extern fn get_Store_unaligned(node: ?*const ir_node) ir_align;
pub extern fn set_Store_unaligned(node: ?*ir_node, unaligned: ir_align) void;
pub extern fn get_op_Store() ?*ir_op;
pub extern fn new_rd_Sub(dbgi: ?*dbg_info, block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node;
pub extern fn new_r_Sub(block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node;
pub extern fn new_d_Sub(dbgi: ?*dbg_info, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node;
pub extern fn new_Sub(irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node;
pub extern fn is_Sub(node: ?*const ir_node) i32;
pub extern fn get_Sub_left(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Sub_left(node: ?*ir_node, left: ?*ir_node) void;
pub extern fn get_Sub_right(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Sub_right(node: ?*ir_node, right: ?*ir_node) void;
pub extern fn get_op_Sub() ?*ir_op;
pub extern fn new_rd_Switch(dbgi: ?*dbg_info, block: ?*ir_node, irn_selector: ?*ir_node, n_outs: u32, table: ?*ir_switch_table) ?*ir_node;
pub extern fn new_r_Switch(block: ?*ir_node, irn_selector: ?*ir_node, n_outs: u32, table: ?*ir_switch_table) ?*ir_node;
pub extern fn new_d_Switch(dbgi: ?*dbg_info, irn_selector: ?*ir_node, n_outs: u32, table: ?*ir_switch_table) ?*ir_node;
pub extern fn new_Switch(irn_selector: ?*ir_node, n_outs: u32, table: ?*ir_switch_table) ?*ir_node;
pub extern fn is_Switch(node: ?*const ir_node) i32;
pub extern fn get_Switch_selector(node: ?*const ir_node) ?*ir_node;
pub extern fn set_Switch_selector(node: ?*ir_node, selector: ?*ir_node) void;
pub extern fn get_Switch_n_outs(node: ?*const ir_node) u32;
pub extern fn set_Switch_n_outs(node: ?*ir_node, n_outs: u32) void;
pub extern fn get_Switch_table(node: ?*const ir_node) ?*ir_switch_table;
pub extern fn set_Switch_table(node: ?*ir_node, table: ?*ir_switch_table) void;
pub extern fn get_op_Switch() ?*ir_op;
pub extern fn new_rd_Sync(dbgi: ?*dbg_info, block: ?*ir_node, arity: i32, in: [*]const ?*ir_node) ?*ir_node;
pub extern fn new_r_Sync(block: ?*ir_node, arity: i32, in: [*]const ?*ir_node) ?*ir_node;
pub extern fn new_d_Sync(dbgi: ?*dbg_info, arity: i32, in: [*]const ?*ir_node) ?*ir_node;
pub extern fn new_Sync(arity: i32, in: [*]const ?*ir_node) ?*ir_node;
pub extern fn is_Sync(node: ?*const ir_node) i32;
pub extern fn get_Sync_n_preds(node: ?*const ir_node) i32;
pub extern fn get_Sync_pred(node: ?*const ir_node, pos: i32) ?*ir_node;
pub extern fn set_Sync_pred(node: ?*ir_node, pos: i32, pred: ?*ir_node) void;
pub extern fn get_Sync_pred_arr(node: ?*ir_node) [*]?*ir_node;
pub extern fn get_op_Sync() ?*ir_op;
pub extern fn new_rd_Tuple(dbgi: ?*dbg_info, block: ?*ir_node, arity: i32, in: [*]const ?*ir_node) ?*ir_node;
pub extern fn new_r_Tuple(block: ?*ir_node, arity: i32, in: [*]const ?*ir_node) ?*ir_node;
pub extern fn new_d_Tuple(dbgi: ?*dbg_info, arity: i32, in: [*]const ?*ir_node) ?*ir_node;
pub extern fn new_Tuple(arity: i32, in: [*]const ?*ir_node) ?*ir_node;
pub extern fn is_Tuple(node: ?*const ir_node) i32;
pub extern fn get_Tuple_n_preds(node: ?*const ir_node) i32;
pub extern fn get_Tuple_pred(node: ?*const ir_node, pos: i32) ?*ir_node;
pub extern fn set_Tuple_pred(node: ?*ir_node, pos: i32, pred: ?*ir_node) void;
pub extern fn get_Tuple_pred_arr(node: ?*ir_node) [*]?*ir_node;
pub extern fn get_op_Tuple() ?*ir_op;
pub extern fn new_rd_Unknown(dbgi: ?*dbg_info, irg: ?*ir_graph, mode: ?*ir_mode) ?*ir_node;
pub extern fn new_r_Unknown(irg: ?*ir_graph, mode: ?*ir_mode) ?*ir_node;
pub extern fn new_d_Unknown(dbgi: ?*dbg_info, mode: ?*ir_mode) ?*ir_node;
pub extern fn new_Unknown(mode: ?*ir_mode) ?*ir_node;
pub extern fn is_Unknown(node: ?*const ir_node) i32;
pub extern fn get_op_Unknown() ?*ir_op;
pub extern fn is_binop(node: ?*const ir_node) i32;
pub extern fn is_entconst(node: ?*const ir_node) i32;
pub extern fn get_entconst_entity(node: ?*const ir_node) ?*ir_entity;
pub extern fn set_entconst_entity(node: ?*ir_node, entity: ?*ir_entity) void;
pub extern fn is_typeconst(node: ?*const ir_node) i32;
pub extern fn get_typeconst_type(node: ?*const ir_node) ?*ir_type;
pub extern fn set_typeconst_type(node: ?*ir_node, @"type": ?*ir_type) void;
pub extern fn get_irn_arity(node: ?*const ir_node) i32;
pub extern fn get_irn_n(node: ?*const ir_node, n: i32) ?*ir_node;
pub extern fn set_irn_in(node: ?*ir_node, arity: i32, in: [*]const ?*ir_node) void;
pub extern fn set_irn_n(node: ?*ir_node, n: i32, in: ?*ir_node) void;
pub extern fn add_irn_n(node: ?*ir_node, in: ?*ir_node) i32;
pub extern fn set_irn_mode(node: ?*ir_node, mode: ?*ir_mode) void;
pub extern fn get_irn_mode(node: ?*const ir_node) ?*ir_mode;
pub extern fn get_irn_op(node: ?*const ir_node) ?*ir_op;
pub extern fn get_irn_opcode(node: ?*const ir_node) u32;
pub extern fn get_irn_opname(node: ?*const ir_node) [*]const u8;
pub extern fn get_irn_opident(node: ?*const ir_node) [*]const u8;
pub extern fn get_irn_visited(node: ?*const ir_node) ir_visited_t;
pub extern fn set_irn_visited(node: ?*ir_node, visited: ir_visited_t) void;
pub extern fn mark_irn_visited(node: ?*ir_node) void;
pub extern fn irn_visited(node: ?*const ir_node) i32;
pub extern fn irn_visited_else_mark(node: ?*ir_node) i32;
pub extern fn set_irn_link(node: ?*ir_node, link: ?*anyopaque) void;
pub extern fn get_irn_link(node: ?*const ir_node) ?*anyopaque;
pub extern fn get_irn_irg(node: ?*const ir_node) ?*ir_graph;
pub extern fn get_irn_node_nr(node: ?*const ir_node) i64;
pub extern fn get_irn_pinned(node: ?*const ir_node) i32;
pub extern fn set_irn_pinned(node: ?*ir_node, pinned: i32) void;
pub extern fn new_ir_node(db: ?*dbg_info, irg: ?*ir_graph, block: ?*ir_node, op: ?*ir_op, mode: ?*ir_mode, arity: i32, in: [*]const ?*ir_node) ?*ir_node;
pub extern fn exact_copy(node: ?*const ir_node) ?*ir_node;
pub extern fn irn_copy_into_irg(node: ?*const ir_node, irg: ?*ir_graph) ?*ir_node;
pub extern fn get_nodes_block(node: ?*const ir_node) ?*ir_node;
pub extern fn set_nodes_block(node: ?*ir_node, block: ?*ir_node) void;
pub extern fn get_Block_cfgpred_block(node: ?*const ir_node, pos: i32) ?*ir_node;
pub extern fn get_Block_matured(block: ?*const ir_node) i32;
pub extern fn set_Block_matured(block: ?*ir_node, matured: i32) void;
pub extern fn get_Block_block_visited(block: ?*const ir_node) ir_visited_t;
pub extern fn set_Block_block_visited(block: ?*ir_node, visit: ir_visited_t) void;
pub extern fn mark_Block_block_visited(node: ?*ir_node) void;
pub extern fn Block_block_visited(node: ?*const ir_node) i32;
pub extern fn create_Block_entity(block: ?*ir_node) ?*ir_entity;
pub extern fn get_Block_phis(block: ?*const ir_node) ?*ir_node;
pub extern fn set_Block_phis(block: ?*ir_node, phi: ?*ir_node) void;
pub extern fn add_Block_phi(block: ?*ir_node, phi: ?*ir_node) void;
pub extern fn get_Block_mark(block: ?*const ir_node) u32;
pub extern fn set_Block_mark(block: ?*ir_node, mark: u32) void;
pub extern fn add_End_keepalive(end: ?*ir_node, ka: ?*ir_node) void;
pub extern fn set_End_keepalives(end: ?*ir_node, n: i32, in: [*]?*ir_node) void;
pub extern fn remove_End_keepalive(end: ?*ir_node, irn: ?*const ir_node) void;
pub extern fn remove_End_n(end: ?*ir_node, idx: i32) void;
pub extern fn remove_End_Bads_and_doublets(end: ?*ir_node) void;
pub extern fn free_End(end: ?*ir_node) void;
pub extern fn is_Const_null(node: ?*const ir_node) i32;
pub extern fn is_Const_one(node: ?*const ir_node) i32;
pub extern fn is_Const_all_one(node: ?*const ir_node) i32;
pub extern fn get_Call_callee(call: ?*const ir_node) ?*ir_entity;
pub extern fn get_builtin_kind_name(kind: ir_builtin_kind) [*]const u8;
pub extern fn get_binop_left(node: ?*const ir_node) ?*ir_node;
pub extern fn set_binop_left(node: ?*ir_node, left: ?*ir_node) void;
pub extern fn get_binop_right(node: ?*const ir_node) ?*ir_node;
pub extern fn set_binop_right(node: ?*ir_node, right: ?*ir_node) void;
pub extern fn is_x_except_Proj(node: ?*const ir_node) i32;
pub extern fn is_x_regular_Proj(node: ?*const ir_node) i32;
pub extern fn ir_set_throws_exception(node: ?*ir_node, throws_exception: i32) void;
pub extern fn ir_throws_exception(node: ?*const ir_node) i32;
pub extern fn get_relation_string(relation: ir_relation) [*]const u8;
pub extern fn get_negated_relation(relation: ir_relation) ir_relation;
pub extern fn get_inversed_relation(relation: ir_relation) ir_relation;
pub extern fn get_Phi_next(phi: ?*const ir_node) ?*ir_node;
pub extern fn set_Phi_next(phi: ?*ir_node, next: ?*ir_node) void;
pub extern fn is_memop(node: ?*const ir_node) i32;
pub extern fn get_memop_mem(node: ?*const ir_node) ?*ir_node;
pub extern fn set_memop_mem(node: ?*ir_node, mem: ?*ir_node) void;
pub extern fn add_Sync_pred(node: ?*ir_node, pred: ?*ir_node) void;
pub extern fn remove_Sync_n(n: ?*ir_node, i: i32) void;
pub extern fn get_ASM_n_constraints(node: ?*const ir_node) usize;
pub extern fn get_ASM_n_clobbers(node: ?*const ir_node) usize;
pub extern fn skip_Proj(node: ?*ir_node) ?*ir_node;
pub extern fn skip_Proj_const(node: ?*const ir_node) ?*const ir_node;
pub extern fn skip_Id(node: ?*ir_node) ?*ir_node;
pub extern fn skip_Tuple(node: ?*ir_node) ?*ir_node;
pub extern fn skip_Pin(node: ?*ir_node) ?*ir_node;
pub extern fn skip_Confirm(node: ?*ir_node) ?*ir_node;
pub extern fn is_cfop(node: ?*const ir_node) i32;
pub extern fn is_unknown_jump(node: ?*const ir_node) i32;
pub extern fn is_fragile_op(node: ?*const ir_node) i32;
pub extern fn is_irn_forking(node: ?*const ir_node) i32;
pub extern fn is_irn_const_memory(node: ?*const ir_node) i32;
pub extern fn copy_node_attr(irg: ?*ir_graph, old_node: ?*const ir_node, new_node: ?*ir_node) void;
pub extern fn get_irn_type_attr(n: ?*ir_node) ?*ir_type;
pub extern fn get_irn_entity_attr(n: ?*ir_node) ?*ir_entity;
pub extern fn is_irn_constlike(node: ?*const ir_node) i32;
pub extern fn is_irn_keep(node: ?*const ir_node) i32;
pub extern fn is_irn_start_block_placed(node: ?*const ir_node) i32;
pub extern fn get_cond_jmp_predicate_name(pred: cond_jmp_predicate) [*]const u8;
pub extern fn get_irn_generic_attr(node: ?*ir_node) ?*anyopaque;
pub extern fn get_irn_generic_attr_const(node: ?*const ir_node) ?*const anyopaque;
pub extern fn get_irn_idx(node: ?*const ir_node) u32;
pub extern fn set_irn_dbg_info(n: ?*ir_node, db: ?*dbg_info) void;
pub extern fn get_irn_dbg_info(n: ?*const ir_node) ?*dbg_info;
pub extern fn gdb_node_helper(firm_object: ?*const anyopaque) [*]const u8;
pub extern fn ir_new_switch_table(irg: ?*ir_graph, n_entries: usize) ?*ir_switch_table;
pub extern fn ir_switch_table_get_n_entries(table: ?*const ir_switch_table) usize;
pub extern fn ir_switch_table_set(table: ?*ir_switch_table, entry: usize, min: ?*ir_tarval, max: ?*ir_tarval, pn: u32) void;
pub extern fn ir_switch_table_get_max(table: ?*const ir_switch_table, entry: usize) ?*ir_tarval;
pub extern fn ir_switch_table_get_min(table: ?*const ir_switch_table, entry: usize) ?*ir_tarval;
pub extern fn ir_switch_table_get_pn(table: ?*const ir_switch_table, entry: usize) u32;
pub extern fn ir_switch_table_duplicate(irg: ?*ir_graph, table: ?*const ir_switch_table) ?*ir_switch_table;
pub extern fn new_rd_Const_long(db: ?*dbg_info, irg: ?*ir_graph, mode: ?*ir_mode, value: i64) ?*ir_node;
pub extern fn new_r_Const_long(irg: ?*ir_graph, mode: ?*ir_mode, value: i64) ?*ir_node;
pub extern fn new_d_Const_long(db: ?*dbg_info, mode: ?*ir_mode, value: i64) ?*ir_node;
pub extern fn new_Const_long(mode: ?*ir_mode, value: i64) ?*ir_node;
pub extern fn new_rd_Phi_loop(db: ?*dbg_info, block: ?*ir_node, arity: i32, in: [*]?*ir_node) ?*ir_node;
pub extern fn new_r_Phi_loop(block: ?*ir_node, arity: i32, in: [*]?*ir_node) ?*ir_node;
pub extern fn new_d_Phi_loop(db: ?*dbg_info, arity: i32, in: [*]?*ir_node) ?*ir_node;
pub extern fn new_Phi_loop(arity: i32, in: [*]?*ir_node) ?*ir_node;
pub extern fn new_rd_DivRL(db: ?*dbg_info, block: ?*ir_node, memop: ?*ir_node, op1: ?*ir_node, op2: ?*ir_node, pinned: i32) ?*ir_node;
pub extern fn new_r_DivRL(block: ?*ir_node, memop: ?*ir_node, op1: ?*ir_node, op2: ?*ir_node, pinned: i32) ?*ir_node;
pub extern fn new_d_DivRL(db: ?*dbg_info, memop: ?*ir_node, op1: ?*ir_node, op2: ?*ir_node, pinned: i32) ?*ir_node;
pub extern fn new_DivRL(memop: ?*ir_node, op1: ?*ir_node, op2: ?*ir_node, pinned: i32) ?*ir_node;
pub extern fn get_current_ir_graph() ?*ir_graph;
pub extern fn set_current_ir_graph(graph: ?*ir_graph) void;
pub extern fn new_d_immBlock(db: ?*dbg_info) ?*ir_node;
pub extern fn new_immBlock() ?*ir_node;
pub extern fn new_r_immBlock(irg: ?*ir_graph) ?*ir_node;
pub extern fn new_rd_immBlock(db: ?*dbg_info, irg: ?*ir_graph) ?*ir_node;
pub extern fn add_immBlock_pred(immblock: ?*ir_node, jmp: ?*ir_node) void;
pub extern fn mature_immBlock(block: ?*ir_node) void;
pub extern fn set_cur_block(target: ?*ir_node) void;
pub extern fn set_r_cur_block(irg: ?*ir_graph, target: ?*ir_node) void;
pub extern fn get_cur_block() ?*ir_node;
pub extern fn get_r_cur_block(irg: ?*ir_graph) ?*ir_node;
pub extern fn get_value(pos: i32, mode: ?*ir_mode) ?*ir_node;
pub extern fn get_r_value(irg: ?*ir_graph, pos: i32, mode: ?*ir_mode) ?*ir_node;
pub extern fn ir_guess_mode(pos: i32) ?*ir_mode;
pub extern fn ir_r_guess_mode(irg: ?*ir_graph, pos: i32) ?*ir_mode;
pub extern fn set_value(pos: i32, value: ?*ir_node) void;
pub extern fn set_r_value(irg: ?*ir_graph, pos: i32, value: ?*ir_node) void;
pub extern fn get_store() ?*ir_node;
pub extern fn get_r_store(irg: ?*ir_graph) ?*ir_node;
pub extern fn set_store(store: ?*ir_node) void;
pub extern fn set_r_store(irg: ?*ir_graph, store: ?*ir_node) void;
pub extern fn keep_alive(ka: ?*ir_node) void;
pub extern fn irg_finalize_cons(irg: ?*ir_graph) void;
pub extern fn verify_new_node(node: ?*ir_node) void;
pub extern fn ir_set_uninitialized_local_variable_func(func: ?uninitialized_local_variable_func_t) void;
pub extern fn construct_confirms(irg: ?*ir_graph) void;
pub extern fn construct_confirms_only(irg: ?*ir_graph) void;
pub extern fn remove_confirms(irg: ?*ir_graph) void;
pub extern fn get_Block_idom(block: ?*const ir_node) ?*ir_node;
pub extern fn get_Block_ipostdom(block: ?*const ir_node) ?*ir_node;
pub extern fn get_Block_dom_depth(bl: ?*const ir_node) i32;
pub extern fn get_Block_postdom_depth(bl: ?*const ir_node) i32;
pub extern fn block_dominates(a: ?*const ir_node, b: ?*const ir_node) i32;
pub extern fn block_postdominates(a: ?*const ir_node, b: ?*const ir_node) i32;
pub extern fn block_strictly_postdominates(a: ?*const ir_node, b: ?*const ir_node) i32;
pub extern fn get_Block_dominated_first(block: ?*const ir_node) ?*ir_node;
pub extern fn get_Block_postdominated_first(bl: ?*const ir_node) ?*ir_node;
pub extern fn get_Block_dominated_next(node: ?*const ir_node) ?*ir_node;
pub extern fn get_Block_postdominated_next(node: ?*const ir_node) ?*ir_node;
pub extern fn ir_deepest_common_dominator(block0: ?*ir_node, block1: ?*ir_node) ?*ir_node;
pub extern fn dom_tree_walk(n: ?*ir_node, pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void;
pub extern fn postdom_tree_walk(n: ?*ir_node, pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void;
pub extern fn dom_tree_walk_irg(irg: ?*ir_graph, pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void;
pub extern fn postdom_tree_walk_irg(irg: ?*ir_graph, pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void;
pub extern fn compute_doms(irg: ?*ir_graph) void;
pub extern fn compute_postdoms(irg: ?*ir_graph) void;
pub extern fn ir_compute_dominance_frontiers(irg: ?*ir_graph) void;
pub extern fn ir_get_dominance_frontier(block: ?*const ir_node) [*]?*ir_node;
pub extern fn dump_ir_graph(graph: ?*ir_graph, suffix: [*]const u8) void;
pub extern fn dump_ir_prog_ext(func: ir_prog_dump_func, suffix: [*]const u8) void;
pub extern fn dump_ir_graph_ext(func: ir_graph_dump_func, graph: ?*ir_graph, suffix: [*]const u8) void;
pub extern fn dump_all_ir_graphs(suffix: [*]const u8) void;
pub extern fn ir_set_dump_path(path: [*]const u8) void;
pub extern fn ir_set_dump_filter(name: [*]const u8) void;
pub extern fn ir_get_dump_filter() [*]const u8;
pub extern fn dump_ir_graph_file(out: *std.c.FILE, graph: ?*ir_graph) void;
pub extern fn dump_cfg(out: *std.c.FILE, graph: ?*ir_graph) void;
pub extern fn dump_callgraph(out: *std.c.FILE) void;
pub extern fn dump_typegraph(out: *std.c.FILE) void;
pub extern fn dump_class_hierarchy(out: *std.c.FILE) void;
pub extern fn dump_loop_tree(out: *std.c.FILE, graph: ?*ir_graph) void;
pub extern fn dump_callgraph_loop_tree(out: *std.c.FILE) void;
pub extern fn dump_types_as_text(out: *std.c.FILE) void;
pub extern fn dump_globals_as_text(out: *std.c.FILE) void;
pub extern fn dump_loop(out: *std.c.FILE, loop: ?*ir_loop) void;
pub extern fn dump_graph_as_text(out: *std.c.FILE, graph: ?*const ir_graph) void;
pub extern fn dump_entity_to_file(out: *std.c.FILE, entity: ?*const ir_entity) void;
pub extern fn dump_type_to_file(out: *std.c.FILE, @"type": ?*const ir_type) void;
pub extern fn ir_set_dump_verbosity(verbosity: ir_dump_verbosity_t) void;
pub extern fn ir_get_dump_verbosity() ir_dump_verbosity_t;
pub extern fn ir_set_dump_flags(flags: ir_dump_flags_t) void;
pub extern fn ir_add_dump_flags(flags: ir_dump_flags_t) void;
pub extern fn ir_remove_dump_flags(flags: ir_dump_flags_t) void;
pub extern fn ir_get_dump_flags() ir_dump_flags_t;
pub extern fn set_dump_node_vcgattr_hook(hook: dump_node_vcgattr_func) void;
pub extern fn set_dump_edge_vcgattr_hook(hook: dump_edge_vcgattr_func) void;
pub extern fn set_dump_node_edge_hook(func: dump_node_edge_func) void;
pub extern fn get_dump_node_edge_hook() dump_node_edge_func;
pub extern fn set_dump_block_edge_hook(func: dump_node_edge_func) void;
pub extern fn get_dump_block_edge_hook() dump_node_edge_func;
pub extern fn dump_add_node_info_callback(cb: ?dump_node_info_cb_t, data: ?*anyopaque) ?*hook_entry_t;
pub extern fn dump_remove_node_info_callback(handle: ?*hook_entry_t) void;
pub extern fn dump_vcg_header(out: *std.c.FILE, name: [*]const u8, layout: [*]const u8, orientation: [*]const u8) void;
pub extern fn dump_vcg_footer(out: *std.c.FILE) void;
pub extern fn dump_node(out: *std.c.FILE, node: ?*const ir_node) void;
pub extern fn dump_ir_data_edges(out: *std.c.FILE, node: ?*const ir_node) void;
pub extern fn print_nodeid(out: *std.c.FILE, node: ?*const ir_node) void;
pub extern fn dump_begin_block_subgraph(out: *std.c.FILE, block: ?*const ir_node) void;
pub extern fn dump_end_block_subgraph(out: *std.c.FILE, block: ?*const ir_node) void;
pub extern fn dump_block_edges(out: *std.c.FILE, block: ?*const ir_node) void;
pub extern fn dump_blocks_as_subgraphs(out: *std.c.FILE, irg: ?*ir_graph) void;
pub extern fn get_irn_out_edge_first_kind(irn: ?*const ir_node, kind: ir_edge_kind_t) ?*const ir_edge_t;
pub extern fn get_irn_out_edge_first(irn: ?*const ir_node) ?*const ir_edge_t;
pub extern fn get_block_succ_first(block: ?*const ir_node) ?*const ir_edge_t;
pub extern fn get_irn_out_edge_next(irn: ?*const ir_node, last: ?*const ir_edge_t, kind: ir_edge_kind_t) ?*const ir_edge_t;
pub extern fn get_edge_src_irn(edge: ?*const ir_edge_t) ?*ir_node;
pub extern fn get_edge_src_pos(edge: ?*const ir_edge_t) i32;
pub extern fn get_irn_n_edges_kind(irn: ?*const ir_node, kind: ir_edge_kind_t) i32;
pub extern fn get_irn_n_edges(irn: ?*const ir_node) i32;
pub extern fn edges_activated_kind(irg: ?*const ir_graph, kind: ir_edge_kind_t) i32;
pub extern fn edges_activated(irg: ?*const ir_graph) i32;
pub extern fn edges_activate_kind(irg: ?*ir_graph, kind: ir_edge_kind_t) void;
pub extern fn edges_deactivate_kind(irg: ?*ir_graph, kind: ir_edge_kind_t) void;
pub extern fn edges_reroute_kind(old: ?*ir_node, nw: ?*ir_node, kind: ir_edge_kind_t) void;
pub extern fn edges_reroute(old: ?*ir_node, nw: ?*ir_node) void;
pub extern fn edges_reroute_except(old: ?*ir_node, nw: ?*ir_node, exception: ?*ir_node) void;
pub extern fn edges_verify(irg: ?*ir_graph) i32;
pub extern fn edges_verify_kind(irg: ?*ir_graph, kind: ir_edge_kind_t) i32;
pub extern fn edges_init_dbg(do_dbg: i32) void;
pub extern fn edges_activate(irg: ?*ir_graph) void;
pub extern fn edges_deactivate(irg: ?*ir_graph) void;
pub extern fn assure_edges(irg: ?*ir_graph) void;
pub extern fn assure_edges_kind(irg: ?*ir_graph, kind: ir_edge_kind_t) void;
pub extern fn irg_block_edges_walk(block: ?*ir_node, pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void;
pub extern fn irg_walk_edges(start: ?*ir_node, pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void;
pub extern fn set_optimize(value: i32) void;
pub extern fn get_optimize() i32;
pub extern fn set_opt_constant_folding(value: i32) void;
pub extern fn get_opt_constant_folding() i32;
pub extern fn set_opt_algebraic_simplification(value: i32) void;
pub extern fn get_opt_algebraic_simplification() i32;
pub extern fn set_opt_cse(value: i32) void;
pub extern fn get_opt_cse() i32;
pub extern fn set_opt_global_cse(value: i32) void;
pub extern fn get_opt_global_cse() i32;
pub extern fn set_opt_global_null_ptr_elimination(value: i32) void;
pub extern fn get_opt_global_null_ptr_elimination() i32;
pub extern fn save_optimization_state(state: [*]optimization_state_t) void;
pub extern fn restore_optimization_state(state: [*]const optimization_state_t) void;
pub extern fn all_optimizations_off() void;
pub extern fn exchange(old: ?*ir_node, nw: ?*ir_node) void;
pub extern fn turn_into_tuple(node: ?*ir_node, arity: i32, in: [*]const ?*ir_node) void;
pub extern fn collect_phiprojs_and_start_block_nodes(irg: ?*ir_graph) void;
pub extern fn collect_new_start_block_node(node: ?*ir_node) void;
pub extern fn collect_new_phi_node(node: ?*ir_node) void;
pub extern fn part_block(node: ?*ir_node) void;
pub extern fn part_block_edges(node: ?*ir_node) ?*ir_node;
pub extern fn kill_node(node: ?*ir_node) void;
pub extern fn duplicate_subgraph(dbg: ?*dbg_info, n: ?*ir_node, to_block: ?*ir_node) ?*ir_node;
pub extern fn local_optimize_node(n: ?*ir_node) void;
pub extern fn optimize_node(n: ?*ir_node) ?*ir_node;
pub extern fn local_optimize_graph(irg: ?*ir_graph) void;
pub extern fn optimize_graph_df(irg: ?*ir_graph) void;
pub extern fn local_opts_const_code() void;
pub extern fn remove_unreachable_code(irg: ?*ir_graph) void;
pub extern fn remove_bads(irg: ?*ir_graph) void;
pub extern fn remove_tuples(irg: ?*ir_graph) void;
pub extern fn remove_critical_cf_edges(irg: ?*ir_graph) void;
pub extern fn remove_critical_cf_edges_ex(irg: ?*ir_graph, ignore_exception_edges: i32) void;
pub extern fn new_ir_graph(ent: ?*ir_entity, n_loc: i32) ?*ir_graph;
pub extern fn free_ir_graph(irg: ?*ir_graph) void;
pub extern fn get_irg_entity(irg: ?*const ir_graph) ?*ir_entity;
pub extern fn set_irg_entity(irg: ?*ir_graph, ent: ?*ir_entity) void;
pub extern fn get_irg_frame_type(irg: ?*ir_graph) ?*ir_type;
pub extern fn set_irg_frame_type(irg: ?*ir_graph, ftp: ?*ir_type) void;
pub extern fn get_irg_start_block(irg: ?*const ir_graph) ?*ir_node;
pub extern fn set_irg_start_block(irg: ?*ir_graph, node: ?*ir_node) void;
pub extern fn get_irg_start(irg: ?*const ir_graph) ?*ir_node;
pub extern fn set_irg_start(irg: ?*ir_graph, node: ?*ir_node) void;
pub extern fn get_irg_end_block(irg: ?*const ir_graph) ?*ir_node;
pub extern fn set_irg_end_block(irg: ?*ir_graph, node: ?*ir_node) void;
pub extern fn get_irg_end(irg: ?*const ir_graph) ?*ir_node;
pub extern fn set_irg_end(irg: ?*ir_graph, node: ?*ir_node) void;
pub extern fn get_irg_frame(irg: ?*const ir_graph) ?*ir_node;
pub extern fn set_irg_frame(irg: ?*ir_graph, node: ?*ir_node) void;
pub extern fn get_irg_initial_mem(irg: ?*const ir_graph) ?*ir_node;
pub extern fn set_irg_initial_mem(irg: ?*ir_graph, node: ?*ir_node) void;
pub extern fn get_irg_args(irg: ?*const ir_graph) ?*ir_node;
pub extern fn set_irg_args(irg: ?*ir_graph, node: ?*ir_node) void;
pub extern fn get_irg_no_mem(irg: ?*const ir_graph) ?*ir_node;
pub extern fn set_irg_no_mem(irg: ?*ir_graph, node: ?*ir_node) void;
pub extern fn get_irg_n_locs(irg: ?*ir_graph) i32;
pub extern fn get_irg_graph_nr(irg: ?*const ir_graph) i64;
pub extern fn get_irg_idx(irg: ?*const ir_graph) usize;
pub extern fn get_idx_irn(irg: ?*const ir_graph, idx: u32) ?*ir_node;
pub extern fn get_irg_pinned(irg: ?*const ir_graph) op_pin_state;
pub extern fn get_irg_callee_info_state(irg: ?*const ir_graph) irg_callee_info_state;
pub extern fn set_irg_callee_info_state(irg: ?*ir_graph, s: irg_callee_info_state) void;
pub extern fn set_irg_link(irg: ?*ir_graph, thing: ?*anyopaque) void;
pub extern fn get_irg_link(irg: ?*const ir_graph) ?*anyopaque;
pub extern fn inc_irg_visited(irg: ?*ir_graph) void;
pub extern fn get_irg_visited(irg: ?*const ir_graph) ir_visited_t;
pub extern fn set_irg_visited(irg: ?*ir_graph, i: ir_visited_t) void;
pub extern fn get_max_irg_visited() ir_visited_t;
pub extern fn set_max_irg_visited(val: i32) void;
pub extern fn inc_max_irg_visited() ir_visited_t;
pub extern fn inc_irg_block_visited(irg: ?*ir_graph) void;
pub extern fn get_irg_block_visited(irg: ?*const ir_graph) ir_visited_t;
pub extern fn set_irg_block_visited(irg: ?*ir_graph, i: ir_visited_t) void;
pub extern fn ir_reserve_resources(irg: ?*ir_graph, resources: ir_resources_t) void;
pub extern fn ir_free_resources(irg: ?*ir_graph, resources: ir_resources_t) void;
pub extern fn ir_resources_reserved(irg: ?*const ir_graph) ir_resources_t;
pub extern fn add_irg_constraints(irg: ?*ir_graph, constraints: ir_graph_constraints_t) void;
pub extern fn clear_irg_constraints(irg: ?*ir_graph, constraints: ir_graph_constraints_t) void;
pub extern fn irg_is_constrained(irg: ?*const ir_graph, constraints: ir_graph_constraints_t) i32;
pub extern fn add_irg_properties(irg: ?*ir_graph, props: ir_graph_properties_t) void;
pub extern fn clear_irg_properties(irg: ?*ir_graph, props: ir_graph_properties_t) void;
pub extern fn irg_has_properties(irg: ?*const ir_graph, props: ir_graph_properties_t) i32;
pub extern fn assure_irg_properties(irg: ?*ir_graph, props: ir_graph_properties_t) void;
pub extern fn confirm_irg_properties(irg: ?*ir_graph, props: ir_graph_properties_t) void;
pub extern fn set_irg_loc_description(irg: ?*ir_graph, n: i32, description: ?*anyopaque) void;
pub extern fn get_irg_loc_description(irg: ?*ir_graph, n: i32) ?*anyopaque;
pub extern fn get_irg_last_idx(irg: ?*const ir_graph) u32;
pub extern fn irg_walk(node: ?*ir_node, pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void;
pub extern fn irg_walk_core(node: ?*ir_node, pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void;
pub extern fn irg_walk_graph(irg: ?*ir_graph, pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void;
pub extern fn irg_walk_in_or_dep(node: ?*ir_node, pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void;
pub extern fn irg_walk_in_or_dep_graph(irg: ?*ir_graph, pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void;
pub extern fn irg_walk_topological(irg: ?*ir_graph, walker: ?irg_walk_func, env: ?*anyopaque) void;
pub extern fn all_irg_walk(pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void;
pub extern fn irg_block_walk(node: ?*ir_node, pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void;
pub extern fn irg_block_walk_graph(irg: ?*ir_graph, pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void;
pub extern fn walk_const_code(pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void;
pub extern fn irg_walk_blkwise_graph(irg: ?*ir_graph, pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void;
pub extern fn irg_walk_blkwise_dom_top_down(irg: ?*ir_graph, pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void;
pub extern fn irg_walk_anchors(irg: ?*ir_graph, pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void;
pub extern fn irg_walk_2(node: ?*ir_node, pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void;
pub extern fn ir_export(filename: [*]const u8) i32;
pub extern fn ir_export_file(output: *std.c.FILE) void;
pub extern fn ir_import(filename: [*]const u8) i32;
pub extern fn ir_import_file(input: *std.c.FILE, inputname: [*]const u8) i32;
pub extern fn is_backedge(n: ?*const ir_node, pos: i32) i32;
pub extern fn set_backedge(n: ?*ir_node, pos: i32) void;
pub extern fn has_backedges(n: ?*const ir_node) i32;
pub extern fn clear_backedges(n: ?*ir_node) void;
pub extern fn set_irg_loop(irg: ?*ir_graph, l: ?*ir_loop) void;
pub extern fn get_irg_loop(irg: ?*const ir_graph) ?*ir_loop;
pub extern fn get_irn_loop(n: ?*const ir_node) ?*ir_loop;
pub extern fn get_loop_outer_loop(loop: ?*const ir_loop) ?*ir_loop;
pub extern fn get_loop_depth(loop: ?*const ir_loop) u32;
pub extern fn get_loop_n_elements(loop: ?*const ir_loop) usize;
pub extern fn get_loop_element(loop: ?*const ir_loop, pos: usize) loop_element;
pub extern fn get_loop_loop_nr(loop: ?*const ir_loop) i64;
pub extern fn set_loop_link(loop: ?*ir_loop, link: ?*anyopaque) void;
pub extern fn get_loop_link(loop: ?*const ir_loop) ?*anyopaque;
pub extern fn construct_cf_backedges(irg: ?*ir_graph) void;
pub extern fn assure_loopinfo(irg: ?*ir_graph) void;
pub extern fn free_loop_information(irg: ?*ir_graph) void;
pub extern fn is_loop_invariant(n: ?*const ir_node, block: ?*const ir_node) i32;
pub extern fn get_ir_alias_relation_name(rel: ir_alias_relation) [*]const u8;
pub extern fn get_alias_relation(addr1: ?*const ir_node, type1: ?*const ir_type, size1: u32, addr2: ?*const ir_node, type2: ?*const ir_type, size2: u32) ir_alias_relation;
pub extern fn assure_irg_entity_usage_computed(irg: ?*ir_graph) void;
pub extern fn get_irp_globals_entity_usage_state() ir_entity_usage_computed_state;
pub extern fn set_irp_globals_entity_usage_state(state: ir_entity_usage_computed_state) void;
pub extern fn assure_irp_globals_entity_usage_computed() void;
pub extern fn get_irg_memory_disambiguator_options(irg: ?*const ir_graph) ir_disambiguator_options;
pub extern fn set_irg_memory_disambiguator_options(irg: ?*ir_graph, options: ir_disambiguator_options) void;
pub extern fn set_irp_memory_disambiguator_options(options: ir_disambiguator_options) void;
pub extern fn mark_private_methods() void;
pub extern fn computed_value(n: ?*const ir_node) ?*ir_tarval;
pub extern fn optimize_in_place(n: ?*ir_node) ?*ir_node;
pub extern fn ir_is_negated_value(a: ?*const ir_node, b: ?*const ir_node) i32;
pub extern fn ir_get_possible_cmp_relations(left: ?*const ir_node, right: ?*const ir_node) ir_relation;
pub extern fn ir_allow_imprecise_float_transforms(enable: i32) void;
pub extern fn ir_imprecise_float_transforms_allowed() i32;
pub extern fn get_irn_n_outs(node: ?*const ir_node) u32;
pub extern fn get_irn_out(def: ?*const ir_node, pos: u32) ?*ir_node;
pub extern fn get_irn_out_ex(def: ?*const ir_node, pos: u32, in_pos: [*]i32) ?*ir_node;
pub extern fn get_Block_n_cfg_outs(node: ?*const ir_node) u32;
pub extern fn get_Block_n_cfg_outs_ka(node: ?*const ir_node) u32;
pub extern fn get_Block_cfg_out(node: ?*const ir_node, pos: u32) ?*ir_node;
pub extern fn get_Block_cfg_out_ex(node: ?*const ir_node, pos: u32, in_pos: [*]i32) ?*ir_node;
pub extern fn get_Block_cfg_out_ka(node: ?*const ir_node, pos: u32) ?*ir_node;
pub extern fn irg_out_walk(node: ?*ir_node, pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void;
pub extern fn irg_out_block_walk(node: ?*ir_node, pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void;
pub extern fn compute_irg_outs(irg: ?*ir_graph) void;
pub extern fn assure_irg_outs(irg: ?*ir_graph) void;
pub extern fn free_irg_outs(irg: ?*ir_graph) void;
pub extern fn irp_reserve_resources(irp: ?*ir_prog, resources: irp_resources_t) void;
pub extern fn irp_free_resources(irp: ?*ir_prog, resources: irp_resources_t) void;
pub extern fn irp_resources_reserved(irp: ?*const ir_prog) irp_resources_t;
pub extern fn get_irp() ?*ir_prog;
pub extern fn set_irp(irp: ?*ir_prog) void;
pub extern fn new_ir_prog(name: [*]const u8) ?*ir_prog;
pub extern fn free_ir_prog() void;
pub extern fn set_irp_prog_name(name: [*]const u8) void;
pub extern fn irp_prog_name_is_set() i32;
pub extern fn get_irp_ident() [*]const u8;
pub extern fn get_irp_name() [*]const u8;
pub extern fn get_irp_main_irg() ?*ir_graph;
pub extern fn set_irp_main_irg(main_irg: ?*ir_graph) void;
pub extern fn get_irp_last_idx() usize;
pub extern fn get_irp_n_irgs() usize;
pub extern fn get_irp_irg(pos: usize) ?*ir_graph;
pub extern fn set_irp_irg(pos: usize, irg: ?*ir_graph) void;
pub extern fn get_segment_type(segment: ir_segment_t) ?*ir_type;
pub extern fn set_segment_type(segment: ir_segment_t, new_type: ?*ir_type) void;
pub extern fn get_glob_type() ?*ir_type;
pub extern fn get_tls_type() ?*ir_type;
pub extern fn ir_get_global(name: [*]const u8) ?*ir_entity;
pub extern fn get_irp_n_types() usize;
pub extern fn get_irp_type(pos: usize) ?*ir_type;
pub extern fn set_irp_type(pos: usize, typ: ?*ir_type) void;
pub extern fn get_const_code_irg() ?*ir_graph;
pub extern fn get_irp_callee_info_state() irg_callee_info_state;
pub extern fn set_irp_callee_info_state(s: irg_callee_info_state) void;
pub extern fn get_irp_next_label_nr() ir_label_t;
pub extern fn add_irp_asm(asm_string: [*]const u8) void;
pub extern fn get_irp_n_asms() usize;
pub extern fn get_irp_asm(pos: usize) [*]const u8;
pub extern fn irn_verify(node: ?*const ir_node) i32;
pub extern fn irg_verify(irg: ?*ir_graph) i32;
pub extern fn irg_assert_verify(irg: ?*ir_graph) void;
pub extern fn lower_CopyB(irg: ?*ir_graph, max_small_size: u32, min_large_size: u32, allow_misalignments: i32) void;
pub extern fn lower_switch(irg: ?*ir_graph, small_switch: u32, spare_size: u32, selector_mode: ?*ir_mode) void;
pub extern fn lower_highlevel_graph(irg: ?*ir_graph) void;
pub extern fn lower_highlevel() void;
pub extern fn lower_const_code() void;
pub extern fn lower_mux(irg: ?*ir_graph, cb_func: ?lower_mux_callback) void;
pub extern fn ir_create_intrinsics_map(list: [*]i_record, length: usize, part_block_used: i32) ?*ir_intrinsics_map;
pub extern fn ir_free_intrinsics_map(map: ?*ir_intrinsics_map) void;
pub extern fn ir_lower_intrinsics(irg: ?*ir_graph, map: ?*ir_intrinsics_map) void;
pub extern fn i_mapper_abs(call: ?*ir_node) i32;
pub extern fn i_mapper_sqrt(call: ?*ir_node) i32;
pub extern fn i_mapper_cbrt(call: ?*ir_node) i32;
pub extern fn i_mapper_pow(call: ?*ir_node) i32;
pub extern fn i_mapper_exp(call: ?*ir_node) i32;
pub extern fn i_mapper_exp2(call: ?*ir_node) i32;
pub extern fn i_mapper_exp10(call: ?*ir_node) i32;
pub extern fn i_mapper_log(call: ?*ir_node) i32;
pub extern fn i_mapper_log2(call: ?*ir_node) i32;
pub extern fn i_mapper_log10(call: ?*ir_node) i32;
pub extern fn i_mapper_sin(call: ?*ir_node) i32;
pub extern fn i_mapper_cos(call: ?*ir_node) i32;
pub extern fn i_mapper_tan(call: ?*ir_node) i32;
pub extern fn i_mapper_asin(call: ?*ir_node) i32;
pub extern fn i_mapper_acos(call: ?*ir_node) i32;
pub extern fn i_mapper_atan(call: ?*ir_node) i32;
pub extern fn i_mapper_sinh(call: ?*ir_node) i32;
pub extern fn i_mapper_cosh(call: ?*ir_node) i32;
pub extern fn i_mapper_tanh(call: ?*ir_node) i32;
pub extern fn i_mapper_strcmp(call: ?*ir_node) i32;
pub extern fn i_mapper_strncmp(call: ?*ir_node) i32;
pub extern fn i_mapper_strcpy(call: ?*ir_node) i32;
pub extern fn i_mapper_strlen(call: ?*ir_node) i32;
pub extern fn i_mapper_memcpy(call: ?*ir_node) i32;
pub extern fn i_mapper_memmove(call: ?*ir_node) i32;
pub extern fn i_mapper_memset(call: ?*ir_node) i32;
pub extern fn i_mapper_memcmp(call: ?*ir_node) i32;
pub extern fn ir_target_set(target_triple: [*]const u8) i32;
pub extern fn ir_target_set_triple(machine: ?*const ir_machine_triple_t) i32;
pub extern fn ir_target_option(option: [*]const u8) i32;
pub extern fn ir_target_init() void;
pub extern fn ir_target_experimental() [*]const u8;
pub extern fn ir_target_big_endian() i32;
pub extern fn ir_target_biggest_alignment() u32;
pub extern fn ir_target_pointer_size() u32;
pub extern fn ir_target_supports_pic() i32;
pub extern fn ir_target_fast_unaligned_memaccess() i32;
pub extern fn ir_target_float_arithmetic_mode() ?*ir_mode;
pub extern fn ir_target_float_int_overflow_style() float_int_conversion_overflow_style_t;
pub extern fn ir_platform_long_long_and_double_struct_align_override() u32;
pub extern fn ir_platform_pic_is_default() i32;
pub extern fn ir_platform_supports_thread_local_storage() i32;
pub extern fn ir_platform_define_value(define: ?*const ir_platform_define_t) [*]const u8;
pub extern fn ir_platform_wchar_type() ir_platform_type_t;
pub extern fn ir_platform_wchar_is_signed() i32;
pub extern fn ir_platform_intptr_type() ir_platform_type_t;
pub extern fn ir_platform_type_size(@"type": ir_platform_type_t) u32;
pub extern fn ir_platform_type_align(@"type": ir_platform_type_t) u32;
pub extern fn ir_platform_type_mode(@"type": ir_platform_type_t, is_signed: i32) ?*ir_mode;
pub extern fn ir_platform_va_list_type() ?*ir_type;
pub extern fn ir_platform_user_label_prefix() u8;
pub extern fn ir_platform_default_exe_name() [*]const u8;
pub extern fn ir_platform_mangle_global(name: [*]const u8) [*]const u8;
pub extern fn ir_platform_define_first() ?*const ir_platform_define_t;
pub extern fn ir_platform_define_next(define: ?*const ir_platform_define_t) ?*const ir_platform_define_t;
pub extern fn ir_platform_define_name(define: ?*const ir_platform_define_t) [*]const u8;
pub extern fn ir_parse_machine_triple(triple_string: [*]const u8) ?*ir_machine_triple_t;
pub extern fn ir_get_host_machine_triple() ?*ir_machine_triple_t;
pub extern fn ir_triple_get_cpu_type(triple: ?*const ir_machine_triple_t) [*]const u8;
pub extern fn ir_triple_get_manufacturer(triple: ?*const ir_machine_triple_t) [*]const u8;
pub extern fn ir_triple_get_operating_system(triple: ?*const ir_machine_triple_t) [*]const u8;
pub extern fn ir_triple_set_cpu_type(triple: ?*ir_machine_triple_t, cpu_type: [*]const u8) void;
pub extern fn ir_free_machine_triple(triple: ?*ir_machine_triple_t) void;
pub extern fn ir_timer_enter_high_priority() i32;
pub extern fn ir_timer_leave_high_priority() i32;
pub extern fn ir_timer_new() ?*ir_timer_t;
pub extern fn ir_timer_free(timer: ?*ir_timer_t) void;
pub extern fn ir_timer_start(timer: ?*ir_timer_t) void;
pub extern fn ir_timer_reset_and_start(timer: ?*ir_timer_t) void;
pub extern fn ir_timer_reset(timer: ?*ir_timer_t) void;
pub extern fn ir_timer_stop(timer: ?*ir_timer_t) void;
pub extern fn ir_timer_init_parent(timer: ?*ir_timer_t) void;
pub extern fn ir_timer_push(timer: ?*ir_timer_t) void;
pub extern fn ir_timer_pop(timer: ?*ir_timer_t) void;
pub extern fn ir_timer_elapsed_msec(timer: ?*const ir_timer_t) u64;
pub extern fn ir_timer_elapsed_usec(timer: ?*const ir_timer_t) u64;
pub extern fn ir_timer_elapsed_sec(timer: ?*const ir_timer_t) f64;
pub extern fn new_tarval_from_str(str: [*]const u8, len: usize, mode: ?*ir_mode) ?*ir_tarval;
pub extern fn new_integer_tarval_from_str(str: [*]const u8, len: usize, negative: i32, base: u8, mode: ?*ir_mode) ?*ir_tarval;
pub extern fn new_tarval_from_long(l: i64, mode: ?*ir_mode) ?*ir_tarval;
pub extern fn new_tarval_from_bytes(buf: [*]const u8, mode: ?*ir_mode) ?*ir_tarval;
pub extern fn new_tarval_nan(mode: ?*ir_mode, signaling: i32, payload: ?*const ir_tarval) ?*ir_tarval;
pub extern fn tarval_to_bytes(buffer: [*]u8, tv: ?*const ir_tarval) void;
pub extern fn get_tarval_long(tv: ?*const ir_tarval) i64;
pub extern fn tarval_is_long(tv: ?*const ir_tarval) i32;
pub extern fn new_tarval_from_double(d: f64, mode: ?*ir_mode) ?*ir_tarval;
pub extern fn new_tarval_from_long_double(d: f64, mode: ?*ir_mode) ?*ir_tarval;
pub extern fn get_tarval_double(tv: ?*const ir_tarval) f64;
pub extern fn get_tarval_long_double(tv: ?*const ir_tarval) f64;
pub extern fn tarval_is_double(tv: ?*const ir_tarval) i32;
pub extern fn get_tarval_mode(tv: ?*const ir_tarval) ?*ir_mode;
pub extern fn tarval_is_negative(tv: ?*const ir_tarval) i32;
pub extern fn tarval_is_null(tv: ?*const ir_tarval) i32;
pub extern fn tarval_is_one(tv: ?*const ir_tarval) i32;
pub extern fn tarval_is_all_one(tv: ?*const ir_tarval) i32;
pub extern fn tarval_is_constant(tv: ?*const ir_tarval) i32;
pub extern fn get_tarval_bad() ?*ir_tarval;
pub extern fn get_tarval_unknown() ?*ir_tarval;
pub extern fn get_tarval_b_false() ?*ir_tarval;
pub extern fn get_tarval_b_true() ?*ir_tarval;
pub extern fn tarval_set_wrap_on_overflow(wrap_on_overflow: i32) void;
pub extern fn tarval_get_wrap_on_overflow() i32;
pub extern fn tarval_cmp(a: ?*const ir_tarval, b: ?*const ir_tarval) ir_relation;
pub extern fn tarval_convert_to(src: ?*const ir_tarval, mode: ?*ir_mode) ?*ir_tarval;
pub extern fn tarval_bitcast(src: ?*const ir_tarval, mode: ?*ir_mode) ?*ir_tarval;
pub extern fn tarval_not(a: ?*const ir_tarval) ?*ir_tarval;
pub extern fn tarval_neg(a: ?*const ir_tarval) ?*ir_tarval;
pub extern fn tarval_add(a: ?*const ir_tarval, b: ?*const ir_tarval) ?*ir_tarval;
pub extern fn tarval_sub(a: ?*const ir_tarval, b: ?*const ir_tarval) ?*ir_tarval;
pub extern fn tarval_mul(a: ?*const ir_tarval, b: ?*const ir_tarval) ?*ir_tarval;
pub extern fn tarval_div(a: ?*const ir_tarval, b: ?*const ir_tarval) ?*ir_tarval;
pub extern fn tarval_mod(a: ?*const ir_tarval, b: ?*const ir_tarval) ?*ir_tarval;
pub extern fn tarval_divmod(a: ?*const ir_tarval, b: ?*const ir_tarval, mod_res: [*]?*ir_tarval) ?*ir_tarval;
pub extern fn tarval_abs(a: ?*const ir_tarval) ?*ir_tarval;
pub extern fn tarval_and(a: ?*const ir_tarval, b: ?*const ir_tarval) ?*ir_tarval;
pub extern fn tarval_andnot(a: ?*const ir_tarval, b: ?*const ir_tarval) ?*ir_tarval;
pub extern fn tarval_or(a: ?*const ir_tarval, b: ?*const ir_tarval) ?*ir_tarval;
pub extern fn tarval_ornot(a: ?*const ir_tarval, b: ?*const ir_tarval) ?*ir_tarval;
pub extern fn tarval_eor(a: ?*const ir_tarval, b: ?*const ir_tarval) ?*ir_tarval;
pub extern fn tarval_shl(a: ?*const ir_tarval, b: ?*const ir_tarval) ?*ir_tarval;
pub extern fn tarval_shl_unsigned(a: ?*const ir_tarval, b: u32) ?*ir_tarval;
pub extern fn tarval_shr(a: ?*const ir_tarval, b: ?*const ir_tarval) ?*ir_tarval;
pub extern fn tarval_shr_unsigned(a: ?*const ir_tarval, b: u32) ?*ir_tarval;
pub extern fn tarval_shrs(a: ?*const ir_tarval, b: ?*const ir_tarval) ?*ir_tarval;
pub extern fn tarval_shrs_unsigned(a: ?*const ir_tarval, b: u32) ?*ir_tarval;
pub extern fn get_tarval_sub_bits(tv: ?*const ir_tarval, byte_ofs: u32) u8;
pub extern fn get_tarval_popcount(tv: ?*const ir_tarval) i32;
pub extern fn get_tarval_lowest_bit(tv: ?*const ir_tarval) i32;
pub extern fn get_tarval_highest_bit(tv: ?*const ir_tarval) i32;
pub extern fn tarval_zero_mantissa(tv: ?*const ir_tarval) i32;
pub extern fn tarval_get_exponent(tv: ?*const ir_tarval) i32;
pub extern fn tarval_ieee754_can_conv_lossless(tv: ?*const ir_tarval, mode: ?*const ir_mode) i32;
pub extern fn tarval_ieee754_get_exact() u32;
pub extern fn tarval_is_nan(tv: ?*const ir_tarval) i32;
pub extern fn tarval_is_quiet_nan(tv: ?*const ir_tarval) i32;
pub extern fn tarval_is_signaling_nan(tv: ?*const ir_tarval) i32;
pub extern fn tarval_is_finite(tv: ?*const ir_tarval) i32;
pub extern fn set_vrp_data(irg: ?*ir_graph) void;
pub extern fn free_vrp_data(irg: ?*ir_graph) void;
pub extern fn vrp_cmp(left: ?*const ir_node, right: ?*const ir_node) ir_relation;
pub extern fn vrp_get_info(n: ?*const ir_node) [*]vrp_attr;
};
pub fn getEntityVisibility(entity: ?*const ir_entity) ir_visibility {
return @intToEnum(ir_visibility, low_level.get_entity_visibility(entity));
}
pub fn setEntityVisibility(entity: ?*ir_entity, visibility: ir_visibility) void {
return low_level.set_entity_visibility(entity, visibility);
}
pub fn entityIsExternallyVisible(entity: ?*const ir_entity) i32 {
return low_level.entity_is_externally_visible(entity);
}
pub fn entityHasDefinition(entity: ?*const ir_entity) i32 {
return low_level.entity_has_definition(entity);
}
pub fn newEntity(owner: ?*ir_type, name: [*]const u8, tp: ?*ir_type) ?*ir_entity {
return low_level.new_entity(owner, name, tp);
}
pub fn newGlobalEntity(segment: ?*ir_type, ld_name: [*]const u8, @"type": ?*ir_type, visibility: ir_visibility, linkage: u32) ?*ir_entity {
return low_level.new_global_entity(segment, ld_name, @"type", @enumToInt(visibility), linkage);
}
pub fn newParameterEntity(owner: ?*ir_type, pos: usize, @"type": ?*ir_type) ?*ir_entity {
return low_level.new_parameter_entity(owner, pos, @"type");
}
pub fn newAliasEntity(owner: ?*ir_type, name: [*]const u8, alias: ?*ir_entity, @"type": ?*ir_type, visibility: ir_visibility) ?*ir_entity {
return low_level.new_alias_entity(owner, name, alias, @"type", @enumToInt(visibility));
}
pub fn setEntityAlias(alias: ?*ir_entity, aliased: ?*ir_entity) void {
return low_level.set_entity_alias(alias, aliased);
}
pub fn getEntityAlias(alias: ?*const ir_entity) ?*ir_entity {
return low_level.get_entity_alias(alias);
}
pub fn checkEntity(ent: ?*const ir_entity) i32 {
return low_level.check_entity(ent);
}
pub fn cloneEntity(old: ?*const ir_entity, name: [*]const u8, owner: ?*ir_type) ?*ir_entity {
return low_level.clone_entity(old, name, owner);
}
pub fn freeEntity(ent: ?*ir_entity) void {
return low_level.free_entity(ent);
}
pub fn getEntityName(ent: ?*const ir_entity) [*]const u8 {
return low_level.get_entity_name(ent);
}
pub fn getEntityIdent(ent: ?*const ir_entity) [*]const u8 {
return low_level.get_entity_ident(ent);
}
pub fn setEntityIdent(ent: ?*ir_entity, id: [*]const u8) void {
return low_level.set_entity_ident(ent, id);
}
pub fn getEntityLdIdent(ent: ?*const ir_entity) [*]const u8 {
return low_level.get_entity_ld_ident(ent);
}
pub fn setEntityLdIdent(ent: ?*ir_entity, ld_ident: [*]const u8) void {
return low_level.set_entity_ld_ident(ent, ld_ident);
}
pub fn getEntityLdName(ent: ?*const ir_entity) [*]const u8 {
return low_level.get_entity_ld_name(ent);
}
pub fn entityHasLdIdent(entity: ?*const ir_entity) i32 {
return low_level.entity_has_ld_ident(entity);
}
pub fn getEntityOwner(ent: ?*const ir_entity) ?*ir_type {
return low_level.get_entity_owner(ent);
}
pub fn setEntityOwner(ent: ?*ir_entity, owner: ?*ir_type) void {
return low_level.set_entity_owner(ent, owner);
}
pub fn getEntityType(ent: ?*const ir_entity) ?*ir_type {
return low_level.get_entity_type(ent);
}
pub fn setEntityType(ent: ?*ir_entity, tp: ?*ir_type) void {
return low_level.set_entity_type(ent, tp);
}
pub fn getEntityLinkage(entity: ?*const ir_entity) ir_linkage {
return @intToEnum(ir_linkage, low_level.get_entity_linkage(entity));
}
pub fn setEntityLinkage(entity: ?*ir_entity, linkage: u32) void {
return low_level.set_entity_linkage(entity, linkage);
}
pub fn addEntityLinkage(entity: ?*ir_entity, linkage: u32) void {
return low_level.add_entity_linkage(entity, linkage);
}
pub fn removeEntityLinkage(entity: ?*ir_entity, linkage: u32) void {
return low_level.remove_entity_linkage(entity, linkage);
}
pub fn getEntityVolatility(ent: ?*const ir_entity) ir_volatility {
return @intToEnum(ir_volatility, low_level.get_entity_volatility(ent));
}
pub fn setEntityVolatility(ent: ?*ir_entity, vol: u32) void {
return low_level.set_entity_volatility(ent, vol);
}
pub fn getVolatilityName(@"var": u32) [*]const u8 {
return low_level.get_volatility_name(@"var");
}
pub fn getEntityAlignment(entity: ?*const ir_entity) u32 {
return low_level.get_entity_alignment(entity);
}
pub fn setEntityAlignment(entity: ?*ir_entity, alignment: u32) void {
return low_level.set_entity_alignment(entity, alignment);
}
pub fn getEntityAligned(ent: ?*const ir_entity) ir_align {
return @intToEnum(ir_align, low_level.get_entity_aligned(ent));
}
pub fn setEntityAligned(ent: ?*ir_entity, a: u32) void {
return low_level.set_entity_aligned(ent, a);
}
pub fn getAlignName(a: u32) [*]const u8 {
return low_level.get_align_name(a);
}
pub fn getEntityOffset(entity: ?*const ir_entity) i32 {
return low_level.get_entity_offset(entity);
}
pub fn setEntityOffset(entity: ?*ir_entity, offset: i32) void {
return low_level.set_entity_offset(entity, offset);
}
pub fn getEntityBitfieldOffset(entity: ?*const ir_entity) u32 {
return low_level.get_entity_bitfield_offset(entity);
}
pub fn setEntityBitfieldOffset(entity: ?*ir_entity, offset: u32) void {
return low_level.set_entity_bitfield_offset(entity, offset);
}
pub fn setEntityBitfieldSize(entity: ?*ir_entity, size: u32) void {
return low_level.set_entity_bitfield_size(entity, size);
}
pub fn getEntityBitfieldSize(entity: ?*const ir_entity) u32 {
return low_level.get_entity_bitfield_size(entity);
}
pub fn getEntityLink(ent: ?*const ir_entity) ?*anyopaque {
return low_level.get_entity_link(ent);
}
pub fn setEntityLink(ent: ?*ir_entity, l: ?*anyopaque) void {
return low_level.set_entity_link(ent, l);
}
pub fn getEntityIrg(ent: ?*const ir_entity) ?*ir_graph {
return low_level.get_entity_irg(ent);
}
pub fn getEntityLinktimeIrg(ent: ?*const ir_entity) ?*ir_graph {
return low_level.get_entity_linktime_irg(ent);
}
pub fn getEntityVtableNumber(ent: ?*const ir_entity) u32 {
return low_level.get_entity_vtable_number(ent);
}
pub fn setEntityVtableNumber(ent: ?*ir_entity, vtable_number: u32) void {
return low_level.set_entity_vtable_number(ent, vtable_number);
}
pub fn setEntityLabel(ent: ?*ir_entity, label: ir_label_t) void {
return low_level.set_entity_label(ent, label);
}
pub fn getEntityLabel(ent: ?*const ir_entity) ir_label_t {
return low_level.get_entity_label(ent);
}
pub fn getEntityUsage(ent: ?*const ir_entity) ir_entity_usage {
return @intToEnum(ir_entity_usage, low_level.get_entity_usage(ent));
}
pub fn setEntityUsage(ent: ?*ir_entity, flag: u32) void {
return low_level.set_entity_usage(ent, flag);
}
pub fn getEntityDbgInfo(ent: ?*const ir_entity) ?*dbg_info {
return low_level.get_entity_dbg_info(ent);
}
pub fn setEntityDbgInfo(ent: ?*ir_entity, db: ?*dbg_info) void {
return low_level.set_entity_dbg_info(ent, db);
}
pub fn isParameterEntity(entity: ?*const ir_entity) bool {
return low_level.is_parameter_entity(entity) == 1;
}
pub fn getEntityParameterNumber(entity: ?*const ir_entity) usize {
return low_level.get_entity_parameter_number(entity);
}
pub fn setEntityParameterNumber(entity: ?*ir_entity, n: usize) void {
return low_level.set_entity_parameter_number(entity, n);
}
pub fn getInitializerKind(initializer: ?*const ir_initializer_t) ir_initializer_kind_t {
return @intToEnum(ir_initializer_kind_t, low_level.get_initializer_kind(initializer));
}
pub fn getInitializerKindName(ini: u32) [*]const u8 {
return low_level.get_initializer_kind_name(ini);
}
pub fn getInitializerNull() ?*ir_initializer_t {
return low_level.get_initializer_null();
}
pub fn createInitializerConst(value: ?*ir_node) ?*ir_initializer_t {
return low_level.create_initializer_const(value);
}
pub fn createInitializerTarval(tv: ?*ir_tarval) ?*ir_initializer_t {
return low_level.create_initializer_tarval(tv);
}
pub fn getInitializerConstValue(initializer: ?*const ir_initializer_t) ?*ir_node {
return low_level.get_initializer_const_value(initializer);
}
pub fn getInitializerTarvalValue(initialzier: ?*const ir_initializer_t) ?*ir_tarval {
return low_level.get_initializer_tarval_value(initialzier);
}
pub fn createInitializerCompound(n_entries: usize) ?*ir_initializer_t {
return low_level.create_initializer_compound(n_entries);
}
pub fn getInitializerCompoundNEntries(initializer: ?*const ir_initializer_t) usize {
return low_level.get_initializer_compound_n_entries(initializer);
}
pub fn setInitializerCompoundValue(initializer: ?*ir_initializer_t, index: usize, value: ?*ir_initializer_t) void {
return low_level.set_initializer_compound_value(initializer, index, value);
}
pub fn getInitializerCompoundValue(initializer: ?*const ir_initializer_t, index: usize) ?*ir_initializer_t {
return low_level.get_initializer_compound_value(initializer, index);
}
pub fn setEntityInitializer(entity: ?*ir_entity, initializer: ?*ir_initializer_t) void {
return low_level.set_entity_initializer(entity, initializer);
}
pub fn getEntityInitializer(entity: ?*const ir_entity) ?*ir_initializer_t {
return low_level.get_entity_initializer(entity);
}
pub fn addEntityOverwrites(ent: ?*ir_entity, overwritten: ?*ir_entity) void {
return low_level.add_entity_overwrites(ent, overwritten);
}
pub fn getEntityNOverwrites(ent: ?*const ir_entity) usize {
return low_level.get_entity_n_overwrites(ent);
}
pub fn getEntityOverwritesIndex(ent: ?*const ir_entity, overwritten: ?*ir_entity) usize {
return low_level.get_entity_overwrites_index(ent, overwritten);
}
pub fn getEntityOverwrites(ent: ?*const ir_entity, pos: usize) ?*ir_entity {
return low_level.get_entity_overwrites(ent, pos);
}
pub fn setEntityOverwrites(ent: ?*ir_entity, pos: usize, overwritten: ?*ir_entity) void {
return low_level.set_entity_overwrites(ent, pos, overwritten);
}
pub fn removeEntityOverwrites(ent: ?*ir_entity, overwritten: ?*ir_entity) void {
return low_level.remove_entity_overwrites(ent, overwritten);
}
pub fn getEntityNOverwrittenby(ent: ?*const ir_entity) usize {
return low_level.get_entity_n_overwrittenby(ent);
}
pub fn getEntityOverwrittenbyIndex(ent: ?*const ir_entity, overwrites: ?*ir_entity) usize {
return low_level.get_entity_overwrittenby_index(ent, overwrites);
}
pub fn getEntityOverwrittenby(ent: ?*const ir_entity, pos: usize) ?*ir_entity {
return low_level.get_entity_overwrittenby(ent, pos);
}
pub fn setEntityOverwrittenby(ent: ?*ir_entity, pos: usize, overwrites: ?*ir_entity) void {
return low_level.set_entity_overwrittenby(ent, pos, overwrites);
}
pub fn removeEntityOverwrittenby(ent: ?*ir_entity, overwrites: ?*ir_entity) void {
return low_level.remove_entity_overwrittenby(ent, overwrites);
}
pub fn isCompoundEntity(ent: ?*const ir_entity) bool {
return low_level.is_compound_entity(ent) == 1;
}
pub fn isMethodEntity(ent: ?*const ir_entity) bool {
return low_level.is_method_entity(ent) == 1;
}
pub fn isAliasEntity(ent: ?*const ir_entity) bool {
return low_level.is_alias_entity(ent) == 1;
}
pub fn getEntityNr(ent: ?*const ir_entity) i64 {
return low_level.get_entity_nr(ent);
}
pub fn getEntityVisited(ent: ?*const ir_entity) ir_visited_t {
return low_level.get_entity_visited(ent);
}
pub fn setEntityVisited(ent: ?*ir_entity, num: ir_visited_t) void {
return low_level.set_entity_visited(ent, num);
}
pub fn markEntityVisited(ent: ?*ir_entity) void {
return low_level.mark_entity_visited(ent);
}
pub fn entityVisited(ent: ?*const ir_entity) i32 {
return low_level.entity_visited(ent);
}
pub fn entityNotVisited(ent: ?*const ir_entity) i32 {
return low_level.entity_not_visited(ent);
}
pub fn entityHasAdditionalProperties(entity: ?*const ir_entity) i32 {
return low_level.entity_has_additional_properties(entity);
}
pub fn getEntityAdditionalProperties(ent: ?*const ir_entity) mtp_additional_properties {
return @intToEnum(mtp_additional_properties, low_level.get_entity_additional_properties(ent));
}
pub fn setEntityAdditionalProperties(ent: ?*ir_entity, prop: u32) void {
return low_level.set_entity_additional_properties(ent, prop);
}
pub fn addEntityAdditionalProperties(ent: ?*ir_entity, flag: u32) void {
return low_level.add_entity_additional_properties(ent, flag);
}
pub fn getUnknownEntity() ?*ir_entity {
return low_level.get_unknown_entity();
}
pub fn isUnknownEntity(entity: ?*const ir_entity) bool {
return low_level.is_unknown_entity(entity) == 1;
}
pub fn getTypeOpcodeName(opcode: u32) [*]const u8 {
return low_level.get_type_opcode_name(opcode);
}
pub fn isSubclassOf(low: ?*const ir_type, high: ?*const ir_type) bool {
return low_level.is_SubClass_of(low, high) == 1;
}
pub fn isSubclassPtrOf(low: ?*ir_type, high: ?*ir_type) bool {
return low_level.is_SubClass_ptr_of(low, high) == 1;
}
pub fn isOverwrittenBy(high: ?*ir_entity, low: ?*ir_entity) bool {
return low_level.is_overwritten_by(high, low) == 1;
}
pub fn resolveEntPolymorphy(dynamic_class: ?*ir_type, static_ent: ?*ir_entity) ?*ir_entity {
return low_level.resolve_ent_polymorphy(dynamic_class, static_ent);
}
pub fn setIrpInhTransitiveClosureState(s: u32) void {
return low_level.set_irp_inh_transitive_closure_state(s);
}
pub fn invalidateIrpInhTransitiveClosureState() void {
return low_level.invalidate_irp_inh_transitive_closure_state();
}
pub fn getIrpInhTransitiveClosureState() inh_transitive_closure_state {
return @intToEnum(inh_transitive_closure_state, low_level.get_irp_inh_transitive_closure_state());
}
pub fn computeInhTransitiveClosure() void {
return low_level.compute_inh_transitive_closure();
}
pub fn freeInhTransitiveClosure() void {
return low_level.free_inh_transitive_closure();
}
pub fn getClassTransSubtypeFirst(tp: ?*const ir_type) ?*ir_type {
return low_level.get_class_trans_subtype_first(tp);
}
pub fn getClassTransSubtypeNext(tp: ?*const ir_type) ?*ir_type {
return low_level.get_class_trans_subtype_next(tp);
}
pub fn isClassTransSubtype(tp: ?*const ir_type, subtp: ?*const ir_type) bool {
return low_level.is_class_trans_subtype(tp, subtp) == 1;
}
pub fn getClassTransSupertypeFirst(tp: ?*const ir_type) ?*ir_type {
return low_level.get_class_trans_supertype_first(tp);
}
pub fn getClassTransSupertypeNext(tp: ?*const ir_type) ?*ir_type {
return low_level.get_class_trans_supertype_next(tp);
}
pub fn getEntityTransOverwrittenbyFirst(ent: ?*const ir_entity) ?*ir_entity {
return low_level.get_entity_trans_overwrittenby_first(ent);
}
pub fn getEntityTransOverwrittenbyNext(ent: ?*const ir_entity) ?*ir_entity {
return low_level.get_entity_trans_overwrittenby_next(ent);
}
pub fn getEntityTransOverwritesFirst(ent: ?*const ir_entity) ?*ir_entity {
return low_level.get_entity_trans_overwrites_first(ent);
}
pub fn getEntityTransOverwritesNext(ent: ?*const ir_entity) ?*ir_entity {
return low_level.get_entity_trans_overwrites_next(ent);
}
pub fn checkType(tp: ?*const ir_type) i32 {
return low_level.check_type(tp);
}
pub fn trVerify() i32 {
return low_level.tr_verify();
}
pub fn freeType(tp: ?*ir_type) void {
return low_level.free_type(tp);
}
pub fn getTypeOpcode(@"type": ?*const ir_type) tp_opcode {
return @intToEnum(tp_opcode, low_level.get_type_opcode(@"type"));
}
pub fn irPrintType(buffer: [*]u8, buffer_size: usize, tp: ?*const ir_type) void {
return low_level.ir_print_type(buffer, buffer_size, tp);
}
pub fn getTypeStateName(s: u32) [*]const u8 {
return low_level.get_type_state_name(s);
}
pub fn getTypeState(tp: ?*const ir_type) ir_type_state {
return @intToEnum(ir_type_state, low_level.get_type_state(tp));
}
pub fn setTypeState(tp: ?*ir_type, state: u32) void {
return low_level.set_type_state(tp, state);
}
pub fn getTypeMode(tp: ?*const ir_type) ?*ir_mode {
return low_level.get_type_mode(tp);
}
pub fn getTypeSize(tp: ?*const ir_type) u32 {
return low_level.get_type_size(tp);
}
pub fn setTypeSize(tp: ?*ir_type, size: u32) void {
return low_level.set_type_size(tp, size);
}
pub fn getTypeAlignment(tp: ?*const ir_type) u32 {
return low_level.get_type_alignment(tp);
}
pub fn setTypeAlignment(tp: ?*ir_type, @"align": u32) void {
return low_level.set_type_alignment(tp, @"align");
}
pub fn getTypeVisited(tp: ?*const ir_type) ir_visited_t {
return low_level.get_type_visited(tp);
}
pub fn setTypeVisited(tp: ?*ir_type, num: ir_visited_t) void {
return low_level.set_type_visited(tp, num);
}
pub fn markTypeVisited(tp: ?*ir_type) void {
return low_level.mark_type_visited(tp);
}
pub fn typeVisited(tp: ?*const ir_type) i32 {
return low_level.type_visited(tp);
}
pub fn getTypeLink(tp: ?*const ir_type) ?*anyopaque {
return low_level.get_type_link(tp);
}
pub fn setTypeLink(tp: ?*ir_type, l: ?*anyopaque) void {
return low_level.set_type_link(tp, l);
}
pub fn incMasterTypeVisited() void {
return low_level.inc_master_type_visited();
}
pub fn setMasterTypeVisited(val: ir_visited_t) void {
return low_level.set_master_type_visited(val);
}
pub fn getMasterTypeVisited() ir_visited_t {
return low_level.get_master_type_visited();
}
pub fn setTypeDbgInfo(tp: ?*ir_type, db: ?*type_dbg_info) void {
return low_level.set_type_dbg_info(tp, db);
}
pub fn getTypeDbgInfo(tp: ?*const ir_type) ?*type_dbg_info {
return low_level.get_type_dbg_info(tp);
}
pub fn getTypeNr(tp: ?*const ir_type) i64 {
return low_level.get_type_nr(tp);
}
pub fn newTypeClass(name: [*]const u8) ?*ir_type {
return low_level.new_type_class(name);
}
pub fn getClassNMembers(clss: ?*const ir_type) usize {
return low_level.get_class_n_members(clss);
}
pub fn getClassMember(clss: ?*const ir_type, pos: usize) ?*ir_entity {
return low_level.get_class_member(clss, pos);
}
pub fn getClassMemberIndex(clss: ?*const ir_type, mem: ?*const ir_entity) usize {
return low_level.get_class_member_index(clss, mem);
}
pub fn addClassSubtype(clss: ?*ir_type, subtype: ?*ir_type) void {
return low_level.add_class_subtype(clss, subtype);
}
pub fn getClassNSubtypes(clss: ?*const ir_type) usize {
return low_level.get_class_n_subtypes(clss);
}
pub fn getClassSubtype(clss: ?*const ir_type, pos: usize) ?*ir_type {
return low_level.get_class_subtype(clss, pos);
}
pub fn getClassSubtypeIndex(clss: ?*const ir_type, subclass: ?*const ir_type) usize {
return low_level.get_class_subtype_index(clss, subclass);
}
pub fn setClassSubtype(clss: ?*ir_type, subtype: ?*ir_type, pos: usize) void {
return low_level.set_class_subtype(clss, subtype, pos);
}
pub fn removeClassSubtype(clss: ?*ir_type, subtype: ?*ir_type) void {
return low_level.remove_class_subtype(clss, subtype);
}
pub fn addClassSupertype(clss: ?*ir_type, supertype: ?*ir_type) void {
return low_level.add_class_supertype(clss, supertype);
}
pub fn getClassNSupertypes(clss: ?*const ir_type) usize {
return low_level.get_class_n_supertypes(clss);
}
pub fn getClassSupertypeIndex(clss: ?*const ir_type, super_clss: ?*const ir_type) usize {
return low_level.get_class_supertype_index(clss, super_clss);
}
pub fn getClassSupertype(clss: ?*const ir_type, pos: usize) ?*ir_type {
return low_level.get_class_supertype(clss, pos);
}
pub fn setClassSupertype(clss: ?*ir_type, supertype: ?*ir_type, pos: usize) void {
return low_level.set_class_supertype(clss, supertype, pos);
}
pub fn removeClassSupertype(clss: ?*ir_type, supertype: ?*ir_type) void {
return low_level.remove_class_supertype(clss, supertype);
}
pub fn isClassType(clss: ?*const ir_type) bool {
return low_level.is_Class_type(clss) == 1;
}
pub fn newTypeStruct(name: [*]const u8) ?*ir_type {
return low_level.new_type_struct(name);
}
pub fn getStructNMembers(strct: ?*const ir_type) usize {
return low_level.get_struct_n_members(strct);
}
pub fn getStructMember(strct: ?*const ir_type, pos: usize) ?*ir_entity {
return low_level.get_struct_member(strct, pos);
}
pub fn getStructMemberIndex(strct: ?*const ir_type, member: ?*const ir_entity) usize {
return low_level.get_struct_member_index(strct, member);
}
pub fn isStructType(strct: ?*const ir_type) bool {
return low_level.is_Struct_type(strct) == 1;
}
pub fn newTypeUnion(name: [*]const u8) ?*ir_type {
return low_level.new_type_union(name);
}
pub fn getUnionNMembers(uni: ?*const ir_type) usize {
return low_level.get_union_n_members(uni);
}
pub fn getUnionMember(uni: ?*const ir_type, pos: usize) ?*ir_entity {
return low_level.get_union_member(uni, pos);
}
pub fn getUnionMemberIndex(uni: ?*const ir_type, member: ?*const ir_entity) usize {
return low_level.get_union_member_index(uni, member);
}
pub fn isUnionType(uni: ?*const ir_type) bool {
return low_level.is_Union_type(uni) == 1;
}
pub fn newTypeMethod(n_param: usize, n_res: usize, is_variadic: bool, cc_mask: calling_convention, property_mask: mtp_additional_properties) ?*ir_type {
switch (cc_mask) {
.calling_convention => return low_level.new_type_method(n_param, n_res, @boolToInt(is_variadic), @enumToInt(cc_mask.calling_convention), property_mask),
.calling_convention_special => return low_level.new_type_method(n_param, n_res, @boolToInt(is_variadic), @enumToInt(cc_mask.calling_convention_special), property_mask),
.value => return low_level.new_type_method(n_param, n_res, @boolToInt(is_variadic), cc_mask.value, property_mask),
}
}
pub fn getMethodNParams(method: ?*const ir_type) usize {
return low_level.get_method_n_params(method);
}
pub fn getMethodParamType(method: ?*const ir_type, pos: usize) ?*ir_type {
return low_level.get_method_param_type(method, pos);
}
pub fn setMethodParamType(method: ?*ir_type, pos: usize, tp: ?*ir_type) void {
return low_level.set_method_param_type(method, pos, tp);
}
pub fn getMethodNRess(method: ?*const ir_type) usize {
return low_level.get_method_n_ress(method);
}
pub fn getMethodResType(method: ?*const ir_type, pos: usize) ?*ir_type {
return low_level.get_method_res_type(method, pos);
}
pub fn setMethodResType(method: ?*ir_type, pos: usize, tp: ?*ir_type) void {
return low_level.set_method_res_type(method, pos, tp);
}
pub fn isMethodVariadic(method: ?*const ir_type) bool {
return low_level.is_method_variadic(method) == 1;
}
pub fn getMethodAdditionalProperties(method: ?*const ir_type) mtp_additional_properties {
return @intToEnum(mtp_additional_properties, low_level.get_method_additional_properties(method));
}
pub fn getMethodCallingConvention(method: ?*const ir_type) calling_convention {
return @intToEnum(calling_convention, low_level.get_method_calling_convention(method));
}
pub fn getMethodNRegparams(method: ?*ir_type) u32 {
return low_level.get_method_n_regparams(method);
}
pub fn isMethodType(method: ?*const ir_type) bool {
return low_level.is_Method_type(method) == 1;
}
pub fn newTypeArray(element_type: ?*ir_type, n_elements: u32) ?*ir_type {
return low_level.new_type_array(element_type, n_elements);
}
pub fn getArraySize(array: ?*const ir_type) u32 {
return low_level.get_array_size(array);
}
pub fn getArrayElementType(array: ?*const ir_type) ?*ir_type {
return low_level.get_array_element_type(array);
}
pub fn isArrayType(array: ?*const ir_type) bool {
return low_level.is_Array_type(array) == 1;
}
pub fn newTypePointer(points_to: ?*ir_type) ?*ir_type {
return low_level.new_type_pointer(points_to);
}
pub fn setPointerPointsToType(pointer: ?*ir_type, tp: ?*ir_type) void {
return low_level.set_pointer_points_to_type(pointer, tp);
}
pub fn getPointerPointsToType(pointer: ?*const ir_type) ?*ir_type {
return low_level.get_pointer_points_to_type(pointer);
}
pub fn isPointerType(pointer: ?*const ir_type) bool {
return low_level.is_Pointer_type(pointer) == 1;
}
pub fn newTypePrimitive(mode: ?*ir_mode) ?*ir_type {
return low_level.new_type_primitive(mode);
}
pub fn isPrimitiveType(primitive: ?*const ir_type) bool {
return low_level.is_Primitive_type(primitive) == 1;
}
pub fn getCodeType() ?*ir_type {
return low_level.get_code_type();
}
pub fn isCodeType(tp: ?*const ir_type) bool {
return low_level.is_code_type(tp) == 1;
}
pub fn getUnknownType() ?*ir_type {
return low_level.get_unknown_type();
}
pub fn isUnknownType(@"type": ?*const ir_type) bool {
return low_level.is_unknown_type(@"type") == 1;
}
pub fn isAtomicType(tp: ?*const ir_type) bool {
return low_level.is_atomic_type(tp) == 1;
}
pub fn getCompoundIdent(tp: ?*const ir_type) [*]const u8 {
return low_level.get_compound_ident(tp);
}
pub fn getCompoundName(tp: ?*const ir_type) [*]const u8 {
return low_level.get_compound_name(tp);
}
pub fn getCompoundNMembers(tp: ?*const ir_type) usize {
return low_level.get_compound_n_members(tp);
}
pub fn getCompoundMember(tp: ?*const ir_type, pos: usize) ?*ir_entity {
return low_level.get_compound_member(tp, pos);
}
pub fn getCompoundMemberIndex(tp: ?*const ir_type, member: ?*const ir_entity) usize {
return low_level.get_compound_member_index(tp, member);
}
pub fn removeCompoundMember(compound: ?*ir_type, entity: ?*ir_entity) void {
return low_level.remove_compound_member(compound, entity);
}
pub fn defaultLayoutCompoundType(tp: ?*ir_type) void {
return low_level.default_layout_compound_type(tp);
}
pub fn isCompoundType(tp: ?*const ir_type) bool {
return low_level.is_compound_type(tp) == 1;
}
pub fn newTypeFrame() ?*ir_type {
return low_level.new_type_frame();
}
pub fn isFrameType(tp: ?*const ir_type) bool {
return low_level.is_frame_type(tp) == 1;
}
pub fn cloneFrameType(@"type": ?*ir_type) ?*ir_type {
return low_level.clone_frame_type(@"type");
}
pub fn isSegmentType(tp: ?*const ir_type) bool {
return low_level.is_segment_type(tp) == 1;
}
pub fn typeWalk(pre: ?type_walk_func, post: ?type_walk_func, env: ?*anyopaque) void {
return low_level.type_walk(pre, post, env);
}
pub fn typeWalkIrg(irg: ?*ir_graph, pre: ?type_walk_func, post: ?type_walk_func, env: ?*anyopaque) void {
return low_level.type_walk_irg(irg, pre, post, env);
}
pub fn typeWalkSuper2sub(pre: ?type_walk_func, post: ?type_walk_func, env: ?*anyopaque) void {
return low_level.type_walk_super2sub(pre, post, env);
}
pub fn typeWalkSuper(pre: ?type_walk_func, post: ?type_walk_func, env: ?*anyopaque) void {
return low_level.type_walk_super(pre, post, env);
}
pub fn classWalkSuper2sub(pre: ?class_walk_func, post: ?class_walk_func, env: ?*anyopaque) void {
return low_level.class_walk_super2sub(pre, post, env);
}
pub fn walkTypesEntities(tp: ?*ir_type, doit: ?entity_walk_func, env: ?*anyopaque) void {
return low_level.walk_types_entities(tp, doit, env);
}
pub fn getMethodParamAccess(ent: ?*ir_entity, pos: usize) ptr_access_kind {
return @intToEnum(ptr_access_kind, low_level.get_method_param_access(ent, pos));
}
pub fn analyzeIrgArgs(irg: ?*ir_graph) void {
return low_level.analyze_irg_args(irg);
}
pub fn getMethodParamWeight(ent: ?*ir_entity, pos: usize) u32 {
return low_level.get_method_param_weight(ent, pos);
}
pub fn analyzeIrgArgsWeight(irg: ?*ir_graph) void {
return low_level.analyze_irg_args_weight(irg);
}
pub fn newIntMode(name: [*]const u8, bit_size: u32, sign: i32, modulo_shift: u32) ?*ir_mode {
return low_level.new_int_mode(name, bit_size, sign, modulo_shift);
}
pub fn newReferenceMode(name: [*]const u8, bit_size: u32, modulo_shift: u32) ?*ir_mode {
return low_level.new_reference_mode(name, bit_size, modulo_shift);
}
pub fn newFloatMode(name: [*]const u8, arithmetic: u32, exponent_size: u32, mantissa_size: u32, int_conv_overflow: u32) ?*ir_mode {
return low_level.new_float_mode(name, arithmetic, exponent_size, mantissa_size, int_conv_overflow);
}
pub fn newNonArithmeticMode(name: [*]const u8, bit_size: u32) ?*ir_mode {
return low_level.new_non_arithmetic_mode(name, bit_size);
}
pub fn getModeIdent(mode: ?*const ir_mode) [*]const u8 {
return low_level.get_mode_ident(mode);
}
pub fn getModeName(mode: ?*const ir_mode) [*]const u8 {
return low_level.get_mode_name(mode);
}
pub fn getModeSizeBits(mode: ?*const ir_mode) u32 {
return low_level.get_mode_size_bits(mode);
}
pub fn getModeSizeBytes(mode: ?*const ir_mode) u32 {
return low_level.get_mode_size_bytes(mode);
}
pub fn getModeArithmetic(mode: ?*const ir_mode) ir_mode_arithmetic {
return @intToEnum(ir_mode_arithmetic, low_level.get_mode_arithmetic(mode));
}
pub fn getModeModuloShift(mode: ?*const ir_mode) u32 {
return low_level.get_mode_modulo_shift(mode);
}
pub fn getModeMin(mode: ?*const ir_mode) ?*ir_tarval {
return low_level.get_mode_min(mode);
}
pub fn getModeMax(mode: ?*const ir_mode) ?*ir_tarval {
return low_level.get_mode_max(mode);
}
pub fn getModeNull(mode: ?*const ir_mode) ?*ir_tarval {
return low_level.get_mode_null(mode);
}
pub fn getModeOne(mode: ?*const ir_mode) ?*ir_tarval {
return low_level.get_mode_one(mode);
}
pub fn getModeAllOne(mode: ?*const ir_mode) ?*ir_tarval {
return low_level.get_mode_all_one(mode);
}
pub fn getModeInfinite(mode: ?*const ir_mode) ?*ir_tarval {
return low_level.get_mode_infinite(mode);
}
pub fn getModef() ?*ir_mode {
return low_level.get_modeF();
}
pub fn getModed() ?*ir_mode {
return low_level.get_modeD();
}
pub fn getModebs() ?*ir_mode {
return low_level.get_modeBs();
}
pub fn getModebu() ?*ir_mode {
return low_level.get_modeBu();
}
pub fn getModehs() ?*ir_mode {
return low_level.get_modeHs();
}
pub fn getModehu() ?*ir_mode {
return low_level.get_modeHu();
}
pub fn getModeis() ?*ir_mode {
return low_level.get_modeIs();
}
pub fn getModeiu() ?*ir_mode {
return low_level.get_modeIu();
}
pub fn getModels() ?*ir_mode {
return low_level.get_modeLs();
}
pub fn getModelu() ?*ir_mode {
return low_level.get_modeLu();
}
pub fn getModep() ?*ir_mode {
return low_level.get_modeP();
}
pub fn getModeb() ?*ir_mode {
return low_level.get_modeb();
}
pub fn getModex() ?*ir_mode {
return low_level.get_modeX();
}
pub fn getModebb() ?*ir_mode {
return low_level.get_modeBB();
}
pub fn getModem() ?*ir_mode {
return low_level.get_modeM();
}
pub fn getModet() ?*ir_mode {
return low_level.get_modeT();
}
pub fn getModeany() ?*ir_mode {
return low_level.get_modeANY();
}
pub fn getModebad() ?*ir_mode {
return low_level.get_modeBAD();
}
pub fn setModep(p: ?*ir_mode) void {
return low_level.set_modeP(p);
}
pub fn modeIsSigned(mode: ?*const ir_mode) i32 {
return low_level.mode_is_signed(mode);
}
pub fn modeIsFloat(mode: ?*const ir_mode) i32 {
return low_level.mode_is_float(mode);
}
pub fn modeIsInt(mode: ?*const ir_mode) i32 {
return low_level.mode_is_int(mode);
}
pub fn modeIsReference(mode: ?*const ir_mode) i32 {
return low_level.mode_is_reference(mode);
}
pub fn modeIsNum(mode: ?*const ir_mode) i32 {
return low_level.mode_is_num(mode);
}
pub fn modeIsData(mode: ?*const ir_mode) i32 {
return low_level.mode_is_data(mode);
}
pub fn smallerMode(sm: ?*const ir_mode, lm: ?*const ir_mode) i32 {
return low_level.smaller_mode(sm, lm);
}
pub fn valuesInMode(sm: ?*const ir_mode, lm: ?*const ir_mode) i32 {
return low_level.values_in_mode(sm, lm);
}
pub fn findUnsignedMode(mode: ?*const ir_mode) ?*ir_mode {
return low_level.find_unsigned_mode(mode);
}
pub fn findSignedMode(mode: ?*const ir_mode) ?*ir_mode {
return low_level.find_signed_mode(mode);
}
pub fn findDoubleBitsIntMode(mode: ?*const ir_mode) ?*ir_mode {
return low_level.find_double_bits_int_mode(mode);
}
pub fn modeHasSignedZero(mode: ?*const ir_mode) i32 {
return low_level.mode_has_signed_zero(mode);
}
pub fn modeOverflowOnUnaryMinus(mode: ?*const ir_mode) i32 {
return low_level.mode_overflow_on_unary_Minus(mode);
}
pub fn modeWrapAround(mode: ?*const ir_mode) i32 {
return low_level.mode_wrap_around(mode);
}
pub fn getReferenceOffsetMode(mode: ?*const ir_mode) ?*ir_mode {
return low_level.get_reference_offset_mode(mode);
}
pub fn setReferenceOffsetMode(ref_mode: ?*ir_mode, int_mode: ?*ir_mode) void {
return low_level.set_reference_offset_mode(ref_mode, int_mode);
}
pub fn getModeMantissaSize(mode: ?*const ir_mode) u32 {
return low_level.get_mode_mantissa_size(mode);
}
pub fn getModeExponentSize(mode: ?*const ir_mode) u32 {
return low_level.get_mode_exponent_size(mode);
}
pub fn getModeFloatIntOverflow(mode: ?*const ir_mode) float_int_conversion_overflow_style_t {
return @intToEnum(float_int_conversion_overflow_style_t, low_level.get_mode_float_int_overflow(mode));
}
pub fn isReinterpretCast(src: ?*const ir_mode, dst: ?*const ir_mode) bool {
return low_level.is_reinterpret_cast(src, dst) == 1;
}
pub fn getTypeForMode(mode: ?*const ir_mode) ?*ir_type {
return low_level.get_type_for_mode(mode);
}
pub fn irGetNModes() usize {
return low_level.ir_get_n_modes();
}
pub fn irGetMode(num: usize) ?*ir_mode {
return low_level.ir_get_mode(num);
}
pub fn optimizeCf(irg: ?*ir_graph) void {
return low_level.optimize_cf(irg);
}
pub fn optJumpthreading(irg: ?*ir_graph) void {
return low_level.opt_jumpthreading(irg);
}
pub fn optBool(irg: ?*ir_graph) void {
return low_level.opt_bool(irg);
}
pub fn convOpt(irg: ?*ir_graph) void {
return low_level.conv_opt(irg);
}
pub fn optimizeFunccalls() void {
return low_level.optimize_funccalls();
}
pub fn doGvnPre(irg: ?*ir_graph) void {
return low_level.do_gvn_pre(irg);
}
pub fn optIfConv(irg: ?*ir_graph) void {
return low_level.opt_if_conv(irg);
}
pub fn optIfConvCb(irg: ?*ir_graph, callback: arch_allow_ifconv_func) void {
return low_level.opt_if_conv_cb(irg, callback);
}
pub fn optParallelizeMem(irg: ?*ir_graph) void {
return low_level.opt_parallelize_mem(irg);
}
pub fn canReplaceLoadByConst(load: ?*const ir_node, c: ?*ir_node) ?*ir_node {
return low_level.can_replace_load_by_const(load, c);
}
pub fn optimizeLoadStore(irg: ?*ir_graph) void {
return low_level.optimize_load_store(irg);
}
pub fn combineMemops(irg: ?*ir_graph) void {
return low_level.combine_memops(irg);
}
pub fn optLdst(irg: ?*ir_graph) void {
return low_level.opt_ldst(irg);
}
pub fn optFrameIrg(irg: ?*ir_graph) void {
return low_level.opt_frame_irg(irg);
}
pub fn optOsr(irg: ?*ir_graph, flags: u32) void {
return low_level.opt_osr(irg, flags);
}
pub fn removePhiCycles(irg: ?*ir_graph) void {
return low_level.remove_phi_cycles(irg);
}
pub fn procCloning(threshold: f32) void {
return low_level.proc_cloning(threshold);
}
pub fn optimizeReassociation(irg: ?*ir_graph) void {
return low_level.optimize_reassociation(irg);
}
pub fn normalizeOneReturn(irg: ?*ir_graph) void {
return low_level.normalize_one_return(irg);
}
pub fn normalizeNReturns(irg: ?*ir_graph) void {
return low_level.normalize_n_returns(irg);
}
pub fn scalarReplacementOpt(irg: ?*ir_graph) void {
return low_level.scalar_replacement_opt(irg);
}
pub fn optTailRecIrg(irg: ?*ir_graph) void {
return low_level.opt_tail_rec_irg(irg);
}
pub fn combo(irg: ?*ir_graph) void {
return low_level.combo(irg);
}
pub fn inlineFunctions(maxsize: u32, inline_threshold: i32, after_inline_opt: opt_ptr) void {
return low_level.inline_functions(maxsize, inline_threshold, after_inline_opt);
}
pub fn shapeBlocks(irg: ?*ir_graph) void {
return low_level.shape_blocks(irg);
}
pub fn doLoopInversion(irg: ?*ir_graph) void {
return low_level.do_loop_inversion(irg);
}
pub fn doLoopUnrolling(irg: ?*ir_graph) void {
return low_level.do_loop_unrolling(irg);
}
pub fn unrollLoops(irg: ?*ir_graph, factor: u32, maxsize: u32) void {
return low_level.unroll_loops(irg, factor, maxsize);
}
pub fn doLoopPeeling(irg: ?*ir_graph) void {
return low_level.do_loop_peeling(irg);
}
pub fn garbageCollectEntities() void {
return low_level.garbage_collect_entities();
}
pub fn deadNodeElimination(irg: ?*ir_graph) void {
return low_level.dead_node_elimination(irg);
}
pub fn placeCode(irg: ?*ir_graph) void {
return low_level.place_code(irg);
}
pub fn occultConsts(irg: ?*ir_graph) void {
return low_level.occult_consts(irg);
}
pub fn valueNotNull(n: ?*const ir_node, confirm: [*]?*const ir_node) i32 {
return low_level.value_not_null(n, confirm);
}
pub fn computedValueCmpConfirm(left: ?*ir_node, right: ?*ir_node, relation: ir_relation) ?*ir_tarval {
return low_level.computed_value_Cmp_Confirm(left, right, @enumToInt(relation));
}
pub fn createCompilerlibEntity(name: [*]const u8, mt: ?*ir_type) ?*ir_entity {
return low_level.create_compilerlib_entity(name, mt);
}
pub fn beLowerForTarget() void {
return low_level.be_lower_for_target();
}
pub fn beSetAfterTransformFunc(func: after_transform_func) void {
return low_level.be_set_after_transform_func(func);
}
pub fn beMain(output: *std.c.FILE, compilation_unit_name: [*]const u8) void {
return low_level.be_main(output, compilation_unit_name);
}
pub fn beParseAsmConstraints(constraints: [*]const u8) asm_constraint_flags_t {
return @intToEnum(asm_constraint_flags_t, low_level.be_parse_asm_constraints(constraints));
}
pub fn beIsValidClobber(clobber: [*]const u8) i32 {
return low_level.be_is_valid_clobber(clobber);
}
pub fn beDwarfSetSourceLanguage(language: u32) void {
return low_level.be_dwarf_set_source_language(language);
}
pub fn beDwarfSetCompilationDirectory(directory: [*]const u8) void {
return low_level.be_dwarf_set_compilation_directory(directory);
}
pub fn getIrpCallgraphState() irp_callgraph_state {
return @intToEnum(irp_callgraph_state, low_level.get_irp_callgraph_state());
}
pub fn setIrpCallgraphState(s: u32) void {
return low_level.set_irp_callgraph_state(s);
}
pub fn getIrgNCallers(irg: ?*const ir_graph) usize {
return low_level.get_irg_n_callers(irg);
}
pub fn getIrgCaller(irg: ?*const ir_graph, pos: usize) ?*ir_graph {
return low_level.get_irg_caller(irg, pos);
}
pub fn isIrgCallerBackedge(irg: ?*const ir_graph, pos: usize) bool {
return low_level.is_irg_caller_backedge(irg, pos) == 1;
}
pub fn hasIrgCallerBackedge(irg: ?*const ir_graph) i32 {
return low_level.has_irg_caller_backedge(irg);
}
pub fn getIrgCallerLoopDepth(irg: ?*const ir_graph, pos: usize) usize {
return low_level.get_irg_caller_loop_depth(irg, pos);
}
pub fn getIrgNCallees(irg: ?*const ir_graph) usize {
return low_level.get_irg_n_callees(irg);
}
pub fn getIrgCallee(irg: ?*const ir_graph, pos: usize) ?*ir_graph {
return low_level.get_irg_callee(irg, pos);
}
pub fn isIrgCalleeBackedge(irg: ?*const ir_graph, pos: usize) bool {
return low_level.is_irg_callee_backedge(irg, pos) == 1;
}
pub fn hasIrgCalleeBackedge(irg: ?*const ir_graph) i32 {
return low_level.has_irg_callee_backedge(irg);
}
pub fn getIrgCalleeLoopDepth(irg: ?*const ir_graph, pos: usize) usize {
return low_level.get_irg_callee_loop_depth(irg, pos);
}
pub fn getIrgMethodExecutionFrequency(irg: ?*const ir_graph) f64 {
return low_level.get_irg_method_execution_frequency(irg);
}
pub fn computeCallgraph() void {
return low_level.compute_callgraph();
}
pub fn freeCallgraph() void {
return low_level.free_callgraph();
}
pub fn callgraphWalk(pre: ?callgraph_walk_func, post: ?callgraph_walk_func, env: ?*anyopaque) void {
return low_level.callgraph_walk(pre, post, env);
}
pub fn findCallgraphRecursions() void {
return low_level.find_callgraph_recursions();
}
pub fn analyseLoopNestingDepth() void {
return low_level.analyse_loop_nesting_depth();
}
pub fn getIrpLoopNestingDepthState() loop_nesting_depth_state {
return @intToEnum(loop_nesting_depth_state, low_level.get_irp_loop_nesting_depth_state());
}
pub fn setIrpLoopNestingDepthState(s: u32) void {
return low_level.set_irp_loop_nesting_depth_state(s);
}
pub fn setIrpLoopNestingDepthStateInconsistent() void {
return low_level.set_irp_loop_nesting_depth_state_inconsistent();
}
pub fn computeCdep(irg: ?*ir_graph) void {
return low_level.compute_cdep(irg);
}
pub fn freeCdep(irg: ?*ir_graph) void {
return low_level.free_cdep(irg);
}
pub fn getCdepNode(cdep: ?*const ir_cdep) ?*ir_node {
return low_level.get_cdep_node(cdep);
}
pub fn getCdepNext(cdep: ?*const ir_cdep) ?*ir_cdep {
return low_level.get_cdep_next(cdep);
}
pub fn findCdep(block: ?*const ir_node) ?*ir_cdep {
return low_level.find_cdep(block);
}
pub fn exchangeCdep(old: ?*ir_node, nw: ?*const ir_node) void {
return low_level.exchange_cdep(old, nw);
}
pub fn isCdepOn(dependee: ?*const ir_node, candidate: ?*const ir_node) bool {
return low_level.is_cdep_on(dependee, candidate) == 1;
}
pub fn getUniqueCdep(block: ?*const ir_node) ?*ir_node {
return low_level.get_unique_cdep(block);
}
pub fn hasMultipleCdep(block: ?*const ir_node) i32 {
return low_level.has_multiple_cdep(block);
}
pub fn cgana(free_methods: [*][*]?*ir_entity) usize {
return low_level.cgana(free_methods);
}
pub fn freeCalleeInfo(irg: ?*ir_graph) void {
return low_level.free_callee_info(irg);
}
pub fn freeIrpCalleeInfo() void {
return low_level.free_irp_callee_info();
}
pub fn optCallAddrs() void {
return low_level.opt_call_addrs();
}
pub fn cgCallHasCallees(node: ?*const ir_node) i32 {
return low_level.cg_call_has_callees(node);
}
pub fn cgGetCallNCallees(node: ?*const ir_node) usize {
return low_level.cg_get_call_n_callees(node);
}
pub fn cgGetCallCallee(node: ?*const ir_node, pos: usize) ?*ir_entity {
return low_level.cg_get_call_callee(node, pos);
}
pub fn cgSetCallCalleeArr(node: ?*ir_node, n: usize, arr: [*]?*ir_entity) void {
return low_level.cg_set_call_callee_arr(node, n, arr);
}
pub fn cgRemoveCallCalleeArr(node: ?*ir_node) void {
return low_level.cg_remove_call_callee_arr(node);
}
pub fn dbgAction2Str(a: u32) [*]const u8 {
return low_level.dbg_action_2_str(a);
}
pub fn dbgInit(dbg_info_merge_pair: ?merge_pair_func, dbg_info_merge_sets: ?merge_sets_func) void {
return low_level.dbg_init(dbg_info_merge_pair, dbg_info_merge_sets);
}
pub fn irSetDebugRetrieve(func: retrieve_dbg_func) void {
return low_level.ir_set_debug_retrieve(func);
}
pub fn irSetTypeDebugRetrieve(func: retrieve_type_dbg_func) void {
return low_level.ir_set_type_debug_retrieve(func);
}
pub fn irRetrieveDbgInfo(dbg: ?*const dbg_info) src_loc_t {
return low_level.ir_retrieve_dbg_info(dbg);
}
pub fn irRetrieveTypeDbgInfo(buffer: [*]u8, buffer_size: usize, tdbgi: ?*const type_dbg_info) void {
return low_level.ir_retrieve_type_dbg_info(buffer, buffer_size, tdbgi);
}
pub fn irEstimateExecfreq(irg: ?*ir_graph) void {
return low_level.ir_estimate_execfreq(irg);
}
pub fn getBlockExecfreq(block: ?*const ir_node) f64 {
return low_level.get_block_execfreq(block);
}
pub fn irInit() void {
return low_level.ir_init();
}
pub fn irInitLibrary() void {
return low_level.ir_init_library();
}
pub fn irFinish() void {
return low_level.ir_finish();
}
pub fn irGetVersionMajor() u32 {
return low_level.ir_get_version_major();
}
pub fn irGetVersionMinor() u32 {
return low_level.ir_get_version_minor();
}
pub fn irGetVersionMicro() u32 {
return low_level.ir_get_version_micro();
}
pub fn irGetVersionRevision() [*]const u8 {
return low_level.ir_get_version_revision();
}
pub fn irGetVersionBuild() [*]const u8 {
return low_level.ir_get_version_build();
}
pub fn getKind(firm_thing: ?*const anyopaque) firm_kind {
return @intToEnum(firm_kind, low_level.get_kind(firm_thing));
}
pub fn getIrnHeight(h: ?*const ir_heights_t, irn: ?*const ir_node) u32 {
return low_level.get_irn_height(h, irn);
}
pub fn heightsReachableInBlock(h: ?*ir_heights_t, src: ?*const ir_node, tgt: ?*const ir_node) i32 {
return low_level.heights_reachable_in_block(h, src, tgt);
}
pub fn heightsRecomputeBlock(h: ?*ir_heights_t, block: ?*ir_node) u32 {
return low_level.heights_recompute_block(h, block);
}
pub fn heightsNew(irg: ?*ir_graph) ?*ir_heights_t {
return low_level.heights_new(irg);
}
pub fn heightsFree(h: ?*ir_heights_t) void {
return low_level.heights_free(h);
}
pub fn newIdFromStr(str: [*]const u8) [*]const u8 {
return low_level.new_id_from_str(str);
}
pub fn newIdFromChars(str: [*]const u8, len: usize) [*]const u8 {
return low_level.new_id_from_chars(str, len);
}
pub fn newIdFmt(fmt: [*]const u8, variadic: anytype) [*]const u8 {
return low_level.new_id_fmt(fmt, variadic);
}
pub fn getIdStr(id: [*]const u8) [*]const u8 {
return low_level.get_id_str(id);
}
pub fn idUnique(tag: [*]const u8) [*]const u8 {
return low_level.id_unique(tag);
}
pub fn gcIrgs(n_keep: usize, keep_arr: [*]?*ir_entity) void {
return low_level.gc_irgs(n_keep, keep_arr);
}
pub fn getOpName(op: ?*const ir_op) [*]const u8 {
return low_level.get_op_name(op);
}
pub fn getOpCode(op: ?*const ir_op) u32 {
return low_level.get_op_code(op);
}
pub fn getOpPinStateName(s: u32) [*]const u8 {
return low_level.get_op_pin_state_name(s);
}
pub fn getOpPinned(op: ?*const ir_op) op_pin_state {
return @intToEnum(op_pin_state, low_level.get_op_pinned(op));
}
pub fn getNextIrOpcode() u32 {
return low_level.get_next_ir_opcode();
}
pub fn getNextIrOpcodes(num: u32) u32 {
return low_level.get_next_ir_opcodes(num);
}
pub fn getGenericFunctionPtr(op: ?*const ir_op) op_func {
return low_level.get_generic_function_ptr(op);
}
pub fn setGenericFunctionPtr(op: ?*ir_op, func: op_func) void {
return low_level.set_generic_function_ptr(op, func);
}
pub fn getOpFlags(op: ?*const ir_op) irop_flags {
return @intToEnum(irop_flags, low_level.get_op_flags(op));
}
pub fn setOpHash(op: ?*ir_op, func: hash_func) void {
return low_level.set_op_hash(op, func);
}
pub fn setOpComputedValue(op: ?*ir_op, func: computed_value_func) void {
return low_level.set_op_computed_value(op, func);
}
pub fn setOpComputedValueProj(op: ?*ir_op, func: computed_value_func) void {
return low_level.set_op_computed_value_proj(op, func);
}
pub fn setOpEquivalentNode(op: ?*ir_op, func: equivalent_node_func) void {
return low_level.set_op_equivalent_node(op, func);
}
pub fn setOpEquivalentNodeProj(op: ?*ir_op, func: equivalent_node_func) void {
return low_level.set_op_equivalent_node_proj(op, func);
}
pub fn setOpTransformNode(op: ?*ir_op, func: transform_node_func) void {
return low_level.set_op_transform_node(op, func);
}
pub fn setOpTransformNodeProj(op: ?*ir_op, func: transform_node_func) void {
return low_level.set_op_transform_node_proj(op, func);
}
pub fn setOpAttrsEqual(op: ?*ir_op, func: node_attrs_equal_func) void {
return low_level.set_op_attrs_equal(op, func);
}
pub fn setOpReassociate(op: ?*ir_op, func: reassociate_func) void {
return low_level.set_op_reassociate(op, func);
}
pub fn setOpCopyAttr(op: ?*ir_op, func: copy_attr_func) void {
return low_level.set_op_copy_attr(op, func);
}
pub fn setOpGetTypeAttr(op: ?*ir_op, func: get_type_attr_func) void {
return low_level.set_op_get_type_attr(op, func);
}
pub fn setOpGetEntityAttr(op: ?*ir_op, func: get_entity_attr_func) void {
return low_level.set_op_get_entity_attr(op, func);
}
pub fn setOpVerify(op: ?*ir_op, func: verify_node_func) void {
return low_level.set_op_verify(op, func);
}
pub fn setOpVerifyProj(op: ?*ir_op, func: verify_proj_node_func) void {
return low_level.set_op_verify_proj(op, func);
}
pub fn setOpDump(op: ?*ir_op, func: dump_node_func) void {
return low_level.set_op_dump(op, func);
}
pub fn newIrOp(code: u32, name: [*]const u8, p: u32, flags: u32, opar: u32, op_index: i32, attr_size: usize) ?*ir_op {
return low_level.new_ir_op(code, name, p, flags, opar, op_index, attr_size);
}
pub fn freeIrOp(code: ?*ir_op) void {
return low_level.free_ir_op(code);
}
pub fn irGetNOpcodes() u32 {
return low_level.ir_get_n_opcodes();
}
pub fn irGetOpcode(code: u32) ?*ir_op {
return low_level.ir_get_opcode(code);
}
pub fn irClearOpcodesGenericFunc() void {
return low_level.ir_clear_opcodes_generic_func();
}
pub fn irOpSetMemoryIndex(op: ?*ir_op, memory_index: i32) void {
return low_level.ir_op_set_memory_index(op, memory_index);
}
pub fn irOpSetFragileIndices(op: ?*ir_op, pn_x_regular: u32, pn_x_except: u32) void {
return low_level.ir_op_set_fragile_indices(op, pn_x_regular, pn_x_except);
}
pub fn newRdAsm(dbgi: ?*dbg_info, block: ?*ir_node, irn_mem: ?*ir_node, arity: i32, in: [*]const ?*ir_node, text: [*]const u8, n_constraints: usize, constraints: [*]ir_asm_constraint, n_clobbers: usize, clobbers: [*][*]const u8, flags: u32) ?*ir_node {
return low_level.new_rd_ASM(dbgi, block, irn_mem, arity, in, text, n_constraints, constraints, n_clobbers, clobbers, flags);
}
pub fn newRAsm(block: ?*ir_node, irn_mem: ?*ir_node, arity: i32, in: [*]const ?*ir_node, text: [*]const u8, n_constraints: usize, constraints: [*]ir_asm_constraint, n_clobbers: usize, clobbers: [*][*]const u8, flags: u32) ?*ir_node {
return low_level.new_r_ASM(block, irn_mem, arity, in, text, n_constraints, constraints, n_clobbers, clobbers, flags);
}
pub fn newDAsm(dbgi: ?*dbg_info, irn_mem: ?*ir_node, arity: i32, in: [*]const ?*ir_node, text: [*]const u8, n_constraints: usize, constraints: [*]ir_asm_constraint, n_clobbers: usize, clobbers: [*][*]const u8, flags: u32) ?*ir_node {
return low_level.new_d_ASM(dbgi, irn_mem, arity, in, text, n_constraints, constraints, n_clobbers, clobbers, flags);
}
pub fn newAsm(irn_mem: ?*ir_node, arity: i32, in: [*]const ?*ir_node, text: [*]const u8, n_constraints: usize, constraints: [*]ir_asm_constraint, n_clobbers: usize, clobbers: [*][*]const u8, flags: u32) ?*ir_node {
return low_level.new_ASM(irn_mem, arity, in, text, n_constraints, constraints, n_clobbers, clobbers, flags);
}
pub fn isAsm(node: ?*const ir_node) bool {
return low_level.is_ASM(node) == 1;
}
pub fn getAsmMem(node: ?*const ir_node) ?*ir_node {
return low_level.get_ASM_mem(node);
}
pub fn setAsmMem(node: ?*ir_node, mem: ?*ir_node) void {
return low_level.set_ASM_mem(node, mem);
}
pub fn getAsmNInputs(node: ?*const ir_node) i32 {
return low_level.get_ASM_n_inputs(node);
}
pub fn getAsmInput(node: ?*const ir_node, pos: i32) ?*ir_node {
return low_level.get_ASM_input(node, pos);
}
pub fn setAsmInput(node: ?*ir_node, pos: i32, input: ?*ir_node) void {
return low_level.set_ASM_input(node, pos, input);
}
pub fn getAsmInputArr(node: ?*ir_node) [*]?*ir_node {
return low_level.get_ASM_input_arr(node);
}
pub fn getAsmConstraints(node: ?*const ir_node) [*]ir_asm_constraint {
return low_level.get_ASM_constraints(node);
}
pub fn setAsmConstraints(node: ?*ir_node, constraints: [*]ir_asm_constraint) void {
return low_level.set_ASM_constraints(node, constraints);
}
pub fn getAsmClobbers(node: ?*const ir_node) [*]const u8 {
return low_level.get_ASM_clobbers(node);
}
pub fn setAsmClobbers(node: ?*ir_node, clobbers: [*][*]const u8) void {
return low_level.set_ASM_clobbers(node, clobbers);
}
pub fn getAsmText(node: ?*const ir_node) [*]const u8 {
return low_level.get_ASM_text(node);
}
pub fn setAsmText(node: ?*ir_node, text: [*]const u8) void {
return low_level.set_ASM_text(node, text);
}
pub fn getOpAsm() ?*ir_op {
return low_level.get_op_ASM();
}
pub fn newRdAdd(dbgi: ?*dbg_info, block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node {
return low_level.new_rd_Add(dbgi, block, irn_left, irn_right);
}
pub fn newRAdd(block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node {
return low_level.new_r_Add(block, irn_left, irn_right);
}
pub fn newDAdd(dbgi: ?*dbg_info, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node {
return low_level.new_d_Add(dbgi, irn_left, irn_right);
}
pub fn newAdd(irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node {
return low_level.new_Add(irn_left, irn_right);
}
pub fn isAdd(node: ?*const ir_node) bool {
return low_level.is_Add(node) == 1;
}
pub fn getAddLeft(node: ?*const ir_node) ?*ir_node {
return low_level.get_Add_left(node);
}
pub fn setAddLeft(node: ?*ir_node, left: ?*ir_node) void {
return low_level.set_Add_left(node, left);
}
pub fn getAddRight(node: ?*const ir_node) ?*ir_node {
return low_level.get_Add_right(node);
}
pub fn setAddRight(node: ?*ir_node, right: ?*ir_node) void {
return low_level.set_Add_right(node, right);
}
pub fn getOpAdd() ?*ir_op {
return low_level.get_op_Add();
}
pub fn newRdAddress(dbgi: ?*dbg_info, irg: ?*ir_graph, entity: ?*ir_entity) ?*ir_node {
return low_level.new_rd_Address(dbgi, irg, entity);
}
pub fn newRAddress(irg: ?*ir_graph, entity: ?*ir_entity) ?*ir_node {
return low_level.new_r_Address(irg, entity);
}
pub fn newDAddress(dbgi: ?*dbg_info, entity: ?*ir_entity) ?*ir_node {
return low_level.new_d_Address(dbgi, entity);
}
pub fn newAddress(entity: ?*ir_entity) ?*ir_node {
return low_level.new_Address(entity);
}
pub fn isAddress(node: ?*const ir_node) bool {
return low_level.is_Address(node) == 1;
}
pub fn getAddressEntity(node: ?*const ir_node) ?*ir_entity {
return low_level.get_Address_entity(node);
}
pub fn setAddressEntity(node: ?*ir_node, entity: ?*ir_entity) void {
return low_level.set_Address_entity(node, entity);
}
pub fn getOpAddress() ?*ir_op {
return low_level.get_op_Address();
}
pub fn newRdAlign(dbgi: ?*dbg_info, irg: ?*ir_graph, mode: ?*ir_mode, @"type": ?*ir_type) ?*ir_node {
return low_level.new_rd_Align(dbgi, irg, mode, @"type");
}
pub fn newRAlign(irg: ?*ir_graph, mode: ?*ir_mode, @"type": ?*ir_type) ?*ir_node {
return low_level.new_r_Align(irg, mode, @"type");
}
pub fn newDAlign(dbgi: ?*dbg_info, mode: ?*ir_mode, @"type": ?*ir_type) ?*ir_node {
return low_level.new_d_Align(dbgi, mode, @"type");
}
pub fn newAlign(mode: ?*ir_mode, @"type": ?*ir_type) ?*ir_node {
return low_level.new_Align(mode, @"type");
}
pub fn isAlign(node: ?*const ir_node) bool {
return low_level.is_Align(node) == 1;
}
pub fn getAlignType(node: ?*const ir_node) ?*ir_type {
return low_level.get_Align_type(node);
}
pub fn setAlignType(node: ?*ir_node, @"type": ?*ir_type) void {
return low_level.set_Align_type(node, @"type");
}
pub fn getOpAlign() ?*ir_op {
return low_level.get_op_Align();
}
pub fn newRdAlloc(dbgi: ?*dbg_info, block: ?*ir_node, irn_mem: ?*ir_node, irn_size: ?*ir_node, alignment: u32) ?*ir_node {
return low_level.new_rd_Alloc(dbgi, block, irn_mem, irn_size, alignment);
}
pub fn newRAlloc(block: ?*ir_node, irn_mem: ?*ir_node, irn_size: ?*ir_node, alignment: u32) ?*ir_node {
return low_level.new_r_Alloc(block, irn_mem, irn_size, alignment);
}
pub fn newDAlloc(dbgi: ?*dbg_info, irn_mem: ?*ir_node, irn_size: ?*ir_node, alignment: u32) ?*ir_node {
return low_level.new_d_Alloc(dbgi, irn_mem, irn_size, alignment);
}
pub fn newAlloc(irn_mem: ?*ir_node, irn_size: ?*ir_node, alignment: u32) ?*ir_node {
return low_level.new_Alloc(irn_mem, irn_size, alignment);
}
pub fn isAlloc(node: ?*const ir_node) bool {
return low_level.is_Alloc(node) == 1;
}
pub fn getAllocMem(node: ?*const ir_node) ?*ir_node {
return low_level.get_Alloc_mem(node);
}
pub fn setAllocMem(node: ?*ir_node, mem: ?*ir_node) void {
return low_level.set_Alloc_mem(node, mem);
}
pub fn getAllocSize(node: ?*const ir_node) ?*ir_node {
return low_level.get_Alloc_size(node);
}
pub fn setAllocSize(node: ?*ir_node, size: ?*ir_node) void {
return low_level.set_Alloc_size(node, size);
}
pub fn getAllocAlignment(node: ?*const ir_node) u32 {
return low_level.get_Alloc_alignment(node);
}
pub fn setAllocAlignment(node: ?*ir_node, alignment: u32) void {
return low_level.set_Alloc_alignment(node, alignment);
}
pub fn getOpAlloc() ?*ir_op {
return low_level.get_op_Alloc();
}
pub fn isAnchor(node: ?*const ir_node) bool {
return low_level.is_Anchor(node) == 1;
}
pub fn getAnchorEndBlock(node: ?*const ir_node) ?*ir_node {
return low_level.get_Anchor_end_block(node);
}
pub fn setAnchorEndBlock(node: ?*ir_node, end_block: ?*ir_node) void {
return low_level.set_Anchor_end_block(node, end_block);
}
pub fn getAnchorStartBlock(node: ?*const ir_node) ?*ir_node {
return low_level.get_Anchor_start_block(node);
}
pub fn setAnchorStartBlock(node: ?*ir_node, start_block: ?*ir_node) void {
return low_level.set_Anchor_start_block(node, start_block);
}
pub fn getAnchorEnd(node: ?*const ir_node) ?*ir_node {
return low_level.get_Anchor_end(node);
}
pub fn setAnchorEnd(node: ?*ir_node, end: ?*ir_node) void {
return low_level.set_Anchor_end(node, end);
}
pub fn getAnchorStart(node: ?*const ir_node) ?*ir_node {
return low_level.get_Anchor_start(node);
}
pub fn setAnchorStart(node: ?*ir_node, start: ?*ir_node) void {
return low_level.set_Anchor_start(node, start);
}
pub fn getAnchorFrame(node: ?*const ir_node) ?*ir_node {
return low_level.get_Anchor_frame(node);
}
pub fn setAnchorFrame(node: ?*ir_node, frame: ?*ir_node) void {
return low_level.set_Anchor_frame(node, frame);
}
pub fn getAnchorInitialMem(node: ?*const ir_node) ?*ir_node {
return low_level.get_Anchor_initial_mem(node);
}
pub fn setAnchorInitialMem(node: ?*ir_node, initial_mem: ?*ir_node) void {
return low_level.set_Anchor_initial_mem(node, initial_mem);
}
pub fn getAnchorArgs(node: ?*const ir_node) ?*ir_node {
return low_level.get_Anchor_args(node);
}
pub fn setAnchorArgs(node: ?*ir_node, args: ?*ir_node) void {
return low_level.set_Anchor_args(node, args);
}
pub fn getAnchorNoMem(node: ?*const ir_node) ?*ir_node {
return low_level.get_Anchor_no_mem(node);
}
pub fn setAnchorNoMem(node: ?*ir_node, no_mem: ?*ir_node) void {
return low_level.set_Anchor_no_mem(node, no_mem);
}
pub fn getOpAnchor() ?*ir_op {
return low_level.get_op_Anchor();
}
pub fn newRdAnd(dbgi: ?*dbg_info, block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node {
return low_level.new_rd_And(dbgi, block, irn_left, irn_right);
}
pub fn newRAnd(block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node {
return low_level.new_r_And(block, irn_left, irn_right);
}
pub fn newDAnd(dbgi: ?*dbg_info, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node {
return low_level.new_d_And(dbgi, irn_left, irn_right);
}
pub fn newAnd(irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node {
return low_level.new_And(irn_left, irn_right);
}
pub fn isAnd(node: ?*const ir_node) bool {
return low_level.is_And(node) == 1;
}
pub fn getAndLeft(node: ?*const ir_node) ?*ir_node {
return low_level.get_And_left(node);
}
pub fn setAndLeft(node: ?*ir_node, left: ?*ir_node) void {
return low_level.set_And_left(node, left);
}
pub fn getAndRight(node: ?*const ir_node) ?*ir_node {
return low_level.get_And_right(node);
}
pub fn setAndRight(node: ?*ir_node, right: ?*ir_node) void {
return low_level.set_And_right(node, right);
}
pub fn getOpAnd() ?*ir_op {
return low_level.get_op_And();
}
pub fn newRdBad(dbgi: ?*dbg_info, irg: ?*ir_graph, mode: ?*ir_mode) ?*ir_node {
return low_level.new_rd_Bad(dbgi, irg, mode);
}
pub fn newRBad(irg: ?*ir_graph, mode: ?*ir_mode) ?*ir_node {
return low_level.new_r_Bad(irg, mode);
}
pub fn newDBad(dbgi: ?*dbg_info, mode: ?*ir_mode) ?*ir_node {
return low_level.new_d_Bad(dbgi, mode);
}
pub fn newBad(mode: ?*ir_mode) ?*ir_node {
return low_level.new_Bad(mode);
}
pub fn isBad(node: ?*const ir_node) bool {
return low_level.is_Bad(node) == 1;
}
pub fn getOpBad() ?*ir_op {
return low_level.get_op_Bad();
}
pub fn newRdBitcast(dbgi: ?*dbg_info, block: ?*ir_node, irn_op: ?*ir_node, mode: ?*ir_mode) ?*ir_node {
return low_level.new_rd_Bitcast(dbgi, block, irn_op, mode);
}
pub fn newRBitcast(block: ?*ir_node, irn_op: ?*ir_node, mode: ?*ir_mode) ?*ir_node {
return low_level.new_r_Bitcast(block, irn_op, mode);
}
pub fn newDBitcast(dbgi: ?*dbg_info, irn_op: ?*ir_node, mode: ?*ir_mode) ?*ir_node {
return low_level.new_d_Bitcast(dbgi, irn_op, mode);
}
pub fn newBitcast(irn_op: ?*ir_node, mode: ?*ir_mode) ?*ir_node {
return low_level.new_Bitcast(irn_op, mode);
}
pub fn isBitcast(node: ?*const ir_node) bool {
return low_level.is_Bitcast(node) == 1;
}
pub fn getBitcastOp(node: ?*const ir_node) ?*ir_node {
return low_level.get_Bitcast_op(node);
}
pub fn setBitcastOp(node: ?*ir_node, op: ?*ir_node) void {
return low_level.set_Bitcast_op(node, op);
}
pub fn getOpBitcast() ?*ir_op {
return low_level.get_op_Bitcast();
}
pub fn newRdBlock(dbgi: ?*dbg_info, irg: ?*ir_graph, arity: i32, in: [*]const ?*ir_node) ?*ir_node {
return low_level.new_rd_Block(dbgi, irg, arity, in);
}
pub fn newRBlock(irg: ?*ir_graph, arity: i32, in: [*]const ?*ir_node) ?*ir_node {
return low_level.new_r_Block(irg, arity, in);
}
pub fn newDBlock(dbgi: ?*dbg_info, arity: i32, in: [*]const ?*ir_node) ?*ir_node {
return low_level.new_d_Block(dbgi, arity, in);
}
pub fn newBlock(arity: i32, in: [*]const ?*ir_node) ?*ir_node {
return low_level.new_Block(arity, in);
}
pub fn isBlock(node: ?*const ir_node) bool {
return low_level.is_Block(node) == 1;
}
pub fn getBlockNCfgpreds(node: ?*const ir_node) i32 {
return low_level.get_Block_n_cfgpreds(node);
}
pub fn getBlockCfgpred(node: ?*const ir_node, pos: i32) ?*ir_node {
return low_level.get_Block_cfgpred(node, pos);
}
pub fn setBlockCfgpred(node: ?*ir_node, pos: i32, cfgpred: ?*ir_node) void {
return low_level.set_Block_cfgpred(node, pos, cfgpred);
}
pub fn getBlockCfgpredArr(node: ?*ir_node) [*]?*ir_node {
return low_level.get_Block_cfgpred_arr(node);
}
pub fn getBlockEntity(node: ?*const ir_node) ?*ir_entity {
return low_level.get_Block_entity(node);
}
pub fn setBlockEntity(node: ?*ir_node, entity: ?*ir_entity) void {
return low_level.set_Block_entity(node, entity);
}
pub fn getOpBlock() ?*ir_op {
return low_level.get_op_Block();
}
pub fn newRdBuiltin(dbgi: ?*dbg_info, block: ?*ir_node, irn_mem: ?*ir_node, arity: i32, in: [*]const ?*ir_node, kind: u32, @"type": ?*ir_type) ?*ir_node {
return low_level.new_rd_Builtin(dbgi, block, irn_mem, arity, in, kind, @"type");
}
pub fn newRBuiltin(block: ?*ir_node, irn_mem: ?*ir_node, arity: i32, in: [*]const ?*ir_node, kind: u32, @"type": ?*ir_type) ?*ir_node {
return low_level.new_r_Builtin(block, irn_mem, arity, in, kind, @"type");
}
pub fn newDBuiltin(dbgi: ?*dbg_info, irn_mem: ?*ir_node, arity: i32, in: [*]const ?*ir_node, kind: u32, @"type": ?*ir_type) ?*ir_node {
return low_level.new_d_Builtin(dbgi, irn_mem, arity, in, kind, @"type");
}
pub fn newBuiltin(irn_mem: ?*ir_node, arity: i32, in: [*]const ?*ir_node, kind: u32, @"type": ?*ir_type) ?*ir_node {
return low_level.new_Builtin(irn_mem, arity, in, kind, @"type");
}
pub fn isBuiltin(node: ?*const ir_node) bool {
return low_level.is_Builtin(node) == 1;
}
pub fn getBuiltinMem(node: ?*const ir_node) ?*ir_node {
return low_level.get_Builtin_mem(node);
}
pub fn setBuiltinMem(node: ?*ir_node, mem: ?*ir_node) void {
return low_level.set_Builtin_mem(node, mem);
}
pub fn getBuiltinNParams(node: ?*const ir_node) i32 {
return low_level.get_Builtin_n_params(node);
}
pub fn getBuiltinParam(node: ?*const ir_node, pos: i32) ?*ir_node {
return low_level.get_Builtin_param(node, pos);
}
pub fn setBuiltinParam(node: ?*ir_node, pos: i32, param: ?*ir_node) void {
return low_level.set_Builtin_param(node, pos, param);
}
pub fn getBuiltinParamArr(node: ?*ir_node) [*]?*ir_node {
return low_level.get_Builtin_param_arr(node);
}
pub fn getBuiltinKind(node: ?*const ir_node) ir_builtin_kind {
return @intToEnum(ir_builtin_kind, low_level.get_Builtin_kind(node));
}
pub fn setBuiltinKind(node: ?*ir_node, kind: u32) void {
return low_level.set_Builtin_kind(node, kind);
}
pub fn getBuiltinType(node: ?*const ir_node) ?*ir_type {
return low_level.get_Builtin_type(node);
}
pub fn setBuiltinType(node: ?*ir_node, @"type": ?*ir_type) void {
return low_level.set_Builtin_type(node, @"type");
}
pub fn getOpBuiltin() ?*ir_op {
return low_level.get_op_Builtin();
}
pub fn newRdCall(dbgi: ?*dbg_info, block: ?*ir_node, irn_mem: ?*ir_node, irn_ptr: ?*ir_node, arity: i32, in: ?[*]const ?*ir_node, @"type": ?*ir_type) ?*ir_node {
return low_level.new_rd_Call(dbgi, block, irn_mem, irn_ptr, arity, in, @"type");
}
pub fn newRCall(block: ?*ir_node, irn_mem: ?*ir_node, irn_ptr: ?*ir_node, arity: i32, in: ?[*]const ?*ir_node, @"type": ?*ir_type) ?*ir_node {
return low_level.new_r_Call(block, irn_mem, irn_ptr, arity, in, @"type");
}
pub fn newDCall(dbgi: ?*dbg_info, irn_mem: ?*ir_node, irn_ptr: ?*ir_node, arity: i32, in: ?[*]const ?*ir_node, @"type": ?*ir_type) ?*ir_node {
return low_level.new_d_Call(dbgi, irn_mem, irn_ptr, arity, in, @"type");
}
pub fn newCall(irn_mem: ?*ir_node, irn_ptr: ?*ir_node, arity: i32, in: ?[*]const ?*ir_node, @"type": ?*ir_type) ?*ir_node {
return low_level.new_Call(irn_mem, irn_ptr, arity, in, @"type");
}
pub fn isCall(node: ?*const ir_node) bool {
return low_level.is_Call(node) == 1;
}
pub fn getCallMem(node: ?*const ir_node) ?*ir_node {
return low_level.get_Call_mem(node);
}
pub fn setCallMem(node: ?*ir_node, mem: ?*ir_node) void {
return low_level.set_Call_mem(node, mem);
}
pub fn getCallPtr(node: ?*const ir_node) ?*ir_node {
return low_level.get_Call_ptr(node);
}
pub fn setCallPtr(node: ?*ir_node, ptr: ?*ir_node) void {
return low_level.set_Call_ptr(node, ptr);
}
pub fn getCallNParams(node: ?*const ir_node) i32 {
return low_level.get_Call_n_params(node);
}
pub fn getCallParam(node: ?*const ir_node, pos: i32) ?*ir_node {
return low_level.get_Call_param(node, pos);
}
pub fn setCallParam(node: ?*ir_node, pos: i32, param: ?*ir_node) void {
return low_level.set_Call_param(node, pos, param);
}
pub fn getCallParamArr(node: ?*ir_node) [*]?*ir_node {
return low_level.get_Call_param_arr(node);
}
pub fn getCallType(node: ?*const ir_node) ?*ir_type {
return low_level.get_Call_type(node);
}
pub fn setCallType(node: ?*ir_node, @"type": ?*ir_type) void {
return low_level.set_Call_type(node, @"type");
}
pub fn getOpCall() ?*ir_op {
return low_level.get_op_Call();
}
pub fn newRdCmp(dbgi: ?*dbg_info, block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node, relation: ir_relation) ?*ir_node {
return low_level.new_rd_Cmp(dbgi, block, irn_left, irn_right, relation);
}
pub fn newRCmp(block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node, relation: ir_relation) ?*ir_node {
return low_level.new_r_Cmp(block, irn_left, irn_right, relation);
}
pub fn newDCmp(dbgi: ?*dbg_info, irn_left: ?*ir_node, irn_right: ?*ir_node, relation: ir_relation) ?*ir_node {
return low_level.new_d_Cmp(dbgi, irn_left, irn_right, relation);
}
pub fn newCmp(irn_left: ?*ir_node, irn_right: ?*ir_node, relation: ir_relation) ?*ir_node {
return low_level.new_Cmp(irn_left, irn_right, relation);
}
pub fn isCmp(node: ?*const ir_node) bool {
return low_level.is_Cmp(node) == 1;
}
pub fn getCmpLeft(node: ?*const ir_node) ?*ir_node {
return low_level.get_Cmp_left(node);
}
pub fn setCmpLeft(node: ?*ir_node, left: ?*ir_node) void {
return low_level.set_Cmp_left(node, left);
}
pub fn getCmpRight(node: ?*const ir_node) ?*ir_node {
return low_level.get_Cmp_right(node);
}
pub fn setCmpRight(node: ?*ir_node, right: ?*ir_node) void {
return low_level.set_Cmp_right(node, right);
}
pub fn getCmpRelation(node: ?*const ir_node) ir_relation {
return @intToEnum(ir_relation, low_level.get_Cmp_relation(node));
}
pub fn setCmpRelation(node: ?*ir_node, relation: ir_relation) void {
return low_level.set_Cmp_relation(node, relation);
}
pub fn getOpCmp() ?*ir_op {
return low_level.get_op_Cmp();
}
pub fn newRdCond(dbgi: ?*dbg_info, block: ?*ir_node, irn_selector: ?*ir_node) ?*ir_node {
return low_level.new_rd_Cond(dbgi, block, irn_selector);
}
pub fn newRCond(block: ?*ir_node, irn_selector: ?*ir_node) ?*ir_node {
return low_level.new_r_Cond(block, irn_selector);
}
pub fn newDCond(dbgi: ?*dbg_info, irn_selector: ?*ir_node) ?*ir_node {
return low_level.new_d_Cond(dbgi, irn_selector);
}
pub fn newCond(irn_selector: ?*ir_node) ?*ir_node {
return low_level.new_Cond(irn_selector);
}
pub fn isCond(node: ?*const ir_node) bool {
return low_level.is_Cond(node) == 1;
}
pub fn getCondSelector(node: ?*const ir_node) ?*ir_node {
return low_level.get_Cond_selector(node);
}
pub fn setCondSelector(node: ?*ir_node, selector: ?*ir_node) void {
return low_level.set_Cond_selector(node, selector);
}
pub fn getCondJmpPred(node: ?*const ir_node) cond_jmp_predicate {
return @intToEnum(cond_jmp_predicate, low_level.get_Cond_jmp_pred(node));
}
pub fn setCondJmpPred(node: ?*ir_node, jmp_pred: u32) void {
return low_level.set_Cond_jmp_pred(node, jmp_pred);
}
pub fn getOpCond() ?*ir_op {
return low_level.get_op_Cond();
}
pub fn newRdConfirm(dbgi: ?*dbg_info, block: ?*ir_node, irn_value: ?*ir_node, irn_bound: ?*ir_node, relation: ir_relation) ?*ir_node {
return low_level.new_rd_Confirm(dbgi, block, irn_value, irn_bound, relation);
}
pub fn newRConfirm(block: ?*ir_node, irn_value: ?*ir_node, irn_bound: ?*ir_node, relation: ir_relation) ?*ir_node {
return low_level.new_r_Confirm(block, irn_value, irn_bound, relation);
}
pub fn newDConfirm(dbgi: ?*dbg_info, irn_value: ?*ir_node, irn_bound: ?*ir_node, relation: ir_relation) ?*ir_node {
return low_level.new_d_Confirm(dbgi, irn_value, irn_bound, relation);
}
pub fn newConfirm(irn_value: ?*ir_node, irn_bound: ?*ir_node, relation: ir_relation) ?*ir_node {
return low_level.new_Confirm(irn_value, irn_bound, relation);
}
pub fn isConfirm(node: ?*const ir_node) bool {
return low_level.is_Confirm(node) == 1;
}
pub fn getConfirmValue(node: ?*const ir_node) ?*ir_node {
return low_level.get_Confirm_value(node);
}
pub fn setConfirmValue(node: ?*ir_node, value: ?*ir_node) void {
return low_level.set_Confirm_value(node, value);
}
pub fn getConfirmBound(node: ?*const ir_node) ?*ir_node {
return low_level.get_Confirm_bound(node);
}
pub fn setConfirmBound(node: ?*ir_node, bound: ?*ir_node) void {
return low_level.set_Confirm_bound(node, bound);
}
pub fn getConfirmRelation(node: ?*const ir_node) ir_relation {
return @intToEnum(ir_relation, low_level.get_Confirm_relation(node));
}
pub fn setConfirmRelation(node: ?*ir_node, relation: ir_relation) void {
return low_level.set_Confirm_relation(node, relation);
}
pub fn getOpConfirm() ?*ir_op {
return low_level.get_op_Confirm();
}
pub fn newRdConst(dbgi: ?*dbg_info, irg: ?*ir_graph, tarval: ?*ir_tarval) ?*ir_node {
return low_level.new_rd_Const(dbgi, irg, tarval);
}
pub fn newRConst(irg: ?*ir_graph, tarval: ?*ir_tarval) ?*ir_node {
return low_level.new_r_Const(irg, tarval);
}
pub fn newDConst(dbgi: ?*dbg_info, tarval: ?*ir_tarval) ?*ir_node {
return low_level.new_d_Const(dbgi, tarval);
}
pub fn newConst(tarval: ?*ir_tarval) ?*ir_node {
return low_level.new_Const(tarval);
}
pub fn isConst(node: ?*const ir_node) bool {
return low_level.is_Const(node) == 1;
}
pub fn getConstTarval(node: ?*const ir_node) ?*ir_tarval {
return low_level.get_Const_tarval(node);
}
pub fn setConstTarval(node: ?*ir_node, tarval: ?*ir_tarval) void {
return low_level.set_Const_tarval(node, tarval);
}
pub fn getOpConst() ?*ir_op {
return low_level.get_op_Const();
}
pub fn newRdConv(dbgi: ?*dbg_info, block: ?*ir_node, irn_op: ?*ir_node, mode: ?*ir_mode) ?*ir_node {
return low_level.new_rd_Conv(dbgi, block, irn_op, mode);
}
pub fn newRConv(block: ?*ir_node, irn_op: ?*ir_node, mode: ?*ir_mode) ?*ir_node {
return low_level.new_r_Conv(block, irn_op, mode);
}
pub fn newDConv(dbgi: ?*dbg_info, irn_op: ?*ir_node, mode: ?*ir_mode) ?*ir_node {
return low_level.new_d_Conv(dbgi, irn_op, mode);
}
pub fn newConv(irn_op: ?*ir_node, mode: ?*ir_mode) ?*ir_node {
return low_level.new_Conv(irn_op, mode);
}
pub fn isConv(node: ?*const ir_node) bool {
return low_level.is_Conv(node) == 1;
}
pub fn getConvOp(node: ?*const ir_node) ?*ir_node {
return low_level.get_Conv_op(node);
}
pub fn setConvOp(node: ?*ir_node, op: ?*ir_node) void {
return low_level.set_Conv_op(node, op);
}
pub fn getOpConv() ?*ir_op {
return low_level.get_op_Conv();
}
pub fn newRdCopyb(dbgi: ?*dbg_info, block: ?*ir_node, irn_mem: ?*ir_node, irn_dst: ?*ir_node, irn_src: ?*ir_node, @"type": ?*ir_type, flags: u32) ?*ir_node {
return low_level.new_rd_CopyB(dbgi, block, irn_mem, irn_dst, irn_src, @"type", flags);
}
pub fn newRCopyb(block: ?*ir_node, irn_mem: ?*ir_node, irn_dst: ?*ir_node, irn_src: ?*ir_node, @"type": ?*ir_type, flags: u32) ?*ir_node {
return low_level.new_r_CopyB(block, irn_mem, irn_dst, irn_src, @"type", flags);
}
pub fn newDCopyb(dbgi: ?*dbg_info, irn_mem: ?*ir_node, irn_dst: ?*ir_node, irn_src: ?*ir_node, @"type": ?*ir_type, flags: u32) ?*ir_node {
return low_level.new_d_CopyB(dbgi, irn_mem, irn_dst, irn_src, @"type", flags);
}
pub fn newCopyb(irn_mem: ?*ir_node, irn_dst: ?*ir_node, irn_src: ?*ir_node, @"type": ?*ir_type, flags: u32) ?*ir_node {
return low_level.new_CopyB(irn_mem, irn_dst, irn_src, @"type", flags);
}
pub fn isCopyb(node: ?*const ir_node) bool {
return low_level.is_CopyB(node) == 1;
}
pub fn getCopybMem(node: ?*const ir_node) ?*ir_node {
return low_level.get_CopyB_mem(node);
}
pub fn setCopybMem(node: ?*ir_node, mem: ?*ir_node) void {
return low_level.set_CopyB_mem(node, mem);
}
pub fn getCopybDst(node: ?*const ir_node) ?*ir_node {
return low_level.get_CopyB_dst(node);
}
pub fn setCopybDst(node: ?*ir_node, dst: ?*ir_node) void {
return low_level.set_CopyB_dst(node, dst);
}
pub fn getCopybSrc(node: ?*const ir_node) ?*ir_node {
return low_level.get_CopyB_src(node);
}
pub fn setCopybSrc(node: ?*ir_node, src: ?*ir_node) void {
return low_level.set_CopyB_src(node, src);
}
pub fn getCopybType(node: ?*const ir_node) ?*ir_type {
return low_level.get_CopyB_type(node);
}
pub fn setCopybType(node: ?*ir_node, @"type": ?*ir_type) void {
return low_level.set_CopyB_type(node, @"type");
}
pub fn getCopybVolatility(node: ?*const ir_node) ir_volatility {
return @intToEnum(ir_volatility, low_level.get_CopyB_volatility(node));
}
pub fn setCopybVolatility(node: ?*ir_node, volatility: u32) void {
return low_level.set_CopyB_volatility(node, volatility);
}
pub fn getOpCopyb() ?*ir_op {
return low_level.get_op_CopyB();
}
pub fn isDeleted(node: ?*const ir_node) bool {
return low_level.is_Deleted(node) == 1;
}
pub fn getOpDeleted() ?*ir_op {
return low_level.get_op_Deleted();
}
pub fn newRdDiv(dbgi: ?*dbg_info, block: ?*ir_node, irn_mem: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node, pinned: i32) ?*ir_node {
return low_level.new_rd_Div(dbgi, block, irn_mem, irn_left, irn_right, pinned);
}
pub fn newRDiv(block: ?*ir_node, irn_mem: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node, pinned: i32) ?*ir_node {
return low_level.new_r_Div(block, irn_mem, irn_left, irn_right, pinned);
}
pub fn newDDiv(dbgi: ?*dbg_info, irn_mem: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node, pinned: i32) ?*ir_node {
return low_level.new_d_Div(dbgi, irn_mem, irn_left, irn_right, pinned);
}
pub fn newDiv(irn_mem: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node, pinned: i32) ?*ir_node {
return low_level.new_Div(irn_mem, irn_left, irn_right, pinned);
}
pub fn isDiv(node: ?*const ir_node) bool {
return low_level.is_Div(node) == 1;
}
pub fn getDivMem(node: ?*const ir_node) ?*ir_node {
return low_level.get_Div_mem(node);
}
pub fn setDivMem(node: ?*ir_node, mem: ?*ir_node) void {
return low_level.set_Div_mem(node, mem);
}
pub fn getDivLeft(node: ?*const ir_node) ?*ir_node {
return low_level.get_Div_left(node);
}
pub fn setDivLeft(node: ?*ir_node, left: ?*ir_node) void {
return low_level.set_Div_left(node, left);
}
pub fn getDivRight(node: ?*const ir_node) ?*ir_node {
return low_level.get_Div_right(node);
}
pub fn setDivRight(node: ?*ir_node, right: ?*ir_node) void {
return low_level.set_Div_right(node, right);
}
pub fn getDivResmode(node: ?*const ir_node) ?*ir_mode {
return low_level.get_Div_resmode(node);
}
pub fn setDivResmode(node: ?*ir_node, resmode: ?*ir_mode) void {
return low_level.set_Div_resmode(node, resmode);
}
pub fn getDivNoRemainder(node: ?*const ir_node) i32 {
return low_level.get_Div_no_remainder(node);
}
pub fn setDivNoRemainder(node: ?*ir_node, no_remainder: i32) void {
return low_level.set_Div_no_remainder(node, no_remainder);
}
pub fn getOpDiv() ?*ir_op {
return low_level.get_op_Div();
}
pub fn newRdDummy(dbgi: ?*dbg_info, irg: ?*ir_graph, mode: ?*ir_mode) ?*ir_node {
return low_level.new_rd_Dummy(dbgi, irg, mode);
}
pub fn newRDummy(irg: ?*ir_graph, mode: ?*ir_mode) ?*ir_node {
return low_level.new_r_Dummy(irg, mode);
}
pub fn newDDummy(dbgi: ?*dbg_info, mode: ?*ir_mode) ?*ir_node {
return low_level.new_d_Dummy(dbgi, mode);
}
pub fn newDummy(mode: ?*ir_mode) ?*ir_node {
return low_level.new_Dummy(mode);
}
pub fn isDummy(node: ?*const ir_node) bool {
return low_level.is_Dummy(node) == 1;
}
pub fn getOpDummy() ?*ir_op {
return low_level.get_op_Dummy();
}
pub fn newRdEnd(dbgi: ?*dbg_info, irg: ?*ir_graph, arity: i32, in: [*]const ?*ir_node) ?*ir_node {
return low_level.new_rd_End(dbgi, irg, arity, in);
}
pub fn newREnd(irg: ?*ir_graph, arity: i32, in: [*]const ?*ir_node) ?*ir_node {
return low_level.new_r_End(irg, arity, in);
}
pub fn newDEnd(dbgi: ?*dbg_info, arity: i32, in: [*]const ?*ir_node) ?*ir_node {
return low_level.new_d_End(dbgi, arity, in);
}
pub fn newEnd(arity: i32, in: [*]const ?*ir_node) ?*ir_node {
return low_level.new_End(arity, in);
}
pub fn isEnd(node: ?*const ir_node) bool {
return low_level.is_End(node) == 1;
}
pub fn getEndNKeepalives(node: ?*const ir_node) i32 {
return low_level.get_End_n_keepalives(node);
}
pub fn getEndKeepalive(node: ?*const ir_node, pos: i32) ?*ir_node {
return low_level.get_End_keepalive(node, pos);
}
pub fn setEndKeepalive(node: ?*ir_node, pos: i32, keepalive: ?*ir_node) void {
return low_level.set_End_keepalive(node, pos, keepalive);
}
pub fn getEndKeepaliveArr(node: ?*ir_node) [*]?*ir_node {
return low_level.get_End_keepalive_arr(node);
}
pub fn getOpEnd() ?*ir_op {
return low_level.get_op_End();
}
pub fn newRdEor(dbgi: ?*dbg_info, block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node {
return low_level.new_rd_Eor(dbgi, block, irn_left, irn_right);
}
pub fn newREor(block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node {
return low_level.new_r_Eor(block, irn_left, irn_right);
}
pub fn newDEor(dbgi: ?*dbg_info, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node {
return low_level.new_d_Eor(dbgi, irn_left, irn_right);
}
pub fn newEor(irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node {
return low_level.new_Eor(irn_left, irn_right);
}
pub fn isEor(node: ?*const ir_node) bool {
return low_level.is_Eor(node) == 1;
}
pub fn getEorLeft(node: ?*const ir_node) ?*ir_node {
return low_level.get_Eor_left(node);
}
pub fn setEorLeft(node: ?*ir_node, left: ?*ir_node) void {
return low_level.set_Eor_left(node, left);
}
pub fn getEorRight(node: ?*const ir_node) ?*ir_node {
return low_level.get_Eor_right(node);
}
pub fn setEorRight(node: ?*ir_node, right: ?*ir_node) void {
return low_level.set_Eor_right(node, right);
}
pub fn getOpEor() ?*ir_op {
return low_level.get_op_Eor();
}
pub fn newRdFree(dbgi: ?*dbg_info, block: ?*ir_node, irn_mem: ?*ir_node, irn_ptr: ?*ir_node) ?*ir_node {
return low_level.new_rd_Free(dbgi, block, irn_mem, irn_ptr);
}
pub fn newRFree(block: ?*ir_node, irn_mem: ?*ir_node, irn_ptr: ?*ir_node) ?*ir_node {
return low_level.new_r_Free(block, irn_mem, irn_ptr);
}
pub fn newDFree(dbgi: ?*dbg_info, irn_mem: ?*ir_node, irn_ptr: ?*ir_node) ?*ir_node {
return low_level.new_d_Free(dbgi, irn_mem, irn_ptr);
}
pub fn newFree(irn_mem: ?*ir_node, irn_ptr: ?*ir_node) ?*ir_node {
return low_level.new_Free(irn_mem, irn_ptr);
}
pub fn isFree(node: ?*const ir_node) bool {
return low_level.is_Free(node) == 1;
}
pub fn getFreeMem(node: ?*const ir_node) ?*ir_node {
return low_level.get_Free_mem(node);
}
pub fn setFreeMem(node: ?*ir_node, mem: ?*ir_node) void {
return low_level.set_Free_mem(node, mem);
}
pub fn getFreePtr(node: ?*const ir_node) ?*ir_node {
return low_level.get_Free_ptr(node);
}
pub fn setFreePtr(node: ?*ir_node, ptr: ?*ir_node) void {
return low_level.set_Free_ptr(node, ptr);
}
pub fn getOpFree() ?*ir_op {
return low_level.get_op_Free();
}
pub fn newRdIjmp(dbgi: ?*dbg_info, block: ?*ir_node, irn_target: ?*ir_node) ?*ir_node {
return low_level.new_rd_IJmp(dbgi, block, irn_target);
}
pub fn newRIjmp(block: ?*ir_node, irn_target: ?*ir_node) ?*ir_node {
return low_level.new_r_IJmp(block, irn_target);
}
pub fn newDIjmp(dbgi: ?*dbg_info, irn_target: ?*ir_node) ?*ir_node {
return low_level.new_d_IJmp(dbgi, irn_target);
}
pub fn newIjmp(irn_target: ?*ir_node) ?*ir_node {
return low_level.new_IJmp(irn_target);
}
pub fn isIjmp(node: ?*const ir_node) bool {
return low_level.is_IJmp(node) == 1;
}
pub fn getIjmpTarget(node: ?*const ir_node) ?*ir_node {
return low_level.get_IJmp_target(node);
}
pub fn setIjmpTarget(node: ?*ir_node, target: ?*ir_node) void {
return low_level.set_IJmp_target(node, target);
}
pub fn getOpIjmp() ?*ir_op {
return low_level.get_op_IJmp();
}
pub fn isId(node: ?*const ir_node) bool {
return low_level.is_Id(node) == 1;
}
pub fn getIdPred(node: ?*const ir_node) ?*ir_node {
return low_level.get_Id_pred(node);
}
pub fn setIdPred(node: ?*ir_node, pred: ?*ir_node) void {
return low_level.set_Id_pred(node, pred);
}
pub fn getOpId() ?*ir_op {
return low_level.get_op_Id();
}
pub fn newRdJmp(dbgi: ?*dbg_info, block: ?*ir_node) ?*ir_node {
return low_level.new_rd_Jmp(dbgi, block);
}
pub fn newRJmp(block: ?*ir_node) ?*ir_node {
return low_level.new_r_Jmp(block);
}
pub fn newDJmp(dbgi: ?*dbg_info) ?*ir_node {
return low_level.new_d_Jmp(dbgi);
}
pub fn newJmp() ?*ir_node {
return low_level.new_Jmp();
}
pub fn isJmp(node: ?*const ir_node) bool {
return low_level.is_Jmp(node) == 1;
}
pub fn getOpJmp() ?*ir_op {
return low_level.get_op_Jmp();
}
pub fn newRdLoad(dbgi: ?*dbg_info, block: ?*ir_node, irn_mem: ?*ir_node, irn_ptr: ?*ir_node, mode: ?*ir_mode, @"type": ?*ir_type, flags: u32) ?*ir_node {
return low_level.new_rd_Load(dbgi, block, irn_mem, irn_ptr, mode, @"type", flags);
}
pub fn newRLoad(block: ?*ir_node, irn_mem: ?*ir_node, irn_ptr: ?*ir_node, mode: ?*ir_mode, @"type": ?*ir_type, flags: u32) ?*ir_node {
return low_level.new_r_Load(block, irn_mem, irn_ptr, mode, @"type", flags);
}
pub fn newDLoad(dbgi: ?*dbg_info, irn_mem: ?*ir_node, irn_ptr: ?*ir_node, mode: ?*ir_mode, @"type": ?*ir_type, flags: u32) ?*ir_node {
return low_level.new_d_Load(dbgi, irn_mem, irn_ptr, mode, @"type", flags);
}
pub fn newLoad(irn_mem: ?*ir_node, irn_ptr: ?*ir_node, mode: ?*ir_mode, @"type": ?*ir_type, flags: ir_cons_flags) ?*ir_node {
return low_level.new_Load(irn_mem, irn_ptr, mode, @"type", flags);
}
pub fn isLoad(node: ?*const ir_node) bool {
return low_level.is_Load(node) == 1;
}
pub fn getLoadMem(node: ?*const ir_node) ?*ir_node {
return low_level.get_Load_mem(node);
}
pub fn setLoadMem(node: ?*ir_node, mem: ?*ir_node) void {
return low_level.set_Load_mem(node, mem);
}
pub fn getLoadPtr(node: ?*const ir_node) ?*ir_node {
return low_level.get_Load_ptr(node);
}
pub fn setLoadPtr(node: ?*ir_node, ptr: ?*ir_node) void {
return low_level.set_Load_ptr(node, ptr);
}
pub fn getLoadMode(node: ?*const ir_node) ?*ir_mode {
return low_level.get_Load_mode(node);
}
pub fn setLoadMode(node: ?*ir_node, mode: ?*ir_mode) void {
return low_level.set_Load_mode(node, mode);
}
pub fn getLoadType(node: ?*const ir_node) ?*ir_type {
return low_level.get_Load_type(node);
}
pub fn setLoadType(node: ?*ir_node, @"type": ?*ir_type) void {
return low_level.set_Load_type(node, @"type");
}
pub fn getLoadVolatility(node: ?*const ir_node) ir_volatility {
return @intToEnum(ir_volatility, low_level.get_Load_volatility(node));
}
pub fn setLoadVolatility(node: ?*ir_node, volatility: u32) void {
return low_level.set_Load_volatility(node, volatility);
}
pub fn getLoadUnaligned(node: ?*const ir_node) ir_align {
return @intToEnum(ir_align, low_level.get_Load_unaligned(node));
}
pub fn setLoadUnaligned(node: ?*ir_node, unaligned: u32) void {
return low_level.set_Load_unaligned(node, unaligned);
}
pub fn getOpLoad() ?*ir_op {
return low_level.get_op_Load();
}
pub fn newRdMember(dbgi: ?*dbg_info, block: ?*ir_node, irn_ptr: ?*ir_node, entity: ?*ir_entity) ?*ir_node {
return low_level.new_rd_Member(dbgi, block, irn_ptr, entity);
}
pub fn newRMember(block: ?*ir_node, irn_ptr: ?*ir_node, entity: ?*ir_entity) ?*ir_node {
return low_level.new_r_Member(block, irn_ptr, entity);
}
pub fn newDMember(dbgi: ?*dbg_info, irn_ptr: ?*ir_node, entity: ?*ir_entity) ?*ir_node {
return low_level.new_d_Member(dbgi, irn_ptr, entity);
}
pub fn newMember(irn_ptr: ?*ir_node, entity: ?*ir_entity) ?*ir_node {
return low_level.new_Member(irn_ptr, entity);
}
pub fn isMember(node: ?*const ir_node) bool {
return low_level.is_Member(node) == 1;
}
pub fn getMemberPtr(node: ?*const ir_node) ?*ir_node {
return low_level.get_Member_ptr(node);
}
pub fn setMemberPtr(node: ?*ir_node, ptr: ?*ir_node) void {
return low_level.set_Member_ptr(node, ptr);
}
pub fn getMemberEntity(node: ?*const ir_node) ?*ir_entity {
return low_level.get_Member_entity(node);
}
pub fn setMemberEntity(node: ?*ir_node, entity: ?*ir_entity) void {
return low_level.set_Member_entity(node, entity);
}
pub fn getOpMember() ?*ir_op {
return low_level.get_op_Member();
}
pub fn newRdMinus(dbgi: ?*dbg_info, block: ?*ir_node, irn_op: ?*ir_node) ?*ir_node {
return low_level.new_rd_Minus(dbgi, block, irn_op);
}
pub fn newRMinus(block: ?*ir_node, irn_op: ?*ir_node) ?*ir_node {
return low_level.new_r_Minus(block, irn_op);
}
pub fn newDMinus(dbgi: ?*dbg_info, irn_op: ?*ir_node) ?*ir_node {
return low_level.new_d_Minus(dbgi, irn_op);
}
pub fn newMinus(irn_op: ?*ir_node) ?*ir_node {
return low_level.new_Minus(irn_op);
}
pub fn isMinus(node: ?*const ir_node) bool {
return low_level.is_Minus(node) == 1;
}
pub fn getMinusOp(node: ?*const ir_node) ?*ir_node {
return low_level.get_Minus_op(node);
}
pub fn setMinusOp(node: ?*ir_node, op: ?*ir_node) void {
return low_level.set_Minus_op(node, op);
}
pub fn getOpMinus() ?*ir_op {
return low_level.get_op_Minus();
}
pub fn newRdMod(dbgi: ?*dbg_info, block: ?*ir_node, irn_mem: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node, pinned: i32) ?*ir_node {
return low_level.new_rd_Mod(dbgi, block, irn_mem, irn_left, irn_right, pinned);
}
pub fn newRMod(block: ?*ir_node, irn_mem: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node, pinned: i32) ?*ir_node {
return low_level.new_r_Mod(block, irn_mem, irn_left, irn_right, pinned);
}
pub fn newDMod(dbgi: ?*dbg_info, irn_mem: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node, pinned: i32) ?*ir_node {
return low_level.new_d_Mod(dbgi, irn_mem, irn_left, irn_right, pinned);
}
pub fn newMod(irn_mem: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node, pinned: i32) ?*ir_node {
return low_level.new_Mod(irn_mem, irn_left, irn_right, pinned);
}
pub fn isMod(node: ?*const ir_node) bool {
return low_level.is_Mod(node) == 1;
}
pub fn getModMem(node: ?*const ir_node) ?*ir_node {
return low_level.get_Mod_mem(node);
}
pub fn setModMem(node: ?*ir_node, mem: ?*ir_node) void {
return low_level.set_Mod_mem(node, mem);
}
pub fn getModLeft(node: ?*const ir_node) ?*ir_node {
return low_level.get_Mod_left(node);
}
pub fn setModLeft(node: ?*ir_node, left: ?*ir_node) void {
return low_level.set_Mod_left(node, left);
}
pub fn getModRight(node: ?*const ir_node) ?*ir_node {
return low_level.get_Mod_right(node);
}
pub fn setModRight(node: ?*ir_node, right: ?*ir_node) void {
return low_level.set_Mod_right(node, right);
}
pub fn getModResmode(node: ?*const ir_node) ?*ir_mode {
return low_level.get_Mod_resmode(node);
}
pub fn setModResmode(node: ?*ir_node, resmode: ?*ir_mode) void {
return low_level.set_Mod_resmode(node, resmode);
}
pub fn getOpMod() ?*ir_op {
return low_level.get_op_Mod();
}
pub fn newRdMul(dbgi: ?*dbg_info, block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node {
return low_level.new_rd_Mul(dbgi, block, irn_left, irn_right);
}
pub fn newRMul(block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node {
return low_level.new_r_Mul(block, irn_left, irn_right);
}
pub fn newDMul(dbgi: ?*dbg_info, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node {
return low_level.new_d_Mul(dbgi, irn_left, irn_right);
}
pub fn newMul(irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node {
return low_level.new_Mul(irn_left, irn_right);
}
pub fn isMul(node: ?*const ir_node) bool {
return low_level.is_Mul(node) == 1;
}
pub fn getMulLeft(node: ?*const ir_node) ?*ir_node {
return low_level.get_Mul_left(node);
}
pub fn setMulLeft(node: ?*ir_node, left: ?*ir_node) void {
return low_level.set_Mul_left(node, left);
}
pub fn getMulRight(node: ?*const ir_node) ?*ir_node {
return low_level.get_Mul_right(node);
}
pub fn setMulRight(node: ?*ir_node, right: ?*ir_node) void {
return low_level.set_Mul_right(node, right);
}
pub fn getOpMul() ?*ir_op {
return low_level.get_op_Mul();
}
pub fn newRdMulh(dbgi: ?*dbg_info, block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node {
return low_level.new_rd_Mulh(dbgi, block, irn_left, irn_right);
}
pub fn newRMulh(block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node {
return low_level.new_r_Mulh(block, irn_left, irn_right);
}
pub fn newDMulh(dbgi: ?*dbg_info, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node {
return low_level.new_d_Mulh(dbgi, irn_left, irn_right);
}
pub fn newMulh(irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node {
return low_level.new_Mulh(irn_left, irn_right);
}
pub fn isMulh(node: ?*const ir_node) bool {
return low_level.is_Mulh(node) == 1;
}
pub fn getMulhLeft(node: ?*const ir_node) ?*ir_node {
return low_level.get_Mulh_left(node);
}
pub fn setMulhLeft(node: ?*ir_node, left: ?*ir_node) void {
return low_level.set_Mulh_left(node, left);
}
pub fn getMulhRight(node: ?*const ir_node) ?*ir_node {
return low_level.get_Mulh_right(node);
}
pub fn setMulhRight(node: ?*ir_node, right: ?*ir_node) void {
return low_level.set_Mulh_right(node, right);
}
pub fn getOpMulh() ?*ir_op {
return low_level.get_op_Mulh();
}
pub fn newRdMux(dbgi: ?*dbg_info, block: ?*ir_node, irn_sel: ?*ir_node, irn_false: ?*ir_node, irn_true: ?*ir_node) ?*ir_node {
return low_level.new_rd_Mux(dbgi, block, irn_sel, irn_false, irn_true);
}
pub fn newRMux(block: ?*ir_node, irn_sel: ?*ir_node, irn_false: ?*ir_node, irn_true: ?*ir_node) ?*ir_node {
return low_level.new_r_Mux(block, irn_sel, irn_false, irn_true);
}
pub fn newDMux(dbgi: ?*dbg_info, irn_sel: ?*ir_node, irn_false: ?*ir_node, irn_true: ?*ir_node) ?*ir_node {
return low_level.new_d_Mux(dbgi, irn_sel, irn_false, irn_true);
}
pub fn newMux(irn_sel: ?*ir_node, irn_false: ?*ir_node, irn_true: ?*ir_node) ?*ir_node {
return low_level.new_Mux(irn_sel, irn_false, irn_true);
}
pub fn isMux(node: ?*const ir_node) bool {
return low_level.is_Mux(node) == 1;
}
pub fn getMuxSel(node: ?*const ir_node) ?*ir_node {
return low_level.get_Mux_sel(node);
}
pub fn setMuxSel(node: ?*ir_node, sel: ?*ir_node) void {
return low_level.set_Mux_sel(node, sel);
}
pub fn getMuxFalse(node: ?*const ir_node) ?*ir_node {
return low_level.get_Mux_false(node);
}
pub fn setMuxFalse(node: ?*ir_node, false_: ?*ir_node) void {
return low_level.set_Mux_false(node, false_);
}
pub fn getMuxTrue(node: ?*const ir_node) ?*ir_node {
return low_level.get_Mux_true(node);
}
pub fn setMuxTrue(node: ?*ir_node, true_: ?*ir_node) void {
return low_level.set_Mux_true(node, true_);
}
pub fn getOpMux() ?*ir_op {
return low_level.get_op_Mux();
}
pub fn newRdNomem(dbgi: ?*dbg_info, irg: ?*ir_graph) ?*ir_node {
return low_level.new_rd_NoMem(dbgi, irg);
}
pub fn newRNomem(irg: ?*ir_graph) ?*ir_node {
return low_level.new_r_NoMem(irg);
}
pub fn newDNomem(dbgi: ?*dbg_info) ?*ir_node {
return low_level.new_d_NoMem(dbgi);
}
pub fn newNomem() ?*ir_node {
return low_level.new_NoMem();
}
pub fn isNomem(node: ?*const ir_node) bool {
return low_level.is_NoMem(node) == 1;
}
pub fn getOpNomem() ?*ir_op {
return low_level.get_op_NoMem();
}
pub fn newRdNot(dbgi: ?*dbg_info, block: ?*ir_node, irn_op: ?*ir_node) ?*ir_node {
return low_level.new_rd_Not(dbgi, block, irn_op);
}
pub fn newRNot(block: ?*ir_node, irn_op: ?*ir_node) ?*ir_node {
return low_level.new_r_Not(block, irn_op);
}
pub fn newDNot(dbgi: ?*dbg_info, irn_op: ?*ir_node) ?*ir_node {
return low_level.new_d_Not(dbgi, irn_op);
}
pub fn newNot(irn_op: ?*ir_node) ?*ir_node {
return low_level.new_Not(irn_op);
}
pub fn isNot(node: ?*const ir_node) bool {
return low_level.is_Not(node) == 1;
}
pub fn getNotOp(node: ?*const ir_node) ?*ir_node {
return low_level.get_Not_op(node);
}
pub fn setNotOp(node: ?*ir_node, op: ?*ir_node) void {
return low_level.set_Not_op(node, op);
}
pub fn getOpNot() ?*ir_op {
return low_level.get_op_Not();
}
pub fn newRdOffset(dbgi: ?*dbg_info, irg: ?*ir_graph, mode: ?*ir_mode, entity: ?*ir_entity) ?*ir_node {
return low_level.new_rd_Offset(dbgi, irg, mode, entity);
}
pub fn newROffset(irg: ?*ir_graph, mode: ?*ir_mode, entity: ?*ir_entity) ?*ir_node {
return low_level.new_r_Offset(irg, mode, entity);
}
pub fn newDOffset(dbgi: ?*dbg_info, mode: ?*ir_mode, entity: ?*ir_entity) ?*ir_node {
return low_level.new_d_Offset(dbgi, mode, entity);
}
pub fn newOffset(mode: ?*ir_mode, entity: ?*ir_entity) ?*ir_node {
return low_level.new_Offset(mode, entity);
}
pub fn isOffset(node: ?*const ir_node) bool {
return low_level.is_Offset(node) == 1;
}
pub fn getOffsetEntity(node: ?*const ir_node) ?*ir_entity {
return low_level.get_Offset_entity(node);
}
pub fn setOffsetEntity(node: ?*ir_node, entity: ?*ir_entity) void {
return low_level.set_Offset_entity(node, entity);
}
pub fn getOpOffset() ?*ir_op {
return low_level.get_op_Offset();
}
pub fn newRdOr(dbgi: ?*dbg_info, block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node {
return low_level.new_rd_Or(dbgi, block, irn_left, irn_right);
}
pub fn newROr(block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node {
return low_level.new_r_Or(block, irn_left, irn_right);
}
pub fn newDOr(dbgi: ?*dbg_info, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node {
return low_level.new_d_Or(dbgi, irn_left, irn_right);
}
pub fn newOr(irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node {
return low_level.new_Or(irn_left, irn_right);
}
pub fn isOr(node: ?*const ir_node) bool {
return low_level.is_Or(node) == 1;
}
pub fn getOrLeft(node: ?*const ir_node) ?*ir_node {
return low_level.get_Or_left(node);
}
pub fn setOrLeft(node: ?*ir_node, left: ?*ir_node) void {
return low_level.set_Or_left(node, left);
}
pub fn getOrRight(node: ?*const ir_node) ?*ir_node {
return low_level.get_Or_right(node);
}
pub fn setOrRight(node: ?*ir_node, right: ?*ir_node) void {
return low_level.set_Or_right(node, right);
}
pub fn getOpOr() ?*ir_op {
return low_level.get_op_Or();
}
pub fn newRdPhi(dbgi: ?*dbg_info, block: ?*ir_node, arity: i32, in: [*]const ?*ir_node, mode: ?*ir_mode) ?*ir_node {
return low_level.new_rd_Phi(dbgi, block, arity, in, mode);
}
pub fn newRPhi(block: ?*ir_node, arity: i32, in: [*]const ?*ir_node, mode: ?*ir_mode) ?*ir_node {
return low_level.new_r_Phi(block, arity, in, mode);
}
pub fn newDPhi(dbgi: ?*dbg_info, arity: i32, in: [*]const ?*ir_node, mode: ?*ir_mode) ?*ir_node {
return low_level.new_d_Phi(dbgi, arity, in, mode);
}
pub fn newPhi(arity: i32, in: [*]const ?*ir_node, mode: ?*ir_mode) ?*ir_node {
return low_level.new_Phi(arity, in, mode);
}
pub fn isPhi(node: ?*const ir_node) bool {
return low_level.is_Phi(node) == 1;
}
pub fn getPhiNPreds(node: ?*const ir_node) i32 {
return low_level.get_Phi_n_preds(node);
}
pub fn getPhiPred(node: ?*const ir_node, pos: i32) ?*ir_node {
return low_level.get_Phi_pred(node, pos);
}
pub fn setPhiPred(node: ?*ir_node, pos: i32, pred: ?*ir_node) void {
return low_level.set_Phi_pred(node, pos, pred);
}
pub fn getPhiPredArr(node: ?*ir_node) [*]?*ir_node {
return low_level.get_Phi_pred_arr(node);
}
pub fn getPhiLoop(node: ?*const ir_node) i32 {
return low_level.get_Phi_loop(node);
}
pub fn setPhiLoop(node: ?*ir_node, loop: i32) void {
return low_level.set_Phi_loop(node, loop);
}
pub fn getOpPhi() ?*ir_op {
return low_level.get_op_Phi();
}
pub fn newRdPin(dbgi: ?*dbg_info, block: ?*ir_node, irn_op: ?*ir_node) ?*ir_node {
return low_level.new_rd_Pin(dbgi, block, irn_op);
}
pub fn newRPin(block: ?*ir_node, irn_op: ?*ir_node) ?*ir_node {
return low_level.new_r_Pin(block, irn_op);
}
pub fn newDPin(dbgi: ?*dbg_info, irn_op: ?*ir_node) ?*ir_node {
return low_level.new_d_Pin(dbgi, irn_op);
}
pub fn newPin(irn_op: ?*ir_node) ?*ir_node {
return low_level.new_Pin(irn_op);
}
pub fn isPin(node: ?*const ir_node) bool {
return low_level.is_Pin(node) == 1;
}
pub fn getPinOp(node: ?*const ir_node) ?*ir_node {
return low_level.get_Pin_op(node);
}
pub fn setPinOp(node: ?*ir_node, op: ?*ir_node) void {
return low_level.set_Pin_op(node, op);
}
pub fn getOpPin() ?*ir_op {
return low_level.get_op_Pin();
}
pub fn newRdProj(dbgi: ?*dbg_info, irn_pred: ?*ir_node, mode: ?*ir_mode, num: u32) ?*ir_node {
return low_level.new_rd_Proj(dbgi, irn_pred, mode, num);
}
pub fn newRProj(irn_pred: ?*ir_node, mode: ?*ir_mode, num: u32) ?*ir_node {
return low_level.new_r_Proj(irn_pred, mode, num);
}
pub fn newDProj(dbgi: ?*dbg_info, irn_pred: ?*ir_node, mode: ?*ir_mode, num: u32) ?*ir_node {
return low_level.new_d_Proj(dbgi, irn_pred, mode, num);
}
pub fn newProj(irn_pred: ?*ir_node, mode: ?*ir_mode, num: u32) ?*ir_node {
return low_level.new_Proj(irn_pred, mode, num);
}
pub fn isProj(node: ?*const ir_node) bool {
return low_level.is_Proj(node) == 1;
}
pub fn getProjPred(node: ?*const ir_node) ?*ir_node {
return low_level.get_Proj_pred(node);
}
pub fn setProjPred(node: ?*ir_node, pred: ?*ir_node) void {
return low_level.set_Proj_pred(node, pred);
}
pub fn getProjNum(node: ?*const ir_node) u32 {
return low_level.get_Proj_num(node);
}
pub fn setProjNum(node: ?*ir_node, num: u32) void {
return low_level.set_Proj_num(node, num);
}
pub fn getOpProj() ?*ir_op {
return low_level.get_op_Proj();
}
pub fn newRdRaise(dbgi: ?*dbg_info, block: ?*ir_node, irn_mem: ?*ir_node, irn_exo_ptr: ?*ir_node) ?*ir_node {
return low_level.new_rd_Raise(dbgi, block, irn_mem, irn_exo_ptr);
}
pub fn newRRaise(block: ?*ir_node, irn_mem: ?*ir_node, irn_exo_ptr: ?*ir_node) ?*ir_node {
return low_level.new_r_Raise(block, irn_mem, irn_exo_ptr);
}
pub fn newDRaise(dbgi: ?*dbg_info, irn_mem: ?*ir_node, irn_exo_ptr: ?*ir_node) ?*ir_node {
return low_level.new_d_Raise(dbgi, irn_mem, irn_exo_ptr);
}
pub fn newRaise(irn_mem: ?*ir_node, irn_exo_ptr: ?*ir_node) ?*ir_node {
return low_level.new_Raise(irn_mem, irn_exo_ptr);
}
pub fn isRaise(node: ?*const ir_node) bool {
return low_level.is_Raise(node) == 1;
}
pub fn getRaiseMem(node: ?*const ir_node) ?*ir_node {
return low_level.get_Raise_mem(node);
}
pub fn setRaiseMem(node: ?*ir_node, mem: ?*ir_node) void {
return low_level.set_Raise_mem(node, mem);
}
pub fn getRaiseExoPtr(node: ?*const ir_node) ?*ir_node {
return low_level.get_Raise_exo_ptr(node);
}
pub fn setRaiseExoPtr(node: ?*ir_node, exo_ptr: ?*ir_node) void {
return low_level.set_Raise_exo_ptr(node, exo_ptr);
}
pub fn getOpRaise() ?*ir_op {
return low_level.get_op_Raise();
}
pub fn newRdReturn(dbgi: ?*dbg_info, block: ?*ir_node, irn_mem: ?*ir_node, arity: i32, in: *?*ir_node) ?*ir_node {
return low_level.new_rd_Return(dbgi, block, irn_mem, arity, in);
}
pub fn newRReturn(block: ?*ir_node, irn_mem: ?*ir_node, arity: i32, in: *?*ir_node) ?*ir_node {
return low_level.new_r_Return(block, irn_mem, arity, in);
}
pub fn newDReturn(dbgi: ?*dbg_info, irn_mem: ?*ir_node, arity: i32, in: *?*ir_node) ?*ir_node {
return low_level.new_d_Return(dbgi, irn_mem, arity, in);
}
pub fn newReturn(irn_mem: ?*ir_node, arity: i32, in: *?*ir_node) ?*ir_node {
return low_level.new_Return(irn_mem, arity, in);
}
pub fn isReturn(node: ?*const ir_node) bool {
return low_level.is_Return(node) == 1;
}
pub fn getReturnMem(node: ?*const ir_node) ?*ir_node {
return low_level.get_Return_mem(node);
}
pub fn setReturnMem(node: ?*ir_node, mem: ?*ir_node) void {
return low_level.set_Return_mem(node, mem);
}
pub fn getReturnNRess(node: ?*const ir_node) i32 {
return low_level.get_Return_n_ress(node);
}
pub fn getReturnRes(node: ?*const ir_node, pos: i32) ?*ir_node {
return low_level.get_Return_res(node, pos);
}
pub fn setReturnRes(node: ?*ir_node, pos: i32, res: ?*ir_node) void {
return low_level.set_Return_res(node, pos, res);
}
pub fn getReturnResArr(node: ?*ir_node) [*]?*ir_node {
return low_level.get_Return_res_arr(node);
}
pub fn getOpReturn() ?*ir_op {
return low_level.get_op_Return();
}
pub fn newRdSel(dbgi: ?*dbg_info, block: ?*ir_node, irn_ptr: ?*ir_node, irn_index: ?*ir_node, @"type": ?*ir_type) ?*ir_node {
return low_level.new_rd_Sel(dbgi, block, irn_ptr, irn_index, @"type");
}
pub fn newRSel(block: ?*ir_node, irn_ptr: ?*ir_node, irn_index: ?*ir_node, @"type": ?*ir_type) ?*ir_node {
return low_level.new_r_Sel(block, irn_ptr, irn_index, @"type");
}
pub fn newDSel(dbgi: ?*dbg_info, irn_ptr: ?*ir_node, irn_index: ?*ir_node, @"type": ?*ir_type) ?*ir_node {
return low_level.new_d_Sel(dbgi, irn_ptr, irn_index, @"type");
}
pub fn newSel(irn_ptr: ?*ir_node, irn_index: ?*ir_node, @"type": ?*ir_type) ?*ir_node {
return low_level.new_Sel(irn_ptr, irn_index, @"type");
}
pub fn isSel(node: ?*const ir_node) bool {
return low_level.is_Sel(node) == 1;
}
pub fn getSelPtr(node: ?*const ir_node) ?*ir_node {
return low_level.get_Sel_ptr(node);
}
pub fn setSelPtr(node: ?*ir_node, ptr: ?*ir_node) void {
return low_level.set_Sel_ptr(node, ptr);
}
pub fn getSelIndex(node: ?*const ir_node) ?*ir_node {
return low_level.get_Sel_index(node);
}
pub fn setSelIndex(node: ?*ir_node, index: ?*ir_node) void {
return low_level.set_Sel_index(node, index);
}
pub fn getSelType(node: ?*const ir_node) ?*ir_type {
return low_level.get_Sel_type(node);
}
pub fn setSelType(node: ?*ir_node, @"type": ?*ir_type) void {
return low_level.set_Sel_type(node, @"type");
}
pub fn getOpSel() ?*ir_op {
return low_level.get_op_Sel();
}
pub fn newRdShl(dbgi: ?*dbg_info, block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node {
return low_level.new_rd_Shl(dbgi, block, irn_left, irn_right);
}
pub fn newRShl(block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node {
return low_level.new_r_Shl(block, irn_left, irn_right);
}
pub fn newDShl(dbgi: ?*dbg_info, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node {
return low_level.new_d_Shl(dbgi, irn_left, irn_right);
}
pub fn newShl(irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node {
return low_level.new_Shl(irn_left, irn_right);
}
pub fn isShl(node: ?*const ir_node) bool {
return low_level.is_Shl(node) == 1;
}
pub fn getShlLeft(node: ?*const ir_node) ?*ir_node {
return low_level.get_Shl_left(node);
}
pub fn setShlLeft(node: ?*ir_node, left: ?*ir_node) void {
return low_level.set_Shl_left(node, left);
}
pub fn getShlRight(node: ?*const ir_node) ?*ir_node {
return low_level.get_Shl_right(node);
}
pub fn setShlRight(node: ?*ir_node, right: ?*ir_node) void {
return low_level.set_Shl_right(node, right);
}
pub fn getOpShl() ?*ir_op {
return low_level.get_op_Shl();
}
pub fn irPrintf(fmt: [*]const u8, variadic: anytype) i32 {
return low_level.ir_printf(fmt, variadic);
}
pub fn irFprintf(f: *std.c.FILE, fmt: [*]const u8, variadic: anytype) i32 {
return low_level.ir_fprintf(f, fmt, variadic);
}
pub fn irSnprintf(buf: [*]u8, n: usize, fmt: [*]const u8, variadic: anytype) i32 {
return low_level.ir_snprintf(buf, n, fmt, variadic);
}
pub fn irVprintf(fmt: [*]const u8, variadic: anytype) i32 {
return low_level.ir_vprintf(fmt, variadic);
}
pub fn irVfprintf(f: *std.c.FILE, fmt: [*]const u8, variadic: anytype) i32 {
return low_level.ir_vfprintf(f, fmt, variadic);
}
pub fn irVsnprintf(buf: [*]u8, len: usize, fmt: [*]const u8, variadic: anytype) i32 {
return low_level.ir_vsnprintf(buf, len, fmt, variadic);
}
pub fn irObstVprintf(obst: ?*obstack, fmt: [*]const u8, variadic: anytype) i32 {
return low_level.ir_obst_vprintf(obst, fmt, variadic);
}
pub fn tarvalSnprintf(buf: [*]u8, buflen: usize, tv: ?*const ir_tarval) i32 {
return low_level.tarval_snprintf(buf, buflen, tv);
}
pub fn newRdShr(dbgi: ?*dbg_info, block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node {
return low_level.new_rd_Shr(dbgi, block, irn_left, irn_right);
}
pub fn newRShr(block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node {
return low_level.new_r_Shr(block, irn_left, irn_right);
}
pub fn newDShr(dbgi: ?*dbg_info, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node {
return low_level.new_d_Shr(dbgi, irn_left, irn_right);
}
pub fn newShr(irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node {
return low_level.new_Shr(irn_left, irn_right);
}
pub fn isShr(node: ?*const ir_node) bool {
return low_level.is_Shr(node) == 1;
}
pub fn getShrLeft(node: ?*const ir_node) ?*ir_node {
return low_level.get_Shr_left(node);
}
pub fn setShrLeft(node: ?*ir_node, left: ?*ir_node) void {
return low_level.set_Shr_left(node, left);
}
pub fn getShrRight(node: ?*const ir_node) ?*ir_node {
return low_level.get_Shr_right(node);
}
pub fn setShrRight(node: ?*ir_node, right: ?*ir_node) void {
return low_level.set_Shr_right(node, right);
}
pub fn getOpShr() ?*ir_op {
return low_level.get_op_Shr();
}
pub fn newRdShrs(dbgi: ?*dbg_info, block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node {
return low_level.new_rd_Shrs(dbgi, block, irn_left, irn_right);
}
pub fn newRShrs(block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node {
return low_level.new_r_Shrs(block, irn_left, irn_right);
}
pub fn newDShrs(dbgi: ?*dbg_info, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node {
return low_level.new_d_Shrs(dbgi, irn_left, irn_right);
}
pub fn newShrs(irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node {
return low_level.new_Shrs(irn_left, irn_right);
}
pub fn isShrs(node: ?*const ir_node) bool {
return low_level.is_Shrs(node) == 1;
}
pub fn getShrsLeft(node: ?*const ir_node) ?*ir_node {
return low_level.get_Shrs_left(node);
}
pub fn setShrsLeft(node: ?*ir_node, left: ?*ir_node) void {
return low_level.set_Shrs_left(node, left);
}
pub fn getShrsRight(node: ?*const ir_node) ?*ir_node {
return low_level.get_Shrs_right(node);
}
pub fn setShrsRight(node: ?*ir_node, right: ?*ir_node) void {
return low_level.set_Shrs_right(node, right);
}
pub fn getOpShrs() ?*ir_op {
return low_level.get_op_Shrs();
}
pub fn newRdSize(dbgi: ?*dbg_info, irg: ?*ir_graph, mode: ?*ir_mode, @"type": ?*ir_type) ?*ir_node {
return low_level.new_rd_Size(dbgi, irg, mode, @"type");
}
pub fn newRSize(irg: ?*ir_graph, mode: ?*ir_mode, @"type": ?*ir_type) ?*ir_node {
return low_level.new_r_Size(irg, mode, @"type");
}
pub fn newDSize(dbgi: ?*dbg_info, mode: ?*ir_mode, @"type": ?*ir_type) ?*ir_node {
return low_level.new_d_Size(dbgi, mode, @"type");
}
pub fn newSize(mode: ?*ir_mode, @"type": ?*ir_type) ?*ir_node {
return low_level.new_Size(mode, @"type");
}
pub fn isSize(node: ?*const ir_node) bool {
return low_level.is_Size(node) == 1;
}
pub fn getSizeType(node: ?*const ir_node) ?*ir_type {
return low_level.get_Size_type(node);
}
pub fn setSizeType(node: ?*ir_node, @"type": ?*ir_type) void {
return low_level.set_Size_type(node, @"type");
}
pub fn getOpSize() ?*ir_op {
return low_level.get_op_Size();
}
pub fn newRdStart(dbgi: ?*dbg_info, irg: ?*ir_graph) ?*ir_node {
return low_level.new_rd_Start(dbgi, irg);
}
pub fn newRStart(irg: ?*ir_graph) ?*ir_node {
return low_level.new_r_Start(irg);
}
pub fn newDStart(dbgi: ?*dbg_info) ?*ir_node {
return low_level.new_d_Start(dbgi);
}
pub fn newStart() ?*ir_node {
return low_level.new_Start();
}
pub fn isStart(node: ?*const ir_node) bool {
return low_level.is_Start(node) == 1;
}
pub fn getOpStart() ?*ir_op {
return low_level.get_op_Start();
}
pub fn newRdStore(dbgi: ?*dbg_info, block: ?*ir_node, irn_mem: ?*ir_node, irn_ptr: ?*ir_node, irn_value: ?*ir_node, @"type": ?*ir_type, flags: ir_cons_flags) ?*ir_node {
return low_level.new_rd_Store(dbgi, block, irn_mem, irn_ptr, irn_value, @"type", flags);
}
pub fn newRStore(block: ?*ir_node, irn_mem: ?*ir_node, irn_ptr: ?*ir_node, irn_value: ?*ir_node, @"type": ?*ir_type, flags: ir_cons_flags) ?*ir_node {
return low_level.new_r_Store(block, irn_mem, irn_ptr, irn_value, @"type", flags);
}
pub fn newDStore(dbgi: ?*dbg_info, irn_mem: ?*ir_node, irn_ptr: ?*ir_node, irn_value: ?*ir_node, @"type": ?*ir_type, flags: ir_cons_flags) ?*ir_node {
return low_level.new_d_Store(dbgi, irn_mem, irn_ptr, irn_value, @"type", flags);
}
pub fn newStore(irn_mem: ?*ir_node, irn_ptr: ?*ir_node, irn_value: ?*ir_node, @"type": ?*ir_type, flags: ir_cons_flags) ?*ir_node {
return low_level.new_Store(irn_mem, irn_ptr, irn_value, @"type", flags);
}
pub fn isStore(node: ?*const ir_node) bool {
return low_level.is_Store(node) == 1;
}
pub fn getStoreMem(node: ?*const ir_node) ?*ir_node {
return low_level.get_Store_mem(node);
}
pub fn setStoreMem(node: ?*ir_node, mem: ?*ir_node) void {
return low_level.set_Store_mem(node, mem);
}
pub fn getStorePtr(node: ?*const ir_node) ?*ir_node {
return low_level.get_Store_ptr(node);
}
pub fn setStorePtr(node: ?*ir_node, ptr: ?*ir_node) void {
return low_level.set_Store_ptr(node, ptr);
}
pub fn getStoreValue(node: ?*const ir_node) ?*ir_node {
return low_level.get_Store_value(node);
}
pub fn setStoreValue(node: ?*ir_node, value: ?*ir_node) void {
return low_level.set_Store_value(node, value);
}
pub fn getStoreType(node: ?*const ir_node) ?*ir_type {
return low_level.get_Store_type(node);
}
pub fn setStoreType(node: ?*ir_node, @"type": ?*ir_type) void {
return low_level.set_Store_type(node, @"type");
}
pub fn getStoreVolatility(node: ?*const ir_node) ir_volatility {
return @intToEnum(ir_volatility, low_level.get_Store_volatility(node));
}
pub fn setStoreVolatility(node: ?*ir_node, volatility: u32) void {
return low_level.set_Store_volatility(node, volatility);
}
pub fn getStoreUnaligned(node: ?*const ir_node) ir_align {
return @intToEnum(ir_align, low_level.get_Store_unaligned(node));
}
pub fn setStoreUnaligned(node: ?*ir_node, unaligned: u32) void {
return low_level.set_Store_unaligned(node, unaligned);
}
pub fn getOpStore() ?*ir_op {
return low_level.get_op_Store();
}
pub fn newRdSub(dbgi: ?*dbg_info, block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node {
return low_level.new_rd_Sub(dbgi, block, irn_left, irn_right);
}
pub fn newRSub(block: ?*ir_node, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node {
return low_level.new_r_Sub(block, irn_left, irn_right);
}
pub fn newDSub(dbgi: ?*dbg_info, irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node {
return low_level.new_d_Sub(dbgi, irn_left, irn_right);
}
pub fn newSub(irn_left: ?*ir_node, irn_right: ?*ir_node) ?*ir_node {
return low_level.new_Sub(irn_left, irn_right);
}
pub fn isSub(node: ?*const ir_node) bool {
return low_level.is_Sub(node) == 1;
}
pub fn getSubLeft(node: ?*const ir_node) ?*ir_node {
return low_level.get_Sub_left(node);
}
pub fn setSubLeft(node: ?*ir_node, left: ?*ir_node) void {
return low_level.set_Sub_left(node, left);
}
pub fn getSubRight(node: ?*const ir_node) ?*ir_node {
return low_level.get_Sub_right(node);
}
pub fn setSubRight(node: ?*ir_node, right: ?*ir_node) void {
return low_level.set_Sub_right(node, right);
}
pub fn getOpSub() ?*ir_op {
return low_level.get_op_Sub();
}
pub fn newRdSwitch(dbgi: ?*dbg_info, block: ?*ir_node, irn_selector: ?*ir_node, n_outs: u32, table: ?*ir_switch_table) ?*ir_node {
return low_level.new_rd_Switch(dbgi, block, irn_selector, n_outs, table);
}
pub fn newRSwitch(block: ?*ir_node, irn_selector: ?*ir_node, n_outs: u32, table: ?*ir_switch_table) ?*ir_node {
return low_level.new_r_Switch(block, irn_selector, n_outs, table);
}
pub fn newDSwitch(dbgi: ?*dbg_info, irn_selector: ?*ir_node, n_outs: u32, table: ?*ir_switch_table) ?*ir_node {
return low_level.new_d_Switch(dbgi, irn_selector, n_outs, table);
}
pub fn newSwitch(irn_selector: ?*ir_node, n_outs: u32, table: ?*ir_switch_table) ?*ir_node {
return low_level.new_Switch(irn_selector, n_outs, table);
}
pub fn isSwitch(node: ?*const ir_node) bool {
return low_level.is_Switch(node) == 1;
}
pub fn getSwitchSelector(node: ?*const ir_node) ?*ir_node {
return low_level.get_Switch_selector(node);
}
pub fn setSwitchSelector(node: ?*ir_node, selector: ?*ir_node) void {
return low_level.set_Switch_selector(node, selector);
}
pub fn getSwitchNOuts(node: ?*const ir_node) u32 {
return low_level.get_Switch_n_outs(node);
}
pub fn setSwitchNOuts(node: ?*ir_node, n_outs: u32) void {
return low_level.set_Switch_n_outs(node, n_outs);
}
pub fn getSwitchTable(node: ?*const ir_node) ?*ir_switch_table {
return low_level.get_Switch_table(node);
}
pub fn setSwitchTable(node: ?*ir_node, table: ?*ir_switch_table) void {
return low_level.set_Switch_table(node, table);
}
pub fn getOpSwitch() ?*ir_op {
return low_level.get_op_Switch();
}
pub fn newRdSync(dbgi: ?*dbg_info, block: ?*ir_node, arity: i32, in: [*]const ?*ir_node) ?*ir_node {
return low_level.new_rd_Sync(dbgi, block, arity, in);
}
pub fn newRSync(block: ?*ir_node, arity: i32, in: [*]const ?*ir_node) ?*ir_node {
return low_level.new_r_Sync(block, arity, in);
}
pub fn newDSync(dbgi: ?*dbg_info, arity: i32, in: [*]const ?*ir_node) ?*ir_node {
return low_level.new_d_Sync(dbgi, arity, in);
}
pub fn newSync(arity: i32, in: [*]const ?*ir_node) ?*ir_node {
return low_level.new_Sync(arity, in);
}
pub fn isSync(node: ?*const ir_node) bool {
return low_level.is_Sync(node) == 1;
}
pub fn getSyncNPreds(node: ?*const ir_node) i32 {
return low_level.get_Sync_n_preds(node);
}
pub fn getSyncPred(node: ?*const ir_node, pos: i32) ?*ir_node {
return low_level.get_Sync_pred(node, pos);
}
pub fn setSyncPred(node: ?*ir_node, pos: i32, pred: ?*ir_node) void {
return low_level.set_Sync_pred(node, pos, pred);
}
pub fn getSyncPredArr(node: ?*ir_node) [*]?*ir_node {
return low_level.get_Sync_pred_arr(node);
}
pub fn getOpSync() ?*ir_op {
return low_level.get_op_Sync();
}
pub fn newRdTuple(dbgi: ?*dbg_info, block: ?*ir_node, arity: i32, in: [*]const ?*ir_node) ?*ir_node {
return low_level.new_rd_Tuple(dbgi, block, arity, in);
}
pub fn newRTuple(block: ?*ir_node, arity: i32, in: [*]const ?*ir_node) ?*ir_node {
return low_level.new_r_Tuple(block, arity, in);
}
pub fn newDTuple(dbgi: ?*dbg_info, arity: i32, in: [*]const ?*ir_node) ?*ir_node {
return low_level.new_d_Tuple(dbgi, arity, in);
}
pub fn newTuple(arity: i32, in: [*]const ?*ir_node) ?*ir_node {
return low_level.new_Tuple(arity, in);
}
pub fn isTuple(node: ?*const ir_node) bool {
return low_level.is_Tuple(node) == 1;
}
pub fn getTupleNPreds(node: ?*const ir_node) i32 {
return low_level.get_Tuple_n_preds(node);
}
pub fn getTuplePred(node: ?*const ir_node, pos: i32) ?*ir_node {
return low_level.get_Tuple_pred(node, pos);
}
pub fn setTuplePred(node: ?*ir_node, pos: i32, pred: ?*ir_node) void {
return low_level.set_Tuple_pred(node, pos, pred);
}
pub fn getTuplePredArr(node: ?*ir_node) [*]?*ir_node {
return low_level.get_Tuple_pred_arr(node);
}
pub fn getOpTuple() ?*ir_op {
return low_level.get_op_Tuple();
}
pub fn newRdUnknown(dbgi: ?*dbg_info, irg: ?*ir_graph, mode: ?*ir_mode) ?*ir_node {
return low_level.new_rd_Unknown(dbgi, irg, mode);
}
pub fn newRUnknown(irg: ?*ir_graph, mode: ?*ir_mode) ?*ir_node {
return low_level.new_r_Unknown(irg, mode);
}
pub fn newDUnknown(dbgi: ?*dbg_info, mode: ?*ir_mode) ?*ir_node {
return low_level.new_d_Unknown(dbgi, mode);
}
pub fn newUnknown(mode: ?*ir_mode) ?*ir_node {
return low_level.new_Unknown(mode);
}
pub fn isUnknown(node: ?*const ir_node) bool {
return low_level.is_Unknown(node) == 1;
}
pub fn getOpUnknown() ?*ir_op {
return low_level.get_op_Unknown();
}
pub fn isBinop(node: ?*const ir_node) bool {
return low_level.is_binop(node) == 1;
}
pub fn isEntconst(node: ?*const ir_node) bool {
return low_level.is_entconst(node) == 1;
}
pub fn getEntconstEntity(node: ?*const ir_node) ?*ir_entity {
return low_level.get_entconst_entity(node);
}
pub fn setEntconstEntity(node: ?*ir_node, entity: ?*ir_entity) void {
return low_level.set_entconst_entity(node, entity);
}
pub fn isTypeconst(node: ?*const ir_node) bool {
return low_level.is_typeconst(node) == 1;
}
pub fn getTypeconstType(node: ?*const ir_node) ?*ir_type {
return low_level.get_typeconst_type(node);
}
pub fn setTypeconstType(node: ?*ir_node, @"type": ?*ir_type) void {
return low_level.set_typeconst_type(node, @"type");
}
pub fn getIrnArity(node: ?*const ir_node) i32 {
return low_level.get_irn_arity(node);
}
pub fn getIrnN(node: ?*const ir_node, n: i32) ?*ir_node {
return low_level.get_irn_n(node, n);
}
pub fn setIrnIn(node: ?*ir_node, arity: i32, in: [*]const ?*ir_node) void {
return low_level.set_irn_in(node, arity, in);
}
pub fn setIrnN(node: ?*ir_node, n: i32, in: ?*ir_node) void {
return low_level.set_irn_n(node, n, in);
}
pub fn addIrnN(node: ?*ir_node, in: ?*ir_node) i32 {
return low_level.add_irn_n(node, in);
}
pub fn setIrnMode(node: ?*ir_node, mode: ?*ir_mode) void {
return low_level.set_irn_mode(node, mode);
}
pub fn getIrnMode(node: ?*const ir_node) ?*ir_mode {
return low_level.get_irn_mode(node);
}
pub fn getIrnOp(node: ?*const ir_node) ?*ir_op {
return low_level.get_irn_op(node);
}
pub fn getIrnOpcode(node: ?*const ir_node) u32 {
return low_level.get_irn_opcode(node);
}
pub fn getIrnOpname(node: ?*const ir_node) [*]const u8 {
return low_level.get_irn_opname(node);
}
pub fn getIrnOpident(node: ?*const ir_node) [*]const u8 {
return low_level.get_irn_opident(node);
}
pub fn getIrnVisited(node: ?*const ir_node) ir_visited_t {
return low_level.get_irn_visited(node);
}
pub fn setIrnVisited(node: ?*ir_node, visited: ir_visited_t) void {
return low_level.set_irn_visited(node, visited);
}
pub fn markIrnVisited(node: ?*ir_node) void {
return low_level.mark_irn_visited(node);
}
pub fn irnVisited(node: ?*const ir_node) i32 {
return low_level.irn_visited(node);
}
pub fn irnVisitedElseMark(node: ?*ir_node) i32 {
return low_level.irn_visited_else_mark(node);
}
pub fn setIrnLink(node: ?*ir_node, link: ?*anyopaque) void {
return low_level.set_irn_link(node, link);
}
pub fn getIrnLink(node: ?*const ir_node) ?*anyopaque {
return low_level.get_irn_link(node);
}
pub fn getIrnIrg(node: ?*const ir_node) ?*ir_graph {
return low_level.get_irn_irg(node);
}
pub fn getIrnNodeNr(node: ?*const ir_node) i64 {
return low_level.get_irn_node_nr(node);
}
pub fn getIrnPinned(node: ?*const ir_node) i32 {
return low_level.get_irn_pinned(node);
}
pub fn setIrnPinned(node: ?*ir_node, pinned: i32) void {
return low_level.set_irn_pinned(node, pinned);
}
pub fn newIrNode(db: ?*dbg_info, irg: ?*ir_graph, block: ?*ir_node, op: ?*ir_op, mode: ?*ir_mode, arity: i32, in: [*]const ?*ir_node) ?*ir_node {
return low_level.new_ir_node(db, irg, block, op, mode, arity, in);
}
pub fn exactCopy(node: ?*const ir_node) ?*ir_node {
return low_level.exact_copy(node);
}
pub fn irnCopyIntoIrg(node: ?*const ir_node, irg: ?*ir_graph) ?*ir_node {
return low_level.irn_copy_into_irg(node, irg);
}
pub fn getNodesBlock(node: ?*const ir_node) ?*ir_node {
return low_level.get_nodes_block(node);
}
pub fn setNodesBlock(node: ?*ir_node, block: ?*ir_node) void {
return low_level.set_nodes_block(node, block);
}
pub fn getBlockCfgpredBlock(node: ?*const ir_node, pos: i32) ?*ir_node {
return low_level.get_Block_cfgpred_block(node, pos);
}
pub fn getBlockMatured(block: ?*const ir_node) i32 {
return low_level.get_Block_matured(block);
}
pub fn setBlockMatured(block: ?*ir_node, matured: i32) void {
return low_level.set_Block_matured(block, matured);
}
pub fn getBlockBlockVisited(block: ?*const ir_node) ir_visited_t {
return low_level.get_Block_block_visited(block);
}
pub fn setBlockBlockVisited(block: ?*ir_node, visit: ir_visited_t) void {
return low_level.set_Block_block_visited(block, visit);
}
pub fn markBlockBlockVisited(node: ?*ir_node) void {
return low_level.mark_Block_block_visited(node);
}
pub fn blockBlockVisited(node: ?*const ir_node) i32 {
return low_level.Block_block_visited(node);
}
pub fn createBlockEntity(block: ?*ir_node) ?*ir_entity {
return low_level.create_Block_entity(block);
}
pub fn getBlockPhis(block: ?*const ir_node) ?*ir_node {
return low_level.get_Block_phis(block);
}
pub fn setBlockPhis(block: ?*ir_node, phi: ?*ir_node) void {
return low_level.set_Block_phis(block, phi);
}
pub fn addBlockPhi(block: ?*ir_node, phi: ?*ir_node) void {
return low_level.add_Block_phi(block, phi);
}
pub fn getBlockMark(block: ?*const ir_node) u32 {
return low_level.get_Block_mark(block);
}
pub fn setBlockMark(block: ?*ir_node, mark: u32) void {
return low_level.set_Block_mark(block, mark);
}
pub fn addEndKeepalive(end: ?*ir_node, ka: ?*ir_node) void {
return low_level.add_End_keepalive(end, ka);
}
pub fn setEndKeepalives(end: ?*ir_node, n: i32, in: [*]?*ir_node) void {
return low_level.set_End_keepalives(end, n, in);
}
pub fn removeEndKeepalive(end: ?*ir_node, irn: ?*const ir_node) void {
return low_level.remove_End_keepalive(end, irn);
}
pub fn removeEndN(end: ?*ir_node, idx: i32) void {
return low_level.remove_End_n(end, idx);
}
pub fn removeEndBadsAndDoublets(end: ?*ir_node) void {
return low_level.remove_End_Bads_and_doublets(end);
}
pub fn freeEnd(end: ?*ir_node) void {
return low_level.free_End(end);
}
pub fn isConstNull(node: ?*const ir_node) bool {
return low_level.is_Const_null(node) == 1;
}
pub fn isConstOne(node: ?*const ir_node) bool {
return low_level.is_Const_one(node) == 1;
}
pub fn isConstAllOne(node: ?*const ir_node) bool {
return low_level.is_Const_all_one(node) == 1;
}
pub fn getCallCallee(call: ?*const ir_node) ?*ir_entity {
return low_level.get_Call_callee(call);
}
pub fn getBuiltinKindName(kind: u32) [*]const u8 {
return low_level.get_builtin_kind_name(kind);
}
pub fn getBinopLeft(node: ?*const ir_node) ?*ir_node {
return low_level.get_binop_left(node);
}
pub fn setBinopLeft(node: ?*ir_node, left: ?*ir_node) void {
return low_level.set_binop_left(node, left);
}
pub fn getBinopRight(node: ?*const ir_node) ?*ir_node {
return low_level.get_binop_right(node);
}
pub fn setBinopRight(node: ?*ir_node, right: ?*ir_node) void {
return low_level.set_binop_right(node, right);
}
pub fn isXExceptProj(node: ?*const ir_node) bool {
return low_level.is_x_except_Proj(node) == 1;
}
pub fn isXRegularProj(node: ?*const ir_node) bool {
return low_level.is_x_regular_Proj(node) == 1;
}
pub fn irSetThrowsException(node: ?*ir_node, throws_exception: i32) void {
return low_level.ir_set_throws_exception(node, throws_exception);
}
pub fn irThrowsException(node: ?*const ir_node) i32 {
return low_level.ir_throws_exception(node);
}
pub fn getRelationString(relation: ir_relation) [*]const u8 {
return low_level.get_relation_string(relation);
}
pub fn getNegatedRelation(relation: ir_relation) ir_relation {
return @intToEnum(ir_relation, low_level.get_negated_relation(relation));
}
pub fn getInversedRelation(relation: ir_relation) ir_relation {
return @intToEnum(ir_relation, low_level.get_inversed_relation(relation));
}
pub fn getPhiNext(phi: ?*const ir_node) ?*ir_node {
return low_level.get_Phi_next(phi);
}
pub fn setPhiNext(phi: ?*ir_node, next: ?*ir_node) void {
return low_level.set_Phi_next(phi, next);
}
pub fn isMemop(node: ?*const ir_node) bool {
return low_level.is_memop(node) == 1;
}
pub fn getMemopMem(node: ?*const ir_node) ?*ir_node {
return low_level.get_memop_mem(node);
}
pub fn setMemopMem(node: ?*ir_node, mem: ?*ir_node) void {
return low_level.set_memop_mem(node, mem);
}
pub fn addSyncPred(node: ?*ir_node, pred: ?*ir_node) void {
return low_level.add_Sync_pred(node, pred);
}
pub fn removeSyncN(n: ?*ir_node, i: i32) void {
return low_level.remove_Sync_n(n, i);
}
pub fn getAsmNConstraints(node: ?*const ir_node) usize {
return low_level.get_ASM_n_constraints(node);
}
pub fn getAsmNClobbers(node: ?*const ir_node) usize {
return low_level.get_ASM_n_clobbers(node);
}
pub fn skipProj(node: ?*ir_node) ?*ir_node {
return low_level.skip_Proj(node);
}
pub fn skipProjConst(node: ?*const ir_node) ir_node {
return low_level.skip_Proj_const(node);
}
pub fn skipId(node: ?*ir_node) ?*ir_node {
return low_level.skip_Id(node);
}
pub fn skipTuple(node: ?*ir_node) ?*ir_node {
return low_level.skip_Tuple(node);
}
pub fn skipPin(node: ?*ir_node) ?*ir_node {
return low_level.skip_Pin(node);
}
pub fn skipConfirm(node: ?*ir_node) ?*ir_node {
return low_level.skip_Confirm(node);
}
pub fn isCfop(node: ?*const ir_node) bool {
return low_level.is_cfop(node) == 1;
}
pub fn isUnknownJump(node: ?*const ir_node) bool {
return low_level.is_unknown_jump(node) == 1;
}
pub fn isFragileOp(node: ?*const ir_node) bool {
return low_level.is_fragile_op(node) == 1;
}
pub fn isIrnForking(node: ?*const ir_node) bool {
return low_level.is_irn_forking(node) == 1;
}
pub fn isIrnConstMemory(node: ?*const ir_node) bool {
return low_level.is_irn_const_memory(node) == 1;
}
pub fn copyNodeAttr(irg: ?*ir_graph, old_node: ?*const ir_node, new_node: ?*ir_node) void {
return low_level.copy_node_attr(irg, old_node, new_node);
}
pub fn getIrnTypeAttr(n: ?*ir_node) ?*ir_type {
return low_level.get_irn_type_attr(n);
}
pub fn getIrnEntityAttr(n: ?*ir_node) ?*ir_entity {
return low_level.get_irn_entity_attr(n);
}
pub fn isIrnConstlike(node: ?*const ir_node) bool {
return low_level.is_irn_constlike(node) == 1;
}
pub fn isIrnKeep(node: ?*const ir_node) bool {
return low_level.is_irn_keep(node) == 1;
}
pub fn isIrnStartBlockPlaced(node: ?*const ir_node) bool {
return low_level.is_irn_start_block_placed(node) == 1;
}
pub fn getCondJmpPredicateName(pred: u32) [*]const u8 {
return low_level.get_cond_jmp_predicate_name(pred);
}
pub fn getIrnGenericAttr(node: ?*ir_node) ?*anyopaque {
return low_level.get_irn_generic_attr(node);
}
pub fn getIrnGenericAttrConst(node: ?*const ir_node) anyopaque {
return low_level.get_irn_generic_attr_const(node);
}
pub fn getIrnIdx(node: ?*const ir_node) u32 {
return low_level.get_irn_idx(node);
}
pub fn setIrnDbgInfo(n: ?*ir_node, db: ?*dbg_info) void {
return low_level.set_irn_dbg_info(n, db);
}
pub fn getIrnDbgInfo(n: ?*const ir_node) ?*dbg_info {
return low_level.get_irn_dbg_info(n);
}
pub fn gdbNodeHelper(firm_object: ?*const anyopaque) [*]const u8 {
return low_level.gdb_node_helper(firm_object);
}
pub fn irNewSwitchTable(irg: ?*ir_graph, n_entries: usize) ?*ir_switch_table {
return low_level.ir_new_switch_table(irg, n_entries);
}
pub fn irSwitchTableGetNEntries(table: ?*const ir_switch_table) usize {
return low_level.ir_switch_table_get_n_entries(table);
}
pub fn irSwitchTableSet(table: ?*ir_switch_table, entry: usize, min: ?*ir_tarval, max: ?*ir_tarval, pn: u32) void {
return low_level.ir_switch_table_set(table, entry, min, max, pn);
}
pub fn irSwitchTableGetMax(table: ?*const ir_switch_table, entry: usize) ?*ir_tarval {
return low_level.ir_switch_table_get_max(table, entry);
}
pub fn irSwitchTableGetMin(table: ?*const ir_switch_table, entry: usize) ?*ir_tarval {
return low_level.ir_switch_table_get_min(table, entry);
}
pub fn irSwitchTableGetPn(table: ?*const ir_switch_table, entry: usize) u32 {
return low_level.ir_switch_table_get_pn(table, entry);
}
pub fn irSwitchTableDuplicate(irg: ?*ir_graph, table: ?*const ir_switch_table) ?*ir_switch_table {
return low_level.ir_switch_table_duplicate(irg, table);
}
pub fn newRdConstLong(db: ?*dbg_info, irg: ?*ir_graph, mode: ?*ir_mode, value: i64) ?*ir_node {
return low_level.new_rd_Const_long(db, irg, mode, value);
}
pub fn newRConstLong(irg: ?*ir_graph, mode: ?*ir_mode, value: i64) ?*ir_node {
return low_level.new_r_Const_long(irg, mode, value);
}
pub fn newDConstLong(db: ?*dbg_info, mode: ?*ir_mode, value: i64) ?*ir_node {
return low_level.new_d_Const_long(db, mode, value);
}
pub fn newConstLong(mode: ?*ir_mode, value: i64) ?*ir_node {
return low_level.new_Const_long(mode, value);
}
pub fn newRdPhiLoop(db: ?*dbg_info, block: ?*ir_node, arity: i32, in: [*]?*ir_node) ?*ir_node {
return low_level.new_rd_Phi_loop(db, block, arity, in);
}
pub fn newRPhiLoop(block: ?*ir_node, arity: i32, in: [*]?*ir_node) ?*ir_node {
return low_level.new_r_Phi_loop(block, arity, in);
}
pub fn newDPhiLoop(db: ?*dbg_info, arity: i32, in: [*]?*ir_node) ?*ir_node {
return low_level.new_d_Phi_loop(db, arity, in);
}
pub fn newPhiLoop(arity: i32, in: [*]?*ir_node) ?*ir_node {
return low_level.new_Phi_loop(arity, in);
}
pub fn newRdDivrl(db: ?*dbg_info, block: ?*ir_node, memop: ?*ir_node, op1: ?*ir_node, op2: ?*ir_node, pinned: i32) ?*ir_node {
return low_level.new_rd_DivRL(db, block, memop, op1, op2, pinned);
}
pub fn newRDivrl(block: ?*ir_node, memop: ?*ir_node, op1: ?*ir_node, op2: ?*ir_node, pinned: i32) ?*ir_node {
return low_level.new_r_DivRL(block, memop, op1, op2, pinned);
}
pub fn newDDivrl(db: ?*dbg_info, memop: ?*ir_node, op1: ?*ir_node, op2: ?*ir_node, pinned: i32) ?*ir_node {
return low_level.new_d_DivRL(db, memop, op1, op2, pinned);
}
pub fn newDivrl(memop: ?*ir_node, op1: ?*ir_node, op2: ?*ir_node, pinned: i32) ?*ir_node {
return low_level.new_DivRL(memop, op1, op2, pinned);
}
pub fn getCurrentIrGraph() ?*ir_graph {
return low_level.get_current_ir_graph();
}
pub fn setCurrentIrGraph(graph: ?*ir_graph) void {
return low_level.set_current_ir_graph(graph);
}
pub fn newDImmblock(db: ?*dbg_info) ?*ir_node {
return low_level.new_d_immBlock(db);
}
pub fn newImmblock() ?*ir_node {
return low_level.new_immBlock();
}
pub fn newRImmblock(irg: ?*ir_graph) ?*ir_node {
return low_level.new_r_immBlock(irg);
}
pub fn newRdImmblock(db: ?*dbg_info, irg: ?*ir_graph) ?*ir_node {
return low_level.new_rd_immBlock(db, irg);
}
pub fn addImmblockPred(immblock: ?*ir_node, jmp: ?*ir_node) void {
return low_level.add_immBlock_pred(immblock, jmp);
}
pub fn matureImmblock(block: ?*ir_node) void {
return low_level.mature_immBlock(block);
}
pub fn setCurBlock(target: ?*ir_node) void {
return low_level.set_cur_block(target);
}
pub fn setRCurBlock(irg: ?*ir_graph, target: ?*ir_node) void {
return low_level.set_r_cur_block(irg, target);
}
pub fn getCurBlock() ?*ir_node {
return low_level.get_cur_block();
}
pub fn getRCurBlock(irg: ?*ir_graph) ?*ir_node {
return low_level.get_r_cur_block(irg);
}
pub fn getValue(pos: i32, mode: ?*ir_mode) ?*ir_node {
return low_level.get_value(pos, mode);
}
pub fn getRValue(irg: ?*ir_graph, pos: i32, mode: ?*ir_mode) ?*ir_node {
return low_level.get_r_value(irg, pos, mode);
}
pub fn irGuessMode(pos: i32) ?*ir_mode {
return low_level.ir_guess_mode(pos);
}
pub fn irRGuessMode(irg: ?*ir_graph, pos: i32) ?*ir_mode {
return low_level.ir_r_guess_mode(irg, pos);
}
pub fn setValue(pos: i32, value: ?*ir_node) void {
return low_level.set_value(pos, value);
}
pub fn setRValue(irg: ?*ir_graph, pos: i32, value: ?*ir_node) void {
return low_level.set_r_value(irg, pos, value);
}
pub fn getStore() ?*ir_node {
return low_level.get_store();
}
pub fn getRStore(irg: ?*ir_graph) ?*ir_node {
return low_level.get_r_store(irg);
}
pub fn setStore(store: ?*ir_node) void {
return low_level.set_store(store);
}
pub fn setRStore(irg: ?*ir_graph, store: ?*ir_node) void {
return low_level.set_r_store(irg, store);
}
pub fn keepAlive(ka: ?*ir_node) void {
return low_level.keep_alive(ka);
}
pub fn irgFinalizeCons(irg: ?*ir_graph) void {
return low_level.irg_finalize_cons(irg);
}
pub fn verifyNewNode(node: ?*ir_node) void {
return low_level.verify_new_node(node);
}
pub fn irSetUninitializedLocalVariableFunc(func: ?uninitialized_local_variable_func_t) void {
return low_level.ir_set_uninitialized_local_variable_func(func);
}
pub fn constructConfirms(irg: ?*ir_graph) void {
return low_level.construct_confirms(irg);
}
pub fn constructConfirmsOnly(irg: ?*ir_graph) void {
return low_level.construct_confirms_only(irg);
}
pub fn removeConfirms(irg: ?*ir_graph) void {
return low_level.remove_confirms(irg);
}
pub fn getBlockIdom(block: ?*const ir_node) ?*ir_node {
return low_level.get_Block_idom(block);
}
pub fn getBlockIpostdom(block: ?*const ir_node) ?*ir_node {
return low_level.get_Block_ipostdom(block);
}
pub fn getBlockDomDepth(bl: ?*const ir_node) i32 {
return low_level.get_Block_dom_depth(bl);
}
pub fn getBlockPostdomDepth(bl: ?*const ir_node) i32 {
return low_level.get_Block_postdom_depth(bl);
}
pub fn blockDominates(a: ?*const ir_node, b: ?*const ir_node) i32 {
return low_level.block_dominates(a, b);
}
pub fn blockPostdominates(a: ?*const ir_node, b: ?*const ir_node) i32 {
return low_level.block_postdominates(a, b);
}
pub fn blockStrictlyPostdominates(a: ?*const ir_node, b: ?*const ir_node) i32 {
return low_level.block_strictly_postdominates(a, b);
}
pub fn getBlockDominatedFirst(block: ?*const ir_node) ?*ir_node {
return low_level.get_Block_dominated_first(block);
}
pub fn getBlockPostdominatedFirst(bl: ?*const ir_node) ?*ir_node {
return low_level.get_Block_postdominated_first(bl);
}
pub fn getBlockDominatedNext(node: ?*const ir_node) ?*ir_node {
return low_level.get_Block_dominated_next(node);
}
pub fn getBlockPostdominatedNext(node: ?*const ir_node) ?*ir_node {
return low_level.get_Block_postdominated_next(node);
}
pub fn irDeepestCommonDominator(block0: ?*ir_node, block1: ?*ir_node) ?*ir_node {
return low_level.ir_deepest_common_dominator(block0, block1);
}
pub fn domTreeWalk(n: ?*ir_node, pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void {
return low_level.dom_tree_walk(n, pre, post, env);
}
pub fn postdomTreeWalk(n: ?*ir_node, pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void {
return low_level.postdom_tree_walk(n, pre, post, env);
}
pub fn domTreeWalkIrg(irg: ?*ir_graph, pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void {
return low_level.dom_tree_walk_irg(irg, pre, post, env);
}
pub fn postdomTreeWalkIrg(irg: ?*ir_graph, pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void {
return low_level.postdom_tree_walk_irg(irg, pre, post, env);
}
pub fn computeDoms(irg: ?*ir_graph) void {
return low_level.compute_doms(irg);
}
pub fn computePostdoms(irg: ?*ir_graph) void {
return low_level.compute_postdoms(irg);
}
pub fn irComputeDominanceFrontiers(irg: ?*ir_graph) void {
return low_level.ir_compute_dominance_frontiers(irg);
}
pub fn irGetDominanceFrontier(block: ?*const ir_node) [*]?*ir_node {
return low_level.ir_get_dominance_frontier(block);
}
pub fn dumpIrGraph(graph: ?*ir_graph, suffix: [*]const u8) void {
return low_level.dump_ir_graph(graph, suffix);
}
pub fn dumpIrProgExt(func: ir_prog_dump_func, suffix: [*]const u8) void {
return low_level.dump_ir_prog_ext(func, suffix);
}
pub fn dumpIrGraphExt(func: ir_graph_dump_func, graph: ?*ir_graph, suffix: [*]const u8) void {
return low_level.dump_ir_graph_ext(func, graph, suffix);
}
pub fn dumpAllIrGraphs(suffix: [*]const u8) void {
return low_level.dump_all_ir_graphs(suffix);
}
pub fn irSetDumpPath(path: [*]const u8) void {
return low_level.ir_set_dump_path(path);
}
pub fn irSetDumpFilter(name: [*]const u8) void {
return low_level.ir_set_dump_filter(name);
}
pub fn irGetDumpFilter() [*]const u8 {
return low_level.ir_get_dump_filter();
}
pub fn dumpIrGraphFile(out: *std.c.FILE, graph: ?*ir_graph) void {
return low_level.dump_ir_graph_file(out, graph);
}
pub fn dumpCfg(out: *std.c.FILE, graph: ?*ir_graph) void {
return low_level.dump_cfg(out, graph);
}
pub fn dumpCallgraph(out: *std.c.FILE) void {
return low_level.dump_callgraph(out);
}
pub fn dumpTypegraph(out: *std.c.FILE) void {
return low_level.dump_typegraph(out);
}
pub fn dumpClassHierarchy(out: *std.c.FILE) void {
return low_level.dump_class_hierarchy(out);
}
pub fn dumpLoopTree(out: *std.c.FILE, graph: ?*ir_graph) void {
return low_level.dump_loop_tree(out, graph);
}
pub fn dumpCallgraphLoopTree(out: *std.c.FILE) void {
return low_level.dump_callgraph_loop_tree(out);
}
pub fn dumpTypesAsText(out: *std.c.FILE) void {
return low_level.dump_types_as_text(out);
}
pub fn dumpGlobalsAsText(out: *std.c.FILE) void {
return low_level.dump_globals_as_text(out);
}
pub fn dumpLoop(out: *std.c.FILE, loop: ?*ir_loop) void {
return low_level.dump_loop(out, loop);
}
pub fn dumpGraphAsText(out: *std.c.FILE, graph: ?*const ir_graph) void {
return low_level.dump_graph_as_text(out, graph);
}
pub fn dumpEntityToFile(out: *std.c.FILE, entity: ?*const ir_entity) void {
return low_level.dump_entity_to_file(out, entity);
}
pub fn dumpTypeToFile(out: *std.c.FILE, @"type": ?*const ir_type) void {
return low_level.dump_type_to_file(out, @"type");
}
pub fn irSetDumpVerbosity(verbosity: u32) void {
return low_level.ir_set_dump_verbosity(verbosity);
}
pub fn irGetDumpVerbosity() ir_dump_verbosity_t {
return @intToEnum(ir_dump_verbosity_t, low_level.ir_get_dump_verbosity());
}
pub fn irSetDumpFlags(flags: u32) void {
return low_level.ir_set_dump_flags(flags);
}
pub fn irAddDumpFlags(flags: u32) void {
return low_level.ir_add_dump_flags(flags);
}
pub fn irRemoveDumpFlags(flags: u32) void {
return low_level.ir_remove_dump_flags(flags);
}
pub fn irGetDumpFlags() ir_dump_flags_t {
return @intToEnum(ir_dump_flags_t, low_level.ir_get_dump_flags());
}
pub fn setDumpNodeVcgattrHook(hook: dump_node_vcgattr_func) void {
return low_level.set_dump_node_vcgattr_hook(hook);
}
pub fn setDumpEdgeVcgattrHook(hook: dump_edge_vcgattr_func) void {
return low_level.set_dump_edge_vcgattr_hook(hook);
}
pub fn setDumpNodeEdgeHook(func: dump_node_edge_func) void {
return low_level.set_dump_node_edge_hook(func);
}
pub fn getDumpNodeEdgeHook() dump_node_edge_func {
return low_level.get_dump_node_edge_hook();
}
pub fn setDumpBlockEdgeHook(func: dump_node_edge_func) void {
return low_level.set_dump_block_edge_hook(func);
}
pub fn getDumpBlockEdgeHook() dump_node_edge_func {
return low_level.get_dump_block_edge_hook();
}
pub fn dumpAddNodeInfoCallback(cb: ?dump_node_info_cb_t, data: ?*anyopaque) ?*hook_entry_t {
return low_level.dump_add_node_info_callback(cb, data);
}
pub fn dumpRemoveNodeInfoCallback(handle: ?*hook_entry_t) void {
return low_level.dump_remove_node_info_callback(handle);
}
pub fn dumpVcgHeader(out: *std.c.FILE, name: [*]const u8, layout: [*]const u8, orientation: [*]const u8) void {
return low_level.dump_vcg_header(out, name, layout, orientation);
}
pub fn dumpVcgFooter(out: *std.c.FILE) void {
return low_level.dump_vcg_footer(out);
}
pub fn dumpNode(out: *std.c.FILE, node: ?*const ir_node) void {
return low_level.dump_node(out, node);
}
pub fn dumpIrDataEdges(out: *std.c.FILE, node: ?*const ir_node) void {
return low_level.dump_ir_data_edges(out, node);
}
pub fn printNodeid(out: *std.c.FILE, node: ?*const ir_node) void {
return low_level.print_nodeid(out, node);
}
pub fn dumpBeginBlockSubgraph(out: *std.c.FILE, block: ?*const ir_node) void {
return low_level.dump_begin_block_subgraph(out, block);
}
pub fn dumpEndBlockSubgraph(out: *std.c.FILE, block: ?*const ir_node) void {
return low_level.dump_end_block_subgraph(out, block);
}
pub fn dumpBlockEdges(out: *std.c.FILE, block: ?*const ir_node) void {
return low_level.dump_block_edges(out, block);
}
pub fn dumpBlocksAsSubgraphs(out: *std.c.FILE, irg: ?*ir_graph) void {
return low_level.dump_blocks_as_subgraphs(out, irg);
}
pub fn getIrnOutEdgeFirstKind(irn: ?*const ir_node, kind: u32) ir_edge_t {
return low_level.get_irn_out_edge_first_kind(irn, kind);
}
pub fn getIrnOutEdgeFirst(irn: ?*const ir_node) ir_edge_t {
return low_level.get_irn_out_edge_first(irn);
}
pub fn getBlockSuccFirst(block: ?*const ir_node) ir_edge_t {
return low_level.get_block_succ_first(block);
}
pub fn getIrnOutEdgeNext(irn: ?*const ir_node, last: ?*const ir_edge_t, kind: u32) ir_edge_t {
return low_level.get_irn_out_edge_next(irn, last, kind);
}
pub fn getEdgeSrcIrn(edge: ?*const ir_edge_t) ?*ir_node {
return low_level.get_edge_src_irn(edge);
}
pub fn getEdgeSrcPos(edge: ?*const ir_edge_t) i32 {
return low_level.get_edge_src_pos(edge);
}
pub fn getIrnNEdgesKind(irn: ?*const ir_node, kind: u32) i32 {
return low_level.get_irn_n_edges_kind(irn, kind);
}
pub fn getIrnNEdges(irn: ?*const ir_node) i32 {
return low_level.get_irn_n_edges(irn);
}
pub fn edgesActivatedKind(irg: ?*const ir_graph, kind: u32) i32 {
return low_level.edges_activated_kind(irg, kind);
}
pub fn edgesActivated(irg: ?*const ir_graph) i32 {
return low_level.edges_activated(irg);
}
pub fn edgesActivateKind(irg: ?*ir_graph, kind: u32) void {
return low_level.edges_activate_kind(irg, kind);
}
pub fn edgesDeactivateKind(irg: ?*ir_graph, kind: u32) void {
return low_level.edges_deactivate_kind(irg, kind);
}
pub fn edgesRerouteKind(old: ?*ir_node, nw: ?*ir_node, kind: u32) void {
return low_level.edges_reroute_kind(old, nw, kind);
}
pub fn edgesReroute(old: ?*ir_node, nw: ?*ir_node) void {
return low_level.edges_reroute(old, nw);
}
pub fn edgesRerouteExcept(old: ?*ir_node, nw: ?*ir_node, exception: ?*ir_node) void {
return low_level.edges_reroute_except(old, nw, exception);
}
pub fn edgesVerify(irg: ?*ir_graph) i32 {
return low_level.edges_verify(irg);
}
pub fn edgesVerifyKind(irg: ?*ir_graph, kind: u32) i32 {
return low_level.edges_verify_kind(irg, kind);
}
pub fn edgesInitDbg(do_dbg: i32) void {
return low_level.edges_init_dbg(do_dbg);
}
pub fn edgesActivate(irg: ?*ir_graph) void {
return low_level.edges_activate(irg);
}
pub fn edgesDeactivate(irg: ?*ir_graph) void {
return low_level.edges_deactivate(irg);
}
pub fn assureEdges(irg: ?*ir_graph) void {
return low_level.assure_edges(irg);
}
pub fn assureEdgesKind(irg: ?*ir_graph, kind: u32) void {
return low_level.assure_edges_kind(irg, kind);
}
pub fn irgBlockEdgesWalk(block: ?*ir_node, pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void {
return low_level.irg_block_edges_walk(block, pre, post, env);
}
pub fn irgWalkEdges(start: ?*ir_node, pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void {
return low_level.irg_walk_edges(start, pre, post, env);
}
pub fn setOptimize(value: i32) void {
return low_level.set_optimize(value);
}
pub fn getOptimize() i32 {
return low_level.get_optimize();
}
pub fn setOptConstantFolding(value: i32) void {
return low_level.set_opt_constant_folding(value);
}
pub fn getOptConstantFolding() i32 {
return low_level.get_opt_constant_folding();
}
pub fn setOptAlgebraicSimplification(value: i32) void {
return low_level.set_opt_algebraic_simplification(value);
}
pub fn getOptAlgebraicSimplification() i32 {
return low_level.get_opt_algebraic_simplification();
}
pub fn setOptCse(value: i32) void {
return low_level.set_opt_cse(value);
}
pub fn getOptCse() i32 {
return low_level.get_opt_cse();
}
pub fn setOptGlobalCse(value: i32) void {
return low_level.set_opt_global_cse(value);
}
pub fn getOptGlobalCse() i32 {
return low_level.get_opt_global_cse();
}
pub fn setOptGlobalNullPtrElimination(value: i32) void {
return low_level.set_opt_global_null_ptr_elimination(value);
}
pub fn getOptGlobalNullPtrElimination() i32 {
return low_level.get_opt_global_null_ptr_elimination();
}
pub fn saveOptimizationState(state: [*]optimization_state_t) void {
return low_level.save_optimization_state(state);
}
pub fn restoreOptimizationState(state: [*]const optimization_state_t) void {
return low_level.restore_optimization_state(state);
}
pub fn allOptimizationsOff() void {
return low_level.all_optimizations_off();
}
pub fn exchange(old: ?*ir_node, nw: ?*ir_node) void {
return low_level.exchange(old, nw);
}
pub fn turnIntoTuple(node: ?*ir_node, arity: i32, in: [*]const ?*ir_node) void {
return low_level.turn_into_tuple(node, arity, in);
}
pub fn collectPhiprojsAndStartBlockNodes(irg: ?*ir_graph) void {
return low_level.collect_phiprojs_and_start_block_nodes(irg);
}
pub fn collectNewStartBlockNode(node: ?*ir_node) void {
return low_level.collect_new_start_block_node(node);
}
pub fn collectNewPhiNode(node: ?*ir_node) void {
return low_level.collect_new_phi_node(node);
}
pub fn partBlock(node: ?*ir_node) void {
return low_level.part_block(node);
}
pub fn partBlockEdges(node: ?*ir_node) ?*ir_node {
return low_level.part_block_edges(node);
}
pub fn killNode(node: ?*ir_node) void {
return low_level.kill_node(node);
}
pub fn duplicateSubgraph(dbg: ?*dbg_info, n: ?*ir_node, to_block: ?*ir_node) ?*ir_node {
return low_level.duplicate_subgraph(dbg, n, to_block);
}
pub fn localOptimizeNode(n: ?*ir_node) void {
return low_level.local_optimize_node(n);
}
pub fn optimizeNode(n: ?*ir_node) ?*ir_node {
return low_level.optimize_node(n);
}
pub fn localOptimizeGraph(irg: ?*ir_graph) void {
return low_level.local_optimize_graph(irg);
}
pub fn optimizeGraphDf(irg: ?*ir_graph) void {
return low_level.optimize_graph_df(irg);
}
pub fn localOptsConstCode() void {
return low_level.local_opts_const_code();
}
pub fn removeUnreachableCode(irg: ?*ir_graph) void {
return low_level.remove_unreachable_code(irg);
}
pub fn removeBads(irg: ?*ir_graph) void {
return low_level.remove_bads(irg);
}
pub fn removeTuples(irg: ?*ir_graph) void {
return low_level.remove_tuples(irg);
}
pub fn removeCriticalCfEdges(irg: ?*ir_graph) void {
return low_level.remove_critical_cf_edges(irg);
}
pub fn removeCriticalCfEdgesEx(irg: ?*ir_graph, ignore_exception_edges: i32) void {
return low_level.remove_critical_cf_edges_ex(irg, ignore_exception_edges);
}
pub fn newIrGraph(ent: ?*ir_entity, n_loc: i32) ?*ir_graph {
return low_level.new_ir_graph(ent, n_loc);
}
pub fn freeIrGraph(irg: ?*ir_graph) void {
return low_level.free_ir_graph(irg);
}
pub fn getIrgEntity(irg: ?*const ir_graph) ?*ir_entity {
return low_level.get_irg_entity(irg);
}
pub fn setIrgEntity(irg: ?*ir_graph, ent: ?*ir_entity) void {
return low_level.set_irg_entity(irg, ent);
}
pub fn getIrgFrameType(irg: ?*ir_graph) ?*ir_type {
return low_level.get_irg_frame_type(irg);
}
pub fn setIrgFrameType(irg: ?*ir_graph, ftp: ?*ir_type) void {
return low_level.set_irg_frame_type(irg, ftp);
}
pub fn getIrgStartBlock(irg: ?*const ir_graph) ?*ir_node {
return low_level.get_irg_start_block(irg);
}
pub fn setIrgStartBlock(irg: ?*ir_graph, node: ?*ir_node) void {
return low_level.set_irg_start_block(irg, node);
}
pub fn getIrgStart(irg: ?*const ir_graph) ?*ir_node {
return low_level.get_irg_start(irg);
}
pub fn setIrgStart(irg: ?*ir_graph, node: ?*ir_node) void {
return low_level.set_irg_start(irg, node);
}
pub fn getIrgEndBlock(irg: ?*const ir_graph) ?*ir_node {
return low_level.get_irg_end_block(irg);
}
pub fn setIrgEndBlock(irg: ?*ir_graph, node: ?*ir_node) void {
return low_level.set_irg_end_block(irg, node);
}
pub fn getIrgEnd(irg: ?*const ir_graph) ?*ir_node {
return low_level.get_irg_end(irg);
}
pub fn setIrgEnd(irg: ?*ir_graph, node: ?*ir_node) void {
return low_level.set_irg_end(irg, node);
}
pub fn getIrgFrame(irg: ?*const ir_graph) ?*ir_node {
return low_level.get_irg_frame(irg);
}
pub fn setIrgFrame(irg: ?*ir_graph, node: ?*ir_node) void {
return low_level.set_irg_frame(irg, node);
}
pub fn getIrgInitialMem(irg: ?*const ir_graph) ?*ir_node {
return low_level.get_irg_initial_mem(irg);
}
pub fn setIrgInitialMem(irg: ?*ir_graph, node: ?*ir_node) void {
return low_level.set_irg_initial_mem(irg, node);
}
pub fn getIrgArgs(irg: ?*const ir_graph) ?*ir_node {
return low_level.get_irg_args(irg);
}
pub fn setIrgArgs(irg: ?*ir_graph, node: ?*ir_node) void {
return low_level.set_irg_args(irg, node);
}
pub fn getIrgNoMem(irg: ?*const ir_graph) ?*ir_node {
return low_level.get_irg_no_mem(irg);
}
pub fn setIrgNoMem(irg: ?*ir_graph, node: ?*ir_node) void {
return low_level.set_irg_no_mem(irg, node);
}
pub fn getIrgNLocs(irg: ?*ir_graph) i32 {
return low_level.get_irg_n_locs(irg);
}
pub fn getIrgGraphNr(irg: ?*const ir_graph) i64 {
return low_level.get_irg_graph_nr(irg);
}
pub fn getIrgIdx(irg: ?*const ir_graph) usize {
return low_level.get_irg_idx(irg);
}
pub fn getIdxIrn(irg: ?*const ir_graph, idx: u32) ?*ir_node {
return low_level.get_idx_irn(irg, idx);
}
pub fn getIrgPinned(irg: ?*const ir_graph) op_pin_state {
return @intToEnum(op_pin_state, low_level.get_irg_pinned(irg));
}
pub fn getIrgCalleeInfoState(irg: ?*const ir_graph) irg_callee_info_state {
return low_level.get_irg_callee_info_state(irg);
}
pub fn setIrgCalleeInfoState(irg: ?*ir_graph, s: irg_callee_info_state) void {
return low_level.set_irg_callee_info_state(irg, s);
}
pub fn setIrgLink(irg: ?*ir_graph, thing: ?*anyopaque) void {
return low_level.set_irg_link(irg, thing);
}
pub fn getIrgLink(irg: ?*const ir_graph) ?*anyopaque {
return low_level.get_irg_link(irg);
}
pub fn incIrgVisited(irg: ?*ir_graph) void {
return low_level.inc_irg_visited(irg);
}
pub fn getIrgVisited(irg: ?*const ir_graph) ir_visited_t {
return low_level.get_irg_visited(irg);
}
pub fn setIrgVisited(irg: ?*ir_graph, i: ir_visited_t) void {
return low_level.set_irg_visited(irg, i);
}
pub fn getMaxIrgVisited() ir_visited_t {
return low_level.get_max_irg_visited();
}
pub fn setMaxIrgVisited(val: i32) void {
return low_level.set_max_irg_visited(val);
}
pub fn incMaxIrgVisited() ir_visited_t {
return low_level.inc_max_irg_visited();
}
pub fn incIrgBlockVisited(irg: ?*ir_graph) void {
return low_level.inc_irg_block_visited(irg);
}
pub fn getIrgBlockVisited(irg: ?*const ir_graph) ir_visited_t {
return low_level.get_irg_block_visited(irg);
}
pub fn setIrgBlockVisited(irg: ?*ir_graph, i: ir_visited_t) void {
return low_level.set_irg_block_visited(irg, i);
}
pub fn irReserveResources(irg: ?*ir_graph, resources: u32) void {
return low_level.ir_reserve_resources(irg, resources);
}
pub fn irFreeResources(irg: ?*ir_graph, resources: u32) void {
return low_level.ir_free_resources(irg, resources);
}
pub fn irResourcesReserved(irg: ?*const ir_graph) ir_resources_t {
return @intToEnum(ir_resources_t, low_level.ir_resources_reserved(irg));
}
pub fn addIrgConstraints(irg: ?*ir_graph, constraints: u32) void {
return low_level.add_irg_constraints(irg, constraints);
}
pub fn clearIrgConstraints(irg: ?*ir_graph, constraints: u32) void {
return low_level.clear_irg_constraints(irg, constraints);
}
pub fn irgIsConstrained(irg: ?*const ir_graph, constraints: u32) i32 {
return low_level.irg_is_constrained(irg, constraints);
}
pub fn addIrgProperties(irg: ?*ir_graph, props: u32) void {
return low_level.add_irg_properties(irg, props);
}
pub fn clearIrgProperties(irg: ?*ir_graph, props: u32) void {
return low_level.clear_irg_properties(irg, props);
}
pub fn irgHasProperties(irg: ?*const ir_graph, props: u32) i32 {
return low_level.irg_has_properties(irg, props);
}
pub fn assureIrgProperties(irg: ?*ir_graph, props: u32) void {
return low_level.assure_irg_properties(irg, props);
}
pub fn confirmIrgProperties(irg: ?*ir_graph, props: u32) void {
return low_level.confirm_irg_properties(irg, props);
}
pub fn setIrgLocDescription(irg: ?*ir_graph, n: i32, description: ?*anyopaque) void {
return low_level.set_irg_loc_description(irg, n, description);
}
pub fn getIrgLocDescription(irg: ?*ir_graph, n: i32) ?*anyopaque {
return low_level.get_irg_loc_description(irg, n);
}
pub fn getIrgLastIdx(irg: ?*const ir_graph) u32 {
return low_level.get_irg_last_idx(irg);
}
pub fn irgWalk(node: ?*ir_node, pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void {
return low_level.irg_walk(node, pre, post, env);
}
pub fn irgWalkCore(node: ?*ir_node, pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void {
return low_level.irg_walk_core(node, pre, post, env);
}
pub fn irgWalkGraph(irg: ?*ir_graph, pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void {
return low_level.irg_walk_graph(irg, pre, post, env);
}
pub fn irgWalkInOrDep(node: ?*ir_node, pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void {
return low_level.irg_walk_in_or_dep(node, pre, post, env);
}
pub fn irgWalkInOrDepGraph(irg: ?*ir_graph, pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void {
return low_level.irg_walk_in_or_dep_graph(irg, pre, post, env);
}
pub fn irgWalkTopological(irg: ?*ir_graph, walker: ?irg_walk_func, env: ?*anyopaque) void {
return low_level.irg_walk_topological(irg, walker, env);
}
pub fn allIrgWalk(pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void {
return low_level.all_irg_walk(pre, post, env);
}
pub fn irgBlockWalk(node: ?*ir_node, pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void {
return low_level.irg_block_walk(node, pre, post, env);
}
pub fn irgBlockWalkGraph(irg: ?*ir_graph, pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void {
return low_level.irg_block_walk_graph(irg, pre, post, env);
}
pub fn walkConstCode(pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void {
return low_level.walk_const_code(pre, post, env);
}
pub fn irgWalkBlkwiseGraph(irg: ?*ir_graph, pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void {
return low_level.irg_walk_blkwise_graph(irg, pre, post, env);
}
pub fn irgWalkBlkwiseDomTopDown(irg: ?*ir_graph, pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void {
return low_level.irg_walk_blkwise_dom_top_down(irg, pre, post, env);
}
pub fn irgWalkAnchors(irg: ?*ir_graph, pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void {
return low_level.irg_walk_anchors(irg, pre, post, env);
}
pub fn irgWalk2(node: ?*ir_node, pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void {
return low_level.irg_walk_2(node, pre, post, env);
}
pub fn irExport(filename: [*]const u8) i32 {
return low_level.ir_export(filename);
}
pub fn irExportFile(output: *std.c.FILE) void {
return low_level.ir_export_file(output);
}
pub fn irImport(filename: [*]const u8) i32 {
return low_level.ir_import(filename);
}
pub fn irImportFile(input: *std.c.FILE, inputname: [*]const u8) i32 {
return low_level.ir_import_file(input, inputname);
}
pub fn isBackedge(n: ?*const ir_node, pos: bool) bool {
return low_level.is_backedge(n, pos) == 1;
}
pub fn setBackedge(n: ?*ir_node, pos: i32) void {
return low_level.set_backedge(n, pos);
}
pub fn hasBackedges(n: ?*const ir_node) i32 {
return low_level.has_backedges(n);
}
pub fn clearBackedges(n: ?*ir_node) void {
return low_level.clear_backedges(n);
}
pub fn setIrgLoop(irg: ?*ir_graph, l: ?*ir_loop) void {
return low_level.set_irg_loop(irg, l);
}
pub fn getIrgLoop(irg: ?*const ir_graph) ?*ir_loop {
return low_level.get_irg_loop(irg);
}
pub fn getIrnLoop(n: ?*const ir_node) ?*ir_loop {
return low_level.get_irn_loop(n);
}
pub fn getLoopOuterLoop(loop: ?*const ir_loop) ?*ir_loop {
return low_level.get_loop_outer_loop(loop);
}
pub fn getLoopDepth(loop: ?*const ir_loop) u32 {
return low_level.get_loop_depth(loop);
}
pub fn getLoopNElements(loop: ?*const ir_loop) usize {
return low_level.get_loop_n_elements(loop);
}
pub fn getLoopElement(loop: ?*const ir_loop, pos: usize) loop_element {
return low_level.get_loop_element(loop, pos);
}
pub fn getLoopLoopNr(loop: ?*const ir_loop) i64 {
return low_level.get_loop_loop_nr(loop);
}
pub fn setLoopLink(loop: ?*ir_loop, link: ?*anyopaque) void {
return low_level.set_loop_link(loop, link);
}
pub fn getLoopLink(loop: ?*const ir_loop) ?*anyopaque {
return low_level.get_loop_link(loop);
}
pub fn constructCfBackedges(irg: ?*ir_graph) void {
return low_level.construct_cf_backedges(irg);
}
pub fn assureLoopinfo(irg: ?*ir_graph) void {
return low_level.assure_loopinfo(irg);
}
pub fn freeLoopInformation(irg: ?*ir_graph) void {
return low_level.free_loop_information(irg);
}
pub fn isLoopInvariant(n: ?*const ir_node, block: ?*const ir_node) bool {
return low_level.is_loop_invariant(n, block) == 1;
}
pub fn getIrAliasRelationName(rel: u32) [*]const u8 {
return low_level.get_ir_alias_relation_name(rel);
}
pub fn getAliasRelation(addr1: ?*const ir_node, type1: ?*const ir_type, size1: u32, addr2: ?*const ir_node, type2: ?*const ir_type, size2: u32) ir_alias_relation {
return @intToEnum(ir_alias_relation, low_level.get_alias_relation(addr1, type1, size1, addr2, type2, size2));
}
pub fn assureIrgEntityUsageComputed(irg: ?*ir_graph) void {
return low_level.assure_irg_entity_usage_computed(irg);
}
pub fn getIrpGlobalsEntityUsageState() ir_entity_usage_computed_state {
return @intToEnum(ir_entity_usage_computed_state, low_level.get_irp_globals_entity_usage_state());
}
pub fn setIrpGlobalsEntityUsageState(state: u32) void {
return low_level.set_irp_globals_entity_usage_state(state);
}
pub fn assureIrpGlobalsEntityUsageComputed() void {
return low_level.assure_irp_globals_entity_usage_computed();
}
pub fn getIrgMemoryDisambiguatorOptions(irg: ?*const ir_graph) ir_disambiguator_options {
return @intToEnum(ir_disambiguator_options, low_level.get_irg_memory_disambiguator_options(irg));
}
pub fn setIrgMemoryDisambiguatorOptions(irg: ?*ir_graph, options: u32) void {
return low_level.set_irg_memory_disambiguator_options(irg, options);
}
pub fn setIrpMemoryDisambiguatorOptions(options: u32) void {
return low_level.set_irp_memory_disambiguator_options(options);
}
pub fn markPrivateMethods() void {
return low_level.mark_private_methods();
}
pub fn computedValue(n: ?*const ir_node) ?*ir_tarval {
return low_level.computed_value(n);
}
pub fn optimizeInPlace(n: ?*ir_node) ?*ir_node {
return low_level.optimize_in_place(n);
}
pub fn irIsNegatedValue(a: ?*const ir_node, b: ?*const ir_node) i32 {
return low_level.ir_is_negated_value(a, b);
}
pub fn irGetPossibleCmpRelations(left: ?*const ir_node, right: ?*const ir_node) ir_relation {
return @intToEnum(ir_relation, low_level.ir_get_possible_cmp_relations(left, right));
}
pub fn irAllowImpreciseFloatTransforms(enable: i32) void {
return low_level.ir_allow_imprecise_float_transforms(enable);
}
pub fn irImpreciseFloatTransformsAllowed() i32 {
return low_level.ir_imprecise_float_transforms_allowed();
}
pub fn getIrnNOuts(node: ?*const ir_node) u32 {
return low_level.get_irn_n_outs(node);
}
pub fn getIrnOut(def: ?*const ir_node, pos: u32) ?*ir_node {
return low_level.get_irn_out(def, pos);
}
pub fn getIrnOutEx(def: ?*const ir_node, pos: u32, in_pos: [*]i32) ?*ir_node {
return low_level.get_irn_out_ex(def, pos, in_pos);
}
pub fn getBlockNCfgOuts(node: ?*const ir_node) u32 {
return low_level.get_Block_n_cfg_outs(node);
}
pub fn getBlockNCfgOutsKa(node: ?*const ir_node) u32 {
return low_level.get_Block_n_cfg_outs_ka(node);
}
pub fn getBlockCfgOut(node: ?*const ir_node, pos: u32) ?*ir_node {
return low_level.get_Block_cfg_out(node, pos);
}
pub fn getBlockCfgOutEx(node: ?*const ir_node, pos: u32, in_pos: [*]i32) ?*ir_node {
return low_level.get_Block_cfg_out_ex(node, pos, in_pos);
}
pub fn getBlockCfgOutKa(node: ?*const ir_node, pos: u32) ?*ir_node {
return low_level.get_Block_cfg_out_ka(node, pos);
}
pub fn irgOutWalk(node: ?*ir_node, pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void {
return low_level.irg_out_walk(node, pre, post, env);
}
pub fn irgOutBlockWalk(node: ?*ir_node, pre: ?irg_walk_func, post: ?irg_walk_func, env: ?*anyopaque) void {
return low_level.irg_out_block_walk(node, pre, post, env);
}
pub fn computeIrgOuts(irg: ?*ir_graph) void {
return low_level.compute_irg_outs(irg);
}
pub fn assureIrgOuts(irg: ?*ir_graph) void {
return low_level.assure_irg_outs(irg);
}
pub fn freeIrgOuts(irg: ?*ir_graph) void {
return low_level.free_irg_outs(irg);
}
pub fn irpReserveResources(irp1: ?*ir_prog, resources: u32) void {
return low_level.irp_reserve_resources(irp1, resources);
}
pub fn irpFreeResources(irp2: ?*ir_prog, resources: u32) void {
return low_level.irp_free_resources(irp2, resources);
}
pub fn irpResourcesReserved(irp3: ?*const ir_prog) irp_resources_t {
return @intToEnum(irp_resources_t, low_level.irp_resources_reserved(irp3));
}
pub fn getIrp() ?*ir_prog {
return low_level.get_irp();
}
pub fn setIrp(irp4: ?*ir_prog) void {
return low_level.set_irp(irp4);
}
pub fn newIrProg(name: [*]const u8) ?*ir_prog {
return low_level.new_ir_prog(name);
}
pub fn freeIrProg() void {
return low_level.free_ir_prog();
}
pub fn setIrpProgName(name: [*]const u8) void {
return low_level.set_irp_prog_name(name);
}
pub fn irpProgNameIsSet() i32 {
return low_level.irp_prog_name_is_set();
}
pub fn getIrpIdent() [*]const u8 {
return low_level.get_irp_ident();
}
pub fn getIrpName() [*]const u8 {
return low_level.get_irp_name();
}
pub fn getIrpMainIrg() ?*ir_graph {
return low_level.get_irp_main_irg();
}
pub fn setIrpMainIrg(main_irg: ?*ir_graph) void {
return low_level.set_irp_main_irg(main_irg);
}
pub fn getIrpLastIdx() usize {
return low_level.get_irp_last_idx();
}
pub fn getIrpNIrgs() usize {
return low_level.get_irp_n_irgs();
}
pub fn getIrpIrg(pos: usize) ?*ir_graph {
return low_level.get_irp_irg(pos);
}
pub fn setIrpIrg(pos: usize, irg: ?*ir_graph) void {
return low_level.set_irp_irg(pos, irg);
}
pub fn getSegmentType(segment: u32) ?*ir_type {
return low_level.get_segment_type(segment);
}
pub fn setSegmentType(segment: u32, new_type: ?*ir_type) void {
return low_level.set_segment_type(segment, new_type);
}
pub fn getGlobType() ?*ir_type {
return low_level.get_glob_type();
}
pub fn getTlsType() ?*ir_type {
return low_level.get_tls_type();
}
pub fn irGetGlobal(name: [*]const u8) ?*ir_entity {
return low_level.ir_get_global(name);
}
pub fn getIrpNTypes() usize {
return low_level.get_irp_n_types();
}
pub fn getIrpType(pos: usize) ?*ir_type {
return low_level.get_irp_type(pos);
}
pub fn setIrpType(pos: usize, typ: ?*ir_type) void {
return low_level.set_irp_type(pos, typ);
}
pub fn getConstCodeIrg() ?*ir_graph {
return low_level.get_const_code_irg();
}
pub fn getIrpCalleeInfoState() irg_callee_info_state {
return low_level.get_irp_callee_info_state();
}
pub fn setIrpCalleeInfoState(s: irg_callee_info_state) void {
return low_level.set_irp_callee_info_state(s);
}
pub fn getIrpNextLabelNr() ir_label_t {
return low_level.get_irp_next_label_nr();
}
pub fn addIrpAsm(asm_string: [*]const u8) void {
return low_level.add_irp_asm(asm_string);
}
pub fn getIrpNAsms() usize {
return low_level.get_irp_n_asms();
}
pub fn getIrpAsm(pos: usize) [*]const u8 {
return low_level.get_irp_asm(pos);
}
pub fn irnVerify(node: ?*const ir_node) i32 {
return low_level.irn_verify(node);
}
pub fn irgVerify(irg: ?*ir_graph) i32 {
return low_level.irg_verify(irg);
}
pub fn irgAssertVerify(irg: ?*ir_graph) void {
return low_level.irg_assert_verify(irg);
}
pub fn lowerCopyb(irg: ?*ir_graph, max_small_size: u32, min_large_size: u32, allow_misalignments: i32) void {
return low_level.lower_CopyB(irg, max_small_size, min_large_size, allow_misalignments);
}
pub fn lowerSwitch(irg: ?*ir_graph, small_switch: u32, spare_size: u32, selector_mode: ?*ir_mode) void {
return low_level.lower_switch(irg, small_switch, spare_size, selector_mode);
}
pub fn lowerHighlevelGraph(irg: ?*ir_graph) void {
return low_level.lower_highlevel_graph(irg);
}
pub fn lowerHighlevel() void {
return low_level.lower_highlevel();
}
pub fn lowerConstCode() void {
return low_level.lower_const_code();
}
pub fn lowerMux(irg: ?*ir_graph, cb_func: ?lower_mux_callback) void {
return low_level.lower_mux(irg, cb_func);
}
pub fn irCreateIntrinsicsMap(list: [*]i_record, length: usize, part_block_used: i32) ?*ir_intrinsics_map {
return low_level.ir_create_intrinsics_map(list, length, part_block_used);
}
pub fn irFreeIntrinsicsMap(map: ?*ir_intrinsics_map) void {
return low_level.ir_free_intrinsics_map(map);
}
pub fn irLowerIntrinsics(irg: ?*ir_graph, map: ?*ir_intrinsics_map) void {
return low_level.ir_lower_intrinsics(irg, map);
}
pub fn iMapperAbs(call: ?*ir_node) i32 {
return low_level.i_mapper_abs(call);
}
pub fn iMapperSqrt(call: ?*ir_node) i32 {
return low_level.i_mapper_sqrt(call);
}
pub fn iMapperCbrt(call: ?*ir_node) i32 {
return low_level.i_mapper_cbrt(call);
}
pub fn iMapperPow(call: ?*ir_node) i32 {
return low_level.i_mapper_pow(call);
}
pub fn iMapperExp(call: ?*ir_node) i32 {
return low_level.i_mapper_exp(call);
}
pub fn iMapperExp2(call: ?*ir_node) i32 {
return low_level.i_mapper_exp2(call);
}
pub fn iMapperExp10(call: ?*ir_node) i32 {
return low_level.i_mapper_exp10(call);
}
pub fn iMapperLog(call: ?*ir_node) i32 {
return low_level.i_mapper_log(call);
}
pub fn iMapperLog2(call: ?*ir_node) i32 {
return low_level.i_mapper_log2(call);
}
pub fn iMapperLog10(call: ?*ir_node) i32 {
return low_level.i_mapper_log10(call);
}
pub fn iMapperSin(call: ?*ir_node) i32 {
return low_level.i_mapper_sin(call);
}
pub fn iMapperCos(call: ?*ir_node) i32 {
return low_level.i_mapper_cos(call);
}
pub fn iMapperTan(call: ?*ir_node) i32 {
return low_level.i_mapper_tan(call);
}
pub fn iMapperAsin(call: ?*ir_node) i32 {
return low_level.i_mapper_asin(call);
}
pub fn iMapperAcos(call: ?*ir_node) i32 {
return low_level.i_mapper_acos(call);
}
pub fn iMapperAtan(call: ?*ir_node) i32 {
return low_level.i_mapper_atan(call);
}
pub fn iMapperSinh(call: ?*ir_node) i32 {
return low_level.i_mapper_sinh(call);
}
pub fn iMapperCosh(call: ?*ir_node) i32 {
return low_level.i_mapper_cosh(call);
}
pub fn iMapperTanh(call: ?*ir_node) i32 {
return low_level.i_mapper_tanh(call);
}
pub fn iMapperStrcmp(call: ?*ir_node) i32 {
return low_level.i_mapper_strcmp(call);
}
pub fn iMapperStrncmp(call: ?*ir_node) i32 {
return low_level.i_mapper_strncmp(call);
}
pub fn iMapperStrcpy(call: ?*ir_node) i32 {
return low_level.i_mapper_strcpy(call);
}
pub fn iMapperStrlen(call: ?*ir_node) i32 {
return low_level.i_mapper_strlen(call);
}
pub fn iMapperMemcpy(call: ?*ir_node) i32 {
return low_level.i_mapper_memcpy(call);
}
pub fn iMapperMemmove(call: ?*ir_node) i32 {
return low_level.i_mapper_memmove(call);
}
pub fn iMapperMemset(call: ?*ir_node) i32 {
return low_level.i_mapper_memset(call);
}
pub fn iMapperMemcmp(call: ?*ir_node) i32 {
return low_level.i_mapper_memcmp(call);
}
pub fn irTargetSet(target_triple: [*]const u8) i32 {
return low_level.ir_target_set(target_triple);
}
pub fn irTargetSetTriple(machine: ?*const ir_machine_triple_t) i32 {
return low_level.ir_target_set_triple(machine);
}
pub fn irTargetOption(option: [*]const u8) i32 {
return low_level.ir_target_option(option);
}
pub fn irTargetInit() void {
return low_level.ir_target_init();
}
pub fn irTargetExperimental() [*]const u8 {
return low_level.ir_target_experimental();
}
pub fn irTargetBigEndian() i32 {
return low_level.ir_target_big_endian();
}
pub fn irTargetBiggestAlignment() u32 {
return low_level.ir_target_biggest_alignment();
}
pub fn irTargetPointerSize() u32 {
return low_level.ir_target_pointer_size();
}
pub fn irTargetSupportsPic() i32 {
return low_level.ir_target_supports_pic();
}
pub fn irTargetFastUnalignedMemaccess() i32 {
return low_level.ir_target_fast_unaligned_memaccess();
}
pub fn irTargetFloatArithmeticMode() ?*ir_mode {
return low_level.ir_target_float_arithmetic_mode();
}
pub fn irTargetFloatIntOverflowStyle() float_int_conversion_overflow_style_t {
return @intToEnum(float_int_conversion_overflow_style_t, low_level.ir_target_float_int_overflow_style());
}
pub fn irPlatformLongLongAndDoubleStructAlignOverride() u32 {
return low_level.ir_platform_long_long_and_double_struct_align_override();
}
pub fn irPlatformPicIsDefault() i32 {
return low_level.ir_platform_pic_is_default();
}
pub fn irPlatformSupportsThreadLocalStorage() i32 {
return low_level.ir_platform_supports_thread_local_storage();
}
pub fn irPlatformDefineValue(define: ?*const ir_platform_define_t) [*]const u8 {
return low_level.ir_platform_define_value(define);
}
pub fn irPlatformWcharType() ir_platform_type_t {
return @intToEnum(ir_platform_type_t, low_level.ir_platform_wchar_type());
}
pub fn irPlatformWcharIsSigned() i32 {
return low_level.ir_platform_wchar_is_signed();
}
pub fn irPlatformIntptrType() ir_platform_type_t {
return @intToEnum(ir_platform_type_t, low_level.ir_platform_intptr_type());
}
pub fn irPlatformTypeSize(@"type": u32) u32 {
return low_level.ir_platform_type_size(@"type");
}
pub fn irPlatformTypeAlign(@"type": u32) u32 {
return low_level.ir_platform_type_align(@"type");
}
pub fn irPlatformTypeMode(@"type": u32, is_signed: i32) ?*ir_mode {
return low_level.ir_platform_type_mode(@"type", is_signed);
}
pub fn irPlatformVaListType() ?*ir_type {
return low_level.ir_platform_va_list_type();
}
pub fn irPlatformUserLabelPrefix() [*]const u8 {
return low_level.ir_platform_user_label_prefix();
}
pub fn irPlatformDefaultExeName() [*]const u8 {
return low_level.ir_platform_default_exe_name();
}
pub fn irPlatformMangleGlobal(name: [*]const u8) [*]const u8 {
return low_level.ir_platform_mangle_global(name);
}
pub fn irPlatformDefineFirst() ir_platform_define_t {
return low_level.ir_platform_define_first();
}
pub fn irPlatformDefineNext(define: ?*const ir_platform_define_t) ir_platform_define_t {
return low_level.ir_platform_define_next(define);
}
pub fn irPlatformDefineName(define: ?*const ir_platform_define_t) [*]const u8 {
return low_level.ir_platform_define_name(define);
}
pub fn irParseMachineTriple(triple_string: [*]const u8) ?*ir_machine_triple_t {
return low_level.ir_parse_machine_triple(triple_string);
}
pub fn irGetHostMachineTriple() ?*ir_machine_triple_t {
return low_level.ir_get_host_machine_triple();
}
pub fn irTripleGetCpuType(triple: ?*const ir_machine_triple_t) [*]const u8 {
return low_level.ir_triple_get_cpu_type(triple);
}
pub fn irTripleGetManufacturer(triple: ?*const ir_machine_triple_t) [*]const u8 {
return low_level.ir_triple_get_manufacturer(triple);
}
pub fn irTripleGetOperatingSystem(triple: ?*const ir_machine_triple_t) [*]const u8 {
return low_level.ir_triple_get_operating_system(triple);
}
pub fn irTripleSetCpuType(triple: ?*ir_machine_triple_t, cpu_type: [*]const u8) void {
return low_level.ir_triple_set_cpu_type(triple, cpu_type);
}
pub fn irFreeMachineTriple(triple: ?*ir_machine_triple_t) void {
return low_level.ir_free_machine_triple(triple);
}
pub fn irTimerEnterHighPriority() i32 {
return low_level.ir_timer_enter_high_priority();
}
pub fn irTimerLeaveHighPriority() i32 {
return low_level.ir_timer_leave_high_priority();
}
pub fn irTimerNew() ?*ir_timer_t {
return low_level.ir_timer_new();
}
pub fn irTimerFree(timer: ?*ir_timer_t) void {
return low_level.ir_timer_free(timer);
}
pub fn irTimerStart(timer: ?*ir_timer_t) void {
return low_level.ir_timer_start(timer);
}
pub fn irTimerResetAndStart(timer: ?*ir_timer_t) void {
return low_level.ir_timer_reset_and_start(timer);
}
pub fn irTimerReset(timer: ?*ir_timer_t) void {
return low_level.ir_timer_reset(timer);
}
pub fn irTimerStop(timer: ?*ir_timer_t) void {
return low_level.ir_timer_stop(timer);
}
pub fn irTimerInitParent(timer: ?*ir_timer_t) void {
return low_level.ir_timer_init_parent(timer);
}
pub fn irTimerPush(timer: ?*ir_timer_t) void {
return low_level.ir_timer_push(timer);
}
pub fn irTimerPop(timer: ?*ir_timer_t) void {
return low_level.ir_timer_pop(timer);
}
pub fn irTimerElapsedMsec(timer: ?*const ir_timer_t) u64 {
return low_level.ir_timer_elapsed_msec(timer);
}
pub fn irTimerElapsedUsec(timer: ?*const ir_timer_t) u64 {
return low_level.ir_timer_elapsed_usec(timer);
}
pub fn irTimerElapsedSec(timer: ?*const ir_timer_t) f64 {
return low_level.ir_timer_elapsed_sec(timer);
}
pub fn newTarvalFromStr(str: [*]const u8, len: usize, mode: ?*ir_mode) ?*ir_tarval {
return low_level.new_tarval_from_str(str, len, mode);
}
pub fn newIntegerTarvalFromStr(str: [*]const u8, len: usize, negative: i32, base: u8, mode: ?*ir_mode) ?*ir_tarval {
return low_level.new_integer_tarval_from_str(str, len, negative, base, mode);
}
pub fn newTarvalFromLong(l: i64, mode: ?*ir_mode) ?*ir_tarval {
return low_level.new_tarval_from_long(l, mode);
}
pub fn newTarvalFromBytes(buf: [*]const u8, mode: ?*ir_mode) ?*ir_tarval {
return low_level.new_tarval_from_bytes(buf, mode);
}
pub fn newTarvalNan(mode: ?*ir_mode, signaling: i32, payload: ?*const ir_tarval) ?*ir_tarval {
return low_level.new_tarval_nan(mode, signaling, payload);
}
pub fn tarvalToBytes(buffer: [*]u8, tv: ?*const ir_tarval) void {
return low_level.tarval_to_bytes(buffer, tv);
}
pub fn getTarvalLong(tv: ?*const ir_tarval) i64 {
return low_level.get_tarval_long(tv);
}
pub fn tarvalIsLong(tv: ?*const ir_tarval) i32 {
return low_level.tarval_is_long(tv);
}
pub fn newTarvalFromDouble(d: f64, mode: ?*ir_mode) ?*ir_tarval {
return low_level.new_tarval_from_double(d, mode);
}
pub fn newTarvalFromLongDouble(d: f64, mode: ?*ir_mode) ?*ir_tarval {
return low_level.new_tarval_from_long_double(d, mode);
}
pub fn getTarvalDouble(tv: ?*const ir_tarval) f64 {
return low_level.get_tarval_double(tv);
}
pub fn getTarvalLongDouble(tv: ?*const ir_tarval) f64 {
return low_level.get_tarval_long_double(tv);
}
pub fn tarvalIsDouble(tv: ?*const ir_tarval) i32 {
return low_level.tarval_is_double(tv);
}
pub fn getTarvalMode(tv: ?*const ir_tarval) ?*ir_mode {
return low_level.get_tarval_mode(tv);
}
pub fn tarvalIsNegative(tv: ?*const ir_tarval) i32 {
return low_level.tarval_is_negative(tv);
}
pub fn tarvalIsNull(tv: ?*const ir_tarval) i32 {
return low_level.tarval_is_null(tv);
}
pub fn tarvalIsOne(tv: ?*const ir_tarval) i32 {
return low_level.tarval_is_one(tv);
}
pub fn tarvalIsAllOne(tv: ?*const ir_tarval) i32 {
return low_level.tarval_is_all_one(tv);
}
pub fn tarvalIsConstant(tv: ?*const ir_tarval) i32 {
return low_level.tarval_is_constant(tv);
}
pub fn getTarvalBad() ?*ir_tarval {
return low_level.get_tarval_bad();
}
pub fn getTarvalUnknown() ?*ir_tarval {
return low_level.get_tarval_unknown();
}
pub fn getTarvalBFalse() ?*ir_tarval {
return low_level.get_tarval_b_false();
}
pub fn getTarvalBTrue() ?*ir_tarval {
return low_level.get_tarval_b_true();
}
pub fn tarvalSetWrapOnOverflow(wrap_on_overflow: i32) void {
return low_level.tarval_set_wrap_on_overflow(wrap_on_overflow);
}
pub fn tarvalGetWrapOnOverflow() i32 {
return low_level.tarval_get_wrap_on_overflow();
}
pub fn tarvalCmp(a: ?*const ir_tarval, b: ?*const ir_tarval) ir_relation {
return @intToEnum(ir_relation, low_level.tarval_cmp(a, b));
}
pub fn tarvalConvertTo(src: ?*const ir_tarval, mode: ?*ir_mode) ?*ir_tarval {
return low_level.tarval_convert_to(src, mode);
}
pub fn tarvalBitcast(src: ?*const ir_tarval, mode: ?*ir_mode) ?*ir_tarval {
return low_level.tarval_bitcast(src, mode);
}
pub fn tarvalNot(a: ?*const ir_tarval) ?*ir_tarval {
return low_level.tarval_not(a);
}
pub fn tarvalNeg(a: ?*const ir_tarval) ?*ir_tarval {
return low_level.tarval_neg(a);
}
pub fn tarvalAdd(a: ?*const ir_tarval, b: ?*const ir_tarval) ?*ir_tarval {
return low_level.tarval_add(a, b);
}
pub fn tarvalSub(a: ?*const ir_tarval, b: ?*const ir_tarval) ?*ir_tarval {
return low_level.tarval_sub(a, b);
}
pub fn tarvalMul(a: ?*const ir_tarval, b: ?*const ir_tarval) ?*ir_tarval {
return low_level.tarval_mul(a, b);
}
pub fn tarvalDiv(a: ?*const ir_tarval, b: ?*const ir_tarval) ?*ir_tarval {
return low_level.tarval_div(a, b);
}
pub fn tarvalMod(a: ?*const ir_tarval, b: ?*const ir_tarval) ?*ir_tarval {
return low_level.tarval_mod(a, b);
}
pub fn tarvalDivmod(a: ?*const ir_tarval, b: ?*const ir_tarval, mod_res: [*]?*ir_tarval) ?*ir_tarval {
return low_level.tarval_divmod(a, b, mod_res);
}
pub fn tarvalAbs(a: ?*const ir_tarval) ?*ir_tarval {
return low_level.tarval_abs(a);
}
pub fn tarvalAnd(a: ?*const ir_tarval, b: ?*const ir_tarval) ?*ir_tarval {
return low_level.tarval_and(a, b);
}
pub fn tarvalAndnot(a: ?*const ir_tarval, b: ?*const ir_tarval) ?*ir_tarval {
return low_level.tarval_andnot(a, b);
}
pub fn tarvalOr(a: ?*const ir_tarval, b: ?*const ir_tarval) ?*ir_tarval {
return low_level.tarval_or(a, b);
}
pub fn tarvalOrnot(a: ?*const ir_tarval, b: ?*const ir_tarval) ?*ir_tarval {
return low_level.tarval_ornot(a, b);
}
pub fn tarvalEor(a: ?*const ir_tarval, b: ?*const ir_tarval) ?*ir_tarval {
return low_level.tarval_eor(a, b);
}
pub fn tarvalShl(a: ?*const ir_tarval, b: ?*const ir_tarval) ?*ir_tarval {
return low_level.tarval_shl(a, b);
}
pub fn tarvalShlUnsigned(a: ?*const ir_tarval, b: u32) ?*ir_tarval {
return low_level.tarval_shl_unsigned(a, b);
}
pub fn tarvalShr(a: ?*const ir_tarval, b: ?*const ir_tarval) ?*ir_tarval {
return low_level.tarval_shr(a, b);
}
pub fn tarvalShrUnsigned(a: ?*const ir_tarval, b: u32) ?*ir_tarval {
return low_level.tarval_shr_unsigned(a, b);
}
pub fn tarvalShrs(a: ?*const ir_tarval, b: ?*const ir_tarval) ?*ir_tarval {
return low_level.tarval_shrs(a, b);
}
pub fn tarvalShrsUnsigned(a: ?*const ir_tarval, b: u32) ?*ir_tarval {
return low_level.tarval_shrs_unsigned(a, b);
}
pub fn getTarvalSubBits(tv: ?*const ir_tarval, byte_ofs: u32) [*]const u8 {
return low_level.get_tarval_sub_bits(tv, byte_ofs);
}
pub fn getTarvalPopcount(tv: ?*const ir_tarval) i32 {
return low_level.get_tarval_popcount(tv);
}
pub fn getTarvalLowestBit(tv: ?*const ir_tarval) i32 {
return low_level.get_tarval_lowest_bit(tv);
}
pub fn getTarvalHighestBit(tv: ?*const ir_tarval) i32 {
return low_level.get_tarval_highest_bit(tv);
}
pub fn tarvalZeroMantissa(tv: ?*const ir_tarval) i32 {
return low_level.tarval_zero_mantissa(tv);
}
pub fn tarvalGetExponent(tv: ?*const ir_tarval) i32 {
return low_level.tarval_get_exponent(tv);
}
pub fn tarvalIeee754CanConvLossless(tv: ?*const ir_tarval, mode: ?*const ir_mode) i32 {
return low_level.tarval_ieee754_can_conv_lossless(tv, mode);
}
pub fn tarvalIeee754GetExact() u32 {
return low_level.tarval_ieee754_get_exact();
}
pub fn tarvalIsNan(tv: ?*const ir_tarval) i32 {
return low_level.tarval_is_nan(tv);
}
pub fn tarvalIsQuietNan(tv: ?*const ir_tarval) i32 {
return low_level.tarval_is_quiet_nan(tv);
}
pub fn tarvalIsSignalingNan(tv: ?*const ir_tarval) i32 {
return low_level.tarval_is_signaling_nan(tv);
}
pub fn tarvalIsFinite(tv: ?*const ir_tarval) i32 {
return low_level.tarval_is_finite(tv);
}
pub fn setVrpData(irg: ?*ir_graph) void {
return low_level.set_vrp_data(irg);
}
pub fn freeVrpData(irg: ?*ir_graph) void {
return low_level.free_vrp_data(irg);
}
pub fn vrpCmp(left: ?*const ir_node, right: ?*const ir_node) ir_relation {
return @intToEnum(ir_relation, low_level.vrp_cmp(left, right));
}
pub fn vrpGetInfo(n: ?*const ir_node) [*]vrp_attr {
return low_level.vrp_get_info(n);
} | src/firm-abi.zig |
const std = @import("std");
var a: *std.mem.Allocator = undefined;
const stdout = std.io.getStdOut().writer(); //prepare stdout to write in
test "simple" {
const input = "byr:1944 iyr:2010 eyr:2021 hgt:158cm hcl:#b6652a ecl:blu pid:093154719 gar:coucou";
var buf = input.*;
std.testing.expect(run(&buf) == 1);
}
test "AoC examples" {
const input =
\\pid:087499704 hgt:74in ecl:grn iyr:2012 eyr:2030 byr:1980
\\hcl:#623a2f
\\
\\eyr:2029 ecl:blu cid:129 byr:1989
\\iyr:2014 pid:896056539 hcl:#a97842 hgt:165cm
\\
\\hcl:#888785
\\hgt:164cm byr:2001 iyr:2015 cid:88
\\pid:545766238 ecl:hzl
\\eyr:2022
\\
\\iyr:2010 hgt:158cm hcl:#b6652a ecl:blu byr:1944 eyr:2021 pid:093154719
\\
\\eyr:1972 cid:100
\\hcl:#18171d ecl:amb hgt:170 pid:186cm iyr:2018 byr:1926
\\
\\iyr:2019
\\hcl:#602927 eyr:1967 hgt:170cm
\\ecl:grn pid:012533040 byr:1946
\\
\\hcl:dab227 iyr:2012
\\ecl:brn hgt:182cm pid:021572410 eyr:2020 byr:1992 cid:277
\\
\\hgt:59cm ecl:zzz
\\eyr:2038 hcl:74454a iyr:2023
\\pid:3556412378 byr:2007
;
var buf = input.*;
std.testing.expect(run(&buf) == 4);
}
fn run(input: [:0]u8) u32 {
var all_lines_it = std.mem.split(input, "\n");
var valid_passwords: u32 = 0;
var correct_fields: std.meta.Vector(7, bool) = [_]bool{false} ** 7; // Vectors allows SIMD reduce.
var all_fields_valid: bool = true;
while (all_lines_it.next()) |line| {
if (line.len == 0) {
// Empty lines are passport delimiters.
if (@reduce(.And, correct_fields) and all_fields_valid) {
// Check that we have the right 7 fields (or more, as long as they're all valid, who cares ?)
valid_passwords += 1;
}
correct_fields = [_]bool{false} ** 7;
all_fields_valid = true;
} else {
if (!all_fields_valid) {
// Don't waste time parsing a line if we know this passport is invalid
continue;
}
var tokenizer = std.mem.tokenize(line, " ");
while (tokenizer.next()) |token| {
if (token.len < 4) {
// Don't crash on malformed input
all_fields_valid = false;
break;
}
if (token[3] != ':') {
all_fields_valid = false;
break;
}
const _type = token[0..3];
const value = token[4..];
if (std.mem.eql(u8, _type, "byr")) {
// byr (Birth Year) - four digits; at least 1920 and at most 2002.
correct_fields[0] = true;
const value_int: u16 = std.fmt.parseInt(u16, value, 10) catch {
// this block is executed if parseInt throws an error
all_fields_valid = false;
continue;
};
if (value_int < 1920 or value_int > 2002) {
all_fields_valid = false;
}
} else if (std.mem.eql(u8, _type, "iyr")) {
// iyr (Issue Year) - four digits; at least 2010 and at most 2020.
correct_fields[1] = true;
const value_int: u16 = std.fmt.parseInt(u16, value, 10) catch {
all_fields_valid = false;
continue;
};
if (value_int < 2010 or value_int > 2020) {
all_fields_valid = false;
}
} else if (std.mem.eql(u8, _type, "eyr")) {
// eyr (Expiration Year) - four digits; at least 2020 and at most 2030.
correct_fields[2] = true;
const value_int: u16 = std.fmt.parseInt(u16, value, 10) catch {
all_fields_valid = false;
continue;
};
if (value_int < 2020 or value_int > 2030) {
all_fields_valid = false;
}
} else if (std.mem.eql(u8, _type, "hgt")) {
// hgt (Height) - a number followed by either cm or in:
// If cm, the number must be at least 150 and at most 193.
// If in, the number must be at least 59 and at most 76.
correct_fields[3] = true;
const len = value.len;
switch (value[len - 1]) {
'm' => {
if (value[value.len - 2] == 'c') {
const hgt = std.fmt.parseInt(u8, value[0 .. len - 2], 10) catch {
all_fields_valid = false;
continue;
};
if (150 > hgt or hgt > 193) { // On a pas le droit de faire plus d'1m93 askip
all_fields_valid = false;
}
}
},
'n' => {
if (value[value.len - 2] == 'i') {
const hgt = std.fmt.parseInt(u8, value[0 .. len - 2], 10) catch {
all_fields_valid = false;
continue;
};
if (59 > hgt or hgt > 76) {
all_fields_valid = false;
}
}
},
else => {
all_fields_valid = false;
continue;
},
}
} else if (std.mem.eql(u8, _type, "hcl")) {
// hcl (Hair Color) - a # followed by exactly six characters 0-9 or a-f.
correct_fields[4] = true;
if (value[0] != '#') {
all_fields_valid = false;
continue;
}
if (value[1..].len != 6) {
all_fields_valid = false;
continue;
}
for (value[1..]) |char| {
if (char < '0' or (char > '9' and (char < 'a' or char > 'z'))) {
all_fields_valid = false;
break;
}
}
} else if (std.mem.eql(u8, _type, "ecl")) {
// ecl (Eye Color) - exactly one of: amb blu brn gry grn hzl oth.
correct_fields[5] = true;
if (!(std.mem.eql(u8, value, "amb") or std.mem.eql(u8, value, "blu") or std.mem.eql(u8, value, "brn") or std.mem.eql(u8, value, "gry") or std.mem.eql(u8, value, "grn") or std.mem.eql(u8, value, "hzl") or std.mem.eql(u8, value, "oth"))) {
all_fields_valid = false;
}
} else if (std.mem.eql(u8, _type, "pid")) {
// pid (Passport ID) - a nine-digit number, including leading zeroes.
correct_fields[6] = true;
var digits: i8 = 0;
for (value) |char| {
if (char >= '0' and char <= '9') {
digits += 1;
} else {
all_fields_valid = false;
break;
}
}
if (digits != 9) {
all_fields_valid = false;
}
}
// cid (Country ID) - ignored, missing or not.
// all extra fields are ignored as well, in case passports contain country-specific extra items
}
}
}
if (@reduce(.And, correct_fields) and all_fields_valid) {
valid_passwords += 1;
}
return valid_passwords;
}
pub fn main() !void {
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); // create memory allocator for strings
defer arena.deinit(); // clear memory
var arg_it = std.process.args();
_ = arg_it.skip(); // skip over exe name
a = &arena.allocator; // get ref to allocator
const input: [:0]u8 = try (arg_it.next(a)).?; // get the first argument
const start: i128 = std.time.nanoTimestamp(); // start time
const answer = run(input); // compute answer
const elapsed_nano: f128 = @intToFloat(f128, std.time.nanoTimestamp() - start);
const elapsed_milli: f64 = @floatCast(f64, @divFloor(elapsed_nano, 1_000_000));
try stdout.print("_duration:{d}\n{}\n", .{ elapsed_milli, answer }); // emit actual lines parsed by AOC
} | day-04/part-2/lelithium.zig |
const std = @import("std");
const cuda = @import("cuda.zig");
const assert = std.debug.assert;
const mem = std.mem;
const Allocator = std.mem.Allocator;
const log = std.log.scoped(.Cuda);
/// This allocator takes the cuda allocator, wraps it, and provides an interface
/// where you can allocate without freeing, and then free it all together.
/// It also need a host allocator to store the node metadata.
/// It is an adapation from std lib arena allocator, where create_node uses the host allocator
/// Technically it works, but don't have all the convenient methods
/// from the std.mem.Allocator API. See below for more explanation
pub const ArenaAllocator = struct {
nodes: std.ArrayList([]u8),
end_index: usize = 0,
const Node = []u8;
pub fn init(host_allocator: Allocator) ArenaAllocator {
return .{ .nodes = std.ArrayList([]u8).init(host_allocator) };
}
pub fn deinit(self: *ArenaAllocator) void {
for (self.nodes.items) |node| {
// this has to occur before the free because the free frees node
cuda.free(node);
}
self.nodes.deinit();
}
fn createNode(self: *ArenaAllocator, prev_len: usize, minimum_size: usize) Allocator.Error!*Node {
const big_enough_len = prev_len + minimum_size;
const len = big_enough_len + big_enough_len / 2;
const buf = cuda.alloc(u8, len) catch |err| switch (err) {
error.OutOfMemory => cuda.alloc(u8, minimum_size) catch return error.OutOfMemory,
else => unreachable,
};
const buf_node = try self.nodes.addOne();
buf_node.* = buf;
self.end_index = 0;
return buf_node;
}
pub fn alloc(self: *ArenaAllocator, comptime T: type, n_items: usize) Allocator.Error![]T {
const n = @sizeOf(T) * n_items;
var num_nodes = self.nodes.items.len;
var cur_node = if (num_nodes > 0) &self.nodes.items[num_nodes - 1] else try self.createNode(0, n);
// this while loop should only execute twice
var counter: u8 = 0;
while (true) {
const cur_buf = cur_node.*;
const new_end_index = self.end_index + n;
if (new_end_index <= cur_buf.len) {
const result = cur_buf[self.end_index..new_end_index];
self.end_index = new_end_index;
return result;
}
// Allocate more memory
cur_node = try self.createNode(cur_buf.len, n);
counter += 1;
std.debug.assert(counter < 2);
}
}
pub fn resizeFn(allocator: Allocator, buf: []u8, buf_align: u29, new_len: usize, len_align: u29, ret_addr: usize) Allocator.Error!usize {
_ = buf_align;
_ = len_align;
_ = ret_addr;
const self = @fieldParentPtr(ArenaAllocator, "allocator", allocator);
var num_nodes = self.nodes.items.len;
var cur_node = if (num_nodes > 0) &self.nodes.items[num_nodes - 1] else return error.OutOfMemory;
const cur_buf = cur_node.*[@sizeOf(Node)..];
if (@ptrToInt(cur_buf.ptr) + self.end_index != @ptrToInt(buf.ptr) + buf.len) {
if (new_len > buf.len)
return error.OutOfMemory;
return new_len;
}
if (buf.len >= new_len) {
self.end_index -= buf.len - new_len;
return new_len;
} else if (cur_buf.len - self.end_index >= new_len - buf.len) {
self.end_index += new_len - buf.len;
return new_len;
} else {
return error.OutOfMemory;
}
}
};
// *** Tentative to create a standard allocator API using cuAlloc ***
// This doesn't work because Allocator.zig from std will call @memset(undefined)
// on the returned pointer which will segfault, because we're returning a device pointer.
// https://github.com/ziglang/zig/issues/4298 want to make the @memset optional
// But does it make sense to have an allocator that return GPU memory ?
// Most function that want an allocator want to read/write the returned data.
// I think we should only have this in GPU code.
// TODO: we could create an allocator that map the memory to the host
// this will likely make read/write much slower though
// https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__VA.html#group__CUDA__VA
// fn cudaAllocMappedFn(allocator: Allocator, n: usize, ptr_align: u29, len_align: u29, ra: usize) Allocator.Error![]u8 {
// }
//
pub const cuda_allocator = &cuda_allocator_state;
var cuda_allocator_state = Allocator{
.allocFn = cudaAllocFn,
.resizeFn = cudaResizeFn,
};
fn cudaAllocFn(allocator: Allocator, n: usize, ptr_align: u29, len_align: u29, ra: usize) Allocator.Error![]u8 {
_ = allocator;
_ = ra;
_ = ptr_align;
_ = len_align;
const x = cuda.alloc(u8, n) catch |err| switch (err) {
error.OutOfMemory => return error.OutOfMemory,
else => {
log.err("Cuda error while allocating memory: {}", .{err});
return error.OutOfMemory;
},
};
@memset(x.ptr, undefined, x.len);
log.warn("allocated {}b at {*}", .{ x.len, x.ptr });
return x;
}
fn cudaResizeFn(allocator: Allocator, buf: []u8, buf_align: u29, new_len: usize, len_align: u29, ra: usize) Allocator.Error!usize {
_ = allocator;
_ = ra;
_ = buf_align;
if (new_len == 0) {
cuda.free(buf);
return new_len;
}
if (new_len <= buf.len) {
return std.mem.alignAllocLen(buf.len, new_len, len_align);
}
return error.OutOfMemory;
}
test "cuda_allocator" {
_ = try cuda.Stream.init(0);
const x = cuda.alloc(u8, 800) catch |err| switch (err) {
error.OutOfMemory => return error.OutOfMemory,
else => {
log.err("Cuda error while allocating memory: {}", .{err});
return error.OutOfMemory;
},
};
log.warn("allocated {} bytes at {*}", .{ x.len, x.ptr });
@memset(x.ptr, undefined, x.len);
// try std.heap.testAllocator(cuda_allocator);
}
test "nice error when OOM" {
var stream = try cuda.Stream.init(0);
defer stream.deinit();
var arena = ArenaAllocator.init(std.testing.allocator);
var last_err: anyerror = blk: {
while (true) {
_ = arena.alloc(u8, 1024 * 1024) catch |err| break :blk err;
}
};
try std.testing.expectEqual(last_err, error.OutOfMemory);
log.warn("Cleaning up cuda memory and reallocating", .{});
arena.deinit();
var buff = try cuda.alloc(u8, 1024 * 1024);
defer cuda.free(buff);
} | cudaz/src/allocator.zig |
const std = @import("std");
const zlm = @import("zlm");
const Vec3 = zlm.Vec3;
const Allocator = std.mem.Allocator;
usingnamespace @import("didot-graphics");
const objects = @import("didot-objects");
const models = @import("didot-models");
const image = @import("didot-image");
const physics = @import("didot-physics");
const bmp = image.bmp;
const obj = models.obj;
const Application = @import("didot-app").Application;
const GameObject = objects.GameObject;
const Scene = objects.Scene;
const Camera = objects.Camera;
const PointLight = objects.PointLight;
var world: physics.World = undefined;
var simPaused: bool = false;
var cube2: GameObject = undefined;
const Component = objects.Component;
const CameraControllerData = struct { input: *Input };
const CameraController = objects.ComponentType(.CameraController, CameraControllerData, .{ .updateFn = cameraInput }) {};
fn cameraInput(allocator: *Allocator, component: *Component, delta: f32) !void {
const data = component.getData(CameraControllerData);
const input = data.input;
const gameObject = component.gameObject;
const speed: f32 = 0.1 * delta;
const forward = gameObject.getForward();
const left = gameObject.getLeft();
if (input.isKeyDown(Input.KEY_W)) {
gameObject.position = gameObject.position.add(forward.scale(speed));
}
if (input.isKeyDown(Input.KEY_S)) {
gameObject.position = gameObject.position.add(forward.scale(-speed));
}
if (input.isKeyDown(Input.KEY_A)) {
gameObject.position = gameObject.position.add(left.scale(speed));
}
if (input.isKeyDown(Input.KEY_D)) {
gameObject.position = gameObject.position.add(left.scale(-speed));
}
if (input.isKeyDown(Input.KEY_UP)) {
if (cube2.findComponent(.Rigidbody)) |rb| {
rb.getData(physics.RigidbodyData).addForce(zlm.Vec3.new(0, 20, 0));
}
}
if (input.isKeyDown(Input.KEY_LEFT)) {
if (cube2.findComponent(.Rigidbody)) |rb| {
rb.getData(physics.RigidbodyData).addForce(zlm.Vec3.new(5, 0, 0));
}
}
if (input.isKeyDown(Input.KEY_RIGHT)) {
if (cube2.findComponent(.Rigidbody)) |rb| {
rb.getData(physics.RigidbodyData).addForce(zlm.Vec3.new(0, 0, 5));
}
}
if (input.isMouseButtonDown(.Left)) {
input.setMouseInputMode(.Grabbed);
simPaused = false;
} else if (input.isMouseButtonDown(.Right)) {
input.setMouseInputMode(.Normal);
} else if (input.isKeyDown(Input.KEY_ESCAPE)) {
input.setMouseInputMode(.Normal);
}
if (input.getMouseInputMode() == .Grabbed) {
gameObject.rotation.x -= (input.mouseDelta.x / 300.0) * delta;
gameObject.rotation.y -= (input.mouseDelta.y / 300.0) * delta;
}
if (input.getJoystick(0)) |joystick| {
const axes = joystick.getRawAxes();
var r = axes[0]; // right
var fw = axes[1]; // forward
const thrust = (axes[3] - 1.0) * -0.5;
const threshold = 0.2;
if (r < threshold and r > 0) r = 0; if (r > -threshold and r < 0) r = 0;
if (fw < threshold and fw > 0) fw = 0; if (fw > -threshold and fw < 0) fw = 0;
gameObject.position = gameObject.position.add(forward.scale(thrust * speed));
gameObject.rotation.x -= (r / 50.0) * delta;
gameObject.rotation.y -= (fw / 50.0) * delta;
// std.debug.warn("A: {}, B: {}, X: {}, Y: {}\n", .{
// joystick.isButtonDown(.A),
// joystick.isButtonDown(.B),
// joystick.isButtonDown(.X),
// joystick.isButtonDown(.Y),
// });
}
}
const TestLight = objects.ComponentType(.TestLight, struct {}, .{ .updateFn = testLight }) {};
fn testLight(allocator: *Allocator, component: *Component, delta: f32) !void {
const time = @intToFloat(f64, std.time.milliTimestamp());
const rad = @floatCast(f32, @mod((time / 1000.0), std.math.pi * 2.0));
component.gameObject.position = Vec3.new(std.math.sin(rad) * 20 + 10, 3, std.math.cos(rad) * 10 - 10);
}
fn loadSkybox(allocator: *Allocator, camera: *Camera, scene: *Scene) !GameObject {
var skyboxShader = try ShaderProgram.createFromFile(allocator, "assets/shaders/skybox-vert.glsl", "assets/shaders/skybox-frag.glsl");
camera.*.skyboxShader = skyboxShader;
try scene.assetManager.put("Texture/Skybox", try TextureAsset.initCubemap(allocator, .{
.front = "assets/textures/skybox/front.bmp",
.back = "assets/textures/skybox/back.bmp",
.left = "assets/textures/skybox/left.bmp",
.right = "assets/textures/skybox/right.bmp",
.top = "assets/textures/skybox/top.bmp",
.bottom = "assets/textures/skybox/bottom.bmp"
}, "bmp"));
var skyboxMaterial = Material{ .texturePath = "Texture/Skybox" };
var skybox = try objects.createSkybox(allocator);
skybox.meshPath = "Mesh/Cube";
skybox.material = skyboxMaterial;
return skybox;
}
fn initFromFile(allocator: *Allocator, app: *Application) !void {
input = &app.window.input;
var scene = Scene.loadFromFile(allocator, "res/example-scene.json");
scene.findChild("Camera").?.updateFn = cameraInput;
scene.findChild("Light").?.updateFn = testLight;
app.scene = scene;
//var skybox = try loadSkybox(allocator, camera);
//try scene.add(skybox);
// var i: f32 = 0;
// while (i < 5) {
// var j: f32 = 0;
// while (j < 5) {
// var kart2 = GameObject.createObject(allocator, "Mesh/Kart");
// kart2.position = Vec3.new(0.7 + (j*8), 0.75, -8 - (i*3));
// try scene.add(kart2);
// j += 1;
// }
// i += 1;
// }
}
fn update(allocator: *Allocator, app: *Application, delta: f32) !void {
if (!simPaused)
world.update();
}
fn init(allocator: *Allocator, app: *Application) !void {
world = physics.World.create();
world.setGravity(zlm.Vec3.new(0, -9.8, 0));
var shader = try ShaderProgram.createFromFile(allocator, "assets/shaders/vert.glsl", "assets/shaders/frag.glsl");
const scene = app.scene;
try scene.assetManager.put("Texture/Grass", try TextureAsset.init(allocator, .{
.path = "assets/textures/grass.png", .format = "png",
.tiling = zlm.Vec2.new(2, 2)
}));
var grassMaterial = Material{ .texturePath = "Texture/Grass" };
var camera = try Camera.create(allocator, shader);
camera.gameObject.position = Vec3.new(1.5, 1.5, -0.5);
camera.gameObject.rotation = Vec3.new(-120.0, -15.0, 0).toRadians();
const controller = try CameraController.newWithData(allocator, .{ .input = &app.window.input });
try camera.gameObject.addComponent(controller);
try scene.add(camera.gameObject);
const skybox = try loadSkybox(allocator, camera, scene);
try scene.add(skybox);
var cube = GameObject.createObject(allocator, "Mesh/Cube");
cube.position = Vec3.new(5, -0.75, -10);
cube.scale = Vec3.new(50, 1, 50);
cube.material = grassMaterial;
try cube.addComponent(try physics.Rigidbody.newWithData(allocator, .{ .world=&world, .kinematic=.Kinematic, .collider = .{
.Box = .{ .size = Vec3.new(50, 1, 50) }
} }));
try scene.add(cube);
cube2 = GameObject.createObject(allocator, "Mesh/Cube");
cube2.position = Vec3.new(-1.2, 5.75, -3);
cube2.material.ambient = Vec3.new(0.2, 0.1, 0.1);
cube2.material.diffuse = Vec3.new(0.8, 0.8, 0.8);
try cube2.addComponent(try physics.Rigidbody.newWithData(allocator, .{ .world = &world }));
try scene.add(cube2);
try scene.assetManager.put("Mesh/Kart", .{
.loader = models.meshAssetLoader,
.loaderData = try models.MeshAssetLoaderData.init(allocator, "assets/kart.obj", "obj"),
.objectType = .Mesh,
});
var kart = GameObject.createObject(allocator, "Mesh/Kart");
kart.position = Vec3.new(0.7, 0.75, -5);
kart.name = "Kart";
try kart.addComponent(try physics.Rigidbody.newWithData(allocator, .{ .world = &world }));
try scene.add(kart);
var i: f32 = 0;
while (i < 7) { // rows front to back
var j: f32 = 0;
while (j < 5) { // cols left to right
var kart2 = GameObject.createObject(allocator, "Mesh/Kart");
kart2.position = Vec3.new(0.7 + (j * 8), 0.75, -8 - (i * 3));
// lets decorate the kart based on its location
kart2.material.ambient = Vec3.new(0.0, j * 0.001, 0.002);
kart2.material.diffuse = Vec3.new(i * 0.1, j * 0.1, 0.6);
// dull on the left, getting shinier to the right
kart2.material.specular = Vec3.new(1.0 - (j * 0.2), 1.0 - (j * 0.2), 0.2);
kart2.material.shininess = 110.0 - (j * 20.0);
//try kart2.addComponent(try physics.Rigidbody.newWithData(allocator,.{.world=&world}));
try scene.add(kart2);
j += 1;
}
i += 1;
}
var light = GameObject.createObject(allocator, "Mesh/Cube");
light.position = Vec3.new(1, 5, -5);
light.material.ambient = Vec3.one;
try light.addComponent(try TestLight.new(allocator));
try light.addComponent(try PointLight.newWithData(allocator, .{}));
try scene.add(light);
}
var gp: std.heap.GeneralPurposeAllocator(.{}) = .{};
pub fn main() !void {
defer _ = gp.deinit();
const allocator = &gp.allocator;
var scene = try Scene.create(allocator, null);
var app = Application{
.title = "Test Cubes",
.initFn = init
};
try app.run(allocator, scene);
} | examples/kart-and-cubes/example-scene.zig |
const std = @import("std");
const c = @cImport({
@cInclude("sqlite3.h");
});
pub const SQLiteExtendedIOError = error{
SQLiteIOErrRead,
SQLiteIOErrShortRead,
SQLiteIOErrWrite,
SQLiteIOErrFsync,
SQLiteIOErrDirFsync,
SQLiteIOErrTruncate,
SQLiteIOErrFstat,
SQLiteIOErrUnlock,
SQLiteIOErrRDLock,
SQLiteIOErrDelete,
SQLiteIOErrBlocked,
SQLiteIOErrNoMem,
SQLiteIOErrAccess,
SQLiteIOErrCheckReservedLock,
SQLiteIOErrLock,
SQLiteIOErrClose,
SQLiteIOErrDirClose,
SQLiteIOErrSHMOpen,
SQLiteIOErrSHMSize,
SQLiteIOErrSHMLock,
SQLiteIOErrSHMMap,
SQLiteIOErrSeek,
SQLiteIOErrDeleteNoEnt,
SQLiteIOErrMmap,
SQLiteIOErrGetTempPath,
SQLiteIOErrConvPath,
SQLiteIOErrVnode,
SQLiteIOErrAuth,
SQLiteIOErrBeginAtomic,
SQLiteIOErrCommitAtomic,
SQLiteIOErrRollbackAtomic,
SQLiteIOErrData,
SQLiteIOErrCorruptFS,
};
pub const SQLiteExtendedCantOpenError = error{
SQLiteCantOpenNoTempDir,
SQLiteCantOpenIsDir,
SQLiteCantOpenFullPath,
SQLiteCantOpenConvPath,
SQLiteCantOpenDirtyWAL,
SQLiteCantOpenSymlink,
};
pub const SQLiteExtendedReadOnlyError = error{
SQLiteReadOnlyRecovery,
SQLiteReadOnlyCantLock,
SQLiteReadOnlyRollback,
SQLiteReadOnlyDBMoved,
SQLiteReadOnlyCantInit,
SQLiteReadOnlyDirectory,
};
pub const SQLiteExtendedConstraintError = error{
SQLiteConstraintCheck,
SQLiteConstraintCommitHook,
SQLiteConstraintForeignKey,
SQLiteConstraintFunction,
SQLiteConstraintNotNull,
SQLiteConstraintPrimaryKey,
SQLiteConstraintTrigger,
SQLiteConstraintUnique,
SQLiteConstraintVTab,
SQLiteConstraintRowID,
SQLiteConstraintPinned,
};
pub const SQLiteExtendedError = error{
SQLiteErrorMissingCollSeq,
SQLiteErrorRetry,
SQLiteErrorSnapshot,
SQLiteLockedSharedCache,
SQLiteLockedVTab,
SQLiteBusyRecovery,
SQLiteBusySnapshot,
SQLiteBusyTimeout,
SQLiteCorruptVTab,
SQLiteCorruptSequence,
SQLiteCorruptIndex,
SQLiteAbortRollback,
};
pub const SQLiteError = error{
SQLiteError,
SQLiteInternal,
SQLitePerm,
SQLiteAbort,
SQLiteBusy,
SQLiteLocked,
SQLiteNoMem,
SQLiteReadOnly,
SQLiteInterrupt,
SQLiteIOErr,
SQLiteCorrupt,
SQLiteNotFound,
SQLiteFull,
SQLiteCantOpen,
SQLiteProtocol,
SQLiteEmpty,
SQLiteSchema,
SQLiteTooBig,
SQLiteConstraint,
SQLiteMismatch,
SQLiteMisuse,
SQLiteNoLFS,
SQLiteAuth,
SQLiteRange,
SQLiteNotADatabase,
SQLiteNotice,
SQLiteWarning,
};
pub const Error = SQLiteError ||
SQLiteExtendedError ||
SQLiteExtendedIOError ||
SQLiteExtendedCantOpenError ||
SQLiteExtendedReadOnlyError ||
SQLiteExtendedConstraintError;
pub fn errorFromResultCode(code: c_int) Error {
// TODO(vincent): can we do something with comptime here ?
// The version number is always static and defined by sqlite.
// These errors are only available since 3.25.0.
if (c.SQLITE_VERSION_NUMBER >= 3025000) {
switch (code) {
c.SQLITE_ERROR_SNAPSHOT => return error.SQLiteErrorSnapshot,
c.SQLITE_LOCKED_VTAB => return error.SQLiteLockedVTab,
c.SQLITE_CANTOPEN_DIRTYWAL => return error.SQLiteCantOpenDirtyWAL,
c.SQLITE_CORRUPT_SEQUENCE => return error.SQLiteCorruptSequence,
else => {},
}
}
// These errors are only available since 3.31.0.
if (c.SQLITE_VERSION_NUMBER >= 3031000) {
switch (code) {
c.SQLITE_CANTOPEN_SYMLINK => return error.SQLiteCantOpenSymlink,
c.SQLITE_CONSTRAINT_PINNED => return error.SQLiteConstraintPinned,
else => {},
}
}
// These errors are only available since 3.32.0.
if (c.SQLITE_VERSION_NUMBER >= 3032000) {
switch (code) {
c.SQLITE_IOERR_DATA => return error.SQLiteIOErrData, // See https://sqlite.org/cksumvfs.html
c.SQLITE_BUSY_TIMEOUT => return error.SQLiteBusyTimeout,
c.SQLITE_CORRUPT_INDEX => return error.SQLiteCorruptIndex,
else => {},
}
}
// These errors are only available since 3.34.0.
if (c.SQLITE_VERSION_NUMBER >= 3034000) {
switch (code) {
c.SQLITE_IOERR_CORRUPTFS => return error.SQLiteIOErrCorruptFS,
else => {},
}
}
switch (code) {
c.SQLITE_ERROR => return error.SQLiteError,
c.SQLITE_INTERNAL => return error.SQLiteInternal,
c.SQLITE_PERM => return error.SQLitePerm,
c.SQLITE_ABORT => return error.SQLiteAbort,
c.SQLITE_BUSY => return error.SQLiteBusy,
c.SQLITE_LOCKED => return error.SQLiteLocked,
c.SQLITE_NOMEM => return error.SQLiteNoMem,
c.SQLITE_READONLY => return error.SQLiteReadOnly,
c.SQLITE_INTERRUPT => return error.SQLiteInterrupt,
c.SQLITE_IOERR => return error.SQLiteIOErr,
c.SQLITE_CORRUPT => return error.SQLiteCorrupt,
c.SQLITE_NOTFOUND => return error.SQLiteNotFound,
c.SQLITE_FULL => return error.SQLiteFull,
c.SQLITE_CANTOPEN => return error.SQLiteCantOpen,
c.SQLITE_PROTOCOL => return error.SQLiteProtocol,
c.SQLITE_EMPTY => return error.SQLiteEmpty,
c.SQLITE_SCHEMA => return error.SQLiteSchema,
c.SQLITE_TOOBIG => return error.SQLiteTooBig,
c.SQLITE_CONSTRAINT => return error.SQLiteConstraint,
c.SQLITE_MISMATCH => return error.SQLiteMismatch,
c.SQLITE_MISUSE => return error.SQLiteMisuse,
c.SQLITE_NOLFS => return error.SQLiteNoLFS,
c.SQLITE_AUTH => return error.SQLiteAuth,
c.SQLITE_RANGE => return error.SQLiteRange,
c.SQLITE_NOTADB => return error.SQLiteNotADatabase,
c.SQLITE_NOTICE => return error.SQLiteNotice,
c.SQLITE_WARNING => return error.SQLiteWarning,
c.SQLITE_ERROR_MISSING_COLLSEQ => return error.SQLiteErrorMissingCollSeq,
c.SQLITE_ERROR_RETRY => return error.SQLiteErrorRetry,
c.SQLITE_IOERR_READ => return error.SQLiteIOErrRead,
c.SQLITE_IOERR_SHORT_READ => return error.SQLiteIOErrShortRead,
c.SQLITE_IOERR_WRITE => return error.SQLiteIOErrWrite,
c.SQLITE_IOERR_FSYNC => return error.SQLiteIOErrFsync,
c.SQLITE_IOERR_DIR_FSYNC => return error.SQLiteIOErrDirFsync,
c.SQLITE_IOERR_TRUNCATE => return error.SQLiteIOErrTruncate,
c.SQLITE_IOERR_FSTAT => return error.SQLiteIOErrFstat,
c.SQLITE_IOERR_UNLOCK => return error.SQLiteIOErrUnlock,
c.SQLITE_IOERR_RDLOCK => return error.SQLiteIOErrRDLock,
c.SQLITE_IOERR_DELETE => return error.SQLiteIOErrDelete,
c.SQLITE_IOERR_BLOCKED => return error.SQLiteIOErrBlocked,
c.SQLITE_IOERR_NOMEM => return error.SQLiteIOErrNoMem,
c.SQLITE_IOERR_ACCESS => return error.SQLiteIOErrAccess,
c.SQLITE_IOERR_CHECKRESERVEDLOCK => return error.SQLiteIOErrCheckReservedLock,
c.SQLITE_IOERR_LOCK => return error.SQLiteIOErrLock,
c.SQLITE_IOERR_CLOSE => return error.SQLiteIOErrClose,
c.SQLITE_IOERR_DIR_CLOSE => return error.SQLiteIOErrDirClose,
c.SQLITE_IOERR_SHMOPEN => return error.SQLiteIOErrSHMOpen,
c.SQLITE_IOERR_SHMSIZE => return error.SQLiteIOErrSHMSize,
c.SQLITE_IOERR_SHMLOCK => return error.SQLiteIOErrSHMLock,
c.SQLITE_IOERR_SHMMAP => return error.SQLiteIOErrSHMMap,
c.SQLITE_IOERR_SEEK => return error.SQLiteIOErrSeek,
c.SQLITE_IOERR_DELETE_NOENT => return error.SQLiteIOErrDeleteNoEnt,
c.SQLITE_IOERR_MMAP => return error.SQLiteIOErrMmap,
c.SQLITE_IOERR_GETTEMPPATH => return error.SQLiteIOErrGetTempPath,
c.SQLITE_IOERR_CONVPATH => return error.SQLiteIOErrConvPath,
c.SQLITE_IOERR_VNODE => return error.SQLiteIOErrVnode,
c.SQLITE_IOERR_AUTH => return error.SQLiteIOErrAuth,
c.SQLITE_IOERR_BEGIN_ATOMIC => return error.SQLiteIOErrBeginAtomic,
c.SQLITE_IOERR_COMMIT_ATOMIC => return error.SQLiteIOErrCommitAtomic,
c.SQLITE_IOERR_ROLLBACK_ATOMIC => return error.SQLiteIOErrRollbackAtomic,
c.SQLITE_LOCKED_SHAREDCACHE => return error.SQLiteLockedSharedCache,
c.SQLITE_BUSY_RECOVERY => return error.SQLiteBusyRecovery,
c.SQLITE_BUSY_SNAPSHOT => return error.SQLiteBusySnapshot,
c.SQLITE_CANTOPEN_NOTEMPDIR => return error.SQLiteCantOpenNoTempDir,
c.SQLITE_CANTOPEN_ISDIR => return error.SQLiteCantOpenIsDir,
c.SQLITE_CANTOPEN_FULLPATH => return error.SQLiteCantOpenFullPath,
c.SQLITE_CANTOPEN_CONVPATH => return error.SQLiteCantOpenConvPath,
c.SQLITE_CORRUPT_VTAB => return error.SQLiteCorruptVTab,
c.SQLITE_READONLY_RECOVERY => return error.SQLiteReadOnlyRecovery,
c.SQLITE_READONLY_CANTLOCK => return error.SQLiteReadOnlyCantLock,
c.SQLITE_READONLY_ROLLBACK => return error.SQLiteReadOnlyRollback,
c.SQLITE_READONLY_DBMOVED => return error.SQLiteReadOnlyDBMoved,
c.SQLITE_READONLY_CANTINIT => return error.SQLiteReadOnlyCantInit,
c.SQLITE_READONLY_DIRECTORY => return error.SQLiteReadOnlyDirectory,
c.SQLITE_ABORT_ROLLBACK => return error.SQLiteAbortRollback,
c.SQLITE_CONSTRAINT_CHECK => return error.SQLiteConstraintCheck,
c.SQLITE_CONSTRAINT_COMMITHOOK => return error.SQLiteConstraintCommitHook,
c.SQLITE_CONSTRAINT_FOREIGNKEY => return error.SQLiteConstraintForeignKey,
c.SQLITE_CONSTRAINT_FUNCTION => return error.SQLiteConstraintFunction,
c.SQLITE_CONSTRAINT_NOTNULL => return error.SQLiteConstraintNotNull,
c.SQLITE_CONSTRAINT_PRIMARYKEY => return error.SQLiteConstraintPrimaryKey,
c.SQLITE_CONSTRAINT_TRIGGER => return error.SQLiteConstraintTrigger,
c.SQLITE_CONSTRAINT_UNIQUE => return error.SQLiteConstraintUnique,
c.SQLITE_CONSTRAINT_VTAB => return error.SQLiteConstraintVTab,
c.SQLITE_CONSTRAINT_ROWID => return error.SQLiteConstraintRowID,
else => std.debug.panic("invalid result code {}", .{code}),
}
} | errors.zig |
const std = @import("std");
const views = @import("view.zig");
const xkbcommon = @import("xkb.zig");
const Xkb = @import("xkb.zig").Xkb;
const Move = @import("move.zig").Move;
const Resize = @import("resize.zig").Resize;
const ClientCursor = @import("cursor.zig").ClientCursor;
const backend = @import("backend/backend.zig");
pub var COMPOSITOR: Compositor = makeCompositor();
const Compositor = struct {
pointer_x: f64,
pointer_y: f64,
client_cursor: ?ClientCursor,
move: ?Move,
resize: ?Resize,
xkb: ?Xkb,
mods_depressed: u32,
mods_latched: u32,
mods_locked: u32,
mods_group: u32,
running: bool,
const Self = @This();
pub fn init(self: *Self) !void {
self.xkb = try xkbcommon.init();
backend.BACKEND_FNS.keyboard = keyboardHandler;
backend.BACKEND_FNS.mouseClick = mouseClickHandler;
backend.BACKEND_FNS.mouseMove = mouseMoveHandler;
backend.BACKEND_FNS.mouseAxis = mouseAxisHandler;
}
pub fn keyboard(self: *Self, time: u32, button: u32, action: u32) !void {
if (button == 224) {
self.running = false;
}
if (self.xkb) |*xkb| {
xkb.updateKey(button, action);
self.mods_depressed = xkb.serializeDepressed();
self.mods_latched = xkb.serializeLatched();
self.mods_locked = xkb.serializeLocked();
self.mods_group = xkb.serializeGroup();
}
try views.CURRENT_VIEW.keyboard(time, button, action);
}
pub fn mouseClick(self: *Self, button: u32, action: u32) !void {
if (self.move) |move| {
if (action == 0) {
self.move = null;
}
}
if (self.resize) |resize| {
if (action == 0) {
self.resize = null;
}
}
try views.CURRENT_VIEW.mouseClick(button, action);
}
pub fn mouseMove(self: *Self, dx: f64, dy: f64) !void {
self.pointer_x = self.pointer_x + dx;
self.pointer_y = self.pointer_y + dy;
if (self.pointer_x < 0) {
self.pointer_x = 0;
}
if (self.pointer_x > @intToFloat(f64, views.CURRENT_VIEW.output.?.getWidth())) {
self.pointer_x = @intToFloat(f64, views.CURRENT_VIEW.output.?.getWidth());
}
if (self.pointer_y < 0) {
self.pointer_y = 0;
}
if (self.pointer_y > @intToFloat(f64, views.CURRENT_VIEW.output.?.getHeight())) {
self.pointer_y = @intToFloat(f64, views.CURRENT_VIEW.output.?.getHeight());
}
if (self.move) |move| {
var new_window_x = move.window_x + @floatToInt(i32, self.pointer_x - move.pointer_x);
var new_window_y = move.window_y + @floatToInt(i32, self.pointer_y - move.pointer_y);
move.window.current().x = new_window_x;
move.window.pending().x = new_window_x;
move.window.current().y = new_window_y;
move.window.pending().y = new_window_y;
return;
}
if (self.resize) |resize| {
try resize.resize(self.pointer_x, self.pointer_y);
return;
}
try views.CURRENT_VIEW.updatePointer(self.pointer_x, self.pointer_y);
}
pub fn mouseAxis(self: *Self, time: u32, axis: u32, value: f64) !void {
try views.CURRENT_VIEW.mouseAxis(time, axis, -1.0 * value);
}
};
fn keyboardHandler(time: u32, button: u32, state: u32) !void {
try COMPOSITOR.keyboard(time, button, state);
}
fn mouseClickHandler(time: u32, button: u32, state: u32) !void {
try COMPOSITOR.mouseClick(button, state);
}
fn mouseMoveHandler(time: u32, x: f64, y: f64) !void {
try COMPOSITOR.mouseMove(x, y);
}
fn mouseAxisHandler(time: u32, axis: u32, value: f64) !void {
try COMPOSITOR.mouseAxis(time, axis, value);
}
fn makeCompositor() Compositor {
return Compositor{
.pointer_x = 0.0,
.pointer_y = 0.0,
.client_cursor = null,
.move = null,
.resize = null,
.xkb = null,
.mods_depressed = 0,
.mods_latched = 0,
.mods_locked = 0,
.mods_group = 0,
.running = true,
};
} | src/compositor.zig |
pub const FnlGenerator = extern struct {
seed: i32 = 1337,
frequency: f32 = 0.01,
noise_type: NoiseType = .opensimplex2,
rotation_type3: RotationType3 = .none,
fractal_type: FractalType = .none,
octaves: i32 = 3,
lacunarity: f32 = 2.0,
gain: f32 = 0.5,
weighted_strength: f32 = 0.0,
ping_pong_strength: f32 = 2.0,
cellular_distance_func: CellularDistanceFunc = .euclideansq,
cellular_return_type: CellularReturnType = .distance,
cellular_jitter_mod: f32 = 1.0,
domain_warp_type: DomainWarpType = .opensimplex2,
domain_warp_amp: f32 = 1.0,
pub const NoiseType = enum(c_int) {
opensimplex2,
opensimplex2s,
cellular,
perlin,
value_cubic,
value,
};
pub const RotationType3 = enum(c_int) {
none,
improve_xy_planes,
improve_xz_planes,
};
pub const FractalType = enum(c_int) {
none,
fbm,
ridged,
pingpong,
domain_warp_progressive,
domain_warp_independent,
};
pub const CellularDistanceFunc = enum(c_int) {
euclidean,
euclideansq,
manhattan,
hybrid,
};
pub const CellularReturnType = enum(c_int) {
cellvalue,
distance,
distance2,
distance2add,
distance2sub,
distance2mul,
distance2div,
};
pub const DomainWarpType = enum(c_int) {
opensimplex2,
opensimplex2_reduced,
basicgrid,
};
pub const noise2 = fnlGetNoise2D;
extern fn fnlGetNoise2D(gen: *const FnlGenerator, x: f32, y: f32) f32;
pub const noise3 = fnlGetNoise3D;
extern fn fnlGetNoise3D(gen: *const FnlGenerator, x: f32, y: f32, z: f32) f32;
pub const domainWarp2 = fnlDomainWarp2D;
extern fn fnlDomainWarp2D(gen: *const FnlGenerator, x: *f32, y: *f32) void;
pub const domainWarp3 = fnlDomainWarp3D;
extern fn fnlDomainWarp3D(gen: *const FnlGenerator, x: *f32, y: *f32, z: *f32) void;
};
test "znoise.basic" {
const gen = FnlGenerator{ .fractal_type = .fbm };
const n2 = gen.noise2(0.1, 0.2);
const n3 = gen.noise3(1.0, 2.0, 3.0);
_ = n2;
_ = n3;
} | libs/znoise/src/znoise.zig |
const std = @import("std");
const base64 = std.base64;
const ascii = std.ascii;
const time = std.time;
const rand = std.rand;
const fmt = std.fmt;
const mem = std.mem;
const http = std.http;
const Sha1 = std.crypto.hash.Sha1;
const assert = std.debug.assert;
usingnamespace @import("common.zig");
fn stripCarriageReturn(buffer: []u8) []u8 {
if (buffer[buffer.len - 1] == '\r') {
return buffer[0 .. buffer.len - 1];
} else {
return buffer;
}
}
pub fn create(buffer: []u8, reader: anytype, writer: anytype) Client(@TypeOf(reader), @TypeOf(writer)) {
assert(buffer.len >= 16);
return Client(@TypeOf(reader), @TypeOf(writer)).init(buffer, reader, writer);
}
const websocket_guid = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
const handshake_key_length = 8;
fn checkHandshakeKey(original: []const u8, recieved: []const u8) bool {
var hash = Sha1.init(.{});
hash.update(original);
hash.update(websocket_guid);
var hashed_key: [Sha1.digest_length]u8 = undefined;
hash.final(&hashed_key);
var encoded: [base64.Base64Encoder.calcSize(Sha1.digest_length)]u8 = undefined;
base64.standard_encoder.encode(&encoded, &hashed_key);
return mem.eql(u8, &encoded, recieved);
}
inline fn extractMaskByte(mask: u32, index: usize) u8 {
return @truncate(u8, mask >> @truncate(u5, (index % 4) * 8));
}
pub fn Client(comptime Reader: type, comptime Writer: type) type {
const ReaderError = if (@typeInfo(Reader) == .Pointer) @typeInfo(Reader).Pointer.child.Error else Reader.Error;
const WriterError = if (@typeInfo(Writer) == .Pointer) @typeInfo(Writer).Pointer.child.Error else Writer.Error;
const HzzpClient = hzzp.Client.Client(Reader, Writer);
return struct {
const Self = @This();
read_buffer: []u8,
prng: rand.DefaultPrng,
reader: Reader,
writer: Writer,
handshaken: bool = false,
handshake_client: HzzpClient,
handshake_key: [base64.Base64Encoder.calcSize(handshake_key_length)]u8 = undefined,
current_mask: ?u32 = null,
mask_index: usize = 0,
chunk_need: usize = 0,
chunk_read: usize = 0,
chunk_mask: ?u32 = undefined,
state: ParserState = .header,
pub fn init(buffer: []u8, reader: Reader, writer: Writer) Self {
return Self{
.read_buffer = buffer,
.handshake_client = hzzp.Client.create(buffer, reader, writer),
.prng = rand.DefaultPrng.init(@bitCast(u64, time.milliTimestamp())),
.reader = reader,
.writer = writer,
};
}
pub fn sendHandshakeHead(self: *Self, path: []const u8) WriterError!void {
var raw_key: [handshake_key_length]u8 = undefined;
self.prng.random.bytes(&raw_key);
base64.standard_encoder.encode(&self.handshake_key, &raw_key);
self.handshake_client.reset();
try self.handshake_client.writeHead("GET", path);
try self.handshake_client.writeHeaderValue("Connection", "Upgrade");
try self.handshake_client.writeHeaderValue("Upgrade", "websocket");
try self.handshake_client.writeHeaderValue("Sec-WebSocket-Version", "13");
try self.handshake_client.writeHeaderValue("Sec-WebSocket-Key", &self.handshake_key);
}
pub fn sendHandshakeHeaderValue(self: *Self, name: []const u8, value: []const u8) WriterError!void {
return self.handshake_client.writeHeaderValue(name, value);
}
pub fn sendHandshakeHeader(self: *Self, header: hzzp.Header) WriterError!void {
return self.handshake_client.writeHeader(header);
}
pub fn sendHandshakeHeaderArray(self: *Self, headers: hzzp.Headers) WriterError!void {
return self.handshake_client.writeHeaders(headers);
}
pub fn sendHandshakeStdHeaders(self: *Self, headers: *http.Headers) WriterError!void {
for (headers.toSlice()) |entry| {
try self.handshake_client.writeHeaderValue(entry.name, entry.value);
}
}
pub fn sendHandshakeHeadComplete(self: *Self) WriterError!void {
return self.handshake_client.writeHeadComplete();
}
pub const HandshakeError = ReaderError || HzzpClient.ReadError || error{ WrongResponse, InvalidConnectionHeader, FailedChallenge, ConnectionClosed };
pub fn waitForHandshake(self: *Self) HandshakeError!void {
var got_upgrade_header: bool = false;
var got_accept_header: bool = false;
while (try self.handshake_client.readEvent()) |event| {
switch (event) {
.status => |etc| {
if (etc.code != 101) {
return error.WrongResponse;
}
},
.header => |etc| {
if (ascii.eqlIgnoreCase(etc.name, "connection")) {
got_upgrade_header = true;
if (!ascii.eqlIgnoreCase(etc.value, "upgrade")) {
return error.InvalidConnectionHeader;
}
} else if (ascii.eqlIgnoreCase(etc.name, "sec-websocket-accept")) {
got_accept_header = true;
if (!checkHandshakeKey(&self.handshake_key, etc.value)) {
return error.FailedChallenge;
}
}
},
.end => break,
.invalid => return error.WrongResponse,
.closed => return error.ConnectionClosed,
else => {},
}
}
if (!got_upgrade_header) {
return error.InvalidConnectionHeader;
} else if (!got_accept_header) {
return error.FailedChallenge;
}
}
pub fn writeMessageHeader(self: *Self, header: MessageHeader) WriterError!void {
var bytes: [2]u8 = undefined;
bytes[0] = @as(u8, header.opcode);
bytes[1] = 0;
if (header.fin) bytes[0] |= 0x80;
if (header.rsv1) bytes[0] |= 0x40;
if (header.rsv2) bytes[0] |= 0x20;
if (header.rsv3) bytes[0] |= 0x10;
const mask = header.mask orelse self.prng.random.int(u32);
bytes[1] |= 0x80;
if (header.length < 126) {
bytes[1] |= @truncate(u8, header.length);
try self.writer.writeAll(&bytes);
} else if (header.length < 0x10000) {
bytes[1] |= 126;
try self.writer.writeAll(&bytes);
var len: [2]u8 = undefined;
mem.writeIntBig(u16, &len, @truncate(u16, header.length));
try self.writer.writeAll(&len);
} else {
bytes[1] |= 127;
try self.writer.writeAll(&bytes);
var len: [8]u8 = undefined;
mem.writeIntBig(u64, &len, header.length);
try self.writer.writeAll(&len);
}
var mask_bytes: [4]u8 = undefined;
mem.writeIntLittle(u32, &mask_bytes, mask);
try self.writer.writeAll(&mask_bytes);
self.current_mask = mask;
self.mask_index = 0;
}
pub fn maskPayload(self: *Self, payload: []const u8, buffer: []u8) void {
if (self.current_mask) |mask| {
assert(buffer.len >= payload.len);
for (payload) |c, i| {
buffer[i] = c ^ extractMaskByte(mask, i + self.mask_index);
}
self.mask_index += payload.len;
}
}
pub fn writeUnmaskedPayload(self: *Self, payload: []const u8) WriterError!void {
try self.writer.writeAll(payload);
}
pub fn writeMessagePayload(self: *Self, payload: []const u8) WriterError!void {
const mask = self.current_mask.?;
for (payload) |c, i| {
try self.writer.writeByte(c ^ extractMaskByte(mask, i + self.mask_index));
}
self.mask_index += payload.len;
}
pub fn readEvent(self: *Self) ReaderError!?ClientEvent {
switch (self.state) {
.header => {
const read_head_len = try self.reader.readAll(self.read_buffer[0..2]);
if (read_head_len != 2) return ClientEvent.closed;
const fin = self.read_buffer[0] & 0x80 == 0x80;
const rsv1 = self.read_buffer[0] & 0x40 == 0x40;
const rsv2 = self.read_buffer[0] & 0x20 == 0x20;
const rsv3 = self.read_buffer[0] & 0x10 == 0x10;
const opcode = @truncate(u4, self.read_buffer[0]);
const masked = self.read_buffer[1] & 0x80 == 0x80;
const check_len = @truncate(u7, self.read_buffer[1]);
var len: u64 = check_len;
var mask_index: u4 = 2;
if (check_len == 127) {
const read_len_len = try self.reader.readAll(self.read_buffer[2..10]);
if (read_len_len != 8) return ClientEvent.closed;
mask_index = 10;
len = mem.readIntBig(u64, self.read_buffer[2..10]);
self.chunk_need = len;
self.chunk_read = 0;
} else if (check_len == 126) {
const read_len_len = try self.reader.readAll(self.read_buffer[2..4]);
if (read_len_len != 2) return ClientEvent.closed;
mask_index = 4;
len = mem.readIntBig(u16, self.read_buffer[2..4]);
self.chunk_need = len;
self.chunk_read = 0;
} else {
self.chunk_need = check_len;
self.chunk_read = 0;
}
if (masked) {
const read_mask_len = try self.reader.readAll(self.read_buffer[mask_index .. mask_index + 4]);
if (read_mask_len != 4) return ClientEvent.closed;
self.chunk_mask = mem.readIntSliceBig(u32, self.read_buffer[mask_index .. mask_index + 4]);
} else {
self.chunk_mask = null;
}
self.state = .chunk;
return ClientEvent{
.header = .{
.fin = fin,
.rsv1 = rsv1,
.rsv2 = rsv2,
.rsv3 = rsv3,
.opcode = opcode,
.length = len,
.mask = self.chunk_mask,
},
};
},
.chunk => {
const left = self.chunk_need - self.chunk_read;
if (left <= self.read_buffer.len) {
const read_len = try self.reader.readAll(self.read_buffer[0..left]);
if (read_len != left) return ClientEvent.closed;
if (self.chunk_mask) |mask| {
for (self.read_buffer[0..read_len]) |*c, i| {
c.* = c.* ^ extractMaskByte(mask, i + self.chunk_read);
}
}
self.state = .header;
return ClientEvent{
.chunk = .{
.data = self.read_buffer[0..read_len],
.final = true,
},
};
} else {
const read_len = try self.reader.read(self.read_buffer);
if (read_len == 0) return ClientEvent.closed;
if (self.chunk_mask) |mask| {
for (self.read_buffer[0..read_len]) |*c, i| {
c.* = c.* ^ extractMaskByte(mask, i + self.chunk_read);
}
}
self.chunk_read += read_len;
return ClientEvent{
.chunk = .{
.data = self.read_buffer[0..read_len],
},
};
}
},
}
}
};
}
const testing = std.testing;
const io = std.io;
test "decodes a simple message" {
var read_buffer: [32]u8 = undefined;
var the_void: [1024]u8 = undefined;
var response = [_]u8{
0x82, 0x0d, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x2c, 0x20, 0x57, 0x6f,
0x72, 0x6c, 0x64, 0x21,
};
var reader = io.fixedBufferStream(&response).reader();
var writer = io.fixedBufferStream(&the_void).writer();
var client = create(&read_buffer, reader, writer);
client.handshaken = true;
try client.writeMessageHeader(.{
.opcode = 2,
.length = 9,
});
try client.writeUnmaskedPayload("aaabbbccc");
var header = (try client.readEvent()).?;
testing.expect(header == .header);
testing.expect(header.header.fin == true);
testing.expect(header.header.rsv1 == false);
testing.expect(header.header.rsv2 == false);
testing.expect(header.header.rsv3 == false);
testing.expect(header.header.opcode == 2);
testing.expect(header.header.length == 13);
testing.expect(header.header.mask == null);
var payload = (try client.readEvent()).?;
testing.expect(payload == .chunk);
testing.expect(payload.chunk.final == true);
testing.expect(mem.eql(u8, payload.chunk.data, "Hello, World!"));
}
test "decodes a masked message" {
var read_buffer: [32]u8 = undefined;
var the_void: [1024]u8 = undefined;
var response = [_]u8{
0x82, 0x8d, 0x12, 0x34, 0x56, 0x78, 0x30, 0x33, 0x58, 0x7e, 0x17,
0x7a, 0x14, 0x45, 0x17, 0x24, 0x58, 0x76, 0x59,
};
var reader = io.fixedBufferStream(&response).reader();
var writer = io.fixedBufferStream(&the_void).writer();
var client = create(&read_buffer, reader, writer);
client.handshaken = true;
try client.writeMessageHeader(.{
.opcode = 2,
.length = 9,
});
try client.writeUnmaskedPayload("aaabbbccc");
var header = (try client.readEvent()).?;
testing.expect(header == .header);
testing.expect(header.header.fin == true);
testing.expect(header.header.rsv1 == false);
testing.expect(header.header.rsv2 == false);
testing.expect(header.header.rsv3 == false);
testing.expect(header.header.opcode == 2);
testing.expect(header.header.length == 13);
testing.expect(header.header.mask.? == 0x12345678);
var payload = (try client.readEvent()).?;
testing.expect(payload == .chunk);
testing.expect(payload.chunk.final == true);
testing.expect(mem.eql(u8, payload.chunk.data, "Hello, World!"));
}
test "attempt echo on echo.websocket.org" {
if (std.builtin.os.tag == .windows) return error.SkipZigTest;
var socket = try std.net.tcpConnectToHost(testing.allocator, "echo.websocket.org", 80);
defer socket.close();
var buffer: [4096]u8 = undefined;
var client = create(&buffer, socket.reader(), socket.writer());
try client.sendHandshakeHead("/");
try client.sendHandshakeHeaderValue("Host", "echo.websocket.org");
try client.sendHandshakeHeadComplete();
try client.waitForHandshake();
try client.writeMessageHeader(.{
.opcode = 2,
.length = 4,
});
try client.writeMessagePayload("test");
var header = (try client.readEvent()).?;
testing.expect(header == .header);
testing.expect(header.header.fin == true);
testing.expect(header.header.rsv1 == false);
testing.expect(header.header.rsv2 == false);
testing.expect(header.header.rsv3 == false);
testing.expect(header.header.opcode == 2);
testing.expect(header.header.length == 4);
testing.expect(header.header.mask == null);
var payload = (try client.readEvent()).?;
testing.expect(payload == .chunk);
testing.expect(payload.chunk.final == true);
testing.expect(mem.eql(u8, payload.chunk.data, "test"));
} | src/base/client.zig |
const std = @import("std");
const version = @import("version");
const zzz = @import("zzz");
const uri = @import("uri");
const Lockfile = @import("Lockfile.zig");
const DependencyTree = @import("DependencyTree.zig");
const api = @import("api.zig");
usingnamespace @import("common.zig");
const Self = @This();
const Allocator = std.mem.Allocator;
const mem = std.mem;
const testing = std.testing;
const SourceType = std.meta.Tag(Lockfile.Entry);
alias: []const u8,
src: Source,
const Source = union(SourceType) {
pkg: struct {
user: []const u8,
name: []const u8,
version: version.Range,
repository: []const u8,
ver_str: []const u8,
},
github: struct {
user: []const u8,
repo: []const u8,
ref: []const u8,
root: []const u8,
},
url: struct {
str: []const u8,
root: []const u8,
//integrity: ?Integrity,
},
};
fn findLatestMatch(self: Self, lockfile: *Lockfile) ?*Lockfile.Entry {
var ret: ?*Lockfile.Entry = null;
for (lockfile.entries.items) |entry| {
if (@as(SourceType, self.src) != @as(SourceType, entry.*)) continue;
switch (self.src) {
.pkg => |pkg| {
if (!mem.eql(u8, pkg.name, entry.pkg.name) or
!mem.eql(u8, pkg.user, entry.pkg.user) or
!mem.eql(u8, pkg.repository, entry.pkg.repository)) continue;
const range = pkg.version;
if (range.contains(entry.pkg.version)) {
if (ret != null and entry.pkg.version.cmp(ret.?.pkg.version) != .gt) {
continue;
}
ret = entry;
}
},
.github => |gh| if (mem.eql(u8, gh.user, entry.github.user) and
mem.eql(u8, gh.repo, entry.github.repo) and
mem.eql(u8, gh.ref, entry.github.ref) and
mem.eql(u8, gh.root, entry.github.root)) return entry,
.url => |url| if (mem.eql(u8, url.str, entry.url.str) and
mem.eql(u8, url.root, entry.url.root)) return entry,
}
}
return ret;
}
fn resolveLatest(
self: Self,
arena: *std.heap.ArenaAllocator,
lockfile: *Lockfile,
) !*Lockfile.Entry {
const allocator = &arena.allocator;
const ret = try allocator.create(Lockfile.Entry);
ret.* = switch (self.src) {
.pkg => |pkg| .{
.pkg = .{
.user = pkg.user,
.name = pkg.name,
.repository = pkg.repository,
.version = try api.getLatest(
allocator,
pkg.repository,
pkg.user,
pkg.name,
pkg.version,
),
},
},
.github => |gh| Lockfile.Entry{
.github = .{
.user = gh.user,
.repo = gh.repo,
.ref = gh.ref,
.commit = try api.getHeadCommit(allocator, gh.user, gh.repo, gh.ref),
.root = gh.root,
},
},
.url => |url| Lockfile.Entry{
.url = .{
.str = url.str,
.root = url.root,
},
},
};
return ret;
}
pub fn resolve(
self: Self,
arena: *std.heap.ArenaAllocator,
lockfile: *Lockfile,
) !*Lockfile.Entry {
return self.findLatestMatch(lockfile) orelse blk: {
const entry = try self.resolveLatest(arena, lockfile);
try lockfile.entries.append(entry);
break :blk entry;
};
}
/// There are four ways for a dependency to be declared in the project file:
///
/// A package from some other index:
/// ```
/// name:
/// src:
/// pkg:
/// user: <user>
/// name: <name> # optional
/// version: <version string>
/// repository: <repository> # optional
/// ```
///
/// A github repo:
/// ```
/// name:
/// src:
/// github:
/// user: <user>
/// repo: <repo>
/// ref: <ref>
/// root: <root file>
/// ```
///
/// A raw url:
/// ```
/// name:
/// src:
/// url: <url>
/// root: <root file>
/// integrity:
/// <type>: <integrity str>
/// ```
pub fn fromZNode(node: *zzz.ZNode) !Self {
if (node.*.child == null) return error.NoChildren;
// check if only one child node and that it has no children
if (node.*.child.?.value == .String and node.*.child.?.child == null) {
if (node.*.child.?.sibling != null) return error.Unknown;
const key = try zGetString(node);
const info = try parseUserRepo(key);
const ver_str = try zGetString(node.*.child.?);
return Self{
.alias = info.repo,
.src = .{
.pkg = .{
.user = info.user,
.name = info.repo,
.ver_str = ver_str,
.version = try version.Range.parse(ver_str),
.repository = api.default_repo,
},
},
};
}
// search for src node
const alias = try zGetString(node);
const src_node = blk: {
var it = ZChildIterator.init(node);
while (it.next()) |child| {
switch (child.value) {
.String => |str| if (mem.eql(u8, str, "src")) break :blk child,
else => continue,
}
} else return error.SrcTagNotFound;
};
const src: Source = blk: {
const child = src_node.child orelse return error.SrcNeedsChild;
const src_str = try zGetString(child);
const src_type = inline for (std.meta.fields(SourceType)) |field| {
if (mem.eql(u8, src_str, field.name)) break @field(SourceType, field.name);
} else return error.InvalidSrcTag;
break :blk switch (src_type) {
.pkg => .{
.pkg = .{
.user = (try zFindString(child, "user")) orelse return error.MissingUser,
.name = (try zFindString(child, "name")) orelse alias,
.ver_str = (try zFindString(child, "version")) orelse return error.MissingVersion,
.version = try version.Range.parse((try zFindString(child, "version")) orelse return error.MissingVersion),
.repository = (try zFindString(child, "repository")) orelse api.default_repo,
},
},
.github => .{
.github = .{
.user = (try zFindString(child, "user")) orelse return error.GithubMissingUser,
.repo = (try zFindString(child, "repo")) orelse return error.GithubMissingRepo,
.ref = (try zFindString(child, "ref")) orelse return error.GithubMissingRef,
.root = (try zFindString(node, "root")) orelse "src/main.zig",
},
},
.url => .{
.url = .{
.str = try zGetString(child.child orelse return error.UrlMissingStr),
.root = (try zFindString(node, "root")) orelse "src/main.zig",
},
},
};
};
if (src == .url) {
_ = uri.parse(src.url.str) catch |err| {
switch (err) {
error.InvalidFormat => {
std.log.err(
"Failed to parse '{s}' as a url ({}), did you forget to wrap your url in double quotes?",
.{ src.url.str, err },
);
},
error.UnexpectedCharacter => {
std.log.err(
"Failed to parse '{s}' as a url ({}), did you forget 'file://' for defining a local path?",
.{ src.url.str, err },
);
},
else => return err,
}
return error.Explained;
};
}
// TODO: integrity
return Self{ .alias = alias, .src = src };
}
/// for testing
fn fromString(str: []const u8) !Self {
var tree = zzz.ZTree(1, 1000){};
const root = try tree.appendText(str);
return Self.fromZNode(root.*.child.?);
}
fn expectDepEqual(expected: Self, actual: Self) void {
testing.expectEqualStrings(expected.alias, actual.alias);
testing.expectEqual(@as(SourceType, expected.src), @as(SourceType, actual.src));
return switch (expected.src) {
.pkg => |pkg| {
testing.expectEqualStrings(pkg.user, actual.src.pkg.user);
testing.expectEqualStrings(pkg.name, actual.src.pkg.name);
testing.expectEqualStrings(pkg.repository, actual.src.pkg.repository);
testing.expectEqualStrings(pkg.ver_str, actual.src.pkg.ver_str);
testing.expectEqual(pkg.version, actual.src.pkg.version);
},
.github => |gh| {
testing.expectEqualStrings(gh.user, actual.src.github.user);
testing.expectEqualStrings(gh.repo, actual.src.github.repo);
testing.expectEqualStrings(gh.ref, actual.src.github.ref);
testing.expectEqualStrings(gh.root, actual.src.github.root);
},
.url => |url| {
testing.expectEqualStrings(url.str, actual.src.url.str);
testing.expectEqualStrings(url.root, actual.src.url.root);
},
};
}
test "default repo pkg" {
expectDepEqual(Self{
.alias = "something",
.src = .{
.pkg = .{
.user = "matt",
.name = "something",
.ver_str = "^0.1.0",
.version = try version.Range.parse("^0.1.0"),
.repository = api.default_repo,
},
},
}, try fromString("matt/something: ^0.1.0"));
}
test "aliased, default repo pkg" {
const actual = try fromString(
\\something:
\\ src:
\\ pkg:
\\ user: matt
\\ name: blarg
\\ version: ^0.1.0
);
const expected = Self{
.alias = "something",
.src = .{
.pkg = .{
.user = "matt",
.name = "blarg",
.ver_str = "^0.1.0",
.version = try version.Range.parse("^0.1.0"),
.repository = api.default_repo,
},
},
};
expectDepEqual(expected, actual);
}
test "error if pkg has any other keys" {
// TODO
//testing.expectError(error.SuperfluousNode, fromString(
// \\something:
// \\ src:
// \\ pkg:
// \\ name: blarg
// \\ version: ^0.1.0
// \\ foo: something
//));
}
test "non-default repo pkg" {
const actual = try fromString(
\\something:
\\ src:
\\ pkg:
\\ user: matt
\\ version: ^0.1.0
\\ repository: example.com
);
const expected = Self{
.alias = "something",
.src = .{
.pkg = .{
.user = "matt",
.name = "something",
.ver_str = "^0.1.0",
.version = try version.Range.parse("^0.1.0"),
.repository = "example.com",
},
},
};
expectDepEqual(expected, actual);
}
test "aliased, non-default repo pkg" {
const actual = try fromString(
\\something:
\\ src:
\\ pkg:
\\ user: matt
\\ name: real_name
\\ version: ^0.1.0
\\ repository: example.com
);
const expected = Self{
.alias = "something",
.src = .{
.pkg = .{
.user = "matt",
.name = "real_name",
.ver_str = "^0.1.0",
.version = try version.Range.parse("^0.1.0"),
.repository = "example.com",
},
},
};
expectDepEqual(expected, actual);
}
test "github default root" {
const actual = try fromString(
\\foo:
\\ src:
\\ github:
\\ user: test
\\ repo: something
\\ ref: main
);
const expected = Self{
.alias = "foo",
.src = .{
.github = .{
.user = "test",
.repo = "something",
.ref = "main",
.root = "src/main.zig",
},
},
};
expectDepEqual(expected, actual);
}
test "github explicit root" {
const actual = try fromString(
\\foo:
\\ src:
\\ github:
\\ user: test
\\ repo: something
\\ ref: main
\\ root: main.zig
);
const expected = Self{
.alias = "foo",
.src = .{
.github = .{
.user = "test",
.repo = "something",
.ref = "main",
.root = "main.zig",
},
},
};
expectDepEqual(expected, actual);
}
test "raw default root" {
const actual = try fromString(
\\foo:
\\ src:
\\ url: "https://astrolabe.pm"
);
const expected = Self{
.alias = "foo",
.src = .{
.url = .{
.str = "https://astrolabe.pm",
.root = "src/main.zig",
},
},
};
expectDepEqual(expected, actual);
}
test "raw explicit root" {
const actual = try fromString(
\\foo:
\\ src:
\\ url: "https://astrolabe.pm"
\\ root: main.zig
);
const expected = Self{
.alias = "foo",
.src = .{
.url = .{
.str = "https://astrolabe.pm",
.root = "main.zig",
},
},
};
expectDepEqual(expected, actual);
}
test "pkg can't take a root" {
// TODO
}
test "pkg can't take an integrity" {
// TODO
}
test "github can't take an integrity " {
// TODO
}
/// serializes dependency information back into zzz format
pub fn addToZNode(
self: Self,
arena: *std.heap.ArenaAllocator,
tree: *zzz.ZTree(1, 1000),
parent: *zzz.ZNode,
explicit: bool,
) !void {
var alias = try tree.addNode(parent, .{ .String = self.alias });
switch (self.src) {
.pkg => |pkg| if (!explicit and
std.mem.eql(u8, self.alias, pkg.name) and
std.mem.eql(u8, pkg.repository, api.default_repo))
{
var fifo = std.fifo.LinearFifo(u8, .{ .Dynamic = {} }).init(&arena.allocator);
try fifo.writer().print("{s}/{s}", .{ pkg.user, pkg.name });
alias.value.String = fifo.readableSlice(0);
_ = try tree.addNode(alias, .{ .String = pkg.ver_str });
} else {
var src = try tree.addNode(alias, .{ .String = "src" });
var node = try tree.addNode(src, .{ .String = "pkg" });
try zPutKeyString(tree, node, "user", pkg.user);
if (explicit or !std.mem.eql(u8, pkg.name, self.alias)) {
try zPutKeyString(tree, node, "name", pkg.name);
}
try zPutKeyString(tree, node, "version", pkg.ver_str);
if (explicit or !std.mem.eql(u8, pkg.repository, api.default_repo)) {
try zPutKeyString(tree, node, "repository", pkg.repository);
}
},
.github => |gh| {
var src = try tree.addNode(alias, .{ .String = "src" });
var github = try tree.addNode(src, .{ .String = "github" });
try zPutKeyString(tree, github, "user", gh.user);
try zPutKeyString(tree, github, "repo", gh.repo);
try zPutKeyString(tree, github, "ref", gh.ref);
if (explicit or !std.mem.eql(u8, gh.root, "src/main.zig")) {
try zPutKeyString(tree, alias, "root", gh.root);
}
},
.url => |url| {
var src = try tree.addNode(alias, .{ .String = "src" });
try zPutKeyString(tree, src, "url", url.str);
if (explicit or !std.mem.eql(u8, url.root, "src/main.zig")) {
try zPutKeyString(tree, alias, "root", url.root);
}
},
}
}
fn expectZzzEqual(expected: *zzz.ZNode, actual: *zzz.ZNode) void {
var expected_it: *zzz.ZNode = expected;
var actual_it: *zzz.ZNode = actual;
var expected_depth: isize = 0;
var actual_depth: isize = 0;
while (expected_it.next(&expected_depth)) |exp| : (expected_it = exp) {
if (actual_it.next(&actual_depth)) |act| {
defer actual_it = act;
testing.expectEqual(expected_depth, actual_depth);
switch (exp.value) {
.String => |str| testing.expectEqualStrings(str, act.value.String),
.Int => |int| testing.expectEqual(int, act.value.Int),
.Float => |float| testing.expectEqual(float, act.value.Float),
.Bool => |b| testing.expectEqual(b, act.value.Bool),
else => {},
}
} else {
testing.expect(false);
}
}
testing.expectEqual(
expected_it.next(&expected_depth),
actual_it.next(&actual_depth),
);
}
fn serializeTest(from: []const u8, to: []const u8, explicit: bool) !void {
var arena = std.heap.ArenaAllocator.init(testing.allocator);
defer arena.deinit();
const dep = try fromString(from);
var actual = zzz.ZTree(1, 1000){};
var actual_root = try actual.addNode(null, .{ .Null = {} });
try dep.addToZNode(&arena, &actual, actual_root, explicit);
var expected = zzz.ZTree(1, 1000){};
const expected_root = try expected.appendText(to);
expectZzzEqual(expected_root, actual_root);
}
test "serialize pkg non-explicit" {
const str =
\\something:
\\ src:
\\ pkg:
\\ user: test
\\ version: ^0.0.0
\\
;
const expected = "test/something: ^0.0.0";
try serializeTest(str, expected, false);
}
test "serialize pkg explicit" {
const str =
\\something:
\\ src:
\\ pkg:
\\ user: test
\\ version: ^0.0.0
\\
;
const expected =
\\something:
\\ src:
\\ pkg:
\\ user: test
\\ name: something
\\ version: ^0.0.0
\\ repository: astrolabe.pm
\\
;
try serializeTest(str, expected, true);
}
test "serialize github non-explicit" {
const str =
\\something:
\\ src:
\\ github:
\\ user: test
\\ repo: my_repo
\\ ref: master
\\ root: main.zig
\\
;
try serializeTest(str, str, false);
}
test "serialize github non-explicit, default root" {
const str =
\\something:
\\ src:
\\ github:
\\ user: test
\\ repo: my_repo
\\ ref: master
\\
;
try serializeTest(str, str, false);
}
test "serialize github explicit, default root" {
const str =
\\something:
\\ src:
\\ github:
\\ user: test
\\ repo: my_repo
\\ ref: master
\\ root: src/main.zig
\\
;
try serializeTest(str, str, true);
}
test "serialize github explicit" {
const from =
\\something:
\\ src:
\\ github:
\\ user: test
\\ repo: my_repo
\\ ref: master
\\
;
const to =
\\something:
\\ src:
\\ github:
\\ user: test
\\ repo: my_repo
\\ ref: master
\\ root: src/main.zig
\\
;
try serializeTest(from, to, true);
}
test "serialize url non-explicit" {
const str =
\\something:
\\ src:
\\ url: "https://github.com"
\\ root: main.zig
\\
;
try serializeTest(str, str, false);
}
test "serialize url explicit" {
const from =
\\something:
\\ src:
\\ url: "https://github.com"
\\
;
const to =
\\something:
\\ src:
\\ url: "https://github.com"
\\ root: src/main.zig
\\
;
try serializeTest(from, to, true);
} | src/Dependency.zig |
const std = @import("std.zig");
const mem = std.mem;
const builtin = std.builtin;
/// TODO Nearly all the functions in this namespace would be
/// better off if https://github.com/ziglang/zig/issues/425
/// was solved.
pub const Target = union(enum) {
Native: void,
Cross: Cross,
pub const Os = enum {
freestanding,
ananas,
cloudabi,
dragonfly,
freebsd,
fuchsia,
ios,
kfreebsd,
linux,
lv2,
macosx,
netbsd,
openbsd,
solaris,
windows,
haiku,
minix,
rtems,
nacl,
cnk,
aix,
cuda,
nvcl,
amdhsa,
ps4,
elfiamcu,
tvos,
watchos,
mesa3d,
contiki,
amdpal,
hermit,
hurd,
wasi,
emscripten,
uefi,
other,
};
pub const aarch64 = @import("target/aarch64.zig");
pub const amdgpu = @import("target/amdgpu.zig");
pub const arm = @import("target/arm.zig");
pub const avr = @import("target/avr.zig");
pub const bpf = @import("target/bpf.zig");
pub const hexagon = @import("target/hexagon.zig");
pub const mips = @import("target/mips.zig");
pub const msp430 = @import("target/msp430.zig");
pub const nvptx = @import("target/nvptx.zig");
pub const powerpc = @import("target/powerpc.zig");
pub const riscv = @import("target/riscv.zig");
pub const sparc = @import("target/sparc.zig");
pub const systemz = @import("target/systemz.zig");
pub const wasm = @import("target/wasm.zig");
pub const x86 = @import("target/x86.zig");
pub const Arch = union(enum) {
arm: Arm32,
armeb: Arm32,
aarch64: Arm64,
aarch64_be: Arm64,
aarch64_32: Arm64,
arc,
avr,
bpfel,
bpfeb,
hexagon,
mips,
mipsel,
mips64,
mips64el,
msp430,
powerpc,
powerpc64,
powerpc64le,
r600,
amdgcn,
riscv32,
riscv64,
sparc,
sparcv9,
sparcel,
s390x,
tce,
tcele,
thumb: Arm32,
thumbeb: Arm32,
i386,
x86_64,
xcore,
nvptx,
nvptx64,
le32,
le64,
amdil,
amdil64,
hsail,
hsail64,
spir,
spir64,
kalimba: Kalimba,
shave,
lanai,
wasm32,
wasm64,
renderscript32,
renderscript64,
pub const Arm32 = enum {
v8_5a,
v8_4a,
v8_3a,
v8_2a,
v8_1a,
v8a,
v8r,
v8m_baseline,
v8m_mainline,
v8_1m_mainline,
v7a,
v7em,
v7m,
v7s,
v7k,
v7ve,
v6,
v6m,
v6k,
v6t2,
v5,
v5te,
v4t,
pub fn version(version: Arm32) comptime_int {
return switch (version) {
.v8_5a, .v8_4a, .v8_3a, .v8_2a, .v8_1a, .v8a, .v8r, .v8m_baseline, .v8m_mainline, .v8_1m_mainline => 8,
.v7a, .v7em, .v7m, .v7s, .v7k, .v7ve => 7,
.v6, .v6m, .v6k, .v6t2 => 6,
.v5, .v5te => 5,
.v4t => 4,
};
}
};
pub const Arm64 = enum {
v8_5a,
v8_4a,
v8_3a,
v8_2a,
v8_1a,
v8a,
};
pub const Kalimba = enum {
v5,
v4,
v3,
};
pub const Mips = enum {
r6,
};
pub fn subArchName(arch: Arch) ?[]const u8 {
return switch (arch) {
.arm, .armeb, .thumb, .thumbeb => |arm32| @tagName(arm32),
.aarch64, .aarch64_be, .aarch64_32 => |arm64| @tagName(arm64),
.kalimba => |kalimba| @tagName(kalimba),
else => return null,
};
}
pub fn subArchFeature(arch: Arch) ?Cpu.Feature.Set.Index {
return switch (arch) {
.arm, .armeb, .thumb, .thumbeb => |arm32| switch (arm32) {
.v8_5a => @enumToInt(arm.Feature.armv8_5_a),
.v8_4a => @enumToInt(arm.Feature.armv8_4_a),
.v8_3a => @enumToInt(arm.Feature.armv8_3_a),
.v8_2a => @enumToInt(arm.Feature.armv8_2_a),
.v8_1a => @enumToInt(arm.Feature.armv8_1_a),
.v8a => @enumToInt(arm.Feature.armv8_a),
.v8r => @enumToInt(arm.Feature.armv8_r),
.v8m_baseline => @enumToInt(arm.Feature.armv8_m_base),
.v8m_mainline => @enumToInt(arm.Feature.armv8_m_main),
.v8_1m_mainline => @enumToInt(arm.Feature.armv8_1_m_main),
.v7a => @enumToInt(arm.Feature.armv7_a),
.v7em => @enumToInt(arm.Feature.armv7e_m),
.v7m => @enumToInt(arm.Feature.armv7_m),
.v7s => @enumToInt(arm.Feature.armv7s),
.v7k => @enumToInt(arm.Feature.armv7k),
.v7ve => @enumToInt(arm.Feature.armv7ve),
.v6 => @enumToInt(arm.Feature.armv6),
.v6m => @enumToInt(arm.Feature.armv6_m),
.v6k => @enumToInt(arm.Feature.armv6k),
.v6t2 => @enumToInt(arm.Feature.armv6t2),
.v5 => @enumToInt(arm.Feature.armv5t),
.v5te => @enumToInt(arm.Feature.armv5te),
.v4t => @enumToInt(arm.Feature.armv4t),
},
.aarch64, .aarch64_be, .aarch64_32 => |arm64| switch (arm64) {
.v8_5a => @enumToInt(aarch64.Feature.v8_5a),
.v8_4a => @enumToInt(aarch64.Feature.v8_4a),
.v8_3a => @enumToInt(aarch64.Feature.v8_3a),
.v8_2a => @enumToInt(aarch64.Feature.v8_2a),
.v8_1a => @enumToInt(aarch64.Feature.v8_1a),
.v8a => @enumToInt(aarch64.Feature.v8a),
},
else => return null,
};
}
pub fn isARM(arch: Arch) bool {
return switch (arch) {
.arm, .armeb => true,
else => false,
};
}
pub fn isThumb(arch: Arch) bool {
return switch (arch) {
.thumb, .thumbeb => true,
else => false,
};
}
pub fn isWasm(arch: Arch) bool {
return switch (arch) {
.wasm32, .wasm64 => true,
else => false,
};
}
pub fn isMIPS(arch: Arch) bool {
return switch (arch) {
.mips, .mipsel, .mips64, .mips64el => true,
else => false,
};
}
pub fn parseCpu(arch: Arch, cpu_name: []const u8) !*const Cpu {
for (arch.allCpus()) |cpu| {
if (mem.eql(u8, cpu_name, cpu.name)) {
return cpu;
}
}
return error.UnknownCpu;
}
/// Comma-separated list of features, with + or - in front of each feature. This
/// form represents a deviation from baseline CPU, which is provided as a parameter.
/// Extra commas are ignored.
pub fn parseCpuFeatureSet(arch: Arch, cpu: *const Cpu, features_text: []const u8) !Cpu.Feature.Set {
const all_features = arch.allFeaturesList();
var set = cpu.features;
var it = mem.tokenize(features_text, ",");
while (it.next()) |item_text| {
var feature_name: []const u8 = undefined;
var op: enum {
add,
sub,
} = undefined;
if (mem.startsWith(u8, item_text, "+")) {
op = .add;
feature_name = item_text[1..];
} else if (mem.startsWith(u8, item_text, "-")) {
op = .sub;
feature_name = item_text[1..];
} else {
return error.InvalidCpuFeatures;
}
for (all_features) |feature, index_usize| {
const index = @intCast(Cpu.Feature.Set.Index, index_usize);
if (mem.eql(u8, feature_name, feature.name)) {
switch (op) {
.add => set.addFeature(index),
.sub => set.removeFeature(index),
}
break;
}
} else {
return error.UnknownCpuFeature;
}
}
return set;
}
pub fn toElfMachine(arch: Arch) std.elf.EM {
return switch (arch) {
.avr => ._AVR,
.msp430 => ._MSP430,
.arc => ._ARC,
.arm => ._ARM,
.armeb => ._ARM,
.hexagon => ._HEXAGON,
.le32 => ._NONE,
.mips => ._MIPS,
.mipsel => ._MIPS_RS3_LE,
.powerpc => ._PPC,
.r600 => ._NONE,
.riscv32 => ._RISCV,
.sparc => ._SPARC,
.sparcel => ._SPARC,
.tce => ._NONE,
.tcele => ._NONE,
.thumb => ._ARM,
.thumbeb => ._ARM,
.i386 => ._386,
.xcore => ._XCORE,
.nvptx => ._NONE,
.amdil => ._NONE,
.hsail => ._NONE,
.spir => ._NONE,
.kalimba => ._CSR_KALIMBA,
.shave => ._NONE,
.lanai => ._LANAI,
.wasm32 => ._NONE,
.renderscript32 => ._NONE,
.aarch64_32 => ._AARCH64,
.aarch64 => ._AARCH64,
.aarch64_be => ._AARCH64,
.mips64 => ._MIPS,
.mips64el => ._MIPS_RS3_LE,
.powerpc64 => ._PPC64,
.powerpc64le => ._PPC64,
.riscv64 => ._RISCV,
.x86_64 => ._X86_64,
.nvptx64 => ._NONE,
.le64 => ._NONE,
.amdil64 => ._NONE,
.hsail64 => ._NONE,
.spir64 => ._NONE,
.wasm64 => ._NONE,
.renderscript64 => ._NONE,
.amdgcn => ._NONE,
.bpfel => ._BPF,
.bpfeb => ._BPF,
.sparcv9 => ._SPARCV9,
.s390x => ._S390,
};
}
pub fn endian(arch: Arch) builtin.Endian {
return switch (arch) {
.avr,
.arm,
.aarch64_32,
.aarch64,
.amdgcn,
.amdil,
.amdil64,
.bpfel,
.hexagon,
.hsail,
.hsail64,
.kalimba,
.le32,
.le64,
.mipsel,
.mips64el,
.msp430,
.nvptx,
.nvptx64,
.sparcel,
.tcele,
.powerpc64le,
.r600,
.riscv32,
.riscv64,
.i386,
.x86_64,
.wasm32,
.wasm64,
.xcore,
.thumb,
.spir,
.spir64,
.renderscript32,
.renderscript64,
.shave,
=> .Little,
.arc,
.armeb,
.aarch64_be,
.bpfeb,
.mips,
.mips64,
.powerpc,
.powerpc64,
.thumbeb,
.sparc,
.sparcv9,
.tce,
.lanai,
.s390x,
=> .Big,
};
}
/// Returns a name that matches the lib/std/target/* directory name.
pub fn genericName(arch: Arch) []const u8 {
return switch (arch) {
.arm, .armeb, .thumb, .thumbeb => "arm",
.aarch64, .aarch64_be, .aarch64_32 => "aarch64",
.avr => "avr",
.bpfel, .bpfeb => "bpf",
.hexagon => "hexagon",
.mips, .mipsel, .mips64, .mips64el => "mips",
.msp430 => "msp430",
.powerpc, .powerpc64, .powerpc64le => "powerpc",
.amdgcn => "amdgpu",
.riscv32, .riscv64 => "riscv",
.sparc, .sparcv9, .sparcel => "sparc",
.s390x => "systemz",
.i386, .x86_64 => "x86",
.nvptx, .nvptx64 => "nvptx",
.wasm32, .wasm64 => "wasm",
else => @tagName(arch),
};
}
/// All CPU features Zig is aware of, sorted lexicographically by name.
pub fn allFeaturesList(arch: Arch) []const Cpu.Feature {
return switch (arch) {
.arm, .armeb, .thumb, .thumbeb => &arm.all_features,
.aarch64, .aarch64_be, .aarch64_32 => &aarch64.all_features,
.avr => &avr.all_features,
.bpfel, .bpfeb => &bpf.all_features,
.hexagon => &hexagon.all_features,
.mips, .mipsel, .mips64, .mips64el => &mips.all_features,
.msp430 => &msp430.all_features,
.powerpc, .powerpc64, .powerpc64le => &powerpc.all_features,
.amdgcn => &amdgpu.all_features,
.riscv32, .riscv64 => &riscv.all_features,
.sparc, .sparcv9, .sparcel => &sparc.all_features,
.s390x => &systemz.all_features,
.i386, .x86_64 => &x86.all_features,
.nvptx, .nvptx64 => &nvptx.all_features,
.wasm32, .wasm64 => &wasm.all_features,
else => &[0]Cpu.Feature{},
};
}
/// The "default" set of CPU features for cross-compiling. A conservative set
/// of features that is expected to be supported on most available hardware.
pub fn getBaselineCpuFeatures(arch: Arch) CpuFeatures {
const S = struct {
const generic_cpu = Cpu{
.name = "generic",
.llvm_name = null,
.features = Cpu.Feature.Set.empty,
};
};
const cpu = switch (arch) {
.arm, .armeb, .thumb, .thumbeb => &arm.cpu.generic,
.aarch64, .aarch64_be, .aarch64_32 => &aarch64.cpu.generic,
.avr => &avr.cpu.avr1,
.bpfel, .bpfeb => &bpf.cpu.generic,
.hexagon => &hexagon.cpu.generic,
.mips, .mipsel => &mips.cpu.mips32,
.mips64, .mips64el => &mips.cpu.mips64,
.msp430 => &msp430.cpu.generic,
.powerpc, .powerpc64, .powerpc64le => &powerpc.cpu.generic,
.amdgcn => &amdgpu.cpu.generic,
.riscv32 => &riscv.cpu.baseline_rv32,
.riscv64 => &riscv.cpu.baseline_rv64,
.sparc, .sparcv9, .sparcel => &sparc.cpu.generic,
.s390x => &systemz.cpu.generic,
.i386 => &x86.cpu.pentium4,
.x86_64 => &x86.cpu.x86_64,
.nvptx, .nvptx64 => &nvptx.cpu.sm_20,
.wasm32, .wasm64 => &wasm.cpu.generic,
else => &S.generic_cpu,
};
return CpuFeatures.initFromCpu(arch, cpu);
}
/// All CPUs Zig is aware of, sorted lexicographically by name.
pub fn allCpus(arch: Arch) []const *const Cpu {
return switch (arch) {
.arm, .armeb, .thumb, .thumbeb => arm.all_cpus,
.aarch64, .aarch64_be, .aarch64_32 => aarch64.all_cpus,
.avr => avr.all_cpus,
.bpfel, .bpfeb => bpf.all_cpus,
.hexagon => hexagon.all_cpus,
.mips, .mipsel, .mips64, .mips64el => mips.all_cpus,
.msp430 => msp430.all_cpus,
.powerpc, .powerpc64, .powerpc64le => powerpc.all_cpus,
.amdgcn => amdgpu.all_cpus,
.riscv32, .riscv64 => riscv.all_cpus,
.sparc, .sparcv9, .sparcel => sparc.all_cpus,
.s390x => systemz.all_cpus,
.i386, .x86_64 => x86.all_cpus,
.nvptx, .nvptx64 => nvptx.all_cpus,
.wasm32, .wasm64 => wasm.all_cpus,
else => &[0]*const Cpu{},
};
}
};
pub const Abi = enum {
none,
gnu,
gnuabin32,
gnuabi64,
gnueabi,
gnueabihf,
gnux32,
code16,
eabi,
eabihf,
elfv1,
elfv2,
android,
musl,
musleabi,
musleabihf,
msvc,
itanium,
cygnus,
coreclr,
simulator,
macabi,
};
pub const Cpu = struct {
name: []const u8,
llvm_name: ?[:0]const u8,
features: Feature.Set,
pub const Feature = struct {
/// The bit index into `Set`. Has a default value of `undefined` because the canonical
/// structures are populated via comptime logic.
index: Set.Index = undefined,
/// Has a default value of `undefined` because the canonical
/// structures are populated via comptime logic.
name: []const u8 = undefined,
/// If this corresponds to an LLVM-recognized feature, this will be populated;
/// otherwise null.
llvm_name: ?[:0]const u8,
/// Human-friendly UTF-8 text.
description: []const u8,
/// Sparse `Set` of features this depends on.
dependencies: Set,
/// A bit set of all the features.
pub const Set = struct {
ints: [usize_count]usize,
pub const needed_bit_count = 174;
pub const byte_count = (needed_bit_count + 7) / 8;
pub const usize_count = (byte_count + (@sizeOf(usize) - 1)) / @sizeOf(usize);
pub const Index = std.math.Log2Int(@IntType(false, usize_count * @bitSizeOf(usize)));
pub const ShiftInt = std.math.Log2Int(usize);
pub const empty = Set{ .ints = [1]usize{0} ** usize_count };
pub fn empty_workaround() Set {
return Set{ .ints = [1]usize{0} ** usize_count };
}
pub fn isEnabled(set: Set, arch_feature_index: Index) bool {
const usize_index = arch_feature_index / @bitSizeOf(usize);
const bit_index = @intCast(ShiftInt, arch_feature_index % @bitSizeOf(usize));
return (set.ints[usize_index] & (@as(usize, 1) << bit_index)) != 0;
}
/// Adds the specified feature but not its dependencies.
pub fn addFeature(set: *Set, arch_feature_index: Index) void {
const usize_index = arch_feature_index / @bitSizeOf(usize);
const bit_index = @intCast(ShiftInt, arch_feature_index % @bitSizeOf(usize));
set.ints[usize_index] |= @as(usize, 1) << bit_index;
}
/// Removes the specified feature but not its dependents.
pub fn removeFeature(set: *Set, arch_feature_index: Index) void {
const usize_index = arch_feature_index / @bitSizeOf(usize);
const bit_index = @intCast(ShiftInt, arch_feature_index % @bitSizeOf(usize));
set.ints[usize_index] &= ~(@as(usize, 1) << bit_index);
}
pub fn populateDependencies(set: *Set, all_features_list: []const Cpu.Feature) void {
var old = set.ints;
while (true) {
for (all_features_list) |feature, index_usize| {
const index = @intCast(Index, index_usize);
if (set.isEnabled(index)) {
set.ints = @as(@Vector(usize_count, usize), set.ints) |
@as(@Vector(usize_count, usize), feature.dependencies.ints);
}
}
const nothing_changed = mem.eql(usize, &old, &set.ints);
if (nothing_changed) return;
old = set.ints;
}
}
pub fn asBytes(set: *const Set) *const [byte_count]u8 {
return @ptrCast(*const [byte_count]u8, &set.ints);
}
pub fn eql(set: Set, other: Set) bool {
return mem.eql(usize, &set.ints, &other.ints);
}
};
pub fn feature_set_fns(comptime F: type) type {
return struct {
/// Populates only the feature bits specified.
pub fn featureSet(features: []const F) Set {
var x = Set.empty_workaround(); // TODO remove empty_workaround
for (features) |feature| {
x.addFeature(@enumToInt(feature));
}
return x;
}
pub fn featureSetHas(set: Set, feature: F) bool {
return set.isEnabled(@enumToInt(feature));
}
};
}
};
};
pub const ObjectFormat = enum {
unknown,
coff,
elf,
macho,
wasm,
};
pub const SubSystem = enum {
Console,
Windows,
Posix,
Native,
EfiApplication,
EfiBootServiceDriver,
EfiRom,
EfiRuntimeDriver,
};
pub const Cross = struct {
arch: Arch,
os: Os,
abi: Abi,
cpu_features: CpuFeatures,
};
pub const CpuFeatures = struct {
/// The CPU to target. It has a set of features
/// which are overridden with the `features` field.
cpu: *const Cpu,
/// Explicitly provide the entire CPU feature set.
features: Cpu.Feature.Set,
pub fn initFromCpu(arch: Arch, cpu: *const Cpu) CpuFeatures {
var features = cpu.features;
if (arch.subArchFeature()) |sub_arch_index| {
features.addFeature(sub_arch_index);
}
features.populateDependencies(arch.allFeaturesList());
return CpuFeatures{
.cpu = cpu,
.features = features,
};
}
};
pub const current = Target{
.Cross = Cross{
.arch = builtin.arch,
.os = builtin.os,
.abi = builtin.abi,
.cpu_features = builtin.cpu_features,
},
};
pub const stack_align = 16;
pub fn getCpuFeatures(self: Target) CpuFeatures {
return switch (self) {
.Native => builtin.cpu_features,
.Cross => |cross| cross.cpu_features,
};
}
pub fn zigTriple(self: Target, allocator: *mem.Allocator) ![]u8 {
return std.fmt.allocPrint(allocator, "{}{}-{}-{}", .{
@tagName(self.getArch()),
Target.archSubArchName(self.getArch()),
@tagName(self.getOs()),
@tagName(self.getAbi()),
});
}
/// Returned slice must be freed by the caller.
pub fn vcpkgTriplet(allocator: *mem.Allocator, target: Target, linkage: std.build.VcpkgLinkage) ![]const u8 {
const arch = switch (target.getArch()) {
.i386 => "x86",
.x86_64 => "x64",
.arm,
.armeb,
.thumb,
.thumbeb,
.aarch64_32,
=> "arm",
.aarch64,
.aarch64_be,
=> "arm64",
else => return error.VcpkgNoSuchArchitecture,
};
const os = switch (target.getOs()) {
.windows => "windows",
.linux => "linux",
.macosx => "macos",
else => return error.VcpkgNoSuchOs,
};
if (linkage == .Static) {
return try mem.join(allocator, "-", &[_][]const u8{ arch, os, "static" });
} else {
return try mem.join(allocator, "-", &[_][]const u8{ arch, os });
}
}
pub fn allocDescription(self: Target, allocator: *mem.Allocator) ![]u8 {
// TODO is there anything else worthy of the description that is not
// already captured in the triple?
return self.zigTriple(allocator);
}
pub fn zigTripleNoSubArch(self: Target, allocator: *mem.Allocator) ![]u8 {
return std.fmt.allocPrint(allocator, "{}-{}-{}", .{
@tagName(self.getArch()),
@tagName(self.getOs()),
@tagName(self.getAbi()),
});
}
pub fn linuxTriple(self: Target, allocator: *mem.Allocator) ![]u8 {
return std.fmt.allocPrint(allocator, "{}-{}-{}", .{
@tagName(self.getArch()),
@tagName(self.getOs()),
@tagName(self.getAbi()),
});
}
/// TODO: Support CPU features here?
/// https://github.com/ziglang/zig/issues/4261
pub fn parse(text: []const u8) !Target {
var it = mem.separate(text, "-");
const arch_name = it.next() orelse return error.MissingArchitecture;
const os_name = it.next() orelse return error.MissingOperatingSystem;
const abi_name = it.next();
const arch = try parseArchSub(arch_name);
var cross = Cross{
.arch = arch,
.cpu_features = arch.getBaselineCpuFeatures(),
.os = try parseOs(os_name),
.abi = undefined,
};
cross.abi = if (abi_name) |n| try parseAbi(n) else defaultAbi(cross.arch, cross.os);
return Target{ .Cross = cross };
}
pub fn defaultAbi(arch: Arch, target_os: Os) Abi {
switch (arch) {
.wasm32, .wasm64 => return .musl,
else => {},
}
switch (target_os) {
.freestanding,
.ananas,
.cloudabi,
.dragonfly,
.lv2,
.solaris,
.haiku,
.minix,
.rtems,
.nacl,
.cnk,
.aix,
.cuda,
.nvcl,
.amdhsa,
.ps4,
.elfiamcu,
.mesa3d,
.contiki,
.amdpal,
.hermit,
.other,
=> return .eabi,
.openbsd,
.macosx,
.freebsd,
.ios,
.tvos,
.watchos,
.fuchsia,
.kfreebsd,
.netbsd,
.hurd,
=> return .gnu,
.windows,
.uefi,
=> return .msvc,
.linux,
.wasi,
.emscripten,
=> return .musl,
}
}
pub const ParseArchSubError = error{
UnknownArchitecture,
UnknownSubArchitecture,
};
pub fn parseArchSub(text: []const u8) ParseArchSubError!Arch {
const info = @typeInfo(Arch);
inline for (info.Union.fields) |field| {
if (mem.startsWith(u8, text, field.name)) {
if (field.field_type == void) {
return @as(Arch, @field(Arch, field.name));
} else {
const sub_info = @typeInfo(field.field_type);
inline for (sub_info.Enum.fields) |sub_field| {
const combined = field.name ++ sub_field.name;
if (mem.eql(u8, text, combined)) {
return @unionInit(Arch, field.name, @field(field.field_type, sub_field.name));
}
}
return error.UnknownSubArchitecture;
}
}
}
return error.UnknownArchitecture;
}
pub fn parseOs(text: []const u8) !Os {
const info = @typeInfo(Os);
inline for (info.Enum.fields) |field| {
if (mem.eql(u8, text, field.name)) {
return @field(Os, field.name);
}
}
return error.UnknownOperatingSystem;
}
pub fn parseAbi(text: []const u8) !Abi {
const info = @typeInfo(Abi);
inline for (info.Enum.fields) |field| {
if (mem.eql(u8, text, field.name)) {
return @field(Abi, field.name);
}
}
return error.UnknownApplicationBinaryInterface;
}
fn archSubArchName(arch: Arch) []const u8 {
return switch (arch) {
.arm => |sub| @tagName(sub),
.armeb => |sub| @tagName(sub),
.thumb => |sub| @tagName(sub),
.thumbeb => |sub| @tagName(sub),
.aarch64 => |sub| @tagName(sub),
.aarch64_be => |sub| @tagName(sub),
.kalimba => |sub| @tagName(sub),
else => "",
};
}
pub fn subArchName(self: Target) []const u8 {
switch (self) {
.Native => return archSubArchName(builtin.arch),
.Cross => |cross| return archSubArchName(cross.arch),
}
}
pub fn oFileExt(self: Target) []const u8 {
return switch (self.getAbi()) {
.msvc => ".obj",
else => ".o",
};
}
pub fn exeFileExt(self: Target) []const u8 {
if (self.isWindows()) {
return ".exe";
} else if (self.isUefi()) {
return ".efi";
} else if (self.isWasm()) {
return ".wasm";
} else {
return "";
}
}
pub fn staticLibSuffix(self: Target) []const u8 {
if (self.isWasm()) {
return ".wasm";
}
switch (self.getAbi()) {
.msvc => return ".lib",
else => return ".a",
}
}
pub fn dynamicLibSuffix(self: Target) []const u8 {
if (self.isDarwin()) {
return ".dylib";
}
switch (self.getOs()) {
.windows => return ".dll",
else => return ".so",
}
}
pub fn libPrefix(self: Target) []const u8 {
if (self.isWasm()) {
return "";
}
switch (self.getAbi()) {
.msvc => return "",
else => return "lib",
}
}
pub fn getOs(self: Target) Os {
return switch (self) {
.Native => builtin.os,
.Cross => |t| t.os,
};
}
pub fn getArch(self: Target) Arch {
switch (self) {
.Native => return builtin.arch,
.Cross => |t| return t.arch,
}
}
pub fn getAbi(self: Target) Abi {
switch (self) {
.Native => return builtin.abi,
.Cross => |t| return t.abi,
}
}
pub fn isMinGW(self: Target) bool {
return self.isWindows() and self.isGnu();
}
pub fn isGnu(self: Target) bool {
return switch (self.getAbi()) {
.gnu, .gnuabin32, .gnuabi64, .gnueabi, .gnueabihf, .gnux32 => true,
else => false,
};
}
pub fn isMusl(self: Target) bool {
return switch (self.getAbi()) {
.musl, .musleabi, .musleabihf => true,
else => false,
};
}
pub fn isDarwin(self: Target) bool {
return switch (self.getOs()) {
.ios, .macosx, .watchos, .tvos => true,
else => false,
};
}
pub fn isWindows(self: Target) bool {
return switch (self.getOs()) {
.windows => true,
else => false,
};
}
pub fn isLinux(self: Target) bool {
return switch (self.getOs()) {
.linux => true,
else => false,
};
}
pub fn isUefi(self: Target) bool {
return switch (self.getOs()) {
.uefi => true,
else => false,
};
}
pub fn isWasm(self: Target) bool {
return switch (self.getArch()) {
.wasm32, .wasm64 => true,
else => false,
};
}
pub fn isFreeBSD(self: Target) bool {
return switch (self.getOs()) {
.freebsd => true,
else => false,
};
}
pub fn isNetBSD(self: Target) bool {
return switch (self.getOs()) {
.netbsd => true,
else => false,
};
}
pub fn wantSharedLibSymLinks(self: Target) bool {
return !self.isWindows();
}
pub fn osRequiresLibC(self: Target) bool {
return self.isDarwin() or self.isFreeBSD() or self.isNetBSD();
}
pub fn getArchPtrBitWidth(self: Target) u32 {
switch (self.getArch()) {
.avr,
.msp430,
=> return 16,
.arc,
.arm,
.armeb,
.hexagon,
.le32,
.mips,
.mipsel,
.powerpc,
.r600,
.riscv32,
.sparc,
.sparcel,
.tce,
.tcele,
.thumb,
.thumbeb,
.i386,
.xcore,
.nvptx,
.amdil,
.hsail,
.spir,
.kalimba,
.shave,
.lanai,
.wasm32,
.renderscript32,
.aarch64_32,
=> return 32,
.aarch64,
.aarch64_be,
.mips64,
.mips64el,
.powerpc64,
.powerpc64le,
.riscv64,
.x86_64,
.nvptx64,
.le64,
.amdil64,
.hsail64,
.spir64,
.wasm64,
.renderscript64,
.amdgcn,
.bpfel,
.bpfeb,
.sparcv9,
.s390x,
=> return 64,
}
}
pub fn supportsNewStackCall(self: Target) bool {
return !self.isWasm();
}
pub const Executor = union(enum) {
native,
qemu: []const u8,
wine: []const u8,
wasmtime: []const u8,
unavailable,
};
pub fn getExternalExecutor(self: Target) Executor {
if (@as(@TagType(Target), self) == .Native) return .native;
// If the target OS matches the host OS, we can use QEMU to emulate a foreign architecture.
if (self.getOs() == builtin.os) {
return switch (self.getArch()) {
.aarch64 => Executor{ .qemu = "qemu-aarch64" },
.aarch64_be => Executor{ .qemu = "qemu-aarch64_be" },
.arm => Executor{ .qemu = "qemu-arm" },
.armeb => Executor{ .qemu = "qemu-armeb" },
.i386 => Executor{ .qemu = "qemu-i386" },
.mips => Executor{ .qemu = "qemu-mips" },
.mipsel => Executor{ .qemu = "qemu-mipsel" },
.mips64 => Executor{ .qemu = "qemu-mips64" },
.mips64el => Executor{ .qemu = "qemu-mips64el" },
.powerpc => Executor{ .qemu = "qemu-ppc" },
.powerpc64 => Executor{ .qemu = "qemu-ppc64" },
.powerpc64le => Executor{ .qemu = "qemu-ppc64le" },
.riscv32 => Executor{ .qemu = "qemu-riscv32" },
.riscv64 => Executor{ .qemu = "qemu-riscv64" },
.s390x => Executor{ .qemu = "qemu-s390x" },
.sparc => Executor{ .qemu = "qemu-sparc" },
.x86_64 => Executor{ .qemu = "qemu-x86_64" },
else => return .unavailable,
};
}
if (self.isWindows()) {
switch (self.getArchPtrBitWidth()) {
32 => return Executor{ .wine = "wine" },
64 => return Executor{ .wine = "wine64" },
else => return .unavailable,
}
}
if (self.getOs() == .wasi) {
switch (self.getArchPtrBitWidth()) {
32 => return Executor{ .wasmtime = "wasmtime" },
else => return .unavailable,
}
}
return .unavailable;
}
};
test "parseCpuFeatureSet" {
const arch: Target.Arch = .x86_64;
const baseline = arch.getBaselineCpuFeatures();
const set = try arch.parseCpuFeatureSet(baseline.cpu, "-sse,-avx,-cx8");
std.testing.expect(!Target.x86.featureSetHas(set, .sse));
std.testing.expect(!Target.x86.featureSetHas(set, .avx));
std.testing.expect(!Target.x86.featureSetHas(set, .cx8));
// These are expected because they are part of the baseline
std.testing.expect(Target.x86.featureSetHas(set, .cmov));
std.testing.expect(Target.x86.featureSetHas(set, .fxsr));
} | lib/std/target.zig |
const std = @import("../std.zig");
const builtin = @import("builtin");
const build = std.build;
const fs = std.fs;
const Step = build.Step;
const Builder = build.Builder;
const GeneratedFile = build.GeneratedFile;
const LibExeObjStep = build.LibExeObjStep;
const FileSource = build.FileSource;
const OptionsStep = @This();
step: Step,
generated_file: GeneratedFile,
builder: *Builder,
contents: std.ArrayList(u8),
artifact_args: std.ArrayList(OptionArtifactArg),
file_source_args: std.ArrayList(OptionFileSourceArg),
pub fn create(builder: *Builder) *OptionsStep {
const self = builder.allocator.create(OptionsStep) catch unreachable;
self.* = .{
.builder = builder,
.step = Step.init(.options, "options", builder.allocator, make),
.generated_file = undefined,
.contents = std.ArrayList(u8).init(builder.allocator),
.artifact_args = std.ArrayList(OptionArtifactArg).init(builder.allocator),
.file_source_args = std.ArrayList(OptionFileSourceArg).init(builder.allocator),
};
self.generated_file = .{ .step = &self.step };
return self;
}
pub fn addOption(self: *OptionsStep, comptime T: type, name: []const u8, value: T) void {
const out = self.contents.writer();
switch (T) {
[]const []const u8 => {
out.print("pub const {}: []const []const u8 = &[_][]const u8{{\n", .{std.zig.fmtId(name)}) catch unreachable;
for (value) |slice| {
out.print(" \"{}\",\n", .{std.zig.fmtEscapes(slice)}) catch unreachable;
}
out.writeAll("};\n") catch unreachable;
return;
},
[:0]const u8 => {
out.print("pub const {}: [:0]const u8 = \"{}\";\n", .{ std.zig.fmtId(name), std.zig.fmtEscapes(value) }) catch unreachable;
return;
},
[]const u8 => {
out.print("pub const {}: []const u8 = \"{}\";\n", .{ std.zig.fmtId(name), std.zig.fmtEscapes(value) }) catch unreachable;
return;
},
?[:0]const u8 => {
out.print("pub const {}: ?[:0]const u8 = ", .{std.zig.fmtId(name)}) catch unreachable;
if (value) |payload| {
out.print("\"{}\";\n", .{std.zig.fmtEscapes(payload)}) catch unreachable;
} else {
out.writeAll("null;\n") catch unreachable;
}
return;
},
?[]const u8 => {
out.print("pub const {}: ?[]const u8 = ", .{std.zig.fmtId(name)}) catch unreachable;
if (value) |payload| {
out.print("\"{}\";\n", .{std.zig.fmtEscapes(payload)}) catch unreachable;
} else {
out.writeAll("null;\n") catch unreachable;
}
return;
},
std.builtin.Version => {
out.print(
\\pub const {}: @import("std").builtin.Version = .{{
\\ .major = {d},
\\ .minor = {d},
\\ .patch = {d},
\\}};
\\
, .{
std.zig.fmtId(name),
value.major,
value.minor,
value.patch,
}) catch unreachable;
return;
},
std.SemanticVersion => {
out.print(
\\pub const {}: @import("std").SemanticVersion = .{{
\\ .major = {d},
\\ .minor = {d},
\\ .patch = {d},
\\
, .{
std.zig.fmtId(name),
value.major,
value.minor,
value.patch,
}) catch unreachable;
if (value.pre) |some| {
out.print(" .pre = \"{}\",\n", .{std.zig.fmtEscapes(some)}) catch unreachable;
}
if (value.build) |some| {
out.print(" .build = \"{}\",\n", .{std.zig.fmtEscapes(some)}) catch unreachable;
}
out.writeAll("};\n") catch unreachable;
return;
},
else => {},
}
switch (@typeInfo(T)) {
.Enum => |enum_info| {
out.print("pub const {} = enum {{\n", .{std.zig.fmtId(@typeName(T))}) catch unreachable;
inline for (enum_info.fields) |field| {
out.print(" {},\n", .{std.zig.fmtId(field.name)}) catch unreachable;
}
out.writeAll("};\n") catch unreachable;
out.print("pub const {}: {s} = {s}.{s};\n", .{
std.zig.fmtId(name),
std.zig.fmtId(@typeName(T)),
std.zig.fmtId(@typeName(T)),
std.zig.fmtId(@tagName(value)),
}) catch unreachable;
return;
},
else => {},
}
out.print("pub const {}: {s} = ", .{ std.zig.fmtId(name), std.zig.fmtId(@typeName(T)) }) catch unreachable;
printLiteral(out, value, 0) catch unreachable;
out.writeAll(";\n") catch unreachable;
}
// TODO: non-recursive?
fn printLiteral(out: anytype, val: anytype, indent: u8) !void {
const T = @TypeOf(val);
switch (@typeInfo(T)) {
.Array => {
try out.print("{s} {{\n", .{@typeName(T)});
for (val) |item| {
try out.writeByteNTimes(' ', indent + 4);
try printLiteral(out, item, indent + 4);
try out.writeAll(",\n");
}
try out.writeByteNTimes(' ', indent);
try out.writeAll("}");
},
.Pointer => |p| {
if (p.size != .Slice) {
@compileError("Non-slice pointers are not yet supported in build options");
}
try out.print("&[_]{s} {{\n", .{@typeName(p.child)});
for (val) |item| {
try out.writeByteNTimes(' ', indent + 4);
try printLiteral(out, item, indent + 4);
try out.writeAll(",\n");
}
try out.writeByteNTimes(' ', indent);
try out.writeAll("}");
},
.Optional => {
if (val) |inner| {
return printLiteral(out, inner, indent);
} else {
return out.writeAll("null");
}
},
.Void,
.Bool,
.Int,
.Float,
.Null,
=> try out.print("{any}", .{val}),
else => @compileError(comptime std.fmt.comptimePrint("`{s}` are not yet supported as build options", .{@tagName(@typeInfo(T))})),
}
}
/// The value is the path in the cache dir.
/// Adds a dependency automatically.
pub fn addOptionFileSource(
self: *OptionsStep,
name: []const u8,
source: FileSource,
) void {
self.file_source_args.append(.{
.name = name,
.source = source.dupe(self.builder),
}) catch unreachable;
source.addStepDependencies(&self.step);
}
/// The value is the path in the cache dir.
/// Adds a dependency automatically.
pub fn addOptionArtifact(self: *OptionsStep, name: []const u8, artifact: *LibExeObjStep) void {
self.artifact_args.append(.{ .name = self.builder.dupe(name), .artifact = artifact }) catch unreachable;
self.step.dependOn(&artifact.step);
}
pub fn getPackage(self: *OptionsStep, package_name: []const u8) build.Pkg {
return .{ .name = package_name, .path = self.getSource() };
}
pub fn getSource(self: *OptionsStep) FileSource {
return .{ .generated = &self.generated_file };
}
fn make(step: *Step) !void {
const self = @fieldParentPtr(OptionsStep, "step", step);
for (self.artifact_args.items) |item| {
self.addOption(
[]const u8,
item.name,
self.builder.pathFromRoot(item.artifact.getOutputSource().getPath(self.builder)),
);
}
for (self.file_source_args.items) |item| {
self.addOption(
[]const u8,
item.name,
item.source.getPath(self.builder),
);
}
const options_directory = self.builder.pathFromRoot(
try fs.path.join(
self.builder.allocator,
&[_][]const u8{ self.builder.cache_root, "options" },
),
);
try fs.cwd().makePath(options_directory);
const options_file = try fs.path.join(
self.builder.allocator,
&[_][]const u8{ options_directory, &self.hashContentsToFileName() },
);
try fs.cwd().writeFile(options_file, self.contents.items);
self.generated_file.path = options_file;
}
fn hashContentsToFileName(self: *OptionsStep) [64]u8 {
// This implementation is copied from `WriteFileStep.make`
var hash = std.crypto.hash.blake2.Blake2b384.init(.{});
// Random bytes to make OptionsStep unique. Refresh this with
// new random bytes when OptionsStep implementation is modified
// in a non-backwards-compatible way.
hash.update("yL0Ya4KkmcCjBlP8");
hash.update(self.contents.items);
var digest: [48]u8 = undefined;
hash.final(&digest);
var hash_basename: [64]u8 = undefined;
_ = fs.base64_encoder.encode(&hash_basename, &digest);
return hash_basename;
}
const OptionArtifactArg = struct {
name: []const u8,
artifact: *LibExeObjStep,
};
const OptionFileSourceArg = struct {
name: []const u8,
source: FileSource,
};
test "OptionsStep" {
if (builtin.os.tag == .wasi) return error.SkipZigTest;
var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
defer arena.deinit();
var builder = try Builder.create(
arena.allocator(),
"test",
"test",
"test",
"test",
);
defer builder.destroy();
const options = builder.addOptions();
const KeywordEnum = enum {
@"0.8.1",
};
const nested_array = [2][2]u16{
[2]u16{ 300, 200 },
[2]u16{ 300, 200 },
};
const nested_slice: []const []const u16 = &[_][]const u16{ &nested_array[0], &nested_array[1] };
options.addOption(usize, "option1", 1);
options.addOption(?usize, "option2", null);
options.addOption(?usize, "option3", 3);
options.addOption([]const u8, "string", "zigisthebest");
options.addOption(?[]const u8, "optional_string", null);
options.addOption([2][2]u16, "nested_array", nested_array);
options.addOption([]const []const u16, "nested_slice", nested_slice);
options.addOption(KeywordEnum, "keyword_enum", .@"0.8.1");
options.addOption(std.builtin.Version, "version", try std.builtin.Version.parse("0.1.2"));
options.addOption(std.SemanticVersion, "semantic_version", try std.SemanticVersion.parse("0.1.2-foo+bar"));
try std.testing.expectEqualStrings(
\\pub const option1: usize = 1;
\\pub const option2: ?usize = null;
\\pub const option3: ?usize = 3;
\\pub const string: []const u8 = "zigisthebest";
\\pub const optional_string: ?[]const u8 = null;
\\pub const nested_array: [2][2]u16 = [2][2]u16 {
\\ [2]u16 {
\\ 300,
\\ 200,
\\ },
\\ [2]u16 {
\\ 300,
\\ 200,
\\ },
\\};
\\pub const nested_slice: []const []const u16 = &[_][]const u16 {
\\ &[_]u16 {
\\ 300,
\\ 200,
\\ },
\\ &[_]u16 {
\\ 300,
\\ 200,
\\ },
\\};
\\pub const KeywordEnum = enum {
\\ @"0.8.1",
\\};
\\pub const keyword_enum: KeywordEnum = KeywordEnum.@"0.8.1";
\\pub const version: @import("std").builtin.Version = .{
\\ .major = 0,
\\ .minor = 1,
\\ .patch = 2,
\\};
\\pub const semantic_version: @import("std").SemanticVersion = .{
\\ .major = 0,
\\ .minor = 1,
\\ .patch = 2,
\\ .pre = "foo",
\\ .build = "bar",
\\};
\\
, options.contents.items);
_ = try std.zig.parse(arena.allocator(), try options.contents.toOwnedSliceSentinel(0));
} | lib/std/build/OptionsStep.zig |
const c = @import("c.zig");
const utils = @import("utils.zig");
const Face = @import("freetype.zig").Face;
pub const Color = c.FT_Color;
pub const LayerIterator = c.FT_LayerIterator;
pub const ColorStopIterator = c.FT_ColorStopIterator;
pub const ColorIndex = c.FT_ColorIndex;
pub const ColorStop = c.FT_ColorStop;
pub const ColorLine = c.FT_ColorLine;
pub const Affine23 = c.FT_Affine23;
pub const OpaquePaint = c.FT_OpaquePaint;
pub const PaintColrLayers = c.FT_PaintColrLayers;
pub const PaintSolid = c.FT_PaintSolid;
pub const PaintLinearGradient = c.FT_PaintLinearGradient;
pub const PaintRadialGradient = c.FT_PaintRadialGradient;
pub const PaintSweepGradient = c.FT_PaintSweepGradient;
pub const PaintGlyph = c.FT_PaintGlyph;
pub const PaintColrGlyph = c.FT_PaintColrGlyph;
pub const PaintTransform = c.FT_PaintTransform;
pub const PaintTranslate = c.FT_PaintTranslate;
pub const PaintScale = c.FT_PaintScale;
pub const PaintRotate = c.FT_PaintRotate;
pub const PaintSkew = c.FT_PaintSkew;
pub const PaintComposite = c.FT_PaintComposite;
pub const ClipBox = c.FT_ClipBox;
pub const RootTransform = enum(u1) {
include_root_transform = c.FT_COLOR_INCLUDE_ROOT_TRANSFORM,
no_root_transform = c.FT_COLOR_NO_ROOT_TRANSFORM,
};
pub const PaintExtend = enum(u2) {
pad = c.FT_COLR_PAINT_EXTEND_PAD,
repeat = c.FT_COLR_PAINT_EXTEND_REPEAT,
reflect = c.FT_COLR_PAINT_EXTEND_REFLECT,
};
pub const PaintFormat = enum(u8) {
color_layers = c.FT_COLR_PAINTFORMAT_COLR_LAYERS,
solid = c.FT_COLR_PAINTFORMAT_SOLID,
linear_gradient = c.FT_COLR_PAINTFORMAT_LINEAR_GRADIENT,
radial_gradient = c.FT_COLR_PAINTFORMAT_RADIAL_GRADIENT,
sweep_gradient = c.FT_COLR_PAINTFORMAT_SWEEP_GRADIENT,
glyph = c.FT_COLR_PAINTFORMAT_GLYPH,
color_glyph = c.FT_COLR_PAINTFORMAT_COLR_GLYPH,
transform = c.FT_COLR_PAINTFORMAT_TRANSFORM,
translate = c.FT_COLR_PAINTFORMAT_TRANSLATE,
scale = c.FT_COLR_PAINTFORMAT_SCALE,
rotate = c.FT_COLR_PAINTFORMAT_ROTATE,
skew = c.FT_COLR_PAINTFORMAT_SKEW,
composite = c.FT_COLR_PAINTFORMAT_COMPOSITE,
};
pub const CompositeMode = enum(u5) {
clear = c.FT_COLR_COMPOSITE_CLEAR,
src = c.FT_COLR_COMPOSITE_SRC,
dest = c.FT_COLR_COMPOSITE_DEST,
src_over = c.FT_COLR_COMPOSITE_SRC_OVER,
dest_over = c.FT_COLR_COMPOSITE_DEST_OVER,
src_in = c.FT_COLR_COMPOSITE_SRC_IN,
dest_in = c.FT_COLR_COMPOSITE_DEST_IN,
src_out = c.FT_COLR_COMPOSITE_SRC_OUT,
dest_out = c.FT_COLR_COMPOSITE_DEST_OUT,
src_atop = c.FT_COLR_COMPOSITE_SRC_ATOP,
dest_atop = c.FT_COLR_COMPOSITE_DEST_ATOP,
xor = c.FT_COLR_COMPOSITE_XOR,
plus = c.FT_COLR_COMPOSITE_PLUS,
screen = c.FT_COLR_COMPOSITE_SCREEN,
overlay = c.FT_COLR_COMPOSITE_OVERLAY,
darken = c.FT_COLR_COMPOSITE_DARKEN,
lighten = c.FT_COLR_COMPOSITE_LIGHTEN,
color_dodge = c.FT_COLR_COMPOSITE_COLOR_DODGE,
color_burn = c.FT_COLR_COMPOSITE_COLOR_BURN,
hard_light = c.FT_COLR_COMPOSITE_HARD_LIGHT,
soft_light = c.FT_COLR_COMPOSITE_SOFT_LIGHT,
difference = c.FT_COLR_COMPOSITE_DIFFERENCE,
exclusion = c.FT_COLR_COMPOSITE_EXCLUSION,
multiply = c.FT_COLR_COMPOSITE_MULTIPLY,
hsl_hue = c.FT_COLR_COMPOSITE_HSL_HUE,
hsl_saturation = c.FT_COLR_COMPOSITE_HSL_SATURATION,
hsl_color = c.FT_COLR_COMPOSITE_HSL_COLOR,
hsl_luminosity = c.FT_COLR_COMPOSITE_HSL_LUMINOSITY,
};
pub const Paint = union(PaintFormat) {
color_layers: PaintColrLayers,
glyph: PaintGlyph,
solid: PaintSolid,
linear_gradient: PaintLinearGradient,
radial_gradient: PaintRadialGradient,
sweep_gradient: PaintSweepGradient,
transform: PaintTransform,
translate: PaintTranslate,
scale: PaintScale,
rotate: PaintRotate,
skew: PaintSkew,
composite: PaintComposite,
color_glyph: PaintColrGlyph,
};
pub const PaletteData = struct {
handle: c.FT_Palette_Data,
pub fn numPalettes(self: PaletteData) u16 {
return self.handle.num_palettes;
}
pub fn paletteNameIDs(self: PaletteData) ?[]const u16 {
return @ptrCast(?[]const u16, self.handle.palette_name_ids[0..self.numPalettes()]);
}
pub fn paletteFlags(self: PaletteData) ?[]const u16 {
return @ptrCast(?[]const u16, self.handle.palette_flags[0..self.numPalettes()]);
}
pub fn paletteFlag(self: PaletteData, index: usize) PaletteFlags {
return PaletteFlags.from(@intCast(u2, self.handle.*.palette_flags[index]));
}
pub fn numPaletteEntries(self: PaletteData) u16 {
return self.handle.num_palette_entries;
}
pub fn paletteEntryNameIDs(self: PaletteData) ?[]const u16 {
return @ptrCast(?[]const u16, self.handle.palette_entry_name_ids[0..self.numPaletteEntries()]);
}
};
pub const PaletteFlags = packed struct {
for_light_background: bool = false,
for_dark_background: bool = false,
pub const Flag = enum(u2) {
for_light_background = c.FT_PALETTE_FOR_LIGHT_BACKGROUND,
for_dark_background = c.FT_PALETTE_FOR_DARK_BACKGROUND,
};
pub fn from(bits: u2) PaletteFlags {
return utils.bitFieldsToStruct(PaletteFlags, Flag, bits);
}
pub fn to(flags: PaletteFlags) u2 {
return utils.structToBitFields(u2, PaletteFlags, Flag, flags);
}
};
pub const GlyphLayersIterator = struct {
face: Face,
glyph_index: u32,
layer_glyph_index: u32,
layer_color_index: u32,
iterator: LayerIterator,
pub fn init(face: Face, glyph_index: u32) GlyphLayersIterator {
var iterator: LayerIterator = undefined;
iterator.p = null;
return .{
.face = face,
.glyph_index = glyph_index,
.layer_glyph_index = 0,
.layer_color_index = 0,
.iterator = iterator,
};
}
pub fn next(self: *GlyphLayersIterator) bool {
return if (c.FT_Get_Color_Glyph_Layer(
self.face.handle,
self.glyph_index,
&self.layer_glyph_index,
&self.layer_color_index,
&self.iterator,
) == 0) false else true;
}
}; | freetype/src/freetype/color.zig |
pub const CRYPTCAT_MAX_MEMBERTAG = @as(u32, 64);
pub const CRYPTCAT_MEMBER_SORTED = @as(u32, 1073741824);
pub const CRYPTCAT_ATTR_AUTHENTICATED = @as(u32, 268435456);
pub const CRYPTCAT_ATTR_UNAUTHENTICATED = @as(u32, 536870912);
pub const CRYPTCAT_ATTR_NAMEASCII = @as(u32, 1);
pub const CRYPTCAT_ATTR_NAMEOBJID = @as(u32, 2);
pub const CRYPTCAT_ATTR_DATAASCII = @as(u32, 65536);
pub const CRYPTCAT_ATTR_DATABASE64 = @as(u32, 131072);
pub const CRYPTCAT_ATTR_DATAREPLACE = @as(u32, 262144);
pub const CRYPTCAT_ATTR_NO_AUTO_COMPAT_ENTRY = @as(u32, 16777216);
pub const CRYPTCAT_E_AREA_HEADER = @as(u32, 0);
pub const CRYPTCAT_E_AREA_MEMBER = @as(u32, 65536);
pub const CRYPTCAT_E_AREA_ATTRIBUTE = @as(u32, 131072);
pub const CRYPTCAT_E_CDF_UNSUPPORTED = @as(u32, 1);
pub const CRYPTCAT_E_CDF_DUPLICATE = @as(u32, 2);
pub const CRYPTCAT_E_CDF_TAGNOTFOUND = @as(u32, 4);
pub const CRYPTCAT_E_CDF_MEMBER_FILE_PATH = @as(u32, 65537);
pub const CRYPTCAT_E_CDF_MEMBER_INDIRECTDATA = @as(u32, 65538);
pub const CRYPTCAT_E_CDF_MEMBER_FILENOTFOUND = @as(u32, 65540);
pub const CRYPTCAT_E_CDF_BAD_GUID_CONV = @as(u32, 131073);
pub const CRYPTCAT_E_CDF_ATTR_TOOFEWVALUES = @as(u32, 131074);
pub const CRYPTCAT_E_CDF_ATTR_TYPECOMBO = @as(u32, 131076);
pub const CRYPTCAT_ADDCATALOG_NONE = @as(u32, 0);
pub const CRYPTCAT_ADDCATALOG_HARDLINK = @as(u32, 1);
//--------------------------------------------------------------------------------
// Section: Types (8)
//--------------------------------------------------------------------------------
pub const CRYPTCAT_VERSION = enum(u32) {
@"1" = 256,
@"2" = 512,
};
pub const CRYPTCAT_VERSION_1 = CRYPTCAT_VERSION.@"1";
pub const CRYPTCAT_VERSION_2 = CRYPTCAT_VERSION.@"2";
pub const CRYPTCAT_OPEN_FLAGS = enum(u32) {
ALWAYS = 2,
CREATENEW = 1,
EXISTING = 4,
EXCLUDE_PAGE_HASHES = 65536,
INCLUDE_PAGE_HASHES = 131072,
VERIFYSIGHASH = 268435456,
NO_CONTENT_HCRYPTMSG = 536870912,
SORTED = 1073741824,
FLAGS_MASK = 4294901760,
_,
pub fn initFlags(o: struct {
ALWAYS: u1 = 0,
CREATENEW: u1 = 0,
EXISTING: u1 = 0,
EXCLUDE_PAGE_HASHES: u1 = 0,
INCLUDE_PAGE_HASHES: u1 = 0,
VERIFYSIGHASH: u1 = 0,
NO_CONTENT_HCRYPTMSG: u1 = 0,
SORTED: u1 = 0,
FLAGS_MASK: u1 = 0,
}) CRYPTCAT_OPEN_FLAGS {
return @intToEnum(CRYPTCAT_OPEN_FLAGS,
(if (o.ALWAYS == 1) @enumToInt(CRYPTCAT_OPEN_FLAGS.ALWAYS) else 0)
| (if (o.CREATENEW == 1) @enumToInt(CRYPTCAT_OPEN_FLAGS.CREATENEW) else 0)
| (if (o.EXISTING == 1) @enumToInt(CRYPTCAT_OPEN_FLAGS.EXISTING) else 0)
| (if (o.EXCLUDE_PAGE_HASHES == 1) @enumToInt(CRYPTCAT_OPEN_FLAGS.EXCLUDE_PAGE_HASHES) else 0)
| (if (o.INCLUDE_PAGE_HASHES == 1) @enumToInt(CRYPTCAT_OPEN_FLAGS.INCLUDE_PAGE_HASHES) else 0)
| (if (o.VERIFYSIGHASH == 1) @enumToInt(CRYPTCAT_OPEN_FLAGS.VERIFYSIGHASH) else 0)
| (if (o.NO_CONTENT_HCRYPTMSG == 1) @enumToInt(CRYPTCAT_OPEN_FLAGS.NO_CONTENT_HCRYPTMSG) else 0)
| (if (o.SORTED == 1) @enumToInt(CRYPTCAT_OPEN_FLAGS.SORTED) else 0)
| (if (o.FLAGS_MASK == 1) @enumToInt(CRYPTCAT_OPEN_FLAGS.FLAGS_MASK) else 0)
);
}
};
pub const CRYPTCAT_OPEN_ALWAYS = CRYPTCAT_OPEN_FLAGS.ALWAYS;
pub const CRYPTCAT_OPEN_CREATENEW = CRYPTCAT_OPEN_FLAGS.CREATENEW;
pub const CRYPTCAT_OPEN_EXISTING = CRYPTCAT_OPEN_FLAGS.EXISTING;
pub const CRYPTCAT_OPEN_EXCLUDE_PAGE_HASHES = CRYPTCAT_OPEN_FLAGS.EXCLUDE_PAGE_HASHES;
pub const CRYPTCAT_OPEN_INCLUDE_PAGE_HASHES = CRYPTCAT_OPEN_FLAGS.INCLUDE_PAGE_HASHES;
pub const CRYPTCAT_OPEN_VERIFYSIGHASH = CRYPTCAT_OPEN_FLAGS.VERIFYSIGHASH;
pub const CRYPTCAT_OPEN_NO_CONTENT_HCRYPTMSG = CRYPTCAT_OPEN_FLAGS.NO_CONTENT_HCRYPTMSG;
pub const CRYPTCAT_OPEN_SORTED = CRYPTCAT_OPEN_FLAGS.SORTED;
pub const CRYPTCAT_OPEN_FLAGS_MASK = CRYPTCAT_OPEN_FLAGS.FLAGS_MASK;
pub const CRYPTCATSTORE = extern struct {
cbStruct: u32,
dwPublicVersion: u32,
pwszP7File: ?PWSTR,
hProv: usize,
dwEncodingType: u32,
fdwStoreFlags: CRYPTCAT_OPEN_FLAGS,
hReserved: ?HANDLE,
hAttrs: ?HANDLE,
hCryptMsg: ?*anyopaque,
hSorted: ?HANDLE,
};
pub const CRYPTCATMEMBER = extern struct {
cbStruct: u32,
pwszReferenceTag: ?PWSTR,
pwszFileName: ?PWSTR,
gSubjectType: Guid,
fdwMemberFlags: u32,
pIndirectData: ?*SIP_INDIRECT_DATA,
dwCertVersion: u32,
dwReserved: u32,
hReserved: ?HANDLE,
sEncodedIndirectData: CRYPTOAPI_BLOB,
sEncodedMemberInfo: CRYPTOAPI_BLOB,
};
pub const CRYPTCATATTRIBUTE = extern struct {
cbStruct: u32,
pwszReferenceTag: ?PWSTR,
dwAttrTypeAndAction: u32,
cbValue: u32,
pbValue: ?*u8,
dwReserved: u32,
};
pub const CRYPTCATCDF = extern struct {
cbStruct: u32,
hFile: ?HANDLE,
dwCurFilePos: u32,
dwLastMemberOffset: u32,
fEOF: BOOL,
pwszResultDir: ?PWSTR,
hCATStore: ?HANDLE,
};
pub const CATALOG_INFO = extern struct {
cbStruct: u32,
wszCatalogFile: [260]u16,
};
pub const PFN_CDF_PARSE_ERROR_CALLBACK = fn(
dwErrorArea: u32,
dwLocalError: u32,
pwszLine: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) void;
//--------------------------------------------------------------------------------
// Section: Functions (34)
//--------------------------------------------------------------------------------
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATOpen(
pwszFileName: ?PWSTR,
fdwOpenFlags: CRYPTCAT_OPEN_FLAGS,
hProv: usize,
dwPublicVersion: CRYPTCAT_VERSION,
dwEncodingType: u32,
) callconv(@import("std").os.windows.WINAPI) ?HANDLE;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATClose(
hCatalog: ?HANDLE,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATStoreFromHandle(
hCatalog: ?HANDLE,
) callconv(@import("std").os.windows.WINAPI) ?*CRYPTCATSTORE;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATHandleFromStore(
pCatStore: ?*CRYPTCATSTORE,
) callconv(@import("std").os.windows.WINAPI) ?HANDLE;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATPersistStore(
hCatalog: ?HANDLE,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "WINTRUST" fn CryptCATGetCatAttrInfo(
hCatalog: ?HANDLE,
pwszReferenceTag: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) ?*CRYPTCATATTRIBUTE;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATPutCatAttrInfo(
hCatalog: ?HANDLE,
pwszReferenceTag: ?PWSTR,
dwAttrTypeAndAction: u32,
cbData: u32,
pbData: ?*u8,
) callconv(@import("std").os.windows.WINAPI) ?*CRYPTCATATTRIBUTE;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATEnumerateCatAttr(
hCatalog: ?HANDLE,
pPrevAttr: ?*CRYPTCATATTRIBUTE,
) callconv(@import("std").os.windows.WINAPI) ?*CRYPTCATATTRIBUTE;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATGetMemberInfo(
hCatalog: ?HANDLE,
pwszReferenceTag: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) ?*CRYPTCATMEMBER;
pub extern "WINTRUST" fn CryptCATAllocSortedMemberInfo(
hCatalog: ?HANDLE,
pwszReferenceTag: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) ?*CRYPTCATMEMBER;
pub extern "WINTRUST" fn CryptCATFreeSortedMemberInfo(
hCatalog: ?HANDLE,
pCatMember: ?*CRYPTCATMEMBER,
) callconv(@import("std").os.windows.WINAPI) void;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATGetAttrInfo(
hCatalog: ?HANDLE,
pCatMember: ?*CRYPTCATMEMBER,
pwszReferenceTag: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) ?*CRYPTCATATTRIBUTE;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATPutMemberInfo(
hCatalog: ?HANDLE,
pwszFileName: ?PWSTR,
pwszReferenceTag: ?PWSTR,
pgSubjectType: ?*Guid,
dwCertVersion: u32,
cbSIPIndirectData: u32,
pbSIPIndirectData: ?*u8,
) callconv(@import("std").os.windows.WINAPI) ?*CRYPTCATMEMBER;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATPutAttrInfo(
hCatalog: ?HANDLE,
pCatMember: ?*CRYPTCATMEMBER,
pwszReferenceTag: ?PWSTR,
dwAttrTypeAndAction: u32,
cbData: u32,
pbData: ?*u8,
) callconv(@import("std").os.windows.WINAPI) ?*CRYPTCATATTRIBUTE;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATEnumerateMember(
hCatalog: ?HANDLE,
pPrevMember: ?*CRYPTCATMEMBER,
) callconv(@import("std").os.windows.WINAPI) ?*CRYPTCATMEMBER;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATEnumerateAttr(
hCatalog: ?HANDLE,
pCatMember: ?*CRYPTCATMEMBER,
pPrevAttr: ?*CRYPTCATATTRIBUTE,
) callconv(@import("std").os.windows.WINAPI) ?*CRYPTCATATTRIBUTE;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATCDFOpen(
pwszFilePath: ?PWSTR,
pfnParseError: ?PFN_CDF_PARSE_ERROR_CALLBACK,
) callconv(@import("std").os.windows.WINAPI) ?*CRYPTCATCDF;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATCDFClose(
pCDF: ?*CRYPTCATCDF,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATCDFEnumCatAttributes(
pCDF: ?*CRYPTCATCDF,
pPrevAttr: ?*CRYPTCATATTRIBUTE,
pfnParseError: ?PFN_CDF_PARSE_ERROR_CALLBACK,
) callconv(@import("std").os.windows.WINAPI) ?*CRYPTCATATTRIBUTE;
pub extern "WINTRUST" fn CryptCATCDFEnumMembers(
pCDF: ?*CRYPTCATCDF,
pPrevMember: ?*CRYPTCATMEMBER,
pfnParseError: ?PFN_CDF_PARSE_ERROR_CALLBACK,
) callconv(@import("std").os.windows.WINAPI) ?*CRYPTCATMEMBER;
pub extern "WINTRUST" fn CryptCATCDFEnumAttributes(
pCDF: ?*CRYPTCATCDF,
pMember: ?*CRYPTCATMEMBER,
pPrevAttr: ?*CRYPTCATATTRIBUTE,
pfnParseError: ?PFN_CDF_PARSE_ERROR_CALLBACK,
) callconv(@import("std").os.windows.WINAPI) ?*CRYPTCATATTRIBUTE;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn IsCatalogFile(
hFile: ?HANDLE,
pwszFileName: ?PWSTR,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATAdminAcquireContext(
phCatAdmin: ?*isize,
pgSubsystem: ?*const Guid,
dwFlags: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows8.0'
pub extern "WINTRUST" fn CryptCATAdminAcquireContext2(
phCatAdmin: ?*isize,
pgSubsystem: ?*const Guid,
pwszHashAlgorithm: ?[*:0]const u16,
pStrongHashPolicy: ?*CERT_STRONG_SIGN_PARA,
dwFlags: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATAdminReleaseContext(
hCatAdmin: isize,
dwFlags: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATAdminReleaseCatalogContext(
hCatAdmin: isize,
hCatInfo: isize,
dwFlags: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATAdminEnumCatalogFromHash(
hCatAdmin: isize,
// TODO: what to do with BytesParamIndex 2?
pbHash: ?*u8,
cbHash: u32,
dwFlags: u32,
phPrevCatInfo: ?*isize,
) callconv(@import("std").os.windows.WINAPI) isize;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATAdminCalcHashFromFileHandle(
hFile: ?HANDLE,
pcbHash: ?*u32,
// TODO: what to do with BytesParamIndex 1?
pbHash: ?*u8,
dwFlags: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows8.0'
pub extern "WINTRUST" fn CryptCATAdminCalcHashFromFileHandle2(
hCatAdmin: isize,
hFile: ?HANDLE,
pcbHash: ?*u32,
// TODO: what to do with BytesParamIndex 2?
pbHash: ?*u8,
dwFlags: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATAdminAddCatalog(
hCatAdmin: isize,
pwszCatalogFile: ?PWSTR,
pwszSelectBaseName: ?PWSTR,
dwFlags: u32,
) callconv(@import("std").os.windows.WINAPI) isize;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATAdminRemoveCatalog(
hCatAdmin: isize,
pwszCatalogFile: ?[*:0]const u16,
dwFlags: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATCatalogInfoFromContext(
hCatInfo: isize,
psCatInfo: ?*CATALOG_INFO,
dwFlags: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
// TODO: this type is limited to platform 'windows5.1.2600'
pub extern "WINTRUST" fn CryptCATAdminResolveCatalogPath(
hCatAdmin: isize,
pwszCatalogFile: ?PWSTR,
psCatInfo: ?*CATALOG_INFO,
dwFlags: u32,
) callconv(@import("std").os.windows.WINAPI) BOOL;
pub extern "WINTRUST" fn CryptCATAdminPauseServiceForBackup(
dwFlags: u32,
fResume: BOOL,
) callconv(@import("std").os.windows.WINAPI) BOOL;
//--------------------------------------------------------------------------------
// Section: Unicode Aliases (0)
//--------------------------------------------------------------------------------
const thismodule = @This();
pub usingnamespace switch (@import("../../zig.zig").unicode_mode) {
.ansi => struct {
},
.wide => struct {
},
.unspecified => if (@import("builtin").is_test) struct {
} else struct {
},
};
//--------------------------------------------------------------------------------
// Section: Imports (7)
//--------------------------------------------------------------------------------
const Guid = @import("../../zig.zig").Guid;
const BOOL = @import("../../foundation.zig").BOOL;
const CERT_STRONG_SIGN_PARA = @import("../../security/cryptography.zig").CERT_STRONG_SIGN_PARA;
const CRYPTOAPI_BLOB = @import("../../security/cryptography.zig").CRYPTOAPI_BLOB;
const HANDLE = @import("../../foundation.zig").HANDLE;
const PWSTR = @import("../../foundation.zig").PWSTR;
const SIP_INDIRECT_DATA = @import("../../security/cryptography/sip.zig").SIP_INDIRECT_DATA;
test {
// The following '_ = <FuncPtrType>' lines are a workaround for https://github.com/ziglang/zig/issues/4476
if (@hasDecl(@This(), "PFN_CDF_PARSE_ERROR_CALLBACK")) { _ = PFN_CDF_PARSE_ERROR_CALLBACK; }
@setEvalBranchQuota(
@import("std").meta.declarations(@This()).len * 3
);
// reference all the pub declarations
if (!@import("builtin").is_test) return;
inline for (@import("std").meta.declarations(@This())) |decl| {
if (decl.is_pub) {
_ = decl;
}
}
} | win32/security/cryptography/catalog.zig |
const std = @import("std");
const testing = std.testing;
const CircBufError = error{
InvalidParam,
Empty,
};
fn CircBuf(comptime T: type) type {
return struct {
head: usize = 0,
tail: usize = 0,
buf: [*]T = null,
buf_len: usize = 0,
pub fn init(buf: [*]T, buf_len: usize) CircBuf(T) {
std.debug.assert(buf_len != 0);
return CircBuf(T){ .buf = buf, .buf_len = buf_len };
}
pub fn push(self: *CircBuf(T), data: T) void {
self.buf[self.head] = data;
self.incHead();
if (self.head == self.tail) {
self.incTail();
}
}
fn incTail(self: *CircBuf(T)) void {
self.tail = (self.tail + 1) % self.buf_len;
}
fn incHead(self: *CircBuf(T)) void {
self.head = (self.head + 1) % self.buf_len;
}
pub fn pop(self: *CircBuf(T)) CircBufError!T {
if (self.empty()) {
return CircBufError.Empty;
}
const data: T = self.buf[self.tail];
self.incTail();
return data;
}
pub fn empty(self: CircBuf(T)) bool {
return self.head == self.tail;
}
pub fn full(self: CircBuf(T)) bool {
if (self.tail == 0) {
return (self.tail == 0) and (self.head == self.buf_len - 1);
}
return self.head == self.tail - 1;
}
};
}
test "circ buf init sets values" {
var data: [256]f16 = undefined;
const cb = CircBuf(@TypeOf(data[0])).init(&data, data.len);
try testing.expect(cb.head == 0);
try testing.expect(cb.tail == 0);
try testing.expect(cb.buf == &data);
try testing.expect(cb.buf_len == data.len);
}
test "circ buf push adds a byte" {
var data: [5]u8 = undefined;
var cb = CircBuf(@TypeOf(data[0])).init(&data, data.len);
try testing.expect(cb.head == 0);
try testing.expect(cb.empty());
try testing.expect(!cb.full());
cb.push(10);
try testing.expect(cb.head == 1);
try testing.expect(cb.tail == 0);
try testing.expect(cb.buf[0] == 10);
try testing.expect(!cb.empty());
try testing.expect(!cb.full());
cb.push(20);
try testing.expect(cb.head == 2);
try testing.expect(cb.tail == 0);
try testing.expect(cb.buf[1] == 20);
try testing.expect(!cb.empty());
try testing.expect(!cb.full());
cb.push(30);
try testing.expect(cb.head == 3);
try testing.expect(cb.tail == 0);
try testing.expect(cb.buf[2] == 30);
try testing.expect(!cb.empty());
try testing.expect(!cb.full());
cb.push(40);
try testing.expect(cb.head == 4);
try testing.expect(cb.tail == 0);
try testing.expect(cb.buf[3] == 40);
try testing.expect(!cb.empty());
try testing.expect(cb.full());
// Loops around, now needs to bump tail since it dropped a datum
cb.push(50);
try testing.expect(cb.head == 0);
try testing.expect(cb.tail == 1);
try testing.expect(cb.buf[4] == 50);
try testing.expect(!cb.empty());
try testing.expect(cb.full());
cb.push(60);
try testing.expect(cb.head == 1);
try testing.expect(cb.tail == 2);
try testing.expect(cb.buf[0] == 60);
try testing.expect(!cb.empty());
try testing.expect(cb.full());
}
test "circbuf pop returns a datum" {
var data: [5]u16 = undefined;
var cb = CircBuf(@TypeOf(data[0])).init(&data, data.len);
if (cb.pop()) |datum| {
_ = datum;
unreachable;
} else |err| {
try testing.expect(err == CircBufError.Empty);
}
cb.push(2000);
try testing.expect(cb.head == 1);
try testing.expect(cb.tail == 0);
const datum = cb.pop() catch 0;
try testing.expect(datum == 2000);
try testing.expect(cb.head == 1);
try testing.expect(cb.tail == 1);
try testing.expect(cb.empty());
cb.push(3000);
cb.push(4000);
cb.push(5000);
cb.push(6000);
try testing.expect(cb.full());
try testing.expect(cb.head == 0);
try testing.expect(cb.tail == 1);
const boop = [_]u16{ 3000, 4000, 5000, 6000 };
for (boop) |x| {
const b = cb.pop() catch 0;
try testing.expect(b == x);
}
try testing.expect(cb.empty());
try testing.expect(cb.head == 0);
try testing.expect(cb.tail == 0);
} | circbuf/generic_circbuf.zig |
const std = @import("std");
const warn = std.debug.warn;
const Allocator = std.mem.Allocator;
const c = @cImport({
@cInclude("GL/gl3w.h");
});
fn readFile(allocator: *Allocator, filename: []const u8) ![]const u8 {
var file = try std.fs.cwd().openFile(filename, .{});
var stat = try file.stat();
// TODO: return error when file size 0
const in_stream = std.io.bufferedInStream(file.inStream()).inStream();
var str = try in_stream.readAllAlloc(allocator, stat.size);
return str;
}
pub fn loadShaders(vertex_file_path: []const u8, fragment_file_path: []const u8) !c.GLuint {
const allocator = std.heap.page_allocator;
const vertex_file = try readFile(allocator, vertex_file_path);
defer allocator.free(vertex_file);
const fragment_file = try readFile(allocator, fragment_file_path);
defer allocator.free(fragment_file);
var result: c.GLint = undefined;
var infoLogLength: c_int = undefined;
var vertexShaderId = c.glCreateShader(c.GL_VERTEX_SHADER);
var fragmentShaderId = c.glCreateShader(c.GL_FRAGMENT_SHADER);
warn("compiling vertex shader: {}\n", .{vertex_file_path});
var vertex_array = [_][*]const u8{vertex_file.ptr};
c.glShaderSource(vertexShaderId, 1, &vertex_array, null);
c.glCompileShader(vertexShaderId);
c.glGetShaderiv(vertexShaderId, c.GL_COMPILE_STATUS, &result);
c.glGetShaderiv(vertexShaderId, c.GL_INFO_LOG_LENGTH, &infoLogLength);
if (infoLogLength > 0) {
var logStr = try allocator.allocSentinel(u8, @intCast(usize, infoLogLength), 0);
defer allocator.free(logStr);
c.glGetShaderInfoLog(vertexShaderId, infoLogLength, null, logStr.ptr);
warn("error compiling shader: {}\n", .{logStr});
}
warn("compiling fragment shader: {}\n", .{fragment_file_path});
var fragment_array = [_][*]const u8{fragment_file.ptr};
c.glShaderSource(fragmentShaderId, 1, &fragment_array, null);
c.glCompileShader(fragmentShaderId);
c.glGetShaderiv(fragmentShaderId, c.GL_COMPILE_STATUS, &result);
c.glGetShaderiv(fragmentShaderId, c.GL_INFO_LOG_LENGTH, &infoLogLength);
if (infoLogLength > 0) {
var logStr = try allocator.allocSentinel(u8, @intCast(usize, infoLogLength), 0);
defer allocator.free(logStr);
c.glGetShaderInfoLog(fragmentShaderId, infoLogLength, null, logStr.ptr);
warn("error compiling shader: {}\n", .{logStr});
}
warn("linking program\n", .{});
var programId = c.glCreateProgram();
c.glAttachShader(programId, vertexShaderId);
c.glAttachShader(programId, fragmentShaderId);
c.glLinkProgram(programId);
c.glGetProgramiv(programId, c.GL_LINK_STATUS, &result);
c.glGetProgramiv(programId, c.GL_INFO_LOG_LENGTH, &infoLogLength);
if (infoLogLength > 0) {
var logStr = try allocator.allocSentinel(u8, @intCast(usize, infoLogLength), 0);
defer allocator.free(logStr);
c.glGetShaderInfoLog(programId, infoLogLength, null, logStr.ptr);
warn("error linking program: {}\n", .{logStr});
}
c.glDetachShader(programId, vertexShaderId);
c.glDetachShader(programId, fragmentShaderId);
c.glDeleteShader(vertexShaderId);
c.glDeleteShader(fragmentShaderId);
return programId;
} | common/shader.zig |
pub const PROGRESS_INDETERMINATE = @as(i32, -1);
pub const PHOTOACQ_ERROR_RESTART_REQUIRED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147180543));
pub const PHOTOACQ_RUN_DEFAULT = @as(u32, 0);
pub const PHOTOACQ_NO_GALLERY_LAUNCH = @as(u32, 1);
pub const PHOTOACQ_DISABLE_AUTO_ROTATE = @as(u32, 2);
pub const PHOTOACQ_DISABLE_PLUGINS = @as(u32, 4);
pub const PHOTOACQ_DISABLE_GROUP_TAG_PROMPT = @as(u32, 8);
pub const PHOTOACQ_DISABLE_DB_INTEGRATION = @as(u32, 16);
pub const PHOTOACQ_DELETE_AFTER_ACQUIRE = @as(u32, 32);
pub const PHOTOACQ_DISABLE_DUPLICATE_DETECTION = @as(u32, 64);
pub const PHOTOACQ_ENABLE_THUMBNAIL_CACHING = @as(u32, 128);
pub const PHOTOACQ_DISABLE_METADATA_WRITE = @as(u32, 256);
pub const PHOTOACQ_DISABLE_THUMBNAIL_PROGRESS = @as(u32, 512);
pub const PHOTOACQ_DISABLE_SETTINGS_LINK = @as(u32, 1024);
pub const PHOTOACQ_ABORT_ON_SETTINGS_UPDATE = @as(u32, 2048);
pub const PHOTOACQ_IMPORT_VIDEO_AS_MULTIPLE_FILES = @as(u32, 4096);
pub const DSF_WPD_DEVICES = @as(u32, 1);
pub const DSF_WIA_CAMERAS = @as(u32, 2);
pub const DSF_WIA_SCANNERS = @as(u32, 4);
pub const DSF_STI_DEVICES = @as(u32, 8);
pub const DSF_TWAIN_DEVICES = @as(u32, 16);
pub const DSF_FS_DEVICES = @as(u32, 32);
pub const DSF_DV_DEVICES = @as(u32, 64);
pub const DSF_ALL_DEVICES = @as(u32, 65535);
pub const DSF_CPL_MODE = @as(u32, 65536);
pub const DSF_SHOW_OFFLINE = @as(u32, 131072);
pub const PAPS_PRESAVE = @as(u32, 0);
pub const PAPS_POSTSAVE = @as(u32, 1);
pub const PAPS_CLEANUP = @as(u32, 2);
//--------------------------------------------------------------------------------
// Section: Types (23)
//--------------------------------------------------------------------------------
const CLSID_PhotoAcquire_Value = @import("../zig.zig").Guid.initString("00f26e02-e9f2-4a9f-9fdd-5a962fb26a98");
pub const CLSID_PhotoAcquire = &CLSID_PhotoAcquire_Value;
const CLSID_PhotoAcquireAutoPlayDropTarget_Value = @import("../zig.zig").Guid.initString("00f20eb5-8fd6-4d9d-b75e-36801766c8f1");
pub const CLSID_PhotoAcquireAutoPlayDropTarget = &CLSID_PhotoAcquireAutoPlayDropTarget_Value;
const CLSID_PhotoAcquireAutoPlayHWEventHandler_Value = @import("../zig.zig").Guid.initString("00f2b433-44e4-4d88-b2b0-2698a0a91dba");
pub const CLSID_PhotoAcquireAutoPlayHWEventHandler = &CLSID_PhotoAcquireAutoPlayHWEventHandler_Value;
const CLSID_PhotoAcquireOptionsDialog_Value = @import("../zig.zig").Guid.initString("00f210a1-62f0-438b-9f7e-9618d72a1831");
pub const CLSID_PhotoAcquireOptionsDialog = &CLSID_PhotoAcquireOptionsDialog_Value;
const CLSID_PhotoProgressDialog_Value = @import("../zig.zig").Guid.initString("00f24ca0-748f-4e8a-894f-0e0357c6799f");
pub const CLSID_PhotoProgressDialog = &CLSID_PhotoProgressDialog_Value;
const CLSID_PhotoAcquireDeviceSelectionDialog_Value = @import("../zig.zig").Guid.initString("00f29a34-b8a1-482c-bcf8-3ac7b0fe8f62");
pub const CLSID_PhotoAcquireDeviceSelectionDialog = &CLSID_PhotoAcquireDeviceSelectionDialog_Value;
const IID_IPhotoAcquireItem_Value = @import("../zig.zig").Guid.initString("00f21c97-28bf-4c02-b842-5e4e90139a30");
pub const IID_IPhotoAcquireItem = &IID_IPhotoAcquireItem_Value;
pub const IPhotoAcquireItem = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
GetItemName: fn(
self: *const IPhotoAcquireItem,
pbstrItemName: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetThumbnail: fn(
self: *const IPhotoAcquireItem,
sizeThumbnail: SIZE,
phbmpThumbnail: ?*?HBITMAP,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetProperty: fn(
self: *const IPhotoAcquireItem,
key: ?*const PROPERTYKEY,
pv: ?*PROPVARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetProperty: fn(
self: *const IPhotoAcquireItem,
key: ?*const PROPERTYKEY,
pv: ?*const PROPVARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetStream: fn(
self: *const IPhotoAcquireItem,
ppStream: ?*?*IStream,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
CanDelete: fn(
self: *const IPhotoAcquireItem,
pfCanDelete: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Delete: fn(
self: *const IPhotoAcquireItem,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetSubItemCount: fn(
self: *const IPhotoAcquireItem,
pnCount: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetSubItemAt: fn(
self: *const IPhotoAcquireItem,
nItemIndex: u32,
ppPhotoAcquireItem: ?*?*IPhotoAcquireItem,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireItem_GetItemName(self: *const T, pbstrItemName: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireItem.VTable, self.vtable).GetItemName(@ptrCast(*const IPhotoAcquireItem, self), pbstrItemName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireItem_GetThumbnail(self: *const T, sizeThumbnail: SIZE, phbmpThumbnail: ?*?HBITMAP) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireItem.VTable, self.vtable).GetThumbnail(@ptrCast(*const IPhotoAcquireItem, self), sizeThumbnail, phbmpThumbnail);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireItem_GetProperty(self: *const T, key: ?*const PROPERTYKEY, pv: ?*PROPVARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireItem.VTable, self.vtable).GetProperty(@ptrCast(*const IPhotoAcquireItem, self), key, pv);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireItem_SetProperty(self: *const T, key: ?*const PROPERTYKEY, pv: ?*const PROPVARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireItem.VTable, self.vtable).SetProperty(@ptrCast(*const IPhotoAcquireItem, self), key, pv);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireItem_GetStream(self: *const T, ppStream: ?*?*IStream) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireItem.VTable, self.vtable).GetStream(@ptrCast(*const IPhotoAcquireItem, self), ppStream);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireItem_CanDelete(self: *const T, pfCanDelete: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireItem.VTable, self.vtable).CanDelete(@ptrCast(*const IPhotoAcquireItem, self), pfCanDelete);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireItem_Delete(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireItem.VTable, self.vtable).Delete(@ptrCast(*const IPhotoAcquireItem, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireItem_GetSubItemCount(self: *const T, pnCount: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireItem.VTable, self.vtable).GetSubItemCount(@ptrCast(*const IPhotoAcquireItem, self), pnCount);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireItem_GetSubItemAt(self: *const T, nItemIndex: u32, ppPhotoAcquireItem: ?*?*IPhotoAcquireItem) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireItem.VTable, self.vtable).GetSubItemAt(@ptrCast(*const IPhotoAcquireItem, self), nItemIndex, ppPhotoAcquireItem);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const USER_INPUT_STRING_TYPE = enum(i32) {
DEFAULT = 0,
PATH_ELEMENT = 1,
};
pub const USER_INPUT_DEFAULT = USER_INPUT_STRING_TYPE.DEFAULT;
pub const USER_INPUT_PATH_ELEMENT = USER_INPUT_STRING_TYPE.PATH_ELEMENT;
const IID_IUserInputString_Value = @import("../zig.zig").Guid.initString("00f243a1-205b-45ba-ae26-abbc53aa7a6f");
pub const IID_IUserInputString = &IID_IUserInputString_Value;
pub const IUserInputString = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
GetSubmitButtonText: fn(
self: *const IUserInputString,
pbstrSubmitButtonText: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetPrompt: fn(
self: *const IUserInputString,
pbstrPromptTitle: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetStringId: fn(
self: *const IUserInputString,
pbstrStringId: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetStringType: fn(
self: *const IUserInputString,
pnStringType: ?*USER_INPUT_STRING_TYPE,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetTooltipText: fn(
self: *const IUserInputString,
pbstrTooltipText: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetMaxLength: fn(
self: *const IUserInputString,
pcchMaxLength: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetDefault: fn(
self: *const IUserInputString,
pbstrDefault: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetMruCount: fn(
self: *const IUserInputString,
pnMruCount: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetMruEntryAt: fn(
self: *const IUserInputString,
nIndex: u32,
pbstrMruEntry: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetImage: fn(
self: *const IUserInputString,
nSize: u32,
phBitmap: ?*?HBITMAP,
phIcon: ?*?HICON,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IUserInputString_GetSubmitButtonText(self: *const T, pbstrSubmitButtonText: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IUserInputString.VTable, self.vtable).GetSubmitButtonText(@ptrCast(*const IUserInputString, self), pbstrSubmitButtonText);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IUserInputString_GetPrompt(self: *const T, pbstrPromptTitle: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IUserInputString.VTable, self.vtable).GetPrompt(@ptrCast(*const IUserInputString, self), pbstrPromptTitle);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IUserInputString_GetStringId(self: *const T, pbstrStringId: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IUserInputString.VTable, self.vtable).GetStringId(@ptrCast(*const IUserInputString, self), pbstrStringId);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IUserInputString_GetStringType(self: *const T, pnStringType: ?*USER_INPUT_STRING_TYPE) callconv(.Inline) HRESULT {
return @ptrCast(*const IUserInputString.VTable, self.vtable).GetStringType(@ptrCast(*const IUserInputString, self), pnStringType);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IUserInputString_GetTooltipText(self: *const T, pbstrTooltipText: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IUserInputString.VTable, self.vtable).GetTooltipText(@ptrCast(*const IUserInputString, self), pbstrTooltipText);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IUserInputString_GetMaxLength(self: *const T, pcchMaxLength: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IUserInputString.VTable, self.vtable).GetMaxLength(@ptrCast(*const IUserInputString, self), pcchMaxLength);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IUserInputString_GetDefault(self: *const T, pbstrDefault: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IUserInputString.VTable, self.vtable).GetDefault(@ptrCast(*const IUserInputString, self), pbstrDefault);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IUserInputString_GetMruCount(self: *const T, pnMruCount: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IUserInputString.VTable, self.vtable).GetMruCount(@ptrCast(*const IUserInputString, self), pnMruCount);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IUserInputString_GetMruEntryAt(self: *const T, nIndex: u32, pbstrMruEntry: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IUserInputString.VTable, self.vtable).GetMruEntryAt(@ptrCast(*const IUserInputString, self), nIndex, pbstrMruEntry);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IUserInputString_GetImage(self: *const T, nSize: u32, phBitmap: ?*?HBITMAP, phIcon: ?*?HICON) callconv(.Inline) HRESULT {
return @ptrCast(*const IUserInputString.VTable, self.vtable).GetImage(@ptrCast(*const IUserInputString, self), nSize, phBitmap, phIcon);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const ERROR_ADVISE_MESSAGE_TYPE = enum(i32) {
SKIPRETRYCANCEL = 0,
RETRYCANCEL = 1,
YESNO = 2,
OK = 3,
};
pub const PHOTOACQUIRE_ERROR_SKIPRETRYCANCEL = ERROR_ADVISE_MESSAGE_TYPE.SKIPRETRYCANCEL;
pub const PHOTOACQUIRE_ERROR_RETRYCANCEL = ERROR_ADVISE_MESSAGE_TYPE.RETRYCANCEL;
pub const PHOTOACQUIRE_ERROR_YESNO = ERROR_ADVISE_MESSAGE_TYPE.YESNO;
pub const PHOTOACQUIRE_ERROR_OK = ERROR_ADVISE_MESSAGE_TYPE.OK;
pub const ERROR_ADVISE_RESULT = enum(i32) {
YES = 0,
NO = 1,
OK = 2,
SKIP = 3,
SKIP_ALL = 4,
RETRY = 5,
ABORT = 6,
};
pub const PHOTOACQUIRE_RESULT_YES = ERROR_ADVISE_RESULT.YES;
pub const PHOTOACQUIRE_RESULT_NO = ERROR_ADVISE_RESULT.NO;
pub const PHOTOACQUIRE_RESULT_OK = ERROR_ADVISE_RESULT.OK;
pub const PHOTOACQUIRE_RESULT_SKIP = ERROR_ADVISE_RESULT.SKIP;
pub const PHOTOACQUIRE_RESULT_SKIP_ALL = ERROR_ADVISE_RESULT.SKIP_ALL;
pub const PHOTOACQUIRE_RESULT_RETRY = ERROR_ADVISE_RESULT.RETRY;
pub const PHOTOACQUIRE_RESULT_ABORT = ERROR_ADVISE_RESULT.ABORT;
const IID_IPhotoAcquireProgressCB_Value = @import("../zig.zig").Guid.initString("00f2ce1e-935e-4248-892c-130f32c45cb4");
pub const IID_IPhotoAcquireProgressCB = &IID_IPhotoAcquireProgressCB_Value;
pub const IPhotoAcquireProgressCB = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
Cancelled: fn(
self: *const IPhotoAcquireProgressCB,
pfCancelled: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
StartEnumeration: fn(
self: *const IPhotoAcquireProgressCB,
pPhotoAcquireSource: ?*IPhotoAcquireSource,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
FoundItem: fn(
self: *const IPhotoAcquireProgressCB,
pPhotoAcquireItem: ?*IPhotoAcquireItem,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EndEnumeration: fn(
self: *const IPhotoAcquireProgressCB,
hr: HRESULT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
StartTransfer: fn(
self: *const IPhotoAcquireProgressCB,
pPhotoAcquireSource: ?*IPhotoAcquireSource,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
StartItemTransfer: fn(
self: *const IPhotoAcquireProgressCB,
nItemIndex: u32,
pPhotoAcquireItem: ?*IPhotoAcquireItem,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
DirectoryCreated: fn(
self: *const IPhotoAcquireProgressCB,
pszDirectory: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
UpdateTransferPercent: fn(
self: *const IPhotoAcquireProgressCB,
fOverall: BOOL,
nPercent: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EndItemTransfer: fn(
self: *const IPhotoAcquireProgressCB,
nItemIndex: u32,
pPhotoAcquireItem: ?*IPhotoAcquireItem,
hr: HRESULT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EndTransfer: fn(
self: *const IPhotoAcquireProgressCB,
hr: HRESULT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
StartDelete: fn(
self: *const IPhotoAcquireProgressCB,
pPhotoAcquireSource: ?*IPhotoAcquireSource,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
StartItemDelete: fn(
self: *const IPhotoAcquireProgressCB,
nItemIndex: u32,
pPhotoAcquireItem: ?*IPhotoAcquireItem,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
UpdateDeletePercent: fn(
self: *const IPhotoAcquireProgressCB,
nPercent: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EndItemDelete: fn(
self: *const IPhotoAcquireProgressCB,
nItemIndex: u32,
pPhotoAcquireItem: ?*IPhotoAcquireItem,
hr: HRESULT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EndDelete: fn(
self: *const IPhotoAcquireProgressCB,
hr: HRESULT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EndSession: fn(
self: *const IPhotoAcquireProgressCB,
hr: HRESULT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetDeleteAfterAcquire: fn(
self: *const IPhotoAcquireProgressCB,
pfDeleteAfterAcquire: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ErrorAdvise: fn(
self: *const IPhotoAcquireProgressCB,
hr: HRESULT,
pszErrorMessage: ?[*:0]const u16,
nMessageType: ERROR_ADVISE_MESSAGE_TYPE,
pnErrorAdviseResult: ?*ERROR_ADVISE_RESULT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetUserInput: fn(
self: *const IPhotoAcquireProgressCB,
riidType: ?*const Guid,
pUnknown: ?*IUnknown,
pPropVarResult: ?*PROPVARIANT,
pPropVarDefault: ?*const PROPVARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireProgressCB_Cancelled(self: *const T, pfCancelled: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireProgressCB.VTable, self.vtable).Cancelled(@ptrCast(*const IPhotoAcquireProgressCB, self), pfCancelled);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireProgressCB_StartEnumeration(self: *const T, pPhotoAcquireSource: ?*IPhotoAcquireSource) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireProgressCB.VTable, self.vtable).StartEnumeration(@ptrCast(*const IPhotoAcquireProgressCB, self), pPhotoAcquireSource);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireProgressCB_FoundItem(self: *const T, pPhotoAcquireItem: ?*IPhotoAcquireItem) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireProgressCB.VTable, self.vtable).FoundItem(@ptrCast(*const IPhotoAcquireProgressCB, self), pPhotoAcquireItem);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireProgressCB_EndEnumeration(self: *const T, hr: HRESULT) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireProgressCB.VTable, self.vtable).EndEnumeration(@ptrCast(*const IPhotoAcquireProgressCB, self), hr);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireProgressCB_StartTransfer(self: *const T, pPhotoAcquireSource: ?*IPhotoAcquireSource) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireProgressCB.VTable, self.vtable).StartTransfer(@ptrCast(*const IPhotoAcquireProgressCB, self), pPhotoAcquireSource);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireProgressCB_StartItemTransfer(self: *const T, nItemIndex: u32, pPhotoAcquireItem: ?*IPhotoAcquireItem) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireProgressCB.VTable, self.vtable).StartItemTransfer(@ptrCast(*const IPhotoAcquireProgressCB, self), nItemIndex, pPhotoAcquireItem);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireProgressCB_DirectoryCreated(self: *const T, pszDirectory: ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireProgressCB.VTable, self.vtable).DirectoryCreated(@ptrCast(*const IPhotoAcquireProgressCB, self), pszDirectory);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireProgressCB_UpdateTransferPercent(self: *const T, fOverall: BOOL, nPercent: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireProgressCB.VTable, self.vtable).UpdateTransferPercent(@ptrCast(*const IPhotoAcquireProgressCB, self), fOverall, nPercent);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireProgressCB_EndItemTransfer(self: *const T, nItemIndex: u32, pPhotoAcquireItem: ?*IPhotoAcquireItem, hr: HRESULT) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireProgressCB.VTable, self.vtable).EndItemTransfer(@ptrCast(*const IPhotoAcquireProgressCB, self), nItemIndex, pPhotoAcquireItem, hr);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireProgressCB_EndTransfer(self: *const T, hr: HRESULT) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireProgressCB.VTable, self.vtable).EndTransfer(@ptrCast(*const IPhotoAcquireProgressCB, self), hr);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireProgressCB_StartDelete(self: *const T, pPhotoAcquireSource: ?*IPhotoAcquireSource) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireProgressCB.VTable, self.vtable).StartDelete(@ptrCast(*const IPhotoAcquireProgressCB, self), pPhotoAcquireSource);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireProgressCB_StartItemDelete(self: *const T, nItemIndex: u32, pPhotoAcquireItem: ?*IPhotoAcquireItem) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireProgressCB.VTable, self.vtable).StartItemDelete(@ptrCast(*const IPhotoAcquireProgressCB, self), nItemIndex, pPhotoAcquireItem);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireProgressCB_UpdateDeletePercent(self: *const T, nPercent: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireProgressCB.VTable, self.vtable).UpdateDeletePercent(@ptrCast(*const IPhotoAcquireProgressCB, self), nPercent);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireProgressCB_EndItemDelete(self: *const T, nItemIndex: u32, pPhotoAcquireItem: ?*IPhotoAcquireItem, hr: HRESULT) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireProgressCB.VTable, self.vtable).EndItemDelete(@ptrCast(*const IPhotoAcquireProgressCB, self), nItemIndex, pPhotoAcquireItem, hr);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireProgressCB_EndDelete(self: *const T, hr: HRESULT) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireProgressCB.VTable, self.vtable).EndDelete(@ptrCast(*const IPhotoAcquireProgressCB, self), hr);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireProgressCB_EndSession(self: *const T, hr: HRESULT) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireProgressCB.VTable, self.vtable).EndSession(@ptrCast(*const IPhotoAcquireProgressCB, self), hr);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireProgressCB_GetDeleteAfterAcquire(self: *const T, pfDeleteAfterAcquire: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireProgressCB.VTable, self.vtable).GetDeleteAfterAcquire(@ptrCast(*const IPhotoAcquireProgressCB, self), pfDeleteAfterAcquire);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireProgressCB_ErrorAdvise(self: *const T, hr: HRESULT, pszErrorMessage: ?[*:0]const u16, nMessageType: ERROR_ADVISE_MESSAGE_TYPE, pnErrorAdviseResult: ?*ERROR_ADVISE_RESULT) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireProgressCB.VTable, self.vtable).ErrorAdvise(@ptrCast(*const IPhotoAcquireProgressCB, self), hr, pszErrorMessage, nMessageType, pnErrorAdviseResult);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireProgressCB_GetUserInput(self: *const T, riidType: ?*const Guid, pUnknown: ?*IUnknown, pPropVarResult: ?*PROPVARIANT, pPropVarDefault: ?*const PROPVARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireProgressCB.VTable, self.vtable).GetUserInput(@ptrCast(*const IPhotoAcquireProgressCB, self), riidType, pUnknown, pPropVarResult, pPropVarDefault);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IPhotoProgressActionCB_Value = @import("../zig.zig").Guid.initString("00f242d0-b206-4e7d-b4c1-4755bcbb9c9f");
pub const IID_IPhotoProgressActionCB = &IID_IPhotoProgressActionCB_Value;
pub const IPhotoProgressActionCB = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
DoAction: fn(
self: *const IPhotoProgressActionCB,
hWndParent: ?HWND,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoProgressActionCB_DoAction(self: *const T, hWndParent: ?HWND) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoProgressActionCB.VTable, self.vtable).DoAction(@ptrCast(*const IPhotoProgressActionCB, self), hWndParent);
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const PROGRESS_DIALOG_IMAGE_TYPE = enum(i32) {
ICON_SMALL = 0,
ICON_LARGE = 1,
ICON_THUMBNAIL = 2,
BITMAP_THUMBNAIL = 3,
};
pub const PROGRESS_DIALOG_ICON_SMALL = PROGRESS_DIALOG_IMAGE_TYPE.ICON_SMALL;
pub const PROGRESS_DIALOG_ICON_LARGE = PROGRESS_DIALOG_IMAGE_TYPE.ICON_LARGE;
pub const PROGRESS_DIALOG_ICON_THUMBNAIL = PROGRESS_DIALOG_IMAGE_TYPE.ICON_THUMBNAIL;
pub const PROGRESS_DIALOG_BITMAP_THUMBNAIL = PROGRESS_DIALOG_IMAGE_TYPE.BITMAP_THUMBNAIL;
pub const PROGRESS_DIALOG_CHECKBOX_ID = enum(i32) {
T = 0,
};
pub const PROGRESS_DIALOG_CHECKBOX_ID_DEFAULT = PROGRESS_DIALOG_CHECKBOX_ID.T;
const IID_IPhotoProgressDialog_Value = @import("../zig.zig").Guid.initString("00f246f9-0750-4f08-9381-2cd8e906a4ae");
pub const IID_IPhotoProgressDialog = &IID_IPhotoProgressDialog_Value;
pub const IPhotoProgressDialog = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
Create: fn(
self: *const IPhotoProgressDialog,
hwndParent: ?HWND,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetWindow: fn(
self: *const IPhotoProgressDialog,
phwndProgressDialog: ?*?HWND,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Destroy: fn(
self: *const IPhotoProgressDialog,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetTitle: fn(
self: *const IPhotoProgressDialog,
pszTitle: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ShowCheckbox: fn(
self: *const IPhotoProgressDialog,
nCheckboxId: PROGRESS_DIALOG_CHECKBOX_ID,
fShow: BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetCheckboxText: fn(
self: *const IPhotoProgressDialog,
nCheckboxId: PROGRESS_DIALOG_CHECKBOX_ID,
pszCheckboxText: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetCheckboxCheck: fn(
self: *const IPhotoProgressDialog,
nCheckboxId: PROGRESS_DIALOG_CHECKBOX_ID,
fChecked: BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetCheckboxTooltip: fn(
self: *const IPhotoProgressDialog,
nCheckboxId: PROGRESS_DIALOG_CHECKBOX_ID,
pszCheckboxTooltipText: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
IsCheckboxChecked: fn(
self: *const IPhotoProgressDialog,
nCheckboxId: PROGRESS_DIALOG_CHECKBOX_ID,
pfChecked: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetCaption: fn(
self: *const IPhotoProgressDialog,
pszTitle: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetImage: fn(
self: *const IPhotoProgressDialog,
nImageType: PROGRESS_DIALOG_IMAGE_TYPE,
hIcon: ?HICON,
hBitmap: ?HBITMAP,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetPercentComplete: fn(
self: *const IPhotoProgressDialog,
nPercent: i32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetProgressText: fn(
self: *const IPhotoProgressDialog,
pszProgressText: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetActionLinkCallback: fn(
self: *const IPhotoProgressDialog,
pPhotoProgressActionCB: ?*IPhotoProgressActionCB,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetActionLinkText: fn(
self: *const IPhotoProgressDialog,
pszCaption: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ShowActionLink: fn(
self: *const IPhotoProgressDialog,
fShow: BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
IsCancelled: fn(
self: *const IPhotoProgressDialog,
pfCancelled: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetUserInput: fn(
self: *const IPhotoProgressDialog,
riidType: ?*const Guid,
pUnknown: ?*IUnknown,
pPropVarResult: ?*PROPVARIANT,
pPropVarDefault: ?*const PROPVARIANT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoProgressDialog_Create(self: *const T, hwndParent: ?HWND) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoProgressDialog.VTable, self.vtable).Create(@ptrCast(*const IPhotoProgressDialog, self), hwndParent);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoProgressDialog_GetWindow(self: *const T, phwndProgressDialog: ?*?HWND) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoProgressDialog.VTable, self.vtable).GetWindow(@ptrCast(*const IPhotoProgressDialog, self), phwndProgressDialog);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoProgressDialog_Destroy(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoProgressDialog.VTable, self.vtable).Destroy(@ptrCast(*const IPhotoProgressDialog, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoProgressDialog_SetTitle(self: *const T, pszTitle: ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoProgressDialog.VTable, self.vtable).SetTitle(@ptrCast(*const IPhotoProgressDialog, self), pszTitle);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoProgressDialog_ShowCheckbox(self: *const T, nCheckboxId: PROGRESS_DIALOG_CHECKBOX_ID, fShow: BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoProgressDialog.VTable, self.vtable).ShowCheckbox(@ptrCast(*const IPhotoProgressDialog, self), nCheckboxId, fShow);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoProgressDialog_SetCheckboxText(self: *const T, nCheckboxId: PROGRESS_DIALOG_CHECKBOX_ID, pszCheckboxText: ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoProgressDialog.VTable, self.vtable).SetCheckboxText(@ptrCast(*const IPhotoProgressDialog, self), nCheckboxId, pszCheckboxText);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoProgressDialog_SetCheckboxCheck(self: *const T, nCheckboxId: PROGRESS_DIALOG_CHECKBOX_ID, fChecked: BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoProgressDialog.VTable, self.vtable).SetCheckboxCheck(@ptrCast(*const IPhotoProgressDialog, self), nCheckboxId, fChecked);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoProgressDialog_SetCheckboxTooltip(self: *const T, nCheckboxId: PROGRESS_DIALOG_CHECKBOX_ID, pszCheckboxTooltipText: ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoProgressDialog.VTable, self.vtable).SetCheckboxTooltip(@ptrCast(*const IPhotoProgressDialog, self), nCheckboxId, pszCheckboxTooltipText);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoProgressDialog_IsCheckboxChecked(self: *const T, nCheckboxId: PROGRESS_DIALOG_CHECKBOX_ID, pfChecked: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoProgressDialog.VTable, self.vtable).IsCheckboxChecked(@ptrCast(*const IPhotoProgressDialog, self), nCheckboxId, pfChecked);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoProgressDialog_SetCaption(self: *const T, pszTitle: ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoProgressDialog.VTable, self.vtable).SetCaption(@ptrCast(*const IPhotoProgressDialog, self), pszTitle);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoProgressDialog_SetImage(self: *const T, nImageType: PROGRESS_DIALOG_IMAGE_TYPE, hIcon: ?HICON, hBitmap: ?HBITMAP) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoProgressDialog.VTable, self.vtable).SetImage(@ptrCast(*const IPhotoProgressDialog, self), nImageType, hIcon, hBitmap);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoProgressDialog_SetPercentComplete(self: *const T, nPercent: i32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoProgressDialog.VTable, self.vtable).SetPercentComplete(@ptrCast(*const IPhotoProgressDialog, self), nPercent);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoProgressDialog_SetProgressText(self: *const T, pszProgressText: ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoProgressDialog.VTable, self.vtable).SetProgressText(@ptrCast(*const IPhotoProgressDialog, self), pszProgressText);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoProgressDialog_SetActionLinkCallback(self: *const T, pPhotoProgressActionCB: ?*IPhotoProgressActionCB) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoProgressDialog.VTable, self.vtable).SetActionLinkCallback(@ptrCast(*const IPhotoProgressDialog, self), pPhotoProgressActionCB);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoProgressDialog_SetActionLinkText(self: *const T, pszCaption: ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoProgressDialog.VTable, self.vtable).SetActionLinkText(@ptrCast(*const IPhotoProgressDialog, self), pszCaption);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoProgressDialog_ShowActionLink(self: *const T, fShow: BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoProgressDialog.VTable, self.vtable).ShowActionLink(@ptrCast(*const IPhotoProgressDialog, self), fShow);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoProgressDialog_IsCancelled(self: *const T, pfCancelled: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoProgressDialog.VTable, self.vtable).IsCancelled(@ptrCast(*const IPhotoProgressDialog, self), pfCancelled);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoProgressDialog_GetUserInput(self: *const T, riidType: ?*const Guid, pUnknown: ?*IUnknown, pPropVarResult: ?*PROPVARIANT, pPropVarDefault: ?*const PROPVARIANT) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoProgressDialog.VTable, self.vtable).GetUserInput(@ptrCast(*const IPhotoProgressDialog, self), riidType, pUnknown, pPropVarResult, pPropVarDefault);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IPhotoAcquireSource_Value = @import("../zig.zig").Guid.initString("00f2c703-8613-4282-a53b-6ec59c5883ac");
pub const IID_IPhotoAcquireSource = &IID_IPhotoAcquireSource_Value;
pub const IPhotoAcquireSource = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
GetFriendlyName: fn(
self: *const IPhotoAcquireSource,
pbstrFriendlyName: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetDeviceIcons: fn(
self: *const IPhotoAcquireSource,
nSize: u32,
phLargeIcon: ?*?HICON,
phSmallIcon: ?*?HICON,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
InitializeItemList: fn(
self: *const IPhotoAcquireSource,
fForceEnumeration: BOOL,
pPhotoAcquireProgressCB: ?*IPhotoAcquireProgressCB,
pnItemCount: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetItemCount: fn(
self: *const IPhotoAcquireSource,
pnItemCount: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetItemAt: fn(
self: *const IPhotoAcquireSource,
nIndex: u32,
ppPhotoAcquireItem: ?*?*IPhotoAcquireItem,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetPhotoAcquireSettings: fn(
self: *const IPhotoAcquireSource,
ppPhotoAcquireSettings: ?*?*IPhotoAcquireSettings,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetDeviceId: fn(
self: *const IPhotoAcquireSource,
pbstrDeviceId: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
BindToObject: fn(
self: *const IPhotoAcquireSource,
riid: ?*const Guid,
ppv: ?*?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireSource_GetFriendlyName(self: *const T, pbstrFriendlyName: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireSource.VTable, self.vtable).GetFriendlyName(@ptrCast(*const IPhotoAcquireSource, self), pbstrFriendlyName);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireSource_GetDeviceIcons(self: *const T, nSize: u32, phLargeIcon: ?*?HICON, phSmallIcon: ?*?HICON) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireSource.VTable, self.vtable).GetDeviceIcons(@ptrCast(*const IPhotoAcquireSource, self), nSize, phLargeIcon, phSmallIcon);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireSource_InitializeItemList(self: *const T, fForceEnumeration: BOOL, pPhotoAcquireProgressCB: ?*IPhotoAcquireProgressCB, pnItemCount: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireSource.VTable, self.vtable).InitializeItemList(@ptrCast(*const IPhotoAcquireSource, self), fForceEnumeration, pPhotoAcquireProgressCB, pnItemCount);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireSource_GetItemCount(self: *const T, pnItemCount: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireSource.VTable, self.vtable).GetItemCount(@ptrCast(*const IPhotoAcquireSource, self), pnItemCount);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireSource_GetItemAt(self: *const T, nIndex: u32, ppPhotoAcquireItem: ?*?*IPhotoAcquireItem) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireSource.VTable, self.vtable).GetItemAt(@ptrCast(*const IPhotoAcquireSource, self), nIndex, ppPhotoAcquireItem);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireSource_GetPhotoAcquireSettings(self: *const T, ppPhotoAcquireSettings: ?*?*IPhotoAcquireSettings) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireSource.VTable, self.vtable).GetPhotoAcquireSettings(@ptrCast(*const IPhotoAcquireSource, self), ppPhotoAcquireSettings);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireSource_GetDeviceId(self: *const T, pbstrDeviceId: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireSource.VTable, self.vtable).GetDeviceId(@ptrCast(*const IPhotoAcquireSource, self), pbstrDeviceId);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireSource_BindToObject(self: *const T, riid: ?*const Guid, ppv: ?*?*anyopaque) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireSource.VTable, self.vtable).BindToObject(@ptrCast(*const IPhotoAcquireSource, self), riid, ppv);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IPhotoAcquire_Value = @import("../zig.zig").Guid.initString("00f23353-e31b-4955-a8ad-ca5ebf31e2ce");
pub const IID_IPhotoAcquire = &IID_IPhotoAcquire_Value;
pub const IPhotoAcquire = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
CreatePhotoSource: fn(
self: *const IPhotoAcquire,
pszDevice: ?[*:0]const u16,
ppPhotoAcquireSource: ?*?*IPhotoAcquireSource,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Acquire: fn(
self: *const IPhotoAcquire,
pPhotoAcquireSource: ?*IPhotoAcquireSource,
fShowProgress: BOOL,
hWndParent: ?HWND,
pszApplicationName: ?[*:0]const u16,
pPhotoAcquireProgressCB: ?*IPhotoAcquireProgressCB,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
EnumResults: fn(
self: *const IPhotoAcquire,
ppEnumFilePaths: ?*?*IEnumString,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquire_CreatePhotoSource(self: *const T, pszDevice: ?[*:0]const u16, ppPhotoAcquireSource: ?*?*IPhotoAcquireSource) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquire.VTable, self.vtable).CreatePhotoSource(@ptrCast(*const IPhotoAcquire, self), pszDevice, ppPhotoAcquireSource);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquire_Acquire(self: *const T, pPhotoAcquireSource: ?*IPhotoAcquireSource, fShowProgress: BOOL, hWndParent: ?HWND, pszApplicationName: ?[*:0]const u16, pPhotoAcquireProgressCB: ?*IPhotoAcquireProgressCB) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquire.VTable, self.vtable).Acquire(@ptrCast(*const IPhotoAcquire, self), pPhotoAcquireSource, fShowProgress, hWndParent, pszApplicationName, pPhotoAcquireProgressCB);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquire_EnumResults(self: *const T, ppEnumFilePaths: ?*?*IEnumString) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquire.VTable, self.vtable).EnumResults(@ptrCast(*const IPhotoAcquire, self), ppEnumFilePaths);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IPhotoAcquireSettings_Value = @import("../zig.zig").Guid.initString("00f2b868-dd67-487c-9553-049240767e91");
pub const IID_IPhotoAcquireSettings = &IID_IPhotoAcquireSettings_Value;
pub const IPhotoAcquireSettings = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
InitializeFromRegistry: fn(
self: *const IPhotoAcquireSettings,
pszRegistryKey: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetFlags: fn(
self: *const IPhotoAcquireSettings,
dwPhotoAcquireFlags: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetOutputFilenameTemplate: fn(
self: *const IPhotoAcquireSettings,
pszTemplate: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetSequencePaddingWidth: fn(
self: *const IPhotoAcquireSettings,
dwWidth: u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetSequenceZeroPadding: fn(
self: *const IPhotoAcquireSettings,
fZeroPad: BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetGroupTag: fn(
self: *const IPhotoAcquireSettings,
pszGroupTag: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetAcquisitionTime: fn(
self: *const IPhotoAcquireSettings,
pftAcquisitionTime: ?*const FILETIME,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetFlags: fn(
self: *const IPhotoAcquireSettings,
pdwPhotoAcquireFlags: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetOutputFilenameTemplate: fn(
self: *const IPhotoAcquireSettings,
pbstrTemplate: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetSequencePaddingWidth: fn(
self: *const IPhotoAcquireSettings,
pdwWidth: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetSequenceZeroPadding: fn(
self: *const IPhotoAcquireSettings,
pfZeroPad: ?*BOOL,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetGroupTag: fn(
self: *const IPhotoAcquireSettings,
pbstrGroupTag: ?*?BSTR,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
GetAcquisitionTime: fn(
self: *const IPhotoAcquireSettings,
pftAcquisitionTime: ?*FILETIME,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireSettings_InitializeFromRegistry(self: *const T, pszRegistryKey: ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireSettings.VTable, self.vtable).InitializeFromRegistry(@ptrCast(*const IPhotoAcquireSettings, self), pszRegistryKey);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireSettings_SetFlags(self: *const T, dwPhotoAcquireFlags: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireSettings.VTable, self.vtable).SetFlags(@ptrCast(*const IPhotoAcquireSettings, self), dwPhotoAcquireFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireSettings_SetOutputFilenameTemplate(self: *const T, pszTemplate: ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireSettings.VTable, self.vtable).SetOutputFilenameTemplate(@ptrCast(*const IPhotoAcquireSettings, self), pszTemplate);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireSettings_SetSequencePaddingWidth(self: *const T, dwWidth: u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireSettings.VTable, self.vtable).SetSequencePaddingWidth(@ptrCast(*const IPhotoAcquireSettings, self), dwWidth);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireSettings_SetSequenceZeroPadding(self: *const T, fZeroPad: BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireSettings.VTable, self.vtable).SetSequenceZeroPadding(@ptrCast(*const IPhotoAcquireSettings, self), fZeroPad);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireSettings_SetGroupTag(self: *const T, pszGroupTag: ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireSettings.VTable, self.vtable).SetGroupTag(@ptrCast(*const IPhotoAcquireSettings, self), pszGroupTag);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireSettings_SetAcquisitionTime(self: *const T, pftAcquisitionTime: ?*const FILETIME) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireSettings.VTable, self.vtable).SetAcquisitionTime(@ptrCast(*const IPhotoAcquireSettings, self), pftAcquisitionTime);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireSettings_GetFlags(self: *const T, pdwPhotoAcquireFlags: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireSettings.VTable, self.vtable).GetFlags(@ptrCast(*const IPhotoAcquireSettings, self), pdwPhotoAcquireFlags);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireSettings_GetOutputFilenameTemplate(self: *const T, pbstrTemplate: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireSettings.VTable, self.vtable).GetOutputFilenameTemplate(@ptrCast(*const IPhotoAcquireSettings, self), pbstrTemplate);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireSettings_GetSequencePaddingWidth(self: *const T, pdwWidth: ?*u32) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireSettings.VTable, self.vtable).GetSequencePaddingWidth(@ptrCast(*const IPhotoAcquireSettings, self), pdwWidth);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireSettings_GetSequenceZeroPadding(self: *const T, pfZeroPad: ?*BOOL) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireSettings.VTable, self.vtable).GetSequenceZeroPadding(@ptrCast(*const IPhotoAcquireSettings, self), pfZeroPad);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireSettings_GetGroupTag(self: *const T, pbstrGroupTag: ?*?BSTR) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireSettings.VTable, self.vtable).GetGroupTag(@ptrCast(*const IPhotoAcquireSettings, self), pbstrGroupTag);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireSettings_GetAcquisitionTime(self: *const T, pftAcquisitionTime: ?*FILETIME) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireSettings.VTable, self.vtable).GetAcquisitionTime(@ptrCast(*const IPhotoAcquireSettings, self), pftAcquisitionTime);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IPhotoAcquireOptionsDialog_Value = @import("../zig.zig").Guid.initString("00f2b3ee-bf64-47ee-89f4-4dedd79643f2");
pub const IID_IPhotoAcquireOptionsDialog = &IID_IPhotoAcquireOptionsDialog_Value;
pub const IPhotoAcquireOptionsDialog = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
Initialize: fn(
self: *const IPhotoAcquireOptionsDialog,
pszRegistryRoot: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Create: fn(
self: *const IPhotoAcquireOptionsDialog,
hWndParent: ?HWND,
phWndDialog: ?*?HWND,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
Destroy: fn(
self: *const IPhotoAcquireOptionsDialog,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
DoModal: fn(
self: *const IPhotoAcquireOptionsDialog,
hWndParent: ?HWND,
ppnReturnCode: ?*isize,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SaveData: fn(
self: *const IPhotoAcquireOptionsDialog,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireOptionsDialog_Initialize(self: *const T, pszRegistryRoot: ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireOptionsDialog.VTable, self.vtable).Initialize(@ptrCast(*const IPhotoAcquireOptionsDialog, self), pszRegistryRoot);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireOptionsDialog_Create(self: *const T, hWndParent: ?HWND, phWndDialog: ?*?HWND) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireOptionsDialog.VTable, self.vtable).Create(@ptrCast(*const IPhotoAcquireOptionsDialog, self), hWndParent, phWndDialog);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireOptionsDialog_Destroy(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireOptionsDialog.VTable, self.vtable).Destroy(@ptrCast(*const IPhotoAcquireOptionsDialog, self));
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireOptionsDialog_DoModal(self: *const T, hWndParent: ?HWND, ppnReturnCode: ?*isize) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireOptionsDialog.VTable, self.vtable).DoModal(@ptrCast(*const IPhotoAcquireOptionsDialog, self), hWndParent, ppnReturnCode);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireOptionsDialog_SaveData(self: *const T) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireOptionsDialog.VTable, self.vtable).SaveData(@ptrCast(*const IPhotoAcquireOptionsDialog, self));
}
};}
pub usingnamespace MethodMixin(@This());
};
pub const DEVICE_SELECTION_DEVICE_TYPE = enum(i32) {
T_UNKNOWN_DEVICE = 0,
T_WPD_DEVICE = 1,
T_WIA_DEVICE = 2,
T_STI_DEVICE = 3,
F_TWAIN_DEVICE = 4,
T_FS_DEVICE = 5,
T_DV_DEVICE = 6,
};
pub const DST_UNKNOWN_DEVICE = DEVICE_SELECTION_DEVICE_TYPE.T_UNKNOWN_DEVICE;
pub const DST_WPD_DEVICE = DEVICE_SELECTION_DEVICE_TYPE.T_WPD_DEVICE;
pub const DST_WIA_DEVICE = DEVICE_SELECTION_DEVICE_TYPE.T_WIA_DEVICE;
pub const DST_STI_DEVICE = DEVICE_SELECTION_DEVICE_TYPE.T_STI_DEVICE;
pub const DSF_TWAIN_DEVICE = DEVICE_SELECTION_DEVICE_TYPE.F_TWAIN_DEVICE;
pub const DST_FS_DEVICE = DEVICE_SELECTION_DEVICE_TYPE.T_FS_DEVICE;
pub const DST_DV_DEVICE = DEVICE_SELECTION_DEVICE_TYPE.T_DV_DEVICE;
const IID_IPhotoAcquireDeviceSelectionDialog_Value = @import("../zig.zig").Guid.initString("00f28837-55dd-4f37-aaf5-6855a9640467");
pub const IID_IPhotoAcquireDeviceSelectionDialog = &IID_IPhotoAcquireDeviceSelectionDialog_Value;
pub const IPhotoAcquireDeviceSelectionDialog = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
SetTitle: fn(
self: *const IPhotoAcquireDeviceSelectionDialog,
pszTitle: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
SetSubmitButtonText: fn(
self: *const IPhotoAcquireDeviceSelectionDialog,
pszSubmitButtonText: ?[*:0]const u16,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
DoModal: fn(
self: *const IPhotoAcquireDeviceSelectionDialog,
hWndParent: ?HWND,
dwDeviceFlags: u32,
pbstrDeviceId: ?*?BSTR,
pnDeviceType: ?*DEVICE_SELECTION_DEVICE_TYPE,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireDeviceSelectionDialog_SetTitle(self: *const T, pszTitle: ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireDeviceSelectionDialog.VTable, self.vtable).SetTitle(@ptrCast(*const IPhotoAcquireDeviceSelectionDialog, self), pszTitle);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireDeviceSelectionDialog_SetSubmitButtonText(self: *const T, pszSubmitButtonText: ?[*:0]const u16) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireDeviceSelectionDialog.VTable, self.vtable).SetSubmitButtonText(@ptrCast(*const IPhotoAcquireDeviceSelectionDialog, self), pszSubmitButtonText);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquireDeviceSelectionDialog_DoModal(self: *const T, hWndParent: ?HWND, dwDeviceFlags: u32, pbstrDeviceId: ?*?BSTR, pnDeviceType: ?*DEVICE_SELECTION_DEVICE_TYPE) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquireDeviceSelectionDialog.VTable, self.vtable).DoModal(@ptrCast(*const IPhotoAcquireDeviceSelectionDialog, self), hWndParent, dwDeviceFlags, pbstrDeviceId, pnDeviceType);
}
};}
pub usingnamespace MethodMixin(@This());
};
const IID_IPhotoAcquirePlugin_Value = @import("../zig.zig").Guid.initString("00f2dceb-ecb8-4f77-8e47-e7a987c83dd0");
pub const IID_IPhotoAcquirePlugin = &IID_IPhotoAcquirePlugin_Value;
pub const IPhotoAcquirePlugin = extern struct {
pub const VTable = extern struct {
base: IUnknown.VTable,
Initialize: fn(
self: *const IPhotoAcquirePlugin,
pPhotoAcquireSource: ?*IPhotoAcquireSource,
pPhotoAcquireProgressCB: ?*IPhotoAcquireProgressCB,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
ProcessItem: fn(
self: *const IPhotoAcquirePlugin,
dwAcquireStage: u32,
pPhotoAcquireItem: ?*IPhotoAcquireItem,
pOriginalItemStream: ?*IStream,
pszFinalFilename: ?[*:0]const u16,
pPropertyStore: ?*IPropertyStore,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
TransferComplete: fn(
self: *const IPhotoAcquirePlugin,
hr: HRESULT,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
DisplayConfigureDialog: fn(
self: *const IPhotoAcquirePlugin,
hWndParent: ?HWND,
) callconv(@import("std").os.windows.WINAPI) HRESULT,
};
vtable: *const VTable,
pub fn MethodMixin(comptime T: type) type { return struct {
pub usingnamespace IUnknown.MethodMixin(T);
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquirePlugin_Initialize(self: *const T, pPhotoAcquireSource: ?*IPhotoAcquireSource, pPhotoAcquireProgressCB: ?*IPhotoAcquireProgressCB) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquirePlugin.VTable, self.vtable).Initialize(@ptrCast(*const IPhotoAcquirePlugin, self), pPhotoAcquireSource, pPhotoAcquireProgressCB);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquirePlugin_ProcessItem(self: *const T, dwAcquireStage: u32, pPhotoAcquireItem: ?*IPhotoAcquireItem, pOriginalItemStream: ?*IStream, pszFinalFilename: ?[*:0]const u16, pPropertyStore: ?*IPropertyStore) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquirePlugin.VTable, self.vtable).ProcessItem(@ptrCast(*const IPhotoAcquirePlugin, self), dwAcquireStage, pPhotoAcquireItem, pOriginalItemStream, pszFinalFilename, pPropertyStore);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquirePlugin_TransferComplete(self: *const T, hr: HRESULT) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquirePlugin.VTable, self.vtable).TransferComplete(@ptrCast(*const IPhotoAcquirePlugin, self), hr);
}
// NOTE: method is namespaced with interface name to avoid conflicts for now
pub fn IPhotoAcquirePlugin_DisplayConfigureDialog(self: *const T, hWndParent: ?HWND) callconv(.Inline) HRESULT {
return @ptrCast(*const IPhotoAcquirePlugin.VTable, self.vtable).DisplayConfigureDialog(@ptrCast(*const IPhotoAcquirePlugin, self), hWndParent);
}
};}
pub usingnamespace MethodMixin(@This());
};
//--------------------------------------------------------------------------------
// Section: Functions (0)
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
// Section: Unicode Aliases (0)
//--------------------------------------------------------------------------------
const thismodule = @This();
pub usingnamespace switch (@import("../zig.zig").unicode_mode) {
.ansi => struct {
},
.wide => struct {
},
.unspecified => if (@import("builtin").is_test) struct {
} else struct {
},
};
//--------------------------------------------------------------------------------
// Section: Imports (16)
//--------------------------------------------------------------------------------
const Guid = @import("../zig.zig").Guid;
const BOOL = @import("../foundation.zig").BOOL;
const BSTR = @import("../foundation.zig").BSTR;
const FILETIME = @import("../foundation.zig").FILETIME;
const HBITMAP = @import("../graphics/gdi.zig").HBITMAP;
const HICON = @import("../ui/windows_and_messaging.zig").HICON;
const HRESULT = @import("../foundation.zig").HRESULT;
const HWND = @import("../foundation.zig").HWND;
const IEnumString = @import("../system/com.zig").IEnumString;
const IPropertyStore = @import("../ui/shell/properties_system.zig").IPropertyStore;
const IStream = @import("../system/com.zig").IStream;
const IUnknown = @import("../system/com.zig").IUnknown;
const PROPERTYKEY = @import("../ui/shell/properties_system.zig").PROPERTYKEY;
const PROPVARIANT = @import("../system/com/structured_storage.zig").PROPVARIANT;
const PWSTR = @import("../foundation.zig").PWSTR;
const SIZE = @import("../foundation.zig").SIZE;
test {
@setEvalBranchQuota(
@import("std").meta.declarations(@This()).len * 3
);
// reference all the pub declarations
if (!@import("builtin").is_test) return;
inline for (@import("std").meta.declarations(@This())) |decl| {
if (decl.is_pub) {
_ = decl;
}
}
} | win32/media/picture_acquisition.zig |
const std = @import("std");
const game = @import("game.zig");
const GameState = game.GameState;
const PurchasableCard = game.PurchasableCard;
const alwaysRollTwo = false; // Default: false
const alwaysActivateHarbor = false; // Default: false
const forceBuyLandmarks = false; // Default: false
pub fn shouldRollTwoDice(state: *GameState) bool {
if (alwaysRollTwo) {
return true;
}
return state.rng.random.uintAtMost(u32, 1) == 1;
}
pub fn shouldActivateHarbor(state: *GameState) bool {
if (alwaysActivateHarbor) {
return true;
}
return state.rng.random.uintAtMost(u32, 1) == 1;
}
pub fn shouldReroll(state: *GameState) bool {
return state.rng.random.uintAtMost(u32, 1) == 1;
}
pub fn getPlayerToStealCoinsFrom(state: *GameState, coinsToSteal: u32) usize {
while (true) {
const victimPid = state.rng.random.uintAtMost(u32, state.players.len - 1);
if (victimPid != state.currentPlayerIndex) return victimPid;
}
}
pub fn getCardToPurchase(state: *GameState) ?PurchasableCard {
var allOptions = std.ArrayList(PurchasableCard).init(state.alloc);
allOptions.ensureCapacity(@memberCount(game.EstablishmentType) + @memberCount(game.Landmark)) catch |err| {
std.debug.warn("Failed to allocate memory for purchasing options\n");
return null;
};
var canPurchaseLandmark = false;
const player = &state.players[state.currentPlayerIndex];
for (player.landmarks) |landmarkBuilt, landmarkIndex| {
if (!landmarkBuilt) {
const landmarkCost = switch (landmarkIndex) {
0 => 2,
1 => 4,
2 => 10,
3 => 16,
4 => 22,
5 => @intCast(i32, 30), // TODO: Compiler bug. If everything is comptime_int it doesn't resolve to i32 and the compiler complains
else => std.debug.panic("Unexpected landmark {}", landmarkIndex),
};
if (landmarkCost <= player.coins) {
const purchase = PurchasableCard{
.type = game.CardType.Landmark,
.index = landmarkIndex,
};
allOptions.appendAssumeCapacity(purchase);
canPurchaseLandmark = true;
}
}
}
if (forceBuyLandmarks and canPurchaseLandmark and (state.currentTurn > 10 * state.players.len)) {
// Force purchase a landmark
const resultIndex = state.rng.random.uintAtMost(usize, allOptions.count() - 1);
return allOptions.at(resultIndex);
}
for (game.allEstablishments) |est, i| {
if (state.establishmentPurchasePiles[i] <= 0) continue;
if (est.cost > player.coins) continue;
if (est.icon == game.CardIcon.Tower) {
var estOwned = false;
for (player.establishmentsYourTurn.toSliceConst()) |e| {
if (e.type == est.type) {
estOwned = true;
break;
}
}
if (estOwned) continue;
}
const purchase = PurchasableCard{
.type = game.CardType.Establishment,
.index = i,
};
allOptions.appendAssumeCapacity(purchase);
}
if (allOptions.count() == 0) return null;
const resultIndex = state.rng.random.uintAtMost(usize, allOptions.count() - 1);
return allOptions.at(resultIndex);
} | src/bot_random.zig |
const std = @import("std");
const meta = std.meta;
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const testing = std.testing;
/// All supported message types by the client
/// any others will be skipped
pub const Message = union(enum(u8)) {
/// Whether or not the remote peer has choked this client.
choke,
/// The remote peer has unchoked the client.
unchoke,
/// Notifies the peer we are interested in more data.
interested,
/// Notifies the peer we are no longer interested in data.
not_interested,
/// Contains the index of a piece the peer has.
have: u32,
/// Only sent in the very first message. Sent to peer
/// to tell which pieces have already been download.
/// This is used to resume a download from a later point.
bitfield: []u8,
/// Tells the peer the index, begin and length of the data we are requesting.
request: Data,
/// Tells the peer the index, begin and piece which the client wants to receive.
piece: struct {
index: u32,
begin: u32,
block: Block,
},
/// Used to notify all-but-one peer to cancel data requests as the last piece is being received.
cancel: Data,
/// Message types
pub const Tag = meta.Tag(Message);
/// `Block` is a slice of data, and is a subset of `Piece`.
pub const Block = []const u8;
/// `Data` specifies the index of the piece, the byte-offset within the piece
/// and the length of the data to be requested/cancelled
pub const Data = struct {
index: u32,
begin: u32,
length: u32,
};
pub const DeserializeError = error{
/// Peer has closed the connection
EndOfStream,
/// Peer has sent an unsupported message type
/// such as notifying us of udp support.
Unsupported,
/// Machine is out of memory and no memory can be allocated
/// on the heap.
OutOfMemory,
};
fn toInt(self: Message) u8 {
return @enumToInt(self);
}
/// Returns the serialization length of the given `Message`
fn serializeLen(self: Message) u32 {
return switch (self) {
.choke,
.unchoke,
.interested,
.not_interested,
=> 0,
.have => 4,
.bitfield => |payload| @intCast(u32, payload.len),
.request, .cancel => 12,
.piece => |piece| 12 + @intCast(u32, piece.block.len),
};
}
/// Deinitializes the given `Message`.
/// The `Allocator` is only needed for messages that have a variable size such as `Message.piece`.
/// All other messages are a no-op.
pub fn deinit(self: *Message, gpa: *Allocator) void {
switch (self.*) {
.piece => |piece| gpa.free(piece.block),
else => {},
}
self.* = undefined;
}
/// Deserializes the current data into a `Message`. Uses the given `Allocator` when
/// the payload is dynamic. All other messages will use a fixed-size buffer for speed.
/// Returns `DeserializeError.Unsupported` when it tries to deserialize a message type that is
/// not supported by the library yet.
/// Returns `null` when peer has sent keep-alive
pub fn deserialize(gpa: *Allocator, reader: anytype) (DeserializeError || @TypeOf(reader).Error)!?Message {
const length = try reader.readIntBig(u32);
if (length == 0) return null;
const type_byte = try reader.readByte();
const message_type = meta.intToEnum(Tag, type_byte) catch {
// we must still read the bytes to ensure it does not mess up new messages
try reader.skipBytes(length - 1, .{});
return error.Unsupported;
};
return switch (message_type) {
.choke => Message.choke,
.unchoke => Message.unchoke,
.interested => Message.interested,
.not_interested => Message.not_interested,
.have => try deserializeHave(reader),
.bitfield => try deserializeBitfield(gpa, length - 1, reader),
.request, .cancel => |tag| try deserializeData(tag, reader),
.piece => try deserializePiece(gpa, length - 9, reader),
};
}
/// Serializes the given `Message` and writes it to the given `writer`
pub fn serialize(self: Message, writer: anytype) @TypeOf(writer).Error!void {
const len = self.serializeLen() + 1; // 1 for the message type
try writer.writeIntBig(u32, len);
try writer.writeByte(self.toInt());
switch (self) {
.choke,
.unchoke,
.interested,
.not_interested,
=> {},
.have => |index| try writer.writeIntBig(u32, index),
.bitfield => |payload| try writer.writeAll(payload),
.request, .cancel => |data| {
try writer.writeIntBig(u32, data.index);
try writer.writeIntBig(u32, data.begin);
try writer.writeIntBig(u32, data.length);
},
.piece => |piece| {
try writer.writeIntBig(u32, piece.index);
try writer.writeIntBig(u32, piece.begin);
try writer.writeAll(piece.block);
},
}
}
/// Deserializes the given `reader` into a `Message.have`
fn deserializeHave(reader: anytype) (DeserializeError || @TypeOf(reader).Error)!Message {
return Message{ .have = try reader.readIntBig(u32) };
}
/// Deserializes the given `reader` into a `Message.bitfield`
/// As the length of the bitfield payload is variable, it requires an allocator
fn deserializeBitfield(gpa: *Allocator, length: u32, reader: anytype) (DeserializeError || @TypeOf(reader).Error)!Message {
const bitfield = try gpa.alloc(u8, length);
try reader.readNoEof(bitfield);
return Message{ .bitfield = bitfield };
}
/// Deserializes a fixed-length payload into a `Message.Request`
fn deserializeData(tag: Tag, reader: anytype) (DeserializeError || @TypeOf(reader).Error)!Message {
const data: Data = .{
.index = try reader.readIntBig(u32),
.begin = try reader.readIntBig(u32),
.length = try reader.readIntBig(u32),
};
return switch (tag) {
.request => Message{ .request = data },
.cancel => Message{ .cancel = data },
else => unreachable,
};
}
/// Deserializes the current reader into `Message.piece`.
/// As the length of the payload is variable, it accepts a length and `Allocator`.
/// Note that it blocks on reading the payload until all is read.
fn deserializePiece(gpa: *Allocator, length: u32, reader: anytype) (DeserializeError || @TypeOf(reader).Error)!Message {
const block = try gpa.alloc(u8, length);
const index = try reader.readIntBig(u32);
const begin = try reader.readIntBig(u32);
try reader.readNoEof(block);
return Message{ .piece = .{
.index = index,
.begin = begin,
.block = block,
} };
}
};
fn serializeTest(message: Message, expected_len: usize) !void {
var list = std.ArrayList(u8).init(testing.allocator);
defer list.deinit();
try message.serialize(list.writer());
testing.expectEqual(expected_len, list.items.len);
}
test "Message serialization length" {
const test_cases = .{
.{ .message = Message.choke, .expected_len = 5 },
.{ .message = Message.unchoke, .expected_len = 5 },
.{ .message = Message.interested, .expected_len = 5 },
.{ .message = Message.not_interested, .expected_len = 5 },
.{ .message = Message{ .have = 2 }, .expected_len = 9 },
.{ .message = Message{ .request = .{ .index = 0, .begin = 0, .length = 0 } }, .expected_len = 17 },
.{ .message = Message{ .cancel = .{ .index = 0, .begin = 0, .length = 0 } }, .expected_len = 17 },
};
inline for (test_cases) |case| {
try serializeTest(case.message, case.expected_len);
}
}
test "Message (de)serialization" {
const test_cases: []const Message = &.{
.choke,
.unchoke,
.interested,
.not_interested,
.{ .have = 2 },
.{ .request = .{ .index = 1, .begin = 5, .length = 8 } },
.{ .cancel = .{ .index = 2, .begin = 3, .length = 5 } },
};
for (test_cases) |case| {
var list = std.ArrayList(u8).init(testing.allocator);
defer list.deinit();
try case.serialize(list.writer());
var out = std.io.fixedBufferStream(list.items);
var result = (try Message.deserialize(testing.allocator, out.reader())).?;
defer result.deinit(testing.allocator);
testing.expectEqual(case.toInt(), result.toInt());
}
} | src/net/message.zig |
const std = @import("std");
const testing = std.testing;
const Handshake = @This();
hash: [20]u8,
peer_id: [20]u8,
const p_str = "BitTorrent protocol";
const p_strlen = @intCast(u8, p_str.len);
/// Serializes a Handshake object into binary data and writes the result to the writer
pub fn serialize(self: Handshake, writer: anytype) @TypeOf(writer).Error!void {
// we first copy everything into a buffer to avoid syscalls as
// the length of the buffer is fixed-length
var buffer: [p_strlen + 49]u8 = undefined;
buffer[0] = p_strlen;
std.mem.copy(u8, buffer[1..], p_str);
const index = p_strlen + 8 + 1; // 8 reserved bytes
std.mem.copy(u8, buffer[index..], &self.hash);
std.mem.copy(u8, buffer[index + 20 ..], &self.peer_id);
try writer.writeAll(&buffer);
}
pub const DeserializeError = error{
/// Connection was closed by peer
EndOfStream,
/// Peer's p_strlen is invalid
BadHandshake,
};
/// Deserializes from an `io.Reader` and parses the binary data into a `Handshake`
pub fn deserialize(
reader: anytype,
) (DeserializeError || @TypeOf(reader).Error)!Handshake {
var buffer: [p_strlen + 49]u8 = undefined;
try reader.readNoEof(&buffer);
const length = std.mem.readIntBig(u8, &buffer[0]);
if (length != 19) return error.BadHandshake; // Peer's p_strlen is invalid
return Handshake{
.hash = buffer[length + 9 ..][0..20].*,
.peer_id = buffer[length + 29 ..][0..20].*,
};
}
test "Serialize handshake" {
var hash = [_]u8{0} ** 20;
var peer_id = [_]u8{0} ** 20;
const hs: Handshake = .{
.hash = hash,
.peer_id = peer_id,
};
var list = std.ArrayList(u8).init(testing.allocator);
defer list.deinit();
try hs.serialize(list.writer());
testing.expect(list.items.len == 68);
}
test "Deserialize handshake" {
var hash = [_]u8{'a'} ** 20;
var peer_id = [_]u8{'a'} ** 20;
const hand_shake: Handshake = .{
.hash = hash,
.peer_id = peer_id,
};
var list = std.ArrayList(u8).init(testing.allocator);
defer list.deinit();
try hand_shake.serialize(list.writer());
const reader = std.io.fixedBufferStream(list.items).reader();
const result = try Handshake.deserialize(reader);
testing.expectEqualSlices(u8, "BitTorrent protocol", p_str);
testing.expectEqualSlices(u8, &hand_shake.hash, &result.hash);
testing.expectEqualSlices(u8, &hand_shake.peer_id, &result.peer_id);
} | src/net/Handshake.zig |
const std = @import("std");
const assert = std.debug.assert;
const crypto = std.crypto;
const mem = std.mem;
const rotl = std.math.rotl;
const AesBlock = std.crypto.core.aes.Block;
const AuthenticationError = std.crypto.errors.AuthenticationError;
const Lane = @Vector(4, u64);
pub const Morus = struct {
pub const tag_length = 16;
pub const nonce_length = 16;
pub const key_length = 16;
const State = [5]Lane;
s: State,
fn update(self: *Morus, input: Lane) void {
const s = &self.s;
s[0] ^= s[3] ^ (s[1] & s[2]);
s[0] = rotl(Lane, s[0], 13);
var t = Lane{ s[3][3], s[3][0], s[3][1], s[3][2] };
s[3] = t;
s[1] ^= input ^ s[4] ^ (s[2] & s[3]);
s[1] = rotl(Lane, s[1], 46);
t = Lane{ s[4][2], s[4][3], s[4][0], s[4][1] };
s[4] = t;
s[2] ^= input ^ s[0] ^ (s[3] & s[4]);
s[2] = rotl(Lane, s[2], 38);
t = Lane{ s[0][1], s[0][2], s[0][3], s[0][0] };
s[0] = t;
s[3] ^= input ^ s[1] ^ (s[4] & s[0]);
s[3] = rotl(Lane, s[3], 7);
t = Lane{ s[1][2], s[1][3], s[1][0], s[1][1] };
s[1] = t;
s[4] ^= input ^ s[2] ^ (s[0] & s[1]);
s[4] = rotl(Lane, s[4], 4);
t = Lane{ s[2][3], s[2][0], s[2][1], s[2][2] };
s[2] = t;
}
fn init(k: [16]u8, iv: [16]u8) Morus {
const c = [_]u8{
0x0, 0x1, 0x01, 0x02, 0x03, 0x05, 0x08, 0x0d, 0x15, 0x22, 0x37, 0x59, 0x90, 0xe9,
0x79, 0x62, 0xdb, 0x3d, 0x18, 0x55, 0x6d, 0xc2, 0x2f, 0xf1, 0x20, 0x11, 0x31, 0x42,
0x73, 0xb5, 0x28, 0xdd,
};
const k0 = mem.readIntLittle(u64, k[0..8]);
const k1 = mem.readIntLittle(u64, k[8..16]);
const iv0 = mem.readIntLittle(u64, iv[0..8]);
const iv1 = mem.readIntLittle(u64, iv[8..16]);
const v0 = Lane{ iv0, iv1, 0, 0 };
const v1 = Lane{ k0, k1, k0, k1 };
const v2 = @splat(4, ~@as(u64, 0));
const v3 = @splat(4, @as(u64, 0));
const v4 = Lane{
mem.readIntLittle(u64, c[0..8]),
mem.readIntLittle(u64, c[8..16]),
mem.readIntLittle(u64, c[16..24]),
mem.readIntLittle(u64, c[24..32]),
};
var self = Morus{ .s = State{ v0, v1, v2, v3, v4 } };
var i: usize = 0;
const zero = @splat(4, @as(u64, 0));
while (i < 16) : (i += 1) {
self.update(zero);
}
self.s[1] ^= v1;
return self;
}
fn enc(self: *Morus, xi: *const [32]u8) [32]u8 {
const p = Lane{
mem.readIntLittle(u64, xi[0..8]),
mem.readIntLittle(u64, xi[8..16]),
mem.readIntLittle(u64, xi[16..24]),
mem.readIntLittle(u64, xi[24..32]),
};
const s = self.s;
const c = p ^ s[0] ^ Lane{ s[1][1], s[1][2], s[1][3], s[1][0] } ^ (s[2] & s[3]);
var ci: [32]u8 = undefined;
mem.writeIntLittle(u64, ci[0..8], c[0]);
mem.writeIntLittle(u64, ci[8..16], c[1]);
mem.writeIntLittle(u64, ci[16..24], c[2]);
mem.writeIntLittle(u64, ci[24..32], c[3]);
self.update(p);
return ci;
}
fn dec(self: *Morus, ci: *const [32]u8) [32]u8 {
const c = Lane{
mem.readIntLittle(u64, ci[0..8]),
mem.readIntLittle(u64, ci[8..16]),
mem.readIntLittle(u64, ci[16..24]),
mem.readIntLittle(u64, ci[24..32]),
};
const s = self.s;
const p = c ^ s[0] ^ Lane{ s[1][1], s[1][2], s[1][3], s[1][0] } ^ (s[2] & s[3]);
var xi: [32]u8 = undefined;
mem.writeIntLittle(u64, xi[0..8], p[0]);
mem.writeIntLittle(u64, xi[8..16], p[1]);
mem.writeIntLittle(u64, xi[16..24], p[2]);
mem.writeIntLittle(u64, xi[24..32], p[3]);
self.update(p);
return xi;
}
fn decPartial(self: *Morus, xn: []u8, cn: []const u8) void {
var pad = [_]u8{0} ** 32;
mem.copy(u8, pad[0..cn.len], cn);
const c = Lane{
mem.readIntLittle(u64, pad[0..8]),
mem.readIntLittle(u64, pad[8..16]),
mem.readIntLittle(u64, pad[16..24]),
mem.readIntLittle(u64, pad[24..32]),
};
const s = self.s;
var p = c ^ s[0] ^ Lane{ s[1][1], s[1][2], s[1][3], s[1][0] } ^ (s[2] & s[3]);
mem.writeIntLittle(u64, pad[0..8], p[0]);
mem.writeIntLittle(u64, pad[8..16], p[1]);
mem.writeIntLittle(u64, pad[16..24], p[2]);
mem.writeIntLittle(u64, pad[24..32], p[3]);
mem.set(u8, pad[cn.len..], 0);
mem.copy(u8, xn, pad[0..cn.len]);
p = Lane{
mem.readIntLittle(u64, pad[0..8]),
mem.readIntLittle(u64, pad[8..16]),
mem.readIntLittle(u64, pad[16..24]),
mem.readIntLittle(u64, pad[24..32]),
};
self.update(p);
}
fn finalize(self: *Morus, adlen: usize, mlen: usize) [16]u8 {
const t = [4]u64{ @intCast(u64, adlen) * 8, @intCast(u64, mlen) * 8, 0, 0 };
var s = &self.s;
s[4] ^= s[0];
var i: usize = 0;
while (i < 10) : (i += 1) {
self.update(t);
}
s = &self.s;
s[0] ^= Lane{ s[1][1], s[1][2], s[1][3], s[1][0] } ^ (s[2] & s[3]);
var tag: [16]u8 = undefined;
mem.writeIntLittle(u64, tag[0..8], s[0][0]);
mem.writeIntLittle(u64, tag[8..16], s[0][1]);
return tag;
}
pub fn encrypt(c: []u8, tag: *[tag_length]u8, m: []const u8, ad: []const u8, iv: [nonce_length]u8, k: [key_length]u8) void {
assert(c.len == m.len);
var morus = init(k, iv);
var i: usize = 0;
while (i + 32 <= ad.len) : (i += 32) {
_ = morus.enc(ad[i..][0..32]);
}
if (ad.len % 32 != 0) {
var pad = [_]u8{0} ** 32;
mem.copy(u8, pad[0 .. ad.len % 32], ad[i..]);
_ = morus.enc(&pad);
}
i = 0;
while (i + 32 <= m.len) : (i += 32) {
mem.copy(u8, c[i..][0..32], &morus.enc(m[i..][0..32]));
}
if (m.len % 32 != 0) {
var pad = [_]u8{0} ** 32;
mem.copy(u8, pad[0 .. m.len % 32], m[i..]);
mem.copy(u8, c[i..], morus.enc(&pad)[0 .. m.len % 32]);
}
tag.* = morus.finalize(ad.len, m.len);
}
pub fn decrypt(m: []u8, c: []const u8, tag: [tag_length]u8, ad: []const u8, iv: [nonce_length]u8, k: [key_length]u8) AuthenticationError!void {
assert(c.len == m.len);
var morus = init(k, iv);
var i: usize = 0;
while (i + 32 <= ad.len) : (i += 32) {
_ = morus.enc(ad[i..][0..32]);
}
if (ad.len % 32 != 0) {
var pad = [_]u8{0} ** 32;
mem.copy(u8, pad[0 .. ad.len % 32], ad[i..]);
_ = morus.enc(&pad);
}
i = 0;
while (i + 32 <= c.len) : (i += 32) {
mem.copy(u8, m[i..][0..32], &morus.dec(c[i..][0..32]));
}
if (c.len % 32 != 0) {
morus.decPartial(m[i..], c[i..]);
}
const expected_tag = morus.finalize(ad.len, m.len);
if (!crypto.utils.timingSafeEql([expected_tag.len]u8, expected_tag, tag)) {
return error.AuthenticationFailed;
}
}
};
const testing = std.testing;
const fmt = std.fmt;
test "morus" {
const k = "YELLOW SUBMARINE".*;
const iv = [_]u8{0} ** 16;
const ad = "Comment numero un";
var m = "Ladies and Gentlemen of the class of '99: If I could offer you only one tip for the future, sunscreen would be it.";
var c: [m.len]u8 = undefined;
var m2: [m.len]u8 = undefined;
var expected_tag: [Morus.tag_length]u8 = undefined;
_ = try fmt.hexToBytes(&expected_tag, "fe0bf3ea600b0355eb535ddd35320e1b");
var expected_c: [m.len]u8 = undefined;
_ = try fmt.hexToBytes(&expected_c, "712ae984433ceea0448a6a4f35afd46b42f42d69316e42aa54264dfd8951293b6ed676c9a813e7f42745e6210de9c82c4ac67fde57695c2d1e1f2f302682f118c6895915de8fa63de1bb798c7a178ce3290dfe3527c370a4c65be01ca55b7abb26b573ade9076cbf9b8c06acc750470a4524");
var tag: [16]u8 = undefined;
Morus.encrypt(&c, &tag, m, ad, iv, k);
try testing.expectEqualSlices(u8, &expected_tag, &tag);
try testing.expectEqualSlices(u8, &expected_c, &c);
try Morus.decrypt(&m2, &c, tag, ad, iv, k);
try testing.expectEqualSlices(u8, m, &m2);
} | src/main.zig |
const kprint = @import("kprint.zig");
const util = @import("arch/aarch64/util.zig");
const arch_init = @import("arch/aarch64/arch_init.zig");
const std = @import("std");
const builtin = @import("std").builtin;
const debug = std.debug;
const assert = debug.assert;
const process = @import("proc.zig");
const thread = @import("thread.zig");
const mem = std.mem;
const Allocator = mem.Allocator;
// const BumpAllocator = @import("vm/page_frame_manager.zig").BumpAllocator;
const page = @import("vm/page.zig");
// Alloc/Free to work?
// Process ping pong
// Verifies that the adjusted length will still map to the full length
const vm = @import("vm.zig");
const kernel_elf = @import("kernel_elf.zig");
const ext2 = @import("ext2");
export fn kmain() noreturn {
arch_init.init();
kernel_elf.init() catch unreachable;
vm.init();
kprint.write("JimZOS v{s}\r", .{util.Version});
//test_crashes();
// Get inside a thread context ASAP
var init_thread = thread.create_initial_thread(&vm.get_page_frame_manager().allocator(), kmainInit) catch unreachable;
thread.switch_to_initial(init_thread);
kprint.write("End of kmain\r", .{});
unreachable;
}
fn kmainInit() noreturn {
// framebuffer.init().?;
// framebuffer.write("JimZOS v{}\r", .{util.Version});
kprint.write("Entered init thread\r", .{});
//TODO: Yield ping pong between EL1 and EL0
// - Copy a flat binary into the "Text" space
// - Handle EL0 sync exceptions
// - Switching address space
// - Pre-allocate some heap + stack space (Later we can on demand)
// testCrashes();
const total_memory = 1024 * 1024 * 1024; //1GB
const memory_start = 0x000000000038e000 + 0x1000000; //__heap_phys_start; FIXME - relocation error when using symbol
const available_memory = total_memory - memory_start;
const page_count = available_memory / 4096; // page_size = 4096
kprint.write("Pages\r", .{});
page.add_phys_pages(@intToPtr(*page.Page, memory_start), memory_start, page_count);
// // page.dump(uart);
// kprint.write("Create init thread\r", .{});
// var alt_thread = thread.create_initial_thread(&vm.get_page_frame_manager().allocator, kmainAlt) catch unreachable;
// kprint.write("Swotcj\r", .{});
// thread.switch_to(alt_thread);
const va_base = 0xFFFF000000000000;
const img_address = 0x2000000 + va_base;
const img_size = 0x040000;
const img_start_ptr = @intToPtr([*]u8, img_address);
const img_slice = img_start_ptr[0..img_size];
var img_stream = std.io.fixedBufferStream(img_slice);
var fs = ext2.FS.mount(&img_stream) catch unreachable;
var super_block = fs.superblock(&img_stream) catch unreachable;
kprint.write("FS Info:\r", .{});
kprint.write("\tMagic 0x{X}\r", .{super_block.s_magic});
kprint.write("\tNumber of block groups {}\r", .{super_block.block_group_count()});
kprint.write("\tBlock size {}\r", .{super_block.block_size()});
kprint.write("\ts_blocks_count {}\r", .{super_block.s_blocks_count});
kprint.write("\ts_first_data_block {}\r", .{super_block.s_first_data_block});
kprint.write("\ts_blocks_per_group {}\r", .{super_block.s_blocks_per_group});
exit();
while (true) {
// kprint.write("INIT\r", .{});
// thread.yield();
// const x = kprint.get();
// kprint.put(x);
// framebuffer.put(x);
}
}
fn kmainAlt() noreturn {
kprint.write("Entered alt thread\r", .{});
while (true) {
kprint.write("ALT\r", .{});
thread.yield();
}
}
pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn {
@import("panic.zig").handlePanic(msg, error_return_trace);
}
extern fn exit() noreturn;
export fn exception_panic(esr_el1: u64, elr_el1: u64, spsr_el1: u64, far_el1: u64) noreturn {
@import("panic.zig").printGuru("Unhandled synchronous exception triggered");
kprint.write("esr_el1: 0x{x:0>16}\r", .{esr_el1});
kprint.write("spsr_el1: 0x{x:0>16}\r", .{spsr_el1});
kprint.write("far_el1: 0x{x:0>16}\r", .{far_el1});
// elr_el1 should contain an address to a source code location, lets
// try to print it.
kprint.write("elr_el1: ", .{});
@import("panic.zig").printAddress(elr_el1) catch unreachable;
exit();
}
fn testCrashes() void {
// const fn someCrash2 () !void {
// return error.Err;
// }
// const fn someCrash () !void {
// try someCrash2();
// }
//some_crash() catch @panic("Oh bum");
// var ptr : *u8 = @intToPtr(*u8, 0xFFFFFFFFFFFFFFFF);
// ptr.* = 2;
} | kernel/src/kernel.zig |
const std = @import("std");
const assert = std.debug.assert;
const c = @import("c.zig");
const helpers = @import("helpers.zig");
const enc = @import("encode.zig");
const dec = @import("decode.zig");
const seek_key = @import("seek_key.zig");
var alloc = std.heap.GeneralPurposeAllocator(.{}){};
var allocator = &alloc.allocator;
export fn napi_register_module_v1(env: c.napi_env, exports: c.napi_value) c.napi_value {
helpers.register_function(env, exports, "encodingLength", encodingLength) catch return null;
helpers.register_function(env, exports, "encode", encode) catch return null;
helpers.register_function(env, exports, "decode", decode) catch return null;
helpers.register_function(env, exports, "seekKey", seekKey) catch return null;
helpers.register_function(env, exports, "allocAndEncode", allocAndEncode) catch return null;
return exports;
}
fn encodingLength(env: c.napi_env, info: c.napi_callback_info) callconv(.C) c.napi_value {
var argc: usize = 1;
var argv: [1]c.napi_value = undefined;
if (c.napi_get_cb_info(env, info, &argc, &argv, null, null) != .napi_ok) {
helpers.throw(env, "Failed to get args") catch return null;
}
var input = if (argc == 1) argv[0] else helpers.getUndefined(env) catch return null;
const result = enc.encodingLength(env, input) catch return null;
return helpers.u32ToJS(env, result) catch return null;
}
fn encode(env: c.napi_env, info: c.napi_callback_info) callconv(.C) c.napi_value {
var argc: usize = 4;
var argv: [4]c.napi_value = undefined;
if (c.napi_get_cb_info(env, info, &argc, &argv, null, null) != .napi_ok) {
helpers.throw(env, "Failed to get args") catch return null;
}
if (argc < 2) {
helpers.throw(env, "Not enough arguments") catch return null;
}
var inputJS = argv[0];
var buffer = helpers.slice_from_value(env, argv[1], "buffer") catch return null;
var start: u32 = undefined;
if (argc >= 3) {
if (c.napi_get_value_uint32(env, argv[2], &start) != .napi_ok) {
helpers.throw(env, "Failed to get start") catch return null;
}
} else {
start = 0;
}
var total = enc.encode(env, inputJS, buffer, start) catch return null;
var totalJS: c.napi_value = undefined;
if (c.napi_create_uint32(env, @intCast(u32, total), &totalJS) != .napi_ok) {
helpers.throw(env, "Failed to create total") catch return null;
}
return totalJS;
}
fn decode(env: c.napi_env, info: c.napi_callback_info) callconv(.C) c.napi_value {
var argc: usize = 2;
var argv: [2]c.napi_value = undefined;
if (c.napi_get_cb_info(env, info, &argc, &argv, null, null) != .napi_ok) {
helpers.throw(env, "Failed to get args") catch return null;
}
if (argc < 1) {
helpers.throw(env, "Not enough arguments") catch return null;
}
var buffer = helpers.slice_from_value(env, argv[0], "buffer") catch return null;
var start: u32 = undefined;
if (argc >= 2) {
if (c.napi_get_value_uint32(env, argv[1], &start) != .napi_ok) {
helpers.throw(env, "Failed to get start") catch return null;
}
} else {
start = 0;
}
return dec.decode(env, buffer, start) catch return null;
}
fn allocAndEncode(env: c.napi_env, info: c.napi_callback_info) callconv(.C) c.napi_value {
var argc: usize = 1;
var argv: [1]c.napi_value = undefined;
if (c.napi_get_cb_info(env, info, &argc, &argv, null, null) != .napi_ok) {
helpers.throw(env, "Failed to get args") catch return null;
}
if (argc < 1) {
helpers.throw(env, "Not enough arguments") catch return null;
}
var inputJS = argv[0];
const len = enc.encodingLength(env, inputJS) catch 0;
var dest = allocator.alloc(u8, len) catch return null;
defer allocator.free(dest);
var written = enc.encode(env, inputJS, dest, 0) catch 0;
return helpers.create_buffer(env, dest, "could not create buffer") catch return null;
}
fn seekKey(env: c.napi_env, info: c.napi_callback_info) callconv(.C) c.napi_value {
var argc: usize = 3;
var argv: [3]c.napi_value = undefined;
if (c.napi_get_cb_info(env, info, &argc, &argv, null, null) != .napi_ok) {
helpers.throw(env, "Failed to get args") catch return null;
}
if (argc < 3) {
helpers.throw(env, "Not enough arguments") catch return null;
}
var buffer = helpers.slice_from_value(env, argv[0], "1st arg") catch return null;
var start_i: i32 = undefined;
if (c.napi_get_value_int32(env, argv[1], &start_i) != .napi_ok) {
helpers.throw(env, "Failed to get start") catch return null;
}
if (start_i == -1) {
return helpers.i32ToJS(env, -1) catch return null;
}
var key: []u8 = undefined;
if (helpers.isTypeof(env, argv[2], c.napi_valuetype.napi_string)) {
// var string: []u8 = undefined;
// var len: usize = 2048;
// var bytes: usize = undefined;
// if (c.napi_get_value_string_utf8(env, argv[2], string, len, bytes) != .napi_ok) {
// helpers.throw(env, "3rd arg is not a string") catch return null;
// }
helpers.throw(env, "Cannot handle strings as 3rd arg, use buffer") catch return null;
} else {
key = helpers.slice_from_value(env, argv[2], "3rd arg") catch return null;
}
if (seek_key.seekKey(env, buffer, @intCast(u32, start_i), key)) |result| {
return helpers.u32ToJS(env, result) catch return null;
} else |err| switch(err) {
error.NOTFOUND => return helpers.i32ToJS(env, -1) catch return null
}
} | src/lib.zig |
const std = @import("std.zig");
const assert = std.debug.assert;
const mem = std.mem;
const testing = std.testing;
/// A structure with an array and a length, that can be used as a slice.
///
/// Useful to pass around small arrays whose exact size is only known at
/// runtime, but whose maximum size is known at comptime, without requiring
/// an `Allocator`.
///
/// ```zig
/// var actual_size = 32;
/// var a = try BoundedArray(u8, 64).init(actual_size);
/// var slice = a.slice(); // a slice of the 64-byte array
/// var a_clone = a; // creates a copy - the structure doesn't use any internal pointers
/// ```
pub fn BoundedArray(comptime T: type, comptime capacity: usize) type {
return struct {
const Self = @This();
buffer: [capacity]T,
len: usize = 0,
/// Set the actual length of the slice.
/// Returns error.Overflow if it exceeds the length of the backing array.
pub fn init(len: usize) !Self {
if (len > capacity) return error.Overflow;
return Self{ .buffer = undefined, .len = len };
}
/// View the internal array as a mutable slice whose size was previously set.
pub fn slice(self: *Self) []T {
return self.buffer[0..self.len];
}
/// View the internal array as a constant slice whose size was previously set.
pub fn constSlice(self: Self) []const T {
return self.buffer[0..self.len];
}
/// Adjust the slice's length to `len`.
/// Does not initialize added items if any.
pub fn resize(self: *Self, len: usize) !void {
if (len > capacity) return error.Overflow;
self.len = len;
}
/// Copy the content of an existing slice.
pub fn fromSlice(m: []const T) !Self {
var list = try init(m.len);
std.mem.copy(T, list.slice(), m);
return list;
}
/// Return the element at index `i` of the slice.
pub fn get(self: Self, i: usize) T {
return self.constSlice()[i];
}
/// Set the value of the element at index `i` of the slice.
pub fn set(self: *Self, i: usize, item: T) void {
self.slice()[i] = item;
}
/// Return the maximum length of a slice.
pub fn capacity(self: Self) usize {
return self.buffer.len;
}
/// Check that the slice can hold at least `additional_count` items.
pub fn ensureUnusedCapacity(self: Self, additional_count: usize) !void {
if (self.len + additional_count > capacity) {
return error.Overflow;
}
}
/// Increase length by 1, returning a pointer to the new item.
pub fn addOne(self: *Self) !*T {
try self.ensureUnusedCapacity(1);
return self.addOneAssumeCapacity();
}
/// Increase length by 1, returning pointer to the new item.
/// Asserts that there is space for the new item.
pub fn addOneAssumeCapacity(self: *Self) *T {
assert(self.len < capacity);
self.len += 1;
return &self.slice()[self.len - 1];
}
/// Resize the slice, adding `n` new elements, which have `undefined` values.
/// The return value is a slice pointing to the uninitialized elements.
pub fn addManyAsArray(self: *Self, comptime n: usize) !*[n]T {
const prev_len = self.len;
try self.resize(self.len + n);
return self.slice()[prev_len..][0..n];
}
/// Remove and return the last element from the slice.
/// Asserts the slice has at least one item.
pub fn pop(self: *Self) T {
const item = self.get(self.len - 1);
self.len -= 1;
return item;
}
/// Remove and return the last element from the slice, or
/// return `null` if the slice is empty.
pub fn popOrNull(self: *Self) ?T {
return if (self.len == 0) null else self.pop();
}
/// Return a slice of only the extra capacity after items.
/// This can be useful for writing directly into it.
/// Note that such an operation must be followed up with a
/// call to `resize()`
pub fn unusedCapacitySlice(self: *Self) []T {
return self.buffer[self.len..];
}
/// Insert `item` at index `i` by moving `slice[n .. slice.len]` to make room.
/// This operation is O(N).
pub fn insert(self: *Self, i: usize, item: T) !void {
if (i >= self.len) {
return error.IndexOutOfBounds;
}
_ = try self.addOne();
var s = self.slice();
mem.copyBackwards(T, s[i + 1 .. s.len], s[i .. s.len - 1]);
self.buffer[i] = item;
}
/// Insert slice `items` at index `i` by moving `slice[i .. slice.len]` to make room.
/// This operation is O(N).
pub fn insertSlice(self: *Self, i: usize, items: []const T) !void {
try self.ensureUnusedCapacity(items.len);
self.len += items.len;
mem.copyBackwards(T, self.slice()[i + items.len .. self.len], self.constSlice()[i .. self.len - items.len]);
mem.copy(T, self.slice()[i .. i + items.len], items);
}
/// Replace range of elements `slice[start..start+len]` with `new_items`.
/// Grows slice if `len < new_items.len`.
/// Shrinks slice if `len > new_items.len`.
pub fn replaceRange(self: *Self, start: usize, len: usize, new_items: []const T) !void {
const after_range = start + len;
var range = self.slice()[start..after_range];
if (range.len == new_items.len) {
mem.copy(T, range, new_items);
} else if (range.len < new_items.len) {
const first = new_items[0..range.len];
const rest = new_items[range.len..];
mem.copy(T, range, first);
try self.insertSlice(after_range, rest);
} else {
mem.copy(T, range, new_items);
const after_subrange = start + new_items.len;
for (self.constSlice()[after_range..]) |item, i| {
self.slice()[after_subrange..][i] = item;
}
self.len -= len - new_items.len;
}
}
/// Extend the slice by 1 element.
pub fn append(self: *Self, item: T) !void {
const new_item_ptr = try self.addOne();
new_item_ptr.* = item;
}
/// Extend the slice by 1 element, asserting the capacity is already
/// enough to store the new item.
pub fn appendAssumeCapacity(self: *Self, item: T) void {
const new_item_ptr = self.addOneAssumeCapacity();
new_item_ptr.* = item;
}
/// Remove the element at index `i`, shift elements after index
/// `i` forward, and return the removed element.
/// Asserts the slice has at least one item.
/// This operation is O(N).
pub fn orderedRemove(self: *Self, i: usize) T {
const newlen = self.len - 1;
if (newlen == i) return self.pop();
const old_item = self.get(i);
for (self.slice()[i..newlen]) |*b, j| b.* = self.get(i + 1 + j);
self.set(newlen, undefined);
self.len = newlen;
return old_item;
}
/// Remove the element at the specified index and return it.
/// The empty slot is filled from the end of the slice.
/// This operation is O(1).
pub fn swapRemove(self: *Self, i: usize) T {
if (self.len - 1 == i) return self.pop();
const old_item = self.get(i);
self.set(i, self.pop());
return old_item;
}
/// Append the slice of items to the slice.
pub fn appendSlice(self: *Self, items: []const T) !void {
try self.ensureUnusedCapacity(items.len);
self.appendSliceAssumeCapacity(items);
}
/// Append the slice of items to the slice, asserting the capacity is already
/// enough to store the new items.
pub fn appendSliceAssumeCapacity(self: *Self, items: []const T) void {
const oldlen = self.len;
self.len += items.len;
mem.copy(T, self.slice()[oldlen..], items);
}
/// Append a value to the slice `n` times.
/// Allocates more memory as necessary.
pub fn appendNTimes(self: *Self, value: T, n: usize) !void {
const old_len = self.len;
try self.resize(old_len + n);
mem.set(T, self.slice()[old_len..self.len], value);
}
/// Append a value to the slice `n` times.
/// Asserts the capacity is enough.
pub fn appendNTimesAssumeCapacity(self: *Self, value: T, n: usize) void {
const old_len = self.len;
self.len += n;
assert(self.len <= capacity);
mem.set(T, self.slice()[old_len..self.len], value);
}
};
}
test "BoundedArray" {
var a = try BoundedArray(u8, 64).init(32);
try testing.expectEqual(a.capacity(), 64);
try testing.expectEqual(a.slice().len, 32);
try testing.expectEqual(a.constSlice().len, 32);
try a.resize(48);
try testing.expectEqual(a.len, 48);
const x = [_]u8{1} ** 10;
a = try BoundedArray(u8, 64).fromSlice(&x);
try testing.expectEqualSlices(u8, &x, a.constSlice());
var a2 = a;
try testing.expectEqualSlices(u8, a.constSlice(), a.constSlice());
a2.set(0, 0);
try testing.expect(a.get(0) != a2.get(0));
try testing.expectError(error.Overflow, a.resize(100));
try testing.expectError(error.Overflow, BoundedArray(u8, x.len - 1).fromSlice(&x));
try a.resize(0);
try a.ensureUnusedCapacity(a.capacity());
(try a.addOne()).* = 0;
try a.ensureUnusedCapacity(a.capacity() - 1);
try testing.expectEqual(a.len, 1);
const uninitialized = try a.addManyAsArray(4);
try testing.expectEqual(uninitialized.len, 4);
try testing.expectEqual(a.len, 5);
try a.append(0xff);
try testing.expectEqual(a.len, 6);
try testing.expectEqual(a.pop(), 0xff);
a.appendAssumeCapacity(0xff);
try testing.expectEqual(a.len, 6);
try testing.expectEqual(a.pop(), 0xff);
try a.resize(1);
try testing.expectEqual(a.popOrNull(), 0);
try testing.expectEqual(a.popOrNull(), null);
var unused = a.unusedCapacitySlice();
mem.set(u8, unused[0..8], 2);
unused[8] = 3;
unused[9] = 4;
try testing.expectEqual(unused.len, a.capacity());
try a.resize(10);
try a.insert(5, 0xaa);
try testing.expectEqual(a.len, 11);
try testing.expectEqual(a.get(5), 0xaa);
try testing.expectEqual(a.get(9), 3);
try testing.expectEqual(a.get(10), 4);
try a.appendSlice(&x);
try testing.expectEqual(a.len, 11 + x.len);
try a.appendNTimes(0xbb, 5);
try testing.expectEqual(a.len, 11 + x.len + 5);
try testing.expectEqual(a.pop(), 0xbb);
a.appendNTimesAssumeCapacity(0xcc, 5);
try testing.expectEqual(a.len, 11 + x.len + 5 - 1 + 5);
try testing.expectEqual(a.pop(), 0xcc);
try testing.expectEqual(a.len, 29);
try a.replaceRange(1, 20, &x);
try testing.expectEqual(a.len, 29 + x.len - 20);
try a.insertSlice(0, &x);
try testing.expectEqual(a.len, 29 + x.len - 20 + x.len);
try a.replaceRange(1, 5, &x);
try testing.expectEqual(a.len, 29 + x.len - 20 + x.len + x.len - 5);
try a.append(10);
try testing.expectEqual(a.pop(), 10);
try a.append(20);
const removed = a.orderedRemove(5);
try testing.expectEqual(removed, 1);
try testing.expectEqual(a.len, 34);
a.set(0, 0xdd);
a.set(a.len - 1, 0xee);
const swapped = a.swapRemove(0);
try testing.expectEqual(swapped, 0xdd);
try testing.expectEqual(a.get(0), 0xee);
} | lib/std/bounded_array.zig |
const std = @import("std");
/// NOTE: This function is probably missing some optimizations of some kind.
/// Feel free to tinker! Also this could easily be genericized by adding a base
/// param, but we only need this for octal, so that isn't necessary yet.
/// Benchmarks on my machine indicate this is twice as fast as std.fmt.parseInt.
pub fn parseOctal(comptime T: type, comptime size: usize, buf: [size]u8) T {
std.debug.assert(buf.len == size);
const VectorT = std.meta.Vector(size, T);
// The size of our Vector is required to be known at compile time,
// so let's compute our "multiplication mask" at compile time too!
comptime var multi_mask: VectorT = undefined;
// This "subtraction mask" Turns ASCII numbers into actual numbers
// by subtracting 48, the ASCII value of '0'
const sub_mask = @splat(size, @intCast(T, 48));
// Our accumulator for our "multiplication mask" (1, 8, 64, etc.)
comptime var acc: T = 1;
comptime var acci: usize = 0;
// Preload the vector with our powers of 8
comptime while (acci < size) : ({
acc *= 8;
acci += 1;
}) {
multi_mask[size - acci - 1] = acc;
};
// Let's actually do the math now!
var vec: VectorT = undefined;
for (buf) |b, i| vec[i] = b;
// Applies our "subtraction mask"
vec -= sub_mask;
// Applies our "multiplication mask"
vec *= multi_mask;
// Finally sum things up
return @reduce(.Add, vec);
}
test "SIMD Octal Parsing" {
try std.testing.expectEqual(parseOctal(u64, 11, "77777777777"), 8589934591);
try std.testing.expectEqual(parseOctal(u64, 11, "74717577077"), 8174632511);
}
fn fillMultiMask(comptime T: type, comptime vector_size: u32, comptime multi_mask: *std.meta.Vector(vector_size, T), comptime offset: usize, comptime size: usize) void {
// Our accumulator for our "multiplication mask" (1, 8, 64, etc.)
comptime var acc: T = 1;
comptime var acci: usize = 0;
// Preload the vector with our powers of 8
comptime while (acci < size) : ({
acc *= 8;
acci += 1;
}) {
multi_mask.*[offset + (size - acci - 1)] = acc;
};
}
/// Parses a set of octal fields all at once.
pub fn OctalGroupParser(comptime T: type, comptime Z: type) type {
const z_fields = std.meta.fields(Z);
const OutT = @Type(.{ .Struct = .{
.layout = .Auto,
.fields = &comptime fields: {
var fields: [z_fields.len]std.builtin.TypeInfo.StructField = undefined;
inline for (z_fields) |field, i| {
fields[i] = .{
.name = field.name,
.field_type = T,
.default_value = null,
.is_comptime = false,
.alignment = 0,
};
}
break :fields fields;
},
.decls = &[0]std.builtin.TypeInfo.Declaration{},
.is_tuple = false,
} });
return struct {
pub fn process(input: Z) OutT {
var o: OutT = undefined;
comptime var vector_size: u32 = 0;
comptime var multi_offset: usize = 0;
inline for (z_fields) |field| {
std.debug.assert(@field(input, field.name).len == @sizeOf(field.field_type)); // Length mismatch
vector_size += @sizeOf(field.field_type);
}
const VectorT = std.meta.Vector(vector_size, T);
comptime var multi_mask: VectorT = undefined;
const sub_mask = @splat(vector_size, @intCast(T, 48));
comptime for (z_fields) |field| {
fillMultiMask(T, vector_size, &multi_mask, multi_offset, @sizeOf(field.field_type));
multi_offset += @sizeOf(field.field_type);
};
var big_boy_buf: [vector_size]T = undefined;
var bc = @bitCast([vector_size]u8, input);
for (bc) |b, i| big_boy_buf[i] = b;
// Let's actually do the math now!
var vec: VectorT = big_boy_buf;
// Applies our "subtraction mask"
vec -= sub_mask;
// Applies our "multiplication mask"
vec *= multi_mask;
comptime var sb_off: usize = 0;
var small_boy_buf: [vector_size]T = vec;
inline for (z_fields) |field| {
var imp: std.meta.Vector(@sizeOf(field.field_type), T) = small_boy_buf[sb_off .. sb_off + @sizeOf(field.field_type)].*;
@field(o, field.name) = @reduce(.Add, imp);
sb_off += @sizeOf(field.field_type);
}
return o;
}
};
} | src/utils/simd.zig |
const std = @import("std");
const string = []const u8;
const time = @import("time");
pub fn main() !void {
std.log.info("All your codebase are belong to us.", .{});
}
fn harness(comptime seed: u64, comptime expects: []const [2]string) void {
var i: usize = 0;
while (i < expects.len) : (i += 1) {
_ = Case(seed, expects[i][0], expects[i][1]);
}
}
fn Case(comptime seed: u64, comptime fmt: string, comptime expected: string) type {
return struct {
test {
const alloc = std.testing.allocator;
const instant = time.DateTime.initUnixMs(seed);
const actual = try instant.formatAlloc(alloc, fmt);
defer alloc.free(actual);
std.testing.expectEqualStrings(expected, actual) catch return error.SkipZigTest;
}
};
}
comptime {
harness(0, &.{.{ "YYYY-MM-DD HH:mm:ss", "1970-01-01 00:00:00" }});
harness(1257894000000, &.{.{ "YYYY-MM-DD HH:mm:ss", "2009-11-10 23:00:00" }});
harness(1634858430000, &.{.{ "YYYY-MM-DD HH:mm:ss", "2021-10-21 23:20:30" }});
harness(1634858430023, &.{.{ "YYYY-MM-DD HH:mm:ss.SSS", "2021-10-21 23:20:30.023" }});
harness(1144509852789, &.{.{ "YYYY-MM-DD HH:mm:ss.SSS", "2006-04-08 15:24:12.789" }});
harness(1635033600000, &.{
.{ "H", "0" }, .{ "HH", "00" },
.{ "h", "12" }, .{ "hh", "12" },
.{ "k", "24" }, .{ "kk", "24" },
});
harness(1635037200000, &.{
.{ "H", "1" }, .{ "HH", "01" },
.{ "h", "1" }, .{ "hh", "01" },
.{ "k", "1" }, .{ "kk", "01" },
});
harness(1635076800000, &.{
.{ "H", "12" }, .{ "HH", "12" },
.{ "h", "12" }, .{ "hh", "12" },
.{ "k", "12" }, .{ "kk", "12" },
});
harness(1635080400000, &.{
.{ "H", "13" }, .{ "HH", "13" },
.{ "h", "1" }, .{ "hh", "01" },
.{ "k", "13" }, .{ "kk", "13" },
});
harness(1144509852789, &.{
.{ "M", "4" },
.{ "Mo", "4th" },
.{ "MM", "04" },
.{ "MMM", "Apr" },
.{ "MMMM", "April" },
.{ "Q", "2" },
.{ "Qo", "2nd" },
.{ "D", "8" },
.{ "Do", "8th" },
.{ "DD", "08" },
.{ "DDD", "98" },
.{ "DDDo", "98th" },
.{ "DDDD", "098" },
.{ "d", "6" },
.{ "do", "6th" },
.{ "dd", "Sa" },
.{ "ddd", "Sat" },
.{ "dddd", "Saturday" },
.{ "e", "6" },
.{ "E", "7" },
.{ "w", "14" },
.{ "wo", "14th" },
.{ "ww", "14" },
.{ "Y", "12006" },
.{ "YY", "06" },
.{ "YYY", "2006" },
.{ "YYYY", "2006" },
.{ "N", "AD" },
.{ "NN", "<NAME>" },
.{ "A", "PM" },
.{ "a", "pm" },
.{ "H", "15" },
.{ "HH", "15" },
.{ "h", "3" },
.{ "hh", "03" },
.{ "k", "15" },
.{ "kk", "15" },
.{ "m", "24" },
.{ "mm", "24" },
.{ "s", "12" },
.{ "ss", "12" },
.{ "S", "7" },
.{ "SS", "78" },
.{ "SSS", "789" },
.{ "z", "UTC" },
.{ "Z", "+00:00" },
.{ "ZZ", "+0000" },
.{ "x", "1144509852789" },
// .{ "X", "1144509852" },
});
} | lib/zig-time/main.zig |
const std = @import("std");
const Builder = std.build.Builder;
const LibExeObjStep = std.build.LibExeObjStep;
const Step = std.build.Step;
pub fn build(b: *std.build.Builder) void {
const target = .{
.cpu_arch = .i386,
.cpu_model = .{ .explicit = &std.Target.x86.cpu._i586 },
.os_tag = .freestanding,
.abi = .none,
};
// Standard release options allow the person running `zig build` to select
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
const mode = b.standardReleaseOptions();
const bootloader = buildBootloader(b);
bootloader.setTarget(target);
bootloader.setBuildMode(mode);
const kernel = buildKernel(b);
kernel.setTarget(target);
const image = generateImage(b, bootloader, kernel, "image.bin");
b.default_step.dependOn(image);
const qemu = b.addSystemCommand(&[_][]const u8{
"qemu-system-i386",
"-drive", "if=ide,format=raw,file=image.bin",
} ++ qemu_serial_conf);
qemu.step.dependOn(b.getInstallStep());
const run_qemu = b.step("run", "Run in qemu");
run_qemu.dependOn(&qemu.step);
}
fn buildBootloader(b: *Builder) *LibExeObjStep {
const stage0_file = "zig-cache/stage0.obj";
const stage0 = b.addSystemCommand(&[_][]const u8{
"nasm",
"-felf32",
"-o", stage0_file,
"-isrc/bootloader",
"src/bootloader/stage0.asm",
});
const stage1 = b.addExecutable("bootloader", "src/main.zig");
stage1.setLinkerScriptPath("linker.ld");
stage1.addObjectFile(stage0_file);
stage1.step.dependOn(&stage0.step);
stage1.install();
return stage1;
}
fn buildKernel(b: *Builder) *LibExeObjStep {
const kernel = b.addExecutable("kernel", "src/kernel.zig");
kernel.setBuildMode(.Debug);
kernel.image_base = 0x4200_0000;
kernel.strip = true;
kernel.install();
return kernel;
}
fn generateImage(
b: *Builder,
bootloader: *LibExeObjStep,
kernel: *LibExeObjStep,
output: []const u8,
) *Step {
if (bootloader.install_step == null) unreachable;
if (kernel.install_step == null) unreachable;
const bootloader_path = b.getInstallPath(
bootloader.install_step.?.dest_dir,
bootloader.out_filename,
);
const kernel_path = b.getInstallPath(
kernel.install_step.?.dest_dir,
kernel.out_filename,
);
const image = b.addSystemCommand(&[_][]const u8{
"tools/gen_image.py",
bootloader_path,
kernel_path,
"image.bin",
});
image.step.dependOn(&bootloader.step);
image.step.dependOn(&kernel.step);
const gen_image = b.step("gen", "Generate image");
gen_image.dependOn(&image.step);
return gen_image;
}
const qemu_serial_conf = [_][]const u8{
"-chardev", "stdio,id=com1",
"-chardev", "pty,id=com2",
"-chardev", "vc,id=com3",
"-chardev", "vc,id=com4",
"-serial", "chardev:com1",
"-serial", "chardev:com2",
"-serial", "chardev:com3",
"-serial", "chardev:com4",
}; | build.zig |
const std = @import("std");
const print = std.debug.print;
const Happiness = std.StringArrayHashMap(std.StringHashMap(isize));
pub fn main() anyerror!void {
const global_allocator = std.heap.page_allocator;
var file = try std.fs.cwd().openFile(
"./inputs/day13.txt",
.{
.read = true,
},
);
var reader = std.io.bufferedReader(file.reader()).reader();
var line = std.ArrayList(u8).init(global_allocator);
defer line.deinit();
var happiness = Happiness.init(global_allocator);
defer happiness.deinit();
var arena = std.heap.ArenaAllocator.init(global_allocator);
defer arena.deinit();
var allocator = &arena.allocator;
while (reader.readUntilDelimiterArrayList(&line, '\n', 1024)) {
var tokens = std.mem.tokenize(u8, line.items, " ");
const from = try std.mem.Allocator.dupe(allocator, u8, tokens.next().?);
_ = tokens.next(); // would
const gain_lose = tokens.next().?;
const amount_str = tokens.next().?;
var amount = try std.fmt.parseInt(isize, amount_str, 10);
if (std.mem.eql(u8, gain_lose, "lose")) {
amount = -amount;
}
_ = tokens.next(); // happiness
_ = tokens.next(); // units
_ = tokens.next(); // by
_ = tokens.next(); // sitting
_ = tokens.next(); // next
_ = tokens.next(); // to
const to_str = tokens.next().?;
const to = try std.mem.Allocator.dupe(allocator, u8, to_str[0 .. to_str.len - 1]);
if (happiness.getPtr(from)) |m| {
try m.put(to, amount);
} else {
var m = std.StringHashMap(isize).init(allocator);
try m.put(to, amount);
try happiness.put(from, m);
}
} else |err| {
if (err != error.EndOfStream) {
return err;
}
}
{
const max_happiness = try maximum_happiness(global_allocator, happiness);
print("Part 1: {d}\n", .{max_happiness});
}
{
var me = std.StringHashMap(isize).init(allocator);
var it = happiness.iterator();
while (it.next()) |e| {
try me.put(e.key_ptr.*, 0);
try e.value_ptr.*.put("me", 0);
}
try happiness.put("me", me);
const max_happiness = try maximum_happiness(global_allocator, happiness);
print("Part 2: {d}\n", .{max_happiness});
}
}
fn get_happiness(happiness: Happiness, arrangement: [][]const u8) isize {
var sum: isize = 0;
for (arrangement) |person, i| {
const a = arrangement[if (i == 0) arrangement.len - 1 else (i - 1) % arrangement.len];
const b = arrangement[(i + 1) % arrangement.len];
const m = happiness.get(person).?;
sum += m.get(a).?;
sum += m.get(b).?;
}
return sum;
}
fn maximum_happiness(allocator: *std.mem.Allocator, happiness: Happiness) !isize {
var people: [][]const u8 = try allocator.alloc([]const u8, happiness.count());
defer allocator.free(people);
for (happiness.keys()) |x, i| {
people[i] = x;
}
var c: []usize = try allocator.alloc(usize, people.len);
defer allocator.free(c);
for (c) |*x| {
x.* = 0;
}
var max_happiness: isize = 0;
var i: usize = 0;
while (i < people.len) {
if (c[i] < i) {
if (i % 2 == 0) {
std.mem.swap([]const u8, &people[0], &people[i]);
} else {
std.mem.swap([]const u8, &people[c[i]], &people[i]);
}
max_happiness = std.math.max(max_happiness, get_happiness(happiness, people));
c[i] += 1;
i = 0;
} else {
c[i] = 0;
i += 1;
}
}
return max_happiness;
} | src/day13.zig |
const std = @import("std");
const print = std.debug.print;
const build_options = @import("build_options");
const Postgres = @import("postgres");
const Pg = Postgres.Pg;
const Result = Postgres.Result;
const Builder = Postgres.Builder;
const FieldInfo = Postgres.FieldInfo;
const Parser = Postgres.Parser;
const ArrayList = std.ArrayList;
const Allocator = std.mem.Allocator;
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
const allocator = &gpa.allocator;
const Stats = struct { wins: u16 = 0, losses: u16 = 0 };
const Player = struct {
id: u16,
name: []const u8,
stats: Stats,
cards: ?[][]const u8 = null,
pub fn onSave(_: *Player, comptime field: FieldInfo, builder: *Builder, value: anytype) !void {
switch (field.type) {
?[][]const u8 => try builder.addStringArray(value.?),
Stats => try builder.addJson(value),
else => {},
}
}
pub fn onLoad(self: *Player, comptime field: FieldInfo, value: []const u8, parser: Parser) !void {
switch (field.type) {
?[][]const u8 => self.cards = try parser.parseArray(value, ","),
Stats => self.stats = try parser.parseJson(Stats, value),
else => {},
}
}
};
pub fn main() !void {
var db = try Pg.connect(allocator, build_options.db_uri);
defer {
std.debug.assert(!gpa.deinit());
db.deinit();
}
const schema =
\\CREATE TABLE IF NOT EXISTS player (id INT, name TEXT, stats JSONB, cards TEXT[]);
;
_ = try db.exec(schema);
var cards = [3][]const u8{
"Ace",
"2",
"Queen",
};
var data = Player{ .id = 1, .name = "Steve", .stats = .{ .wins = 3, .losses = 2 }, .cards = cards[0..] };
var data2 = Player{ .id = 2, .name = "Karl", .stats = .{ .wins = 3, .losses = 2 }, .cards = null };
_ = try db.insert(&data);
_ = try db.insert(&data2);
var result = try db.execValues("SELECT * FROM player WHERE name = {s}", .{"Steve"});
while (result.parse(Player, allocator)) |res| {
print("id {d} \n", .{res.id});
print("name {s} \n", .{res.name});
print("wins {d} \n", .{res.stats.wins});
for (res.cards.?) |card| {
print("card {s} \n", .{card});
}
defer allocator.free(res.cards.?);
}
//_ = try db.exec("DROP TABLE player");
} | examples/custom_types.zig |
const std = @import("std");
const io = std.io;
const fs = std.fs;
const testing = std.testing;
const mem = std.mem;
const deflate = std.compress.deflate;
// Flags for the FLG field in the header
const FTEXT = 1 << 0;
const FHCRC = 1 << 1;
const FEXTRA = 1 << 2;
const FNAME = 1 << 3;
const FCOMMENT = 1 << 4;
pub fn GzipStream(comptime ReaderType: type) type {
return struct {
const Self = @This();
pub const Error = ReaderType.Error ||
deflate.Decompressor(ReaderType).Error ||
error{ CorruptedData, WrongChecksum };
pub const Reader = io.Reader(*Self, Error, read);
allocator: mem.Allocator,
inflater: deflate.Decompressor(ReaderType),
in_reader: ReaderType,
hasher: std.hash.Crc32,
read_amt: usize,
info: struct {
filename: ?[]const u8,
comment: ?[]const u8,
modification_time: u32,
},
fn init(allocator: mem.Allocator, source: ReaderType) !Self {
// gzip header format is specified in RFC1952
const header = try source.readBytesNoEof(10);
// Check the ID1/ID2 fields
if (header[0] != 0x1f or header[1] != 0x8b)
return error.BadHeader;
const CM = header[2];
// The CM field must be 8 to indicate the use of DEFLATE
if (CM != 8) return error.InvalidCompression;
// Flags
const FLG = header[3];
// Modification time, as a Unix timestamp.
// If zero there's no timestamp available.
const MTIME = mem.readIntLittle(u32, header[4..8]);
// Extra flags
const XFL = header[8];
// Operating system where the compression took place
const OS = header[9];
_ = XFL;
_ = OS;
if (FLG & FEXTRA != 0) {
// Skip the extra data, we could read and expose it to the user
// if somebody needs it.
const len = try source.readIntLittle(u16);
try source.skipBytes(len, .{});
}
var filename: ?[]const u8 = null;
if (FLG & FNAME != 0) {
filename = try source.readUntilDelimiterAlloc(
allocator,
0,
std.math.maxInt(usize),
);
}
errdefer if (filename) |p| allocator.free(p);
var comment: ?[]const u8 = null;
if (FLG & FCOMMENT != 0) {
comment = try source.readUntilDelimiterAlloc(
allocator,
0,
std.math.maxInt(usize),
);
}
errdefer if (comment) |p| allocator.free(p);
if (FLG & FHCRC != 0) {
// TODO: Evaluate and check the header checksum. The stdlib has
// no CRC16 yet :(
_ = try source.readIntLittle(u16);
}
return Self{
.allocator = allocator,
.inflater = try deflate.decompressor(allocator, source, null),
.in_reader = source,
.hasher = std.hash.Crc32.init(),
.info = .{
.filename = filename,
.comment = comment,
.modification_time = MTIME,
},
.read_amt = 0,
};
}
pub fn deinit(self: *Self) void {
self.inflater.deinit();
if (self.info.filename) |filename|
self.allocator.free(filename);
if (self.info.comment) |comment|
self.allocator.free(comment);
}
// Implements the io.Reader interface
pub fn read(self: *Self, buffer: []u8) Error!usize {
if (buffer.len == 0)
return 0;
// Read from the compressed stream and update the computed checksum
const r = try self.inflater.read(buffer);
if (r != 0) {
self.hasher.update(buffer[0..r]);
self.read_amt += r;
return r;
}
// We've reached the end of stream, check if the checksum matches
const hash = try self.in_reader.readIntLittle(u32);
if (hash != self.hasher.final())
return error.WrongChecksum;
// The ISIZE field is the size of the uncompressed input modulo 2^32
const input_size = try self.in_reader.readIntLittle(u32);
if (self.read_amt & 0xffffffff != input_size)
return error.CorruptedData;
return 0;
}
pub fn reader(self: *Self) Reader {
return .{ .context = self };
}
};
}
pub fn gzipStream(allocator: mem.Allocator, reader: anytype) !GzipStream(@TypeOf(reader)) {
return GzipStream(@TypeOf(reader)).init(allocator, reader);
}
fn testReader(data: []const u8, comptime expected: []const u8) !void {
var in_stream = io.fixedBufferStream(data);
var gzip_stream = try gzipStream(testing.allocator, in_stream.reader());
defer gzip_stream.deinit();
// Read and decompress the whole file
const buf = try gzip_stream.reader().readAllAlloc(testing.allocator, std.math.maxInt(usize));
defer testing.allocator.free(buf);
// Check against the reference
try testing.expectEqualSlices(u8, buf, expected);
}
// All the test cases are obtained by compressing the RFC1952 text
//
// https://tools.ietf.org/rfc/rfc1952.txt length=25037 bytes
// SHA256=164ef0897b4cbec63abf1b57f069f3599bd0fb7c72c2a4dee21bd7e03ec9af67
test "compressed data" {
try testReader(
@embedFile("rfc1952.txt.gz"),
@embedFile("rfc1952.txt"),
);
}
test "sanity checks" {
// Truncated header
try testing.expectError(
error.EndOfStream,
testReader(&[_]u8{ 0x1f, 0x8B }, ""),
);
// Wrong CM
try testing.expectError(
error.InvalidCompression,
testReader(&[_]u8{
0x1f, 0x8b, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x03,
}, ""),
);
// Wrong checksum
try testing.expectError(
error.WrongChecksum,
testReader(&[_]u8{
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00,
}, ""),
);
// Truncated checksum
try testing.expectError(
error.EndOfStream,
testReader(&[_]u8{
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00,
}, ""),
);
// Wrong initial size
try testing.expectError(
error.CorruptedData,
testReader(&[_]u8{
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01,
}, ""),
);
// Truncated initial size field
try testing.expectError(
error.EndOfStream,
testReader(&[_]u8{
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
}, ""),
);
} | lib/std/compress/gzip.zig |
const std = @import("std");
const assert = std.debug.assert;
const c = @cImport({
@cInclude("SDL2/SDL.h");
});
const game = @import("../minesweeper/game.zig");
const GameState = game.GameState;
const event = @import("../minesweeper/event.zig");
const GameEventTag = event.GameEventTag;
const SpriteSheetTileExtent = 19;
const SpriteScreenExtent = 38;
const InvalidMoveTimeSecs: f32 = 0.3;
const GfxState = struct {
invalid_move_time_secs: f32 = 0.0,
is_hovered: bool = false,
is_exploded: bool = false,
};
fn get_tile_index(cell: game.CellState, gfx_cell: GfxState, is_game_ended: bool) [2]u8 {
if (cell.is_covered) {
var index_x: u8 = 0;
if (cell.marking == game.Marking.Flag) {
if (is_game_ended and !cell.is_mine) {
index_x = 8;
} else {
index_x = 2;
}
} else if (cell.marking == game.Marking.Guess) {
index_x = 4;
}
if (gfx_cell.is_hovered and !is_game_ended)
index_x += 1;
return .{ index_x, 1 };
} else {
if (cell.is_mine) {
if (gfx_cell.is_exploded) {
return .{ 7, 1 };
} else return .{ 6, 1 };
}
return .{ cell.mine_neighbors, 0 };
}
}
fn get_sprite_sheet_rect(position: [2]u8) c.SDL_Rect {
return c.SDL_Rect{
.x = position[0] * SpriteSheetTileExtent,
.y = position[1] * SpriteSheetTileExtent,
.w = SpriteSheetTileExtent,
.h = SpriteSheetTileExtent,
};
}
fn allocate_2d_array_default_init(comptime T: type, allocator: std.mem.Allocator, x: usize, y: usize) ![][]T {
var array = try allocator.alloc([]T, x);
errdefer allocator.free(array);
for (array) |*column| {
column.* = try allocator.alloc(T, y);
errdefer allocator.free(column);
for (column.*) |*cell| {
cell.* = .{};
}
}
return array;
}
fn deallocate_2d_array(comptime T: type, allocator: std.mem.Allocator, array: [][]T) void {
for (array) |column| {
allocator.free(column);
}
allocator.free(array);
}
pub fn execute_main_loop(allocator: std.mem.Allocator, game_state: *GameState) !void {
const width = game_state.extent[0] * SpriteScreenExtent;
const height = game_state.extent[1] * SpriteScreenExtent;
if (c.SDL_Init(c.SDL_INIT_EVERYTHING) != 0) {
c.SDL_Log("Unable to initialize SDL: %s", c.SDL_GetError());
return error.SDLInitializationFailed;
}
defer c.SDL_Quit();
const window = c.SDL_CreateWindow("Minesweeper", c.SDL_WINDOWPOS_UNDEFINED, c.SDL_WINDOWPOS_UNDEFINED, @intCast(c_int, width), @intCast(c_int, height), c.SDL_WINDOW_SHOWN) orelse {
c.SDL_Log("Unable to create window: %s", c.SDL_GetError());
return error.SDLInitializationFailed;
};
defer c.SDL_DestroyWindow(window);
if (c.SDL_SetHint(c.SDL_HINT_RENDER_VSYNC, "1") == c.SDL_FALSE) {
c.SDL_Log("Unable to set hint: %s", c.SDL_GetError());
return error.SDLInitializationFailed;
}
const ren = c.SDL_CreateRenderer(window, -1, c.SDL_RENDERER_ACCELERATED) orelse {
c.SDL_Log("Unable to create renderer: %s", c.SDL_GetError());
return error.SDLInitializationFailed;
};
defer c.SDL_DestroyRenderer(ren);
// Create sprite sheet
// Using relative path for now
const sprite_sheet_surface = c.SDL_LoadBMP("res/tile.bmp") orelse {
c.SDL_Log("Unable to create BMP surface from file: %s", c.SDL_GetError());
return error.SDLInitializationFailed;
};
defer c.SDL_FreeSurface(sprite_sheet_surface);
const sprite_sheet_texture = c.SDL_CreateTextureFromSurface(ren, sprite_sheet_surface) orelse {
c.SDL_Log("Unable to create texture from surface: %s", c.SDL_GetError());
return error.SDLInitializationFailed;
};
defer c.SDL_DestroyTexture(sprite_sheet_texture);
var shouldExit = false;
var gfx_board = try allocate_2d_array_default_init(GfxState, allocator, game_state.extent[0], game_state.extent[1]);
var gfx_event_index: usize = 0;
var last_frame_time_ms: u32 = c.SDL_GetTicks();
while (!shouldExit) {
const current_frame_time_ms: u32 = c.SDL_GetTicks();
const frame_delta_secs = @intToFloat(f32, current_frame_time_ms - last_frame_time_ms) * 0.001;
// Poll events
var sdlEvent: c.SDL_Event = undefined;
while (c.SDL_PollEvent(&sdlEvent) > 0) {
switch (sdlEvent.type) {
c.SDL_QUIT => {
shouldExit = true;
},
c.SDL_KEYDOWN => {
if (sdlEvent.key.keysym.sym == c.SDLK_ESCAPE)
shouldExit = true;
},
c.SDL_MOUSEBUTTONUP => {
const x = @intCast(u16, @divTrunc(sdlEvent.button.x, SpriteScreenExtent));
const y = @intCast(u16, @divTrunc(sdlEvent.button.y, SpriteScreenExtent));
if (sdlEvent.button.button == c.SDL_BUTTON_LEFT) {
game.uncover(game_state, .{ x, y });
} else if (sdlEvent.button.button == c.SDL_BUTTON_RIGHT) {
game.toggle_flag(game_state, .{ x, y });
}
},
else => {},
}
}
const string = try std.fmt.allocPrintZ(allocator, "Minesweeper {d}x{d} with {d}/{d} mines", .{ game_state.extent[0], game_state.extent[1], game_state.flag_count, game_state.mine_count });
defer allocator.free(string);
c.SDL_SetWindowTitle(window, string.ptr);
var mouse_x: c_int = undefined;
var mouse_y: c_int = undefined;
_ = c.SDL_GetMouseState(&mouse_x, &mouse_y);
const hovered_cell_x = @intCast(u16, std.math.max(0, std.math.min(game_state.extent[0], @divTrunc(mouse_x, SpriteScreenExtent))));
const hovered_cell_y = @intCast(u16, std.math.max(0, std.math.min(game_state.extent[1], @divTrunc(mouse_y, SpriteScreenExtent))));
for (gfx_board) |column| {
for (column) |*cell| {
cell.is_hovered = false;
cell.invalid_move_time_secs = std.math.max(0.0, cell.invalid_move_time_secs - frame_delta_secs);
}
}
gfx_board[hovered_cell_x][hovered_cell_y].is_hovered = true;
// Process game events for the gfx side
for (game_state.event_history[gfx_event_index..game_state.event_history_index]) |game_event| {
switch (game_event) {
GameEventTag.discover_number => |event| {
if (event.children.len == 0) {
gfx_board[event.location[0]][event.location[1]].invalid_move_time_secs = InvalidMoveTimeSecs;
}
},
GameEventTag.game_end => |event| {
for (event.exploded_mines) |mine_location| {
gfx_board[mine_location[0]][mine_location[1]].is_exploded = true;
}
},
else => {},
}
}
// Advance event index since we processed the rest
gfx_event_index = game_state.event_history_index;
// Render game
_ = c.SDL_RenderClear(ren);
for (game_state.board) |column, i| {
for (column) |cell, j| {
const gfx_cell = gfx_board[i][j];
const sprite_output_pos_rect = c.SDL_Rect{
.x = @intCast(c_int, i * SpriteScreenExtent),
.y = @intCast(c_int, j * SpriteScreenExtent),
.w = SpriteScreenExtent,
.h = SpriteScreenExtent,
};
// Draw base cell sprite
{
const sprite_sheet_pos = get_tile_index(cell, gfx_cell, game_state.is_ended);
const sprite_sheet_rect = get_sprite_sheet_rect(sprite_sheet_pos);
_ = c.SDL_RenderCopy(ren, sprite_sheet_texture, &sprite_sheet_rect, &sprite_output_pos_rect);
}
// Draw overlay on invalid move
if (gfx_cell.invalid_move_time_secs > 0.0) {
const alpha = gfx_cell.invalid_move_time_secs / InvalidMoveTimeSecs;
const sprite_sheet_rect = get_sprite_sheet_rect(.{ 8, 1 });
_ = c.SDL_SetTextureAlphaMod(sprite_sheet_texture, @floatToInt(u8, alpha * 255.0));
_ = c.SDL_RenderCopy(ren, sprite_sheet_texture, &sprite_sheet_rect, &sprite_output_pos_rect);
_ = c.SDL_SetTextureAlphaMod(sprite_sheet_texture, 255);
}
}
}
// Present
c.SDL_RenderPresent(ren);
last_frame_time_ms = current_frame_time_ms;
}
deallocate_2d_array(GfxState, allocator, gfx_board);
} | src/sdl2/sdl2_backend.zig |
const std = @import("std");
const assert = std.debug.assert;
const Allocator = std.mem.Allocator;
/// Caller must free returned memory.
pub fn latin1ToUtf8Alloc(allocator: Allocator, latin1_text: []const u8) ![]u8 {
var buffer = try std.ArrayList(u8).initCapacity(allocator, latin1_text.len);
errdefer buffer.deinit();
for (latin1_text) |c| switch (c) {
0...127 => try buffer.append(c),
else => {
try buffer.append(0xC0 | (c >> 6));
try buffer.append(0x80 | (c & 0x3f));
},
};
return buffer.toOwnedSlice();
}
/// buf must be twice as big as latin1_text to ensure that it
/// can contain the converted string
pub fn latin1ToUtf8(latin1_text: []const u8, buf: []u8) []u8 {
assert(buf.len >= latin1_text.len * 2);
var i: usize = 0;
for (latin1_text) |c| switch (c) {
0...127 => {
buf[i] = c;
i += 1;
},
else => {
buf[i] = 0xC0 | (c >> 6);
buf[i + 1] = 0x80 | (c & 0x3f);
i += 2;
},
};
return buf[0..i];
}
/// Returns true if all codepoints in the UTF-8 string
/// are within the range of Latin-1 characters
pub fn isUtf8AllLatin1(utf8_text: []const u8) bool {
var utf8_it = std.unicode.Utf8Iterator{
.bytes = utf8_text,
.i = 0,
};
while (utf8_it.nextCodepoint()) |codepoint| switch (codepoint) {
0x00...0xFF => {},
else => return false,
};
return true;
}
pub fn utf8ToLatin1Alloc(allocator: Allocator, utf8_text: []const u8) ![]u8 {
assert(isUtf8AllLatin1(utf8_text));
var buffer = try std.ArrayList(u8).initCapacity(allocator, utf8_text.len);
errdefer buffer.deinit();
var utf8_it = std.unicode.Utf8Iterator{ .bytes = utf8_text, .i = 0 };
while (utf8_it.nextCodepoint()) |codepoint| {
// this cast is guaranteed to work since we know the UTF-8 is made up
// of all Latin-1 characters
try buffer.append(@intCast(u8, codepoint));
}
return buffer.toOwnedSlice();
}
/// buf must be at least 1/2 the size of utf8_text
pub fn utf8ToLatin1(utf8_text: []const u8, buf: []u8) []u8 {
assert(isUtf8AllLatin1(utf8_text));
assert(buf.len >= utf8_text.len / 2);
var i: usize = 0;
var utf8_it = std.unicode.Utf8Iterator{ .bytes = utf8_text, .i = 0 };
while (utf8_it.nextCodepoint()) |codepoint| {
// this cast is guaranteed to work since we know the UTF-8 is made up
// of all Latin-1 characters
buf[i] = @intCast(u8, codepoint);
i += 1;
}
return buf[0..i];
}
test "latin1 to utf8 and back" {
var utf8_buf: [512]u8 = undefined;
var latin1_buf: [512]u8 = undefined;
const latin1 = "a\xE0b\xE6c\xEFd";
const utf8 = latin1ToUtf8(latin1, &utf8_buf);
try std.testing.expectEqualSlices(u8, "aàbæcïd", utf8);
const latin1_converted = utf8ToLatin1(utf8, &latin1_buf);
try std.testing.expectEqualSlices(u8, latin1, latin1_converted);
}
test "latin1 to utf8 alloc and back" {
const latin1 = "a\xE0b\xE6c\xEFd";
const utf8 = try latin1ToUtf8Alloc(std.testing.allocator, latin1);
defer std.testing.allocator.free(utf8);
try std.testing.expectEqualSlices(u8, "aàbæcïd", utf8);
const latin1_converted = try utf8ToLatin1Alloc(std.testing.allocator, utf8);
defer std.testing.allocator.free(latin1_converted);
try std.testing.expectEqualSlices(u8, latin1, latin1_converted);
}
test "is utf8 all latin1" {
var buf: [512]u8 = undefined;
const utf8 = latin1ToUtf8("abc\x01\x7F\x80\xFF", &buf);
try std.testing.expect(isUtf8AllLatin1(utf8));
try std.testing.expect(isUtf8AllLatin1("aàbæcïd"));
try std.testing.expect(!isUtf8AllLatin1("Д"));
} | src/latin1.zig |
const std = @import("std");
const minInt = std.math.minInt;
const maxInt = std.math.maxInt;
const assert = std.debug.assert;
pub const register = @import("register.zig");
pub const machine = @import("machine.zig");
pub const avx = @import("avx.zig");
usingnamespace(@import("types.zig"));
const Register = register.Register;
pub const OperandType = enum(u32) {
const num_pos = 0;
pub const Class = enum (u8) {
const Type = u8;
const mask = 0xff;
const pos = 8;
reg8 = 0x00,
reg16 = 0x01,
reg32 = 0x02,
reg64 = 0x03,
reg_seg,
reg_st,
reg_cr,
reg_dr,
reg_bnd,
reg_k,
mm,
xmm,
ymm,
zmm,
mem,
imm,
moffs,
ptr16_16,
ptr16_32,
_void,
vsib,
vm32x,
vm32y,
vm32z,
vm64x,
vm64y,
vm64z,
invalid = 0xfe,
none = 0xff,
pub fn asTag(self: Class) u16 {
return @intCast(u16, @enumToInt(self)) << Class.pos;
}
};
pub const MemClass = enum (u4) {
const pos = 16;
const Type = u4;
const mask = 0x0f;
no_mem = 0,
mem_void,
mem8,
mem16,
mem32,
mem64,
mem80,
mem128,
mem256,
mem512,
mem16_16,
mem16_32,
mem16_64,
};
pub const RmClass = enum (u1) {
const pos = 20;
const Type = u1;
const mask = 0x01;
no_rm = 0,
rm = 1,
};
pub const Modifier = enum (u3) {
const pos = 21;
const Type = u3;
const mask = 0x07;
no_mod = 0b000,
k = 0b001,
kz = 0b010,
sae = 0b011,
er = 0b100,
};
pub const Broadcast = enum(u2) {
const pos = 24;
const Type = u2;
const mask = 0x03;
no_bcst = 0b00,
m32bcst = 0b01,
m64bcst = 0b10,
};
pub const SpecialCase = enum (u2) {
const pos = 26;
const Type = u2;
const mask = 0x03;
no_special = 0,
low16 = 1,
match_larger_versions = 2,
};
pub fn create(
num: u8,
class: Class,
mem: MemClass,
rm: RmClass,
mod: Modifier,
bcst: Broadcast,
special: SpecialCase,
) u32 {
return (
@intCast(u32, num) << num_pos
| @intCast(u32, @enumToInt(class)) << Class.pos
| @intCast(u32, @enumToInt(mem)) << MemClass.pos
| @intCast(u32, @enumToInt(rm)) << RmClass.pos
| @intCast(u32, @enumToInt(mod)) << Modifier.pos
| @intCast(u32, @enumToInt(bcst)) << Broadcast.pos
| @intCast(u32, @enumToInt(special)) << SpecialCase.pos
);
}
pub fn create_basic(num: u8, reg_class: Class) u32 {
return create(num, reg_class, .no_mem, .no_rm, .no_mod, .no_bcst, .no_special);
}
pub fn create_rm(num: u8, reg_class: Class, mem: MemClass) u32 {
return create(num, reg_class, mem, .rm, .no_mod, .no_bcst, .no_special);
}
fn _getCommon(self: OperandType, comptime T: type) T {
return @intToEnum(T, @intCast(T.Type, (@enumToInt(self) >> T.pos) & T.mask));
}
pub fn getNum(self: OperandType) u8 {
return @intCast(u8, (@enumToInt(self) >> num_pos) & 0xff);
}
pub fn getClass(self: OperandType) Class {
return self._getCommon(Class);
}
pub fn getMemClass(self: OperandType) MemClass {
return self._getCommon(MemClass);
}
pub fn getRmClass(self: OperandType) RmClass {
return self._getCommon(RmClass);
}
pub fn getModifier(self: OperandType) Modifier {
return self._getCommon(Modifier);
}
pub fn getBroadcast(self: OperandType) Broadcast {
return self._getCommon(Broadcast);
}
pub fn getSpecialCase(self: OperandType) SpecialCase {
return self._getCommon(SpecialCase);
}
fn matchRmClass(template: OperandType, other: OperandType) bool {
// 0 = no_rm
// 1 = rm
return @enumToInt(other.getRmClass()) <= @enumToInt(template.getRmClass());
}
fn matchModifer(template: OperandType, other: OperandType) bool {
// no_mod = 0b000,
// k = 0b001,
// kz = 0b010,
// sae = 0b011,
// er = 0b100,
const temp_mod = template.getModifier();
const other_mod = other.getModifier();
return (
temp_mod == other_mod
or (temp_mod == .kz and other_mod == .k)
or (other_mod == .no_mod)
);
}
reg8 = create_basic(0, .reg8),
reg_al,
reg_cl,
reg_dl,
reg_bl,
reg16 = create_basic(0, .reg16),
reg_ax,
reg_cx,
reg_dx,
reg_bx,
reg32 = create_basic(0, .reg32),
reg_eax,
reg_ecx,
reg_edx,
reg_ebx,
reg64 = create_basic(0, .reg64),
reg_rax,
reg_rcx,
reg_rdx,
reg_rbx,
reg_seg = create_basic(0, .reg_seg),
reg_es = create_basic(1, .reg_seg),
reg_cs,
reg_ss,
reg_ds,
reg_fs,
reg_gs = create_basic(6, .reg_seg),
reg_st = create_basic(0, .reg_st),
reg_st0,
reg_st1,
reg_st2,
reg_st3,
reg_st4,
reg_st5,
reg_st6,
reg_st7 = create_basic(8, .reg_st),
reg_cr = create_basic(0, .reg_cr),
reg_cr0,
reg_cr1,
reg_cr2,
reg_cr3,
reg_cr4,
reg_cr5,
reg_cr6,
reg_cr7,
reg_cr8,
reg_cr9,
reg_cr10,
reg_cr11,
reg_cr12,
reg_cr13,
reg_cr14,
reg_cr15 = create_basic(16, .reg_cr),
reg_dr = create_basic(0, .reg_dr),
reg_dr0,
reg_dr1,
reg_dr2,
reg_dr3,
reg_dr4,
reg_dr5,
reg_dr6,
reg_dr7,
reg_dr8,
reg_dr9,
reg_dr10,
reg_dr11,
reg_dr12,
reg_dr13,
reg_dr14,
reg_dr15 = create_basic(16, .reg_dr),
mm = create_basic(0, .mm),
mm0,
mm1,
mm2,
mm3,
mm4,
mm5,
mm6,
mm7 = create_basic(8, .mm),
xmm = create_basic(0, .xmm),
xmm0,
xmm1,
xmm2,
xmm3,
xmm4,
xmm5,
xmm6,
xmm7,
xmm8,
xmm9,
xmm10,
xmm11,
xmm12,
xmm13,
xmm14,
xmm15,
xmm16,
xmm17,
xmm18,
xmm19,
xmm20,
xmm21,
xmm22,
xmm23,
xmm24,
xmm25,
xmm26,
xmm27,
xmm28,
xmm29,
xmm30,
xmm31 = create_basic(32, .xmm),
ymm = create_basic(0, .ymm),
ymm0,
ymm1,
ymm2,
ymm3,
ymm4,
ymm5,
ymm6,
ymm7,
ymm8,
ymm9,
ymm10,
ymm11,
ymm12,
ymm13,
ymm14,
ymm15,
ymm16,
ymm17,
ymm18,
ymm19,
ymm20,
ymm21,
ymm22,
ymm23,
ymm24,
ymm25,
ymm26,
ymm27,
ymm28,
ymm29,
ymm30,
ymm31 = create_basic(32, .ymm),
zmm = create_basic(0, .zmm),
zmm0,
zmm1,
zmm2,
zmm3,
zmm4,
zmm5,
zmm6,
zmm7,
zmm8,
zmm9,
zmm10,
zmm11,
zmm12,
zmm13,
zmm14,
zmm15,
zmm16,
zmm17,
zmm18,
zmm19,
zmm20,
zmm21,
zmm22,
zmm23,
zmm24,
zmm25,
zmm26,
zmm27,
zmm28,
zmm29,
zmm30,
zmm31 = create_basic(32, .zmm),
reg_k = create_basic(0, .reg_k),
reg_k0,
reg_k1,
reg_k2,
reg_k3,
reg_k4,
reg_k5,
reg_k6,
reg_k7 = create_basic(8, .reg_k),
bnd = create_basic(0, .reg_bnd),
bnd0,
bnd1,
bnd2,
bnd3 = create_basic(4, .reg_bnd),
rm8 = create_rm(0, .reg8, .mem8),
rm_reg8 = create_rm(0, .reg8, .no_mem),
rm_mem8 = create_rm(0, .mem, .mem8),
rm16 = create_rm(0, .reg16, .mem16),
rm_reg16 = create_rm(0, .reg16, .no_mem),
rm_mem16 = create_rm(0, .mem, .mem16),
rm32 = create_rm(0, .reg32, .mem32),
rm_reg32 = create_rm(0, .reg32, .no_mem),
rm_mem32 = create_rm(0, .mem, .mem32),
reg32_m8 = create_rm(0, .reg32, .mem8),
reg32_m16 = create_rm(0, .reg32, .mem16),
rm64 = create_rm(0, .reg64, .mem64),
rm_reg64 = create_rm(0, .reg64, .no_mem),
rm_mem64 = create_rm(0, .mem, .mem64),
// matches memory of any type
rm_mem = create_rm(0, .mem, .mem_void),
rm_mem80 = create_rm(0, .mem, .mem80),
rm_mem128 = create_rm(0, .mem, .mem128),
rm_mem256 = create_rm(0, .mem, .mem256),
rm_mem512 = create_rm(0, .mem, .mem512),
rm_m32bcst = create(0, .mem, .no_mem, .rm, .no_mod, .m32bcst, .no_special),
rm_m64bcst = create(0, .mem, .no_mem, .rm, .no_mod, .m64bcst, .no_special),
m16_16 = create_rm(0, .mem, .mem16_16),
m16_32 = create_rm(0, .mem, .mem16_32),
m16_64 = create_rm(0, .mem, .mem16_64),
rm_st = create_rm(0, .reg_st, .no_mem),
rm_seg = create_rm(0, .reg_seg, .no_mem),
rm_cr = create_rm(0, .reg_cr, .no_mem),
rm_dr = create_rm(0, .reg_dr, .no_mem),
rm_k = create_rm(0, .reg_k, .no_mem),
rm_bnd = create_rm(0, .reg_bnd, .no_mem),
rm_mm = create_rm(0, .mm, .no_mem),
rm_xmml = create(0, .xmm, .no_mem, .rm, .no_mod, .no_bcst, .low16),
rm_ymml = create(0, .ymm, .no_mem, .rm, .no_mod, .no_bcst, .low16),
rm_xmm = create_rm(0, .xmm, .no_mem),
rm_ymm = create_rm(0, .ymm, .no_mem),
rm_zmm = create_rm(0, .zmm, .no_mem),
rm_xmm_kz = create(0, .xmm, .no_mem, .rm, .kz, .no_bcst, .no_special),
rm_ymm_kz = create(0, .ymm, .no_mem, .rm, .kz, .no_bcst, .no_special),
rm_zmm_kz = create(0, .zmm, .no_mem, .rm, .kz, .no_bcst, .no_special),
moffs = create_basic(0, .moffs),
moffs8,
moffs16,
moffs32,
moffs64,
_void = create_basic(0, ._void),
_void8,
_void16,
_void32,
_void64,
invalid = create_basic(0, .invalid),
none = create_basic(0, .none),
imm = create_basic(0, .imm),
// imm_1,
imm8 = create_basic(2, .imm),
imm16,
imm32,
imm64,
imm_any = create(0, .imm, .no_mem, .no_rm, .no_mod, .no_bcst, .match_larger_versions),
imm_1,
imm8_any = create(2, .imm, .no_mem, .no_rm, .no_mod, .no_bcst, .match_larger_versions),
imm16_any,
imm32_any,
imm64_any,
ptr16_16 = create_basic(0, .ptr16_16),
ptr16_32 = create_basic(0, .ptr16_32),
mm_m64 = create(0, .mm, .mem64, .rm, .no_mod, .no_bcst, .no_special),
bnd_m64 = create(0, .reg_bnd, .mem64, .rm, .no_mod, .no_bcst, .no_special),
bnd_m128 = create(0, .reg_bnd, .mem128, .rm, .no_mod, .no_bcst, .no_special),
reg32_er = create(0, .reg32, .no_mem, .rm, .er, .no_bcst, .no_special),
reg64_er = create(0, .reg64, .no_mem, .rm, .er, .no_bcst, .no_special),
rm32_er = create(0, .reg32, .mem32, .rm, .er, .no_bcst, .no_special),
rm64_er = create(0, .reg64, .mem64, .rm, .er, .no_bcst, .no_special),
rm_mem64_kz = create(0, .mem, .mem64, .rm, .kz, .no_bcst, .no_special),
rm_mem128_k = create(0, .mem, .mem128, .rm, .k, .no_bcst, .no_special),
rm_mem256_k = create(0, .mem, .mem256, .rm, .k, .no_bcst, .no_special),
rm_mem512_k = create(0, .mem, .mem512, .rm, .k, .no_bcst, .no_special),
rm_mem128_kz = create(0, .mem, .mem128, .rm, .kz, .no_bcst, .no_special),
rm_mem256_kz = create(0, .mem, .mem256, .rm, .kz, .no_bcst, .no_special),
rm_mem512_kz = create(0, .mem, .mem512, .rm, .kz, .no_bcst, .no_special),
reg_k_k = create(0, .reg_k, .no_mem, .no_rm, .k, .no_bcst, .no_special),
reg_k_kz = create(0, .reg_k, .no_mem, .no_rm, .kz, .no_bcst, .no_special),
k_m8 = create(0, .reg_k, .mem8, .rm, .no_mod, .no_bcst, .no_special),
k_m16 = create(0, .reg_k, .mem16, .rm, .no_mod, .no_bcst, .no_special),
k_m32 = create(0, .reg_k, .mem32, .rm, .no_mod, .no_bcst, .no_special),
k_m64 = create(0, .reg_k, .mem64, .rm, .no_mod, .no_bcst, .no_special),
// TODO: probably should support .low16 variants
// VSIB memory addressing
vm32xl = create(0, .vm32x, .no_mem, .rm, .no_mod, .no_bcst, .low16),
vm32yl = create(0, .vm32y, .no_mem, .rm, .no_mod, .no_bcst, .low16),
//
vm64xl = create(0, .vm64x, .no_mem, .rm, .no_mod, .no_bcst, .low16),
vm64yl = create(0, .vm64y, .no_mem, .rm, .no_mod, .no_bcst, .low16),
//
vm32x = create(0, .vm32x, .no_mem, .rm, .no_mod, .no_bcst, .no_special),
vm32y = create(0, .vm32y, .no_mem, .rm, .no_mod, .no_bcst, .no_special),
vm32z = create(0, .vm32z, .no_mem, .rm, .no_mod, .no_bcst, .no_special),
vm32x_k = create(0, .vm32x, .no_mem, .rm, .k, .no_bcst, .no_special),
vm32y_k = create(0, .vm32y, .no_mem, .rm, .k, .no_bcst, .no_special),
vm32z_k = create(0, .vm32z, .no_mem, .rm, .k, .no_bcst, .no_special),
//
vm64x = create(0, .vm64x, .no_mem, .rm, .no_mod, .no_bcst, .no_special),
vm64y = create(0, .vm64y, .no_mem, .rm, .no_mod, .no_bcst, .no_special),
vm64z = create(0, .vm64z, .no_mem, .rm, .no_mod, .no_bcst, .no_special),
vm64x_k = create(0, .vm64x, .no_mem, .rm, .k, .no_bcst, .no_special),
vm64y_k = create(0, .vm64y, .no_mem, .rm, .k, .no_bcst, .no_special),
vm64z_k = create(0, .vm64z, .no_mem, .rm, .k, .no_bcst, .no_special),
/// Only matches xmm[0..15]
xmml = create(0, .xmm, .no_mem, .no_rm, .no_mod, .no_bcst, .low16),
xmml_m8 = create(0, .xmm, .mem8, .rm, .no_mod, .no_bcst, .low16),
xmml_m16 = create(0, .xmm, .mem16, .rm, .no_mod, .no_bcst, .low16),
xmml_m32 = create(0, .xmm, .mem32, .rm, .no_mod, .no_bcst, .low16),
xmml_m64 = create(0, .xmm, .mem64, .rm, .no_mod, .no_bcst, .low16),
xmml_m128 = create(0, .xmm, .mem128, .rm, .no_mod, .no_bcst, .low16),
/// Only matches ymm[0..15]
ymml = create(0, .ymm, .no_mem, .no_rm, .no_mod, .no_bcst, .low16),
ymml_m256 = create(0, .ymm, .mem256, .rm, .no_mod, .no_bcst, .low16),
/// xmm[0..31]
xmm_k = create(0, .xmm, .no_mem, .no_rm, .k, .no_bcst, .no_special),
xmm_kz = create(0, .xmm, .no_mem, .no_rm, .kz, .no_bcst, .no_special),
xmm_sae = create(0, .xmm, .no_mem, .no_rm, .sae, .no_bcst, .no_special),
xmm_er = create(0, .xmm, .no_mem, .no_rm, .er, .no_bcst, .no_special),
xmm_m8 = create(0, .xmm, .mem8, .rm, .no_mod, .no_bcst, .no_special),
xmm_m16 = create(0, .xmm, .mem16, .rm, .no_mod, .no_bcst, .no_special),
xmm_m16_kz = create(0, .xmm, .mem16, .rm, .kz, .no_bcst, .no_special),
xmm_m32 = create(0, .xmm, .mem32, .rm, .no_mod, .no_bcst, .no_special),
xmm_m32_kz = create(0, .xmm, .mem32, .rm, .kz, .no_bcst, .no_special),
xmm_m32_er = create(0, .xmm, .mem32, .rm, .er, .no_bcst, .no_special),
xmm_m32_sae = create(0, .xmm, .mem32, .rm, .sae, .no_bcst, .no_special),
xmm_m64 = create(0, .xmm, .mem64, .rm, .no_mod, .no_bcst, .no_special),
xmm_m64_kz = create(0, .xmm, .mem64, .rm, .kz, .no_bcst, .no_special),
xmm_m64_er = create(0, .xmm, .mem64, .rm, .er, .no_bcst, .no_special),
xmm_m64_sae = create(0, .xmm, .mem64, .rm, .sae, .no_bcst, .no_special),
xmm_m64_m32bcst = create(0, .xmm, .mem64, .rm, .no_mod, .m32bcst, .no_special),
xmm_m128 = create(0, .xmm, .mem128, .rm, .no_mod, .no_bcst, .no_special),
xmm_m128_kz = create(0, .xmm, .mem128, .rm, .kz, .no_bcst, .no_special),
xmm_m128_sae = create(0, .xmm, .mem128, .rm, .sae, .no_bcst, .no_special),
xmm_m128_er = create(0, .xmm, .mem128, .rm, .er, .no_bcst, .no_special),
xmm_m128_m32bcst = create(0, .xmm, .mem128, .rm, .no_mod, .m32bcst, .no_special),
xmm_m128_m32bcst_sae = create(0, .xmm, .mem128, .rm, .sae, .m32bcst, .no_special),
xmm_m128_m32bcst_er = create(0, .xmm, .mem128, .rm, .er, .m32bcst, .no_special),
xmm_m128_m64bcst = create(0, .xmm, .mem128, .rm, .no_mod, .m64bcst, .no_special),
xmm_m128_m64bcst_sae = create(0, .xmm, .mem128, .rm, .sae, .m64bcst, .no_special),
xmm_m128_m64bcst_er = create(0, .xmm, .mem128, .rm, .er, .m64bcst, .no_special),
/// ymm[0..31]
ymm_k = create(0, .ymm, .no_mem, .no_rm, .k, .no_bcst, .no_special),
ymm_kz = create(0, .ymm, .no_mem, .no_rm, .kz, .no_bcst, .no_special),
ymm_sae = create(0, .ymm, .no_mem, .no_rm, .sae, .no_bcst, .no_special),
ymm_er = create(0, .ymm, .no_mem, .no_rm, .er, .no_bcst, .no_special),
ymm_m256 = create(0, .ymm, .mem256, .rm, .no_mod, .no_bcst, .no_special),
ymm_m256_kz = create(0, .ymm, .mem256, .rm, .kz, .no_bcst, .no_special),
ymm_m256_sae = create(0, .ymm, .mem256, .rm, .sae, .no_bcst, .no_special),
ymm_m256_er = create(0, .ymm, .mem256, .rm, .er, .no_bcst, .no_special),
ymm_m256_m32bcst = create(0, .ymm, .mem256, .rm, .no_mod, .m32bcst, .no_special),
ymm_m256_m32bcst_sae = create(0, .ymm, .mem256, .rm, .sae, .m32bcst, .no_special),
ymm_m256_m32bcst_er = create(0, .ymm, .mem256, .rm, .er, .m32bcst, .no_special),
ymm_m256_m64bcst = create(0, .ymm, .mem256, .rm, .no_mod, .m64bcst, .no_special),
ymm_m256_m64bcst_sae = create(0, .ymm, .mem256, .rm, .sae, .m64bcst, .no_special),
ymm_m256_m64bcst_er = create(0, .ymm, .mem256, .rm, .er, .m64bcst, .no_special),
/// Zmm[0..31]
zmm_k = create(0, .zmm, .no_mem, .no_rm, .k, .no_bcst, .no_special),
zmm_kz = create(0, .zmm, .no_mem, .no_rm, .kz, .no_bcst, .no_special),
zmm_sae = create(0, .zmm, .no_mem, .no_rm, .sae, .no_bcst, .no_special),
zmm_er = create(0, .zmm, .no_mem, .no_rm, .er, .no_bcst, .no_special),
zmm_m512 = create(0, .zmm, .mem512, .rm, .no_mod, .no_bcst, .no_special),
zmm_m512_kz = create(0, .zmm, .mem512, .rm, .kz, .no_bcst, .no_special),
zmm_m512_sae = create(0, .zmm, .mem512, .rm, .sae, .no_bcst, .no_special),
zmm_m512_er = create(0, .zmm, .mem512, .rm, .er, .no_bcst, .no_special),
zmm_m512_m32bcst = create(0, .zmm, .mem512, .rm, .no_mod, .m32bcst, .no_special),
zmm_m512_m32bcst_sae = create(0, .zmm, .mem512, .rm, .sae, .m32bcst, .no_special),
zmm_m512_m32bcst_er = create(0, .zmm, .mem512, .rm, .er, .m32bcst, .no_special),
zmm_m512_m64bcst = create(0, .zmm, .mem512, .rm, .no_mod, .m64bcst, .no_special),
zmm_m512_m64bcst_sae = create(0, .zmm, .mem512, .rm, .sae, .m64bcst, .no_special),
zmm_m512_m64bcst_er = create(0, .zmm, .mem512, .rm, .er, .m64bcst, .no_special),
_,
fn isLowReg(self: OperandType) bool {
const max_reg_num = 15 + 1;
return (@enumToInt(self) & 0xff) <= max_reg_num ;
}
pub fn fromRegister(reg: Register) OperandType {
if (reg.registerType() != .General) {
return @intToEnum(OperandType, @enumToInt(reg) + 1);
}
// General purpose register
if (reg.number() <= Register.BX.number()) {
const size_tag: u16 = @as(u16, @enumToInt(reg) & 0x30) << 4;
const num_tag: u16 = @as(u16, @enumToInt(reg) & 0x03) + 1;
return @intToEnum(OperandType, size_tag | num_tag);
} else {
return switch (reg.bitSize()) {
.Bit8 => OperandType.reg8,
.Bit16 => OperandType.reg16,
.Bit32 => OperandType.reg32,
.Bit64 => OperandType.reg64,
else => unreachable,
};
}
}
pub fn fromImmediate(imm: Immediate) OperandType {
switch (imm.size) {
.Imm8 => return OperandType.imm8,
.Imm16 => return OperandType.imm16,
.Imm32 => return OperandType.imm32,
.Imm64 => return OperandType.imm64,
.Imm8_any => {
if (imm.value() == 1) {
return OperandType.imm_1;
} else {
return OperandType.imm8_any;
}
},
.Imm16_any => return OperandType.imm16_any,
.Imm32_any => return OperandType.imm32_any,
.Imm64_any => return OperandType.imm64_any,
}
}
pub fn fromAddress(addr: Address) OperandType {
return switch (addr) {
.MOffset => |moff| switch (moff.operand_size.bitSize()) {
.Bit8 => OperandType.moffs8,
.Bit16 => OperandType.moffs16,
.Bit32 => OperandType.moffs32,
.Bit64 => OperandType.moffs64,
else => unreachable,
},
.FarJmp => switch(addr.getDisp().bitSize()) {
.Bit16 => OperandType.ptr16_16,
.Bit32 => OperandType.ptr16_32,
else => unreachable,
},
};
}
pub fn fromRegisterPredicate(reg_pred: avx.RegisterPredicate) OperandType {
return switch (reg_pred.z) {
.Merge => switch (reg_pred.reg.registerType()) {
.XMM => OperandType.xmm_k,
.YMM => OperandType.ymm_k,
.ZMM => OperandType.zmm_k,
.Mask => OperandType.reg_k_k,
else => OperandType.invalid,
},
.Zero => switch (reg_pred.reg.registerType()) {
.XMM => OperandType.xmm_kz,
.YMM => OperandType.ymm_kz,
.ZMM => OperandType.zmm_kz,
.Mask => OperandType.reg_k_kz,
else => OperandType.invalid,
},
};
}
pub fn fromModRm(modrm: ModRm) OperandType {
return switch (modrm) {
.Reg => |reg| switch (reg.registerType()) {
.General => switch (reg.bitSize()) {
.Bit8 => OperandType.rm_reg8,
.Bit16 => OperandType.rm_reg16,
.Bit32 => OperandType.rm_reg32,
.Bit64 => OperandType.rm_reg64,
else => unreachable,
},
.Float => OperandType.reg_st,
.Segment => OperandType.rm_seg,
.Control => OperandType.rm_cr,
.Debug => OperandType.rm_dr,
.MMX => OperandType.rm_mm,
.XMM => if (reg.number() <= 15) OperandType.rm_xmml else OperandType.rm_xmm,
.YMM => if (reg.number() <= 15) OperandType.rm_ymml else OperandType.rm_ymm,
.ZMM => OperandType.rm_zmm,
.Mask => OperandType.rm_k,
.Bound => OperandType.rm_bnd,
},
.Mem,
.Mem16,
.Sib,
.Rel => switch (modrm.operandDataSize()) {
.Void => OperandType.rm_mem,
.BYTE => OperandType.rm_mem8,
.WORD => OperandType.rm_mem16,
.DWORD => OperandType.rm_mem32,
.QWORD => OperandType.rm_mem64,
.TBYTE => OperandType.rm_mem80,
.OWORD, .XMM_WORD => OperandType.rm_mem128,
.YMM_WORD => OperandType.rm_mem256,
.ZMM_WORD => OperandType.rm_mem512,
.DWORD_BCST => OperandType.rm_m32bcst,
.QWORD_BCST => OperandType.rm_m64bcst,
.FAR_WORD => OperandType.m16_16,
.FAR_DWORD => OperandType.m16_32,
.FAR_QWORD => OperandType.m16_64,
// TODO:
else => unreachable,
},
.VecSib => |vsib| switch (modrm.operandDataSize()) {
.DWORD => switch (vsib.index.registerType()) {
.XMM => if (vsib.index.number() <= 15) OperandType.vm32xl else OperandType.vm32x,
.YMM => if (vsib.index.number() <= 15) OperandType.vm32yl else OperandType.vm32y,
.ZMM => OperandType.vm32z,
else => OperandType.invalid,
},
.QWORD => switch (vsib.index.registerType()) {
.XMM => if (vsib.index.number() <= 15) OperandType.vm64xl else OperandType.vm64x,
.YMM => if (vsib.index.number() <= 15) OperandType.vm64yl else OperandType.vm64y,
.ZMM => OperandType.vm64z,
else => OperandType.invalid,
},
else => OperandType.invalid,
},
};
}
pub fn fromRmPredicate(rm_pred: avx.RmPredicate) OperandType {
const modifier = switch (rm_pred.z) {
.Zero => OperandType.Modifier.kz,
else => OperandType.Modifier.k,
};
const base_type = OperandType.fromModRm(rm_pred.rm);
const mod_tag = @intCast(u32, @enumToInt(modifier)) << Modifier.pos;
const mod_type = @enumToInt(base_type) | mod_tag;
return @intToEnum(OperandType, mod_type);
}
pub fn fromSae(reg_sae: avx.RegisterSae) OperandType {
return switch (reg_sae.sae) {
.SAE, .AE => switch (reg_sae.reg.registerType()) {
.XMM => OperandType.xmm_sae,
.YMM => OperandType.ymm_sae,
.ZMM => OperandType.zmm_sae,
else => unreachable,
},
.RN_SAE, .RD_SAE, .RU_SAE, .RZ_SAE => switch (reg_sae.reg.registerType()) {
.General => switch (reg_sae.reg.bitSize()) {
.Bit32 => OperandType.reg32_er,
.Bit64 => OperandType.reg64_er,
else => unreachable,
},
.XMM => OperandType.xmm_er,
.YMM => OperandType.ymm_er,
.ZMM => OperandType.zmm_er,
else => unreachable,
},
};
}
pub fn matchTemplate(template: OperandType, other: OperandType) bool {
const num = template.getNum();
const class = template.getClass();
const other_num = other.getNum();
const other_special = other.getSpecialCase();
// if the template and operand type have matching classes
const class_match = (class == other.getClass());
// if the OperandType have matching register numbers:
// eg: template .xmm matches xmm0..xmm31
// eg: template .xmm1 matches only .xmm1
const num_match = (num == 0) or (num == other.getNum());
// if template is rm type, then it can match other OperandType with or without rm
// if template is no_rm type,
// eg: rm8 matches either .rm_reg8 or .reg8
// eg: reg8 matches only .reg8 but not .rm_reg8
const rm_match = matchRmClass(template, other);
// if template allows memory operand and other OperandType matches that memory type
// eg: .xmm_m128 matches .rm_mem128
const mem_match = (other.getClass() == .mem and (template.getMemClass() == other.getMemClass()));
// if template allows a broadcast and other OperandType is a matching broadcast type
// eg: .xmm_m128_m32bcst matches .rm_m32bcst
const bcst_match = (
other.getClass() == .mem
and (template.getBroadcast() != .no_bcst)
and (template.getBroadcast() == other.getBroadcast())
);
// For user supplied immediates without an explicit size are allowed to match
// against larger immediate sizes:
// * .imm8_any <-> imm8, imm16, imm32, imm64
// * .imm16_any <-> imm16, imm32, imm64
// * .imm32_any <-> imm32, imm64
// * .imm64_any <-> imm64
// NOTE: .match_larger_versions only used for immediates
const special_match = (other_special == .match_larger_versions and num >= other_num);
// Matches register number <= 15.
// eg: .xmml (.low16) matches .xmm0..15
// eg: .xmm (.no_mod) matches .xmm0..31
const invalid_size = (template.getSpecialCase() == .low16 and other_num != 0 and other_num > 16);
// eg: rm_xmml (num = 0 and .low16 and .rm)
const invalid_size_rm = (
other_num == 0 and template.getSpecialCase() == .low16 and other.getSpecialCase() != .low16
);
// modifier type matches ie sae/er/mask
// eg: .xmm_kz matches .xmm and .xmm_k and .xmm_kz
// eg: .reg_k_k matches .reg_k and reg_k_k
// eg: .xmm_sae matches .xmm and .xmm_sae
// eg: .rm32_er matches .rm_reg8 and rm_reg8_er and rm_mem32 and rm_mem32_er
const modifier_match = matchModifer(template, other);
const extra_critera = class != .mem and !invalid_size and !invalid_size_rm;
const normal_class_match = (num_match and class_match and rm_match and modifier_match and extra_critera);
const special_class_match = (special_match and class_match);
const mem_class_match = mem_match or bcst_match;
return normal_class_match or special_class_match or mem_class_match;
}
};
/// Possible displacement sizes for 32 and 64 bit addressing
const DispSize = enum(u8) {
None = 0,
Disp8 = 1,
Disp16 = 2,
Disp32 = 4,
};
const MemDisp = struct {
displacement: i32 = 0,
size: DispSize = .None,
pub fn create(dis_size: DispSize, dis: i32) @This() {
return @This() {
.displacement = dis,
.size = dis_size,
};
}
pub fn disp(max_size: DispSize, dis: i32) @This() {
if (dis == 0) {
return @This().create(.None, 0);
} else if (minInt(i8) <= dis and dis <= maxInt(i8)) {
return @This().create(.Disp8, dis);
} else if (max_size == .Disp16) {
assert(minInt(i16) <= dis and dis <= maxInt(i16));
return @This().create(.Disp16, dis);
} else if (max_size == .Disp32) {
assert(minInt(i32) <= dis and dis <= maxInt(i32));
return @This().create(.Disp32, dis);
} else {
unreachable;
}
}
pub fn value(self: @This()) i32 {
return self.displacement;
}
pub fn dispSize(self: @This()) DispSize {
return self.size;
}
pub fn bitSize(self: @This()) BitSize {
return @intToEnum(BitSize, @enumToInt(self.size));
}
};
const SibScale = enum(u2) {
Scale1 = 0b00,
Scale2 = 0b01,
Scale4 = 0b10,
Scale8 = 0b11,
pub fn value(self: @This()) u8 {
return @as(u8, 1) << @enumToInt(self);
}
pub fn scale(s: u8) SibScale {
return switch (s) {
1 => .Scale1,
2 => .Scale2,
4 => .Scale4,
8 => .Scale8,
else => unreachable,
};
}
};
/// Encodes memory addressing of the form: [BP,BX] + [DI,SI] + disp0/8/16
const Memory16Bit = struct {
/// Base register either BP or BX
base: ?Register,
/// Index register either DI or SI
index: ?Register,
/// 0, 8 or 16 bit memory displacement
disp: MemDisp,
/// Size of the data this memory address points to
data_size: DataSize,
/// Segment register to offset the memory address
segment: Segment,
pub fn hasValidRegisters(self: Memory16Bit) bool {
if (self.base) |base| {
switch (base) {
.BX, .BP => {},
else => return false,
}
}
if (self.index) |index| {
switch (index) {
.DI, .SI => {},
else => return false,
}
}
return true;
}
};
/// Encodes memory addressing of the form: [r/m + disp]
const Memory = struct {
reg: Register,
/// 0, 8 or 32 bit memory displacement
disp: MemDisp,
data_size: DataSize,
segment: Segment,
};
/// Encodes memory addressing using the SIB byte: [(s * index) + base + disp]
const MemorySib = struct {
scale: SibScale,
base: ?Register,
index: ?Register,
disp: MemDisp,
data_size: DataSize,
segment: Segment,
};
/// Encodes VSIB memory addresing: [(s * vec_index) + base + disp]
const MemoryVecSib = struct {
scale: SibScale,
base: ?Register,
index: Register,
disp: MemDisp,
data_size: DataSize,
segment: Segment,
};
const RelRegister = enum {
EIP,
RIP,
pub fn bitSize(self: @This()) BitSize {
return switch(self) {
.EIP => .Bit32,
.RIP => .Bit64,
};
}
};
/// Encodes memory addressing relative to RIP/EIP: [RIP + disp] or [EIP + disp]
const RelMemory = struct {
reg: RelRegister,
disp: i32,
data_size: DataSize,
segment: Segment,
pub fn relMemory(seg: Segment, data_size: DataSize, reg: RelRegister, disp: i32) RelMemory {
return RelMemory {
.reg = reg,
.disp = disp,
.data_size = data_size,
.segment = seg,
};
}
};
pub const ModRmResult = struct {
needs_rex: bool = false,
needs_no_rex: bool = false,
prefixes: Prefixes = Prefixes {},
reg_size: BitSize = .None,
addressing_size: BitSize = .None,
data_size: DataSize = .Void,
rex_w: u1 = 0,
rex_r: u1 = 0,
rex_x: u1 = 0,
rex_b: u1 = 0,
evex_v: u1 = 0,
mod: u2 = 0,
reg: u3 = 0,
rm: u3 = 0,
sib: ?u8 = null,
disp_bit_size: BitSize = .None,
disp: i32 = 0,
segment: Segment = .DefaultSeg,
pub fn rexRequirements(self: *@This(), reg: Register, overides: Overides) void {
self.needs_rex = self.needs_rex or reg.needsRex();
self.needs_no_rex = self.needs_no_rex or reg.needsNoRex();
}
pub fn addMemDisp(self: *@This(), disp: var) void {
self.disp_bit_size = disp.bitSize();
self.disp = disp.value();
}
pub fn rex(self: @This(), w: u1) u8 {
return (
(0x40)
| (@as(u8, self.rex_w | w) << 3)
| (@as(u8, self.rex_r) << 2)
| (@as(u8, self.rex_x) << 1)
| (@as(u8, self.rex_b) << 0)
);
}
pub fn isRexRequired(self: @This()) bool {
return self.rex(0) != 0x40 or self.needs_rex;
}
pub fn modrm(self: @This()) u8 {
return (
(@as(u8, self.mod) << 6)
| (@as(u8, self.reg) << 3)
| (@as(u8, self.rm ) << 0)
);
}
};
pub const ModRmTag = enum {
Reg,
Mem16,
Mem,
Sib,
Rel,
VecSib,
};
/// Encodes an R/M operand
pub const ModRm = union(ModRmTag) {
Reg: Register,
Mem16: Memory16Bit,
Mem: Memory,
Sib: MemorySib,
Rel: RelMemory,
VecSib: MemoryVecSib,
pub fn operandSize(self: @This()) BitSize {
return switch (self) {
.Reg => |reg| reg.bitSize(),
.Mem16 => |mem| mem.data_size.bitSize(),
.Mem => |mem| mem.data_size.bitSize(),
.Sib => |sib| sib.data_size.bitSize(),
.Rel => |reg| reg.data_size.bitSize(),
.VecSib => |vsib| vsib.data_size.bitSize(),
};
}
pub fn operandDataSize(self: @This()) DataSize {
return switch (self) {
.Reg => |reg| reg.dataSize(),
.Mem16 => |mem| mem.data_size,
.Mem => |mem| mem.data_size,
.Sib => |sib| sib.data_size,
.Rel => |reg| reg.data_size,
.VecSib => |vsib| vsib.data_size,
};
}
pub fn operandDataType(self: @This()) DataType {
return switch (self) {
.Reg => |reg| DataType.Register,
.Mem16 => |mem| mem.data_size.dataType(),
.Mem => |mem| mem.data_size.dataType(),
.Sib => |sib| sib.data_size.dataType(),
.Rel => |reg| reg.data_size.dataType(),
.VecSib => |vsib| if (vsib.base) |reg| reg.bitSize() else .None,
};
}
pub fn encodeOpcodeRm(self: @This(), mode: Mode86, reg_bits: u3, overides: Overides) AsmError!ModRmResult {
const fake_reg = @intToEnum(Register, reg_bits + @enumToInt(Register.AX));
var res = try self.encodeReg(mode, fake_reg, overides);
res.reg_size = .None;
return res;
}
pub fn getDisplacement(self: @This()) MemDisp {
return switch (self) {
.Reg => |reg| MemDisp.create(.None, 0),
.Mem16 => |mem| mem.disp,
.Mem => |mem| mem.disp,
.Sib => |sib| sib.disp,
.Rel => |rel| MemDisp.create(.Disp32, rel.disp),
.VecSib => |vsib| vsib.disp,
};
}
pub fn setDisplacement(self: *@This(), disp: MemDisp) void {
switch (self.*) {
.Reg => unreachable,
.Mem16 => self.Mem16.disp = disp,
.Mem => self.Mem.disp = disp,
.Sib => self.Sib.disp = disp,
.Rel => self.Rel.disp = disp.displacement,
.VecSib => self.VecSib.disp = disp,
}
}
/// Compress or Expand displacement for disp8*N feature in AVX512
///
/// In AVX512 8 bit displacements are multiplied by some factor N which
/// is dependend on the instruction. So if
/// disp % N == 0 -> use 8 bit displacement (if the value fits)
/// disp % N != 0 -> we have to use a 16/32 bit displacement
pub fn scaleAvx512Displacement(self: *@This(), disp_mult: u8) void {
const mem_disp = self.getDisplacement();
if (
mem_disp.size == .None
or (disp_mult <= 1)
// rel memory can only use 32 bit displacement, so can't compress it
or (@as(ModRmTag, self.*) == .Rel)
) {
return;
}
// Broadcast overides the value of disp_mult
const disp_n = switch (self.operandDataSize()) {
.DWORD_BCST => 4,
.QWORD_BCST => 8,
else => disp_mult,
};
if (@rem(mem_disp.displacement, @intCast(i32, disp_n)) != 0) {
if (minInt(i8) <= mem_disp.displacement and mem_disp.displacement <= maxInt(i8)) {
// We have to use a larger displacement
const new_disp = switch (self.*) {
.Rel => unreachable,
.Mem16 => MemDisp.create(.Disp16, mem_disp.displacement),
else => MemDisp.create(.Disp32, mem_disp.displacement),
};
self.setDisplacement(new_disp);
}
} else {
const scaled = @divExact(mem_disp.displacement, @intCast(i32, disp_n));
if (std.math.minInt(i8) <= scaled and scaled <= std.math.maxInt(i8)) {
// can use a smaller displacement
const new_disp = MemDisp.create(.Disp8, scaled);
self.setDisplacement(new_disp);
}
}
}
pub fn encodeMem16(mem: Memory16Bit, mode:Mode86, modrm_reg: Register) AsmError!ModRmResult {
var res = ModRmResult{};
if (modrm_reg.needsRex()) {
return AsmError.InvalidMemoryAddressing;
}
// base ∈ {BX, BP, null}, index ∈ {DI, SI, null}
if (!mem.hasValidRegisters()) {
return AsmError.InvalidMemoryAddressing;
}
res.reg = modrm_reg.numberRm();
res.mod = switch (mem.disp.dispSize()) {
.None => 0b00,
.Disp8 => 0b01,
.Disp16 => 0b10,
.Disp32 => unreachable,
};
res.addMemDisp(mem.disp);
res.data_size = mem.data_size;
res.addressing_size = .Bit16;
res.segment = mem.segment;
const base = mem.base;
const index = mem.index;
if (base == null and index == null and mem.disp.dispSize() != .None) {
// [disp16] = 0b110
res.rm = 0b110;
res.disp_bit_size = .Bit16;
} else if (base != null and index != null) {
// [BX + SI] = 0b000
// [BX + DI] = 0b001
// [BP + SI] = 0b010
// [BP + DI] = 0b011
const base_val: u3 = if (base.? == .BP) 0b010 else 0;
const index_val: u3 = if (index.? == .DI) 0b001 else 0;
res.rm = 0b000 | base_val | index_val;
} else if (base == null and index != null) {
// [SI] = 0b100
// [DI] = 0b101
const index_val: u3 = if (index.? == .DI) 0b001 else 0;
res.rm = 0b100 | index_val;
} else if (base != null and index == null) {
// [BP] = 0b110 (use this when there is no displacement)
// [BX] = 0b111
if (mem.disp.dispSize() == .None and base.? == .BP) {
return AsmError.InvalidMemoryAddressing;
}
const base_val: u3 = if (base.? == .BX) 0b001 else 0;
res.rm = 0b110 | base_val;
} else {
return AsmError.InvalidMemoryAddressing;
}
return res;
}
// TODO: probably change the asserts in this function to errors
pub fn encodeReg(self: @This(), mode: Mode86, modrm_reg: Register, overides: Overides) AsmError!ModRmResult {
var res = ModRmResult{};
res.rex_r = modrm_reg.numberRex();
res.reg = modrm_reg.numberRm();
res.reg_size = modrm_reg.bitSize();
res.rexRequirements(modrm_reg, overides);
switch (self) {
.Reg => |reg| {
res.mod = 0b11;
res.rexRequirements(reg, overides);
res.rm = reg.numberRm();
res.rex_b = reg.numberRex();
res.data_size = reg.dataSize();
},
.Mem16 => |mem| res = try encodeMem16(mem, mode, modrm_reg),
.Mem => |mem| {
// Can't use SP or R12 without a SIB byte since they are used to encode it.
if ((mem.reg.name() == .SP) or (mem.reg.name() == .R12)){
return AsmError.InvalidMemoryAddressing;
}
res.data_size = mem.data_size;
res.addressing_size = mem.reg.bitSize();
res.segment = mem.segment;
if (mem.disp.dispSize() != .None) {
// ModRM addressing: [r/m + disp8/32]
switch (mem.disp.dispSize()) {
.Disp8 => res.mod = 0b01,
.Disp32 => res.mod = 0b10,
else => unreachable,
}
res.rm = mem.reg.numberRm();
res.rex_b = mem.reg.numberRex();
res.addMemDisp(mem.disp);
} else {
// ModRM addressing: [r/m]
// Can't use BP or R13 and no displacement without a SIB byte
// (it is used to encode RIP/EIP relative addressing)
if ((mem.reg.name() == .BP) or (mem.reg.name() == .R13)) {
return AsmError.InvalidMemoryAddressing;
}
res.mod = 0b00;
res.rm = mem.reg.numberRm();
res.rex_b = mem.reg.numberRex();
}
},
.Sib => |sib| {
var base: u3 = undefined;
var index: u3 = undefined;
res.mod = 0b00; // most modes use this value, so set it here
res.rm = Register.SP.numberRm(); // 0b100, magic value for SIB addressing
const disp_size = sib.disp.dispSize();
res.data_size = sib.data_size;
res.segment = sib.segment;
// Check that the base and index registers are valid (if present)
// and that their sizes match.
if (sib.base) |base_reg| {
res.addressing_size = base_reg.bitSize();
}
if (sib.index) |index_reg| {
if (res.addressing_size == .None) {
res.addressing_size = index_reg.bitSize();
} else {
if (res.addressing_size != index_reg.bitSize()) {
return AsmError.InvalidMemoryAddressing;
}
}
}
if (sib.base != null and sib.index != null and disp_size != .None) {
// SIB addressing: [base + (index * scale) + disp8/32]
if (sib.index.?.name() == .SP) {
return AsmError.InvalidMemoryAddressing;
}
switch (disp_size) {
.Disp8 => res.mod = 0b01,
.Disp32 => res.mod = 0b10,
else => unreachable,
}
// encode the base
base = sib.base.?.numberRm();
res.rex_b = sib.base.?.numberRex();
// encode the index
index = sib.index.?.numberRm();
res.rex_x = sib.index.?.numberRex();
// encode displacement
res.addMemDisp(sib.disp);
} else if (sib.base != null and sib.index == null and disp_size != .None) {
// SIB addressing: [base + disp8/32]
const magic_index = Register.SP;
switch (disp_size) {
.Disp8 => res.mod = 0b01,
.Disp32 => res.mod = 0b10,
else => unreachable,
}
// encode the base
base = sib.base.?.numberRm();
res.rex_b = sib.base.?.numberRex();
// encode magic index
index = magic_index.numberRm();
res.rex_x = magic_index.numberRex();
// encode displacement
res.addMemDisp(sib.disp);
} else if (disp_size == .None and sib.index != null and sib.base != null) {
// SIB addressing: [base + (index * s)]
if ((sib.base.?.name() == .BP) or (sib.base.?.name() == .R13)) {
return AsmError.InvalidMemoryAddressing;
}
base = sib.base.?.numberRm();
res.rex_b = sib.base.?.numberRex();
index = sib.index.?.numberRm();
res.rex_x = sib.index.?.numberRex();
} else if (disp_size == .Disp32 and sib.index != null and sib.base == null) {
// SIB addressing: [(index * s) + disp32]
if (sib.index.?.name() == .SP) {
return AsmError.InvalidMemoryAddressing;
}
const magic_base = switch (0) {
0 => Register.BP,
1 => Register.R13,
else => unreachable,
};
base = magic_base.numberRm();
res.rex_b = magic_base.numberRex();
index = sib.index.?.numberRm();
res.rex_x = sib.index.?.numberRex();
res.addMemDisp(sib.disp);
} else if (disp_size == .None and sib.index == null and sib.base != null) {
// SIB addressing: [base]
// NOTE: illegal to use BP or R13 as the base
if ((sib.base.?.name() == .BP) or (sib.base.?.name() == .R13)){
return AsmError.InvalidMemoryAddressing;
}
const magic_index = Register.SP;
base = sib.base.?.numberRm();
res.rex_b = sib.base.?.numberRex();
index = magic_index.numberRm();
res.rex_x = magic_index.numberRex();
} else if (disp_size == .Disp32 and sib.index == null and sib.base == null) {
// SIB addressing: [disp32]
const magic_index = Register.SP;
const magic_base = switch (0) {
0 => Register.BP,
1 => Register.R13,
else => unreachable,
};
base = magic_base.numberRm();
res.rex_b = magic_base.numberRex();
index = magic_index.numberRm();
res.rex_x = magic_index.numberRex();
res.addMemDisp(sib.disp);
} else {
// other forms are impossible to encode on x86
return AsmError.InvalidMemoryAddressing;
}
res.sib = (
(@as(u8, @enumToInt(sib.scale)) << 6)
| (@as(u8, index) << 3)
| (@as(u8, base) << 0)
);
},
.Rel => |rel| {
res.mod = 0b00;
// NOTE: We can use either SP or R13 for relative addressing.
// We use SP here because it works for both 32/64 bit.
const tmp_reg = switch (0) {
0 => Register.BP,
1 => Register.R13,
else => unreachable,
};
res.rm = tmp_reg.numberRm();
res.rex_b = tmp_reg.numberRex();
res.segment = rel.segment;
res.disp_bit_size = .Bit32;
res.disp = rel.disp;
res.data_size = rel.data_size;
res.addressing_size = switch (rel.reg) {
.EIP => .Bit32,
.RIP => .Bit64,
};
},
.VecSib => |vsib| {
var base: u3 = undefined;
const disp_size = vsib.disp.dispSize();
res.rm = Register.SP.numberRm(); // 0b100, magic value for SIB addressing
if (vsib.base == null) {
// [scale*index + disp32] (no base register)
if (disp_size == .None) {
return AsmError.InvalidMemoryAddressing;
}
// Magic register value for [s*index + disp32] addressing
const tmp_reg = switch (0) {
0 => Register.EBP,
1 => Register.R13D,
else => unreachable,
};
res.mod = 0b00;
res.disp_bit_size = .Bit32;
res.disp = vsib.disp.value();
base = tmp_reg.numberRm();
res.rex_b = tmp_reg.numberRex();
res.addressing_size = if (mode == .x64) .Bit64 else .Bit32;
} else {
if (
disp_size == .None
and vsib.base.?.numberRm() == Register.BP.numberRm()
) {
return AsmError.InvalidMemoryAddressing;
}
switch (disp_size) {
.None => res.mod = 0b00,
.Disp8 => res.mod = 0b01,
.Disp32 => res.mod = 0b10,
.Disp16 => unreachable,
}
base = vsib.base.?.numberRm();
res.rex_b = vsib.base.?.numberRex();
res.addMemDisp(vsib.disp);
res.addressing_size = vsib.base.?.bitSize();
}
if (!vsib.index.isVector()) {
return AsmError.InvalidMemoryAddressing;
}
const index = vsib.index.numberRm();
res.rex_x = vsib.index.numberRex();
res.evex_v = vsib.index.numberEvex();
res.data_size = vsib.data_size;
res.segment = vsib.segment;
res.sib = (
(@as(u8, @enumToInt(vsib.scale)) << 6)
| (@as(u8, index) << 3)
| (@as(u8, base) << 0)
);
},
}
if (res.segment != .DefaultSeg) {
res.prefixes.addSegmentOveride(res.segment);
}
try res.prefixes.addOverides(
mode, &res.rex_w, res.addressing_size, overides
);
return res;
}
pub fn register(reg: Register) ModRm {
return ModRm { .Reg = reg };
}
pub fn relMemory(seg: Segment, data_size: DataSize, reg: RelRegister, disp: i32) ModRm {
return ModRm { .Rel = RelMemory.relMemory(seg, data_size, reg, disp) };
}
pub fn memory16Bit(
seg: Segment,
data_size: DataSize,
base: ?Register,
index: ?Register,
disp: i16
) ModRm {
var displacement: MemDisp = undefined;
if (base == null and index == null) {
// need to use 16 bit displacement
displacement = MemDisp.create(.Disp16, disp);
} else {
displacement = MemDisp.disp(.Disp16, disp);
}
return ModRm {
.Mem16 = Memory16Bit {
.base = base,
.index = index,
.disp = displacement,
.data_size = data_size,
.segment = seg,
}
};
}
/// data_size [seg: reg + disp]
pub fn memoryRm(seg: Segment, data_size: DataSize, reg: Register, disp: i32) ModRm {
var displacement: MemDisp = undefined;
// can encode these, but need to choose 8 bit displacement
if ((reg.name() == .BP or reg.name() == .R13) and disp == 0) {
displacement = MemDisp.create(.Disp8, 0);
} else {
displacement = MemDisp.disp(.Disp32, disp);
}
return ModRm {
.Mem = Memory {
.reg = reg,
.disp = displacement,
.data_size = data_size,
.segment = seg,
}
};
}
/// data_size [reg + disp8]
pub fn memoryRm8(seg: Segment, data_size: DataSize, reg: Register, disp: i8) ModRm {
return ModRm {
.Mem = Memory {
.reg = reg,
.disp = MemDisp.create(.Disp8, disp),
.data_size = data_size,
.segment = seg,
}
};
}
/// data_size [reg + disp32]
pub fn memoryRm32(seg: Segment, data_size: DataSize, reg: Register, disp: i32) ModRm {
return ModRm {
.Mem = Memory {
.reg = reg,
.disp = MemDisp.create(.Disp32, disp),
.data_size = data_size,
.segment = seg,
}
};
}
/// data_size [(scale*index) + base + disp8]
pub fn memorySib8(seg: Segment, data_size: DataSize, scale: u8, index: ?Register, base: ?Register, disp8: i8) ModRm {
return ModRm {
.Sib = MemorySib {
.scale = SibScale.scale(scale),
.index = index,
.base = base,
.disp = MemDisp.create(.Disp8, disp8),
.data_size = data_size,
.segment = seg,
}
};
}
/// data_size [(scale*index) + base + disp32]
pub fn memorySib32(seg: Segment, data_size: DataSize, scale: u8, index: ?Register, base: ?Register, disp32: i32) ModRm {
return ModRm {
.Sib = MemorySib {
.scale = SibScale.scale(scale),
.index = index,
.base = base,
.disp = MemDisp.create(.Disp32, disp32),
.data_size = data_size,
.segment = seg,
}
};
}
/// data_size [seg: (scale*index) + base + disp]
pub fn memorySib(seg: Segment, data_size: DataSize, scale: u8, index: ?Register, base: ?Register, disp: i32) ModRm {
// When base is not used, only 32bit diplacements are valid
const mem_disp = if (base == null) x: {
break :x MemDisp.create(.Disp32, disp);
} else x: {
break :x MemDisp.disp(.Disp32, disp);
};
return ModRm {
.Sib = MemorySib {
.scale = SibScale.scale(scale),
.index = index,
.base = base,
.disp = mem_disp,
.data_size = data_size,
.segment = seg,
}
};
}
/// data_size [seg: (scale*vec_index) + base + disp]
pub fn memoryVecSib(
seg: Segment,
data_size: DataSize,
scale: u8,
index: Register,
base: ?Register,
disp: i32
) ModRm {
// If base register is RBP/R13 (or EBP/R13D), then must use disp8 or disp32
const mem_disp = if (
base != null
and (base.?.numberRm() == Register.BP.numberRm())
and (disp == 0)
) x: {
break :x MemDisp.create(.Disp8, 0);
} else if (base == null) x: {
break :x MemDisp.create(.Disp32, disp);
} else x: {
break :x MemDisp.disp(.Disp32, disp);
};
return ModRm {
.VecSib = MemoryVecSib {
.scale = SibScale.scale(scale),
.index = index,
.base = base,
.disp = mem_disp,
.data_size = data_size,
.segment = seg,
}
};
}
pub fn format(
self: ModRm,
comptime fmt: []const u8,
options: std.fmt.FormatOptions,
context: var,
comptime FmtError: type,
comptime output: fn (@TypeOf(context), []const u8) FmtError!void,
) FmtError!void {
switch (self) {
.Reg => |reg| {
try output(context, "RM.");
try output(context, @tagName(reg));
},
.Mem16 => |mem| {
try output(context, @tagName(mem.data_size));
try output(context, " ");
if (mem.segment != .DefaultSeg) {
try output(context, @tagName(mem.segment));
try output(context, ":");
}
try output(context, "[");
if (mem.base) |base| {
try output(context, @tagName(base));
if (mem.index != null or mem.disp.dispSize() != .None) {
try output(context, " + ");
}
}
if (mem.index) |index| {
try output(context, @tagName(index));
if (mem.disp.dispSize() != .None ) {
try output(context, " + ");
}
}
if (mem.disp.dispSize() != .None) {
const disp = mem.disp.value();
if (disp < 0) {
try std.fmt.format(context, FmtError, output, "-0x{x}", .{-disp});
} else {
try std.fmt.format(context, FmtError, output, "0x{x}", .{disp});
}
}
try output(context, "]");
},
.Mem => |mem| {
try output(context, @tagName(mem.data_size));
try output(context, " ");
if (mem.segment != .DefaultSeg) {
try output(context, @tagName(mem.segment));
try output(context, ": ");
}
try output(context, "[");
try output(context, @tagName(mem.reg));
if (mem.disp.dispSize() != .None) {
const disp = mem.disp.value();
if (disp < 0) {
try std.fmt.format(context, FmtError, output, " - 0x{x}", .{-disp});
} else {
try std.fmt.format(context, FmtError, output, " + 0x{x}", .{disp});
}
}
try output(context, "]");
},
.Sib => |sib| {
try output(context, @tagName(sib.data_size));
try output(context, " ");
if (sib.segment != .DefaultSeg) {
try output(context, @tagName(sib.segment));
try output(context, ":");
}
try output(context, "[");
if (sib.index) |index| {
try std.fmt.format(context, FmtError, output, "{}*{}", .{sib.scale.value(), @tagName(index)});
if (sib.base != null or sib.disp.dispSize() != .None) {
try output(context, " + ");
}
}
if (sib.base) |base| {
try output(context, @tagName(base));
if (sib.disp.dispSize() != .None ) {
try output(context, " + ");
}
}
if (sib.disp.dispSize() != .None) {
const disp = sib.disp.value();
if (disp < 0) {
try std.fmt.format(context, FmtError, output, "-0x{x}", .{-disp});
} else {
try std.fmt.format(context, FmtError, output, "0x{x}", .{disp});
}
}
try output(context, "]");
},
.VecSib => |vsib| {
try output(context, @tagName(vsib.data_size));
try output(context, " ");
if (vsib.segment != .DefaultSeg) {
try output(context, @tagName(vsib.segment));
try output(context, ":");
}
try output(context, "[");
try std.fmt.format(context, FmtError, output, "{}*{}", .{vsib.scale.value(), @tagName(vsib.index)});
if (vsib.base != null or vsib.disp.dispSize() != .None) {
try output(context, " + ");
}
if (vsib.base) |base| {
try output(context, @tagName(base));
if (vsib.disp.dispSize() != .None ) {
try output(context, " + ");
}
}
if (vsib.disp.dispSize() != .None) {
const disp = vsib.disp.value();
if (disp < 0) {
try std.fmt.format(context, FmtError, output, "-0x{x}", .{-disp});
} else {
try std.fmt.format(context, FmtError, output, "0x{x}", .{disp});
}
}
try output(context, "]");
},
.Rel => |rel| {
try output(context, @tagName(rel.data_size));
try output(context, " ");
if (rel.segment != .DefaultSeg) {
try output(context, @tagName(rel.segment));
try output(context, ": ");
}
try output(context, "[");
try output(context, @tagName(rel.reg));
const disp = rel.disp;
if (disp < 0) {
try std.fmt.format(context, FmtError, output, " - 0x{x}", .{-disp});
} else {
try std.fmt.format(context, FmtError, output, " + 0x{x}", .{disp});
}
try output(context, "]");
},
else => {
try output(context, "<Format TODO>");
},
}
}
};
pub const MOffsetDisp = union(enum) {
Disp16: u16,
Disp32: u32,
Disp64: u64,
pub fn bitSize(self: MOffsetDisp) BitSize {
return switch (self) {
.Disp16 => .Bit16,
.Disp32 => .Bit32,
.Disp64 => .Bit64,
};
}
pub fn value(self: MOffsetDisp) u64 {
return switch (self) {
.Disp16 => |dis| dis,
.Disp32 => |dis| dis,
.Disp64 => |dis| dis,
};
}
};
pub const MemoryOffsetFarJmp = struct {
addr: MOffsetDisp,
segment: u16,
operand_size: DataSize,
};
pub const MemoryOffset = struct {
disp: MOffsetDisp,
segment: Segment,
operand_size: DataSize,
};
pub const Address = union(enum) {
MOffset: MemoryOffset,
FarJmp: MemoryOffsetFarJmp,
pub fn getDisp(self: Address) MOffsetDisp {
return switch (self) {
.FarJmp => |far| far.addr,
.MOffset => |moff| moff.disp,
};
}
pub fn operandSize(self: Address) BitSize {
return self.operandDataSize().bitSize();
}
pub fn operandDataSize(self: Address) DataSize {
return switch (self) {
.MOffset => |moff| moff.operand_size,
.FarJmp => |far| far.operand_size,
};
}
pub fn moffset16(seg: Segment, size: DataSize, disp: u16) Address {
return Address {
.MOffset = MemoryOffset {
.disp = MOffsetDisp { .Disp16 = disp },
.segment = seg,
.operand_size = size,
}
};
}
pub fn moffset32(seg: Segment, size: DataSize, disp: u32) Address {
return Address {
.MOffset = MemoryOffset {
.disp = MOffsetDisp { .Disp32 = disp },
.segment = seg,
.operand_size = size,
}
};
}
pub fn moffset64(seg: Segment, size: DataSize, disp: u64) Address {
return Address {
.MOffset = MemoryOffset {
.disp = MOffsetDisp { .Disp64 = disp },
.segment = seg,
.operand_size = size,
}
};
}
pub fn far16(seg: u16, size: DataSize, addr: u16) Address {
return Address {
.FarJmp = MemoryOffsetFarJmp {
.addr = MOffsetDisp { .Disp16 = addr },
.segment = seg,
.operand_size = size,
}
};
}
pub fn far32(seg: u16, size: DataSize, addr: u32) Address {
return Address {
.FarJmp = MemoryOffsetFarJmp {
.addr = MOffsetDisp { .Disp32 = addr },
.segment = seg,
.operand_size = size,
}
};
}
pub fn format(
self: Address,
comptime fmt: []const u8,
options: std.fmt.FormatOptions,
context: var,
comptime FmtError: type,
comptime output: fn (@TypeOf(context), []const u8) FmtError!void,
) FmtError!void {
switch (self) {
.MOffset => |moff| {
try std.fmt.format(context, FmtError, output, "{}:0x{x}", .{@tagName(moff.segment), moff.disp.value()});
},
.FarJmp => |far| {
try std.fmt.format(context, FmtError, output, "0x{x}:0x{x}", .{far.segment, far.addr.value()});
},
else => {},
}
}
};
pub const ImmediateSize = enum(u8) {
const strict_flag: u8 = 0x10;
const size_mask: u8 = 0x03;
Imm8_any = 0x00,
Imm16_any = 0x01,
Imm32_any = 0x02,
Imm64_any = 0x03,
Imm8 = 0x00 | strict_flag,
Imm16 = 0x01 | strict_flag,
Imm32 = 0x02 | strict_flag,
Imm64 = 0x03 | strict_flag,
};
pub const ImmediateSign = enum (u1) {
Unsigned = 0,
Signed = 1,
};
/// Encodes an immediate value
pub const Immediate = struct {
size: ImmediateSize,
_value: u64,
sign: ImmediateSign,
pub fn value(self: Immediate) u64 {
return self._value;
}
pub fn asSignedValue(self: Immediate) i64 {
std.debug.assert(self.sign == .Signed);
return @bitCast(i64, self._value);
}
pub fn isStrict(self: Immediate) bool {
return (@enumToInt(self.size) & ImmediateSize.strict_flag) != 0;
}
pub fn bitSize(self: Immediate) BitSize {
const size: u8 = @enumToInt(self.size) & ImmediateSize.size_mask;
return @intToEnum(BitSize, @as(u8,1) << (@intCast(u3,size)));
}
pub fn dataSize(self: Immediate) DataSize {
return DataSize.fromByteValue(self.bitSize().valueBytes());
}
pub fn as8(self: Immediate) u8 {
std.debug.assert(self.bitSize() == .Bit8);
return @intCast(u8, self._value & 0xff);
}
pub fn as16(self: Immediate) u16 {
std.debug.assert(self.bitSize() == .Bit16);
return @intCast(u16, self._value & 0xffff);
}
pub fn as32(self: Immediate) u32 {
std.debug.assert(self.bitSize() == .Bit32);
return @intCast(u32, self._value & 0xffffffff);
}
pub fn as64(self: Immediate) u64 {
std.debug.assert(self.bitSize() == .Bit64);
return self._value;
}
pub fn willSignExtend(self: Immediate, op_type: OperandType) bool {
switch (op_type) {
.imm8_any, .imm8 => return (self._value & (1<<7)) == (1<<7),
.imm16_any, .imm16 => return (self._value & (1<<15)) == (1<<15),
.imm32_any, .imm32 => return (self._value & (1<<31)) == (1<<31),
.imm64_any, .imm64 => return (self._value & (1<<63)) == (1<<63),
else => unreachable,
}
}
pub fn isNegative(self: Immediate) bool {
if (self.sign == .Unsigned) {
return false;
}
switch (self.size) {
.Imm8_any, .Imm8 => return (self._value & (1<<7)) == (1<<7),
.Imm16_any, .Imm16 => return (self._value & (1<<15)) == (1<<15),
.Imm32_any, .Imm32 => return (self._value & (1<<31)) == (1<<31),
.Imm64_any, .Imm64 => return (self._value & (1<<63)) == (1<<63),
}
}
pub fn coerce(self: Immediate, bit_size: BitSize) Immediate {
var result = self;
switch (bit_size) {
.Bit8 => result.size = .Imm8,
.Bit16 => result.size = .Imm16,
.Bit32 => result.size = .Imm32,
.Bit64 => result.size = .Imm64,
else => unreachable,
}
return result;
}
pub fn immSigned(im: i64) Immediate {
if (minInt(i8) <= im and im <= maxInt(i8)) {
return createSigned(.Imm8_any, im);
} else if (minInt(i16) <= im and im <= maxInt(i16)) {
return createSigned(.Imm16_any, im);
} else if (minInt(i32) <= im and im <= maxInt(i32)) {
return createSigned(.Imm32_any, im);
} else {
return createSigned(.Imm64_any, im);
}
}
pub fn immUnsigned(im : u64) Immediate {
if (im <= maxInt(u8)) {
return createUnsigned(.Imm8_any, im);
} else if (im <= maxInt(u16)) {
return createUnsigned(.Imm16_any, im);
} else if (im <= maxInt(u32)) {
return createUnsigned(.Imm32_any, im);
} else {
return createUnsigned(.Imm64_any, im);
}
}
pub fn createUnsigned(size: ImmediateSize, val: u64) Immediate {
return Immediate {
.size = size,
._value = val,
.sign = .Unsigned,
};
}
pub fn createSigned(size: ImmediateSize, val: i64) Immediate {
return Immediate {
.size = size,
._value = @bitCast(u64, val),
.sign = .Signed,
};
}
};
pub const VoidOperand = struct {
operand_size: DataSize,
};
pub const OperandTag = enum {
None,
Reg,
Imm,
Rm,
Addr,
RegPred,
RmPred,
RegSae,
};
pub const Operand = union(OperandTag) {
None: VoidOperand,
Reg: Register,
Imm: Immediate,
Rm: ModRm,
Addr: Address,
RegPred: avx.RegisterPredicate,
RmPred: avx.RmPredicate,
RegSae: avx.RegisterSae,
pub fn tag(self: Operand) OperandTag {
return @as(OperandTag, self);
}
pub fn operandType(self: Operand) OperandType {
return switch (self) {
.Reg => |reg| OperandType.fromRegister(reg),
.Imm => |imm_| OperandType.fromImmediate(imm_),
.Rm => |rm| OperandType.fromModRm(rm),
.Addr => |addr| OperandType.fromAddress(addr),
.RegPred => |reg_pred| OperandType.fromRegisterPredicate(reg_pred),
.RmPred => |rm_pred| OperandType.fromRmPredicate(rm_pred),
.RegSae => |sae| OperandType.fromSae(sae),
// TODO: get size
.None => OperandType._void,
};
}
pub fn operandSize(self: Operand) BitSize {
return switch (self) {
.Reg => |reg| reg.bitSize(),
.Imm => |imm_| (imm_.bitSize()),
.Rm => |rm| rm.operandSize(),
.Addr => |addr| addr.operandSize(),
.None => |none| none.operand_size.bitSize(),
.RegPred => |reg_pred| reg_pred.reg.bitSize(),
.RmPred => |rm_pred| rm_pred.rm.operandSize(),
.RegSae => |reg_sae| reg_sae.reg.bitSize(),
};
}
/// If the operand has a size overide get it instead of the underlying
/// operand size.
pub fn operandDataSize(self: Operand) DataSize {
return switch (self) {
.Reg => |reg| reg.dataSize(),
.Imm => |imm_| (imm_.dataSize()),
.Rm => |rm| rm.operandDataSize(),
.Addr => |addr| addr.operandDataSize(),
.None => |none| none.operand_size,
.RegPred => |reg_pred| reg_pred.reg.dataSize(),
.RmPred => |rm_pred| rm_pred.rm.operandDataSize(),
.RegSae => |rc| DataSize.Void,
};
}
pub fn register(reg: Register) Operand {
return Operand { .Reg = reg };
}
pub fn registerRm(reg: Register) Operand {
return Operand { .Rm = ModRm.register(reg) };
}
pub fn registerPredicate(reg: Register, mask: avx.MaskRegister, z: avx.ZeroOrMerge) Operand {
return Operand { .RegPred = avx.RegisterPredicate.create(reg, mask, z) };
}
pub fn rmPredicate(op: Operand, mask: avx.MaskRegister, z: avx.ZeroOrMerge) Operand {
return switch (op) {
.Reg => |reg| Operand { .RmPred = avx.RmPredicate.create(ModRm.register(reg), mask, z) },
.Rm => |rm| Operand { .RmPred = avx.RmPredicate.create(rm, mask, z) },
else => {
std.debug.panic("Expected Operand.Register or Operand.ModRm, got: {}", .{op});
},
};
}
pub fn registerSae(reg: Register, sae: avx.SuppressAllExceptions) Operand {
return Operand { .RegSae = avx.RegisterSae.create(reg, sae) };
}
pub fn voidOperand(data_size: DataSize) Operand {
return Operand { .None = VoidOperand { .operand_size = data_size } };
}
pub fn immediate(im: u64) Operand {
return Operand { .Imm = Immediate.immUnsigned(im) };
}
pub fn immediate8(im: u8) Operand {
return Operand { .Imm = Immediate.createUnsigned(.Imm8, im) };
}
pub fn immediate16(im: u16) Operand {
return Operand { .Imm = Immediate.createUnsigned(.Imm16, im) };
}
pub fn immediate32(im: u32) Operand {
return Operand { .Imm = Immediate.createUnsigned(.Imm32, im) };
}
pub fn immediate64(im: u64) Operand {
return Operand { .Imm = Immediate.createUnsigned(.Imm64, im) };
}
pub fn immediateSigned(im: i64) Operand {
return Operand { .Imm = Immediate.immSigned(im) };
}
pub fn immediateSigned8(im: i8) Operand {
return Operand { .Imm = Immediate.createSigned(.Imm8, @intCast(i64, im)) };
}
pub fn immediateSigned16(im: i16) Operand {
return Operand { .Imm = Immediate.createSigned(.Imm16, @intCast(i64, im)) };
}
pub fn immediateSigned32(im: i32) Operand {
return Operand { .Imm = Immediate.createSigned(.Imm32, @intCast(i64, im)) };
}
pub fn immediateSigned64(im: i64) Operand {
return Operand { .Imm = Immediate.createSigned(.Imm64, @intCast(i64, im)) };
}
pub fn memory16Bit(seg: Segment, data_size: DataSize, base: ?Register, index: ?Register, disp: i16) Operand {
return Operand { .Rm = ModRm.memory16Bit(seg, data_size, base, index, disp) };
}
/// Same as memorySib, except it may choose to encode it as memoryRm if the encoding is shorter
pub fn memory(seg: Segment, data_size: DataSize, scale: u8, index: ?Register, base: ?Register, disp: i32) Operand {
var modrm: ModRm = undefined;
if (index != null and index.?.isVector()) {
return Operand { .Rm = ModRm.memoryVecSib(seg, data_size, scale, index.?, base, disp) };
}
if (index == null and base != null) edge_case: {
const reg_name = base.?.name();
// Can encode these, but need to choose 32 bit displacement and SIB byte
if (reg_name == .SP or reg_name == .R12) {
break :edge_case;
}
return Operand { .Rm = ModRm.memoryRm(seg, data_size, base.?, disp) };
}
return Operand { .Rm = ModRm.memorySib(seg, data_size, scale, index, base, disp) };
}
/// Same memory() except uses the default segment
pub fn memoryDef(data_size: DataSize, scale: u8, index: ?Register, base: ?Register, disp: i32) Operand {
return memory(.DefaultSeg, data_size, scale, index, base, disp);
}
/// data_size [seg: reg + disp0/8/32]
pub fn memoryRm(seg: Segment, data_size: DataSize, reg: Register, disp: i32) Operand {
return Operand { .Rm = ModRm.memoryRm(seg, data_size, reg, disp) };
}
/// data_size [DefaultSeg: reg + disp0/8/32]
pub fn memoryRmDef(data_size: DataSize, reg: Register, disp: i32) Operand {
return Operand { .Rm = ModRm.memoryRm(.DefaultSeg, data_size, reg, disp) };
}
/// data_size [seg: reg + disp8]
pub fn memoryRm8(seg: Segment, data_size: DataSize, reg: Register, disp: i8) Operand {
return Operand { .Rm = ModRm.memoryRm8(seg, data_size, reg, disp) };
}
/// data_size [seg: reg + disp32]
pub fn memoryRm32(seg: Segment, data_size: DataSize, reg: Register, disp: i32) Operand {
return Operand { .Rm = ModRm.memoryRm32(seg, data_size, reg, disp) };
}
/// data_size [seg: (scale*index) + base + disp0/8/32]
pub fn memorySib(seg: Segment, data_size: DataSize, scale: u8, index: ?Register, base: ?Register, disp: i32) Operand {
return Operand { .Rm = ModRm.memorySib(seg, data_size, scale, index, base, disp) };
}
/// data_size [seg: (scale*index) + base + disp8]
pub fn memorySib8(seg: Segment, data_size: DataSize, scale: u8, index: ?Register, base: ?Register, disp: i8) Operand {
return Operand { .Rm = ModRm.memorySib8(seg, data_size, scale, index, base, disp) };
}
/// data_size [seg: (scale*index) + base + disp32]
pub fn memorySib32(seg: Segment, data_size: DataSize, scale: u8, index: ?Register, base: ?Register, disp: i32) Operand {
return Operand { .Rm = ModRm.memorySib32(seg, data_size, scale, index, base, disp) };
}
/// data_size [DefaultSeg: (scale*index) + base + disp]
pub fn memorySibDef(data_size: DataSize, scale: u8, index: ?Register, base: ?Register, disp: i32) Operand {
return Operand { .Rm = ModRm.memorySib(.DefaultSeg, data_size, scale, index, base, disp) };
}
/// data_size [seg: (scale*vec_index) + base + disp0/8/32]
pub fn memoryVecSib(seg: Segment, data_size: DataSize, scale: u8, index: Register, base: ?Register, disp: i32) Operand {
return Operand { .Rm = ModRm.memoryVecSib(seg, data_size, scale, index, base, disp) };
}
/// data_size [Seg: EIP/RIP + disp]
pub fn relMemory(seg: Segment, data_size: DataSize, reg: RelRegister, disp: i32) Operand {
return Operand { .Rm = ModRm.relMemory(seg, data_size, reg, disp) };
}
/// data_size [DefaultSeg: EIP/RIP + disp]
pub fn relMemoryDef(data_size: DataSize, reg: RelRegister, disp: i32) Operand {
return Operand { .Rm = ModRm.relMemory(.DefaultSeg, data_size, reg, disp) };
}
pub fn moffset16(seg: Segment, size: DataSize, disp: u16) Operand {
return Operand { .Addr = Address.moffset16(seg, size, disp) };
}
pub fn moffset32(seg: Segment, size: DataSize, disp: u32) Operand {
return Operand { .Addr = Address.moffset32(seg, size, disp) };
}
pub fn moffset64(seg: Segment, size: DataSize, disp: u64) Operand {
return Operand { .Addr = Address.moffset64(seg, size, disp) };
}
// pub fn far16(seg: u16, size: DataSize, addr: u16) Operand {
pub fn far16(seg: u16, addr: u16) Operand {
return Operand { .Addr = Address.far16(seg, .Default, addr) };
}
pub fn far32(seg: u16, addr: u32) Operand {
return Operand { .Addr = Address.far32(seg, .Default, addr) };
}
/// fn format(value: ?, comptime fmt: []const u8, options: std.fmt.FormatOptions, context: var, comptime Errors: type, output: fn (@TypeOf(context), []const u8) Errors!void) Errors!void
pub fn format(
self: Operand,
comptime fmt: []const u8,
options: std.fmt.FormatOptions,
context: var,
comptime FmtError: type,
comptime output: fn (@TypeOf(context), []const u8) FmtError!void,
) FmtError!void {
// self.assertWritable();
// TODO look at fmt and support other bases
// TODO support read-only fixed integers
switch (self) {
.Reg => |reg| try output(context, @tagName(reg)),
.Rm => |rm| try rm.format(fmt, options, context, FmtError, output),
.Imm => |im| {
if (im.sign == .Signed and im.isNegative()) {
try std.fmt.format(context, FmtError, output, "{}", .{im.asSignedValue()});
} else {
try std.fmt.format(context, FmtError, output, "0x{x}", .{im.value()});
}
},
.Addr => |addr| {
if (addr.operandDataSize() != .Default) {
try output(context, @tagName(addr.operandDataSize()));
try output(context, " ");
}
try addr.format(fmt, options, context, FmtError, output);
},
.RegPred => |pred| {
try output(context, @tagName(pred.reg));
if (pred.mask != .NoMask) {
try output(context, " {");
try output(context, @tagName(pred.mask));
try output(context, "}");
}
if (pred.z == .Zero) {
try output(context, " {z}");
}
},
.RegSae => |sae_reg| {
try output(context, @tagName(sae_reg.reg));
switch (sae_reg.sae) {
.AE => {},
.SAE => try output(context, " {sae}"),
.RN_SAE => try output(context, " {rn-sae}"),
.RD_SAE => try output(context, " {rd-sae}"),
.RU_SAE => try output(context, " {ru-sae}"),
.RZ_SAE => try output(context, " {rz-sae}"),
}
},
.RmPred => |rm_pred| {
try std.fmt.format(context, FmtError, output, "{}", .{rm_pred.rm});
if (rm_pred.mask != .NoMask) {
try output(context, " {");
try output(context, @tagName(rm_pred.mask));
try output(context, "}");
}
if (rm_pred.z == .Zero) {
try output(context, " {z}");
}
},
else => {
try output(context, "<Format TODO>");
},
}
}
};
test "ModRm Encoding" {
const testing = std.testing;
const warn = if (true) std.debug.warn else util.warnDummy;
const expect = testing.expect;
const expectError = testing.expectError;
// x86_16: [BP + SI]
{
const modrm = ModRm.memory16Bit(.DefaultSeg, .WORD, .BP, .SI, 0);
const result = try modrm.encodeOpcodeRm(.x86_16, 7, .Op16);
expect(result.modrm() == 0b00111010);
expect(result.disp_bit_size == .None);
expect(result.disp == 0);
expect(std.mem.eql(u8, result.prefixes.asSlice(), &[_]u8{}));
}
// x86_32: WORD [BP + DI + 0x10], (RM32)
{
const modrm = ModRm.memory16Bit(.DefaultSeg, .WORD, .BP, .DI, 0x10);
const result = try modrm.encodeOpcodeRm(.x86_32, 7, .Op16);
expect(result.modrm() == 0b01111011);
expect(result.disp_bit_size == .Bit8);
expect(result.disp == 0x10);
expect(std.mem.eql(u8, result.prefixes.asSlice(), &[_]u8{0x66, 0x67}));
}
// x86_16: DWORD [BX], (RM32)
{
const modrm = ModRm.memory16Bit(.DefaultSeg, .DWORD, .BX, null, 0x1100);
const result = try modrm.encodeOpcodeRm(.x86_16, 5, .Op32);
expect(result.modrm() == 0b10101111);
expect(result.disp_bit_size == .Bit16);
expect(result.disp == 0x1100);
expect(std.mem.eql(u8, result.prefixes.asSlice(), &[_]u8{0x66}));
}
{
const modrm = ModRm.register(.RAX);
const result = try modrm.encodeOpcodeRm(.x64, 0, .REX_W);
expect(result.rex(0) == 0b01001000);
expect(result.rex(1) == 0b01001000);
expect(result.modrm() == 0b11000000);
expect(result.sib == null);
expect(result.disp_bit_size == .None);
}
{
const modrm = ModRm.register(.R15);
const result = try modrm.encodeReg(.x64, .R9, .REX_W);
expect(result.rex(0) == 0b01001101);
expect(result.rex(1) == 0b01001101);
expect(result.modrm() == 0b11001111);
expect(result.sib == null);
expect(result.disp_bit_size == .None);
expect(result.prefixes.len == 0);
}
{
const modrm = ModRm.relMemory(.DefaultSeg, .DWORD, .EIP, 0x76543210);
const result = try modrm.encodeReg(.x64, .R8, .REX_W);
expect(result.rex(0) == 0b01001100);
expect(result.rex(1) == 0b01001100);
expect(result.modrm() == 0b00000101);
expect(result.sib == null);
expect(result.disp == 0x76543210);
expect(std.mem.eql(u8, result.prefixes.asSlice(), &[_]u8{0x67}));
}
{
const modrm = ModRm.relMemory(.DefaultSeg, .QWORD, .RIP, 0x76543210);
const result = try modrm.encodeReg(.x64, .R8, .REX_W);
expect(result.rex(0) == 0b01001100);
expect(result.rex(1) == 0b01001100);
expect(result.modrm() == 0b00000101);
expect(result.sib == null);
expect(result.disp == 0x76543210);
expect(result.prefixes.len == 0);
}
{
const modrm = ModRm.memoryRm(.DefaultSeg, .QWORD, .R9, 0x0);
const result = try modrm.encodeReg(.x64, .RAX, .REX_W);
expect(result.rex(0) == 0b01001001);
expect(result.rex(1) == 0b01001001);
expect(result.modrm() == 0b00000001);
expect(result.sib == null);
expect(result.disp_bit_size == .None);
}
{
const modrm = ModRm.memoryRm(.DefaultSeg, .QWORD, .R9, 0x10);
const result = try modrm.encodeReg(.x64, .RAX, .REX_W);
expect(result.rex(0) == 0b01001001);
expect(result.rex(1) == 0b01001001);
expect(result.modrm() == 0b01000001);
expect(result.sib == null);
expect(result.disp == 0x10);
}
{
const modrm = ModRm.memoryRm(.DefaultSeg, .QWORD, .R9, 0x76543210);
const result = try modrm.encodeReg(.x64, .R15, .REX_W);
expect(result.rex(0) == 0b01001101);
expect(result.rex(1) == 0b01001101);
expect(result.modrm() == 0b10111001);
expect(result.sib == null);
expect(result.disp == 0x76543210);
}
// [2*R15 + R15 + 0x10]
{
const modrm = ModRm.memorySib(.DefaultSeg, .QWORD, 2, .R15, .R15, 0x10);
const result = try modrm.encodeReg(.x64, .RAX, .REX_W);
expect(result.rex(1) == 0b01001011);
expect(result.modrm() == 0b01000100);
expect(result.sib.? == 0b01111111);
expect(result.disp == 0x10);
}
// [2*R15 + R15 + 0x76543210]
{
const modrm = ModRm.memorySib(.DefaultSeg, .QWORD, 1, .R15, .R15, 0x76543210);
const result = try modrm.encodeReg(.x64, .RAX, .REX_W);
expect(result.rex(1) == 0b01001011);
expect(result.modrm() == 0b10000100);
expect(result.sib.? == 0b00111111);
expect(result.disp == 0x76543210);
}
// [R15 + 0x10]
{
const modrm = ModRm.memorySib(.DefaultSeg, .QWORD, 2, null, .R15, 0x10);
const result = try modrm.encodeReg(.x64, .RAX, .REX_W);
expect(result.rex(1) == 0b01001001);
expect(result.modrm() == 0b01000100);
expect(result.sib.? == 0b01100111);
expect(result.disp == 0x10);
}
// [R15 + 0x3210]
{
const modrm = ModRm.memorySib(.DefaultSeg, .QWORD, 2, null, .R15, 0x3210);
const result = try modrm.encodeReg(.x64, .RAX, .REX_W);
expect(result.rex(1) == 0b01001001);
expect(result.modrm() == 0b10000100);
expect(result.sib.? == 0b01100111);
expect(result.disp == 0x3210);
}
// [4*R15 + R15]
{
const modrm = ModRm.memorySib(.DefaultSeg, .QWORD, 4, .R15, .R15, 0x00);
const result = try modrm.encodeReg(.x64, .RAX, .REX_W);
expect(result.rex(1) == 0b01001011);
expect(result.modrm() == 0b00000100);
expect(result.sib.? == 0b10111111);
expect(result.disp_bit_size == .None);
}
// [4*R15 + 0x10]
{
const modrm = ModRm.memorySib(.DefaultSeg, .QWORD, 4, .R15, null, 0x10);
const result = try modrm.encodeReg(.x64, .RAX, .REX_W);
expect(result.rex(1) == 0b01001010);
expect(result.modrm() == 0b00000100);
expect(result.sib.? == 0b10111101);
expect(result.disp_bit_size == .Bit32);
}
// [0x10]
{
const modrm = ModRm.memorySib(.DefaultSeg, .QWORD, 8, null, null, 0x10);
const result = try modrm.encodeReg(.x64, .RAX, .REX_W);
expect(result.rex(1) == 0b01001000);
expect(result.modrm() == 0b00000100);
expect(result.sib.? == 0b11100101);
expect(result.disp_bit_size == .Bit32);
}
// [R15]
{
const modrm = ModRm.memorySib(.DefaultSeg, .QWORD, 4, null, .R15, 0x00);
const result = try modrm.encodeReg(.x64, .RAX, .REX_W);
expect(result.rex(1) == 0b01001001);
expect(result.modrm() == 0b00000100);
expect(result.sib.? == 0b10100111);
expect(result.disp_bit_size == .None);
}
// DWORD [1*xmm0 + RAX + 0x00]
{
const modrm = ModRm.memoryVecSib(.DefaultSeg, .DWORD, 1, .XMM0, .RAX, 0x00);
const result = try modrm.encodeReg(.x64, .RAX, .Op32);
expect(result.modrm() == 0b00000100);
expect(result.sib.? == 0b00000000);
expect(result.disp_bit_size == .None);
}
// DWORD [4*xmm31 + R8 + 0x33221100]
{
const modrm = ModRm.memoryVecSib(.DefaultSeg, .DWORD, 4, .XMM31, .R9, 0x33221100);
const result = try modrm.encodeReg(.x64, .RAX, .Op32);
expect(result.modrm() == 0b10000100);
expect(result.sib.? == 0b10111001);
expect(result.rex_b == 1);
expect(result.rex_x == 1);
expect(result.evex_v == 1);
expect(result.disp_bit_size == .Bit32);
expect(result.disp == 0x33221100);
}
// DWORD [8*xmm17 + RBP]
{
const modrm = ModRm.memoryVecSib(.DefaultSeg, .DWORD, 8, .XMM17, .RBP, 0);
const result = try modrm.encodeReg(.x64, .RAX, .Op32);
expect(result.modrm() == 0b01000100);
expect(result.sib.? == 0b11001101);
expect(result.rex_b == 0);
expect(result.rex_x == 0);
expect(result.evex_v == 1);
expect(result.disp_bit_size == .Bit8);
expect(result.disp == 0x00);
}
// DWORD [8*xmm17 + 0x77]
{
const modrm = ModRm.memoryVecSib(.DefaultSeg, .DWORD, 8, .XMM17, null, 0x77);
const result = try modrm.encodeReg(.x64, .RAX, .Op32);
expect(result.modrm() == 0b00000100);
expect(result.sib.? == 0b11001101);
expect(result.rex_b == 0);
expect(result.rex_x == 0);
expect(result.evex_v == 1);
expect(result.disp_bit_size == .Bit32);
expect(result.disp == 0x77);
}
} | src/x86/operand.zig |
const std = @import("std");
const CrossTarget = std.zig.CrossTarget;
const TestContext = @import("../../src/test.zig").TestContext;
const linux_aarch64 = CrossTarget{
.cpu_arch = .aarch64,
.os_tag = .linux,
};
const macos_aarch64 = CrossTarget{
.cpu_arch = .aarch64,
.os_tag = .macos,
};
pub fn addCases(ctx: *TestContext) !void {
// Linux tests
{
var case = ctx.exe("linux_aarch64 hello world", linux_aarch64);
// Regular old hello world
case.addCompareOutput(
\\pub export fn _start() noreturn {
\\ print();
\\ exit();
\\}
\\
\\fn doNothing() void {}
\\
\\fn answer() u64 {
\\ return 0x1234abcd1234abcd;
\\}
\\
\\fn print() void {
\\ asm volatile ("svc #0"
\\ :
\\ : [number] "{x8}" (64),
\\ [arg1] "{x0}" (1),
\\ [arg2] "{x1}" (@ptrToInt("Hello, World!\n")),
\\ [arg3] "{x2}" ("Hello, World!\n".len)
\\ : "memory", "cc"
\\ );
\\}
\\
\\fn exit() noreturn {
\\ asm volatile ("svc #0"
\\ :
\\ : [number] "{x8}" (93),
\\ [arg1] "{x0}" (0)
\\ : "memory", "cc"
\\ );
\\ unreachable;
\\}
,
"Hello, World!\n",
);
}
{
var case = ctx.exe("exit fn taking argument", linux_aarch64);
case.addCompareOutput(
\\pub export fn _start() noreturn {
\\ exit(0);
\\}
\\
\\fn exit(ret: usize) noreturn {
\\ asm volatile ("svc #0"
\\ :
\\ : [number] "{x8}" (93),
\\ [arg1] "{x0}" (ret)
\\ : "memory", "cc"
\\ );
\\ unreachable;
\\}
,
"",
);
}
{
var case = ctx.exe("conditional branches", linux_aarch64);
case.addCompareOutput(
\\pub fn main() void {
\\ foo(123);
\\}
\\
\\fn foo(x: u64) void {
\\ if (x > 42) {
\\ print();
\\ }
\\}
\\
\\fn print() void {
\\ asm volatile ("svc #0"
\\ :
\\ : [number] "{x8}" (64),
\\ [arg1] "{x0}" (1),
\\ [arg2] "{x1}" (@ptrToInt("Hello, World!\n")),
\\ [arg3] "{x2}" ("Hello, World!\n".len),
\\ : "memory", "cc"
\\ );
\\}
,
"Hello, World!\n",
);
}
// macOS tests
{
var case = ctx.exe("hello world with updates", macos_aarch64);
case.addError("", &[_][]const u8{
":99:9: error: struct 'tmp.tmp' has no member named 'main'",
});
// Incorrect return type
case.addError(
\\pub export fn main() noreturn {
\\}
, &[_][]const u8{
":2:1: error: expected noreturn, found void",
});
// Regular old hello world
case.addCompareOutput(
\\extern "c" fn write(usize, usize, usize) usize;
\\extern "c" fn exit(usize) noreturn;
\\
\\pub export fn main() noreturn {
\\ print();
\\
\\ exit(0);
\\}
\\
\\fn print() void {
\\ const msg = @ptrToInt("Hello, World!\n");
\\ const len = 14;
\\ _ = write(1, msg, len);
\\}
,
"Hello, World!\n",
);
// Now using start.zig without an explicit extern exit fn
case.addCompareOutput(
\\extern "c" fn write(usize, usize, usize) usize;
\\
\\pub fn main() void {
\\ print();
\\}
\\
\\fn print() void {
\\ const msg = @ptrToInt("Hello, World!\n");
\\ const len = 14;
\\ _ = write(1, msg, len);
\\}
,
"Hello, World!\n",
);
// Print it 4 times and force growth and realloc.
case.addCompareOutput(
\\extern "c" fn write(usize, usize, usize) usize;
\\
\\pub fn main() void {
\\ print();
\\ print();
\\ print();
\\ print();
\\}
\\
\\fn print() void {
\\ const msg = @ptrToInt("Hello, World!\n");
\\ const len = 14;
\\ _ = write(1, msg, len);
\\}
,
\\Hello, World!
\\Hello, World!
\\Hello, World!
\\Hello, World!
\\
);
// Print it once, and change the message.
case.addCompareOutput(
\\extern "c" fn write(usize, usize, usize) usize;
\\
\\pub fn main() void {
\\ print();
\\}
\\
\\fn print() void {
\\ const msg = @ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n");
\\ const len = 104;
\\ _ = write(1, msg, len);
\\}
,
"What is up? This is a longer message that will force the data to be relocated in virtual address space.\n",
);
// Now we print it twice.
case.addCompareOutput(
\\extern "c" fn write(usize, usize, usize) usize;
\\
\\pub fn main() void {
\\ print();
\\ print();
\\}
\\
\\fn print() void {
\\ const msg = @ptrToInt("What is up? This is a longer message that will force the data to be relocated in virtual address space.\n");
\\ const len = 104;
\\ _ = write(1, msg, len);
\\}
,
\\What is up? This is a longer message that will force the data to be relocated in virtual address space.
\\What is up? This is a longer message that will force the data to be relocated in virtual address space.
\\
);
}
} | test/stage2/aarch64.zig |
const std = @import("std");
const print = std.debug.print;
const data = @embedFile("../data/day05.txt");
pub fn main() !void {
var timer = try std.time.Timer.start();
// I've vetted the input, which is at max 1000x1000.
const board_width = 1000;
// We need two boards - one for the first hit on the location, and one for the
// second (what our puzzle solution requires).
var board_1st_hit = std.StaticBitSet(board_width * board_width).initEmpty();
var board_2nd_hit = std.StaticBitSet(board_width * board_width).initEmpty();
{
var line_iterator = std.mem.tokenize(data, "\r\n");
while (line_iterator.next()) |line| {
var coord_iterator = std.mem.tokenize(line, ",-> ");
var x1 : u32 = try std.fmt.parseInt(u32, coord_iterator.next().?, 10);
var y1 : u32 = try std.fmt.parseInt(u32, coord_iterator.next().?, 10);
var x2 : u32 = try std.fmt.parseInt(u32, coord_iterator.next().?, 10);
var y2 : u32 = try std.fmt.parseInt(u32, coord_iterator.next().?, 10);
// Skip non-straight line segments.
if ((x1 != x2) and (y1 != y2)) {
continue;
}
// We order points so that x1 is smaller.
if (x1 > x2) {
std.mem.swap(u32, &x1, &x2);
}
// We order points so that y1 is smaller.
if (y1 > y2) {
std.mem.swap(u32, &y1, &y2);
}
var y = y1;
while (y <= y2) : (y += 1) {
var x = x1;
while (x <= x2) : (x += 1) {
const index = y * board_width + x;
if (board_1st_hit.isSet(index)) {
board_2nd_hit.set(index);
} else {
board_1st_hit.set(index);
}
}
}
}
}
print("🎁 At least two overlaps: {}\n", .{board_2nd_hit.count()});
print("Day 05 - part 01 took {:15}ns\n", .{timer.lap()});
timer.reset();
{
var line_iterator = std.mem.tokenize(data, "\r\n");
while (line_iterator.next()) |line| {
var coord_iterator = std.mem.tokenize(line, ",-> ");
var x1 : u32 = try std.fmt.parseInt(u32, coord_iterator.next().?, 10);
var y1 : u32 = try std.fmt.parseInt(u32, coord_iterator.next().?, 10);
var x2 : u32 = try std.fmt.parseInt(u32, coord_iterator.next().?, 10);
var y2 : u32 = try std.fmt.parseInt(u32, coord_iterator.next().?, 10);
// Skip non-diagonal line segments.
if ((x1 == x2) or (y1 == y2)) {
continue;
}
const steps = if (x1 < x2) x2 - x1 else x1 - x2;
var step : u32 = 0;
while (step <= steps) : (step += 1) {
var x = if (x1 < x2) x1 + step else x1 - step;
var y = if (y1 < y2) y1 + step else y1 - step;
const index = y * board_width + x;
if (board_1st_hit.isSet(index)) {
board_2nd_hit.set(index);
} else {
board_1st_hit.set(index);
}
}
}
}
print("🎁 At least two overlaps: {}\n", .{board_2nd_hit.count()});
print("Day 05 - part 02 took {:15}ns\n", .{timer.lap()});
print("❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️❄️\n", .{});
} | src/day05.zig |
const Elf = @This();
const std = @import("std");
const builtin = @import("builtin");
const assert = std.debug.assert;
const elf = std.elf;
const fs = std.fs;
const log = std.log.scoped(.elf);
const mem = std.mem;
const Allocator = mem.Allocator;
const Archive = @import("Elf/Archive.zig");
const Atom = @import("Elf/Atom.zig");
const Object = @import("Elf/Object.zig");
const Zld = @import("Zld.zig");
pub const base_tag = Zld.Tag.elf;
base: Zld,
archives: std.ArrayListUnmanaged(Archive) = .{},
objects: std.ArrayListUnmanaged(Object) = .{},
header: ?elf.Elf64_Ehdr = null,
shdrs: std.ArrayListUnmanaged(elf.Elf64_Shdr) = .{},
phdrs: std.ArrayListUnmanaged(elf.Elf64_Phdr) = .{},
strtab: std.ArrayListUnmanaged(u8) = .{},
shstrtab: std.ArrayListUnmanaged(u8) = .{},
phdr_seg_index: ?u16 = null,
load_r_seg_index: ?u16 = null,
load_re_seg_index: ?u16 = null,
load_rw_seg_index: ?u16 = null,
null_sect_index: ?u16 = null,
rodata_sect_index: ?u16 = null,
text_sect_index: ?u16 = null,
init_sect_index: ?u16 = null,
init_array_sect_index: ?u16 = null,
fini_sect_index: ?u16 = null,
fini_array_sect_index: ?u16 = null,
data_rel_ro_sect_index: ?u16 = null,
got_sect_index: ?u16 = null,
data_sect_index: ?u16 = null,
bss_sect_index: ?u16 = null,
debug_loc_index: ?u16 = null,
debug_abbrev_index: ?u16 = null,
debug_info_index: ?u16 = null,
debug_str_index: ?u16 = null,
debug_frame_index: ?u16 = null,
debug_line_index: ?u16 = null,
symtab_sect_index: ?u16 = null,
strtab_sect_index: ?u16 = null,
shstrtab_sect_index: ?u16 = null,
next_offset: u64 = 0,
base_addr: u64 = 0x200000,
locals: std.ArrayListUnmanaged(elf.Elf64_Sym) = .{},
globals: std.StringArrayHashMapUnmanaged(SymbolWithLoc) = .{},
unresolved: std.AutoArrayHashMapUnmanaged(u32, void) = .{},
got_entries_map: std.AutoArrayHashMapUnmanaged(SymbolWithLoc, *Atom) = .{},
managed_atoms: std.ArrayListUnmanaged(*Atom) = .{},
atoms: std.AutoHashMapUnmanaged(u16, *Atom) = .{},
pub const SymbolWithLoc = struct {
/// Index in the respective symbol table.
sym_index: u32,
/// null means it's a synthetic global.
file: ?u16,
};
pub fn openPath(allocator: Allocator, options: Zld.Options) !*Elf {
const file = try options.emit.directory.createFile(options.emit.sub_path, .{
.truncate = true,
.read = true,
.mode = if (builtin.os.tag == .windows) 0 else 0o777,
});
errdefer file.close();
const self = try createEmpty(allocator, options);
errdefer allocator.destroy(self);
self.base.file = file;
try self.populateMetadata();
return self;
}
fn createEmpty(gpa: Allocator, options: Zld.Options) !*Elf {
const self = try gpa.create(Elf);
self.* = .{
.base = .{
.tag = .elf,
.options = options,
.allocator = gpa,
.file = undefined,
},
};
return self;
}
pub fn deinit(self: *Elf) void {
self.closeFiles();
self.atoms.deinit(self.base.allocator);
for (self.managed_atoms.items) |atom| {
atom.deinit(self.base.allocator);
self.base.allocator.destroy(atom);
}
self.managed_atoms.deinit(self.base.allocator);
for (self.globals.keys()) |key| {
self.base.allocator.free(key);
}
self.got_entries_map.deinit(self.base.allocator);
self.unresolved.deinit(self.base.allocator);
self.globals.deinit(self.base.allocator);
self.locals.deinit(self.base.allocator);
self.shstrtab.deinit(self.base.allocator);
self.strtab.deinit(self.base.allocator);
self.shdrs.deinit(self.base.allocator);
self.phdrs.deinit(self.base.allocator);
for (self.objects.items) |*object| {
object.deinit(self.base.allocator);
}
self.objects.deinit(self.base.allocator);
for (self.archives.items) |*archive| {
archive.deinit(self.base.allocator);
}
self.archives.deinit(self.base.allocator);
}
fn closeFiles(self: Elf) void {
for (self.objects.items) |object| {
object.file.close();
}
for (self.archives.items) |archive| {
archive.file.close();
}
}
fn resolveLib(
arena: Allocator,
search_dirs: []const []const u8,
name: []const u8,
ext: []const u8,
) !?[]const u8 {
const search_name = try std.fmt.allocPrint(arena, "lib{s}{s}", .{ name, ext });
for (search_dirs) |dir| {
const full_path = try fs.path.join(arena, &[_][]const u8{ dir, search_name });
// Check if the file exists.
const tmp = fs.cwd().openFile(full_path, .{}) catch |err| switch (err) {
error.FileNotFound => continue,
else => |e| return e,
};
defer tmp.close();
return full_path;
}
return null;
}
pub fn flush(self: *Elf) !void {
var arena_allocator = std.heap.ArenaAllocator.init(self.base.allocator);
defer arena_allocator.deinit();
const arena = arena_allocator.allocator();
var lib_dirs = std.ArrayList([]const u8).init(arena);
for (self.base.options.lib_dirs) |dir| {
// Verify that search path actually exists
var tmp = fs.cwd().openDir(dir, .{}) catch |err| switch (err) {
error.FileNotFound => continue,
else => |e| return e,
};
defer tmp.close();
try lib_dirs.append(dir);
}
var libs = std.ArrayList([]const u8).init(arena);
var lib_not_found = false;
for (self.base.options.libs) |lib_name| {
for (&[_][]const u8{ ".dylib", ".a" }) |ext| {
if (try resolveLib(arena, lib_dirs.items, lib_name, ext)) |full_path| {
try libs.append(full_path);
break;
}
} else {
log.warn("library not found for '-l{s}'", .{lib_name});
lib_not_found = true;
}
}
if (lib_not_found) {
log.warn("Library search paths:", .{});
for (lib_dirs.items) |dir| {
log.warn(" {s}", .{dir});
}
}
try self.parsePositionals(self.base.options.positionals);
try self.parseLibs(libs.items);
for (self.objects.items) |_, object_id| {
try self.resolveSymbolsInObject(@intCast(u16, object_id));
}
try self.resolveSymbolsInArchives();
try self.resolveSpecialSymbols();
// self.logSymtab();
for (self.unresolved.keys()) |ndx| {
const global = self.globals.values()[ndx];
const object = self.objects.items[global.file.?];
const sym = object.symtab.items[global.sym_index];
const sym_name = object.getString(sym.st_name);
log.err("undefined reference to symbol '{s}'", .{sym_name});
log.err(" first referenced in '{s}'", .{object.name});
}
if (self.unresolved.count() > 0) {
return error.UndefinedSymbolReference;
}
for (self.objects.items) |*object, object_id| {
try object.parseIntoAtoms(self.base.allocator, @intCast(u16, object_id), self);
}
try self.sortShdrs();
try self.allocateLoadRSeg();
try self.allocateLoadRESeg();
try self.allocateLoadRWSeg();
try self.allocateNonAllocSections();
try self.allocateAtoms();
try self.setEntryPoint();
{
// TODO this should be put in its own logic but probably is linked to
// C++ handling so leaving it here until I gather more knowledge on
// those special symbols.
if (self.init_array_sect_index == null) {
if (self.globals.get("__init_array_start")) |global| {
assert(global.file == null);
const sym = &self.locals.items[global.sym_index];
sym.st_value = self.header.?.e_entry;
sym.st_shndx = self.text_sect_index.?;
}
if (self.globals.get("__init_array_end")) |global| {
assert(global.file == null);
const sym = &self.locals.items[global.sym_index];
sym.st_value = self.header.?.e_entry;
sym.st_shndx = self.text_sect_index.?;
}
}
if (self.fini_array_sect_index == null) {
if (self.globals.get("__fini_array_start")) |global| {
assert(global.file == null);
const sym = &self.locals.items[global.sym_index];
sym.st_value = self.header.?.e_entry;
sym.st_shndx = self.text_sect_index.?;
}
if (self.globals.get("__fini_array_end")) |global| {
assert(global.file == null);
const sym = &self.locals.items[global.sym_index];
sym.st_value = self.header.?.e_entry;
sym.st_shndx = self.text_sect_index.?;
}
}
}
self.logSymtab();
self.logAtoms();
try self.writeAtoms();
try self.writePhdrs();
try self.writeSymtab();
try self.writeStrtab();
try self.writeShStrtab();
try self.writeShdrs();
try self.writeHeader();
}
fn populateMetadata(self: *Elf) !void {
if (self.header == null) {
var header = elf.Elf64_Ehdr{
.e_ident = undefined,
.e_type = switch (self.base.options.output_mode) {
.exe => elf.ET.EXEC,
.lib => elf.ET.DYN,
},
.e_machine = self.base.options.target.cpu.arch.toElfMachine(),
.e_version = 1,
.e_entry = 0,
.e_phoff = @sizeOf(elf.Elf64_Ehdr),
.e_shoff = 0,
.e_flags = 0,
.e_ehsize = @sizeOf(elf.Elf64_Ehdr),
.e_phentsize = @sizeOf(elf.Elf64_Phdr),
.e_phnum = 0,
.e_shentsize = @sizeOf(elf.Elf64_Shdr),
.e_shnum = 0,
.e_shstrndx = 0,
};
// Magic
mem.copy(u8, header.e_ident[0..4], Object.magic);
// Class
header.e_ident[4] = elf.ELFCLASS64;
// Endianness
header.e_ident[5] = elf.ELFDATA2LSB;
// ELF version
header.e_ident[6] = 1;
// OS ABI, often set to 0 regardless of target platform
// ABI Version, possibly used by glibc but not by static executables
// padding
mem.set(u8, header.e_ident[7..][0..9], 0);
self.header = header;
}
if (self.phdr_seg_index == null) {
const offset = @sizeOf(elf.Elf64_Ehdr);
const size = @sizeOf(elf.Elf64_Phdr);
self.phdr_seg_index = @intCast(u16, self.phdrs.items.len);
try self.phdrs.append(self.base.allocator, .{
.p_type = elf.PT_PHDR,
.p_flags = elf.PF_R,
.p_offset = offset,
.p_vaddr = offset + self.base_addr,
.p_paddr = offset + self.base_addr,
.p_filesz = size,
.p_memsz = size,
.p_align = @alignOf(elf.Elf64_Phdr),
});
}
if (self.load_r_seg_index == null) {
self.load_r_seg_index = @intCast(u16, self.phdrs.items.len);
try self.phdrs.append(self.base.allocator, .{
.p_type = elf.PT_LOAD,
.p_flags = elf.PF_R,
.p_offset = 0,
.p_vaddr = self.base_addr,
.p_paddr = self.base_addr,
.p_filesz = @sizeOf(elf.Elf64_Ehdr),
.p_memsz = @sizeOf(elf.Elf64_Ehdr),
.p_align = 0x1000,
});
{
const phdr = &self.phdrs.items[self.phdr_seg_index.?];
phdr.p_filesz += @sizeOf(elf.Elf64_Phdr);
phdr.p_memsz += @sizeOf(elf.Elf64_Phdr);
}
}
if (self.load_re_seg_index == null) {
self.load_re_seg_index = @intCast(u16, self.phdrs.items.len);
try self.phdrs.append(self.base.allocator, .{
.p_type = elf.PT_LOAD,
.p_flags = elf.PF_R | elf.PF_X,
.p_offset = 0,
.p_vaddr = self.base_addr,
.p_paddr = self.base_addr,
.p_filesz = 0,
.p_memsz = 0,
.p_align = 0x1000,
});
{
const phdr = &self.phdrs.items[self.phdr_seg_index.?];
phdr.p_filesz += @sizeOf(elf.Elf64_Phdr);
phdr.p_memsz += @sizeOf(elf.Elf64_Phdr);
}
}
if (self.load_rw_seg_index == null) {
self.load_rw_seg_index = @intCast(u16, self.phdrs.items.len);
try self.phdrs.append(self.base.allocator, .{
.p_type = elf.PT_LOAD,
.p_flags = elf.PF_R | elf.PF_W,
.p_offset = 0,
.p_vaddr = self.base_addr,
.p_paddr = self.base_addr,
.p_filesz = 0,
.p_memsz = 0,
.p_align = 0x1000,
});
{
const phdr = &self.phdrs.items[self.phdr_seg_index.?];
phdr.p_filesz += @sizeOf(elf.Elf64_Phdr);
phdr.p_memsz += @sizeOf(elf.Elf64_Phdr);
}
}
if (self.shstrtab_sect_index == null) {
try self.shstrtab.append(self.base.allocator, 0);
self.shstrtab_sect_index = @intCast(u16, self.shdrs.items.len);
try self.shdrs.append(self.base.allocator, .{
.sh_name = try self.makeShString(".shstrtab"),
.sh_type = elf.SHT_STRTAB,
.sh_flags = 0,
.sh_addr = 0,
.sh_offset = 0,
.sh_size = 0,
.sh_link = 0,
.sh_info = 0,
.sh_addralign = 1,
.sh_entsize = 0,
});
self.header.?.e_shstrndx = self.shstrtab_sect_index.?;
}
if (self.null_sect_index == null) {
self.null_sect_index = @intCast(u16, self.shdrs.items.len);
try self.shdrs.append(self.base.allocator, .{
.sh_name = 0,
.sh_type = elf.SHT_NULL,
.sh_flags = 0,
.sh_addr = 0,
.sh_offset = 0,
.sh_size = 0,
.sh_link = 0,
.sh_info = 0,
.sh_addralign = 0,
.sh_entsize = 0,
});
}
if (self.symtab_sect_index == null) {
self.symtab_sect_index = @intCast(u16, self.shdrs.items.len);
try self.shdrs.append(self.base.allocator, .{
.sh_name = try self.makeShString(".symtab"),
.sh_type = elf.SHT_SYMTAB,
.sh_flags = 0,
.sh_addr = 0,
.sh_offset = 0,
.sh_size = 0,
.sh_link = 0,
.sh_info = 0,
.sh_addralign = @alignOf(elf.Elf64_Sym),
.sh_entsize = @sizeOf(elf.Elf64_Sym),
});
}
if (self.strtab_sect_index == null) {
try self.strtab.append(self.base.allocator, 0);
self.strtab_sect_index = @intCast(u16, self.shdrs.items.len);
try self.shdrs.append(self.base.allocator, .{
.sh_name = try self.makeShString(".strtab"),
.sh_type = elf.SHT_STRTAB,
.sh_flags = 0,
.sh_addr = 0,
.sh_offset = 0,
.sh_size = 0,
.sh_link = 0,
.sh_info = 0,
.sh_addralign = 1,
.sh_entsize = 0,
});
// Link .strtab with .symtab via sh_link field.
self.shdrs.items[self.symtab_sect_index.?].sh_link = self.strtab_sect_index.?;
}
}
pub fn getMatchingSection(self: *Elf, object_id: u16, sect_id: u16) !?u16 {
const object = self.objects.items[object_id];
const shdr = object.shdrs.items[sect_id];
const shdr_name = object.getString(shdr.sh_name);
const flags = shdr.sh_flags;
const res: ?u16 = blk: {
if (flags & elf.SHF_EXCLUDE != 0) break :blk null;
if (flags & elf.SHF_ALLOC == 0) {
if (flags & elf.SHF_MERGE != 0 and flags & elf.SHF_STRINGS != 0) {
if (mem.eql(u8, shdr_name, ".debug_str")) {
if (self.debug_str_index == null) {
self.debug_str_index = @intCast(u16, self.shdrs.items.len);
try self.shdrs.append(self.base.allocator, .{
.sh_name = try self.makeShString(shdr_name),
.sh_type = elf.SHT_PROGBITS,
.sh_flags = elf.SHF_MERGE | elf.SHF_STRINGS,
.sh_addr = 0,
.sh_offset = 0,
.sh_size = 0,
.sh_link = 0,
.sh_info = 0,
.sh_addralign = 0,
.sh_entsize = 1,
});
}
break :blk self.debug_str_index.?;
} else if (mem.eql(u8, shdr_name, ".comment")) {
log.debug("TODO .comment section", .{});
break :blk null;
}
} else if (flags == 0) {
if (mem.eql(u8, shdr_name, ".debug_loc")) {
if (self.debug_loc_index == null) {
self.debug_loc_index = @intCast(u16, self.shdrs.items.len);
try self.shdrs.append(self.base.allocator, .{
.sh_name = try self.makeShString(shdr_name),
.sh_type = elf.SHT_PROGBITS,
.sh_flags = 0,
.sh_addr = 0,
.sh_offset = 0,
.sh_size = 0,
.sh_link = 0,
.sh_info = 0,
.sh_addralign = 0,
.sh_entsize = 0,
});
}
break :blk self.debug_loc_index.?;
} else if (mem.eql(u8, shdr_name, ".debug_abbrev")) {
if (self.debug_abbrev_index == null) {
self.debug_abbrev_index = @intCast(u16, self.shdrs.items.len);
try self.shdrs.append(self.base.allocator, .{
.sh_name = try self.makeShString(shdr_name),
.sh_type = elf.SHT_PROGBITS,
.sh_flags = 0,
.sh_addr = 0,
.sh_offset = 0,
.sh_size = 0,
.sh_link = 0,
.sh_info = 0,
.sh_addralign = 0,
.sh_entsize = 0,
});
}
break :blk self.debug_abbrev_index.?;
} else if (mem.eql(u8, shdr_name, ".debug_info")) {
if (self.debug_info_index == null) {
self.debug_info_index = @intCast(u16, self.shdrs.items.len);
try self.shdrs.append(self.base.allocator, .{
.sh_name = try self.makeShString(shdr_name),
.sh_type = elf.SHT_PROGBITS,
.sh_flags = 0,
.sh_addr = 0,
.sh_offset = 0,
.sh_size = 0,
.sh_link = 0,
.sh_info = 0,
.sh_addralign = 0,
.sh_entsize = 0,
});
}
break :blk self.debug_info_index.?;
} else if (mem.eql(u8, shdr_name, ".debug_frame")) {
if (self.debug_frame_index == null) {
self.debug_frame_index = @intCast(u16, self.shdrs.items.len);
try self.shdrs.append(self.base.allocator, .{
.sh_name = try self.makeShString(shdr_name),
.sh_type = elf.SHT_PROGBITS,
.sh_flags = 0,
.sh_addr = 0,
.sh_offset = 0,
.sh_size = 0,
.sh_link = 0,
.sh_info = 0,
.sh_addralign = 0,
.sh_entsize = 0,
});
}
break :blk self.debug_frame_index.?;
} else if (mem.eql(u8, shdr_name, ".debug_line")) {
if (self.debug_line_index == null) {
self.debug_line_index = @intCast(u16, self.shdrs.items.len);
try self.shdrs.append(self.base.allocator, .{
.sh_name = try self.makeShString(shdr_name),
.sh_type = elf.SHT_PROGBITS,
.sh_flags = 0,
.sh_addr = 0,
.sh_offset = 0,
.sh_size = 0,
.sh_link = 0,
.sh_info = 0,
.sh_addralign = 0,
.sh_entsize = 0,
});
}
break :blk self.debug_line_index.?;
}
}
log.debug("TODO non-alloc sections", .{});
log.debug(" {s} => {}", .{ object.getString(shdr.sh_name), shdr });
break :blk null;
}
if (flags & elf.SHF_EXECINSTR != 0) {
if (mem.eql(u8, shdr_name, ".init")) {
if (self.init_sect_index == null) {
self.init_sect_index = @intCast(u16, self.shdrs.items.len);
try self.shdrs.append(self.base.allocator, .{
.sh_name = try self.makeShString(shdr_name),
.sh_type = elf.SHT_PROGBITS,
.sh_flags = elf.SHF_EXECINSTR | elf.SHF_ALLOC,
.sh_addr = 0,
.sh_offset = 0,
.sh_size = 0,
.sh_link = 0,
.sh_info = 0,
.sh_addralign = 0,
.sh_entsize = 0,
});
}
break :blk self.init_sect_index.?;
} else if (mem.eql(u8, shdr_name, ".fini")) {
if (self.fini_sect_index == null) {
self.fini_sect_index = @intCast(u16, self.shdrs.items.len);
try self.shdrs.append(self.base.allocator, .{
.sh_name = try self.makeShString(shdr_name),
.sh_type = elf.SHT_PROGBITS,
.sh_flags = elf.SHF_EXECINSTR | elf.SHF_ALLOC,
.sh_addr = 0,
.sh_offset = 0,
.sh_size = 0,
.sh_link = 0,
.sh_info = 0,
.sh_addralign = 0,
.sh_entsize = 0,
});
}
break :blk self.fini_sect_index.?;
} else if (mem.eql(u8, shdr_name, ".init_array")) {
if (self.init_array_sect_index == null) {
self.init_array_sect_index = @intCast(u16, self.shdrs.items.len);
try self.shdrs.append(self.base.allocator, .{
.sh_name = try self.makeShString(shdr_name),
.sh_type = elf.SHT_PROGBITS,
.sh_flags = elf.SHF_EXECINSTR | elf.SHF_ALLOC,
.sh_addr = 0,
.sh_offset = 0,
.sh_size = 0,
.sh_link = 0,
.sh_info = 0,
.sh_addralign = 0,
.sh_entsize = 0,
});
}
break :blk self.init_array_sect_index.?;
} else if (mem.eql(u8, shdr_name, ".fini_array")) {
if (self.fini_array_sect_index == null) {
self.fini_array_sect_index = @intCast(u16, self.shdrs.items.len);
try self.shdrs.append(self.base.allocator, .{
.sh_name = try self.makeShString(shdr_name),
.sh_type = elf.SHT_PROGBITS,
.sh_flags = elf.SHF_EXECINSTR | elf.SHF_ALLOC,
.sh_addr = 0,
.sh_offset = 0,
.sh_size = 0,
.sh_link = 0,
.sh_info = 0,
.sh_addralign = 0,
.sh_entsize = 0,
});
}
break :blk self.fini_array_sect_index.?;
}
if (self.text_sect_index == null) {
self.text_sect_index = @intCast(u16, self.shdrs.items.len);
try self.shdrs.append(self.base.allocator, .{
.sh_name = try self.makeShString(".text"),
.sh_type = elf.SHT_PROGBITS,
.sh_flags = elf.SHF_EXECINSTR | elf.SHF_ALLOC,
.sh_addr = 0,
.sh_offset = 0,
.sh_size = 0,
.sh_link = 0,
.sh_info = 0,
.sh_addralign = 0,
.sh_entsize = 0,
});
}
break :blk self.text_sect_index.?;
}
if (flags & elf.SHF_WRITE != 0) {
if (shdr.sh_type == elf.SHT_NOBITS) {
if (self.bss_sect_index == null) {
self.bss_sect_index = @intCast(u16, self.shdrs.items.len);
try self.shdrs.append(self.base.allocator, .{
.sh_name = try self.makeShString(".bss"),
.sh_type = elf.SHT_NOBITS,
.sh_flags = elf.SHF_WRITE | elf.SHF_ALLOC,
.sh_addr = 0,
.sh_offset = 0,
.sh_size = 0,
.sh_link = 0,
.sh_info = 0,
.sh_addralign = 0,
.sh_entsize = 0,
});
}
break :blk self.bss_sect_index.?;
}
if (mem.startsWith(u8, shdr_name, ".data.rel.ro")) {
if (self.data_rel_ro_sect_index == null) {
self.data_rel_ro_sect_index = @intCast(u16, self.shdrs.items.len);
try self.shdrs.append(self.base.allocator, .{
.sh_name = try self.makeShString(".data.rel.ro"),
.sh_type = elf.SHT_PROGBITS,
.sh_flags = elf.SHF_WRITE | elf.SHF_ALLOC,
.sh_addr = 0,
.sh_offset = 0,
.sh_size = 0,
.sh_link = 0,
.sh_info = 0,
.sh_addralign = 0,
.sh_entsize = 0,
});
}
break :blk self.data_rel_ro_sect_index.?;
}
if (self.data_sect_index == null) {
self.data_sect_index = @intCast(u16, self.shdrs.items.len);
try self.shdrs.append(self.base.allocator, .{
.sh_name = try self.makeShString(".data"),
.sh_type = elf.SHT_PROGBITS,
.sh_flags = elf.SHF_WRITE | elf.SHF_ALLOC,
.sh_addr = 0,
.sh_offset = 0,
.sh_size = 0,
.sh_link = 0,
.sh_info = 0,
.sh_addralign = 0,
.sh_entsize = 0,
});
}
break :blk self.data_sect_index.?;
}
if (self.rodata_sect_index == null) {
self.rodata_sect_index = @intCast(u16, self.shdrs.items.len);
try self.shdrs.append(self.base.allocator, .{
.sh_name = try self.makeShString(".rodata"),
.sh_type = elf.SHT_PROGBITS,
.sh_flags = elf.SHF_MERGE | elf.SHF_STRINGS | elf.SHF_ALLOC,
.sh_addr = 0,
.sh_offset = 0,
.sh_size = 0,
.sh_link = 0,
.sh_info = 0,
.sh_addralign = 0,
.sh_entsize = 0,
});
}
break :blk self.rodata_sect_index.?;
};
return res;
}
/// Sorts section headers such that loadable sections come first (following the order of program headers),
/// and symbol and string tables come last. The order of the contents within the file does not have to match
/// the order of the section headers. However loadable sections do have to be within bounds
/// of their respective program headers.
fn sortShdrs(self: *Elf) !void {
var index_mapping = std.AutoHashMap(u16, u16).init(self.base.allocator);
defer index_mapping.deinit();
var shdrs = self.shdrs.toOwnedSlice(self.base.allocator);
defer self.base.allocator.free(shdrs);
try self.shdrs.ensureTotalCapacity(self.base.allocator, shdrs.len);
const indices = &[_]*?u16{
&self.null_sect_index,
&self.rodata_sect_index,
&self.text_sect_index,
&self.init_sect_index,
&self.init_array_sect_index,
&self.fini_sect_index,
&self.fini_array_sect_index,
&self.data_rel_ro_sect_index,
&self.got_sect_index,
&self.data_sect_index,
&self.bss_sect_index,
&self.debug_loc_index,
&self.debug_abbrev_index,
&self.debug_info_index,
&self.debug_str_index,
&self.debug_frame_index,
&self.debug_line_index,
&self.symtab_sect_index,
&self.shstrtab_sect_index,
&self.strtab_sect_index,
};
for (indices) |maybe_index| {
const new_index: u16 = if (maybe_index.*) |index| blk: {
const idx = @intCast(u16, self.shdrs.items.len);
self.shdrs.appendAssumeCapacity(shdrs[index]);
try index_mapping.putNoClobber(index, idx);
break :blk idx;
} else continue;
maybe_index.* = new_index;
}
self.header.?.e_shstrndx = index_mapping.get(self.header.?.e_shstrndx).?;
{
var shdr = &self.shdrs.items[self.symtab_sect_index.?];
shdr.sh_link = self.strtab_sect_index.?;
}
var transient: std.AutoHashMapUnmanaged(u16, *Atom) = .{};
try transient.ensureTotalCapacity(self.base.allocator, self.atoms.count());
var it = self.atoms.iterator();
while (it.next()) |entry| {
const old_sect_id = entry.key_ptr.*;
const new_sect_id = index_mapping.get(old_sect_id).?;
transient.putAssumeCapacityNoClobber(new_sect_id, entry.value_ptr.*);
}
self.atoms.clearAndFree(self.base.allocator);
self.atoms.deinit(self.base.allocator);
self.atoms = transient;
}
fn parsePositionals(self: *Elf, files: []const []const u8) !void {
for (files) |file_name| {
const full_path = full_path: {
var buffer: [fs.MAX_PATH_BYTES]u8 = undefined;
const path = try std.fs.realpath(file_name, &buffer);
break :full_path try self.base.allocator.dupe(u8, path);
};
defer self.base.allocator.free(full_path);
log.debug("parsing input file path '{s}'", .{full_path});
if (try self.parseObject(full_path)) continue;
if (try self.parseArchive(full_path)) continue;
log.warn("unknown filetype for positional input file: '{s}'", .{file_name});
}
}
fn parseLibs(self: *Elf, libs: []const []const u8) !void {
for (libs) |lib| {
log.debug("parsing lib path '{s}'", .{lib});
if (try self.parseArchive(lib)) continue;
log.warn("unknown filetype for a library: '{s}'", .{lib});
}
}
fn parseObject(self: *Elf, path: []const u8) !bool {
const file = fs.cwd().openFile(path, .{}) catch |err| switch (err) {
error.FileNotFound => return false,
else => |e| return e,
};
errdefer file.close();
const name = try self.base.allocator.dupe(u8, path);
errdefer self.base.allocator.free(name);
var object = Object{
.name = name,
.file = file,
};
object.parse(self.base.allocator, self.base.options.target) catch |err| switch (err) {
error.EndOfStream, error.NotObject => {
object.deinit(self.base.allocator);
return false;
},
else => |e| return e,
};
try self.objects.append(self.base.allocator, object);
return true;
}
fn parseArchive(self: *Elf, path: []const u8) !bool {
const file = fs.cwd().openFile(path, .{}) catch |err| switch (err) {
error.FileNotFound => return false,
else => |e| return e,
};
errdefer file.close();
const name = try self.base.allocator.dupe(u8, path);
errdefer self.base.allocator.free(name);
var archive = Archive{
.name = name,
.file = file,
};
archive.parse(self.base.allocator) catch |err| switch (err) {
error.EndOfStream, error.NotArchive => {
archive.deinit(self.base.allocator);
return false;
},
else => |e| return e,
};
try self.archives.append(self.base.allocator, archive);
return true;
}
fn resolveSymbolsInObject(self: *Elf, object_id: u16) !void {
const object = self.objects.items[object_id];
log.debug("resolving symbols in {s}", .{object.name});
for (object.symtab.items) |sym, i| {
const sym_id = @intCast(u32, i);
const sym_name = object.getString(sym.st_name);
const st_bind = sym.st_info >> 4;
const st_type = sym.st_info & 0xf;
switch (st_bind) {
elf.STB_LOCAL => {
log.debug(" (symbol '{s}' local to object; skipping...)", .{sym_name});
continue;
},
elf.STB_WEAK, elf.STB_GLOBAL => {
const name = try self.base.allocator.dupe(u8, sym_name);
const glob_ndx = @intCast(u32, self.globals.values().len);
const res = try self.globals.getOrPut(self.base.allocator, name);
defer if (res.found_existing) self.base.allocator.free(name);
if (!res.found_existing) {
res.value_ptr.* = .{
.sym_index = sym_id,
.file = object_id,
};
if (sym.st_shndx == elf.SHN_UNDEF and st_type == elf.STT_NOTYPE) {
try self.unresolved.putNoClobber(self.base.allocator, glob_ndx, {});
}
continue;
}
const global = res.value_ptr.*;
const linked_obj = self.objects.items[global.file.?];
const linked_sym = linked_obj.symtab.items[global.sym_index];
const linked_sym_bind = linked_sym.st_info >> 4;
if (sym.st_shndx == elf.SHN_UNDEF and st_type == elf.STT_NOTYPE) {
log.debug(" (symbol '{s}' already defined; skipping...)", .{sym_name});
continue;
}
if (linked_sym.st_shndx != elf.SHN_UNDEF) {
if (linked_sym_bind == elf.STB_GLOBAL and st_bind == elf.STB_GLOBAL) {
log.err("symbol '{s}' defined multiple times", .{sym_name});
log.err(" first definition in '{s}'", .{linked_obj.name});
log.err(" next definition in '{s}'", .{object.name});
return error.MultipleSymbolDefinitions;
}
if (st_bind == elf.STB_WEAK) {
log.debug(" (symbol '{s}' already defined; skipping...)", .{sym_name});
continue;
}
}
_ = self.unresolved.fetchSwapRemove(@intCast(u32, self.globals.getIndex(name).?));
res.value_ptr.* = .{
.sym_index = sym_id,
.file = object_id,
};
},
else => {
log.err("unhandled symbol binding type: {}", .{st_bind});
log.err(" symbol '{s}'", .{sym_name});
log.err(" first definition in '{s}'", .{object.name});
return error.UnhandledSymbolBindType;
},
}
}
}
fn resolveSymbolsInArchives(self: *Elf) !void {
if (self.archives.items.len == 0) return;
var next_sym: usize = 0;
loop: while (next_sym < self.unresolved.count()) {
const global = self.globals.values()[self.unresolved.keys()[next_sym]];
const ref_object = self.objects.items[global.file.?];
const sym = ref_object.symtab.items[global.sym_index];
const sym_name = ref_object.getString(sym.st_name);
for (self.archives.items) |archive| {
// Check if the entry exists in a static archive.
const offsets = archive.toc.get(sym_name) orelse {
// No hit.
continue;
};
assert(offsets.items.len > 0);
const object_id = @intCast(u16, self.objects.items.len);
const object = try self.objects.addOne(self.base.allocator);
object.* = try archive.parseObject(self.base.allocator, self.base.options.target, offsets.items[0]);
try self.resolveSymbolsInObject(object_id);
continue :loop;
}
next_sym += 1;
}
}
fn resolveSpecialSymbols(self: *Elf) !void {
var next_sym: usize = 0;
loop: while (next_sym < self.unresolved.count()) {
const global = &self.globals.values()[self.unresolved.keys()[next_sym]];
const object = self.objects.items[global.file.?];
const sym = object.symtab.items[global.sym_index];
const sym_name = object.getString(sym.st_name);
if (mem.eql(u8, sym_name, "__init_array_start") or
mem.eql(u8, sym_name, "__init_array_end") or
mem.eql(u8, sym_name, "__fini_array_start") or
mem.eql(u8, sym_name, "__fini_array_end") or
mem.eql(u8, sym_name, "_DYNAMIC"))
{
const st_shndx: u8 = if (mem.eql(u8, sym_name, "_DYNAMIC")) 0 else 1;
const sym_index = @intCast(u32, self.locals.items.len);
try self.locals.append(self.base.allocator, .{
.st_name = try self.makeString(sym_name),
.st_info = 0,
.st_other = 0,
.st_shndx = st_shndx,
.st_value = 0,
.st_size = 0,
});
global.* = .{
.sym_index = sym_index,
.file = null,
};
_ = self.unresolved.fetchSwapRemove(@intCast(u32, self.globals.getIndex(sym_name).?));
continue :loop;
}
next_sym += 1;
}
}
pub fn createGotAtom(self: *Elf, target: SymbolWithLoc) !*Atom {
const shdr_ndx = self.got_sect_index orelse blk: {
const shdr_ndx = @intCast(u16, self.shdrs.items.len);
try self.shdrs.append(self.base.allocator, .{
.sh_name = try self.makeShString(".got"),
.sh_type = elf.SHT_PROGBITS,
.sh_flags = elf.SHF_WRITE | elf.SHF_ALLOC,
.sh_addr = 0,
.sh_offset = 0,
.sh_size = 0,
.sh_link = 0,
.sh_info = 0,
.sh_addralign = @alignOf(u64),
.sh_entsize = 0,
});
self.got_sect_index = shdr_ndx;
break :blk shdr_ndx;
};
const shdr = &self.shdrs.items[shdr_ndx];
const atom = try Atom.createEmpty(self.base.allocator);
errdefer {
atom.deinit(self.base.allocator);
self.base.allocator.destroy(atom);
}
try self.managed_atoms.append(self.base.allocator, atom);
atom.file = null;
atom.size = @sizeOf(u64);
atom.alignment = @alignOf(u64);
var code = try self.base.allocator.alloc(u8, @sizeOf(u64));
defer self.base.allocator.free(code);
mem.set(u8, code, 0);
try atom.code.appendSlice(self.base.allocator, code);
const tsym = if (target.file) |file| blk: {
const object = self.objects.items[file];
break :blk object.symtab.items[target.sym_index];
} else self.locals.items[target.sym_index];
const tsym_name = if (target.file) |file| blk: {
const object = self.objects.items[file];
break :blk object.getString(tsym.st_name);
} else self.getString(tsym.st_name);
const r_sym = @intCast(u64, target.sym_index) << 32;
const r_addend: i64 = target.file orelse -1;
const r_info = r_sym | elf.R_X86_64_64;
try atom.relocs.append(self.base.allocator, .{
.r_offset = 0,
.r_info = r_info,
.r_addend = r_addend,
});
const tmp_name = try std.fmt.allocPrint(self.base.allocator, ".got.{s}", .{tsym_name});
defer self.base.allocator.free(tmp_name);
const sym_index = @intCast(u32, self.locals.items.len);
try self.locals.append(self.base.allocator, .{
.st_name = try self.makeString(tmp_name),
.st_info = (elf.STB_LOCAL << 4) | elf.STT_OBJECT,
.st_other = 1,
.st_shndx = shdr_ndx,
.st_value = 0,
.st_size = @sizeOf(u64),
});
atom.local_sym_index = sym_index;
// Update target section's metadata
shdr.sh_size += @sizeOf(u64);
if (self.atoms.getPtr(shdr_ndx)) |last| {
last.*.next = atom;
atom.prev = last.*;
last.* = atom;
} else {
try self.atoms.putNoClobber(self.base.allocator, shdr_ndx, atom);
}
return atom;
}
fn allocateSection(self: *Elf, ndx: u16, phdr_ndx: u16) !void {
const shdr = &self.shdrs.items[ndx];
const phdr = &self.phdrs.items[phdr_ndx];
const base_offset = phdr.p_offset + phdr.p_filesz;
shdr.sh_offset = mem.alignForwardGeneric(u64, base_offset, shdr.sh_addralign);
shdr.sh_addr = phdr.p_vaddr + shdr.sh_offset - phdr.p_offset;
const p_size = shdr.sh_offset + shdr.sh_size - base_offset;
if (phdr.p_filesz == 0) {
shdr.sh_addr += phdr.p_offset;
phdr.p_offset = shdr.sh_offset;
phdr.p_vaddr += shdr.sh_offset;
phdr.p_paddr += shdr.sh_offset;
}
log.debug("allocating section '{s}' from 0x{x} to 0x{x} (0x{x} - 0x{x})", .{
self.getShString(shdr.sh_name),
shdr.sh_addr,
shdr.sh_addr + shdr.sh_size,
shdr.sh_offset,
shdr.sh_offset + shdr.sh_size,
});
phdr.p_filesz += p_size;
phdr.p_memsz += p_size;
}
fn getSegmentBaseAddr(self: *Elf, phdr_ndx: u16) u64 {
const phdr = self.phdrs.items[phdr_ndx];
const base_addr = mem.alignForwardGeneric(u64, phdr.p_vaddr + phdr.p_memsz, 0x1000);
return base_addr;
}
fn getSegmentBaseOff(self: *Elf, phdr_ndx: u16) u64 {
const phdr = self.phdrs.items[phdr_ndx];
const base_off = phdr.p_offset + phdr.p_filesz;
return base_off;
}
fn allocateLoadRSeg(self: *Elf) !void {
const phdr = &self.phdrs.items[self.load_r_seg_index.?];
const init_size = @sizeOf(elf.Elf64_Ehdr) + self.phdrs.items.len * @sizeOf(elf.Elf64_Phdr);
phdr.p_offset = 0;
phdr.p_vaddr = self.base_addr;
phdr.p_paddr = self.base_addr;
phdr.p_filesz = init_size;
phdr.p_memsz = init_size;
// This assumes ordering of section headers matches ordering of sections in file
// so that the segments are contiguous in memory.
for (self.shdrs.items) |shdr, ndx| {
const is_read_alloc = blk: {
const flags = shdr.sh_flags;
if (flags & elf.SHF_ALLOC == 0) break :blk false;
if (flags & elf.SHF_WRITE != 0) break :blk false;
if (flags & elf.SHF_EXECINSTR != 0) break :blk false;
break :blk true;
};
if (!is_read_alloc) continue;
try self.allocateSection(@intCast(u16, ndx), self.load_r_seg_index.?);
}
log.debug("allocating read-only LOAD segment:", .{});
log.debug(" in file from 0x{x} to 0x{x}", .{ phdr.p_offset, phdr.p_offset + phdr.p_filesz });
log.debug(" in memory from 0x{x} to 0x{x}", .{ phdr.p_vaddr, phdr.p_vaddr + phdr.p_memsz });
}
fn allocateLoadRESeg(self: *Elf) !void {
const base_addr = self.getSegmentBaseAddr(self.load_r_seg_index.?);
const base_off = self.getSegmentBaseOff(self.load_r_seg_index.?);
const phdr = &self.phdrs.items[self.load_re_seg_index.?];
phdr.p_offset = base_off;
phdr.p_vaddr = base_addr;
phdr.p_paddr = base_addr;
phdr.p_filesz = 0;
phdr.p_memsz = 0;
// This assumes ordering of section headers matches ordering of sections in file
// so that the segments are contiguous in memory.
for (self.shdrs.items) |shdr, ndx| {
const is_exec_alloc = blk: {
const flags = shdr.sh_flags;
break :blk flags & elf.SHF_ALLOC != 0 and flags & elf.SHF_EXECINSTR != 0;
};
if (!is_exec_alloc) continue;
try self.allocateSection(@intCast(u16, ndx), self.load_re_seg_index.?);
}
log.debug("allocating read-execute LOAD segment:", .{});
log.debug(" in file from 0x{x} to 0x{x}", .{ phdr.p_offset, phdr.p_offset + phdr.p_filesz });
log.debug(" in memory from 0x{x} to 0x{x}", .{ phdr.p_vaddr, phdr.p_vaddr + phdr.p_memsz });
}
fn allocateLoadRWSeg(self: *Elf) !void {
const base_addr = self.getSegmentBaseAddr(self.load_re_seg_index.?);
const base_off = self.getSegmentBaseOff(self.load_re_seg_index.?);
const phdr = &self.phdrs.items[self.load_rw_seg_index.?];
phdr.p_offset = base_off;
phdr.p_vaddr = base_addr;
phdr.p_paddr = base_addr;
phdr.p_filesz = 0;
phdr.p_memsz = 0;
// This assumes ordering of section headers matches ordering of sections in file
// so that the segments are contiguous in memory.
for (self.shdrs.items) |shdr, ndx| {
const is_write_alloc = blk: {
const flags = shdr.sh_flags;
break :blk flags & elf.SHF_ALLOC != 0 and flags & elf.SHF_WRITE != 0;
};
if (!is_write_alloc) continue;
try self.allocateSection(@intCast(u16, ndx), self.load_rw_seg_index.?);
}
log.debug("allocating read-write LOAD segment:", .{});
log.debug(" in file from 0x{x} to 0x{x}", .{ phdr.p_offset, phdr.p_offset + phdr.p_filesz });
log.debug(" in memory from 0x{x} to 0x{x}", .{ phdr.p_vaddr, phdr.p_vaddr + phdr.p_memsz });
self.next_offset = phdr.p_offset + phdr.p_filesz;
}
fn allocateNonAllocSections(self: *Elf) !void {
for (self.shdrs.items) |*shdr| {
if (shdr.sh_type == elf.SHT_NULL) continue;
if (shdr.sh_flags & elf.SHF_ALLOC != 0) continue;
shdr.sh_offset = mem.alignForwardGeneric(u64, self.next_offset, shdr.sh_addralign);
log.debug("setting '{s}' non-alloc section's offsets from 0x{x} to 0x{x}", .{
self.getShString(shdr.sh_name),
shdr.sh_offset,
shdr.sh_offset + shdr.sh_size,
});
self.next_offset = shdr.sh_offset + shdr.sh_size;
}
}
fn allocateAtoms(self: *Elf) !void {
var it = self.atoms.iterator();
while (it.next()) |entry| {
const shdr_ndx = entry.key_ptr.*;
const shdr = self.shdrs.items[shdr_ndx];
var atom: *Atom = entry.value_ptr.*;
// Find the first atom
while (atom.prev) |prev| {
atom = prev;
}
log.debug("allocating atoms in '{s}' section", .{self.getShString(shdr.sh_name)});
var base_addr: u64 = shdr.sh_addr;
while (true) {
base_addr = mem.alignForwardGeneric(u64, base_addr, atom.alignment);
if (atom.file) |file| {
const object = &self.objects.items[file];
const sym = &object.symtab.items[atom.local_sym_index];
sym.st_value = base_addr;
sym.st_shndx = shdr_ndx;
sym.st_size = atom.size;
log.debug(" atom '{s}' allocated from 0x{x} to 0x{x}", .{
object.getString(sym.st_name),
base_addr,
base_addr + atom.size,
});
// Update each alias (if any)
for (atom.aliases.items) |index| {
const alias_sym = &object.symtab.items[index];
alias_sym.st_value = base_addr;
alias_sym.st_shndx = shdr_ndx;
alias_sym.st_size = atom.size;
}
// Update each symbol contained within the TextBlock
for (atom.contained.items) |sym_at_off| {
const contained_sym = &object.symtab.items[sym_at_off.local_sym_index];
contained_sym.st_value = base_addr + sym_at_off.offset;
contained_sym.st_shndx = shdr_ndx;
}
} else {
// Synthetic
const sym = &self.locals.items[atom.local_sym_index];
sym.st_value = base_addr;
sym.st_shndx = shdr_ndx;
sym.st_size = atom.size;
log.debug(" atom '{s}' allocated from 0x{x} to 0x{x}", .{
self.getString(sym.st_name),
base_addr,
base_addr + atom.size,
});
}
base_addr += atom.size;
if (atom.next) |next| {
atom = next;
} else break;
}
}
}
fn logAtoms(self: Elf) void {
for (self.shdrs.items) |shdr, ndx| {
var atom = self.atoms.get(@intCast(u16, ndx)) orelse continue;
log.debug("WAT >>> {s}", .{self.getShString(shdr.sh_name)});
while (atom.prev) |prev| {
atom = prev;
}
while (true) {
if (atom.file) |file| {
const object = self.objects.items[file];
const sym = object.symtab.items[atom.local_sym_index];
const sym_name = object.getString(sym.st_name);
log.debug(" {s} : {d} => 0x{x}", .{ sym_name, atom.local_sym_index, sym.st_value });
log.debug(" defined in {s}", .{object.name});
log.debug(" aliases:", .{});
for (atom.aliases.items) |alias| {
const asym = object.symtab.items[alias];
const asym_name = object.getString(asym.st_name);
log.debug(" {s} : {d} => 0x{x}", .{ asym_name, alias, asym.st_value });
}
} else {
const sym = self.locals.items[atom.local_sym_index];
const sym_name = self.getString(sym.st_name);
log.debug(" {s} : {d} => 0x{x}", .{ sym_name, atom.local_sym_index, sym.st_value });
log.debug(" synthetic", .{});
log.debug(" aliases:", .{});
for (atom.aliases.items) |alias| {
const asym = self.locals.items[alias];
const asym_name = self.getString(asym.st_name);
log.debug(" {s} : {d} => 0x{x}", .{ asym_name, alias, asym.st_value });
}
}
if (atom.next) |next| {
atom = next;
} else break;
}
}
}
fn writeAtoms(self: *Elf) !void {
var it = self.atoms.iterator();
while (it.next()) |entry| {
const shdr_ndx = entry.key_ptr.*;
const shdr = self.shdrs.items[shdr_ndx];
var atom: *Atom = entry.value_ptr.*;
// Find the first atom
while (atom.prev) |prev| {
atom = prev;
}
log.debug("writing atoms in '{s}' section", .{self.getShString(shdr.sh_name)});
var buffer = try self.base.allocator.alloc(u8, shdr.sh_size);
defer self.base.allocator.free(buffer);
mem.set(u8, buffer, 0);
while (true) {
const sym = if (atom.file) |file| blk: {
const object = self.objects.items[file];
break :blk object.symtab.items[atom.local_sym_index];
} else self.locals.items[atom.local_sym_index];
const off = sym.st_value - shdr.sh_addr;
try atom.resolveRelocs(self);
const sym_name = if (atom.file) |file|
self.objects.items[file].getString(sym.st_name)
else
self.getString(sym.st_name);
log.debug(" writing atom '{s}' at offset 0x{x}", .{ sym_name, shdr.sh_offset + off });
mem.copy(u8, buffer[off..][0..atom.size], atom.code.items);
if (atom.next) |next| {
atom = next;
} else break;
}
try self.base.file.pwriteAll(buffer, shdr.sh_offset);
}
}
fn setEntryPoint(self: *Elf) !void {
if (self.base.options.output_mode != .exe) return;
const global = self.globals.get("_start") orelse return error.DefaultEntryPointNotFound;
const object = self.objects.items[global.file.?];
const sym = object.symtab.items[global.sym_index];
self.header.?.e_entry = sym.st_value;
}
fn writeSymtab(self: *Elf) !void {
const shdr = &self.shdrs.items[self.symtab_sect_index.?];
var symtab = std.ArrayList(elf.Elf64_Sym).init(self.base.allocator);
defer symtab.deinit();
try symtab.ensureUnusedCapacity(1);
symtab.appendAssumeCapacity(.{
.st_name = 0,
.st_info = 0,
.st_other = 0,
.st_shndx = 0,
.st_value = 0,
.st_size = 0,
});
for (self.objects.items) |object| {
for (object.symtab.items) |sym| {
if (sym.st_name == 0) continue;
const st_bind = sym.st_info >> 4;
const st_type = sym.st_info & 0xf;
if (st_bind != elf.STB_LOCAL) continue;
if (st_type == elf.STT_SECTION) continue;
const sym_name = object.getString(sym.st_name);
var out_sym = sym;
out_sym.st_name = try self.makeString(sym_name);
try symtab.append(out_sym);
}
}
for (self.locals.items) |sym| {
const st_bind = sym.st_info >> 4;
if (st_bind != elf.STB_LOCAL) continue;
try symtab.append(sym);
}
// Denote start of globals
shdr.sh_info = @intCast(u32, symtab.items.len);
try symtab.ensureUnusedCapacity(self.globals.count());
for (self.globals.values()) |global| {
const sym = if (global.file) |file| blk: {
const obj = self.objects.items[file];
const sym = obj.symtab.items[global.sym_index];
const sym_name = obj.getString(sym.st_name);
var out_sym = sym;
out_sym.st_name = try self.makeString(sym_name);
break :blk out_sym;
} else self.locals.items[global.sym_index];
// TODO refactor
if (sym.st_info >> 4 == elf.STB_LOCAL) continue;
symtab.appendAssumeCapacity(sym);
}
shdr.sh_offset = mem.alignForwardGeneric(u64, self.next_offset, @alignOf(elf.Elf64_Sym));
shdr.sh_size = symtab.items.len * @sizeOf(elf.Elf64_Sym);
log.debug("writing '{s}' contents from 0x{x} to 0x{x}", .{
self.getShString(shdr.sh_name),
shdr.sh_offset,
shdr.sh_offset + shdr.sh_size,
});
try self.base.file.pwriteAll(mem.sliceAsBytes(symtab.items), shdr.sh_offset);
self.next_offset = shdr.sh_offset + shdr.sh_size;
}
fn writeStrtab(self: *Elf) !void {
const shdr = &self.shdrs.items[self.strtab_sect_index.?];
shdr.sh_offset = self.next_offset;
shdr.sh_size = self.strtab.items.len;
log.debug("writing '{s}' contents from 0x{x} to 0x{x}", .{
self.getShString(shdr.sh_name),
shdr.sh_offset,
shdr.sh_offset + shdr.sh_size,
});
try self.base.file.pwriteAll(self.strtab.items, shdr.sh_offset);
self.next_offset += shdr.sh_size;
}
fn writeShStrtab(self: *Elf) !void {
const shdr = &self.shdrs.items[self.shstrtab_sect_index.?];
shdr.sh_offset = self.next_offset;
shdr.sh_size = self.shstrtab.items.len;
log.debug("writing '{s}' contents from 0x{x} to 0x{x}", .{
self.getShString(shdr.sh_name),
shdr.sh_offset,
shdr.sh_offset + shdr.sh_size,
});
try self.base.file.pwriteAll(self.shstrtab.items, shdr.sh_offset);
self.next_offset += shdr.sh_size;
}
fn writePhdrs(self: *Elf) !void {
const phdrs_size = self.phdrs.items.len * @sizeOf(elf.Elf64_Phdr);
log.debug("writing program headers from 0x{x} to 0x{x}", .{
self.header.?.e_phoff,
self.header.?.e_phoff + phdrs_size,
});
try self.base.file.pwriteAll(mem.sliceAsBytes(self.phdrs.items), self.header.?.e_phoff);
}
fn writeShdrs(self: *Elf) !void {
const shdrs_size = self.shdrs.items.len * @sizeOf(elf.Elf64_Shdr);
const e_shoff = mem.alignForwardGeneric(u64, self.next_offset, @alignOf(elf.Elf64_Shdr));
log.debug("writing section headers from 0x{x} to 0x{x}", .{
e_shoff,
e_shoff + shdrs_size,
});
try self.base.file.pwriteAll(mem.sliceAsBytes(self.shdrs.items), e_shoff);
self.header.?.e_shoff = e_shoff;
self.next_offset = e_shoff + shdrs_size;
}
fn writeHeader(self: *Elf) !void {
self.header.?.e_phnum = @intCast(u16, self.phdrs.items.len);
self.header.?.e_shnum = @intCast(u16, self.shdrs.items.len);
log.debug("writing ELF header {} at 0x{x}", .{ self.header.?, 0 });
try self.base.file.pwriteAll(mem.asBytes(&self.header.?), 0);
}
fn makeShString(self: *Elf, bytes: []const u8) !u32 {
try self.shstrtab.ensureUnusedCapacity(self.base.allocator, bytes.len + 1);
const new_off = @intCast(u32, self.shstrtab.items.len);
log.debug("writing new string'{s}' in .shstrtab at offset 0x{x}", .{ bytes, new_off });
self.shstrtab.appendSliceAssumeCapacity(bytes);
self.shstrtab.appendAssumeCapacity(0);
return new_off;
}
pub fn getShString(self: Elf, off: u32) []const u8 {
assert(off < self.shstrtab.items.len);
return mem.sliceTo(@ptrCast([*:0]const u8, self.shstrtab.items.ptr + off), 0);
}
fn makeString(self: *Elf, bytes: []const u8) !u32 {
try self.strtab.ensureUnusedCapacity(self.base.allocator, bytes.len + 1);
const new_off = @intCast(u32, self.strtab.items.len);
log.debug("writing new string'{s}' in .strtab at offset 0x{x}", .{ bytes, new_off });
self.strtab.appendSliceAssumeCapacity(bytes);
self.strtab.appendAssumeCapacity(0);
return new_off;
}
pub fn getString(self: Elf, off: u32) []const u8 {
assert(off < self.strtab.items.len);
return mem.sliceTo(@ptrCast([*:0]const u8, self.strtab.items.ptr + off), 0);
}
fn logSymtab(self: Elf) void {
for (self.objects.items) |object| {
log.debug("locals in {s}", .{object.name});
for (object.symtab.items) |sym, i| {
const st_type = sym.st_info & 0xf;
const st_bind = sym.st_info >> 4;
if (st_bind != elf.STB_LOCAL or st_type != elf.STT_SECTION) continue;
log.debug(" {d}: {s}: {}", .{ i, object.getString(sym.st_name), sym });
}
}
log.debug("globals:", .{});
for (self.globals.values()) |global| {
if (global.file) |file| {
const object = self.objects.items[file];
const sym = object.symtab.items[global.sym_index];
log.debug(" {d}: {s}: 0x{x}, {s}", .{ global.sym_index, object.getString(sym.st_name), sym.st_value, object.name });
} else {
const sym = self.locals.items[global.sym_index];
log.debug(" {d}: {s}: 0x{x}", .{ global.sym_index, self.getString(sym.st_name), sym.st_value });
}
}
} | src/link/Elf.zig |
const std = @import("std");
const Arena = std.heap.ArenaAllocator;
const expectEqual = std.testing.expectEqual;
const expectEqualStrings = std.testing.expectEqualStrings;
const yeti = @import("yeti");
const initCodebase = yeti.initCodebase;
const tokenize = yeti.tokenize;
const parse = yeti.parse;
const analyzeSemantics = yeti.analyzeSemantics;
const codegen = yeti.codegen;
const printWasm = yeti.printWasm;
const components = yeti.components;
const literalOf = yeti.query.literalOf;
const typeOf = yeti.query.typeOf;
const parentType = yeti.query.parentType;
const valueType = yeti.query.valueType;
const Entity = yeti.ecs.Entity;
const MockFileSystem = yeti.FileSystem;
test "analyze semantics of vector load" {
var arena = Arena.init(std.heap.page_allocator);
defer arena.deinit();
var codebase = try initCodebase(&arena);
const builtins = codebase.get(components.Builtins);
var fs = try MockFileSystem.init(&arena);
_ = try fs.newFile("foo.yeti",
\\start() i64x2 {
\\ ptr = cast(*i64x2, 0)
\\ *ptr
\\}
);
_ = try analyzeSemantics(codebase, fs, "foo.yeti");
const module = try analyzeSemantics(codebase, fs, "foo.yeti");
const top_level = module.get(components.TopLevel);
const start = top_level.findString("start").get(components.Overloads).slice()[0];
try expectEqualStrings(literalOf(start.get(components.Module).entity), "foo");
try expectEqualStrings(literalOf(start.get(components.Name).entity), "start");
try expectEqual(start.get(components.Parameters).len(), 0);
try expectEqual(start.get(components.ReturnType).entity, builtins.I64X2);
const body = start.get(components.Body).slice();
try expectEqual(body.len, 2);
const ptr = blk: {
const define = body[0];
try expectEqual(define.get(components.AstKind), .define);
try expectEqual(typeOf(define), builtins.Void);
const cast = define.get(components.Value).entity;
try expectEqual(cast.get(components.AstKind), .cast);
const pointer_type = typeOf(cast);
try expectEqual(parentType(pointer_type), builtins.Ptr);
try expectEqual(valueType(pointer_type), builtins.I64X2);
const zero = cast.get(components.Value).entity;
try expectEqual(zero.get(components.AstKind), .int);
try expectEqual(typeOf(zero), builtins.I32);
try expectEqualStrings(literalOf(zero), "0");
const local = define.get(components.Local).entity;
try expectEqual(local.get(components.AstKind), .local);
try expectEqualStrings(literalOf(local.get(components.Name).entity), "ptr");
try expectEqual(typeOf(local), pointer_type);
break :blk local;
};
const load = body[1];
try expectEqual(load.get(components.AstKind), .intrinsic);
try expectEqual(load.get(components.Intrinsic), .v128_load);
try expectEqual(typeOf(load), builtins.I64X2);
const arguments = load.get(components.Arguments).slice();
try expectEqual(arguments.len, 1);
try expectEqual(arguments[0], ptr);
}
test "analyze semantics of binary operators on two int vectors" {
var arena = Arena.init(std.heap.page_allocator);
defer arena.deinit();
var codebase = try initCodebase(&arena);
const b = codebase.get(components.Builtins);
const type_strings = [_][]const u8{ "i64x2", "i32x4", "i16x8", "i8x16", "u64x2", "u32x4", "u16x8", "u8x16" };
const builtins = [_]Entity{ b.I64X2, b.I32X4, b.I16X8, b.I8X16, b.U64X2, b.U32X4, b.U16X8, b.U8X16 };
const op_strings = [_][]const u8{ "+", "-", "*" };
const intrinsics = [_]components.Intrinsic{ .add, .subtract, .multiply };
for (type_strings) |type_string, type_index| {
for (op_strings) |op_string, i| {
var fs = try MockFileSystem.init(&arena);
_ = try fs.newFile("foo.yeti", try std.fmt.allocPrint(arena.allocator(),
\\start() {s} {{
\\ v = *cast(*{s}, 0)
\\ v {s} v
\\}}
, .{ type_string, type_string, op_string }));
_ = try analyzeSemantics(codebase, fs, "foo.yeti");
const module = try analyzeSemantics(codebase, fs, "foo.yeti");
const top_level = module.get(components.TopLevel);
const start = top_level.findString("start").get(components.Overloads).slice()[0];
try expectEqualStrings(literalOf(start.get(components.Module).entity), "foo");
try expectEqualStrings(literalOf(start.get(components.Name).entity), "start");
try expectEqual(start.get(components.Parameters).len(), 0);
try expectEqual(start.get(components.ReturnType).entity, builtins[type_index]);
const body = start.get(components.Body).slice();
try expectEqual(body.len, 2);
const v = blk: {
const define = body[0];
try expectEqual(define.get(components.AstKind), .define);
try expectEqual(typeOf(define), b.Void);
const load = define.get(components.Value).entity;
try expectEqual(load.get(components.AstKind), .intrinsic);
try expectEqual(load.get(components.Intrinsic), .v128_load);
try expectEqual(typeOf(load), builtins[type_index]);
const arguments = load.get(components.Arguments).slice();
try expectEqual(arguments.len, 1);
const cast = arguments[0];
try expectEqual(cast.get(components.AstKind), .cast);
const pointer_type = typeOf(cast);
try expectEqual(parentType(pointer_type), b.Ptr);
try expectEqual(valueType(pointer_type), builtins[type_index]);
const zero = cast.get(components.Value).entity;
try expectEqual(zero.get(components.AstKind), .int);
try expectEqual(typeOf(zero), b.I32);
try expectEqualStrings(literalOf(zero), "0");
const local = define.get(components.Local).entity;
try expectEqual(local.get(components.AstKind), .local);
try expectEqualStrings(literalOf(local.get(components.Name).entity), "v");
try expectEqual(typeOf(local), builtins[type_index]);
break :blk local;
};
const intrinsic = body[1];
try expectEqual(intrinsic.get(components.AstKind), .intrinsic);
try expectEqual(intrinsic.get(components.Intrinsic), intrinsics[i]);
try expectEqual(typeOf(intrinsic), builtins[type_index]);
const intrinsic_arguments = intrinsic.get(components.Arguments).slice();
try expectEqual(intrinsic_arguments.len, 2);
try expectEqual(intrinsic_arguments[0], v);
try expectEqual(intrinsic_arguments[1], v);
}
}
}
test "analyze semantics of binary operators on two float vectors" {
var arena = Arena.init(std.heap.page_allocator);
defer arena.deinit();
var codebase = try initCodebase(&arena);
const b = codebase.get(components.Builtins);
const type_strings = [_][]const u8{ "f64x2", "f32x4" };
const builtins = [_]Entity{ b.F64X2, b.F32X4 };
const op_strings = [_][]const u8{ "+", "-", "*", "/" };
const intrinsics = [_]components.Intrinsic{ .add, .subtract, .multiply, .divide };
for (type_strings) |type_string, type_index| {
for (op_strings) |op_string, i| {
var fs = try MockFileSystem.init(&arena);
_ = try fs.newFile("foo.yeti", try std.fmt.allocPrint(arena.allocator(),
\\start() {s} {{
\\ v = *cast(*{s}, 0)
\\ v {s} v
\\}}
, .{ type_string, type_string, op_string }));
_ = try analyzeSemantics(codebase, fs, "foo.yeti");
const module = try analyzeSemantics(codebase, fs, "foo.yeti");
const top_level = module.get(components.TopLevel);
const start = top_level.findString("start").get(components.Overloads).slice()[0];
try expectEqualStrings(literalOf(start.get(components.Module).entity), "foo");
try expectEqualStrings(literalOf(start.get(components.Name).entity), "start");
try expectEqual(start.get(components.Parameters).len(), 0);
try expectEqual(start.get(components.ReturnType).entity, builtins[type_index]);
const body = start.get(components.Body).slice();
try expectEqual(body.len, 2);
const v = blk: {
const define = body[0];
try expectEqual(define.get(components.AstKind), .define);
try expectEqual(typeOf(define), b.Void);
const load = define.get(components.Value).entity;
try expectEqual(load.get(components.AstKind), .intrinsic);
try expectEqual(load.get(components.Intrinsic), .v128_load);
try expectEqual(typeOf(load), builtins[type_index]);
const arguments = load.get(components.Arguments).slice();
try expectEqual(arguments.len, 1);
const cast = arguments[0];
try expectEqual(cast.get(components.AstKind), .cast);
const pointer_type = typeOf(cast);
try expectEqual(parentType(pointer_type), b.Ptr);
try expectEqual(valueType(pointer_type), builtins[type_index]);
const zero = cast.get(components.Value).entity;
try expectEqual(zero.get(components.AstKind), .int);
try expectEqual(typeOf(zero), b.I32);
try expectEqualStrings(literalOf(zero), "0");
const local = define.get(components.Local).entity;
try expectEqual(local.get(components.AstKind), .local);
try expectEqualStrings(literalOf(local.get(components.Name).entity), "v");
try expectEqual(typeOf(local), builtins[type_index]);
break :blk local;
};
const intrinsic = body[1];
try expectEqual(intrinsic.get(components.AstKind), .intrinsic);
try expectEqual(intrinsic.get(components.Intrinsic), intrinsics[i]);
try expectEqual(typeOf(intrinsic), builtins[type_index]);
const intrinsic_arguments = intrinsic.get(components.Arguments).slice();
try expectEqual(intrinsic_arguments.len, 2);
try expectEqual(intrinsic_arguments[0], v);
try expectEqual(intrinsic_arguments[1], v);
}
}
}
test "analyze semantics of vector store" {
var arena = Arena.init(std.heap.page_allocator);
defer arena.deinit();
var codebase = try initCodebase(&arena);
const builtins = codebase.get(components.Builtins);
var fs = try MockFileSystem.init(&arena);
_ = try fs.newFile("foo.yeti",
\\start() void {
\\ ptr = cast(*i64x2, 0)
\\ *ptr = *ptr
\\}
);
_ = try analyzeSemantics(codebase, fs, "foo.yeti");
const module = try analyzeSemantics(codebase, fs, "foo.yeti");
const top_level = module.get(components.TopLevel);
const start = top_level.findString("start").get(components.Overloads).slice()[0];
try expectEqualStrings(literalOf(start.get(components.Module).entity), "foo");
try expectEqualStrings(literalOf(start.get(components.Name).entity), "start");
try expectEqual(start.get(components.Parameters).len(), 0);
try expectEqual(start.get(components.ReturnType).entity, builtins.Void);
const body = start.get(components.Body).slice();
try expectEqual(body.len, 2);
const ptr = blk: {
const define = body[0];
try expectEqual(define.get(components.AstKind), .define);
try expectEqual(typeOf(define), builtins.Void);
const cast = define.get(components.Value).entity;
try expectEqual(cast.get(components.AstKind), .cast);
const pointer_type = typeOf(cast);
try expectEqual(parentType(pointer_type), builtins.Ptr);
try expectEqual(valueType(pointer_type), builtins.I64X2);
const zero = cast.get(components.Value).entity;
try expectEqual(zero.get(components.AstKind), .int);
try expectEqual(typeOf(zero), builtins.I32);
try expectEqualStrings(literalOf(zero), "0");
const local = define.get(components.Local).entity;
try expectEqual(local.get(components.AstKind), .local);
try expectEqualStrings(literalOf(local.get(components.Name).entity), "ptr");
try expectEqual(typeOf(local), pointer_type);
break :blk local;
};
const store = body[1];
try expectEqual(store.get(components.AstKind), .intrinsic);
try expectEqual(store.get(components.Intrinsic), .v128_store);
try expectEqual(typeOf(store), builtins.Void);
const arguments = store.get(components.Arguments).slice();
try expectEqual(arguments.len, 2);
try expectEqual(arguments[0], ptr);
const load = arguments[1];
try expectEqual(load.get(components.AstKind), .intrinsic);
try expectEqual(load.get(components.Intrinsic), .v128_load);
try expectEqual(typeOf(load), builtins.I64X2);
const load_arguments = load.get(components.Arguments).slice();
try expectEqual(load_arguments.len, 1);
try expectEqual(load_arguments[0], ptr);
}
test "codegen of loading i64x2 through pointer" {
var arena = Arena.init(std.heap.page_allocator);
defer arena.deinit();
var codebase = try initCodebase(&arena);
var fs = try MockFileSystem.init(&arena);
_ = try fs.newFile("foo.yeti",
\\start() i64x2 {
\\ ptr = cast(*i64x2, 0)
\\ *ptr
\\}
);
const module = try analyzeSemantics(codebase, fs, "foo.yeti");
try codegen(module);
const top_level = module.get(components.TopLevel);
const start = top_level.findString("start").get(components.Overloads).slice()[0];
const wasm_instructions = start.get(components.WasmInstructions).slice();
try expectEqual(wasm_instructions.len, 4);
{
const constant = wasm_instructions[0];
try expectEqual(constant.get(components.WasmInstructionKind), .i32_const);
try expectEqualStrings(literalOf(constant.get(components.Constant).entity), "0");
}
{
const local_set = wasm_instructions[1];
try expectEqual(local_set.get(components.WasmInstructionKind), .local_set);
const local = local_set.get(components.Local).entity;
try expectEqualStrings(literalOf(local.get(components.Name).entity), "ptr");
}
{
const local_get = wasm_instructions[2];
try expectEqual(local_get.get(components.WasmInstructionKind), .local_get);
const local = local_get.get(components.Local).entity;
try expectEqualStrings(literalOf(local.get(components.Name).entity), "ptr");
}
try expectEqual(wasm_instructions[3].get(components.WasmInstructionKind), .v128_load);
}
test "codegen of binary op on two int vectors" {
var arena = Arena.init(std.heap.page_allocator);
defer arena.deinit();
var codebase = try initCodebase(&arena);
const type_strings = [_][]const u8{ "i64x2", "i32x4", "i16x8", "i8x16", "u64x2", "u32x4", "u16x8", "u8x16" };
const op_strings = [_][]const u8{ "+", "-", "*" };
const kinds = [_][3]components.WasmInstructionKind{
.{ .i64x2_add, .i64x2_sub, .i64x2_mul },
.{ .i32x4_add, .i32x4_sub, .i32x4_mul },
.{ .i16x8_add, .i16x8_sub, .i16x8_mul },
.{ .i8x16_add, .i8x16_sub, .i8x16_mul },
.{ .i64x2_add, .i64x2_sub, .i64x2_mul },
.{ .i32x4_add, .i32x4_sub, .i32x4_mul },
.{ .i16x8_add, .i16x8_sub, .i16x8_mul },
.{ .i8x16_add, .i8x16_sub, .i8x16_mul },
};
for (type_strings) |type_string, type_index| {
for (op_strings) |op_string, i| {
var fs = try MockFileSystem.init(&arena);
_ = try fs.newFile("foo.yeti", try std.fmt.allocPrint(arena.allocator(),
\\start() {s} {{
\\ v = *cast(*{s}, 0)
\\ v {s} v
\\}}
, .{ type_string, type_string, op_string }));
const module = try analyzeSemantics(codebase, fs, "foo.yeti");
try codegen(module);
const top_level = module.get(components.TopLevel);
const start = top_level.findString("start").get(components.Overloads).slice()[0];
const wasm_instructions = start.get(components.WasmInstructions).slice();
try expectEqual(wasm_instructions.len, 6);
{
const constant = wasm_instructions[0];
try expectEqual(constant.get(components.WasmInstructionKind), .i32_const);
try expectEqualStrings(literalOf(constant.get(components.Constant).entity), "0");
}
try expectEqual(wasm_instructions[1].get(components.WasmInstructionKind), .v128_load);
{
const local_set = wasm_instructions[2];
try expectEqual(local_set.get(components.WasmInstructionKind), .local_set);
const local = local_set.get(components.Local).entity;
try expectEqualStrings(literalOf(local.get(components.Name).entity), "v");
}
{
const local_get = wasm_instructions[3];
try expectEqual(local_get.get(components.WasmInstructionKind), .local_get);
const local = local_get.get(components.Local).entity;
try expectEqualStrings(literalOf(local.get(components.Name).entity), "v");
}
{
const local_get = wasm_instructions[4];
try expectEqual(local_get.get(components.WasmInstructionKind), .local_get);
const local = local_get.get(components.Local).entity;
try expectEqualStrings(literalOf(local.get(components.Name).entity), "v");
}
try expectEqual(wasm_instructions[5].get(components.WasmInstructionKind), kinds[type_index][i]);
}
}
}
test "codegen of binary op on two float vectors" {
var arena = Arena.init(std.heap.page_allocator);
defer arena.deinit();
var codebase = try initCodebase(&arena);
const type_strings = [_][]const u8{ "f64x2", "f32x4" };
const op_strings = [_][]const u8{ "+", "-", "*", "/" };
const kinds = [_][4]components.WasmInstructionKind{
.{ .f64x2_add, .f64x2_sub, .f64x2_mul, .f64x2_div },
.{ .f32x4_add, .f32x4_sub, .f32x4_mul, .f32x4_div },
};
for (type_strings) |type_string, type_index| {
for (op_strings) |op_string, i| {
var fs = try MockFileSystem.init(&arena);
_ = try fs.newFile("foo.yeti", try std.fmt.allocPrint(arena.allocator(),
\\start() {s} {{
\\ v = *cast(*{s}, 0)
\\ v {s} v
\\}}
, .{ type_string, type_string, op_string }));
const module = try analyzeSemantics(codebase, fs, "foo.yeti");
try codegen(module);
const top_level = module.get(components.TopLevel);
const start = top_level.findString("start").get(components.Overloads).slice()[0];
const wasm_instructions = start.get(components.WasmInstructions).slice();
try expectEqual(wasm_instructions.len, 6);
{
const constant = wasm_instructions[0];
try expectEqual(constant.get(components.WasmInstructionKind), .i32_const);
try expectEqualStrings(literalOf(constant.get(components.Constant).entity), "0");
}
try expectEqual(wasm_instructions[1].get(components.WasmInstructionKind), .v128_load);
{
const local_set = wasm_instructions[2];
try expectEqual(local_set.get(components.WasmInstructionKind), .local_set);
const local = local_set.get(components.Local).entity;
try expectEqualStrings(literalOf(local.get(components.Name).entity), "v");
}
{
const local_get = wasm_instructions[3];
try expectEqual(local_get.get(components.WasmInstructionKind), .local_get);
const local = local_get.get(components.Local).entity;
try expectEqualStrings(literalOf(local.get(components.Name).entity), "v");
}
{
const local_get = wasm_instructions[4];
try expectEqual(local_get.get(components.WasmInstructionKind), .local_get);
const local = local_get.get(components.Local).entity;
try expectEqualStrings(literalOf(local.get(components.Name).entity), "v");
}
try expectEqual(wasm_instructions[5].get(components.WasmInstructionKind), kinds[type_index][i]);
}
}
}
test "codegen of storing i64x2 through pointer" {
var arena = Arena.init(std.heap.page_allocator);
defer arena.deinit();
var codebase = try initCodebase(&arena);
var fs = try MockFileSystem.init(&arena);
_ = try fs.newFile("foo.yeti",
\\start() void {
\\ ptr = cast(*i64x2, 0)
\\ *ptr = *ptr
\\}
);
const module = try analyzeSemantics(codebase, fs, "foo.yeti");
try codegen(module);
const top_level = module.get(components.TopLevel);
const start = top_level.findString("start").get(components.Overloads).slice()[0];
const wasm_instructions = start.get(components.WasmInstructions).slice();
try expectEqual(wasm_instructions.len, 6);
{
const constant = wasm_instructions[0];
try expectEqual(constant.get(components.WasmInstructionKind), .i32_const);
try expectEqualStrings(literalOf(constant.get(components.Constant).entity), "0");
}
{
const local_set = wasm_instructions[1];
try expectEqual(local_set.get(components.WasmInstructionKind), .local_set);
const local = local_set.get(components.Local).entity;
try expectEqualStrings(literalOf(local.get(components.Name).entity), "ptr");
}
{
const local_get = wasm_instructions[2];
try expectEqual(local_get.get(components.WasmInstructionKind), .local_get);
const local = local_get.get(components.Local).entity;
try expectEqualStrings(literalOf(local.get(components.Name).entity), "ptr");
}
{
const local_get = wasm_instructions[3];
try expectEqual(local_get.get(components.WasmInstructionKind), .local_get);
const local = local_get.get(components.Local).entity;
try expectEqualStrings(literalOf(local.get(components.Name).entity), "ptr");
}
try expectEqual(wasm_instructions[4].get(components.WasmInstructionKind), .v128_load);
try expectEqual(wasm_instructions[5].get(components.WasmInstructionKind), .v128_store);
}
test "print wasm pointer v128 load" {
var arena = Arena.init(std.heap.page_allocator);
defer arena.deinit();
var codebase = try initCodebase(&arena);
var fs = try MockFileSystem.init(&arena);
_ = try fs.newFile("foo.yeti",
\\start() i64x2 {
\\ ptr = cast(*i64x2, 0)
\\ *ptr
\\}
);
const module = try analyzeSemantics(codebase, fs, "foo.yeti");
try codegen(module);
const wasm = try printWasm(module);
try expectEqualStrings(wasm,
\\(module
\\
\\ (func $foo/start (result v128)
\\ (local $ptr i32)
\\ (i32.const 0)
\\ (local.set $ptr)
\\ (local.get $ptr)
\\ v128.load)
\\
\\ (export "_start" (func $foo/start))
\\
\\ (memory 1)
\\ (export "memory" (memory 0)))
);
}
test "print wasm pointer v128 store" {
var arena = Arena.init(std.heap.page_allocator);
defer arena.deinit();
var codebase = try initCodebase(&arena);
var fs = try MockFileSystem.init(&arena);
_ = try fs.newFile("foo.yeti",
\\start() void {
\\ ptr = cast(*i64x2, 0)
\\ *ptr = *ptr
\\}
);
const module = try analyzeSemantics(codebase, fs, "foo.yeti");
try codegen(module);
const wasm = try printWasm(module);
try expectEqualStrings(wasm,
\\(module
\\
\\ (func $foo/start
\\ (local $ptr i32)
\\ (i32.const 0)
\\ (local.set $ptr)
\\ (local.get $ptr)
\\ (local.get $ptr)
\\ v128.load
\\ v128.store)
\\
\\ (export "_start" (func $foo/start))
\\
\\ (memory 1)
\\ (export "memory" (memory 0)))
);
}
test "print wasm binary op on two int vectors" {
var arena = Arena.init(std.heap.page_allocator);
defer arena.deinit();
var codebase = try initCodebase(&arena);
const type_strings = [_][]const u8{ "i64x2", "i32x4", "i16x8", "i8x16", "u64x2", "u32x4", "u16x8", "u8x16" };
const op_strings = [_][]const u8{ "+", "-", "*" };
const instructions = [_][3][]const u8{
.{ "i64x2.add", "i64x2.sub", "i64x2.mul" },
.{ "i32x4.add", "i32x4.sub", "i32x4.mul" },
.{ "i16x8.add", "i16x8.sub", "i16x8.mul" },
.{ "i8x16.add", "i8x16.sub", "i8x16.mul" },
.{ "i64x2.add", "i64x2.sub", "i64x2.mul" },
.{ "i32x4.add", "i32x4.sub", "i32x4.mul" },
.{ "i16x8.add", "i16x8.sub", "i16x8.mul" },
.{ "i8x16.add", "i8x16.sub", "i8x16.mul" },
};
for (type_strings) |type_string, type_index| {
for (op_strings) |op_string, i| {
var fs = try MockFileSystem.init(&arena);
_ = try fs.newFile("foo.yeti", try std.fmt.allocPrint(arena.allocator(),
\\start() {s} {{
\\ v = *cast(*{s}, 0)
\\ v {s} v
\\}}
, .{ type_string, type_string, op_string }));
const module = try analyzeSemantics(codebase, fs, "foo.yeti");
try codegen(module);
const wasm = try printWasm(module);
try expectEqualStrings(wasm, try std.fmt.allocPrint(arena.allocator(),
\\(module
\\
\\ (func $foo/start (result v128)
\\ (local $v v128)
\\ (i32.const 0)
\\ v128.load
\\ (local.set $v)
\\ (local.get $v)
\\ (local.get $v)
\\ {s})
\\
\\ (export "_start" (func $foo/start))
\\
\\ (memory 1)
\\ (export "memory" (memory 0)))
, .{instructions[type_index][i]}));
}
}
}
test "print wasm binary op on two float vectors" {
var arena = Arena.init(std.heap.page_allocator);
defer arena.deinit();
var codebase = try initCodebase(&arena);
const type_strings = [_][]const u8{ "f64x2", "f32x4" };
const op_strings = [_][]const u8{ "+", "-", "*", "/" };
const instructions = [_][4][]const u8{
.{ "f64x2.add", "f64x2.sub", "f64x2.mul", "f64x2.div" },
.{ "f32x4.add", "f32x4.sub", "f32x4.mul", "f32x4.div" },
};
for (type_strings) |type_string, type_index| {
for (op_strings) |op_string, i| {
var fs = try MockFileSystem.init(&arena);
_ = try fs.newFile("foo.yeti", try std.fmt.allocPrint(arena.allocator(),
\\start() {s} {{
\\ v = *cast(*{s}, 0)
\\ v {s} v
\\}}
, .{ type_string, type_string, op_string }));
const module = try analyzeSemantics(codebase, fs, "foo.yeti");
try codegen(module);
const wasm = try printWasm(module);
try expectEqualStrings(wasm, try std.fmt.allocPrint(arena.allocator(),
\\(module
\\
\\ (func $foo/start (result v128)
\\ (local $v v128)
\\ (i32.const 0)
\\ v128.load
\\ (local.set $v)
\\ (local.get $v)
\\ (local.get $v)
\\ {s})
\\
\\ (export "_start" (func $foo/start))
\\
\\ (memory 1)
\\ (export "memory" (memory 0)))
, .{instructions[type_index][i]}));
}
}
} | src/tests/test_simd.zig |
const std = @import("std");
const fmt = std.fmt;
const mem = std.mem;
const print = std.debug.print;
const Mask = struct {
on: u36 = 0,
off: u36 = 0,
fn update(self: *Mask, mask: *const [36]u8) void {
var on: u36 = 0;
var off: u36 = 0;
var bit_mask: u36 = 1 << 35;
for (mask) |digit| {
if (digit == '1') {
on |= bit_mask;
}
if (digit == '0') {
off |= bit_mask;
}
bit_mask >>= 1;
}
self.on = on;
self.off = off;
}
};
const Memory = struct {
mask: *const Mask,
rv: [99999]u36 = [_]u36{0} ** 99999,
fn init(mask: *const Mask) Memory {
return Memory { .mask = mask };
}
fn update(self: *Memory, address: u36, value: u36) !void {
const real_value = (value | self.mask.on) & ~self.mask.off;
self.rv[address] = real_value;
}
fn sum(self: *Memory) u64 {
var total: u64 = 0;
for (self.rv) |i| {
total += i;
}
return total;
}
};
pub fn main() !void {
var mask = Mask {};
var memory = Memory.init(&mask);
const stdin = std.io.getStdIn().inStream();
var buf: [256]u8 = undefined;
while (try stdin.readUntilDelimiterOrEof(buf[0..], '\r')) |line| {
// lol windows
try stdin.skipUntilDelimiterOrEof('\n');
if (mem.eql(u8, line[0..4], "mask")) {
const new_mask = line[7..43]; // 36 characters after "mask = "
mask.update(new_mask);
} else {
const index_start = 4; // after "mem["
const index_end = index_start + mem.indexOfScalar(u8, line[index_start..], ']').?;
const value_start = index_end + 4; // after "] = ";
const index = try fmt.parseInt(u36, line[index_start..index_end], 10);
const value = try fmt.parseInt(u36, line[value_start..], 10);
try memory.update(index, value);
}
}
const result = memory.sum();
print("{}\n", .{result});
} | 14/part1.zig |
const std = @import("std");
const Report = std.ArrayList(struct {
keep: bool,
code: u12,
});
fn calcRating(report: Report, op: std.math.CompareOperator, decider: u1) !u12 {
var total: usize = report.items.len;
var bit: u4 = 0;
return blk: while (bit < 12) : (bit += 1) {
var ones_count: usize = 0;
var zeroes_count: usize = 0;
for (report.items) |entry| {
if (entry.keep) {
if (0 == (entry.code & (@as(u12, 1) << (11 - bit))))
zeroes_count += 1
else
ones_count += 1;
}
}
const keep_bit: u1 = if (ones_count == zeroes_count)
decider
else if (std.math.compare(ones_count, op, zeroes_count))
@as(u1, 1)
else
@as(u1, 0);
for (report.items) |*entry| {
if (entry.keep) {
const bit_val: u1 = if (0 == (entry.code & (@as(u12, 1) << (11 - bit)))) 0 else 1;
if (bit_val != keep_bit) {
entry.keep = false;
total -= 1;
}
}
}
// found it
if (total == 1)
for (report.items) |entry| if (entry.keep)
break :blk entry.code;
} else error.NoRatingFound;
}
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
var report = Report.init(gpa.allocator());
defer report.deinit();
const stdin = std.io.getStdIn().reader();
var buf: [80]u8 = undefined;
while (try stdin.readUntilDelimiterOrEof(&buf, '\n')) |line|
try report.append(.{
.keep = true,
.code = try std.fmt.parseInt(u12, line, 2),
});
const oxygen_rating = try calcRating(report, .gt, 1);
// reset keep flags
for (report.items) |*entry| entry.keep = true;
const co2_rating = try calcRating(report, .lt, 0);
const stdout = std.io.getStdOut().writer();
try stdout.print("oxygen: {}, co2: {}, value: {}\n", .{ oxygen_rating, co2_rating, @as(u32, oxygen_rating) * @as(u32, co2_rating) });
}
test "calcRating, decider is 1" {
var report = Report.init(std.testing.allocator);
defer report.deinit();
try report.append(.{ .keep = true, .code = 0b0000_0000_0000 });
try report.append(.{ .keep = true, .code = 0b1000_0000_0000 });
try report.append(.{ .keep = true, .code = 0b0100_0000_0000 });
const rating = try calcRating(report, .gt, 1);
try std.testing.expectEqual(@as(u12, 0b0100_0000_0000), rating);
}
test "calcRating, decider is 0" {
var report = Report.init(std.testing.allocator);
defer report.deinit();
try report.append(.{ .keep = true, .code = 0b1111_1111_1111 });
try report.append(.{ .keep = true, .code = 0b0111_1111_1111 });
try report.append(.{ .keep = true, .code = 0b1011_1111_1111 });
const rating = try calcRating(report, .lt, 0);
try std.testing.expectEqual(@as(u12, 0b0111_1111_1111), rating);
} | src/03.zig |
const std = @import("std");
const Table = [1024]u32;
const BufferSize = 4;
pub const Hc256 = struct {
ptable: Table,
qtable: Table,
buffer: [BufferSize]u8 = [_]u8{0} ** BufferSize,
buffered: bool,
ctr: usize = 0,
/// Initialize the cipher with the key and iv
pub fn init(key: [32]u8, iv: [32]u8, buffered: bool) Hc256 {
var cipher = Hc256{
.ptable = undefined,
.qtable = undefined,
.buffered = buffered,
};
var w: [2560]u32 = undefined;
var i: u32 = 0;
while (i < 8) : (i += 1) {
w[i] = @as(u32, key[i * 4]) | (@as(u32, key[(i * 4) + 1]) << 8) | (@as(u32, key[(i * 4) + 2]) << 16) | (@as(u32, key[(i * 4) + 3]) << 24);
w[i + 8] = @as(u32, iv[i * 4]) | (@as(u32, iv[(i * 4) + 1]) << 8) | (@as(u32, iv[(i * 4) + 2]) << 16) | (@as(u32, iv[(i * 4) + 3]) << 24);
}
i = 16;
while (i < 2560) : (i += 1) w[i] = f2(w[i - 2]) +% w[i - 7] +% f1(w[i - 15]) +% w[i - 16] +% i;
i = 0;
while (i < 1024) : (i += 1) {
cipher.ptable[i] = w[i + 512];
cipher.qtable[i] = w[i + 1536];
}
i = 0;
while (i < 4096) : (i += 1) _ = cipher.genWord();
if (buffered) cipher.buffer = [4]u8{ 0, 0, 0, 0 };
return cipher;
}
/// Applies the keystream from the cipher to the given bytes in place
pub fn applyStream(self: *Hc256, data: []u8) void {
const buf_size = @as(usize, self.buffer[0]);
// Handle initial buffering
const dlen = if (self.buffered) blk: {
var i: usize = 0;
const buf_start = 4 - buf_size;
if (data.len <= buf_size) {
while (i < data.len) : (i += 1) {
data[i] ^= self.buffer[buf_start + i];
self.buffer[buf_start + i] = 0;
}
self.buffer[0] = @intCast(u8, (data.len - buf_size));
return;
} else {
while (i < buf_size) : (i += 1) {
data[i] ^= self.buffer[buf_start + i];
self.buffer[buf_start + i] = 0;
}
self.buffer[0] = 0;
}
break :blk data.len - buf_size;
} else data.len;
var i: usize = 0;
while (i < (dlen / 4)) : (i += 1) {
var word = @bitCast([4]u8, self.genWord());
data[(i * 4) + buf_size] ^= word[0];
data[((i * 4) + buf_size) + 1] ^= word[1];
data[((i * 4) + buf_size) + 2] ^= word[2];
data[((i * 4) + buf_size) + 3] ^= word[3];
}
switch (dlen % 4) {
1 => {
var word = @bitCast([4]u8, self.genWord());
data[(i * 4) + buf_size] ^= word[0];
self.buffer = [4]u8{ 3, word[1], word[2], word[3] };
},
2 => {
var word = @bitCast([4]u8, self.genWord());
data[(i * 4) + buf_size] ^= word[0];
data[((i * 4) + buf_size) + 1] ^= word[1];
self.buffer = [4]u8{ 2, 0, word[2], word[3] };
},
3 => {
var word = @bitCast([4]u8, self.genWord());
data[(i * 4) + buf_size] ^= word[0];
data[((i * 4) + buf_size) + 1] ^= word[1];
data[((i * 4) + buf_size) + 2] ^= word[2];
self.buffer = [4]u8{ 1, 0, 0, word[3] };
},
else => {}, // This will always be zeroes if buffered
}
}
/// Generates the next word from the cipher
pub fn genWord(self: *Hc256) u32 {
defer self.ctr = (self.ctr + 1) & 2047;
if (self.ctr < 1024) {
self.ptable[self.ctr & 1023] = self.ptable[self.ctr & 1023] +% self.ptable[(self.ctr -% 10) & 1023] +% self.g1(self.ptable[(self.ctr -% 3) & 1023], self.ptable[(self.ctr -% 1023) & 1023]);
return self.h1(self.ptable[(self.ctr -% 12) & 1023]) ^ self.ptable[self.ctr & 1023];
} else {
self.qtable[self.ctr & 1023] = self.qtable[self.ctr & 1023] +% self.qtable[(self.ctr -% 10) & 1023] +% self.g2(self.qtable[(self.ctr -% 3) & 1023], self.qtable[(self.ctr -% 1023) & 1023]);
return self.h1(self.qtable[(self.ctr -% 12) & 1023]) ^ self.qtable[self.ctr & 1023];
}
}
pub fn random(self: *Hc256) std.rand.Random {
return std.rand.Random.init(self, applyStream);
}
fn h1(self: *Hc256, x: u32) u32 {
return self.qtable[x & 255] +% self.qtable[256 + ((x >> 8) & 255)] +% self.qtable[512 + ((x >> 16) & 255)] +% self.qtable[768 + ((x >> 24) & 255)];
}
fn h2(self: *Hc256, x: u32) u32 {
return self.ptable[x & 255] +% self.ptable[256 + ((x >> 8) & 255)] +% self.ptable[512 + ((x >> 16) & 255)] +% self.ptable[768 + ((x >> 24) & 255)];
}
fn g1(self: *Hc256, x: u32, y: u32) u32 {
return (((x >> 10) | (x << (32 - 10))) ^ ((y >> 23) | (y << (32 - 23)))) +% self.qtable[(x ^ y) & 1023];
}
fn g2(self: *Hc256, x: u32, y: u32) u32 {
return (((x >> 10) | (x << (32 - 10))) ^ ((y >> 23) | (y << (32 - 23)))) +% self.ptable[(x ^ y) & 1023];
}
};
fn f1(x: u32) u32 {
return ((x >> 7) | (x << (32 - 7))) ^ ((x >> 18) | (x << (32 - 18))) ^ (x >> 3);
}
fn f2(x: u32) u32 {
return ((x >> 17) | (x << (32 - 17))) ^ ((x >> 19) | (x << (32 - 19))) ^ (x >> 10);
} | hc256.zig |
const std = @import("std");
const testing = std.testing;
const c = @import("c/c.zig");
const windows = c.windows;
const utils = @import("utils.zig");
pub const types = @import("types.zig");
pub const Event = @import("events.zig").Event;
pub fn getCodepage() c_uint {
return c.GetConsoleOutputCP();
}
pub fn setCodepage(codepage: c_uint) !void {
if (c.SetConsoleOutputCP(codepage) == 0) {
switch (windows.kernel32.GetLastError()) {
else => |err| return windows.unexpectedError(err),
}
}
}
pub const ConsoleApp = struct {
const Self = @This();
stdin_handle: windows.HANDLE,
stdout_handle: windows.HANDLE,
pub fn init() !Self {
return Self{ .stdin_handle = try windows.GetStdHandle(windows.STD_INPUT_HANDLE), .stdout_handle = try windows.GetStdHandle(windows.STD_OUTPUT_HANDLE) };
}
pub fn getInputMode(self: Self) !types.InputMode {
var mode: windows.DWORD = undefined;
if (c.GetConsoleMode(self.stdin_handle, &mode) == 0) {
switch (windows.kernel32.GetLastError()) {
else => |err| return windows.unexpectedError(err),
}
}
return utils.fromUnsigned(types.InputMode, mode);
}
pub fn setInputMode(self: Self, mode: types.InputMode) !void {
if (c.SetConsoleMode(self.stdin_handle, utils.toUnsigned(types.InputMode, mode)) == 0) {
switch (windows.kernel32.GetLastError()) {
else => |err| return windows.unexpectedError(err),
}
}
}
pub fn getOutputMode(self: Self) !types.OutputMode {
var mode: windows.DWORD = undefined;
if (c.GetConsoleMode(self.stdout_handle, &mode) == 0) {
switch (windows.kernel32.GetLastError()) {
else => |err| return windows.unexpectedError(err),
}
}
return utils.fromUnsigned(types.OutputMode, mode);
}
pub fn setOutputMode(self: Self, mode: types.OutputMode) !void {
if (c.SetConsoleMode(self.stdout_handle, utils.toUnsigned(types.OutputMode, mode)) == 0) {
switch (windows.kernel32.GetLastError()) {
else => |err| return windows.unexpectedError(err),
}
}
}
pub fn getEvent(self: Self) !Event {
var event_count: u32 = 0;
var input_record = std.mem.zeroes(c.INPUT_RECORD);
if (c.ReadConsoleInputW(self.stdin_handle, &input_record, 1, &event_count) == 0) {
switch (windows.kernel32.GetLastError()) {
else => |err| return windows.unexpectedError(err),
}
}
return Event.fromInputRecord(input_record);
}
pub fn viewportCoords(self: Self, coords: types.Coords, viewport_rect: ?types.Rect) !types.Coords {
return types.Coords{ .x = coords.x, .y = coords.y - (viewport_rect orelse (try self.getScreenBufferInfo()).viewport_rect).top };
}
pub fn getScreenBufferInfo(self: Self) !types.ScreenBufferInfo {
var bf = std.mem.zeroes(windows.CONSOLE_SCREEN_BUFFER_INFO);
if (windows.kernel32.GetConsoleScreenBufferInfo(self.stdout_handle, &bf) == 0) {
switch (windows.kernel32.GetLastError()) {
else => |err| return windows.unexpectedError(err),
}
}
return @bitCast(types.ScreenBufferInfo, bf);
}
}; | src/main.zig |
const std = @import("std");
const immu = @import("mmu.zig");
const Mmu = immu.Mmu;
const A = immu.addresses;
const meta = @import("meta.zig");
// number of cycles to scan and vblank
pub const frame_cycle_time = 70224;
pub fn Gpu(comptime Window: type) type {
comptime {
std.debug.assert(meta.hasField(Window, "pixels"));
std.debug.assert(meta.hasFunction(Window, "init"));
std.debug.assert(meta.hasFunction(Window, "render"));
}
return struct {
const Self = @This();
window: *Window,
ticks: usize,
// NOTE: We bypass the mmu in most cases since we don't have the same R/W restrictions on
// various registers that the mmu imposes.
mmu: *Mmu,
pub fn init(mmu: *Mmu, window: *Window) Self {
return Self{
.window = window,
.ticks = 0,
.mmu = mmu,
};
}
// swizzle(abcdefgh, ABCDEFGH) = aAbBcCdDeEfFgGhH
fn swizzle(x: u8, y: u8) u16 {
return @truncate(u16, ((u64(x) *% 0x0101010101010101 & 0x8040201008040201) *%
0x0102040810204081 >> 49) & 0x5555 |
((u64(y) *% 0x0101010101010101 & 0x8040201008040201) *%
0x0102040810204081 >> 48) & 0xAAAA);
}
// NOTE: We could draw the entire frame at once since we don't blit until the end but this
// is more authentic compared to how the screen is actually drawn in hardware.
fn renderScanLine(g: *Self) void {
// We have two tile-maps. Use the correct one and offset by SCY scanlines.
const map_offset = ((g.mmu.mem[A.LY__] +% g.mmu.mem[A.SCY_]) >> 3) + if (g.mmu.mem[A.LCDC] & 0x08 != 0) u16(0x1c00) else 0x1800;
var line_offset = g.mmu.mem[A.SCX_] >> 3;
const y = (g.mmu.mem[A.LY__] +% g.mmu.mem[A.SCY_]) & 3;
var x = g.mmu.mem[A.SCX_] & 7;
// Look up the palette order from BGP and display
const palette = [4][3]u8{
[]u8{ 0xff, 0xff, 0xff }, // White
[]u8{ 0xaa, 0xaa, 0xaa }, // Light gray
[]u8{ 0x55, 0x55, 0x55 }, // Dark gray
[]u8{ 0x00, 0x00, 0x00 }, // Black
};
// TODO: Can LCDC be modified during the write to switch tiles mid-scroll.
const tile_offset = x % 8;
if (tile_offset != 0) {
var tile: u16 = g.mmu.vram[map_offset + line_offset];
if (g.mmu.mem[A.LCDC] & 0x04 != 0 and tile < 128) tile += 256;
line_offset = (line_offset + 1) & 31;
const b = swizzle(g.mmu.read(2 * tile), g.mmu.read(2 * tile + 1));
var px: usize = tile_offset;
while (px < 8) : (px += 1) {
const shift = @truncate(u3, b >> @intCast(u4, 2 * px));
const c = palette[(g.mmu.mem[A.BGP_] >> shift) & 3];
g.window.pixels[y][x] = (u32(c[0]) << 24) | (u32(c[1]) << 16) | (u32(c[2]) << 8);
}
}
var i: usize = 0;
while (i < 160 - tile_offset) : (i += 8) {
var tile: u16 = g.mmu.vram[map_offset + line_offset];
if (g.mmu.mem[A.LCDC] & 0x04 != 0 and tile < 128) tile += 256;
line_offset = (line_offset + 1) & 31;
const b = swizzle(g.mmu.read(2 * tile), g.mmu.read(2 * tile + 1));
var px: usize = 0;
while (px < 8) : (px += 1) {
const shift = @truncate(u3, b >> @intCast(u4, 2 * px));
const c = palette[(g.mmu.mem[A.BGP_] >> shift) & 3];
g.window.pixels[y][x] = (u32(c[0]) << 24) | (u32(c[1]) << 16) | (u32(c[2]) << 8);
}
}
if (tile_offset != 0) {
var tile: u16 = g.mmu.vram[map_offset + line_offset];
if (g.mmu.mem[A.LCDC] & 0x04 != 0 and tile < 128) tile += 256;
line_offset = (line_offset + 1) & 31;
const b = swizzle(g.mmu.read(2 * tile), g.mmu.read(2 * tile + 1));
var px: usize = 0;
while (px < 8 - tile_offset) : (px += 1) {
const shift = @truncate(u3, b >> @intCast(u4, 2 * px));
const c = palette[(g.mmu.mem[A.BGP_] >> shift) & 3];
g.window.pixels[y][x] = (u32(c[0]) << 24) | (u32(c[1]) << 16) | (u32(c[2]) << 8);
}
}
}
pub fn step(g: *Self, cycles: usize) void {
g.ticks += cycles;
const mode = @truncate(u2, g.mmu.mem[A.STAT]);
switch (mode) {
// The LCD controller is in the H-Blank period and
// the CPU can access both the display RAM (8000h-9FFFh)
// and OAM (FE00h-FE9Fh)
0 => {
if (g.ticks >= 80) {
g.ticks -= 80;
g.mmu.mem[A.STAT] = ~u8(0b11);
g.mmu.mem[A.STAT] |= 0b11;
}
},
// The LCD controller is in the V-Blank period (or the
// display is disabled) and the CPU can access both the
// display RAM (8000h-9FFFh) and OAM (FE00h-FE9Fh)
1 => {
if (g.ticks >= 172) {
g.ticks -= 172;
g.mmu.mem[A.STAT] = ~u8(0b11);
g.renderScanLine();
}
},
// The LCD controller is reading from OAM memory.
// The CPU <cannot> access OAM memory (FE00h-FE9Fh)
// during this period.
2 => {
if (g.ticks >= 204) {
g.ticks -= 204;
g.mmu.mem[A.LY__] += 1;
if (g.mmu.mem[A.LY__] == 143) {
g.mmu.mem[A.STAT] = ~u8(0b11);
g.mmu.mem[A.STAT] |= 1;
g.window.render();
} else {
g.mmu.mem[A.STAT] = ~u8(0b11);
g.mmu.mem[A.STAT] |= 2;
}
}
},
// The LCD controller is reading from both OAM and VRAM,
// The CPU <cannot> access OAM and VRAM during this period.
// CGB Mode: Cannot access Palette Data (FF69,FF6B) either.
3 => {
if (g.ticks >= 456) {
g.ticks -= 456;
g.mmu.mem[A.LY__] += 1;
if (g.mmu.mem[A.LY__] > 153) {
g.mmu.mem[A.STAT] = ~u8(0b11);
g.mmu.mem[A.STAT] |= 2;
g.mmu.mem[A.LY__] = 0;
}
}
},
}
}
};
} | src/gpu.zig |
const std = @import("std");
const argsParser = @import("args");
const ihex = @import("ihex");
extern fn configure_serial(fd: c_int) u8;
extern fn flush_serial(fd: c_int) void;
pub fn main() anyerror!u8 {
const cli_args = argsParser.parseForCurrentProcess(struct {
// This declares long options for double hyphen
output: ?[]const u8 = null,
help: bool = false,
size: ?usize = null,
// This declares short-hand options for single hyphen
pub const shorthands = .{
.o = "output",
.h = "help",
.s = "size",
};
}, std.heap.page_allocator, .print) catch return 1;
defer cli_args.deinit();
const stdout = std.io.getStdOut().writer();
// const stdin = std.io.getStdOut().reader();
if (cli_args.options.help or cli_args.positionals.len == 0 or cli_args.options.output == null) {
try stdout.writeAll(
\\ hex2bin [-h] [-o outfile] infile.hex [infile.hex …]
\\ -h, --help Outputs this help text
\\ -o, --output Defines the name of the output file, required
\\ -s, --size If given, the file will have this size in bytes,
\\ otherwise the size will be determined automatically.
\\
\\ Combines one or more intel hex files into a binary file.
\\ The output file will have all bytes set to zero for all bytes
\\ not contained in the hex files.
\\
);
return if (cli_args.options.help) @as(u8, 0) else 1; // when we explicitly call help, we succeed
}
const outfile = try std.fs.cwd().createFile(cli_args.options.output.?, .{ .truncate = true, .read = true });
defer outfile.close();
const HexParser = struct {
const Self = @This();
const Error = error{InvalidHexFile} || std.os.WriteError || std.os.SeekError;
file: *const std.fs.File,
fn load(p: *const Self, base: u32, data: []const u8) Error!void {
try p.file.seekTo(base);
try p.file.writeAll(data);
}
};
const parseMode = ihex.ParseMode{
.pedantic = true,
};
const parser = HexParser{
.file = &outfile,
};
for (cli_args.positionals) |file_name| {
var infile = try std.fs.cwd().openFile(file_name, .{ .read = true, .write = false });
defer infile.close();
_ = try ihex.parseData(infile.reader(), parseMode, &parser, HexParser.Error, HexParser.load);
}
return 0;
} | tools/hex2bin/main.zig |
const std = @import("std");
const t = std.testing;
const Input = @This();
pub const Position = struct {
index: usize = 0,
label: ?[]const u8 = null,
line: usize = 1,
col: usize = 1,
pub fn format(
self: Position,
comptime fmt: []const u8,
options: std.fmt.FormatOptions,
writer: anytype,
) !void {
_ = fmt;
_ = options;
_ = writer;
std.fmt.format("{}:{}:{}", .{
self.label orelse "(null)",
self.line,
self.col,
});
}
};
buffer: []const u8,
pos: Position = Position{},
pub fn init(bytes: []const u8, name: ?[]const u8) Input {
return .{ .buffer = bytes, .pos = .{ .label = name } };
}
///
/// Returns the slice between two inputs
///
/// Arguments:
/// `self: Self` - lagging input
/// `tail: Self` - leading input
///
/// Returns:
/// `[self.index..tail.index]const u8`
///
pub fn diff(self: Input, tail: Input) []const u8 {
return self.buffer[self.pos.index..tail.pos.index];
}
///
/// Returns the length of the remaining input
///
/// Arguments:
/// `self: Self`
///
/// Returns:
/// `usize`
///
pub fn len(self: Input) usize {
return self.buffer.len - self.pos.index;
}
///
/// Returns a slice with the remaining input
///
/// Arguments:
/// `self: Self`
/// `length: ?usize` - optional max length
///
/// Returns:
/// `[index..]const u8`
///
pub fn peek(self: Input, length: ?usize) []const u8 {
const here = self.pos.index;
const end = self.buffer.len;
const there = if (length) |l| std.math.min(end, here + l) else end;
return self.buffer[here..there];
}
test "peek at the tail" {
const input = Input.init("hello", null);
try t.expectEqualSlices(u8, "hello", input.peek(null));
}
///
/// Returns an input with the index moved forward
///
/// Arguments:
/// `self: Self` - input
/// `length: usize` - length of the slice that was taken
///
pub fn take(self: Input, length: usize) Input {
const here = self.pos.index;
const next = std.math.min(self.buffer.len, here + length);
var new = self;
var i = here;
while (i < next) : (i += 1) {
// TODO:
// Do we need anything else than LF and CR+LF line ends?
//
switch (self.buffer[i]) {
'\n' => {
new.pos.line += 1;
new.pos.col = 1;
},
'\r' => {},
else => new.pos.col += 1,
}
}
new.pos.index = i;
return new;
}
test "take nothing" {
const input0 = Input.init("hello, world\n", null);
const input1 = input0.take(0);
try t.expectEqualSlices(u8, input0.peek(null), input1.peek(null));
}
test "take everything" {
const input0 = Input.init("hello, world\n", null);
const input1 = input0.take(std.math.maxInt(usize));
try t.expectEqualSlices(u8, "", input1.peek(null));
} | src/input.zig |
const std = @import("std");
const zap = @import("zap");
const hyperia = @import("hyperia");
const picohttp = @import("picohttp");
const Reactor = hyperia.Reactor;
const AsyncSocket = hyperia.AsyncSocket;
const AsyncWaitGroupAllocator = hyperia.AsyncWaitGroupAllocator;
const os = std.os;
const net = std.net;
const mem = std.mem;
const math = std.math;
const mpsc = hyperia.mpsc;
const log = std.log.scoped(.server);
usingnamespace hyperia.select;
pub const log_level = .debug;
var stopped: bool = false;
var pool: hyperia.ObjectPool(mpsc.Sink([]const u8).Node, 4096) = undefined;
pub const Server = struct {
pub const Connection = struct {
server: *Server,
socket: AsyncSocket,
address: net.Address,
frame: @Frame(Connection.start),
queue: mpsc.AsyncSink([]const u8) = .{},
pub fn start(self: *Connection) !void {
defer {
// log.info("{} has disconnected", .{self.address});
if (self.server.deregister(self.address)) {
suspend {
self.cleanup();
self.socket.deinit();
self.server.wga.allocator.destroy(self);
}
}
}
const Cases = struct {
write: struct {
run: Case(Connection.writeLoop),
cancel: Case(mpsc.AsyncSink([]const u8).close),
},
read: struct {
run: Case(Connection.readLoop),
cancel: Case(AsyncSocket.cancel),
},
};
switch (select(
Cases{
.write = .{
.run = call(Connection.writeLoop, .{self}),
.cancel = call(mpsc.AsyncSink([]const u8).close, .{&self.queue}),
},
.read = .{
.run = call(Connection.readLoop, .{self}),
.cancel = call(AsyncSocket.cancel, .{ &self.socket, .read }),
},
},
)) {
.write => |result| return result,
.read => |result| return result,
}
}
pub fn cleanup(self: *Connection) void {
var first: *mpsc.Sink([]const u8).Node = undefined;
var last: *mpsc.Sink([]const u8).Node = undefined;
while (true) {
var num_items = self.queue.tryPopBatch(&first, &last);
if (num_items == 0) break;
while (num_items > 0) : (num_items -= 1) {
const next = first.next;
pool.release(hyperia.allocator, first);
first = next orelse continue;
}
}
}
pub fn writeLoop(self: *Connection) !void {
var first: *mpsc.Sink([]const u8).Node = undefined;
var last: *mpsc.Sink([]const u8).Node = undefined;
while (true) {
const num_items = self.queue.popBatch(&first, &last);
if (num_items == 0) return;
var i: usize = 0;
defer while (i < num_items) : (i += 1) {
const next = first.next;
pool.release(hyperia.allocator, first);
first = next orelse continue;
};
while (i < num_items) : (i += 1) {
var index: usize = 0;
while (index < first.value.len) {
index += try self.socket.send(first.value[index..], os.MSG_NOSIGNAL);
}
const next = first.next;
pool.release(hyperia.allocator, first);
first = next orelse continue;
}
}
}
pub fn readLoop(self: *Connection) !void {
var buf = std.ArrayList(u8).init(hyperia.allocator);
defer buf.deinit();
var headers: [128]picohttp.Header = undefined;
while (true) {
const old_len = buf.items.len;
try buf.ensureCapacity(4096);
buf.items.len = buf.capacity;
const num_bytes = try self.socket.recv(buf.items[old_len..], os.MSG_NOSIGNAL);
if (num_bytes == 0) return;
buf.items.len = old_len + num_bytes;
const end_idx = mem.indexOf(u8, buf.items[old_len - math.min(old_len, 4) ..], "\r\n\r\n") orelse continue;
const req = try picohttp.Request.parse(buf.items[0 .. end_idx + 4], &headers);
// std.debug.print("Method: {s}\n", .{req.method});
// std.debug.print("Path: {s}\n", .{req.path});
// std.debug.print("Minor Version: {}\n", .{req.minor_version});
// for (req.headers) |header| {
// std.debug.print("{}\n", .{header});
// }
const RES = "HTTP/1.1 200 OK\r\nContent-Type: text/html; charset=utf-8\r\nContent-Length: 12\r\n\r\nHello world!";
const node = try pool.acquire(hyperia.allocator);
node.* = .{ .value = RES };
self.queue.push(node);
buf.items.len = 0;
}
}
};
listener: AsyncSocket,
wga: AsyncWaitGroupAllocator,
lock: std.Thread.Mutex = .{},
connections: std.AutoArrayHashMapUnmanaged(os.sockaddr, *Connection) = .{},
pub fn init(allocator: *mem.Allocator) Server {
return Server{
.listener = undefined,
.wga = .{ .backing_allocator = allocator },
};
}
pub fn deinit(self: *Server, allocator: *mem.Allocator) void {
{
const held = self.lock.acquire();
defer held.release();
for (self.connections.items()) |entry| {
log.info("closing {}", .{entry.value.address});
entry.value.socket.shutdown(.both) catch {};
}
}
self.wga.wait();
self.connections.deinit(allocator);
}
pub fn close(self: *Server) void {
self.listener.shutdown(.recv) catch {};
}
pub fn start(self: *Server, reactor: Reactor, address: net.Address) !void {
self.listener = try AsyncSocket.init(os.AF_INET, os.SOCK_STREAM | os.SOCK_CLOEXEC, os.IPPROTO_TCP);
errdefer self.listener.deinit();
try reactor.add(self.listener.socket.fd, &self.listener.handle, .{ .readable = true });
try self.listener.setReuseAddress(true);
try self.listener.setReusePort(true);
try self.listener.setNoDelay(true);
try self.listener.setFastOpen(true);
try self.listener.setQuickAck(true);
try self.listener.bind(address);
try self.listener.listen(128);
log.info("listening for connections on: {}", .{try self.listener.getName()});
}
fn accept(self: *Server, allocator: *mem.Allocator, reactor: Reactor) !void {
while (true) {
var conn = try self.listener.accept(os.SOCK_CLOEXEC | os.SOCK_NONBLOCK);
errdefer conn.socket.deinit();
try conn.socket.setNoDelay(true);
// log.info("got connection: {}", .{conn.address});
const wga_allocator = &self.wga.allocator;
const connection = try wga_allocator.create(Connection);
errdefer wga_allocator.destroy(connection);
connection.server = self;
connection.socket = AsyncSocket.from(conn.socket);
connection.address = conn.address;
connection.queue = .{};
try reactor.add(conn.socket.fd, &connection.socket.handle, .{ .readable = true, .writable = true });
{
const held = self.lock.acquire();
defer held.release();
try self.connections.put(allocator, connection.address.any, connection);
}
connection.frame = async connection.start();
}
}
fn deregister(self: *Server, address: net.Address) bool {
const held = self.lock.acquire();
defer held.release();
const entry = self.connections.swapRemove(address.any) orelse return false;
return true;
}
};
pub fn runApp(reactor: Reactor, reactor_event: *Reactor.AutoResetEvent) !void {
defer {
log.info("shutting down...", .{});
@atomicStore(bool, &stopped, true, .Release);
reactor_event.post();
}
var server = Server.init(hyperia.allocator);
defer server.deinit(hyperia.allocator);
const address = net.Address.initIp4(.{ 0, 0, 0, 0 }, 9000);
try server.start(reactor, address);
const Cases = struct {
accept: struct {
run: Case(Server.accept),
cancel: Case(Server.close),
},
ctrl_c: struct {
run: Case(hyperia.ctrl_c.wait),
cancel: Case(hyperia.ctrl_c.cancel),
},
};
switch (select(
Cases{
.accept = .{
.run = call(Server.accept, .{ &server, hyperia.allocator, reactor }),
.cancel = call(Server.close, .{&server}),
},
.ctrl_c = .{
.run = call(hyperia.ctrl_c.wait, .{}),
.cancel = call(hyperia.ctrl_c.cancel, .{}),
},
},
)) {
.accept => |result| return result,
.ctrl_c => |result| return result,
}
}
pub fn main() !void {
hyperia.init();
defer hyperia.deinit();
hyperia.ctrl_c.init();
defer hyperia.ctrl_c.deinit();
pool = try hyperia.ObjectPool(mpsc.Sink([]const u8).Node, 4096).init(hyperia.allocator);
defer pool.deinit(hyperia.allocator);
const reactor = try Reactor.init(os.EPOLL_CLOEXEC);
defer reactor.deinit();
var reactor_event = try Reactor.AutoResetEvent.init(os.EFD_CLOEXEC, reactor);
defer reactor_event.deinit();
try reactor.add(reactor_event.fd, &reactor_event.handle, .{});
var frame = async runApp(reactor, &reactor_event);
while (!@atomicLoad(bool, &stopped, .Acquire)) {
const EventProcessor = struct {
batch: zap.Pool.Batch = .{},
pub fn call(self: *@This(), event: Reactor.Event) void {
const handle = @intToPtr(*Reactor.Handle, event.data);
handle.call(&self.batch, event);
}
};
var processor: EventProcessor = .{};
defer hyperia.pool.schedule(.{}, processor.batch);
try reactor.poll(128, &processor, null);
}
try nosuspend await frame;
log.info("good bye!", .{});
} | example_http_server.zig |
const std = @import("std");
const layout = @import("layout.zig");
const mem = @import("mem.zig");
const pmem = @import("pmem.zig");
const vmem = @import("vmem.zig");
const scheduler = @import("scheduler.zig");
const thread = @import("thread.zig");
const x86 = @import("x86.zig");
const HashMap = std.HashMap;
const LinkedList = std.LinkedList;
const List = std.LinkedList;
const MailboxId = std.os.zen.MailboxId;
const Message = std.os.zen.Message;
const Thread = thread.Thread;
const ThreadQueue = thread.ThreadQueue;
// Structure representing a mailbox.
pub const Mailbox = struct {
messages: List(Message),
waiting_queue: LinkedList(void),
// TODO: simplify once #679 is resolved.
////
// Initialize a mailbox.
//
// Returns:
// An empty mailbox.
//
pub fn init() Mailbox {
return Mailbox {
.messages = List(Message).init(),
.waiting_queue = ThreadQueue.init(),
};
}
};
// Keep track of the registered ports.
var ports = HashMap(u16, *Mailbox, hash_u16, eql_u16).init(&mem.allocator);
fn hash_u16(x: u16) u32 { return x; }
fn eql_u16(a: u16, b: u16) bool { return a == b; }
////
// Get the port with the given ID, or create one if it doesn't exist.
//
// Arguments:
// id: The index of the port.
//
// Returns:
// Mailbox associated to the port.
//
pub fn getOrCreatePort(id: u16) *Mailbox {
// TODO: check that the ID is not reserved.
if (ports.get(id)) |entry| {
return entry.value;
}
const mailbox = mem.allocator.createOne(Mailbox) catch unreachable;
mailbox.* = Mailbox.init();
_ = ports.put(id, mailbox) catch unreachable;
return mailbox;
}
////
// Asynchronously send a message to a mailbox.
//
// Arguments:
// message: Pointer to the message to be sent.
//
pub fn send(message: *const Message) void {
// NOTE: We need a copy in kernel space, because we
// are potentially switching address spaces.
const message_copy = processOutgoingMessage(message.*); // FIXME: should this be volatile?
const mailbox = getMailbox(message.receiver);
if (mailbox.waiting_queue.popFirst()) |first| {
// There's a thread waiting to receive, wake it up.
const receiving_thread = @fieldParentPtr(Thread, "queue_link", first);
scheduler.new(receiving_thread);
// Deliver the message into the receiver's address space.
deliverMessage(message_copy);
} else {
// No thread is waiting to receive, put the message in the queue.
const node = mailbox.messages.createNode(message_copy, &mem.allocator) catch unreachable;
mailbox.messages.append(node);
}
}
////
// Receive a message from a mailbox.
// Block if there are no messages.
//
// Arguments:
// destination: Address where to deliver the message.
//
pub fn receive(destination: *Message) void {
// TODO: validation, i.e. check if the thread has the right permissions.
const mailbox = getMailbox(destination.receiver);
// Specify where the thread wants to get the message delivered.
const receiving_thread = scheduler.current().?;
receiving_thread.message_destination = destination;
if (mailbox.messages.popFirst()) |first| {
// There's a message in the queue, deliver immediately.
const message = first.data;
deliverMessage(message);
mem.allocator.destroy(first);
} else {
// No message in the queue, block the thread.
scheduler.remove(receiving_thread);
mailbox.waiting_queue.append(&receiving_thread.queue_link);
}
}
////
// Get the mailbox associated with the given mailbox ID.
//
// Arguments:
// mailbox_id: The ID of the mailbox.
//
// Returns:
// The address of the mailbox.
//
fn getMailbox(mailbox_id: MailboxId) *Mailbox {
return switch (mailbox_id) {
MailboxId.This => &(scheduler.current().?).mailbox,
MailboxId.Thread => |tid| &(thread.get(tid).?).mailbox,
MailboxId.Port => |id| getOrCreatePort(id),
else => unreachable,
};
}
////
// Process the outgoing message. Return a copy of the message with
// an explicit sender field and the physical address of a copy of
// the message's payload (if specified).
//
// Arguments:
// message: The original message.
//
// Returns:
// A copy of the message, post processing.
//
fn processOutgoingMessage(message: Message) Message {
var message_copy = message;
switch (message.sender) {
MailboxId.This => message_copy.sender = MailboxId { .Thread = (scheduler.current().?).tid },
// MailboxId.Port => TODO: ensure the sender owns the port.
// MailboxId.Kernel => TODO: ensure the sender is really the kernel.
else => {},
}
// Copy the message's payload into a kernel buffer.
if (message.payload) |payload| {
// Allocate space for a copy of the payload and map it somewhere.
const physical_buffer = pmem.allocate();
vmem.map(layout.TMP, physical_buffer, vmem.PAGE_WRITE);
const tmp_buffer = @intToPtr([*]u8, layout.TMP)[0..x86.PAGE_SIZE];
// Copy the sender's payload into the newly allocated space.
std.mem.copy(u8, tmp_buffer, payload);
// Substitute the original pointer with the new physical one.
// When the receiving thread is ready, it will be mapped
// somewhere in its address space and this field will hold
// the final virtual address.
message_copy.payload = @intToPtr([*]u8, physical_buffer)[0..payload.len];
}
return message_copy;
}
////
// Deliver a message to the current thread.
//
// Arguments:
// message: The message to be delivered.
//
fn deliverMessage(message: Message) void {
const receiver_thread = scheduler.current().?;
const destination = receiver_thread.message_destination;
// Copy the message structure.
destination.* = message;
// Map the message's payload into the thread's address space.
if (message.payload) |payload| {
// TODO: leave empty pages in between destination buffers.
const destination_buffer = layout.USER_MESSAGES + (receiver_thread.local_tid * x86.PAGE_SIZE);
// Deallocate the physical memory used for the previous payload.
if (vmem.virtualToPhysical(destination_buffer)) |old_physical| {
pmem.free(old_physical);
}
// Map the current message's payload.
vmem.map(destination_buffer, @ptrToInt(payload.ptr), vmem.PAGE_WRITE | vmem.PAGE_USER);
// Update the payload field in the delivered message.
destination.payload = @intToPtr([*]u8, destination_buffer)[0..payload.len];
}
} | kernel/ipc.zig |
const std = @import("std");
pub fn Vec(comptime T: type, comptime size: u32) type {
if (@typeInfo(T) != .Float and @typeInfo(T) != .Int) {
@compileError("Unsupported Vec element type " ++ @typeName(T));
}
return struct {
data: [size]T = [_]T{0} ** size,
const Self = @This();
pub inline fn x(self: *const Self) T {
return self.data[0];
}
pub inline fn y(self: *const Self) T {
return self.data[1];
}
pub inline fn z(self: *const Self) T {
return self.data[2];
}
pub inline fn w(self: *const Self) T {
return self.data[3];
}
pub fn fromSlice(slice: []const T) Self {
var res = Self{};
for (slice) |v, i| {
res.data[i] = v;
}
return res;
}
pub fn zero(self: *Self) *Self {
return self.setN(0);
}
pub fn one(self: *Self) *Self {
return self.setN(1);
}
pub fn set(self: *Self, a: *const Self) *Self {
var i: usize = 0;
while (i < size) : (i += 1) {
self.data[i] = a.data[i];
}
return self;
}
pub fn setN(self: *Self, n: T) *Self {
var i: usize = 0;
while (i < size) : (i += 1) {
self.data[i] = n;
}
return self;
}
pub fn swizzle2(self: *const Self, a: u32, b: u32) Vec(T, 2) {
return Vec(T, 2){
.data = [_]T{ self.data[a], self.data[b] },
};
}
pub fn swizzle3(self: *const Self, a: u32, b: u32, c: u32) Vec(T, 3) {
return Vec(T, 3){
.data = [_]T{
self.data[a],
self.data[b],
self.data[c],
},
};
}
pub fn swizzle4(self: *const Self, a: u32, b: u32, c: u32, d: u32) Vec(T, 4) {
return Vec(T, 4){
.data = [_]T{
self.data[a],
self.data[b],
self.data[c],
self.data[d],
},
};
}
pub fn copy(self: *const Self) Self {
return Self{
.data = self.data,
};
}
pub fn eq(self: *const Self, a: *const Self) bool {
var i: usize = 0;
while (i < size) : (i += 1) {
if (self.data[i] != a.data[i]) return false;
}
return true;
}
pub fn eqDelta(self: *const Self, a: *const Self, eps: T) bool {
var i: usize = 0;
while (i < size) : (i += 1) {
const v = self.data[i] - a.data[i];
if (v < eps or v > eps) return false;
}
return true;
}
pub fn add(self: *Self, a: *const Self) *Self {
var i: usize = 0;
while (i < size) : (i += 1) {
self.data[i] += a.data[i];
}
return self;
}
pub fn addN(self: *Self, n: T) *Self {
var i: usize = 0;
while (i < size) : (i += 1) {
self.data[i] += n;
}
return self;
}
pub fn sub(self: *Self, a: *const Self) *Self {
var i: usize = 0;
while (i < size) : (i += 1) {
self.data[i] -= a.data[i];
}
return self;
}
pub fn subN(self: *Self, n: T) *Self {
var i: usize = 0;
while (i < size) : (i += 1) {
self.data[i] -= n;
}
return self;
}
pub fn mul(self: *Self, a: *const Self) *Self {
var i: usize = 0;
while (i < size) : (i += 1) {
self.data[i] *= a.data[i];
}
return self;
}
pub fn mulN(self: *Self, n: T) *Self {
var i: usize = 0;
while (i < size) : (i += 1) {
self.data[i] *= n;
}
return self;
}
pub fn div(self: *Self, a: *const Self) *Self {
var i: usize = 0;
while (i < size) : (i += 1) {
self.data[i] /= a.data[i];
}
return self;
}
pub fn divN(self: *Self, n: T) *Self {
var i: usize = 0;
while (i < size) : (i += 1) {
self.data[i] /= n;
}
return self;
}
pub fn madd(self: *Self, a: *const Self, b: *const Self) *Self {
var i: usize = 0;
while (i < size) : (i += 1) {
self.data[i] += a.data[i] * b[i];
}
return self;
}
pub fn maddN(self: *Self, a: *const Self, n: T) *Self {
var i: usize = 0;
while (i < size) : (i += 1) {
self.data[i] = std.math.fma(T, a.data[i], n, self.data[i]);
}
return self;
}
pub fn mix(self: *Self, a: *const Self, t: *const Self) *Self {
var i: usize = 0;
while (i < size) : (i += 1) {
// self.data[i] += (a.data[i] - self.data[i]) * t.data[i];
self.data[i] = std.math.fma(a.data[i] - self.data[i], t.data[i], self.data[i]);
}
return self;
}
pub fn mixN(self: *Self, a: *const Self, t: T) *Self {
var i: usize = 0;
while (i < size) : (i += 1) {
// self.data[i] += (a.data[i] - self.data[i]) * t;
self.data[i] = std.math.fma(a.data[i] - self.data[i], t, self.data[i]);
}
return self;
}
pub fn dot(self: *const Self, a: *const Self) T {
var i: usize = 0;
var res: T = 0;
while (i < size) : (i += 1) {
res += self.data[i] * a.data[i];
}
return res;
}
pub fn magSq(self: *const Self) T {
return self.dot(self);
}
pub fn mag(self: *const Self) T {
return @sqrt(self.dot(self));
}
pub fn normalize(self: *Self) *Self {
return self.normalizeN(1);
}
pub fn normalizeN(self: *Self, n: T) *Self {
var m: T = self.dot(self);
if (m > 1e-12) {
_ = self.mulN(n / @sqrt(m));
}
return self;
}
pub fn limit(self: *Self, n: T) *Self {
var m: T = self.dot(self);
if (m > n * n) {
_ = self.mulN(n / @sqrt(m));
}
return self;
}
pub fn vsum(self: *const Self) T {
var sum: T = 0;
for (self.data) |v| {
sum += v;
}
return sum;
}
pub fn abs(self: *Self) *Self {
var i: usize = 0;
while (i < size) : (i += 1) {
if (@typeInfo(T) == .Float) {
self.data[i] = @fabs(self.data[i]);
} else {
if (self.data[i] < 0) self.data[i] *= -1;
}
}
return self;
}
pub fn neg(self: *Self) *Self {
return self.mulN(-1);
}
pub fn min(self: *Self, a: *const Self) *Self {
var i: usize = 0;
while (i < size) : (i += 1) {
self.data[i] = @minimum(self.data[i], a.data[i]);
}
return self;
}
pub fn max(self: *Self, a: *const Self) *Self {
var i: usize = 0;
while (i < size) : (i += 1) {
self.data[i] = @maximum(self.data[i], a.data[i]);
}
return self;
}
pub fn minId(self: *const Self) u32 {
var id: u32 = 0;
var acc: T = self.data[0];
var i: usize = 1;
while (i < size) : (i += 1) {
if (self.data[i] < acc) {
id = i;
acc = self.data[i];
}
}
return id;
}
pub fn maxId(self: *const Self) u32 {
var id: u32 = 0;
var acc: T = self.data[0];
var i: usize = 1;
while (i < size) : (i += 1) {
if (self.data[i] > acc) {
id = i;
acc = self.data[i];
}
}
return id;
}
pub fn clamp(self: *Self, a: *const Self, b: *const Self) *Self {
var i: usize = 0;
while (i < size) : (i += 1) {
if (self.data[i] < a.data[i]) {
self.data[i] = a.data[i];
} else if (self.data[i] > b.data[i]) {
self.data[i] = b.data[i];
}
}
return self;
}
pub fn clamp01(self: *Self) *Self {
var i: usize = 0;
while (i < size) : (i += 1) {
if (self.data[i] < 0) {
self.data[i] = 0;
} else if (self.data[i] > 1) {
self.data[i] = 1;
}
}
return self;
}
pub fn fit(self: *Self, a: *const Self, b: *const Self, c: *const Self, d: *const Self) *Self {
var i: usize = 0;
while (i < size) : (i += 1) {
const aa = a.data[i];
const bb = b.data[i];
const cc = c.data[i];
const dd = d.data[i];
var norm: T = if (bb != aa) 1 / (bb - aa) else 0;
self.data[i] = cc + (dd - cc) * (self.data[i] - aa) * norm;
}
}
pub fn fitClamped(self: *Self, a: *const Self, b: *const Self, c: *const Self, d: *const Self) *Self {
return self.clamp(a, b).fit(a, b, c, d);
}
pub fn fit01(self: *Self, a: *const Self, b: *const Self) *Self {
var i: usize = 0;
while (i < size) : (i += 1) {
self.data[i] = a.data[i] + (b.data[i] - a.data[i]) * self.data[i];
}
return self;
}
pub fn floor(self: *Self) *Self {
var i: usize = 0;
while (i < size) : (i += 1) {
self.data[i] = @floor(self.data[i]);
}
return self;
}
pub fn ceil(self: *Self) *Self {
var i: usize = 0;
while (i < size) : (i += 1) {
self.data[i] = @ceil(self.data[i]);
}
return self;
}
pub fn round(self: *Self) *Self {
var i: usize = 0;
while (i < size) : (i += 1) {
self.data[i] = @round(self.data[i]);
}
return self;
}
pub fn roundTo(self: *Self, n: T) *Self {
var i: usize = 0;
while (i < size) : (i += 1) {
self.data[i] = @round(self.data[i] / n) * n;
}
return self;
}
pub fn step(self: *Self, a: *const Self) *Self {
var i: usize = 0;
while (i < size) : (i += 1) {
self.data[i] = if (self.data[i] >= a.data[i]) 1 else 0;
}
return self;
}
pub fn smoothStep(self: *Self, a: *const Self, b: *const Self) *Self {
var i: usize = 0;
while (i < size) : (i += 1) {
var v: T = (self.data[i] - a.data[i]) / (b.data[i] - a.data[i]);
v = if (v < 0) 0 else if (v > 1) 1 else v;
self.data[i] = (3 - 2 * v) * v * v;
}
return self;
}
pub fn exp(self: *Self) *Self {
var i: usize = 0;
while (i < size) : (i += 1) {
self.data[i] = @exp(self.data[i]);
}
return self;
}
pub fn exp2(self: *Self) *Self {
var i: usize = 0;
while (i < size) : (i += 1) {
self.data[i] = @exp2(self.data[i]);
}
return self;
}
pub fn log(self: *Self) *Self {
var i: usize = 0;
while (i < size) : (i += 1) {
self.data[i] = @log(self.data[i]);
}
return self;
}
pub fn log2(self: *Self) *Self {
var i: usize = 0;
while (i < size) : (i += 1) {
self.data[i] = @log2(self.data[i]);
}
return self;
}
pub fn log10(self: *Self) *Self {
var i: usize = 0;
while (i < size) : (i += 1) {
self.data[i] = @log10(self.data[i]);
}
return self;
}
pub fn sqrt(self: *Self) *Self {
var i: usize = 0;
while (i < size) : (i += 1) {
self.data[i] = @sqrt(self.data[i]);
}
return self;
}
pub fn invSqrt(self: *Self) *Self {
var i: usize = 0;
while (i < size) : (i += 1) {
self.data[i] = 1 / @sqrt(self.data[i]);
}
return self;
}
pub fn sin(self: *Self) *Self {
var i: usize = 0;
while (i < size) : (i += 1) {
self.data[i] = @sin(self.data[i]);
}
return self;
}
pub fn cos(self: *Self) *Self {
var i: usize = 0;
while (i < size) : (i += 1) {
self.data[i] = @cos(self.data[i]);
}
return self;
}
pub fn isZero(self: *const Self) bool {
var i: usize = 0;
while (i < size) : (i += 1) {
if (self.data[i] != 0) return false;
}
return true;
}
pub fn any(self: *const Self) bool {
return !self.isZero();
}
pub fn every(self: *const Self) bool {
var i: usize = 0;
while (i < size) : (i += 1) {
if (self.data[i] == 0) return false;
}
return true;
}
};
}
const Vec2f = Vec(f32, 2);
const Vec3f = Vec(f32, 3);
const Vec4f = Vec(f32, 4);
const Vec3i = Vec(i32, 3);
fn vec3(x: f32, y: f32, z: f32) Vec3f {
return Vec3f{ .data = [_]f32{ x, y, z } };
}
export fn add3(a: *Vec3f, b: *Vec3f, c: *Vec3f) *Vec3f {
c.* = a.copy().add(b).*;
return c;
}
export fn add4(a: *Vec4f, b: *Vec4f, c: *Vec4f) *Vec4f {
c.* = a.copy().add(b).*;
return c;
}
export fn normalize3(a: *Vec3f, b: *Vec3f) *Vec3f {
b.* = a.copy().normalize().*;
return b;
}
export fn zero4(a: *Vec4f, b: *Vec4f) *Vec4f {
b.* = a.copy().zero().*;
return b;
}
export fn exp3(a: *Vec3f) *Vec3f {
a.* = a.copy().exp().*;
return a;
}
export fn testAdd(c: *Vec3f) *Vec3f {
const a = vec3(1, 2, 3);
var b = Vec3f{};
_ = b.zero();
c.* = a.copy().add(&b).*;
return c;
}
export fn testSwizzle(c: *Vec4f) *Vec4f {
var a = vec3(1, 2, 3);
a.data[0] = a.dot(&a);
c.* = a.swizzle4(2, 2, 1, 0);
return c;
}
pub fn main() void {
var a = Vec3f{ .data = [_]f32{ 1, 2, 3 } };
const b = a.copy();
const c = a.add(&b);
std.debug.print("a: {}\n", .{a});
std.debug.print("b: {}\n", .{b});
std.debug.print("c: {} {}\n", .{ c, &c });
std.debug.print("a: {}\n", .{a});
_ = a.add(c);
std.debug.print("a: {}\n", .{a});
} | src/vec.zig |
const std = @import("std");
const tests = @import("tests.zig");
const nl = std.cstr.line_sep;
pub fn addCases(cases: *tests.RunTranslatedCContext) void {
cases.add("division of floating literals",
\\#define _NO_CRT_STDIO_INLINE 1
\\#include <stdio.h>
\\#define PI 3.14159265358979323846f
\\#define DEG2RAD (PI/180.0f)
\\int main(void) {
\\ printf("DEG2RAD is: %f\n", DEG2RAD);
\\ return 0;
\\}
, "DEG2RAD is: 0.017453" ++ nl);
cases.add("use global scope for record/enum/typedef type transalation if needed",
\\void bar(void);
\\void baz(void);
\\struct foo { int x; };
\\void bar() {
\\ struct foo tmp;
\\}
\\
\\void baz() {
\\ struct foo tmp;
\\}
\\
\\int main(void) {
\\ bar();
\\ baz();
\\ return 0;
\\}
, "");
cases.add("failed macros are only declared once",
\\#define FOO =
\\#define FOO =
\\#define PtrToPtr64(p) ((void *POINTER_64) p)
\\#define STRUC_ALIGNED_STACK_COPY(t,s) ((CONST t *)(s))
\\#define bar = 0x
\\#define baz = 0b
\\int main(void) {}
, "");
cases.add("parenthesized string literal",
\\void foo(const char *s) {}
\\int main(void) {
\\ foo(("bar"));
\\}
, "");
cases.add("variable shadowing type type",
\\#include <stdlib.h>
\\int main() {
\\ int type = 1;
\\ if (type != 1) abort();
\\}
, "");
cases.add("assignment as expression",
\\#include <stdlib.h>
\\int main() {
\\ int a, b, c, d = 5;
\\ int e = a = b = c = d;
\\ if (e != 5) abort();
\\}
, "");
cases.add("static variable in block scope",
\\#include <stdlib.h>
\\int foo() {
\\ static int bar;
\\ bar += 1;
\\ return bar;
\\}
\\int main() {
\\ foo();
\\ foo();
\\ if (foo() != 3) abort();
\\}
, "");
cases.add("array initializer",
\\#include <stdlib.h>
\\int main(int argc, char **argv) {
\\ int a0[4] = {1};
\\ int a1[4] = {1,2,3,4};
\\ int s0 = 0, s1 = 0;
\\ for (int i = 0; i < 4; i++) {
\\ s0 += a0[i];
\\ s1 += a1[i];
\\ }
\\ if (s0 != 1) abort();
\\ if (s1 != 10) abort();
\\}
, "");
cases.add("forward declarations",
\\#include <stdlib.h>
\\int foo(int);
\\int foo(int x) { return x + 1; }
\\int main(int argc, char **argv) {
\\ if (foo(2) != 3) abort();
\\ return 0;
\\}
, "");
cases.add("typedef and function pointer",
\\#include <stdlib.h>
\\typedef struct _Foo Foo;
\\typedef int Ret;
\\typedef int Param;
\\struct _Foo { Ret (*func)(Param p); };
\\static Ret add1(Param p) {
\\ return p + 1;
\\}
\\int main(int argc, char **argv) {
\\ Foo strct = { .func = add1 };
\\ if (strct.func(16) != 17) abort();
\\ return 0;
\\}
, "");
cases.add("ternary operator",
\\#include <stdlib.h>
\\static int cnt = 0;
\\int foo() { cnt++; return 42; }
\\int main(int argc, char **argv) {
\\ short q = 3;
\\ signed char z0 = q?:1;
\\ if (z0 != 3) abort();
\\ int z1 = 3?:1;
\\ if (z1 != 3) abort();
\\ int z2 = foo()?:-1;
\\ if (z2 != 42) abort();
\\ if (cnt != 1) abort();
\\ return 0;
\\}
, "");
cases.add("switch case",
\\#include <stdlib.h>
\\int lottery(unsigned int x) {
\\ switch (x) {
\\ case 3: return 0;
\\ case -1: return 3;
\\ case 8 ... 10: return x;
\\ default: return -1;
\\ }
\\}
\\int main(int argc, char **argv) {
\\ if (lottery(2) != -1) abort();
\\ if (lottery(3) != 0) abort();
\\ if (lottery(-1) != 3) abort();
\\ if (lottery(9) != 9) abort();
\\ return 0;
\\}
, "");
cases.add("boolean values and expressions",
\\#include <stdlib.h>
\\static const _Bool false_val = 0;
\\static const _Bool true_val = 1;
\\void foo(int x, int y) {
\\ _Bool r = x < y;
\\ if (!r) abort();
\\ _Bool self = foo;
\\ if (self == false_val) abort();
\\ if (((r) ? 'a' : 'b') != 'a') abort();
\\}
\\int main(int argc, char **argv) {
\\ foo(2, 5);
\\ if (false_val == true_val) abort();
\\ return 0;
\\}
, "");
cases.add("hello world",
\\#define _NO_CRT_STDIO_INLINE 1
\\#include <stdio.h>
\\int main(int argc, char **argv) {
\\ printf("hello, world!\n");
\\ return 0;
\\}
, "hello, world!" ++ nl);
cases.add("anon struct init",
\\#include <stdlib.h>
\\struct {int a; int b;} x = {1, 2};
\\int main(int argc, char **argv) {
\\ x.a += 2;
\\ x.b += 1;
\\ if (x.a != 3) abort();
\\ if (x.b != 3) abort();
\\ return 0;
\\}
, "");
cases.add("casting away const and volatile",
\\void foo(int *a) {}
\\void bar(const int *a) {
\\ foo((int *)a);
\\}
\\void baz(volatile int *a) {
\\ foo((int *)a);
\\}
\\int main(int argc, char **argv) {
\\ int a = 0;
\\ bar((const int *)&a);
\\ baz((volatile int *)&a);
\\ return 0;
\\}
, "");
cases.add("anonymous struct & unions",
\\#include <stdlib.h>
\\#include <stdint.h>
\\static struct { struct { uint16_t x, y; }; } x = { 1 };
\\static struct { union { uint32_t x; uint8_t y; }; } y = { 0x55AA55AA };
\\int main(int argc, char **argv) {
\\ if (x.x != 1) abort();
\\ if (x.y != 0) abort();
\\ if (y.x != 0x55AA55AA) abort();
\\ if (y.y != 0xAA) abort();
\\ return 0;
\\}
, "");
cases.add("array to pointer decay",
\\#include <stdlib.h>
\\int main(int argc, char **argv) {
\\ char data[3] = {'a','b','c'};
\\ if (2[data] != data[2]) abort();
\\ if ("abc"[1] != data[1]) abort();
\\ char *as_ptr = data;
\\ if (2[as_ptr] != as_ptr[2]) abort();
\\ if ("abc"[1] != as_ptr[1]) abort();
\\ return 0;
\\}
, "");
cases.add("struct initializer - packed",
\\#define _NO_CRT_STDIO_INLINE 1
\\#include <stdint.h>
\\#include <stdlib.h>
\\struct s {uint8_t x,y;
\\ uint32_t z;} __attribute__((packed)) s0 = {1, 2};
\\int main() {
\\ /* sizeof nor offsetof currently supported */
\\ if (((intptr_t)&s0.z - (intptr_t)&s0.x) != 2) abort();
\\ return 0;
\\}
, "");
cases.add("cast signed array index to unsigned",
\\#include <stdlib.h>
\\int main(int argc, char **argv) {
\\ int a[10], i = 0;
\\ a[i] = 0;
\\ if (a[i] != 0) abort();
\\ return 0;
\\}
, "");
cases.add("cast long long array index to unsigned",
\\#include <stdlib.h>
\\int main(int argc, char **argv) {
\\ long long a[10], i = 0;
\\ a[i] = 0;
\\ if (a[i] != 0) abort();
\\ return 0;
\\}
, "");
cases.add("case boolean expression converted to int",
\\#include <stdlib.h>
\\int main(int argc, char **argv) {
\\ int value = 1 + 2 * 3 + 4 * 5 + 6 << 7 | 8 == 9;
\\ if (value != 4224) abort();
\\ return 0;
\\}
, "");
cases.add("case boolean expression on left converted to int",
\\#include <stdlib.h>
\\int main(int argc, char **argv) {
\\ int value = 8 == 9 | 1 + 2 * 3 + 4 * 5 + 6 << 7;
\\ if (value != 4224) abort();
\\ return 0;
\\}
, "");
cases.add("case boolean and operator+ converts bool to int",
\\#include <stdlib.h>
\\int main(int argc, char **argv) {
\\ int value = (8 == 9) + 3;
\\ int value2 = 3 + (8 == 9);
\\ if (value != value2) abort();
\\ return 0;
\\}
, "");
cases.add("case boolean and operator<",
\\#include <stdlib.h>
\\int main(int argc, char **argv) {
\\ int value = (8 == 9) < 3;
\\ if (value == 0) abort();
\\ return 0;
\\}
, "");
cases.add("case boolean and operator*",
\\#include <stdlib.h>
\\int main(int argc, char **argv) {
\\ int value = (8 == 9) * 3;
\\ int value2 = 3 * (9 == 9);
\\ if (value != 0) abort();
\\ if (value2 == 0) abort();
\\ return 0;
\\}
, "");
cases.add("scoped typedef",
\\int main(int argc, char **argv) {
\\ typedef int Foo;
\\ typedef Foo Bar;
\\ typedef void (*func)(int);
\\ typedef int uint32_t;
\\ uint32_t a;
\\ Foo i;
\\ Bar j;
\\ return 0;
\\}
, "");
cases.add("scoped for loops with shadowing",
\\#include <stdlib.h>
\\int main() {
\\ int count = 0;
\\ for (int x = 0; x < 2; x++)
\\ for (int x = 0; x < 2; x++)
\\ count++;
\\
\\ if (count != 4) abort();
\\ return 0;
\\}
, "");
cases.add("array value type casts properly",
\\#include <stdlib.h>
\\unsigned int choose[53][10];
\\static int hash_binary(int k)
\\{
\\ choose[0][k] = 3;
\\ int sum = 0;
\\ sum += choose[0][k];
\\ return sum;
\\}
\\
\\int main() {
\\ int s = hash_binary(4);
\\ if (s != 3) abort();
\\ return 0;
\\}
, "");
cases.add("array value type casts properly use +=",
\\#include <stdlib.h>
\\static int hash_binary(int k)
\\{
\\ unsigned int choose[1][1] = {{3}};
\\ int sum = -1;
\\ int prev = 0;
\\ prev = sum += choose[0][0];
\\ if (sum != 2) abort();
\\ return sum + prev;
\\}
\\
\\int main() {
\\ int x = hash_binary(4);
\\ if (x != 4) abort();
\\ return 0;
\\}
, "");
cases.add("ensure array casts outisde +=",
\\#include <stdlib.h>
\\static int hash_binary(int k)
\\{
\\ unsigned int choose[3] = {1, 2, 3};
\\ int sum = -2;
\\ int prev = sum + choose[k];
\\ if (prev != 0) abort();
\\ return sum + prev;
\\}
\\
\\int main() {
\\ int x = hash_binary(1);
\\ if (x != -2) abort();
\\ return 0;
\\}
, "");
cases.add("array cast int to uint",
\\#include <stdlib.h>
\\static unsigned int hash_binary(int k)
\\{
\\ int choose[3] = {-1, -2, 3};
\\ unsigned int sum = 2;
\\ sum += choose[k];
\\ return sum;
\\}
\\
\\int main() {
\\ unsigned int x = hash_binary(1);
\\ if (x != 0) abort();
\\ return 0;
\\}
, "");
cases.add("assign enum to uint, no explicit cast",
\\#include <stdlib.h>
\\typedef enum {
\\ ENUM_0 = 0,
\\ ENUM_1 = 1,
\\} my_enum_t;
\\
\\int main() {
\\ my_enum_t val = ENUM_1;
\\ unsigned int x = val;
\\ if (x != 1) abort();
\\ return 0;
\\}
, "");
cases.add("assign enum to int",
\\#include <stdlib.h>
\\typedef enum {
\\ ENUM_0 = 0,
\\ ENUM_1 = 1,
\\} my_enum_t;
\\
\\int main() {
\\ my_enum_t val = ENUM_1;
\\ int x = val;
\\ if (x != 1) abort();
\\ return 0;
\\}
, "");
cases.add("cast enum to smaller uint",
\\#include <stdlib.h>
\\#include <stdint.h>
\\typedef enum {
\\ ENUM_0 = 0,
\\ ENUM_257 = 257,
\\} my_enum_t;
\\
\\int main() {
\\ my_enum_t val = ENUM_257;
\\ uint8_t x = (uint8_t)val;
\\ if (x != (uint8_t)257) abort();
\\ return 0;
\\}
, "");
cases.add("cast enum to smaller signed int",
\\#include <stdlib.h>
\\#include <stdint.h>
\\typedef enum {
\\ ENUM_0 = 0,
\\ ENUM_384 = 384,
\\} my_enum_t;
\\
\\int main() {
\\ my_enum_t val = ENUM_384;
\\ int8_t x = (int8_t)val;
\\ if (x != (int8_t)384) abort();
\\ return 0;
\\}
, "");
cases.add("cast negative enum to smaller signed int",
\\#include <stdlib.h>
\\#include <stdint.h>
\\typedef enum {
\\ ENUM_MINUS_1 = -1,
\\ ENUM_384 = 384,
\\} my_enum_t;
\\
\\int main() {
\\ my_enum_t val = ENUM_MINUS_1;
\\ int8_t x = (int8_t)val;
\\ if (x != -1) abort();
\\ return 0;
\\}
, "");
cases.add("cast negative enum to smaller unsigned int",
\\#include <stdlib.h>
\\#include <stdint.h>
\\typedef enum {
\\ ENUM_MINUS_1 = -1,
\\ ENUM_384 = 384,
\\} my_enum_t;
\\
\\int main() {
\\ my_enum_t val = ENUM_MINUS_1;
\\ uint8_t x = (uint8_t)val;
\\ if (x != (uint8_t)-1) abort();
\\ return 0;
\\}
, "");
cases.add("implicit enum cast in boolean expression",
\\#include <stdlib.h>
\\enum Foo {
\\ FooA,
\\ FooB,
\\ FooC,
\\};
\\int main() {
\\ int a = 0;
\\ float b = 0;
\\ void *c = 0;
\\ enum Foo d = FooA;
\\ if (a || d) abort();
\\ if (d && b) abort();
\\ if (c || d) abort();
\\ return 0;
\\}
, "");
cases.add("issue #6707 cast builtin call result to opaque struct pointer",
\\#include <stdlib.h>
\\struct foo* make_foo(void)
\\{
\\ return (struct foo*)__builtin_strlen("0123456789ABCDEF");
\\}
\\int main(void) {
\\ struct foo *foo_pointer = make_foo();
\\ if (foo_pointer != (struct foo*)16) abort();
\\ return 0;
\\}
, "");
cases.add("C built-ins",
\\#include <stdlib.h>
\\#include <limits.h>
\\#include <stdbool.h>
\\#define M_E 2.71828182845904523536
\\#define M_PI_2 1.57079632679489661923
\\bool check_clz(unsigned int pos) {
\\ return (__builtin_clz(1 << pos) == (8 * sizeof(unsigned int) - pos - 1));
\\}
\\int main(void) {
\\ if (__builtin_bswap16(0x0102) != 0x0201) abort();
\\ if (__builtin_bswap32(0x01020304) != 0x04030201) abort();
\\ if (__builtin_bswap64(0x0102030405060708) != 0x0807060504030201) abort();
\\
\\ if (__builtin_signbit(0.0) != 0) abort();
\\ if (__builtin_signbitf(0.0f) != 0) abort();
\\ if (__builtin_signbit(1.0) != 0) abort();
\\ if (__builtin_signbitf(1.0f) != 0) abort();
\\ if (__builtin_signbit(-1.0) != 1) abort();
\\ if (__builtin_signbitf(-1.0f) != 1) abort();
\\
\\ if (__builtin_popcount(0) != 0) abort();
\\ if (__builtin_popcount(0b1) != 1) abort();
\\ if (__builtin_popcount(0b11) != 2) abort();
\\ if (__builtin_popcount(0b1111) != 4) abort();
\\ if (__builtin_popcount(0b11111111) != 8) abort();
\\
\\ if (__builtin_ctz(0b1) != 0) abort();
\\ if (__builtin_ctz(0b10) != 1) abort();
\\ if (__builtin_ctz(0b100) != 2) abort();
\\ if (__builtin_ctz(0b10000) != 4) abort();
\\ if (__builtin_ctz(0b100000000) != 8) abort();
\\
\\ if (!check_clz(0)) abort();
\\ if (!check_clz(1)) abort();
\\ if (!check_clz(2)) abort();
\\ if (!check_clz(4)) abort();
\\ if (!check_clz(8)) abort();
\\
\\ if (__builtin_sqrt(__builtin_sqrt(__builtin_sqrt(256))) != 2.0) abort();
\\ if (__builtin_sqrt(__builtin_sqrt(__builtin_sqrt(256.0))) != 2.0) abort();
\\ if (__builtin_sqrt(__builtin_sqrt(__builtin_sqrt(256.0f))) != 2.0) abort();
\\ if (__builtin_sqrtf(__builtin_sqrtf(__builtin_sqrtf(256.0f))) != 2.0f) abort();
\\
\\ if (__builtin_sin(1.0) != -__builtin_sin(-1.0)) abort();
\\ if (__builtin_sinf(1.0f) != -__builtin_sinf(-1.0f)) abort();
\\ if (__builtin_sin(M_PI_2) != 1.0) abort();
\\ if (__builtin_sinf(M_PI_2) != 1.0f) abort();
\\
\\ if (__builtin_cos(1.0) != __builtin_cos(-1.0)) abort();
\\ if (__builtin_cosf(1.0f) != __builtin_cosf(-1.0f)) abort();
\\ if (__builtin_cos(0.0) != 1.0) abort();
\\ if (__builtin_cosf(0.0f) != 1.0f) abort();
\\
\\ if (__builtin_exp(0) != 1.0) abort();
\\ if (__builtin_fabs(__builtin_exp(1.0) - M_E) > 0.00000001) abort();
\\ if (__builtin_exp(0.0f) != 1.0f) abort();
\\
\\ if (__builtin_exp2(0) != 1.0) abort();
\\ if (__builtin_exp2(4.0) != 16.0) abort();
\\ if (__builtin_exp2f(0.0f) != 1.0f) abort();
\\ if (__builtin_exp2f(4.0f) != 16.0f) abort();
\\
\\ if (__builtin_log(M_E) != 1.0) abort();
\\ if (__builtin_log(1.0) != 0.0) abort();
\\ if (__builtin_logf(1.0f) != 0.0f) abort();
\\
\\ if (__builtin_log2(8.0) != 3.0) abort();
\\ if (__builtin_log2(1.0) != 0.0) abort();
\\ if (__builtin_log2f(8.0f) != 3.0f) abort();
\\ if (__builtin_log2f(1.0f) != 0.0f) abort();
\\
\\ if (__builtin_log10(1000.0) != 3.0) abort();
\\ if (__builtin_log10(1.0) != 0.0) abort();
\\ if (__builtin_log10f(1000.0f) != 3.0f) abort();
\\ if (__builtin_log10f(1.0f) != 0.0f) abort();
\\
\\ if (__builtin_fabs(-42.0f) != 42.0) abort();
\\ if (__builtin_fabs(-42.0) != 42.0) abort();
\\ if (__builtin_fabs(-42) != 42.0) abort();
\\ if (__builtin_fabsf(-42.0f) != 42.0f) abort();
\\
\\ if (__builtin_fabs(-42.0f) != 42.0) abort();
\\ if (__builtin_fabs(-42.0) != 42.0) abort();
\\ if (__builtin_fabs(-42) != 42.0) abort();
\\ if (__builtin_fabsf(-42.0f) != 42.0f) abort();
\\
\\ if (__builtin_abs(42) != 42) abort();
\\ if (__builtin_abs(-42) != 42) abort();
\\ if (__builtin_abs(INT_MIN) != INT_MIN) abort();
\\
\\ if (__builtin_floor(42.9) != 42.0) abort();
\\ if (__builtin_floor(-42.9) != -43.0) abort();
\\ if (__builtin_floorf(42.9f) != 42.0f) abort();
\\ if (__builtin_floorf(-42.9f) != -43.0f) abort();
\\
\\ if (__builtin_ceil(42.9) != 43.0) abort();
\\ if (__builtin_ceil(-42.9) != -42) abort();
\\ if (__builtin_ceilf(42.9f) != 43.0f) abort();
\\ if (__builtin_ceilf(-42.9f) != -42.0f) abort();
\\
\\ if (__builtin_trunc(42.9) != 42.0) abort();
\\ if (__builtin_truncf(42.9f) != 42.0f) abort();
\\ if (__builtin_trunc(-42.9) != -42.0) abort();
\\ if (__builtin_truncf(-42.9f) != -42.0f) abort();
\\
\\ if (__builtin_round(0.5) != 1.0) abort();
\\ if (__builtin_round(-0.5) != -1.0) abort();
\\ if (__builtin_roundf(0.5f) != 1.0f) abort();
\\ if (__builtin_roundf(-0.5f) != -1.0f) abort();
\\
\\ if (__builtin_strcmp("abc", "abc") != 0) abort();
\\ if (__builtin_strcmp("abc", "def") >= 0 ) abort();
\\ if (__builtin_strcmp("def", "abc") <= 0) abort();
\\
\\ if (__builtin_strlen("this is a string") != 16) abort();
\\
\\ char *s = malloc(6);
\\ __builtin_memcpy(s, "hello", 5);
\\ s[5] = '\0';
\\ if (__builtin_strlen(s) != 5) abort();
\\
\\ __builtin_memset(s, 42, __builtin_strlen(s));
\\ if (s[0] != 42 || s[1] != 42 || s[2] != 42 || s[3] != 42 || s[4] != 42) abort();
\\
\\ free(s);
\\
\\ return 0;
\\}
, "");
cases.add("function macro that uses builtin",
\\#include <stdlib.h>
\\#define FOO(x, y) (__builtin_popcount((x)) + __builtin_strlen((y)))
\\int main() {
\\ if (FOO(7, "hello!") != 9) abort();
\\ return 0;
\\}
, "");
cases.add("assign bool result to int or char",
\\#include <stdlib.h>
\\#include <stdbool.h>
\\bool foo() { return true; }
\\int main() {
\\ int x = foo();
\\ if (x != 1) abort();
\\ signed char c = foo();
\\ if (c != 1) abort();
\\ return 0;
\\}
, "");
cases.add("static K&R-style no prototype function declaration (empty parameter list)",
\\#include <stdlib.h>
\\static int foo() {
\\ return 42;
\\}
\\int main() {
\\ if (foo() != 42) abort();
\\ return 0;
\\}
, "");
cases.add("K&R-style static function prototype for unused function",
\\static int foo();
\\int main() {
\\ return 0;
\\}
, "");
cases.add("K&R-style static function prototype + separate definition",
\\#include <stdlib.h>
\\static int foo();
\\static int foo(int a, int b) {
\\ return a + b;
\\}
\\int main() {
\\ if (foo(40, 2) != 42) abort();
\\ return 0;
\\}
, "");
cases.add("dollar sign in identifiers",
\\#include <stdlib.h>
\\#define $FOO 2
\\#define $foo bar$
\\#define $baz($x) ($x + $FOO)
\\int $$$(int $x$) { return $x$ + $FOO; }
\\int main() {
\\ int bar$ = 42;
\\ if ($foo != 42) abort();
\\ if (bar$ != 42) abort();
\\ if ($baz(bar$) != 44) abort();
\\ if ($$$(bar$) != 44) abort();
\\ return 0;
\\}
, "");
cases.add("Cast boolean expression result to int",
\\#include <stdlib.h>
\\char foo(char c) { return c; }
\\int bar(int i) { return i; }
\\long baz(long l) { return l; }
\\int main() {
\\ if (foo(1 == 2)) abort();
\\ if (!foo(1 == 1)) abort();
\\ if (bar(1 == 2)) abort();
\\ if (!bar(1 == 1)) abort();
\\ if (baz(1 == 2)) abort();
\\ if (!baz(1 == 1)) abort();
\\ return 0;
\\}
, "");
cases.add("Wide, UTF-16, and UTF-32 character literals",
\\#include <wchar.h>
\\#include <stdlib.h>
\\int main() {
\\ wchar_t wc = L'™';
\\ int utf16_char = u'™';
\\ int utf32_char = U'💯';
\\ if (wc != 8482) abort();
\\ if (utf16_char != 8482) abort();
\\ if (utf32_char != 128175) abort();
\\ unsigned char c = wc;
\\ if (c != 0x22) abort();
\\ c = utf32_char;
\\ if (c != 0xaf) abort();
\\ return 0;
\\}
, "");
cases.add("Variadic function call",
\\#define _NO_CRT_STDIO_INLINE 1
\\#include <stdio.h>
\\int main(void) {
\\ printf("%d %d\n", 1, 2);
\\ return 0;
\\}
, "1 2" ++ nl);
cases.add("multi-character character constant",
\\#include <stdlib.h>
\\int main(void) {
\\ int foo = 'abcd';
\\ switch (foo) {
\\ case 'abcd': break;
\\ default: abort();
\\ }
\\ return 0;
\\}
, "");
cases.add("Array initializers (string literals, incomplete arrays)",
\\#include <stdlib.h>
\\#include <string.h>
\\extern int foo[];
\\int global_arr[] = {1, 2, 3};
\\char global_string[] = "hello";
\\int main(int argc, char *argv[]) {
\\ if (global_arr[2] != 3) abort();
\\ if (strlen(global_string) != 5) abort();
\\ const char *const_str = "hello";
\\ if (strcmp(const_str, "hello") != 0) abort();
\\ char empty_str[] = "";
\\ if (strlen(empty_str) != 0) abort();
\\ char hello[] = "hello";
\\ if (strlen(hello) != 5 || sizeof(hello) != 6) abort();
\\ int empty[] = {};
\\ if (sizeof(empty) != 0) abort();
\\ int bar[] = {42};
\\ if (bar[0] != 42) abort();
\\ bar[0] = 43;
\\ if (bar[0] != 43) abort();
\\ int baz[] = {1, [42] = 123, 456};
\\ if (baz[42] != 123 || baz[43] != 456) abort();
\\ if (sizeof(baz) != sizeof(int) * 44) abort();
\\ const char *const names[] = {"first", "second", "third"};
\\ if (strcmp(names[2], "third") != 0) abort();
\\ char catted_str[] = "abc" "def";
\\ if (strlen(catted_str) != 6 || sizeof(catted_str) != 7) abort();
\\ char catted_trunc_str[2] = "abc" "def";
\\ if (sizeof(catted_trunc_str) != 2 || catted_trunc_str[0] != 'a' || catted_trunc_str[1] != 'b') abort();
\\ char big_array_utf8lit[10] = "💯";
\\ if (strcmp(big_array_utf8lit, "💯") != 0 || big_array_utf8lit[9] != 0) abort();
\\ return 0;
\\}
, "");
cases.add("Wide, UTF-16, and UTF-32 string literals",
\\#include <stdlib.h>
\\#include <stdint.h>
\\#include <wchar.h>
\\int main(void) {
\\ const wchar_t *wide_str = L"wide";
\\ const wchar_t wide_hello[] = L"hello";
\\ if (wcslen(wide_str) != 4) abort();
\\ if (wcslen(L"literal") != 7) abort();
\\ if (wcscmp(wide_hello, L"hello") != 0) abort();
\\
\\ const uint16_t *u16_str = u"wide";
\\ const uint16_t u16_hello[] = u"hello";
\\ if (u16_str[3] != u'e' || u16_str[4] != 0) abort();
\\ if (u16_hello[4] != u'o' || u16_hello[5] != 0) abort();
\\
\\ const uint32_t *u32_str = U"wide";
\\ const uint32_t u32_hello[] = U"hello";
\\ if (u32_str[3] != U'e' || u32_str[4] != 0) abort();
\\ if (u32_hello[4] != U'o' || u32_hello[5] != 0) abort();
\\ return 0;
\\}
, "");
cases.add("Address of function is no-op",
\\#include <stdlib.h>
\\#include <stdbool.h>
\\typedef int (*myfunc)(int);
\\int a(int arg) { return arg + 1;}
\\int b(int arg) { return arg + 2;}
\\int caller(myfunc fn, int arg) {
\\ return fn(arg);
\\}
\\int main() {
\\ myfunc arr[3] = {&a, &b, a};
\\ myfunc foo = a;
\\ myfunc bar = &(a);
\\ if (foo != bar) abort();
\\ if (arr[0] == arr[1]) abort();
\\ if (arr[0] != arr[2]) abort();
\\ if (caller(b, 40) != 42) abort();
\\ if (caller(&b, 40) != 42) abort();
\\ return 0;
\\}
, "");
cases.add("Obscure ways of calling functions; issue #4124",
\\#include <stdlib.h>
\\static int add(int a, int b) {
\\ return a + b;
\\}
\\typedef int (*adder)(int, int);
\\typedef void (*funcptr)(void);
\\int main() {
\\ if ((add)(1, 2) != 3) abort();
\\ if ((&add)(1, 2) != 3) abort();
\\ if (add(3, 1) != 4) abort();
\\ if ((*add)(2, 3) != 5) abort();
\\ if ((**add)(7, -1) != 6) abort();
\\ if ((***add)(-2, 9) != 7) abort();
\\
\\ int (*ptr)(int a, int b);
\\ ptr = add;
\\
\\ if (ptr(1, 2) != 3) abort();
\\ if ((*ptr)(3, 1) != 4) abort();
\\ if ((**ptr)(2, 3) != 5) abort();
\\ if ((***ptr)(7, -1) != 6) abort();
\\ if ((****ptr)(-2, 9) != 7) abort();
\\
\\ funcptr addr1 = (funcptr)(add);
\\ funcptr addr2 = (funcptr)(&add);
\\
\\ if (addr1 != addr2) abort();
\\ if (((int(*)(int, int))addr1)(1, 2) != 3) abort();
\\ if (((adder)addr2)(1, 2) != 3) abort();
\\ return 0;
\\}
, "");
cases.add("Return boolean expression as int; issue #6215",
\\#include <stdlib.h>
\\#include <stdbool.h>
\\bool actual_bool(void) { return 4 - 1 < 4;}
\\char char_bool_ret(void) { return 0 || 1; }
\\short short_bool_ret(void) { return 0 < 1; }
\\int int_bool_ret(void) { return 1 && 1; }
\\long long_bool_ret(void) { return !(0 > 1); }
\\static int GLOBAL = 1;
\\int nested_scopes(int a, int b) {
\\ if (a == 1) {
\\ int target = 1;
\\ return b == target;
\\ } else {
\\ int target = 2;
\\ if (b == target) {
\\ return GLOBAL == 1;
\\ }
\\ return target == 2;
\\ }
\\}
\\int main(void) {
\\ if (!actual_bool()) abort();
\\ if (!char_bool_ret()) abort();
\\ if (!short_bool_ret()) abort();
\\ if (!int_bool_ret()) abort();
\\ if (!long_bool_ret()) abort();
\\ if (!nested_scopes(1, 1)) abort();
\\ if (nested_scopes(1, 2)) abort();
\\ if (!nested_scopes(0, 2)) abort();
\\ if (!nested_scopes(0, 3)) abort();
\\ return 1 != 1;
\\}
, "");
cases.add("Comma operator should create new scope; issue #7989",
\\#include <stdlib.h>
\\#include <stdio.h>
\\int main(void) {
\\ if (1 || (abort(), 1)) {}
\\ if (0 && (1, printf("do not print\n"))) {}
\\ int x = 0;
\\ x = (x = 3, 4, x + 1);
\\ if (x != 4) abort();
\\ return 0;
\\}
, "");
cases.add("Use correct break label for statement expression in nested scope",
\\#include <stdlib.h>
\\int main(void) {
\\ int x = ({1, ({2; 3;});});
\\ if (x != 3) abort();
\\ return 0;
\\}
, "");
cases.add("pointer difference: scalar array w/ size truncation or negative result. Issue #7216",
\\#include <stdlib.h>
\\#include <stddef.h>
\\#define SIZE 10
\\int main() {
\\ int foo[SIZE];
\\ int *start = &foo[0];
\\ int *one_past_end = start + SIZE;
\\ ptrdiff_t diff = one_past_end - start;
\\ char diff_char = one_past_end - start;
\\ if (diff != SIZE || diff_char != SIZE) abort();
\\ diff = start - one_past_end;
\\ if (diff != -SIZE) abort();
\\ if (one_past_end - foo != SIZE) abort();
\\ if ((one_past_end - 1) - foo != SIZE - 1) abort();
\\ if ((start + 1) - foo != 1) abort();
\\ return 0;
\\}
, "");
// C standard: if the expression P points either to an element of an array object or one
// past the last element of an array object, and the expression Q points to the last
// element of the same array object, the expression ((Q)+1)-(P) has the same value as
// ((Q)-(P))+1 and as -((P)-((Q)+1)), and has the value zero if the expression P points
// one past the last element of the array object, even though the expression (Q)+1
// does not point to an element of the array object
cases.add("pointer difference: C standard edge case",
\\#include <stdlib.h>
\\#include <stddef.h>
\\#define SIZE 10
\\int main() {
\\ int foo[SIZE];
\\ int *start = &foo[0];
\\ int *P = start + SIZE;
\\ int *Q = &foo[SIZE - 1];
\\ if ((Q + 1) - P != 0) abort();
\\ if ((Q + 1) - P != (Q - P) + 1) abort();
\\ if ((Q + 1) - P != -(P - (Q + 1))) abort();
\\ return 0;
\\}
, "");
cases.add("pointer difference: unary operators",
\\#include <stdlib.h>
\\int main() {
\\ int foo[10];
\\ int *x = &foo[1];
\\ const int *y = &foo[5];
\\ if (y - x++ != 4) abort();
\\ if (y - x != 3) abort();
\\ if (y - ++x != 2) abort();
\\ if (y - x-- != 2) abort();
\\ if (y - x != 3) abort();
\\ if (y - --x != 4) abort();
\\ if (y - &foo[0] != 5) abort();
\\ return 0;
\\}
, "");
cases.add("pointer difference: struct array with padding",
\\#include <stdlib.h>
\\#include <stddef.h>
\\#define SIZE 10
\\typedef struct my_struct {
\\ int x;
\\ char c;
\\ int y;
\\} my_struct_t;
\\int main() {
\\ my_struct_t foo[SIZE];
\\ my_struct_t *start = &foo[0];
\\ my_struct_t *one_past_end = start + SIZE;
\\ ptrdiff_t diff = one_past_end - start;
\\ int diff_int = one_past_end - start;
\\ if (diff != SIZE || diff_int != SIZE) abort();
\\ diff = start - one_past_end;
\\ if (diff != -SIZE) abort();
\\ return 0;
\\}
, "");
cases.add("pointer difference: array of function pointers",
\\#include <stdlib.h>
\\int a(void) { return 1;}
\\int b(void) { return 2;}
\\int c(void) { return 3;}
\\typedef int (*myfunc)(void);
\\int main() {
\\ myfunc arr[] = {a, b, c, a, b, c};
\\ myfunc *f1 = &arr[1];
\\ myfunc *f4 = &arr[4];
\\ if (f4 - f1 != 3) abort();
\\ return 0;
\\}
, "");
cases.add("typeof operator",
\\#include <stdlib.h>
\\static int FOO = 42;
\\typedef typeof(FOO) foo_type;
\\typeof(foo_type) myfunc(typeof(FOO) x) { return (typeof(FOO)) x; }
\\int main(void) {
\\ int x = FOO;
\\ typeof(x) y = x;
\\ foo_type z = y;
\\ if (x != y) abort();
\\ if (myfunc(z) != x) abort();
\\
\\ const char *my_string = "bar";
\\ typeof (typeof (my_string)[4]) string_arr = {"a","b","c","d"};
\\ if (string_arr[0][0] != 'a' || string_arr[3][0] != 'd') abort();
\\ return 0;
\\}
, "");
cases.add("offsetof",
\\#include <stddef.h>
\\#include <stdlib.h>
\\#define container_of(ptr, type, member) ({ \
\\ const typeof( ((type *)0)->member ) *__mptr = (ptr); \
\\ (type *)( (char *)__mptr - offsetof(type,member) );})
\\typedef struct {
\\ int i;
\\ struct { int x; char y; int z; } s;
\\ float f;
\\} container;
\\int main(void) {
\\ if (offsetof(container, i) != 0) abort();
\\ if (offsetof(container, s) <= offsetof(container, i)) abort();
\\ if (offsetof(container, f) <= offsetof(container, s)) abort();
\\
\\ container my_container;
\\ typeof(my_container.s) *inner_member_pointer = &my_container.s;
\\ float *float_member_pointer = &my_container.f;
\\ int *anon_member_pointer = &my_container.s.z;
\\ container *my_container_p;
\\
\\ my_container_p = container_of(inner_member_pointer, container, s);
\\ if (my_container_p != &my_container) abort();
\\
\\ my_container_p = container_of(float_member_pointer, container, f);
\\ if (my_container_p != &my_container) abort();
\\
\\ if (container_of(anon_member_pointer, typeof(my_container.s), z) != inner_member_pointer) abort();
\\ return 0;
\\}
, "");
cases.add("handle assert.h",
\\#include <assert.h>
\\int main() {
\\ int x = 1;
\\ int *xp = &x;
\\ assert(1);
\\ assert(x != 0);
\\ assert(xp);
\\ assert(*xp);
\\ return 0;
\\}
, "");
cases.add("NDEBUG disables assert",
\\#define NDEBUG
\\#include <assert.h>
\\int main() {
\\ assert(0);
\\ assert(NULL);
\\ return 0;
\\}
, "");
cases.add("pointer arithmetic with signed operand",
\\#include <stdlib.h>
\\int main() {
\\ int array[10];
\\ int *x = &array[5];
\\ int *y;
\\ int idx = 0;
\\ y = x + ++idx;
\\ if (y != x + 1 || y != &array[6]) abort();
\\ y = idx + x;
\\ if (y != x + 1 || y != &array[6]) abort();
\\ y = x - idx;
\\ if (y != x - 1 || y != &array[4]) abort();
\\
\\ idx = 0;
\\ y = --idx + x;
\\ if (y != x - 1 || y != &array[4]) abort();
\\ y = idx + x;
\\ if (y != x - 1 || y != &array[4]) abort();
\\ y = x - idx;
\\ if (y != x + 1 || y != &array[6]) abort();
\\
\\ idx = 1;
\\ x += idx;
\\ if (x != &array[6]) abort();
\\ x -= idx;
\\ if (x != &array[5]) abort();
\\ y = (x += idx);
\\ if (y != x || y != &array[6]) abort();
\\ y = (x -= idx);
\\ if (y != x || y != &array[5]) abort();
\\
\\ if (array + idx != &array[1] || array + 1 != &array[1]) abort();
\\ idx = -1;
\\ if (array - idx != &array[1]) abort();
\\
\\ return 0;
\\}
, "");
cases.add("Compound literals",
\\#include <stdlib.h>
\\struct Foo {
\\ int a;
\\ char b[2];
\\ float c;
\\};
\\int main() {
\\ struct Foo foo;
\\ int x = 1, y = 2;
\\ foo = (struct Foo) {x + y, {'a', 'b'}, 42.0f};
\\ if (foo.a != x + y || foo.b[0] != 'a' || foo.b[1] != 'b' || foo.c != 42.0f) abort();
\\ return 0;
\\}
, "");
cases.add("Generic selections",
\\#include <stdlib.h>
\\#include <string.h>
\\#include <stdint.h>
\\#define my_generic_fn(X) _Generic((X), \
\\ int: abs, \
\\ char *: strlen, \
\\ size_t: malloc, \
\\ default: free \
\\)(X)
\\#define my_generic_val(X) _Generic((X), \
\\ int: 1, \
\\ const char *: "bar" \
\\)
\\int main(void) {
\\ if (my_generic_val(100) != 1) abort();
\\
\\ const char *foo = "foo";
\\ const char *bar = my_generic_val(foo);
\\ if (strcmp(bar, "bar") != 0) abort();
\\
\\ if (my_generic_fn(-42) != 42) abort();
\\ if (my_generic_fn("hello") != 5) abort();
\\
\\ size_t size = 8192;
\\ uint8_t *mem = my_generic_fn(size);
\\ memset(mem, 42, size);
\\ if (mem[size - 1] != 42) abort();
\\ my_generic_fn(mem);
\\
\\ return 0;
\\}
, "");
// See __builtin_alloca_with_align comment in std.c.builtins
cases.add("use of unimplemented builtin in unused function does not prevent compilation",
\\#include <stdlib.h>
\\void unused() {
\\ __builtin_alloca_with_align(1, 8);
\\}
\\int main(void) {
\\ if (__builtin_sqrt(1.0) != 1.0) abort();
\\ return 0;
\\}
, "");
cases.add("convert single-statement bodies into blocks for if/else/for/while. issue #8159",
\\#include <stdlib.h>
\\int foo() { return 1; }
\\int main(void) {
\\ int i = 0;
\\ if (i == 0) if (i == 0) if (i != 0) i = 1;
\\ if (i != 0) i = 1; else if (i == 0) if (i == 0) i += 1;
\\ for (; i < 10;) for (; i < 10;) i++;
\\ while (i == 100) while (i == 100) foo();
\\ if (0) do do "string"; while(1); while(1);
\\ return 0;
\\}
, "");
cases.add("cast RHS of compound assignment if necessary, unused result",
\\#include <stdlib.h>
\\int main(void) {
\\ signed short val = -1;
\\ val += 1; if (val != 0) abort();
\\ val -= 1; if (val != -1) abort();
\\ val *= 2; if (val != -2) abort();
\\ val /= 2; if (val != -1) abort();
\\ val %= 2; if (val != -1) abort();
\\ val <<= 1; if (val != -2) abort();
\\ val >>= 1; if (val != -1) abort();
\\ val += 100000000; // compile error if @truncate() not inserted
\\ unsigned short uval = 1;
\\ uval += 1; if (uval != 2) abort();
\\ uval -= 1; if (uval != 1) abort();
\\ uval *= 2; if (uval != 2) abort();
\\ uval /= 2; if (uval != 1) abort();
\\ uval %= 2; if (uval != 1) abort();
\\ uval <<= 1; if (uval != 2) abort();
\\ uval >>= 1; if (uval != 1) abort();
\\ uval += 100000000; // compile error if @truncate() not inserted
\\}
, "");
cases.add("cast RHS of compound assignment if necessary, used result",
\\#include <stdlib.h>
\\int main(void) {
\\ signed short foo;
\\ signed short val = -1;
\\ foo = (val += 1); if (foo != 0) abort();
\\ foo = (val -= 1); if (foo != -1) abort();
\\ foo = (val *= 2); if (foo != -2) abort();
\\ foo = (val /= 2); if (foo != -1) abort();
\\ foo = (val %= 2); if (foo != -1) abort();
\\ foo = (val <<= 1); if (foo != -2) abort();
\\ foo = (val >>= 1); if (foo != -1) abort();
\\ foo = (val += 100000000); // compile error if @truncate() not inserted
\\ unsigned short ufoo;
\\ unsigned short uval = 1;
\\ ufoo = (uval += 1); if (ufoo != 2) abort();
\\ ufoo = (uval -= 1); if (ufoo != 1) abort();
\\ ufoo = (uval *= 2); if (ufoo != 2) abort();
\\ ufoo = (uval /= 2); if (ufoo != 1) abort();
\\ ufoo = (uval %= 2); if (ufoo != 1) abort();
\\ ufoo = (uval <<= 1); if (ufoo != 2) abort();
\\ ufoo = (uval >>= 1); if (ufoo != 1) abort();
\\ ufoo = (uval += 100000000); // compile error if @truncate() not inserted
\\}
, "");
cases.add("basic vector expressions",
\\#include <stdlib.h>
\\#include <stdint.h>
\\typedef int16_t __v8hi __attribute__((__vector_size__(16)));
\\int main(int argc, char**argv) {
\\ __v8hi uninitialized;
\\ __v8hi empty_init = {};
\\ __v8hi partial_init = {0, 1, 2, 3};
\\
\\ __v8hi a = {0, 1, 2, 3, 4, 5, 6, 7};
\\ __v8hi b = (__v8hi) {100, 200, 300, 400, 500, 600, 700, 800};
\\
\\ __v8hi sum = a + b;
\\ for (int i = 0; i < 8; i++) {
\\ if (sum[i] != a[i] + b[i]) abort();
\\ }
\\ return 0;
\\}
, "");
cases.add("__builtin_shufflevector",
\\#include <stdlib.h>
\\#include <stdint.h>
\\typedef int16_t __v4hi __attribute__((__vector_size__(8)));
\\typedef int16_t __v8hi __attribute__((__vector_size__(16)));
\\int main(int argc, char**argv) {
\\ __v8hi v8_a = {0, 1, 2, 3, 4, 5, 6, 7};
\\ __v8hi v8_b = {100, 200, 300, 400, 500, 600, 700, 800};
\\ __v8hi shuffled = __builtin_shufflevector(v8_a, v8_b, 0, 1, 2, 3, 8, 9, 10, 11);
\\ for (int i = 0; i < 8; i++) {
\\ if (i < 4) {
\\ if (shuffled[i] != v8_a[i]) abort();
\\ } else {
\\ if (shuffled[i] != v8_b[i - 4]) abort();
\\ }
\\ }
\\ shuffled = __builtin_shufflevector(
\\ (__v8hi) {-1, -1, -1, -1, -1, -1, -1, -1},
\\ (__v8hi) {42, 42, 42, 42, 42, 42, 42, 42},
\\ 0, 1, 2, 3, 8, 9, 10, 11
\\ );
\\ for (int i = 0; i < 8; i++) {
\\ if (i < 4) {
\\ if (shuffled[i] != -1) abort();
\\ } else {
\\ if (shuffled[i] != 42) abort();
\\ }
\\ }
\\ __v4hi shuffled_to_fewer_elements = __builtin_shufflevector(v8_a, v8_b, 0, 1, 8, 9);
\\ for (int i = 0; i < 4; i++) {
\\ if (i < 2) {
\\ if (shuffled_to_fewer_elements[i] != v8_a[i]) abort();
\\ } else {
\\ if (shuffled_to_fewer_elements[i] != v8_b[i - 2]) abort();
\\ }
\\ }
\\ __v4hi v4_a = {0, 1, 2, 3};
\\ __v4hi v4_b = {100, 200, 300, 400};
\\ __v8hi shuffled_to_more_elements = __builtin_shufflevector(v4_a, v4_b, 0, 1, 2, 3, 4, 5, 6, 7);
\\ for (int i = 0; i < 4; i++) {
\\ if (shuffled_to_more_elements[i] != v4_a[i]) abort();
\\ if (shuffled_to_more_elements[i + 4] != v4_b[i]) abort();
\\ }
\\ return 0;
\\}
, "");
cases.add("__builtin_convertvector",
\\#include <stdlib.h>
\\#include <stdint.h>
\\typedef int16_t __v8hi __attribute__((__vector_size__(16)));
\\typedef uint16_t __v8hu __attribute__((__vector_size__(16)));
\\int main(int argc, char**argv) {
\\ __v8hi signed_vector = { 1, 2, 3, 4, -1, -2, -3,-4};
\\ __v8hu unsigned_vector = __builtin_convertvector(signed_vector, __v8hu);
\\
\\ for (int i = 0; i < 8; i++) {
\\ if (unsigned_vector[i] != (uint16_t)signed_vector[i]) abort();
\\ }
\\ return 0;
\\}
, "");
cases.add("vector casting",
\\#include <stdlib.h>
\\#include <stdint.h>
\\typedef int8_t __v8qi __attribute__((__vector_size__(8)));
\\typedef uint8_t __v8qu __attribute__((__vector_size__(8)));
\\int main(int argc, char**argv) {
\\ __v8qi signed_vector = { 1, 2, 3, 4, -1, -2, -3,-4};
\\
\\ uint64_t big_int = (uint64_t) signed_vector;
\\ if (big_int != 0x01020304FFFEFDFCULL && big_int != 0xFCFDFEFF04030201ULL) abort();
\\ __v8qu unsigned_vector = (__v8qu) big_int;
\\ for (int i = 0; i < 8; i++) {
\\ if (unsigned_vector[i] != (uint8_t)signed_vector[i] && unsigned_vector[i] != (uint8_t)signed_vector[7 - i]) abort();
\\ }
\\ return 0;
\\}
, "");
cases.add("break from switch statement. Issue #8387",
\\#include <stdlib.h>
\\int switcher(int x) {
\\ switch (x) {
\\ case 0: // no braces
\\ x += 1;
\\ break;
\\ case 1: // conditional break
\\ if (x == 1) {
\\ x += 1;
\\ break;
\\ }
\\ x += 100;
\\ case 2: { // braces with fallthrough
\\ x += 1;
\\ }
\\ case 3: // fallthrough to return statement
\\ x += 1;
\\ case 42: { // random out of order case
\\ x += 1;
\\ return x;
\\ }
\\ case 4: { // break within braces
\\ x += 1;
\\ break;
\\ }
\\ case 5:
\\ x += 1; // fallthrough to default
\\ default:
\\ x += 1;
\\ }
\\ return x;
\\}
\\int main(void) {
\\ int expected[] = {1, 2, 5, 5, 5, 7, 7};
\\ for (int i = 0; i < sizeof(expected) / sizeof(int); i++) {
\\ int res = switcher(i);
\\ if (res != expected[i]) abort();
\\ }
\\ if (switcher(42) != 43) abort();
\\ return 0;
\\}
, "");
cases.add("Cast to enum from larger integral type. Issue #6011",
\\#include <stdint.h>
\\#include <stdlib.h>
\\enum Foo { A, B, C };
\\static inline enum Foo do_stuff(void) {
\\ int64_t i = 1;
\\ return (enum Foo)i;
\\}
\\int main(void) {
\\ if (do_stuff() != B) abort();
\\ return 0;
\\}
, "");
cases.add("Render array LHS as grouped node if necessary",
\\#include <stdlib.h>
\\int main(void) {
\\ int arr[] = {40, 41, 42, 43};
\\ if ((arr + 1)[1] != 42) abort();
\\ return 0;
\\}
, "");
cases.add("typedef with multiple names",
\\#include <stdlib.h>
\\typedef struct {
\\ char field;
\\} a_t, b_t;
\\
\\int main(void) {
\\ a_t a = { .field = 42 };
\\ b_t b = a;
\\ if (b.field != 42) abort();
\\ return 0;
\\}
, "");
cases.add("__cleanup__ attribute",
\\#include <stdlib.h>
\\static int cleanup_count = 0;
\\void clean_up(int *final_value) {
\\ if (*final_value != cleanup_count++) abort();
\\}
\\void doit(void) {
\\ int a __attribute__ ((__cleanup__(clean_up))) __attribute__ ((unused)) = 2;
\\ int b __attribute__ ((__cleanup__(clean_up))) __attribute__ ((unused)) = 1;
\\ int c __attribute__ ((__cleanup__(clean_up))) __attribute__ ((unused)) = 0;
\\}
\\int main(void) {
\\ doit();
\\ if (cleanup_count != 3) abort();
\\ return 0;
\\}
, "");
cases.add("enum used as boolean expression",
\\#include <stdlib.h>
\\enum FOO {BAR, BAZ};
\\int main(void) {
\\ enum FOO x = BAR;
\\ if (x) abort();
\\ if (!BAZ) abort();
\\ return 0;
\\}
, "");
} | test/run_translated_c.zig |
const std = @import("../std.zig");
const builtin = @import("builtin");
const os = std.os;
const io = std.io;
const mem = std.mem;
const math = std.math;
const assert = std.debug.assert;
const windows = os.windows;
const Os = builtin.Os;
const maxInt = std.math.maxInt;
const is_windows = std.Target.current.os.tag == .windows;
pub const File = struct {
/// The OS-specific file descriptor or file handle.
handle: os.fd_t,
/// On some systems, such as Linux, file system file descriptors are incapable of non-blocking I/O.
/// This forces us to perform asynchronous I/O on a dedicated thread, to achieve non-blocking
/// file-system I/O. To do this, `File` must be aware of whether it is a file system file descriptor,
/// or, more specifically, whether the I/O is always blocking.
capable_io_mode: io.ModeOverride = io.default_mode,
/// Furthermore, even when `std.io.mode` is async, it is still sometimes desirable to perform blocking I/O,
/// although not by default. For example, when printing a stack trace to stderr.
/// This field tracks both by acting as an overriding I/O mode. When not building in async I/O mode,
/// the type only has the `.blocking` tag, making it a zero-bit type.
intended_io_mode: io.ModeOverride = io.default_mode,
pub const Mode = os.mode_t;
pub const INode = os.ino_t;
pub const Kind = enum {
BlockDevice,
CharacterDevice,
Directory,
NamedPipe,
SymLink,
File,
UnixDomainSocket,
Whiteout,
Unknown,
};
pub const default_mode = switch (builtin.os.tag) {
.windows => 0,
.wasi => 0,
else => 0o666,
};
pub const OpenError = error{
SharingViolation,
PathAlreadyExists,
FileNotFound,
AccessDenied,
PipeBusy,
NameTooLong,
/// On Windows, file paths must be valid Unicode.
InvalidUtf8,
/// On Windows, file paths cannot contain these characters:
/// '/', '*', '?', '"', '<', '>', '|'
BadPathName,
Unexpected,
} || os.OpenError || os.FlockError;
pub const Lock = enum { None, Shared, Exclusive };
/// TODO https://github.com/ziglang/zig/issues/3802
pub const OpenFlags = struct {
read: bool = true,
write: bool = false,
/// Open the file with a lock to prevent other processes from accessing it at the
/// same time. An exclusive lock will prevent other processes from acquiring a lock.
/// A shared lock will prevent other processes from acquiring a exclusive lock, but
/// doesn't prevent other process from getting their own shared locks.
///
/// Note that the lock is only advisory on Linux, except in very specific cirsumstances[1].
/// This means that a process that does not respect the locking API can still get access
/// to the file, despite the lock.
///
/// Windows' file locks are mandatory, and any process attempting to access the file will
/// receive an error.
///
/// [1]: https://www.kernel.org/doc/Documentation/filesystems/mandatory-locking.txt
lock: Lock = .None,
/// Sets whether or not to wait until the file is locked to return. If set to true,
/// `error.WouldBlock` will be returned. Otherwise, the file will wait until the file
/// is available to proceed.
/// In async I/O mode, non-blocking at the OS level is
/// determined by `intended_io_mode`, and `true` means `error.WouldBlock` is returned,
/// and `false` means `error.WouldBlock` is handled by the event loop.
lock_nonblocking: bool = false,
/// Setting this to `.blocking` prevents `O_NONBLOCK` from being passed even
/// if `std.io.is_async`. It allows the use of `nosuspend` when calling functions
/// related to opening the file, reading, writing, and locking.
intended_io_mode: io.ModeOverride = io.default_mode,
};
/// TODO https://github.com/ziglang/zig/issues/3802
pub const CreateFlags = struct {
/// Whether the file will be created with read access.
read: bool = false,
/// If the file already exists, and is a regular file, and the access
/// mode allows writing, it will be truncated to length 0.
truncate: bool = true,
/// Ensures that this open call creates the file, otherwise causes
/// `error.FileAlreadyExists` to be returned.
exclusive: bool = false,
/// Open the file with a lock to prevent other processes from accessing it at the
/// same time. An exclusive lock will prevent other processes from acquiring a lock.
/// A shared lock will prevent other processes from acquiring a exclusive lock, but
/// doesn't prevent other process from getting their own shared locks.
///
/// Note that the lock is only advisory on Linux, except in very specific cirsumstances[1].
/// This means that a process that does not respect the locking API can still get access
/// to the file, despite the lock.
///
/// Windows's file locks are mandatory, and any process attempting to access the file will
/// receive an error.
///
/// [1]: https://www.kernel.org/doc/Documentation/filesystems/mandatory-locking.txt
lock: Lock = .None,
/// Sets whether or not to wait until the file is locked to return. If set to true,
/// `error.WouldBlock` will be returned. Otherwise, the file will wait until the file
/// is available to proceed.
/// In async I/O mode, non-blocking at the OS level is
/// determined by `intended_io_mode`, and `true` means `error.WouldBlock` is returned,
/// and `false` means `error.WouldBlock` is handled by the event loop.
lock_nonblocking: bool = false,
/// For POSIX systems this is the file system mode the file will
/// be created with.
mode: Mode = default_mode,
/// Setting this to `.blocking` prevents `O_NONBLOCK` from being passed even
/// if `std.io.is_async`. It allows the use of `nosuspend` when calling functions
/// related to opening the file, reading, writing, and locking.
intended_io_mode: io.ModeOverride = io.default_mode,
};
/// Upon success, the stream is in an uninitialized state. To continue using it,
/// you must use the open() function.
pub fn close(self: File) void {
if (is_windows) {
windows.CloseHandle(self.handle);
} else if (self.capable_io_mode != self.intended_io_mode) {
std.event.Loop.instance.?.close(self.handle);
} else {
os.close(self.handle);
}
}
/// Test whether the file refers to a terminal.
/// See also `supportsAnsiEscapeCodes`.
pub fn isTty(self: File) bool {
return os.isatty(self.handle);
}
/// Test whether ANSI escape codes will be treated as such.
pub fn supportsAnsiEscapeCodes(self: File) bool {
if (builtin.os.tag == .windows) {
return os.isCygwinPty(self.handle);
}
if (builtin.os.tag == .wasi) {
// WASI sanitizes stdout when fd is a tty so ANSI escape codes
// will not be interpreted as actual cursor commands, and
// stderr is always sanitized.
return false;
}
if (self.isTty()) {
if (self.handle == os.STDOUT_FILENO or self.handle == os.STDERR_FILENO) {
// Use getenvC to workaround https://github.com/ziglang/zig/issues/3511
if (os.getenvZ("TERM")) |term| {
if (std.mem.eql(u8, term, "dumb"))
return false;
}
}
return true;
}
return false;
}
pub const SetEndPosError = os.TruncateError;
/// Shrinks or expands the file.
/// The file offset after this call is left unchanged.
pub fn setEndPos(self: File, length: u64) SetEndPosError!void {
try os.ftruncate(self.handle, length);
}
pub const SeekError = os.SeekError;
/// Repositions read/write file offset relative to the current offset.
/// TODO: integrate with async I/O
pub fn seekBy(self: File, offset: i64) SeekError!void {
return os.lseek_CUR(self.handle, offset);
}
/// Repositions read/write file offset relative to the end.
/// TODO: integrate with async I/O
pub fn seekFromEnd(self: File, offset: i64) SeekError!void {
return os.lseek_END(self.handle, offset);
}
/// Repositions read/write file offset relative to the beginning.
/// TODO: integrate with async I/O
pub fn seekTo(self: File, offset: u64) SeekError!void {
return os.lseek_SET(self.handle, offset);
}
pub const GetPosError = os.SeekError || os.FStatError;
/// TODO: integrate with async I/O
pub fn getPos(self: File) GetPosError!u64 {
return os.lseek_CUR_get(self.handle);
}
/// TODO: integrate with async I/O
pub fn getEndPos(self: File) GetPosError!u64 {
if (builtin.os.tag == .windows) {
return windows.GetFileSizeEx(self.handle);
}
return (try self.stat()).size;
}
pub const ModeError = os.FStatError;
/// TODO: integrate with async I/O
pub fn mode(self: File) ModeError!Mode {
if (builtin.os.tag == .windows) {
return 0;
}
return (try self.stat()).mode;
}
pub const Stat = struct {
/// A number that the system uses to point to the file metadata. This number is not guaranteed to be
/// unique across time, as some file systems may reuse an inode after its file has been deleted.
/// Some systems may change the inode of a file over time.
///
/// On Linux, the inode is a structure that stores the metadata, and the inode _number_ is what
/// you see here: the index number of the inode.
///
/// The FileIndex on Windows is similar. It is a number for a file that is unique to each filesystem.
inode: INode,
size: u64,
mode: Mode,
kind: Kind,
/// Access time in nanoseconds, relative to UTC 1970-01-01.
atime: i128,
/// Last modification time in nanoseconds, relative to UTC 1970-01-01.
mtime: i128,
/// Creation time in nanoseconds, relative to UTC 1970-01-01.
ctime: i128,
};
pub const StatError = os.FStatError;
/// TODO: integrate with async I/O
pub fn stat(self: File) StatError!Stat {
if (builtin.os.tag == .windows) {
var io_status_block: windows.IO_STATUS_BLOCK = undefined;
var info: windows.FILE_ALL_INFORMATION = undefined;
const rc = windows.ntdll.NtQueryInformationFile(self.handle, &io_status_block, &info, @sizeOf(windows.FILE_ALL_INFORMATION), .FileAllInformation);
switch (rc) {
.SUCCESS => {},
.BUFFER_OVERFLOW => {},
.INVALID_PARAMETER => unreachable,
.ACCESS_DENIED => return error.AccessDenied,
else => return windows.unexpectedStatus(rc),
}
return Stat{
.inode = info.InternalInformation.IndexNumber,
.size = @bitCast(u64, info.StandardInformation.EndOfFile),
.mode = 0,
.kind = if (info.StandardInformation.Directory == 0) .File else .Directory,
.atime = windows.fromSysTime(info.BasicInformation.LastAccessTime),
.mtime = windows.fromSysTime(info.BasicInformation.LastWriteTime),
.ctime = windows.fromSysTime(info.BasicInformation.CreationTime),
};
}
const st = try os.fstat(self.handle);
const atime = st.atime();
const mtime = st.mtime();
const ctime = st.ctime();
return Stat{
.inode = st.ino,
.size = @bitCast(u64, st.size),
.mode = st.mode,
.kind = switch (builtin.os.tag) {
.wasi => switch (st.filetype) {
os.FILETYPE_BLOCK_DEVICE => Kind.BlockDevice,
os.FILETYPE_CHARACTER_DEVICE => Kind.CharacterDevice,
os.FILETYPE_DIRECTORY => Kind.Directory,
os.FILETYPE_SYMBOLIC_LINK => Kind.SymLink,
os.FILETYPE_REGULAR_FILE => Kind.File,
os.FILETYPE_SOCKET_STREAM, os.FILETYPE_SOCKET_DGRAM => Kind.UnixDomainSocket,
else => Kind.Unknown,
},
else => switch (st.mode & os.S_IFMT) {
os.S_IFBLK => Kind.BlockDevice,
os.S_IFCHR => Kind.CharacterDevice,
os.S_IFDIR => Kind.Directory,
os.S_IFIFO => Kind.NamedPipe,
os.S_IFLNK => Kind.SymLink,
os.S_IFREG => Kind.File,
os.S_IFSOCK => Kind.UnixDomainSocket,
else => Kind.Unknown,
},
},
.atime = @as(i128, atime.tv_sec) * std.time.ns_per_s + atime.tv_nsec,
.mtime = @as(i128, mtime.tv_sec) * std.time.ns_per_s + mtime.tv_nsec,
.ctime = @as(i128, ctime.tv_sec) * std.time.ns_per_s + ctime.tv_nsec,
};
}
pub const UpdateTimesError = os.FutimensError || windows.SetFileTimeError;
/// The underlying file system may have a different granularity than nanoseconds,
/// and therefore this function cannot guarantee any precision will be stored.
/// Further, the maximum value is limited by the system ABI. When a value is provided
/// that exceeds this range, the value is clamped to the maximum.
/// TODO: integrate with async I/O
pub fn updateTimes(
self: File,
/// access timestamp in nanoseconds
atime: i128,
/// last modification timestamp in nanoseconds
mtime: i128,
) UpdateTimesError!void {
if (builtin.os.tag == .windows) {
const atime_ft = windows.nanoSecondsToFileTime(atime);
const mtime_ft = windows.nanoSecondsToFileTime(mtime);
return windows.SetFileTime(self.handle, null, &atime_ft, &mtime_ft);
}
const times = [2]os.timespec{
os.timespec{
.tv_sec = math.cast(isize, @divFloor(atime, std.time.ns_per_s)) catch maxInt(isize),
.tv_nsec = math.cast(isize, @mod(atime, std.time.ns_per_s)) catch maxInt(isize),
},
os.timespec{
.tv_sec = math.cast(isize, @divFloor(mtime, std.time.ns_per_s)) catch maxInt(isize),
.tv_nsec = math.cast(isize, @mod(mtime, std.time.ns_per_s)) catch maxInt(isize),
},
};
try os.futimens(self.handle, ×);
}
/// On success, caller owns returned buffer.
/// If the file is larger than `max_bytes`, returns `error.FileTooBig`.
pub fn readAllAlloc(self: File, allocator: *mem.Allocator, stat_size: u64, max_bytes: usize) ![]u8 {
return self.readAllAllocOptions(allocator, stat_size, max_bytes, @alignOf(u8), null);
}
/// On success, caller owns returned buffer.
/// If the file is larger than `max_bytes`, returns `error.FileTooBig`.
/// Allows specifying alignment and a sentinel value.
pub fn readAllAllocOptions(
self: File,
allocator: *mem.Allocator,
stat_size: u64,
max_bytes: usize,
comptime alignment: u29,
comptime optional_sentinel: ?u8,
) !(if (optional_sentinel) |s| [:s]align(alignment) u8 else []align(alignment) u8) {
const size = math.cast(usize, stat_size) catch math.maxInt(usize);
if (size > max_bytes) return error.FileTooBig;
const buf = try allocator.allocWithOptions(u8, size, alignment, optional_sentinel);
errdefer allocator.free(buf);
try self.reader().readNoEof(buf);
return buf;
}
pub const ReadError = os.ReadError;
pub const PReadError = os.PReadError;
pub fn read(self: File, buffer: []u8) ReadError!usize {
if (is_windows) {
return windows.ReadFile(self.handle, buffer, null, self.intended_io_mode);
} else if (self.capable_io_mode != self.intended_io_mode) {
return std.event.Loop.instance.?.read(self.handle, buffer);
} else {
return os.read(self.handle, buffer);
}
}
/// Returns the number of bytes read. If the number read is smaller than `buffer.len`, it
/// means the file reached the end. Reaching the end of a file is not an error condition.
pub fn readAll(self: File, buffer: []u8) ReadError!usize {
var index: usize = 0;
while (index != buffer.len) {
const amt = try self.read(buffer[index..]);
if (amt == 0) break;
index += amt;
}
return index;
}
pub fn pread(self: File, buffer: []u8, offset: u64) PReadError!usize {
if (is_windows) {
return windows.ReadFile(self.handle, buffer, offset, self.intended_io_mode);
} else if (self.capable_io_mode != self.intended_io_mode) {
return std.event.Loop.instance.?.pread(self.handle, buffer, offset);
} else {
return os.pread(self.handle, buffer, offset);
}
}
/// Returns the number of bytes read. If the number read is smaller than `buffer.len`, it
/// means the file reached the end. Reaching the end of a file is not an error condition.
pub fn preadAll(self: File, buffer: []u8, offset: u64) PReadError!usize {
var index: usize = 0;
while (index != buffer.len) {
const amt = try self.pread(buffer[index..], offset + index);
if (amt == 0) break;
index += amt;
}
return index;
}
pub fn readv(self: File, iovecs: []const os.iovec) ReadError!usize {
if (is_windows) {
// TODO improve this to use ReadFileScatter
if (iovecs.len == 0) return @as(usize, 0);
const first = iovecs[0];
return windows.ReadFile(self.handle, first.iov_base[0..first.iov_len], null, self.intended_io_mode);
} else if (self.capable_io_mode != self.intended_io_mode) {
return std.event.Loop.instance.?.readv(self.handle, iovecs);
} else {
return os.readv(self.handle, iovecs);
}
}
/// Returns the number of bytes read. If the number read is smaller than the total bytes
/// from all the buffers, it means the file reached the end. Reaching the end of a file
/// is not an error condition.
/// The `iovecs` parameter is mutable because this function needs to mutate the fields in
/// order to handle partial reads from the underlying OS layer.
pub fn readvAll(self: File, iovecs: []os.iovec) ReadError!usize {
if (iovecs.len == 0) return;
var i: usize = 0;
var off: usize = 0;
while (true) {
var amt = try self.readv(iovecs[i..]);
var eof = amt == 0;
off += amt;
while (amt >= iovecs[i].iov_len) {
amt -= iovecs[i].iov_len;
i += 1;
if (i >= iovecs.len) return off;
eof = false;
}
if (eof) return off;
iovecs[i].iov_base += amt;
iovecs[i].iov_len -= amt;
}
}
pub fn preadv(self: File, iovecs: []const os.iovec, offset: u64) PReadError!usize {
if (is_windows) {
// TODO improve this to use ReadFileScatter
if (iovecs.len == 0) return @as(usize, 0);
const first = iovecs[0];
return windows.ReadFile(self.handle, first.iov_base[0..first.iov_len], offset, self.intended_io_mode);
} else if (self.capable_io_mode != self.intended_io_mode) {
return std.event.Loop.instance.?.preadv(self.handle, iovecs, offset);
} else {
return os.preadv(self.handle, iovecs, offset);
}
}
/// Returns the number of bytes read. If the number read is smaller than the total bytes
/// from all the buffers, it means the file reached the end. Reaching the end of a file
/// is not an error condition.
/// The `iovecs` parameter is mutable because this function needs to mutate the fields in
/// order to handle partial reads from the underlying OS layer.
pub fn preadvAll(self: File, iovecs: []const os.iovec, offset: u64) PReadError!void {
if (iovecs.len == 0) return;
var i: usize = 0;
var off: usize = 0;
while (true) {
var amt = try self.preadv(iovecs[i..], offset + off);
var eof = amt == 0;
off += amt;
while (amt >= iovecs[i].iov_len) {
amt -= iovecs[i].iov_len;
i += 1;
if (i >= iovecs.len) return off;
eof = false;
}
if (eof) return off;
iovecs[i].iov_base += amt;
iovecs[i].iov_len -= amt;
}
}
pub const WriteError = os.WriteError;
pub const PWriteError = os.PWriteError;
pub fn write(self: File, bytes: []const u8) WriteError!usize {
if (is_windows) {
return windows.WriteFile(self.handle, bytes, null, self.intended_io_mode);
} else if (self.capable_io_mode != self.intended_io_mode) {
return std.event.Loop.instance.?.write(self.handle, bytes);
} else {
return os.write(self.handle, bytes);
}
}
pub fn writeAll(self: File, bytes: []const u8) WriteError!void {
var index: usize = 0;
while (index < bytes.len) {
index += try self.write(bytes[index..]);
}
}
pub fn pwrite(self: File, bytes: []const u8, offset: u64) PWriteError!usize {
if (is_windows) {
return windows.WriteFile(self.handle, bytes, offset, self.intended_io_mode);
} else if (self.capable_io_mode != self.intended_io_mode) {
return std.event.Loop.instance.?.pwrite(self.handle, bytes, offset);
} else {
return os.pwrite(self.handle, bytes, offset);
}
}
pub fn pwriteAll(self: File, bytes: []const u8, offset: u64) PWriteError!void {
var index: usize = 0;
while (index < bytes.len) {
index += try self.pwrite(bytes[index..], offset + index);
}
}
pub fn writev(self: File, iovecs: []const os.iovec_const) WriteError!usize {
if (is_windows) {
// TODO improve this to use WriteFileScatter
if (iovecs.len == 0) return @as(usize, 0);
const first = iovecs[0];
return windows.WriteFile(self.handle, first.iov_base[0..first.iov_len], null, self.intended_io_mode);
} else if (self.capable_io_mode != self.intended_io_mode) {
return std.event.Loop.instance.?.writev(self.handle, iovecs);
} else {
return os.writev(self.handle, iovecs);
}
}
/// The `iovecs` parameter is mutable because this function needs to mutate the fields in
/// order to handle partial writes from the underlying OS layer.
pub fn writevAll(self: File, iovecs: []os.iovec_const) WriteError!void {
if (iovecs.len == 0) return;
var i: usize = 0;
while (true) {
var amt = try self.writev(iovecs[i..]);
while (amt >= iovecs[i].iov_len) {
amt -= iovecs[i].iov_len;
i += 1;
if (i >= iovecs.len) return;
}
iovecs[i].iov_base += amt;
iovecs[i].iov_len -= amt;
}
}
pub fn pwritev(self: File, iovecs: []os.iovec_const, offset: usize) PWriteError!usize {
if (is_windows) {
// TODO improve this to use WriteFileScatter
if (iovecs.len == 0) return @as(usize, 0);
const first = iovecs[0];
return windows.WriteFile(self.handle, first.iov_base[0..first.iov_len], offset, self.intended_io_mode);
} else if (self.capable_io_mode != self.intended_io_mode) {
return std.event.Loop.instance.?.pwritev(self.handle, iovecs, offset);
} else {
return os.pwritev(self.handle, iovecs, offset);
}
}
/// The `iovecs` parameter is mutable because this function needs to mutate the fields in
/// order to handle partial writes from the underlying OS layer.
pub fn pwritevAll(self: File, iovecs: []os.iovec_const, offset: usize) PWriteError!void {
if (iovecs.len == 0) return;
var i: usize = 0;
var off: usize = 0;
while (true) {
var amt = try self.pwritev(iovecs[i..], offset + off);
off += amt;
while (amt >= iovecs[i].iov_len) {
amt -= iovecs[i].iov_len;
i += 1;
if (i >= iovecs.len) return;
}
iovecs[i].iov_base += amt;
iovecs[i].iov_len -= amt;
}
}
pub const CopyRangeError = os.CopyFileRangeError;
pub fn copyRange(in: File, in_offset: u64, out: File, out_offset: u64, len: usize) CopyRangeError!usize {
return os.copy_file_range(in.handle, in_offset, out.handle, out_offset, len, 0);
}
/// Returns the number of bytes copied. If the number read is smaller than `buffer.len`, it
/// means the in file reached the end. Reaching the end of a file is not an error condition.
pub fn copyRangeAll(in: File, in_offset: u64, out: File, out_offset: u64, len: usize) CopyRangeError!usize {
var total_bytes_copied: usize = 0;
var in_off = in_offset;
var out_off = out_offset;
while (total_bytes_copied < len) {
const amt_copied = try copyRange(in, in_off, out, out_off, len - total_bytes_copied);
if (amt_copied == 0) return total_bytes_copied;
total_bytes_copied += amt_copied;
in_off += amt_copied;
out_off += amt_copied;
}
return total_bytes_copied;
}
pub const WriteFileOptions = struct {
in_offset: u64 = 0,
/// `null` means the entire file. `0` means no bytes from the file.
/// When this is `null`, trailers must be sent in a separate writev() call
/// due to a flaw in the BSD sendfile API. Other operating systems, such as
/// Linux, already do this anyway due to API limitations.
/// If the size of the source file is known, passing the size here will save one syscall.
in_len: ?u64 = null,
headers_and_trailers: []os.iovec_const = &[0]os.iovec_const{},
/// The trailer count is inferred from `headers_and_trailers.len - header_count`
header_count: usize = 0,
};
pub const WriteFileError = os.SendFileError;
/// TODO integrate with async I/O
pub fn writeFileAll(self: File, in_file: File, args: WriteFileOptions) WriteFileError!void {
const count = blk: {
if (args.in_len) |l| {
if (l == 0) {
return self.writevAll(args.headers_and_trailers);
} else {
break :blk l;
}
} else {
break :blk 0;
}
};
const headers = args.headers_and_trailers[0..args.header_count];
const trailers = args.headers_and_trailers[args.header_count..];
const zero_iovec = &[0]os.iovec_const{};
// When reading the whole file, we cannot put the trailers in the sendfile() syscall,
// because we have no way to determine whether a partial write is past the end of the file or not.
const trls = if (count == 0) zero_iovec else trailers;
const offset = args.in_offset;
const out_fd = self.handle;
const in_fd = in_file.handle;
const flags = 0;
var amt: usize = 0;
hdrs: {
var i: usize = 0;
while (i < headers.len) {
amt = try os.sendfile(out_fd, in_fd, offset, count, headers[i..], trls, flags);
while (amt >= headers[i].iov_len) {
amt -= headers[i].iov_len;
i += 1;
if (i >= headers.len) break :hdrs;
}
headers[i].iov_base += amt;
headers[i].iov_len -= amt;
}
}
if (count == 0) {
var off: u64 = amt;
while (true) {
amt = try os.sendfile(out_fd, in_fd, offset + off, 0, zero_iovec, zero_iovec, flags);
if (amt == 0) break;
off += amt;
}
} else {
var off: u64 = amt;
while (off < count) {
amt = try os.sendfile(out_fd, in_fd, offset + off, count - off, zero_iovec, trailers, flags);
off += amt;
}
amt = @intCast(usize, off - count);
}
var i: usize = 0;
while (i < trailers.len) {
while (amt >= headers[i].iov_len) {
amt -= trailers[i].iov_len;
i += 1;
if (i >= trailers.len) return;
}
trailers[i].iov_base += amt;
trailers[i].iov_len -= amt;
amt = try os.writev(self.handle, trailers[i..]);
}
}
pub const Reader = io.Reader(File, ReadError, read);
/// Deprecated: use `Reader`
pub const InStream = Reader;
pub fn reader(file: File) io.Reader(File, ReadError, read) {
return .{ .context = file };
}
/// Deprecated: use `reader`
pub fn inStream(file: File) io.InStream(File, ReadError, read) {
return .{ .context = file };
}
pub const Writer = io.Writer(File, WriteError, write);
/// Deprecated: use `Writer`
pub const OutStream = Writer;
pub fn writer(file: File) Writer {
return .{ .context = file };
}
/// Deprecated: use `writer`
pub fn outStream(file: File) Writer {
return .{ .context = file };
}
pub const SeekableStream = io.SeekableStream(
File,
SeekError,
GetPosError,
seekTo,
seekBy,
getPos,
getEndPos,
);
pub fn seekableStream(file: File) SeekableStream {
return .{ .context = file };
}
}; | lib/std/fs/file.zig |
const std = @import("std");
const person_module = @import("person.zig");
const family_module = @import("family.zig");
const json = std.json;
const util = @import("util.zig");
const Person = person_module.Person;
const Family = family_module.Family;
const Allocator = std.mem.Allocator;
const ArenaAllocator = std.heap.ArenaAllocator;
const Prng = std.rand.DefaultPrng;
const AutoHashMapUnmanaged = std.AutoHashMapUnmanaged;
const ArrayListUnmanaged = std.ArrayListUnmanaged;
const logger = std.log.scoped(.ft);
const FamilyTree = struct {
ator: Allocator,
rand: Prng,
pk2person_info: AutoHashMapUnmanaged(PersonKey, PersonInfo) = .{},
fk2family: AutoHashMapUnmanaged(FamilyKey, Family) = .{},
pub const person_unregistered = @as(Person.Id, -1);
pub const family_unregistered = @as(Family.Id, -1);
pub const person_invalidated = @as(Person.Id, -2);
pub const family_invalidated = @as(Family.Id, -2);
pub const max_pid = switch (@typeInfo(Person.Id).Int.signedness) {
.signed => ~@bitReverse(Person.Id, 1),
.unsigned => @compileError("wrong understanding of Person.Id as signed int"),
};
pub const min_pid = @as(Person.Id, 0);
pub const max_fid = switch (@typeInfo(Family.Id).Int.signedness) {
.signed => ~@bitReverse(Family.Id, 1),
.unsigned => @compileError("wrong understanding of Family.Id as signed int"),
};
pub const min_fid = @as(Family.Id, 0);
pub const max_pkgen_iter = ~@as(u8, 0);
pub const max_fkgen_iter = ~@as(u8, 0);
pub const PersonKey = switch (Person.Id == i64) {
true => u32,
false => @compileError("wrong understanding of Person.Id as i64"),
};
pub const FamilyKey = switch (Family.Id == i64) {
true => u32,
false => @compileError("wrong understanding of Family.Id as i64"),
};
pub const PersonInfo = struct {
person: Person,
fo_connections: FOConnections = .{},
pub const FOConnections = struct {
// blood
father_key: ?PersonKey = null,
mother_key: ?PersonKey = null,
mit_mother_key: ?PersonKey = null,
children: ArrayListUnmanaged(PersonKey) = .{},
// social
families: ArrayListUnmanaged(FamilyKey) = .{},
pub fn deinit(this: *FOConnections, ator: Allocator) void {
this.families.deinit(ator);
this.children.deinit(ator);
}
pub fn hasChild(self: FOConnections, candidate: PersonKey) bool {
for (self.children.items) |child_key| {
if (child_key == candidate)
return true;
}
return false;
}
pub fn hasFamily(self: FOConnections, candidate: FamilyKey) bool {
for (self.families.items) |family_key| {
if (family_key == candidate)
return true;
}
return false;
}
pub fn addChild(this: *FOConnections, child: PersonKey, ator: Allocator) !bool {
if (!this.hasChild(child)) {
try this.children.append(ator, child);
return true;
}
return false;
}
pub fn addFamily(this: *FOConnections, family: FamilyKey, ator: Allocator) !bool {
if (!this.hasFamily(family)) {
try this.families.append(ator, family);
return true;
}
return false;
}
pub const ParentEnum = enum {
father, mother, mit_mother,
pub fn asText(comptime self: ParentEnum) switch (self) {
.father => @TypeOf("father"),
.mother => @TypeOf("mother"),
.mit_mother => @TypeOf("mit_mother"),
} {
return switch (self) {
.father => "father",
.mother => "mother",
.mit_mother => "mit_mother",
};
}
};
pub const ListConnEnum = enum {
children, families,
pub fn asText(comptime self: ListConnEnum) switch (self) {
.children => @TypeOf("children"),
.families => @TypeOf("families"),
} {
return switch (self) {
.children => "children",
.families => "families",
};
}
};
};
pub fn deinit(this: *PersonInfo, ator: Allocator) void {
this.fo_connections.deinit(ator);
this.person.deinit(ator);
}
}; // FOConnections
pub const Error = error {
person_not_unregistered, family_not_unregistered,
person_already_registered, family_already_registered,
person_negative_id, family_negative_id,
person_not_registered, family_not_registered,
person_key_overfull, family_key_overfull,
OutOfMemory,
// I don't know if this is clever
// this is for callbacks
UserDefinedError1, UserDefinedError2, UserDefinedError3,
UserDefinedError4, UserDefinedError5, UserDefinedError6,
UserDefinedError7, UserDefinedError8, UserDefinedError9,
};
pub const Settings = struct {
seed: ?u64 = null,
};
pub fn init(
ator: Allocator,
comptime settings: Settings,
) if (settings.seed) |_| FamilyTree else std.os.OpenError!FamilyTree {
var prng = if (settings.seed) |seed| Prng.init(seed)
else
Prng.init(blk: {
var seed: u64 = undefined;
try std.os.getrandom(std.mem.asBytes(&seed));
break :blk seed;
})
;
return FamilyTree{.ator=ator, .rand=prng};
}
pub fn deinit(this: *FamilyTree) void {
var f_it = this.fk2family.valueIterator();
while (f_it.next()) |f_ptr| {
f_ptr.deinit(this.ator);
}
this.fk2family.deinit(this.ator);
var pi_it = this.pk2person_info.valueIterator();
while (pi_it.next()) |pi_ptr| {
pi_ptr.deinit(this.ator);
}
this.pk2person_info.deinit(this.ator);
}
pub fn randPersonKey(this: *FamilyTree) PersonKey {
return this.rand.random().int(PersonKey);
}
pub fn randFamilyKey(this: *FamilyTree) FamilyKey {
return this.rand.random().int(FamilyKey);
}
pub fn personKeyIsFree(self: FamilyTree, pk: PersonKey) bool {
return !self.pk2person_info.contains(pk);
}
pub fn familyKeyIsFree(self: FamilyTree, fk: FamilyKey) bool {
return !self.fk2family.contains(fk);
}
pub fn personKeyIsRegistered(self: FamilyTree, pk: PersonKey) bool {
return self.pk2person.contains(pk);
}
pub fn familyKeyIsRegistered(self: FamilyTree, fk: FamilyKey) bool {
return self.fk2family.contains(fk);
}
pub fn genPersonKey(this: *FamilyTree) !PersonKey {
var res: PersonKey = this.randPersonKey();
var counter: @TypeOf(max_pkgen_iter) = 0;
while (!this.personKeyIsFree(res) and counter < max_pkgen_iter) :
({res = this.randPersonKey(); counter += 1;})
{}
if (!this.personKeyIsFree(res)) {
logger.err("in FamilyTree.genPersonKey() reached max_pkgen_iter", .{});
return Error.person_key_overfull;
}
return res;
}
pub fn genFamilyKey(this: *FamilyTree) !FamilyKey {
var res: FamilyKey = this.randFamilyKey();
var counter: @TypeOf(max_fkgen_iter) = 0;
while (!this.familyKeyIsFree(res) and counter < max_fkgen_iter) :
({res = this.randFamilyKey(); counter += 1;})
{}
if (!this.familyKeyIsFree(res)) {
logger.err("in FamilyTree.genFamilyKey() reached max_fkgen_iter", .{});
return Error.family_key_overfull;
}
return res;
}
pub fn registerPerson(this: *FamilyTree, person: *Person) !PersonKey {
if (person.id < 0) { // need to generate new person key
if (person.id != person_unregistered) {
logger.err(
"in FamilyTree.registerPerson()" ++
" person w/ id={d} is not unregistered"
, .{person.id}
);
return Error.person_not_unregistered;
}
const key = try this.genPersonKey();
person.id = key;
try this.pk2person_info.putNoClobber(this.ator, key, .{.person=person.*});
person.* = Person{.id=person_invalidated};
return key;
} else { // register using person id as person key
if (this.pk2person_info.contains(@intCast(PersonKey, person.id))) {
logger.err(
"in FamilyTree.registerPerson()" ++
" person w/ id={d} is already registered"
, .{person.id}
);
return Error.person_already_registered;
}
const key = @intCast(PersonKey, person.id);
try this.pk2person_info.putNoClobber(this.ator, key, .{.person=person.*});
person.* = Person{.id=person_invalidated};
return key;
}
}
pub fn registerFamily(this: *FamilyTree, family: *Family) !FamilyKey {
if (family.id < 0) { // need to generate new family key
if (family.id != family_unregistered) {
logger.err(
"in FamilyTree.registerFamily()" ++
" family w/ id={d} is not unregistered"
, .{family.id}
);
return Error.family_not_unregistered;
}
const key = try this.genFamilyKey();
family.id = key;
try this.fk2family.putNoClobber(this.ator, key, family.*);
family.* = Family{.id=family_invalidated};
return key;
} else { // register using family id as family key
if (this.fk2family.contains(@intCast(FamilyKey, family.id))) {
logger.err(
"in FamilyTree.registerFamily()" ++
" family w/ id={d} is already registered"
, .{family.id}
);
return Error.family_already_registered;
}
const key = @intCast(FamilyKey, family.id);
try this.fk2family.putNoClobber(this.ator, key, family.*);
family.* = Family{.id=family_invalidated};
return key;
}
}
pub fn createPerson(this: *FamilyTree) !PersonKey {
const key = try this.genPersonKey();
var p = Person{.id=key};
return try this.registerPerson(&p);
}
pub fn createFamily(this: *FamilyTree) !FamilyKey {
const key = try this.genFamilyKey();
var f = Family{.id=key};
return try this.registerFamily(&f);
}
pub fn createPersonPtr(this: *FamilyTree) !*Person {
const key = try this.createPerson();
return this.getPersonPtr(key).?;
}
pub fn createPersonInfoPtr(this: *FamilyTree) !*PersonInfo {
const key = try this.createPerson();
return this.getPersonInfoPtr(key).?;
}
pub fn createFamilyPtr(this: *FamilyTree) !*Family {
const key = try this.createFamily();
return this.getFamilyPtr(key).?;
}
pub fn getPersonPtr(this: *FamilyTree, key: PersonKey) ?*Person {
const info_ptr = this.getPersonInfoPtr(key);
return if (info_ptr) |ip| {
&ip.person;
} else {
null;
};
}
pub fn getPersonInfoPtr(this: *FamilyTree, key: PersonKey) ?*PersonInfo {
return this.pk2person_info.getPtr(key);
}
pub fn getFamilyPtr(this: *FamilyTree, key: FamilyKey) ?*Family {
return this.fk2family.getPtr(key);
}
pub fn visitFamilies(
this: *FamilyTree,
visitor: anytype,
userdata: anytype,
) !void {
var f_it = this.fk2family.valueIterator();
while (f_it.next()) |f_ptr| {
if (!try visitor(f_ptr, userdata))
break;
}
}
pub fn visitPeople(
this: *FamilyTree,
visitor: anytype,
userdata: anytype,
) !void {
var pi_it = this.pk2person_info.valueIterator();
while (pi_it.next()) |pi_ptr| {
if (!try visitor(pi_ptr, userdata))
break;
}
}
fn danglingPeopleFamilyShallowVisitor(
family: *Family,
userdata: struct {
tree: *FamilyTree,
found_dangling: *bool,
},
) !bool {
const tree = userdata.tree;
const found_dangling = userdata.found_dangling;
inline for (.{Family.ParentEnum.father, Family.ParentEnum.mother}) |pe| {
if (switch (pe) {
.father => family.father_id,
.mother => family.mother_id,
}) |parent_id| {
if (parent_id < 0) {
logger.err(
"in FamilyTree.danglingPeopleFamilyShallowVisitor()" ++
" encountered negative {s} id={d}"
, .{pe.asText(), parent_id}
);
return Error.person_negative_id;
}
if (tree.personKeyIsFree(@intCast(PersonKey, parent_id))) {
found_dangling.* = true;
return false; // breaks loop in visitFamilies()
}
}
}
for (family.children_ids.data.items) |child_id| {
if (child_id < 0) {
logger.err(
"in FamilyTree.danglingPeopleFamilyShallowVisitor()" ++
" encountered negative child id={d}"
, .{child_id}
);
return Error.person_negative_id;
}
if (tree.personKeyIsFree(@intCast(PersonKey, child_id))) {
found_dangling.* = true;
return false; // breaks loop in visitFamilies()
}
}
found_dangling.* = false;
return true; // continues loop in visitFamilies()
}
pub fn hasNoDanglingPersonKeysFamiliesShallow(this: *FamilyTree) !bool {
// this is probably not very efficient due to duplicate checks
var found_dangling = false;
const visitor_data = .{.tree=this, .found_dangling=&found_dangling};
try this.visitFamilies(danglingPeopleFamilyShallowVisitor, visitor_data);
return !found_dangling;
}
fn danglingPeoplePersonShallowVisitor(
person_info: *PersonInfo,
userdata: struct {
tree: *FamilyTree,
found_dangling: *bool,
},
) !bool { // never actually errors
const tree = userdata.tree;
const found_dangling = userdata.found_dangling;
const fo_connections = person_info.fo_connections;
inline for (.{
PersonInfo.FOConnections.ParentEnum.father,
PersonInfo.FOConnections.ParentEnum.mother,
PersonInfo.FOConnections.ParentEnum.mit_mother,
}) |pe| {
if (switch (pe) {
.father => fo_connections.father_key,
.mother => fo_connections.mother_key,
.mit_mother => fo_connections.mit_mother_key,
}) |pk| {
if (tree.personKeyIsFree(pk)) {
found_dangling.* = true;
return false; // breaks loop in visitPeople()
}
}
}
for (fo_connections.children.items) |child_key| {
if (tree.personKeyIsFree(child_key)) {
found_dangling.* = true;
return false; // breaks loop in visitPeople()
}
}
return true; // continues loop in visitPeople()
}
pub fn hasNoDanglingPersonKeysPeopleShallow(this: *FamilyTree) !bool {
// this is probably not very efficient due to duplicate checks
var found_dangling = false;
const visitor_data = .{.tree=this, .found_dangling=&found_dangling};
try this.visitPeople(danglingPeoplePersonShallowVisitor, visitor_data);
return !found_dangling;
}
fn danglingFamiliesPersonShallowVisitor(
person_info: *PersonInfo,
userdata: struct {
tree: *FamilyTree,
found_dangling: *bool,
},
) !bool {
const tree = userdata.tree;
const found_dangling = userdata.found_dangling;
const fo_connections = person_info.fo_connections;
for (fo_connections.families.items) |family_key| {
if (tree.familyKeyIsFree(family_key)) {
found_dangling.* = true;
return false; // breaks loop in visitPeople()
}
}
return true; // continues loop in visitPeople()
}
pub fn hasNoDanglingFamilyKeysPeopleShallow(this: *FamilyTree) !bool {
var found_dangling = false;
const visitor_data = .{.tree=this, .found_dangling=&found_dangling};
try this.visitPeople(danglingFamiliesPersonShallowVisitor, visitor_data);
return !found_dangling;
}
fn assignPersonInfoFamiliesFamilyShallowVisitor(
family: *Family,
userdata: struct {
tree: *FamilyTree,
},
) !bool { // does no checks
const tree = userdata.tree;
inline for (.{.father, .mother}) |pe| {
if (switch (pe) {
.father => family.father_id,
.mother => family.mother_id,
else => @compileError(
"nonexhaustive switch on ParentEnum in" ++
" assignPersonInfoFamiliesFamilyShallowVisitor()"
),
}) |pid| {
const person_info_ptr = tree.getPersonInfoPtr(@intCast(PersonKey, pid)).?;
const fo_connections_ptr = &person_info_ptr.fo_connections;
_ = try fo_connections_ptr.addFamily(
@intCast(FamilyKey, family.id),
tree.ator,
);
}
}
for (family.children_ids.data.items) |child_id| {
const person_info_ptr = tree.getPersonInfoPtr(@intCast(PersonKey, child_id)).?;
const fo_connections_ptr = &person_info_ptr.fo_connections;
_ = try fo_connections_ptr.addFamily(
@intCast(FamilyKey, family.id),
tree.ator,
);
}
return true; // continues loop in visitFamilies()
}
pub fn assignPeopleTheirFamilies(this: *FamilyTree) !void {
try this.visitFamilies(assignPersonInfoFamiliesFamilyShallowVisitor, .{.tree=this});
}
fn assignPeopleInfoChildrenPersonShallowVisitor(
person_info: *PersonInfo,
userdata: struct {
tree: *FamilyTree,
},
) !bool {
const tree = userdata.tree;
const fo_connections = person_info.fo_connections;
if (fo_connections.father_key) |fak| {
const father_info_ptr = tree.getPersonInfoPtr(fak).?;
const fo_connections_ptr = &father_info_ptr.fo_connections;
_ = try fo_connections_ptr.addChild(
@intCast(PersonKey, person_info.person.id),
tree.ator,
);
}
if (fo_connections.mother_key) |fak| {
const mother_info_ptr = tree.getPersonInfoPtr(fak).?;
const fo_connections_ptr = &mother_info_ptr.fo_connections;
_ = try fo_connections_ptr.addChild(
@intCast(PersonKey, person_info.person.id),
tree.ator,
);
}
return true; // continues loop in visitPeople()
}
pub fn assignPeopleTheirChildren(this: *FamilyTree) !void {
try this.visitPeople(assignPeopleInfoChildrenPersonShallowVisitor, .{.tree=this});
}
pub fn buildConnections(this: *FamilyTree) !void {
if (!try this.hasNoDanglingPersonKeysFamiliesShallow()) {
logger.err(
"in FamilyTree.buildConnections() family stores dangling person key"
, .{}
);
return Error.person_not_registered;
}
if (!try this.hasNoDanglingPersonKeysPeopleShallow()) {
logger.err(
"in FamilyTree.buildConnections() person stores dangling person key"
, .{}
);
return Error.person_not_registered;
}
if (!try this.hasNoDanglingFamilyKeysPeopleShallow()) {
logger.err(
"in FamilyTree.buildConnections() person stores dangling family key"
, .{}
);
return Error.family_not_registered;
}
try this.assignPeopleTheirFamilies();
try this.assignPeopleTheirChildren();
}
pub const FromJsonError = error { bad_type, bad_field, };
pub fn readFromJson(
this: *FamilyTree,
json_tree: *json.Value,
comptime options: JsonReadOptions,
) !void {
options.AOCheck();
logger.debug("FamilyTree.readFromJson() w/ options={s}", .{options.str_mgmt.asText()});
switch (json_tree.*) {
json.Value.Object => |jtmap| {
inline for (.{.people, .families}) |pfe| {
const pfs = switch (pfe) {
.people => "people",
.families => "families",
else => @compileError("nonexhaustive switch on people-families enum"),
};
if (jtmap.get(pfs)) |*payload| {
try this.readPayloadFromJson(payload, pfe, options);
}
}
},
else => {
logger.err(
"in FamilyTree.readFromJson() j_tree is not of type {s}"
, .{"json.ObjectMap"},
);
return FromJsonError.bad_type;
},
}
try this.buildConnections();
}
pub fn readPayloadFromJson(
this: *FamilyTree,
json_payload: *json.Value,
comptime which: @TypeOf(.enum_literal),//enum {people, families},
comptime options: JsonReadOptions,
) !void {
options.AOCheck();
switch (json_payload.*) {
json.Value.Array => |parr| {
switch (which) {
.people => {
for (parr.items) |*jperson| {
var person = Person{.id=person_invalidated};
if (options.use_ator) {
try person.readFromJson(
jperson,
this.ator,
options.str_mgmt.asEnumLiteral(),
);
} else {
try person.readFromJson(
jperson,
null,
options.str_mgmt.asEnumLiteral(),
);
}
errdefer {
if (options.use_ator)
switch (options.str_mgmt) {
.weak => {},
else => {
person.deinit(this.ator);
},
};
}
const pk = try this.registerPerson(&person);
logger.debug("FamilyTree: registering person with id {}", .{person.id});
var pinfo_ptr = this.getPersonInfoPtr(pk).?;
switch (jperson.*) {
json.Value.Object => |jpmap| {
inline for (.{.father, .mother, .mit_mother}) |fme| {
const fmks = switch (fme) {
.father => "father_key",
.mother => "mother_key",
.mit_mother => "mit_mother_key",
else => @compileError("nonexhaustive switch on father-(mit)mother enum"),
};
if (jpmap.get(fmks)) |jfm| {
switch (jfm) {
json.Value.Integer => |jfmi| {
if (jfmi > max_pid or jfmi < min_pid) {
logger.err(
"in FamilyTree.readPayloadFromJson()" ++
" j_parent_key is out of bounds"
, .{},
);
return FromJsonError.bad_field;
}
@field(pinfo_ptr.fo_connections, fmks) = @intCast(PersonKey, jfmi);
},
json.Value.Null => {
@field(pinfo_ptr.fo_connections, fmks) = null;
},
else => {
logger.err(
"in FamilyTree.readPayloadFromJson()" ++
" j_parent_key is not of type {s}"
, .{"json.Int"}
);
return FromJsonError.bad_type;
},
}
}
}
},
else => {},
}
}
},
.families => {
for (parr.items) |jfamily| {
var family = Family{.id=family_invalidated};
try family.readFromJson(
jfamily,
if (options.use_ator) this.ator else null,
);
errdefer {
if (options.use_ator)
switch (options.str_mgmt) {
.weak => {},
else => {
family.deinit(this.ator);
},
};
}
_ = try this.registerFamily(&family);
}
},
else => {
@compileError("bruh");
},
}
},
else => {
logger.err(
"in FamilyTree.readPeopleFromJson() j_people is not of type {s}"
, .{"json.ObjectMap"},
);
return FromJsonError.bad_type;
}
}
}
pub fn readFromJsonSourceStr(
this: *FamilyTree,
source_str: []const u8,
comptime options: JsonReadOptions,
) !void {
// TODO should only .copy be allowed???
var parser = json.Parser.init(this.ator, false); // strings are copied in readFromJson
defer parser.deinit();
var tree = try parser.parse(source_str);
defer tree.deinit();
try this.readFromJson(&tree.root, options);
}
pub const JsonReadOptions = struct {
str_mgmt: StrMgmt = .copy,
use_ator: bool = true,
fn AOCheck(comptime self: JsonReadOptions) void {
switch (self.str_mgmt) {
.copy => {
if (!self.use_ator)
@compileError("FamilyTree: can't copy w\\o allocator");
},
.move, .weak => {},
}
}
};
pub fn toJson(
self: FamilyTree,
_ator: Allocator,
comptime settings: util.ToJsonSettings,
) util.ToJsonError!util.ToJsonResult {
// TODO make 2 if's 1
var res = util.ToJsonResult{
.value = undefined,
.arena = if (settings.apply_arena) ArenaAllocator.init(_ator) else null,
};
errdefer res.deinit();
const ator = if (res.arena) |*arena| arena.allocator() else _ator;
res.value = .{.Object = json.ObjectMap.init(ator)};
const settings_to_pass = util.ToJsonSettings{
.allow_overload=true,
.apply_arena=false,
};
var people_array = json.Value{.Array = json.Array.init(ator)};
try people_array.Array.ensureUnusedCapacity(self.pk2person_info.count());
var piter = self.pk2person_info.valueIterator();
while (piter.next()) |person_info| {
var person_json = (try person_info.person.toJson(ator, settings_to_pass)).value;
inline for (.{"father_key", "mother_key", "mit_mother_key"}) |ancestor_key| {
try person_json.Object.ensureUnusedCapacity(3); // DANGER
person_json.Object.putAssumeCapacity(
ancestor_key,
(try util.toJson(
@field(person_info.fo_connections, ancestor_key),
ator,
settings_to_pass,
)).value,
);
}
people_array.Array.appendAssumeCapacity(person_json);
}
var families_array = json.Value{.Array = json.Array.init(ator)};
try families_array.Array.ensureUnusedCapacity(self.fk2family.count());
var fiter = self.fk2family.valueIterator();
while (fiter.next()) |family| {
families_array.Array.appendAssumeCapacity(
(try family.toJson(ator, settings_to_pass)).value
);
}
try res.value.Object.put("people", people_array);
try res.value.Object.put("families", families_array);
return res;
}
pub fn personCount(self: FamilyTree) usize {
return self.pk2person_info.count();
}
pub fn familyCount(self: FamilyTree) usize {
return self.fk2family.count();
}
pub fn equal(
self: FamilyTree,
other: FamilyTree,
comptime settings: util.EqualSettings
) bool {
_ = settings;
var lpiter = self.pk2person_info.iterator();
if (self.personCount() != other.personCount()) {
return false;
}
while (lpiter.next()) |lentry| {
if (other.pk2person_info.get(lentry.key_ptr.*)) |rinfo| {
if (!util.equal(lentry.value_ptr.*, rinfo, .{})) {
return false;
}
} else {
return false;
}
}
var lfiter = self.fk2family.iterator();
if (self.familyCount() != other.familyCount()) {
return false;
}
while (lfiter.next()) |lentry| {
if (other.fk2family.get(lentry.key_ptr.*)) |rval| {
if (!util.equal(lentry.value_ptr.*, rval, .{})) {
return false;
}
} else {
return false;
}
}
return true;
}
}; // FamilyTree
pub const StrMgmt = enum {
copy, move, weak,
pub fn asText(comptime options: StrMgmt) switch (options) {
.copy => @TypeOf("copy"),
.move => @TypeOf("move"),
.weak => @TypeOf("weak"),
} {
return switch (options) {
.copy => "copy",
.move => "move",
.weak => "weak",
};
}
pub fn asEnumLiteral(comptime options: StrMgmt) @TypeOf(.enum_literal) {
return switch (options) {
.copy => .copy,
.move => .move,
.weak => .weak,
};
}
};
const testing = std.testing;
const tator = testing.allocator;
const expect = testing.expect;
const expectError = testing.expectError;
const expectEqual = testing.expectEqual;
test "register" {
var ft = FamilyTree.init(tator, .{.seed=0});
defer ft.deinit();
var up = Person{.id=-1};
const pk = try ft.registerPerson(&up);
try expectEqual(up.id, -2);
var uf = Family{.id=-1};
const fk = try ft.registerFamily(&uf);
try expectEqual(uf.id, -2);
try expectError(anyerror.person_not_unregistered, ft.registerPerson(&up));
try expectError(anyerror.family_not_unregistered, ft.registerFamily(&uf));
const rpk = try ft.genPersonKey();
var rp = Person{.id=rpk};
try expectEqual(rpk, try ft.registerPerson(&rp));
try expectEqual(rp.id, -2);
const rfk = try ft.genFamilyKey();
var rf = Family{.id=rfk};
try expectEqual(rfk, try ft.registerFamily(&rf));
try expectEqual(rf.id, -2);
up = Person{.id=pk};
uf = Family{.id=fk};
rp = Person{.id=rpk};
rf = Family{.id=rfk};
try expectError(anyerror.person_already_registered, ft.registerPerson(&up));
try expectError(anyerror.person_already_registered, ft.registerPerson(&rp));
try expectError(anyerror.family_already_registered, ft.registerFamily(&uf));
try expectError(anyerror.family_already_registered, ft.registerFamily(&rf));
}
test "dangling people" {
var ft = FamilyTree.init(tator, .{.seed=0});
defer ft.deinit();
var c: u32 = 0;
while (c < 32) : (c+=1) { // create 32 people w/ ids < 64
var key = try ft.genPersonKey();
while (!ft.personKeyIsFree(key % 64)) {
key = try ft.genPersonKey();
}
var p = Person{.id=key%64};
_ = try ft.registerPerson(&p);
}
while (c < 16) : (c+=1) { // create 16 random families
var fkey = ft.rand.random().int(u6);
var mkey = ft.rand.random().int(u6);
var c1key = ft.rand.random().int(u6);
var c2key = ft.rand.random().int(u6);
var c3key = ft.rand.random().int(u6);
inline for (.{.f, .m, .c1, .c2, .c3}) |pe| {
var k_ptr = switch (pe) {
.f => &fkey, .m => &mkey, .c1 => &c1key, .c2 => &c2key, .c3 => &c3key, else => @compileError("bruh"),
};
while (ft.personKeyIsFree(k_ptr.*)) {
k_ptr.* = ft.rand.random().int(u6);
}
}
var f = Family{.id=-1, .father_id=fkey, .mother_id=mkey};
errdefer f.deinit(tator);
// try f.children_ids.data.ensureUnusedCapacity(tator, 3);
try f.addChild(c1key, tator);
try f.addChild(c2key, tator);
try f.addChild(c3key, tator);
_ = try ft.registerFamily(&f);
}
try expect(try ft.hasNoDanglingPersonKeysFamiliesShallow());
try expect(try ft.hasNoDanglingPersonKeysPeopleShallow());
try expect(try ft.hasNoDanglingFamilyKeysPeopleShallow());
var f = Family{.id=-1, .father_id=try ft.genPersonKey()};
_ = try ft.registerFamily(&f);
try expect(!try ft.hasNoDanglingPersonKeysFamiliesShallow());
var pk = ft.rand.random().int(u6);
while (ft.personKeyIsFree(pk)) {
pk = ft.rand.random().int(u6);
}
const person_info_ptr = ft.getPersonInfoPtr(pk).?;
person_info_ptr.fo_connections.father_key = try ft.genPersonKey();
try expect(!try ft.hasNoDanglingPersonKeysPeopleShallow());
try person_info_ptr.fo_connections.families.append(tator, try ft.genFamilyKey());
try expect(!try ft.hasNoDanglingFamilyKeysPeopleShallow());
}
test "assign people, families" {
var tree = FamilyTree.init(tator, .{.seed=0});
defer tree.deinit();
const fk: FamilyTree.PersonKey = 1;
const mk: FamilyTree.PersonKey = 2;
const c1k: FamilyTree.PersonKey = 3;
const c2k: FamilyTree.PersonKey = 4;
const c3k: FamilyTree.PersonKey = 5;
var f = Person{.id=fk};
var m = Person{.id=mk};
try expectEqual(fk, try tree.registerPerson(&f));
try expectEqual(mk, try tree.registerPerson(&m));
var c1 = Person{.id=c1k};
var c2 = Person{.id=c2k};
var c3 = Person{.id=c3k};
try expectEqual(c1k, try tree.registerPerson(&c1));
try expectEqual(c2k, try tree.registerPerson(&c2));
try expectEqual(c3k, try tree.registerPerson(&c3));
const fip = tree.getPersonInfoPtr(fk).?;
const mip = tree.getPersonInfoPtr(mk).?;
const c1ip = tree.getPersonInfoPtr(c1k).?;
c1ip.fo_connections.father_key = fk;
c1ip.fo_connections.mother_key = mk;
const c2ip = tree.getPersonInfoPtr(c2k).?;
c2ip.fo_connections.father_key = fk;
c2ip.fo_connections.mother_key = mk;
const c3ip = tree.getPersonInfoPtr(c3k).?;
c3ip.fo_connections.father_key = fk;
c3ip.fo_connections.mother_key = mk;
try expect(!fip.fo_connections.hasChild(c1k));
try expect(!fip.fo_connections.hasChild(c2k));
try expect(!fip.fo_connections.hasChild(c3k));
try expect(!mip.fo_connections.hasChild(c1k));
try expect(!mip.fo_connections.hasChild(c2k));
try expect(!mip.fo_connections.hasChild(c3k));
try tree.assignPeopleTheirChildren();
try expect(fip.fo_connections.hasChild(c1k));
try expect(fip.fo_connections.hasChild(c2k));
try expect(fip.fo_connections.hasChild(c3k));
try expect(mip.fo_connections.hasChild(c1k));
try expect(mip.fo_connections.hasChild(c2k));
try expect(mip.fo_connections.hasChild(c3k));
const famk: FamilyTree.FamilyKey = 1;
var fam = Family{.id=famk, .father_id=fk, .mother_id=mk};
try fam.addChild(c1k, tator);
try fam.addChild(c2k, tator);
try fam.addChild(c3k, tator);
try expectEqual(famk, try tree.registerFamily(&fam));
const folks = [_]FamilyTree.PersonKey{fk, mk, c1k, c2k, c3k};
for (folks) |k| {
try expect(!tree.getPersonInfoPtr(k).?.fo_connections.hasFamily(famk));
}
try tree.assignPeopleTheirFamilies();
for (folks) |k| {
try expect(tree.getPersonInfoPtr(k).?.fo_connections.hasFamily(famk));
}
}
test "build connections" {
var tree = FamilyTree.init(tator, .{.seed=0});
defer tree.deinit();
const fk: FamilyTree.PersonKey = 1;
const mk: FamilyTree.PersonKey = 2;
const c1k: FamilyTree.PersonKey = 3;
const c2k: FamilyTree.PersonKey = 4;
const c3k: FamilyTree.PersonKey = 5;
var f = Person{.id=fk};
var m = Person{.id=mk};
try expectEqual(fk, try tree.registerPerson(&f));
try expectEqual(mk, try tree.registerPerson(&m));
var c1 = Person{.id=c1k};
var c2 = Person{.id=c2k};
var c3 = Person{.id=c3k};
try expectEqual(c1k, try tree.registerPerson(&c1));
try expectEqual(c2k, try tree.registerPerson(&c2));
try expectEqual(c3k, try tree.registerPerson(&c3));
const fip = tree.getPersonInfoPtr(fk).?;
const mip = tree.getPersonInfoPtr(mk).?;
const c1ip = tree.getPersonInfoPtr(c1k).?;
c1ip.fo_connections.father_key = fk;
c1ip.fo_connections.mother_key = mk;
const c2ip = tree.getPersonInfoPtr(c2k).?;
c2ip.fo_connections.father_key = fk;
c2ip.fo_connections.mother_key = mk;
const c3ip = tree.getPersonInfoPtr(c3k).?;
c3ip.fo_connections.father_key = fk;
c3ip.fo_connections.mother_key = mk;
const famk: FamilyTree.FamilyKey = 1;
var fam = Family{.id=famk, .father_id=fk, .mother_id=mk};
try fam.addChild(c1k, tator);
try fam.addChild(c2k, tator);
try fam.addChild(c3k, tator);
try expectEqual(famk, try tree.registerFamily(&fam));
const folks = [_]FamilyTree.PersonKey{fk, mk, c1k, c2k, c3k};
try expect(!fip.fo_connections.hasChild(c1k));
try expect(!fip.fo_connections.hasChild(c2k));
try expect(!fip.fo_connections.hasChild(c3k));
try expect(!mip.fo_connections.hasChild(c1k));
try expect(!mip.fo_connections.hasChild(c2k));
try expect(!mip.fo_connections.hasChild(c3k));
for (folks) |k| {
try expect(!tree.getPersonInfoPtr(k).?.fo_connections.hasFamily(famk));
}
try tree.buildConnections();
try expect(fip.fo_connections.hasChild(c1k));
try expect(fip.fo_connections.hasChild(c2k));
try expect(fip.fo_connections.hasChild(c3k));
try expect(mip.fo_connections.hasChild(c1k));
try expect(mip.fo_connections.hasChild(c2k));
try expect(mip.fo_connections.hasChild(c3k));
for (folks) |k| {
try expect(tree.getPersonInfoPtr(k).?.fo_connections.hasFamily(famk));
}
const fam_ptr = tree.getFamilyPtr(famk).?;
try fam_ptr.addChild(6, tator);
try expectError(anyerror.person_not_registered, tree.buildConnections());
_ = fam_ptr.children_ids.data.pop();
try tree.buildConnections();
fip.fo_connections.father_key = 6;
try expectError(anyerror.person_not_registered, tree.buildConnections());
fip.fo_connections.father_key = null;
try tree.buildConnections();
try expect(try fip.fo_connections.addFamily(2, tator));
try expectError(anyerror.family_not_registered, tree.buildConnections());
_ = fip.fo_connections.families.pop();
try tree.buildConnections();
}
const healthy_family_src =
\\{
\\ "people": [
\\ {"id": 1, "name": "father"},
\\ {"id": 2, "name": "son", "father_key": 1},
\\ {"id": 3, "name": "adopted"},
\\ {"id": 4, "name": "bastard", "father_key": 1}
\\ ],
\\ "families": [
\\ {"id": 1, "father_id": 1, "children_ids": [2, 3]}
\\ ]
\\}
;
test "read from json" {
var ft = FamilyTree.init(tator, .{.seed=0});
defer ft.deinit();
try ft.readFromJsonSourceStr(healthy_family_src, .{});
const father_info = ft.getPersonInfoPtr(1).?;
const son_info = ft.getPersonInfoPtr(2).?;
const adopted_info = ft.getPersonInfoPtr(3).?;
const bastard_info = ft.getPersonInfoPtr(4).?;
try expectEqual(father_info.person.id, 1);
try expectEqual(son_info.person.id, 2);
try expectEqual(adopted_info.person.id, 3);
try expectEqual(bastard_info.person.id, 4);
try expectEqual(son_info.fo_connections.father_key, 1);
try expectEqual(adopted_info.fo_connections.father_key, null);
try expectEqual(bastard_info.fo_connections.father_key, 1);
try expect(father_info.fo_connections.hasChild(2));
try expect(!father_info.fo_connections.hasChild(3));
try expect(father_info.fo_connections.hasChild(4));
const family = ft.getFamilyPtr(1).?;
try expectEqual(family.father_id, 1);
try expect(family.hasChild(2));
try expect(family.hasChild(3));
try expect(!family.hasChild(4));
}
test "to json" {
var ft = FamilyTree.init(tator, .{.seed=0});
defer ft.deinit();
try ft.readFromJsonSourceStr(healthy_family_src, .{});
var jft = try ft.toJson(tator, .{});
defer jft.deinit();
var tf = FamilyTree.init(tator, .{.seed=0});
defer tf.deinit();
try tf.readFromJson(&jft.value, .{});
try expect(util.equal(ft, tf, .{}));
} | src/family_tree.zig |
const std = @import("../std.zig");
const math = std.math;
const expect = std.testing.expect;
const maxInt = std.math.maxInt;
/// Returns whether x is an infinity, ignoring sign.
pub fn isInf(x: var) bool {
const T = @typeOf(x);
switch (T) {
f16 => {
const bits = @bitCast(u16, x);
return bits & 0x7FFF == 0x7C00;
},
f32 => {
const bits = @bitCast(u32, x);
return bits & 0x7FFFFFFF == 0x7F800000;
},
f64 => {
const bits = @bitCast(u64, x);
return bits & (maxInt(u64) >> 1) == (0x7FF << 52);
},
f128 => {
const bits = @bitCast(u128, x);
return bits & (maxInt(u128) >> 1) == (0x7FFF << 112);
},
else => {
@compileError("isInf not implemented for " ++ @typeName(T));
},
}
}
/// Returns whether x is an infinity with a positive sign.
pub fn isPositiveInf(x: var) bool {
const T = @typeOf(x);
switch (T) {
f16 => {
return @bitCast(u16, x) == 0x7C00;
},
f32 => {
return @bitCast(u32, x) == 0x7F800000;
},
f64 => {
return @bitCast(u64, x) == 0x7FF << 52;
},
f128 => {
return @bitCast(u128, x) == 0x7FFF << 112;
},
else => {
@compileError("isPositiveInf not implemented for " ++ @typeName(T));
},
}
}
/// Returns whether x is an infinity with a negative sign.
pub fn isNegativeInf(x: var) bool {
const T = @typeOf(x);
switch (T) {
f16 => {
return @bitCast(u16, x) == 0xFC00;
},
f32 => {
return @bitCast(u32, x) == 0xFF800000;
},
f64 => {
return @bitCast(u64, x) == 0xFFF << 52;
},
f128 => {
return @bitCast(u128, x) == 0xFFFF << 112;
},
else => {
@compileError("isNegativeInf not implemented for " ++ @typeName(T));
},
}
}
test "math.isInf" {
expect(!isInf(@as(f16, 0.0)));
expect(!isInf(@as(f16, -0.0)));
expect(!isInf(@as(f32, 0.0)));
expect(!isInf(@as(f32, -0.0)));
expect(!isInf(@as(f64, 0.0)));
expect(!isInf(@as(f64, -0.0)));
expect(!isInf(@as(f128, 0.0)));
expect(!isInf(@as(f128, -0.0)));
expect(isInf(math.inf(f16)));
expect(isInf(-math.inf(f16)));
expect(isInf(math.inf(f32)));
expect(isInf(-math.inf(f32)));
expect(isInf(math.inf(f64)));
expect(isInf(-math.inf(f64)));
expect(isInf(math.inf(f128)));
expect(isInf(-math.inf(f128)));
}
test "math.isPositiveInf" {
expect(!isPositiveInf(@as(f16, 0.0)));
expect(!isPositiveInf(@as(f16, -0.0)));
expect(!isPositiveInf(@as(f32, 0.0)));
expect(!isPositiveInf(@as(f32, -0.0)));
expect(!isPositiveInf(@as(f64, 0.0)));
expect(!isPositiveInf(@as(f64, -0.0)));
expect(!isPositiveInf(@as(f128, 0.0)));
expect(!isPositiveInf(@as(f128, -0.0)));
expect(isPositiveInf(math.inf(f16)));
expect(!isPositiveInf(-math.inf(f16)));
expect(isPositiveInf(math.inf(f32)));
expect(!isPositiveInf(-math.inf(f32)));
expect(isPositiveInf(math.inf(f64)));
expect(!isPositiveInf(-math.inf(f64)));
expect(isPositiveInf(math.inf(f128)));
expect(!isPositiveInf(-math.inf(f128)));
}
test "math.isNegativeInf" {
expect(!isNegativeInf(@as(f16, 0.0)));
expect(!isNegativeInf(@as(f16, -0.0)));
expect(!isNegativeInf(@as(f32, 0.0)));
expect(!isNegativeInf(@as(f32, -0.0)));
expect(!isNegativeInf(@as(f64, 0.0)));
expect(!isNegativeInf(@as(f64, -0.0)));
expect(!isNegativeInf(@as(f128, 0.0)));
expect(!isNegativeInf(@as(f128, -0.0)));
expect(!isNegativeInf(math.inf(f16)));
expect(isNegativeInf(-math.inf(f16)));
expect(!isNegativeInf(math.inf(f32)));
expect(isNegativeInf(-math.inf(f32)));
expect(!isNegativeInf(math.inf(f64)));
expect(isNegativeInf(-math.inf(f64)));
expect(!isNegativeInf(math.inf(f128)));
expect(isNegativeInf(-math.inf(f128)));
} | lib/std/math/isinf.zig |
const std = @import("std");
const math = @import("zlm.zig");
const assert = std.debug.assert;
const vec2 = math.vec2;
const vec3 = math.vec3;
const vec4 = math.vec4;
const Vec2 = math.Vec2;
const Vec3 = math.Vec3;
const Vec4 = math.Vec4;
const Mat3 = math.Mat3;
const Mat4 = math.Mat4;
test "default generic is f32" {
const T = @TypeOf(vec2(1,2).x);
try std.testing.expectEqual(T, f32);
}
test "SpecializeOn()" {
const math_u64 = math.SpecializeOn(u64);
const T = @TypeOf(math_u64.vec2(3,4).x);
try std.testing.expectEqual(T, u64);
}
test "constructors" {
const v2 = vec2(1, 2);
assert(v2.x == 1);
assert(v2.y == 2);
const v3 = vec3(1, 2, 3);
assert(v3.x == 1);
assert(v3.y == 2);
assert(v3.z == 3);
const v4 = vec4(1, 2, 3, 4);
assert(v4.x == 1);
assert(v4.y == 2);
assert(v4.z == 3);
assert(v4.w == 4);
}
test "vec2 arithmetics" {
const a = vec2(2, 1);
const b = vec2(1, 2);
assert(std.meta.eql(Vec2.add(a, b), vec2(3, 3)));
assert(std.meta.eql(Vec2.sub(a, b), vec2(1, -1)));
assert(std.meta.eql(Vec2.mul(a, b), vec2(2, 2)));
assert(std.meta.eql(Vec2.div(a, b), vec2(2, 0.5)));
assert(std.meta.eql(Vec2.scale(a, 2.0), vec2(4, 2)));
assert(Vec2.dot(a, b) == 4.0);
assert(Vec2.length2(a) == 5.0);
assert(Vec2.length(a) == std.math.sqrt(5.0));
assert(Vec2.length(b) == std.math.sqrt(5.0));
}
test "vec3 arithmetics" {
const a = vec3(2, 1, 3);
const b = vec3(1, 2, 3);
assert(std.meta.eql(Vec3.add(a, b), vec3(3, 3, 6)));
assert(std.meta.eql(Vec3.sub(a, b), vec3(1, -1, 0)));
assert(std.meta.eql(Vec3.mul(a, b), vec3(2, 2, 9)));
assert(std.meta.eql(Vec3.div(a, b), vec3(2, 0.5, 1)));
assert(std.meta.eql(Vec3.scale(a, 2.0), vec3(4, 2, 6)));
assert(Vec3.dot(a, b) == 13.0);
assert(Vec3.length2(a) == 14.0);
assert(Vec3.length(a) == std.math.sqrt(14.0));
assert(Vec3.length(b) == std.math.sqrt(14.0));
assert(std.meta.eql(Vec3.cross(vec3(1, 2, 3), vec3(-7, 8, 9)), vec3(-6, -30, 22)));
}
test "vec4 arithmetics" {
const a = vec4(2, 1, 4, 3);
const b = vec4(1, 2, 3, 4);
assert(std.meta.eql(Vec4.add(a, b), vec4(3, 3, 7, 7)));
assert(std.meta.eql(Vec4.sub(a, b), vec4(1, -1, 1, -1)));
assert(std.meta.eql(Vec4.mul(a, b), vec4(2, 2, 12, 12)));
assert(std.meta.eql(Vec4.div(a, b), vec4(2, 0.5, 4.0 / 3.0, 3.0 / 4.0)));
assert(std.meta.eql(Vec4.scale(a, 2.0), vec4(4, 2, 8, 6)));
assert(Vec4.dot(a, b) == 28.0);
assert(Vec4.length2(a) == 30.0);
assert(Vec4.length(a) == std.math.sqrt(30.0));
assert(Vec4.length(b) == std.math.sqrt(30.0));
}
test "vec3 <-> vec4 interop" {
const v = vec3(1, 2, 3);
const pos = vec4(1, 2, 3, 1);
const dir = vec4(1, 2, 3, 0);
assert(std.meta.eql(Vec3.toAffinePosition(v), pos));
assert(std.meta.eql(Vec3.toAffineDirection(v), dir));
assert(std.meta.eql(Vec3.fromAffinePosition(pos), v));
assert(std.meta.eql(Vec3.fromAffineDirection(dir), v));
}
// TODO: write tests for mat2, mat3
// zig fmt: off
test "mat4 arithmetics" {
const id = Mat4.identity;
const mat = Mat4{
.fields = [4][4]f32{
// zig fmt: off
[4]f32{ 1, 2, 3, 4 },
[4]f32{ 5, 6, 7, 8 },
[4]f32{ 9, 10, 11, 12 },
[4]f32{ 13, 14, 15, 16 },
// zig-fmt: on
},
};
const mat_mult_by_mat_by_hand = Mat4{
.fields = [4][4]f32{
// zig fmt: off
[4]f32{ 90, 100, 110, 120 },
[4]f32{ 202, 228, 254, 280 },
[4]f32{ 314, 356, 398, 440 },
[4]f32{ 426, 484, 542, 600 },
// zig-fmt: on
},
};
const mat_transposed = Mat4{
.fields = [4][4]f32{
[4]f32{ 1, 5, 9, 13 },
[4]f32{ 2, 6, 10, 14 },
[4]f32{ 3, 7, 11, 15 },
[4]f32{ 4, 8, 12, 16 },
},
};
const mat_a = Mat4{
.fields = [4][4]f32{
[4]f32{ 1, 2, 3, 1 },
[4]f32{ 2, 3, 1, 2 },
[4]f32{ 3, 1, 2, 3 },
[4]f32{ 1, 2, 3, 1 },
},
};
const mat_b = Mat4{
.fields = [4][4]f32{
[4]f32{ 3, 2, 1, 3 },
[4]f32{ 2, 1, 3, 2 },
[4]f32{ 1, 3, 2, 1 },
[4]f32{ 3, 2, 1, 3 },
},
};
const mat_a_times_b = Mat4{
.fields = [4][4]f32{
[4]f32{ 13, 15, 14, 13 },
[4]f32{ 19, 14, 15, 19 },
[4]f32{ 22, 19, 13, 22 },
[4]f32{ 13, 15, 14, 13 },
},
};
const mat_b_times_a = Mat4{
.fields = [4][4]f32{
[4]f32{ 13, 19, 22, 13 },
[4]f32{ 15, 14, 19, 15 },
[4]f32{ 14, 15, 13, 14 },
[4]f32{ 13, 19, 22, 13 },
},
};
// make sure basic properties are not messed up
assert(std.meta.eql(Mat4.mul(id, id), id));
assert(std.meta.eql(Mat4.mul(mat, id), mat));
assert(std.meta.eql(Mat4.mul(id, mat), mat));
assert(std.meta.eql(Mat4.mul(mat, mat), mat_mult_by_mat_by_hand));
assert(std.meta.eql(Mat4.mul(mat_a, mat_b), mat_a_times_b));
assert(std.meta.eql(Mat4.mul(mat_b, mat_a), mat_b_times_a));
assert(std.meta.eql(Mat4.transpose(mat), mat_transposed));
}
// zig fmt: on
test "vec4 transform" {
const mat = Mat4{
.fields = [4][4]f32{
// zig fmt: off
[4]f32{ 1, 2, 3, 4 },
[4]f32{ 5, 6, 7, 8 },
[4]f32{ 9, 10, 11, 12 },
[4]f32{ 13, 14, 15, 16 },
// zig-fmt: on
},
};
const transform = Mat4{
.fields = [4][4]f32{
// zig fmt: off
[4]f32{ 2, 0, 0, 0 },
[4]f32{ 0, 2, 0, 0 },
[4]f32{ 0, 0, 2, 0 },
[4]f32{ 10, 20, 30, 1 },
// zig-fmt: on
},
};
const vec = vec4(1, 2, 3, 4);
assert(std.meta.eql(Vec4.transform(vec, mat), vec4(90, 100, 110, 120)));
assert(std.meta.eql(Vec4.transform(vec4(1, 2, 3, 1), transform), vec4(12, 24, 36, 1)));
assert(std.meta.eql(Vec4.transform(vec4(1, 2, 3, 0), transform), vec4(2, 4, 6, 0)));
}
test "vec2 swizzle" {
assert(std.meta.eql(vec4(0, 1, 1, 2), vec2(1, 2).swizzle("0x1y")));
assert(std.meta.eql(vec2(2, 1), vec2(1, 2).swizzle("yx")));
}
test "vec3 swizzle" {
assert(std.meta.eql(vec4(1, 1, 2, 3), vec3(1, 2, 3).swizzle("xxyz")));
assert(std.meta.eql(vec2(3, 3), vec3(1, 2, 3).swizzle("zz")));
}
test "vec4 swizzle" {
assert(std.meta.eql(vec4(3, 4, 2, 1), vec4(1, 2, 3, 4).swizzle("zwyx")));
assert(std.meta.eql(@as(f32, 3), vec4(1, 2, 3, 4).swizzle("z")));
} | test.zig |
const std = @import("std");
pub const QueueError = error{
/// Tried to add to a queue that is full.
FullQueue,
/// Tried to take from an empty queue.
EmptyQueue,
/// ThreadsafeQueue's "wait" function call has timed out.
TimedOut,
};
/// Threadsafe wrapper around our FIFO Queue
pub fn ThreadsafeQueue(comptime T: type, comptime maxItems: usize) type {
return struct {
const Self = @This();
queue: Queue(T, maxItems),
mutex: std.Thread.Mutex,
wait_limiter: std.Thread.Mutex,
waiter: std.Thread.StaticResetEvent,
pub fn init() Self {
return Self{
.queue = Queue(T, maxItems).init(),
.mutex = std.Thread.Mutex{},
.wait_limiter = std.Thread.Mutex{},
.waiter = std.Thread.StaticResetEvent{},
};
}
pub fn put(self: *Self, item: T) QueueError!void {
const held = self.mutex.acquire();
defer held.release();
if (!waiter_is_set(&self.waiter)) self.waiter.set();
return self.queue.put(item);
}
pub fn take(self: *Self) QueueError!T {
const held = self.mutex.acquire();
defer held.release();
return self.queue.take();
}
pub fn count(self: *Self) usize {
const held = self.mutex.acquire();
defer held.release();
return self.queue.count();
}
pub fn copyItems(self: *Self) [maxItems]?T {
const held = self.mutex.acquire();
defer held.release();
return self.queue.copyItems();
}
/// Waits until Queue is not empty.
/// Timeout is in nanoseconds.
/// Funtion is exclusive to ThreadsafeQueue.
/// Can be called by multiple threads at the same time.
/// Threads beyond the first will wait on a mutex before
/// waiting on a reset event.
pub fn wait(self: *Self, timeout: ?u64) QueueError!T {
const wait_held = self.wait_limiter.acquire();
defer wait_held.release();
while (true) {
const result = self.take() catch null;
if (result) |r| {
return r;
}
if (timeout) |t| {
switch (self.waiter.timedWait(t)) {
.timed_out => return QueueError.TimedOut,
.event_set => {},
}
} else {
self.waiter.wait();
}
const held = self.mutex.acquire();
self.waiter.reset();
held.release();
}
}
};
}
fn waiter_is_set(waiter: *std.Thread.StaticResetEvent) bool {
const waiters = @atomicLoad(u32, &waiter.impl.waiters, .Acquire);
const WAKE = 1 << 0;
const WAIT = 1 << 1;
return (waiters == WAKE);
}
/// FIFO queue that is statically allocated at comptime.
pub fn Queue(comptime T: type, comptime maxItems: usize) type {
return struct {
const Self = @This();
items: [maxItems]?T,
takePos: usize,
putPos: usize,
pub fn init() Self {
return Self{
.items = [_]?T{null} ** maxItems,
.takePos = 0,
.putPos = 0,
};
}
pub fn put(self: *Self, item: T) QueueError!void {
try self.assertCanPut();
self.items[self.nextPut()] = item;
}
pub fn take(self: *Self) QueueError!T {
try self.assertCanTake();
const n = self.nextTake();
defer self.items[n] = null;
return self.items[n].?;
}
fn nextPut(self: *Self) usize {
self.putPos = self.next(self.putPos);
return self.putPos;
}
fn nextTake(self: *Self) usize {
self.takePos = self.next(self.takePos);
return self.takePos;
}
fn next(self: *Self, i: usize) usize {
var result: usize = i;
result += 1;
if (result >= maxItems) result = 0;
return result;
}
fn assertCanTake(self: *Self) QueueError!void {
//if (self.count() == 0) return QueueError.EmptyQueue;
if (self.items[self.next(self.takePos)] == null) return QueueError.EmptyQueue;
}
fn assertCanPut(self: *Self) QueueError!void {
//if (self.count() == maxItems) return QueueError.FullQueue;
if (self.items[self.next(self.putPos)] != null) return QueueError.FullQueue;
}
/// Returns number of filled slots in Queue
pub fn count(self: *Self) usize {
if (self.putPos > self.takePos) {
return self.putPos - self.takePos;
}
if (self.putPos == self.takePos) {
if (maxItems == 0) return 0;
// occurs when queue is full
if (self.items[self.putPos] != null) return maxItems;
return 0;
}
return (self.putPos + maxItems) - self.takePos;
}
/// returns an in order copy of our internal array
/// in order meaning in the order we would .get() them
pub fn copyItems(self: *Self) [maxItems]?T {
var items = [_]?T{null} ** maxItems;
var item: ?T = null;
var index: usize = 0;
var queueIndex: usize = self.next(self.takePos);
while (true) {
item = self.items[queueIndex];
if (item == null or index == maxItems) break;
items[index] = item;
queueIndex = self.next(queueIndex);
index += 1;
}
return items;
}
};
}
test "happy path" {
@setEvalBranchQuota(10000);
const types = [_]type{ u8, i8, u3 };
inline for (types) |T| {
comptime var testingCounts = [_]T{0} ** std.math.maxInt(T);
inline for (testingCounts) |itemCount| {
// var q = Queue(T, itemCount).init();
var q = ThreadsafeQueue(T, itemCount).init();
var arr = [_]T{0} ** itemCount;
// set each elem's value to its index
for (arr) |_, index| arr[index] = @intCast(T, index);
// put items into queue in order
for (arr) |i| try q.put(i);
// take them out
for (arr) |expected| expect(try q.take() == expected);
expect(q.count() == 0);
}
}
}
test "put too many items" {
const itemCount = 5;
const T = u8;
//var q = Queue(T, itemCount).init();
var q = ThreadsafeQueue(T, itemCount).init();
var arr = [_]T{0} ** itemCount;
for (arr) |_, index| arr[index] = @intCast(T, index);
for (arr) |i| try q.put(i);
expectError(QueueError.FullQueue, q.put(100));
_ = try q.take();
try q.put(10);
expectError(QueueError.FullQueue, q.put(10));
}
test "take too many items" {
const itemCount = 5;
const T = u8;
var q = Queue(T, itemCount).init();
try q.put(1);
_ = try q.take();
_ = expectError(QueueError.EmptyQueue, q.take());
}
test "circular behaviour" {
const itemCount = 3;
const T = u8;
//var q = Queue(T, itemCount).init();
var q = ThreadsafeQueue(T, itemCount).init();
try q.put(1);
expect(q.count() == 1);
try q.put(2);
expect(q.count() == 2);
expect(q.take() catch unreachable == 1);
expect(q.count() == 1);
try q.put(3);
expect(q.count() == 2);
expect(q.take() catch unreachable == 2);
expect(q.count() == 1);
try q.put(4);
expect(q.count() == 2);
expect(q.take() catch unreachable == 3);
expect(q.count() == 1);
expect(q.take() catch unreachable == 4);
expect(q.count() == 0);
try q.put(1);
expect(q.count() == 1);
expect(q.take() catch unreachable == 1);
expect(q.count() == 0);
try q.put(2);
expect(q.count() == 1);
try q.put(3);
expect(q.count() == 2);
try q.put(4);
expect(q.count() == 3);
expectError(QueueError.FullQueue, q.put(100));
expect(q.count() == 3);
expect(q.take() catch unreachable == 2);
expect(q.count() == 2);
expect(q.take() catch unreachable == 3);
expect(q.count() == 1);
try q.put(5);
expect(q.count() == 2);
expect(q.take() catch unreachable == 4);
expect(q.take() catch unreachable == 5);
expect(q.count() == 0);
}
test "copy items" {
const itemCount = 3;
const T = u8;
var q = Queue(T, itemCount).init();
var items = [_]?T{null} ** itemCount;
items = q.copyItems();
for (items) |i| expect(i == null);
try q.put(10);
try q.put(11);
try q.put(12);
items = q.copyItems();
expect(items[0].? == 10);
expect(items[1].? == 11);
expect(items[2].? == 12);
_ = try q.take();
try q.put(13);
_ = try q.take();
try q.put(14);
items = q.copyItems();
expect(items[0].? == 12);
expect(items[1].? == 13);
expect(items[2].? == 14);
}
test "Optional type" {
var q = Queue(?u8, 10).init();
const a: ?u8 = 1;
const b: ?u8 = null;
const c: ?u8 = 2;
try q.put(a);
expectEqual(@as(usize, 1), q.count());
try q.put(b);
expectEqual(@as(usize, 2), q.count());
try q.put(c);
expectEqual(@as(usize, 3), q.count());
expectEqual(@as(?u8, 1), try q.take());
expectEqual(@as(?u8, null), try q.take());
expectEqual(@as(?u8, 2), try q.take());
for (q.items) |_| {
try q.put(null);
}
expectEqual(@as(usize, q.items.len), q.count());
expectError(QueueError.FullQueue, q.put(null));
expectError(QueueError.FullQueue, q.put(10));
}
test "Threadsafe waiting" {
var q = ThreadsafeQueue(u8, 10).init();
try q.put(10);
expectEqual(@as(u8, 10), try q.take());
var thread = try std.Thread.spawn(testDelayedPut, &q);
const timer_start = std.time.milliTimestamp();
const wait_result = try q.wait(null);
const time_taken = std.time.milliTimestamp() - timer_start;
expectEqual(@as(u8, 4), wait_result);
// Wait should be around 300 ms
expect(time_taken > 150);
expect(time_taken < 450);
thread.wait();
expectError(QueueError.EmptyQueue, q.take());
expectEqual(false, waiter_is_set(&q.waiter));
expectError(QueueError.TimedOut, q.wait(5 * std.time.ns_per_ms));
}
fn testDelayedPut(queue: *ThreadsafeQueue(u8, 10)) void {
std.time.sleep(300 * std.time.ns_per_ms);
queue.put(@as(u8, 4)) catch @panic("Test administration error");
}
test "Timed wait" {
var q = ThreadsafeQueue(u8, 10).init();
// wait is in nanoseconds
expectError(QueueError.TimedOut, q.wait(100));
const expected: u8 = 33;
try q.put(expected);
expectEqual(expected, try q.wait(1));
expectError(QueueError.TimedOut, q.wait(100));
}
test "Multiple waiting threads" {
var q = ThreadsafeQueue(u8, 10).init();
// try q.put(1);
var threads: [3]*std.Thread = undefined;
for (threads) |*thread| {
thread.* = try std.Thread.spawn(testWait, &q);
}
std.time.sleep(5 * std.time.ns_per_ms);
try q.put(1);
try q.put(1);
try q.put(1);
for (threads) |thread| {
thread.wait();
}
}
fn testWait(queue: *ThreadsafeQueue(u8, 10)) void {
const result = queue.wait(100 * std.time.ns_per_ms) catch @panic("Queue.wait timed out");
}
fn expectEqual(expected: anytype, actual: @TypeOf(expected)) void {
std.testing.expectEqual(expected, actual) catch unreachable;
}
fn expectError(expected_error: anyerror, actual_error_union: anytype) void {
std.testing.expectError(expected_error, actual_error_union) catch unreachable;
}
fn expect(ok: bool) void {
std.testing.expect(ok) catch unreachable;
} | static_queue.zig |
const std = @import("std");
const panic = std.debug.panic;
const assert = std.debug.assert;
const bufPrint = std.fmt.bufPrint;
const math = std.math;
usingnamespace @import("math3d.zig");
const pieces = @import("pieces.zig");
const Piece = pieces.Piece;
pub const Tetris = struct {
projection: Mat4x4,
prng: std.rand.DefaultPrng,
rand: *std.rand.Random,
piece_delay: f64,
delay_left: f64,
grid: [grid_height][grid_width]Cell,
next_piece: *const Piece,
hold_piece: ?*const Piece,
hold_was_set: bool,
cur_piece: *const Piece,
cur_piece_x: i32,
cur_piece_y: i32,
cur_piece_rot: usize,
score: c_int,
game_over: bool,
next_particle_index: usize,
next_falling_block_index: usize,
ghost_y: i32,
framebuffer_width: c_int,
framebuffer_height: c_int,
screen_shake_timeout: f64,
screen_shake_elapsed: f64,
level: i32,
time_till_next_level: f64,
piece_pool: [pieces.pieces.len]i32,
is_paused: bool,
particles: [max_particle_count]?Particle,
falling_blocks: [max_falling_block_count]?Particle,
};
const Cell = union(enum) {
Empty,
Color: Vec4,
};
pub const Particle = struct {
color: Vec4,
pos: Vec3,
vel: Vec3,
axis: Vec3,
scale_w: f32,
scale_h: f32,
angle: f32,
angle_vel: f32,
};
const PI = 3.14159265358979;
const max_particle_count = 500;
const max_falling_block_count = grid_width * grid_height;
const margin_size = 10;
const grid_width = 10;
const grid_height = 20;
pub const cell_size = 32;
const board_width = grid_width * cell_size;
const board_height = grid_height * cell_size;
const board_left = margin_size;
const board_top = margin_size;
const next_piece_width = margin_size + 4 * cell_size + margin_size;
const next_piece_height = next_piece_width;
const next_piece_left = board_left + board_width + margin_size;
const next_piece_top = board_top + board_height - next_piece_height;
const score_width = next_piece_width;
const score_height = next_piece_height;
const score_left = next_piece_left;
const score_top = next_piece_top - margin_size - score_height;
const level_display_width = next_piece_width;
const level_display_height = next_piece_height;
const level_display_left = next_piece_left;
const level_display_top = score_top - margin_size - level_display_height;
const hold_piece_width = next_piece_width;
const hold_piece_height = next_piece_height;
const hold_piece_left = next_piece_left;
const hold_piece_top = level_display_top - margin_size - hold_piece_height;
pub const window_width = next_piece_left + next_piece_width + margin_size;
pub const window_height = board_top + board_height + margin_size;
const board_color = Vec4{ .data = [_]f32{ 72.0 / 255.0, 72.0 / 255.0, 72.0 / 255.0, 1.0 } };
const init_piece_delay = 0.5;
const min_piece_delay = 0.05;
const level_delay_increment = 0.05;
pub const font_char_width = 18;
pub const font_char_height = 32;
const gravity = 1000.0;
const time_per_level = 60.0;
const empty_row = [_]Cell{Cell{ .Empty = {} }} ** grid_width;
const empty_grid = [_][grid_width]Cell{empty_row} ** grid_height;
var tetris_state: Tetris = undefined;
fn fillRect(t: *Tetris, comptime g: type, color: Vec4, x: f32, y: f32, w: f32, h: f32) void {
const model = mat4x4_identity.translate(x, y, 0.0).scale(w, h, 0.0);
const mvp = t.projection.mult(model);
g.fillRectMvp(t, color, mvp);
}
fn drawFallingBlock(t: *Tetris, comptime g: type, p: Particle) void {
const model = mat4x4_identity.translateByVec(p.pos).rotate(p.angle, p.axis).scale(p.scale_w, p.scale_h, 0.0);
const mvp = t.projection.mult(model);
g.fillRectMvp(t, p.color, mvp);
}
fn drawCenteredText(t: *Tetris, comptime g: type, text: []const u8) void {
const label_width = font_char_width * @intCast(i32, text.len);
const draw_left = board_left + board_width / 2 - @divExact(label_width, 2);
const draw_top = board_top + board_height / 2 - font_char_height / 2;
g.drawText(t, text, draw_left, draw_top, 1.0);
}
pub fn draw(t: *Tetris, comptime g: type) void {
fillRect(t, g, board_color, board_left, board_top, board_width, board_height);
fillRect(t, g, board_color, next_piece_left, next_piece_top, next_piece_width, next_piece_height);
fillRect(t, g, board_color, score_left, score_top, score_width, score_height);
fillRect(t, g, board_color, level_display_left, level_display_top, level_display_width, level_display_height);
fillRect(t, g, board_color, hold_piece_left, hold_piece_top, hold_piece_width, hold_piece_height);
if (t.game_over) {
drawCenteredText(t, g, "GAME OVER");
} else if (t.is_paused) {
drawCenteredText(t, g, "PAUSED");
} else {
const abs_x = board_left + t.cur_piece_x * cell_size;
const abs_y = board_top + t.cur_piece_y * cell_size;
drawPiece(t, g, t.cur_piece.*, abs_x, abs_y, t.cur_piece_rot);
const ghost_color = vec4(t.cur_piece.color.data[0], t.cur_piece.color.data[1], t.cur_piece.color.data[2], 0.2);
drawPieceWithColor(t, g, t.cur_piece.*, abs_x, t.ghost_y, t.cur_piece_rot, ghost_color);
drawPiece(t, g, t.next_piece.*, next_piece_left + margin_size, next_piece_top + margin_size, 0);
if (t.hold_piece) |piece| {
if (!t.hold_was_set) {
drawPiece(t, g, piece.*, hold_piece_left + margin_size, hold_piece_top + margin_size, 0);
} else {
const grey = vec4(0.65, 0.65, 0.65, 1.0);
drawPieceWithColor(t, g, piece.*, hold_piece_left + margin_size, hold_piece_top + margin_size, 0, grey);
}
}
for (t.grid) |row, y| {
for (row) |cell, x| {
switch (cell) {
Cell.Color => |color| {
const cell_left = board_left + @intCast(i32, x) * cell_size;
const cell_top = board_top + @intCast(i32, y) * cell_size;
fillRect(
t,
g,
color,
@intToFloat(f32, cell_left),
@intToFloat(f32, cell_top),
cell_size,
cell_size,
);
},
else => {},
}
}
}
}
{
const score_text = "SCORE:";
const score_label_width = font_char_width * @intCast(i32, score_text.len);
g.drawText(
t,
score_text,
score_left + score_width / 2 - score_label_width / 2,
score_top + margin_size,
1.0,
);
}
{
var score_text_buf: [20]u8 = undefined;
const score_text = bufPrint(score_text_buf[0..], "{}", .{t.score}) catch unreachable;
const score_label_width = font_char_width * @intCast(i32, score_text.len);
g.drawText(t, score_text, score_left + score_width / 2 - @divExact(score_label_width, 2), score_top + score_height / 2, 1.0);
}
{
const text = "LEVEL:";
const text_width = font_char_width * @intCast(i32, text.len);
g.drawText(t, text, level_display_left + level_display_width / 2 - text_width / 2, level_display_top + margin_size, 1.0);
}
{
var text_buf: [20]u8 = undefined;
const text = bufPrint(text_buf[0..], "{}", .{t.level}) catch unreachable;
const text_width = font_char_width * @intCast(i32, text.len);
g.drawText(t, text, level_display_left + level_display_width / 2 - @divExact(text_width, 2), level_display_top + level_display_height / 2, 1.0);
}
{
const text = "HOLD:";
const text_width = font_char_width * @intCast(i32, text.len);
g.drawText(t, text, hold_piece_left + hold_piece_width / 2 - text_width / 2, hold_piece_top + margin_size, 1.0);
}
for (t.falling_blocks) |maybe_particle| {
if (maybe_particle) |particle| {
drawFallingBlock(t, g, particle);
}
}
for (t.particles) |maybe_particle| {
if (maybe_particle) |particle| {
g.drawParticle(t, particle);
}
}
}
fn drawPiece(t: *Tetris, comptime g: type, piece: Piece, left: i32, top: i32, rot: usize) void {
drawPieceWithColor(t, g, piece, left, top, rot, piece.color);
}
fn drawPieceWithColor(t: *Tetris, comptime g: type, piece: Piece, left: i32, top: i32, rot: usize, color: Vec4) void {
for (piece.layout[rot]) |row, y| {
for (row) |is_filled, x| {
if (!is_filled) continue;
const abs_x = @intToFloat(f32, left + @intCast(i32, x) * cell_size);
const abs_y = @intToFloat(f32, top + @intCast(i32, y) * cell_size);
fillRect(t, g, color, abs_x, abs_y, cell_size, cell_size);
}
}
}
pub fn nextFrame(t: *Tetris, elapsed: f64) void {
if (t.is_paused) return;
updateKineticMotion(t, elapsed, t.falling_blocks[0..]);
updateKineticMotion(t, elapsed, t.particles[0..]);
if (!t.game_over) {
t.delay_left -= elapsed;
if (t.delay_left <= 0) {
_ = curPieceFall(t);
t.delay_left = t.piece_delay;
}
t.time_till_next_level -= elapsed;
if (t.time_till_next_level <= 0.0) {
levelUp(t);
}
computeGhost(t);
}
if (t.screen_shake_elapsed < t.screen_shake_timeout) {
t.screen_shake_elapsed += elapsed;
if (t.screen_shake_elapsed >= t.screen_shake_timeout) {
resetProjection(t);
} else {
const rate = 8; // oscillations per sec
const amplitude = 4; // pixels
const offset = @floatCast(f32, amplitude * -math.sin(2.0 * PI * t.screen_shake_elapsed * rate));
t.projection = mat4x4Ortho(
0.0,
@intToFloat(f32, t.framebuffer_width),
@intToFloat(f32, t.framebuffer_height) + offset,
offset,
);
}
}
}
fn updateKineticMotion(t: *Tetris, elapsed: f64, some_particles: []?Particle) void {
for (some_particles) |*maybe_p| {
if (maybe_p.*) |*p| {
p.pos.data[1] += @floatCast(f32, elapsed) * p.vel.data[1];
p.vel.data[1] += @floatCast(f32, elapsed) * gravity;
p.angle += p.angle_vel;
if (p.pos.data[1] > @intToFloat(f32, t.framebuffer_height)) {
maybe_p.* = null;
}
}
}
}
fn levelUp(t: *Tetris) void {
t.level += 1;
t.time_till_next_level = time_per_level;
const new_piece_delay = t.piece_delay - level_delay_increment;
t.piece_delay = if (new_piece_delay >= min_piece_delay) new_piece_delay else min_piece_delay;
activateScreenShake(t, 0.08);
const max_lines_to_fill = 4;
const proposed_lines_to_fill = @divTrunc(t.level + 2, 3);
const lines_to_fill = if (proposed_lines_to_fill > max_lines_to_fill)
max_lines_to_fill
else
proposed_lines_to_fill;
{
var i: i32 = 0;
while (i < lines_to_fill) : (i += 1) {
insertGarbageRowAtBottom(t);
}
}
}
fn insertGarbageRowAtBottom(t: *Tetris) void {
// move everything up to make room at the bottom
{
var y: usize = 1;
while (y < t.grid.len) : (y += 1) {
t.grid[y - 1] = t.grid[y];
}
}
// populate bottom row with garbage and make sure it fills at least
// one and leaves at least one empty
while (true) {
var all_empty = true;
var all_filled = true;
const bottom_y = grid_height - 1;
for (t.grid[bottom_y]) |_, x| {
const filled = t.rand.boolean();
if (filled) {
const index = t.rand.intRangeLessThan(usize, 0, pieces.pieces.len);
t.grid[bottom_y][x] = Cell{ .Color = pieces.pieces[index].color };
all_empty = false;
} else {
t.grid[bottom_y][x] = Cell{ .Empty = {} };
all_filled = false;
}
}
if (!all_empty and !all_filled) break;
}
}
fn computeGhost(t: *Tetris) void {
var off_y: i32 = 1;
while (!pieceWouldCollide(t, t.cur_piece.*, t.cur_piece_x, t.cur_piece_y + off_y, t.cur_piece_rot)) {
off_y += 1;
}
t.ghost_y = board_top + cell_size * (t.cur_piece_y + off_y - 1);
}
pub fn userCurPieceFall(t: *Tetris) void {
if (t.game_over or t.is_paused) return;
_ = curPieceFall(t);
}
fn curPieceFall(t: *Tetris) bool {
// if it would hit something, make it stop instead
if (pieceWouldCollide(t, t.cur_piece.*, t.cur_piece_x, t.cur_piece_y + 1, t.cur_piece_rot)) {
lockPiece(t);
dropNextPiece(t);
return true;
} else {
t.cur_piece_y += 1;
return false;
}
}
pub fn userDropCurPiece(t: *Tetris) void {
if (t.game_over or t.is_paused) return;
while (!curPieceFall(t)) {
t.score += 1;
}
}
pub fn userMoveCurPiece(t: *Tetris, dir: i8) void {
if (t.game_over or t.is_paused) return;
if (pieceWouldCollide(t, t.cur_piece.*, t.cur_piece_x + dir, t.cur_piece_y, t.cur_piece_rot)) {
return;
}
t.cur_piece_x += dir;
}
pub fn userRotateCurPiece(t: *Tetris, rot: i8) void {
if (t.game_over or t.is_paused) return;
const new_rot = @intCast(usize, @rem(@intCast(isize, t.cur_piece_rot) + rot + 4, 4));
if (pieceWouldCollide(t, t.cur_piece.*, t.cur_piece_x, t.cur_piece_y, new_rot)) {
return;
}
t.cur_piece_rot = new_rot;
}
pub fn userTogglePause(t: *Tetris) void {
if (t.game_over) return;
t.is_paused = !t.is_paused;
}
pub fn restartGame(t: *Tetris) void {
t.piece_delay = init_piece_delay;
t.delay_left = init_piece_delay;
t.score = 0;
t.game_over = false;
t.screen_shake_elapsed = 0.0;
t.screen_shake_timeout = 0.0;
t.level = 1;
t.time_till_next_level = time_per_level;
t.is_paused = false;
t.hold_was_set = false;
t.hold_piece = null;
t.piece_pool = [_]i32{1} ** pieces.pieces.len;
clearParticles(t);
t.grid = empty_grid;
populateNextPiece(t);
dropNextPiece(t);
}
fn lockPiece(t: *Tetris) void {
t.score += 1;
for (t.cur_piece.layout[t.cur_piece_rot]) |row, y| {
for (row) |is_filled, x| {
if (!is_filled) {
continue;
}
const abs_x = t.cur_piece_x + @intCast(i32, x);
const abs_y = t.cur_piece_y + @intCast(i32, y);
if (abs_x >= 0 and abs_y >= 0 and abs_x < grid_width and abs_y < grid_height) {
t.grid[@intCast(usize, abs_y)][@intCast(usize, abs_x)] = Cell{ .Color = t.cur_piece.color };
}
}
}
// find lines once and spawn explosions
for (t.grid) |row, y| {
var all_filled = true;
for (t.grid[y]) |cell| {
const filled = switch (cell) {
Cell.Empty => false,
else => true,
};
if (!filled) {
all_filled = false;
break;
}
}
if (all_filled) {
for (t.grid[y]) |cell, x| {
const color = switch (cell) {
Cell.Empty => continue,
Cell.Color => |col| col,
};
const center_x = @intToFloat(f32, board_left + x * cell_size) +
@intToFloat(f32, cell_size) / 2.0;
const center_y = @intToFloat(f32, board_top + y * cell_size) +
@intToFloat(f32, cell_size) / 2.0;
addExplosion(t, color, center_x, center_y);
}
}
}
// test for line
var rows_deleted: usize = 0;
var y: i32 = grid_height - 1;
while (y >= 0) {
var all_filled: bool = true;
for (t.grid[@intCast(usize, y)]) |cell| {
const filled = switch (cell) {
Cell.Empty => false,
else => true,
};
if (!filled) {
all_filled = false;
break;
}
}
if (all_filled) {
rows_deleted += 1;
deleteRow(t, @intCast(usize, y));
} else {
y -= 1;
}
}
const score_per_rows_deleted = [_]c_int{ 0, 10, 30, 50, 70 };
t.score += score_per_rows_deleted[rows_deleted];
if (rows_deleted > 0) {
activateScreenShake(t, 0.04);
}
}
pub fn resetProjection(t: *Tetris) void {
t.projection = mat4x4Ortho(
0.0,
@intToFloat(f32, t.framebuffer_width),
@intToFloat(f32, t.framebuffer_height),
0.0,
);
}
fn activateScreenShake(t: *Tetris, duration: f64) void {
t.screen_shake_elapsed = 0.0;
t.screen_shake_timeout = duration;
}
fn deleteRow(t: *Tetris, del_index: usize) void {
var y: usize = del_index;
while (y >= 1) {
t.grid[y] = t.grid[y - 1];
y -= 1;
}
t.grid[y] = empty_row;
}
fn cellEmpty(t: *Tetris, x: i32, y: i32) bool {
return switch (t.grid[@intCast(usize, y)][@intCast(usize, x)]) {
Cell.Empty => true,
else => false,
};
}
fn pieceWouldCollide(t: *Tetris, piece: Piece, grid_x: i32, grid_y: i32, rot: usize) bool {
for (piece.layout[rot]) |row, y| {
for (row) |is_filled, x| {
if (!is_filled) {
continue;
}
const abs_x = grid_x + @intCast(i32, x);
const abs_y = grid_y + @intCast(i32, y);
if (abs_x >= 0 and abs_y >= 0 and abs_x < grid_width and abs_y < grid_height) {
if (!cellEmpty(t, abs_x, abs_y)) {
return true;
}
} else if (abs_y >= 0) {
return true;
}
}
}
return false;
}
fn populateNextPiece(t: *Tetris) void {
// Let's turn Gambler's Fallacy into Gambler's Accurate Model of Reality.
var upper_bound: i32 = 0;
for (t.piece_pool) |count| {
if (count == 0) unreachable;
upper_bound += count;
}
const rand_val = t.rand.intRangeLessThan(i32, 0, upper_bound);
var this_piece_upper_bound: i32 = 0;
var any_zero = false;
for (t.piece_pool) |count, piece_index| {
this_piece_upper_bound += count;
if (rand_val < this_piece_upper_bound) {
t.next_piece = &pieces.pieces[piece_index];
t.piece_pool[piece_index] -= 1;
if (count <= 1) {
any_zero = true;
}
break;
}
}
// if any of the pieces are 0, add 1 to all of them
if (any_zero) {
for (t.piece_pool) |_, i| {
t.piece_pool[i] += 1;
}
}
}
fn doGameOver(t: *Tetris) void {
t.game_over = true;
// turn every piece into a falling object
for (t.grid) |row, y| {
for (row) |cell, x| {
const color = switch (cell) {
Cell.Empty => continue,
Cell.Color => |col| col,
};
const left = @intToFloat(f32, board_left + x * cell_size);
const top = @intToFloat(f32, board_top + y * cell_size);
t.falling_blocks[getNextFallingBlockIndex(t)] = createBlockParticle(t, color, vec3(left, top, 0.0));
}
}
}
pub fn userSetHoldPiece(t: *Tetris) void {
if (t.game_over or t.is_paused or t.hold_was_set) return;
var next_cur: *const Piece = undefined;
if (t.hold_piece) |hold_piece| {
next_cur = hold_piece;
} else {
next_cur = t.next_piece;
populateNextPiece(t);
}
t.hold_piece = t.cur_piece;
t.hold_was_set = true;
dropNewPiece(t, next_cur);
}
fn dropNewPiece(t: *Tetris, p: *const Piece) void {
const start_x = 4;
const start_y = -1;
const start_rot = 0;
if (pieceWouldCollide(t, p.*, start_x, start_y, start_rot)) {
doGameOver(t);
return;
}
t.delay_left = t.piece_delay;
t.cur_piece = p;
t.cur_piece_x = start_x;
t.cur_piece_y = start_y;
t.cur_piece_rot = start_rot;
}
fn dropNextPiece(t: *Tetris) void {
t.hold_was_set = false;
dropNewPiece(t, t.next_piece);
populateNextPiece(t);
}
fn clearParticles(t: *Tetris) void {
for (t.particles) |*p| {
p.* = null;
}
t.next_particle_index = 0;
for (t.falling_blocks) |*fb| {
fb.* = null;
}
t.next_falling_block_index = 0;
}
fn getNextParticleIndex(t: *Tetris) usize {
const result = t.next_particle_index;
t.next_particle_index = (t.next_particle_index + 1) % max_particle_count;
return result;
}
fn getNextFallingBlockIndex(t: *Tetris) usize {
const result = t.next_falling_block_index;
t.next_falling_block_index = (t.next_falling_block_index + 1) % max_falling_block_count;
return result;
}
fn addExplosion(t: *Tetris, color: Vec4, center_x: f32, center_y: f32) void {
const particle_count = 12;
const particle_size = @as(f32, cell_size) / 3.0;
{
var i: i32 = 0;
while (i < particle_count) : (i += 1) {
const off_x = t.rand.float(f32) * @as(f32, cell_size) / 2.0;
const off_y = t.rand.float(f32) * @as(f32, cell_size) / 2.0;
const pos = vec3(center_x + off_x, center_y + off_y, 0.0);
t.particles[getNextParticleIndex(t)] = createParticle(t, color, particle_size, pos);
}
}
}
fn createParticle(t: *Tetris, color: Vec4, size: f32, pos: Vec3) Particle {
var p: Particle = undefined;
p.angle_vel = t.rand.float(f32) * 0.1 - 0.05;
p.angle = t.rand.float(f32) * 2.0 * PI;
p.axis = vec3(0.0, 0.0, 1.0);
p.scale_w = size * (0.8 + t.rand.float(f32) * 0.4);
p.scale_h = size * (0.8 + t.rand.float(f32) * 0.4);
p.color = color;
p.pos = pos;
const vel_x = t.rand.float(f32) * 2.0 - 1.0;
const vel_y = -(2.0 + t.rand.float(f32) * 1.0);
p.vel = vec3(vel_x, vel_y, 0.0);
return p;
}
fn createBlockParticle(t: *Tetris, color: Vec4, pos: Vec3) Particle {
var p: Particle = undefined;
p.angle_vel = t.rand.float(f32) * 0.05 - 0.025;
p.angle = 0;
p.axis = vec3(0.0, 0.0, 1.0);
p.scale_w = cell_size;
p.scale_h = cell_size;
p.color = color;
p.pos = pos;
const vel_x = t.rand.float(f32) * 0.5 - 0.25;
const vel_y = -t.rand.float(f32) * 0.5;
p.vel = vec3(vel_x, vel_y, 0.0);
return p;
} | src/tetris.zig |
const std = @import("std");
const lib = @import("../../main.zig");
const shared = @import("../shared.zig");
const EventType = shared.BackendEventType;
const win32 = @import("win32.zig");
const HWND = win32.HWND;
const HINSTANCE = win32.HINSTANCE;
const RECT = win32.RECT;
const MSG = win32.MSG;
const WPARAM = win32.WPARAM;
const LPARAM = win32.LPARAM;
const LRESULT = win32.LRESULT;
const WINAPI = win32.WINAPI;
const Win32Error = error{ UnknownError, InitializationError };
pub const Capabilities = .{ .useEventLoop = true };
pub const PeerType = HWND;
var hInst: HINSTANCE = undefined;
pub const public = struct {
pub fn main() !void {
try init();
try @import("root").run();
}
};
pub fn init() !void {
const hInstance = @ptrCast(win32.HINSTANCE, @alignCast(@alignOf(win32.HINSTANCE), win32.GetModuleHandleW(null).?));
hInst = hInstance;
const initEx = win32.INITCOMMONCONTROLSEX{ .dwSize = @sizeOf(win32.INITCOMMONCONTROLSEX), .dwICC = win32.ICC_STANDARD_CLASSES };
const code = win32.InitCommonControlsEx(&initEx);
if (code == 0) {
std.debug.print("Failed to initialize Common Controls.", .{});
}
}
pub const MessageType = enum { Information, Warning, Error };
pub fn showNativeMessageDialog(msgType: MessageType, comptime fmt: []const u8, args: anytype) void {
const msg = std.fmt.allocPrintZ(lib.internal.scratch_allocator, fmt, args) catch {
std.log.err("Could not launch message dialog, original text: " ++ fmt, args);
return;
};
defer lib.internal.scratch_allocator.free(msg);
const icon: u32 = switch (msgType) {
.Information => win32.MB_ICONINFORMATION,
.Warning => win32.MB_ICONWARNING,
.Error => win32.MB_ICONERROR,
};
_ = win32.messageBoxA(null, msg, "Dialog", icon) catch {
std.log.err("Could not launch message dialog, original text: " ++ fmt, args);
return;
};
}
const className = "zgtWClass";
var defaultWHWND: HWND = undefined;
pub const Window = struct {
hwnd: HWND,
fn relayoutChild(hwnd: HWND, lp: LPARAM) callconv(WINAPI) c_int {
const parent = @intToPtr(HWND, @bitCast(usize, lp));
if (win32.GetParent(hwnd) != parent) {
return 1; // ignore recursive childrens
}
var rect: RECT = undefined;
_ = win32.GetClientRect(parent, &rect);
_ = win32.MoveWindow(hwnd, 0, 0, rect.right - rect.left, rect.bottom - rect.top, 1);
return 1;
}
fn process(hwnd: HWND, wm: c_uint, wp: WPARAM, lp: LPARAM) callconv(WINAPI) LRESULT {
switch (wm) {
win32.WM_SIZE => {
_ = win32.EnumChildWindows(hwnd, relayoutChild, @bitCast(isize, @ptrToInt(hwnd)));
},
else => {},
}
return win32.DefWindowProcA(hwnd, wm, wp, lp);
}
pub fn create() !Window {
var wc: win32.WNDCLASSEXA = .{
.style = 0,
.lpfnWndProc = process,
.cbClsExtra = 0,
.cbWndExtra = 0,
.hInstance = hInst,
.hIcon = null, // TODO: LoadIcon
.hCursor = null, // TODO: LoadCursor
.hbrBackground = win32.GetSysColorBrush(win32.COLOR_WINDOW),
.lpszMenuName = null,
.lpszClassName = className,
.hIconSm = null,
};
if ((try win32.registerClassExA(&wc)) == 0) {
showNativeMessageDialog(.Error, "Could not register window class {s}", .{className});
return Win32Error.InitializationError;
}
const hwnd = try win32.createWindowExA(win32.WS_EX_LEFT, // dwExtStyle
className, // lpClassName
"", // lpWindowName
win32.WS_OVERLAPPEDWINDOW, // dwStyle
win32.CW_USEDEFAULT, // X
win32.CW_USEDEFAULT, // Y
win32.CW_USEDEFAULT, // nWidth
win32.CW_USEDEFAULT, // nHeight
null, // hWindParent
null, // hMenu
hInst, // hInstance
null // lpParam
);
defaultWHWND = hwnd;
return Window{ .hwnd = hwnd };
}
// TODO: handle the fact that ONLY the root child must forcibly draw a background
pub fn setChild(self: *Window, hwnd: ?HWND) void {
// TODO: if null, remove child
_ = win32.SetParent(hwnd.?, self.hwnd);
const style = win32.GetWindowLongPtr(hwnd.?, win32.GWL_STYLE);
win32.SetWindowLongPtr(hwnd.?, win32.GWL_STYLE, style | win32.WS_CHILD);
_ = win32.showWindow(hwnd.?, win32.SW_SHOWDEFAULT);
_ = win32.UpdateWindow(hwnd.?);
}
pub fn resize(self: *Window, width: c_int, height: c_int) void {
var rect: RECT = undefined;
_ = win32.GetWindowRect(self.hwnd, &rect);
_ = win32.MoveWindow(self.hwnd, rect.left, rect.top, @intCast(c_int, width), @intCast(c_int, height), 1);
}
pub fn show(self: *Window) void {
_ = win32.showWindow(self.hwnd, win32.SW_SHOWDEFAULT);
_ = win32.UpdateWindow(self.hwnd);
}
pub fn close(self: *Window) void {
_ = win32.showWindow(self.hwnd, win32.SW_HIDE);
_ = win32.UpdateWindow(self.hwnd);
}
};
// zig fmt: off
const EventUserData = struct {
/// Only works for buttons
clickHandler: ?fn (data: usize) void = null,
mouseButtonHandler: ?fn (button: MouseButton, pressed: bool, x: u32, y: u32, data: usize) void = null,
keyTypeHandler: ?fn (str: []const u8, data: usize) void = null,
scrollHandler: ?fn (dx: f32, dy: f32, data: usize) void = null,
resizeHandler: ?fn (width: u32, height: u32, data: usize) void = null,
/// Only works for canvas (althought technically it isn't required to)
drawHandler: ?fn (ctx: *Canvas.DrawContext, data: usize) void = null,
changedTextHandler: ?fn (data: usize) void = null,
userdata: usize = 0
};
// zig fmt: on
inline fn getEventUserData(peer: HWND) *EventUserData {
return @intToPtr(*EventUserData, win32.GetWindowLongPtr(peer, win32.GWL_USERDATA));
}
pub fn Events(comptime T: type) type {
return struct {
const Self = @This();
pub fn process(hwnd: HWND, wm: c_uint, wp: WPARAM, lp: LPARAM) callconv(WINAPI) LRESULT {
if (win32.GetWindowLongPtr(hwnd, win32.GWL_USERDATA) == 0) return win32.DefWindowProcA(hwnd, wm, wp, lp);
switch (wm) {
win32.WM_COMMAND => {
const code = @intCast(u16, wp << 16);
const data = getEventUserData(@intToPtr(HWND, @bitCast(usize, lp)));
switch (code) {
win32.BN_CLICKED => {
if (data.clickHandler) |handler| {
handler(data.userdata);
}
},
else => {},
}
},
win32.WM_SIZE => {
const data = getEventUserData(hwnd);
if (data.resizeHandler) |handler| {
var rect: RECT = undefined;
_ = win32.GetWindowRect(hwnd, &rect);
handler(@intCast(u32, rect.right - rect.left), @intCast(u32, rect.bottom - rect.top), data.userdata);
}
},
win32.WM_PAINT => {
const data = getEventUserData(hwnd);
if (data.drawHandler) |handler| {
var ps: win32.PAINTSTRUCT = undefined;
var hdc: win32.HDC = win32.BeginPaint(hwnd, &ps);
defer _ = win32.EndPaint(hwnd, &ps);
const brush = @ptrCast(win32.HBRUSH, win32.GetStockObject(win32.DC_BRUSH));
win32.SelectObject(hdc, @ptrCast(win32.HGDIOBJ, brush));
var dc = Canvas.DrawContext{ .hdc = hdc, .hbr = brush, .path = std.ArrayList(Canvas.DrawContext.PathElement)
.init(lib.internal.scratch_allocator) };
defer dc.path.deinit();
handler(&dc, data.userdata);
}
},
else => {},
}
return win32.DefWindowProcA(hwnd, wm, wp, lp);
}
pub fn setupEvents(peer: HWND) !void {
var data = try lib.internal.lasting_allocator.create(EventUserData);
data.* = EventUserData{}; // ensure that it uses default values
win32.SetWindowLongPtr(peer, win32.GWL_USERDATA, @ptrToInt(data));
}
pub inline fn setUserData(self: *T, data: anytype) void {
comptime {
if (!std.meta.trait.isSingleItemPtr(@TypeOf(data))) {
@compileError(std.fmt.comptimePrint("Expected single item pointer, got {s}", .{@typeName(@TypeOf(data))}));
}
}
getEventUserData(self.peer).userdata = @ptrToInt(data);
}
pub inline fn setCallback(self: *T, comptime eType: EventType, cb: anytype) !void {
const data = getEventUserData(self.peer);
switch (eType) {
.Click => data.clickHandler = cb,
.Draw => data.drawHandler = cb,
.MouseButton => data.mouseButtonHandler = cb,
.Scroll => data.scrollHandler = cb,
.TextChanged => data.changedTextHandler = cb,
.Resize => data.resizeHandler = cb,
.KeyType => data.keyTypeHandler = cb,
}
}
/// Requests a redraw
pub fn requestDraw(self: *T) !void {
var updateRect: RECT = undefined;
updateRect = .{ .left = 0, .top = 0, .right = 10000, .bottom = 10000 };
if (win32.InvalidateRect(self.peer, &updateRect, 0) == 0) {
return Win32Error.UnknownError;
}
if (win32.UpdateWindow(self.peer) == 0) {
return Win32Error.UnknownError;
}
}
pub fn getWidth(self: *const T) c_int {
var rect: RECT = undefined;
_ = win32.GetWindowRect(self.peer, &rect);
return rect.right - rect.left;
}
pub fn getHeight(self: *const T) c_int {
var rect: RECT = undefined;
_ = win32.GetWindowRect(self.peer, &rect);
return rect.bottom - rect.top;
}
pub fn setOpacity(self: *const T, opacity: f64) void {
_ = self;
_ = opacity;
// TODO
}
pub fn deinit(self: *const T) void {
_ = self;
// TODO
}
};
}
pub const MouseButton = enum { Left, Middle, Right };
pub const Canvas = struct {
peer: HWND,
data: usize = 0,
pub usingnamespace Events(Canvas);
pub const DrawContext = struct {
hdc: win32.HDC,
hbr: win32.HBRUSH,
path: std.ArrayList(PathElement),
const PathElement = union(enum) { SetColor: win32.COLORREF, Rectangle: struct { left: c_int, top: c_int, right: c_int, bottom: c_int } };
pub const TextLayout = struct {
font: win32.HFONT,
/// HDC only used for getting text metrics
hdc: win32.HDC,
pub const Font = struct {
face: [:0]const u8,
size: f64,
};
pub const TextSize = struct { width: u32, height: u32 };
pub fn init() TextLayout {
// creates an HDC for the current screen, whatever it means given we can have windows on different screens
const hdc = win32.CreateCompatibleDC(null).?;
const defaultFont = @ptrCast(win32.HFONT, win32.GetStockObject(win32.DEFAULT_GUI_FONT));
win32.SelectObject(hdc, @ptrCast(win32.HGDIOBJ, defaultFont));
return TextLayout{ .font = defaultFont, .hdc = hdc };
}
pub fn setFont(self: *TextLayout, font: Font) void {
// _ = win32.DeleteObject(@ptrCast(win32.HGDIOBJ, self.font)); // delete old font
if (win32.CreateFontA(0, // cWidth
0, // cHeight
0, // cEscapement,
0, // cOrientation,
win32.FW_NORMAL, // cWeight
0, // bItalic
0, // bUnderline
0, // bStrikeOut
0, // iCharSet
0, // iOutPrecision
0, // iClipPrecision
0, // iQuality
0, // iPitchAndFamily
font.face // pszFaceName
)) |winFont| {
_ = win32.DeleteObject(@ptrCast(win32.HGDIOBJ, self.font));
self.font = winFont;
}
win32.SelectObject(self.hdc, @ptrCast(win32.HGDIOBJ, self.font));
}
pub fn getTextSize(self: *TextLayout, str: []const u8) TextSize {
var size: win32.SIZE = undefined;
_ = win32.GetTextExtentPoint32A(self.hdc, str.ptr, @intCast(c_int, str.len), &size);
return TextSize{ .width = @intCast(u32, size.cx), .height = @intCast(u32, size.cy) };
}
pub fn deinit(self: *TextLayout) void {
_ = win32.DeleteObject(@ptrCast(win32.HGDIOBJ, self.hdc));
_ = win32.DeleteObject(@ptrCast(win32.HGDIOBJ, self.font));
}
};
// TODO: transparency support using https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-alphablend
// or use GDI+ and https://docs.microsoft.com/en-us/windows/win32/gdiplus/-gdiplus-drawing-with-opaque-and-semitransparent-brushes-use
pub fn setColorByte(self: *DrawContext, color: lib.Color) void {
const colorref: win32.COLORREF = (@as(win32.COLORREF, color.blue) << 16) |
(@as(win32.COLORREF, color.green) << 8) | color.red;
_ = win32.SetDCBrushColor(self.hdc, colorref);
}
pub fn setColor(self: *DrawContext, r: f32, g: f32, b: f32) void {
self.setColorRGBA(r, g, b, 1);
}
pub fn setColorRGBA(self: *DrawContext, r: f32, g: f32, b: f32, a: f32) void {
self.setColorByte(.{ .red = @floatToInt(u8, r * 255), .green = @floatToInt(u8, g * 255), .blue = @floatToInt(u8, b * 255), .alpha = @floatToInt(u8, a * 255) });
}
pub fn rectangle(self: *DrawContext, x: u32, y: u32, w: u32, h: u32) void {
_ = win32.Rectangle(self.hdc, @intCast(c_int, x), @intCast(c_int, y), @intCast(c_int, x + w), @intCast(c_int, y + h));
}
pub fn ellipse(self: *DrawContext, x: u32, y: u32, w: f32, h: f32) void {
const cw = @floatToInt(c_int, w);
const ch = @floatToInt(c_int, h);
_ = win32.Ellipse(self.hdc, @intCast(c_int, x) - cw, @intCast(c_int, y) - ch, @intCast(c_int, x) + cw * 2, @intCast(c_int, y) + ch * 2);
}
pub fn text(self: *DrawContext, x: i32, y: i32, layout: TextLayout, str: []const u8) void {
// select current color
const color = win32.GetDCBrushColor(self.hdc);
_ = win32.SetTextColor(self.hdc, color);
// select the font
win32.SelectObject(self.hdc, @ptrCast(win32.HGDIOBJ, layout.font));
// and draw
_ = win32.ExtTextOutA(self.hdc, @intCast(c_int, x), @intCast(c_int, y), 0, null, str.ptr, @intCast(std.os.windows.UINT, str.len), null);
}
pub fn line(self: *DrawContext, x1: u32, y1: u32, x2: u32, y2: u32) void {
_ = win32.MoveToEx(self.hdc, @intCast(c_int, x1), @intCast(c_int, y1), null);
_ = win32.LineTo(self.hdc, @intCast(c_int, x2), @intCast(c_int, y2));
}
pub fn fill(self: *DrawContext) void {
self.path.clearRetainingCapacity();
}
pub fn stroke(self: *DrawContext) void {
self.path.clearRetainingCapacity();
}
};
var classRegistered = false;
pub fn create() !Canvas {
if (!classRegistered) {
var wc: win32.WNDCLASSEXA = .{
.style = 0,
.lpfnWndProc = Canvas.process,
.cbClsExtra = 0,
.cbWndExtra = 0,
.hInstance = hInst,
.hIcon = null, // TODO: LoadIcon
.hCursor = null, // TODO: LoadCursor
.hbrBackground = null,
.lpszMenuName = null,
.lpszClassName = "zgtCanvasClass",
.hIconSm = null,
};
if ((try win32.registerClassExA(&wc)) == 0) {
showNativeMessageDialog(.Error, "Could not register window class {s}", .{"zgtCanvasClass"});
return Win32Error.InitializationError;
}
classRegistered = true;
}
const hwnd = try win32.createWindowExA(win32.WS_EX_LEFT, // dwExtStyle
"zgtCanvasClass", // lpClassName
"", // lpWindowName
win32.WS_TABSTOP | win32.WS_CHILD, // dwStyle
10, // X
10, // Y
100, // nWidth
100, // nHeight
defaultWHWND, // hWindParent
null, // hMenu
hInst, // hInstance
null // lpParam
);
try Canvas.setupEvents(hwnd);
return Canvas{ .peer = hwnd };
}
};
pub const Button = struct {
peer: HWND,
data: usize = 0,
clickHandler: ?fn (data: usize) void = null,
oldWndProc: ?win32.WNDPROC = null,
arena: std.heap.ArenaAllocator,
pub usingnamespace Events(Button);
pub fn create() !Button {
const hwnd = try win32.createWindowExA(win32.WS_EX_LEFT, // dwExtStyle
"BUTTON", // lpClassName
"", // lpWindowName
win32.WS_TABSTOP | win32.WS_CHILD | win32.BS_DEFPUSHBUTTON, // dwStyle
10, // X
10, // Y
100, // nWidth
100, // nHeight
defaultWHWND, // hWindParent
null, // hMenu
hInst, // hInstance
null // lpParam
);
try Button.setupEvents(hwnd);
return Button{ .peer = hwnd, .arena = std.heap.ArenaAllocator.init(lib.internal.lasting_allocator) };
}
pub fn setLabel(self: *Button, label: [:0]const u8) void {
const allocator = lib.internal.scratch_allocator;
const wide = std.unicode.utf8ToUtf16LeWithNull(allocator, label) catch return; // invalid utf8 or not enough memory
defer allocator.free(wide);
if (win32.SetWindowTextW(self.peer, wide) == 0) {
std.os.windows.unexpectedError(win32.GetLastError()) catch {};
}
}
pub fn getLabel(self: *Button) [:0]const u8 {
const allocator = self.arena.allocator();
const len = win32.GetWindowTextLengthW(self.peer);
var buf = allocator.allocSentinel(u16, @intCast(usize, len), 0) catch unreachable; // TODO return error
defer allocator.free(buf);
const realLen = @intCast(usize, win32.GetWindowTextW(self.peer, buf.ptr, len + 1));
const utf16Slice = buf[0..realLen];
const text = std.unicode.utf16leToUtf8AllocZ(allocator, utf16Slice) catch unreachable; // TODO return error
return text;
}
};
pub const Label = struct {
peer: HWND,
data: usize = 0,
arena: std.heap.ArenaAllocator,
pub usingnamespace Events(Label);
pub fn create() !Label {
const hwnd = try win32.createWindowExA(win32.WS_EX_LEFT, // dwExtStyle
"STATIC", // lpClassName
"", // lpWindowName
win32.WS_TABSTOP | win32.WS_CHILD, // dwStyle
10, // X
10, // Y
100, // nWidth
100, // nHeight
defaultWHWND, // hWindParent
null, // hMenu
hInst, // hInstance
null // lpParam
);
try Label.setupEvents(hwnd);
return Label{ .peer = hwnd, .arena = std.heap.ArenaAllocator.init(lib.internal.lasting_allocator) };
}
pub fn setAlignment(self: *Label, alignment: f32) void {
_ = self;
_ = alignment;
}
pub fn setText(self: *Label, text: [:0]const u8) void {
const allocator = lib.internal.scratch_allocator;
const wide = std.unicode.utf8ToUtf16LeWithNull(allocator, text) catch return; // invalid utf8 or not enough memory
defer allocator.free(wide);
if (win32.SetWindowTextW(self.peer, wide) == 0) {
std.os.windows.unexpectedError(win32.GetLastError()) catch {};
}
}
pub fn getText(self: *Label) [:0]const u8 {
const allocator = self.arena.allocator();
const len = win32.GetWindowTextLengthW(self.peer);
var buf = allocator.allocSentinel(u16, @intCast(usize, len), 0) catch unreachable; // TODO return error
defer allocator.free(buf);
const utf16Slice = buf[0..@intCast(usize, win32.GetWindowTextW(self.peer, buf.ptr, len + 1))];
return std.unicode.utf16leToUtf8AllocZ(allocator, utf16Slice) catch unreachable; // TODO return error
}
pub fn destroy(self: *Label) void {
self.arena.deinit();
}
};
const ContainerStruct = struct { hwnd: HWND, count: usize, index: usize };
pub const Container = struct {
peer: HWND,
pub usingnamespace Events(Container);
var classRegistered = false;
pub fn create() !Container {
if (!classRegistered) {
var wc: win32.WNDCLASSEXA = .{
.style = 0,
.lpfnWndProc = Container.process,
.cbClsExtra = 0,
.cbWndExtra = 0,
.hInstance = hInst,
.hIcon = null, // TODO: LoadIcon
.hCursor = null, // TODO: LoadCursor
//.hbrBackground = null,
.hbrBackground = win32.GetSysColorBrush(win32.COLOR_WINDOW), // TODO: transparent background!
.lpszMenuName = null,
.lpszClassName = "zgtContainerClass",
.hIconSm = null,
};
if ((try win32.registerClassExA(&wc)) == 0) {
showNativeMessageDialog(.Error, "Could not register window class {s}", .{"zgtContainerClass"});
return Win32Error.InitializationError;
}
classRegistered = true;
}
const hwnd = try win32.createWindowExA(win32.WS_EX_LEFT, // dwExtStyle
"zgtContainerClass", // lpClassName
"", // lpWindowName
win32.WS_TABSTOP | win32.WS_CHILD, // dwStyle
10, // X
10, // Y
100, // nWidth
100, // nHeight
defaultWHWND, // hWindParent
null, // hMenu
hInst, // hInstance
null // lpParam
);
try Container.setupEvents(hwnd);
return Container{ .peer = hwnd };
}
pub fn add(self: *Container, peer: PeerType) void {
_ = win32.SetParent(peer, self.peer);
const style = win32.GetWindowLongPtr(peer, win32.GWL_STYLE);
win32.SetWindowLongPtr(peer, win32.GWL_STYLE, style | win32.WS_CHILD);
_ = win32.showWindow(peer, win32.SW_SHOWDEFAULT);
_ = win32.UpdateWindow(peer);
}
pub fn move(self: *const Container, peer: PeerType, x: u32, y: u32) void {
_ = self;
var rect: RECT = undefined;
_ = win32.GetWindowRect(peer, &rect);
_ = win32.MoveWindow(peer, @intCast(c_int, x), @intCast(c_int, y), rect.right - rect.left, rect.bottom - rect.top, 1);
}
pub fn resize(self: *const Container, peer: PeerType, width: u32, height: u32) void {
var rect: RECT = undefined;
_ = win32.GetWindowRect(peer, &rect);
if (rect.right - rect.left == width and rect.bottom - rect.top == height) {
return;
}
var parent: RECT = undefined;
_ = win32.GetWindowRect(self.peer, &parent);
_ = win32.MoveWindow(peer, rect.left - parent.left, rect.top - parent.top, @intCast(c_int, width), @intCast(c_int, height), 1);
rect.bottom -= rect.top;
rect.right -= rect.left;
rect.top = 0;
rect.left = 0;
//_ = win32.InvalidateRect(self.peer, &rect, 0);
_ = win32.UpdateWindow(peer);
}
};
pub fn runStep(step: shared.EventLoopStep) bool {
var msg: MSG = undefined;
switch (step) {
.Blocking => {
if (win32.GetMessageA(&msg, null, 0, 0) <= 0) {
return false; // error or WM_QUIT message
}
},
.Asynchronous => {
if (win32.PeekMessageA(&msg, null, 0, 0, 1) == 0) {
return true; // no message available
}
},
}
if ((msg.message & 0xFF) == 0x012) { // WM_QUIT
return false;
}
_ = win32.TranslateMessage(&msg);
_ = win32.DispatchMessageA(&msg);
return true;
} | src/backends/win32/backend.zig |
pub const WEB_SOCKET_MAX_CLOSE_REASON_LENGTH = @as(u32, 123);
//--------------------------------------------------------------------------------
// Section: Types (9)
//--------------------------------------------------------------------------------
pub const WEB_SOCKET_HANDLE = isize;
pub const WEB_SOCKET_CLOSE_STATUS = enum(i32) {
SUCCESS_CLOSE_STATUS = 1000,
ENDPOINT_UNAVAILABLE_CLOSE_STATUS = 1001,
PROTOCOL_ERROR_CLOSE_STATUS = 1002,
INVALID_DATA_TYPE_CLOSE_STATUS = 1003,
EMPTY_CLOSE_STATUS = 1005,
ABORTED_CLOSE_STATUS = 1006,
INVALID_PAYLOAD_CLOSE_STATUS = 1007,
POLICY_VIOLATION_CLOSE_STATUS = 1008,
MESSAGE_TOO_BIG_CLOSE_STATUS = 1009,
UNSUPPORTED_EXTENSIONS_CLOSE_STATUS = 1010,
SERVER_ERROR_CLOSE_STATUS = 1011,
SECURE_HANDSHAKE_ERROR_CLOSE_STATUS = 1015,
};
pub const WEB_SOCKET_SUCCESS_CLOSE_STATUS = WEB_SOCKET_CLOSE_STATUS.SUCCESS_CLOSE_STATUS;
pub const WEB_SOCKET_ENDPOINT_UNAVAILABLE_CLOSE_STATUS = WEB_SOCKET_CLOSE_STATUS.ENDPOINT_UNAVAILABLE_CLOSE_STATUS;
pub const WEB_SOCKET_PROTOCOL_ERROR_CLOSE_STATUS = WEB_SOCKET_CLOSE_STATUS.PROTOCOL_ERROR_CLOSE_STATUS;
pub const WEB_SOCKET_INVALID_DATA_TYPE_CLOSE_STATUS = WEB_SOCKET_CLOSE_STATUS.INVALID_DATA_TYPE_CLOSE_STATUS;
pub const WEB_SOCKET_EMPTY_CLOSE_STATUS = WEB_SOCKET_CLOSE_STATUS.EMPTY_CLOSE_STATUS;
pub const WEB_SOCKET_ABORTED_CLOSE_STATUS = WEB_SOCKET_CLOSE_STATUS.ABORTED_CLOSE_STATUS;
pub const WEB_SOCKET_INVALID_PAYLOAD_CLOSE_STATUS = WEB_SOCKET_CLOSE_STATUS.INVALID_PAYLOAD_CLOSE_STATUS;
pub const WEB_SOCKET_POLICY_VIOLATION_CLOSE_STATUS = WEB_SOCKET_CLOSE_STATUS.POLICY_VIOLATION_CLOSE_STATUS;
pub const WEB_SOCKET_MESSAGE_TOO_BIG_CLOSE_STATUS = WEB_SOCKET_CLOSE_STATUS.MESSAGE_TOO_BIG_CLOSE_STATUS;
pub const WEB_SOCKET_UNSUPPORTED_EXTENSIONS_CLOSE_STATUS = WEB_SOCKET_CLOSE_STATUS.UNSUPPORTED_EXTENSIONS_CLOSE_STATUS;
pub const WEB_SOCKET_SERVER_ERROR_CLOSE_STATUS = WEB_SOCKET_CLOSE_STATUS.SERVER_ERROR_CLOSE_STATUS;
pub const WEB_SOCKET_SECURE_HANDSHAKE_ERROR_CLOSE_STATUS = WEB_SOCKET_CLOSE_STATUS.SECURE_HANDSHAKE_ERROR_CLOSE_STATUS;
pub const WEB_SOCKET_PROPERTY_TYPE = enum(i32) {
RECEIVE_BUFFER_SIZE_PROPERTY_TYPE = 0,
SEND_BUFFER_SIZE_PROPERTY_TYPE = 1,
DISABLE_MASKING_PROPERTY_TYPE = 2,
ALLOCATED_BUFFER_PROPERTY_TYPE = 3,
DISABLE_UTF8_VERIFICATION_PROPERTY_TYPE = 4,
KEEPALIVE_INTERVAL_PROPERTY_TYPE = 5,
SUPPORTED_VERSIONS_PROPERTY_TYPE = 6,
};
pub const WEB_SOCKET_RECEIVE_BUFFER_SIZE_PROPERTY_TYPE = WEB_SOCKET_PROPERTY_TYPE.RECEIVE_BUFFER_SIZE_PROPERTY_TYPE;
pub const WEB_SOCKET_SEND_BUFFER_SIZE_PROPERTY_TYPE = WEB_SOCKET_PROPERTY_TYPE.SEND_BUFFER_SIZE_PROPERTY_TYPE;
pub const WEB_SOCKET_DISABLE_MASKING_PROPERTY_TYPE = WEB_SOCKET_PROPERTY_TYPE.DISABLE_MASKING_PROPERTY_TYPE;
pub const WEB_SOCKET_ALLOCATED_BUFFER_PROPERTY_TYPE = WEB_SOCKET_PROPERTY_TYPE.ALLOCATED_BUFFER_PROPERTY_TYPE;
pub const WEB_SOCKET_DISABLE_UTF8_VERIFICATION_PROPERTY_TYPE = WEB_SOCKET_PROPERTY_TYPE.DISABLE_UTF8_VERIFICATION_PROPERTY_TYPE;
pub const WEB_SOCKET_KEEPALIVE_INTERVAL_PROPERTY_TYPE = WEB_SOCKET_PROPERTY_TYPE.KEEPALIVE_INTERVAL_PROPERTY_TYPE;
pub const WEB_SOCKET_SUPPORTED_VERSIONS_PROPERTY_TYPE = WEB_SOCKET_PROPERTY_TYPE.SUPPORTED_VERSIONS_PROPERTY_TYPE;
pub const WEB_SOCKET_ACTION_QUEUE = enum(i32) {
SEND_ACTION_QUEUE = 1,
RECEIVE_ACTION_QUEUE = 2,
ALL_ACTION_QUEUE = 3,
};
pub const WEB_SOCKET_SEND_ACTION_QUEUE = WEB_SOCKET_ACTION_QUEUE.SEND_ACTION_QUEUE;
pub const WEB_SOCKET_RECEIVE_ACTION_QUEUE = WEB_SOCKET_ACTION_QUEUE.RECEIVE_ACTION_QUEUE;
pub const WEB_SOCKET_ALL_ACTION_QUEUE = WEB_SOCKET_ACTION_QUEUE.ALL_ACTION_QUEUE;
pub const WEB_SOCKET_BUFFER_TYPE = enum(i32) {
UTF8_MESSAGE_BUFFER_TYPE = -2147483648,
UTF8_FRAGMENT_BUFFER_TYPE = -2147483647,
BINARY_MESSAGE_BUFFER_TYPE = -2147483646,
BINARY_FRAGMENT_BUFFER_TYPE = -2147483645,
CLOSE_BUFFER_TYPE = -2147483644,
PING_PONG_BUFFER_TYPE = -2147483643,
UNSOLICITED_PONG_BUFFER_TYPE = -2147483642,
};
pub const WEB_SOCKET_UTF8_MESSAGE_BUFFER_TYPE = WEB_SOCKET_BUFFER_TYPE.UTF8_MESSAGE_BUFFER_TYPE;
pub const WEB_SOCKET_UTF8_FRAGMENT_BUFFER_TYPE = WEB_SOCKET_BUFFER_TYPE.UTF8_FRAGMENT_BUFFER_TYPE;
pub const WEB_SOCKET_BINARY_MESSAGE_BUFFER_TYPE = WEB_SOCKET_BUFFER_TYPE.BINARY_MESSAGE_BUFFER_TYPE;
pub const WEB_SOCKET_BINARY_FRAGMENT_BUFFER_TYPE = WEB_SOCKET_BUFFER_TYPE.BINARY_FRAGMENT_BUFFER_TYPE;
pub const WEB_SOCKET_CLOSE_BUFFER_TYPE = WEB_SOCKET_BUFFER_TYPE.CLOSE_BUFFER_TYPE;
pub const WEB_SOCKET_PING_PONG_BUFFER_TYPE = WEB_SOCKET_BUFFER_TYPE.PING_PONG_BUFFER_TYPE;
pub const WEB_SOCKET_UNSOLICITED_PONG_BUFFER_TYPE = WEB_SOCKET_BUFFER_TYPE.UNSOLICITED_PONG_BUFFER_TYPE;
pub const WEB_SOCKET_ACTION = enum(i32) {
NO_ACTION = 0,
SEND_TO_NETWORK_ACTION = 1,
INDICATE_SEND_COMPLETE_ACTION = 2,
RECEIVE_FROM_NETWORK_ACTION = 3,
INDICATE_RECEIVE_COMPLETE_ACTION = 4,
};
pub const WEB_SOCKET_NO_ACTION = WEB_SOCKET_ACTION.NO_ACTION;
pub const WEB_SOCKET_SEND_TO_NETWORK_ACTION = WEB_SOCKET_ACTION.SEND_TO_NETWORK_ACTION;
pub const WEB_SOCKET_INDICATE_SEND_COMPLETE_ACTION = WEB_SOCKET_ACTION.INDICATE_SEND_COMPLETE_ACTION;
pub const WEB_SOCKET_RECEIVE_FROM_NETWORK_ACTION = WEB_SOCKET_ACTION.RECEIVE_FROM_NETWORK_ACTION;
pub const WEB_SOCKET_INDICATE_RECEIVE_COMPLETE_ACTION = WEB_SOCKET_ACTION.INDICATE_RECEIVE_COMPLETE_ACTION;
pub const WEB_SOCKET_PROPERTY = extern struct {
Type: WEB_SOCKET_PROPERTY_TYPE,
pvValue: ?*anyopaque,
ulValueSize: u32,
};
pub const WEB_SOCKET_HTTP_HEADER = extern struct {
pcName: ?[*]u8,
ulNameLength: u32,
pcValue: ?[*]u8,
ulValueLength: u32,
};
pub const WEB_SOCKET_BUFFER = extern union {
Data: extern struct {
pbBuffer: ?*u8,
ulBufferLength: u32,
},
CloseStatus: extern struct {
pbReason: ?*u8,
ulReasonLength: u32,
usStatus: u16,
},
};
//--------------------------------------------------------------------------------
// Section: Functions (13)
//--------------------------------------------------------------------------------
// TODO: this type is limited to platform 'windows8.0'
pub extern "websocket" fn WebSocketCreateClientHandle(
pProperties: [*]const WEB_SOCKET_PROPERTY,
ulPropertyCount: u32,
phWebSocket: ?*WEB_SOCKET_HANDLE,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "websocket" fn WebSocketBeginClientHandshake(
hWebSocket: WEB_SOCKET_HANDLE,
pszSubprotocols: ?[*]?PSTR,
ulSubprotocolCount: u32,
pszExtensions: ?[*]?PSTR,
ulExtensionCount: u32,
pInitialHeaders: ?[*]const WEB_SOCKET_HTTP_HEADER,
ulInitialHeaderCount: u32,
pAdditionalHeaders: [*]?*WEB_SOCKET_HTTP_HEADER,
pulAdditionalHeaderCount: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "websocket" fn WebSocketEndClientHandshake(
hWebSocket: WEB_SOCKET_HANDLE,
pResponseHeaders: [*]const WEB_SOCKET_HTTP_HEADER,
ulReponseHeaderCount: u32,
pulSelectedExtensions: ?[*]u32,
pulSelectedExtensionCount: ?*u32,
pulSelectedSubprotocol: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "websocket" fn WebSocketCreateServerHandle(
pProperties: [*]const WEB_SOCKET_PROPERTY,
ulPropertyCount: u32,
phWebSocket: ?*WEB_SOCKET_HANDLE,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "websocket" fn WebSocketBeginServerHandshake(
hWebSocket: WEB_SOCKET_HANDLE,
pszSubprotocolSelected: ?[*:0]const u8,
pszExtensionSelected: ?[*]?PSTR,
ulExtensionSelectedCount: u32,
pRequestHeaders: [*]const WEB_SOCKET_HTTP_HEADER,
ulRequestHeaderCount: u32,
pResponseHeaders: [*]?*WEB_SOCKET_HTTP_HEADER,
pulResponseHeaderCount: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "websocket" fn WebSocketEndServerHandshake(
hWebSocket: WEB_SOCKET_HANDLE,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "websocket" fn WebSocketSend(
hWebSocket: WEB_SOCKET_HANDLE,
BufferType: WEB_SOCKET_BUFFER_TYPE,
pBuffer: ?*WEB_SOCKET_BUFFER,
Context: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "websocket" fn WebSocketReceive(
hWebSocket: WEB_SOCKET_HANDLE,
pBuffer: ?*WEB_SOCKET_BUFFER,
pvContext: ?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "websocket" fn WebSocketGetAction(
hWebSocket: WEB_SOCKET_HANDLE,
eActionQueue: WEB_SOCKET_ACTION_QUEUE,
pDataBuffers: [*]WEB_SOCKET_BUFFER,
pulDataBufferCount: ?*u32,
pAction: ?*WEB_SOCKET_ACTION,
pBufferType: ?*WEB_SOCKET_BUFFER_TYPE,
pvApplicationContext: ?*?*anyopaque,
pvActionContext: ?*?*anyopaque,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
// TODO: this type is limited to platform 'windows8.0'
pub extern "websocket" fn WebSocketCompleteAction(
hWebSocket: WEB_SOCKET_HANDLE,
pvActionContext: ?*anyopaque,
ulBytesTransferred: u32,
) callconv(@import("std").os.windows.WINAPI) void;
// TODO: this type is limited to platform 'windows8.0'
pub extern "websocket" fn WebSocketAbortHandle(
hWebSocket: WEB_SOCKET_HANDLE,
) callconv(@import("std").os.windows.WINAPI) void;
// TODO: this type is limited to platform 'windows8.0'
pub extern "websocket" fn WebSocketDeleteHandle(
hWebSocket: WEB_SOCKET_HANDLE,
) callconv(@import("std").os.windows.WINAPI) void;
// TODO: this type is limited to platform 'windows8.0'
pub extern "websocket" fn WebSocketGetGlobalProperty(
eType: WEB_SOCKET_PROPERTY_TYPE,
pvValue: [*]u8,
ulSize: ?*u32,
) callconv(@import("std").os.windows.WINAPI) HRESULT;
//--------------------------------------------------------------------------------
// Section: Unicode Aliases (0)
//--------------------------------------------------------------------------------
const thismodule = @This();
pub usingnamespace switch (@import("../zig.zig").unicode_mode) {
.ansi => struct {
},
.wide => struct {
},
.unspecified => if (@import("builtin").is_test) struct {
} else struct {
},
};
//--------------------------------------------------------------------------------
// Section: Imports (2)
//--------------------------------------------------------------------------------
const HRESULT = @import("../foundation.zig").HRESULT;
const PSTR = @import("../foundation.zig").PSTR;
test {
@setEvalBranchQuota(
@import("std").meta.declarations(@This()).len * 3
);
// reference all the pub declarations
if (!@import("builtin").is_test) return;
inline for (@import("std").meta.declarations(@This())) |decl| {
if (decl.is_pub) {
_ = decl;
}
}
} | win32/networking/web_socket.zig |
const std = @import("std");
const game = @import("game.zig");
const Game = game.Game;
const GameError =game.GameError;
const dice = @import("dice.zig");
/// Get a generator for finished games that employs the given picking strategy
pub fn GameGenerator(comptime picking_strategy: anytype, game_count: usize) type {
//TODO maybe make sure that this is a picking strategy via concepts
return struct {
current_game_count: usize,
max_game_count: usize,
prng: std.rand.DefaultPrng,
/// initialize the game generator with a seed for the random number generator
pub fn new(rng_seed: u64) @This() {
return .{
.current_game_count = 0,
.max_game_count = game_count,
.prng = std.rand.DefaultPrng.init(rng_seed),
};
}
/// generate the next game which is played from new game to finish
/// returns null if the max number of games was reached
/// this iterator uses !?Game as the return type because the iteration
/// could potentially fail if invalid values are used inside the game
/// this is nothing the user has control over and indicates a programming error
/// so from this point of view just crashing and returning ?Game would be fine.
/// I just wanted to work with !? iterators...
pub fn next(self: *@This()) !?Game {
if (self.current_game_count < self.max_game_count) {
self.current_game_count +=1;
var g = Game.new();
try playGameToFinish(&self.prng,&g, &picking_strategy);
return g;
} else {
return null;
}
}
};
}
// internal helper function to help play a game to finish
fn playGameToFinish(prng : anytype, g: *Game, strategy : anytype) !void {
var dice_result = dice.DiceResult.new_random(prng);
while (!(g.isWon() or g.isLost())) : (dice_result = dice.DiceResult.new_random(prng)) {
try applySingleTurn(g,dice_result, strategy);
}
if (g.isWon() == g.isLost()) {
return GameError.IllegalGameState;
}
}
/// Apply a single turn to a game using the given dice result and picking strat
/// the picking strat will only be used if the dice result warrants it, i.e.
/// it is a basket.
/// each single turn increases the turn count by one.
/// # Arguments
/// * `game`
/// * `dice_result` the dice result
/// * `strategy` a picking strategy that is invoked on a basket dice result. It must be
/// a container that exposes a method `fn pick (Game)?usize`.
pub fn applySingleTurn(g: *Game, dice_result: dice.DiceResult, strategy: anytype) !void {
//TODO comment this back in
//comptime static_assert(isPickingStrategy(@TypeOf(strategy)), "Strategy parameter must have the strategy interface");
//std.log.info("Dice = {s}", .{dice_result});
switch (dice_result) {
dice.DiceResult.raven => g.raven_count += 1,
dice.DiceResult.fruit => |fruit| {
//std.log.info("Fruit = {s}", .{fruit});
// ignore errors here because the dice might pick an empty tree
g.pickOne(fruit.index) catch {};
},
dice.DiceResult.basket => {
const _idxs = [_]u8{ 1, 2 };
const total_fruit_before = g.totalFruitCount();
for (_idxs) |_| {
if (strategy.pickOne(g.*)) |index| {
try g.pickOne(index);
}
}
// ensure that the picking strategies always decrease
// must decrease either to zero or decrease by two pieces of fruit
if (g.totalFruitCount() != 0 and
g.totalFruitCount() != total_fruit_before - 2)
{
return GameError.IllegalPickingStrategy;
}
},
}
g.turn_count +=1;
}
// a dummy strategy that always returns a null index
const NullPickingStrategy = struct {
pub fn pickOne(self : *@This(),g:Game) ?usize {
_ = self;
_ = g;
return null;
}
};
const expect = std.testing.expect;
const expectError = std.testing.expectError;
// adds a raven, increases turn count, leave fruit untouched
test "applySingleTurn: DiceResult = Raven" {
var g = Game.new();
try expect(g.raven_count == 0);
try expect(g.turn_count == 0);
try expect(g.totalFruitCount() == game.TREE_COUNT*game.INITIAL_FRUIT_COUNT);
var strat = NullPickingStrategy{};
try applySingleTurn(&g,dice.DiceResult.new_raven(), &strat);
try expect(g.turn_count == 1);
try expect(g.raven_count == 1);
try expect(g.totalFruitCount() == game.TREE_COUNT*game.INITIAL_FRUIT_COUNT);
}
// take one piece from the given tree and leave others untouched, increase turn count
test "applySingleTurn: DiceResult = Fruit" {
var g = Game.new();
var strat = NullPickingStrategy{};
try applySingleTurn(&g, try dice.DiceResult.new_fruit(1), &strat);
try expect(g.turn_count == 1);
try expect(g.raven_count == 0);
try expect(g.totalFruitCount() == game.TREE_COUNT*game.INITIAL_FRUIT_COUNT-1);
try expect(g.fruit_count[1] == game.INITIAL_FRUIT_COUNT-1);
}
// simple mocks which picks according to a given list. If the last pick from the list
// was taken, null is returned
const MockStrategy = struct {
idx: usize = 0,
picks: []const usize,
pub fn init(picks : []const usize) @This() {
return @This(){.picks = picks, .idx = 0};
}
pub fn pickOne(self : *@This(), _ : game.Game)?usize {
if (self.idx < self.picks.len) {
const pick = self.picks[self.idx];
self.idx +=1;
return pick;
} else {
return null;
}
}
};
test "applySingleTurn: DiceResult = Basket" {
var strat = MockStrategy.init(&[_]usize{2,1,3});
var g = game.Game.new();
try applySingleTurn(&g, dice.DiceResult.new_basket(), &strat);
try expect(std.mem.eql(usize, &g.fruit_count, &[_]usize{10,9,9,10}));
// we must pick 2 as long as the trees are not empty
try expectError(error.IllegalPickingStrategy,applySingleTurn(&g,dice.DiceResult.new_basket(), &strat));
}
test "applySingleTurn: DiceResult = Basket, Picking from emtpy tree" {
var strat = MockStrategy.init(&[_]usize{0,0});
var g = game.Game.new();
g.fruit_count[0]=0;
try expectError(error.EmptyTreePick,applySingleTurn(&g,dice.DiceResult.new_basket(), &strat));
} | src/simulate.zig |
const std = @import("std");
const mem = std.mem;
const testing = std.testing;
const log = std.log;
const ArrayList = std.ArrayList;
const TailQueue = std.TailQueue;
const intcode = @import("intcode.zig");
const IntcodeProgram = intcode.IntcodeProgram;
const Instruction = intcode.Instruction;
const ParamMode = intcode.ParamMode;
const TestCase = struct {
const Self = @This();
code: []const i64,
input: ?i64,
expected_code: ?[]const i64,
expected_output: []const i64,
pub fn run(self: Self) !void {
var program = try IntcodeProgram.init(testing.allocator, self.code);
defer program.deinit();
var input = ArrayList(i64).init(testing.allocator);
defer input.deinit();
if (self.input) |data| {
try input.append(data);
}
var output = ArrayList(i64).init(testing.allocator);
defer output.deinit();
const status = try program.run(i64, input.items, i64, &output);
log.debug("status: {s}, output: {d}", .{ status, output.items });
try testing.expectEqual(IntcodeProgram.Status.terminated, status);
if (self.expected_code) |expected| {
try testing.expectEqualSlices(i64, expected[0..], program.code);
}
try testing.expectEqualSlices(i64, self.expected_output[0..], output.items);
}
};
const empty = [_]i64{};
test "parseInstruction" {
const instruction = Instruction.fromValue(1002);
try testing.expectEqual(ParamMode.position, instruction.mul.first);
try testing.expectEqual(ParamMode.immediate, instruction.mul.second);
}
test "run" {
{
const code = [_]i64{ 1, 0, 0, 0, 99 };
const expected = [_]i64{ 2, 0, 0, 0, 99 };
const tc = TestCase{
.code = code[0..],
.input = 42,
.expected_code = expected[0..],
.expected_output = empty[0..],
};
try tc.run();
}
{
const code = [_]i64{ 2, 3, 0, 3, 99 };
const expected = [_]i64{ 2, 3, 0, 6, 99 };
const tc = TestCase{
.code = code[0..],
.input = 42,
.expected_code = expected[0..],
.expected_output = empty[0..],
};
try tc.run();
}
{
const code = [_]i64{ 2, 4, 4, 5, 99, 0 };
const expected = [_]i64{ 2, 4, 4, 5, 99, 9801 };
const tc = TestCase{
.code = code[0..],
.input = 42,
.expected_code = expected[0..],
.expected_output = empty[0..],
};
try tc.run();
}
{
const code = [_]i64{ 1, 1, 1, 4, 99, 5, 6, 0, 99 };
const expected = [_]i64{ 30, 1, 1, 4, 2, 5, 6, 0, 99 };
const tc = TestCase{
.code = code[0..],
.input = 42,
.expected_code = expected[0..],
.expected_output = empty[0..],
};
try tc.run();
}
}
test "block and resume" {
const code = [_]i64{
3, 21, 1008, 21, 8, 20, 1005, 20, 22, 107, 8, 21, 20, 1006, 20, 31, 1106, 0, 36, 98, 0,
0, 1002, 21, 125, 20, 4, 20, 1105, 1, 46, 104, 999, 1105, 1, 46, 1101, 1000, 1, 20, 4, 20,
1105, 1, 46, 98, 99,
};
var program = try IntcodeProgram.init(testing.allocator, code[0..]);
defer program.deinit();
var output = ArrayList(i64).init(testing.allocator);
defer output.deinit();
var status = try program.run(i64, empty[0..], i64, &output);
try testing.expectEqual(IntcodeProgram.Status.blocked, status);
try testing.expectEqual(@as(usize, 0), output.items.len);
var input = [_]i64{7};
status = try program.run(i64, input[0..], i64, &output);
try testing.expectEqual(IntcodeProgram.Status.terminated, status);
try testing.expectEqual(@as(i64, 999), output.items[0]);
try testing.expectEqual(@as(usize, 1), output.items.len);
}
test "extra memory" {
const code = [_]i64{ 104, 1125899906842624, 99 };
const expected = [_]i64{1125899906842624};
const tc = TestCase{
.code = code[0..],
.input = null,
.expected_code = null,
.expected_output = expected[0..],
};
try tc.run();
}
test "quine" {
const code = [_]i64{ 109, 1, 204, -1, 1001, 100, 1, 100, 1008, 100, 16, 101, 1006, 101, 0, 99 };
const expected = [_]i64{ 109, 1, 204, -1, 1001, 100, 1, 100, 1008, 100, 16, 101, 1006, 101, 0, 99 };
const tc = TestCase{
.code = code[0..],
.input = null,
.expected_code = null,
.expected_output = expected[0..],
};
try tc.run();
}
test "day 5" {
const code_template = [_]i64{
3, 225, 1, 225, 6, 6, 1100, 1, 238, 225, 104, 0, 1101, 91, 67, 225, 1102, 67, 36, 225,
1102, 21, 90, 225, 2, 13, 48, 224, 101, -819, 224, 224, 4, 224, 1002, 223, 8, 223, 101, 7,
224, 224, 1, 223, 224, 223, 1101, 62, 9, 225, 1, 139, 22, 224, 101, -166, 224, 224, 4, 224,
1002, 223, 8, 223, 101, 3, 224, 224, 1, 223, 224, 223, 102, 41, 195, 224, 101, -2870, 224, 224,
4, 224, 1002, 223, 8, 223, 101, 1, 224, 224, 1, 224, 223, 223, 1101, 46, 60, 224, 101, -106,
224, 224, 4, 224, 1002, 223, 8, 223, 1001, 224, 2, 224, 1, 224, 223, 223, 1001, 191, 32, 224,
101, -87, 224, 224, 4, 224, 102, 8, 223, 223, 1001, 224, 1, 224, 1, 223, 224, 223, 1101, 76,
90, 225, 1101, 15, 58, 225, 1102, 45, 42, 224, 101, -1890, 224, 224, 4, 224, 1002, 223, 8, 223,
1001, 224, 5, 224, 1, 224, 223, 223, 101, 62, 143, 224, 101, -77, 224, 224, 4, 224, 1002, 223,
8, 223, 1001, 224, 4, 224, 1, 224, 223, 223, 1101, 55, 54, 225, 1102, 70, 58, 225, 1002, 17,
80, 224, 101, -5360, 224, 224, 4, 224, 102, 8, 223, 223, 1001, 224, 3, 224, 1, 223, 224, 223,
4, 223, 99, 0, 0, 0, 677, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1105, 0,
99999, 1105, 227, 247, 1105, 1, 99999, 1005, 227, 99999, 1005, 0, 256, 1105, 1, 99999, 1106, 227, 99999, 1106,
0, 265, 1105, 1, 99999, 1006, 0, 99999, 1006, 227, 274, 1105, 1, 99999, 1105, 1, 280, 1105, 1, 99999,
1, 225, 225, 225, 1101, 294, 0, 0, 105, 1, 0, 1105, 1, 99999, 1106, 0, 300, 1105, 1, 99999,
1, 225, 225, 225, 1101, 314, 0, 0, 106, 0, 0, 1105, 1, 99999, 1008, 677, 677, 224, 102, 2,
223, 223, 1005, 224, 329, 1001, 223, 1, 223, 1108, 677, 226, 224, 1002, 223, 2, 223, 1006, 224, 344,
101, 1, 223, 223, 107, 677, 226, 224, 1002, 223, 2, 223, 1006, 224, 359, 101, 1, 223, 223, 108,
677, 677, 224, 1002, 223, 2, 223, 1006, 224, 374, 1001, 223, 1, 223, 108, 226, 677, 224, 1002, 223,
2, 223, 1006, 224, 389, 101, 1, 223, 223, 7, 226, 677, 224, 102, 2, 223, 223, 1006, 224, 404,
1001, 223, 1, 223, 1108, 677, 677, 224, 1002, 223, 2, 223, 1005, 224, 419, 101, 1, 223, 223, 1008,
226, 677, 224, 102, 2, 223, 223, 1006, 224, 434, 101, 1, 223, 223, 107, 226, 226, 224, 102, 2,
223, 223, 1005, 224, 449, 1001, 223, 1, 223, 1007, 677, 677, 224, 1002, 223, 2, 223, 1006, 224, 464,
1001, 223, 1, 223, 1007, 226, 226, 224, 1002, 223, 2, 223, 1005, 224, 479, 101, 1, 223, 223, 1008,
226, 226, 224, 102, 2, 223, 223, 1006, 224, 494, 1001, 223, 1, 223, 8, 226, 226, 224, 102, 2,
223, 223, 1006, 224, 509, 101, 1, 223, 223, 1107, 677, 677, 224, 102, 2, 223, 223, 1005, 224, 524,
1001, 223, 1, 223, 1108, 226, 677, 224, 1002, 223, 2, 223, 1006, 224, 539, 101, 1, 223, 223, 1107,
677, 226, 224, 1002, 223, 2, 223, 1006, 224, 554, 101, 1, 223, 223, 1007, 677, 226, 224, 1002, 223,
2, 223, 1005, 224, 569, 101, 1, 223, 223, 7, 677, 226, 224, 1002, 223, 2, 223, 1006, 224, 584,
101, 1, 223, 223, 107, 677, 677, 224, 1002, 223, 2, 223, 1005, 224, 599, 1001, 223, 1, 223, 8,
226, 677, 224, 1002, 223, 2, 223, 1005, 224, 614, 101, 1, 223, 223, 7, 677, 677, 224, 1002, 223,
2, 223, 1006, 224, 629, 1001, 223, 1, 223, 1107, 226, 677, 224, 1002, 223, 2, 223, 1006, 224, 644,
101, 1, 223, 223, 108, 226, 226, 224, 102, 2, 223, 223, 1005, 224, 659, 1001, 223, 1, 223, 8,
677, 226, 224, 1002, 223, 2, 223, 1005, 224, 674, 101, 1, 223, 223, 4, 223, 99, 226,
};
// It will then perform a series of diagnostic tests confirming that
// various parts of the Intcode computer, like parameter modes, function
// correctly. For each test, it will run an output instruction indicating
// how far the result of the test was from the expected value, where 0
// means the test was successful.
{
var code = try testing.allocator.alloc(i64, code_template.len);
mem.copy(i64, code, code_template[0..]);
defer testing.allocator.free(code);
const expected = [_]i64{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 15508323 };
const tc = TestCase{
.code = code[0..],
.input = 1,
.expected_code = null,
.expected_output = expected[0..],
};
try tc.run();
}
{
var code = try testing.allocator.alloc(i64, code_template.len);
mem.copy(i64, code, code_template[0..]);
defer testing.allocator.free(code);
const expected = [_]i64{9006327};
const tc = TestCase{
.code = code[0..],
.input = 5,
.expected_code = null,
.expected_output = expected[0..],
};
try tc.run();
}
}
test "BOOST" {
var code = [_]i64{
1102, 34463338, 34463338, 63, 1007, 63, 34463338, 63, 1005, 63, 53, 1101, 0, 3, 1000,
109, 988, 209, 12, 9, 1000, 209, 6, 209, 3, 203, 0, 1008, 1000, 1,
63, 1005, 63, 65, 1008, 1000, 2, 63, 1005, 63, 904, 1008, 1000, 0, 63,
1005, 63, 58, 4, 25, 104, 0, 99, 4, 0, 104, 0, 99, 4, 17,
104, 0, 99, 0, 0, 1101, 0, 36, 1015, 1102, 1, 387, 1028, 1101, 24,
0, 1016, 1101, 0, 23, 1008, 1102, 1, 35, 1012, 1102, 1, 554, 1023, 1101,
29, 0, 1003, 1101, 27, 0, 1011, 1101, 25, 0, 1000, 1101, 0, 38, 1018,
1102, 20, 1, 1019, 1102, 28, 1, 1005, 1102, 1, 619, 1026, 1102, 1, 22,
1004, 1101, 0, 0, 1020, 1101, 0, 31, 1009, 1102, 1, 783, 1024, 1102, 1,
33, 1001, 1102, 616, 1, 1027, 1102, 1, 21, 1006, 1101, 32, 0, 1013, 1102,
39, 1, 1014, 1102, 1, 378, 1029, 1101, 774, 0, 1025, 1102, 1, 1, 1021,
1102, 30, 1, 1007, 1102, 37, 1, 1002, 1102, 1, 26, 1017, 1101, 0, 557,
1022, 1102, 1, 34, 1010, 109, 13, 2101, 0, -5, 63, 1008, 63, 23, 63,
1005, 63, 203, 4, 187, 1105, 1, 207, 1001, 64, 1, 64, 1002, 64, 2,
64, 109, -14, 2107, 28, 4, 63, 1005, 63, 225, 4, 213, 1106, 0, 229,
1001, 64, 1, 64, 1002, 64, 2, 64, 109, 10, 1207, -3, 20, 63, 1005,
63, 245, 1106, 0, 251, 4, 235, 1001, 64, 1, 64, 1002, 64, 2, 64,
109, 8, 1205, 3, 263, 1105, 1, 269, 4, 257, 1001, 64, 1, 64, 1002,
64, 2, 64, 109, -9, 1207, -7, 34, 63, 1005, 63, 287, 4, 275, 1105,
1, 291, 1001, 64, 1, 64, 1002, 64, 2, 64, 109, -4, 2102, 1, -3,
63, 1008, 63, 32, 63, 1005, 63, 311, 1105, 1, 317, 4, 297, 1001, 64,
1, 64, 1002, 64, 2, 64, 109, 21, 21101, 40, 0, -6, 1008, 1019, 43,
63, 1005, 63, 337, 1106, 0, 343, 4, 323, 1001, 64, 1, 64, 1002, 64,
2, 64, 109, -26, 1202, 7, 1, 63, 1008, 63, 21, 63, 1005, 63, 365,
4, 349, 1106, 0, 369, 1001, 64, 1, 64, 1002, 64, 2, 64, 109, 26,
2106, 0, 3, 4, 375, 1001, 64, 1, 64, 1105, 1, 387, 1002, 64, 2,
64, 109, -9, 21108, 41, 40, 3, 1005, 1019, 407, 1001, 64, 1, 64, 1106,
0, 409, 4, 393, 1002, 64, 2, 64, 109, 13, 1205, -8, 423, 4, 415,
1106, 0, 427, 1001, 64, 1, 64, 1002, 64, 2, 64, 109, -19, 21107, 42,
41, 5, 1005, 1015, 447, 1001, 64, 1, 64, 1106, 0, 449, 4, 433, 1002,
64, 2, 64, 109, -3, 2102, 1, -5, 63, 1008, 63, 37, 63, 1005, 63,
471, 4, 455, 1105, 1, 475, 1001, 64, 1, 64, 1002, 64, 2, 64, 109,
-2, 1201, 0, 0, 63, 1008, 63, 28, 63, 1005, 63, 497, 4, 481, 1105,
1, 501, 1001, 64, 1, 64, 1002, 64, 2, 64, 109, 8, 2107, 29, -8,
63, 1005, 63, 521, 1001, 64, 1, 64, 1106, 0, 523, 4, 507, 1002, 64,
2, 64, 109, -3, 1208, -3, 30, 63, 1005, 63, 541, 4, 529, 1106, 0,
545, 1001, 64, 1, 64, 1002, 64, 2, 64, 109, 4, 2105, 1, 9, 1105,
1, 563, 4, 551, 1001, 64, 1, 64, 1002, 64, 2, 64, 109, 9, 1206,
-3, 581, 4, 569, 1001, 64, 1, 64, 1106, 0, 581, 1002, 64, 2, 64,
109, -8, 1201, -9, 0, 63, 1008, 63, 23, 63, 1005, 63, 605, 1001, 64,
1, 64, 1106, 0, 607, 4, 587, 1002, 64, 2, 64, 109, 21, 2106, 0,
-9, 1106, 0, 625, 4, 613, 1001, 64, 1, 64, 1002, 64, 2, 64, 109,
-35, 2108, 31, 8, 63, 1005, 63, 647, 4, 631, 1001, 64, 1, 64, 1105,
1, 647, 1002, 64, 2, 64, 109, 2, 1202, 0, 1, 63, 1008, 63, 30,
63, 1005, 63, 667, 1105, 1, 673, 4, 653, 1001, 64, 1, 64, 1002, 64,
2, 64, 109, 17, 21108, 43, 43, -4, 1005, 1016, 691, 4, 679, 1106, 0,
695, 1001, 64, 1, 64, 1002, 64, 2, 64, 109, -14, 1208, -1, 30, 63,
1005, 63, 711, 1106, 0, 717, 4, 701, 1001, 64, 1, 64, 1002, 64, 2,
64, 109, 6, 21101, 44, 0, -1, 1008, 1011, 44, 63, 1005, 63, 739, 4,
723, 1105, 1, 743, 1001, 64, 1, 64, 1002, 64, 2, 64, 109, -15, 2108,
30, 8, 63, 1005, 63, 759, 1106, 0, 765, 4, 749, 1001, 64, 1, 64,
1002, 64, 2, 64, 109, 27, 2105, 1, 0, 4, 771, 1001, 64, 1, 64,
1105, 1, 783, 1002, 64, 2, 64, 109, -9, 1206, 6, 795, 1105, 1, 801,
4, 789, 1001, 64, 1, 64, 1002, 64, 2, 64, 109, 4, 21102, 45, 1,
-7, 1008, 1012, 45, 63, 1005, 63, 823, 4, 807, 1105, 1, 827, 1001, 64,
1, 64, 1002, 64, 2, 64, 109, -14, 21102, 46, 1, 5, 1008, 1010, 43,
63, 1005, 63, 851, 1001, 64, 1, 64, 1105, 1, 853, 4, 833, 1002, 64,
2, 64, 109, -1, 2101, 0, 1, 63, 1008, 63, 25, 63, 1005, 63, 873,
1105, 1, 879, 4, 859, 1001, 64, 1, 64, 1002, 64, 2, 64, 109, 9,
21107, 47, 48, -3, 1005, 1010, 897, 4, 885, 1105, 1, 901, 1001, 64, 1,
64, 4, 64, 99, 21101, 0, 27, 1, 21101, 915, 0, 0, 1106, 0, 922,
21201, 1, 57526, 1, 204, 1, 99, 109, 3, 1207, -2, 3, 63, 1005, 63,
964, 21201, -2, -1, 1, 21101, 942, 0, 0, 1106, 0, 922, 21201, 1, 0,
-1, 21201, -2, -3, 1, 21101, 957, 0, 0, 1106, 0, 922, 22201, 1, -1,
-2, 1105, 1, 968, 21202, -2, 1, -2, 109, -3, 2106, 0, 0,
};
const expected = [_]i64{3380552333};
const tc = TestCase{
.code = code[0..],
.input = 1,
.expected_code = null,
.expected_output = expected[0..],
};
try tc.run();
} | share/zig/intcode_test.zig |
const sf = @import("../sfml.zig");
const math = @import("std").math;
pub fn Rect(comptime T: type) type {
return struct {
const Self = @This();
/// The CSFML vector type equivalent
const CsfmlEquivalent = switch (T) {
i32 => sf.c.sfIntRect,
f32 => sf.c.sfFloatRect,
else => void,
};
/// Creates a rect (just for convinience)
pub fn init(left: T, top: T, width: T, height: T) Self {
return Self{
.left = left,
.top = top,
.width = width,
.height = height,
};
}
/// Makes a CSFML rect with this rect (only if the corresponding type exists)
/// This is mainly for the inner workings of this wrapper
pub fn toCSFML(self: Self) CsfmlEquivalent {
if (CsfmlEquivalent == void) @compileError("This rectangle type doesn't have a CSFML equivalent.");
return CsfmlEquivalent{
.left = self.left,
.top = self.top,
.width = self.width,
.height = self.height,
};
}
/// Creates a rect from a CSFML one (only if the corresponding type exists)
/// This is mainly for the inner workings of this wrapper
pub fn fromCSFML(rect: CsfmlEquivalent) Self {
if (CsfmlEquivalent == void) @compileError("This rectangle type doesn't have a CSFML equivalent.");
return Self.init(rect.left, rect.top, rect.width, rect.width);
}
/// Checks if a point is inside this recangle
pub fn contains(self: Self, vec: sf.Vector2(T)) bool {
// Shamelessly stolen
var min_x: T = math.min(self.left, self.left + self.width);
var max_x: T = math.max(self.left, self.left + self.width);
var min_y: T = math.min(self.top, self.top + self.height);
var max_y: T = math.max(self.top, self.top + self.height);
return (vec.x >= min_x and
vec.x < max_x and
vec.y >= min_y and
vec.y < max_y);
}
/// Checks if two rectangles have a common intersection, if yes returns that zone, if not returns null
pub fn intersects(self: Self, other: Self) ?Self {
// Shamelessly stolen too
var r1_min_x: T = math.min(self.left, self.left + self.width);
var r1_max_x: T = math.max(self.left, self.left + self.width);
var r1_min_y: T = math.min(self.top, self.top + self.height);
var r1_max_y: T = math.max(self.top, self.top + self.height);
var r2_min_x: T = math.min(other.left, other.left + other.width);
var r2_max_x: T = math.max(other.left, other.left + other.width);
var r2_min_y: T = math.min(other.top, other.top + other.height);
var r2_max_y: T = math.max(other.top, other.top + other.height);
var inter_left: T = math.max(r1_min_x, r2_min_x);
var inter_top: T = math.max(r1_min_y, r2_min_y);
var inter_right: T = math.min(r1_max_x, r2_max_x);
var inter_bottom: T = math.min(r1_max_y, r2_max_y);
if (inter_left < inter_right and inter_top < inter_bottom) {
return Self.init(inter_left, inter_top, inter_right - inter_left, inter_bottom - inter_top);
} else {
return null;
}
}
/// Checks if two rectangles are the same
pub fn equals(self: Self, other: Self) bool {
return (self.left == other.left and
self.top == other.top and
self.width == other.width and
self.height == other.height);
}
/// Gets a vector with left and top components inside
pub fn getCorner(self: Self) sf.Vector2(T) {
return sf.Vector2(T){ .x = self.left, .y = self.top };
}
/// Gets a vector with the bottom right corner coordinates
pub fn getOtherCorner(self: Self) sf.Vector2(T) {
return self.getCorner().add(self.getSize());
}
/// Gets a vector with width and height components inside
pub fn getSize(self: Self) sf.Vector2(T) {
return sf.Vector2(T){ .x = self.width, .y = self.height };
}
/// x component of the top left corner
left: T,
/// x component of the top left corner
top: T,
/// width of the rectangle
width: T,
/// height of the rectangle
height: T
};
}
// Common rect types
pub const IntRect = Rect(i32);
pub const UintRect = Rect(u32);
pub const FloatRect = Rect(f32);
test "rect: intersect" {
const tst = @import("std").testing;
var r1 = IntRect.init(0, 0, 10, 10);
var r2 = IntRect.init(6, 6, 20, 20);
var r3 = IntRect.init(-5, -5, 10, 10);
tst.expectEqual(@as(?IntRect, null), r2.intersects(r3));
var inter1: sf.c.sfIntRect = undefined;
var inter2: sf.c.sfIntRect = undefined;
tst.expectEqual(sf.c.sfIntRect_intersects(&r1.toCSFML(), &r2.toCSFML(), &inter1), 1);
tst.expectEqual(sf.c.sfIntRect_intersects(&r1.toCSFML(), &r3.toCSFML(), &inter2), 1);
tst.expectEqual(IntRect.fromCSFML(inter1), r1.intersects(r2).?);
tst.expectEqual(IntRect.fromCSFML(inter2), r1.intersects(r3).?);
}
test "rect: contains" {
const tst = @import("std").testing;
var r1 = FloatRect.init(0, 0, 10, 10);
tst.expect(r1.contains(.{ .x = 0, .y = 0 }));
tst.expect(r1.contains(.{ .x = 9, .y = 9 }));
tst.expect(!r1.contains(.{ .x = 5, .y = -1 }));
tst.expect(!r1.contains(.{ .x = 10, .y = 5 }));
} | src/sfml/graphics/rect.zig |
const std = @import("std");
const Allocator = std.mem.Allocator;
const ArrayList = std.ArrayList;
const Map = std.AutoHashMap;
const StrMap = std.StringHashMap;
const BitSet = std.DynamicBitSet;
const Str = []const u8;
const util = @import("util.zig");
const gpa = util.gpa;
const data = @embedFile("../data/test/day18.txt");
const SfNumber = struct {
const Self = @This();
const Side = enum {
left,
right,
};
depth: u64 = 0,
value: ?u64 = null,
left: ?*Self = null,
right: ?*Self = null,
parent: ?*Self = null,
side: ?Side = null,
allocator: *Allocator,
fn valSplit(self: *Self, val: SfValue) SfValue {
switch (val) {
.sf => |sf_number| return val,
.value => |value| {
if (value < 10) return val;
var a = value / 2;
var b = value / 2 + value % 2;
var sf = Self.init(a, b, self.allocator);
sf.parent = self;
return .{ .sf = sf };
},
}
}
fn init(allocator: *Allocator) *Self {
var sf_area = allocator.alloc(Self, 1) catch unreachable;
var sf = &sf_area[0];
sf.* = .{ .allocator = allocator };
return sf;
}
fn initPair(left_val: u64, right_val: u64, allocator: *Allocator) *Self {
var sf = Self.init(allocator);
var left = Self.init(allocator);
var right = Self.init(allocator);
sf.*.left = left;
sf.*.right = right;
left.*.value = left_val;
right.*.value = right_val;
left.*.side = .left;
right.*.side = .right;
left.*.parent = sf;
right.*.parent = sf;
left.*.depth = 1;
right.*.depth = 1;
return sf;
}
fn assignChild(self: *Self, child: *Self, side: Side) void {
switch (side) {
.left => {
if (self.left) |old_child| old_child.deinit();
self.left = child;
},
.right => {
if (self.right) |old_child| old_child.deinit();
self.right = child;
},
}
child.side = side;
child.parent = self;
_ = child.updateDepth();
}
fn deinit(self: *Self) void {
if (self.left) |child| child.deinit();
if (self.right) |child| child.deinit();
self.allocator.free(@ptrCast(comptime *[1]Self, self));
}
fn updateDepth(self: *Self) u64 {
var d = self.depth;
if (self.parent) |parent| {
self.depth = parent.depth + 1;
} else {
self.depth = 0;
}
var max_depth = self.depth;
if (d != self.depth) {
if (self.left) |child| max_depth = max(max_depth, child.updateDepth());
if (self.right) |child| max_depth = max(max_depth, child.updateDepth());
}
return max_depth;
}
fn splitNode(self: *Self) *Self {
var a = self.value.? / 2;
var b = self.value.? / 2 + self.value.? % 2;
return Self.initPair(a, b, self.allocator);
}
fn doSplit(self: *Self) bool {
if (self.left) |child| {
if (child.value) |value| {
if (value >= 10) {
self.assignChild(child.splitNode(), .left);
return true;
}
} else {
if (child.doSplit()) return true;
}
}
if (self.right) |child| {
if (child.value) |value| {
if (value >= 10) {
self.assignChild(child.splitNode(), .right);
return true;
}
} else {
if (child.doSplit()) return true;
}
}
return false;
}
fn magnitude(self: *Self) u64 {
if (self.value) |value| return value;
return 3 * self.left.?.magnitude() + 2 * self.right.?.magnitude();
}
fn doExplode(self: *Self) bool {
if (self.depth >= 4 and self.value == null and self.left.?.value != null and self.right.?.value != null) {
var p = self.parent.?;
var left = self.left.?;
var right = self.right.?;
var a = left.value.?;
var b = right.value.?;
var side = self.side.?;
while (right.side != null and right.side.? == .right) {
right = right.parent.?;
}
if (right.parent != null) {
right = right.parent.?;
if (right.right.?.value != null) {
right.right.?.value.? += b;
} else {
right = right.right.?;
while (right.left.?.value == null) {
right = right.left.?;
}
right.left.?.value.? += b;
}
}
while (left.side != null and left.side.? == .left) {
left = left.parent.?;
}
if (left.parent != null) {
left = left.parent.?;
if (left.left.?.value != null) {
left.left.?.value.? += a;
} else {
left = left.left.?;
while (left.right.?.value == null) {
left = left.right.?;
}
left.right.?.value.? += a;
}
}
var child = Self.init(self.allocator);
child.value = 0;
p.assignChild(child, side);
return true;
}
if (self.left != null and self.left.?.doExplode()) return true;
if (self.left != null and self.right.?.doExplode()) return true;
return false;
}
fn simplfy(self: *Self) void {
var did_something: bool = true;
while (did_something) {
did_something = self.doExplode();
if (!did_something) {
did_something = self.doSplit();
}
}
}
fn parseFromString(str: []const u8, allocator: *Allocator) !*Self {
var depth: u64 = 0;
const SfParsedType = enum {
num,
pair,
};
const SfParsed = union(SfParsedType) {
num: u64,
pair: *Self,
};
var num_stack = ArrayList(SfParsed).init(gpa);
defer num_stack.deinit();
var idx: usize = 0;
while (idx < str.len) : (idx += 1) {
var char = str[idx];
switch (char) {
'0'...'9' => {
var part = tokenize(str[idx..], "[],").next().?;
var value = parseInt(u64, part, 0) catch unreachable;
num_stack.append(.{ .num = value }) catch unreachable;
idx += part.len - 1;
},
']' => {
var vright = num_stack.pop();
var vleft = num_stack.pop();
var sf = Self.init(allocator);
switch (vleft) {
.num => |num| {
var child = Self.init(allocator);
child.*.value = num;
sf.assignChild(child, .left);
},
.pair => |pair| sf.assignChild(pair, .left),
}
switch (vright) {
.num => |num| {
var child = Self.init(allocator);
child.*.value = num;
sf.assignChild(child, .right);
},
.pair => |pair| sf.assignChild(pair, .right),
}
num_stack.append(.{ .pair = sf }) catch unreachable;
},
else => {},
}
}
var x = num_stack.pop();
switch (x) {
.num => return error.InvalidNumber,
.pair => |value| return value,
}
}
fn printShort(self: *Self) void {
if (self.value) |value| {
print("{}", .{value});
} else {
print("[", .{});
if (self.left) |child| child.printShort();
print(",", .{});
if (self.right) |child| child.printShort();
print("]", .{});
}
}
fn printTree(self: *Self, depth: usize) void {
var idx: usize = 0;
while (idx < depth) : (idx += 1) {
print(" ", .{});
}
if (self.value) |value| {
print("{} {}\n", .{ self.side, value });
} else {
print("{} [\n", .{self.side});
}
if (self.left) |child| child.printTree(depth + 2);
if (self.right) |child| child.printTree(depth + 2);
}
};
pub fn main() !void {
var lines = tokenize(data, "\r\n");
var all_lines = ArrayList([]const u8).init(gpa);
defer all_lines.deinit();
var line0 = lines.next().?;
all_lines.append(line0) catch unreachable;
var sf_number = SfNumber.parseFromString(line0, gpa) catch unreachable;
defer sf_number.deinit();
while (lines.next()) |line| {
all_lines.append(line) catch unreachable;
var old_number = sf_number;
var new_number = SfNumber.parseFromString(line, gpa) catch unreachable;
sf_number = SfNumber.init(gpa);
sf_number.assignChild(old_number, .left);
sf_number.assignChild(new_number, .right);
sf_number.simplfy();
}
sf_number.printShort();
print(" {} \n", .{sf_number.magnitude()});
var maximum: u64 = 0;
{
var idx: usize = 0;
while (idx < all_lines.items.len) : (idx += 1) {
var jdx: usize = idx + 1;
while (jdx < all_lines.items.len) : (jdx += 1) {
{
var a = SfNumber.parseFromString(all_lines.items[idx], gpa) catch unreachable;
var b = SfNumber.parseFromString(all_lines.items[jdx], gpa) catch unreachable;
var x = SfNumber.init(gpa);
defer x.deinit();
x.assignChild(a, .left);
x.assignChild(b, .right);
x.simplfy();
maximum = max(x.magnitude(), maximum);
}
{
var a = SfNumber.parseFromString(all_lines.items[idx], gpa) catch unreachable;
var b = SfNumber.parseFromString(all_lines.items[jdx], gpa) catch unreachable;
var x = SfNumber.init(gpa);
defer x.deinit();
x.assignChild(b, .left);
x.assignChild(a, .right);
x.simplfy();
maximum = max(x.magnitude(), maximum);
}
}
}
}
print(" {} \n", .{maximum});
}
// Useful stdlib functions
const tokenize = std.mem.tokenize;
const split = std.mem.split;
const indexOf = std.mem.indexOfScalar;
const indexOfAny = std.mem.indexOfAny;
const indexOfStr = std.mem.indexOfPosLinear;
const lastIndexOf = std.mem.lastIndexOfScalar;
const lastIndexOfAny = std.mem.lastIndexOfAny;
const lastIndexOfStr = std.mem.lastIndexOfLinear;
const trim = std.mem.trim;
const sliceMin = std.mem.min;
const sliceMax = std.mem.max;
const parseInt = std.fmt.parseInt;
const parseFloat = std.fmt.parseFloat;
const min = std.math.min;
const min3 = std.math.min3;
const max = std.math.max;
const max3 = std.math.max3;
const print = std.debug.print;
const assert = std.debug.assert;
const sort = std.sort.sort;
const asc = std.sort.asc;
const desc = std.sort.desc; | src/day18.zig |
const base = @import("base.zig");
const warn = @import("std").debug.warn;
pub fn is16(ranges: []const base.Range16, r: u16) bool {
if (ranges.len <= base.linear_max or r <= base.linear_max) {
for (ranges) |*range| {
if (r < range.lo) {
return false;
}
if (r <= range.hi) {
return range.stride == 1 or (r - range.lo) % range.stride == 0;
}
}
return false;
}
var lo: usize = 0;
var hi: usize = ranges.len;
while (lo < hi) {
const m: usize = lo + ((hi - lo) / 2);
const range = &ranges[m];
if (range.lo <= r and r <= range.hi) {
return range.stride == 1 or (r - range.lo) % range.stride == 0;
}
if (r < range.lo) {
hi = m;
} else {
lo = m + 1;
}
}
return false;
}
pub fn is32(ranges: []base.Range32, r: u32) bool {
if (ranges.len <= base.linear_max or r <= base.max_latin1) {
for (ranges) |*range| {
if (r < range.lo) {
return false;
}
if (r <= range.hi) {
return range.stride == 1 or (r - range.lo) % range.stride == 0;
}
}
return false;
}
var lo: usize = 0;
var hi: usize = ranges.len;
while (lo < hi) {
const m: usize = lo + (hi - lo) / 2;
const range = &ranges[m];
if (range.lo <= r and r <= range.hi) {
return range.stride == 1 or (r - range.lo) % range.stride == 0;
}
if (r < range.lo) {
hi = m;
} else {
lo = m + 1;
}
}
return false;
}
pub fn is(range_tab: *const base.RangeTable, r: u32) bool {
if (range_tab.r16.len > 0 and r <= range_tab.r16[range_tab.r16.len - 1].hi) {
var x = @intCast(u16, r);
return is16(range_tab.r16, x);
}
if (range_tab.r32.len > 0 and r > range_tab.r32[0].lo) {
var x: u32 = r;
return is32(range_tab.r32, x);
}
return false;
}
pub fn isExcludingLatin(range_tab: *const base.RangeTable, r: u32) bool {
const off = range_tab.latin_offset;
const r16_len = range_tab.r16.len;
if (r16_len > off and r <= @intCast(u32, range_tab.r16[r16_len - 1].hi)) {
return is16(range_tab.r16[off..], @intCast(u16, r));
}
if (range_tab.r32.len > 0 and r >= range_tab.r32[0].lo) {
return is32(range_tab.r32, r);
}
return false;
} | src/unicode/letter.zig |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.