From 0db108101a30a2ac5ec4dc9911d488f9036256b8 Mon Sep 17 00:00:00 2001 From: Lachlan Easton Date: Mon, 9 Mar 2020 18:10:41 +1100 Subject: [PATCH 01/91] Translate C: Add comment containing c source location for failed decls --- src-self-hosted/translate_c.zig | 1 + 1 file changed, 1 insertion(+) diff --git a/src-self-hosted/translate_c.zig b/src-self-hosted/translate_c.zig index 41e4665ffe5a9c8d794d2c433b5170ebd03c8f0c..ffb76c60b78ec0c4f2d5fb4ad9922147ab8b82df 100644 --- a/src-self-hosted/translate_c.zig +++ b/src-self-hosted/translate_c.zig @@ -4687,6 +4687,7 @@ pub fn failDecl(c: *Context, loc: ZigClangSourceLocation, name: []const u8, comp const msg_tok = try appendTokenFmt(c, .StringLiteral, "\"" ++ format ++ "\"", args); const rparen_tok = try appendToken(c, .RParen, ")"); const semi_tok = try appendToken(c, .Semicolon, ";"); + _ = try appendTokenFmt(c, .LineComment, "// {}", .{c.locStr(loc)}); const msg_node = try c.a().create(ast.Node.StringLiteral); msg_node.* = ast.Node.StringLiteral{ -- 2.54.0 From a255b0f842cea070ae40bd62b77b63a3b256be75 Mon Sep 17 00:00:00 2001 From: Jadon Fowler Date: Wed, 1 Apr 2020 14:17:53 -0400 Subject: [PATCH 02/91] translate-c: translate DivAssign & RemAssign Closes #4790 Signed-off-by: Jadon Fowler --- src-self-hosted/translate_c.zig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src-self-hosted/translate_c.zig b/src-self-hosted/translate_c.zig index 6ba7fc8ca1a906e5f06f01235b354c2c287c5e67..da7053d25aa4ef2b207c71270d790103adabe6f2 100644 --- a/src-self-hosted/translate_c.zig +++ b/src-self-hosted/translate_c.zig @@ -3018,6 +3018,8 @@ fn transCompoundAssignOperator(rp: RestorePoint, scope: *Scope, stmt: *const Zig return transCreateCompoundAssign(rp, scope, stmt, .AssignSubWrap, .MinusPercentEqual, "-%=", .SubWrap, .MinusPercent, "-%", used) else return transCreateCompoundAssign(rp, scope, stmt, .AssignSub, .MinusPercentEqual, "-=", .Sub, .Minus, "-", used), + .DivAssign => return transCreateCompoundAssign(rp, scope, stmt, .AssignDiv, .SlashEqual, "/=", .Div, .Slash, "/", used), + .RemAssign => return transCreateCompoundAssign(rp, scope, stmt, .AssignMod, .PercentEqual, "%=", .Mod, .Percent, "%", used), .ShlAssign => return transCreateCompoundAssign(rp, scope, stmt, .AssignBitShiftLeft, .AngleBracketAngleBracketLeftEqual, "<<=", .BitShiftLeft, .AngleBracketAngleBracketLeft, "<<", used), .ShrAssign => return transCreateCompoundAssign(rp, scope, stmt, .AssignBitShiftRight, .AngleBracketAngleBracketRightEqual, ">>=", .BitShiftRight, .AngleBracketAngleBracketRight, ">>", used), .AndAssign => return transCreateCompoundAssign(rp, scope, stmt, .AssignBitAnd, .AmpersandEqual, "&=", .BitAnd, .Ampersand, "&", used), -- 2.54.0 From b9cb1e0d837a9660b95a4476202baf1533614c9d Mon Sep 17 00:00:00 2001 From: Jadon Fowler Date: Wed, 1 Apr 2020 14:28:21 -0400 Subject: [PATCH 03/91] translate-c: add tests for div & rem assignment Signed-off-by: Jadon Fowler --- test/translate_c.zig | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/translate_c.zig b/test/translate_c.zig index 8c84526a4914605e39a84e8070174271d2b7da63..a09f6b42b126ea465c056e467408964123737ba6 100644 --- a/test/translate_c.zig +++ b/test/translate_c.zig @@ -2381,6 +2381,8 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\ a &= (a &= 1); \\ a |= (a |= 1); \\ a ^= (a ^= 1); + \\ a /= (a /= 1); + \\ a %= (a %= 1); \\ a >>= (a >>= 1); \\ a <<= (a <<= 1); \\} @@ -2417,6 +2419,16 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\ ref.* = ref.* ^ @as(c_int, 1); \\ break :blk ref.*; \\ }); + \\ a /= (blk: { + \\ const ref = &a; + \\ ref.* = ref.* / @as(c_int, 1); + \\ break :blk ref.*; + \\ }); + \\ a %= (blk: { + \\ const ref = &a; + \\ ref.* = ref.* % @as(c_int, 1); + \\ break :blk ref.*; + \\ }); \\ a >>= @intCast(@import("std").math.Log2Int(c_int), (blk: { \\ const ref = &a; \\ ref.* = ref.* >> @intCast(@import("std").math.Log2Int(c_int), @as(c_int, 1)); -- 2.54.0 From dd570dbc0dd78e3b2f9cfb5a1febb325e585e12d Mon Sep 17 00:00:00 2001 From: xackus <14938807+xackus@users.noreply.github.com> Date: Tue, 31 Mar 2020 02:47:19 +0200 Subject: [PATCH 04/91] new ArrayList API, fix enough std lib to test --- lib/std/array_list.zig | 183 ++++++++++++++++++++------------------- lib/std/dwarf.zig | 8 +- lib/std/io/in_stream.zig | 2 +- 3 files changed, 100 insertions(+), 93 deletions(-) diff --git a/lib/std/array_list.zig b/lib/std/array_list.zig index 523d1c810f6b7d1dadec54b1f19d6fea646e5031..94383c49efda922d2cd2b07fb0f162f40e8f4370 100644 --- a/lib/std/array_list.zig +++ b/lib/std/array_list.zig @@ -20,11 +20,9 @@ pub fn AlignedArrayList(comptime T: type, comptime alignment: ?u29) type { return struct { const Self = @This(); - /// Use `span` instead of slicing this directly, because if you don't - /// specify the end position of the slice, this will potentially give - /// you uninitialized memory. + /// Content of the ArrayList items: Slice, - len: usize, + capacity: usize, allocator: *Allocator, pub const Slice = if (alignment) |a| ([]align(a) T) else []T; @@ -34,7 +32,7 @@ pub fn AlignedArrayList(comptime T: type, comptime alignment: ?u29) type { pub fn init(allocator: *Allocator) Self { return Self{ .items = &[_]T{}, - .len = 0, + .capacity = 0, .allocator = allocator, }; } @@ -49,60 +47,55 @@ pub fn AlignedArrayList(comptime T: type, comptime alignment: ?u29) type { /// Release all allocated memory. pub fn deinit(self: Self) void { - self.allocator.free(self.items); + self.allocator.free(self.allocatedSlice()); } + /// Deprecated: use `items` field directly. /// Return contents as a slice. Only valid while the list /// doesn't change size. - pub fn span(self: var) @TypeOf(self.items[0..self.len]) { - return self.items[0..self.len]; + pub fn span(self: var) @TypeOf(self.items) { + return self.items; } - /// Deprecated: use `span`. + /// Deprecated: use `items` field directly. pub fn toSlice(self: Self) Slice { - return self.span(); + return self.items; } - /// Deprecated: use `span`. + /// Deprecated: use `items` field directly. pub fn toSliceConst(self: Self) SliceConst { - return self.span(); + return self.items; } - /// Deprecated: use `span()[i]`. + /// Deprecated: use `list.items[i]`. pub fn at(self: Self, i: usize) T { - return self.span()[i]; + return self.items[i]; } - /// Deprecated: use `&span()[i]`. + /// Deprecated: use `&list.items[i]`. pub fn ptrAt(self: Self, i: usize) *T { - return &self.span()[i]; + return &self.items[i]; } - /// Deprecated: use `if (i >= list.len) return error.OutOfBounds else span()[i] = item`. + /// Deprecated: use `if (i >= list.items.len) return error.OutOfBounds else list.items[i] = item`. pub fn setOrError(self: Self, i: usize, item: T) !void { - if (i >= self.len) return error.OutOfBounds; + if (i >= self.items.len) return error.OutOfBounds; self.items[i] = item; } - /// Deprecated: use `list.span()[i] = item`. + /// Deprecated: use `list.items[i] = item`. pub fn set(self: *Self, i: usize, item: T) void { - assert(i < self.len); + assert(i < self.items.len); self.items[i] = item; } - /// Return the maximum number of items the list can hold - /// without allocating more memory. - pub fn capacity(self: Self) usize { - return self.items.len; - } - /// ArrayList takes ownership of the passed in slice. The slice must have been /// allocated with `allocator`. /// Deinitialize with `deinit` or use `toOwnedSlice`. pub fn fromOwnedSlice(allocator: *Allocator, slice: Slice) Self { return Self{ .items = slice, - .len = slice.len, + .capacity = slice.len, .allocator = allocator, }; } @@ -110,7 +103,7 @@ pub fn AlignedArrayList(comptime T: type, comptime alignment: ?u29) type { /// The caller owns the returned memory. ArrayList becomes empty. pub fn toOwnedSlice(self: *Self) Slice { const allocator = self.allocator; - const result = allocator.shrink(self.items, self.len); + const result = allocator.shrink(self.allocatedSlice(), self.items.len); self.* = init(allocator); return result; } @@ -118,10 +111,10 @@ pub fn AlignedArrayList(comptime T: type, comptime alignment: ?u29) type { /// Insert `item` at index `n`. Moves `list[n .. list.len]` /// to make room. pub fn insert(self: *Self, n: usize, item: T) !void { - try self.ensureCapacity(self.len + 1); - self.len += 1; + try self.ensureCapacity(self.items.len + 1); + self.items.len += 1; - mem.copyBackwards(T, self.items[n + 1 .. self.len], self.items[n .. self.len - 1]); + mem.copyBackwards(T, self.items[n + 1 .. self.items.len], self.items[n .. self.items.len - 1]); self.items[n] = item; } @@ -129,10 +122,10 @@ pub fn AlignedArrayList(comptime T: type, comptime alignment: ?u29) type { /// `list[i .. list.len]` to make room. /// This operation is O(N). pub fn insertSlice(self: *Self, i: usize, items: SliceConst) !void { - try self.ensureCapacity(self.len + items.len); - self.len += items.len; + try self.ensureCapacity(self.items.len + items.len); + self.items.len += items.len; - mem.copyBackwards(T, self.items[i + items.len .. self.len], self.items[i .. self.len - items.len]); + mem.copyBackwards(T, self.items[i + items.len .. self.items.len], self.items[i .. self.items.len - items.len]); mem.copy(T, self.items[i .. i + items.len], items); } @@ -153,13 +146,13 @@ pub fn AlignedArrayList(comptime T: type, comptime alignment: ?u29) type { /// Asserts the array has at least one item. /// This operation is O(N). pub fn orderedRemove(self: *Self, i: usize) T { - const newlen = self.len - 1; + const newlen = self.items.len - 1; if (newlen == i) return self.pop(); - const old_item = self.at(i); + const old_item = self.items[i]; for (self.items[i..newlen]) |*b, j| b.* = self.items[i + 1 + j]; self.items[newlen] = undefined; - self.len = newlen; + self.items.len = newlen; return old_item; } @@ -167,26 +160,28 @@ pub fn AlignedArrayList(comptime T: type, comptime alignment: ?u29) type { /// The empty slot is filled from the end of the list. /// This operation is O(1). pub fn swapRemove(self: *Self, i: usize) T { - if (self.len - 1 == i) return self.pop(); + if (self.items.len - 1 == i) return self.pop(); - const slice = self.span(); - const old_item = slice[i]; - slice[i] = self.pop(); + const old_item = self.items[i]; + self.items[i] = self.pop(); return old_item; } - /// Deprecated: use `if (i >= list.len) return error.OutOfBounds else list.swapRemove(i)`. + /// Deprecated: use `if (i >= list.items.len) return error.OutOfBounds else list.swapRemove(i)`. pub fn swapRemoveOrError(self: *Self, i: usize) !T { - if (i >= self.len) return error.OutOfBounds; + if (i >= self.items.len) return error.OutOfBounds; return self.swapRemove(i); } /// Append the slice of items to the list. Allocates more /// memory as necessary. pub fn appendSlice(self: *Self, items: SliceConst) !void { - try self.ensureCapacity(self.len + items.len); - mem.copy(T, self.items[self.len..], items); - self.len += items.len; + const oldlen = self.items.len; + const newlen = self.items.len + items.len; + + try self.ensureCapacity(newlen); + self.items.len = newlen; + mem.copy(T, self.items[oldlen..], items); } /// Same as `append` except it returns the number of bytes written, which is always the same @@ -206,50 +201,55 @@ pub fn AlignedArrayList(comptime T: type, comptime alignment: ?u29) type { /// Append a value to the list `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(self.len + n); - mem.set(T, self.items[old_len..self.len], value); + const old_len = self.items.len; + try self.resize(self.items.len + n); + mem.set(T, self.items[old_len..self.items.len], value); } /// Adjust the list's length to `new_len`. /// Does not initialize added items if any. pub fn resize(self: *Self, new_len: usize) !void { try self.ensureCapacity(new_len); - self.len = new_len; + self.items.len = new_len; } /// Reduce allocated capacity to `new_len`. /// Invalidates element pointers. pub fn shrink(self: *Self, new_len: usize) void { - assert(new_len <= self.len); - self.len = new_len; - self.items = self.allocator.realloc(self.items, new_len) catch |e| switch (e) { + assert(new_len <= self.items.len); + + self.items = self.allocator.realloc(self.allocatedSlice(), new_len) catch |e| switch (e) { error.OutOfMemory => return, // no problem, capacity is still correct then. }; + self.capacity = new_len; } pub fn ensureCapacity(self: *Self, new_capacity: usize) !void { - var better_capacity = self.capacity(); + var better_capacity = self.capacity; if (better_capacity >= new_capacity) return; + while (true) { better_capacity += better_capacity / 2 + 8; if (better_capacity >= new_capacity) break; } - self.items = try self.allocator.realloc(self.items, better_capacity); + + const new_memory = try self.allocator.realloc(self.allocatedSlice(), better_capacity); + self.items.ptr = new_memory.ptr; + self.capacity = new_memory.len; } /// Increases the array's length to match the full capacity that is already allocated. /// The new elements have `undefined` values. This operation does not invalidate any /// element pointers. pub fn expandToCapacity(self: *Self) void { - self.len = self.items.len; + self.items.len = self.capacity; } /// Increase length by 1, returning pointer to the new item. /// The returned pointer becomes invalid when the list is resized. pub fn addOne(self: *Self) !*T { - const new_length = self.len + 1; - try self.ensureCapacity(new_length); + const newlen = self.items.len + 1; + try self.ensureCapacity(newlen); return self.addOneAssumeCapacity(); } @@ -257,25 +257,32 @@ pub fn AlignedArrayList(comptime T: type, comptime alignment: ?u29) type { /// Asserts that there is already space for the new item without allocating more. /// The returned pointer becomes invalid when the list is resized. pub fn addOneAssumeCapacity(self: *Self) *T { - assert(self.len < self.capacity()); - const result = &self.items[self.len]; - self.len += 1; - return result; + assert(self.items.len < self.capacity); + + self.items.len += 1; + return &self.items[self.items.len - 1]; } /// Remove and return the last element from the list. /// Asserts the list has at least one item. pub fn pop(self: *Self) T { - self.len -= 1; - return self.items[self.len]; + const val = self.items[self.items.len - 1]; + self.items.len -= 1; + return val; } /// Remove and return the last element from the list. /// If the list is empty, returns `null`. pub fn popOrNull(self: *Self) ?T { - if (self.len == 0) return null; + if (self.items.len == 0) return null; return self.pop(); } + + // For a nicer API, `items.len` is the length, not the capacity. + // This requires "unsafe" slicing. + fn allocatedSlice(self: Self) Slice { + return self.items.ptr[0..self.capacity]; + } }; } @@ -283,15 +290,15 @@ test "std.ArrayList.init" { var list = ArrayList(i32).init(testing.allocator); defer list.deinit(); - testing.expect(list.len == 0); - testing.expect(list.capacity() == 0); + testing.expect(list.items.len == 0); + testing.expect(list.capacity == 0); } test "std.ArrayList.initCapacity" { var list = try ArrayList(i8).initCapacity(testing.allocator, 200); defer list.deinit(); - testing.expect(list.len == 0); - testing.expect(list.capacity() >= 200); + testing.expect(list.items.len == 0); + testing.expect(list.capacity >= 200); } test "std.ArrayList.basic" { @@ -315,7 +322,7 @@ test "std.ArrayList.basic" { } } - for (list.span()) |v, i| { + for (list.items) |v, i| { testing.expect(v == @intCast(i32, i + 1)); } @@ -324,19 +331,19 @@ test "std.ArrayList.basic" { } testing.expect(list.pop() == 10); - testing.expect(list.len == 9); + testing.expect(list.items.len == 9); list.appendSlice(&[_]i32{ 1, 2, 3 }) catch unreachable; - testing.expect(list.len == 12); + testing.expect(list.items.len == 12); testing.expect(list.pop() == 3); testing.expect(list.pop() == 2); testing.expect(list.pop() == 1); - testing.expect(list.len == 9); + testing.expect(list.items.len == 9); list.appendSlice(&[_]i32{}) catch unreachable; - testing.expect(list.len == 9); + testing.expect(list.items.len == 9); - // can only set on indices < self.len + // can only set on indices < self.items.len list.set(7, 33); list.set(8, 42); @@ -352,8 +359,8 @@ test "std.ArrayList.appendNTimes" { defer list.deinit(); try list.appendNTimes(2, 10); - testing.expectEqual(@as(usize, 10), list.len); - for (list.span()) |element| { + testing.expectEqual(@as(usize, 10), list.items.len); + for (list.items) |element| { testing.expectEqual(@as(i32, 2), element); } } @@ -378,17 +385,17 @@ test "std.ArrayList.orderedRemove" { //remove from middle testing.expectEqual(@as(i32, 4), list.orderedRemove(3)); - testing.expectEqual(@as(i32, 5), list.at(3)); - testing.expectEqual(@as(usize, 6), list.len); + testing.expectEqual(@as(i32, 5), list.items[3]); + testing.expectEqual(@as(usize, 6), list.items.len); //remove from end testing.expectEqual(@as(i32, 7), list.orderedRemove(5)); - testing.expectEqual(@as(usize, 5), list.len); + testing.expectEqual(@as(usize, 5), list.items.len); //remove from front testing.expectEqual(@as(i32, 1), list.orderedRemove(0)); - testing.expectEqual(@as(i32, 2), list.at(0)); - testing.expectEqual(@as(usize, 4), list.len); + testing.expectEqual(@as(i32, 2), list.items[0]); + testing.expectEqual(@as(usize, 4), list.items.len); } test "std.ArrayList.swapRemove" { @@ -405,17 +412,17 @@ test "std.ArrayList.swapRemove" { //remove from middle testing.expect(list.swapRemove(3) == 4); - testing.expect(list.at(3) == 7); - testing.expect(list.len == 6); + testing.expect(list.items[3] == 7); + testing.expect(list.items.len == 6); //remove from end testing.expect(list.swapRemove(5) == 6); - testing.expect(list.len == 5); + testing.expect(list.items.len == 5); //remove from front testing.expect(list.swapRemove(0) == 1); - testing.expect(list.at(0) == 5); - testing.expect(list.len == 4); + testing.expect(list.items[0] == 5); + testing.expect(list.items.len == 4); } test "std.ArrayList.swapRemoveOrError" { @@ -478,7 +485,7 @@ test "std.ArrayList.insertSlice" { const items = [_]i32{1}; try list.insertSlice(0, items[0..0]); - testing.expect(list.len == 6); + testing.expect(list.items.len == 6); testing.expect(list.items[0] == 1); } diff --git a/lib/std/dwarf.zig b/lib/std/dwarf.zig index 95403bc1096c215c8939624ef4b4def87cd3c575..3381321330db3a4022d6f3d560590f0850813e83 100644 --- a/lib/std/dwarf.zig +++ b/lib/std/dwarf.zig @@ -206,7 +206,7 @@ const LineNumberProgram = struct { if (self.target_address >= self.prev_address and self.target_address < self.address) { const file_entry = if (self.prev_file == 0) { return error.MissingDebugInfo; - } else if (self.prev_file - 1 >= self.file_entries.len) { + } else if (self.prev_file - 1 >= self.file_entries.items.len) { return error.InvalidDebugInfo; } else &self.file_entries.items[self.prev_file - 1]; @@ -645,7 +645,7 @@ pub const DwarfInfo = struct { .offset = abbrev_offset, .table = try di.parseAbbrevTable(abbrev_offset), }); - return &di.abbrev_table_list.items[di.abbrev_table_list.len - 1].table; + return &di.abbrev_table_list.items[di.abbrev_table_list.items.len - 1].table; } fn parseAbbrevTable(di: *DwarfInfo, offset: u64) !AbbrevTable { @@ -665,7 +665,7 @@ pub const DwarfInfo = struct { .has_children = (try in.readByte()) == CHILDREN_yes, .attrs = ArrayList(AbbrevAttr).init(di.allocator()), }); - const attrs = &result.items[result.len - 1].attrs; + const attrs = &result.items[result.items.len - 1].attrs; while (true) { const attr_id = try leb.readULEB128(u64, in); @@ -689,7 +689,7 @@ pub const DwarfInfo = struct { .has_children = table_entry.has_children, .attrs = ArrayList(Die.Attr).init(di.allocator()), }; - try result.attrs.resize(table_entry.attrs.len); + try result.attrs.resize(table_entry.attrs.items.len); for (table_entry.attrs.span()) |attr, i| { result.attrs.items[i] = Die.Attr{ .id = attr.attr_id, diff --git a/lib/std/io/in_stream.zig b/lib/std/io/in_stream.zig index 340995198f52ce27185835db5485e14257fa748c..f9696a328de0f470f8c8e4e61ec0e6cb28fe276e 100644 --- a/lib/std/io/in_stream.zig +++ b/lib/std/io/in_stream.zig @@ -106,7 +106,7 @@ pub fn InStream( return; } - if (array_list.len == max_size) { + if (array_list.items.len == max_size) { return error.StreamTooLong; } -- 2.54.0 From 93a20f2e825790daa487eae0ccec3d7c9126f42c Mon Sep 17 00:00:00 2001 From: xackus <14938807+xackus@users.noreply.github.com> Date: Tue, 31 Mar 2020 03:17:05 +0200 Subject: [PATCH 05/91] new ArrayList API: fix std.ArrayListSentineled --- lib/std/array_list_sentineled.zig | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/std/array_list_sentineled.zig b/lib/std/array_list_sentineled.zig index ee262b032276bd5cfda00b52439534e7ceda61a5..b83cc4ad62b46c5cf3cfa120221ac4a13667c5ce 100644 --- a/lib/std/array_list_sentineled.zig +++ b/lib/std/array_list_sentineled.zig @@ -82,8 +82,8 @@ pub fn ArrayListSentineled(comptime T: type, comptime sentinel: T) type { self.list.deinit(); } - pub fn span(self: var) @TypeOf(self.list.items[0 .. self.list.len - 1 :sentinel]) { - return self.list.span()[0..self.len() :sentinel]; + pub fn span(self: var) @TypeOf(self.list.items[0..:sentinel]) { + return self.list.items[0..self.len() :sentinel]; } pub fn shrink(self: *Self, new_len: usize) void { @@ -98,16 +98,16 @@ pub fn ArrayListSentineled(comptime T: type, comptime sentinel: T) type { } pub fn isNull(self: Self) bool { - return self.list.len == 0; + return self.list.items.len == 0; } pub fn len(self: Self) usize { - return self.list.len - 1; + return self.list.items.len - 1; } pub fn capacity(self: Self) usize { - return if (self.list.items.len > 0) - self.list.items.len - 1 + return if (self.list.capacity > 0) + self.list.capacity - 1 else 0; } @@ -115,13 +115,13 @@ pub fn ArrayListSentineled(comptime T: type, comptime sentinel: T) type { pub fn appendSlice(self: *Self, m: []const T) !void { const old_len = self.len(); try self.resize(old_len + m.len); - mem.copy(T, self.list.span()[old_len..], m); + mem.copy(T, self.list.items[old_len..], m); } pub fn append(self: *Self, byte: T) !void { const old_len = self.len(); try self.resize(old_len + 1); - self.list.span()[old_len] = byte; + self.list.items[old_len] = byte; } pub fn eql(self: Self, m: []const T) bool { -- 2.54.0 From d3ab0eb28de5a5a94fd4ef988dd4c4b0e3ddf927 Mon Sep 17 00:00:00 2001 From: xackus <14938807+xackus@users.noreply.github.com> Date: Wed, 1 Apr 2020 21:05:46 +0200 Subject: [PATCH 06/91] new ArrayList API: fix ArrayList.shrink --- lib/std/array_list.zig | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/std/array_list.zig b/lib/std/array_list.zig index 94383c49efda922d2cd2b07fb0f162f40e8f4370..c6bb5bf3e7328d42bd2af85d99b6a00fe33234b7 100644 --- a/lib/std/array_list.zig +++ b/lib/std/array_list.zig @@ -219,7 +219,10 @@ pub fn AlignedArrayList(comptime T: type, comptime alignment: ?u29) type { assert(new_len <= self.items.len); self.items = self.allocator.realloc(self.allocatedSlice(), new_len) catch |e| switch (e) { - error.OutOfMemory => return, // no problem, capacity is still correct then. + error.OutOfMemory => { // no problem, capacity is still correct then. + self.items.len = new_len; + return; + }, }; self.capacity = new_len; } @@ -511,3 +514,18 @@ test "std.ArrayList(u8) implements outStream" { testing.expectEqualSlices(u8, "x: 42\ny: 1234\n", buffer.span()); } + +test "std.ArrayList.shrink still sets length on error.OutOfMemory" { + // use an arena allocator to make sure realloc returns error.OutOfMemory + var arena = std.heap.ArenaAllocator.init(testing.allocator); + defer arena.deinit(); + + var list = ArrayList(i32).init(&arena.allocator); + + try list.append(1); + try list.append(2); + try list.append(3); + + list.shrink(1); + testing.expect(list.items.len == 1); +} -- 2.54.0 From 7a28c644aa8eb3d27dee113338af8278f8f6334f Mon Sep 17 00:00:00 2001 From: xackus <14938807+xackus@users.noreply.github.com> Date: Thu, 2 Apr 2020 00:00:42 +0200 Subject: [PATCH 07/91] new ArrayList API: fix everything else --- lib/std/build.zig | 4 ++-- lib/std/build/emit_raw.zig | 2 +- lib/std/coff.zig | 2 +- lib/std/debug.zig | 2 +- lib/std/fs.zig | 6 +++--- lib/std/http/headers.zig | 24 ++++++++++++------------ lib/std/io/in_stream.zig | 2 +- lib/std/json.zig | 20 ++++++++++---------- lib/std/math/big/rational.zig | 1 - lib/std/net.zig | 16 ++++++++-------- lib/std/special/build_runner.zig | 2 +- lib/std/unicode.zig | 4 ++-- src-self-hosted/libc_installation.zig | 6 +++--- src-self-hosted/stage2.zig | 4 ++-- src-self-hosted/translate_c.zig | 6 +++--- test/standalone/brace_expansion/main.zig | 4 ++-- test/tests.zig | 4 ++-- tools/merge_anal_dumps.zig | 8 ++++---- 18 files changed, 58 insertions(+), 59 deletions(-) diff --git a/lib/std/build.zig b/lib/std/build.zig index ccd0ebaf8adf4166bce0d521e6bd99edba5a612d..f62448ea1c49a561778d82b76bd6bfc742055db0 100644 --- a/lib/std/build.zig +++ b/lib/std/build.zig @@ -1779,7 +1779,7 @@ pub const LibExeObjStep = struct { const self = @fieldParentPtr(LibExeObjStep, "step", step); const builder = self.builder; - if (self.root_src == null and self.link_objects.len == 0) { + if (self.root_src == null and self.link_objects.items.len == 0) { warn("{}: linker needs 1 or more objects to link\n", .{self.step.name}); return error.NeedAnObject; } @@ -1847,7 +1847,7 @@ pub const LibExeObjStep = struct { } } - if (self.build_options_contents.len > 0) { + if (self.build_options_contents.items.len > 0) { const build_options_file = try fs.path.join( builder.allocator, &[_][]const u8{ builder.cache_root, builder.fmt("{}_build_options.zig", .{self.name}) }, diff --git a/lib/std/build/emit_raw.zig b/lib/std/build/emit_raw.zig index 367da2f747331bbe1a28404b11bbff26095f4a1f..f3549491d618e4f95db4679f11079c8d446ba16d 100644 --- a/lib/std/build/emit_raw.zig +++ b/lib/std/build/emit_raw.zig @@ -94,7 +94,7 @@ const BinaryElfOutput = struct { sort.sort(*BinaryElfSegment, self.segments.span(), segmentSortCompare); - if (self.segments.len > 0) { + if (self.segments.items.len > 0) { const firstSegment = self.segments.at(0); if (firstSegment.firstSection) |firstSection| { const diff = firstSection.elfOffset - firstSegment.elfOffset; diff --git a/lib/std/coff.zig b/lib/std/coff.zig index d89019eec689e5cb757a8f7c049cc74a8b1ecf9f..1ab88f6baffdfa2c64cdff189f3f61efd92fbf3d 100644 --- a/lib/std/coff.zig +++ b/lib/std/coff.zig @@ -181,7 +181,7 @@ pub const Coff = struct { } pub fn loadSections(self: *Coff) !void { - if (self.sections.len == self.coff_header.number_of_sections) + if (self.sections.items.len == self.coff_header.number_of_sections) return; try self.sections.ensureCapacity(self.coff_header.number_of_sections); diff --git a/lib/std/debug.zig b/lib/std/debug.zig index 9e14d132a84204afdd03f6edb774991315e74c94..ed327fc6de4c0f81dca44e7dcc94482c2ab724a1 100644 --- a/lib/std/debug.zig +++ b/lib/std/debug.zig @@ -1478,7 +1478,7 @@ pub const ModuleDebugInfo = switch (builtin.os.tag) { var coff_section: *coff.Section = undefined; const mod_index = for (self.sect_contribs) |sect_contrib| { - if (sect_contrib.Section > self.coff.sections.len) continue; + if (sect_contrib.Section > self.coff.sections.items.len) continue; // Remember that SectionContribEntry.Section is 1-based. coff_section = &self.coff.sections.span()[sect_contrib.Section - 1]; diff --git a/lib/std/fs.zig b/lib/std/fs.zig index 0eeb1758f26efc60d10612c9170709229941d55a..feb74be2c891aaf4102e19eca1dbe1defaef720e 100644 --- a/lib/std/fs.zig +++ b/lib/std/fs.zig @@ -1440,9 +1440,9 @@ pub const Walker = struct { /// a reference to the path. pub fn next(self: *Walker) !?Entry { while (true) { - if (self.stack.len == 0) return null; + if (self.stack.items.len == 0) return null; // `top` becomes invalid after appending to `self.stack`. - const top = &self.stack.span()[self.stack.len - 1]; + const top = &self.stack.span()[self.stack.items.len - 1]; const dirname_len = top.dirname_len; if (try top.dir_it.next()) |base| { self.name_buffer.shrink(dirname_len); @@ -1457,7 +1457,7 @@ pub const Walker = struct { errdefer new_dir.close(); try self.stack.append(StackItem{ .dir_it = new_dir.iterate(), - .dirname_len = self.name_buffer.len, + .dirname_len = self.name_buffer.items.len, }); } } diff --git a/lib/std/http/headers.zig b/lib/std/http/headers.zig index a4558435397450b8938a02fa0b76465cbce428a1..bcbd6a1e192eb9cf6f26efb857508c4e11d6e5c2 100644 --- a/lib/std/http/headers.zig +++ b/lib/std/http/headers.zig @@ -139,7 +139,7 @@ pub const Headers = struct { pub fn clone(self: Self, allocator: *Allocator) !Self { var other = Headers.init(allocator); errdefer other.deinit(); - try other.data.ensureCapacity(self.data.len); + try other.data.ensureCapacity(self.data.items.len); try other.index.initCapacity(self.index.entries.len); for (self.data.span()) |entry| { try other.append(entry.name, entry.value, entry.never_index); @@ -152,7 +152,7 @@ pub const Headers = struct { } pub fn append(self: *Self, name: []const u8, value: []const u8, never_index: ?bool) !void { - const n = self.data.len + 1; + const n = self.data.items.len + 1; try self.data.ensureCapacity(n); var entry: HeaderEntry = undefined; if (self.index.get(name)) |kv| { @@ -197,7 +197,7 @@ pub const Headers = struct { if (self.index.remove(name)) |kv| { var dex = &kv.value; // iterate backwards - var i = dex.len; + var i = dex.items.len; while (i > 0) { i -= 1; const data_index = dex.at(i); @@ -220,18 +220,18 @@ pub const Headers = struct { const removed = self.data.orderedRemove(i); const kv = self.index.get(removed.name).?; var dex = &kv.value; - if (dex.len == 1) { + if (dex.items.len == 1) { // was last item; delete the index _ = self.index.remove(kv.key); dex.deinit(); removed.deinit(); self.allocator.free(kv.key); } else { - dex.shrink(dex.len - 1); + dex.shrink(dex.items.len - 1); removed.deinit(); } // if it was the last item; no need to rebuild index - if (i != self.data.len) { + if (i != self.data.items.len) { self.rebuild_index(); } } @@ -242,18 +242,18 @@ pub const Headers = struct { const removed = self.data.swapRemove(i); const kv = self.index.get(removed.name).?; var dex = &kv.value; - if (dex.len == 1) { + if (dex.items.len == 1) { // was last item; delete the index _ = self.index.remove(kv.key); dex.deinit(); removed.deinit(); self.allocator.free(kv.key); } else { - dex.shrink(dex.len - 1); + dex.shrink(dex.items.len - 1); removed.deinit(); } // if it was the last item; no need to rebuild index - if (i != self.data.len) { + if (i != self.data.items.len) { self.rebuild_index(); } } @@ -277,7 +277,7 @@ pub const Headers = struct { pub fn get(self: Self, allocator: *Allocator, name: []const u8) !?[]const HeaderEntry { const dex = self.getIndices(name) orelse return null; - const buf = try allocator.alloc(HeaderEntry, dex.len); + const buf = try allocator.alloc(HeaderEntry, dex.items.len); var n: usize = 0; for (dex.span()) |idx| { buf[n] = self.data.at(idx); @@ -301,7 +301,7 @@ pub const Headers = struct { // adapted from mem.join const total_len = blk: { - var sum: usize = dex.len - 1; // space for separator(s) + var sum: usize = dex.items.len - 1; // space for separator(s) for (dex.span()) |idx| sum += self.data.at(idx).value.len; break :blk sum; @@ -330,7 +330,7 @@ pub const Headers = struct { var it = self.index.iterator(); while (it.next()) |kv| { var dex = &kv.value; - dex.len = 0; // keeps capacity available + dex.items.len = 0; // keeps capacity available } } { // fill up indexes again; we know capacity is fine from before diff --git a/lib/std/io/in_stream.zig b/lib/std/io/in_stream.zig index f9696a328de0f470f8c8e4e61ec0e6cb28fe276e..2a03ba3037104ad3fa7c313802ca56344f22ae64 100644 --- a/lib/std/io/in_stream.zig +++ b/lib/std/io/in_stream.zig @@ -54,7 +54,7 @@ pub fn InStream( /// and the `std.ArrayList` has exactly `max_append_size` bytes appended. pub fn readAllArrayList(self: Self, array_list: *std.ArrayList(u8), max_append_size: usize) !void { try array_list.ensureCapacity(math.min(max_append_size, 4096)); - const original_len = array_list.len; + const original_len = array_list.items.len; var start_index: usize = original_len; while (true) { array_list.expandToCapacity(); diff --git a/lib/std/json.zig b/lib/std/json.zig index 12020e6e25eaa9e72352582ce075638de09d5b7d..79830d8a2c45d95259b99a86c1569d427cbf30e8 100644 --- a/lib/std/json.zig +++ b/lib/std/json.zig @@ -1556,7 +1556,7 @@ fn parseInternal(comptime T: type, token: Token, tokens: *TokenStream, options: else => {}, } - try arraylist.ensureCapacity(arraylist.len + 1); + try arraylist.ensureCapacity(arraylist.items.len + 1); const v = try parseInternal(ptrInfo.child, tok, tokens, options); arraylist.appendAssumeCapacity(v); } @@ -1874,7 +1874,7 @@ pub const Parser = struct { try p.transition(&arena.allocator, input, s.i - 1, token); } - debug.assert(p.stack.len == 1); + debug.assert(p.stack.items.len == 1); return ValueTree{ .arena = arena, @@ -1888,7 +1888,7 @@ pub const Parser = struct { switch (p.state) { .ObjectKey => switch (token) { .ObjectEnd => { - if (p.stack.len == 1) { + if (p.stack.items.len == 1) { return; } @@ -1907,8 +1907,8 @@ pub const Parser = struct { }, }, .ObjectValue => { - var object = &p.stack.items[p.stack.len - 2].Object; - var key = p.stack.items[p.stack.len - 1].String; + var object = &p.stack.items[p.stack.items.len - 2].Object; + var key = p.stack.items[p.stack.items.len - 1].String; switch (token) { .ObjectBegin => { @@ -1950,11 +1950,11 @@ pub const Parser = struct { } }, .ArrayValue => { - var array = &p.stack.items[p.stack.len - 1].Array; + var array = &p.stack.items[p.stack.items.len - 1].Array; switch (token) { .ArrayEnd => { - if (p.stack.len == 1) { + if (p.stack.items.len == 1) { return; } @@ -2021,12 +2021,12 @@ pub const Parser = struct { } fn pushToParent(p: *Parser, value: *const Value) !void { - switch (p.stack.span()[p.stack.len - 1]) { + switch (p.stack.span()[p.stack.items.len - 1]) { // Object Parent -> [ ..., object, , value ] Value.String => |key| { _ = p.stack.pop(); - var object = &p.stack.items[p.stack.len - 1].Object; + var object = &p.stack.items[p.stack.items.len - 1].Object; _ = try object.put(key, value.*); p.state = .ObjectKey; }, @@ -2165,7 +2165,7 @@ test "json.parser.dynamic" { testing.expect(animated.Bool == false); const array_of_object = image.Object.get("ArrayOfObject").?.value; - testing.expect(array_of_object.Array.len == 1); + testing.expect(array_of_object.Array.items.len == 1); const obj0 = array_of_object.Array.at(0).Object.get("n").?.value; testing.expect(mem.eql(u8, obj0.String, "m")); diff --git a/lib/std/math/big/rational.zig b/lib/std/math/big/rational.zig index cf885585767985ceccea05cef69069860f4293e5..8d2932a92052ca6fa26e0617200af33cf70e40d2 100644 --- a/lib/std/math/big/rational.zig +++ b/lib/std/math/big/rational.zig @@ -4,7 +4,6 @@ const math = std.math; const mem = std.mem; const testing = std.testing; const Allocator = mem.Allocator; -const ArrayList = std.ArrayList; const bn = @import("int.zig"); const Limb = bn.Limb; diff --git a/lib/std/net.zig b/lib/std/net.zig index 0f7118c331929598bcba7368d2ac1d25b6c24c3f..f91b2b86aa3a60dda3206027f5a3bdbd4cb20afa 100644 --- a/lib/std/net.zig +++ b/lib/std/net.zig @@ -509,7 +509,7 @@ pub fn getAddressList(allocator: *mem.Allocator, name: []const u8, port: u16) !* try linuxLookupName(&lookup_addrs, &canon, name, family, flags, port); - result.addrs = try arena.alloc(Address, lookup_addrs.len); + result.addrs = try arena.alloc(Address, lookup_addrs.items.len); if (!canon.isNull()) { result.canon_name = canon.toOwnedSlice(); } @@ -554,7 +554,7 @@ fn linuxLookupName( return name_err; } else { try linuxLookupNameFromHosts(addrs, canon, name, family, port); - if (addrs.len == 0) { + if (addrs.items.len == 0) { try linuxLookupNameFromDnsSearch(addrs, canon, name, family, port); } } @@ -562,11 +562,11 @@ fn linuxLookupName( try canon.resize(0); try linuxLookupNameFromNull(addrs, family, flags, port); } - if (addrs.len == 0) return error.UnknownHostName; + if (addrs.items.len == 0) return error.UnknownHostName; // No further processing is needed if there are fewer than 2 // results or if there are only IPv4 results. - if (addrs.len == 1 or family == os.AF_INET) return; + if (addrs.items.len == 1 or family == os.AF_INET) return; const all_ip4 = for (addrs.span()) |addr| { if (addr.addr.any.family != os.AF_INET) break false; } else true; @@ -908,7 +908,7 @@ fn linuxLookupNameFromDnsSearch( canon.shrink(canon_name.len + 1); try canon.appendSlice(tok); try linuxLookupNameFromDns(addrs, canon, canon.span(), family, rc, port); - if (addrs.len != 0) return; + if (addrs.items.len != 0) return; } canon.shrink(canon_name.len); @@ -967,7 +967,7 @@ fn linuxLookupNameFromDns( dnsParse(ap[i], ctx, dnsParseCallback) catch {}; } - if (addrs.len != 0) return; + if (addrs.items.len != 0) return; if (ap[0].len < 4 or (ap[0][3] & 15) == 2) return error.TemporaryNameServerFailure; if ((ap[0][3] & 15) == 0) return error.UnknownHostName; if ((ap[0][3] & 15) == 3) return; @@ -1049,7 +1049,7 @@ fn getResolvConf(allocator: *mem.Allocator, rc: *ResolvConf) !void { } } - if (rc.ns.len == 0) { + if (rc.ns.items.len == 0) { return linuxLookupNameFromNumericUnspec(&rc.ns, "127.0.0.1", 53); } } @@ -1078,7 +1078,7 @@ fn resMSendRc( var ns_list = std.ArrayList(Address).init(rc.ns.allocator); defer ns_list.deinit(); - try ns_list.resize(rc.ns.len); + try ns_list.resize(rc.ns.items.len); const ns = ns_list.span(); for (rc.ns.span()) |iplit, i| { diff --git a/lib/std/special/build_runner.zig b/lib/std/special/build_runner.zig index 665d47c1bd87bd7c8067dcf5842b73f691948410..1c88f98e6e784798d387a9cf447080dbbb852d8c 100644 --- a/lib/std/special/build_runner.zig +++ b/lib/std/special/build_runner.zig @@ -171,7 +171,7 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: var) !void { \\ ); - if (builder.available_options_list.len == 0) { + if (builder.available_options_list.items.len == 0) { try out_stream.print(" (none)\n", .{}); } else { for (builder.available_options_list.span()) |option| { diff --git a/lib/std/unicode.zig b/lib/std/unicode.zig index a971a730e84066f74eb98cad728e840946cebc7c..333287b3516db6394358200ae5afc9b45e02198b 100644 --- a/lib/std/unicode.zig +++ b/lib/std/unicode.zig @@ -475,7 +475,7 @@ pub fn utf16leToUtf8Alloc(allocator: *mem.Allocator, utf16le: []const u16) ![]u8 var it = Utf16LeIterator.init(utf16le); while (try it.nextCodepoint()) |codepoint| { const utf8_len = utf8CodepointSequenceLength(codepoint) catch unreachable; - try result.resize(result.len + utf8_len); + try result.resize(result.items.len + utf8_len); assert((utf8Encode(codepoint, result.items[out_index..]) catch unreachable) == utf8_len); out_index += utf8_len; } @@ -571,7 +571,7 @@ pub fn utf8ToUtf16LeWithNull(allocator: *mem.Allocator, utf8: []const u8) ![:0]u } } - const len = result.len; + const len = result.items.len; try result.append(0); return result.toOwnedSlice()[0..len :0]; } diff --git a/src-self-hosted/libc_installation.zig b/src-self-hosted/libc_installation.zig index 60124d30e525b1f4c6d0328fea88b0872ee41abd..f3441cec0dec604a66c3cf36da5bda1a90a4df81 100644 --- a/src-self-hosted/libc_installation.zig +++ b/src-self-hosted/libc_installation.zig @@ -268,7 +268,7 @@ pub const LibCInstallation = struct { try search_paths.append(line); } } - if (search_paths.len == 0) { + if (search_paths.items.len == 0) { return error.CCompilerCannotFindHeaders; } @@ -276,9 +276,9 @@ pub const LibCInstallation = struct { const sys_include_dir_example_file = if (is_windows) "sys\\types.h" else "sys/errno.h"; var path_i: usize = 0; - while (path_i < search_paths.len) : (path_i += 1) { + while (path_i < search_paths.items.len) : (path_i += 1) { // search in reverse order - const search_path_untrimmed = search_paths.at(search_paths.len - path_i - 1); + const search_path_untrimmed = search_paths.at(search_paths.items.len - path_i - 1); const search_path = std.mem.trimLeft(u8, search_path_untrimmed, " "); var search_dir = fs.cwd().openDir(search_path, .{}) catch |err| switch (err) { error.FileNotFound, diff --git a/src-self-hosted/stage2.zig b/src-self-hosted/stage2.zig index 798fb552c05ac549511118d10a59477c326d8f9a..a3cae6c0742d76046db11f9748027e247e014992 100644 --- a/src-self-hosted/stage2.zig +++ b/src-self-hosted/stage2.zig @@ -239,7 +239,7 @@ fn fmtMain(argc: c_int, argv: [*]const [*:0]const u8) !void { } if (stdin_flag) { - if (input_files.len != 0) { + if (input_files.items.len != 0) { try stderr.writeAll("cannot use --stdin with positional arguments\n"); process.exit(1); } @@ -273,7 +273,7 @@ fn fmtMain(argc: c_int, argv: [*]const [*:0]const u8) !void { return; } - if (input_files.len == 0) { + if (input_files.items.len == 0) { try stderr.writeAll("expected at least one source file argument\n"); process.exit(1); } diff --git a/src-self-hosted/translate_c.zig b/src-self-hosted/translate_c.zig index 6ba7fc8ca1a906e5f06f01235b354c2c287c5e67..a7622a3ffa3e3fdf4fc270edb543d39ce68a511d 100644 --- a/src-self-hosted/translate_c.zig +++ b/src-self-hosted/translate_c.zig @@ -4309,7 +4309,7 @@ fn makeRestorePoint(c: *Context) RestorePoint { return RestorePoint{ .c = c, .token_index = c.tree.tokens.len, - .src_buf_index = c.source_buffer.len, + .src_buf_index = c.source_buffer.items.len, }; } @@ -4771,11 +4771,11 @@ fn appendToken(c: *Context, token_id: Token.Id, bytes: []const u8) !ast.TokenInd fn appendTokenFmt(c: *Context, token_id: Token.Id, comptime format: []const u8, args: var) !ast.TokenIndex { assert(token_id != .Invalid); - const start_index = c.source_buffer.len; + const start_index = c.source_buffer.items.len; errdefer c.source_buffer.shrink(start_index); try c.source_buffer.outStream().print(format, args); - const end_index = c.source_buffer.len; + const end_index = c.source_buffer.items.len; const token_index = c.tree.tokens.len; const new_token = try c.tree.tokens.addOne(); errdefer c.tree.tokens.shrink(token_index); diff --git a/test/standalone/brace_expansion/main.zig b/test/standalone/brace_expansion/main.zig index 411f2bfaf679649d77d48db52b24c6c0e13ffc21..8abe39a428d00120d551c3ef2ac5d979f0481677 100644 --- a/test/standalone/brace_expansion/main.zig +++ b/test/standalone/brace_expansion/main.zig @@ -113,7 +113,7 @@ fn parse(tokens: *const ArrayList(Token), token_index: *usize) ParseError!Node { fn expandString(input: []const u8, output: *ArrayListSentineled(u8, 0)) !void { const tokens = try tokenize(input); - if (tokens.len == 1) { + if (tokens.items.len == 1) { return output.resize(0); } @@ -142,7 +142,7 @@ fn expandString(input: []const u8, output: *ArrayListSentineled(u8, 0)) !void { const ExpandNodeError = error{OutOfMemory}; fn expandNode(node: Node, output: *ArrayList(ArrayListSentineled(u8, 0))) ExpandNodeError!void { - assert(output.len == 0); + assert(output.items.len == 0); switch (node) { Node.Scalar => |scalar| { try output.append(try ArrayListSentineled(u8, 0).init(global_allocator, scalar)); diff --git a/test/tests.zig b/test/tests.zig index 7f3e55ec7ab5a9c01ebf4ef5e3258cccc66790c3..dc94cce811700da2a102ce7d33ab1963200e39a7 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -864,13 +864,13 @@ pub const CompileErrorContext = struct { var err_iter = ErrLineIter.init(stderr); var i: usize = 0; ok = while (err_iter.next()) |line| : (i += 1) { - if (i >= self.case.expected_errors.len) break false; + if (i >= self.case.expected_errors.items.len) break false; const expected = self.case.expected_errors.at(i); if (mem.indexOf(u8, line, expected) == null) break false; continue; } else true; - ok = ok and i == self.case.expected_errors.len; + ok = ok and i == self.case.expected_errors.items.len; if (!ok) { warn("\n======== Expected these compile errors: ========\n", .{}); diff --git a/tools/merge_anal_dumps.zig b/tools/merge_anal_dumps.zig index 3399c15fd7fa3a6cbf89809da63f5b9b0aa3eee7..e0b3a036f1963f4151600f057ad82ad253d13161 100644 --- a/tools/merge_anal_dumps.zig +++ b/tools/merge_anal_dumps.zig @@ -194,7 +194,7 @@ const Dump = struct { for (other_files) |other_file, i| { const gop = try self.file_map.getOrPut(other_file.String); if (!gop.found_existing) { - gop.kv.value = self.file_list.len; + gop.kv.value = self.file_list.items.len; try self.file_list.append(other_file.String); } try other_file_to_mine.putNoClobber(i, gop.kv.value); @@ -213,7 +213,7 @@ const Dump = struct { }; const gop = try self.node_map.getOrPut(other_node); if (!gop.found_existing) { - gop.kv.value = self.node_list.len; + gop.kv.value = self.node_list.items.len; try self.node_list.append(other_node); } try other_ast_node_to_mine.putNoClobber(i, gop.kv.value); @@ -243,7 +243,7 @@ const Dump = struct { }; const gop = try self.error_map.getOrPut(other_error); if (!gop.found_existing) { - gop.kv.value = self.error_list.len; + gop.kv.value = self.error_list.items.len; try self.error_list.append(other_error); } try other_error_to_mine.putNoClobber(i, gop.kv.value); @@ -304,7 +304,7 @@ const Dump = struct { ) !void { const gop = try self.type_map.getOrPut(other_type); if (!gop.found_existing) { - gop.kv.value = self.type_list.len; + gop.kv.value = self.type_list.items.len; try self.type_list.append(other_type); } try other_types_to_mine.putNoClobber(other_type_index, gop.kv.value); -- 2.54.0 From f8cc6a191723d763fc7a8908f3e5beb4eff8317f Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 2 Apr 2020 21:15:36 -0400 Subject: [PATCH 08/91] zig cc: fix ambiguity with -MT In an MSVC context, `-MT` means "Use static run-time" and it is a flag with no parameter. On POSIX it means "Specify name of main file output in depfile" and it is "joined or separate". The former was interfering with the latter. Now, the MT flag is required to be specified with a `/` to disambiguate: `/MT`. --- src-self-hosted/clang_options.zig | 10 ++++ src-self-hosted/clang_options_data.zig | 74 ++++++++++++++++++++------ tools/update_clang_options.zig | 37 ++++++++++++- 3 files changed, 104 insertions(+), 17 deletions(-) diff --git a/src-self-hosted/clang_options.zig b/src-self-hosted/clang_options.zig index 70525655dee33650bbf2bce4195dc0857a0d6e49..1b70c71dac990901258be3bf0aceae2cdc88b209 100644 --- a/src-self-hosted/clang_options.zig +++ b/src-self-hosted/clang_options.zig @@ -95,6 +95,16 @@ pub fn flagpd1(name: []const u8) CliArg { }; } +/// Shortcut function for initializing a `CliArg` +pub fn flagpsl(name: []const u8) CliArg { + return .{ + .name = name, + .syntax = .flag, + .zig_equivalent = .other, + .psl = true, + }; +} + /// Shortcut function for initializing a `CliArg` pub fn joinpd1(name: []const u8) CliArg { return .{ diff --git a/src-self-hosted/clang_options_data.zig b/src-self-hosted/clang_options_data.zig index 0b3a3b9416dacbe32c819efa18f0e80da26489c3..2afe7f56819e112df24d6a2359f9e0dd57691d00 100644 --- a/src-self-hosted/clang_options_data.zig +++ b/src-self-hosted/clang_options_data.zig @@ -34,10 +34,38 @@ flagpd1("M"), .pd2 = false, .psl = false, }, -flagpd1("MG"), -flagpd1("MM"), -flagpd1("MMD"), -flagpd1("MP"), +.{ + .name = "MG", + .syntax = .flag, + .zig_equivalent = .dep_file, + .pd1 = true, + .pd2 = false, + .psl = false, +}, +.{ + .name = "MM", + .syntax = .flag, + .zig_equivalent = .dep_file, + .pd1 = true, + .pd2 = false, + .psl = false, +}, +.{ + .name = "MMD", + .syntax = .flag, + .zig_equivalent = .dep_file, + .pd1 = true, + .pd2 = false, + .psl = false, +}, +.{ + .name = "MP", + .syntax = .flag, + .zig_equivalent = .dep_file, + .pd1 = true, + .pd2 = false, + .psl = false, +}, .{ .name = "MV", .syntax = .flag, @@ -517,14 +545,7 @@ sepd1("Zlinker-input"), .pd2 = false, .psl = true, }, -.{ - .name = "MT", - .syntax = .flag, - .zig_equivalent = .other, - .pd1 = true, - .pd2 = false, - .psl = true, -}, +flagpsl("MT"), .{ .name = "MTd", .syntax = .flag, @@ -5463,9 +5484,30 @@ joinpd1("G="), .pd2 = false, .psl = false, }, -jspd1("MJ"), -jspd1("MQ"), -jspd1("MT"), +.{ + .name = "MJ", + .syntax = .joined_or_separate, + .zig_equivalent = .dep_file, + .pd1 = true, + .pd2 = false, + .psl = false, +}, +.{ + .name = "MQ", + .syntax = .joined_or_separate, + .zig_equivalent = .dep_file, + .pd1 = true, + .pd2 = false, + .psl = false, +}, +.{ + .name = "MT", + .syntax = .joined_or_separate, + .zig_equivalent = .dep_file, + .pd1 = true, + .pd2 = false, + .psl = false, +}, .{ .name = "AI", .syntax = .joined_or_separate, @@ -5589,7 +5631,7 @@ jspd1("MT"), .{ .name = "MP", .syntax = .joined, - .zig_equivalent = .other, + .zig_equivalent = .dep_file, .pd1 = true, .pd2 = false, .psl = true, diff --git a/tools/update_clang_options.zig b/tools/update_clang_options.zig index dd46f72d4cae72304f44b702b893d70a704eeaf9..fd6edbdf2c5316193a5d18d57a168832ee023b61 100644 --- a/tools/update_clang_options.zig +++ b/tools/update_clang_options.zig @@ -206,6 +206,34 @@ const known_options = [_]KnownOpt{ .name = "MF", .ident = "dep_file", }, + .{ + .name = "MT", + .ident = "dep_file", + }, + .{ + .name = "MG", + .ident = "dep_file", + }, + .{ + .name = "MJ", + .ident = "dep_file", + }, + .{ + .name = "MM", + .ident = "dep_file", + }, + .{ + .name = "MMD", + .ident = "dep_file", + }, + .{ + .name = "MP", + .ident = "dep_file", + }, + .{ + .name = "MQ", + .ident = "dep_file", + }, .{ .name = "F", .ident = "framework_dir", @@ -336,7 +364,12 @@ pub fn main() anyerror!void { } const syntax = objSyntax(obj); - if (knownOption(name)) |ident| { + if (std.mem.eql(u8, name, "MT") and syntax == .flag) { + // `-MT foo` is ambiguous because there is also an -MT flag + // The canonical way to specify the flag is with `/MT` and so we make this + // the only way. + try stdout.print("flagpsl(\"{}\"),\n", .{name}); + } else if (knownOption(name)) |ident| { try stdout.print( \\.{{ \\ .name = "{}", @@ -350,6 +383,8 @@ pub fn main() anyerror!void { , .{ name, syntax, ident, pd1, pd2, pslash }); } else if (pd1 and !pd2 and !pslash and syntax == .flag) { try stdout.print("flagpd1(\"{}\"),\n", .{name}); + } else if (!pd1 and !pd2 and pslash and syntax == .flag) { + try stdout.print("flagpsl(\"{}\"),\n", .{name}); } else if (pd1 and !pd2 and !pslash and syntax == .joined) { try stdout.print("joinpd1(\"{}\"),\n", .{name}); } else if (pd1 and !pd2 and !pslash and syntax == .joined_or_separate) { -- 2.54.0 From 048da6f6315772cd4fb6356c2dd50f0b60cbf6b5 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 2 Apr 2020 19:48:48 -0400 Subject: [PATCH 09/91] ci: enable riscv64-linux tests Thanks to Michael Dusan's work in deef063bbf these tests can be enabled. --- test/tests.zig | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/test/tests.zig b/test/tests.zig index 7f3e55ec7ab5a9c01ebf4ef5e3258cccc66790c3..9ada899b1bf001c0b334ad25794792d01114759f 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -152,17 +152,15 @@ const test_targets = blk: { .link_libc = true, }, - // TODO disabled only because the CI server has such an old qemu that - // qemu-riscv64 isn't available :( - //TestTarget{ - // .target = .{ - // .cpu_arch = .riscv64, - // .os_tag = .linux, - // .abi = .none, - // }, - //}, + TestTarget{ + .target = .{ + .cpu_arch = .riscv64, + .os_tag = .linux, + .abi = .none, + }, + }, - // https://github.com/ziglang/zig/issues/4485 + // https://github.com/ziglang/zig/issues/4863 //TestTarget{ // .target = .{ // .cpu_arch = .riscv64, -- 2.54.0 From 0dbf8aaab83d7387568d6387c6cbd263e04c7397 Mon Sep 17 00:00:00 2001 From: Jay Petacat Date: Thu, 2 Apr 2020 23:46:46 -0400 Subject: [PATCH 10/91] crypto: fix benchmark compile error (#4919) --- lib/std/crypto/benchmark.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/std/crypto/benchmark.zig b/lib/std/crypto/benchmark.zig index 0cc2c1d3ad709a39cfaf17aa8ff9b325967c845f..8f961f80f27b8eed0daccd59c561d37b2ee06723 100644 --- a/lib/std/crypto/benchmark.zig +++ b/lib/std/crypto/benchmark.zig @@ -133,7 +133,7 @@ fn printPad(stdout: var, s: []const u8) !void { } pub fn main() !void { - const stdout = &std.io.getStdOut().outStream().stream; + const stdout = std.io.getStdOut().outStream(); var buffer: [1024]u8 = undefined; var fixed = std.heap.FixedBufferAllocator.init(buffer[0..]); -- 2.54.0 From 855edd2949c6b3b36be4c3ba8d30f174ff8b8db1 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Sun, 22 Mar 2020 20:20:36 +0100 Subject: [PATCH 11/91] ir: Rewrite the bound checks in slice operator Closes #4777 --- src/codegen.cpp | 239 ++++++++++++++++++++++++++++-------------------- 1 file changed, 140 insertions(+), 99 deletions(-) diff --git a/src/codegen.cpp b/src/codegen.cpp index c9e67dcac514f36bf9e75d98fda7c98172f42d44..7a2ee6b2a3fc49a62f9e0b8d4d7ff48f265bf636 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -5408,6 +5408,8 @@ static LLVMValueRef ir_render_memcpy(CodeGen *g, IrExecutableGen *executable, Ir } static LLVMValueRef ir_render_slice(CodeGen *g, IrExecutableGen *executable, IrInstGenSlice *instruction) { + Error err; + LLVMValueRef array_ptr_ptr = ir_llvm_value(g, instruction->ptr); ZigType *array_ptr_type = instruction->ptr->value->type; assert(array_ptr_type->id == ZigTypeIdPointer); @@ -5416,15 +5418,16 @@ static LLVMValueRef ir_render_slice(CodeGen *g, IrExecutableGen *executable, IrI bool want_runtime_safety = instruction->safety_check_on && ir_want_runtime_safety(g, &instruction->base); + // The result is either a slice or a pointer to an array ZigType *result_type = instruction->base.value->type; - if (!type_has_bits(g, result_type)) { - return nullptr; - } // This is not whether the result type has a sentinel, but whether there should be a sentinel check, // e.g. if they used [a..b :s] syntax. ZigValue *sentinel = instruction->sentinel; + LLVMValueRef slice_start_ptr = nullptr; + LLVMValueRef len_value = nullptr; + if (array_type->id == ZigTypeIdArray || (array_type->id == ZigTypeIdPointer && array_type->data.pointer.ptr_len == PtrLenSingle)) { @@ -5438,111 +5441,86 @@ static LLVMValueRef ir_render_slice(CodeGen *g, IrExecutableGen *executable, IrI } else { end_val = LLVMConstInt(g->builtin_types.entry_usize->llvm_type, array_type->data.array.len, false); } + if (want_runtime_safety) { + // Safety check: start <= end if (instruction->start->value->special == ConstValSpecialRuntime || instruction->end) { add_bounds_check(g, start_val, LLVMIntEQ, nullptr, LLVMIntULE, end_val); } - if (instruction->end) { - LLVMValueRef array_end = LLVMConstInt(g->builtin_types.entry_usize->llvm_type, - array_type->data.array.len, false); - add_bounds_check(g, end_val, LLVMIntEQ, nullptr, LLVMIntULE, array_end); - if (sentinel != nullptr) { - LLVMValueRef indices[] = { - LLVMConstNull(g->builtin_types.entry_usize->llvm_type), - end_val, - }; - LLVMValueRef sentinel_elem_ptr = LLVMBuildInBoundsGEP(g->builder, array_ptr, indices, 2, ""); - add_sentinel_check(g, sentinel_elem_ptr, sentinel); - } - } - } - if (!type_has_bits(g, array_type)) { - LLVMValueRef tmp_struct_ptr = ir_llvm_value(g, instruction->result_loc); - - LLVMValueRef len_field_ptr = LLVMBuildStructGEP(g->builder, tmp_struct_ptr, slice_len_index, ""); + // Safety check: the last element of the slice (the sentinel if + // requested) must be inside the array + // XXX: Overflow is not checked here... + const size_t full_len = array_type->data.array.len + + (array_type->data.array.sentinel != nullptr); + LLVMValueRef array_end = LLVMConstInt(g->builtin_types.entry_usize->llvm_type, + full_len, false); - // TODO if runtime safety is on, store 0xaaaaaaa in ptr field - LLVMValueRef len_value = LLVMBuildNSWSub(g->builder, end_val, start_val, ""); - gen_store_untyped(g, len_value, len_field_ptr, 0, false); - return tmp_struct_ptr; + LLVMValueRef check_end_val = end_val; + if (sentinel != nullptr) { + LLVMValueRef usize_one = LLVMConstInt(g->builtin_types.entry_usize->llvm_type, 1, false); + check_end_val = LLVMBuildNUWAdd(g->builder, end_val, usize_one, ""); + } + add_bounds_check(g, check_end_val, LLVMIntEQ, nullptr, LLVMIntULE, array_end); } - LLVMValueRef indices[] = { - LLVMConstNull(g->builtin_types.entry_usize->llvm_type), - start_val, - }; - LLVMValueRef slice_start_ptr = LLVMBuildInBoundsGEP(g->builder, array_ptr, indices, 2, ""); - if (result_type->id == ZigTypeIdPointer) { - ir_assert(instruction->result_loc == nullptr, &instruction->base); - LLVMTypeRef result_ptr_type = get_llvm_type(g, result_type); - return LLVMBuildBitCast(g->builder, slice_start_ptr, result_ptr_type, ""); - } else { - LLVMValueRef tmp_struct_ptr = ir_llvm_value(g, instruction->result_loc); - LLVMValueRef ptr_field_ptr = LLVMBuildStructGEP(g->builder, tmp_struct_ptr, slice_ptr_index, ""); - gen_store_untyped(g, slice_start_ptr, ptr_field_ptr, 0, false); + bool value_has_bits; + if ((err = type_has_bits2(g, array_type, &value_has_bits))) + codegen_report_errors_and_exit(g); - LLVMValueRef len_field_ptr = LLVMBuildStructGEP(g->builder, tmp_struct_ptr, slice_len_index, ""); - LLVMValueRef len_value = LLVMBuildNSWSub(g->builder, end_val, start_val, ""); - gen_store_untyped(g, len_value, len_field_ptr, 0, false); + if (value_has_bits) { + if (want_runtime_safety && sentinel != nullptr) { + LLVMValueRef indices[] = { + LLVMConstNull(g->builtin_types.entry_usize->llvm_type), + end_val, + }; + LLVMValueRef sentinel_elem_ptr = LLVMBuildInBoundsGEP(g->builder, array_ptr, indices, 2, ""); + add_sentinel_check(g, sentinel_elem_ptr, sentinel); + } - return tmp_struct_ptr; + LLVMValueRef indices[] = { + LLVMConstNull(g->builtin_types.entry_usize->llvm_type), + start_val, + }; + slice_start_ptr = LLVMBuildInBoundsGEP(g->builder, array_ptr, indices, 2, ""); } + + len_value = LLVMBuildNUWSub(g->builder, end_val, start_val, ""); } else if (array_type->id == ZigTypeIdPointer) { assert(array_type->data.pointer.ptr_len != PtrLenSingle); LLVMValueRef start_val = ir_llvm_value(g, instruction->start); LLVMValueRef end_val = ir_llvm_value(g, instruction->end); if (want_runtime_safety) { + // Safety check: start <= end add_bounds_check(g, start_val, LLVMIntEQ, nullptr, LLVMIntULE, end_val); - if (sentinel != nullptr) { + } + + bool value_has_bits; + if ((err = type_has_bits2(g, array_type, &value_has_bits))) + codegen_report_errors_and_exit(g); + + if (value_has_bits) { + if (want_runtime_safety && sentinel != nullptr) { LLVMValueRef sentinel_elem_ptr = LLVMBuildInBoundsGEP(g->builder, array_ptr, &end_val, 1, ""); add_sentinel_check(g, sentinel_elem_ptr, sentinel); } - } - - if (!type_has_bits(g, array_type)) { - LLVMValueRef tmp_struct_ptr = ir_llvm_value(g, instruction->result_loc); - size_t gen_len_index = result_type->data.structure.fields[slice_len_index]->gen_index; - LLVMValueRef len_field_ptr = LLVMBuildStructGEP(g->builder, tmp_struct_ptr, gen_len_index, ""); - LLVMValueRef len_value = LLVMBuildNSWSub(g->builder, end_val, start_val, ""); - gen_store_untyped(g, len_value, len_field_ptr, 0, false); - return tmp_struct_ptr; - } - LLVMValueRef slice_start_ptr = LLVMBuildInBoundsGEP(g->builder, array_ptr, &start_val, 1, ""); - if (result_type->id == ZigTypeIdPointer) { - ir_assert(instruction->result_loc == nullptr, &instruction->base); - LLVMTypeRef result_ptr_type = get_llvm_type(g, result_type); - return LLVMBuildBitCast(g->builder, slice_start_ptr, result_ptr_type, ""); + slice_start_ptr = LLVMBuildInBoundsGEP(g->builder, array_ptr, &start_val, 1, ""); } - LLVMValueRef tmp_struct_ptr = ir_llvm_value(g, instruction->result_loc); - - size_t gen_ptr_index = result_type->data.structure.fields[slice_ptr_index]->gen_index; - LLVMValueRef ptr_field_ptr = LLVMBuildStructGEP(g->builder, tmp_struct_ptr, gen_ptr_index, ""); - gen_store_untyped(g, slice_start_ptr, ptr_field_ptr, 0, false); - - size_t gen_len_index = result_type->data.structure.fields[slice_len_index]->gen_index; - LLVMValueRef len_field_ptr = LLVMBuildStructGEP(g->builder, tmp_struct_ptr, gen_len_index, ""); - LLVMValueRef len_value = LLVMBuildNSWSub(g->builder, end_val, start_val, ""); - gen_store_untyped(g, len_value, len_field_ptr, 0, false); - - return tmp_struct_ptr; - + len_value = LLVMBuildNUWSub(g->builder, end_val, start_val, ""); } else if (array_type->id == ZigTypeIdStruct) { assert(array_type->data.structure.special == StructSpecialSlice); assert(LLVMGetTypeKind(LLVMTypeOf(array_ptr)) == LLVMPointerTypeKind); assert(LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(array_ptr))) == LLVMStructTypeKind); - size_t ptr_index = array_type->data.structure.fields[slice_ptr_index]->gen_index; - assert(ptr_index != SIZE_MAX); - size_t len_index = array_type->data.structure.fields[slice_len_index]->gen_index; - assert(len_index != SIZE_MAX); + const size_t gen_len_index = array_type->data.structure.fields[slice_len_index]->gen_index; + assert(gen_len_index != SIZE_MAX); LLVMValueRef prev_end = nullptr; if (!instruction->end || want_runtime_safety) { - LLVMValueRef src_len_ptr = LLVMBuildStructGEP(g->builder, array_ptr, (unsigned)len_index, ""); + LLVMValueRef src_len_ptr = LLVMBuildStructGEP(g->builder, array_ptr, gen_len_index, ""); prev_end = gen_load_untyped(g, src_len_ptr, 0, false, ""); } @@ -5554,41 +5532,104 @@ static LLVMValueRef ir_render_slice(CodeGen *g, IrExecutableGen *executable, IrI end_val = prev_end; } - LLVMValueRef src_ptr_ptr = LLVMBuildStructGEP(g->builder, array_ptr, (unsigned)ptr_index, ""); - LLVMValueRef src_ptr = gen_load_untyped(g, src_ptr_ptr, 0, false, ""); + ZigType *ptr_field_type = array_type->data.structure.fields[slice_ptr_index]->type_entry; if (want_runtime_safety) { assert(prev_end); + // Safety check: start <= end add_bounds_check(g, start_val, LLVMIntEQ, nullptr, LLVMIntULE, end_val); - if (instruction->end) { - add_bounds_check(g, end_val, LLVMIntEQ, nullptr, LLVMIntULE, prev_end); - if (sentinel != nullptr) { - LLVMValueRef sentinel_elem_ptr = LLVMBuildInBoundsGEP(g->builder, src_ptr, &end_val, 1, ""); - add_sentinel_check(g, sentinel_elem_ptr, sentinel); - } + // Safety check: the sentinel counts as one more element + // XXX: Overflow is not checked here... + LLVMValueRef check_prev_end = prev_end; + if (ptr_field_type->data.pointer.sentinel != nullptr) { + LLVMValueRef usize_one = LLVMConstInt(g->builtin_types.entry_usize->llvm_type, 1, false); + check_prev_end = LLVMBuildNUWAdd(g->builder, prev_end, usize_one, ""); } + LLVMValueRef check_end_val = end_val; + if (sentinel != nullptr) { + LLVMValueRef usize_one = LLVMConstInt(g->builtin_types.entry_usize->llvm_type, 1, false); + check_end_val = LLVMBuildNUWAdd(g->builder, end_val, usize_one, ""); + } + + add_bounds_check(g, check_end_val, LLVMIntEQ, nullptr, LLVMIntULE, check_prev_end); } - LLVMValueRef slice_start_ptr = LLVMBuildInBoundsGEP(g->builder, src_ptr, &start_val, 1, ""); - if (result_type->id == ZigTypeIdPointer) { - ir_assert(instruction->result_loc == nullptr, &instruction->base); - LLVMTypeRef result_ptr_type = get_llvm_type(g, result_type); - return LLVMBuildBitCast(g->builder, slice_start_ptr, result_ptr_type, ""); - } else { - LLVMValueRef tmp_struct_ptr = ir_llvm_value(g, instruction->result_loc); - LLVMValueRef ptr_field_ptr = LLVMBuildStructGEP(g->builder, tmp_struct_ptr, (unsigned)ptr_index, ""); - gen_store_untyped(g, slice_start_ptr, ptr_field_ptr, 0, false); - - LLVMValueRef len_field_ptr = LLVMBuildStructGEP(g->builder, tmp_struct_ptr, (unsigned)len_index, ""); - LLVMValueRef len_value = LLVMBuildNSWSub(g->builder, end_val, start_val, ""); - gen_store_untyped(g, len_value, len_field_ptr, 0, false); - - return tmp_struct_ptr; + bool ptr_has_bits; + if ((err = type_has_bits2(g, ptr_field_type, &ptr_has_bits))) + codegen_report_errors_and_exit(g); + + if (ptr_has_bits) { + const size_t gen_ptr_index = array_type->data.structure.fields[slice_ptr_index]->gen_index; + assert(gen_ptr_index != SIZE_MAX); + + LLVMValueRef src_ptr_ptr = LLVMBuildStructGEP(g->builder, array_ptr, gen_ptr_index, ""); + LLVMValueRef src_ptr = gen_load_untyped(g, src_ptr_ptr, 0, false, ""); + + if (sentinel != nullptr) { + LLVMValueRef sentinel_elem_ptr = LLVMBuildInBoundsGEP(g->builder, src_ptr, &end_val, 1, ""); + add_sentinel_check(g, sentinel_elem_ptr, sentinel); + } + + slice_start_ptr = LLVMBuildInBoundsGEP(g->builder, src_ptr, &start_val, 1, ""); } + + len_value = LLVMBuildNUWSub(g->builder, end_val, start_val, ""); } else { zig_unreachable(); } + + bool result_has_bits; + if ((err = type_has_bits2(g, result_type, &result_has_bits))) + codegen_report_errors_and_exit(g); + + // Nothing to do, we're only interested in the bound checks emitted above + if (!result_has_bits) + return nullptr; + + // The starting pointer for the slice may be null in case of zero-sized + // arrays, the length value is always defined. + assert(len_value != nullptr); + + // The slice decays into a pointer to an array, the size is tracked in the + // type itself + if (result_type->id == ZigTypeIdPointer) { + ir_assert(instruction->result_loc == nullptr, &instruction->base); + LLVMTypeRef result_ptr_type = get_llvm_type(g, result_type); + + if (slice_start_ptr != nullptr) { + return LLVMBuildBitCast(g->builder, slice_start_ptr, result_ptr_type, ""); + } + + return LLVMGetUndef(result_ptr_type); + } + + ir_assert(instruction->result_loc != nullptr, &instruction->base); + // Create a new slice + LLVMValueRef tmp_struct_ptr = ir_llvm_value(g, instruction->result_loc); + + ZigType *slice_ptr_type = result_type->data.structure.fields[slice_ptr_index]->type_entry; + + // The slice may not have a pointer at all if it points to a zero-sized type + const size_t gen_ptr_index = result_type->data.structure.fields[slice_ptr_index]->gen_index; + if (gen_ptr_index != SIZE_MAX) { + LLVMValueRef ptr_field_ptr = LLVMBuildStructGEP(g->builder, tmp_struct_ptr, gen_ptr_index, ""); + if (slice_start_ptr != nullptr) { + gen_store_untyped(g, slice_start_ptr, ptr_field_ptr, 0, false); + } else if (want_runtime_safety) { + gen_undef_init(g, slice_ptr_type->abi_align, slice_ptr_type, ptr_field_ptr); + } else { + gen_store_untyped(g, LLVMGetUndef(get_llvm_type(g, slice_ptr_type)), ptr_field_ptr, 0, false); + } + } + + const size_t gen_len_index = result_type->data.structure.fields[slice_len_index]->gen_index; + assert(gen_len_index != SIZE_MAX); + + LLVMValueRef len_field_ptr = LLVMBuildStructGEP(g->builder, tmp_struct_ptr, gen_len_index, ""); + gen_store_untyped(g, len_value, len_field_ptr, 0, false); + + return tmp_struct_ptr; } static LLVMValueRef get_trap_fn_val(CodeGen *g) { -- 2.54.0 From aa5865b9beea6d2e5615b1d9a2e6de723e006f26 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Tue, 31 Mar 2020 10:37:56 +0200 Subject: [PATCH 12/91] std: Fix oob slicing operator --- lib/std/fs.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/std/fs.zig b/lib/std/fs.zig index 0eeb1758f26efc60d10612c9170709229941d55a..622700e05ff944d193a9b9048f55913489bb33fc 100644 --- a/lib/std/fs.zig +++ b/lib/std/fs.zig @@ -1522,7 +1522,7 @@ pub fn openSelfExe() OpenSelfExeError!File { var buf: [MAX_PATH_BYTES]u8 = undefined; const self_exe_path = try selfExePath(&buf); buf[self_exe_path.len] = 0; - return openFileAbsoluteZ(self_exe_path[0..self_exe_path.len :0].ptr, .{}); + return openFileAbsoluteZ(buf[0..self_exe_path.len :0].ptr, .{}); } test "openSelfExe" { -- 2.54.0 From dc54e50db27f76721c33cd437b62ceb598a00447 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Fri, 3 Apr 2020 12:03:36 +0200 Subject: [PATCH 13/91] std: Fix one more sentinel buffer overrun --- lib/std/debug.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/std/debug.zig b/lib/std/debug.zig index 9e14d132a84204afdd03f6edb774991315e74c94..2f5040a9265835fbdf8c7b775243a540b171ea6e 100644 --- a/lib/std/debug.zig +++ b/lib/std/debug.zig @@ -1213,7 +1213,7 @@ pub const DebugInfo = struct { const obj_di = try self.allocator.create(ModuleDebugInfo); errdefer self.allocator.destroy(obj_di); - obj_di.* = openCoffDebugInfo(self.allocator, name_buffer[0..:0]) catch |err| switch (err) { + obj_di.* = openCoffDebugInfo(self.allocator, name_buffer[0 .. len + 4 :0]) catch |err| switch (err) { error.FileNotFound => return error.MissingDebugInfo, else => return err, }; -- 2.54.0 From 08a9ab4d8c7f1baeb6169088284c06fb2b9707ce Mon Sep 17 00:00:00 2001 From: Ryan Liptak Date: Fri, 3 Apr 2020 00:46:16 -0700 Subject: [PATCH 14/91] Update all remaining uses of &outStream().stream --- lib/std/hash/benchmark.zig | 4 +--- lib/std/unicode/throughput_test.zig | 2 +- lib/std/zig/perf_test.zig | 2 +- tools/merge_anal_dumps.zig | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/std/hash/benchmark.zig b/lib/std/hash/benchmark.zig index 4762b65afb7357d2112205af0eb0ae8b312c3a78..255c98e409014a1de192f122f3e6ce5a70639c86 100644 --- a/lib/std/hash/benchmark.zig +++ b/lib/std/hash/benchmark.zig @@ -172,9 +172,7 @@ fn mode(comptime x: comptime_int) comptime_int { } pub fn main() !void { - var stdout_file = std.io.getStdOut(); - var stdout_out_stream = stdout_file.outStream(); - const stdout = &stdout_out_stream.stream; + const stdout = std.io.getStdOut().outStream(); var buffer: [1024]u8 = undefined; var fixed = std.heap.FixedBufferAllocator.init(buffer[0..]); diff --git a/lib/std/unicode/throughput_test.zig b/lib/std/unicode/throughput_test.zig index 7265361b31f2b9cafa67918d8b68a8903b25abe3..050340cd556afed74e79767a7cea3e24e1ac3822 100644 --- a/lib/std/unicode/throughput_test.zig +++ b/lib/std/unicode/throughput_test.zig @@ -2,7 +2,7 @@ const builtin = @import("builtin"); const std = @import("std"); pub fn main() !void { - const stdout = &std.io.getStdOut().outStream().stream; + const stdout = std.io.getStdOut().outStream(); const args = try std.process.argsAlloc(std.heap.page_allocator); diff --git a/lib/std/zig/perf_test.zig b/lib/std/zig/perf_test.zig index 070d9c3bc9ebb2c9d870c7584fc59ebe5268f622..689fea96f6c685ca14e1bf4995f64618e20298c3 100644 --- a/lib/std/zig/perf_test.zig +++ b/lib/std/zig/perf_test.zig @@ -24,7 +24,7 @@ pub fn main() !void { const mb_per_sec = bytes_per_sec / (1024 * 1024); var stdout_file = std.io.getStdOut(); - const stdout = &stdout_file.outStream().stream; + const stdout = stdout_file.outStream(); try stdout.print("{:.3} MiB/s, {} KiB used \n", .{ mb_per_sec, memory_used / 1024 }); } diff --git a/tools/merge_anal_dumps.zig b/tools/merge_anal_dumps.zig index 3399c15fd7fa3a6cbf89809da63f5b9b0aa3eee7..10c401ec38f7dd25ff36d4810cf9fb3ac0d4b78d 100644 --- a/tools/merge_anal_dumps.zig +++ b/tools/merge_anal_dumps.zig @@ -23,7 +23,7 @@ pub fn main() anyerror!void { } const stdout = try std.io.getStdOut(); - try dump.render(&stdout.outStream().stream); + try dump.render(stdout.outStream()); } /// AST source node -- 2.54.0 From 203d6554b1e54e06aa28cbcfa74596911cd60b4c Mon Sep 17 00:00:00 2001 From: markfirmware Date: Thu, 2 Apr 2020 22:39:23 -0400 Subject: [PATCH 15/91] Update fmt.zig --- lib/std/fmt.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/std/fmt.zig b/lib/std/fmt.zig index bcc470e9b93f23c8edd483f9fbade4c6b1497968..dca2a591713833089053f498132a2e200a6e681d 100644 --- a/lib/std/fmt.zig +++ b/lib/std/fmt.zig @@ -69,7 +69,7 @@ fn peekIsAlign(comptime fmt: []const u8) bool { /// /// If a formatted user type contains a function of the type /// ``` -/// fn format(value: ?, comptime fmt: []const u8, options: std.fmt.FormatOptions, out_stream: var) !void +/// pub fn format(value: ?, comptime fmt: []const u8, options: std.fmt.FormatOptions, out_stream: var) !void /// ``` /// with `?` being the type formatted, this function will be called instead of the default implementation. /// This allows user types to be formatted in a logical manner instead of dumping all fields of the type. -- 2.54.0 From 11b50e3ad8781fd600961e80aad622c6f5616acc Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 3 Apr 2020 11:02:22 -0400 Subject: [PATCH 16/91] change the default ABI of riscv64-linux-musl Before, this would cause a link failure when mixing Zig and C code for RISC-V targets. Now, the ABIs match and Zig and C code can be mixed successfully. I will file a follow-up issue for the ability to deal more explicitly with ABIs. closes #4863 --- src/codegen.cpp | 16 +++++++++++++++- src/zig_llvm.cpp | 17 ++++++++++++++++- src/zig_llvm.h | 9 ++++++++- test/tests.zig | 17 ++++++++--------- 4 files changed, 47 insertions(+), 12 deletions(-) diff --git a/src/codegen.cpp b/src/codegen.cpp index c9e67dcac514f36bf9e75d98fda7c98172f42d44..ed8fcf54d7cebe6c07c84daf96fda3338ae959a7 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -8940,10 +8940,24 @@ static void init(CodeGen *g) { fprintf(stderr, "name=%s target_specific_cpu_args=%s\n", buf_ptr(g->root_out_name), target_specific_cpu_args); fprintf(stderr, "name=%s target_specific_features=%s\n", buf_ptr(g->root_out_name), target_specific_features); } + + // TODO handle float ABI better- it should depend on the ABI portion of std.Target + ZigLLVMABIType float_abi = ZigLLVMABITypeDefault; + + // TODO a way to override this as part of std.Target ABI? + const char *abi_name = nullptr; + if (target_is_riscv(g->zig_target)) { + // RISC-V Linux defaults to ilp32d/lp64d + if (g->zig_target->os == OsLinux) { + abi_name = (g->zig_target->arch == ZigLLVM_riscv32) ? "ilp32d" : "lp64d"; + } else { + abi_name = (g->zig_target->arch == ZigLLVM_riscv32) ? "ilp32" : "lp64"; + } + } g->target_machine = ZigLLVMCreateTargetMachine(target_ref, buf_ptr(&g->llvm_triple_str), target_specific_cpu_args, target_specific_features, opt_level, reloc_mode, - to_llvm_code_model(g), g->function_sections); + to_llvm_code_model(g), g->function_sections, float_abi, abi_name); g->target_data_ref = LLVMCreateTargetDataLayout(g->target_machine); diff --git a/src/zig_llvm.cpp b/src/zig_llvm.cpp index 5569f90cdc2a20d2aa185e3360765e5e08c29515..e5b9df625c566cefed426e8d6a33a750505227f1 100644 --- a/src/zig_llvm.cpp +++ b/src/zig_llvm.cpp @@ -100,7 +100,7 @@ static const bool assertions_on = false; LLVMTargetMachineRef ZigLLVMCreateTargetMachine(LLVMTargetRef T, const char *Triple, const char *CPU, const char *Features, LLVMCodeGenOptLevel Level, LLVMRelocMode Reloc, - LLVMCodeModel CodeModel, bool function_sections) + LLVMCodeModel CodeModel, bool function_sections, ZigLLVMABIType float_abi, const char *abi_name) { Optional RM; switch (Reloc){ @@ -147,6 +147,21 @@ LLVMTargetMachineRef ZigLLVMCreateTargetMachine(LLVMTargetRef T, const char *Tri TargetOptions opt; opt.FunctionSections = function_sections; + switch (float_abi) { + case ZigLLVMABITypeDefault: + opt.FloatABIType = FloatABI::Default; + break; + case ZigLLVMABITypeSoft: + opt.FloatABIType = FloatABI::Soft; + break; + case ZigLLVMABITypeHard: + opt.FloatABIType = FloatABI::Hard; + break; + } + + if (abi_name != nullptr) { + opt.MCOptions.ABIName = abi_name; + } TargetMachine *TM = reinterpret_cast(T)->createTargetMachine(Triple, CPU, Features, opt, RM, CM, OL, JIT); diff --git a/src/zig_llvm.h b/src/zig_llvm.h index c2c4b4dd777c40c31937eef232bd0645001b284b..f07684f2a404670d51fd9b994ef950f407b43f31 100644 --- a/src/zig_llvm.h +++ b/src/zig_llvm.h @@ -51,9 +51,16 @@ ZIG_EXTERN_C bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machi bool is_small, bool time_report, const char *asm_filename, const char *bin_filename, const char *llvm_ir_filename); + +enum ZigLLVMABIType { + ZigLLVMABITypeDefault, // Target-specific (either soft or hard depending on triple, etc). + ZigLLVMABITypeSoft, // Soft float. + ZigLLVMABITypeHard // Hard float. +}; + ZIG_EXTERN_C LLVMTargetMachineRef ZigLLVMCreateTargetMachine(LLVMTargetRef T, const char *Triple, const char *CPU, const char *Features, LLVMCodeGenOptLevel Level, LLVMRelocMode Reloc, - LLVMCodeModel CodeModel, bool function_sections); + LLVMCodeModel CodeModel, bool function_sections, ZigLLVMABIType float_abi, const char *abi_name); ZIG_EXTERN_C LLVMTypeRef ZigLLVMTokenTypeInContext(LLVMContextRef context_ref); diff --git a/test/tests.zig b/test/tests.zig index 9ada899b1bf001c0b334ad25794792d01114759f..686127079206a130517ae5a9dd611121f9b1b41b 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -160,15 +160,14 @@ const test_targets = blk: { }, }, - // https://github.com/ziglang/zig/issues/4863 - //TestTarget{ - // .target = .{ - // .cpu_arch = .riscv64, - // .os_tag = .linux, - // .abi = .musl, - // }, - // .link_libc = true, - //}, + TestTarget{ + .target = .{ + .cpu_arch = .riscv64, + .os_tag = .linux, + .abi = .musl, + }, + .link_libc = true, + }, // https://github.com/ziglang/zig/issues/3340 //TestTarget{ -- 2.54.0 From cf52f3f99a371fd4cb897afb2ed515ea00927808 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 3 Apr 2020 13:44:56 -0400 Subject: [PATCH 17/91] zig cc: add -allow-shlib-undefined alias --- src/main.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index cd45d40e5f8ad0b2afcecc416e691257489666d6..4d2775d75a9d00f5201528e03bdd2c1a542e9b51 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -833,9 +833,13 @@ static int main0(int argc, char **argv) { linker_gc_sections = OptionalBoolTrue; } else if (buf_eql_str(arg, "--no-gc-sections")) { linker_gc_sections = OptionalBoolFalse; - } else if (buf_eql_str(arg, "--allow-shlib-undefined")) { + } else if (buf_eql_str(arg, "--allow-shlib-undefined") || + buf_eql_str(arg, "-allow-shlib-undefined")) + { linker_allow_shlib_undefined = OptionalBoolTrue; - } else if (buf_eql_str(arg, "--no-allow-shlib-undefined")) { + } else if (buf_eql_str(arg, "--no-allow-shlib-undefined") || + buf_eql_str(arg, "-no-allow-shlib-undefined")) + { linker_allow_shlib_undefined = OptionalBoolFalse; } else if (buf_eql_str(arg, "-z")) { i += 1; -- 2.54.0 From ed69821f5b4e47b25b95d2a1099e95ece477b66a Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Fri, 3 Apr 2020 19:13:21 +0200 Subject: [PATCH 18/91] compiler-rt: Add the __atomic family of builtins The implementation was checked against a few files using std::atomic and compiled using zig c++. Closes #4887 --- lib/std/special/compiler_rt.zig | 2 + lib/std/special/compiler_rt/atomics.zig | 253 ++++++++++++++++++++++++ 2 files changed, 255 insertions(+) create mode 100644 lib/std/special/compiler_rt/atomics.zig diff --git a/lib/std/special/compiler_rt.zig b/lib/std/special/compiler_rt.zig index 2a454b19dcfd5ba3593153d081489e91427b2425..aa94d29b11283d0bc76a47e474cf7b29fe53c137 100644 --- a/lib/std/special/compiler_rt.zig +++ b/lib/std/special/compiler_rt.zig @@ -317,6 +317,8 @@ comptime { @export(@import("compiler_rt/mulodi4.zig").__mulodi4, .{ .name = "__mulodi4", .linkage = linkage }); } +pub usingnamespace @import("compiler_rt/atomics.zig"); + // Avoid dragging in the runtime safety mechanisms into this .o file, // unless we're trying to test this file. pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn { diff --git a/lib/std/special/compiler_rt/atomics.zig b/lib/std/special/compiler_rt/atomics.zig new file mode 100644 index 0000000000000000000000000000000000000000..9d68ee28094832fc871378806c1c7b366f1b81b9 --- /dev/null +++ b/lib/std/special/compiler_rt/atomics.zig @@ -0,0 +1,253 @@ +const std = @import("std"); +const builtin = std.builtin; + +const linkage: builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; + +const cache_line_size = 64; + +const SpinlockTable = struct { + // Allocate ~4096 bytes of memory for the spinlock table + const max_spinlocks = 64; + + const Spinlock = struct { + // Prevent false sharing by providing enough padding between two + // consecutive spinlock elements + v: enum(usize) { Unlocked = 0, Locked } align(cache_line_size) = .Unlocked, + + fn acquire(self: *@This()) void { + while (true) { + switch (@atomicRmw(@TypeOf(self.v), &self.v, .Xchg, .Locked, .Acquire)) { + .Unlocked => break, + .Locked => {}, + } + } + } + fn release(self: *@This()) void { + @atomicStore(@TypeOf(self.v), &self.v, .Unlocked, .Release); + } + }; + + list: [max_spinlocks]Spinlock = [_]Spinlock{.{}} ** max_spinlocks, + + // The spinlock table behaves as a really simple hash table, mapping + // addresses to spinlocks. The mapping is not unique but that's only a + // performance problem as the lock will be contended by more than a pair of + // threads. + fn get(self: *@This(), address: usize) *Spinlock { + var sl = &self.list[(address >> 3) % max_spinlocks]; + sl.acquire(); + return sl; + } +}; + +var spinlocks: SpinlockTable = SpinlockTable{}; + +// The following builtins do not respect the specified memory model and instead +// uses seq_cst, the strongest one, for simplicity sake. + +// Generic version of GCC atomic builtin functions. +// Those work on any object no matter the pointer alignment nor its size. + +fn __atomic_load(size: u32, src: [*]u8, dest: [*]u8, model: i32) callconv(.C) void { + var sl = spinlocks.get(@ptrToInt(src)); + defer sl.release(); + @memcpy(dest, src, size); +} + +fn __atomic_store(size: u32, dest: [*]u8, src: [*]u8, model: i32) callconv(.C) void { + var sl = spinlocks.get(@ptrToInt(dest)); + defer sl.release(); + @memcpy(dest, src, size); +} + +fn __atomic_exchange(size: u32, ptr: [*]u8, val: [*]u8, old: [*]u8, model: i32) callconv(.C) void { + var sl = spinlocks.get(@ptrToInt(ptr)); + defer sl.release(); + @memcpy(old, ptr, size); + @memcpy(ptr, val, size); +} + +fn __atomic_compare_exchange( + size: u32, + ptr: [*]u8, + expected: [*]u8, + desired: [*]u8, + success: i32, + failure: i32, +) callconv(.C) i32 { + var sl = spinlocks.get(@ptrToInt(ptr)); + defer sl.release(); + for (ptr[0..size]) |b, i| { + if (expected[i] != b) break; + } else { + // The two objects, ptr and expected, are equal + @memcpy(ptr, desired, size); + return 1; + } + @memcpy(expected, ptr, size); + return 0; +} + +// Specialized versions of the GCC atomic builtin functions. +// LLVM emits those iff the object size is known and the pointers are correctly +// aligned. + +// The size (in bytes) of the biggest object that the architecture can access +// atomically. Objects bigger than this threshold require the use of a lock. +const largest_atomic_size = switch (builtin.arch) { + .x86_64 => 16, + else => @sizeOf(usize), +}; + +fn makeAtomicLoadFn(comptime T: type) type { + return struct { + fn atomic_load_N(src: *T, model: i32) callconv(.C) T { + if (@sizeOf(T) > largest_atomic_size) { + var sl = spinlocks.get(@ptrToInt(src)); + defer sl.release(); + return src.*; + } else { + return @atomicLoad(T, src, .SeqCst); + } + } + }; +} + +comptime { + @export(makeAtomicLoadFn(u8).atomic_load_N, .{ .name = "__atomic_load_1", .linkage = linkage }); + @export(makeAtomicLoadFn(u16).atomic_load_N, .{ .name = "__atomic_load_2", .linkage = linkage }); + @export(makeAtomicLoadFn(u32).atomic_load_N, .{ .name = "__atomic_load_4", .linkage = linkage }); + @export(makeAtomicLoadFn(u64).atomic_load_N, .{ .name = "__atomic_load_8", .linkage = linkage }); +} + +fn makeAtomicStoreFn(comptime T: type) type { + return struct { + fn atomic_store_N(dst: *T, value: T, model: i32) callconv(.C) void { + if (@sizeOf(T) > largest_atomic_size) { + var sl = spinlocks.get(@ptrToInt(dst)); + defer sl.release(); + dst.* = value; + } else { + @atomicStore(T, dst, value, .SeqCst); + } + } + }; +} + +comptime { + @export(makeAtomicStoreFn(u8).atomic_store_N, .{ .name = "__atomic_store_1", .linkage = linkage }); + @export(makeAtomicStoreFn(u16).atomic_store_N, .{ .name = "__atomic_store_2", .linkage = linkage }); + @export(makeAtomicStoreFn(u32).atomic_store_N, .{ .name = "__atomic_store_4", .linkage = linkage }); + @export(makeAtomicStoreFn(u64).atomic_store_N, .{ .name = "__atomic_store_8", .linkage = linkage }); +} + +fn makeAtomicExchangeFn(comptime T: type) type { + return struct { + fn atomic_exchange_N(ptr: *T, val: T, model: i32) callconv(.C) T { + if (@sizeOf(T) > largest_atomic_size) { + var sl = spinlocks.get(@ptrToInt(ptr)); + defer sl.release(); + var value = ptr.*; + ptr.* = val; + return value; + } else { + return @atomicRmw(T, ptr, .Xchg, val, .SeqCst); + } + } + }; +} + +comptime { + @export(makeAtomicExchangeFn(u8).atomic_exchange_N, .{ .name = "__atomic_exchange_1", .linkage = linkage }); + @export(makeAtomicExchangeFn(u16).atomic_exchange_N, .{ .name = "__atomic_exchange_2", .linkage = linkage }); + @export(makeAtomicExchangeFn(u32).atomic_exchange_N, .{ .name = "__atomic_exchange_4", .linkage = linkage }); + @export(makeAtomicExchangeFn(u64).atomic_exchange_N, .{ .name = "__atomic_exchange_8", .linkage = linkage }); +} + +fn makeAtomicCompareExchangeFn(comptime T: type) type { + return struct { + fn atomic_compare_exchange_N(ptr: *T, expected: *T, desired: T, success: i32, failure: i32) callconv(.C) i32 { + if (@sizeOf(T) > largest_atomic_size) { + var sl = spinlocks.get(@ptrToInt(ptr)); + defer sl.release(); + if (ptr.* == expected.*) { + ptr.* = desired; + return 1; + } + expected.* = ptr.*; + return 0; + } else { + if (@cmpxchgStrong(T, ptr, expected.*, desired, .SeqCst, .SeqCst)) |old_value| { + expected.* = old_value; + return 0; + } + return 1; + } + } + }; +} + +comptime { + @export(makeAtomicCompareExchangeFn(u8).atomic_compare_exchange_N, .{ .name = "__atomic_compare_exchange_1", .linkage = linkage }); + @export(makeAtomicCompareExchangeFn(u16).atomic_compare_exchange_N, .{ .name = "__atomic_compare_exchange_2", .linkage = linkage }); + @export(makeAtomicCompareExchangeFn(u32).atomic_compare_exchange_N, .{ .name = "__atomic_compare_exchange_4", .linkage = linkage }); + @export(makeAtomicCompareExchangeFn(u64).atomic_compare_exchange_N, .{ .name = "__atomic_compare_exchange_8", .linkage = linkage }); +} + +fn makeFetchFn(comptime T: type, comptime op: builtin.AtomicRmwOp) type { + return struct { + pub fn fetch_op_N(ptr: *T, val: T, model: i32) callconv(.C) T { + if (@sizeOf(T) > largest_atomic_size) { + var sl = spinlocks.get(@ptrToInt(ptr)); + defer sl.release(); + + var value = ptr.*; + ptr.* = switch (op) { + .Add => ptr.* +% val, + .Sub => ptr.* -% val, + .And => ptr.* & val, + .Nand => ~(ptr.* & val), + .Or => ptr.* | val, + .Xor => ptr.* ^ val, + else => @compileError("unsupported atomic op"), + }; + + return value; + } + + return @atomicRmw(T, ptr, op, val, .SeqCst); + } + }; +} + +comptime { + @export(makeFetchFn(u8, .Add).fetch_op_N, .{ .name = "__atomic_fetch_add_1", .linkage = linkage }); + @export(makeFetchFn(u16, .Add).fetch_op_N, .{ .name = "__atomic_fetch_add_2", .linkage = linkage }); + @export(makeFetchFn(u32, .Add).fetch_op_N, .{ .name = "__atomic_fetch_add_4", .linkage = linkage }); + @export(makeFetchFn(u64, .Add).fetch_op_N, .{ .name = "__atomic_fetch_add_8", .linkage = linkage }); + + @export(makeFetchFn(u8, .Sub).fetch_op_N, .{ .name = "__atomic_fetch_sub_1", .linkage = linkage }); + @export(makeFetchFn(u16, .Sub).fetch_op_N, .{ .name = "__atomic_fetch_sub_2", .linkage = linkage }); + @export(makeFetchFn(u32, .Sub).fetch_op_N, .{ .name = "__atomic_fetch_sub_4", .linkage = linkage }); + @export(makeFetchFn(u64, .Sub).fetch_op_N, .{ .name = "__atomic_fetch_sub_8", .linkage = linkage }); + + @export(makeFetchFn(u8, .And).fetch_op_N, .{ .name = "__atomic_fetch_and_1", .linkage = linkage }); + @export(makeFetchFn(u16, .And).fetch_op_N, .{ .name = "__atomic_fetch_and_2", .linkage = linkage }); + @export(makeFetchFn(u32, .And).fetch_op_N, .{ .name = "__atomic_fetch_and_4", .linkage = linkage }); + @export(makeFetchFn(u64, .And).fetch_op_N, .{ .name = "__atomic_fetch_and_8", .linkage = linkage }); + + @export(makeFetchFn(u8, .Or).fetch_op_N, .{ .name = "__atomic_fetch_or_1", .linkage = linkage }); + @export(makeFetchFn(u16, .Or).fetch_op_N, .{ .name = "__atomic_fetch_or_2", .linkage = linkage }); + @export(makeFetchFn(u32, .Or).fetch_op_N, .{ .name = "__atomic_fetch_or_4", .linkage = linkage }); + @export(makeFetchFn(u64, .Or).fetch_op_N, .{ .name = "__atomic_fetch_or_8", .linkage = linkage }); + + @export(makeFetchFn(u8, .Xor).fetch_op_N, .{ .name = "__atomic_fetch_xor_1", .linkage = linkage }); + @export(makeFetchFn(u16, .Xor).fetch_op_N, .{ .name = "__atomic_fetch_xor_2", .linkage = linkage }); + @export(makeFetchFn(u32, .Xor).fetch_op_N, .{ .name = "__atomic_fetch_xor_4", .linkage = linkage }); + @export(makeFetchFn(u64, .Xor).fetch_op_N, .{ .name = "__atomic_fetch_xor_8", .linkage = linkage }); + + @export(makeFetchFn(u8, .Nand).fetch_op_N, .{ .name = "__atomic_fetch_nand_1", .linkage = linkage }); + @export(makeFetchFn(u16, .Nand).fetch_op_N, .{ .name = "__atomic_fetch_nand_2", .linkage = linkage }); + @export(makeFetchFn(u32, .Nand).fetch_op_N, .{ .name = "__atomic_fetch_nand_4", .linkage = linkage }); + @export(makeFetchFn(u64, .Nand).fetch_op_N, .{ .name = "__atomic_fetch_nand_8", .linkage = linkage }); +} -- 2.54.0 From e03cbb117ee661824a1025ffee39f3ae80e660a9 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 3 Apr 2020 16:07:32 -0400 Subject: [PATCH 19/91] compiler-rt: don't forget to export these functions --- lib/std/special/compiler_rt/atomics.zig | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/std/special/compiler_rt/atomics.zig b/lib/std/special/compiler_rt/atomics.zig index 9d68ee28094832fc871378806c1c7b366f1b81b9..ea990cb193dd08b7b791ff9aa440341dc72e10be 100644 --- a/lib/std/special/compiler_rt/atomics.zig +++ b/lib/std/special/compiler_rt/atomics.zig @@ -88,6 +88,13 @@ fn __atomic_compare_exchange( return 0; } +comptime { + @export(__atomic_load, .{ .name = "__atomic_load", .linkage = linkage }); + @export(__atomic_store, .{ .name = "__atomic_store", .linkage = linkage }); + @export(__atomic_exchange, .{ .name = "__atomic_exchange", .linkage = linkage }); + @export(__atomic_compare_exchange, .{ .name = "__atomic_compare_exchange", .linkage = linkage }); +} + // Specialized versions of the GCC atomic builtin functions. // LLVM emits those iff the object size is known and the pointers are correctly // aligned. -- 2.54.0 From a2cad9a3d9a2d7b578628c10bf0fa69c09623347 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 3 Apr 2020 18:36:13 -0400 Subject: [PATCH 20/91] add issue links to disabled test cases --- test/tests.zig | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/test/tests.zig b/test/tests.zig index 686127079206a130517ae5a9dd611121f9b1b41b..8ad58031842ba9d890b821ca22ceff3ce1f089ff 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -89,6 +89,15 @@ const test_targets = blk: { }, .link_libc = true, }, + // https://github.com/ziglang/zig/issues/4926 + //TestTarget{ + // .target = .{ + // .cpu_arch = .i386, + // .os_tag = .linux, + // .abi = .gnu, + // }, + // .link_libc = true, + //}, TestTarget{ .target = .{ @@ -127,7 +136,7 @@ const test_targets = blk: { }) catch unreachable, .link_libc = true, }, - // TODO https://github.com/ziglang/zig/issues/3287 + // https://github.com/ziglang/zig/issues/3287 //TestTarget{ // .target = CrossTarget.parse(.{ // .arch_os_abi = "arm-linux-gnueabihf", @@ -151,6 +160,15 @@ const test_targets = blk: { }, .link_libc = true, }, + // https://github.com/ziglang/zig/issues/4927 + //TestTarget{ + // .target = .{ + // .cpu_arch = .mipsel, + // .os_tag = .linux, + // .abi = .gnu, + // }, + // .link_libc = true, + //}, TestTarget{ .target = .{ @@ -185,7 +203,7 @@ const test_targets = blk: { .os_tag = .macosx, .abi = .gnu, }, - // TODO https://github.com/ziglang/zig/issues/3295 + // https://github.com/ziglang/zig/issues/3295 .disable_native = true, }, -- 2.54.0 From f1425fd9da1b2e1297a36108b12b0bd89398b057 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 3 Apr 2020 18:36:42 -0400 Subject: [PATCH 21/91] gitattributes: note that libcxxabi is vendored --- .gitattributes | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitattributes b/.gitattributes index 8f894eb5690f3dc39c69699a4e8d06e526906a27..a2ec267781ae2fab049e7ca9306a864a78cdaf09 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6,4 +6,5 @@ deps/* linguist-vendored lib/include/* linguist-vendored lib/libc/* linguist-vendored lib/libcxx/* linguist-vendored +lib/libcxxabi/* linguist-vendored lib/libunwind/* linguist-vendored -- 2.54.0 From db4c06ce606dcfe989b5c1f76d5ed00e90d5dd9f Mon Sep 17 00:00:00 2001 From: Michael Dusan Date: Fri, 3 Apr 2020 11:41:55 -0400 Subject: [PATCH 22/91] stage1: add compile errors for sentinel slicing closes #3963 --- src/ir.cpp | 108 ++++++- test/compile_errors.zig | 295 ++++++++++++++++++ test/stage1/behavior.zig | 1 + .../behavior/slice_sentinel_comptime.zig | 199 ++++++++++++ 4 files changed, 602 insertions(+), 1 deletion(-) create mode 100644 test/stage1/behavior/slice_sentinel_comptime.zig diff --git a/src/ir.cpp b/src/ir.cpp index 2f9e3638f85c1a5c39de5bfa5624287d9e94cc0c..1e3fe67b2b714d9db9f1e20559a3db1ada634ad1 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -26583,7 +26583,6 @@ done_with_return_type: if (parent_ptr == nullptr) return ira->codegen->invalid_inst_gen; - if (parent_ptr->special == ConstValSpecialUndef) { array_val = nullptr; abs_offset = 0; @@ -26746,6 +26745,113 @@ done_with_return_type: return ira->codegen->invalid_inst_gen; } + // check sentinel when target is comptime-known + { + if (!sentinel_val) + goto exit_check_sentinel; + + switch (ptr_ptr->value->data.x_ptr.mut) { + case ConstPtrMutComptimeConst: + case ConstPtrMutComptimeVar: + break; + case ConstPtrMutRuntimeVar: + case ConstPtrMutInfer: + goto exit_check_sentinel; + } + + // prepare check parameters + ZigValue *target = const_ptr_pointee(ira, ira->codegen, ptr_ptr->value, instruction->base.base.source_node); + if (target == nullptr) + return ira->codegen->invalid_inst_gen; + + uint64_t target_len = 0; + ZigValue *target_sentinel = nullptr; + ZigValue *target_elements = nullptr; + + for (;;) { + if (target->type->id == ZigTypeIdArray) { + // handle `[N]T` + target_len = target->type->data.array.len; + target_sentinel = target->type->data.array.sentinel; + target_elements = target->data.x_array.data.s_none.elements; + break; + } else if (target->type->id == ZigTypeIdPointer && target->type->data.pointer.child_type->id == ZigTypeIdArray) { + // handle `*[N]T` + target = const_ptr_pointee(ira, ira->codegen, target, instruction->base.base.source_node); + if (target == nullptr) + return ira->codegen->invalid_inst_gen; + assert(target->type->id == ZigTypeIdArray); + continue; + } else if (target->type->id == ZigTypeIdPointer) { + // handle `[*]T` + // handle `[*c]T` + switch (target->data.x_ptr.special) { + case ConstPtrSpecialInvalid: + case ConstPtrSpecialDiscard: + zig_unreachable(); + case ConstPtrSpecialRef: + target = target->data.x_ptr.data.ref.pointee; + assert(target->type->id == ZigTypeIdArray); + continue; + case ConstPtrSpecialBaseArray: + case ConstPtrSpecialSubArray: + target = target->data.x_ptr.data.base_array.array_val; + assert(target->type->id == ZigTypeIdArray); + continue; + case ConstPtrSpecialBaseStruct: + zig_panic("TODO slice const inner struct"); + case ConstPtrSpecialBaseErrorUnionCode: + zig_panic("TODO slice const inner error union code"); + case ConstPtrSpecialBaseErrorUnionPayload: + zig_panic("TODO slice const inner error union payload"); + case ConstPtrSpecialBaseOptionalPayload: + zig_panic("TODO slice const inner optional payload"); + case ConstPtrSpecialHardCodedAddr: + // skip check + goto exit_check_sentinel; + case ConstPtrSpecialFunction: + zig_panic("TODO slice of ptr cast from function"); + case ConstPtrSpecialNull: + zig_panic("TODO slice of null ptr"); + } + break; + } else if (is_slice(target->type)) { + // handle `[]T` + target = target->data.x_struct.fields[slice_ptr_index]; + assert(target->type->id == ZigTypeIdPointer); + continue; + } + + zig_unreachable(); + } + + // perform check + if (target_sentinel == nullptr) { + if (end_scalar >= target_len) { + ir_add_error(ira, &instruction->base.base, buf_sprintf("slice-sentinel is out of bounds")); + return ira->codegen->invalid_inst_gen; + } + if (!const_values_equal(ira->codegen, sentinel_val, &target_elements[end_scalar])) { + ir_add_error(ira, &instruction->base.base, buf_sprintf("slice-sentinel does not match memory at target index")); + return ira->codegen->invalid_inst_gen; + } + } else { + assert(end_scalar <= target_len); + if (end_scalar == target_len) { + if (!const_values_equal(ira->codegen, sentinel_val, target_sentinel)) { + ir_add_error(ira, &instruction->base.base, buf_sprintf("slice-sentinel does not match target-sentinel")); + return ira->codegen->invalid_inst_gen; + } + } else { + if (!const_values_equal(ira->codegen, sentinel_val, &target_elements[end_scalar])) { + ir_add_error(ira, &instruction->base.base, buf_sprintf("slice-sentinel does not match memory at target index")); + return ira->codegen->invalid_inst_gen; + } + } + } + } + exit_check_sentinel: + IrInstGen *result = ir_const(ira, &instruction->base.base, return_type); ZigValue *ptr_val; diff --git a/test/compile_errors.zig b/test/compile_errors.zig index e54f6591b54be69df11241cd15b819036720bd1a..a3c29e0dd60f341787a48cccc1f4add4047e41bc 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -6857,4 +6857,299 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { "tmp.zig:7:32: error: destination type 'u16' has size 2 but source type '[]u8' has size 16", "tmp.zig:7:37: note: referenced here", }); + + cases.add("comptime slice-sentinel is out of bounds (unterminated)", + \\export fn foo_array() void { + \\ comptime { + \\ var target = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + \\ const slice = target[0..14 :0]; + \\ } + \\} + \\export fn foo_ptr_array() void { + \\ comptime { + \\ var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + \\ var target = &buf; + \\ const slice = target[0..14 :0]; + \\ } + \\} + \\export fn foo_vector_ConstPtrSpecialBaseArray() void { + \\ comptime { + \\ var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + \\ var target: [*]u8 = &buf; + \\ const slice = target[0..14 :0]; + \\ } + \\} + \\export fn foo_vector_ConstPtrSpecialRef() void { + \\ comptime { + \\ var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + \\ var target: [*]u8 = @ptrCast([*]u8, &buf); + \\ const slice = target[0..14 :0]; + \\ } + \\} + \\export fn foo_cvector_ConstPtrSpecialBaseArray() void { + \\ comptime { + \\ var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + \\ var target: [*c]u8 = &buf; + \\ const slice = target[0..14 :0]; + \\ } + \\} + \\export fn foo_cvector_ConstPtrSpecialRef() void { + \\ comptime { + \\ var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + \\ var target: [*c]u8 = @ptrCast([*c]u8, &buf); + \\ const slice = target[0..14 :0]; + \\ } + \\} + \\export fn foo_slice() void { + \\ comptime { + \\ var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + \\ var target: []u8 = &buf; + \\ const slice = target[0..14 :0]; + \\ } + \\} + , &[_][]const u8{ + ":4:29: error: slice-sentinel is out of bounds", + ":11:29: error: slice-sentinel is out of bounds", + ":18:29: error: slice-sentinel is out of bounds", + ":25:29: error: slice-sentinel is out of bounds", + ":32:29: error: slice-sentinel is out of bounds", + ":39:29: error: slice-sentinel is out of bounds", + ":46:29: error: slice-sentinel is out of bounds", + }); + + cases.add("comptime slice-sentinel is out of bounds (terminated)", + \\export fn foo_array() void { + \\ comptime { + \\ var target = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + \\ const slice = target[0..15 :1]; + \\ } + \\} + \\export fn foo_ptr_array() void { + \\ comptime { + \\ var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + \\ var target = &buf; + \\ const slice = target[0..15 :0]; + \\ } + \\} + \\export fn foo_vector_ConstPtrSpecialBaseArray() void { + \\ comptime { + \\ var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + \\ var target: [*]u8 = &buf; + \\ const slice = target[0..15 :0]; + \\ } + \\} + \\export fn foo_vector_ConstPtrSpecialRef() void { + \\ comptime { + \\ var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + \\ var target: [*]u8 = @ptrCast([*]u8, &buf); + \\ const slice = target[0..15 :0]; + \\ } + \\} + \\export fn foo_cvector_ConstPtrSpecialBaseArray() void { + \\ comptime { + \\ var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + \\ var target: [*c]u8 = &buf; + \\ const slice = target[0..15 :0]; + \\ } + \\} + \\export fn foo_cvector_ConstPtrSpecialRef() void { + \\ comptime { + \\ var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + \\ var target: [*c]u8 = @ptrCast([*c]u8, &buf); + \\ const slice = target[0..15 :0]; + \\ } + \\} + \\export fn foo_slice() void { + \\ comptime { + \\ var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + \\ var target: []u8 = &buf; + \\ const slice = target[0..15 :0]; + \\ } + \\} + , &[_][]const u8{ + ":4:29: error: out of bounds slice", + ":11:29: error: out of bounds slice", + ":18:29: error: out of bounds slice", + ":25:29: error: out of bounds slice", + ":32:29: error: out of bounds slice", + ":39:29: error: out of bounds slice", + ":46:29: error: out of bounds slice", + }); + + cases.add("comptime slice-sentinel does not match memory at target index (unterminated)", + \\export fn foo_array() void { + \\ comptime { + \\ var target = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + \\ const slice = target[0..3 :0]; + \\ } + \\} + \\export fn foo_ptr_array() void { + \\ comptime { + \\ var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + \\ var target = &buf; + \\ const slice = target[0..3 :0]; + \\ } + \\} + \\export fn foo_vector_ConstPtrSpecialBaseArray() void { + \\ comptime { + \\ var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + \\ var target: [*]u8 = &buf; + \\ const slice = target[0..3 :0]; + \\ } + \\} + \\export fn foo_vector_ConstPtrSpecialRef() void { + \\ comptime { + \\ var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + \\ var target: [*]u8 = @ptrCast([*]u8, &buf); + \\ const slice = target[0..3 :0]; + \\ } + \\} + \\export fn foo_cvector_ConstPtrSpecialBaseArray() void { + \\ comptime { + \\ var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + \\ var target: [*c]u8 = &buf; + \\ const slice = target[0..3 :0]; + \\ } + \\} + \\export fn foo_cvector_ConstPtrSpecialRef() void { + \\ comptime { + \\ var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + \\ var target: [*c]u8 = @ptrCast([*c]u8, &buf); + \\ const slice = target[0..3 :0]; + \\ } + \\} + \\export fn foo_slice() void { + \\ comptime { + \\ var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + \\ var target: []u8 = &buf; + \\ const slice = target[0..3 :0]; + \\ } + \\} + , &[_][]const u8{ + ":4:29: error: slice-sentinel does not match memory at target index", + ":11:29: error: slice-sentinel does not match memory at target index", + ":18:29: error: slice-sentinel does not match memory at target index", + ":25:29: error: slice-sentinel does not match memory at target index", + ":32:29: error: slice-sentinel does not match memory at target index", + ":39:29: error: slice-sentinel does not match memory at target index", + ":46:29: error: slice-sentinel does not match memory at target index", + }); + + cases.add("comptime slice-sentinel does not match memory at target index (terminated)", + \\export fn foo_array() void { + \\ comptime { + \\ var target = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + \\ const slice = target[0..3 :0]; + \\ } + \\} + \\export fn foo_ptr_array() void { + \\ comptime { + \\ var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + \\ var target = &buf; + \\ const slice = target[0..3 :0]; + \\ } + \\} + \\export fn foo_vector_ConstPtrSpecialBaseArray() void { + \\ comptime { + \\ var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + \\ var target: [*]u8 = &buf; + \\ const slice = target[0..3 :0]; + \\ } + \\} + \\export fn foo_vector_ConstPtrSpecialRef() void { + \\ comptime { + \\ var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + \\ var target: [*]u8 = @ptrCast([*]u8, &buf); + \\ const slice = target[0..3 :0]; + \\ } + \\} + \\export fn foo_cvector_ConstPtrSpecialBaseArray() void { + \\ comptime { + \\ var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + \\ var target: [*c]u8 = &buf; + \\ const slice = target[0..3 :0]; + \\ } + \\} + \\export fn foo_cvector_ConstPtrSpecialRef() void { + \\ comptime { + \\ var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + \\ var target: [*c]u8 = @ptrCast([*c]u8, &buf); + \\ const slice = target[0..3 :0]; + \\ } + \\} + \\export fn foo_slice() void { + \\ comptime { + \\ var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + \\ var target: []u8 = &buf; + \\ const slice = target[0..3 :0]; + \\ } + \\} + , &[_][]const u8{ + ":4:29: error: slice-sentinel does not match memory at target index", + ":11:29: error: slice-sentinel does not match memory at target index", + ":18:29: error: slice-sentinel does not match memory at target index", + ":25:29: error: slice-sentinel does not match memory at target index", + ":32:29: error: slice-sentinel does not match memory at target index", + ":39:29: error: slice-sentinel does not match memory at target index", + ":46:29: error: slice-sentinel does not match memory at target index", + }); + + cases.add("comptime slice-sentinel does not match target-sentinel", + \\export fn foo_array() void { + \\ comptime { + \\ var target = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + \\ const slice = target[0..14 :255]; + \\ } + \\} + \\export fn foo_ptr_array() void { + \\ comptime { + \\ var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + \\ var target = &buf; + \\ const slice = target[0..14 :255]; + \\ } + \\} + \\export fn foo_vector_ConstPtrSpecialBaseArray() void { + \\ comptime { + \\ var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + \\ var target: [*]u8 = &buf; + \\ const slice = target[0..14 :255]; + \\ } + \\} + \\export fn foo_vector_ConstPtrSpecialRef() void { + \\ comptime { + \\ var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + \\ var target: [*]u8 = @ptrCast([*]u8, &buf); + \\ const slice = target[0..14 :255]; + \\ } + \\} + \\export fn foo_cvector_ConstPtrSpecialBaseArray() void { + \\ comptime { + \\ var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + \\ var target: [*c]u8 = &buf; + \\ const slice = target[0..14 :255]; + \\ } + \\} + \\export fn foo_cvector_ConstPtrSpecialRef() void { + \\ comptime { + \\ var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + \\ var target: [*c]u8 = @ptrCast([*c]u8, &buf); + \\ const slice = target[0..14 :255]; + \\ } + \\} + \\export fn foo_slice() void { + \\ comptime { + \\ var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + \\ var target: []u8 = &buf; + \\ const slice = target[0..14 :255]; + \\ } + \\} + , &[_][]const u8{ + ":4:29: error: slice-sentinel does not match target-sentinel", + ":11:29: error: slice-sentinel does not match target-sentinel", + ":18:29: error: slice-sentinel does not match target-sentinel", + ":25:29: error: slice-sentinel does not match target-sentinel", + ":32:29: error: slice-sentinel does not match target-sentinel", + ":39:29: error: slice-sentinel does not match target-sentinel", + ":46:29: error: slice-sentinel does not match target-sentinel", + }); } diff --git a/test/stage1/behavior.zig b/test/stage1/behavior.zig index c3407db3e6560bd76666862701fc068573348ac6..52ce5979e11a6d7e9ff3bc20c2ef9ae810bf9793 100644 --- a/test/stage1/behavior.zig +++ b/test/stage1/behavior.zig @@ -96,6 +96,7 @@ comptime { _ = @import("behavior/shuffle.zig"); _ = @import("behavior/sizeof_and_typeof.zig"); _ = @import("behavior/slice.zig"); + _ = @import("behavior/slice_sentinel_comptime.zig"); _ = @import("behavior/struct.zig"); _ = @import("behavior/struct_contains_null_ptr_itself.zig"); _ = @import("behavior/struct_contains_slice_of_itself.zig"); diff --git a/test/stage1/behavior/slice_sentinel_comptime.zig b/test/stage1/behavior/slice_sentinel_comptime.zig new file mode 100644 index 0000000000000000000000000000000000000000..79da5d3c528872a5e56d8b8ff67bdcdfff089f8d --- /dev/null +++ b/test/stage1/behavior/slice_sentinel_comptime.zig @@ -0,0 +1,199 @@ +test "comptime slice-sentinel in bounds (unterminated)" { + // array + comptime { + var target = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + const slice = target[0..3 :'d']; + } + + // ptr_array + comptime { + var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + var target = &buf; + const slice = target[0..3 :'d']; + } + + // vector_ConstPtrSpecialBaseArray + comptime { + var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + var target: [*]u8 = &buf; + const slice = target[0..3 :'d']; + } + + // vector_ConstPtrSpecialRef + comptime { + var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + var target: [*]u8 = @ptrCast([*]u8, &buf); + const slice = target[0..3 :'d']; + } + + // cvector_ConstPtrSpecialBaseArray + comptime { + var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + var target: [*c]u8 = &buf; + const slice = target[0..3 :'d']; + } + + // cvector_ConstPtrSpecialRef + comptime { + var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + var target: [*c]u8 = @ptrCast([*c]u8, &buf); + const slice = target[0..3 :'d']; + } + + // slice + comptime { + var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + var target: []u8 = &buf; + const slice = target[0..3 :'d']; + } +} + +test "comptime slice-sentinel in bounds (end,unterminated)" { + // array + comptime { + var target = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10; + const slice = target[0..13 :0xff]; + } + + // ptr_array + comptime { + var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10; + var target = &buf; + const slice = target[0..13 :0xff]; + } + + // vector_ConstPtrSpecialBaseArray + comptime { + var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10; + var target: [*]u8 = &buf; + const slice = target[0..13 :0xff]; + } + + // vector_ConstPtrSpecialRef + comptime { + var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10; + var target: [*]u8 = @ptrCast([*]u8, &buf); + const slice = target[0..13 :0xff]; + } + + // cvector_ConstPtrSpecialBaseArray + comptime { + var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10; + var target: [*c]u8 = &buf; + const slice = target[0..13 :0xff]; + } + + // cvector_ConstPtrSpecialRef + comptime { + var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10; + var target: [*c]u8 = @ptrCast([*c]u8, &buf); + const slice = target[0..13 :0xff]; + } + + // slice + comptime { + var buf = [_]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{0xff} ** 10; + var target: []u8 = &buf; + const slice = target[0..13 :0xff]; + } +} + +test "comptime slice-sentinel in bounds (terminated)" { + // array + comptime { + var target = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + const slice = target[0..3 :'d']; + } + + // ptr_array + comptime { + var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + var target = &buf; + const slice = target[0..3 :'d']; + } + + // vector_ConstPtrSpecialBaseArray + comptime { + var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + var target: [*]u8 = &buf; + const slice = target[0..3 :'d']; + } + + // vector_ConstPtrSpecialRef + comptime { + var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + var target: [*]u8 = @ptrCast([*]u8, &buf); + const slice = target[0..3 :'d']; + } + + // cvector_ConstPtrSpecialBaseArray + comptime { + var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + var target: [*c]u8 = &buf; + const slice = target[0..3 :'d']; + } + + // cvector_ConstPtrSpecialRef + comptime { + var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + var target: [*c]u8 = @ptrCast([*c]u8, &buf); + const slice = target[0..3 :'d']; + } + + // slice + comptime { + var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + var target: []u8 = &buf; + const slice = target[0..3 :'d']; + } +} + +test "comptime slice-sentinel in bounds (on target sentinel)" { + // array + comptime { + var target = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + const slice = target[0..14 :0]; + } + + // ptr_array + comptime { + var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + var target = &buf; + const slice = target[0..14 :0]; + } + + // vector_ConstPtrSpecialBaseArray + comptime { + var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + var target: [*]u8 = &buf; + const slice = target[0..14 :0]; + } + + // vector_ConstPtrSpecialRef + comptime { + var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + var target: [*]u8 = @ptrCast([*]u8, &buf); + const slice = target[0..14 :0]; + } + + // cvector_ConstPtrSpecialBaseArray + comptime { + var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + var target: [*c]u8 = &buf; + const slice = target[0..14 :0]; + } + + // cvector_ConstPtrSpecialRef + comptime { + var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + var target: [*c]u8 = @ptrCast([*c]u8, &buf); + const slice = target[0..14 :0]; + } + + // slice + comptime { + var buf = [_:0]u8{ 'a', 'b', 'c', 'd' } ++ [_]u8{undefined} ** 10; + var target: []u8 = &buf; + const slice = target[0..14 :0]; + } +} -- 2.54.0 From 8b6a06eefe8738896a6657c86af5770250e0b67a Mon Sep 17 00:00:00 2001 From: Michael Dusan Date: Fri, 3 Apr 2020 19:11:51 -0400 Subject: [PATCH 23/91] add compiler-error test: coerce Issue fixed by an unknown commit. closes #4207 --- test/compile_errors.zig | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/compile_errors.zig b/test/compile_errors.zig index a3c29e0dd60f341787a48cccc1f4add4047e41bc..166ed67561c96d576897f401fb2771bace9995b2 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -7152,4 +7152,14 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { ":39:29: error: slice-sentinel does not match target-sentinel", ":46:29: error: slice-sentinel does not match target-sentinel", }); + + cases.add("issue #4207: coerce from non-terminated-slice to terminated-pointer", + \\export fn foo() [*:0]const u8 { + \\ var buffer: [64]u8 = undefined; + \\ return buffer[0..]; + \\} + , &[_][]const u8{ + ":3:18: error: expected type '[*:0]const u8', found '*[64]u8'", + ":3:18: note: destination pointer requires a terminating '0' sentinel", + }); } -- 2.54.0 From 391ee996a57873b7dfc0f72b3904051a6e1a6e8a Mon Sep 17 00:00:00 2001 From: Jadon Fowler Date: Sat, 4 Apr 2020 02:16:30 -0400 Subject: [PATCH 24/91] translate-c: account for signedness when translating div & mod Signed-off-by: Jadon Fowler --- src-self-hosted/translate_c.zig | 84 +++++++++++++++++++++++++-------- test/translate_c.zig | 38 ++++++++++----- 2 files changed, 91 insertions(+), 31 deletions(-) diff --git a/src-self-hosted/translate_c.zig b/src-self-hosted/translate_c.zig index da7053d25aa4ef2b207c71270d790103adabe6f2..66dd8d581e98adc387377275868fd620bd841178 100644 --- a/src-self-hosted/translate_c.zig +++ b/src-self-hosted/translate_c.zig @@ -1170,7 +1170,7 @@ fn transBinaryOperator( } }, .Div => { - if (!cIsUnsignedInteger(qt)) { + if (cIsSignedInteger(qt)) { // signed integer division uses @divTrunc const div_trunc_node = try transCreateNodeBuiltinFnCall(rp.c, "@divTrunc"); try div_trunc_node.params.push(try transExpr(rp, scope, ZigClangBinaryOperator_getLHS(stmt), .used, .l_value)); @@ -1182,7 +1182,7 @@ fn transBinaryOperator( } }, .Rem => { - if (!cIsUnsignedInteger(qt)) { + if (cIsSignedInteger(qt)) { // signed integer division uses @rem const rem_node = try transCreateNodeBuiltinFnCall(rp.c, "@rem"); try rem_node.params.push(try transExpr(rp, scope, ZigClangBinaryOperator_getLHS(stmt), .used, .l_value)); @@ -3048,13 +3048,37 @@ fn transCreateCompoundAssign( used: ResultUsed, ) TransError!*ast.Node { const is_shift = bin_op == .BitShiftLeft or bin_op == .BitShiftRight; + const is_div = bin_op == .Div; + const is_mod = bin_op == .Mod; const lhs = ZigClangCompoundAssignOperator_getLHS(stmt); const rhs = ZigClangCompoundAssignOperator_getRHS(stmt); const loc = ZigClangCompoundAssignOperator_getBeginLoc(stmt); + const is_signed = cIsSignedInteger(getExprQualType(rp.c, lhs)); if (used == .unused) { // common case // c: lhs += rhs // zig: lhs += rhs + + if ((is_mod or is_div) and is_signed) { + const op_token = try appendToken(rp.c, .Equal, "="); + const op_node = try rp.c.a().create(ast.Node.InfixOp); + const builtin = if (is_mod) "@rem" else "@divTrunc"; + const builtin_node = try transCreateNodeBuiltinFnCall(rp.c, builtin); + const lhs_node = try transExpr(rp, scope, lhs, .used, .l_value); + try builtin_node.params.push(lhs_node); + _ = try appendToken(rp.c, .Comma, ","); + try builtin_node.params.push(try transExpr(rp, scope, rhs, .used, .r_value)); + builtin_node.rparen_token = try appendToken(rp.c, .RParen, ")"); + op_node.* = .{ + .op_token = op_token, + .lhs = lhs_node, + .op = .Assign, + .rhs = &builtin_node.base, + }; + _ = try appendToken(rp.c, .Semicolon, ";"); + return &op_node.base; + } + const lhs_node = try transExpr(rp, scope, lhs, .used, .l_value); const eq_token = try appendToken(rp.c, assign_tok_id, assign_bytes); var rhs_node = if (is_shift) @@ -3097,31 +3121,53 @@ fn transCreateCompoundAssign( const lhs_node = try transCreateNodeIdentifier(rp.c, ref); const ref_node = try transCreateNodePtrDeref(rp.c, lhs_node); _ = try appendToken(rp.c, .Semicolon, ";"); - const bin_token = try appendToken(rp.c, bin_tok_id, bin_bytes); - var rhs_node = try transExpr(rp, scope, rhs, .used, .r_value); - if (is_shift) { - const cast_node = try transCreateNodeBuiltinFnCall(rp.c, "@intCast"); - const rhs_type = try qualTypeToLog2IntRef(rp, getExprQualType(rp.c, rhs), loc); - try cast_node.params.push(rhs_type); + + if ((is_mod or is_div) and is_signed) { + const op_token = try appendToken(rp.c, .Equal, "="); + const op_node = try rp.c.a().create(ast.Node.InfixOp); + const builtin = if (is_mod) "@rem" else "@divTrunc"; + const builtin_node = try transCreateNodeBuiltinFnCall(rp.c, builtin); + try builtin_node.params.push(try transCreateNodePtrDeref(rp.c, lhs_node)); _ = try appendToken(rp.c, .Comma, ","); - try cast_node.params.push(rhs_node); - cast_node.rparen_token = try appendToken(rp.c, .RParen, ")"); - rhs_node = &cast_node.base; + try builtin_node.params.push(try transExpr(rp, scope, rhs, .used, .r_value)); + builtin_node.rparen_token = try appendToken(rp.c, .RParen, ")"); + _ = try appendToken(rp.c, .Semicolon, ";"); + op_node.* = .{ + .op_token = op_token, + .lhs = ref_node, + .op = .Assign, + .rhs = &builtin_node.base, + }; + _ = try appendToken(rp.c, .Semicolon, ";"); + try block_scope.block_node.statements.push(&op_node.base); + } else { + const bin_token = try appendToken(rp.c, bin_tok_id, bin_bytes); + var rhs_node = try transExpr(rp, scope, rhs, .used, .r_value); + + if (is_shift) { + const cast_node = try transCreateNodeBuiltinFnCall(rp.c, "@intCast"); + const rhs_type = try qualTypeToLog2IntRef(rp, getExprQualType(rp.c, rhs), loc); + try cast_node.params.push(rhs_type); + _ = try appendToken(rp.c, .Comma, ","); + try cast_node.params.push(rhs_node); + cast_node.rparen_token = try appendToken(rp.c, .RParen, ")"); + rhs_node = &cast_node.base; + } + + const rhs_bin = try transCreateNodeInfixOp(rp, scope, ref_node, bin_op, bin_token, rhs_node, .used, false); + _ = try appendToken(rp.c, .Semicolon, ";"); + + const eq_token = try appendToken(rp.c, .Equal, "="); + const assign = try transCreateNodeInfixOp(rp, scope, ref_node, .Assign, eq_token, rhs_bin, .used, false); + try block_scope.block_node.statements.push(assign); } - const rhs_bin = try transCreateNodeInfixOp(rp, scope, ref_node, bin_op, bin_token, rhs_node, .used, false); - - _ = try appendToken(rp.c, .Semicolon, ";"); - - const eq_token = try appendToken(rp.c, .Equal, "="); - const assign = try transCreateNodeInfixOp(rp, scope, ref_node, .Assign, eq_token, rhs_bin, .used, false); - try block_scope.block_node.statements.push(assign); const break_node = try transCreateNodeBreak(rp.c, block_scope.label); break_node.rhs = ref_node; try block_scope.block_node.statements.push(&break_node.base); block_scope.block_node.rbrace = try appendToken(rp.c, .RBrace, "}"); // semicolon must immediately follow rbrace because it is the last token in a block - _ = try appendToken(rp.c, .Semicolon, ";"); + _ = try appendToken(rp.c, .Semicolon, ";4"); const grouped_expr = try rp.c.a().create(ast.Node.GroupedExpression); grouped_expr.* = .{ .lparen = try appendToken(rp.c, .LParen, "("), diff --git a/test/translate_c.zig b/test/translate_c.zig index a09f6b42b126ea465c056e467408964123737ba6..a3a22a199253a50015226f0477134dbfc9a035eb 100644 --- a/test/translate_c.zig +++ b/test/translate_c.zig @@ -2375,20 +2375,24 @@ pub fn addCases(cases: *tests.TranslateCContext) void { cases.add("compound assignment operators", \\void foo(void) { \\ int a = 0; + \\ unsigned b = 0; \\ a += (a += 1); \\ a -= (a -= 1); \\ a *= (a *= 1); \\ a &= (a &= 1); \\ a |= (a |= 1); \\ a ^= (a ^= 1); + \\ a >>= (a >>= 1); + \\ a <<= (a <<= 1); \\ a /= (a /= 1); \\ a %= (a %= 1); - \\ a >>= (a >>= 1); - \\ a <<= (a <<= 1); + \\ b /= (b /= 1); + \\ b %= (b %= 1); \\} , &[_][]const u8{ \\pub export fn foo() void { \\ var a: c_int = 0; + \\ var b: c_uint = @bitCast(c_uint, @as(c_int, 0)); \\ a += (blk: { \\ const ref = &a; \\ ref.* = ref.* + @as(c_int, 1); @@ -2419,16 +2423,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\ ref.* = ref.* ^ @as(c_int, 1); \\ break :blk ref.*; \\ }); - \\ a /= (blk: { - \\ const ref = &a; - \\ ref.* = ref.* / @as(c_int, 1); - \\ break :blk ref.*; - \\ }); - \\ a %= (blk: { - \\ const ref = &a; - \\ ref.* = ref.* % @as(c_int, 1); - \\ break :blk ref.*; - \\ }); \\ a >>= @intCast(@import("std").math.Log2Int(c_int), (blk: { \\ const ref = &a; \\ ref.* = ref.* >> @intCast(@import("std").math.Log2Int(c_int), @as(c_int, 1)); @@ -2439,6 +2433,26 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\ ref.* = ref.* << @intCast(@import("std").math.Log2Int(c_int), @as(c_int, 1)); \\ break :blk ref.*; \\ })); + \\ a = @divTrunc(a, (blk: { + \\ const ref = &a; + \\ ref.* = @divTrunc(ref.*, @as(c_int, 1)); + \\ break :blk ref.*; + \\ })); + \\ a = @rem(a, (blk: { + \\ const ref = &a; + \\ ref.* = @rem(ref.*, @as(c_int, 1)); + \\ break :blk ref.*; + \\ })); + \\ b /= (blk: { + \\ const ref = &b; + \\ ref.* = ref.* / @bitCast(c_uint, @as(c_int, 1)); + \\ break :blk ref.*; + \\ }); + \\ b %= (blk: { + \\ const ref = &b; + \\ ref.* = ref.* % @bitCast(c_uint, @as(c_int, 1)); + \\ break :blk ref.*; + \\ }); \\} }); -- 2.54.0 From 084c62f5d1fd6bf5e8df84e0cc87408ae38ca48f Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Sat, 4 Apr 2020 14:06:32 +0200 Subject: [PATCH 25/91] stage1: Fix serialization of ZigValue on BE machines --- src/ir.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ir.cpp b/src/ir.cpp index 1e3fe67b2b714d9db9f1e20559a3db1ada634ad1..54a5e89e17629cc452cef9e6a066282441c18073 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -28417,6 +28417,7 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou } BigInt big_int; bigint_read_twos_complement(&big_int, buf + offset, big_int_byte_count * 8, is_big_endian, false); + uint64_t bit_offset = 0; while (src_i < src_field_count) { TypeStructField *field = val->type->data.structure.fields[src_i]; src_assert(field->gen_index != SIZE_MAX, source_node); @@ -28429,7 +28430,11 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou BigInt child_val; if (is_big_endian) { - zig_panic("TODO buf_read_value_bytes packed struct big endian"); + BigInt packed_bits_size_bi; + bigint_init_unsigned(&packed_bits_size_bi, big_int_byte_count * 8 - packed_bits_size - bit_offset); + BigInt tmp; + bigint_shr(&tmp, &big_int, &packed_bits_size_bi); + bigint_truncate(&child_val, &tmp, packed_bits_size, false); } else { BigInt packed_bits_size_bi; bigint_init_unsigned(&packed_bits_size_bi, packed_bits_size); @@ -28439,11 +28444,12 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou big_int = tmp; } - bigint_write_twos_complement(&child_val, child_buf, big_int_byte_count * 8, is_big_endian); + bigint_write_twos_complement(&child_val, child_buf, packed_bits_size, is_big_endian); if ((err = buf_read_value_bytes(ira, codegen, source_node, child_buf, field_val))) { return err; } + bit_offset += packed_bits_size; src_i += 1; } offset += big_int_byte_count; -- 2.54.0 From ad2ebc87f2870ae297cdc2b8fd071668a90c2d83 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Sat, 4 Apr 2020 16:46:39 +0200 Subject: [PATCH 26/91] stage1: Byteswap floats when serializing them --- src/ir.cpp | 101 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 65 insertions(+), 36 deletions(-) diff --git a/src/ir.cpp b/src/ir.cpp index 54a5e89e17629cc452cef9e6a066282441c18073..bc222a311bfd16c6ae168abf21b24874bc23b345 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -10993,48 +10993,77 @@ static void float_negate(ZigValue *out_val, ZigValue *op) { } void float_write_ieee597(ZigValue *op, uint8_t *buf, bool is_big_endian) { - if (op->type->id == ZigTypeIdFloat) { - switch (op->type->data.floating.bit_count) { - case 16: - memcpy(buf, &op->data.x_f16, 2); // TODO wrong when compiler is big endian - return; - case 32: - memcpy(buf, &op->data.x_f32, 4); // TODO wrong when compiler is big endian - return; - case 64: - memcpy(buf, &op->data.x_f64, 8); // TODO wrong when compiler is big endian - return; - case 128: - memcpy(buf, &op->data.x_f128, 16); // TODO wrong when compiler is big endian - return; - default: - zig_unreachable(); - } - } else { + if (op->type->id != ZigTypeIdFloat) zig_unreachable(); + + const unsigned n = op->type->data.floating.bit_count / 8; + assert(n <= 16); + + switch (op->type->data.floating.bit_count) { + case 16: + memcpy(buf, &op->data.x_f16, 2); + break; + case 32: + memcpy(buf, &op->data.x_f32, 4); + break; + case 64: + memcpy(buf, &op->data.x_f64, 8); + break; + case 128: + memcpy(buf, &op->data.x_f128, 16); + break; + default: + zig_unreachable(); + } + + if (is_big_endian) { + // Byteswap in place if needed + for (size_t i = 0; i < n / 2; i++) { + uint8_t u = buf[i]; + buf[i] = buf[n - 1 - i]; + buf[n - 1 - i] = u; + } } } void float_read_ieee597(ZigValue *val, uint8_t *buf, bool is_big_endian) { - if (val->type->id == ZigTypeIdFloat) { - switch (val->type->data.floating.bit_count) { - case 16: - memcpy(&val->data.x_f16, buf, 2); // TODO wrong when compiler is big endian - return; - case 32: - memcpy(&val->data.x_f32, buf, 4); // TODO wrong when compiler is big endian - return; - case 64: - memcpy(&val->data.x_f64, buf, 8); // TODO wrong when compiler is big endian - return; - case 128: - memcpy(&val->data.x_f128, buf, 16); // TODO wrong when compiler is big endian - return; - default: - zig_unreachable(); - } - } else { + if (val->type->id != ZigTypeIdFloat) zig_unreachable(); + + const unsigned n = val->type->data.floating.bit_count / 8; + assert(n <= 16); + + uint8_t tmp[16]; + uint8_t *ptr = buf; + + if (is_big_endian) { + memcpy(tmp, buf, n); + + // Byteswap if needed + for (size_t i = 0; i < n / 2; i++) { + uint8_t u = tmp[i]; + tmp[i] = tmp[n - 1 - i]; + tmp[n - 1 - i] = u; + } + + ptr = tmp; + } + + switch (val->type->data.floating.bit_count) { + case 16: + memcpy(&val->data.x_f16, ptr, 2); + return; + case 32: + memcpy(&val->data.x_f32, ptr, 4); + return; + case 64: + memcpy(&val->data.x_f64, ptr, 8); + return; + case 128: + memcpy(&val->data.x_f128, ptr, 16); + return; + default: + zig_unreachable(); } } -- 2.54.0 From d73808f3ff7d36b32d53cc38cf9a5b29b1ea57d4 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 4 Apr 2020 11:57:28 -0400 Subject: [PATCH 27/91] remove `zig BUILD_INFO` hack Rather than stuffing configuration information into the Zig binary, the build script reads it from config.h. This solves a problem for package maintainers and improves the use case of deterministic builds. closes #3758 --- build.zig | 112 +++++++++++++++++++++++++++++++++++---------------- src/main.cpp | 12 ------ 2 files changed, 77 insertions(+), 47 deletions(-) diff --git a/build.zig b/build.zig index d31d8bbe3ca2667ff9f87fc2dadc95d4a323f384..16f279ac90af5edc490f41fd2504c41735e9505b 100644 --- a/build.zig +++ b/build.zig @@ -34,22 +34,7 @@ pub fn build(b: *Builder) !void { const test_step = b.step("test", "Run all the tests"); - // find the stage0 build artifacts because we're going to re-use config.h and zig_cpp library - const build_info = try b.exec(&[_][]const u8{ - b.zig_exe, - "BUILD_INFO", - }); - var index: usize = 0; - var ctx = Context{ - .cmake_binary_dir = nextValue(&index, build_info), - .cxx_compiler = nextValue(&index, build_info), - .llvm_config_exe = nextValue(&index, build_info), - .lld_include_dir = nextValue(&index, build_info), - .lld_libraries = nextValue(&index, build_info), - .clang_libraries = nextValue(&index, build_info), - .dia_guids_lib = nextValue(&index, build_info), - .llvm = undefined, - }; + var ctx = try findAndParseConfigH(b); ctx.llvm = try findLLVM(b, ctx.llvm_config_exe); var test_stage2 = b.addTest("src-self-hosted/test.zig"); @@ -262,25 +247,6 @@ fn findLLVM(b: *Builder, llvm_config_exe: []const u8) !LibraryDep { return result; } -fn nextValue(index: *usize, build_info: []const u8) []const u8 { - const start = index.*; - while (true) : (index.* += 1) { - switch (build_info[index.*]) { - '\n' => { - const result = build_info[start..index.*]; - index.* += 1; - return result; - }, - '\r' => { - const result = build_info[start..index.*]; - index.* += 2; - return result; - }, - else => continue, - } - } -} - fn configureStage2(b: *Builder, exe: var, ctx: Context) !void { exe.addIncludeDir("src"); exe.addIncludeDir(ctx.cmake_binary_dir); @@ -376,3 +342,79 @@ const Context = struct { dia_guids_lib: []const u8, llvm: LibraryDep, }; + +fn findAndParseConfigH(b: *Builder) !Context { + var check_dir = fs.path.dirname(b.zig_exe).?; + const config_h_text = while (true) { + var dir = try fs.cwd().openDir(check_dir, .{}); + defer dir.close(); + + const max_bytes = 1 * 1024 * 1024; + const config_h_text = dir.readFileAlloc(b.allocator, "config.h", max_bytes) catch |err| switch (err) { + error.FileNotFound => { + check_dir = fs.path.dirname(check_dir) orelse { + std.debug.warn("Unable to find config.h file relative to Zig executable.\n", .{}); + std.debug.warn("`zig build` must be run using a Zig executable within the source tree.\n", .{}); + std.process.exit(1); + }; + continue; + }, + else => |e| return e, + }; + break config_h_text; + } else unreachable; // TODO should not need `else unreachable`. + + var ctx: Context = .{ + .cmake_binary_dir = undefined, + .cxx_compiler = undefined, + .llvm_config_exe = undefined, + .lld_include_dir = undefined, + .lld_libraries = undefined, + .clang_libraries = undefined, + .dia_guids_lib = undefined, + .llvm = undefined, + }; + + const mappings = [_]struct { prefix: []const u8, field: []const u8 }{ + .{ + .prefix = "#define ZIG_CMAKE_BINARY_DIR ", + .field = "cmake_binary_dir", + }, + .{ + .prefix = "#define ZIG_CXX_COMPILER ", + .field = "cxx_compiler", + }, + .{ + .prefix = "#define ZIG_LLD_INCLUDE_PATH ", + .field = "lld_include_dir", + }, + .{ + .prefix = "#define ZIG_LLD_LIBRARIES ", + .field = "lld_libraries", + }, + .{ + .prefix = "#define ZIG_CLANG_LIBRARIES ", + .field = "clang_libraries", + }, + .{ + .prefix = "#define ZIG_LLVM_CONFIG_EXE ", + .field = "llvm_config_exe", + }, + .{ + .prefix = "#define ZIG_DIA_GUIDS_LIB ", + .field = "dia_guids_lib", + }, + }; + + var lines_it = mem.tokenize(config_h_text, "\r\n"); + while (lines_it.next()) |line| { + inline for (mappings) |mapping| { + if (mem.startsWith(u8, line, mapping.prefix)) { + var it = mem.separate(line, "\""); + _ = it.next().?; // skip the stuff before the quote + @field(ctx, mapping.field) = it.next().?; // the stuff inside the quote + } + } + } + return ctx; +} diff --git a/src/main.cpp b/src/main.cpp index 4d2775d75a9d00f5201528e03bdd2c1a542e9b51..17a1c2bc5346d0108b55868b76e57fdac4e93d3e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -260,18 +260,6 @@ static int main0(int argc, char **argv) { char *arg0 = argv[0]; Error err; - if (argc == 2 && strcmp(argv[1], "BUILD_INFO") == 0) { - printf("%s\n%s\n%s\n%s\n%s\n%s\n%s\n", - ZIG_CMAKE_BINARY_DIR, - ZIG_CXX_COMPILER, - ZIG_LLVM_CONFIG_EXE, - ZIG_LLD_INCLUDE_PATH, - ZIG_LLD_LIBRARIES, - ZIG_CLANG_LIBRARIES, - ZIG_DIA_GUIDS_LIB); - return 0; - } - if (argc >= 2 && (strcmp(argv[1], "clang") == 0 || strcmp(argv[1], "-cc1") == 0 || strcmp(argv[1], "-cc1as") == 0)) { -- 2.54.0 From 12cdea452524e4b852cb433728c834a7b0203b67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20=28xq=29=20Quei=C3=9Fner?= Date: Sat, 4 Apr 2020 15:45:04 +0200 Subject: [PATCH 28/91] Adds some documentation to std.atomic.Queue. --- lib/std/atomic/queue.zig | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/std/atomic/queue.zig b/lib/std/atomic/queue.zig index be0894d5cf21296ece10235b9977a3d9c32f0bc1..d6d0b707540580392cc788c095099db00883e971 100644 --- a/lib/std/atomic/queue.zig +++ b/lib/std/atomic/queue.zig @@ -5,6 +5,8 @@ const expect = std.testing.expect; /// Many producer, many consumer, non-allocating, thread-safe. /// Uses a mutex to protect access. +/// The queue does not manage ownership and the user is responsible to +/// manage the storage of the nodes. pub fn Queue(comptime T: type) type { return struct { head: ?*Node, @@ -14,6 +16,8 @@ pub fn Queue(comptime T: type) type { pub const Self = @This(); pub const Node = std.TailQueue(T).Node; + /// Initializes a new queue. The queue does not provide a `deinit()` + /// function, so the user must take care of cleaning up the queue elements. pub fn init() Self { return Self{ .head = null, @@ -22,6 +26,8 @@ pub fn Queue(comptime T: type) type { }; } + /// Appends `node` to the queue. + /// The lifetime of `node` must be longer than lifetime of queue. pub fn put(self: *Self, node: *Node) void { node.next = null; @@ -38,6 +44,9 @@ pub fn Queue(comptime T: type) type { } } + /// Gets a previously inserted node or returns `null` if there is none. + /// It is safe to `get()` a node from the queue while another thread tries + /// to `remove()` the same node at the same time. pub fn get(self: *Self) ?*Node { const held = self.mutex.acquire(); defer held.release(); @@ -71,7 +80,9 @@ pub fn Queue(comptime T: type) type { } } - /// Thread-safe with get() and remove(). Returns whether node was actually removed. + /// Removes a node from the queue, returns whether node was actually removed. + /// It is safe to `remove()` a node from the queue while another thread tries + /// to `get()` the same node at the same time. pub fn remove(self: *Self, node: *Node) bool { const held = self.mutex.acquire(); defer held.release(); @@ -95,16 +106,23 @@ pub fn Queue(comptime T: type) type { return true; } + /// Returns `true` if the queue is currently empty. + /// Note that in a multi-consumer environment a return value of `false` + /// does not mean that `get` will yield a non-`null` value! pub fn isEmpty(self: *Self) bool { const held = self.mutex.acquire(); defer held.release(); return self.head == null; } + /// Dumps the contents of the queue to `stderr`. pub fn dump(self: *Self) void { self.dumpToStream(std.io.getStdErr().outStream()) catch return; } + /// Dumps the contents of the queue to `stream`. + /// Up to 4 elements from the head are dumped and the tail of the queue is + /// dumped as well. pub fn dumpToStream(self: *Self, stream: var) !void { const S = struct { fn dumpRecursive( -- 2.54.0 From dc7e8b2fdcc35bc78abfe2413201ca6a74aa20d4 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 4 Apr 2020 14:05:49 -0400 Subject: [PATCH 29/91] build.zig: better detection of using outside zig executable As pointed out by gereeter, dirname("/") successfully returns "/" again. So checking for null is not sufficient. --- build.zig | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/build.zig b/build.zig index 16f279ac90af5edc490f41fd2504c41735e9505b..65175256a86517c7425c8dc756d26508b3365d66 100644 --- a/build.zig +++ b/build.zig @@ -352,11 +352,13 @@ fn findAndParseConfigH(b: *Builder) !Context { const max_bytes = 1 * 1024 * 1024; const config_h_text = dir.readFileAlloc(b.allocator, "config.h", max_bytes) catch |err| switch (err) { error.FileNotFound => { - check_dir = fs.path.dirname(check_dir) orelse { + const new_check_dir = fs.path.dirname(check_dir); + if (new_check_dir == null or mem.eql(u8, new_check_dir.?, check_dir)) { std.debug.warn("Unable to find config.h file relative to Zig executable.\n", .{}); std.debug.warn("`zig build` must be run using a Zig executable within the source tree.\n", .{}); std.process.exit(1); - }; + } + check_dir = new_check_dir.?; continue; }, else => |e| return e, -- 2.54.0 From d02838b71a0b0fd3495c1b714ab3c6da05441980 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 4 Apr 2020 14:43:51 -0400 Subject: [PATCH 30/91] add libutil to zig's glibc support --- lib/libc/glibc/abi.txt | 90 ++++++++++++++++++++++++++++++++++++++++++ lib/libc/glibc/fns.txt | 6 +++ src/glibc.cpp | 1 + src/target.cpp | 2 + tools/update_glibc.zig | 4 +- 5 files changed, 102 insertions(+), 1 deletion(-) diff --git a/lib/libc/glibc/abi.txt b/lib/libc/glibc/abi.txt index 4d8d6f52555ec8e320ec3ce3f21943d765876d68..4832449214ce0f3cd6faf08b1dec9c657b886866 100644 --- a/lib/libc/glibc/abi.txt +++ b/lib/libc/glibc/abi.txt @@ -1856,6 +1856,7 @@ aarch64-linux-gnu aarch64_be-linux-gnu 29 29 29 +29 37 37 37 @@ -2422,6 +2423,10 @@ aarch64-linux-gnu aarch64_be-linux-gnu 29 29 29 +29 +29 +29 +29 37 37 37 @@ -2625,6 +2630,7 @@ aarch64-linux-gnu aarch64_be-linux-gnu 29 29 29 +29 @@ -5572,6 +5578,7 @@ s390x-linux-gnu 5 5 5 +5 5 16 5 5 @@ -6151,7 +6158,11 @@ s390x-linux-gnu 37 37 37 +5 +5 5 16 +5 +5 31 5 5 5 @@ -6361,6 +6372,7 @@ s390x-linux-gnu 5 5 5 +5 @@ -9328,6 +9340,7 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf 16 16 16 +16 37 37 @@ -9894,6 +9907,10 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf 16 16 16 +16 +16 +16 +16 37 37 @@ -10108,6 +10125,7 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf 16 16 16 +16 21 16 37 @@ -13044,6 +13062,7 @@ sparc-linux-gnu sparcel-linux-gnu 0 5 0 0 +0 0 16 0 0 @@ -13623,10 +13642,14 @@ sparc-linux-gnu sparcel-linux-gnu 37 37 37 +0 +0 0 16 0 0 0 +0 +0 12 1 1 @@ -13833,6 +13856,7 @@ sparc-linux-gnu sparcel-linux-gnu 0 0 0 +0 @@ -16779,6 +16803,7 @@ sparcv9-linux-gnu 5 5 5 +0 5 5 5 @@ -17359,7 +17384,11 @@ sparcv9-linux-gnu 37 37 37 +0 +0 5 +0 +0 5 5 5 @@ -17565,6 +17594,7 @@ sparcv9-linux-gnu 16 5 5 +0 5 5 5 @@ -20520,6 +20550,7 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64 0 0 0 +0 5 5 5 @@ -21099,6 +21130,10 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64 0 0 0 +0 +0 +0 +0 12 5 5 @@ -21305,6 +21340,7 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64 0 0 0 +0 @@ -24256,6 +24292,7 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32 0 0 0 +0 5 5 5 @@ -24835,6 +24872,10 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32 0 0 0 +0 +0 +0 +0 12 5 5 @@ -25041,6 +25082,7 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32 0 0 0 +0 @@ -27992,6 +28034,7 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf 0 0 0 +0 5 5 5 @@ -28567,6 +28610,10 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf 37 37 +0 +0 +0 +0 0 0 0 @@ -28777,6 +28824,7 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf 0 0 0 +0 @@ -31728,6 +31776,7 @@ mipsel-linux-gnueabi mips-linux-gnueabi 0 0 0 +0 5 5 5 @@ -32303,6 +32352,10 @@ mipsel-linux-gnueabi mips-linux-gnueabi 37 37 +0 +0 +0 +0 0 0 0 @@ -32513,6 +32566,7 @@ mipsel-linux-gnueabi mips-linux-gnueabi 0 0 0 +0 @@ -35473,6 +35527,7 @@ x86_64-linux-gnu 10 10 10 +10 12 12 12 @@ -36043,6 +36098,10 @@ x86_64-linux-gnu 10 10 10 +10 +10 +10 +10 12 10 10 @@ -36249,6 +36308,7 @@ x86_64-linux-gnu 10 10 10 +10 @@ -39216,6 +39276,7 @@ x86_64-linux-gnux32 28 28 28 +28 36 37 37 @@ -39782,6 +39843,10 @@ x86_64-linux-gnux32 28 28 28 +28 +28 +28 +28 36 37 37 @@ -39985,6 +40050,7 @@ x86_64-linux-gnux32 28 28 28 +28 @@ -42936,6 +43002,7 @@ i386-linux-gnu 0 0 0 +0 1 5 5 @@ -43515,6 +43582,10 @@ i386-linux-gnu 0 0 0 +0 +0 +0 +0 12 1 1 @@ -43721,6 +43792,7 @@ i386-linux-gnu 0 0 0 +0 @@ -46688,6 +46760,7 @@ powerpc64le-linux-gnu 29 29 29 +29 36 37 37 @@ -47254,6 +47327,10 @@ powerpc64le-linux-gnu 29 29 29 +29 +29 +29 +29 36 37 37 @@ -47457,6 +47534,7 @@ powerpc64le-linux-gnu 29 29 29 +29 @@ -50404,6 +50482,7 @@ powerpc64-linux-gnu 12 12 12 +12 12 16 12 12 @@ -50983,7 +51062,11 @@ powerpc64-linux-gnu 37 37 +12 +12 12 16 +12 +12 12 15 12 12 @@ -51193,6 +51276,7 @@ powerpc64-linux-gnu 12 12 12 +12 @@ -54140,6 +54224,7 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf 0 5 0 0 +0 0 16 0 0 @@ -54719,7 +54804,11 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf 37 37 +0 +0 0 16 +0 +0 0 15 0 0 @@ -54929,6 +55018,7 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf 0 0 0 +0 diff --git a/lib/libc/glibc/fns.txt b/lib/libc/glibc/fns.txt index 4e2e126b0ed865244400daeaa43c57de9dfdcdb4..a1dd9b18e19ccc228f5db26db4198524c487a506 100644 --- a/lib/libc/glibc/fns.txt +++ b/lib/libc/glibc/fns.txt @@ -1834,6 +1834,7 @@ fopen c fopen64 c fopencookie c fork c +forkpty util fpathconf c fprintf c fputc c @@ -2414,7 +2415,11 @@ logf32 m logf32x m logf64 m logf64x m +login util +login_tty util logl m +logout util +logwtmp util longjmp c lrand48 c lrand48_r c @@ -2620,6 +2625,7 @@ openat c openat64 c opendir c openlog c +openpty util optarg c opterr c optind c diff --git a/src/glibc.cpp b/src/glibc.cpp index 75b77ec1228c061b44bd0e86f0d0931a980b9429..b78e140e1d83421e4c8dd53d4e865da01fdd7b32 100644 --- a/src/glibc.cpp +++ b/src/glibc.cpp @@ -17,6 +17,7 @@ static const ZigGLibCLib glibc_libs[] = { {"dl", 2}, {"rt", 1}, {"ld", 2}, + {"util", 1}, }; Error glibc_load_metadata(ZigGLibCAbi **out_result, Buf *zig_lib_dir, bool verbose) { diff --git a/src/target.cpp b/src/target.cpp index da19f76f4542c0e7081c0a0d08c9bcc66fa36bff..73c0924ab8a9364fac7785e6be95bf77a4223e5b 100644 --- a/src/target.cpp +++ b/src/target.cpp @@ -1238,6 +1238,8 @@ bool target_is_libc_lib_name(const ZigTarget *target, const char *name) { return true; if (strcmp(name, "dl") == 0) return true; + if (strcmp(name, "util") == 0) + return true; } return false; diff --git a/tools/update_glibc.zig b/tools/update_glibc.zig index d118b1482ef67f0398d0bd45ac4caf5fdfeac11a..38a781057921be1c963c54db515ed297c9b98faa 100644 --- a/tools/update_glibc.zig +++ b/tools/update_glibc.zig @@ -21,6 +21,7 @@ const lib_names = [_][]const u8{ "pthread", "rt", "ld", + "util", }; // fpu/nofpu are hardcoded elsewhere, based on .gnueabi/.gnueabihf with an exception for .arm @@ -182,7 +183,8 @@ pub fn main() !void { } break :blk try fs.path.join(allocator, &[_][]const u8{ prefix, abi_list.path, basename }); }; - const contents = std.io.readFileAlloc(allocator, abi_list_filename) catch |err| { + const max_bytes = 10 * 1024 * 1024; + const contents = std.fs.cwd().readFileAlloc(allocator, abi_list_filename, max_bytes) catch |err| { std.debug.warn("unable to open {}: {}\n", .{ abi_list_filename, err }); std.process.exit(1); }; -- 2.54.0 From 52db13738b3fca0ad5d83476e584be1d61a1428f Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 4 Apr 2020 14:58:24 -0400 Subject: [PATCH 31/91] zig cc looks for native include directories unless -nostdinc closes #4938 --- src-self-hosted/clang_options_data.zig | 38 ++++++++++++++++++++++---- src-self-hosted/stage2.zig | 1 + src/main.cpp | 7 ++++- src/stage2.h | 1 + tools/update_clang_options.zig | 20 ++++++++++++++ 5 files changed, 61 insertions(+), 6 deletions(-) diff --git a/src-self-hosted/clang_options_data.zig b/src-self-hosted/clang_options_data.zig index 2afe7f56819e112df24d6a2359f9e0dd57691d00..889737bdac6020f99333755b321bd664a2818d26 100644 --- a/src-self-hosted/clang_options_data.zig +++ b/src-self-hosted/clang_options_data.zig @@ -1725,7 +1725,7 @@ flagpsl("MT"), .{ .name = "no-standard-includes", .syntax = .flag, - .zig_equivalent = .other, + .zig_equivalent = .nostdlibinc, .pd1 = false, .pd2 = true, .psl = false, @@ -3781,7 +3781,14 @@ flagpd1("nocudainc"), flagpd1("nodefaultlibs"), flagpd1("nofixprebinding"), flagpd1("nogpulib"), -flagpd1("nolibc"), +.{ + .name = "nolibc", + .syntax = .flag, + .zig_equivalent = .nostdlib, + .pd1 = true, + .pd2 = false, + .psl = false, +}, flagpd1("nomultidefs"), flagpd1("fnon-call-exceptions"), flagpd1("fno-non-call-exceptions"), @@ -3790,8 +3797,22 @@ flagpd1("noprebind"), flagpd1("noprofilelib"), flagpd1("noseglinkedit"), flagpd1("nostartfiles"), -flagpd1("nostdinc"), -flagpd1("nostdinc++"), +.{ + .name = "nostdinc", + .syntax = .flag, + .zig_equivalent = .nostdlibinc, + .pd1 = true, + .pd2 = false, + .psl = false, +}, +.{ + .name = "nostdinc++", + .syntax = .flag, + .zig_equivalent = .nostdlib_cpp, + .pd1 = true, + .pd2 = false, + .psl = false, +}, .{ .name = "nostdlib", .syntax = .flag, @@ -3800,7 +3821,14 @@ flagpd1("nostdinc++"), .pd2 = false, .psl = false, }, -flagpd1("nostdlibinc"), +.{ + .name = "nostdlibinc", + .syntax = .flag, + .zig_equivalent = .nostdlibinc, + .pd1 = true, + .pd2 = false, + .psl = false, +}, .{ .name = "nostdlib++", .syntax = .flag, diff --git a/src-self-hosted/stage2.zig b/src-self-hosted/stage2.zig index b63b6e8ca8f5b7fdf94eeb33d18e3e568a8b49f5..bfc49a876bdfec6ebae61e4f01f3408fbc4043a9 100644 --- a/src-self-hosted/stage2.zig +++ b/src-self-hosted/stage2.zig @@ -1293,6 +1293,7 @@ pub const ClangArgIterator = extern struct { dep_file, framework_dir, framework, + nostdlibinc, }; const Args = struct { diff --git a/src/main.cpp b/src/main.cpp index 17a1c2bc5346d0108b55868b76e57fdac4e93d3e..a2d7577a7420c6c5ad16530461188c9199891ade 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -447,6 +447,7 @@ static int main0(int argc, char **argv) { bool ensure_libc_on_non_freestanding = false; bool ensure_libcpp_on_non_freestanding = false; bool disable_c_depfile = false; + bool want_native_include_dirs = false; Buf *linker_optimization = nullptr; OptionalBool linker_gc_sections = OptionalBoolNull; OptionalBool linker_allow_shlib_undefined = OptionalBoolNull; @@ -581,6 +582,7 @@ static int main0(int argc, char **argv) { strip = true; ensure_libc_on_non_freestanding = true; ensure_libcpp_on_non_freestanding = (strcmp(argv[1], "c++") == 0); + want_native_include_dirs = true; bool c_arg = false; Stage2ClangArgIterator it; @@ -747,6 +749,9 @@ static int main0(int argc, char **argv) { case Stage2ClangArgFramework: frameworks.append(it.only_arg); break; + case Stage2ClangArgNoStdLibInc: + want_native_include_dirs = false; + break; } } // Parse linker args @@ -1418,7 +1423,7 @@ static int main0(int argc, char **argv) { } } - if (target.is_native_os && any_system_lib_dependencies) { + if (target.is_native_os && (any_system_lib_dependencies || want_native_include_dirs)) { Error err; Stage2NativePaths paths; if ((err = stage2_detect_native_paths(&paths))) { diff --git a/src/stage2.h b/src/stage2.h index 02b33419f6ddeaa42c3320db739596669c411bd4..e397291f52b8d056f0b6ff6c0bf277a161df6001 100644 --- a/src/stage2.h +++ b/src/stage2.h @@ -352,6 +352,7 @@ enum Stage2ClangArg { Stage2ClangArgDepFile, Stage2ClangArgFrameworkDir, Stage2ClangArgFramework, + Stage2ClangArgNoStdLibInc, }; // ABI warning diff --git a/tools/update_clang_options.zig b/tools/update_clang_options.zig index fd6edbdf2c5316193a5d18d57a168832ee023b61..f1029cb0678606bc58b823a377bcd9c17e4abc4d 100644 --- a/tools/update_clang_options.zig +++ b/tools/update_clang_options.zig @@ -54,6 +54,10 @@ const known_options = [_]KnownOpt{ .name = "fno-PIC", .ident = "no_pic", }, + .{ + .name = "nolibc", + .ident = "nostdlib", + }, .{ .name = "nostdlib", .ident = "nostdlib", @@ -66,6 +70,22 @@ const known_options = [_]KnownOpt{ .name = "nostdlib++", .ident = "nostdlib_cpp", }, + .{ + .name = "nostdinc++", + .ident = "nostdlib_cpp", + }, + .{ + .name = "nostdlibinc", + .ident = "nostdlibinc", + }, + .{ + .name = "nostdinc", + .ident = "nostdlibinc", + }, + .{ + .name = "no-standard-includes", + .ident = "nostdlibinc", + }, .{ .name = "shared", .ident = "shared", -- 2.54.0 From e5d479b06e74e04b3ef3108e6098424b2130cbe5 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 4 Apr 2020 12:26:57 -0400 Subject: [PATCH 32/91] detect an endless loop when trying to detect native libc installation closes #4810 --- src-self-hosted/libc_installation.zig | 19 +++++++++++++++++++ src-self-hosted/stage2.zig | 2 ++ src/error.cpp | 1 + src/stage2.h | 1 + 4 files changed, 23 insertions(+) diff --git a/src-self-hosted/libc_installation.zig b/src-self-hosted/libc_installation.zig index f3441cec0dec604a66c3cf36da5bda1a90a4df81..db9db64a67d080b346c1342077835e174f554729 100644 --- a/src-self-hosted/libc_installation.zig +++ b/src-self-hosted/libc_installation.zig @@ -32,6 +32,7 @@ pub const LibCInstallation = struct { LibCKernel32LibNotFound, UnsupportedArchitecture, WindowsSdkNotFound, + ZigIsTheCCompiler, }; pub fn parse( @@ -229,10 +230,19 @@ pub const LibCInstallation = struct { "-xc", dev_null, }; + var env_map = try std.process.getEnvMap(allocator); + defer env_map.deinit(); + + // Detect infinite loops. + const inf_loop_env_key = "ZIG_IS_DETECTING_LIBC_PATHS"; + if (env_map.get(inf_loop_env_key) != null) return error.ZigIsTheCCompiler; + try env_map.set(inf_loop_env_key, "1"); + const exec_res = std.ChildProcess.exec(.{ .allocator = allocator, .argv = &argv, .max_output_bytes = 1024 * 1024, + .env_map = &env_map, // Some C compilers, such as Clang, are known to rely on argv[0] to find the path // to their own executable, without even bothering to resolve PATH. This results in the message: // error: unable to execute command: Executable "" doesn't exist! @@ -518,10 +528,19 @@ fn ccPrintFileName(args: CCPrintFileNameOptions) ![:0]u8 { defer allocator.free(arg1); const argv = [_][]const u8{ cc_exe, arg1 }; + var env_map = try std.process.getEnvMap(allocator); + defer env_map.deinit(); + + // Detect infinite loops. + const inf_loop_env_key = "ZIG_IS_DETECTING_LIBC_PATHS"; + if (env_map.get(inf_loop_env_key) != null) return error.ZigIsTheCCompiler; + try env_map.set(inf_loop_env_key, "1"); + const exec_res = std.ChildProcess.exec(.{ .allocator = allocator, .argv = &argv, .max_output_bytes = 1024 * 1024, + .env_map = &env_map, // Some C compilers, such as Clang, are known to rely on argv[0] to find the path // to their own executable, without even bothering to resolve PATH. This results in the message: // error: unable to execute command: Executable "" doesn't exist! diff --git a/src-self-hosted/stage2.zig b/src-self-hosted/stage2.zig index bfc49a876bdfec6ebae61e4f01f3408fbc4043a9..3f96ff2110b7480ffb4395dd1dfa8727c06b0001 100644 --- a/src-self-hosted/stage2.zig +++ b/src-self-hosted/stage2.zig @@ -115,6 +115,7 @@ const Error = extern enum { InvalidOperatingSystemVersion, UnknownClangOption, NestedResponseFile, + ZigIsTheCCompiler, }; const FILE = std.c.FILE; @@ -868,6 +869,7 @@ export fn stage2_libc_find_native(stage1_libc: *Stage2LibCInstallation) Error { error.LibCKernel32LibNotFound => return .LibCKernel32LibNotFound, error.UnsupportedArchitecture => return .UnsupportedArchitecture, error.WindowsSdkNotFound => return .WindowsSdkNotFound, + error.ZigIsTheCCompiler => return .ZigIsTheCCompiler, }; stage1_libc.initFromStage2(libc); return .None; diff --git a/src/error.cpp b/src/error.cpp index 76b510ecf3527de0f63858d026968ac93bef0fa7..0ca7d25b79205016a2df7e0030bcd37b412bd890 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -85,6 +85,7 @@ const char *err_str(Error err) { case ErrorInvalidOperatingSystemVersion: return "invalid operating system version"; case ErrorUnknownClangOption: return "unknown Clang option"; case ErrorNestedResponseFile: return "nested response file"; + case ErrorZigIsTheCCompiler: return "Zig was not provided with libc installation information, and so it does not know where the libc paths are on the system. Zig attempted to use the system C compiler to find out where the libc paths are, but discovered that Zig is being used as the system C compiler."; } return "(invalid error)"; } diff --git a/src/stage2.h b/src/stage2.h index e397291f52b8d056f0b6ff6c0bf277a161df6001..7dd2de988e9fc131d3e7f4b00509a01f221a68bd 100644 --- a/src/stage2.h +++ b/src/stage2.h @@ -107,6 +107,7 @@ enum Error { ErrorInvalidOperatingSystemVersion, ErrorUnknownClangOption, ErrorNestedResponseFile, + ErrorZigIsTheCCompiler, }; // ABI warning -- 2.54.0 From cd20e0cc672249555709e1b58a415ddd50b03ad9 Mon Sep 17 00:00:00 2001 From: xackus <14938807+xackus@users.noreply.github.com> Date: Sat, 4 Apr 2020 19:15:08 +0200 Subject: [PATCH 33/91] rename mem.separate to mem.split --- build.zig | 2 +- lib/std/builtin.zig | 2 +- lib/std/mem.zig | 24 ++++++++++++------------ lib/std/net.zig | 6 +++--- lib/std/process.zig | 2 +- lib/std/zig/cross_target.zig | 10 +++++----- src-self-hosted/libc_installation.zig | 2 +- src-self-hosted/main.zig | 2 +- test/tests.zig | 4 ++-- 9 files changed, 27 insertions(+), 27 deletions(-) diff --git a/build.zig b/build.zig index 65175256a86517c7425c8dc756d26508b3365d66..3abe5ff92b7399787bee14ac661b248dd9f14f92 100644 --- a/build.zig +++ b/build.zig @@ -412,7 +412,7 @@ fn findAndParseConfigH(b: *Builder) !Context { while (lines_it.next()) |line| { inline for (mappings) |mapping| { if (mem.startsWith(u8, line, mapping.prefix)) { - var it = mem.separate(line, "\""); + var it = mem.split(line, "\""); _ = it.next().?; // skip the stuff before the quote @field(ctx, mapping.field) = it.next().?; // the stuff inside the quote } diff --git a/lib/std/builtin.zig b/lib/std/builtin.zig index 3dbd82b2b582449a78b702976a073e82cce37d55..af8033ae91852f5cea5a4e77afecfdd7e991f380 100644 --- a/lib/std/builtin.zig +++ b/lib/std/builtin.zig @@ -424,7 +424,7 @@ pub const Version = struct { } pub fn parse(text: []const u8) !Version { - var it = std.mem.separate(text, "."); + var it = std.mem.split(text, "."); return Version{ .major = try std.fmt.parseInt(u32, it.next() orelse return error.InvalidVersion, 10), .minor = try std.fmt.parseInt(u32, it.next() orelse "0", 10), diff --git a/lib/std/mem.zig b/lib/std/mem.zig index f54eb03d65b1a145021e710250f9253543e1eead..f3220ba9fe2349fdae4c4179d15546c88469652b 100644 --- a/lib/std/mem.zig +++ b/lib/std/mem.zig @@ -1141,7 +1141,7 @@ test "writeIntBig and writeIntLittle" { /// If `buffer` is empty, the iterator will return null. /// If `delimiter_bytes` does not exist in buffer, /// the iterator will return `buffer`, null, in that order. -/// See also the related function `separate`. +/// See also the related function `split`. pub fn tokenize(buffer: []const u8, delimiter_bytes: []const u8) TokenIterator { return TokenIterator{ .index = 0, @@ -1196,15 +1196,13 @@ test "mem.tokenize (multibyte)" { /// Returns an iterator that iterates over the slices of `buffer` that /// are separated by bytes in `delimiter`. -/// separate("abc|def||ghi", "|") +/// split("abc|def||ghi", "|") /// will return slices for "abc", "def", "", "ghi", null, in that order. /// If `delimiter` does not exist in buffer, /// the iterator will return `buffer`, null, in that order. /// The delimiter length must not be zero. /// See also the related function `tokenize`. -/// It is planned to rename this function to `split` before 1.0.0, like this: -/// pub fn split(buffer: []const u8, delimiter: []const u8) SplitIterator { -pub fn separate(buffer: []const u8, delimiter: []const u8) SplitIterator { +pub fn split(buffer: []const u8, delimiter: []const u8) SplitIterator { assert(delimiter.len != 0); return SplitIterator{ .index = 0, @@ -1213,30 +1211,32 @@ pub fn separate(buffer: []const u8, delimiter: []const u8) SplitIterator { }; } -test "mem.separate" { - var it = separate("abc|def||ghi", "|"); +pub const separate = @compileError("deprecated: renamed to split (behavior remains unchanged)"); + +test "mem.split" { + var it = split("abc|def||ghi", "|"); testing.expect(eql(u8, it.next().?, "abc")); testing.expect(eql(u8, it.next().?, "def")); testing.expect(eql(u8, it.next().?, "")); testing.expect(eql(u8, it.next().?, "ghi")); testing.expect(it.next() == null); - it = separate("", "|"); + it = split("", "|"); testing.expect(eql(u8, it.next().?, "")); testing.expect(it.next() == null); - it = separate("|", "|"); + it = split("|", "|"); testing.expect(eql(u8, it.next().?, "")); testing.expect(eql(u8, it.next().?, "")); testing.expect(it.next() == null); - it = separate("hello", " "); + it = split("hello", " "); testing.expect(eql(u8, it.next().?, "hello")); testing.expect(it.next() == null); } -test "mem.separate (multibyte)" { - var it = separate("a, b ,, c, d, e", ", "); +test "mem.split (multibyte)" { + var it = split("a, b ,, c, d, e", ", "); testing.expect(eql(u8, it.next().?, "a")); testing.expect(eql(u8, it.next().?, "b ,")); testing.expect(eql(u8, it.next().?, "c")); diff --git a/lib/std/net.zig b/lib/std/net.zig index f91b2b86aa3a60dda3206027f5a3bdbd4cb20afa..9e57aa500b3e6763582967f5e2948037bddde3bf 100644 --- a/lib/std/net.zig +++ b/lib/std/net.zig @@ -823,7 +823,7 @@ fn linuxLookupNameFromHosts( }, else => |e| return e, }) |line| { - const no_comment_line = mem.separate(line, "#").next().?; + const no_comment_line = mem.split(line, "#").next().?; var line_it = mem.tokenize(no_comment_line, " \t"); const ip_text = line_it.next() orelse continue; @@ -1020,13 +1020,13 @@ fn getResolvConf(allocator: *mem.Allocator, rc: *ResolvConf) !void { }, else => |e| return e, }) |line| { - const no_comment_line = mem.separate(line, "#").next().?; + const no_comment_line = mem.split(line, "#").next().?; var line_it = mem.tokenize(no_comment_line, " \t"); const token = line_it.next() orelse continue; if (mem.eql(u8, token, "options")) { while (line_it.next()) |sub_tok| { - var colon_it = mem.separate(sub_tok, ":"); + var colon_it = mem.split(sub_tok, ":"); const name = colon_it.next().?; const value_txt = colon_it.next() orelse continue; const value = std.fmt.parseInt(u8, value_txt, 10) catch |err| switch (err) { diff --git a/lib/std/process.zig b/lib/std/process.zig index 89e9cea8d65c6c2222a218cdedb7332eb5811d21..b4baf49cf2e4522b7eae69efe79c98a9453359c6 100644 --- a/lib/std/process.zig +++ b/lib/std/process.zig @@ -84,7 +84,7 @@ pub fn getEnvMap(allocator: *Allocator) !BufMap { for (environ) |env| { if (env) |ptr| { const pair = mem.spanZ(ptr); - var parts = mem.separate(pair, "="); + var parts = mem.split(pair, "="); const key = parts.next().?; const value = parts.next().?; try result.set(key, value); diff --git a/lib/std/zig/cross_target.zig b/lib/std/zig/cross_target.zig index 76aff2ae51133ea8ad3c6eca9cc27f579dbae85d..8783ddcb6db345e1158bdf45da5c39d1a53abd9e 100644 --- a/lib/std/zig/cross_target.zig +++ b/lib/std/zig/cross_target.zig @@ -224,7 +224,7 @@ pub const CrossTarget = struct { .dynamic_linker = DynamicLinker.init(args.dynamic_linker), }; - var it = mem.separate(args.arch_os_abi, "-"); + var it = mem.split(args.arch_os_abi, "-"); const arch_name = it.next().?; const arch_is_native = mem.eql(u8, arch_name, "native"); if (!arch_is_native) { @@ -242,7 +242,7 @@ pub const CrossTarget = struct { const opt_abi_text = it.next(); if (opt_abi_text) |abi_text| { - var abi_it = mem.separate(abi_text, "."); + var abi_it = mem.split(abi_text, "."); const abi = std.meta.stringToEnum(Target.Abi, abi_it.next().?) orelse return error.UnknownApplicationBinaryInterface; result.abi = abi; @@ -668,7 +668,7 @@ pub const CrossTarget = struct { } fn parseOs(result: *CrossTarget, diags: *ParseOptions.Diagnostics, text: []const u8) !void { - var it = mem.separate(text, "."); + var it = mem.split(text, "."); const os_name = it.next().?; diags.os_name = os_name; const os_is_native = mem.eql(u8, os_name, "native"); @@ -722,7 +722,7 @@ pub const CrossTarget = struct { .linux, .dragonfly, => { - var range_it = mem.separate(version_text, "..."); + var range_it = mem.split(version_text, "..."); const min_text = range_it.next().?; const min_ver = SemVer.parse(min_text) catch |err| switch (err) { @@ -742,7 +742,7 @@ pub const CrossTarget = struct { }, .windows => { - var range_it = mem.separate(version_text, "..."); + var range_it = mem.split(version_text, "..."); const min_text = range_it.next().?; const min_ver = std.meta.stringToEnum(Target.Os.WindowsVersion, min_text) orelse diff --git a/src-self-hosted/libc_installation.zig b/src-self-hosted/libc_installation.zig index db9db64a67d080b346c1342077835e174f554729..943405310cce3d7312f40f46e4661d3687bf6476 100644 --- a/src-self-hosted/libc_installation.zig +++ b/src-self-hosted/libc_installation.zig @@ -61,7 +61,7 @@ pub const LibCInstallation = struct { var it = std.mem.tokenize(contents, "\n"); while (it.next()) |line| { if (line.len == 0 or line[0] == '#') continue; - var line_it = std.mem.separate(line, "="); + var line_it = std.mem.split(line, "="); const name = line_it.next() orelse { try stderr.print("missing equal sign after field name\n", .{}); return error.ParseError; diff --git a/src-self-hosted/main.zig b/src-self-hosted/main.zig index fb96e0260a0235a4d3fdc973acfd32ae98f96c45..b7535fca6f922acfeb6b842e494d9ebe4f379128 100644 --- a/src-self-hosted/main.zig +++ b/src-self-hosted/main.zig @@ -403,7 +403,7 @@ fn buildOutputType(allocator: *Allocator, args: []const []const u8, out_type: Co const root_name = if (provided_name) |n| n else blk: { if (root_src_file) |file| { const basename = fs.path.basename(file); - var it = mem.separate(basename, "."); + var it = mem.split(basename, "."); break :blk it.next() orelse basename; } else { try stderr.writeAll("--name [name] not provided and unable to infer\n"); diff --git a/test/tests.zig b/test/tests.zig index e66ae7296a4bff31976d0dcbb9c05a03a68151bf..d88c84502dc39753471108b9bd8a5f51d1e72e8a 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -657,7 +657,7 @@ pub const StackTracesContext = struct { var buf = ArrayList(u8).init(b.allocator); defer buf.deinit(); if (stderr.len != 0 and stderr[stderr.len - 1] == '\n') stderr = stderr[0 .. stderr.len - 1]; - var it = mem.separate(stderr, "\n"); + var it = mem.split(stderr, "\n"); process_lines: while (it.next()) |line| { if (line.len == 0) continue; const delims = [_][]const u8{ ":", ":", ":", " in " }; @@ -750,7 +750,7 @@ pub const CompileErrorContext = struct { const source_file = "tmp.zig"; fn init(input: []const u8) ErrLineIter { - return ErrLineIter{ .lines = mem.separate(input, "\n") }; + return ErrLineIter{ .lines = mem.split(input, "\n") }; } fn next(self: *ErrLineIter) ?[]const u8 { -- 2.54.0 From f9474443620c9c654c0a888a928557f8ec2815c8 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Sun, 5 Apr 2020 13:55:56 +1000 Subject: [PATCH 34/91] Tidy up compiler_rt/atomics --- lib/std/special/compiler_rt/atomics.zig | 100 ++++++++++++------------ 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/lib/std/special/compiler_rt/atomics.zig b/lib/std/special/compiler_rt/atomics.zig index ea990cb193dd08b7b791ff9aa440341dc72e10be..8b0fe4795288ef344c05fb65fd5cb380eb97fd20 100644 --- a/lib/std/special/compiler_rt/atomics.zig +++ b/lib/std/special/compiler_rt/atomics.zig @@ -106,7 +106,7 @@ const largest_atomic_size = switch (builtin.arch) { else => @sizeOf(usize), }; -fn makeAtomicLoadFn(comptime T: type) type { +fn atomicLoadFn(comptime T: type) fn (*T, i32) callconv(.C) T { return struct { fn atomic_load_N(src: *T, model: i32) callconv(.C) T { if (@sizeOf(T) > largest_atomic_size) { @@ -117,17 +117,17 @@ fn makeAtomicLoadFn(comptime T: type) type { return @atomicLoad(T, src, .SeqCst); } } - }; + }.atomic_load_N; } comptime { - @export(makeAtomicLoadFn(u8).atomic_load_N, .{ .name = "__atomic_load_1", .linkage = linkage }); - @export(makeAtomicLoadFn(u16).atomic_load_N, .{ .name = "__atomic_load_2", .linkage = linkage }); - @export(makeAtomicLoadFn(u32).atomic_load_N, .{ .name = "__atomic_load_4", .linkage = linkage }); - @export(makeAtomicLoadFn(u64).atomic_load_N, .{ .name = "__atomic_load_8", .linkage = linkage }); + @export(atomicLoadFn(u8), .{ .name = "__atomic_load_1", .linkage = linkage }); + @export(atomicLoadFn(u16), .{ .name = "__atomic_load_2", .linkage = linkage }); + @export(atomicLoadFn(u32), .{ .name = "__atomic_load_4", .linkage = linkage }); + @export(atomicLoadFn(u64), .{ .name = "__atomic_load_8", .linkage = linkage }); } -fn makeAtomicStoreFn(comptime T: type) type { +fn atomicStoreFn(comptime T: type) fn (*T, T, i32) callconv(.C) void { return struct { fn atomic_store_N(dst: *T, value: T, model: i32) callconv(.C) void { if (@sizeOf(T) > largest_atomic_size) { @@ -138,17 +138,17 @@ fn makeAtomicStoreFn(comptime T: type) type { @atomicStore(T, dst, value, .SeqCst); } } - }; + }.atomic_store_N; } comptime { - @export(makeAtomicStoreFn(u8).atomic_store_N, .{ .name = "__atomic_store_1", .linkage = linkage }); - @export(makeAtomicStoreFn(u16).atomic_store_N, .{ .name = "__atomic_store_2", .linkage = linkage }); - @export(makeAtomicStoreFn(u32).atomic_store_N, .{ .name = "__atomic_store_4", .linkage = linkage }); - @export(makeAtomicStoreFn(u64).atomic_store_N, .{ .name = "__atomic_store_8", .linkage = linkage }); + @export(atomicStoreFn(u8), .{ .name = "__atomic_store_1", .linkage = linkage }); + @export(atomicStoreFn(u16), .{ .name = "__atomic_store_2", .linkage = linkage }); + @export(atomicStoreFn(u32), .{ .name = "__atomic_store_4", .linkage = linkage }); + @export(atomicStoreFn(u64), .{ .name = "__atomic_store_8", .linkage = linkage }); } -fn makeAtomicExchangeFn(comptime T: type) type { +fn atomicExchangeFn(comptime T: type) fn (*T, T, i32) callconv(.C) T { return struct { fn atomic_exchange_N(ptr: *T, val: T, model: i32) callconv(.C) T { if (@sizeOf(T) > largest_atomic_size) { @@ -161,17 +161,17 @@ fn makeAtomicExchangeFn(comptime T: type) type { return @atomicRmw(T, ptr, .Xchg, val, .SeqCst); } } - }; + }.atomic_exchange_N; } comptime { - @export(makeAtomicExchangeFn(u8).atomic_exchange_N, .{ .name = "__atomic_exchange_1", .linkage = linkage }); - @export(makeAtomicExchangeFn(u16).atomic_exchange_N, .{ .name = "__atomic_exchange_2", .linkage = linkage }); - @export(makeAtomicExchangeFn(u32).atomic_exchange_N, .{ .name = "__atomic_exchange_4", .linkage = linkage }); - @export(makeAtomicExchangeFn(u64).atomic_exchange_N, .{ .name = "__atomic_exchange_8", .linkage = linkage }); + @export(atomicExchangeFn(u8), .{ .name = "__atomic_exchange_1", .linkage = linkage }); + @export(atomicExchangeFn(u16), .{ .name = "__atomic_exchange_2", .linkage = linkage }); + @export(atomicExchangeFn(u32), .{ .name = "__atomic_exchange_4", .linkage = linkage }); + @export(atomicExchangeFn(u64), .{ .name = "__atomic_exchange_8", .linkage = linkage }); } -fn makeAtomicCompareExchangeFn(comptime T: type) type { +fn atomicCompareExchangeFn(comptime T: type) fn (*T, *T, T, i32, i32) callconv(.C) i32 { return struct { fn atomic_compare_exchange_N(ptr: *T, expected: *T, desired: T, success: i32, failure: i32) callconv(.C) i32 { if (@sizeOf(T) > largest_atomic_size) { @@ -191,17 +191,17 @@ fn makeAtomicCompareExchangeFn(comptime T: type) type { return 1; } } - }; + }.atomic_compare_exchange_N; } comptime { - @export(makeAtomicCompareExchangeFn(u8).atomic_compare_exchange_N, .{ .name = "__atomic_compare_exchange_1", .linkage = linkage }); - @export(makeAtomicCompareExchangeFn(u16).atomic_compare_exchange_N, .{ .name = "__atomic_compare_exchange_2", .linkage = linkage }); - @export(makeAtomicCompareExchangeFn(u32).atomic_compare_exchange_N, .{ .name = "__atomic_compare_exchange_4", .linkage = linkage }); - @export(makeAtomicCompareExchangeFn(u64).atomic_compare_exchange_N, .{ .name = "__atomic_compare_exchange_8", .linkage = linkage }); + @export(atomicCompareExchangeFn(u8), .{ .name = "__atomic_compare_exchange_1", .linkage = linkage }); + @export(atomicCompareExchangeFn(u16), .{ .name = "__atomic_compare_exchange_2", .linkage = linkage }); + @export(atomicCompareExchangeFn(u32), .{ .name = "__atomic_compare_exchange_4", .linkage = linkage }); + @export(atomicCompareExchangeFn(u64), .{ .name = "__atomic_compare_exchange_8", .linkage = linkage }); } -fn makeFetchFn(comptime T: type, comptime op: builtin.AtomicRmwOp) type { +fn fetchFn(comptime T: type, comptime op: builtin.AtomicRmwOp) fn (*T, T, i32) callconv(.C) T { return struct { pub fn fetch_op_N(ptr: *T, val: T, model: i32) callconv(.C) T { if (@sizeOf(T) > largest_atomic_size) { @@ -224,37 +224,37 @@ fn makeFetchFn(comptime T: type, comptime op: builtin.AtomicRmwOp) type { return @atomicRmw(T, ptr, op, val, .SeqCst); } - }; + }.fetch_op_N; } comptime { - @export(makeFetchFn(u8, .Add).fetch_op_N, .{ .name = "__atomic_fetch_add_1", .linkage = linkage }); - @export(makeFetchFn(u16, .Add).fetch_op_N, .{ .name = "__atomic_fetch_add_2", .linkage = linkage }); - @export(makeFetchFn(u32, .Add).fetch_op_N, .{ .name = "__atomic_fetch_add_4", .linkage = linkage }); - @export(makeFetchFn(u64, .Add).fetch_op_N, .{ .name = "__atomic_fetch_add_8", .linkage = linkage }); + @export(fetchFn(u8, .Add), .{ .name = "__atomic_fetch_add_1", .linkage = linkage }); + @export(fetchFn(u16, .Add), .{ .name = "__atomic_fetch_add_2", .linkage = linkage }); + @export(fetchFn(u32, .Add), .{ .name = "__atomic_fetch_add_4", .linkage = linkage }); + @export(fetchFn(u64, .Add), .{ .name = "__atomic_fetch_add_8", .linkage = linkage }); - @export(makeFetchFn(u8, .Sub).fetch_op_N, .{ .name = "__atomic_fetch_sub_1", .linkage = linkage }); - @export(makeFetchFn(u16, .Sub).fetch_op_N, .{ .name = "__atomic_fetch_sub_2", .linkage = linkage }); - @export(makeFetchFn(u32, .Sub).fetch_op_N, .{ .name = "__atomic_fetch_sub_4", .linkage = linkage }); - @export(makeFetchFn(u64, .Sub).fetch_op_N, .{ .name = "__atomic_fetch_sub_8", .linkage = linkage }); + @export(fetchFn(u8, .Sub), .{ .name = "__atomic_fetch_sub_1", .linkage = linkage }); + @export(fetchFn(u16, .Sub), .{ .name = "__atomic_fetch_sub_2", .linkage = linkage }); + @export(fetchFn(u32, .Sub), .{ .name = "__atomic_fetch_sub_4", .linkage = linkage }); + @export(fetchFn(u64, .Sub), .{ .name = "__atomic_fetch_sub_8", .linkage = linkage }); - @export(makeFetchFn(u8, .And).fetch_op_N, .{ .name = "__atomic_fetch_and_1", .linkage = linkage }); - @export(makeFetchFn(u16, .And).fetch_op_N, .{ .name = "__atomic_fetch_and_2", .linkage = linkage }); - @export(makeFetchFn(u32, .And).fetch_op_N, .{ .name = "__atomic_fetch_and_4", .linkage = linkage }); - @export(makeFetchFn(u64, .And).fetch_op_N, .{ .name = "__atomic_fetch_and_8", .linkage = linkage }); + @export(fetchFn(u8, .And), .{ .name = "__atomic_fetch_and_1", .linkage = linkage }); + @export(fetchFn(u16, .And), .{ .name = "__atomic_fetch_and_2", .linkage = linkage }); + @export(fetchFn(u32, .And), .{ .name = "__atomic_fetch_and_4", .linkage = linkage }); + @export(fetchFn(u64, .And), .{ .name = "__atomic_fetch_and_8", .linkage = linkage }); - @export(makeFetchFn(u8, .Or).fetch_op_N, .{ .name = "__atomic_fetch_or_1", .linkage = linkage }); - @export(makeFetchFn(u16, .Or).fetch_op_N, .{ .name = "__atomic_fetch_or_2", .linkage = linkage }); - @export(makeFetchFn(u32, .Or).fetch_op_N, .{ .name = "__atomic_fetch_or_4", .linkage = linkage }); - @export(makeFetchFn(u64, .Or).fetch_op_N, .{ .name = "__atomic_fetch_or_8", .linkage = linkage }); + @export(fetchFn(u8, .Or), .{ .name = "__atomic_fetch_or_1", .linkage = linkage }); + @export(fetchFn(u16, .Or), .{ .name = "__atomic_fetch_or_2", .linkage = linkage }); + @export(fetchFn(u32, .Or), .{ .name = "__atomic_fetch_or_4", .linkage = linkage }); + @export(fetchFn(u64, .Or), .{ .name = "__atomic_fetch_or_8", .linkage = linkage }); - @export(makeFetchFn(u8, .Xor).fetch_op_N, .{ .name = "__atomic_fetch_xor_1", .linkage = linkage }); - @export(makeFetchFn(u16, .Xor).fetch_op_N, .{ .name = "__atomic_fetch_xor_2", .linkage = linkage }); - @export(makeFetchFn(u32, .Xor).fetch_op_N, .{ .name = "__atomic_fetch_xor_4", .linkage = linkage }); - @export(makeFetchFn(u64, .Xor).fetch_op_N, .{ .name = "__atomic_fetch_xor_8", .linkage = linkage }); + @export(fetchFn(u8, .Xor), .{ .name = "__atomic_fetch_xor_1", .linkage = linkage }); + @export(fetchFn(u16, .Xor), .{ .name = "__atomic_fetch_xor_2", .linkage = linkage }); + @export(fetchFn(u32, .Xor), .{ .name = "__atomic_fetch_xor_4", .linkage = linkage }); + @export(fetchFn(u64, .Xor), .{ .name = "__atomic_fetch_xor_8", .linkage = linkage }); - @export(makeFetchFn(u8, .Nand).fetch_op_N, .{ .name = "__atomic_fetch_nand_1", .linkage = linkage }); - @export(makeFetchFn(u16, .Nand).fetch_op_N, .{ .name = "__atomic_fetch_nand_2", .linkage = linkage }); - @export(makeFetchFn(u32, .Nand).fetch_op_N, .{ .name = "__atomic_fetch_nand_4", .linkage = linkage }); - @export(makeFetchFn(u64, .Nand).fetch_op_N, .{ .name = "__atomic_fetch_nand_8", .linkage = linkage }); + @export(fetchFn(u8, .Nand), .{ .name = "__atomic_fetch_nand_1", .linkage = linkage }); + @export(fetchFn(u16, .Nand), .{ .name = "__atomic_fetch_nand_2", .linkage = linkage }); + @export(fetchFn(u32, .Nand), .{ .name = "__atomic_fetch_nand_4", .linkage = linkage }); + @export(fetchFn(u64, .Nand), .{ .name = "__atomic_fetch_nand_8", .linkage = linkage }); } -- 2.54.0 From e9e43ed0d39f623d424f87fbd035f949cf5a3227 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Sun, 5 Apr 2020 14:08:25 +1000 Subject: [PATCH 35/91] compiler_rt/atomics: be consistent with `const value` --- lib/std/special/compiler_rt/atomics.zig | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/std/special/compiler_rt/atomics.zig b/lib/std/special/compiler_rt/atomics.zig index 8b0fe4795288ef344c05fb65fd5cb380eb97fd20..5cc7c42293e4ead5100627504b20a6720e6443d3 100644 --- a/lib/std/special/compiler_rt/atomics.zig +++ b/lib/std/special/compiler_rt/atomics.zig @@ -154,7 +154,7 @@ fn atomicExchangeFn(comptime T: type) fn (*T, T, i32) callconv(.C) T { if (@sizeOf(T) > largest_atomic_size) { var sl = spinlocks.get(@ptrToInt(ptr)); defer sl.release(); - var value = ptr.*; + const value = ptr.*; ptr.* = val; return value; } else { @@ -177,11 +177,12 @@ fn atomicCompareExchangeFn(comptime T: type) fn (*T, *T, T, i32, i32) callconv(. if (@sizeOf(T) > largest_atomic_size) { var sl = spinlocks.get(@ptrToInt(ptr)); defer sl.release(); - if (ptr.* == expected.*) { + const value = ptr.*; + if (value == expected.*) { ptr.* = desired; return 1; } - expected.* = ptr.*; + expected.* = value; return 0; } else { if (@cmpxchgStrong(T, ptr, expected.*, desired, .SeqCst, .SeqCst)) |old_value| { @@ -208,14 +209,14 @@ fn fetchFn(comptime T: type, comptime op: builtin.AtomicRmwOp) fn (*T, T, i32) c var sl = spinlocks.get(@ptrToInt(ptr)); defer sl.release(); - var value = ptr.*; + const value = ptr.*; ptr.* = switch (op) { - .Add => ptr.* +% val, - .Sub => ptr.* -% val, - .And => ptr.* & val, - .Nand => ~(ptr.* & val), - .Or => ptr.* | val, - .Xor => ptr.* ^ val, + .Add => value +% val, + .Sub => value -% val, + .And => value & val, + .Nand => ~(value & val), + .Or => value | val, + .Xor => value ^ val, else => @compileError("unsupported atomic op"), }; -- 2.54.0 From ae376e0758bc9d756b3fb778537ad3ea1813ae00 Mon Sep 17 00:00:00 2001 From: Jadon Fowler Date: Sun, 5 Apr 2020 10:44:42 -0400 Subject: [PATCH 36/91] translate-c: remove unneeded semicolon Signed-off-by: Jadon Fowler --- src-self-hosted/translate_c.zig | 2 -- 1 file changed, 2 deletions(-) diff --git a/src-self-hosted/translate_c.zig b/src-self-hosted/translate_c.zig index 66dd8d581e98adc387377275868fd620bd841178..54ce117957d6f66e039640d2f9ac1504b0cc30ac 100644 --- a/src-self-hosted/translate_c.zig +++ b/src-self-hosted/translate_c.zig @@ -3166,8 +3166,6 @@ fn transCreateCompoundAssign( break_node.rhs = ref_node; try block_scope.block_node.statements.push(&break_node.base); block_scope.block_node.rbrace = try appendToken(rp.c, .RBrace, "}"); - // semicolon must immediately follow rbrace because it is the last token in a block - _ = try appendToken(rp.c, .Semicolon, ";4"); const grouped_expr = try rp.c.a().create(ast.Node.GroupedExpression); grouped_expr.* = .{ .lparen = try appendToken(rp.c, .LParen, "("), -- 2.54.0 From c4a5f519f22511ce90bfe0aca0690b24cc592f88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Larouche?= Date: Sat, 4 Apr 2020 18:41:16 -0400 Subject: [PATCH 37/91] Do not parse native_libc.txt anymore when linking on native target, always run detection of libc. Fixes #4772 --- src/codegen.cpp | 81 +++---------------------------------------------- 1 file changed, 5 insertions(+), 76 deletions(-) diff --git a/src/codegen.cpp b/src/codegen.cpp index ed8fcf54d7cebe6c07c84daf96fda3338ae959a7..84168f509fc9c8f6a522678f13b70afdddd8c3d9 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -9057,80 +9057,13 @@ static void detect_libc(CodeGen *g) { if (g->zig_target->is_native_os) { g->libc = heap::c_allocator.create(); - // search for native_libc.txt in following dirs: - // - LOCAL_CACHE_DIR - // - GLOBAL_CACHE_DIR - // if not found create at: - // - GLOBAL_CACHE_DIR - // be mindful local/global caches may be the same dir - - Buf basename = BUF_INIT; - buf_init_from_str(&basename, "native_libc.txt"); - - Buf local_libc_txt = BUF_INIT; - os_path_join(g->cache_dir, &basename, &local_libc_txt); - - Buf global_libc_txt = BUF_INIT; - os_path_join(get_global_cache_dir(), &basename, &global_libc_txt); - - Buf *pathnames[3] = { nullptr }; - size_t pathnames_idx = 0; - - pathnames[pathnames_idx] = &local_libc_txt; - pathnames_idx += 1; - - if (!buf_eql_buf(pathnames[0], &global_libc_txt)) { - pathnames[pathnames_idx] = &global_libc_txt; - pathnames_idx += 1; + if ((err = stage2_libc_find_native(g->libc))) { + fprintf(stderr, + "Unable to link against libc: Unable to find libc installation: %s\n" + "See `zig libc --help` for more details.\n", err_str(err)); + exit(1); } - Buf* libc_txt = nullptr; - for (auto name : pathnames) { - if (name == nullptr) - break; - - bool result; - if (os_file_exists(name, &result) != ErrorNone || !result) - continue; - - libc_txt = name; - break; - } - - if (libc_txt == nullptr) - libc_txt = &global_libc_txt; - - if ((err = stage2_libc_parse(g->libc, buf_ptr(libc_txt)))) { - if ((err = stage2_libc_find_native(g->libc))) { - fprintf(stderr, - "Unable to link against libc: Unable to find libc installation: %s\n" - "See `zig libc --help` for more details.\n", err_str(err)); - exit(1); - } - Buf libc_txt_dir = BUF_INIT; - os_path_dirname(libc_txt, &libc_txt_dir); - buf_deinit(&libc_txt_dir); - if ((err = os_make_path(&libc_txt_dir))) { - fprintf(stderr, "Unable to create %s directory: %s\n", - buf_ptr(g->cache_dir), err_str(err)); - exit(1); - } - Buf *native_libc_tmp = buf_sprintf("%s.tmp", buf_ptr(libc_txt)); - FILE *file = fopen(buf_ptr(native_libc_tmp), "wb"); - if (file == nullptr) { - fprintf(stderr, "Unable to open %s: %s\n", buf_ptr(native_libc_tmp), strerror(errno)); - exit(1); - } - stage2_libc_render(g->libc, file); - if (fclose(file) != 0) { - fprintf(stderr, "Unable to save %s: %s\n", buf_ptr(native_libc_tmp), strerror(errno)); - exit(1); - } - if ((err = os_rename(native_libc_tmp, libc_txt))) { - fprintf(stderr, "Unable to create %s: %s\n", buf_ptr(libc_txt), err_str(err)); - exit(1); - } - } bool want_sys_dir = !mem_eql_mem(g->libc->include_dir, g->libc->include_dir_len, g->libc->sys_include_dir, g->libc->sys_include_dir_len); size_t want_um_and_shared_dirs = (g->zig_target->os == OsWindows) ? 2 : 0; @@ -9164,10 +9097,6 @@ static void detect_libc(CodeGen *g) { g->libc_include_dir_len += 1; } assert(g->libc_include_dir_len == dir_count); - - buf_deinit(&global_libc_txt); - buf_deinit(&local_libc_txt); - buf_deinit(&basename); } else if ((g->out_type == OutTypeExe || (g->out_type == OutTypeLib && g->is_dynamic)) && !target_os_is_darwin(g->zig_target->os)) { -- 2.54.0 From d4d21801481bc964eea40f67d59f3384af33c2cc Mon Sep 17 00:00:00 2001 From: daurnimator Date: Sun, 5 Apr 2020 18:50:26 +1000 Subject: [PATCH 38/91] Convert .gitattributes to use unix line endings --- .gitattributes | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.gitattributes b/.gitattributes index a2ec267781ae2fab049e7ca9306a864a78cdaf09..340a216f0197cacf18378c838cc930910003f9d0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,10 +1,10 @@ -*.zig text eol=lf -*.txt text eol=lf -langref.html.in text eol=lf - -deps/* linguist-vendored -lib/include/* linguist-vendored -lib/libc/* linguist-vendored -lib/libcxx/* linguist-vendored -lib/libcxxabi/* linguist-vendored -lib/libunwind/* linguist-vendored +*.zig text eol=lf +*.txt text eol=lf +langref.html.in text eol=lf + +deps/* linguist-vendored +lib/include/* linguist-vendored +lib/libc/* linguist-vendored +lib/libcxx/* linguist-vendored +lib/libcxxabi/* linguist-vendored +lib/libunwind/* linguist-vendored -- 2.54.0 From 4daec63aead9da8ee9934975623db990e05303ed Mon Sep 17 00:00:00 2001 From: daurnimator Date: Sun, 5 Apr 2020 18:50:58 +1000 Subject: [PATCH 39/91] .gitattributes: deps/SoftFloat-3e/*.txt lines are crlf terminated --- .gitattributes | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitattributes b/.gitattributes index 340a216f0197cacf18378c838cc930910003f9d0..8bf58434257e0994acb022401419ff1c000f16c2 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,6 +1,7 @@ *.zig text eol=lf *.txt text eol=lf langref.html.in text eol=lf +deps/SoftFloat-3e/*.txt text eol=crlf deps/* linguist-vendored lib/include/* linguist-vendored -- 2.54.0 From e2dc63644ab3d8e5cdaec2d58dc57c587295081f Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 5 Apr 2020 17:09:01 -0400 Subject: [PATCH 40/91] type_has_one_possible_value takes comptime struct fields into account Before, type_has_one_possible_value would return false for the value `.{1}`. But actually, that type is a tuple with a single comptime field. Such a type, in fact, has one possible value. This plus the corresponding adjustment to get_the_one_possible_value solves #3878. --- src/analyze.cpp | 8 ++++++++ test/stage1/behavior/tuple.zig | 16 +++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/analyze.cpp b/src/analyze.cpp index e627eaf91b274df7aeef77a5a55ca9ca2d515312..14b9c25c07ef3ecae3fc74c38ece863ae9d77343 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -5769,6 +5769,10 @@ OnePossibleValue type_has_one_possible_value(CodeGen *g, ZigType *type_entry) { type_entry->one_possible_value = OnePossibleValueNo; for (size_t i = 0; i < type_entry->data.structure.src_field_count; i += 1) { TypeStructField *field = type_entry->data.structure.fields[i]; + if (field->is_comptime) { + // If this field is comptime then the field can only be one possible value + continue; + } OnePossibleValue opv = (field->type_entry != nullptr) ? type_has_one_possible_value(g, field->type_entry) : type_val_resolve_has_one_possible_value(g, field->type_val); @@ -5825,6 +5829,10 @@ ZigValue *get_the_one_possible_value(CodeGen *g, ZigType *type_entry) { result->data.x_struct.fields = alloc_const_vals_ptrs(g, field_count); for (size_t i = 0; i < field_count; i += 1) { TypeStructField *field = struct_type->data.structure.fields[i]; + if (field->is_comptime) { + copy_const_val(g, result->data.x_struct.fields[i], field->init_val); + continue; + } ZigType *field_type = resolve_struct_field_type(g, field); assert(field_type != nullptr); result->data.x_struct.fields[i] = get_the_one_possible_value(g, field_type); diff --git a/test/stage1/behavior/tuple.zig b/test/stage1/behavior/tuple.zig index 686a9ad83ecb6d97bcc90118e32cf1c5decd3773..3c467baaa43e39f66cad7b9f368864fd26898e08 100644 --- a/test/stage1/behavior/tuple.zig +++ b/test/stage1/behavior/tuple.zig @@ -36,7 +36,7 @@ test "tuple concatenation" { consume_tuple(.{} ++ .{}, 0); consume_tuple(.{0} ++ .{}, 1); consume_tuple(.{0} ++ .{1}, 2); - consume_tuple(.{0, 1, 2} ++ .{u8, 1, noreturn}, 6); + consume_tuple(.{ 0, 1, 2 } ++ .{ u8, 1, noreturn }, 6); consume_tuple(t2 ++ t1, 1); consume_tuple(t1 ++ t2, 1); consume_tuple(t2 ++ t2, 2); @@ -54,3 +54,17 @@ test "tuple concatenation" { T.doTheTest(); comptime T.doTheTest(); } + +test "pass tuple to comptime var parameter" { + const S = struct { + fn Foo(comptime args: var) void { + expect(args[0] == 1); + } + + fn doTheTest() void { + Foo(.{1}); + } + }; + S.doTheTest(); + comptime S.doTheTest(); +} -- 2.54.0 From 54ffcf95a8596aa3adf57cddbe079a24f849f408 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Sat, 14 Mar 2020 13:23:41 +0100 Subject: [PATCH 41/91] ir: Support div/mod/rem on vector types Closes #4050 --- src/codegen.cpp | 140 +++++++++++----- src/ir.cpp | 284 +++++++++++++++++--------------- test/stage1/behavior/vector.zig | 75 +++++++++ 3 files changed, 326 insertions(+), 173 deletions(-) diff --git a/src/codegen.cpp b/src/codegen.cpp index 84168f509fc9c8f6a522678f13b70afdddd8c3d9..0fa181b32c12e7c7ac133ac88904fb21d560e40c 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -2591,12 +2591,7 @@ static LLVMValueRef gen_overflow_shr_op(CodeGen *g, ZigType *type_entry, } static LLVMValueRef gen_float_op(CodeGen *g, LLVMValueRef val, ZigType *type_entry, BuiltinFnId op) { - if ((op == BuiltinFnIdCeil || - op == BuiltinFnIdFloor) && - type_entry->id == ZigTypeIdInt) - return val; - assert(type_entry->id == ZigTypeIdFloat); - + assert(type_entry->id == ZigTypeIdFloat || type_entry->id == ZigTypeIdVector); LLVMValueRef floor_fn = get_float_fn(g, type_entry, ZigLLVMFnIdFloatOp, op); return LLVMBuildCall(g->builder, floor_fn, &val, 1, ""); } @@ -2612,6 +2607,21 @@ static LLVMValueRef bigint_to_llvm_const(LLVMTypeRef type_ref, BigInt *bigint) { if (bigint->digit_count == 0) { return LLVMConstNull(type_ref); } + + if (LLVMGetTypeKind(type_ref) == LLVMVectorTypeKind) { + const unsigned vector_len = LLVMGetVectorSize(type_ref); + LLVMTypeRef elem_type = LLVMGetElementType(type_ref); + + LLVMValueRef *values = heap::c_allocator.allocate_nonzero(vector_len); + // Create a vector with all the elements having the same value + for (unsigned i = 0; i < vector_len; i++) { + values[i] = bigint_to_llvm_const(elem_type, bigint); + } + LLVMValueRef result = LLVMConstVector(values, vector_len); + heap::c_allocator.deallocate(values, vector_len); + return result; + } + LLVMValueRef unsigned_val; if (bigint->digit_count == 1) { unsigned_val = LLVMConstInt(type_ref, bigint_ptr(bigint)[0], false); @@ -2625,22 +2635,40 @@ static LLVMValueRef bigint_to_llvm_const(LLVMTypeRef type_ref, BigInt *bigint) { } } +// Collapses a vector into a single i1 whose value is 1 iff all the +// vector elements are 1 +static LLVMValueRef scalarize_cmp_result(CodeGen *g, LLVMValueRef val) { + assert(LLVMGetTypeKind(LLVMTypeOf(val)) == LLVMVectorTypeKind); + LLVMTypeRef scalar_type = LLVMIntType(LLVMGetVectorSize(LLVMTypeOf(val))); + LLVMValueRef all_ones = LLVMConstAllOnes(scalar_type); + LLVMValueRef casted = LLVMBuildBitCast(g->builder, val, scalar_type, ""); + return LLVMBuildICmp(g->builder, LLVMIntEQ, casted, all_ones, ""); +} + static LLVMValueRef gen_div(CodeGen *g, bool want_runtime_safety, bool want_fast_math, - LLVMValueRef val1, LLVMValueRef val2, - ZigType *type_entry, DivKind div_kind) + LLVMValueRef val1, LLVMValueRef val2, ZigType *operand_type, DivKind div_kind) { + ZigType *scalar_type = (operand_type->id == ZigTypeIdVector) ? + operand_type->data.vector.elem_type : operand_type; + ZigLLVMSetFastMath(g->builder, want_fast_math); - LLVMValueRef zero = LLVMConstNull(get_llvm_type(g, type_entry)); - if (want_runtime_safety && (want_fast_math || type_entry->id != ZigTypeIdFloat)) { + LLVMValueRef zero = LLVMConstNull(get_llvm_type(g, operand_type)); + if (want_runtime_safety && (want_fast_math || scalar_type->id != ZigTypeIdFloat)) { + // Safety check: divisor != 0 LLVMValueRef is_zero_bit; - if (type_entry->id == ZigTypeIdInt) { + if (scalar_type->id == ZigTypeIdInt) { is_zero_bit = LLVMBuildICmp(g->builder, LLVMIntEQ, val2, zero, ""); - } else if (type_entry->id == ZigTypeIdFloat) { + } else if (scalar_type->id == ZigTypeIdFloat) { is_zero_bit = LLVMBuildFCmp(g->builder, LLVMRealOEQ, val2, zero, ""); } else { zig_unreachable(); } + + if (operand_type->id == ZigTypeIdVector) { + is_zero_bit = scalarize_cmp_result(g, is_zero_bit); + } + LLVMBasicBlockRef div_zero_fail_block = LLVMAppendBasicBlock(g->cur_fn_val, "DivZeroFail"); LLVMBasicBlockRef div_zero_ok_block = LLVMAppendBasicBlock(g->cur_fn_val, "DivZeroOk"); LLVMBuildCondBr(g->builder, is_zero_bit, div_zero_fail_block, div_zero_ok_block); @@ -2650,16 +2678,21 @@ static LLVMValueRef gen_div(CodeGen *g, bool want_runtime_safety, bool want_fast LLVMPositionBuilderAtEnd(g->builder, div_zero_ok_block); - if (type_entry->id == ZigTypeIdInt && type_entry->data.integral.is_signed) { - LLVMValueRef neg_1_value = LLVMConstInt(get_llvm_type(g, type_entry), -1, true); + // Safety check: check for overflow (dividend = minInt and divisor = -1) + if (scalar_type->id == ZigTypeIdInt && scalar_type->data.integral.is_signed) { + LLVMValueRef neg_1_value = LLVMConstAllOnes(get_llvm_type(g, operand_type)); BigInt int_min_bi = {0}; - eval_min_max_value_int(g, type_entry, &int_min_bi, false); - LLVMValueRef int_min_value = bigint_to_llvm_const(get_llvm_type(g, type_entry), &int_min_bi); + eval_min_max_value_int(g, scalar_type, &int_min_bi, false); + LLVMValueRef int_min_value = bigint_to_llvm_const(get_llvm_type(g, operand_type), &int_min_bi); + LLVMBasicBlockRef overflow_fail_block = LLVMAppendBasicBlock(g->cur_fn_val, "DivOverflowFail"); LLVMBasicBlockRef overflow_ok_block = LLVMAppendBasicBlock(g->cur_fn_val, "DivOverflowOk"); LLVMValueRef num_is_int_min = LLVMBuildICmp(g->builder, LLVMIntEQ, val1, int_min_value, ""); LLVMValueRef den_is_neg_1 = LLVMBuildICmp(g->builder, LLVMIntEQ, val2, neg_1_value, ""); LLVMValueRef overflow_fail_bit = LLVMBuildAnd(g->builder, num_is_int_min, den_is_neg_1, ""); + if (operand_type->id == ZigTypeIdVector) { + overflow_fail_bit = scalarize_cmp_result(g, overflow_fail_bit); + } LLVMBuildCondBr(g->builder, overflow_fail_bit, overflow_fail_block, overflow_ok_block); LLVMPositionBuilderAtEnd(g->builder, overflow_fail_block); @@ -2669,18 +2702,22 @@ static LLVMValueRef gen_div(CodeGen *g, bool want_runtime_safety, bool want_fast } } - if (type_entry->id == ZigTypeIdFloat) { + if (scalar_type->id == ZigTypeIdFloat) { LLVMValueRef result = LLVMBuildFDiv(g->builder, val1, val2, ""); switch (div_kind) { case DivKindFloat: return result; case DivKindExact: if (want_runtime_safety) { - LLVMValueRef floored = gen_float_op(g, result, type_entry, BuiltinFnIdFloor); + // Safety check: a / b == floor(a / b) + LLVMValueRef floored = gen_float_op(g, result, operand_type, BuiltinFnIdFloor); + LLVMBasicBlockRef ok_block = LLVMAppendBasicBlock(g->cur_fn_val, "DivExactOk"); LLVMBasicBlockRef fail_block = LLVMAppendBasicBlock(g->cur_fn_val, "DivExactFail"); LLVMValueRef ok_bit = LLVMBuildFCmp(g->builder, LLVMRealOEQ, floored, result, ""); - + if (operand_type->id == ZigTypeIdVector) { + ok_bit = scalarize_cmp_result(g, ok_bit); + } LLVMBuildCondBr(g->builder, ok_bit, ok_block, fail_block); LLVMPositionBuilderAtEnd(g->builder, fail_block); @@ -2695,54 +2732,61 @@ static LLVMValueRef gen_div(CodeGen *g, bool want_runtime_safety, bool want_fast LLVMBasicBlockRef gez_block = LLVMAppendBasicBlock(g->cur_fn_val, "DivTruncGEZero"); LLVMBasicBlockRef end_block = LLVMAppendBasicBlock(g->cur_fn_val, "DivTruncEnd"); LLVMValueRef ltz = LLVMBuildFCmp(g->builder, LLVMRealOLT, val1, zero, ""); + if (operand_type->id == ZigTypeIdVector) { + ltz = scalarize_cmp_result(g, ltz); + } LLVMBuildCondBr(g->builder, ltz, ltz_block, gez_block); LLVMPositionBuilderAtEnd(g->builder, ltz_block); - LLVMValueRef ceiled = gen_float_op(g, result, type_entry, BuiltinFnIdCeil); + LLVMValueRef ceiled = gen_float_op(g, result, operand_type, BuiltinFnIdCeil); LLVMBasicBlockRef ceiled_end_block = LLVMGetInsertBlock(g->builder); LLVMBuildBr(g->builder, end_block); LLVMPositionBuilderAtEnd(g->builder, gez_block); - LLVMValueRef floored = gen_float_op(g, result, type_entry, BuiltinFnIdFloor); + LLVMValueRef floored = gen_float_op(g, result, operand_type, BuiltinFnIdFloor); LLVMBasicBlockRef floored_end_block = LLVMGetInsertBlock(g->builder); LLVMBuildBr(g->builder, end_block); LLVMPositionBuilderAtEnd(g->builder, end_block); - LLVMValueRef phi = LLVMBuildPhi(g->builder, get_llvm_type(g, type_entry), ""); + LLVMValueRef phi = LLVMBuildPhi(g->builder, get_llvm_type(g, operand_type), ""); LLVMValueRef incoming_values[] = { ceiled, floored }; LLVMBasicBlockRef incoming_blocks[] = { ceiled_end_block, floored_end_block }; LLVMAddIncoming(phi, incoming_values, incoming_blocks, 2); return phi; } case DivKindFloor: - return gen_float_op(g, result, type_entry, BuiltinFnIdFloor); + return gen_float_op(g, result, operand_type, BuiltinFnIdFloor); } zig_unreachable(); } - assert(type_entry->id == ZigTypeIdInt); + assert(scalar_type->id == ZigTypeIdInt); switch (div_kind) { case DivKindFloat: zig_unreachable(); case DivKindTrunc: - if (type_entry->data.integral.is_signed) { + if (scalar_type->data.integral.is_signed) { return LLVMBuildSDiv(g->builder, val1, val2, ""); } else { return LLVMBuildUDiv(g->builder, val1, val2, ""); } case DivKindExact: if (want_runtime_safety) { + // Safety check: a % b == 0 LLVMValueRef remainder_val; - if (type_entry->data.integral.is_signed) { + if (scalar_type->data.integral.is_signed) { remainder_val = LLVMBuildSRem(g->builder, val1, val2, ""); } else { remainder_val = LLVMBuildURem(g->builder, val1, val2, ""); } - LLVMValueRef ok_bit = LLVMBuildICmp(g->builder, LLVMIntEQ, remainder_val, zero, ""); LLVMBasicBlockRef ok_block = LLVMAppendBasicBlock(g->cur_fn_val, "DivExactOk"); LLVMBasicBlockRef fail_block = LLVMAppendBasicBlock(g->cur_fn_val, "DivExactFail"); + LLVMValueRef ok_bit = LLVMBuildICmp(g->builder, LLVMIntEQ, remainder_val, zero, ""); + if (operand_type->id == ZigTypeIdVector) { + ok_bit = scalarize_cmp_result(g, ok_bit); + } LLVMBuildCondBr(g->builder, ok_bit, ok_block, fail_block); LLVMPositionBuilderAtEnd(g->builder, fail_block); @@ -2750,14 +2794,14 @@ static LLVMValueRef gen_div(CodeGen *g, bool want_runtime_safety, bool want_fast LLVMPositionBuilderAtEnd(g->builder, ok_block); } - if (type_entry->data.integral.is_signed) { + if (scalar_type->data.integral.is_signed) { return LLVMBuildExactSDiv(g->builder, val1, val2, ""); } else { return LLVMBuildExactUDiv(g->builder, val1, val2, ""); } case DivKindFloor: { - if (!type_entry->data.integral.is_signed) { + if (!scalar_type->data.integral.is_signed) { return LLVMBuildUDiv(g->builder, val1, val2, ""); } // const d = @divTrunc(a, b); @@ -2784,22 +2828,30 @@ enum RemKind { }; static LLVMValueRef gen_rem(CodeGen *g, bool want_runtime_safety, bool want_fast_math, - LLVMValueRef val1, LLVMValueRef val2, - ZigType *type_entry, RemKind rem_kind) + LLVMValueRef val1, LLVMValueRef val2, ZigType *operand_type, RemKind rem_kind) { + ZigType *scalar_type = (operand_type->id == ZigTypeIdVector) ? + operand_type->data.vector.elem_type : operand_type; + ZigLLVMSetFastMath(g->builder, want_fast_math); - LLVMValueRef zero = LLVMConstNull(get_llvm_type(g, type_entry)); + LLVMValueRef zero = LLVMConstNull(get_llvm_type(g, operand_type)); if (want_runtime_safety) { + // Safety check: divisor != 0 LLVMValueRef is_zero_bit; - if (type_entry->id == ZigTypeIdInt) { - LLVMIntPredicate pred = type_entry->data.integral.is_signed ? LLVMIntSLE : LLVMIntEQ; + if (scalar_type->id == ZigTypeIdInt) { + LLVMIntPredicate pred = scalar_type->data.integral.is_signed ? LLVMIntSLE : LLVMIntEQ; is_zero_bit = LLVMBuildICmp(g->builder, pred, val2, zero, ""); - } else if (type_entry->id == ZigTypeIdFloat) { + } else if (scalar_type->id == ZigTypeIdFloat) { is_zero_bit = LLVMBuildFCmp(g->builder, LLVMRealOEQ, val2, zero, ""); } else { zig_unreachable(); } + + if (operand_type->id == ZigTypeIdVector) { + is_zero_bit = scalarize_cmp_result(g, is_zero_bit); + } + LLVMBasicBlockRef rem_zero_ok_block = LLVMAppendBasicBlock(g->cur_fn_val, "RemZeroOk"); LLVMBasicBlockRef rem_zero_fail_block = LLVMAppendBasicBlock(g->cur_fn_val, "RemZeroFail"); LLVMBuildCondBr(g->builder, is_zero_bit, rem_zero_fail_block, rem_zero_ok_block); @@ -2810,7 +2862,7 @@ static LLVMValueRef gen_rem(CodeGen *g, bool want_runtime_safety, bool want_fast LLVMPositionBuilderAtEnd(g->builder, rem_zero_ok_block); } - if (type_entry->id == ZigTypeIdFloat) { + if (scalar_type->id == ZigTypeIdFloat) { if (rem_kind == RemKindRem) { return LLVMBuildFRem(g->builder, val1, val2, ""); } else { @@ -2821,8 +2873,8 @@ static LLVMValueRef gen_rem(CodeGen *g, bool want_runtime_safety, bool want_fast return LLVMBuildSelect(g->builder, ltz, c, a, ""); } } else { - assert(type_entry->id == ZigTypeIdInt); - if (type_entry->data.integral.is_signed) { + assert(scalar_type->id == ZigTypeIdInt); + if (scalar_type->data.integral.is_signed) { if (rem_kind == RemKindRem) { return LLVMBuildSRem(g->builder, val1, val2, ""); } else { @@ -3010,22 +3062,22 @@ static LLVMValueRef ir_render_bin_op(CodeGen *g, IrExecutableGen *executable, } case IrBinOpDivUnspecified: return gen_div(g, want_runtime_safety, ir_want_fast_math(g, &bin_op_instruction->base), - op1_value, op2_value, scalar_type, DivKindFloat); + op1_value, op2_value, operand_type, DivKindFloat); case IrBinOpDivExact: return gen_div(g, want_runtime_safety, ir_want_fast_math(g, &bin_op_instruction->base), - op1_value, op2_value, scalar_type, DivKindExact); + op1_value, op2_value, operand_type, DivKindExact); case IrBinOpDivTrunc: return gen_div(g, want_runtime_safety, ir_want_fast_math(g, &bin_op_instruction->base), - op1_value, op2_value, scalar_type, DivKindTrunc); + op1_value, op2_value, operand_type, DivKindTrunc); case IrBinOpDivFloor: return gen_div(g, want_runtime_safety, ir_want_fast_math(g, &bin_op_instruction->base), - op1_value, op2_value, scalar_type, DivKindFloor); + op1_value, op2_value, operand_type, DivKindFloor); case IrBinOpRemRem: return gen_rem(g, want_runtime_safety, ir_want_fast_math(g, &bin_op_instruction->base), - op1_value, op2_value, scalar_type, RemKindRem); + op1_value, op2_value, operand_type, RemKindRem); case IrBinOpRemMod: return gen_rem(g, want_runtime_safety, ir_want_fast_math(g, &bin_op_instruction->base), - op1_value, op2_value, scalar_type, RemKindMod); + op1_value, op2_value, operand_type, RemKindMod); } zig_unreachable(); } diff --git a/src/ir.cpp b/src/ir.cpp index bc222a311bfd16c6ae168abf21b24874bc23b345..04eaa217b9999d20501fb7757e3c3453913fcca7 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -16943,6 +16943,7 @@ static bool ok_float_op(IrBinOp op) { case IrBinOpDivExact: case IrBinOpRemRem: case IrBinOpRemMod: + case IrBinOpRemUnspecified: return true; case IrBinOpBoolOr: @@ -16963,7 +16964,6 @@ static bool ok_float_op(IrBinOp op) { case IrBinOpAddWrap: case IrBinOpSubWrap: case IrBinOpMultWrap: - case IrBinOpRemUnspecified: case IrBinOpArrayCat: case IrBinOpArrayMult: return false; @@ -16991,6 +16991,31 @@ static bool is_pointer_arithmetic_allowed(ZigType *lhs_type, IrBinOp op) { zig_unreachable(); } +static bool value_cmp_zero_any(ZigValue *value, Cmp predicate) { + assert(value->special == ConstValSpecialStatic); + + switch (value->type->id) { + case ZigTypeIdComptimeInt: + case ZigTypeIdInt: + return bigint_cmp_zero(&value->data.x_bigint) == predicate; + case ZigTypeIdComptimeFloat: + case ZigTypeIdFloat: + if (float_is_nan(value)) + return false; + return float_cmp_zero(value) == predicate; + case ZigTypeIdVector: { + for (size_t i = 0; i < value->type->data.vector.len; i++) { + ZigValue *scalar_val = &value->data.x_array.data.s_none.elements[i]; + if (!value_cmp_zero_any(scalar_val, predicate)) + return true; + } + return false; + } + default: + zig_unreachable(); + } +} + static IrInstGen *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstSrcBinOp *instruction) { Error err; @@ -17096,127 +17121,13 @@ static IrInstGen *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstSrcBinOp *instruc if (type_is_invalid(resolved_type)) return ira->codegen->invalid_inst_gen; - bool is_int = resolved_type->id == ZigTypeIdInt || resolved_type->id == ZigTypeIdComptimeInt; - bool is_float = resolved_type->id == ZigTypeIdFloat || resolved_type->id == ZigTypeIdComptimeFloat; - bool is_signed_div = ( - (resolved_type->id == ZigTypeIdInt && resolved_type->data.integral.is_signed) || - resolved_type->id == ZigTypeIdFloat || - (resolved_type->id == ZigTypeIdComptimeFloat && - ((bigfloat_cmp_zero(&op1->value->data.x_bigfloat) != CmpGT) != - (bigfloat_cmp_zero(&op2->value->data.x_bigfloat) != CmpGT))) || - (resolved_type->id == ZigTypeIdComptimeInt && - ((bigint_cmp_zero(&op1->value->data.x_bigint) != CmpGT) != - (bigint_cmp_zero(&op2->value->data.x_bigint) != CmpGT))) - ); - if (op_id == IrBinOpDivUnspecified && is_int) { - if (is_signed_div) { - bool ok = false; - if (instr_is_comptime(op1) && instr_is_comptime(op2)) { - ZigValue *op1_val = ir_resolve_const(ira, op1, UndefBad); - if (op1_val == nullptr) - return ira->codegen->invalid_inst_gen; + ZigType *scalar_type = (resolved_type->id == ZigTypeIdVector) ? + resolved_type->data.vector.elem_type : resolved_type; - ZigValue *op2_val = ir_resolve_const(ira, op2, UndefBad); - if (op2_val == nullptr) - return ira->codegen->invalid_inst_gen; + bool is_int = scalar_type->id == ZigTypeIdInt || scalar_type->id == ZigTypeIdComptimeInt; + bool is_float = scalar_type->id == ZigTypeIdFloat || scalar_type->id == ZigTypeIdComptimeFloat; - if (bigint_cmp_zero(&op2_val->data.x_bigint) == CmpEQ) { - // the division by zero error will be caught later, but we don't have a - // division function ambiguity problem. - op_id = IrBinOpDivTrunc; - ok = true; - } else { - BigInt trunc_result; - BigInt floor_result; - bigint_div_trunc(&trunc_result, &op1_val->data.x_bigint, &op2_val->data.x_bigint); - bigint_div_floor(&floor_result, &op1_val->data.x_bigint, &op2_val->data.x_bigint); - if (bigint_cmp(&trunc_result, &floor_result) == CmpEQ) { - ok = true; - op_id = IrBinOpDivTrunc; - } - } - } - if (!ok) { - ir_add_error(ira, &instruction->base.base, - buf_sprintf("division with '%s' and '%s': signed integers must use @divTrunc, @divFloor, or @divExact", - buf_ptr(&op1->value->type->name), - buf_ptr(&op2->value->type->name))); - return ira->codegen->invalid_inst_gen; - } - } else { - op_id = IrBinOpDivTrunc; - } - } else if (op_id == IrBinOpRemUnspecified) { - if (is_signed_div && (is_int || is_float)) { - bool ok = false; - if (instr_is_comptime(op1) && instr_is_comptime(op2)) { - ZigValue *op1_val = ir_resolve_const(ira, op1, UndefBad); - if (op1_val == nullptr) - return ira->codegen->invalid_inst_gen; - - if (is_int) { - ZigValue *op2_val = ir_resolve_const(ira, op2, UndefBad); - if (op2_val == nullptr) - return ira->codegen->invalid_inst_gen; - - if (bigint_cmp_zero(&op2->value->data.x_bigint) == CmpEQ) { - // the division by zero error will be caught later, but we don't - // have a remainder function ambiguity problem - ok = true; - } else { - BigInt rem_result; - BigInt mod_result; - bigint_rem(&rem_result, &op1_val->data.x_bigint, &op2_val->data.x_bigint); - bigint_mod(&mod_result, &op1_val->data.x_bigint, &op2_val->data.x_bigint); - ok = bigint_cmp(&rem_result, &mod_result) == CmpEQ; - } - } else { - IrInstGen *casted_op2 = ir_implicit_cast(ira, op2, resolved_type); - if (type_is_invalid(casted_op2->value->type)) - return ira->codegen->invalid_inst_gen; - - ZigValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); - if (op2_val == nullptr) - return ira->codegen->invalid_inst_gen; - - if (float_cmp_zero(casted_op2->value) == CmpEQ) { - // the division by zero error will be caught later, but we don't - // have a remainder function ambiguity problem - ok = true; - } else { - ZigValue rem_result = {}; - ZigValue mod_result = {}; - float_rem(&rem_result, op1_val, op2_val); - float_mod(&mod_result, op1_val, op2_val); - ok = float_cmp(&rem_result, &mod_result) == CmpEQ; - } - } - } - if (!ok) { - ir_add_error(ira, &instruction->base.base, - buf_sprintf("remainder division with '%s' and '%s': signed integers and floats must use @rem or @mod", - buf_ptr(&op1->value->type->name), - buf_ptr(&op2->value->type->name))); - return ira->codegen->invalid_inst_gen; - } - } - op_id = IrBinOpRemRem; - } - - bool ok = false; - if (is_int) { - ok = true; - } else if (is_float && ok_float_op(op_id)) { - ok = true; - } else if (resolved_type->id == ZigTypeIdVector) { - ZigType *elem_type = resolved_type->data.vector.elem_type; - if (elem_type->id == ZigTypeIdInt || elem_type->id == ZigTypeIdComptimeInt) { - ok = true; - } else if ((elem_type->id == ZigTypeIdFloat || elem_type->id == ZigTypeIdComptimeFloat) && ok_float_op(op_id)) { - ok = true; - } - } - if (!ok) { + if (!is_int && !(is_float && ok_float_op(op_id))) { AstNode *source_node = instruction->base.base.source_node; ir_add_error_node(ira, source_node, buf_sprintf("invalid operands to binary expression: '%s' and '%s'", @@ -17225,7 +17136,16 @@ static IrInstGen *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstSrcBinOp *instruc return ira->codegen->invalid_inst_gen; } - if (resolved_type->id == ZigTypeIdComptimeInt) { + IrInstGen *casted_op1 = ir_implicit_cast(ira, op1, resolved_type); + if (type_is_invalid(casted_op1->value->type)) + return ira->codegen->invalid_inst_gen; + + IrInstGen *casted_op2 = ir_implicit_cast(ira, op2, resolved_type); + if (type_is_invalid(casted_op2->value->type)) + return ira->codegen->invalid_inst_gen; + + // Comptime integers have no fixed size + if (scalar_type->id == ZigTypeIdComptimeInt) { if (op_id == IrBinOpAddWrap) { op_id = IrBinOpAdd; } else if (op_id == IrBinOpSubWrap) { @@ -17235,25 +17155,131 @@ static IrInstGen *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstSrcBinOp *instruc } } - IrInstGen *casted_op1 = ir_implicit_cast(ira, op1, resolved_type); - if (type_is_invalid(casted_op1->value->type)) - return ira->codegen->invalid_inst_gen; - - IrInstGen *casted_op2 = ir_implicit_cast(ira, op2, resolved_type); - if (type_is_invalid(casted_op2->value->type)) - return ira->codegen->invalid_inst_gen; - if (instr_is_comptime(casted_op1) && instr_is_comptime(casted_op2)) { ZigValue *op1_val = ir_resolve_const(ira, casted_op1, UndefBad); if (op1_val == nullptr) return ira->codegen->invalid_inst_gen; + ZigValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); if (op2_val == nullptr) return ira->codegen->invalid_inst_gen; + // Promote division with negative numbers to signed + bool is_signed_div = value_cmp_zero_any(op1_val, CmpLT) || + value_cmp_zero_any(op2_val, CmpLT); + + if (op_id == IrBinOpDivUnspecified && is_int) { + // Default to truncating division and check if it's valid for the + // given operands if signed + op_id = IrBinOpDivTrunc; + + if (is_signed_div) { + bool ok = false; + + if (value_cmp_zero_any(op2_val, CmpEQ)) { + // the division by zero error will be caught later, but we don't have a + // division function ambiguity problem. + ok = true; + } else { + IrInstGen *trunc_val = ir_analyze_math_op(ira, &instruction->base.base, resolved_type, + op1_val, IrBinOpDivTrunc, op2_val); + if (type_is_invalid(trunc_val->value->type)) + return ira->codegen->invalid_inst_gen; + + IrInstGen *floor_val = ir_analyze_math_op(ira, &instruction->base.base, resolved_type, + op1_val, IrBinOpDivFloor, op2_val); + if (type_is_invalid(floor_val->value->type)) + return ira->codegen->invalid_inst_gen; + + IrInstGen *cmp_val = ir_analyze_bin_op_cmp_numeric(ira, &instruction->base.base, + trunc_val, floor_val, IrBinOpCmpEq); + if (type_is_invalid(cmp_val->value->type)) + return ira->codegen->invalid_inst_gen; + + // We can "upgrade" the operator only if trunc(a/b) == floor(a/b) + if (!ir_resolve_bool(ira, cmp_val, &ok)) + return ira->codegen->invalid_inst_gen; + } + + if (!ok) { + ir_add_error(ira, &instruction->base.base, + buf_sprintf("division with '%s' and '%s': signed integers must use @divTrunc, @divFloor, or @divExact", + buf_ptr(&op1->value->type->name), + buf_ptr(&op2->value->type->name))); + return ira->codegen->invalid_inst_gen; + } + } + } else if (op_id == IrBinOpRemUnspecified) { + op_id = IrBinOpRemRem; + + if (is_signed_div) { + bool ok = false; + + if (value_cmp_zero_any(op2_val, CmpEQ)) { + // the division by zero error will be caught later, but we don't have a + // division function ambiguity problem. + ok = true; + } else { + IrInstGen *rem_val = ir_analyze_math_op(ira, &instruction->base.base, resolved_type, + op1_val, IrBinOpRemRem, op2_val); + if (type_is_invalid(rem_val->value->type)) + return ira->codegen->invalid_inst_gen; + + IrInstGen *mod_val = ir_analyze_math_op(ira, &instruction->base.base, resolved_type, + op1_val, IrBinOpRemMod, op2_val); + if (type_is_invalid(mod_val->value->type)) + return ira->codegen->invalid_inst_gen; + + IrInstGen *cmp_val = ir_analyze_bin_op_cmp_numeric(ira, &instruction->base.base, + rem_val, mod_val, IrBinOpCmpEq); + if (type_is_invalid(cmp_val->value->type)) + return ira->codegen->invalid_inst_gen; + + // We can "upgrade" the operator only if mod(a,b) == rem(a,b) + if (!ir_resolve_bool(ira, cmp_val, &ok)) + return ira->codegen->invalid_inst_gen; + } + + if (!ok) { + ir_add_error(ira, &instruction->base.base, + buf_sprintf("remainder division with '%s' and '%s': signed integers and floats must use @rem or @mod", + buf_ptr(&op1->value->type->name), + buf_ptr(&op2->value->type->name))); + return ira->codegen->invalid_inst_gen; + } + } + } + return ir_analyze_math_op(ira, &instruction->base.base, resolved_type, op1_val, op_id, op2_val); } + const bool is_signed_div = + (scalar_type->id == ZigTypeIdInt && scalar_type->data.integral.is_signed) || + scalar_type->id == ZigTypeIdFloat; + + // Warn the user to use the proper operators here + if (op_id == IrBinOpDivUnspecified && is_int) { + op_id = IrBinOpDivTrunc; + + if (is_signed_div) { + ir_add_error(ira, &instruction->base.base, + buf_sprintf("division with '%s' and '%s': signed integers must use @divTrunc, @divFloor, or @divExact", + buf_ptr(&op1->value->type->name), + buf_ptr(&op2->value->type->name))); + return ira->codegen->invalid_inst_gen; + } + } else if (op_id == IrBinOpRemUnspecified) { + op_id = IrBinOpRemRem; + + if (is_signed_div) { + ir_add_error(ira, &instruction->base.base, + buf_sprintf("remainder division with '%s' and '%s': signed integers and floats must use @rem or @mod", + buf_ptr(&op1->value->type->name), + buf_ptr(&op2->value->type->name))); + return ira->codegen->invalid_inst_gen; + } + } + return ir_build_bin_op_gen(ira, &instruction->base.base, resolved_type, op_id, casted_op1, casted_op2, instruction->safety_check_on); } diff --git a/test/stage1/behavior/vector.zig b/test/stage1/behavior/vector.zig index 01e5ac1fb8b69e37e94cbda2f5a045da7ab66e9f..6db695bfa331758b81f6f8741c98aee367d2dae5 100644 --- a/test/stage1/behavior/vector.zig +++ b/test/stage1/behavior/vector.zig @@ -276,3 +276,78 @@ test "vector comparison operators" { S.doTheTest(); comptime S.doTheTest(); } + +test "vector division operators" { + const S = struct { + fn doTheTestDiv(comptime T: type, x: @Vector(4, T), y: @Vector(4, T)) void { + if (!comptime std.meta.trait.isSignedInt(T)) { + const d0 = x / y; + for (@as([4]T, d0)) |v, i| { + expectEqual(x[i] / y[i], v); + } + } + const d1 = @divExact(x, y); + for (@as([4]T, d1)) |v, i| { + expectEqual(@divExact(x[i], y[i]), v); + } + const d2 = @divFloor(x, y); + for (@as([4]T, d2)) |v, i| { + expectEqual(@divFloor(x[i], y[i]), v); + } + const d3 = @divTrunc(x, y); + for (@as([4]T, d3)) |v, i| { + expectEqual(@divTrunc(x[i], y[i]), v); + } + } + + fn doTheTestMod(comptime T: type, x: @Vector(4, T), y: @Vector(4, T)) void { + if ((!comptime std.meta.trait.isSignedInt(T)) and @typeInfo(T) != .Float) { + const r0 = x % y; + for (@as([4]T, r0)) |v, i| { + expectEqual(x[i] % y[i], v); + } + } + const r1 = @mod(x, y); + for (@as([4]T, r1)) |v, i| { + expectEqual(@mod(x[i], y[i]), v); + } + const r2 = @rem(x, y); + for (@as([4]T, r2)) |v, i| { + expectEqual(@rem(x[i], y[i]), v); + } + } + + fn doTheTest() void { + doTheTestDiv(f16, [4]f16{ 4.0, -4.0, 4.0, -4.0 }, [4]f16{ 1.0, 2.0, -1.0, -2.0 }); + doTheTestDiv(f32, [4]f32{ 4.0, -4.0, 4.0, -4.0 }, [4]f32{ 1.0, 2.0, -1.0, -2.0 }); + doTheTestDiv(f64, [4]f64{ 4.0, -4.0, 4.0, -4.0 }, [4]f64{ 1.0, 2.0, -1.0, -2.0 }); + + doTheTestMod(f16, [4]f16{ 4.0, -4.0, 4.0, -4.0 }, [4]f16{ 1.0, 2.0, 0.5, 3.0 }); + doTheTestMod(f32, [4]f32{ 4.0, -4.0, 4.0, -4.0 }, [4]f32{ 1.0, 2.0, 0.5, 3.0 }); + doTheTestMod(f64, [4]f64{ 4.0, -4.0, 4.0, -4.0 }, [4]f64{ 1.0, 2.0, 0.5, 3.0 }); + + doTheTestDiv(i8, [4]i8{ 4, -4, 4, -4 }, [4]i8{ 1, 2, -1, -2 }); + doTheTestDiv(i16, [4]i16{ 4, -4, 4, -4 }, [4]i16{ 1, 2, -1, -2 }); + doTheTestDiv(i32, [4]i32{ 4, -4, 4, -4 }, [4]i32{ 1, 2, -1, -2 }); + doTheTestDiv(i64, [4]i64{ 4, -4, 4, -4 }, [4]i64{ 1, 2, -1, -2 }); + + doTheTestMod(i8, [4]i8{ 4, -4, 4, -4 }, [4]i8{ 1, 2, 4, 8 }); + doTheTestMod(i16, [4]i16{ 4, -4, 4, -4 }, [4]i16{ 1, 2, 4, 8 }); + doTheTestMod(i32, [4]i32{ 4, -4, 4, -4 }, [4]i32{ 1, 2, 4, 8 }); + doTheTestMod(i64, [4]i64{ 4, -4, 4, -4 }, [4]i64{ 1, 2, 4, 8 }); + + doTheTestDiv(u8, [4]u8{ 1, 2, 4, 8 }, [4]u8{ 1, 1, 2, 4 }); + doTheTestDiv(u16, [4]u16{ 1, 2, 4, 8 }, [4]u16{ 1, 1, 2, 4 }); + doTheTestDiv(u32, [4]u32{ 1, 2, 4, 8 }, [4]u32{ 1, 1, 2, 4 }); + doTheTestDiv(u64, [4]u64{ 1, 2, 4, 8 }, [4]u64{ 1, 1, 2, 4 }); + + doTheTestMod(u8, [4]u8{ 1, 2, 4, 8 }, [4]u8{ 1, 1, 2, 4 }); + doTheTestMod(u16, [4]u16{ 1, 2, 4, 8 }, [4]u16{ 1, 1, 2, 4 }); + doTheTestMod(u32, [4]u32{ 1, 2, 4, 8 }, [4]u32{ 1, 1, 2, 4 }); + doTheTestMod(u64, [4]u64{ 1, 2, 4, 8 }, [4]u64{ 1, 1, 2, 4 }); + } + }; + + S.doTheTest(); + comptime S.doTheTest(); +} -- 2.54.0 From 2485f3004659723a1ccd2799a6e0bddb09e32d3b Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Sat, 14 Mar 2020 16:55:27 +0100 Subject: [PATCH 42/91] ir: Support bitwise not on vectors --- src/ir.cpp | 53 +++++++++++++++++++++++---------- test/stage1/behavior/vector.zig | 25 ++++++++++++++++ 2 files changed, 62 insertions(+), 16 deletions(-) diff --git a/src/ir.cpp b/src/ir.cpp index 04eaa217b9999d20501fb7757e3c3453913fcca7..436db592f2c536ff7befcaf3e5dcfb6119c14256 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -20363,24 +20363,45 @@ static IrInstGen *ir_analyze_bin_not(IrAnalyze *ira, IrInstSrcUnOp *instruction) if (type_is_invalid(expr_type)) return ira->codegen->invalid_inst_gen; - if (expr_type->id == ZigTypeIdInt) { - if (instr_is_comptime(value)) { - ZigValue *target_const_val = ir_resolve_const(ira, value, UndefBad); - if (target_const_val == nullptr) - return ira->codegen->invalid_inst_gen; + ZigType *scalar_type = (expr_type->id == ZigTypeIdVector) ? + expr_type->data.vector.elem_type : expr_type; - IrInstGen *result = ir_const(ira, &instruction->base.base, expr_type); - bigint_not(&result->value->data.x_bigint, &target_const_val->data.x_bigint, - expr_type->data.integral.bit_count, expr_type->data.integral.is_signed); - return result; - } - - return ir_build_binary_not(ira, &instruction->base.base, value, expr_type); - } - - ir_add_error(ira, &instruction->base.base, + if (scalar_type->id != ZigTypeIdInt) { + ir_add_error(ira, &instruction->base.base, buf_sprintf("unable to perform binary not operation on type '%s'", buf_ptr(&expr_type->name))); - return ira->codegen->invalid_inst_gen; + return ira->codegen->invalid_inst_gen; + } + + if (instr_is_comptime(value)) { + ZigValue *expr_val = ir_resolve_const(ira, value, UndefBad); + if (expr_val == nullptr) + return ira->codegen->invalid_inst_gen; + + IrInstGen *result = ir_const(ira, &instruction->base.base, expr_type); + + if (expr_type->id == ZigTypeIdVector) { + expand_undef_array(ira->codegen, expr_val); + result->value->special = ConstValSpecialUndef; + expand_undef_array(ira->codegen, result->value); + + for (size_t i = 0; i < expr_type->data.vector.len; i++) { + ZigValue *src_val = &expr_val->data.x_array.data.s_none.elements[i]; + ZigValue *dst_val = &result->value->data.x_array.data.s_none.elements[i]; + + dst_val->type = scalar_type; + dst_val->special = ConstValSpecialStatic; + bigint_not(&dst_val->data.x_bigint, &src_val->data.x_bigint, + scalar_type->data.integral.bit_count, scalar_type->data.integral.is_signed); + } + } else { + bigint_not(&result->value->data.x_bigint, &expr_val->data.x_bigint, + scalar_type->data.integral.bit_count, scalar_type->data.integral.is_signed); + } + + return result; + } + + return ir_build_binary_not(ira, &instruction->base.base, value, expr_type); } static IrInstGen *ir_analyze_instruction_un_op(IrAnalyze *ira, IrInstSrcUnOp *instruction) { diff --git a/test/stage1/behavior/vector.zig b/test/stage1/behavior/vector.zig index 6db695bfa331758b81f6f8741c98aee367d2dae5..f242aa0fbff2a2d5f48529f92a92e3ab6e3d7399 100644 --- a/test/stage1/behavior/vector.zig +++ b/test/stage1/behavior/vector.zig @@ -351,3 +351,28 @@ test "vector division operators" { S.doTheTest(); comptime S.doTheTest(); } + +test "vector bitwise not operator" { + const S = struct { + fn doTheTestNot(comptime T: type, x: @Vector(4, T)) void { + var y = ~x; + for (@as([4]T, y)) |v, i| { + expectEqual(~x[i], v); + } + } + fn doTheTest() void { + doTheTestNot(u8, [_]u8{ 0, 2, 4, 255 }); + doTheTestNot(u16, [_]u16{ 0, 2, 4, 255 }); + doTheTestNot(u32, [_]u32{ 0, 2, 4, 255 }); + doTheTestNot(u64, [_]u64{ 0, 2, 4, 255 }); + + doTheTestNot(u8, [_]u8{ 0, 2, 4, 255 }); + doTheTestNot(u16, [_]u16{ 0, 2, 4, 255 }); + doTheTestNot(u32, [_]u32{ 0, 2, 4, 255 }); + doTheTestNot(u64, [_]u64{ 0, 2, 4, 255 }); + } + }; + + S.doTheTest(); + comptime S.doTheTest(); +} -- 2.54.0 From d2d97e55ccd2d7c992d01bd05ea52a52fe36776e Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Sat, 14 Mar 2020 20:01:28 +0100 Subject: [PATCH 43/91] ir: Support shift left/right on vectors --- src/codegen.cpp | 50 +++++++++----- src/ir.cpp | 116 +++++++++++++++++++++++--------- test/stage1/behavior/vector.zig | 65 ++++++++++++++++++ 3 files changed, 183 insertions(+), 48 deletions(-) diff --git a/src/codegen.cpp b/src/codegen.cpp index 0fa181b32c12e7c7ac133ac88904fb21d560e40c..97d960b5230bc17853479ebe25e57306ec9e5c37 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -155,6 +155,7 @@ static LLVMValueRef gen_await_early_return(CodeGen *g, IrInstGen *source_instr, LLVMValueRef target_frame_ptr, ZigType *result_type, ZigType *ptr_result_type, LLVMValueRef result_loc, bool non_async); static Error get_tmp_filename(CodeGen *g, Buf *out, Buf *suffix); +static LLVMValueRef scalarize_cmp_result(CodeGen *g, LLVMValueRef val); static void addLLVMAttr(LLVMValueRef val, LLVMAttributeIndex attr_index, const char *attr_name) { unsigned kind_id = LLVMGetEnumAttributeKindForName(attr_name, strlen(attr_name)); @@ -2535,19 +2536,21 @@ static LLVMValueRef ir_render_return(CodeGen *g, IrExecutableGen *executable, Ir return nullptr; } -static LLVMValueRef gen_overflow_shl_op(CodeGen *g, ZigType *type_entry, - LLVMValueRef val1, LLVMValueRef val2) +static LLVMValueRef gen_overflow_shl_op(CodeGen *g, ZigType *operand_type, + LLVMValueRef val1, LLVMValueRef val2) { // for unsigned left shifting, we do the lossy shift, then logically shift // right the same number of bits // if the values don't match, we have an overflow // for signed left shifting we do the same except arithmetic shift right + ZigType *scalar_type = (operand_type->id == ZigTypeIdVector) ? + operand_type->data.vector.elem_type : operand_type; - assert(type_entry->id == ZigTypeIdInt); + assert(scalar_type->id == ZigTypeIdInt); LLVMValueRef result = LLVMBuildShl(g->builder, val1, val2, ""); LLVMValueRef orig_val; - if (type_entry->data.integral.is_signed) { + if (scalar_type->data.integral.is_signed) { orig_val = LLVMBuildAShr(g->builder, result, val2, ""); } else { orig_val = LLVMBuildLShr(g->builder, result, val2, ""); @@ -2556,6 +2559,9 @@ static LLVMValueRef gen_overflow_shl_op(CodeGen *g, ZigType *type_entry, LLVMBasicBlockRef ok_block = LLVMAppendBasicBlock(g->cur_fn_val, "OverflowOk"); LLVMBasicBlockRef fail_block = LLVMAppendBasicBlock(g->cur_fn_val, "OverflowFail"); + if (operand_type->id == ZigTypeIdVector) { + ok_bit = scalarize_cmp_result(g, ok_bit); + } LLVMBuildCondBr(g->builder, ok_bit, ok_block, fail_block); LLVMPositionBuilderAtEnd(g->builder, fail_block); @@ -2565,13 +2571,16 @@ static LLVMValueRef gen_overflow_shl_op(CodeGen *g, ZigType *type_entry, return result; } -static LLVMValueRef gen_overflow_shr_op(CodeGen *g, ZigType *type_entry, - LLVMValueRef val1, LLVMValueRef val2) +static LLVMValueRef gen_overflow_shr_op(CodeGen *g, ZigType *operand_type, + LLVMValueRef val1, LLVMValueRef val2) { - assert(type_entry->id == ZigTypeIdInt); + ZigType *scalar_type = (operand_type->id == ZigTypeIdVector) ? + operand_type->data.vector.elem_type : operand_type; + + assert(scalar_type->id == ZigTypeIdInt); LLVMValueRef result; - if (type_entry->data.integral.is_signed) { + if (scalar_type->data.integral.is_signed) { result = LLVMBuildAShr(g->builder, val1, val2, ""); } else { result = LLVMBuildLShr(g->builder, val1, val2, ""); @@ -2581,6 +2590,9 @@ static LLVMValueRef gen_overflow_shr_op(CodeGen *g, ZigType *type_entry, LLVMBasicBlockRef ok_block = LLVMAppendBasicBlock(g->cur_fn_val, "OverflowOk"); LLVMBasicBlockRef fail_block = LLVMAppendBasicBlock(g->cur_fn_val, "OverflowFail"); + if (operand_type->id == ZigTypeIdVector) { + ok_bit = scalarize_cmp_result(g, ok_bit); + } LLVMBuildCondBr(g->builder, ok_bit, ok_block, fail_block); LLVMPositionBuilderAtEnd(g->builder, fail_block); @@ -2897,11 +2909,17 @@ static void gen_shift_rhs_check(CodeGen *g, ZigType *lhs_type, ZigType *rhs_type // otherwise the check is useful as the allowed values are limited by the // operand type itself if (!is_power_of_2(lhs_type->data.integral.bit_count)) { - LLVMValueRef bit_count_value = LLVMConstInt(get_llvm_type(g, rhs_type), - lhs_type->data.integral.bit_count, false); - LLVMValueRef less_than_bit = LLVMBuildICmp(g->builder, LLVMIntULT, value, bit_count_value, ""); + BigInt bit_count_bi = {0}; + bigint_init_unsigned(&bit_count_bi, lhs_type->data.integral.bit_count); + LLVMValueRef bit_count_value = bigint_to_llvm_const(get_llvm_type(g, rhs_type), + &bit_count_bi); + LLVMBasicBlockRef fail_block = LLVMAppendBasicBlock(g->cur_fn_val, "CheckFail"); LLVMBasicBlockRef ok_block = LLVMAppendBasicBlock(g->cur_fn_val, "CheckOk"); + LLVMValueRef less_than_bit = LLVMBuildICmp(g->builder, LLVMIntULT, value, bit_count_value, ""); + if (rhs_type->id == ZigTypeIdVector) { + less_than_bit = scalarize_cmp_result(g, less_than_bit); + } LLVMBuildCondBr(g->builder, less_than_bit, ok_block, fail_block); LLVMPositionBuilderAtEnd(g->builder, fail_block); @@ -3018,7 +3036,8 @@ static LLVMValueRef ir_render_bin_op(CodeGen *g, IrExecutableGen *executable, case IrBinOpBitShiftLeftExact: { assert(scalar_type->id == ZigTypeIdInt); - LLVMValueRef op2_casted = gen_widen_or_shorten(g, false, op2->value->type, scalar_type, op2_value); + LLVMValueRef op2_casted = LLVMBuildZExt(g->builder, op2_value, + LLVMTypeOf(op1_value), "");//gen_widen_or_shorten(g, false, op2->value->type, scalar_type, op2_value); if (want_runtime_safety) { gen_shift_rhs_check(g, scalar_type, op2->value->type, op2_value); @@ -3028,7 +3047,7 @@ static LLVMValueRef ir_render_bin_op(CodeGen *g, IrExecutableGen *executable, if (is_sloppy) { return LLVMBuildShl(g->builder, op1_value, op2_casted, ""); } else if (want_runtime_safety) { - return gen_overflow_shl_op(g, scalar_type, op1_value, op2_casted); + return gen_overflow_shl_op(g, operand_type, op1_value, op2_casted); } else if (scalar_type->data.integral.is_signed) { return ZigLLVMBuildNSWShl(g->builder, op1_value, op2_casted, ""); } else { @@ -3039,7 +3058,8 @@ static LLVMValueRef ir_render_bin_op(CodeGen *g, IrExecutableGen *executable, case IrBinOpBitShiftRightExact: { assert(scalar_type->id == ZigTypeIdInt); - LLVMValueRef op2_casted = gen_widen_or_shorten(g, false, op2->value->type, scalar_type, op2_value); + LLVMValueRef op2_casted = LLVMBuildZExt(g->builder, op2_value, + LLVMTypeOf(op1_value), "");//gen_widen_or_shorten(g, false, op2->value->type, scalar_type, op2_value); if (want_runtime_safety) { gen_shift_rhs_check(g, scalar_type, op2->value->type, op2_value); @@ -3053,7 +3073,7 @@ static LLVMValueRef ir_render_bin_op(CodeGen *g, IrExecutableGen *executable, return LLVMBuildLShr(g->builder, op1_value, op2_casted, ""); } } else if (want_runtime_safety) { - return gen_overflow_shr_op(g, scalar_type, op1_value, op2_casted); + return gen_overflow_shr_op(g, operand_type, op1_value, op2_casted); } else if (scalar_type->data.integral.is_signed) { return ZigLLVMBuildAShrExact(g->builder, op1_value, op2_casted, ""); } else { diff --git a/src/ir.cpp b/src/ir.cpp index 436db592f2c536ff7befcaf3e5dcfb6119c14256..6fed044c6ce8c988b4da9d06caef889ca7b28eb6 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -283,6 +283,8 @@ static IrInstGen *ir_analyze_union_init(IrAnalyze *ira, IrInst* source_instructi IrInstGen *result_loc); static IrInstGen *ir_analyze_struct_value_field_value(IrAnalyze *ira, IrInst* source_instr, IrInstGen *struct_operand, TypeStructField *field); +static bool value_cmp_numeric_val_any(ZigValue *left, Cmp predicate, ZigValue *right); +static bool value_cmp_numeric_val_all(ZigValue *left, Cmp predicate, ZigValue *right); static void destroy_instruction_src(IrInstSrc *inst) { switch (inst->id) { @@ -16803,7 +16805,6 @@ static IrInstGen *ir_analyze_math_op(IrAnalyze *ira, IrInst* source_instr, ZigValue *scalar_op2_val = &op2_val->data.x_array.data.s_none.elements[i]; ZigValue *scalar_out_val = &out_val->data.x_array.data.s_none.elements[i]; assert(scalar_op1_val->type == scalar_type); - assert(scalar_op2_val->type == scalar_type); assert(scalar_out_val->type == scalar_type); ErrorMsg *msg = ir_eval_math_op_scalar(ira, source_instr, scalar_type, scalar_op1_val, op_id, scalar_op2_val, scalar_out_val); @@ -16828,27 +16829,49 @@ static IrInstGen *ir_analyze_bit_shift(IrAnalyze *ira, IrInstSrcBinOp *bin_op_in if (type_is_invalid(op1->value->type)) return ira->codegen->invalid_inst_gen; - if (op1->value->type->id != ZigTypeIdInt && op1->value->type->id != ZigTypeIdComptimeInt) { + IrInstGen *op2 = bin_op_instruction->op2->child; + if (type_is_invalid(op2->value->type)) + return ira->codegen->invalid_inst_gen; + + ZigType *op1_type = op1->value->type; + ZigType *op2_type = op2->value->type; + + if (op1_type->id == ZigTypeIdVector && op2_type->id != ZigTypeIdVector) { + ir_add_error(ira, &bin_op_instruction->op1->base, + buf_sprintf("bit shifting operation expected vector type, found '%s'", + buf_ptr(&op2_type->name))); + return ira->codegen->invalid_inst_gen; + } + + if (op1_type->id != ZigTypeIdVector && op2_type->id == ZigTypeIdVector) { + ir_add_error(ira, &bin_op_instruction->op1->base, + buf_sprintf("bit shifting operation expected vector type, found '%s'", + buf_ptr(&op1_type->name))); + return ira->codegen->invalid_inst_gen; + } + + ZigType *op1_scalar_type = (op1_type->id == ZigTypeIdVector) ? + op1_type->data.vector.elem_type : op1_type; + ZigType *op2_scalar_type = (op2_type->id == ZigTypeIdVector) ? + op2_type->data.vector.elem_type : op2_type; + + if (op1_scalar_type->id != ZigTypeIdInt && op1_scalar_type->id != ZigTypeIdComptimeInt) { ir_add_error(ira, &bin_op_instruction->op1->base, buf_sprintf("bit shifting operation expected integer type, found '%s'", - buf_ptr(&op1->value->type->name))); + buf_ptr(&op1_scalar_type->name))); return ira->codegen->invalid_inst_gen; } - IrInstGen *op2 = bin_op_instruction->op2->child; - if (type_is_invalid(op2->value->type)) - return ira->codegen->invalid_inst_gen; - - if (op2->value->type->id != ZigTypeIdInt && op2->value->type->id != ZigTypeIdComptimeInt) { + if (op2_scalar_type->id != ZigTypeIdInt && op2_scalar_type->id != ZigTypeIdComptimeInt) { ir_add_error(ira, &bin_op_instruction->op2->base, buf_sprintf("shift amount has to be an integer type, but found '%s'", - buf_ptr(&op2->value->type->name))); + buf_ptr(&op2_scalar_type->name))); return ira->codegen->invalid_inst_gen; } IrInstGen *casted_op2; IrBinOp op_id = bin_op_instruction->op_id; - if (op1->value->type->id == ZigTypeIdComptimeInt) { + if (op1_scalar_type->id == ZigTypeIdComptimeInt) { // comptime_int has no finite bit width casted_op2 = op2; @@ -16874,10 +16897,15 @@ static IrInstGen *ir_analyze_bit_shift(IrAnalyze *ira, IrInstSrcBinOp *bin_op_in return ira->codegen->invalid_inst_gen; } } else { - const unsigned bit_count = op1->value->type->data.integral.bit_count; + const unsigned bit_count = op1_scalar_type->data.integral.bit_count; ZigType *shift_amt_type = get_smallest_unsigned_int_type(ira->codegen, bit_count > 0 ? bit_count - 1 : 0); + if (op1_type->id == ZigTypeIdVector) { + shift_amt_type = get_vector_type(ira->codegen, op1_type->data.vector.len, + shift_amt_type); + } + casted_op2 = ir_implicit_cast(ira, op2, shift_amt_type); if (type_is_invalid(casted_op2->value->type)) return ira->codegen->invalid_inst_gen; @@ -16888,10 +16916,10 @@ static IrInstGen *ir_analyze_bit_shift(IrAnalyze *ira, IrInstSrcBinOp *bin_op_in if (op2_val == nullptr) return ira->codegen->invalid_inst_gen; - BigInt bit_count_value = {0}; - bigint_init_unsigned(&bit_count_value, bit_count); + ZigValue bit_count_value; + init_const_usize(ira->codegen, &bit_count_value, bit_count); - if (bigint_cmp(&op2_val->data.x_bigint, &bit_count_value) != CmpLT) { + if (!value_cmp_numeric_val_all(op2_val, CmpLT, &bit_count_value)) { ErrorMsg* msg = ir_add_error(ira, &bin_op_instruction->base.base, buf_sprintf("RHS of shift is too large for LHS type")); @@ -16910,7 +16938,7 @@ static IrInstGen *ir_analyze_bit_shift(IrAnalyze *ira, IrInstSrcBinOp *bin_op_in if (op2_val == nullptr) return ira->codegen->invalid_inst_gen; - if (bigint_cmp_zero(&op2_val->data.x_bigint) == CmpEQ) + if (value_cmp_numeric_val_all(op2_val, CmpEQ, nullptr)) return ir_analyze_cast(ira, &bin_op_instruction->base.base, op1->value->type, op1); } @@ -16923,7 +16951,7 @@ static IrInstGen *ir_analyze_bit_shift(IrAnalyze *ira, IrInstSrcBinOp *bin_op_in if (op2_val == nullptr) return ira->codegen->invalid_inst_gen; - return ir_analyze_math_op(ira, &bin_op_instruction->base.base, op1->value->type, op1_val, op_id, op2_val); + return ir_analyze_math_op(ira, &bin_op_instruction->base.base, op1_type, op1_val, op_id, op2_val); } return ir_build_bin_op_gen(ira, &bin_op_instruction->base.base, op1->value->type, @@ -16991,31 +17019,53 @@ static bool is_pointer_arithmetic_allowed(ZigType *lhs_type, IrBinOp op) { zig_unreachable(); } -static bool value_cmp_zero_any(ZigValue *value, Cmp predicate) { - assert(value->special == ConstValSpecialStatic); +static bool value_cmp_numeric_val(ZigValue *left, Cmp predicate, ZigValue *right, bool any) { + assert(left->special == ConstValSpecialStatic); + assert(right == nullptr || right->special == ConstValSpecialStatic); - switch (value->type->id) { + switch (left->type->id) { case ZigTypeIdComptimeInt: - case ZigTypeIdInt: - return bigint_cmp_zero(&value->data.x_bigint) == predicate; + case ZigTypeIdInt: { + const Cmp result = right ? + bigint_cmp(&left->data.x_bigint, &right->data.x_bigint) : + bigint_cmp_zero(&left->data.x_bigint); + return result == predicate; + } case ZigTypeIdComptimeFloat: - case ZigTypeIdFloat: - if (float_is_nan(value)) + case ZigTypeIdFloat: { + if (float_is_nan(left)) return false; - return float_cmp_zero(value) == predicate; + if (right != nullptr && float_is_nan(right)) + return false; + + const Cmp result = right ? float_cmp(left, right) : float_cmp_zero(left); + return result == predicate; + } case ZigTypeIdVector: { - for (size_t i = 0; i < value->type->data.vector.len; i++) { - ZigValue *scalar_val = &value->data.x_array.data.s_none.elements[i]; - if (!value_cmp_zero_any(scalar_val, predicate)) - return true; + for (size_t i = 0; i < left->type->data.vector.len; i++) { + ZigValue *scalar_val = &left->data.x_array.data.s_none.elements[i]; + const bool result = value_cmp_numeric_val(scalar_val, predicate, right, any); + + if (any && result) + return true; // This element satisfies the predicate + else if (!any && !result) + return false; // This element doesn't satisfy the predicate } - return false; + return any ? false : true; } default: zig_unreachable(); } } +static bool value_cmp_numeric_val_any(ZigValue *left, Cmp predicate, ZigValue *right) { + return value_cmp_numeric_val(left, predicate, right, true); +} + +static bool value_cmp_numeric_val_all(ZigValue *left, Cmp predicate, ZigValue *right) { + return value_cmp_numeric_val(left, predicate, right, false); +} + static IrInstGen *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstSrcBinOp *instruction) { Error err; @@ -17165,8 +17215,8 @@ static IrInstGen *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstSrcBinOp *instruc return ira->codegen->invalid_inst_gen; // Promote division with negative numbers to signed - bool is_signed_div = value_cmp_zero_any(op1_val, CmpLT) || - value_cmp_zero_any(op2_val, CmpLT); + bool is_signed_div = value_cmp_numeric_val_any(op1_val, CmpLT, nullptr) || + value_cmp_numeric_val_any(op2_val, CmpLT, nullptr); if (op_id == IrBinOpDivUnspecified && is_int) { // Default to truncating division and check if it's valid for the @@ -17176,7 +17226,7 @@ static IrInstGen *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstSrcBinOp *instruc if (is_signed_div) { bool ok = false; - if (value_cmp_zero_any(op2_val, CmpEQ)) { + if (value_cmp_numeric_val_any(op2_val, CmpEQ, nullptr)) { // the division by zero error will be caught later, but we don't have a // division function ambiguity problem. ok = true; @@ -17215,7 +17265,7 @@ static IrInstGen *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstSrcBinOp *instruc if (is_signed_div) { bool ok = false; - if (value_cmp_zero_any(op2_val, CmpEQ)) { + if (value_cmp_numeric_val_any(op2_val, CmpEQ, nullptr)) { // the division by zero error will be caught later, but we don't have a // division function ambiguity problem. ok = true; diff --git a/test/stage1/behavior/vector.zig b/test/stage1/behavior/vector.zig index f242aa0fbff2a2d5f48529f92a92e3ab6e3d7399..f3bc334b84af3e34f736af0108750ef050af3009 100644 --- a/test/stage1/behavior/vector.zig +++ b/test/stage1/behavior/vector.zig @@ -1,5 +1,6 @@ const std = @import("std"); const mem = std.mem; +const math = std.math; const expect = std.testing.expect; const expectEqual = std.testing.expectEqual; @@ -376,3 +377,67 @@ test "vector bitwise not operator" { S.doTheTest(); comptime S.doTheTest(); } + +test "vector shift operators" { + const S = struct { + fn doTheTestShift(x: var, y: var) void { + const N = @typeInfo(@TypeOf(x)).Array.len; + const TX = @typeInfo(@TypeOf(x)).Array.child; + const TY = @typeInfo(@TypeOf(y)).Array.child; + + var xv = @as(@Vector(N, TX), x); + var yv = @as(@Vector(N, TY), y); + + var z0 = xv >> yv; + for (@as([N]TX, z0)) |v, i| { + expectEqual(x[i] >> y[i], v); + } + var z1 = xv << yv; + for (@as([N]TX, z1)) |v, i| { + expectEqual(x[i] << y[i], v); + } + } + fn doTheTestShiftExact(x: var, y: var, dir: enum { Left, Right }) void { + const N = @typeInfo(@TypeOf(x)).Array.len; + const TX = @typeInfo(@TypeOf(x)).Array.child; + const TY = @typeInfo(@TypeOf(y)).Array.child; + + var xv = @as(@Vector(N, TX), x); + var yv = @as(@Vector(N, TY), y); + + var z = if (dir == .Left) @shlExact(xv, yv) else @shrExact(xv, yv); + for (@as([N]TX, z)) |v, i| { + const check = if (dir == .Left) x[i] << y[i] else x[i] >> y[i]; + expectEqual(check, v); + } + } + fn doTheTest() void { + doTheTestShift([_]u8{ 0, 2, 4, math.maxInt(u8) }, [_]u3{ 2, 0, 2, 7 }); + doTheTestShift([_]u16{ 0, 2, 4, math.maxInt(u16) }, [_]u4{ 2, 0, 2, 15 }); + doTheTestShift([_]u24{ 0, 2, 4, math.maxInt(u24) }, [_]u5{ 2, 0, 2, 23 }); + doTheTestShift([_]u32{ 0, 2, 4, math.maxInt(u32) }, [_]u5{ 2, 0, 2, 31 }); + doTheTestShift([_]u64{ 0xfe, math.maxInt(u64) }, [_]u6{ 0, 63 }); + + doTheTestShift([_]i8{ 0, 2, 4, math.maxInt(i8) }, [_]u3{ 2, 0, 2, 7 }); + doTheTestShift([_]i16{ 0, 2, 4, math.maxInt(i16) }, [_]u4{ 2, 0, 2, 7 }); + doTheTestShift([_]i24{ 0, 2, 4, math.maxInt(i24) }, [_]u5{ 2, 0, 2, 7 }); + doTheTestShift([_]i32{ 0, 2, 4, math.maxInt(i32) }, [_]u5{ 2, 0, 2, 7 }); + doTheTestShift([_]i64{ 0xfe, math.maxInt(i64) }, [_]u6{ 0, 63 }); + + doTheTestShiftExact([_]u8{ 0, 1, 1 << 7, math.maxInt(u8) ^ 1 }, [_]u3{ 4, 0, 7, 1 }, .Right); + doTheTestShiftExact([_]u16{ 0, 1, 1 << 15, math.maxInt(u16) ^ 1 }, [_]u4{ 4, 0, 15, 1 }, .Right); + doTheTestShiftExact([_]u24{ 0, 1, 1 << 23, math.maxInt(u24) ^ 1 }, [_]u5{ 4, 0, 23, 1 }, .Right); + doTheTestShiftExact([_]u32{ 0, 1, 1 << 31, math.maxInt(u32) ^ 1 }, [_]u5{ 4, 0, 31, 1 }, .Right); + doTheTestShiftExact([_]u64{ 1 << 63, 1 }, [_]u6{ 63, 0 }, .Right); + + doTheTestShiftExact([_]u8{ 0, 1, 1, math.maxInt(u8) ^ (1 << 7) }, [_]u3{ 4, 0, 7, 1 }, .Left); + doTheTestShiftExact([_]u16{ 0, 1, 1, math.maxInt(u16) ^ (1 << 15) }, [_]u4{ 4, 0, 15, 1 }, .Left); + doTheTestShiftExact([_]u24{ 0, 1, 1, math.maxInt(u24) ^ (1 << 23) }, [_]u5{ 4, 0, 23, 1 }, .Left); + doTheTestShiftExact([_]u32{ 0, 1, 1, math.maxInt(u32) ^ (1 << 31) }, [_]u5{ 4, 0, 31, 1 }, .Left); + doTheTestShiftExact([_]u64{ 1 << 63, 1 }, [_]u6{ 0, 63 }, .Left); + } + }; + + S.doTheTest(); + comptime S.doTheTest(); +} -- 2.54.0 From eff7555d5d62fc8c701529a9540fb296646d348e Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Sat, 14 Mar 2020 20:01:42 +0100 Subject: [PATCH 44/91] std: Delete a hack in the feature set code Now that bitwise not works on vectors we can simplify the code. --- lib/std/target.zig | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/std/target.zig b/lib/std/target.zig index 3f18791eb96808d95f6708f13c443db112c56778..f920845d0def308a5910fceec364a3de4de9083d 100644 --- a/lib/std/target.zig +++ b/lib/std/target.zig @@ -501,11 +501,8 @@ pub const Target = struct { /// Removes the specified feature but not its dependents. pub fn removeFeatureSet(set: *Set, other_set: Set) void { - // TODO should be able to use binary not on @Vector type. - // https://github.com/ziglang/zig/issues/903 - for (set.ints) |*int, i| { - int.* &= ~other_set.ints[i]; - } + set.ints = @as(@Vector(usize_count, usize), set.ints) & + ~@as(@Vector(usize_count, usize), other_set.ints); } pub fn populateDependencies(set: *Set, all_features_list: []const Cpu.Feature) void { -- 2.54.0 From fe77c38247a8869719579f911bf2775f00462330 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Tue, 24 Mar 2020 18:58:53 +0100 Subject: [PATCH 45/91] ir: Remove unused and commented out code --- src/codegen.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/codegen.cpp b/src/codegen.cpp index 97d960b5230bc17853479ebe25e57306ec9e5c37..e7fff882c375b01607cf84e48bfe3e9431000cdf 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -3037,7 +3037,7 @@ static LLVMValueRef ir_render_bin_op(CodeGen *g, IrExecutableGen *executable, { assert(scalar_type->id == ZigTypeIdInt); LLVMValueRef op2_casted = LLVMBuildZExt(g->builder, op2_value, - LLVMTypeOf(op1_value), "");//gen_widen_or_shorten(g, false, op2->value->type, scalar_type, op2_value); + LLVMTypeOf(op1_value), ""); if (want_runtime_safety) { gen_shift_rhs_check(g, scalar_type, op2->value->type, op2_value); @@ -3059,7 +3059,7 @@ static LLVMValueRef ir_render_bin_op(CodeGen *g, IrExecutableGen *executable, { assert(scalar_type->id == ZigTypeIdInt); LLVMValueRef op2_casted = LLVMBuildZExt(g->builder, op2_value, - LLVMTypeOf(op1_value), "");//gen_widen_or_shorten(g, false, op2->value->type, scalar_type, op2_value); + LLVMTypeOf(op1_value), ""); if (want_runtime_safety) { gen_shift_rhs_check(g, scalar_type, op2->value->type, op2_value); -- 2.54.0 From 91a8e3b47bef12727dc6d9e0dfe378f81375c794 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Tue, 24 Mar 2020 18:59:03 +0100 Subject: [PATCH 46/91] tests: Chop away some flaky tests --- test/stage1/behavior/vector.zig | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/test/stage1/behavior/vector.zig b/test/stage1/behavior/vector.zig index f3bc334b84af3e34f736af0108750ef050af3009..7e8eb6a42e0ea6be3b06fa3ee967f29196e149aa 100644 --- a/test/stage1/behavior/vector.zig +++ b/test/stage1/behavior/vector.zig @@ -319,11 +319,13 @@ test "vector division operators" { } fn doTheTest() void { - doTheTestDiv(f16, [4]f16{ 4.0, -4.0, 4.0, -4.0 }, [4]f16{ 1.0, 2.0, -1.0, -2.0 }); + if (std.builtin.os.tag != .windows) + doTheTestDiv(f16, [4]f16{ 4.0, -4.0, 4.0, -4.0 }, [4]f16{ 1.0, 2.0, -1.0, -2.0 }); doTheTestDiv(f32, [4]f32{ 4.0, -4.0, 4.0, -4.0 }, [4]f32{ 1.0, 2.0, -1.0, -2.0 }); doTheTestDiv(f64, [4]f64{ 4.0, -4.0, 4.0, -4.0 }, [4]f64{ 1.0, 2.0, -1.0, -2.0 }); - doTheTestMod(f16, [4]f16{ 4.0, -4.0, 4.0, -4.0 }, [4]f16{ 1.0, 2.0, 0.5, 3.0 }); + if (std.builtin.os.tag != .windows) + doTheTestMod(f16, [4]f16{ 4.0, -4.0, 4.0, -4.0 }, [4]f16{ 1.0, 2.0, 0.5, 3.0 }); doTheTestMod(f32, [4]f32{ 4.0, -4.0, 4.0, -4.0 }, [4]f32{ 1.0, 2.0, 0.5, 3.0 }); doTheTestMod(f64, [4]f64{ 4.0, -4.0, 4.0, -4.0 }, [4]f64{ 1.0, 2.0, 0.5, 3.0 }); @@ -412,27 +414,37 @@ test "vector shift operators" { } } fn doTheTest() void { + const is32 = @sizeOf(usize) < 8; + doTheTestShift([_]u8{ 0, 2, 4, math.maxInt(u8) }, [_]u3{ 2, 0, 2, 7 }); doTheTestShift([_]u16{ 0, 2, 4, math.maxInt(u16) }, [_]u4{ 2, 0, 2, 15 }); - doTheTestShift([_]u24{ 0, 2, 4, math.maxInt(u24) }, [_]u5{ 2, 0, 2, 23 }); - doTheTestShift([_]u32{ 0, 2, 4, math.maxInt(u32) }, [_]u5{ 2, 0, 2, 31 }); + if (!is32) { + doTheTestShift([_]u24{ 0, 2, 4, math.maxInt(u24) }, [_]u5{ 2, 0, 2, 23 }); + doTheTestShift([_]u32{ 0, 2, 4, math.maxInt(u32) }, [_]u5{ 2, 0, 2, 31 }); + } doTheTestShift([_]u64{ 0xfe, math.maxInt(u64) }, [_]u6{ 0, 63 }); doTheTestShift([_]i8{ 0, 2, 4, math.maxInt(i8) }, [_]u3{ 2, 0, 2, 7 }); doTheTestShift([_]i16{ 0, 2, 4, math.maxInt(i16) }, [_]u4{ 2, 0, 2, 7 }); - doTheTestShift([_]i24{ 0, 2, 4, math.maxInt(i24) }, [_]u5{ 2, 0, 2, 7 }); - doTheTestShift([_]i32{ 0, 2, 4, math.maxInt(i32) }, [_]u5{ 2, 0, 2, 7 }); + if (!is32) { + doTheTestShift([_]i24{ 0, 2, 4, math.maxInt(i24) }, [_]u5{ 2, 0, 2, 7 }); + doTheTestShift([_]i32{ 0, 2, 4, math.maxInt(i32) }, [_]u5{ 2, 0, 2, 7 }); + } doTheTestShift([_]i64{ 0xfe, math.maxInt(i64) }, [_]u6{ 0, 63 }); doTheTestShiftExact([_]u8{ 0, 1, 1 << 7, math.maxInt(u8) ^ 1 }, [_]u3{ 4, 0, 7, 1 }, .Right); doTheTestShiftExact([_]u16{ 0, 1, 1 << 15, math.maxInt(u16) ^ 1 }, [_]u4{ 4, 0, 15, 1 }, .Right); - doTheTestShiftExact([_]u24{ 0, 1, 1 << 23, math.maxInt(u24) ^ 1 }, [_]u5{ 4, 0, 23, 1 }, .Right); + if (!is32) { + doTheTestShiftExact([_]u24{ 0, 1, 1 << 23, math.maxInt(u24) ^ 1 }, [_]u5{ 4, 0, 23, 1 }, .Right); + } doTheTestShiftExact([_]u32{ 0, 1, 1 << 31, math.maxInt(u32) ^ 1 }, [_]u5{ 4, 0, 31, 1 }, .Right); doTheTestShiftExact([_]u64{ 1 << 63, 1 }, [_]u6{ 63, 0 }, .Right); doTheTestShiftExact([_]u8{ 0, 1, 1, math.maxInt(u8) ^ (1 << 7) }, [_]u3{ 4, 0, 7, 1 }, .Left); doTheTestShiftExact([_]u16{ 0, 1, 1, math.maxInt(u16) ^ (1 << 15) }, [_]u4{ 4, 0, 15, 1 }, .Left); - doTheTestShiftExact([_]u24{ 0, 1, 1, math.maxInt(u24) ^ (1 << 23) }, [_]u5{ 4, 0, 23, 1 }, .Left); + if (!is32) { + doTheTestShiftExact([_]u24{ 0, 1, 1, math.maxInt(u24) ^ (1 << 23) }, [_]u5{ 4, 0, 23, 1 }, .Left); + } doTheTestShiftExact([_]u32{ 0, 1, 1, math.maxInt(u32) ^ (1 << 31) }, [_]u5{ 4, 0, 31, 1 }, .Left); doTheTestShiftExact([_]u64{ 1 << 63, 1 }, [_]u6{ 0, 63 }, .Left); } -- 2.54.0 From 0f964e19109d44d039fbefa691657ca82c7bbe52 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Thu, 2 Apr 2020 10:25:08 +0200 Subject: [PATCH 47/91] I'm getting tired of this shit LLVM --- test/stage1/behavior/vector.zig | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/test/stage1/behavior/vector.zig b/test/stage1/behavior/vector.zig index 7e8eb6a42e0ea6be3b06fa3ee967f29196e149aa..15ecd004e10e851a7ddf6a984c5e75f2d2aa80c8 100644 --- a/test/stage1/behavior/vector.zig +++ b/test/stage1/behavior/vector.zig @@ -414,42 +414,36 @@ test "vector shift operators" { } } fn doTheTest() void { - const is32 = @sizeOf(usize) < 8; - doTheTestShift([_]u8{ 0, 2, 4, math.maxInt(u8) }, [_]u3{ 2, 0, 2, 7 }); doTheTestShift([_]u16{ 0, 2, 4, math.maxInt(u16) }, [_]u4{ 2, 0, 2, 15 }); - if (!is32) { - doTheTestShift([_]u24{ 0, 2, 4, math.maxInt(u24) }, [_]u5{ 2, 0, 2, 23 }); - doTheTestShift([_]u32{ 0, 2, 4, math.maxInt(u32) }, [_]u5{ 2, 0, 2, 31 }); - } + doTheTestShift([_]u24{ 0, 2, 4, math.maxInt(u24) }, [_]u5{ 2, 0, 2, 23 }); + doTheTestShift([_]u32{ 0, 2, 4, math.maxInt(u32) }, [_]u5{ 2, 0, 2, 31 }); doTheTestShift([_]u64{ 0xfe, math.maxInt(u64) }, [_]u6{ 0, 63 }); doTheTestShift([_]i8{ 0, 2, 4, math.maxInt(i8) }, [_]u3{ 2, 0, 2, 7 }); doTheTestShift([_]i16{ 0, 2, 4, math.maxInt(i16) }, [_]u4{ 2, 0, 2, 7 }); - if (!is32) { - doTheTestShift([_]i24{ 0, 2, 4, math.maxInt(i24) }, [_]u5{ 2, 0, 2, 7 }); - doTheTestShift([_]i32{ 0, 2, 4, math.maxInt(i32) }, [_]u5{ 2, 0, 2, 7 }); - } + doTheTestShift([_]i24{ 0, 2, 4, math.maxInt(i24) }, [_]u5{ 2, 0, 2, 7 }); + doTheTestShift([_]i32{ 0, 2, 4, math.maxInt(i32) }, [_]u5{ 2, 0, 2, 7 }); doTheTestShift([_]i64{ 0xfe, math.maxInt(i64) }, [_]u6{ 0, 63 }); doTheTestShiftExact([_]u8{ 0, 1, 1 << 7, math.maxInt(u8) ^ 1 }, [_]u3{ 4, 0, 7, 1 }, .Right); doTheTestShiftExact([_]u16{ 0, 1, 1 << 15, math.maxInt(u16) ^ 1 }, [_]u4{ 4, 0, 15, 1 }, .Right); - if (!is32) { - doTheTestShiftExact([_]u24{ 0, 1, 1 << 23, math.maxInt(u24) ^ 1 }, [_]u5{ 4, 0, 23, 1 }, .Right); - } + doTheTestShiftExact([_]u24{ 0, 1, 1 << 23, math.maxInt(u24) ^ 1 }, [_]u5{ 4, 0, 23, 1 }, .Right); doTheTestShiftExact([_]u32{ 0, 1, 1 << 31, math.maxInt(u32) ^ 1 }, [_]u5{ 4, 0, 31, 1 }, .Right); doTheTestShiftExact([_]u64{ 1 << 63, 1 }, [_]u6{ 63, 0 }, .Right); doTheTestShiftExact([_]u8{ 0, 1, 1, math.maxInt(u8) ^ (1 << 7) }, [_]u3{ 4, 0, 7, 1 }, .Left); doTheTestShiftExact([_]u16{ 0, 1, 1, math.maxInt(u16) ^ (1 << 15) }, [_]u4{ 4, 0, 15, 1 }, .Left); - if (!is32) { - doTheTestShiftExact([_]u24{ 0, 1, 1, math.maxInt(u24) ^ (1 << 23) }, [_]u5{ 4, 0, 23, 1 }, .Left); - } + doTheTestShiftExact([_]u24{ 0, 1, 1, math.maxInt(u24) ^ (1 << 23) }, [_]u5{ 4, 0, 23, 1 }, .Left); doTheTestShiftExact([_]u32{ 0, 1, 1, math.maxInt(u32) ^ (1 << 31) }, [_]u5{ 4, 0, 31, 1 }, .Left); doTheTestShiftExact([_]u64{ 1 << 63, 1 }, [_]u6{ 0, 63 }, .Left); } }; + // LLVM miscompiles pretty much every case on other architectures so don't + // even bother running this test + if (std.builtin.arch != .x86_64) return error.SkipZigTest; + S.doTheTest(); comptime S.doTheTest(); } -- 2.54.0 From f6cdc94a50235eaf145f6c2c2ec257008d592494 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Sun, 5 Apr 2020 10:40:41 +0200 Subject: [PATCH 48/91] ir: Fix error checking for vector ops The extra logic that's needed was lost during a refactoring, now it should be fine. --- src/codegen.cpp | 59 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 20 deletions(-) diff --git a/src/codegen.cpp b/src/codegen.cpp index e7fff882c375b01607cf84e48bfe3e9431000cdf..a2cd5fafc01168671abc8ad4821072adb5934bf5 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -155,7 +155,6 @@ static LLVMValueRef gen_await_early_return(CodeGen *g, IrInstGen *source_instr, LLVMValueRef target_frame_ptr, ZigType *result_type, ZigType *ptr_result_type, LLVMValueRef result_loc, bool non_async); static Error get_tmp_filename(CodeGen *g, Buf *out, Buf *suffix); -static LLVMValueRef scalarize_cmp_result(CodeGen *g, LLVMValueRef val); static void addLLVMAttr(LLVMValueRef val, LLVMAttributeIndex attr_index, const char *attr_name) { unsigned kind_id = LLVMGetEnumAttributeKindForName(attr_name, strlen(attr_name)); @@ -2536,6 +2535,36 @@ static LLVMValueRef ir_render_return(CodeGen *g, IrExecutableGen *executable, Ir return nullptr; } +enum class ScalarizePredicate { + // Returns true iff all the elements in the vector are 1. + // Equivalent to folding all the bits with `and`. + All, + // Returns true iff there's at least one element in the vector that is 1. + // Equivalent to folding all the bits with `or`. + Any, +}; + +// Collapses a vector into a single i1 according to the given predicate +static LLVMValueRef scalarize_cmp_result(CodeGen *g, LLVMValueRef val, ScalarizePredicate predicate) { + assert(LLVMGetTypeKind(LLVMTypeOf(val)) == LLVMVectorTypeKind); + LLVMTypeRef scalar_type = LLVMIntType(LLVMGetVectorSize(LLVMTypeOf(val))); + LLVMValueRef casted = LLVMBuildBitCast(g->builder, val, scalar_type, ""); + + switch (predicate) { + case ScalarizePredicate::Any: { + LLVMValueRef all_zeros = LLVMConstNull(scalar_type); + return LLVMBuildICmp(g->builder, LLVMIntNE, casted, all_zeros, ""); + } + case ScalarizePredicate::All: { + LLVMValueRef all_ones = LLVMConstAllOnes(scalar_type); + return LLVMBuildICmp(g->builder, LLVMIntEQ, casted, all_ones, ""); + } + } + + zig_unreachable(); +} + + static LLVMValueRef gen_overflow_shl_op(CodeGen *g, ZigType *operand_type, LLVMValueRef val1, LLVMValueRef val2) { @@ -2560,7 +2589,7 @@ static LLVMValueRef gen_overflow_shl_op(CodeGen *g, ZigType *operand_type, LLVMBasicBlockRef ok_block = LLVMAppendBasicBlock(g->cur_fn_val, "OverflowOk"); LLVMBasicBlockRef fail_block = LLVMAppendBasicBlock(g->cur_fn_val, "OverflowFail"); if (operand_type->id == ZigTypeIdVector) { - ok_bit = scalarize_cmp_result(g, ok_bit); + ok_bit = scalarize_cmp_result(g, ok_bit, ScalarizePredicate::All); } LLVMBuildCondBr(g->builder, ok_bit, ok_block, fail_block); @@ -2591,7 +2620,7 @@ static LLVMValueRef gen_overflow_shr_op(CodeGen *g, ZigType *operand_type, LLVMBasicBlockRef ok_block = LLVMAppendBasicBlock(g->cur_fn_val, "OverflowOk"); LLVMBasicBlockRef fail_block = LLVMAppendBasicBlock(g->cur_fn_val, "OverflowFail"); if (operand_type->id == ZigTypeIdVector) { - ok_bit = scalarize_cmp_result(g, ok_bit); + ok_bit = scalarize_cmp_result(g, ok_bit, ScalarizePredicate::All); } LLVMBuildCondBr(g->builder, ok_bit, ok_block, fail_block); @@ -2647,16 +2676,6 @@ static LLVMValueRef bigint_to_llvm_const(LLVMTypeRef type_ref, BigInt *bigint) { } } -// Collapses a vector into a single i1 whose value is 1 iff all the -// vector elements are 1 -static LLVMValueRef scalarize_cmp_result(CodeGen *g, LLVMValueRef val) { - assert(LLVMGetTypeKind(LLVMTypeOf(val)) == LLVMVectorTypeKind); - LLVMTypeRef scalar_type = LLVMIntType(LLVMGetVectorSize(LLVMTypeOf(val))); - LLVMValueRef all_ones = LLVMConstAllOnes(scalar_type); - LLVMValueRef casted = LLVMBuildBitCast(g->builder, val, scalar_type, ""); - return LLVMBuildICmp(g->builder, LLVMIntEQ, casted, all_ones, ""); -} - static LLVMValueRef gen_div(CodeGen *g, bool want_runtime_safety, bool want_fast_math, LLVMValueRef val1, LLVMValueRef val2, ZigType *operand_type, DivKind div_kind) { @@ -2678,7 +2697,7 @@ static LLVMValueRef gen_div(CodeGen *g, bool want_runtime_safety, bool want_fast } if (operand_type->id == ZigTypeIdVector) { - is_zero_bit = scalarize_cmp_result(g, is_zero_bit); + is_zero_bit = scalarize_cmp_result(g, is_zero_bit, ScalarizePredicate::Any); } LLVMBasicBlockRef div_zero_fail_block = LLVMAppendBasicBlock(g->cur_fn_val, "DivZeroFail"); @@ -2703,7 +2722,7 @@ static LLVMValueRef gen_div(CodeGen *g, bool want_runtime_safety, bool want_fast LLVMValueRef den_is_neg_1 = LLVMBuildICmp(g->builder, LLVMIntEQ, val2, neg_1_value, ""); LLVMValueRef overflow_fail_bit = LLVMBuildAnd(g->builder, num_is_int_min, den_is_neg_1, ""); if (operand_type->id == ZigTypeIdVector) { - overflow_fail_bit = scalarize_cmp_result(g, overflow_fail_bit); + overflow_fail_bit = scalarize_cmp_result(g, overflow_fail_bit, ScalarizePredicate::Any); } LLVMBuildCondBr(g->builder, overflow_fail_bit, overflow_fail_block, overflow_ok_block); @@ -2728,7 +2747,7 @@ static LLVMValueRef gen_div(CodeGen *g, bool want_runtime_safety, bool want_fast LLVMBasicBlockRef fail_block = LLVMAppendBasicBlock(g->cur_fn_val, "DivExactFail"); LLVMValueRef ok_bit = LLVMBuildFCmp(g->builder, LLVMRealOEQ, floored, result, ""); if (operand_type->id == ZigTypeIdVector) { - ok_bit = scalarize_cmp_result(g, ok_bit); + ok_bit = scalarize_cmp_result(g, ok_bit, ScalarizePredicate::All); } LLVMBuildCondBr(g->builder, ok_bit, ok_block, fail_block); @@ -2745,7 +2764,7 @@ static LLVMValueRef gen_div(CodeGen *g, bool want_runtime_safety, bool want_fast LLVMBasicBlockRef end_block = LLVMAppendBasicBlock(g->cur_fn_val, "DivTruncEnd"); LLVMValueRef ltz = LLVMBuildFCmp(g->builder, LLVMRealOLT, val1, zero, ""); if (operand_type->id == ZigTypeIdVector) { - ltz = scalarize_cmp_result(g, ltz); + ltz = scalarize_cmp_result(g, ltz, ScalarizePredicate::Any); } LLVMBuildCondBr(g->builder, ltz, ltz_block, gez_block); @@ -2797,7 +2816,7 @@ static LLVMValueRef gen_div(CodeGen *g, bool want_runtime_safety, bool want_fast LLVMBasicBlockRef fail_block = LLVMAppendBasicBlock(g->cur_fn_val, "DivExactFail"); LLVMValueRef ok_bit = LLVMBuildICmp(g->builder, LLVMIntEQ, remainder_val, zero, ""); if (operand_type->id == ZigTypeIdVector) { - ok_bit = scalarize_cmp_result(g, ok_bit); + ok_bit = scalarize_cmp_result(g, ok_bit, ScalarizePredicate::All); } LLVMBuildCondBr(g->builder, ok_bit, ok_block, fail_block); @@ -2861,7 +2880,7 @@ static LLVMValueRef gen_rem(CodeGen *g, bool want_runtime_safety, bool want_fast } if (operand_type->id == ZigTypeIdVector) { - is_zero_bit = scalarize_cmp_result(g, is_zero_bit); + is_zero_bit = scalarize_cmp_result(g, is_zero_bit, ScalarizePredicate::Any); } LLVMBasicBlockRef rem_zero_ok_block = LLVMAppendBasicBlock(g->cur_fn_val, "RemZeroOk"); @@ -2918,7 +2937,7 @@ static void gen_shift_rhs_check(CodeGen *g, ZigType *lhs_type, ZigType *rhs_type LLVMBasicBlockRef ok_block = LLVMAppendBasicBlock(g->cur_fn_val, "CheckOk"); LLVMValueRef less_than_bit = LLVMBuildICmp(g->builder, LLVMIntULT, value, bit_count_value, ""); if (rhs_type->id == ZigTypeIdVector) { - less_than_bit = scalarize_cmp_result(g, less_than_bit); + less_than_bit = scalarize_cmp_result(g, less_than_bit, ScalarizePredicate::Any); } LLVMBuildCondBr(g->builder, less_than_bit, ok_block, fail_block); -- 2.54.0 From 5597b11a527b4495bcb3001211e6ee3923c00f87 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 5 Apr 2020 17:44:34 -0400 Subject: [PATCH 49/91] add runtime safety tests for SIMD integer division --- test/runtime_safety.zig | 43 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/test/runtime_safety.zig b/test/runtime_safety.zig index b8ab47ddac99765eff724efdd91b368ace5c6f47..f0c83049dac45ec52168280f5c94f285dba1f75f 100644 --- a/test/runtime_safety.zig +++ b/test/runtime_safety.zig @@ -505,6 +505,21 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\} ); + cases.addRuntimeSafety("signed integer division overflow - vectors", + \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn { + \\ @import("std").os.exit(126); + \\} + \\pub fn main() !void { + \\ var a: @Vector(4, i16) = [_]i16{ 1, 2, -32768, 4 }; + \\ var b: @Vector(4, i16) = [_]i16{ 1, 2, -1, 4 }; + \\ const x = div(a, b); + \\ if (x[2] == 32767) return error.Whatever; + \\} + \\fn div(a: @Vector(4, i16), b: @Vector(4, i16)) @Vector(4, i16) { + \\ return @divTrunc(a, b); + \\} + ); + cases.addRuntimeSafety("signed shift left overflow", \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn { \\ @import("std").os.exit(126); @@ -569,6 +584,20 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\} ); + cases.addRuntimeSafety("integer division by zero - vectors", + \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn { + \\ @import("std").os.exit(126); + \\} + \\pub fn main() void { + \\ var a: @Vector(4, i32) = [4]i32{111, 222, 333, 444}; + \\ var b: @Vector(4, i32) = [4]i32{111, 0, 333, 444}; + \\ const x = div0(a, b); + \\} + \\fn div0(a: @Vector(4, i32), b: @Vector(4, i32)) @Vector(4, i32) { + \\ return @divTrunc(a, b); + \\} + ); + cases.addRuntimeSafety("exact division failure", \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn { \\ @import("std").os.exit(126); @@ -582,6 +611,20 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\} ); + cases.addRuntimeSafety("exact division failure - vectors", + \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn { + \\ @import("std").os.exit(126); + \\} + \\pub fn main() !void { + \\ var a: @Vector(4, i32) = [4]i32{111, 222, 333, 444}; + \\ var b: @Vector(4, i32) = [4]i32{111, 222, 333, 441}; + \\ const x = divExact(a, b); + \\} + \\fn divExact(a: @Vector(4, i32), b: @Vector(4, i32)) @Vector(4, i32) { + \\ return @divExact(a, b); + \\} + ); + cases.addRuntimeSafety("cast []u8 to bigger slice of wrong size", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { -- 2.54.0 From e84b9b70ff2814d6e50a851dc9f094b15399d2fe Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 5 Apr 2020 18:33:47 -0400 Subject: [PATCH 50/91] annotate disabled tests with github issue links --- test/stage1/behavior/vector.zig | 34 ++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/test/stage1/behavior/vector.zig b/test/stage1/behavior/vector.zig index 15ecd004e10e851a7ddf6a984c5e75f2d2aa80c8..1d175de22ff05dab553a74e9b8b655753400d37f 100644 --- a/test/stage1/behavior/vector.zig +++ b/test/stage1/behavior/vector.zig @@ -319,13 +319,18 @@ test "vector division operators" { } fn doTheTest() void { - if (std.builtin.os.tag != .windows) + // https://github.com/ziglang/zig/issues/4952 + if (std.builtin.os.tag != .windows) { doTheTestDiv(f16, [4]f16{ 4.0, -4.0, 4.0, -4.0 }, [4]f16{ 1.0, 2.0, -1.0, -2.0 }); + } + doTheTestDiv(f32, [4]f32{ 4.0, -4.0, 4.0, -4.0 }, [4]f32{ 1.0, 2.0, -1.0, -2.0 }); doTheTestDiv(f64, [4]f64{ 4.0, -4.0, 4.0, -4.0 }, [4]f64{ 1.0, 2.0, -1.0, -2.0 }); - if (std.builtin.os.tag != .windows) + // https://github.com/ziglang/zig/issues/4952 + if (std.builtin.os.tag != .windows) { doTheTestMod(f16, [4]f16{ 4.0, -4.0, 4.0, -4.0 }, [4]f16{ 1.0, 2.0, 0.5, 3.0 }); + } doTheTestMod(f32, [4]f32{ 4.0, -4.0, 4.0, -4.0 }, [4]f32{ 1.0, 2.0, 0.5, 3.0 }); doTheTestMod(f64, [4]f64{ 4.0, -4.0, 4.0, -4.0 }, [4]f64{ 1.0, 2.0, 0.5, 3.0 }); @@ -440,9 +445,28 @@ test "vector shift operators" { } }; - // LLVM miscompiles pretty much every case on other architectures so don't - // even bother running this test - if (std.builtin.arch != .x86_64) return error.SkipZigTest; + switch (std.builtin.arch) { + .i386, + .aarch64, + .aarch64_be, + .aarch64_32, + .arm, + .armeb, + .thumb, + .thumbeb, + .mips, + .mipsel, + .mips64, + .mips64el, + .riscv64, + .sparcv9, + => { + // LLVM miscompiles on this architecture + // https://github.com/ziglang/zig/issues/4951 + return error.SkipZigTest; + }, + else => {}, + } S.doTheTest(); comptime S.doTheTest(); -- 2.54.0 From cb98984ae6fa73ab3e4ad660af272d8604f513fa Mon Sep 17 00:00:00 2001 From: Benjamin Feng Date: Sun, 5 Apr 2020 12:26:26 -0500 Subject: [PATCH 51/91] Generate clearer size mismatch error message --- lib/std/mem.zig | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/std/mem.zig b/lib/std/mem.zig index f3220ba9fe2349fdae4c4179d15546c88469652b..a21626e3a1c57e61b5f6e70ad5f749796a4aed77 100644 --- a/lib/std/mem.zig +++ b/lib/std/mem.zig @@ -501,7 +501,7 @@ pub const toSlice = @compileError("deprecated; use std.mem.spanZ"); /// the constness of the input type. `[*c]` pointers are assumed to be 0-terminated, /// and assumed to not allow null. pub fn Span(comptime T: type) type { - switch(@typeInfo(T)) { + switch (@typeInfo(T)) { .Optional => |optional_info| { return ?Span(optional_info.child); }, @@ -1758,7 +1758,8 @@ fn BytesAsValueReturnType(comptime T: type, comptime B: type) type { if (comptime !trait.is(.Pointer)(B) or (meta.Child(B) != [size]u8 and meta.Child(B) != [size:0]u8)) { - @compileError("expected *[N]u8 " ++ ", passed " ++ @typeName(B)); + comptime var buf: [100]u8 = undefined; + @compileError(std.fmt.bufPrint(&buf, "expected *[{}]u8, passed " ++ @typeName(B), .{size}) catch unreachable); } const alignment = comptime meta.alignment(B); -- 2.54.0 From 28d96966174e0cd38133ca2885240c9825a384f9 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 5 Apr 2020 19:32:37 -0400 Subject: [PATCH 52/91] use mingw-w64 to provide -luuid if requested --- lib/libc/mingw/libsrc/ativscp-uuid.c | 16 + lib/libc/mingw/libsrc/atsmedia-uuid.c | 7 + lib/libc/mingw/libsrc/bth-uuid.c | 84 +++++ lib/libc/mingw/libsrc/cguid-uuid.c | 19 ++ lib/libc/mingw/libsrc/comcat-uuid.c | 30 ++ lib/libc/mingw/libsrc/devguid.c | 61 ++++ lib/libc/mingw/libsrc/docobj-uuid.c | 15 + lib/libc/mingw/libsrc/dxva-uuid.c | 40 +++ lib/libc/mingw/libsrc/exdisp-uuid.c | 18 + lib/libc/mingw/libsrc/extras-uuid.c | 42 +++ lib/libc/mingw/libsrc/fwp-uuid.c | 7 + lib/libc/mingw/libsrc/guid_nul.c | 4 + lib/libc/mingw/libsrc/hlguids-uuid.c | 15 + lib/libc/mingw/libsrc/hlink-uuid.c | 13 + lib/libc/mingw/libsrc/mlang-uuid.c | 13 + lib/libc/mingw/libsrc/msctf-uuid.c | 31 ++ lib/libc/mingw/libsrc/mshtmhst-uuid.c | 3 + lib/libc/mingw/libsrc/mshtml-uuid.c | 147 +++++++++ lib/libc/mingw/libsrc/msxml-uuid.c | 29 ++ lib/libc/mingw/libsrc/netcon-uuid.c | 19 ++ lib/libc/mingw/libsrc/ntddkbd-uuid.c | 7 + lib/libc/mingw/libsrc/ntddmou-uuid.c | 7 + lib/libc/mingw/libsrc/ntddpar-uuid.c | 12 + lib/libc/mingw/libsrc/ntddscsi-uuid.c | 8 + lib/libc/mingw/libsrc/ntddser-uuid.c | 11 + lib/libc/mingw/libsrc/ntddstor-uuid.c | 41 +++ lib/libc/mingw/libsrc/ntddvdeo-uuid.c | 7 + lib/libc/mingw/libsrc/oaidl-uuid.c | 20 ++ lib/libc/mingw/libsrc/objidl-uuid.c | 43 +++ lib/libc/mingw/libsrc/objsafe-uuid.c | 9 + lib/libc/mingw/libsrc/ocidl-uuid.c | 46 +++ lib/libc/mingw/libsrc/oleacc-uuid.c | 12 + lib/libc/mingw/libsrc/olectlid-uuid.c | 36 ++ lib/libc/mingw/libsrc/oleidl-uuid.c | 27 ++ lib/libc/mingw/libsrc/power-uuid.c | 18 + lib/libc/mingw/libsrc/powrprof-uuid.c | 15 + lib/libc/mingw/libsrc/uianimation-uuid.c | 44 +++ lib/libc/mingw/libsrc/usbcamdi-uuid.c | 7 + lib/libc/mingw/libsrc/usbiodef-uuid.c | 18 + lib/libc/mingw/libsrc/uuid.c | 397 +++++++++++++++++++++++ lib/libc/mingw/libsrc/vds-uuid.c | 12 + lib/libc/mingw/libsrc/virtdisk-uuid.c | 4 + lib/libc/mingw/libsrc/wia-uuid.c | 106 ++++++ src/link.cpp | 100 +++++- 44 files changed, 1611 insertions(+), 9 deletions(-) create mode 100644 lib/libc/mingw/libsrc/ativscp-uuid.c create mode 100644 lib/libc/mingw/libsrc/atsmedia-uuid.c create mode 100644 lib/libc/mingw/libsrc/bth-uuid.c create mode 100644 lib/libc/mingw/libsrc/cguid-uuid.c create mode 100644 lib/libc/mingw/libsrc/comcat-uuid.c create mode 100644 lib/libc/mingw/libsrc/devguid.c create mode 100644 lib/libc/mingw/libsrc/docobj-uuid.c create mode 100644 lib/libc/mingw/libsrc/dxva-uuid.c create mode 100644 lib/libc/mingw/libsrc/exdisp-uuid.c create mode 100644 lib/libc/mingw/libsrc/extras-uuid.c create mode 100644 lib/libc/mingw/libsrc/fwp-uuid.c create mode 100644 lib/libc/mingw/libsrc/guid_nul.c create mode 100644 lib/libc/mingw/libsrc/hlguids-uuid.c create mode 100644 lib/libc/mingw/libsrc/hlink-uuid.c create mode 100644 lib/libc/mingw/libsrc/mlang-uuid.c create mode 100644 lib/libc/mingw/libsrc/msctf-uuid.c create mode 100644 lib/libc/mingw/libsrc/mshtmhst-uuid.c create mode 100644 lib/libc/mingw/libsrc/mshtml-uuid.c create mode 100644 lib/libc/mingw/libsrc/msxml-uuid.c create mode 100644 lib/libc/mingw/libsrc/netcon-uuid.c create mode 100644 lib/libc/mingw/libsrc/ntddkbd-uuid.c create mode 100644 lib/libc/mingw/libsrc/ntddmou-uuid.c create mode 100644 lib/libc/mingw/libsrc/ntddpar-uuid.c create mode 100644 lib/libc/mingw/libsrc/ntddscsi-uuid.c create mode 100644 lib/libc/mingw/libsrc/ntddser-uuid.c create mode 100644 lib/libc/mingw/libsrc/ntddstor-uuid.c create mode 100644 lib/libc/mingw/libsrc/ntddvdeo-uuid.c create mode 100644 lib/libc/mingw/libsrc/oaidl-uuid.c create mode 100644 lib/libc/mingw/libsrc/objidl-uuid.c create mode 100644 lib/libc/mingw/libsrc/objsafe-uuid.c create mode 100644 lib/libc/mingw/libsrc/ocidl-uuid.c create mode 100644 lib/libc/mingw/libsrc/oleacc-uuid.c create mode 100644 lib/libc/mingw/libsrc/olectlid-uuid.c create mode 100644 lib/libc/mingw/libsrc/oleidl-uuid.c create mode 100644 lib/libc/mingw/libsrc/power-uuid.c create mode 100644 lib/libc/mingw/libsrc/powrprof-uuid.c create mode 100644 lib/libc/mingw/libsrc/uianimation-uuid.c create mode 100644 lib/libc/mingw/libsrc/usbcamdi-uuid.c create mode 100644 lib/libc/mingw/libsrc/usbiodef-uuid.c create mode 100644 lib/libc/mingw/libsrc/uuid.c create mode 100644 lib/libc/mingw/libsrc/vds-uuid.c create mode 100644 lib/libc/mingw/libsrc/virtdisk-uuid.c create mode 100644 lib/libc/mingw/libsrc/wia-uuid.c diff --git a/lib/libc/mingw/libsrc/ativscp-uuid.c b/lib/libc/mingw/libsrc/ativscp-uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..4cfdc3e80520d2ff87ed3ec6ef33e631c151a98a --- /dev/null +++ b/lib/libc/mingw/libsrc/ativscp-uuid.c @@ -0,0 +1,16 @@ +/* ativscp-uuid.c */ +/* Generate GUIDs for ActiveScript interfaces */ + +/* All IIDs defined in this file were extracted from + * HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface\ */ + +/* All CLSIDs defined in this file were extracted from + * HKEY_CLASSES_ROOT\CLSID\ */ + +#define INITGUID +#include +DEFINE_GUID(IID_IActiveScript,0xbb1a2ae1,0xa4f9,0x11cf,0x8f,0x20,0,0x80,0x5f,0x2c,0xd0,0x64); +DEFINE_GUID(IID_IActiveScriptError,0xeae1ba61,0xa4ed,0x11cf,0x8f,0x20,0,0x80,0x5f,0x2c,0xd0,0x64); +DEFINE_GUID(IID_IActiveScriptParse,0xbb1a2ae2,0xa4f9,0x11cf,0x8f,0x20,0,0x80,0x5f,0x2c,0xd0,0x64); +DEFINE_GUID(IID_IActiveScriptSite,0xdb01a1e3,0xa42b,0x11cf,0x8f,0x20,0,0x80,0x5f,0x2c,0xd0,0x64); +DEFINE_GUID(IID_IActiveScriptSiteWindow,0xd10f6761,0x83e9,0x11cf,0x8f,0x20,0,0x80,0x5f,0x2c,0xd0,0x64); diff --git a/lib/libc/mingw/libsrc/atsmedia-uuid.c b/lib/libc/mingw/libsrc/atsmedia-uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..8235a2bd6991d98f592c7228658cb317ae937bdd --- /dev/null +++ b/lib/libc/mingw/libsrc/atsmedia-uuid.c @@ -0,0 +1,7 @@ +/* from atsmedia.h */ + +#define INITGUID +#include + +DEFINE_GUID(BDANETWORKTYPE_ATSC, 0x71985F51, 0x1CA1, 0x11D3, 0x9C, 0xC8, 0x0, 0xC0, 0x4F, 0x79, 0x71, 0xE0); + diff --git a/lib/libc/mingw/libsrc/bth-uuid.c b/lib/libc/mingw/libsrc/bth-uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..2834070a55220ce457a23effefe658013b3f8cbf --- /dev/null +++ b/lib/libc/mingw/libsrc/bth-uuid.c @@ -0,0 +1,84 @@ +#define INITGUID +#include + +DEFINE_GUID(GUID_BTHPORT_DEVICE_INTERFACE,0x0850302A,0xB344,0x4fda,0x9B,0xE9,0x90,0x57,0x6B,0x8D,0x46,0xF0); +DEFINE_GUID(GUID_BLUETOOTH_RADIO_IN_RANGE,0xEA3B5B82,0x26EE,0x450E,0xB0,0xD8,0xD2,0x6F,0xE3,0x0A,0x38,0x69); +DEFINE_GUID(GUID_BLUETOOTH_RADIO_OUT_OF_RANGE,0xE28867C9,0xC2AA,0x4CED,0xB9,0x69,0x45,0x70,0x86,0x60,0x37,0xC4); +DEFINE_GUID(GUID_BLUETOOTH_PIN_REQUEST,0xBD198B7C,0x24AB,0x4B9A,0x8C,0x0D,0xA8,0xEA,0x83,0x49,0xAA,0x16); +DEFINE_GUID(GUID_BLUETOOTH_L2CAP_EVENT,0x7EAE4030,0xB709,0x4AA8,0xAC,0x55,0xE9,0x53,0x82,0x9C,0x9D,0xAA); +DEFINE_GUID(GUID_BLUETOOTH_HCI_EVENT,0xFC240062,0x1541,0x49BE,0xB4,0x63,0x84,0xC4,0xDC,0xD7,0xBF,0x7F); +DEFINE_GUID(BLUETOOTH_BASE_UUID,0x00000000,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(SDP_PROTOCOL_UUID,0x00000001,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(UDP_PROTOCOL_UUID,0x00000002,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(RFCOMM_PROTOCOL_UUID,0x00000003,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(TCP_PROTOCOL_UUID,0x00000004,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(TCSBIN_PROTOCOL_UUID,0x00000005,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(TCSAT_PROTOCOL_UUID,0x00000006,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(OBEX_PROTOCOL_UUID,0x00000008,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(IP_PROTOCOL_UUID,0x00000009,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(FTP_PROTOCOL_UUID,0x0000000A,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(HTTP_PROTOCOL_UUID,0x0000000C,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(WSP_PROTOCOL_UUID,0x0000000E,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(BNEP_PROTOCOL_UUID,0x0000000F,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(UPNP_PROTOCOL_UUID,0x00000010,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(HCCC_PROTOCOL_UUID,0x00000012,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(HCDC_PROTOCOL_UUID,0x00000014,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(HN_PROTOCOL_UUID,0x00000016,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(AVCTP_PROTOCOL_UUID,0x00000017,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(AVDTP_PROTOCOL_UUID,0x00000019,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(CMPT_PROTOCOL_UUID,0x0000001B,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(UDI_C_PLANE_PROTOCOL_UUID,0x0000001D,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(L2CAP_PROTOCOL_UUID,0x00000100,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); + +DEFINE_GUID(ServiceDiscoveryServerServiceClassID_UUID,0x00001000,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(BrowseGroupDescriptorServiceClassID_UUID,0x00001001,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(PublicBrowseGroupServiceClass_UUID,0x00001002,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(SerialPortServiceClass_UUID,0x00001101,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(LANAccessUsingPPPServiceClass_UUID,0x00001102,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(DialupNetworkingServiceClass_UUID,0x00001103,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(IrMCSyncServiceClass_UUID,0x00001104,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(OBEXObjectPushServiceClass_UUID,0x00001105,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(OBEXFileTransferServiceClass_UUID,0x00001106,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(IrMCSyncCommandServiceClass_UUID,0x00001107,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(HeadsetServiceClass_UUID,0x00001108,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(CordlessTelephonyServiceClass_UUID,0x00001109,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(AudioSourceServiceClass_UUID,0x0000110A,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(AudioSinkServiceClass_UUID,0x0000110B,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(AVRemoteControlTargetServiceClass_UUID,0x0000110C,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(AdvancedAudioDistributionServiceClass_UUID,0x0000110D,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(AVRemoteControlServiceClass_UUID,0x0000110E,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(VideoConferencingServiceClass_UUID,0x0000110F,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(IntercomServiceClass_UUID,0x00001110,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(FaxServiceClass_UUID,0x00001111,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(HeadsetAudioGatewayServiceClass_UUID,0x00001112,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(WAPServiceClass_UUID,0x00001113,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(WAPClientServiceClass_UUID,0x00001114,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(PANUServiceClass_UUID,0x00001115,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(NAPServiceClass_UUID,0x00001116,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(GNServiceClass_UUID,0x00001117,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(DirectPrintingServiceClass_UUID,0x00001118,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(ReferencePrintingServiceClass_UUID,0x00001119,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(ImagingServiceClass_UUID,0x0000111A,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(ImagingResponderServiceClass_UUID,0x0000111B,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(ImagingAutomaticArchiveServiceClass_UUID,0x0000111C,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(ImagingReferenceObjectsServiceClass_UUID,0x0000111D,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(HandsfreeServiceClass_UUID,0x0000111E,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(HandsfreeAudioGatewayServiceClass_UUID,0x0000111F,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(DirectPrintingReferenceObjectsServiceClass_UUID,0x00001120,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(ReflectedUIServiceClass_UUID,0x00001121,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(BasicPringingServiceClass_UUID,0x00001122,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(PrintingStatusServiceClass_UUID,0x00001123,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(HumanInterfaceDeviceServiceClass_UUID,0x00001124,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(HardcopyCableReplacementServiceClass_UUID,0x00001125,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(HCRPrintServiceClass_UUID,0x00001126,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(HCRScanServiceClass_UUID,0x00001127,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(CommonISDNAccessServiceClass_UUID,0x00001128,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(VideoConferencingGWServiceClass_UUID,0x00001129,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(UDIMTServiceClass_UUID,0x0000112A,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(UDITAServiceClass_UUID,0x0000112B,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(AudioVideoServiceClass_UUID,0x0000112C,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(PnPInformationServiceClass_UUID,0x00001200,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(GenericNetworkingServiceClass_UUID,0x00001201,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(GenericFileTransferServiceClass_UUID,0x00001202,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(GenericAudioServiceClass_UUID,0x00001203,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); +DEFINE_GUID(GenericTelephonyServiceClass_UUID,0x00001204,0x0000,0x1000,0x80,0x00,0x00,0x80,0x5F,0x9B,0x34,0xFB); diff --git a/lib/libc/mingw/libsrc/cguid-uuid.c b/lib/libc/mingw/libsrc/cguid-uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..3be836f9bd7b36a42ea72eeebcfb88d40549c89e --- /dev/null +++ b/lib/libc/mingw/libsrc/cguid-uuid.c @@ -0,0 +1,19 @@ +/* cguid-uuid.c */ +/* Generate GUIDs for CGUID interfaces */ + +/* All IIDs defined in this file were extracted from + * HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface\ */ + +/* All CLSIDs defined in this file were extracted from + * HKEY_CLASSES_ROOT\CLSID\ */ + +#define INITGUID +#include +DEFINE_OLEGUID(IID_IRpcChannel,0x4,0,0); +DEFINE_OLEGUID(IID_IRpcStub,0x5,0,0); +DEFINE_OLEGUID(IID_IRpcProxy,0x7,0,0); +DEFINE_OLEGUID(IID_IPSFactory,0x9,0,0); +// Picture (Device Independant Bitmap) CLSID +DEFINE_OLEGUID(CLSID_StaticDib,0x316,0,0); +// Picture (Metafile) CLSID +DEFINE_OLEGUID(CLSID_StaticMetafile,0x315,0,0); diff --git a/lib/libc/mingw/libsrc/comcat-uuid.c b/lib/libc/mingw/libsrc/comcat-uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..1b7586dc5d28e192483210bd40693864e2894330 --- /dev/null +++ b/lib/libc/mingw/libsrc/comcat-uuid.c @@ -0,0 +1,30 @@ +/* comcat-uuid.c */ +/* Generate GUIDs for COMCAT interfaces */ + +/* All IIDs defined in this file were extracted from + * HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface\ */ + +/* All CLSIDs defined in this file were extracted from + * HKEY_CLASSES_ROOT\CLSID\ */ + +#define INITGUID +#include +DEFINE_OLEGUID(IID_IEnumGUID,0x2e000,0,0); +DEFINE_OLEGUID(IID_ICatInformation,0x2e013,0,0); +DEFINE_OLEGUID(IID_ICatRegister,0x2e012,0,0); +DEFINE_OLEGUID(IID_IEnumCATEGORYINFO,0x2e011,0,0); +// Component Catagories Manager CLSID +DEFINE_OLEGUID(CLSID_StdComponentCategoriesMgr,0x2e005,0,0); +// Implemented Categories under Outlook Express MsgTable Object CLSID +DEFINE_GUID(CATID_Insertable,0x40fc6ed3,0x2438,0x11cf,0xa3,0xdb,0x8,0,0x36,0xf1,0x25,0x2); +DEFINE_GUID(CATID_Control,0x40fc6ed4,0x2438,0x11cf,0xa3,0xdb,0x8,0,0x36,0xf1,0x25,0x2); +// Implemented Categories under Microsoft PowerPoint Slide CLSID +DEFINE_GUID(CATID_DocObject,0x40fc6ed8,0x2438,0x11cf,0xa3,0xdb,0x8,0,0x36,0xf1,0x25,0x2); +// Implemented Categories under Microsoft Toolbar Control CLSID +DEFINE_GUID(CATID_Programmable,0x40fc6ed5,0x2438,0x11cf,0xa3,0xdb,0x8,0,0x36,0xf1,0x25,0x2); +// Implemented Categories under SSCommand Control CLSID +DEFINE_GUID(CATID_Printable,0x40fc6ed9,0x2438,0x11cf,0xa3,0xdb,0x8,0,0x36,0xf1,0x25,0x2); +DEFINE_GUID(CATID_PersistsToStorage,0xde86a52,0x2baa,0x11cf,0xa2,0x29,0,0xaa,0,0x3d,0x73,0x52); +DEFINE_GUID(CATID_PersistsToPropertyBag,0xde86a57,0x2baa,0x11cf,0xa2,0x29,0,0xaa,0,0x3d,0x73,0x52); +DEFINE_GUID(CATID_PersistsToStream,0xde86a54,0x2baa,0x11cf,0xa2,0x29,0,0xaa,0,0x3d,0x73,0x52); +DEFINE_GUID(CATID_PersistsToStreamInit,0xde86a53,0x2baa,0x11cf,0xa2,0x29,0,0xaa,0,0x3d,0x73,0x52); diff --git a/lib/libc/mingw/libsrc/devguid.c b/lib/libc/mingw/libsrc/devguid.c new file mode 100644 index 0000000000000000000000000000000000000000..7e4c5f11832c0fc25bb66748303d3344f4e2dc64 --- /dev/null +++ b/lib/libc/mingw/libsrc/devguid.c @@ -0,0 +1,61 @@ +/* + Generate GUIDs for device classes for PnP and SetupAPI + + This file was generated by extracting the UUIDs from the registry at + \\SYSTEM\\CurrentControlSet\\Control\\Class and pairing them with + the class name in the registry value "Class" with GUID_DEVCLASS_ prepended + */ + +#define INITGUID +#include +DEFINE_GUID(GUID_DEVCLASS_WCEUSBS, 0x25DBCE51, 0x6C8F, 0x4A72, 0x8A, 0x6D, 0xB5, 0x4C, 0x2B, 0x4F, 0xC8, 0x35); +DEFINE_GUID(GUID_DEVCLASS_USB, 0x36FC9E60, 0xC465, 0x11CF, 0x80, 0x56, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00); +DEFINE_GUID(GUID_DEVCLASS_PNPPRINTERS, 0x4658EE7E, 0xF050, 0x11D1, 0xB6, 0xBD, 0x00, 0xC0, 0x4F, 0xA3, 0x72, 0xA7); +DEFINE_GUID(GUID_DEVCLASS_DOT4, 0x48721B56, 0x6795, 0x11D2, 0xB1, 0xA8, 0x00, 0x80, 0xC7, 0x2E, 0x74, 0xA2); +DEFINE_GUID(GUID_DEVCLASS_DOT4PRINT, 0x49CE6AC8, 0x6F86, 0x11D2, 0xB1, 0xE5, 0x00, 0x80, 0xC7, 0x2E, 0x74, 0xA2); +DEFINE_GUID(GUID_DEVCLASS_CDROM, 0x4D36E965, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18); +DEFINE_GUID(GUID_DEVCLASS_COMPUTER, 0x4D36E966, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18); +DEFINE_GUID(GUID_DEVCLASS_DISKDRIVE, 0x4D36E967, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18); +DEFINE_GUID(GUID_DEVCLASS_DISPLAY, 0x4D36E968, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18); +DEFINE_GUID(GUID_DEVCLASS_FDC, 0x4D36E969, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18); +DEFINE_GUID(GUID_DEVCLASS_HDC, 0x4D36E96A, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18); +DEFINE_GUID(GUID_DEVCLASS_KEYBOARD, 0x4D36E96B, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18); +DEFINE_GUID(GUID_DEVCLASS_MEDIA, 0x4D36E96C, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18); +DEFINE_GUID(GUID_DEVCLASS_MODEM, 0x4D36E96D, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18); +DEFINE_GUID(GUID_DEVCLASS_MONITOR, 0x4D36E96E, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18); +DEFINE_GUID(GUID_DEVCLASS_MOUSE, 0x4D36E96F, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18); +DEFINE_GUID(GUID_DEVCLASS_MTD, 0x4D36E970, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18); +DEFINE_GUID(GUID_DEVCLASS_MULTIFUNCTION, 0x4D36E971, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18); +DEFINE_GUID(GUID_DEVCLASS_NET, 0x4D36E972, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2b, 0xE1, 0x03, 0x18); +DEFINE_GUID(GUID_DEVCLASS_NETCLIENT, 0x4D36E973, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18); +DEFINE_GUID(GUID_DEVCLASS_NETSERVICE, 0x4D36E974, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18); +DEFINE_GUID(GUID_DEVCLASS_NETTRANS, 0x4D36E975, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18); +DEFINE_GUID(GUID_DEVCLASS_PCMCIA, 0x4D36E977, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18); +DEFINE_GUID(GUID_DEVCLASS_PORTS, 0x4D36E978, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18); +DEFINE_GUID(GUID_DEVCLASS_PRINTER, 0x4D36E979, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18); +DEFINE_GUID(GUID_DEVCLASS_SCSIADAPTER, 0x4D36E97B, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18); +DEFINE_GUID(GUID_DEVCLASS_SYSTEM, 0x4D36E97D, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18); +DEFINE_GUID(GUID_DEVCLASS_UNKNOWN, 0x4D36E97E, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18); +DEFINE_GUID(GUID_DEVCLASS_FLOPPYDISK, 0x4D36E980, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18); +DEFINE_GUID(GUID_DEVCLASS_PROCESSOR, 0x50127DC3, 0x0F36, 0x415E, 0xA6, 0xCC, 0x4C, 0xB3, 0xBE, 0x91, 0x0B, 0x65); +DEFINE_GUID(GUID_DEVCLASS_MULTIPORTSERIAL, 0x50906CB8, 0xBA12, 0x11D1, 0xBF, 0x5D, 0x00, 0x00, 0xF8, 0x05, 0xF5, 0x30); +DEFINE_GUID(GUID_DEVCLASS_SMARTCARDREADER, 0x50DD5230, 0xBA8A, 0x11D1, 0xBF, 0x5D, 0x00, 0x00, 0xF8, 0x05, 0xF5, 0x30); +DEFINE_GUID(GUID_DEVCLASS_VOLUMESNAPSHOT, 0x533C5B84, 0xEC70, 0x11D2, 0x95, 0x05, 0x00, 0xC0, 0x4F, 0x79, 0xDE, 0xAF); +DEFINE_GUID(GUID_DEVCLASS_1394DEBUG, 0x66F250D6, 0x7801, 0x4A64, 0xB1, 0x39, 0xEE, 0xA8, 0x0A, 0x45, 0x0B, 0x24); +DEFINE_GUID(GUID_DEVCLASS_1394, 0x6BDD1FC1, 0x810F, 0x11D0, 0xBE, 0xC7, 0x08, 0x00, 0x2B, 0xE2, 0x09, 0x2F); +DEFINE_GUID(GUID_DEVCLASS_INFRARED, 0x6BDD1FC5, 0x810F, 0x11D0, 0xBE, 0xC7, 0x08, 0x00, 0x2B, 0xE2, 0x09, 0x2F); +DEFINE_GUID(GUID_DEVCLASS_IMAGE, 0x6BDD1FC6, 0x810F, 0x11D0, 0xBE, 0xC7, 0x08, 0x00, 0x2B, 0xE2, 0x09, 0x2F); +DEFINE_GUID(GUID_DEVCLASS_TAPEDRIVE, 0x6D807884, 0x7D21, 0x11CF, 0x80, 0x1C, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18); +DEFINE_GUID(GUID_DEVCLASS_VOLUME, 0x71A27CDD, 0x812A, 0x11D0, 0xBE, 0xC7, 0x08, 0x00, 0x2B, 0xE2, 0x09, 0x2F); +DEFINE_GUID(GUID_DEVCLASS_BATTERY, 0x72631E54, 0x78A4, 0x11D0, 0xBC, 0xF7, 0x00, 0xAA, 0x00, 0xB7, 0xB3, 0x2A); +DEFINE_GUID(GUID_DEVCLASS_HIDCLASS, 0x745A17A0, 0x74D3, 0x11D0, 0xB6, 0xFE, 0x00, 0xA0, 0xC9, 0x0F, 0x57, 0xDA); +DEFINE_GUID(GUID_DEVCLASS_61883, 0x7EBEFBC0, 0x3200, 0x11D2, 0xB4, 0xC2, 0x00, 0xA0, 0xC9, 0x69, 0x7D, 0x07); +DEFINE_GUID(GUID_DEVCLASS_LEGACYDRIVER, 0x8ECC055D, 0x047F, 0x11D1, 0xA5, 0x37, 0x00, 0x00, 0xF8, 0x75, 0x3E, 0xD1); +DEFINE_GUID(GUID_DEVCLASS_SDHOST, 0xA0A588A4, 0xC46F, 0x4B37, 0xB7, 0xEA, 0xC8, 0x2F, 0xE8, 0x98, 0x70, 0xC6); +DEFINE_GUID(GUID_DEVCLASS_AVC, 0xC06FF265, 0xAE09, 0x48F0, 0x81, 0x2C, 0x16, 0x75, 0x3D, 0x7C, 0xBA, 0x83); +DEFINE_GUID(GUID_DEVCLASS_ENUM1394, 0xC459DF55, 0xDB08, 0x11D1, 0xB0, 0x09, 0x00, 0xA0, 0xC9, 0x08, 0x1F, 0xF6); +DEFINE_GUID(GUID_DEVCLASS_MEDIUMCHANGER, 0xCE5939AE, 0xEBDE, 0x11D0, 0xB1, 0x81, 0x00, 0x00, 0xF8, 0x75, 0x3E, 0xC4); +DEFINE_GUID(GUID_DEVCLASS_NTAPM, 0xD45B1C18, 0xC8FA, 0x11D1, 0x9F, 0x77, 0x00, 0x00, 0xF8, 0x05, 0xF5, 0x30); +DEFINE_GUID(GUID_DEVCLASS_SBP2, 0xD48179BE, 0xEC20, 0x11D1, 0xB6, 0xB8, 0x00, 0xC0, 0x4F, 0xA3, 0x72, 0xA7); +DEFINE_GUID(GUID_DEVCLASS_BLUETOOTH, 0xE0CBF06C, 0xCD8B, 0x4647, 0xBB, 0x8A, 0x26, 0x3B, 0x43, 0xF0, 0xF9, 0x74); +DEFINE_GUID(GUID_DEVCLASS_PROBES, 0xFD02DFAC, 0x6A7C, 0x4391, 0x97, 0xDA, 0xF8, 0x1F, 0xEF, 0x1F, 0xC9, 0xD3); diff --git a/lib/libc/mingw/libsrc/docobj-uuid.c b/lib/libc/mingw/libsrc/docobj-uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..6d933259944698ed57a0009d7b58df2c7616596a --- /dev/null +++ b/lib/libc/mingw/libsrc/docobj-uuid.c @@ -0,0 +1,15 @@ +/* docobj-uuid.c */ +/* Generate GUIDs for Document Object interfaces */ + +/* All IIDs defined in this file were extracted from + * HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface\ */ + +#define INITGUID +#include +DEFINE_GUID(IID_IContinueCallback,0xb722bcca,0x4e68,0x101b,0xa2,0xbc,0,0xaa,0,0x40,0x47,0x70); +DEFINE_GUID(IID_IEnumOleDocumentViews,0xb722bcc8,0x4e68,0x101b,0xa2,0xbc,0,0xaa,0,0x40,0x47,0x70); +DEFINE_GUID(IID_IPrint,0xb722bcc9,0x4e68,0x101b,0xa2,0xbc,0,0xaa,0,0x40,0x47,0x70); +DEFINE_GUID(IID_IOleDocument,0xb722bcc5,0x4e68,0x101b,0xa2,0xbc,0,0xaa,0,0x40,0x47,0x70); +DEFINE_GUID(IID_IOleDocumentView,0xb722bcc6,0x4e68,0x101b,0xa2,0xbc,0,0xaa,0,0x40,0x47,0x70); +DEFINE_GUID(IID_IOleDocumentSite,0xb722bcc7,0x4e68,0x101b,0xa2,0xbc,0,0xaa,0,0x40,0x47,0x70); +DEFINE_GUID(IID_IOleCommandTarget,0xb722bccb,0x4e68,0x101b,0xa2,0xbc,0,0xaa,0,0x40,0x47,0x70); diff --git a/lib/libc/mingw/libsrc/dxva-uuid.c b/lib/libc/mingw/libsrc/dxva-uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..9273219ccf85171e8cc72560b8c01c5c4f67d576 --- /dev/null +++ b/lib/libc/mingw/libsrc/dxva-uuid.c @@ -0,0 +1,40 @@ +/** + * DISCLAIMER + * This file has no copyright assigned and is placed in the Public Domain. + * This file is part of the mingw-w64 runtime package. + * + * The mingw-w64 runtime package and its code is distributed in the hope that it + * will be useful but WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESSED OR + * IMPLIED ARE HEREBY DISCLAIMED. This includes but is not limited to + * warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + */ + +#if defined(__LCC__) || defined(__GNUC__) +#define INITGUID 1 +#include +#else +#include +#endif + +DEFINE_GUID(IID_IDirectXVideoDecoderService, 0xfc51a551, 0xd5e7, 0x11d9, 0xaf,0x55,0x00,0x05,0x4e,0x43,0xff,0x02); +DEFINE_GUID(IID_IDirectXVideoAccelerationService, 0xfc51a550, 0xd5e7, 0x11d9, 0xaf,0x55,0x00,0x05,0x4e,0x43,0xff,0x02); + +DEFINE_GUID(DXVA2_ModeMPEG2_MoComp, 0xe6a9f44b, 0x61b0,0x4563, 0x9e,0xa4,0x63,0xd2,0xa3,0xc6,0xfe,0x66); +DEFINE_GUID(DXVA2_ModeMPEG2_IDCT, 0xbf22ad00, 0x03ea,0x4690, 0x80,0x77,0x47,0x33,0x46,0x20,0x9b,0x7e); +DEFINE_GUID(DXVA2_ModeMPEG2_VLD, 0xee27417f, 0x5e28,0x4e65, 0xbe,0xea,0x1d,0x26,0xb5,0x08,0xad,0xc9); +DEFINE_GUID(DXVA2_ModeH264_A, 0x1b81be64, 0xa0c7,0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5); +DEFINE_GUID(DXVA2_ModeH264_B, 0x1b81be65, 0xa0c7,0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5); +DEFINE_GUID(DXVA2_ModeH264_C, 0x1b81be66, 0xa0c7,0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5); +DEFINE_GUID(DXVA2_ModeH264_D, 0x1b81be67, 0xa0c7,0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5); +DEFINE_GUID(DXVA2_ModeH264_E, 0x1b81be68, 0xa0c7,0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5); +DEFINE_GUID(DXVA2_ModeH264_F, 0x1b81be69, 0xa0c7,0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5); +DEFINE_GUID(DXVA2_ModeWMV8_A, 0x1b81be80, 0xa0c7,0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5); +DEFINE_GUID(DXVA2_ModeWMV8_B, 0x1b81be81, 0xa0c7,0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5); +DEFINE_GUID(DXVA2_ModeWMV9_A, 0x1b81be90, 0xa0c7,0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5); +DEFINE_GUID(DXVA2_ModeWMV9_B, 0x1b81be91, 0xa0c7,0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5); +DEFINE_GUID(DXVA2_ModeWMV9_C, 0x1b81be94, 0xa0c7,0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5); +DEFINE_GUID(DXVA2_ModeVC1_A, 0x1b81beA0, 0xa0c7,0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5); +DEFINE_GUID(DXVA2_ModeVC1_B, 0x1b81beA1, 0xa0c7,0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5); +DEFINE_GUID(DXVA2_ModeVC1_C, 0x1b81beA2, 0xa0c7,0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5); +DEFINE_GUID(DXVA2_ModeVC1_D, 0x1b81beA3, 0xa0c7,0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5); +DEFINE_GUID(DXVA_NoEncrypt, 0x1b81bed0, 0xa0c7,0x11d3, 0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5); diff --git a/lib/libc/mingw/libsrc/exdisp-uuid.c b/lib/libc/mingw/libsrc/exdisp-uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..1c0401e015b11d0a566e5003f65b8d8275d8fdb9 --- /dev/null +++ b/lib/libc/mingw/libsrc/exdisp-uuid.c @@ -0,0 +1,18 @@ +/* exdisp-uuid.c */ +/* Generate GUIDs for Object EXDISP interfaces */ + +/* All IIDs defined in this file were extracted from + * HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface\ */ + +/* All CLSIDs defined in this file were extracted from + * HKEY_CLASSES_ROOT\CLSID\ */ + +#define INITGUID +#include +// Microsoft Web Browser CLSID +DEFINE_GUID(CLSID_WebBrowser,0x8856f961,0x340a,0x11d0,0xa9,0x6b,0x0,0xc0,0x4f,0xd7,0x5,0xa2); +DEFINE_GUID(DIID_DWebBrowserEvents,0xeab22ac2,0x30c1,0x11cf,0xa7,0xeb,0x0,0x0,0xc0,0x5b,0xae,0x0b); +DEFINE_GUID(DIID_DWebBrowserEvents2,0x34a715a0,0x6587,0x11d0,0x92,0x4a,0x0,0x20,0xaf,0xc7,0xac,0x4d); +DEFINE_GUID(IID_IWebBrowser,0xeab22ac1,0x30c1,0x11cf,0xa7,0xeb,0x0,0x0,0xc0,0x5b,0xae,0x0b); +DEFINE_GUID(IID_IWebBrowser2,0xd30c1661,0xcdaf,0x11d0,0x8a,0x3e,0x0,0xc0,0x4f,0xc9,0xe2,0x6e); +DEFINE_GUID(IID_IWebBrowserApp,0x2df05,0x0,0x0,0xc0,0x0,0x0,0x0,0x0,0x0,0x0,0x46); diff --git a/lib/libc/mingw/libsrc/extras-uuid.c b/lib/libc/mingw/libsrc/extras-uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..f09ba330f83e2ecc01d4041ec29824310a083284 --- /dev/null +++ b/lib/libc/mingw/libsrc/extras-uuid.c @@ -0,0 +1,42 @@ +/* extras-uuid.c */ +/* Generate GUIDs for interfaces not defined in any headers*/ + +/* All IIDs defined in this file were extracted from + * HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface\ */ + +/* All CLSIDs defined in this file were extracted from + * HKEY_CLASSES_ROOT\CLSID\ */ + +#define INITGUID +#include +// Microsoft Web Browser CLSID +DEFINE_GUID(IID_IClientSiteHandler,0xf4f569d1,0x593b,0x101a,0xb5,0x69,0x8,0,0x2b,0x2d,0xbf,0x7a); +DEFINE_OLEGUID(IID_IContinue,0x12a,0,0); +DEFINE_GUID(IID_IHttpNegotiate,0x79eac9d2,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb); +DEFINE_GUID(IID_IPersistMoniker,0x79eac9c9,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0x0b); +DEFINE_GUID(IID_IServerHandler,0xf4f569d0,0x593b,0x101a,0xb5,0x69,0x8,0,0x2b,0x2d,0xbf,0x7a); +DEFINE_GUID(IID_ITargetEmbedding,0x548793c0,0x9e74,0x11cf,0x96,0x55,0,0xa0,0xc9,0x3,0x49,0x23); +DEFINE_GUID(IID_ITargetFrame,0xd5f78c80,0x5252,0x11cf,0x90,0xfa,0,0xaa,0,0x42,0x10,0x6e); +DEFINE_OLEGUID(IID_ITypeComp,0x20403,0,0); +DEFINE_GUID(IID_IUrlHistoryStg,0x3c374a41,0xbae4,0x11cf,0xbf,0x7d,0,0xaa,0,0x69,0x46,0xee); +DEFINE_GUID(IID_IWinInetHttpInfo,0x79eac9d8,0xbafa,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb); +DEFINE_GUID(IID_IWinInetInfo,0x79eac9d6,0xbafa,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb); +DEFINE_OLEGUID(IID_IEnumSTATPROPSETSTG,0x13b,0,0); +DEFINE_OLEGUID(IID_IEnumSTATPROPSTG,0x139,0,0); +DEFINE_GUID(IID_IEnumSTATURL,0x3c374a42,0xbae4,0x11cf,0xbf,0x7d,0,0xaa,0,0x69,0x46,0xee); +// file:, local: Asychronous Pluggable Protocol Handler CLSID +DEFINE_GUID(CLSID_FileProtocol,0x79eac9e7,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb); +// ftp: Asychronous Pluggable Protocol Handler CLSID +DEFINE_GUID(CLSID_FtpProtocol,0x79eac9e3,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb); +// gopher: Asychronous Pluggable Protocol Handler CLSID +DEFINE_GUID(CLSID_GopherProtocol,0x79eac9e4,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb); +// http: Asychronous Pluggable Protocol Handler CLSID +DEFINE_GUID(CLSID_HttpProtocol,0x79eac9e2,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb); +// https: Asychronous Pluggable Protocol Handler CLSID +DEFINE_GUID(CLSID_HttpSProtocol,0x79eac9e5,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb); +// mk: Asychronous Pluggable Protocol Handler CLSID +DEFINE_GUID(CLSID_MkProtocol,0x79eac9e6,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb); +// URLMoniker ProxyStub Factory CLSID +DEFINE_GUID(CLSID_PSUrlMonProxy,0x79eac9f1,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb); +// URL Moniker CLSID +DEFINE_GUID(CLSID_StdURLMoniker,0x79eac9e0,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb); diff --git a/lib/libc/mingw/libsrc/fwp-uuid.c b/lib/libc/mingw/libsrc/fwp-uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..3207e1a9343fb4fd639d09a0748b44eaca39c0f2 --- /dev/null +++ b/lib/libc/mingw/libsrc/fwp-uuid.c @@ -0,0 +1,7 @@ +/* http://msdn.microsoft.com/en-us/library/bb427366%28v=VS.85%29.aspx */ +#define INITGUID +#include + +DEFINE_GUID(FWPM_PROVIDER_IKEEXT,0x10AD9216L,0xCCDE,0x456C,0x8B,0x16,0xE9,0xF0,0x4E,0x60,0xA9,0x0B); +DEFINE_GUID(FWPM_PROVIDER_IPSEC_DOS_CONFIG,0x3C6C0519L,0xC05C,0x4BB9,0x83,0x38,0x23,0x27,0x81,0x4C,0xE8,0xBF); +DEFINE_GUID(FWPM_PROVIDER_TCP_CHIMNEY_OFFLOAD,0x896AA19EL,0x9A34,0x4BCB,0xAE,0x79,0xBE,0xB9,0x12,0x7C,0x84,0xB9); diff --git a/lib/libc/mingw/libsrc/guid_nul.c b/lib/libc/mingw/libsrc/guid_nul.c new file mode 100644 index 0000000000000000000000000000000000000000..3e385353e6c847b5f0cdedba123e88b167841d10 --- /dev/null +++ b/lib/libc/mingw/libsrc/guid_nul.c @@ -0,0 +1,4 @@ +#define INITGUID +#include + +DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0); diff --git a/lib/libc/mingw/libsrc/hlguids-uuid.c b/lib/libc/mingw/libsrc/hlguids-uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..05c90e52602425119f121b95dd18f4ba2f7721e2 --- /dev/null +++ b/lib/libc/mingw/libsrc/hlguids-uuid.c @@ -0,0 +1,15 @@ +/* hlguids-uuid.c */ +/* Generate GUIDs for HyperLink GUID interfaces */ + +/* All IIDs defined in this file were extracted from + * HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface\ */ + +/* All CLSIDs defined in this file were extracted from + * HKEY_CLASSES_ROOT\CLSID\ */ + +#define INITGUID +#include +// StdHlink CLSID +DEFINE_GUID(CLSID_StdHlink,0x79eac9d0,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb); +// StdHlinkBrowseContext CLSID +DEFINE_GUID(CLSID_StdHlinkBrowseContext,0x79eac9d1,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb); diff --git a/lib/libc/mingw/libsrc/hlink-uuid.c b/lib/libc/mingw/libsrc/hlink-uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..433429f718d972db433f5c426c90a37921383c4e --- /dev/null +++ b/lib/libc/mingw/libsrc/hlink-uuid.c @@ -0,0 +1,13 @@ +/* hlink-uuid.c */ +/* Generate GUIDs for HyperLink interfaces */ + +/* All IIDs defined in this file were extracted from + * HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface\ */ + +#define INITGUID +#include +DEFINE_GUID(IID_IHlink,0x79eac9c3,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb); +DEFINE_GUID(IID_IHlinkBrowseContext,0x79eac9c7,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb); +DEFINE_GUID(IID_IHlinkFrame,0x79eac9c5,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb); +DEFINE_GUID(IID_IHlinkSite,0x79eac9c2,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb); +DEFINE_GUID(IID_IHlinkTarget,0x79eac9c4,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb); diff --git a/lib/libc/mingw/libsrc/mlang-uuid.c b/lib/libc/mingw/libsrc/mlang-uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..c7cab7cc82e7485f229f0d9581c668a0df830388 --- /dev/null +++ b/lib/libc/mingw/libsrc/mlang-uuid.c @@ -0,0 +1,13 @@ +/* mlang-uuid.c */ +/* Generate GUIDs for Object Multi Language interfaces */ + +/* All IIDs defined in this file were extracted from + * HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface\ */ + +/* All CLSIDs defined in this file were extracted from + * HKEY_CLASSES_ROOT\CLSID\ */ + +#define INITGUID +#include +// Multi Language Support CLSID +DEFINE_GUID(CLSID_CMultiLanguage,0x275c23e2,0x3747,0x11d0,0x9f,0xea,0,0xaa,0,0x3f,0x86,0x46); diff --git a/lib/libc/mingw/libsrc/msctf-uuid.c b/lib/libc/mingw/libsrc/msctf-uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..1b3329832b080c470b1cdaf2940e0bb87566a323 --- /dev/null +++ b/lib/libc/mingw/libsrc/msctf-uuid.c @@ -0,0 +1,31 @@ +/* msctf-uuid.c */ +/* Generate GUIDs for Text Services interfaces */ + +#include +#include +#include +#include + +#include +#include + +DEFINE_GUID(CLSID_TF_ThreadMgr,0x529a9e6b,0x6587,0x4f23,0xab,0x9e,0x9c,0x7d,0x68,0x3e,0x3c,0x50); +DEFINE_GUID(CLSID_TF_InputProcessorProfiles,0x33c53a50,0xf456,0x4884,0xb0,0x49,0x85,0xfd,0x64,0x3e,0xcf,0xed); +DEFINE_GUID(CLSID_TF_CategoryMgr,0xA4B544A1,0x438D,0x4B41,0x93,0x25,0x86,0x95,0x23,0xE2,0xD6,0xC7); +DEFINE_GUID(CLSID_TF_LangBarMgr,0xebb08c45,0x6c4a,0x4fdc,0xae,0x53,0x4e,0xb8,0xc4,0xc7,0xdb,0x8e); +DEFINE_GUID(CLSID_TF_DisplayAttributeMgr,0x3ce74de4,0x53d3,0x4d74,0x8b,0x83,0x43,0x1b,0x38,0x28,0xba,0x53); + +DEFINE_GUID(GUID_TFCAT_TIP_KEYBOARD,0x34745c63,0xb2f0,0x4784,0x8b,0x67,0x5e,0x12,0xc8,0x70,0x1a,0x31); +DEFINE_GUID(GUID_TFCAT_TIP_SPEECH,0xB5A73CD1,0x8355,0x426B,0xA1,0x61,0x25,0x98,0x08,0xF2,0x6B,0x14); +DEFINE_GUID(GUID_TFCAT_TIP_HANDWRITING,0x246ecb87,0xc2f2,0x4abe,0x90,0x5b,0xc8,0xb3,0x8a,0xdd,0x2c,0x43); +DEFINE_GUID(GUID_TFCAT_DISPLAYATTRIBUTEPROVIDER,0x046B8C80,0x1647,0x40F7,0x9B,0x21,0xB9,0x3B,0x81,0xAA,0xBC,0x1B); +DEFINE_GUID(GUID_COMPARTMENT_KEYBOARD_DISABLED,0x71a5b253,0x1951,0x466b,0x9f,0xbc,0x9c,0x88,0x08,0xfa,0x84,0xf2); +DEFINE_GUID(GUID_COMPARTMENT_KEYBOARD_OPENCLOSE,0x58273aad,0x01bb,0x4164,0x95,0xc6,0x75,0x5b,0xa0,0xb5,0x16,0x2d); +DEFINE_GUID(GUID_COMPARTMENT_HANDWRITING_OPENCLOSE,0xf9ae2c6b,0x1866,0x4361,0xaf,0x72,0x7a,0xa3,0x09,0x48,0x89,0x0e); +DEFINE_GUID(GUID_COMPARTMENT_SPEECH_DISABLED,0x56c5c607,0x0703,0x4e59,0x8e,0x52,0xcb,0xc8,0x4e,0x8b,0xbe,0x35); +DEFINE_GUID(GUID_COMPARTMENT_SPEECH_OPENCLOSE,0x544d6a63,0xe2e8,0x4752,0xbb,0xd1,0x00,0x09,0x60,0xbc,0xa0,0x83); +DEFINE_GUID(GUID_COMPARTMENT_SPEECH_GLOBALSTATE,0x2a54fe8e,0x0d08,0x460c,0xa7,0x5d,0x87,0x03,0x5f,0xf4,0x36,0xc5); +DEFINE_GUID(GUID_COMPARTMENT_PERSISTMENUENABLED,0x575f3783,0x70c8,0x47c8,0xae,0x5d,0x91,0xa0,0x1a,0x1f,0x75,0x92); +DEFINE_GUID(GUID_COMPARTMENT_EMPTYCONTEXT,0xd7487dbf,0x804e,0x41c5,0x89,0x4d,0xad,0x96,0xfd,0x4e,0xea,0x13); +DEFINE_GUID(GUID_COMPARTMENT_TIPUISTATUS,0x148ca3ec,0x0366,0x401c,0x8d,0x75,0xed,0x97,0x8d,0x85,0xfb,0xc9); + diff --git a/lib/libc/mingw/libsrc/mshtmhst-uuid.c b/lib/libc/mingw/libsrc/mshtmhst-uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..cf018c08bd0109a4278c6b779b0b7d44449db6e8 --- /dev/null +++ b/lib/libc/mingw/libsrc/mshtmhst-uuid.c @@ -0,0 +1,3 @@ +#define INITGUID +#include +DEFINE_GUID(IID_IDocHostUIHandler,0xbd3f23c0,0xd43e,0x11cf,0x89,0x3b,0x00,0xaa,0x00,0xbd,0xce,0x1a); diff --git a/lib/libc/mingw/libsrc/mshtml-uuid.c b/lib/libc/mingw/libsrc/mshtml-uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..2a1ce57da143e77012fc95a7888e55e1375c9e3c --- /dev/null +++ b/lib/libc/mingw/libsrc/mshtml-uuid.c @@ -0,0 +1,147 @@ +/* mshtml-uuid.c */ +/* Generate GUIDs for MSHTML interfaces */ + +#define INITGUID +#include +DEFINE_GUID(IID_IHTMLDocument,0x626fc520,0xa41e,0x11cf,0xa7,0x31,0x0,0xa0,0xc9,0x8,0x26,0x37); +DEFINE_GUID(IID_IHTMLDocument2,0x332c4425,0x26cb,0x11d0,0xb4,0x83,0x0,0xc0,0x4f,0xd9,0x1,0x19); +DEFINE_GUID(IID_IHTMLElement,0x3050f1ff,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0xb); +DEFINE_GUID(IID_IHTMLSelectionObject,0x3050f25a,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0xb); +DEFINE_GUID(IID_IHTMLTxtRange,0x3050f220,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLImgElement,0x3050f240,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLBodyElement,0x3050f1d8,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLFontElement,0x3050f1d9,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLAnchorElement,0x3050f1da,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLUListElement,0x3050f1dd,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLOListElement,0x3050f1de,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLLIElement,0x3050f1e0,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLBRElement,0x3050f1f0,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLDListElement,0x3050f1f1,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLDDElement,0x3050f1f2,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLDTElement,0x3050f1f3,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLHRElement,0x3050f1f4,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLParaElement,0x3050f1f5,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLHeaderElement,0x3050f1f6,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLFormElement,0x3050f1f7,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLDivElement,0x3050f200,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLBaseFontElement,0x3050f202,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLMetaElement,0x3050f203,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLBaseElement,0x3050f204,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLLinkElement,0x3050f205,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLIsIndexElement,0x3050f206,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLNextIdElement,0x3050f207,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLBlockElement,0x3050f208,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLUnknownElement,0x3050f209,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLPhraseElement,0x3050f20a,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLCommentElement,0x3050f20c,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLListElement,0x3050f20e,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLOptionElement,0x3050f211,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLDivPosition,0x3050f212,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLDialog,0x3050f216,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLTextElement,0x3050f218,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLTable,0x3050f21e,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLElementCollection,0x3050f21f,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLTextContainer,0x3050f230,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLTableCol,0x3050f23a,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLTableSection,0x3050f23b,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLTableRow,0x3050f23c,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLTableCell,0x3050f23d,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLSelectElement,0x3050f244,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLObjectElement,0x3050f24f,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLStyle,0x3050f25e,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLEmbedElement,0x3050f25f,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLAreaElement,0x3050f265,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLMapElement,0x3050f266,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLScriptElement,0x3050f28b,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLControlRange,0x3050f29c,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLInputHiddenElement,0x3050f2a4,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLInputTextElement,0x3050f2a6,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLTextAreaElement,0x3050f2aa,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLInputFileElement,0x3050f2ad,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLInputButtonElement,0x3050f2b2,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLMarqueeElement,0x3050f2b5,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLButtonElement,0x3050f2bb,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLOptionButtonElement,0x3050f2bc,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLInputImage,0x3050f2c2,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLStyleSheet,0x3050f2e3,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLStyleSheetRulesCollection,0x3050f2e5,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLTableCaption,0x3050f2eb,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLFrameBase,0x3050f311,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLFrameElement,0x3050f313,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLIFrameElement,0x3050f315,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLFrameSetElement,0x3050f319,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLTitleElement,0x3050f322,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLLabelElement,0x3050f32a,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLEventObj,0x3050f32d,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLStyleSheetRule,0x3050f357,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLScreen,0x3050f35c,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLBGsound,0x3050f369,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLStyleElement,0x3050f375,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLFontNamesCollection,0x3050f376,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLFontSizesCollection,0x3050f377,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLOptionsHolder,0x3050f378,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLStyleSheetsCollection,0x3050f37e,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLAreasCollection,0x3050f383,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLNoShowElement,0x3050f38a,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLOptionElementFactory,0x3050f38c,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLImageElementFactory,0x3050f38e,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLRuleStyle,0x3050f3cf,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLStyleFontFace,0x3050f3d5,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLCurrentStyle,0x3050f3db,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLSpanFlow,0x3050f3e5,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLFieldSetElement,0x3050f3e7,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLLegendElement,0x3050f3ea,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLFiltersCollection,0x3050f3ee,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLDatabinding,0x3050f3f2,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLSpanElement,0x3050f3f3,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLMimeTypesCollection,0x3050f3fc,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLPluginsCollection,0x3050f3fd,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLOpsProfile,0x3050f401,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLTextRangeMetrics,0x3050f40b,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLTableRowMetrics,0x3050f413,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLElement2,0x3050f434,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLDocument3,0x3050f485,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLEventObj2,0x3050f48b,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLUserDataOM,0x3050f48f,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLTableRow2,0x3050f4a1,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLStyle2,0x3050f4a2,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLRect,0x3050f4a3,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLRectCollection,0x3050f4a4,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLTextRangeMetrics2,0x3050f4a6,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLRuleStyle2,0x3050f4ac,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLTable2,0x3050f4ad,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLWindow3,0x3050f4ae,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLDOMAttribute,0x3050f4b0,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLDOMTextNode,0x3050f4b1,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLDataTransfer,0x3050f4b3,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLGenericElement,0x3050f4b7,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLPersistDataOM,0x3050f4c0,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLAttributeCollection,0x3050f4c3,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLPersistData,0x3050f4c5,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLObjectElement2,0x3050f4cd,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLBookmarkCollection,0x3050f4ce,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLUniqueName,0x3050f4d0,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLLinkElement2,0x3050f4e5,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLIFrameElement2,0x3050f4e6,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLControlElement,0x3050f4e9,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLFormElement2,0x3050f4f6,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLDOMChildrenCollection,0x3050f5ab,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLBodyElement2,0x3050f5c5,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLFrameSetElement2,0x3050f5c6,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLTableSection2,0x3050f5c7,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLAppBehavior2,0x3050f5c9,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLAppBehavior,0x3050f5ca,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLInputElement,0x3050f5d2,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLDOMNode,0x3050f5da,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLDialog2,0x3050f5e0,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLUrnCollection,0x3050f5e2,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLModelessInit,0x3050f5e4,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLDocumentFragment,0x3050f5e5,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLAreasCollection2,0x3050f5ec,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLSelectElement2,0x3050f5ed,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLElementCollection2,0x3050f5ee,0x98b5,0x11cf,0xbb,0x82,0x0,0xaa,0x0,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLFramesCollection2,0x332c4426,0x26cb,0x11d0,0xb4,0x83,0x0,0xc0,0x4f,0xd9,0x01,0x19); +DEFINE_GUID(IID_IHTMLWindow2,0x332c4427,0x26cb,0x11d0,0xb4,0x83,0x0,0xc0,0x4f,0xd9,0x01,0x19); +DEFINE_GUID(IID_IHTMLLocation,0x163bb1e0,0x6e00,0x11cf,0x83,0x7a,0x48,0xdc,0x04,0xc1,0x0,0x0); +DEFINE_GUID(IID_IHTMLFrameBase2,0x3050f6db,0x98b5,0x11cf,0xbb,0x82,0x00,0xaa,0x00,0xbd,0xce,0x0b); +DEFINE_GUID(IID_IHTMLFrameBase3,0x3050f82e,0x98b5,0x11cf,0xbb,0x82,0x00,0xaa,0x00,0xbd,0xce,0x0b); diff --git a/lib/libc/mingw/libsrc/msxml-uuid.c b/lib/libc/mingw/libsrc/msxml-uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..0f4c7a1d2484d98938a567fa7f9eba84f2555ff3 --- /dev/null +++ b/lib/libc/mingw/libsrc/msxml-uuid.c @@ -0,0 +1,29 @@ +/* msxml-uuid.c */ +/* Generate GUIDs for MSXML interfaces */ + +#define INITGUID +#include +DEFINE_GUID(CLSID_DOMDocument,0x2933bf90,0x7b36,0x11d2,0xb2,0x0e,0x00,0xc0,0x4f,0x98,0x3e,0x60); +DEFINE_GUID(CLSID_DOMFreeThreadedDocument,0x2933bf91,0x7b36,0x11d2,0xb2,0x0e,0x00,0xc0,0x4f,0x98,0x3e,0x60); +DEFINE_GUID(CLSID_XMLHTTPRequest,0xed8c108e,0x4349,0x11d2,0x91,0xa4,0x00,0xc0,0x4f,0x79,0x69,0xe8); +DEFINE_GUID(DIID_XMLDOMDocumentEvents,0x3efaa427,0x272f,0x11d2,0x83,0x6f,0x00,0x00,0xf8,0x7a,0x77,0x82); +DEFINE_GUID(IID_IXMLDOMAttribute,0x2933bf85,0x7b36,0x11d2,0xb2,0x0e,0x00,0xc0,0x4f,0x98,0x3e,0x60); +DEFINE_GUID(IID_IXMLDOMCharacterData,0x2933bf84,0x7b36,0x11d2,0xb2,0x0e,0x00,0xc0,0x4f,0x98,0x3e,0x60); +DEFINE_GUID(IID_IXMLDOMCDATASection,0x2933bf8a,0x7b36,0x11d2,0xb2,0x0e,0x00,0xc0,0x4f,0x98,0x3e,0x60); +DEFINE_GUID(IID_IXMLDOMComment,0x2933bf88,0x7b36,0x11d2,0xb2,0x0e,0x00,0xc0,0x4f,0x98,0x3e,0x60); +DEFINE_GUID(IID_IXMLDOMDocument,0x2933bf81,0x7b36,0x11d2,0xb2,0x0e,0x00,0xc0,0x4f,0x98,0x3e,0x60); +DEFINE_GUID(IID_IXMLDOMDocumentFragment,0x3efaa413,0x272f,0x11d2,0x83,0x6f,0x00,0x00,0xf8,0x7a,0x77,0x82); +DEFINE_GUID(IID_IXMLDOMDocumentType,0x2933bf8b,0x7b36,0x11d2,0xb2,0x0e,0x00,0xc0,0x4f,0x98,0x3e,0x60); +DEFINE_GUID(IID_IXMLDOMElement,0x2933bf86,0x7b36,0x11d2,0xb2,0x0e,0x00,0xc0,0x4f,0x98,0x3e,0x60); +DEFINE_GUID(IID_IXMLDOMEntity,0x2933bf8d,0x7b36,0x11d2,0xb2,0x0e,0x00,0xc0,0x4f,0x98,0x3e,0x60); +DEFINE_GUID(IID_IXMLDOMEntityReference,0x2933bf8e,0x7b36,0x11d2,0xb2,0x0e,0x00,0xc0,0x4f,0x98,0x3e,0x60); +DEFINE_GUID(IID_IXMLDOMImplementation,0x2933bf8e,0x7b36,0x11d2,0xb2,0x0e,0x00,0xc0,0x4f,0x98,0x3e,0x60); +DEFINE_GUID(IID_IXMLDOMNamedNodeMap,0x2933bf83,0x7b36,0x11d2,0xb2,0x0e,0x00,0xc0,0x4f,0x98,0x3e,0x60); +DEFINE_GUID(IID_IXMLDOMNode,0x2933bf80,0x7b36,0x11d2,0xb2,0x0e,0x00,0xc0,0x4f,0x98,0x3e,0x60); +DEFINE_GUID(IID_IXMLDOMNodeList,0x2933bf82,0x7b36,0x11d2,0xb2,0x0e,0x00,0xc0,0x4f,0x98,0x3e,0x60); +DEFINE_GUID(IID_IXMLDOMNotation,0x2933bf8c,0x7b36,0x11d2,0xb2,0x0e,0x00,0xc0,0x4f,0x98,0x3e,0x60); +DEFINE_GUID(IID_IXMLDOMParseError,0x3efaa426,0x272f,0x11d2,0x83,0x6f,0x00,0x00,0xf8,0x7a,0x77,0x82); +DEFINE_GUID(IID_IXMLDOMProcessingInstruction,0x2933bf89,0x7b36,0x11d2,0xb2,0x0e,0x00,0xc0,0x4f,0x98,0x3e,0x60); +DEFINE_GUID(IID_IXMLDOMText,0x2933bf87,0x7b36,0x11d2,0xb2,0x0e,0x00,0xc0,0x4f,0x98,0x3e,0x60); +DEFINE_GUID(IID_IXMLHttpRequest,0xed8c108d,0x4349,0x11d2,0x91,0xa4,0x00,0xc0,0x4f,0x79,0x69,0xe8); +DEFINE_GUID(IID_IXTLRuntime,0x3efaa425,0x272f,0x11d2,0x83,0x6f,0x00,0x00,0xf8,0x7a,0x77,0x82); diff --git a/lib/libc/mingw/libsrc/netcon-uuid.c b/lib/libc/mingw/libsrc/netcon-uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..08f345cc9ebb49d1640ed28becc03ccb506ecad1 --- /dev/null +++ b/lib/libc/mingw/libsrc/netcon-uuid.c @@ -0,0 +1,19 @@ +/* netcon-uuid.c */ +/* Generate GUIDs for network connection management interfaces */ + +#define INITGUID +#include +DEFINE_GUID(CLSID_NetSharingManager,0x5c63c1ad,0x3956,0x4ff8,0x84,0x86,0x40,0x03,0x47,0x58,0x31,0x5b); +DEFINE_GUID(IID_INetConnection,0xc08956a1,0x1cd3,0x11d1,0xb1,0xc5,0x00,0x80,0x5f,0xc1,0x27,0x0e); +DEFINE_GUID(IID_INetSharingPortMappingProps,0x24b7e9b5,0xe38f,0x4685,0x85,0x1b,0x00,0x89,0x2c,0xf5,0xf9,0x40); +DEFINE_GUID(IID_INetSharingPortMapping,0xc08956b1,0x1cd3,0x11d1,0xb1,0xc5,0x00,0x80,0x5f,0xc1,0x27,0x0e); +DEFINE_GUID(IID_INetSharingPortMappingCollection,0x02e4a2de,0xda20,0x4e34,0x89,0xc8,0xac,0x22,0x27,0x5a,0x01,0x0b); +DEFINE_GUID(IID_INetSharingConfiguration,0xc08956b6,0x1cd3,0x11d1,0xb1,0xc5,0x00,0x80,0x5f,0xc1,0x27,0x0e); +DEFINE_GUID(IID_IEnumNetSharingPublicConnection,0xc08956b4,0x1cd3,0x11d1,0xb1,0xc5,0x00,0x80,0x5f,0xc1,0x27,0x0e); +DEFINE_GUID(IID_IEnumNetSharingPrivateConnection,0xc08956b5,0x1cd3,0x11d1,0xb1,0xc5,0x00,0x80,0x5f,0xc1,0x27,0x0e); +DEFINE_GUID(IID_INetConnectionProps,0xf4277c95,0xce5b,0x463d,0x81,0x67,0x56,0x62,0xd9,0xbc,0xaa,0x72); +DEFINE_GUID(IID_INetSharingPublicConnectionCollection,0x7d7a6355,0xf372,0x4971,0xa1,0x49,0xbf,0xc9,0x27,0xbe,0x76,0x2a); +DEFINE_GUID(IID_INetSharingEveryConnectionCollection,0x33c4643c,0x7811,0x46fa,0xa8,0x9a,0x76,0x85,0x97,0xbd,0x72,0x23); +DEFINE_GUID(IID_INetSharingPrivateConnectionCollection,0x38ae69e0,0x4409,0x402a,0xa2,0xcb,0xe9,0x65,0xc7,0x27,0xf8,0x40); +DEFINE_GUID(IID_INetSharingManager,0xc08956b7,0x1cd3,0x11d1,0xb1,0xc5,0x00,0x80,0x5f,0xc1,0x27,0x0e); + diff --git a/lib/libc/mingw/libsrc/ntddkbd-uuid.c b/lib/libc/mingw/libsrc/ntddkbd-uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..dea453d20ab1beb7e806e8b562029b851ac410ee --- /dev/null +++ b/lib/libc/mingw/libsrc/ntddkbd-uuid.c @@ -0,0 +1,7 @@ +/* from ntddkbd.h */ + +#define INITGUID +#include + +DEFINE_GUID(GUID_DEVINTERFACE_KEYBOARD, 0x884b96c3, 0x56ef, 0x11d1, 0xbc, 0x8c, 0x00, 0xa0, 0xc9, 0x14, 0x05, 0xdd); + diff --git a/lib/libc/mingw/libsrc/ntddmou-uuid.c b/lib/libc/mingw/libsrc/ntddmou-uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..b6e9f6de42c7c52e0403d807557b1cf500f493e6 --- /dev/null +++ b/lib/libc/mingw/libsrc/ntddmou-uuid.c @@ -0,0 +1,7 @@ +/* from ntddmou.h */ + +#define INITGUID +#include + +DEFINE_GUID(GUID_DEVINTERFACE_MOUSE, 0x378de44c, 0x56ef, 0x11d1, 0xbc, 0x8c, 0x00, 0xa0, 0xc9, 0x14, 0x05, 0xdd); + diff --git a/lib/libc/mingw/libsrc/ntddpar-uuid.c b/lib/libc/mingw/libsrc/ntddpar-uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..ad4f13dc6ee31ccde5d0eb008c9242d2075ecc25 --- /dev/null +++ b/lib/libc/mingw/libsrc/ntddpar-uuid.c @@ -0,0 +1,12 @@ +/* Parallel port device GUIDs */ +/* from ntddpar.h */ + +#define INITGUID +#include + +#define GUID_PARALLEL_DEVICE GUID_DEVINTERFACE_PARALLEL +#define GUID_PARCLASS_DEVICE GUID_DEVINTERFACE_PARCLASS + +DEFINE_GUID (GUID_DEVINTERFACE_PARALLEL, 0x97F76EF0, 0xF883, 0x11D0, 0xAF, 0x1F, 0x00, 0x00, 0xF8, 0x00, 0x84, 0x5C); +DEFINE_GUID (GUID_DEVINTERFACE_PARCLASS, 0x811FC6A5, 0xF728, 0x11D0, 0xA5, 0x37, 0x00, 0x00, 0xF8, 0x75, 0x3E, 0xD1); + diff --git a/lib/libc/mingw/libsrc/ntddscsi-uuid.c b/lib/libc/mingw/libsrc/ntddscsi-uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..b7ab40a68cc0892a5809532760c6e5eea9261ee6 --- /dev/null +++ b/lib/libc/mingw/libsrc/ntddscsi-uuid.c @@ -0,0 +1,8 @@ +/* from ntddscsi.h */ + +#define INITGUID +#include + +DEFINE_GUID(ScsiRawInterfaceGuid,0x53f56309L,0xb6bf,0x11d0,0x94,0xf2,0x00,0xa0,0xc9,0x1e,0xfb,0x8b); +DEFINE_GUID(WmiScsiAddressGuid,0x53f5630fL,0xb6bf,0x11d0,0x94,0xf2,0x00,0xa0,0xc9,0x1e,0xfb,0x8b); + diff --git a/lib/libc/mingw/libsrc/ntddser-uuid.c b/lib/libc/mingw/libsrc/ntddser-uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..a0126f055a877be938c132557cf622aebc5b210c --- /dev/null +++ b/lib/libc/mingw/libsrc/ntddser-uuid.c @@ -0,0 +1,11 @@ +/* from ntddser.h */ + +#define INITGUID +#include + +#define GUID_CLASS_COMPORT GUID_DEVINTERFACE_COMPORT +#define GUID_SERENUM_BUS_ENUMERATOR GUID_DEVINTERFACE_SERENUM_BUS_ENUMERATOR + +DEFINE_GUID(GUID_DEVINTERFACE_COMPORT, 0x86e0d1e0L, 0x8089, 0x11d0, 0x9c, 0xe4, 0x08, 0x00, 0x3e, 0x30, 0x1f, 0x73); +DEFINE_GUID(GUID_DEVINTERFACE_SERENUM_BUS_ENUMERATOR, 0x4D36E978L, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18); + diff --git a/lib/libc/mingw/libsrc/ntddstor-uuid.c b/lib/libc/mingw/libsrc/ntddstor-uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..b109e82cc70d28ca5caab196e310ccd3b6f41a8d --- /dev/null +++ b/lib/libc/mingw/libsrc/ntddstor-uuid.c @@ -0,0 +1,41 @@ +/* from ntddstor.h */ + +#define INITGUID +#include + +DEFINE_GUID(GUID_DEVINTERFACE_DISK, + 0x53f56307L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b); + +DEFINE_GUID(GUID_DEVINTERFACE_CDROM, + 0x53f56308L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b); + +DEFINE_GUID(GUID_DEVINTERFACE_PARTITION, + 0x53f5630aL, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b); + +DEFINE_GUID(GUID_DEVINTERFACE_TAPE, + 0x53f5630bL, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b); + +DEFINE_GUID(GUID_DEVINTERFACE_WRITEONCEDISK, + 0x53f5630cL, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b); + +DEFINE_GUID(GUID_DEVINTERFACE_VOLUME, + 0x53f5630dL, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b); + +DEFINE_GUID(GUID_DEVINTERFACE_MEDIUMCHANGER, + 0x53f56310L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b); + +DEFINE_GUID(GUID_DEVINTERFACE_FLOPPY, + 0x53f56311L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b); + +DEFINE_GUID(GUID_DEVINTERFACE_CDCHANGER, + 0x53f56312L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b); + +DEFINE_GUID(GUID_DEVINTERFACE_STORAGEPORT, + 0x2accfe60L, 0xc130, 0x11d2, 0xb0, 0x82, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b); + +DEFINE_GUID(GUID_DEVINTERFACE_HIDDEN_VOLUME, + 0x7f108a28L, 0x9833, 0x4b3b, 0xb7, 0x80, 0x2c, 0x6b, 0x5f, 0xa5, 0xc0, 0x62); + +#define WDI_STORAGE_PREDICT_FAILURE_DPS_GUID \ + {0xe9f2d03aL, 0x747c, 0x41c2, {0xbb, 0x9a, 0x02, 0xc6, 0x2b, 0x6d, 0x5f, 0xcb}}; + diff --git a/lib/libc/mingw/libsrc/ntddvdeo-uuid.c b/lib/libc/mingw/libsrc/ntddvdeo-uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..740e677b7cef5fa7afddb8f5511d63e7bc68657f --- /dev/null +++ b/lib/libc/mingw/libsrc/ntddvdeo-uuid.c @@ -0,0 +1,7 @@ +/* from ntddvdeo.h */ + +#define INITGUID +#include + +DEFINE_GUID(GUID_DEVINTERFACE_DISPLAY_ADAPTER, 0x5b45201d, 0xf2f2, 0x4f3b, 0x85, 0xbb, 0x30, 0xff, 0x1f, 0x95, 0x35, 0x99); + diff --git a/lib/libc/mingw/libsrc/oaidl-uuid.c b/lib/libc/mingw/libsrc/oaidl-uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..20d84d452e4b61cd66c5556ca414964f05732808 --- /dev/null +++ b/lib/libc/mingw/libsrc/oaidl-uuid.c @@ -0,0 +1,20 @@ +/* oaidl-uuid.c */ +/* Generate GUIDs for OA IDL interfaces */ + +/* All IIDs defined in this file were extracted from + * HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface\ */ + +#define INITGUID +#include +DEFINE_GUID(IID_IErrorInfo,0x1cf2b120,0x547d,0x101b,0x8e,0x65,0x8,0,0x2b,0x2b,0xd1,0x19); +DEFINE_GUID(IID_ICreateErrorInfo,0x22f03340,0x547d,0x101b,0x8e,0x65,0x8,0,0x2b,0x2b,0xd1,0x19); +DEFINE_GUID(IID_ISupportErrorInfo,0xdf0b3d60,0x548f,0x101b,0x8e,0x65,0x8,0,0x2b,0x2b,0xd1,0x19); +DEFINE_OLEGUID(IID_ICreateTypeInfo,0x20405,0,0); +DEFINE_OLEGUID(IID_ICreateTypeInfo2,0x2040e,0,0); +DEFINE_OLEGUID(IID_ICreateTypeLib,0x20406,0,0); +DEFINE_OLEGUID(IID_ICreateTypeLib2,0x2040F,0,0); +DEFINE_OLEGUID(IID_ITypeInfo,0x20401,0,0); +DEFINE_OLEGUID(IID_ITypeInfo2,0x20412,0,0); +DEFINE_OLEGUID(IID_ITypeLib,0x20402,0,0); +DEFINE_OLEGUID(IID_ITypeLib2,0x20411,0,0); +DEFINE_OLEGUID(IID_IEnumVARIANT,0x20404,0,0); diff --git a/lib/libc/mingw/libsrc/objidl-uuid.c b/lib/libc/mingw/libsrc/objidl-uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..5a41ed276c1165c4978a0622f3728cf1dadf57b8 --- /dev/null +++ b/lib/libc/mingw/libsrc/objidl-uuid.c @@ -0,0 +1,43 @@ +/* objidl-uuid.c */ +/* Generate GUIDs for Object IDL interfaces */ + +/* All IIDs defined in this file were extracted from + * HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface\ */ + +#define INITGUID +#include +DEFINE_OLEGUID(IID_IMarshal,0x3,0,0); +DEFINE_OLEGUID(IID_IStream,0xc,0,0); +DEFINE_OLEGUID(IID_IMalloc,0x2,0,0); +DEFINE_OLEGUID(IID_IMessageFilter,0x16,0,0); +DEFINE_OLEGUID(IID_IPersist,0x10c,0,0); +DEFINE_OLEGUID(IID_IPersistFile,0x10b,0,0); +DEFINE_OLEGUID(IID_IPersistStorage,0x10a,0,0); +DEFINE_OLEGUID(IID_IPersistStream,0x109,0,0); +DEFINE_OLEGUID(IID_IMoniker,0xf,0,0); +DEFINE_OLEGUID(IID_IAdviseSink,0x10f,0,0); +/*DEFINE_OLEGUID(IID_IAdviseSink2,0x125,0,0);*/ +DEFINE_OLEGUID(IID_IDataObject,0x10e,0,0); +DEFINE_OLEGUID(IID_IDataAdviseHolder,0x110,0,0); +DEFINE_OLEGUID(IID_IStorage,0xb,0,0); +DEFINE_OLEGUID(IID_IRootStorage,0x12,0,0); +DEFINE_GUID(IID_IRpcChannelBuffer,0xd5f56b60,0x593b,0x101a,0xb5,0x69,0x8,0,0x2b,0x2d,0xbf,0x7a); +DEFINE_GUID(IID_IRpcProxyBuffer,0xd5f56a34,0x593b,0x101a,0xb5,0x69,8,0,0x2b,0x2d,0xbf,0x7a); +DEFINE_GUID(IID_IRpcStubBuffer,0xd5f56afc,0x593b,0x101a,0xb5,0x69,0x8,0,0x2b,0x2d,0xbf,0x7a); +DEFINE_GUID(IID_ISequentialStream,0xc733a30,0x2a1c,0x11ce,0xad,0xe5,0,0xaa,0,0x44,0x77,0x3d); +DEFINE_OLEGUID(IID_IStdMarshalInfo,0x18,0,0); +DEFINE_OLEGUID(IID_IRunningObjectTable,0x10,0,0); +DEFINE_OLEGUID(IID_IBindCtx,0xe,0,0); +DEFINE_GUID(IID_IPSFactoryBuffer,0xd5f569d0,0x593b,0x101a,0xb5,0x69,0x8,0,0x2b,0x2d,0xbf,0x7a); +DEFINE_OLEGUID(IID_ILockBytes,0xa,0,0); +DEFINE_OLEGUID(IID_IExternalConnection,0x19,0,0); +DEFINE_OLEGUID(IID_IRunnableObject,0x126,0,0); +DEFINE_GUID(IID_IROTData,0xf29f6bc0,0x5021,0x11ce,0xaa,0x15,0,0,0x69,0x1,0x29,0x3f); +DEFINE_OLEGUID(IID_IPropertySetStorage,0x13a,0,0); +DEFINE_OLEGUID(IID_IPropertyStorage,0x138,0,0); +DEFINE_OLEGUID(IID_IClassActivator,0x140,0,0); +DEFINE_GUID(IID_IFillLockBytes,0x99caf010,0x415e,0x11cf,0x88,0x14,0,0xaa,0,0xb5,0x69,0xf5); +DEFINE_GUID(IID_IProgressNotify,0xa9d758a0,0x4617,0x11cf,0x95,0xfc,0,0xaa,0,0x68,0xd,0xb4); +DEFINE_OLEGUID(IID_IClientSecurity,0x13D,0,0); +DEFINE_OLEGUID(IID_IMallocSpy,0x1d,0,0); +DEFINE_OLEGUID(IID_IServerSecurity,0x13E,0,0); diff --git a/lib/libc/mingw/libsrc/objsafe-uuid.c b/lib/libc/mingw/libsrc/objsafe-uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..6deae9a40d9b079ee174fa101daaf69998ca0759 --- /dev/null +++ b/lib/libc/mingw/libsrc/objsafe-uuid.c @@ -0,0 +1,9 @@ +/* objsafe-uuid.c */ +/* Generate GUIDs for Object Safe interfaces */ + +/* All IIDs defined in this file were extracted from + * HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface\ */ + +#define INITGUID +#include +DEFINE_GUID(IID_IObjectSafety,0xcb5bdc81,0x93c1,0x11cf,0x8f,0x20,0,0x80,0x5f,0x2c,0xd0,0x64); diff --git a/lib/libc/mingw/libsrc/ocidl-uuid.c b/lib/libc/mingw/libsrc/ocidl-uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..5dbab20f063e0bf764cadd0ad13f0bc8cfe9c3e6 --- /dev/null +++ b/lib/libc/mingw/libsrc/ocidl-uuid.c @@ -0,0 +1,46 @@ +/* ocidl-uuid.c */ +/* Generate GUIDs for OCIDL interfaces */ + +/* All IIDs defined in this file were extracted from + * HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface\ */ + +#define INITGUID +#include +DEFINE_GUID(IID_IQuickActivate,0xcf51ed10,0x62fe,0x11cf,0xbf,0x86,0,0xa0,0xc9,0x3,0x48,0x36); +DEFINE_GUID(IID_IOleUndoManager,0xd001f200,0xef97,0x11ce,0x9b,0xc9,0,0xaa,0,0x60,0x8e,0x1); +DEFINE_GUID(IID_IOleParentUndoUnit,0xa1faf330,0xef97,0x11ce,0x9b,0xc9,0,0xaa,0,0x60,0x8e,0x1); +DEFINE_GUID(IID_IOleUndoUnit,0x894ad3b0,0xef97,0x11ce,0x9b,0xc9,0,0xaa,0,0x60,0x8e,0x1); +DEFINE_GUID(IID_IEnumOleUndoUnits,0xb3e7c340,0xef97,0x11ce,0x9b,0xc9,0,0xaa,0,0x60,0x8e,0x1); +DEFINE_GUID(IID_IPointerInactive,0x55980ba0,0x35aa,0x11cf,0xb6,0x71,0,0xaa,0,0x4c,0xd6,0xd8); +/*DEFINE_GUID(IID_IAdviseSinkEx,0x3af24290,0xc96,0x11ce,0xa0,0xcf,0,0xaa,0,0x60,0xa,0xb8);*/ +DEFINE_GUID(IID_IOleInPlaceSiteEx,0x9c2cad80,0x3424,0x11cf,0xb6,0x70,0,0xaa,0,0x4c,0xd6,0xd8); +DEFINE_GUID(IID_IOleControl,0xb196b288,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7); +DEFINE_GUID(IID_IOleControlSite,0xB196B289,0xBAB4,0x101A,0xB6,0x9C,0x00,0xAA,0x00,0x34,0x1D,0x07); +DEFINE_GUID(IID_IPersistPropertyBag,0x37d84f60,0x42cb,0x11ce,0x81,0x35,0,0xaa,0,0x4b,0xb8,0x51); +DEFINE_GUID(IID_IPersistPropertyBag2,0x22f55881,0x280b,0x11d0,0xa8,0xa9,0,0xa0,0xc9,0xc,0x20,4); +DEFINE_GUID(IID_IPersistStreamInit,0x7fd52380,0x4e07,0x101b,0xae,0x2d,0x8,0,0x2b,0x2e,0xc7,0x13); +DEFINE_GUID(IID_IPersistMemory,0xbd1ae5e0,0xa6ae,0x11ce,0xbd,0x37,0x50,0x42,0,0xc1,0,0); +DEFINE_GUID(IID_IPropertyBag,0x55272a00,0x42cb,0x11ce,0x81,0x35,0,0xaa,0,0x4b,0xb8,0x51); +DEFINE_GUID(IID_IPropertyBag2,0x22f55882,0x280b,0x11d0,0xa8,0xa9,0,0xa0,0xc9,0xc,0x20,0x4); +DEFINE_GUID(IID_IPropertyNotifySink,0x9bfbbc02,0xeff1,0x101a,0x84,0xed,0,0xaa,0,0x34,0x1d,0x7); +DEFINE_GUID(IID_IPropertyPage,0xb196b28d,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7); +DEFINE_GUID(IID_IPropertyPage2,0x1e44665,0x24ac,0x101b,0x84,0xed,0x8,0,0x2b,0x2e,0xc7,0x13); +DEFINE_GUID(IID_IPropertyPageSite,0xb196b28c,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7); +DEFINE_GUID(IID_IFont,0xbef6e002,0xa874,0x101a,0x8b,0xba,0,0xaa,0,0x30,0xc,0xab); +// Font +DEFINE_GUID(IID_IFontDisp,0xbef6e003,0xa874,0x101a,0x8b,0xba,0,0xaa,0,0x30,0xc,0xab); +DEFINE_GUID(IID_IPicture,0x7bf80980,0xbf32,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab); +// Picture +DEFINE_GUID(IID_IPictureDisp,0x7bf80981,0xbf32,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab); +DEFINE_GUID(IID_IProvideClassInfo,0xb196b283,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7); +DEFINE_GUID(IID_IProvideClassInfo2,0xa6bc3ac0,0xdbaa,0x11ce,0x9d,0xe3,0,0xaa,0,0x4b,0xb8,0x51); +DEFINE_GUID(IID_IEnumConnectionPoints,0xb196b285,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7); +DEFINE_GUID(IID_IEnumConnections,0xb196b287,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7); +DEFINE_GUID(IID_IConnectionPoint,0xb196b286,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7); +DEFINE_GUID(IID_IConnectionPointContainer,0xb196b284,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7); +DEFINE_GUID(IID_IClassFactory2,0xb196b28f,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7); +DEFINE_GUID(IID_IErrorLog,0x3127ca40,0x446e,0x11ce,0x81,0x35,0,0xaa,0,0x4b,0xb8,0x51); +DEFINE_GUID(IID_IObjectWithSite,0xfc4801a3,0x2ba9,0x11cf,0xa2,0x29,0,0xaa,0,0x3d,0x73,0x52); +DEFINE_GUID(IID_IPerPropertyBrowsing,0x376bd3aa,0x3845,0x101b,0x84,0xed,0x8,0,0x2b,0x2e,0xc7,0x13); +DEFINE_GUID(IID_ISimpleFrameSite,0x742b0e01,0x14e6,0x101b,0x91,0x4e,0,0xaa,0,0x30,0xc,0xab); +DEFINE_GUID(IID_ISpecifyPropertyPages,0xb196b28b,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7); diff --git a/lib/libc/mingw/libsrc/oleacc-uuid.c b/lib/libc/mingw/libsrc/oleacc-uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..3a47f45a446a0ca91606c3fb64feddc82e4590eb --- /dev/null +++ b/lib/libc/mingw/libsrc/oleacc-uuid.c @@ -0,0 +1,12 @@ +/* oleacc-uuid.c */ +/* Generate GUIDs for OLE Accessibility interfaces */ + +/* All IIDs defined in this file were extracted from + * HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface\ */ + +#define INITGUID +#include +DEFINE_GUID(IID_IAccessible,0x618736e0,0x3c3d,0x11cf,0x81,0x0c,0x00,0xaa,0x00,0x38,0x9b,0x71); +// IAccessibleHandler TypeLib +DEFINE_GUID(LIBID_Accessibility, 0x1ea4dbf0, 0x3c3b,0x11cf, 0x81, 0x0c, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71); +DEFINE_GUID(IID_IAccessibleHandler, 0x03022430, 0xABC4, 0x11d0, 0xBD, 0xE2, 0x00, 0xAA, 0x00, 0x1A, 0x19, 0x53); diff --git a/lib/libc/mingw/libsrc/olectlid-uuid.c b/lib/libc/mingw/libsrc/olectlid-uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..1fde2dc98f525ad5069efc7f5655d69c8f901b5f --- /dev/null +++ b/lib/libc/mingw/libsrc/olectlid-uuid.c @@ -0,0 +1,36 @@ +/* olectlid-uuid.c */ +/* Generate GUIDs for OLECTLID interfaces */ + +/* All IIDs defined in this file were extracted from + * HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface\ */ + +/* All CLSIDs defined in this file were extracted from + * HKEY_CLASSES_ROOT\CLSID\ */ + +#define INITGUID +#include +DEFINE_OLEGUID(IID_IDispatch,0x20400,0,0); +DEFINE_OLEGUID(IID_IEnumUnknown,0x100,0,0); +DEFINE_OLEGUID(IID_IEnumString,0x101,0,0); +DEFINE_OLEGUID(IID_IEnumMoniker,0x102,0,0); +DEFINE_OLEGUID(IID_IEnumFORMATETC,0x103,0,0); +DEFINE_OLEGUID(IID_IEnumOLEVERB,0x104,0,0); +DEFINE_OLEGUID(IID_IEnumSTATDATA,0x105,0,0); +DEFINE_OLEGUID(IID_IEnumSTATSTG,0xd,0,0); +DEFINE_OLEGUID(IID_IOleLink,0x11d,0,0); +DEFINE_OLEGUID(IID_IDebug,0x123,0,0); +DEFINE_OLEGUID(IID_IDebugStream,0x124,0,0); +// Font Property Page CLSID +DEFINE_GUID(CLSID_CFontPropPage, 0x0be35200,0x8f91,0x11ce,0x9d,0xe3,0x00,0xaa,0x00,0x4b,0xb8,0x51); +// Color Property Page CLSID +DEFINE_GUID(CLSID_CColorPropPage,0xbe35201,0x8f91,0x11ce,0x9d,0xe3,0,0xaa,0,0x4b,0xb8,0x51); +// Picture Property Page CLSID +DEFINE_GUID(CLSID_CPicturePropPage,0xbe35202,0x8f91,0x11ce,0x9d,0xe3,0,0xaa,0,0x4b,0xb8,0x51); +// Standard Font CLSID +DEFINE_GUID(CLSID_StdFont,0xbe35203,0x8f91,0x11ce,0x9d,0xe3,0,0xaa,0,0x4b,0xb8,0x51); +// Standard Picture CLSID +DEFINE_GUID(CLSID_StdPicture,0xbe35204,0x8f91,0x11ce,0x9d,0xe3,0,0xaa,0,0x4b,0xb8,0x51); +// Picture (Metafile) CLSID +DEFINE_OLEGUID(CLSID_Picture_Metafile,0x315,0,0); +// Picture (Device Independent Bitmap) CLSID +DEFINE_OLEGUID(CLSID_Picture_Dib,0x316,0,0); diff --git a/lib/libc/mingw/libsrc/oleidl-uuid.c b/lib/libc/mingw/libsrc/oleidl-uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..929754e00f849be4540541238feed9773fa55e7f --- /dev/null +++ b/lib/libc/mingw/libsrc/oleidl-uuid.c @@ -0,0 +1,27 @@ +/* oleidl-uuid.c */ +/* Generate GUIDs for OLE IDL interfaces */ + +/* All IIDs defined in this file were extracted from + * HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface\ */ + +#define INITGUID +#include +DEFINE_OLEGUID(IID_IOleCache,0x11e,0,0); +DEFINE_OLEGUID(IID_IOleCache2,0x128,0,0); +DEFINE_OLEGUID(IID_IOleCacheControl,0x129,0,0); +DEFINE_OLEGUID(IID_IViewObject,0x10d,0,0); +DEFINE_OLEGUID(IID_IViewObject2,0x127,0,0); +DEFINE_OLEGUID(IID_IDropSource,0x121,0,0); +DEFINE_OLEGUID(IID_IDropTarget,0x122,0,0); +DEFINE_OLEGUID(IID_IOleAdviseHolder,0x111,0,0); +DEFINE_OLEGUID(IID_IOleInPlaceUIWindow,0x115,0,0); +DEFINE_OLEGUID(IID_IOleInPlaceObject,0x113,0,0); +DEFINE_OLEGUID(IID_IOleInPlaceActiveObject,0x117,0,0); +DEFINE_OLEGUID(IID_IOleInPlaceFrame,0x116,0,0); +DEFINE_OLEGUID(IID_IOleInPlaceSite,0x119,0,0); +DEFINE_OLEGUID(IID_IOleContainer,0x11b,0,0); +DEFINE_OLEGUID(IID_IOleItemContainer,0x11c,0,0); +DEFINE_OLEGUID(IID_IOleClientSite,0x118,0,0); +DEFINE_OLEGUID(IID_IOleObject,0x112,0,0); +DEFINE_OLEGUID(IID_IOleWindow,0x114,0,0); +DEFINE_OLEGUID(IID_IParseDisplayName,0x11a,0,0); diff --git a/lib/libc/mingw/libsrc/power-uuid.c b/lib/libc/mingw/libsrc/power-uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..1126d282513d2becb7c85becb4e27c3b6ce17843 --- /dev/null +++ b/lib/libc/mingw/libsrc/power-uuid.c @@ -0,0 +1,18 @@ +/* power-uuid.c */ +/* Generate GUIDs for OLE Accessibility interfaces */ + +/* All IIDs defined in this file were found at "Registering for Power Events" on MSDN here: + * http://msdn2.microsoft.com/en-us/library/aa373195.aspx + */ + +#define INITGUID +#include +DEFINE_GUID(GUID_POWERSCHEME_PERSONALITY, 0x245d8541, 0x3943, 0x4422, 0xb0, 0x25, 0x13, 0xA7, 0x84, 0xF6, 0x79, 0xB7); +DEFINE_GUID(GUID_MIN_POWER_SAVINGS, 0x8c5e7fda, 0xe8bf, 0x4a96, 0x9a, 0x85, 0xa6, 0xe2, 0x3a, 0x8c, 0x63, 0x5c); +DEFINE_GUID(GUID_MAX_POWER_SAVINGS, 0xa1841308, 0x3541, 0x4fab, 0xbc, 0x81, 0xf7, 0x15, 0x56, 0xf2, 0x0b, 0x4a); +DEFINE_GUID(GUID_TYPICAL_POWER_SAVINGS, 0x381b4222, 0xf694, 0x41f0, 0x96, 0x85, 0xff, 0x5b, 0xb2, 0x60, 0xdf, 0x2e); +DEFINE_GUID(GUID_ACDC_POWER_SOURCE, 0x5d3e9a59, 0xe9D5, 0x4b00, 0xa6, 0xbd, 0xff, 0x34, 0xff, 0x51, 0x65, 0x48); +DEFINE_GUID(GUID_BATTERY_PERCENTAGE_REMAINING, 0xa7ad8041, 0xb45a, 0x4cae, 0x87, 0xa3, 0xee, 0xcb, 0xb4, 0x68, 0xa9, 0xe1); +DEFINE_GUID(GUID_IDLE_BACKGROUND_TASK, 0x515c31d8, 0xf734, 0x163d, 0xa0, 0xfd, 0x11, 0xa0, 0x8c, 0x91, 0xe8, 0xf1); +DEFINE_GUID(GUID_SYSTEM_AWAYMODE, 0x98a7f580, 0x01f7, 0x48aa, 0x9c, 0x0f, 0x44, 0x35, 0x2c, 0x29, 0xe5, 0xC0); +DEFINE_GUID(GUID_MONITOR_POWER_ON, 0x02731015, 0x4510, 0x4526, 0x99, 0xe6, 0xe5, 0xa1, 0x7e, 0xbd, 0x1a, 0xea); diff --git a/lib/libc/mingw/libsrc/powrprof-uuid.c b/lib/libc/mingw/libsrc/powrprof-uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..931f4c66d553aafbe3cc91dfa07a6f31a1ffafc0 --- /dev/null +++ b/lib/libc/mingw/libsrc/powrprof-uuid.c @@ -0,0 +1,15 @@ +/* +http://msdn.microsoft.com/en-us/library/aa372725%28v=VS.85%29.aspx +PowerCreatePossibleSetting GUIDs +*/ + +#define INITGUID +#include +DEFINE_GUID(NO_SUBGROUP_GUID,0xfea3413e,0x7e05,0x4911,0x9a,0x71,0x70,0x03,0x31,0xf1,0xc2,0x94); +DEFINE_GUID(GUID_DISK_SUBGROUP,0x0012ee47,0x9041,0x4b5d,0x9b,0x77,0x53,0x5f,0xba,0x8b,0x14,0x42); +DEFINE_GUID(GUID_SYSTEM_BUTTON_SUBGROUP,0x4f971e89,0xeebd,0x4455,0xa8,0xde,0x9e,0x59,0x04,0x0e,0x73,0x47); +DEFINE_GUID(GUID_PROCESSOR_SETTINGS_SUBGROUP,0x54533251,0x82be,0x4824,0x96,0xc1,0x47,0xb6,0x0b,0x74,0x0d,0x00); +DEFINE_GUID(GUID_VIDEO_SUBGROUP,0x7516b95f,0xf776,0x4464,0x8c,0x53,0x06,0x16,0x7f,0x40,0xcc,0x99); +DEFINE_GUID(GUID_BATTERY_SUBGROUP,0xe73a048d,0xbf27,0x4f12,0x97,0x31,0x8b,0x20,0x76,0xe8,0x89,0x1f); +DEFINE_GUID(GUID_SLEEP_SUBGROUP,0x238C9FA8,0x0AAD,0x41ED,0x83,0xF4,0x97,0xBE,0x24,0x2C,0x8F,0x20); +DEFINE_GUID(GUID_PCIEXPRESS_SETTINGS_SUBGROUP,0x501a4d13,0x42af,0x4429,0x9f,0xd1,0xa8,0x21,0x8c,0x26,0x8e,0x20); diff --git a/lib/libc/mingw/libsrc/uianimation-uuid.c b/lib/libc/mingw/libsrc/uianimation-uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..75c3a241727a1fc1c2dd97f70ebe28cd924d4ae8 --- /dev/null +++ b/lib/libc/mingw/libsrc/uianimation-uuid.c @@ -0,0 +1,44 @@ +/* uianimation-uuid.c */ +/* Generate GUIDs for Microsoft Windows Animation Manager interfaces */ +#define INITGUID +#include + +DEFINE_GUID(CLSID_UIAnimationManager, 0x4c1fc63a, 0x695c, 0x47e8, 0xa3,0x39, 0x1a,0x19,0x4b,0xe3,0xd0,0xb8); +DEFINE_GUID(CLSID_UIAnimationManager2, 0xd25d8842, 0x8884, 0x4a4a, 0xb3,0x21, 0x09,0x13,0x14,0x37,0x9b,0xdd); +DEFINE_GUID(CLSID_UIAnimationTransitionLibrary, 0x1d6322ad, 0xaa85, 0x4ef5, 0xa8,0x28, 0x86,0xd7,0x10,0x67,0xd1,0x45); +DEFINE_GUID(CLSID_UIAnimationTransitionLibrary2, 0x812f944a, 0xc5c8, 0x4cd9, 0xb0,0xa6, 0xb3,0xda,0x80,0x2f,0x22,0x8d); +DEFINE_GUID(CLSID_UIAnimationTransitionFactory, 0x8a9b1cdd, 0xfcd7, 0x419c, 0x8b,0x44, 0x42,0xfd,0x17,0xdb,0x18,0x87); +DEFINE_GUID(CLSID_UIAnimationTransitionFactory2, 0x84302f97, 0x7f7b, 0x4040, 0xb1,0x90, 0x72,0xac,0x9d,0x18,0xe4,0x20); +DEFINE_GUID(CLSID_UIAnimationTimer, 0xbfcd4a0c, 0x06b6, 0x4384, 0xb7,0x68, 0x0d,0xaa,0x79,0x2c,0x38,0x0e); +DEFINE_GUID(IID_IUIAnimationManager, 0x9169896c, 0xac8d, 0x4e7d, 0x94,0xe5, 0x67,0xfa,0x4d,0xc2,0xf2,0xe8); +DEFINE_GUID(IID_IUIAnimationVariable, 0x8ceeb155, 0x2849, 0x4ce5, 0x94,0x48, 0x91,0xff,0x70,0xe1,0xe4,0xd9); +DEFINE_GUID(IID_IUIAnimationStoryboard, 0xa8ff128f, 0x9bf9, 0x4af1, 0x9e,0x67, 0xe5,0xe4,0x10,0xde,0xfb,0x84); +DEFINE_GUID(IID_IUIAnimationTransition, 0xdc6ce252, 0xf731, 0x41cf, 0xb6,0x10, 0x61,0x4b,0x6c,0xa0,0x49,0xad); +DEFINE_GUID(IID_IUIAnimationStoryboardEventHandler, 0x3d5c9008, 0xec7c, 0x4364, 0x9f,0x8a, 0x9a,0xf3,0xc5,0x8c,0xba,0xe6); +DEFINE_GUID(IID_IUIAnimationVariableChangeHandler, 0x6358b7ba, 0x87d2, 0x42d5, 0xbf,0x71, 0x82,0xe9,0x19,0xdd,0x58,0x62); +DEFINE_GUID(IID_IUIAnimationVariableIntegerChangeHandler, 0xbb3e1550, 0x356e, 0x44b0, 0x99,0xda, 0x85,0xac,0x60,0x17,0x86,0x5e); +DEFINE_GUID(IID_IUIAnimationManagerEventHandler, 0x783321ed, 0x78a3, 0x4366, 0xb5,0x74, 0x6a,0xf6,0x07,0xa6,0x47,0x88); +DEFINE_GUID(IID_IUIAnimationPriorityComparison, 0x83fa9b74, 0x5f86, 0x4618, 0xbc,0x6a, 0xa2,0xfa,0xc1,0x9b,0x3f,0x44); +DEFINE_GUID(IID_IUIAnimationManager2, 0xd8b6f7d4, 0x4109, 0x4d3f, 0xac,0xee, 0x87,0x99,0x26,0x96,0x8c,0xb1); +DEFINE_GUID(IID_IUIAnimationVariable2, 0x4914b304, 0x96ab, 0x44d9, 0x9e,0x77, 0xd5,0x10,0x9b,0x7e,0x74,0x66); +DEFINE_GUID(IID_IDCompositionAnimation, 0xcbfd91d9, 0x51b2, 0x45e4, 0xb3,0xde, 0xd1,0x9c,0xcf,0xb8,0x63,0xc5); +DEFINE_GUID(IID_IUIAnimationStoryboard2, 0xae289cd2, 0x12d4, 0x4945, 0x94,0x19, 0x9e,0x41,0xbe,0x03,0x4d,0xf2); +DEFINE_GUID(IID_IUIAnimationTransition2, 0x62ff9123, 0xa85a, 0x4e9b, 0xa2,0x18, 0x43,0x5a,0x93,0xe2,0x68,0xfd); +DEFINE_GUID(IID_IUIAnimationLoopIterationChangeHandler2, 0x2d3b15a4, 0x4762, 0x47ab, 0xa0,0x30, 0xb2,0x32,0x21,0xdf,0x3a,0xe0); +DEFINE_GUID(IID_IUIAnimationStoryboardEventHandler2, 0xbac5f55a, 0xba7c, 0x414c, 0xb5,0x99, 0xfb,0xf8,0x50,0xf5,0x53,0xc6); +DEFINE_GUID(IID_IUIAnimationVariableChangeHandler2, 0x63acc8d2, 0x6eae, 0x4bb0, 0xb8,0x79, 0x58,0x6d,0xd8,0xcf,0xbe,0x42); +DEFINE_GUID(IID_IUIAnimationVariableIntegerChangeHandler2, 0x829b6cf1, 0x4f3a, 0x4412, 0xae,0x09, 0xb2,0x43,0xeb,0x4c,0x6b,0x58); +DEFINE_GUID(IID_IUIAnimationVariableCurveChangeHandler2, 0x72895e91, 0x0145, 0x4c21, 0x91,0x92, 0x5a,0xab,0x40,0xed,0xdf,0x80); +DEFINE_GUID(IID_IUIAnimationManagerEventHandler2, 0xf6e022ba, 0xbff3, 0x42ec, 0x90,0x33, 0xe0,0x73,0xf3,0x3e,0x83,0xc3); +DEFINE_GUID(IID_IUIAnimationPriorityComparison2, 0x5b6d7a37, 0x4621, 0x467c, 0x8b,0x05, 0x70,0x13,0x1d,0xe6,0x2d,0xdb); +DEFINE_GUID(IID_IUIAnimationTransitionLibrary, 0xca5a14b1, 0xd24f, 0x48b8, 0x8f,0xe4, 0xc7,0x81,0x69,0xba,0x95,0x4e); +DEFINE_GUID(IID_IUIAnimationTransitionLibrary2, 0x03cfae53, 0x9580, 0x4ee3, 0xb3,0x63, 0x2e,0xce,0x51,0xb4,0xaf,0x6a); +DEFINE_GUID(IID_IUIAnimationTransitionFactory, 0xfcd91e03, 0x3e3b, 0x45ad, 0xbb,0xb1, 0x6d,0xfc,0x81,0x53,0x74,0x3d); +DEFINE_GUID(IID_IUIAnimationInterpolator, 0x7815cbba, 0xddf7, 0x478c, 0xa4,0x6c, 0x7b,0x6c,0x73,0x8b,0x79,0x78); +DEFINE_GUID(IID_IUIAnimationTransitionFactory2, 0x937d4916, 0xc1a6, 0x42d5, 0x88,0xd8, 0x30,0x34,0x4d,0x6e,0xfe,0x31); +DEFINE_GUID(IID_IUIAnimationInterpolator2, 0xea76aff8, 0xea22, 0x4a23, 0xa0,0xef, 0xa6,0xa9,0x66,0x70,0x35,0x18); +DEFINE_GUID(IID_IUIAnimationPrimitiveInterpolation, 0xbab20d63, 0x4361, 0x45da, 0xa2,0x4f, 0xab,0x85,0x08,0x84,0x6b,0x5b); +DEFINE_GUID(IID_IUIAnimationTimer, 0x6b0efad1, 0xa053, 0x41d6, 0x90,0x85, 0x33,0xa6,0x89,0x14,0x46,0x65); +DEFINE_GUID(IID_IUIAnimationTimerUpdateHandler, 0x195509b7, 0x5d5e, 0x4e3e, 0xb2,0x78, 0xee,0x37,0x59,0xb3,0x67,0xad); +DEFINE_GUID(IID_IUIAnimationTimerClientEventHandler, 0xbedb4db6, 0x94fa, 0x4bfb, 0xa4,0x7f, 0xef,0x2d,0x9e,0x40,0x8c,0x25); +DEFINE_GUID(IID_IUIAnimationTimerEventHandler, 0x274a7dea, 0xd771, 0x4095, 0xab,0xbd, 0x8d,0xf7,0xab,0xd2,0x3c,0xe3); diff --git a/lib/libc/mingw/libsrc/usbcamdi-uuid.c b/lib/libc/mingw/libsrc/usbcamdi-uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..ec06d4d2fb554064ea6f57020e2d75709bcf547b --- /dev/null +++ b/lib/libc/mingw/libsrc/usbcamdi-uuid.c @@ -0,0 +1,7 @@ +/* from usbcamdi.h */ + +#define INITGUID +#include + +DEFINE_GUID(GUID_USBCAMD_INTERFACE, 0x2bcb75c0, 0xb27f, 0x11d1, 0xba, 0x41, 0x0, 0xa0, 0xc9, 0xd, 0x2b, 0x5); + diff --git a/lib/libc/mingw/libsrc/usbiodef-uuid.c b/lib/libc/mingw/libsrc/usbiodef-uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..45cb23a2638babd693f57d433b205c16d22f7225 --- /dev/null +++ b/lib/libc/mingw/libsrc/usbiodef-uuid.c @@ -0,0 +1,18 @@ +/* from usbiodef.h */ + +#define INITGUID +#include + +DEFINE_GUID(GUID_DEVINTERFACE_USB_HUB, 0xF18A0E88, 0xc30C, 0x11D0, 0x88, 0x15, 0x00, 0xA0, 0xC9, 0x06, 0xBE, 0xD8); +DEFINE_GUID(GUID_DEVINTERFACE_USB_DEVICE, 0xA5DCBF10L, 0x6530, 0x11D2, 0x90, 0x1F, 0x00, 0xC0, 0x4F, 0xB9, 0x51, 0xED); +DEFINE_GUID(GUID_DEVINTERFACE_USB_HOST_CONTROLLER, 0x3ABF6F2D, 0x71C4, 0x462A, 0x8A, 0x92, 0x1E, 0x68, 0x61, 0xE6, 0xAF, 0x27); +DEFINE_GUID(GUID_USB_WMI_STD_DATA, 0x4E623B20L, 0xCB14, 0x11D1, 0xB3, 0x31, 0x00, 0xA0, 0xC9, 0x59, 0xBB, 0xD2); +DEFINE_GUID(GUID_USB_WMI_STD_NOTIFICATION, 0x4E623B20L, 0xCB14, 0x11D1, 0xB3, 0x31, 0x00, 0xA0, 0xC9, 0x59, 0xBB, 0xD2); + +DEFINE_GUID(GUID_USB_WMI_DEVICE_PERF_INFO, 0x66c1aa3c, 0x499f, 0x49a0, 0xa9, 0xa5, 0x61, 0xe2, 0x35, 0x9f, 0x64, 0x7); +DEFINE_GUID(GUID_USB_WMI_NODE_INFO, 0x9c179357, 0xdc7a, 0x4f41, 0xb6, 0x6b, 0x32, 0x3b, 0x9d, 0xdc, 0xb5, 0xb1); +DEFINE_GUID(GUID_USB_WMI_HUB_DIAGNOSTICS, 0xad0379e4, 0x72db, 0x42ed, 0xba, 0x6e, 0x67, 0x57, 0x4, 0x79, 0x7, 0xd); +DEFINE_GUID(GUID_USB_WMI_TRACING, 0x3a61881b, 0xb4e6, 0x4bf9, 0xae, 0xf, 0x3c, 0xd8, 0xf3, 0x94, 0xe5, 0x2f); +DEFINE_GUID(GUID_USB_TRANSFER_TRACING, 0x681eb8aa, 0x403d, 0x452c, 0x9f, 0x8a, 0xf0, 0x61, 0x6f, 0xac, 0x95, 0x40); +DEFINE_GUID(GUID_USB_PERFORMANCE_TRACING, 0xd5de77a6, 0x6ae9, 0x425c, 0xb1, 0xe2, 0xf5, 0x61, 0x5f, 0xd3, 0x48, 0xa9); + diff --git a/lib/libc/mingw/libsrc/uuid.c b/lib/libc/mingw/libsrc/uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..37390f57bf4f68da27f42ff39f6453d92ae6a1ba --- /dev/null +++ b/lib/libc/mingw/libsrc/uuid.c @@ -0,0 +1,397 @@ +/* + Generate GUIDs for OLE and other interfaces. + + This file was generated by extracting the names of all GUIDs + from uuid.lib. The names were in turn processed by a script + to build a C program that when run generated this file. + Some definitions were added by hand afterwards. +*/ + +/* + TODO: Break up into smaller units, based on declarations in headers. +*/ + +#define INITGUID +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +DEFINE_GUID(ARRAYID_PathProperties,0x7ecbba04,0x2d97,0x11cf,0xa2,0x29,0,0xaa,0,0x3d,0x73,0x52); +DEFINE_GUID(CATID_InternetAware,0xde86a58,0x2baa,0x11cf,0xa2,0x29,0,0xaa,0,0x3d,0x73,0x52); +DEFINE_GUID(CATID_IsShortcut,0x40fc6ed6,0x2438,0x11cf,0xa3,0xdb,0x8,0,0x36,0xf1,0x25,0x2); +DEFINE_GUID(CATID_NeverShowExt,0x40fc6ed7,0x2438,0x11cf,0xa3,0xdb,0x8,0,0x36,0xf1,0x25,0x2); +DEFINE_GUID(CATID_PersistsToFile,0xde86a56,0x2baa,0x11cf,0xa2,0x29,0,0xaa,0,0x3d,0x73,0x52); +DEFINE_GUID(CATID_PersistsToMemory,0xde86a55,0x2baa,0x11cf,0xa2,0x29,0,0xaa,0,0x3d,0x73,0x52); +DEFINE_GUID(CATID_PersistsToMoniker,0xde86a51,0x2baa,0x11cf,0xa2,0x29,0,0xaa,0,0x3d,0x73,0x52); +DEFINE_GUID(CATID_RequiresDataPathHost,0xde86a50,0x2baa,0x11cf,0xa2,0x29,0,0xaa,0,0x3d,0x73,0x52); +DEFINE_GUID(CATID_SafeForInitializing,0x7dd95802,0x9882,0x11cf,0x9f,0xa9,0,0xaa,0,0x6c,0x42,0xc4); +DEFINE_GUID(CATID_SafeForScripting,0x7dd95801,0x9882,0x11cf,0x9f,0xa9,0,0xaa,0,0x6c,0x42,0xc4); +DEFINE_GUID(CLSID_AllClasses,0x330,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(CLSID_CColorPropPage,0xbe35201,0x8f91,0x11ce,0x9d,0xe3,0,0xaa,0,0x4b,0xb8,0x51); +DEFINE_GUID(CLSID_CFontPropPage, 0x0be35200,0x8f91,0x11ce,0x9d,0xe3,0x00,0xaa,0x00,0x4b,0xb8,0x51); +DEFINE_GUID(CLSID_CPicturePropPage,0xbe35202,0x8f91,0x11ce,0x9d,0xe3,0,0xaa,0,0x4b,0xb8,0x51); +DEFINE_GUID(CLSID_ConvertVBX,0xfb8f0822,0x164,0x101b,0x84,0xed,0x8,0,0x2b,0x2e,0xc7,0x13); +DEFINE_GUID(CLSID_CurrentUserClasses,0x332,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(CLSID_IdentityUnmarshal,0x1b,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(CLSID_InProcFreeMarshaler,0x1c,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(CLSID_LocalMachineClasses,0x331,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(CLSID_PSBindCtx,0x312,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(CLSID_PSClassObject,0x30E,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(CLSID_PSClientSite,0x30d,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(CLSID_PSDragDrop,0x311,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(CLSID_PSEnumerators,0x313,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(CLSID_PSGenObject,0x30c,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(CLSID_PSInPlaceActive,0x30f,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(CLSID_PSInPlaceFrame,0x310,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(CLSID_PersistPropset,0xfb8f0821,0x164,0x101b,0x84,0xed,0x8,0,0x2b,0x2e,0xc7,0x13); +DEFINE_GUID(CLSID_Picture_Dib,0x316,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(CLSID_Picture_EnhMetafile,0x319,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(CLSID_Picture_Metafile,0x315,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(CLSID_DCOMAccessControl,0x0000031d,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46); +DEFINE_GUID(CLSID_StaticDib,0x316,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(CLSID_StaticMetafile,0x315,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(CLSID_StdFont,0xbe35203,0x8f91,0x11ce,0x9d,0xe3,0,0xaa,0,0x4b,0xb8,0x51); +DEFINE_GUID(CLSID_StdHlink,0x79eac9d0,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb); +DEFINE_GUID(CLSID_StdHlinkBrowseContext,0x79eac9d1,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb); +DEFINE_GUID(CLSID_StdMarshal,0x17,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(CLSID_StdPicture,0xbe35204,0x8f91,0x11ce,0x9d,0xe3,0,0xaa,0,0x4b,0xb8,0x51); +DEFINE_GUID(CLSID_StdURLProtocol,0x79eac9e1,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb); +DEFINE_GUID(CLSID_CTask, 0x148BD520, 0xA2AB, 0x11CE, 0xB1, 0x1F, 0x00, 0xAA, 0x00, 0x53, 0x05, 0x03); +DEFINE_GUID(CLSID_CTaskScheduler, 0x148BD52A, 0xA2AB, 0x11CE, 0xB1, 0x1F, 0x00, 0xAA, 0x00, 0x53, 0x05, 0x03); +DEFINE_GUID(FLAGID_Internet,0x96300da0,0x2bab,0x11cf,0xa2,0x29,0,0xaa,0,0x3d,0x73,0x52); +DEFINE_GUID(FMTID_DocSummaryInformation,0xd5cdd502,0x2e9c,0x101b,0x93,0x97,0x8,0,0x2b,0x2c,0xf9,0xae); +DEFINE_GUID(FMTID_SummaryInformation,0xf29f85e0,0x4ff9,0x1068,0xab,0x91,0x8,0,0x2b,0x27,0xb3,0xd9); +DEFINE_GUID(FMTID_UserDefinedProperties,0xd5cdd505,0x2e9c,0x101b,0x93,0x97,0x8,0,0x2b,0x2c,0xf9,0xae); +DEFINE_GUID(GUID_CHECKVALUEEXCLUSIVE,0x6650430c,0xbe0f,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab); +DEFINE_GUID(GUID_COLOR,0x66504301,0xbe0f,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab); +DEFINE_GUID(GUID_FONTBOLD,0x6650430f,0xbe0f,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab); +DEFINE_GUID(GUID_FONTITALIC,0x66504310,0xbe0f,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab); +DEFINE_GUID(GUID_FONTNAME,0x6650430d,0xbe0f,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab); +DEFINE_GUID(GUID_FONTSIZE,0x6650430e,0xbe0f,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab); +DEFINE_GUID(GUID_FONTSTRIKETHROUGH,0x66504312,0xbe0f,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab); +DEFINE_GUID(GUID_FONTUNDERSCORE,0x66504311,0xBE0F,0x101A,0x8B,0xBB,0x00,0xAA,0x00,0x30,0x0C,0xAB); +DEFINE_GUID(GUID_HANDLE,0x66504313,0xbe0f,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab); +DEFINE_GUID(GUID_HIMETRIC,0x66504300,0xbe0f,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab); +DEFINE_GUID(GUID_HasPathProperties,0x2de81,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(GUID_OPTIONVALUEEXCLUSIVE,0x6650430b,0xbe0f,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab); +DEFINE_GUID(GUID_PathProperty,0x2de80,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(GUID_TRISTATE,0x6650430a,0xbe0f,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab); +DEFINE_GUID(GUID_XPOS,0x66504306,0xbe0f,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab); +DEFINE_GUID(GUID_XPOSPIXEL,0x66504302,0xbe0f,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab); +DEFINE_GUID(GUID_XSIZE,0x66504308,0xbe0f,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab); +DEFINE_GUID(GUID_XSIZEPIXEL,0x66504304,0xbe0f,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab); +DEFINE_GUID(GUID_YPOS,0x66504307,0xbe0f,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab); +DEFINE_GUID(GUID_YPOSPIXEL,0x66504303,0xbe0f,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab); +DEFINE_GUID(GUID_YSIZE,0x66504309,0xbe0f,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab); +DEFINE_GUID(GUID_YSIZEPIXEL,0x66504305,0xbe0f,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab); +/*DEFINE_GUID(IID_IAdviseSink2,0x125,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(IID_IAdviseSinkEx,0x3af24290,0xc96,0x11ce,0xa0,0xcf,0,0xaa,0,0x60,0xa,0xb8);*/ +DEFINE_GUID(IID_IAccessControl,0xeedd23e0,0x8410,0x11CE,0xA1,0xC3,0x08,0x00,0x2B,0x2B,0x8D,0x8F); +DEFINE_GUID(IID_IAsyncMoniker,0x79eac9d3,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb); +DEFINE_GUID(IID_IAsyncOperation,0x3d8b0590,0xf691,0x11d2,0x8e,0xa9,0x00,0x60,0x97,0xdf,0x5b,0xd4); +/*DEFINE_GUID(IID_IAuthenticate,0x79eac9d0,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);*/ +/*DEFINE_GUID(IID_IBindHost,0xfc4801a1,0x2ba9,0x11cf,0xa2,0x29,0,0xaa,0,0x3d,0x73,0x52); +DEFINE_GUID(IID_IBindProtocol,0x79eac9cd,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);*/ +DEFINE_GUID(IID_IBindStatusCallbackMsg,0x79eac9cb,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb); +DEFINE_GUID(CLSID_InternetSecurityManager, 0x7b8a2d94,0x0ac9,0x11d1,0x89,0x6c,0x00,0xc0,0x4f,0xb6,0xbf,0xc4); +DEFINE_GUID(CLSID_InternetZoneManager, 0x7B8A2D95,0x0AC9,0x11D1,0x89,0x6C,0x00,0xC0,0x4F,0xB6,0xBF,0xC4); +/*DEFINE_GUID(IID_IChannelHook,0x1008c4a0,0x7613,0x11cf,0x9a,0xf1,0,0x20,0xaf,0x6e,0x72,0xf4); +DEFINE_GUID(IID_IClassActivator,0x140,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(IID_IClassFactory2,0xb196b28f,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7); +DEFINE_GUID(IID_IClientSecurity,0x13D,0,0,0xc0,0,0,0,0,0,0,0x46);*/ +DEFINE_GUID(IID_IContext, 0x000001c0, 0x0000, 0x0000, 0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46); +/*DEFINE_GUID(IID_ICodeInstall,0x79eac9d1,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb); +DEFINE_GUID(IID_IConnectionPoint,0xb196b286,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7); +DEFINE_GUID(IID_IConnectionPointContainer,0xb196b284,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7); +DEFINE_GUID(IID_IContinue,0x12a,0,0,0xc0,0,0,0,0,0,0,0x46);*/ +/*DEFINE_GUID(IID_IContinueCallback,0xb722bcca,0x4e68,0x101b,0xa2,0xbc,0,0xaa,0,0x40,0x47,0x70);*/ +/*DEFINE_GUID(IID_ICreateErrorInfo,0x22f03340,0x547d,0x101b,0x8e,0x65,0x8,0,0x2b,0x2b,0xd1,0x19);*/ +/*DEFINE_GUID(IID_ICreateTypeInfo2,0x2040e,0,0,0xc0,0,0,0,0,0,0,0x46);*/ +/*DEFINE_GUID(IID_ICreateTypeLib,0x20406,0,0,0xc0,0,0,0,0,0,0,0x46);*/ +/*DEFINE_GUID(IID_ICreateTypeLib2,0x2040F,0,0,0xc0,0,0,0,0,0,0,0x46);*/ +/*DEFINE_GUID(IID_IDataAdviseHolder,0x110,0,0,0xc0,0,0,0,0,0,0,0x46);*/ +DEFINE_GUID(IID_IDebug,0x123,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(IID_IDebugStream,0x124,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(IID_IDfReserved1,0x13,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(IID_IDfReserved2,0x14,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(IID_IDfReserved3,0x15,0,0,0xc0,0,0,0,0,0,0,0x46); +/*DEFINE_GUID(IID_IDropSource,0x121,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(IID_IDropTarget,0x122,0,0,0xc0,0,0,0,0,0,0,0x46);*/ +DEFINE_GUID(IID_IEmptyVolumeCacheCallBack, 0x6E793361, 0x73C6, 0x11D0, 0x84, 0x69, 0, 0xAA, 0, 0x44, 0x29, 0x1); +DEFINE_GUID(IID_IEmptyVolumeCache2, 0x02B7E3BA, 0x4DB3, 0x11D2, 0xB2, 0xD9, 0, 0xC0, 0x4F, 0x8E, 0xEC, 0x8C); +DEFINE_GUID(IID_IEmptyVolumeCache, 0x8FCE5227, 0x04DA, 0x11D1, 0xA0, 0x4, 0, 0x80, 0x5F, 0x8A, 0xBE, 0x6); +DEFINE_GUID(IID_IEnumCallback,0x108,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(IID_IEnumContextProps, 0x000001c1, 0x0000, 0x0000, 0xc0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46); +/*DEFINE_GUID(IID_IEnumConnectionPoints,0xb196b285,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7); +DEFINE_GUID(IID_IEnumConnections,0xb196b287,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7);*/ +DEFINE_GUID(IID_IEnumGeneric,0x106,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(IID_IEnumHLITEM,0x79eac9c6,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb); +DEFINE_GUID(IID_IEnumHolder,0x107,0,0,0xc0,0,0,0,0,0,0,0x46); +/*DEFINE_GUID(IID_IEnumOLEVERB,0x104,0,0,0xc0,0,0,0,0,0,0,0x46);*/ +/*DEFINE_GUID(IID_IEnumOleDocumentViews,0xb722bcc8,0x4e68,0x101b,0xa2,0xbc,0,0xaa,0,0x40,0x47,0x70);*/ +/*DEFINE_GUID(IID_IEnumOleUndoUnits,0xb3e7c340,0xef97,0x11ce,0x9b,0xc9,0,0xaa,0,0x60,0x8e,0x1);*/ +/*DEFINE_GUID(IID_IEnumSTATPROPSETSTG,0x13b,0,0,0xc0,0,0,0,0,0,0,0x46);*/ +/*DEFINE_GUID(IID_IEnumSTATPROPSTG,0x139,0,0,0xc0,0,0,0,0,0,0,0x46);*/ +/*DEFINE_GUID(IID_IErrorInfo,0x1cf2b120,0x547d,0x101b,0x8e,0x65,0x8,0,0x2b,0x2b,0xd1,0x19);*/ +/*DEFINE_GUID(IID_IExternalConnection,0x19,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(IID_IFillLockBytes,0x99caf010,0x415e,0x11cf,0x88,0x14,0,0xaa,0,0xb5,0x69,0xf5);*/ +DEFINE_GUID(IID_IFilter,0x89bcb740,0x6119,0x101a,0xbc,0xb7,0,0xdd,0x1,0x6,0x55,0xaf); +/*DEFINE_GUID(IID_IFont,0xbef6e002,0xa874,0x101a,0x8b,0xba,0,0xaa,0,0x30,0xc,0xab); +DEFINE_GUID(IID_IFontDisp,0xbef6e003,0xa874,0x101a,0x8b,0xba,0,0xaa,0,0x30,0xc,0xab); +DEFINE_GUID(IID_IGlobalInterfaceTable,0x146,0,0,0xc0,0,0,0,0,0,0,0x46);*/ +DEFINE_GUID(IID_IHlink,0x79eac9c3,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb); +DEFINE_GUID(IID_IHlinkBrowseContext,0x79eac9c7,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb); +DEFINE_GUID(IID_IHlinkFrame,0x79eac9c5,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb); +DEFINE_GUID(IID_IHlinkSite,0x79eac9c2,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb); +DEFINE_GUID(IID_IHlinkTarget,0x79eac9c4,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb); +DEFINE_GUID(IID_IHTMLOMWindowServices, 0x3050F5FC, 0x98B5, 0x11CF, 0xBB, 0x82, 0, 0xAA, 0, 0xBD, 0xCE, 0xB); +/*DEFINE_GUID(IID_IHttpNegotiate,0x79eac9d2,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb); +DEFINE_GUID(IID_IHttpSecurity,0x79eac9d7,0xbafa,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);*/ +DEFINE_GUID(IID_IInternalMoniker,0x11,0,0,0xc0,0,0,0,0,0,0,0x46); +/*DEFINE_GUID(IID_ILayoutStorage,0xe6d4d90,0x6738,0x11cf,0x96,0x8,0,0xaa,0,0x68,0xd,0xb4); +DEFINE_GUID(IID_ILockBytes,0xa,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(IID_IMalloc,0x2,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(IID_IMallocSpy,0x1d,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(IID_IMarshal,0x3,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(IID_IMessageFilter,0x16,0,0,0xc0,0,0,0,0,0,0,0x46);*/ +DEFINE_GUID(IID_IMimeInfo,0xf77459a0,0xbf9a,0x11cf,0xba,0x4e,0,0xc0,0x4f,0xd7,0x8,0x16); +/*DEFINE_GUID(IID_IMultiQI,0x20,0,0,0xc0,0,0,0,0,0,0,0x46);*/ +DEFINE_GUID(IID_IObjectSafety,0xcb5bdc81,0x93c1,0x11cf,0x8f,0x20,0,0x80,0x5f,0x2c,0xd0,0x64); +/*DEFINE_GUID(IID_IObjectWithSite,0xfc4801a3,0x2ba9,0x11cf,0xa2,0x29,0,0xaa,0,0x3d,0x73,0x52); +DEFINE_GUID(IID_IOleAdviseHolder,0x111,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(IID_IOleCache,0x11e,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(IID_IOleCache2,0x128,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(IID_IOleCacheControl,0x129,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(IID_IOleClientSite,0x118,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(IID_IOleContainer,0x11b,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(IID_IOleControl,0xb196b288,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7); +DEFINE_GUID(IID_IOleControlSite,0xB196B289,0xBAB4,0x101A,0xB6,0x9C,0x00,0xAA,0x00,0x34,0x1D,0x07);*/ +/*DEFINE_GUID(IID_IOleDocument,0xb722bcc5,0x4e68,0x101b,0xa2,0xbc,0,0xaa,0,0x40,0x47,0x70);*/ +/*DEFINE_GUID(IID_IOleDocumentSite,0xb722bcc7,0x4e68,0x101b,0xa2,0xbc,0,0xaa,0,0x40,0x47,0x70);*/ +/*DEFINE_GUID(IID_IOleDocumentView,0xb722bcc6,0x4e68,0x101b,0xa2,0xbc,0,0xaa,0,0x40,0x47,0x70);*/ +/*DEFINE_GUID(IID_IOleInPlaceActiveObject,0x117,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(IID_IOleInPlaceFrame,0x116,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(IID_IOleInPlaceObject,0x113,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(IID_IOleInPlaceObjectWindowless,0x1c2056cc,0x5ef4,0x101b,0x8b,0xc8,0,0xaa,0,0x3e,0x3b,0x29); +DEFINE_OLEGUID(IID_IOleInPlaceSite,0x00000119,0,0); +DEFINE_GUID(IID_IOleInPlaceSiteEx,0x9c2cad80,0x3424,0x11cf,0xb6,0x70,0,0xaa,0,0x4c,0xd6,0xd8); +DEFINE_GUID(IID_IOleInPlaceSiteWindowless,0x922eada0,0x3424,0x11cf,0xb6,0x70,0,0xaa,0,0x4c,0xd6,0xd8); +DEFINE_GUID(IID_IOleInPlaceUIWindow,0x115,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(IID_IOleItemContainer,0x11c,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(IID_IOleLink,0x11d,0,0,0xc0,0,0,0,0,0,0,0x46);*/ +DEFINE_GUID(IID_IOleManager,0x11f,0,0,0xc0,0,0,0,0,0,0,0x46); +/*DEFINE_GUID(IID_IOleObject,0x112,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(IID_IOleParentUndoUnit,0xa1faf330,0xef97,0x11ce,0x9b,0xc9,0,0xaa,0,0x60,0x8e,0x1);*/ +DEFINE_GUID(IID_IOlePresObj,0x120,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(IID_IOleUndoManager00,0x97d001f2,0xceef,0x9b11,0xc9,0,0xaa,0,0x60,0x8e,0x1,0); +/*DEFINE_GUID(IID_IOleUndoManager,0xd001f200,0xef97,0x11ce,0x9b,0xc9,0,0xaa,0,0x60,0x8e,0x1); +DEFINE_GUID(IID_IOleUndoUnit,0x894ad3b0,0xef97,0x11ce,0x9b,0xc9,0,0xaa,0,0x60,0x8e,0x1); +DEFINE_GUID(IID_IOleWindow,0x114,0,0,0xc0,0,0,0,0,0,0,0x46);*/ +DEFINE_GUID(IID_IOverlappedCompletion,0x521a28f0,0xe40b,0x11ce,0xb2,0xc9,0,0xaa,0,0x68,0x9,0x37); +DEFINE_GUID(IID_IOverlappedStream,0x49384070,0xe40a,0x11ce,0xb2,0xc9,0,0xaa,0,0x68,0x9,0x37); +DEFINE_GUID(IID_IPSFactory,0x9,0,0,0xc0,0,0,0,0,0,0,0x46); +/*DEFINE_GUID(IID_IPSFactoryBuffer,0xd5f569d0,0x593b,0x101a,0xb5,0x69,0x8,0,0x2b,0x2d,0xbf,0x7a); +DEFINE_GUID(IID_IParseDisplayName,0x11a,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(IID_IPerPropertyBrowsing,0x376bd3aa,0x3845,0x101b,0x84,0xed,0x8,0,0x2b,0x2e,0xc7,0x13); +DEFINE_GUID(IID_IPersistFile,0x10b,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(IID_IPersistMemory,0xbd1ae5e0,0xa6ae,0x11ce,0xbd,0x37,0x50,0x42,0,0xc1,0,0); +DEFINE_GUID(IID_IPersistMoniker,0x79eac9c9,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0x0b); +DEFINE_GUID(IID_IPersistPropertyBag,0x37d84f60,0x42cb,0x11ce,0x81,0x35,0,0xaa,0,0x4b,0xb8,0x51); +DEFINE_GUID(IID_IPersistPropertyBag2,0x22f55881,0x280b,0x11d0,0xa8,0xa9,0,0xa0,0xc9,0xc,0x20,4); +DEFINE_OLEGUID(IID_IPersistStorage,0x0000010a,0,0); +DEFINE_GUID(IID_IPersistStreamInit,0x7fd52380,0x4e07,0x101b,0xae,0x2d,0x8,0,0x2b,0x2e,0xc7,0x13); +DEFINE_GUID(IID_IPicture,0x7bf80980,0xbf32,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab); +DEFINE_GUID(IID_IPictureDisp,0x7bf80981,0xbf32,0x101a,0x8b,0xbb,0,0xaa,0,0x30,0xc,0xab); +DEFINE_GUID(IID_IPointerInactive,0x55980ba0,0x35aa,0x11cf,0xb6,0x71,0,0xaa,0,0x4c,0xd6,0xd8);*/ +/*DEFINE_GUID(IID_IPrint,0xb722bcc9,0x4e68,0x101b,0xa2,0xbc,0,0xaa,0,0x40,0x47,0x70);*/ +/*DEFINE_GUID(IID_IProgressNotify,0xa9d758a0,0x4617,0x11cf,0x95,0xfc,0,0xaa,0,0x68,0xd,0xb4);*/ +DEFINE_GUID(IID_IPropertyFrame,0xb196b28a,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7); +/*DEFINE_GUID(IID_IPropertyNotifySink,0x9bfbbc02,0xeff1,0x101a,0x84,0xed,0,0xaa,0,0x34,0x1d,0x7); +DEFINE_GUID(IID_IPropertyPage,0xb196b28d,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7); +DEFINE_GUID(IID_IPropertyPage2,0x1e44665,0x24ac,0x101b,0x84,0xed,0x8,0,0x2b,0x2e,0xc7,0x13); +DEFINE_GUID(IID_IPropertyPageSite,0xb196b28c,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7);*/ +/*DEFINE_GUID(IID_IPropertySetStorage,0x13a,0,0,0xc0,0,0,0,0,0,0,0x46);*/ +/*DEFINE_GUID(IID_IPropertyStorage,0x138,0,0,0xc0,0,0,0,0,0,0,0x46);*/ +/*DEFINE_GUID(IID_IProvideClassInfo,0xb196b283,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7); +DEFINE_GUID(IID_IProvideClassInfo2,0xa6bc3ac0,0xdbaa,0x11ce,0x9d,0xe3,0,0xaa,0,0x4b,0xb8,0x51);*/ +DEFINE_GUID(IID_IProvideTaskPage, 0x4086658A, 0xCBBB, 0x11CF, 0xB6, 0x4, 0, 0xC0, 0x4F, 0xD8, 0xD5, 0x65); +DEFINE_GUID(IID_IProxy,0x27,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(IID_IProxyManager,0x8,0,0,0xc0,0,0,0,0,0,0,0x46); +/*DEFINE_GUID(IID_IQuickActivate,0xcf51ed10,0x62fe,0x11cf,0xbf,0x86,0,0xa0,0xc9,0x3,0x48,0x36);*/ +/*DEFINE_GUID(IID_IROTData,0xf29f6bc0,0x5021,0x11ce,0xaa,0x15,0,0,0x69,0x1,0x29,0x3f);*/ +DEFINE_GUID(IID_IRichEditOle,0x20d00,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(IID_IRichEditOleCallback,0x20d03,0,0,0xc0,0,0,0,0,0,0,0x46); +/*DEFINE_GUID(IID_IRootStorage,0x12,0,0,0xc0,0,0,0,0,0,0,0x46);*/ +DEFINE_GUID(IID_IRpcChannel,0x4,0,0,0xc0,0,0,0,0,0,0,0x46); +/*DEFINE_GUID(IID_IRpcChannelBuffer,0xd5f56b60,0x593b,0x101a,0xb5,0x69,0x8,0,0x2b,0x2d,0xbf,0x7a);*/ +DEFINE_GUID(IID_IRpcProxy,0x7,0,0,0xc0,0,0,0,0,0,0,0x46); +/*DEFINE_GUID(IID_IRpcProxyBuffer,0xd5f56a34,0x593b,0x101a,0xb5,0x69,8,0,0x2b,0x2d,0xbf,0x7a);*/ +DEFINE_GUID(IID_IRpcProxyBuffer34,0x3bd5f56a,0x1a59,0xb510,0x69,0x8,0,0x2b,0x2d,0xbf,0x7a,0); +DEFINE_GUID(IID_IRpcStub,0x5,0,0,0xc0,0,0,0,0,0,0,0x46); +/*DEFINE_GUID(IID_IRpcStubBuffer,0xd5f56afc,0x593b,0x101a,0xb5,0x69,0x8,0,0x2b,0x2d,0xbf,0x7a);*/ +/*DEFINE_OLEGUID(IID_IRunnableObject,0x00000126,0,0);*/ +DEFINE_GUID(IID_IScheduledWorkItem, 0xA6B952F0, 0xA4B1, 0x11D0, 0x99, 0x7D, 0, 0xAA, 0, 0x68, 0x87, 0xEC); +/*DEFINE_GUID(IID_IServerSecurity,0x13E,0,0,0xc0,0,0,0,0,0,0,0x46);*/ +/*DEFINE_GUID(IID_ISimpleFrameSite,0x742b0e01,0x14e6,0x101b,0x91,0x4e,0,0xaa,0,0x30,0xc,0xab);*/ +/*DEFINE_GUID(IID_ISpecifyPropertyPages,0xb196b28b,0xbab4,0x101a,0xb6,0x9c,0,0xaa,0,0x34,0x1d,0x7);*/ +/*DEFINE_OLEGUID(IID_IStdMarshalInfo,24,0,0);*/ +DEFINE_GUID(IID_IStub,0x26,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(IID_IStubManager,0x6,0,0,0xc0,0,0,0,0,0,0,0x46); +/*DEFINE_GUID(IID_ISupportErrorInfo,0xdf0b3d60,0x548f,0x101b,0x8e,0x65,0x8,0,0x2b,0x2b,0xd1,0x19);*/ +DEFINE_GUID(IID_ITask, 0x148BD524, 0xA2AB, 0x11CE, 0xB1, 0x1F, 0, 0xAA, 0, 0x53, 0x5, 0x3); +DEFINE_GUID(IID_ITaskScheduler, 0x148BD527, 0xA2AB, 0x11CE, 0xB1, 0x1F, 0, 0xAA, 0, 0x53, 0x5, 0x3); +DEFINE_GUID(IID_ITaskTrigger, 0x148BD52B, 0xA2AB, 0x11CE, 0xB1, 0x1F, 0, 0xAA, 0, 0x53, 0x5, 0x3); +/*DEFINE_GUID(IID_ITypeChangeEvents,0x20410,0,0,0xc0,0,0,0,0,0,0,0x46);*/ +/*DEFINE_GUID(IID_ITypeInfo2,0x20412,0,0,0xc0,0,0,0,0,0,0,0x46); */ +/*DEFINE_GUID(IID_ITypeLib2,0x20411,0,0,0xc0,0,0,0,0,0,0,0x46); */ +/*DEFINE_GUID(IID_IViewObject,0x10d,0,0,0xc0,0,0,0,0,0,0,0x46); */ +/*DEFINE_GUID(IID_IViewObject2,0x127,0,0,0xc0,0,0,0,0,0,0,0x46);*/ +/*DEFINE_GUID(IID_IViewObjectEx,0x3af24292,0xc96,0x11ce,0xa0,0xcf,0,0xaa,0,0x60,0xa,0xb8);*/ +/*DEFINE_GUID(IID_IWinInetHttpInfo,0x79eac9d8,0xbafa,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);*/ +/*DEFINE_GUID(IID_IWinInetInfo,0x79eac9d6,0xbafa,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);*/ +/*DEFINE_GUID(IID_IWindowForBindingUI,0x79eac9d5,0xbafa,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);*/ +DEFINE_GUID(IID_StdOle,0x20430,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(OLE_DATAPATH_ALLIMAGE,0x2de0e,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(OLE_DATAPATH_ALLMM,0x2de18,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(OLE_DATAPATH_ALLTEXT,0x2de1e,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(OLE_DATAPATH_ANSITEXT,0x2de19,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(OLE_DATAPATH_AVI,0x2de0f,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(OLE_DATAPATH_BASICAUDIO,0x2de12,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(OLE_DATAPATH_BIFF,0x2de21,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(OLE_DATAPATH_BMP,0x2de01,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(OLE_DATAPATH_CGM,0x2de0b,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(OLE_DATAPATH_COMMONIMAGE,0x2de0d,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(OLE_DATAPATH_DIB,0x2de02,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(OLE_DATAPATH_DIF,0x2de1f,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(OLE_DATAPATH_ENHMF,0x2de04,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(OLE_DATAPATH_EPS,0x2de0c,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(OLE_DATAPATH_GIF,0x2de05,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(OLE_DATAPATH_HTML,0x2de1c,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(OLE_DATAPATH_JPEG,0x2de06,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(OLE_DATAPATH_MIDI,0x2de13,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(OLE_DATAPATH_MPEG,0x2de10,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(OLE_DATAPATH_PALETTE,0x2de22,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(OLE_DATAPATH_PCX,0x2de09,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(OLE_DATAPATH_PENDATA,0x2de23,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(OLE_DATAPATH_PICT,0x2de0a,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(OLE_DATAPATH_POSTSCRIPT,0x2de1d,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(OLE_DATAPATH_QUICKTIME,0x2de11,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(OLE_DATAPATH_RIFF,0x2de15,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(OLE_DATAPATH_RTF,0x2de1b,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(OLE_DATAPATH_SOUND,0x2de16,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(OLE_DATAPATH_SYLK,0x2de20,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(OLE_DATAPATH_TIFF,0x2de07,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(OLE_DATAPATH_UNICODE,0x2de1a,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(OLE_DATAPATH_VIDEO,0x2de17,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(OLE_DATAPATH_WAV,0x2de14,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(OLE_DATAPATH_WMF,0x2de03,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(OLE_DATAPATH_XBM,0x2de08,0,0,0xc0,0,0,0,0,0,0,0x46); +DEFINE_GUID(SID_SContainerDispatch,0xb722be00,0x4e68,0x101b,0xa2,0xbc,0,0xaa,0,0x40,0x47,0x70); +DEFINE_GUID(SID_SDataPathBrowser,0xfc4801a5,0x2ba9,0x11cf,0xa2,0x29,0,0xaa,0,0x3d,0x73,0x52); +DEFINE_GUID(CLSID_GlobalOptions,0x0000034b,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46); +DEFINE_GUID(CLSID_StdGlobalInterfaceTable,0x00000323,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46); +DEFINE_GUID(IID_ICallFrameEvents,0xfd5e0843,0xfc91,0x11d0,0x97,0xd7,0x00,0xc0,0x4f,0xb9,0x61,0x8a); +DEFINE_GUID(IID_ICallFrameWalker,0x08b23919,0x392d,0x11d2,0xb8,0xa4,0x00,0xc0,0x4f,0xb9,0x61,0x8a); +DEFINE_GUID(IID_ICallInterceptor,0x60c7ca75,0x896d,0x11d2,0xb8,0xb6,0x00,0xc0,0x4f,0xb9,0x61,0x8a); +DEFINE_GUID(CLSID_MSDAINITIALIZE,0x2206cdb0,0x19c1,0x11d1,0x89,0xe0,0x00,0xc0,0x4f,0xd7,0xa8,0x29); +DEFINE_GUID(CLSID_DataLinks,0x2206cdb2,0x19c1,0x11d1,0x89,0xe0,0x00,0xc0,0x4f,0xd7,0xa8,0x29); +DEFINE_GUID(CLSID_RootBinder,0xff151822,0xb0bf,0x11d1,0xa8,0x0d,0x00,0x00,0x00,0x00,0x00,0x00); +DEFINE_GUID(IID_IDataInitialize,0x2206ccb1,0x19c1,0x11d1,0x89,0xe0,0x00,0xc0,0x4f,0xd7,0xa8,0x29); +DEFINE_GUID(IID_IDBInitialize,0x0c733a8b,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IAccessor,0x0c733a8c,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IRowset,0x0c733a7c,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IRowsetInfo,0x0c733a55,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IRowsetLocate,0x0c733a7d,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IRowsetResynch,0x0c733a84,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IRowsetScroll,0x0c733a7e,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IRowsetChange,0x0c733a05,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IRowsetUpdate,0x0c733a6d,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IRowsetIdentity,0x0c733a09,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IRowsetNotify,0x0c733a83,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IRowsetIndex,0x0c733a82,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_ICommand,0x0c733a63,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IMultipleResults,0x0c733a90,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IConvertType,0x0c733a88,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_ICommandPrepare,0x0c733a26,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_ICommandProperties,0x0c733a79,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_ICommandText,0x0c733a27,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_ICommandWithParameters,0x0c733a64,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IColumnsRowset,0x0c733a10,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IColumnsInfo,0x0c733a11,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IDBCreateCommand,0x0c733a1d,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IDBCreateSession,0x0c733a5d,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_ISourcesRowset,0x0c733a1e,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IDBProperties,0x0c733a8a,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IDBInfo,0x0c733a89,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IDBDataSourceAdmin,0x0c733a7a,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_ISessionProperties,0x0c733a85,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IIndexDefinition,0x0c733a68,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_ITableDefinition,0x0c733a86,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IOpenRowset,0x0c733a69,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IDBSchemaRowset,0x0c733a7b,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IErrorRecords,0x0c733a67,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IErrorLookup,0x0c733a66,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_ISQLErrorInfo,0x0c733a74,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IGetDataSource,0x0c733a75,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_ITransactionLocal,0x0c733a5f,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_ITransactionJoin,0x0c733a5e,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_ITransactionObject,0x0c733a60,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +/* OLE DB v1.5 */ +DEFINE_GUID(IID_IChapteredRowset,0x0c733a93,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IDBAsynchNotify,0x0c733a96,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IDBAsynchStatus,0x0c733a95,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IRowsetFind,0x0c733a9d,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IRowPosition,0x0c733a94,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IRowPositionChange,0x0997a571,0x126e,0x11d0,0x9f,0x8a,0x00,0xa0,0xc9,0xa0,0x63,0x1e); +DEFINE_GUID(IID_IViewRowset,0x0c733a97,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IViewChapter,0x0c733a98,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IViewSort,0x0c733a9a,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IViewFilter,0x0c733a9b,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IRowsetView,0x0c733a99,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +/* OLE DB v2.0 */ +DEFINE_GUID(IID_IMDDataset,0xa07cccd1,0x8148,0x11d0,0x87,0xbb,0x00,0xc0,0x4f,0xc3,0x39,0x42); +DEFINE_GUID(IID_IMDFind,0xa07cccd2,0x8148,0x11d0,0x87,0xbb,0x00,0xc0,0x4f,0xc3,0x39,0x42); +DEFINE_GUID(IID_IMDRangeRowset,0x0c733aa0,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IAlterTable,0x0c733aa5,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IAlterIndex,0x0c733aa6,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_ICommandPersist,0x0c733aa7,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IRowsetChapterMember,0x0c733aa8,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IRowsetRefresh,0x0c733aa9,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IParentRowset,0x0c733aaa,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +/* OLE DB v2.1 */ +DEFINE_GUID(IID_ITrusteeAdmin,0x0c733aa1,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_ITrusteeGroupAdmin,0x0c733aa2,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IObjectAccessControl,0x0c733aa3,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_ISecurityInfo,0x0c733aa4,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IRow,0x0c733ab4,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IRowChange,0x0c733ab5,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IRowSchemaChange,0x0c733aae,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IGetRow,0x0c733aaf,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IScopedOperations,0x0c733ab0,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IBindResource,0x0c733ab1,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_ICreateRow,0x0c733ab2,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IColumnsInfo2,0x0c733ab8,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IRegisterProvider,0x0c733ab9,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IGetSession,0x0c733aba,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IGetSourceRow,0x0c733abb,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_ITableCreation,0x0c733abc,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +DEFINE_GUID(IID_IRowsetCurrentIndex,0x0c733abd,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +/* OLE DB v2.6 */ +/* + * The `IID_ICommandStream` may be defined in (when the + * `DBINITCONSTANTS` is defned). +DEFINE_GUID(IID_ICommandStream,0x0c733ac0,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); +*/ +DEFINE_GUID(IID_IRowsetBookmark,0x0c733ac2,0x2a1c,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d); diff --git a/lib/libc/mingw/libsrc/vds-uuid.c b/lib/libc/mingw/libsrc/vds-uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..8dd15a0ea05af61a03a5d5aa8fe87e44e3f88e76 --- /dev/null +++ b/lib/libc/mingw/libsrc/vds-uuid.c @@ -0,0 +1,12 @@ +#define INITGUID +#include + +/*http://msdn.microsoft.com/en-us/library/aa381635%28VS.85%29.aspx*/ + +DEFINE_GUID(PARTITION_ENTRY_UNUSED_GUID,0x00000000,0x0000,0x0000,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00); +DEFINE_GUID(PARTITION_SYSTEM_GUID,0xc12a7328,0xf81f,0x11d2,0xba,0x4b,0x00,0xa0,0xc9,0x3e,0xc9,0x3b); +DEFINE_GUID(PARTITION_MSFT_RESERVED_GUID,0xe3c9e316,0x0b5c,0x4db8,0x81,0x7d,0xf9,0x2d,0xf0,0x02,0x15,0xae); +DEFINE_GUID(PARTITION_BASIC_DATA_GUID,0xebd0a0a2,0xb9e5,0x4433,0x87,0xc0,0x68,0xb6,0xb7,0x26,0x99,0xc7); +DEFINE_GUID(PARTITION_LDM_METADATA_GUID,0x5808c8aa,0x7e8f,0x42e0,0x85,0xd2,0xe1,0xe9,0x04,0x34,0xcf,0xb3); +DEFINE_GUID(PARTITION_LDM_DATA_GUID,0xaf9b60a0,0x1431,0x4f62,0xbc,0x68,0x33,0x11,0x71,0x4a,0x69,0xad); +DEFINE_GUID(PARTITION_MSFT_RECOVERY_GUID,0xde94bba4,0x06d1,0x4d40,0xa1,0x6a,0xbf,0xd5,0x01,0x79,0xd6,0xac); diff --git a/lib/libc/mingw/libsrc/virtdisk-uuid.c b/lib/libc/mingw/libsrc/virtdisk-uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..4d0146293615eeeeecc2996fec6631dc0350db3d --- /dev/null +++ b/lib/libc/mingw/libsrc/virtdisk-uuid.c @@ -0,0 +1,4 @@ +#define INITGUID +#include + +DEFINE_GUID(VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT,0xEC984AEC,0xA0F9,0x47e9,0x90,0x1F,0x71,0x41,0x5A,0x66,0x34,0x5B); diff --git a/lib/libc/mingw/libsrc/wia-uuid.c b/lib/libc/mingw/libsrc/wia-uuid.c new file mode 100644 index 0000000000000000000000000000000000000000..cd5609a048f425dded2c269f6f1a6be6164967be --- /dev/null +++ b/lib/libc/mingw/libsrc/wia-uuid.c @@ -0,0 +1,106 @@ +/* unknwn-uuid.c */ +/* Generate GUIDs for WIA interfaces */ + +/* All IIDs defined in this file were extracted from + * HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface\ */ + +#define INITGUID +#include + +// Image types +DEFINE_GUID(WiaImgFmt_UNDEFINED,0xb96b3ca9,0x0728,0x11d3,0x9d,0x7b,0x00,0x00,0xf8,0x1e,0xf3,0x2e); +DEFINE_GUID(WiaImgFmt_RAWRGB,0xbca48b55,0xf272,0x4371,0xb0,0xf1,0x4a,0x15,0x0d,0x05,0x7b,0xb4); +DEFINE_GUID(WiaImgFmt_MEMORYBMP,0xb96b3caa,0x0728,0x11d3,0x9d,0x7b,0x00,0x00,0xf8,0x1e,0xf3,0x2e); +DEFINE_GUID(WiaImgFmt_BMP,0xb96b3cab,0x0728,0x11d3,0x9d,0x7b,0x00,0x00,0xf8,0x1e,0xf3,0x2e); +DEFINE_GUID(WiaImgFmt_EMF,0xb96b3cac,0x0728,0x11d3,0x9d,0x7b,0x00,0x00,0xf8,0x1e,0xf3,0x2e); +DEFINE_GUID(WiaImgFmt_WMF,0xb96b3cad,0x0728,0x11d3,0x9d,0x7b,0x00,0x00,0xf8,0x1e,0xf3,0x2e); +DEFINE_GUID(WiaImgFmt_JPEG,0xb96b3cae,0x0728,0x11d3,0x9d,0x7b,0x00,0x00,0xf8,0x1e,0xf3,0x2e); +DEFINE_GUID(WiaImgFmt_PNG,0xb96b3caf,0x0728,0x11d3,0x9d,0x7b,0x00,0x00,0xf8,0x1e,0xf3,0x2e); +DEFINE_GUID(WiaImgFmt_GIF,0xb96b3cb0,0x0728,0x11d3,0x9d,0x7b,0x00,0x00,0xf8,0x1e,0xf3,0x2e); +DEFINE_GUID(WiaImgFmt_TIFF,0xb96b3cb1,0x0728,0x11d3,0x9d,0x7b,0x00,0x00,0xf8,0x1e,0xf3,0x2e); +DEFINE_GUID(WiaImgFmt_EXIF,0xb96b3cb2,0x0728,0x11d3,0x9d,0x7b,0x00,0x00,0xf8,0x1e,0xf3,0x2e); +DEFINE_GUID(WiaImgFmt_PHOTOCD,0xb96b3cb3,0x0728,0x11d3,0x9d,0x7b,0x00,0x00,0xf8,0x1e,0xf3,0x2e); +DEFINE_GUID(WiaImgFmt_FLASHPIX,0xb96b3cb4,0x0728,0x11d3,0x9d,0x7b,0x00,0x00,0xf8,0x1e,0xf3,0x2e); +DEFINE_GUID(WiaImgFmt_ICO,0xb96b3cb5,0x0728,0x11d3,0x9d,0x7b,0x00,0x00,0xf8,0x1e,0xf3,0x2e); +DEFINE_GUID(WiaImgFmt_CIFF,0x9821a8ab,0x3a7e,0x4215,0x94,0xe0,0xd2,0x7a,0x46,0x0c,0x03,0xb2); +DEFINE_GUID(WiaImgFmt_PICT,0xa6bc85d8,0x6b3e,0x40ee,0xa9,0x5c,0x25,0xd4,0x82,0xe4,0x1a,0xdc); +DEFINE_GUID(WiaImgFmt_JPEG2K,0x344ee2b2,0x39db,0x4dde,0x81,0x73,0xc4,0xb7,0x5f,0x8f,0x1e,0x49); +DEFINE_GUID(WiaImgFmt_JPEG2KX,0x43e14614,0xc80a,0x4850,0xba,0xf3,0x4b,0x15,0x2d,0xc8,0xda,0x27); + +// Document and other types +DEFINE_GUID(WiaImgFmt_RTF,0x573dd6a3,0x4834,0x432d,0xa9,0xb5,0xe1,0x98,0xdd,0x9e,0x89,0x0d); +DEFINE_GUID(WiaImgFmt_XML,0xb9171457,0xdac8,0x4884,0xb3,0x93,0x15,0xb4,0x71,0xd5,0xf0,0x7e); +DEFINE_GUID(WiaImgFmt_HTML,0xc99a4e62,0x99de,0x4a94,0xac,0xca,0x71,0x95,0x6a,0xc2,0x97,0x7d); +DEFINE_GUID(WiaImgFmt_TXT,0xfafd4d82,0x723f,0x421f,0x93,0x18,0x30,0x50,0x1a,0xc4,0x4b,0x59); +DEFINE_GUID(WiaImgFmt_MPG,0xecd757e4,0xd2ec,0x4f57,0x95,0x5d,0xbc,0xf8,0xa9,0x7c,0x4e,0x52); +DEFINE_GUID(WiaImgFmt_AVI,0x32f8ca14,0x087c,0x4908,0xb7,0xc4,0x67,0x57,0xfe,0x7e,0x90,0xab); +DEFINE_GUID(WiaImgFmt_ASF,0x8d948ee9,0xd0aa,0x4a12,0x9d,0x9a,0x9c,0xc5,0xde,0x36,0x19,0x9b); +DEFINE_GUID(WiaImgFmt_SCRIPT,0xfe7d6c53,0x2dac,0x446a,0xb0,0xbd,0xd7,0x3e,0x21,0xe9,0x24,0xc9); +DEFINE_GUID(WiaImgFmt_EXEC,0x485da097,0x141e,0x4aa5,0xbb,0x3b,0xa5,0x61,0x8d,0x95,0xd0,0x2b); +DEFINE_GUID(WiaImgFmt_UNICODE16,0x1b7639b6,0x6357,0x47d1,0x9a,0x07,0x12,0x45,0x2d,0xc0,0x73,0xe9); +DEFINE_GUID(WiaImgFmt_DPOF,0x369eeeab,0xa0e8,0x45ca,0x86,0xa6,0xa8,0x3c,0xe5,0x69,0x7e,0x28); + +// Audio types +DEFINE_GUID(WiaAudFmt_WAV,0xf818e146,0x07af,0x40ff,0xae,0x55,0xbe,0x8f,0x2c,0x06,0x5d,0xbe); +DEFINE_GUID(WiaAudFmt_MP3,0x0fbc71fb,0x43bf,0x49f2,0x91,0x90,0xe6,0xfe,0xcf,0xf3,0x7e,0x54); +DEFINE_GUID(WiaAudFmt_AIFF,0x66e2bf4f,0xb6fc,0x443f,0x94,0xc8,0x2f,0x33,0xc8,0xa6,0x5a,0xaf); +DEFINE_GUID(WiaAudFmt_WMA,0xd61d6413,0x8bc2,0x438f,0x93,0xad,0x21,0xbd,0x48,0x4d,0xb6,0xa1); + +// Event GUIDs +DEFINE_GUID(WIA_EVENT_DEVICE_DISCONNECTED,0x143e4e83,0x6497,0x11d2,0xa2,0x31,0x00,0xc0,0x4f,0xa3,0x18,0x09); +DEFINE_GUID(WIA_EVENT_DEVICE_CONNECTED,0xa28bbade,0x64b6,0x11d2,0xa2,0x31,0x00,0xc0,0x4f,0xa3,0x18,0x09); +DEFINE_GUID(WIA_EVENT_ITEM_DELETED,0x1d22a559,0xe14f,0x11d2,0xb3,0x26,0x00,0xc0,0x4f,0x68,0xce,0x61); +DEFINE_GUID(WIA_EVENT_ITEM_CREATED,0x4c8f4ef5,0xe14f,0x11d2,0xb3,0x26,0x00,0xc0,0x4f,0x68,0xce,0x61); +DEFINE_GUID(WIA_EVENT_TREE_UPDATED,0xc9859b91,0x4ab2,0x4cd6,0xa1,0xfc,0x58,0x2e,0xec,0x55,0xe5,0x85); +DEFINE_GUID(WIA_EVENT_VOLUME_INSERT,0x9638bbfd,0xd1bd,0x11d2,0xb3,0x1f,0x00,0xc0,0x4f,0x68,0xce,0x61); +DEFINE_GUID(WIA_EVENT_SCAN_IMAGE,0xa6c5a715,0x8c6e,0x11d2,0x97,0x7a,0x00,0x00,0xf8,0x7a,0x92,0x6f); +DEFINE_GUID(WIA_EVENT_SCAN_PRINT_IMAGE,0xb441f425,0x8c6e,0x11d2,0x97,0x7a,0x00,0x00,0xf8,0x7a,0x92,0x6f); +DEFINE_GUID(WIA_EVENT_SCAN_FAX_IMAGE,0xc00eb793,0x8c6e,0x11d2,0x97,0x7a,0x00,0x00,0xf8,0x7a,0x92,0x6f); +DEFINE_GUID(WIA_EVENT_SCAN_OCR_IMAGE,0x9d095b89,0x37d6,0x4877,0xaf,0xed,0x62,0xa2,0x97,0xdc,0x6d,0xbe); +DEFINE_GUID(WIA_EVENT_SCAN_EMAIL_IMAGE,0xc686dcee,0x54f2,0x419e,0x9a,0x27,0x2f,0xc7,0xf2,0xe9,0x8f,0x9e); +DEFINE_GUID(WIA_EVENT_SCAN_FILM_IMAGE,0x9b2b662c,0x6185,0x438c,0xb6,0x8b,0xe3,0x9e,0xe2,0x5e,0x71,0xcb); +DEFINE_GUID(WIA_EVENT_SCAN_IMAGE2,0xfc4767c1,0xc8b3,0x48a2,0x9c,0xfa,0x2e,0x90,0xcb,0x3d,0x35,0x90); +DEFINE_GUID(WIA_EVENT_SCAN_IMAGE3,0x154e27be,0xb617,0x4653,0xac,0xc5,0x0f,0xd7,0xbd,0x4c,0x65,0xce); +DEFINE_GUID(WIA_EVENT_SCAN_IMAGE4,0xa65b704a,0x7f3c,0x4447,0xa7,0x5d,0x8a,0x26,0xdf,0xca,0x1f,0xdf); +DEFINE_GUID(WIA_EVENT_STORAGE_CREATED,0x353308b2,0xfe73,0x46c8,0x89,0x5e,0xfa,0x45,0x51,0xcc,0xc8,0x5a); +DEFINE_GUID(WIA_EVENT_STORAGE_DELETED,0x5e41e75e,0x9390,0x44c5,0x9a,0x51,0xe4,0x70,0x19,0xe3,0x90,0xcf); +DEFINE_GUID(WIA_EVENT_STI_PROXY,0xd711f81f,0x1f0d,0x422d,0x86,0x41,0x92,0x7d,0x1b,0x93,0xe5,0xe5); +DEFINE_GUID(WIA_EVENT_CANCEL_IO,0xc860f7b8,0x9ccd,0x41ea,0xbb,0xbf,0x4d,0xd0,0x9c,0x5b,0x17,0x95); + +// Power management event GUIDs,sent by the WIA service to drivers +DEFINE_GUID(WIA_EVENT_POWER_SUSPEND,0xa0922ff9,0xc3b4,0x411c,0x9e,0x29,0x03,0xa6,0x69,0x93,0xd2,0xbe); +DEFINE_GUID(WIA_EVENT_POWER_RESUME,0x618f153e,0xf686,0x4350,0x96,0x34,0x41,0x15,0xa3,0x04,0x83,0x0c); + +// No action handler and prompt handler +DEFINE_GUID(WIA_EVENT_HANDLER_NO_ACTION,0xe0372b7d,0xe115,0x4525,0xbc,0x55,0xb6,0x29,0xe6,0x8c,0x74,0x5a); +DEFINE_GUID(WIA_EVENT_HANDLER_PROMPT,0x5f4baad0,0x4d59,0x4fcd,0xb2,0x13,0x78,0x3c,0xe7,0xa9,0x2f,0x22); + +// WIA Commands +DEFINE_GUID(WIA_CMD_SYNCHRONIZE,0x9b26b7b2,0xacad,0x11d2,0xa0,0x93,0x00,0xc0,0x4f,0x72,0xdc,0x3c); +DEFINE_GUID(WIA_CMD_TAKE_PICTURE,0xaf933cac,0xacad,0x11d2,0xa0,0x93,0x00,0xc0,0x4f,0x72,0xdc,0x3c); +DEFINE_GUID(WIA_CMD_DELETE_ALL_ITEMS,0xe208c170,0xacad,0x11d2,0xa0,0x93,0x00,0xc0,0x4f,0x72,0xdc,0x3c); +DEFINE_GUID(WIA_CMD_CHANGE_DOCUMENT,0x04e725b0,0xacae,0x11d2,0xa0,0x93,0x00,0xc0,0x4f,0x72,0xdc,0x3c); +DEFINE_GUID(WIA_CMD_UNLOAD_DOCUMENT,0x1f3b3d8e,0xacae,0x11d2,0xa0,0x93,0x00,0xc0,0x4f,0x72,0xdc,0x3c); +DEFINE_GUID(WIA_CMD_DIAGNOSTIC,0x10ff52f5,0xde04,0x4cf0,0xa5,0xad,0x69,0x1f,0x8d,0xce,0x01,0x41); + +DEFINE_GUID(WIA_CMD_DELETE_DEVICE_TREE,0x73815942,0xdbea,0x11d2,0x84,0x16,0x00,0xc0,0x4f,0xa3,0x61,0x45); +DEFINE_GUID(WIA_CMD_BUILD_DEVICE_TREE,0x9cba5ce0,0xdbea,0x11d2,0x84,0x16,0x00,0xc0,0x4f,0xa3,0x61,0x45); + +DEFINE_GUID(IID_IWiaUIExtension,0xDA319113,0x50EE,0x4C80,0xB4,0x60,0x57,0xD0,0x05,0xD4,0x4A,0x2C); + +DEFINE_GUID(IID_IWiaDevMgr,0x5eb2502a,0x8cf1,0x11d1,0xbf,0x92,0x00,0x60,0x08,0x1e,0xd8,0x11); +DEFINE_GUID(IID_IEnumWIA_DEV_INFO,0x5e38b83c,0x8cf1,0x11d1,0xbf,0x92,0x00,0x60,0x08,0x1e,0xd8,0x11); +DEFINE_GUID(IID_IWiaEventCallback,0xae6287b0,0x0084,0x11d2,0x97,0x3b,0x00,0xa0,0xc9,0x06,0x8f,0x2e); +DEFINE_GUID(IID_IWiaDataCallback,0xa558a866,0xa5b0,0x11d2,0xa0,0x8f,0x00,0xc0,0x4f,0x72,0xdc,0x3c); +DEFINE_GUID(IID_IWiaDataTransfer,0xa6cef998,0xa5b0,0x11d2,0xa0,0x8f,0x00,0xc0,0x4f,0x72,0xdc,0x3c); +DEFINE_GUID(IID_IWiaItem,0x4db1ad10,0x3391,0x11d2,0x9a,0x33,0x00,0xc0,0x4f,0xa3,0x61,0x45); +DEFINE_GUID(IID_IWiaPropertyStorage,0x98B5E8A0,0x29CC,0x491a,0xAA,0xC0,0xE6,0xDB,0x4F,0xDC,0xCE,0xB6); +DEFINE_GUID(IID_IEnumWiaItem,0x5e8383fc,0x3391,0x11d2,0x9a,0x33,0x00,0xc0,0x4f,0xa3,0x61,0x45); +DEFINE_GUID(IID_IEnumWIA_DEV_CAPS,0x1fcc4287,0xaca6,0x11d2,0xa0,0x93,0x00,0xc0,0x4f,0x72,0xdc,0x3c); +DEFINE_GUID(IID_IEnumWIA_FORMAT_INFO,0x81BEFC5B,0x656D,0x44f1,0xB2,0x4C,0xD4,0x1D,0x51,0xB4,0xDC,0x81); +DEFINE_GUID(IID_IWiaLog,0xA00C10B6,0x82A1,0x452f,0x8B,0x6C,0x86,0x06,0x2A,0xAD,0x68,0x90); +DEFINE_GUID(IID_IWiaLogEx,0xAF1F22AC,0x7A40,0x4787,0xB4,0x21,0xAE,0xb4,0x7A,0x1F,0xBD,0x0B); +DEFINE_GUID(IID_IWiaNotifyDevMgr,0x70681EA0,0xE7BF,0x4291,0x9F,0xB1,0x4E,0x88,0x13,0xA3,0xF7,0x8E); +DEFINE_GUID(IID_IWiaItemExtras,0x6291ef2c,0x36ef,0x4532,0x87,0x6a,0x8e,0x13,0x25,0x93,0x77,0x8d); +DEFINE_GUID(CLSID_WiaDevMgr,0xa1f4e726,0x8cf1,0x11d1,0xbf,0x92,0x00,0x60,0x08,0x1e,0xd8,0x11); +DEFINE_GUID(CLSID_WiaLog,0xA1E75357,0x881A,0x419e,0x83,0xE2,0xBB,0x16,0xDB,0x19,0x7C,0x68); diff --git a/src/link.cpp b/src/link.cpp index e26a7ea4362393c681a49ee6b4c60635c5178815..2cb23698abea5bca763561100df7d2c985a1b50a 100644 --- a/src/link.cpp +++ b/src/link.cpp @@ -517,6 +517,52 @@ static const char *mingwex_arm64_src[] = { "math" OS_SEP "arm64" OS_SEP "trunc.S", }; +static const char *mingw_uuid_src[] = { + "libsrc/ativscp-uuid.c", + "libsrc/atsmedia-uuid.c", + "libsrc/bth-uuid.c", + "libsrc/cguid-uuid.c", + "libsrc/comcat-uuid.c", + "libsrc/devguid.c", + "libsrc/docobj-uuid.c", + "libsrc/dxva-uuid.c", + "libsrc/exdisp-uuid.c", + "libsrc/extras-uuid.c", + "libsrc/fwp-uuid.c", + "libsrc/guid_nul.c", + "libsrc/hlguids-uuid.c", + "libsrc/hlink-uuid.c", + "libsrc/mlang-uuid.c", + "libsrc/msctf-uuid.c", + "libsrc/mshtmhst-uuid.c", + "libsrc/mshtml-uuid.c", + "libsrc/msxml-uuid.c", + "libsrc/netcon-uuid.c", + "libsrc/ntddkbd-uuid.c", + "libsrc/ntddmou-uuid.c", + "libsrc/ntddpar-uuid.c", + "libsrc/ntddscsi-uuid.c", + "libsrc/ntddser-uuid.c", + "libsrc/ntddstor-uuid.c", + "libsrc/ntddvdeo-uuid.c", + "libsrc/oaidl-uuid.c", + "libsrc/objidl-uuid.c", + "libsrc/objsafe-uuid.c", + "libsrc/ocidl-uuid.c", + "libsrc/oleacc-uuid.c", + "libsrc/olectlid-uuid.c", + "libsrc/oleidl-uuid.c", + "libsrc/power-uuid.c", + "libsrc/powrprof-uuid.c", + "libsrc/uianimation-uuid.c", + "libsrc/usbcamdi-uuid.c", + "libsrc/usbiodef-uuid.c", + "libsrc/uuid.c", + "libsrc/vds-uuid.c", + "libsrc/virtdisk-uuid.c", + "libsrc/wia-uuid.c", +}; + struct MinGWDef { const char *name; bool always_link; @@ -1261,7 +1307,32 @@ static void add_msvcrt_os_dep(CodeGen *parent, CodeGen *child_gen, const char *s child_gen->c_source_files.append(c_file); } -static void add_mingwex_os_dep(CodeGen *parent, CodeGen *child_gen, const char *src_path) { +static void add_mingwex_dep(CodeGen *parent, CodeGen *child_gen, const char *src_path) { + CFile *c_file = heap::c_allocator.create(); + c_file->source_path = buf_ptr(buf_sprintf("%s" OS_SEP "libc" OS_SEP "mingw" OS_SEP "%s", + buf_ptr(parent->zig_lib_dir), src_path)); + c_file->args.append("-DHAVE_CONFIG_H"); + + c_file->args.append("-I"); + c_file->args.append(path_from_libc(parent, "mingw")); + + c_file->args.append("-I"); + c_file->args.append(path_from_libc(parent, "mingw" OS_SEP "include")); + + c_file->args.append("-std=gnu99"); + c_file->args.append("-D_CRTBLD"); + c_file->args.append("-D_WIN32_WINNT=0x0f00"); + c_file->args.append("-D__MSVCRT_VERSION__=0x700"); + c_file->args.append("-g"); + c_file->args.append("-O2"); + + c_file->args.append("-isystem"); + c_file->args.append(path_from_libc(parent, "include" OS_SEP "any-windows-any")); + + child_gen->c_source_files.append(c_file); +} + +static void add_mingw_uuid_dep(CodeGen *parent, CodeGen *child_gen, const char *src_path) { CFile *c_file = heap::c_allocator.create(); c_file->source_path = buf_ptr(buf_sprintf("%s" OS_SEP "libc" OS_SEP "mingw" OS_SEP "%s", buf_ptr(parent->zig_lib_dir), src_path)); @@ -1387,20 +1458,20 @@ static const char *get_libc_crt_file(CodeGen *parent, const char *file, Stage2Pr CodeGen *child_gen = create_child_codegen(parent, nullptr, OutTypeLib, nullptr, "mingwex", progress_node); for (size_t i = 0; i < array_length(mingwex_generic_src); i += 1) { - add_mingwex_os_dep(parent, child_gen, mingwex_generic_src[i]); + add_mingwex_dep(parent, child_gen, mingwex_generic_src[i]); } if (parent->zig_target->arch == ZigLLVM_x86 || parent->zig_target->arch == ZigLLVM_x86_64) { for (size_t i = 0; i < array_length(mingwex_x86_src); i += 1) { - add_mingwex_os_dep(parent, child_gen, mingwex_x86_src[i]); + add_mingwex_dep(parent, child_gen, mingwex_x86_src[i]); } } else if (target_is_arm(parent->zig_target)) { if (target_arch_pointer_bit_width(parent->zig_target->arch) == 32) { for (size_t i = 0; i < array_length(mingwex_arm32_src); i += 1) { - add_mingwex_os_dep(parent, child_gen, mingwex_arm32_src[i]); + add_mingwex_dep(parent, child_gen, mingwex_arm32_src[i]); } } else { for (size_t i = 0; i < array_length(mingwex_arm64_src); i += 1) { - add_mingwex_os_dep(parent, child_gen, mingwex_arm64_src[i]); + add_mingwex_dep(parent, child_gen, mingwex_arm64_src[i]); } } } else { @@ -1408,6 +1479,13 @@ static const char *get_libc_crt_file(CodeGen *parent, const char *file, Stage2Pr } codegen_build_and_link(child_gen); return buf_ptr(&child_gen->bin_file_output_path); + } else if (strcmp(file, "uuid.lib") == 0) { + CodeGen *child_gen = create_child_codegen(parent, nullptr, OutTypeLib, nullptr, "uuid", progress_node); + for (size_t i = 0; i < array_length(mingw_uuid_src); i += 1) { + add_mingw_uuid_dep(parent, child_gen, mingw_uuid_src[i]); + } + codegen_build_and_link(child_gen); + return buf_ptr(&child_gen->bin_file_output_path); } else { zig_unreachable(); } @@ -2526,10 +2604,14 @@ static void construct_linker_job_coff(LinkJob *lj) { // If we're linking in the CRT or the libs are provided explictly we don't want to generate def/libs if ((lj->link_in_crt && is_sys_lib) || link_lib->provided_explicitly) { if (target_abi_is_gnu(lj->codegen->zig_target->abi)) { - Buf* lib_name = buf_sprintf("lib%s.a", buf_ptr(link_lib->name)); - lj->args.append(buf_ptr(lib_name)); - } - else { + if (buf_eql_str(link_lib->name, "uuid")) { + // mingw-w64 provides this lib + lj->args.append(get_libc_crt_file(g, "uuid.lib", lj->build_dep_prog_node)); + } else { + Buf* lib_name = buf_sprintf("lib%s.a", buf_ptr(link_lib->name)); + lj->args.append(buf_ptr(lib_name)); + } + } else { Buf* lib_name = buf_sprintf("%s.lib", buf_ptr(link_lib->name)); lj->args.append(buf_ptr(lib_name)); } -- 2.54.0 From 701c03d083c4d57275d95e921f03184515e0d247 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 5 Apr 2020 19:39:28 -0400 Subject: [PATCH 53/91] zig uses mingw-w64 to provide -lpsapi --- src/link.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/link.cpp b/src/link.cpp index 2cb23698abea5bca763561100df7d2c985a1b50a..4ee8915e55095fc900043934a0201c9186af6973 100644 --- a/src/link.cpp +++ b/src/link.cpp @@ -587,6 +587,7 @@ static const MinGWDef mingw_def_list[] = { {"ole32", false}, {"oleaut32",false}, {"opengl32",false}, + {"psapi", false}, {"rpcns4", false}, {"rpcrt4", false}, {"scarddlg",false}, -- 2.54.0 From a0b73c9f02b3bb9e550d0283053cc9fc6c1dade6 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Mon, 6 Apr 2020 12:54:35 +0200 Subject: [PATCH 54/91] compiler-rt: Separate max size allowed for load/store and CAS The v6m ISA has no way to express a CAS loop natively without turning off the interrupts or using the kernel cmpxchg harness. On such a platform the user has to provide a few __sync_* builtins to satisfy the linker. --- lib/std/special/compiler_rt/atomics.zig | 27 ++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/lib/std/special/compiler_rt/atomics.zig b/lib/std/special/compiler_rt/atomics.zig index 5cc7c42293e4ead5100627504b20a6720e6443d3..e2cb45bef32a7ff70135c9bde427684fc52b2b5a 100644 --- a/lib/std/special/compiler_rt/atomics.zig +++ b/lib/std/special/compiler_rt/atomics.zig @@ -99,13 +99,30 @@ comptime { // LLVM emits those iff the object size is known and the pointers are correctly // aligned. -// The size (in bytes) of the biggest object that the architecture can access -// atomically. Objects bigger than this threshold require the use of a lock. +// The size (in bytes) of the biggest object that the architecture can +// load/store atomically. +// Objects bigger than this threshold require the use of a lock. const largest_atomic_size = switch (builtin.arch) { .x86_64 => 16, else => @sizeOf(usize), }; +// The size (in bytes) of the biggest object that the architecture can perform +// an atomic CAS operation with. +// Objects bigger than this threshold require the use of a lock. +const largest_atomic_cas_size = switch (builtin.arch) { + .arm, .armeb, .thumb, .thumbeb => + // The ARM v6m ISA has no ldrex/strex and so it's impossible to do CAS + // operations unless we're targeting Linux or the user provides the missing + // builtin functions. + if (std.Target.arm.featureSetHas(std.Target.current.cpu.features, .has_v6m) and + std.Target.current.os.tag != .linux) + 0 + else + @sizeOf(usize), + else => @sizeOf(usize), +}; + fn atomicLoadFn(comptime T: type) fn (*T, i32) callconv(.C) T { return struct { fn atomic_load_N(src: *T, model: i32) callconv(.C) T { @@ -151,7 +168,7 @@ comptime { fn atomicExchangeFn(comptime T: type) fn (*T, T, i32) callconv(.C) T { return struct { fn atomic_exchange_N(ptr: *T, val: T, model: i32) callconv(.C) T { - if (@sizeOf(T) > largest_atomic_size) { + if (@sizeOf(T) > largest_atomic_cas_size) { var sl = spinlocks.get(@ptrToInt(ptr)); defer sl.release(); const value = ptr.*; @@ -174,7 +191,7 @@ comptime { fn atomicCompareExchangeFn(comptime T: type) fn (*T, *T, T, i32, i32) callconv(.C) i32 { return struct { fn atomic_compare_exchange_N(ptr: *T, expected: *T, desired: T, success: i32, failure: i32) callconv(.C) i32 { - if (@sizeOf(T) > largest_atomic_size) { + if (@sizeOf(T) > largest_atomic_cas_size) { var sl = spinlocks.get(@ptrToInt(ptr)); defer sl.release(); const value = ptr.*; @@ -205,7 +222,7 @@ comptime { fn fetchFn(comptime T: type, comptime op: builtin.AtomicRmwOp) fn (*T, T, i32) callconv(.C) T { return struct { pub fn fetch_op_N(ptr: *T, val: T, model: i32) callconv(.C) T { - if (@sizeOf(T) > largest_atomic_size) { + if (@sizeOf(T) > largest_atomic_cas_size) { var sl = spinlocks.get(@ptrToInt(ptr)); defer sl.release(); -- 2.54.0 From 96ed5446659549cd21574dcd4996797a99aae39d Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 6 Apr 2020 13:07:19 -0400 Subject: [PATCH 55/91] build.zig supports specifying config.h location explicitly also it does not try to run llvm-config executable when -Dlib-files-only This fixes cross-compiling using the bootstrap repository. --- CMakeLists.txt | 4 +++- build.zig | 32 ++++++++++++++++++++++---------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7349fa01c482e4ebc6fb1b8dcc45c7970e1ca16c..2598d386b75b815029a210afdf3cb94903159716 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -303,9 +303,10 @@ set(LIBC_FILES_DEST "${ZIG_LIB_DIR}/libc") set(LIBUNWIND_FILES_DEST "${ZIG_LIB_DIR}/libunwind") set(LIBCXX_FILES_DEST "${ZIG_LIB_DIR}/libcxx") set(ZIG_STD_DEST "${ZIG_LIB_DIR}/std") +set(ZIG_CONFIG_H_OUT "${CMAKE_BINARY_DIR}/config.h") configure_file ( "${CMAKE_SOURCE_DIR}/src/config.h.in" - "${CMAKE_BINARY_DIR}/config.h" + "${ZIG_CONFIG_H_OUT}" ) include_directories( @@ -485,6 +486,7 @@ set(ZIG_INSTALL_ARGS "build" --override-lib-dir "${CMAKE_SOURCE_DIR}/lib" "-Dlib-files-only" --prefix "${CMAKE_INSTALL_PREFIX}" + "-Dconfig_h=${ZIG_CONFIG_H_OUT}" install ) diff --git a/build.zig b/build.zig index 3abe5ff92b7399787bee14ac661b248dd9f14f92..78d5391e7e754602aa5bfad522dd7b1197a99065 100644 --- a/build.zig +++ b/build.zig @@ -34,8 +34,14 @@ pub fn build(b: *Builder) !void { const test_step = b.step("test", "Run all the tests"); - var ctx = try findAndParseConfigH(b); - ctx.llvm = try findLLVM(b, ctx.llvm_config_exe); + const config_h_text = if (b.option( + []const u8, + "config_h", + "Path to the generated config.h", + )) |config_h_path| + try std.fs.cwd().readFileAlloc(b.allocator, config_h_path, max_config_h_bytes) + else + try findAndReadConfigH(b); var test_stage2 = b.addTest("src-self-hosted/test.zig"); test_stage2.setBuildMode(builtin.Mode.Debug); @@ -46,9 +52,6 @@ pub fn build(b: *Builder) !void { var exe = b.addExecutable("zig", "src-self-hosted/main.zig"); exe.setBuildMode(mode); - try configureStage2(b, test_stage2, ctx); - try configureStage2(b, exe, ctx); - const skip_release = b.option(bool, "skip-release", "Main test suite skips release builds") orelse false; const skip_release_small = b.option(bool, "skip-release-small", "Main test suite skips release-small builds") orelse skip_release; const skip_release_fast = b.option(bool, "skip-release-fast", "Main test suite skips release-fast builds") orelse skip_release; @@ -62,6 +65,12 @@ pub fn build(b: *Builder) !void { const only_install_lib_files = b.option(bool, "lib-files-only", "Only install library files") orelse false; if (!only_install_lib_files and !skip_self_hosted) { + var ctx = parseConfigH(config_h_text); + ctx.llvm = try findLLVM(b, ctx.llvm_config_exe); + + try configureStage2(b, test_stage2, ctx); + try configureStage2(b, exe, ctx); + b.default_step.dependOn(&exe.step); exe.install(); } @@ -343,14 +352,15 @@ const Context = struct { llvm: LibraryDep, }; -fn findAndParseConfigH(b: *Builder) !Context { +const max_config_h_bytes = 1 * 1024 * 1024; + +fn findAndReadConfigH(b: *Builder) ![]const u8 { var check_dir = fs.path.dirname(b.zig_exe).?; - const config_h_text = while (true) { + while (true) { var dir = try fs.cwd().openDir(check_dir, .{}); defer dir.close(); - const max_bytes = 1 * 1024 * 1024; - const config_h_text = dir.readFileAlloc(b.allocator, "config.h", max_bytes) catch |err| switch (err) { + const config_h_text = dir.readFileAlloc(b.allocator, "config.h", max_config_h_bytes) catch |err| switch (err) { error.FileNotFound => { const new_check_dir = fs.path.dirname(check_dir); if (new_check_dir == null or mem.eql(u8, new_check_dir.?, check_dir)) { @@ -363,9 +373,11 @@ fn findAndParseConfigH(b: *Builder) !Context { }, else => |e| return e, }; - break config_h_text; + return config_h_text; } else unreachable; // TODO should not need `else unreachable`. +} +fn parseConfigH(config_h_text: []const u8) Context { var ctx: Context = .{ .cmake_binary_dir = undefined, .cxx_compiler = undefined, -- 2.54.0 From e4eb817f7999a2ee9ff62f59a6bf72a57bdf40a5 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 6 Apr 2020 13:33:32 -0400 Subject: [PATCH 56/91] libc_installation.zig: don't special-case based on C ABI Whether the C ABI is mingw-w64 or msvc, detection of native libc paths should be the same. In the future we may want to allow passing a C ABI parameter to detectNativeCPaths() but for now we have the same behavior regardless. --- src-self-hosted/libc_installation.zig | 37 +++++++++++---------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/src-self-hosted/libc_installation.zig b/src-self-hosted/libc_installation.zig index 943405310cce3d7312f40f46e4661d3687bf6476..a17393434d40f7a5a728cca140d51b33b3a66c06 100644 --- a/src-self-hosted/libc_installation.zig +++ b/src-self-hosted/libc_installation.zig @@ -168,29 +168,22 @@ pub const LibCInstallation = struct { var self: LibCInstallation = .{}; if (is_windows) { - if (is_gnu) { - var batch = Batch(FindError!void, 3, .auto_async).init(); - batch.add(&async self.findNativeIncludeDirPosix(args)); - batch.add(&async self.findNativeCrtDirPosix(args)); - try batch.wait(); - } else { - var sdk: *ZigWindowsSDK = undefined; - switch (zig_find_windows_sdk(&sdk)) { - .None => { - defer zig_free_windows_sdk(sdk); + var sdk: *ZigWindowsSDK = undefined; + switch (zig_find_windows_sdk(&sdk)) { + .None => { + defer zig_free_windows_sdk(sdk); - var batch = Batch(FindError!void, 5, .auto_async).init(); - batch.add(&async self.findNativeMsvcIncludeDir(args, sdk)); - batch.add(&async self.findNativeMsvcLibDir(args, sdk)); - batch.add(&async self.findNativeKernel32LibDir(args, sdk)); - batch.add(&async self.findNativeIncludeDirWindows(args, sdk)); - batch.add(&async self.findNativeCrtDirWindows(args, sdk)); - try batch.wait(); - }, - .OutOfMemory => return error.OutOfMemory, - .NotFound => return error.WindowsSdkNotFound, - .PathTooLong => return error.WindowsSdkNotFound, - } + var batch = Batch(FindError!void, 5, .auto_async).init(); + batch.add(&async self.findNativeMsvcIncludeDir(args, sdk)); + batch.add(&async self.findNativeMsvcLibDir(args, sdk)); + batch.add(&async self.findNativeKernel32LibDir(args, sdk)); + batch.add(&async self.findNativeIncludeDirWindows(args, sdk)); + batch.add(&async self.findNativeCrtDirWindows(args, sdk)); + try batch.wait(); + }, + .OutOfMemory => return error.OutOfMemory, + .NotFound => return error.WindowsSdkNotFound, + .PathTooLong => return error.WindowsSdkNotFound, } } else { try blk: { -- 2.54.0 From a59d31bd28f82e002f68ce25581c0437463137ed Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Tue, 3 Mar 2020 21:46:30 +0100 Subject: [PATCH 57/91] ir: Support tuple multiplication --- src/ir.cpp | 122 ++++++++++++++++++++++++++++++--- test/stage1/behavior/tuple.zig | 31 ++++++++- 2 files changed, 141 insertions(+), 12 deletions(-) diff --git a/src/ir.cpp b/src/ir.cpp index 6fed044c6ce8c988b4da9d06caef889ca7b28eb6..5a96bc2d52ee00de912cbf0174442320fafeac2e 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -17351,14 +17351,15 @@ static IrInstGen *ir_analyze_tuple_cat(IrAnalyze *ira, IrInst* source_instr, ContainerKindStruct, source_instr->source_node, buf_ptr(name), bare_name, ContainerLayoutAuto); new_type->data.structure.special = StructSpecialInferredTuple; new_type->data.structure.resolve_status = ResolveStatusBeingInferred; - - IrInstGen *new_struct_ptr = ir_resolve_result(ira, source_instr, no_result_loc(), - new_type, nullptr, false, true); uint32_t new_field_count = op1_field_count + op2_field_count; new_type->data.structure.src_field_count = new_field_count; new_type->data.structure.fields = realloc_type_struct_fields(new_type->data.structure.fields, 0, new_field_count); + + IrInstGen *new_struct_ptr = ir_resolve_result(ira, source_instr, no_result_loc(), + new_type, nullptr, false, true); + for (uint32_t i = 0; i < new_field_count; i += 1) { TypeStructField *src_field; if (i < op1_field_count) { @@ -17422,8 +17423,10 @@ static IrInstGen *ir_analyze_tuple_cat(IrAnalyze *ira, IrInst* source_instr, ir_analyze_store_ptr(ira, &elem_result_loc->base, elem_result_loc, deref, true); } } - IrInstGen *result = ir_get_deref(ira, source_instr, new_struct_ptr, nullptr); - return result; + + const_ptrs.deinit(); + + return ir_get_deref(ira, source_instr, new_struct_ptr, nullptr); } static IrInstGen *ir_analyze_array_cat(IrAnalyze *ira, IrInstSrcBinOp *instruction) { @@ -17480,8 +17483,9 @@ static IrInstGen *ir_analyze_array_cat(IrAnalyze *ira, IrInstSrcBinOp *instructi ZigValue *len_val = op1_val->data.x_struct.fields[slice_len_index]; op1_array_end = op1_array_index + bigint_as_usize(&len_val->data.x_bigint); sentinel1 = ptr_type->data.pointer.sentinel; - } else if (op1_type->id == ZigTypeIdPointer && op1_type->data.pointer.ptr_len == PtrLenSingle && - op1_type->data.pointer.child_type->id == ZigTypeIdArray) + } else if (op1_type->id == ZigTypeIdPointer && + op1_type->data.pointer.ptr_len == PtrLenSingle && + op1_type->data.pointer.child_type->id == ZigTypeIdArray) { ZigType *array_type = op1_type->data.pointer.child_type; child_type = array_type->data.array.child_type; @@ -17654,6 +17658,103 @@ static IrInstGen *ir_analyze_array_cat(IrAnalyze *ira, IrInstSrcBinOp *instructi return result; } +static IrInstGen *ir_analyze_tuple_mult(IrAnalyze *ira, IrInst* source_instr, + IrInstGen *op1, IrInstGen *op2) +{ + Error err; + ZigType *op1_type = op1->value->type; + uint64_t op1_field_count = op1_type->data.structure.src_field_count; + + uint64_t mult_amt; + if (!ir_resolve_usize(ira, op2, &mult_amt)) + return ira->codegen->invalid_inst_gen; + + uint64_t new_field_count; + if (mul_u64_overflow(op1_field_count, mult_amt, &new_field_count)) { + ir_add_error(ira, source_instr, buf_sprintf("operation results in overflow")); + return ira->codegen->invalid_inst_gen; + } + + Buf *bare_name = buf_alloc(); + Buf *name = get_anon_type_name(ira->codegen, nullptr, container_string(ContainerKindStruct), + source_instr->scope, source_instr->source_node, bare_name); + ZigType *new_type = get_partial_container_type(ira->codegen, source_instr->scope, + ContainerKindStruct, source_instr->source_node, buf_ptr(name), bare_name, ContainerLayoutAuto); + new_type->data.structure.special = StructSpecialInferredTuple; + new_type->data.structure.resolve_status = ResolveStatusBeingInferred; + new_type->data.structure.src_field_count = new_field_count; + new_type->data.structure.fields = realloc_type_struct_fields( + new_type->data.structure.fields, 0, new_field_count); + + IrInstGen *new_struct_ptr = ir_resolve_result(ira, source_instr, no_result_loc(), + new_type, nullptr, false, true); + + for (uint64_t i = 0; i < new_field_count; i += 1) { + TypeStructField *src_field = op1_type->data.structure.fields[i % op1_field_count]; + TypeStructField *new_field = new_type->data.structure.fields[i]; + + new_field->name = buf_sprintf("%lu", i); + new_field->type_entry = src_field->type_entry; + new_field->type_val = src_field->type_val; + new_field->src_index = i; + new_field->decl_node = src_field->decl_node; + new_field->init_val = src_field->init_val; + new_field->is_comptime = src_field->is_comptime; + } + + if ((err = type_resolve(ira->codegen, new_type, ResolveStatusZeroBitsKnown))) + return ira->codegen->invalid_inst_gen; + + ZigList const_ptrs = {}; + for (uint64_t i = 0; i < new_field_count; i += 1) { + TypeStructField *src_field = op1_type->data.structure.fields[i % op1_field_count]; + TypeStructField *dst_field = new_type->data.structure.fields[i]; + + IrInstGen *field_value = ir_analyze_struct_value_field_value( + ira, source_instr, op1, src_field); + if (type_is_invalid(field_value->value->type)) + return ira->codegen->invalid_inst_gen; + + IrInstGen *dest_ptr = ir_analyze_struct_field_ptr( + ira, source_instr, dst_field, new_struct_ptr, new_type, true); + if (type_is_invalid(dest_ptr->value->type)) + return ira->codegen->invalid_inst_gen; + + if (instr_is_comptime(field_value)) { + const_ptrs.append(dest_ptr); + } + + IrInstGen *store_ptr_inst = ir_analyze_store_ptr( + ira, source_instr, dest_ptr, field_value, true); + if (type_is_invalid(store_ptr_inst->value->type)) + return ira->codegen->invalid_inst_gen; + } + + if (const_ptrs.length != new_field_count) { + new_struct_ptr->value->special = ConstValSpecialRuntime; + for (size_t i = 0; i < const_ptrs.length; i += 1) { + IrInstGen *elem_result_loc = const_ptrs.at(i); + assert(elem_result_loc->value->special == ConstValSpecialStatic); + if (elem_result_loc->value->type->data.pointer.inferred_struct_field != nullptr) { + // This field will be generated comptime; no need to do this. + continue; + } + IrInstGen *deref = ir_get_deref(ira, &elem_result_loc->base, elem_result_loc, nullptr); + if (!type_requires_comptime(ira->codegen, elem_result_loc->value->type->data.pointer.child_type)) { + elem_result_loc->value->special = ConstValSpecialRuntime; + } + IrInstGen *store_ptr_inst = ir_analyze_store_ptr( + ira, &elem_result_loc->base, elem_result_loc, deref, true); + if (type_is_invalid(store_ptr_inst->value->type)) + return ira->codegen->invalid_inst_gen; + } + } + + const_ptrs.deinit(); + + return ir_get_deref(ira, source_instr, new_struct_ptr, nullptr); +} + static IrInstGen *ir_analyze_array_mult(IrAnalyze *ira, IrInstSrcBinOp *instruction) { IrInstGen *op1 = instruction->op1->child; if (type_is_invalid(op1->value->type)) @@ -17671,8 +17772,9 @@ static IrInstGen *ir_analyze_array_mult(IrAnalyze *ira, IrInstSrcBinOp *instruct array_val = ir_resolve_const(ira, op1, UndefOk); if (array_val == nullptr) return ira->codegen->invalid_inst_gen; - } else if (op1->value->type->id == ZigTypeIdPointer && op1->value->type->data.pointer.ptr_len == PtrLenSingle && - op1->value->type->data.pointer.child_type->id == ZigTypeIdArray) + } else if (op1->value->type->id == ZigTypeIdPointer && + op1->value->type->data.pointer.ptr_len == PtrLenSingle && + op1->value->type->data.pointer.child_type->id == ZigTypeIdArray) { array_type = op1->value->type->data.pointer.child_type; IrInstGen *array_inst = ir_get_deref(ira, &op1->base, op1, nullptr); @@ -17682,6 +17784,8 @@ static IrInstGen *ir_analyze_array_mult(IrAnalyze *ira, IrInstSrcBinOp *instruct if (array_val == nullptr) return ira->codegen->invalid_inst_gen; want_ptr_to_array = true; + } else if (is_tuple(op1->value->type)) { + return ir_analyze_tuple_mult(ira, &instruction->base.base, op1, op2); } else { ir_add_error(ira, &op1->base, buf_sprintf("expected array type, found '%s'", buf_ptr(&op1->value->type->name))); return ira->codegen->invalid_inst_gen; diff --git a/test/stage1/behavior/tuple.zig b/test/stage1/behavior/tuple.zig index 3c467baaa43e39f66cad7b9f368864fd26898e08..0b2fdfe4e0a56998cbee404380751122fb4fef29 100644 --- a/test/stage1/behavior/tuple.zig +++ b/test/stage1/behavior/tuple.zig @@ -1,5 +1,7 @@ const std = @import("std"); -const expect = std.testing.expect; +const testing = std.testing; +const expect = testing.expect; +const expectEqual = testing.expectEqual; test "tuple concatenation" { const S = struct { @@ -9,8 +11,31 @@ test "tuple concatenation" { var x = .{a}; var y = .{b}; var c = x ++ y; - expect(c[0] == 1); - expect(c[1] == 2); + expectEqual(@as(i32, 1), c[0]); + expectEqual(@as(i32, 2), c[1]); + } + }; + S.doTheTest(); + comptime S.doTheTest(); +} + +test "tuple multiplication" { + const S = struct { + fn doTheTest() void { + { + const t = .{} ** 4; + expectEqual(0, @typeInfo(@TypeOf(t)).Struct.fields.len); + } + { + const t = .{'a'} ** 4; + expectEqual(4, @typeInfo(@TypeOf(t)).Struct.fields.len); + inline for (t) |x| expectEqual('a', x); + } + { + const t = .{ 1, 2, 3 } ** 4; + expectEqual(12, @typeInfo(@TypeOf(t)).Struct.fields.len); + inline for (t) |x, i| expectEqual(1 + i % 3, x); + } } }; S.doTheTest(); -- 2.54.0 From 0a936c1d766e3f0b81d86bffee95d15b50fc6d58 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Mon, 6 Apr 2020 20:14:06 +0200 Subject: [PATCH 58/91] Add some tests for the runtime safety checks --- test/runtime_safety.zig | 69 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/test/runtime_safety.zig b/test/runtime_safety.zig index b8ab47ddac99765eff724efdd91b368ace5c6f47..7209ca5b1688035fe2e114364b011e35518d08c1 100644 --- a/test/runtime_safety.zig +++ b/test/runtime_safety.zig @@ -1,6 +1,75 @@ const tests = @import("tests.zig"); pub fn addCases(cases: *tests.CompareOutputContext) void { + { + const check_panic_msg = + \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn { + \\ if (std.mem.eql(u8, message, "index out of bounds")) { + \\ std.process.exit(126); // good + \\ } + \\ std.process.exit(0); // test failed + \\} + ; + + cases.addRuntimeSafety("slicing operator with sentinel", + \\const std = @import("std"); + ++ check_panic_msg ++ + \\pub fn main() void { + \\ var buf = [4]u8{'a','b','c',0}; + \\ const slice = buf[0..4 :0]; + \\} + ); + cases.addRuntimeSafety("slicing operator with sentinel", + \\const std = @import("std"); + ++ check_panic_msg ++ + \\pub fn main() void { + \\ var buf = [4]u8{'a','b','c',0}; + \\ const slice = buf[0..:0]; + \\} + ); + cases.addRuntimeSafety("slicing operator with sentinel", + \\const std = @import("std"); + ++ check_panic_msg ++ + \\pub fn main() void { + \\ var buf_zero = [0]u8{}; + \\ const slice = buf_zero[0..0 :0]; + \\} + ); + cases.addRuntimeSafety("slicing operator with sentinel", + \\const std = @import("std"); + ++ check_panic_msg ++ + \\pub fn main() void { + \\ var buf_zero = [0]u8{}; + \\ const slice = buf_zero[0..:0]; + \\} + ); + cases.addRuntimeSafety("slicing operator with sentinel", + \\const std = @import("std"); + ++ check_panic_msg ++ + \\pub fn main() void { + \\ var buf_sentinel = [2:0]u8{'a','b'}; + \\ @ptrCast(*[3]u8, &buf_sentinel)[2] = 0; + \\ const slice = buf_sentinel[0..3 :0]; + \\} + ); + cases.addRuntimeSafety("slicing operator with sentinel", + \\const std = @import("std"); + ++ check_panic_msg ++ + \\pub fn main() void { + \\ var buf_slice: []u8 = &[3]u8{ 'a', 'b', 0 }; + \\ const slice = buf_slice[0..3 :0]; + \\} + ); + cases.addRuntimeSafety("slicing operator with sentinel", + \\const std = @import("std"); + ++ check_panic_msg ++ + \\pub fn main() void { + \\ var buf_slice: []u8 = &[3]u8{ 'a', 'b', 0 }; + \\ const slice = buf_slice[0.. :0]; + \\} + ); + } + cases.addRuntimeSafety("shift left by huge amount", \\const std = @import("std"); \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn { -- 2.54.0 From afa24ccd993e38b56407c83160da567bc2b0ae8a Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 6 Apr 2020 18:35:49 -0400 Subject: [PATCH 59/91] fix the build on Windows Workaround for issue #2668 Zig std lib currently does not allow forward slashes in Windows path names. --- build.zig | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/build.zig b/build.zig index 78d5391e7e754602aa5bfad522dd7b1197a99065..ba37c1aa4278bec51bc35d12687fd24d9e58b668 100644 --- a/build.zig +++ b/build.zig @@ -39,7 +39,7 @@ pub fn build(b: *Builder) !void { "config_h", "Path to the generated config.h", )) |config_h_path| - try std.fs.cwd().readFileAlloc(b.allocator, config_h_path, max_config_h_bytes) + try std.fs.cwd().readFileAlloc(b.allocator, toNativePathSep(b, config_h_path), max_config_h_bytes) else try findAndReadConfigH(b); @@ -65,7 +65,7 @@ pub fn build(b: *Builder) !void { const only_install_lib_files = b.option(bool, "lib-files-only", "Only install library files") orelse false; if (!only_install_lib_files and !skip_self_hosted) { - var ctx = parseConfigH(config_h_text); + var ctx = parseConfigH(b, config_h_text); ctx.llvm = try findLLVM(b, ctx.llvm_config_exe); try configureStage2(b, test_stage2, ctx); @@ -377,7 +377,7 @@ fn findAndReadConfigH(b: *Builder) ![]const u8 { } else unreachable; // TODO should not need `else unreachable`. } -fn parseConfigH(config_h_text: []const u8) Context { +fn parseConfigH(b: *Builder, config_h_text: []const u8) Context { var ctx: Context = .{ .cmake_binary_dir = undefined, .cxx_compiler = undefined, @@ -426,9 +426,19 @@ fn parseConfigH(config_h_text: []const u8) Context { if (mem.startsWith(u8, line, mapping.prefix)) { var it = mem.split(line, "\""); _ = it.next().?; // skip the stuff before the quote - @field(ctx, mapping.field) = it.next().?; // the stuff inside the quote + const quoted = it.next().?; // the stuff inside the quote + @field(ctx, mapping.field) = toNativePathSep(b, quoted); } } } return ctx; } + +fn toNativePathSep(b: *Builder, s: []const u8) []u8 { + const duplicated = mem.dupe(b.allocator, u8, s) catch unreachable; + for (duplicated) |*byte| switch (byte.*) { + '/' => byte.* = fs.path.sep, + else => {}, + }; + return duplicated; +} -- 2.54.0 From 15ab61b2a00b56c5b15a2d5a4efbf6b7bde7a868 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 6 Apr 2020 15:42:04 -0400 Subject: [PATCH 60/91] cmake: improvements to cross-compiling for Windows * don't unconditionally pass -lz3 for mingw builds. If mingw builds require this then the llvm-config executable should put it as part of --system-libs. If there is a bug and it does not do that, and we need a workaround, then the workaround should be an explicit cmake option. * don't link libstage2.a against -lntdll. This causes zig to set `builtin.link_mode == .Dynamic` and include the TLS definitions, which then collide with the mingw-w64 symbols. This should probably be addressed separately, but for now this solves the problem and there is no reason to link a static library against a DLL. * Findllvm.cmake no longer treats the libraries as "optional" and will emit a cmake error if one is not found. Additionally, the not-required LLVM library LLVMTableGen is omitted. --- CMakeLists.txt | 8 +------- cmake/Findllvm.cmake | 5 +---- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2598d386b75b815029a210afdf3cb94903159716..14b490fa547c3dc1f30a5292e38ad53774c2259d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -365,7 +365,7 @@ if(ZIG_STATIC) endif() else() if(MINGW) - set(EXE_LDFLAGS "${EXE_LDFLAGS} -lz3") + set(EXE_LDFLAGS "${EXE_LDFLAGS}") endif() endif() @@ -429,11 +429,6 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") else() set(LIBSTAGE2_RELEASE_ARG --release-fast --strip) endif() -if(WIN32) - set(LIBSTAGE2_WINDOWS_ARGS "-lntdll") -else() - set(LIBSTAGE2_WINDOWS_ARGS "") -endif() set(BUILD_LIBSTAGE2_ARGS "build-lib" "src-self-hosted/stage2.zig" @@ -447,7 +442,6 @@ set(BUILD_LIBSTAGE2_ARGS "build-lib" --bundle-compiler-rt -fPIC -lc - ${LIBSTAGE2_WINDOWS_ARGS} ) if("${ZIG_TARGET_TRIPLE}" STREQUAL "native") diff --git a/cmake/Findllvm.cmake b/cmake/Findllvm.cmake index 6819c23ee5be6a5956bb0330124ea0f8e2c3eafd..12e1ff7eb0683969b1f5fc025f9b6f707ae2eed0 100644 --- a/cmake/Findllvm.cmake +++ b/cmake/Findllvm.cmake @@ -144,9 +144,7 @@ else() /mingw64/lib /c/msys64/mingw64/lib c:\\msys64\\mingw64\\lib) - if(LLVM_${_prettylibname_}_LIB) - set(LLVM_LIBRARIES ${LLVM_LIBRARIES} ${LLVM_${_prettylibname_}_LIB}) - endif() + set(LLVM_LIBRARIES ${LLVM_LIBRARIES} ${LLVM_${_prettylibname_}_LIB}) endmacro(FIND_AND_ADD_LLVM_LIB) # This list can be re-generated with `llvm-config --libfiles` and then @@ -154,7 +152,6 @@ else() # `llvm-config` here because we are cross compiling. FIND_AND_ADD_LLVM_LIB(LLVMXRay) FIND_AND_ADD_LLVM_LIB(LLVMWindowsManifest) - FIND_AND_ADD_LLVM_LIB(LLVMTableGen) FIND_AND_ADD_LLVM_LIB(LLVMSymbolize) FIND_AND_ADD_LLVM_LIB(LLVMDebugInfoPDB) FIND_AND_ADD_LLVM_LIB(LLVMOrcJIT) -- 2.54.0 From 64d0960244a219526fc100b17f4ecd26223df496 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 6 Apr 2020 19:13:36 -0400 Subject: [PATCH 61/91] zig cc: recognize a few more linker options * `--major-image-version` * `--minor-image-version` * `--stack` --- src/all_types.hpp | 1 + src/codegen.cpp | 1 + src/link.cpp | 6 ++++-- src/main.cpp | 23 +++++++++++++++++++++++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/all_types.hpp b/src/all_types.hpp index 9b22279b9120d3ba4d1aa504ca368687314a3512..650dcfd0c7a8cf57d2af7f657fdc123dd76f1400 100644 --- a/src/all_types.hpp +++ b/src/all_types.hpp @@ -2259,6 +2259,7 @@ struct CodeGen { size_t version_minor; size_t version_patch; const char *linker_script; + size_t stack_size_override; BuildMode build_mode; OutType out_type; diff --git a/src/codegen.cpp b/src/codegen.cpp index a2cd5fafc01168671abc8ad4821072adb5934bf5..7de26e0b6d41d70581a8119b7057aad346f418bf 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -10597,6 +10597,7 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) { cache_int(ch, g->linker_allow_shlib_undefined); cache_bool(ch, g->linker_z_nodelete); cache_bool(ch, g->linker_z_defs); + cache_usize(ch, g->stack_size_override); // gen_c_objects appends objects to g->link_objects which we want to include in the hash gen_c_objects(g); diff --git a/src/link.cpp b/src/link.cpp index 4ee8915e55095fc900043934a0201c9186af6973..439b76a75601e1a3c6e035a9bb618e0cacca7c04 100644 --- a/src/link.cpp +++ b/src/link.cpp @@ -1840,7 +1840,8 @@ static void construct_linker_job_elf(LinkJob *lj) { if (g->out_type == OutTypeExe) { lj->args.append("-z"); - lj->args.append("stack-size=16777216"); // default to 16 MiB + size_t stack_size = (g->stack_size_override == 0) ? 16777216 : g->stack_size_override; + lj->args.append(buf_ptr(buf_sprintf("stack-size=%" ZIG_PRI_usize, stack_size))); } if (g->linker_script) { @@ -2479,7 +2480,8 @@ static void construct_linker_job_coff(LinkJob *lj) { if (g->out_type == OutTypeExe) { // TODO compile time stack upper bound detection - lj->args.append("-STACK:16777216"); + size_t stack_size = (g->stack_size_override == 0) ? 16777216 : g->stack_size_override; + lj->args.append(buf_ptr(buf_sprintf("-STACK:%" ZIG_PRI_usize, stack_size))); } coff_append_machine_arg(g, &lj->args); diff --git a/src/main.cpp b/src/main.cpp index a2d7577a7420c6c5ad16530461188c9199891ade..8805382f3764c1797491e071267b1b1daabb59c8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -453,6 +453,7 @@ static int main0(int argc, char **argv) { OptionalBool linker_allow_shlib_undefined = OptionalBoolNull; bool linker_z_nodelete = false; bool linker_z_defs = false; + size_t stack_size_override = 0; ZigList llvm_argv = {0}; llvm_argv.append("zig (LLVM option parsing)"); @@ -848,6 +849,27 @@ static int main0(int argc, char **argv) { } else { fprintf(stderr, "warning: unsupported linker arg: -z %s\n", buf_ptr(z_arg)); } + } else if (buf_eql_str(arg, "--major-image-version")) { + i += 1; + if (i >= linker_args.length) { + fprintf(stderr, "expected linker arg after '%s'\n", buf_ptr(arg)); + return EXIT_FAILURE; + } + ver_major = atoi(buf_ptr(linker_args.at(i))); + } else if (buf_eql_str(arg, "--minor-image-version")) { + i += 1; + if (i >= linker_args.length) { + fprintf(stderr, "expected linker arg after '%s'\n", buf_ptr(arg)); + return EXIT_FAILURE; + } + ver_minor = atoi(buf_ptr(linker_args.at(i))); + } else if (buf_eql_str(arg, "--stack")) { + i += 1; + if (i >= linker_args.length) { + fprintf(stderr, "expected linker arg after '%s'\n", buf_ptr(arg)); + return EXIT_FAILURE; + } + stack_size_override = atoi(buf_ptr(linker_args.at(i))); } else { fprintf(stderr, "warning: unsupported linker arg: %s\n", buf_ptr(arg)); } @@ -1573,6 +1595,7 @@ static int main0(int argc, char **argv) { g->linker_allow_shlib_undefined = linker_allow_shlib_undefined; g->linker_z_nodelete = linker_z_nodelete; g->linker_z_defs = linker_z_defs; + g->stack_size_override = stack_size_override; if (override_soname) { g->override_soname = buf_create_from_str(override_soname); -- 2.54.0 From 9ed00b3829dae0fca3db6c0e501ae006e9e8aad8 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 6 Apr 2020 19:26:31 -0400 Subject: [PATCH 62/91] provide ___mb_cur_max_func for i386-windows-gnu --- lib/libc/mingw/misc/___mb_cur_max_func.c | 18 ++++++++++++++++++ src/link.cpp | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 lib/libc/mingw/misc/___mb_cur_max_func.c diff --git a/lib/libc/mingw/misc/___mb_cur_max_func.c b/lib/libc/mingw/misc/___mb_cur_max_func.c new file mode 100644 index 0000000000000000000000000000000000000000..61dcdb7a6620b52ff4f25bc6f6cb3a992a9fe77a --- /dev/null +++ b/lib/libc/mingw/misc/___mb_cur_max_func.c @@ -0,0 +1,18 @@ +/** + * This file has no copyright assigned and is placed in the Public Domain. + * This file is part of the mingw-w64 runtime package. + * No warranty is given; refer to the file DISCLAIMER.PD within this package. + */ + +#include <_mingw.h> + +extern int* __MINGW_IMP_SYMBOL(__mb_cur_max); + +int __cdecl ___mb_cur_max_func(void); +int __cdecl ___mb_cur_max_func(void) +{ + return *__MINGW_IMP_SYMBOL(__mb_cur_max); +} + +typedef int __cdecl (*_f___mb_cur_max_func)(void); +_f___mb_cur_max_func __MINGW_IMP_SYMBOL(___mb_cur_max_func) = ___mb_cur_max_func; diff --git a/src/link.cpp b/src/link.cpp index 439b76a75601e1a3c6e035a9bb618e0cacca7c04..0c02837630133e9f90f10ad1fd49126d25c6f47f 100644 --- a/src/link.cpp +++ b/src/link.cpp @@ -72,7 +72,7 @@ static const char *msvcrt_common_src[] = { static const char *msvcrt_i386_src[] = { "misc" OS_SEP "lc_locale_func.c", - + "misc" OS_SEP "___mb_cur_max_func.c", }; static const char *msvcrt_other_src[] = { -- 2.54.0 From 41cb49eb5807f89ca81f725885e5194690f5f1d8 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 6 Apr 2020 20:30:34 -0400 Subject: [PATCH 63/91] stage1 fixes to support building with 32-bit mingw-w64 --- src/os.cpp | 2 ++ src/zig_clang.h | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/os.cpp b/src/os.cpp index 505063f827d994790c5aae92a69aadb797ea0be6..16d6847d4e5011a767c688e93d1adad46147d819 100644 --- a/src/os.cpp +++ b/src/os.cpp @@ -37,7 +37,9 @@ #include #include +#if defined(_MSC_VER) typedef SSIZE_T ssize_t; +#endif #else #define ZIG_OS_POSIX diff --git a/src/zig_clang.h b/src/zig_clang.h index f938d8b56e521bf651bb254503cdf8bd068a3af1..272064a0ef928fa25642f3a2b17e8be96e819231 100644 --- a/src/zig_clang.h +++ b/src/zig_clang.h @@ -50,7 +50,9 @@ enum ZigClangAPValueKind { struct ZigClangAPValue { enum ZigClangAPValueKind Kind; // experimentally-derived size of clang::APValue::DataType -#if defined(_WIN32) && defined(_MSC_VER) +#if defined(_WIN32) && defined(__i386__) + char Data[68]; +#elif defined(_WIN32) && defined(_MSC_VER) char Data[52]; #elif defined(__i386__) char Data[48]; -- 2.54.0 From fc662ddd54df75bf21d1be74c9d720fb8f164591 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 6 Apr 2020 20:31:00 -0400 Subject: [PATCH 64/91] mingw-w64: add 32-bit version.def fixes -lversion on 32-bit windows builds --- lib/libc/mingw/lib32/version.def | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 lib/libc/mingw/lib32/version.def diff --git a/lib/libc/mingw/lib32/version.def b/lib/libc/mingw/lib32/version.def new file mode 100644 index 0000000000000000000000000000000000000000..35a087e5dc2c948cafc314343b939bedf039cbd4 --- /dev/null +++ b/lib/libc/mingw/lib32/version.def @@ -0,0 +1,16 @@ +LIBRARY "VERSION.dll" +EXPORTS +GetFileVersionInfoA@16 +GetFileVersionInfoSizeA@8 +GetFileVersionInfoSizeW@8 +GetFileVersionInfoW@16 +VerFindFileA@32 +VerFindFileW@32 +VerInstallFileA@32 +VerInstallFileW@32 +VerLanguageNameA@12 +VerLanguageNameW@12 +VerQueryValueA@16 +VerQueryValueIndexA@24 +VerQueryValueIndexW@24 +VerQueryValueW@16 -- 2.54.0 From e62671f643a5072fb8e56306a87a2772dc357e9c Mon Sep 17 00:00:00 2001 From: Vexu Date: Tue, 7 Apr 2020 15:12:37 +0300 Subject: [PATCH 65/91] fix missing const on address of literal --- src/all_types.hpp | 2 -- src/ir.cpp | 21 +++++++++++++-------- src/ir_print.cpp | 4 +--- test/compile_errors.zig | 28 ++++++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 13 deletions(-) diff --git a/src/all_types.hpp b/src/all_types.hpp index 650dcfd0c7a8cf57d2af7f657fdc123dd76f1400..56ce74caae983dc010ddeb814197d275c7123a69 100644 --- a/src/all_types.hpp +++ b/src/all_types.hpp @@ -3519,8 +3519,6 @@ struct IrInstSrcRef { IrInstSrc base; IrInstSrc *value; - bool is_const; - bool is_volatile; }; struct IrInstGenRef { diff --git a/src/ir.cpp b/src/ir.cpp index 5a96bc2d52ee00de912cbf0174442320fafeac2e..b57011717761477c6c994fbac3e43f030c42b6a9 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -3290,13 +3290,9 @@ static IrInstSrc *ir_build_import(IrBuilderSrc *irb, Scope *scope, AstNode *sour return &instruction->base; } -static IrInstSrc *ir_build_ref_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *value, - bool is_const, bool is_volatile) -{ +static IrInstSrc *ir_build_ref_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *value) { IrInstSrcRef *instruction = ir_build_instruction(irb, scope, source_node); instruction->value = value; - instruction->is_const = is_const; - instruction->is_volatile = is_volatile; ir_ref_instruction(value, irb->current_basic_block); @@ -5938,7 +5934,7 @@ static IrInstSrc *ir_gen_symbol(IrBuilderSrc *irb, Scope *scope, AstNode *node, } else { IrInstSrc *value = ir_build_const_type(irb, scope, node, primitive_type); if (lval == LValPtr) { - return ir_build_ref_src(irb, scope, node, value, false, false); + return ir_build_ref_src(irb, scope, node, value); } else { return ir_expr_wrap(irb, scope, value, result_loc); } @@ -7486,7 +7482,7 @@ static IrInstSrc *ir_lval_wrap(IrBuilderSrc *irb, Scope *scope, IrInstSrc *value if (lval == LValPtr) { // We needed a pointer to a value, but we got a value. So we create // an instruction which just makes a pointer of it. - return ir_build_ref_src(irb, scope, value->base.source_node, value, false, false); + return ir_build_ref_src(irb, scope, value->base.source_node, value); } else if (result_loc != nullptr) { return ir_expr_wrap(irb, scope, value, result_loc); } else { @@ -23348,7 +23344,16 @@ static IrInstGen *ir_analyze_instruction_ref(IrAnalyze *ira, IrInstSrcRef *ref_i IrInstGen *value = ref_instruction->value->child; if (type_is_invalid(value->value->type)) return ira->codegen->invalid_inst_gen; - return ir_get_ref(ira, &ref_instruction->base.base, value, ref_instruction->is_const, ref_instruction->is_volatile); + + bool is_const = false; + bool is_volatile = false; + + ZigValue *child_value = value->value; + if (child_value->special == ConstValSpecialStatic) { + is_const = true; + } + + return ir_get_ref(ira, &ref_instruction->base.base, value, is_const, is_volatile); } static IrInstGen *ir_analyze_union_init(IrAnalyze *ira, IrInst* source_instruction, diff --git a/src/ir_print.cpp b/src/ir_print.cpp index e66b4a3cdf7b0b3505d25d85f0188672aba59ebb..0477f3edaa84e86f1f61a4fdc6c46862f052e91e 100644 --- a/src/ir_print.cpp +++ b/src/ir_print.cpp @@ -1476,9 +1476,7 @@ static void ir_print_import(IrPrintSrc *irp, IrInstSrcImport *instruction) { } static void ir_print_ref(IrPrintSrc *irp, IrInstSrcRef *instruction) { - const char *const_str = instruction->is_const ? "const " : ""; - const char *volatile_str = instruction->is_volatile ? "volatile " : ""; - fprintf(irp->f, "%s%sref ", const_str, volatile_str); + fprintf(irp->f, "ref "); ir_print_other_inst_src(irp, instruction->value); } diff --git a/test/compile_errors.zig b/test/compile_errors.zig index 166ed67561c96d576897f401fb2771bace9995b2..696ef1f6ceb87d2268731e9acdeb477ee56134e2 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -2,6 +2,34 @@ const tests = @import("tests.zig"); const std = @import("std"); pub fn addCases(cases: *tests.CompileErrorContext) void { + cases.addTest("reference to const data", + \\export fn foo() void { + \\ var ptr = &[_]u8{0,0,0,0}; + \\ ptr[1] = 2; + \\} + \\export fn bar() void { + \\ var ptr = &@as(u32, 2); + \\ ptr.* = 2; + \\} + \\export fn baz() void { + \\ var ptr = &true; + \\ ptr.* = false; + \\} + \\export fn qux() void { + \\ const S = struct{ + \\ x: usize, + \\ y: usize, + \\ }; + \\ var ptr = &S{.x=1,.y=2}; + \\ ptr.x = 2; + \\} + , &[_][]const u8{ + "tmp.zig:3:14: error: cannot assign to constant", + "tmp.zig:7:13: error: cannot assign to constant", + "tmp.zig:11:13: error: cannot assign to constant", + "tmp.zig:19:13: error: cannot assign to constant", + }); + cases.addTest("cast between ?T where T is not a pointer", \\pub const fnty1 = ?fn (i8) void; \\pub const fnty2 = ?fn (u64) void; -- 2.54.0 From 95fefcd4c91e517a51f4b55924979421c6f7e8d3 Mon Sep 17 00:00:00 2001 From: Vexu Date: Tue, 7 Apr 2020 15:24:49 +0300 Subject: [PATCH 66/91] fix broken tests --- lib/std/json.zig | 11 ++++++----- lib/std/testing.zig | 3 ++- test/compile_errors.zig | 10 +++++----- test/stage1/behavior/for.zig | 4 ++-- test/stage1/behavior/pointers.zig | 6 +++--- test/stage1/behavior/slice.zig | 4 ++-- 6 files changed, 20 insertions(+), 18 deletions(-) diff --git a/lib/std/json.zig b/lib/std/json.zig index 79830d8a2c45d95259b99a86c1569d427cbf30e8..d271b6c19fd59c2e34b4238c2d78ffda5857ea99 100644 --- a/lib/std/json.zig +++ b/lib/std/json.zig @@ -1327,12 +1327,13 @@ test "Value.jsonStringify" { { var buffer: [10]u8 = undefined; var fbs = std.io.fixedBufferStream(&buffer); + var vals = [_]Value{ + .{ .Integer = 1 }, + .{ .Integer = 2 }, + .{ .Integer = 3 }, + }; try (Value{ - .Array = Array.fromOwnedSlice(undefined, &[_]Value{ - .{ .Integer = 1 }, - .{ .Integer = 2 }, - .{ .Integer = 3 }, - }), + .Array = Array.fromOwnedSlice(undefined, &vals), }).jsonStringify(.{}, fbs.outStream()); testing.expectEqualSlices(u8, fbs.getWritten(), "[1,2,3]"); } diff --git a/lib/std/testing.zig b/lib/std/testing.zig index 4f527ba700ab99288309eec7fb8f5fe649ba5765..4b629156f6e2578ac241c59cd41a93dea9d6a340 100644 --- a/lib/std/testing.zig +++ b/lib/std/testing.zig @@ -7,7 +7,8 @@ pub const FailingAllocator = @import("testing/failing_allocator.zig").FailingAll pub const allocator = &allocator_instance.allocator; pub var allocator_instance = LeakCountAllocator.init(&base_allocator_instance.allocator); -pub const failing_allocator = &FailingAllocator.init(&base_allocator_instance.allocator, 0).allocator; +pub const failing_allocator = &failing_allocator_instance.allocator; +pub var failing_allocator_instance = FailingAllocator.init(&base_allocator_instance.allocator, 0); pub var base_allocator_instance = std.heap.ThreadSafeFixedBufferAllocator.init(allocator_mem[0..]); var allocator_mem: [1024 * 1024]u8 = undefined; diff --git a/test/compile_errors.zig b/test/compile_errors.zig index 696ef1f6ceb87d2268731e9acdeb477ee56134e2..1d8f5e17f98e40c08ac09a521fe31d866480fc66 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -997,7 +997,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { \\ const x = 1 << &@as(u8, 10); \\} , &[_][]const u8{ - "tmp.zig:2:21: error: shift amount has to be an integer type, but found '*u8'", + "tmp.zig:2:21: error: shift amount has to be an integer type, but found '*const u8'", "tmp.zig:2:17: note: referenced here", }); @@ -1006,7 +1006,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { \\ const x = &@as(u8, 1) << 10; \\} , &[_][]const u8{ - "tmp.zig:2:16: error: bit shifting operation expected integer type, found '*u8'", + "tmp.zig:2:16: error: bit shifting operation expected integer type, found '*const u8'", "tmp.zig:2:27: note: referenced here", }); @@ -6033,7 +6033,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { \\ fn bar(self: *const Foo) void {} \\}; , &[_][]const u8{ - "tmp.zig:2:4: error: variable of type '*comptime_int' must be const or comptime", + "tmp.zig:2:4: error: variable of type '*const comptime_int' must be const or comptime", "tmp.zig:5:4: error: variable of type '(undefined)' must be const or comptime", "tmp.zig:8:4: error: variable of type 'comptime_int' must be const or comptime", "tmp.zig:11:4: error: variable of type 'comptime_float' must be const or comptime", @@ -6877,12 +6877,12 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { \\ const word: u16 = @bitCast(u16, bytes[0..]); \\} \\export fn foo2() void { - \\ var bytes: []u8 = &[_]u8{1, 2}; + \\ var bytes: []const u8 = &[_]u8{1, 2}; \\ const word: u16 = @bitCast(u16, bytes); \\} , &[_][]const u8{ "tmp.zig:3:42: error: unable to @bitCast from pointer type '*[2]u8'", - "tmp.zig:7:32: error: destination type 'u16' has size 2 but source type '[]u8' has size 16", + "tmp.zig:7:32: error: destination type 'u16' has size 2 but source type '[]const u8' has size 16", "tmp.zig:7:37: note: referenced here", }); diff --git a/test/stage1/behavior/for.zig b/test/stage1/behavior/for.zig index c0b1cf264afa83ee820e05479234a83deb25d163..fd98ec48dee51e83add9ce627ad0eed182deb04b 100644 --- a/test/stage1/behavior/for.zig +++ b/test/stage1/behavior/for.zig @@ -161,8 +161,8 @@ test "for copies its payload" { test "for on slice with allowzero ptr" { const S = struct { - fn doTheTest(slice: []u8) void { - var ptr = @ptrCast([*]allowzero u8, slice.ptr)[0..slice.len]; + fn doTheTest(slice: []const u8) void { + var ptr = @ptrCast([*]const allowzero u8, slice.ptr)[0..slice.len]; for (ptr) |x, i| expect(x == i + 1); for (ptr) |*x, i| expect(x.* == i + 1); } diff --git a/test/stage1/behavior/pointers.zig b/test/stage1/behavior/pointers.zig index 6b86c2f6ac84693301396945b2206973749f58bc..fa5f2a469db12f917b1b8a96f8aa7a5af2bb772d 100644 --- a/test/stage1/behavior/pointers.zig +++ b/test/stage1/behavior/pointers.zig @@ -253,7 +253,7 @@ test "pointer sentinel with enums" { }; fn doTheTest() void { - var ptr: [*:.sentinel]Number = &[_:.sentinel]Number{ .one, .two, .two, .one }; + var ptr: [*:.sentinel]const Number = &[_:.sentinel]Number{ .one, .two, .two, .one }; expect(ptr[4] == .sentinel); // TODO this should be comptime expect, see #3731 } }; @@ -264,7 +264,7 @@ test "pointer sentinel with enums" { test "pointer sentinel with optional element" { const S = struct { fn doTheTest() void { - var ptr: [*:null]?i32 = &[_:null]?i32{ 1, 2, 3, 4 }; + var ptr: [*:null]const ?i32 = &[_:null]?i32{ 1, 2, 3, 4 }; expect(ptr[4] == null); // TODO this should be comptime expect, see #3731 } }; @@ -276,7 +276,7 @@ test "pointer sentinel with +inf" { const S = struct { fn doTheTest() void { const inf = std.math.inf_f32; - var ptr: [*:inf]f32 = &[_:inf]f32{ 1.1, 2.2, 3.3, 4.4 }; + var ptr: [*:inf]const f32 = &[_:inf]f32{ 1.1, 2.2, 3.3, 4.4 }; expect(ptr[4] == inf); // TODO this should be comptime expect, see #3731 } }; diff --git a/test/stage1/behavior/slice.zig b/test/stage1/behavior/slice.zig index e357ad2f0f30317f5fb4c688a94e00b4fa558d11..1faefe680037b38cfb196e487558c87c8a9f4838 100644 --- a/test/stage1/behavior/slice.zig +++ b/test/stage1/behavior/slice.zig @@ -218,9 +218,9 @@ test "slice syntax resulting in pointer-to-array" { } fn testPointer0() void { - var pointer: [*]u0 = &[1]u0{0}; + var pointer: [*]const u0 = &[1]u0{0}; var slice = pointer[0..1]; - comptime expect(@TypeOf(slice) == *[1]u0); + comptime expect(@TypeOf(slice) == *const [1]u0); expect(slice[0] == 0); } -- 2.54.0 From 7a829a70152522551610c692fe2253b2197ddb66 Mon Sep 17 00:00:00 2001 From: Michael Neumann Date: Tue, 7 Apr 2020 17:13:33 +0200 Subject: [PATCH 67/91] Fix paths to find llvm/clang on DragonFly --- cmake/Findclang.cmake | 2 ++ cmake/Findlld.cmake | 3 +++ cmake/Findllvm.cmake | 4 +++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/cmake/Findclang.cmake b/cmake/Findclang.cmake index 751cc5c824ac89d300c24b87876f2862496d006c..13f9225a34b6c3e634fc6bea137027040cf65c1c 100644 --- a/cmake/Findclang.cmake +++ b/cmake/Findclang.cmake @@ -13,6 +13,7 @@ find_path(CLANG_INCLUDE_DIRS NAMES clang/Frontend/ASTUnit.h /usr/lib/llvm-10/include /usr/lib/llvm-10.0/include /usr/local/llvm100/include + /usr/local/llvm10/include /mingw64/include) macro(FIND_AND_ADD_CLANG_LIB _libname_) @@ -24,6 +25,7 @@ macro(FIND_AND_ADD_CLANG_LIB _libname_) /usr/lib/llvm-10/lib /usr/lib/llvm-10.0/lib /usr/local/llvm100/lib + /usr/local/llvm10/lib /mingw64/lib /c/msys64/mingw64/lib c:\\msys64\\mingw64\\lib) diff --git a/cmake/Findlld.cmake b/cmake/Findlld.cmake index e27605a54d91613b4dd6e7c84071b6c540057fec..123984ee118e992fabf96aa0d6ac57fcd781e2c6 100644 --- a/cmake/Findlld.cmake +++ b/cmake/Findlld.cmake @@ -10,12 +10,14 @@ find_path(LLD_INCLUDE_DIRS NAMES lld/Common/Driver.h PATHS /usr/lib/llvm-10/include /usr/local/llvm100/include + /usr/local/llvm10/include /mingw64/include) find_library(LLD_LIBRARY NAMES lld-10.0 lld100 lld PATHS /usr/lib/llvm-10/lib /usr/local/llvm100/lib + /usr/local/llvm10/lib ) if(EXISTS ${LLD_LIBRARY}) set(LLD_LIBRARIES ${LLD_LIBRARY}) @@ -27,6 +29,7 @@ else() ${LLD_LIBDIRS} /usr/lib/llvm-10/lib /usr/local/llvm100/lib + /usr/local/llvm10/lib /mingw64/lib /c/msys64/mingw64/lib c:/msys64/mingw64/lib) diff --git a/cmake/Findllvm.cmake b/cmake/Findllvm.cmake index 12e1ff7eb0683969b1f5fc025f9b6f707ae2eed0..7d6a4b04da0f56618bdf44066354bc5175483baa 100644 --- a/cmake/Findllvm.cmake +++ b/cmake/Findllvm.cmake @@ -9,7 +9,7 @@ if("${ZIG_TARGET_TRIPLE}" STREQUAL "native") find_program(LLVM_CONFIG_EXE - NAMES llvm-config-10 llvm-config-10.0 llvm-config100 llvm-config + NAMES llvm-config-10 llvm-config-10.0 llvm-config100 llvm-config10 llvm-config PATHS "/mingw64/bin" "/c/msys64/mingw64/bin" @@ -130,6 +130,7 @@ else() /usr/lib/llvm-10/include /usr/lib/llvm-10.0/include /usr/local/llvm100/include + /usr/local/llvm10/include /mingw64/include) macro(FIND_AND_ADD_LLVM_LIB _libname_) @@ -141,6 +142,7 @@ else() /usr/lib/llvm-10/lib /usr/lib/llvm-10.0/lib /usr/local/llvm100/lib + /usr/local/llvm10/lib /mingw64/lib /c/msys64/mingw64/lib c:\\msys64\\mingw64\\lib) -- 2.54.0 From 2b9cef1e0414f01e024af6f69a885faaeaa95f7c Mon Sep 17 00:00:00 2001 From: Michael Neumann Date: Tue, 7 Apr 2020 17:23:20 +0200 Subject: [PATCH 68/91] Add missing constants for DragonFly --- lib/std/os/bits/dragonfly.zig | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/std/os/bits/dragonfly.zig b/lib/std/os/bits/dragonfly.zig index 4a9b51d472ad27ac4c8ac30570a18ce0ac4211dc..1e869679efb48fddbd48947c8ca285f51a893dff 100644 --- a/lib/std/os/bits/dragonfly.zig +++ b/lib/std/os/bits/dragonfly.zig @@ -244,6 +244,12 @@ pub const KERN_MAXID = 37; pub const HOST_NAME_MAX = 255; +// access function +pub const F_OK = 0; // test for existence of file +pub const X_OK = 1; // test for execute or search permission +pub const W_OK = 2; // test for write permission +pub const R_OK = 4; // test for read permission + pub const O_RDONLY = 0; pub const O_NDELAY = O_NONBLOCK; pub const O_WRONLY = 1; @@ -277,7 +283,6 @@ pub const SEEK_END = 2; pub const SEEK_DATA = 3; pub const SEEK_HOLE = 4; -pub const F_OK = 0; pub const F_ULOCK = 0; pub const F_LOCK = 1; pub const F_TLOCK = 2; -- 2.54.0 From 1ee59c5c31efca394d7e6d9da3f64c289a996b99 Mon Sep 17 00:00:00 2001 From: joachimschmidt557 Date: Mon, 6 Apr 2020 23:22:03 +0200 Subject: [PATCH 69/91] move big.rational.gcd to big.int.gcd --- lib/std/math/big/int.zig | 187 +++++++++++++++++++++++++++++++++ lib/std/math/big/rational.zig | 189 +--------------------------------- 2 files changed, 188 insertions(+), 188 deletions(-) diff --git a/lib/std/math/big/int.zig b/lib/std/math/big/int.zig index 51e97abf61ced0ddd017e617f3c29ad5272249e1..54f4a48d35df482ec437967b33475104e95bac41 100644 --- a/lib/std/math/big/int.zig +++ b/lib/std/math/big/int.zig @@ -10,6 +10,7 @@ const minInt = std.math.minInt; pub const Limb = usize; pub const DoubleLimb = std.meta.IntType(false, 2 * Limb.bit_count); +pub const SignedDoubleLimb = std.meta.IntType(true, DoubleLimb.bit_count); pub const Log2Limb = math.Log2Int(Limb); comptime { @@ -1359,8 +1360,129 @@ pub const Int = struct { r[i] = a[i]; } } + + pub fn gcd(rma: *Int, x: Int, y: Int) !void { + rma.assertWritable(); + var r = rma; + var aliased = rma.limbs.ptr == x.limbs.ptr or rma.limbs.ptr == y.limbs.ptr; + + var sr: Int = undefined; + if (aliased) { + sr = try Int.initCapacity(rma.allocator.?, math.max(x.len(), y.len())); + r = &sr; + aliased = true; + } + defer if (aliased) { + rma.swap(r); + r.deinit(); + }; + + try gcdLehmer(r, x, y); + } + + fn gcdLehmer(r: *Int, xa: Int, ya: Int) !void { + var x = try xa.clone(); + x.abs(); + defer x.deinit(); + + var y = try ya.clone(); + y.abs(); + defer y.deinit(); + + if (x.cmp(y) == .lt) { + x.swap(&y); + } + + var T = try Int.init(r.allocator.?); + defer T.deinit(); + + while (y.len() > 1) { + debug.assert(x.isPositive() and y.isPositive()); + debug.assert(x.len() >= y.len()); + + var xh: SignedDoubleLimb = x.limbs[x.len() - 1]; + var yh: SignedDoubleLimb = if (x.len() > y.len()) 0 else y.limbs[x.len() - 1]; + + var A: SignedDoubleLimb = 1; + var B: SignedDoubleLimb = 0; + var C: SignedDoubleLimb = 0; + var D: SignedDoubleLimb = 1; + + while (yh + C != 0 and yh + D != 0) { + const q = @divFloor(xh + A, yh + C); + const qp = @divFloor(xh + B, yh + D); + if (q != qp) { + break; + } + + var t = A - q * C; + A = C; + C = t; + t = B - q * D; + B = D; + D = t; + + t = xh - q * yh; + xh = yh; + yh = t; + } + + if (B == 0) { + // T = x % y, r is unused + try Int.divTrunc(r, &T, x, y); + debug.assert(T.isPositive()); + + x.swap(&y); + y.swap(&T); + } else { + var storage: [8]Limb = undefined; + const Ap = FixedIntFromSignedDoubleLimb(A, storage[0..2]); + const Bp = FixedIntFromSignedDoubleLimb(B, storage[2..4]); + const Cp = FixedIntFromSignedDoubleLimb(C, storage[4..6]); + const Dp = FixedIntFromSignedDoubleLimb(D, storage[6..8]); + + // T = Ax + By + try r.mul(x, Ap); + try T.mul(y, Bp); + try T.add(r.*, T); + + // u = Cx + Dy, r as u + try x.mul(x, Cp); + try r.mul(y, Dp); + try r.add(x, r.*); + + x.swap(&T); + y.swap(r); + } + } + + // euclidean algorithm + debug.assert(x.cmp(y) != .lt); + + while (!y.eqZero()) { + try Int.divTrunc(&T, r, x, y); + x.swap(&y); + y.swap(r); + } + + r.swap(&x); + } + }; +// Storage must live for the lifetime of the returned value +fn FixedIntFromSignedDoubleLimb(A: SignedDoubleLimb, storage: []Limb) Int { + std.debug.assert(storage.len >= 2); + + var A_is_positive = A >= 0; + const Au = @intCast(DoubleLimb, if (A < 0) -A else A); + storage[0] = @truncate(Limb, Au); + storage[1] = @truncate(Limb, Au >> Limb.bit_count); + var Ap = Int.initFixed(storage[0..2]); + Ap.setSign(A_is_positive); + return Ap; +} + // NOTE: All the following tests assume the max machine-word will be 64-bit. // // They will still run on larger than this and should pass, but the multi-limb code-paths @@ -2738,3 +2860,68 @@ test "big.int var args" { defer d.deinit(); testing.expect(a.cmp(d) != .gt); } + +test "big.int gcd non-one small" { + var a = try Int.initSet(testing.allocator, 17); + defer a.deinit(); + var b = try Int.initSet(testing.allocator, 97); + defer b.deinit(); + var r = try Int.init(testing.allocator); + defer r.deinit(); + + try r.gcd(a, b); + + testing.expect((try r.to(u32)) == 1); +} + +test "big.int gcd non-one small" { + var a = try Int.initSet(testing.allocator, 4864); + defer a.deinit(); + var b = try Int.initSet(testing.allocator, 3458); + defer b.deinit(); + var r = try Int.init(testing.allocator); + defer r.deinit(); + + try r.gcd(a, b); + + testing.expect((try r.to(u32)) == 38); +} + +test "big.int gcd non-one large" { + var a = try Int.initSet(testing.allocator, 0xffffffffffffffff); + defer a.deinit(); + var b = try Int.initSet(testing.allocator, 0xffffffffffffffff7777); + defer b.deinit(); + var r = try Int.init(testing.allocator); + defer r.deinit(); + + try r.gcd(a, b); + + testing.expect((try r.to(u32)) == 4369); +} + +test "big.int gcd large multi-limb result" { + var a = try Int.initSet(testing.allocator, 0x12345678123456781234567812345678123456781234567812345678); + defer a.deinit(); + var b = try Int.initSet(testing.allocator, 0x12345671234567123456712345671234567123456712345671234567); + defer b.deinit(); + var r = try Int.init(testing.allocator); + defer r.deinit(); + + try r.gcd(a, b); + + testing.expect((try r.to(u256)) == 0xf000000ff00000fff0000ffff000fffff00ffffff1); +} + +test "big.int gcd one large" { + var a = try Int.initSet(testing.allocator, 1897056385327307); + defer a.deinit(); + var b = try Int.initSet(testing.allocator, 2251799813685248); + defer b.deinit(); + var r = try Int.init(testing.allocator); + defer r.deinit(); + + try r.gcd(a, b); + + testing.expect((try r.to(u64)) == 1); +} diff --git a/lib/std/math/big/rational.zig b/lib/std/math/big/rational.zig index 8d2932a92052ca6fa26e0617200af33cf70e40d2..21e89ff8c451d2996b9564e145e92dbbb17dfb33 100644 --- a/lib/std/math/big/rational.zig +++ b/lib/std/math/big/rational.zig @@ -447,7 +447,7 @@ pub const Rational = struct { const sign = r.p.isPositive(); r.p.abs(); - try gcd(&a, r.p, r.q); + try a.gcd(r.p, r.q); r.p.setSign(sign); const one = Int.initFixed(([_]Limb{1})[0..]); @@ -463,193 +463,6 @@ pub const Rational = struct { } }; -const SignedDoubleLimb = std.meta.IntType(true, DoubleLimb.bit_count); - -fn gcd(rma: *Int, x: Int, y: Int) !void { - rma.assertWritable(); - var r = rma; - var aliased = rma.limbs.ptr == x.limbs.ptr or rma.limbs.ptr == y.limbs.ptr; - - var sr: Int = undefined; - if (aliased) { - sr = try Int.initCapacity(rma.allocator.?, math.max(x.len(), y.len())); - r = &sr; - aliased = true; - } - defer if (aliased) { - rma.swap(r); - r.deinit(); - }; - - try gcdLehmer(r, x, y); -} - -// Storage must live for the lifetime of the returned value -fn FixedIntFromSignedDoubleLimb(A: SignedDoubleLimb, storage: []Limb) Int { - std.debug.assert(storage.len >= 2); - - var A_is_positive = A >= 0; - const Au = @intCast(DoubleLimb, if (A < 0) -A else A); - storage[0] = @truncate(Limb, Au); - storage[1] = @truncate(Limb, Au >> Limb.bit_count); - var Ap = Int.initFixed(storage[0..2]); - Ap.setSign(A_is_positive); - return Ap; -} - -fn gcdLehmer(r: *Int, xa: Int, ya: Int) !void { - var x = try xa.clone(); - x.abs(); - defer x.deinit(); - - var y = try ya.clone(); - y.abs(); - defer y.deinit(); - - if (x.cmp(y) == .lt) { - x.swap(&y); - } - - var T = try Int.init(r.allocator.?); - defer T.deinit(); - - while (y.len() > 1) { - debug.assert(x.isPositive() and y.isPositive()); - debug.assert(x.len() >= y.len()); - - var xh: SignedDoubleLimb = x.limbs[x.len() - 1]; - var yh: SignedDoubleLimb = if (x.len() > y.len()) 0 else y.limbs[x.len() - 1]; - - var A: SignedDoubleLimb = 1; - var B: SignedDoubleLimb = 0; - var C: SignedDoubleLimb = 0; - var D: SignedDoubleLimb = 1; - - while (yh + C != 0 and yh + D != 0) { - const q = @divFloor(xh + A, yh + C); - const qp = @divFloor(xh + B, yh + D); - if (q != qp) { - break; - } - - var t = A - q * C; - A = C; - C = t; - t = B - q * D; - B = D; - D = t; - - t = xh - q * yh; - xh = yh; - yh = t; - } - - if (B == 0) { - // T = x % y, r is unused - try Int.divTrunc(r, &T, x, y); - debug.assert(T.isPositive()); - - x.swap(&y); - y.swap(&T); - } else { - var storage: [8]Limb = undefined; - const Ap = FixedIntFromSignedDoubleLimb(A, storage[0..2]); - const Bp = FixedIntFromSignedDoubleLimb(B, storage[2..4]); - const Cp = FixedIntFromSignedDoubleLimb(C, storage[4..6]); - const Dp = FixedIntFromSignedDoubleLimb(D, storage[6..8]); - - // T = Ax + By - try r.mul(x, Ap); - try T.mul(y, Bp); - try T.add(r.*, T); - - // u = Cx + Dy, r as u - try x.mul(x, Cp); - try r.mul(y, Dp); - try r.add(x, r.*); - - x.swap(&T); - y.swap(r); - } - } - - // euclidean algorithm - debug.assert(x.cmp(y) != .lt); - - while (!y.eqZero()) { - try Int.divTrunc(&T, r, x, y); - x.swap(&y); - y.swap(r); - } - - r.swap(&x); -} - -test "big.rational gcd non-one small" { - var a = try Int.initSet(testing.allocator, 17); - defer a.deinit(); - var b = try Int.initSet(testing.allocator, 97); - defer b.deinit(); - var r = try Int.init(testing.allocator); - defer r.deinit(); - - try gcd(&r, a, b); - - testing.expect((try r.to(u32)) == 1); -} - -test "big.rational gcd non-one small" { - var a = try Int.initSet(testing.allocator, 4864); - defer a.deinit(); - var b = try Int.initSet(testing.allocator, 3458); - defer b.deinit(); - var r = try Int.init(testing.allocator); - defer r.deinit(); - - try gcd(&r, a, b); - - testing.expect((try r.to(u32)) == 38); -} - -test "big.rational gcd non-one large" { - var a = try Int.initSet(testing.allocator, 0xffffffffffffffff); - defer a.deinit(); - var b = try Int.initSet(testing.allocator, 0xffffffffffffffff7777); - defer b.deinit(); - var r = try Int.init(testing.allocator); - defer r.deinit(); - - try gcd(&r, a, b); - - testing.expect((try r.to(u32)) == 4369); -} - -test "big.rational gcd large multi-limb result" { - var a = try Int.initSet(testing.allocator, 0x12345678123456781234567812345678123456781234567812345678); - defer a.deinit(); - var b = try Int.initSet(testing.allocator, 0x12345671234567123456712345671234567123456712345671234567); - defer b.deinit(); - var r = try Int.init(testing.allocator); - defer r.deinit(); - - try gcd(&r, a, b); - - testing.expect((try r.to(u256)) == 0xf000000ff00000fff0000ffff000fffff00ffffff1); -} - -test "big.rational gcd one large" { - var a = try Int.initSet(testing.allocator, 1897056385327307); - defer a.deinit(); - var b = try Int.initSet(testing.allocator, 2251799813685248); - defer b.deinit(); - var r = try Int.init(testing.allocator); - defer r.deinit(); - - try gcd(&r, a, b); - - testing.expect((try r.to(u64)) == 1); -} - fn extractLowBits(a: Int, comptime T: type) T { testing.expect(@typeInfo(T) == .Int); -- 2.54.0 From cc0fca9d83f5a62cf0e109dde3a323c01ea71301 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Tue, 7 Apr 2020 10:23:51 +0200 Subject: [PATCH 70/91] stage1: Respect the specified name for extern var Extend the logic used for function definitions to variables. Closes #4947 --- src/all_types.hpp | 2 +- src/analyze.cpp | 6 +++++- src/codegen.cpp | 27 +++++++++++++-------------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/all_types.hpp b/src/all_types.hpp index 56ce74caae983dc010ddeb814197d275c7123a69..db745275f7508a95b72efd7038e2634bf77674dd 100644 --- a/src/all_types.hpp +++ b/src/all_types.hpp @@ -2083,7 +2083,7 @@ struct CodeGen { HashMap memoized_fn_eval_table; HashMap llvm_fn_table; HashMap exported_symbol_names; - HashMap external_prototypes; + HashMap external_symbol_names; HashMap string_literals_table; HashMap type_info_cache; HashMap one_possible_values; diff --git a/src/analyze.cpp b/src/analyze.cpp index 14b9c25c07ef3ecae3fc74c38ece863ae9d77343..c3580e35ea4b38d45a16ac5fcf5e423cae0ebb75 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -3498,7 +3498,7 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) { } } else { fn_table_entry->inferred_async_node = inferred_async_none; - g->external_prototypes.put_unique(tld_fn->base.name, &tld_fn->base); + g->external_symbol_names.put_unique(tld_fn->base.name, &tld_fn->base); } Scope *child_scope = fn_table_entry->fndef_scope ? &fn_table_entry->fndef_scope->base : tld_fn->base.parent_scope; @@ -4048,6 +4048,10 @@ static void resolve_decl_var(CodeGen *g, TldVar *tld_var, bool allow_lazy) { add_var_export(g, tld_var->var, tld_var->var->name, GlobalLinkageIdStrong); } + if (is_extern) { + g->external_symbol_names.put_unique(tld_var->base.name, &tld_var->base); + } + g->global_vars.append(tld_var); } diff --git a/src/codegen.cpp b/src/codegen.cpp index 7de26e0b6d41d70581a8119b7057aad346f418bf..980a8a4aca3b74203a73dd59e2a4f7de8a1db0e8 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -204,15 +204,14 @@ static bool is_symbol_available(CodeGen *g, const char *name) { Buf *buf_name = buf_create_from_str(name); bool result = g->exported_symbol_names.maybe_get(buf_name) == nullptr && - g->external_prototypes.maybe_get(buf_name) == nullptr; + g->external_symbol_names.maybe_get(buf_name) == nullptr; buf_destroy(buf_name); return result; } -static const char *get_mangled_name(CodeGen *g, const char *original_name, bool external_linkage) { - if (external_linkage || is_symbol_available(g, original_name)) { +static const char *get_mangled_name(CodeGen *g, const char *original_name) { + if (is_symbol_available(g, original_name)) return original_name; - } int n = 0; for (;; n += 1) { @@ -437,7 +436,7 @@ static LLVMValueRef make_fn_llvm_value(CodeGen *g, ZigFn *fn) { symbol_name = unmangled_name; linkage = GlobalLinkageIdStrong; } else if (fn->export_list.length == 0) { - symbol_name = get_mangled_name(g, unmangled_name, false); + symbol_name = get_mangled_name(g, unmangled_name); linkage = GlobalLinkageIdInternal; } else { GlobalExport *fn_export = &fn->export_list.items[0]; @@ -1115,7 +1114,7 @@ static LLVMValueRef get_add_error_return_trace_addr_fn(CodeGen *g) { }; LLVMTypeRef fn_type_ref = LLVMFunctionType(LLVMVoidType(), arg_types, 2, false); - const char *fn_name = get_mangled_name(g, "__zig_add_err_ret_trace_addr", false); + const char *fn_name = get_mangled_name(g, "__zig_add_err_ret_trace_addr"); LLVMValueRef fn_val = LLVMAddFunction(g->module, fn_name, fn_type_ref); addLLVMFnAttr(fn_val, "alwaysinline"); LLVMSetLinkage(fn_val, LLVMInternalLinkage); @@ -1194,7 +1193,7 @@ static LLVMValueRef get_return_err_fn(CodeGen *g) { }; LLVMTypeRef fn_type_ref = LLVMFunctionType(LLVMVoidType(), arg_types, 1, false); - const char *fn_name = get_mangled_name(g, "__zig_return_error", false); + const char *fn_name = get_mangled_name(g, "__zig_return_error"); LLVMValueRef fn_val = LLVMAddFunction(g->module, fn_name, fn_type_ref); addLLVMFnAttr(fn_val, "noinline"); // so that we can look at return address addLLVMFnAttr(fn_val, "cold"); @@ -1264,7 +1263,7 @@ static LLVMValueRef get_safety_crash_err_fn(CodeGen *g) { LLVMSetLinkage(msg_prefix, LLVMPrivateLinkage); LLVMSetGlobalConstant(msg_prefix, true); - const char *fn_name = get_mangled_name(g, "__zig_fail_unwrap", false); + const char *fn_name = get_mangled_name(g, "__zig_fail_unwrap"); LLVMTypeRef fn_type_ref; if (g->have_err_ret_tracing) { LLVMTypeRef arg_types[] = { @@ -2174,7 +2173,7 @@ static LLVMValueRef get_merge_err_ret_traces_fn_val(CodeGen *g) { }; LLVMTypeRef fn_type_ref = LLVMFunctionType(LLVMVoidType(), param_types, 2, false); - const char *fn_name = get_mangled_name(g, "__zig_merge_error_return_traces", false); + const char *fn_name = get_mangled_name(g, "__zig_merge_error_return_traces"); LLVMValueRef fn_val = LLVMAddFunction(g->module, fn_name, fn_type_ref); LLVMSetLinkage(fn_val, LLVMInternalLinkage); ZigLLVMFunctionSetCallingConv(fn_val, get_llvm_cc(g, CallingConventionUnspecified)); @@ -5099,7 +5098,7 @@ static LLVMValueRef get_enum_tag_name_function(CodeGen *g, ZigType *enum_type) { &tag_int_llvm_type, 1, false); const char *fn_name = get_mangled_name(g, - buf_ptr(buf_sprintf("__zig_tag_name_%s", buf_ptr(&enum_type->name))), false); + buf_ptr(buf_sprintf("__zig_tag_name_%s", buf_ptr(&enum_type->name)))); LLVMValueRef fn_val = LLVMAddFunction(g->module, fn_name, fn_type_ref); LLVMSetLinkage(fn_val, LLVMInternalLinkage); ZigLLVMFunctionSetCallingConv(fn_val, get_llvm_cc(g, CallingConventionUnspecified)); @@ -7588,7 +7587,7 @@ static void generate_error_name_table(CodeGen *g) { LLVMValueRef err_name_table_init = LLVMConstArray(get_llvm_type(g, str_type), values, (unsigned)g->errors_by_index.length); g->err_name_table = LLVMAddGlobal(g->module, LLVMTypeOf(err_name_table_init), - get_mangled_name(g, buf_ptr(buf_create_from_str("__zig_err_name_table")), false)); + get_mangled_name(g, buf_ptr(buf_create_from_str("__zig_err_name_table")))); LLVMSetInitializer(g->err_name_table, err_name_table_init); LLVMSetLinkage(g->err_name_table, LLVMPrivateLinkage); LLVMSetGlobalConstant(g->err_name_table, true); @@ -7719,7 +7718,7 @@ static void do_code_gen(CodeGen *g) { symbol_name = unmangled_name; linkage = GlobalLinkageIdStrong; } else { - symbol_name = get_mangled_name(g, unmangled_name, false); + symbol_name = get_mangled_name(g, unmangled_name); linkage = GlobalLinkageIdInternal; } } else { @@ -10954,7 +10953,7 @@ CodeGen *codegen_create(Buf *main_pkg_path, Buf *root_src_path, const ZigTarget g->llvm_fn_table.init(16); g->memoized_fn_eval_table.init(16); g->exported_symbol_names.init(8); - g->external_prototypes.init(8); + g->external_symbol_names.init(8); g->string_literals_table.init(16); g->type_info_cache.init(32); g->one_possible_values.init(32); @@ -10964,7 +10963,7 @@ CodeGen *codegen_create(Buf *main_pkg_path, Buf *root_src_path, const ZigTarget buf_resize(&g->global_asm, 0); for (size_t i = 0; i < array_length(symbols_that_llvm_depends_on); i += 1) { - g->external_prototypes.put(buf_create_from_str(symbols_that_llvm_depends_on[i]), nullptr); + g->external_symbol_names.put(buf_create_from_str(symbols_that_llvm_depends_on[i]), nullptr); } if (root_src_path) { -- 2.54.0 From b7f116a774ce64b39ddf9798e135aee76d03f44e Mon Sep 17 00:00:00 2001 From: xackus <14938807+xackus@users.noreply.github.com> Date: Tue, 24 Mar 2020 00:00:52 +0100 Subject: [PATCH 71/91] langref: small updates --- doc/langref.html.in | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/doc/langref.html.in b/doc/langref.html.in index 3d38d67e005fd96b0f2608b5c8462ff68247bc1e..46228d43af77e7bd205661cfc6a434b6fbdbf48e 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -247,8 +247,7 @@ pub fn main() void { } {#code_end#}

- Note that we also left off the {#syntax#}!{#endsyntax#} from the return type. - In Zig, if your main function cannot fail, you must use the {#syntax#}void{#endsyntax#} return type. + Note that you can leave off the {#syntax#}!{#endsyntax#} from the return type because {#syntax#}warn{#endsyntax#} cannot fail.

{#see_also|Values|@import|Errors|Root Source File#} {#header_close#} @@ -985,7 +984,7 @@ export fn foo_strict(x: f64) f64 { } export fn foo_optimized(x: f64) f64 { - @setFloatMode(builtin.FloatMode.Optimized); + @setFloatMode(.Optimized); return x + big - big; } {#code_end#} @@ -2992,7 +2991,7 @@ test "simple union" { This turns the union into a tagged union, which makes it eligible to use with {#link|switch#} expressions. One can use {#link|@TagType#} to obtain the enum type from the union type. - Tagged unions coerce to their enum {#link|Type Coercion: unions and enums#} + Tagged unions coerce to their tag type: {#link|Type Coercion: unions and enums#}.

{#code_begin|test#} const std = @import("std"); @@ -9479,7 +9478,7 @@ pub fn main() void { const builtin = @import("builtin"); const c = @cImport({ - @cDefine("NDEBUG", builtin.mode == builtin.Mode.ReleaseFast); + @cDefine("NDEBUG", builtin.mode == .ReleaseFast); if (something) { @cDefine("_GNU_SOURCE", {}); } @@ -10077,7 +10076,6 @@ fn readU32Be() u32 {} {#header_open|Keyword: pub#}

The {#syntax#}pub{#endsyntax#} in front of a top level declaration makes the declaration available to reference from a different file than the one it is declared in.

-

TODO delete pub syntax for fields, or make it do something.

{#see_also|@import#} {#header_close#} {#header_close#} -- 2.54.0 From 4d290758bb3145f65840ad0ac244fc4388bde9e0 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 7 Apr 2020 15:06:58 -0400 Subject: [PATCH 72/91] fix compile errors in some std.Target functions The `ve` architecture needed to be added to a couple switch statements. --- lib/std/target.zig | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/std/target.zig b/lib/std/target.zig index f920845d0def308a5910fceec364a3de4de9083d..8388fda72a1e1be18459744e9c172caaa6bc2239 100644 --- a/lib/std/target.zig +++ b/lib/std/target.zig @@ -698,6 +698,7 @@ pub const Target = struct { .bpfeb => ._BPF, .sparcv9 => ._SPARCV9, .s390x => ._S390, + .ve => ._NONE, }; } @@ -739,6 +740,7 @@ pub const Target = struct { .renderscript32, .renderscript64, .shave, + .ve, => .Little, .arc, @@ -1317,3 +1319,7 @@ pub const Target = struct { } } }; + +test "" { + std.meta.refAllDecls(Target.Cpu.Arch); +} -- 2.54.0 From ed23dad4877cd93fd684852b17e0e554ef71e297 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 7 Apr 2020 16:05:42 -0400 Subject: [PATCH 73/91] fix the new runtime-safety tests Thanks to Vexu's work in e62671f643, compile errors were identified in these test cases! This commit fixes them to use `const` as appropriate. --- test/runtime_safety.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/runtime_safety.zig b/test/runtime_safety.zig index 6bbc7dc19df4aa0f02a266b728a8dffb98ea3aea..a2eed71b452b70a47769d22094f0de0984d69d7d 100644 --- a/test/runtime_safety.zig +++ b/test/runtime_safety.zig @@ -56,7 +56,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\const std = @import("std"); ++ check_panic_msg ++ \\pub fn main() void { - \\ var buf_slice: []u8 = &[3]u8{ 'a', 'b', 0 }; + \\ var buf_slice: []const u8 = &[3]u8{ 'a', 'b', 0 }; \\ const slice = buf_slice[0..3 :0]; \\} ); @@ -64,7 +64,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\const std = @import("std"); ++ check_panic_msg ++ \\pub fn main() void { - \\ var buf_slice: []u8 = &[3]u8{ 'a', 'b', 0 }; + \\ var buf_slice: []const u8 = &[3]u8{ 'a', 'b', 0 }; \\ const slice = buf_slice[0.. :0]; \\} ); -- 2.54.0 From ff0f97a1bcab4d27212c67b0ebc6233adf2f0de9 Mon Sep 17 00:00:00 2001 From: Vexu Date: Tue, 7 Apr 2020 23:34:30 +0300 Subject: [PATCH 74/91] fix missing compile error on assign to slice and array parameters --- build.zig | 5 +++-- src/ir.cpp | 19 ++++++++++++++++++- test/compile_errors.zig | 36 ++++++++++++++++++++++++++++++++++++ test/tests.zig | 2 +- 4 files changed, 58 insertions(+), 4 deletions(-) diff --git a/build.zig b/build.zig index ba37c1aa4278bec51bc35d12687fd24d9e58b668..f6f929c72732a9aef1d4f7e1d1d0cfa07edfc303 100644 --- a/build.zig +++ b/build.zig @@ -225,10 +225,11 @@ fn findLLVM(b: *Builder, llvm_config_exe: []const u8) !LibraryDep { if (fs.path.isAbsolute(lib_arg)) { try result.libs.append(lib_arg); } else { + var lib_arg_copy = lib_arg; if (mem.endsWith(u8, lib_arg, ".lib")) { - lib_arg = lib_arg[0 .. lib_arg.len - 4]; + lib_arg_copy = lib_arg[0 .. lib_arg.len - 4]; } - try result.system_libs.append(lib_arg); + try result.system_libs.append(lib_arg_copy); } } } diff --git a/src/ir.cpp b/src/ir.cpp index b57011717761477c6c994fbac3e43f030c42b6a9..7dbf365355118e25e42a44f2acadaa80e972bfc1 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -27175,6 +27175,16 @@ done_with_return_type: if (type_is_invalid(result_loc->value->type) || result_loc->value->type->id == ZigTypeIdUnreachable) { return result_loc; } + + if (result_loc->value->type->id == ZigTypeIdPointer && + result_loc->value->type->data.pointer.is_const && + instruction->result_loc->id == ResultLocIdInstruction && + !instruction->result_loc->allow_write_through_const) + { + ir_add_error(ira, &instruction->base.base, buf_sprintf("cannot assign to constant")); + return ira->codegen->invalid_inst_gen; + } + IrInstGen *dummy_value = ir_const(ira, &instruction->base.base, return_type); dummy_value->value->special = ConstValSpecialRuntime; IrInstGen *dummy_result = ir_implicit_cast2(ira, &instruction->base.base, @@ -29908,8 +29918,15 @@ static IrInstGen *ir_analyze_instruction_end_expr(IrAnalyze *ira, IrInstSrcEndEx return result_loc; if (!was_written || instruction->result_loc->id == ResultLocIdPeer) { + bool can_write_to_const_ptr = true; + if (result_loc->value->type->id == ZigTypeIdPointer && + result_loc->value->type->data.pointer.is_const && + instruction->result_loc->id == ResultLocIdInstruction) + { + can_write_to_const_ptr = false; + } IrInstGen *store_ptr = ir_analyze_store_ptr(ira, &instruction->base.base, result_loc, value, - instruction->result_loc->allow_write_through_const); + instruction->result_loc->allow_write_through_const && can_write_to_const_ptr); if (type_is_invalid(store_ptr->value->type)) { return ira->codegen->invalid_inst_gen; } diff --git a/test/compile_errors.zig b/test/compile_errors.zig index 1d8f5e17f98e40c08ac09a521fe31d866480fc66..c966f8771df529f831d10682cb0f2f54b2a0bd93 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -2,6 +2,42 @@ const tests = @import("tests.zig"); const std = @import("std"); pub fn addCases(cases: *tests.CompileErrorContext) void { + cases.addTest("reassign to array parameter", + \\fn reassign(a: [3]f32) void { + \\ a = [3]f32{4, 5, 6}; + \\} + \\export fn entry() void { + \\ reassign(.{1, 2, 3}); + \\} + , &[_][]const u8{ + "tmp.zig:2:16: error: cannot assign to constant" + }); + + cases.addTest("reassign to slice parameter", + \\pub fn reassign(s: []const u8) void { + \\ s = s[0..]; + \\} + \\export fn entry() void { + \\ reassign("foo"); + \\} + , &[_][]const u8{ + "tmp.zig:2:10: error: cannot assign to constant" + }); + + cases.addTest("reassign to struct parameter", + \\const S = struct { + \\ x: u32, + \\}; + \\fn reassign(s: S) void { + \\ s = S{.x = 2}; + \\} + \\export fn entry() void { + \\ reassign(S{.x = 3}); + \\} + , &[_][]const u8{ + "tmp.zig:5:16: error: cannot assign to constant" + }); + cases.addTest("reference to const data", \\export fn foo() void { \\ var ptr = &[_]u8{0,0,0,0}; diff --git a/test/tests.zig b/test/tests.zig index d88c84502dc39753471108b9bd8a5f51d1e72e8a..59a0af195e1347c5b4c28a542936f17059d0ac7e 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -612,7 +612,7 @@ pub const StackTracesContext = struct { const stdout = child.stdout.?.inStream().readAllAlloc(b.allocator, max_stdout_size) catch unreachable; defer b.allocator.free(stdout); - const stderr = child.stderr.?.inStream().readAllAlloc(b.allocator, max_stdout_size) catch unreachable; + var stderr = child.stderr.?.inStream().readAllAlloc(b.allocator, max_stdout_size) catch unreachable; defer b.allocator.free(stderr); const term = child.wait() catch |err| { -- 2.54.0 From 66b2477ab668447c6cbff68770de14ec8db991be Mon Sep 17 00:00:00 2001 From: xackus <14938807+xackus@users.noreply.github.com> Date: Mon, 6 Apr 2020 09:44:06 +0200 Subject: [PATCH 75/91] fix lazy value in ir_analyze_instruction_elem_ptr --- src/ir.cpp | 6 +++++- test/stage1/behavior.zig | 1 + test/stage1/behavior/bugs/4954.zig | 8 ++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 test/stage1/behavior/bugs/4954.zig diff --git a/src/ir.cpp b/src/ir.cpp index b57011717761477c6c994fbac3e43f030c42b6a9..bcadc892432f43bec7afd122a5f8f9a74deed4f9 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -21149,7 +21149,11 @@ static IrInstGen *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstSrcElemP bool safety_check_on = elem_ptr_instruction->safety_check_on; if (instr_is_comptime(casted_elem_index)) { - uint64_t index = bigint_as_u64(&casted_elem_index->value->data.x_bigint); + ZigValue *index_val = ir_resolve_const(ira, casted_elem_index, UndefBad); + if (index_val == nullptr) + return ira->codegen->invalid_inst_gen; + uint64_t index = bigint_as_u64(&index_val->data.x_bigint); + if (array_type->id == ZigTypeIdArray) { uint64_t array_len = array_type->data.array.len + (array_type->data.array.sentinel != nullptr); diff --git a/test/stage1/behavior.zig b/test/stage1/behavior.zig index 52ce5979e11a6d7e9ff3bc20c2ef9ae810bf9793..61b0c1aa56c643c09077c14c411fbd2aefa7027c 100644 --- a/test/stage1/behavior.zig +++ b/test/stage1/behavior.zig @@ -44,6 +44,7 @@ comptime { _ = @import("behavior/bugs/4769_a.zig"); _ = @import("behavior/bugs/4769_b.zig"); _ = @import("behavior/bugs/4769_c.zig"); + _ = @import("behavior/bugs/4954.zig"); _ = @import("behavior/bugs/394.zig"); _ = @import("behavior/bugs/421.zig"); _ = @import("behavior/bugs/529.zig"); diff --git a/test/stage1/behavior/bugs/4954.zig b/test/stage1/behavior/bugs/4954.zig new file mode 100644 index 0000000000000000000000000000000000000000..b5a9bdf8517abacce8cdf2987f801771c9385016 --- /dev/null +++ b/test/stage1/behavior/bugs/4954.zig @@ -0,0 +1,8 @@ +fn f(buf: []u8) void { + var ptr = &buf[@sizeOf(u32)]; +} + +test "crash" { + var buf: [4096]u8 = undefined; + f(&buf); +} -- 2.54.0 From b109186dd5e11e3da2f0f49de370e2b8447e92a0 Mon Sep 17 00:00:00 2001 From: Phil Schumann Date: Wed, 8 Apr 2020 02:27:18 +0200 Subject: [PATCH 76/91] std/zig/parse_string_literal.zig: add hex+unicode escapes (#4678) --- lib/std/zig/parse_string_literal.zig | 63 ++++++++++++++++++++++++---- 1 file changed, 56 insertions(+), 7 deletions(-) diff --git a/lib/std/zig/parse_string_literal.zig b/lib/std/zig/parse_string_literal.zig index a6bdff4a023db6915ffea1d6c84b0e1ac526e152..949940f550a65fa055141698fccfca81e58afef7 100644 --- a/lib/std/zig/parse_string_literal.zig +++ b/lib/std/zig/parse_string_literal.zig @@ -19,17 +19,19 @@ pub fn parseStringLiteral( bytes: []const u8, bad_index: *usize, // populated if error.InvalidCharacter is returned ) ParseStringLiteralError![]u8 { - const first_index = if (bytes[0] == 'c') @as(usize, 2) else @as(usize, 1); - assert(bytes[bytes.len - 1] == '"'); + assert(bytes.len >= 2 and bytes[0] == '"' and bytes[bytes.len - 1] == '"'); var list = std.ArrayList(u8).init(allocator); errdefer list.deinit(); - const slice = bytes[first_index..]; + const slice = bytes[1..]; try list.ensureCapacity(slice.len - 1); var state = State.Start; - for (slice) |b, index| { + var index: usize = 0; + while (index < slice.len) : (index += 1) { + const b = slice[index]; + switch (state) { State.Start => switch (b) { '\\' => state = State.Backslash, @@ -41,9 +43,6 @@ pub fn parseStringLiteral( else => try list.append(b), }, State.Backslash => switch (b) { - 'x' => @panic("TODO"), - 'u' => @panic("TODO"), - 'U' => @panic("TODO"), 'n' => { try list.append('\n'); state = State.Start; @@ -60,10 +59,46 @@ pub fn parseStringLiteral( try list.append('\t'); state = State.Start; }, + '\'' => { + try list.append('\''); + state = State.Start; + }, '"' => { try list.append('"'); state = State.Start; }, + 'x' => { + // TODO: add more/better/broader tests for this. + const index_continue = index + 3; + if (slice.len >= index_continue) + if (std.fmt.parseUnsigned(u8, slice[index + 1 .. index_continue], 16)) |char| { + try list.append(char); + state = State.Start; + index = index_continue - 1; // loop-header increments again + continue; + } else |_| {}; + + bad_index.* = index; + return error.InvalidCharacter; + }, + 'u' => { + // TODO: add more/better/broader tests for this. + if (slice.len > index + 2 and slice[index + 1] == '{') + if (std.mem.indexOfScalarPos(u8, slice[0..std.math.min(index + 9, slice.len)], index + 3, '}')) |index_end| { + const hex_str = slice[index + 2 .. index_end]; + if (std.fmt.parseUnsigned(u32, hex_str, 16)) |uint| { + if (uint <= 0x10ffff) { + try list.appendSlice(std.mem.toBytes(uint)[0..]); + state = State.Start; + index = index_end; // loop-header increments + continue; + } + } else |_| {} + }; + + bad_index.* = index; + return error.InvalidCharacter; + }, else => { bad_index.* = index; return error.InvalidCharacter; @@ -74,3 +109,17 @@ pub fn parseStringLiteral( } unreachable; } + +test "parseStringLiteral" { + const expect = std.testing.expect; + const eql = std.mem.eql; + + var fixed_buf_mem: [32]u8 = undefined; + var fixed_buf_alloc = std.heap.FixedBufferAllocator.init(fixed_buf_mem[0..]); + var alloc = &fixed_buf_alloc.allocator; + var bad_index: usize = undefined; + + expect(eql(u8, "foo", try parseStringLiteral(alloc, "\"foo\"", &bad_index))); + expect(eql(u8, "foo", try parseStringLiteral(alloc, "\"f\x6f\x6f\"", &bad_index))); + expect(eql(u8, "f💯", try parseStringLiteral(alloc, "\"f\u{1f4af}\"", &bad_index))); +} -- 2.54.0 From b3aef49eeaa42127ac57ded3b15228db39f806b3 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 8 Apr 2020 01:21:00 -0400 Subject: [PATCH 77/91] zig provides shlwapi.lib for *-windows-gnu closes #3711 --- lib/libc/mingw/lib-common/shlwapi.def | 386 ++++++++++++++++++++++++++ lib/libc/mingw/lib32/shlwapi.def | 376 +++++++++++++++++++++++++ src/link.cpp | 1 + 3 files changed, 763 insertions(+) create mode 100644 lib/libc/mingw/lib-common/shlwapi.def create mode 100644 lib/libc/mingw/lib32/shlwapi.def diff --git a/lib/libc/mingw/lib-common/shlwapi.def b/lib/libc/mingw/lib-common/shlwapi.def new file mode 100644 index 0000000000000000000000000000000000000000..850fa7f9207f11d8b250641f9580307676a06df6 --- /dev/null +++ b/lib/libc/mingw/lib-common/shlwapi.def @@ -0,0 +1,386 @@ +; +; Definition file of SHLWAPI.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "SHLWAPI.dll" +EXPORTS +ParseURLA +ParseURLW +SHAllocShared +SHLockShared +SHUnlockShared +SHFreeShared +SHCreateMemStream +GetAcceptLanguagesA +GetAcceptLanguagesW +SHCreateThread +IsCharSpaceW +StrCmpNCA +StrCmpNCW +StrCmpNICA +StrCmpNICW +StrCmpCA +StrCmpCW +StrCmpICA +StrCmpICW +IUnknown_QueryStatus +IUnknown_Exec +ConnectToConnectionPoint +IUnknown_AtomicRelease +IUnknown_GetWindow +IUnknown_SetSite +IUnknown_QueryService +IStream_Read +SHMessageBoxCheckA +SHMessageBoxCheckW +IUnknown_Set +SHStripMneumonicA +SHIsChildOrSelf +IStream_Write +IStream_Reset +IStream_Size +SHAnsiToUnicode +SHUnicodeToAnsi +SHUnicodeToAnsiCP +QISearch +SHStripMneumonicW +SHPinDllOfCLSID +IUnknown_GetSite +GUIDFromStringW +WhichPlatform +SHCreateWorkerWindowW +SHRegGetIntW +SHPackDispParamsV +SHAnsiToAnsi +SHUnicodeToUnicode +SHFormatDateTimeA +SHFormatDateTimeW +MLLoadLibraryA +MLLoadLibraryW +ShellMessageBoxW +MLFreeLibrary +SHSendMessageBroadcastA +SHSendMessageBroadcastW +IsOS +PathFileExistsAndAttributesW +UrlFixupW +SHRunIndirectRegClientCommand +SHLoadIndirectString +IStream_ReadPidl +IStream_WritePidl +SHGetViewStatePropertyBag +IsInternetESCEnabled +SHPropertyBag_ReadStrAlloc +IStream_Copy +DelayLoadFailureHook +SHPropertyBag_WriteBSTR +AssocCreate +AssocGetPerceivedType +AssocIsDangerous +AssocQueryKeyA +AssocQueryKeyW +AssocQueryStringA +AssocQueryStringByKeyA +AssocQueryStringByKeyW +AssocQueryStringW +ChrCmpIA +ChrCmpIW +ColorAdjustLuma +ColorHLSToRGB +IStream_ReadStr +IStream_WriteStr +ColorRGBToHLS +DllGetVersion +GetMenuPosFromID +HashData +SHCreateThreadWithHandle +IntlStrEqWorkerA +IntlStrEqWorkerW +IsCharSpaceA +PathAddBackslashA +PathAddBackslashW +SHRegGetValueFromHKCUHKLM +SHRegGetBoolValueFromHKCUHKLM +PathAddExtensionA +PathAddExtensionW +PathAppendA +PathAppendW +PathBuildRootA +PathBuildRootW +PathCanonicalizeA +PathCanonicalizeW +PathCombineA +PathCombineW +PathCommonPrefixA +PathCommonPrefixW +PathCompactPathA +PathCompactPathExA +PathCompactPathExW +PathCompactPathW +PathCreateFromUrlA +PathCreateFromUrlAlloc +PathCreateFromUrlW +PathFileExistsA +PathFileExistsW +PathFindExtensionA +PathFindExtensionW +PathFindFileNameA +PathFindFileNameW +PathFindNextComponentA +PathFindNextComponentW +PathFindOnPathA +PathFindOnPathW +PathFindSuffixArrayA +PathFindSuffixArrayW +PathGetArgsA +PathGetArgsW +PathGetCharTypeA +PathGetCharTypeW +PathGetDriveNumberA +PathGetDriveNumberW +PathIsContentTypeA +PathIsContentTypeW +PathIsDirectoryA +PathIsDirectoryEmptyA +PathIsDirectoryEmptyW +PathIsDirectoryW +PathIsFileSpecA +PathIsFileSpecW +PathIsLFNFileSpecA +PathIsLFNFileSpecW +PathIsNetworkPathA +PathIsNetworkPathW +PathIsPrefixA +PathIsPrefixW +PathIsRelativeA +PathIsRelativeW +PathIsRootA +PathIsRootW +PathIsSameRootA +PathIsSameRootW +PathIsSystemFolderA +PathIsSystemFolderW +PathIsUNCA +PathIsUNCServerA +PathIsUNCServerShareA +PathIsUNCServerShareW +PathIsUNCServerW +PathIsUNCW +PathIsURLA +PathIsURLW +PathMakePrettyA +PathMakePrettyW +PathMakeSystemFolderA +PathMakeSystemFolderW +PathMatchSpecA +PathMatchSpecExA +PathMatchSpecExW +PathMatchSpecW +PathParseIconLocationA +PathParseIconLocationW +PathQuoteSpacesA +PathQuoteSpacesW +PathRelativePathToA +PathRelativePathToW +PathRemoveArgsA +PathRemoveArgsW +PathRemoveBackslashA +PathRemoveBackslashW +PathRemoveBlanksA +PathRemoveBlanksW +PathRemoveExtensionA +PathRemoveExtensionW +PathRemoveFileSpecA +PathRemoveFileSpecW +PathRenameExtensionA +PathRenameExtensionW +PathSearchAndQualifyA +PathSearchAndQualifyW +PathSetDlgItemPathA +PathSetDlgItemPathW +PathSkipRootA +PathSkipRootW +PathStripPathA +PathStripPathW +PathStripToRootA +PathStripToRootW +PathUnExpandEnvStringsA +PathUnExpandEnvStringsW +PathUndecorateA +PathUndecorateW +PathUnmakeSystemFolderA +PathUnmakeSystemFolderW +PathUnquoteSpacesA +PathUnquoteSpacesW +SHAutoComplete +SHCopyKeyA +SHCopyKeyW +SHCreateShellPalette +SHCreateStreamOnFileA +SHCreateStreamOnFileEx +SHCreateStreamOnFileW +SHCreateStreamWrapper +SHCreateThreadRef +SHDeleteEmptyKeyA +SHDeleteEmptyKeyW +SHDeleteKeyA +SHDeleteKeyW +SHDeleteOrphanKeyA +SHDeleteOrphanKeyW +SHDeleteValueA +SHDeleteValueW +SHEnumKeyExA +SHEnumKeyExW +SHEnumValueA +SHEnumValueW +SHGetInverseCMAP +SHGetThreadRef +SHGetValueA +SHGetValueW +SHIsLowMemoryMachine +SHOpenRegStream2A +SHOpenRegStream2W +SHOpenRegStreamA +SHOpenRegStreamW +SHQueryInfoKeyA +SHQueryInfoKeyW +SHQueryValueExA +SHQueryValueExW +SHRegCloseUSKey +SHRegCreateUSKeyA +SHRegCreateUSKeyW +SHRegDeleteEmptyUSKeyA +SHRegDeleteEmptyUSKeyW +SHRegDeleteUSValueA +SHRegDeleteUSValueW +SHRegDuplicateHKey +SHRegEnumUSKeyA +SHRegEnumUSKeyW +SHRegEnumUSValueA +SHRegEnumUSValueW +SHRegGetBoolUSValueA +SHRegGetBoolUSValueW +SHRegGetPathA +SHRegGetPathW +SHRegGetUSValueA +SHRegGetUSValueW +SHRegGetValueA +SHRegGetValueW +SHRegOpenUSKeyA +SHRegOpenUSKeyW +SHRegQueryInfoUSKeyA +SHRegQueryInfoUSKeyW +SHRegQueryUSValueA +SHRegQueryUSValueW +SHRegSetPathA +SHRegSetPathW +SHRegSetUSValueA +SHRegSetUSValueW +SHRegWriteUSValueA +SHRegWriteUSValueW +SHRegisterValidateTemplate +SHReleaseThreadRef +SHSetThreadRef +SHSetValueA +SHSetValueW +SHSkipJunction +SHStrDupA +SHStrDupW +ShellMessageBoxA +StrCSpnA +StrCSpnIA +StrCSpnIW +StrCSpnW +StrCatBuffA +StrCatBuffW +StrCatChainW +StrCatW +StrChrA +StrChrIA +StrChrIW +StrChrNIW +StrChrNW +StrChrW +StrCmpIW +StrCmpLogicalW +StrCmpNA +StrCmpNIA +StrCmpNIW +StrCmpNW +StrCmpW +StrCpyNW +StrCpyW +StrDupA +StrDupW +StrFormatByteSize64A +StrFormatByteSizeA +StrFormatByteSizeEx +StrFormatByteSizeW +StrFormatKBSizeA +StrFormatKBSizeW +StrFromTimeIntervalA +StrFromTimeIntervalW +StrIsIntlEqualA +StrIsIntlEqualW +StrNCatA +StrNCatW +StrPBrkA +StrPBrkW +StrRChrA +StrRChrIA +StrRChrIW +StrRChrW +StrRStrIA +StrRStrIW +StrRetToBSTR +StrRetToBufA +StrRetToBufW +StrRetToStrA +StrRetToStrW +StrSpnA +StrSpnW +StrStrA +StrStrIA +StrStrIW +StrStrNIW +StrStrNW +StrStrW +StrToInt64ExA +StrToInt64ExW +StrToIntA +StrToIntExA +StrToIntExW +StrToIntW +StrTrimA +StrTrimW +UrlApplySchemeA +UrlApplySchemeW +UrlCanonicalizeA +UrlCanonicalizeW +UrlCombineA +UrlCombineW +UrlCompareA +UrlCompareW +UrlCreateFromPathA +UrlCreateFromPathW +UrlEscapeA +UrlEscapeW +UrlGetLocationA +UrlGetLocationW +UrlGetPartA +UrlGetPartW +UrlHashA +UrlHashW +UrlIsA +UrlIsNoHistoryA +UrlIsNoHistoryW +UrlIsOpaqueA +UrlIsOpaqueW +UrlIsW +UrlUnescapeA +UrlUnescapeW +wnsprintfA +wnsprintfW +wvnsprintfA +wvnsprintfW diff --git a/lib/libc/mingw/lib32/shlwapi.def b/lib/libc/mingw/lib32/shlwapi.def new file mode 100644 index 0000000000000000000000000000000000000000..4978994c5d69ef59159664491cc3ec26a3ad70bd --- /dev/null +++ b/lib/libc/mingw/lib32/shlwapi.def @@ -0,0 +1,376 @@ +; +; Definition file of SHLWAPI.dll +; Automatic generated by gendef +; written by Kai Tietz 2008 +; +LIBRARY "SHLWAPI.dll" +EXPORTS +ParseURLA@8 +ParseURLW@8 +SHAllocShared@12 +SHLockShared@8 +SHUnlockShared@4 +SHFreeShared@8 +SHCreateMemStream@8 +GetAcceptLanguagesA@8 +GetAcceptLanguagesW@8 +SHCreateThread@16 +IsCharSpaceW@4 +StrCmpNCA@12 +StrCmpNCW@12 +StrCmpNICA@12 +StrCmpNICW@12 +StrCmpCA@8 +StrCmpCW@8 +StrCmpICA@8 +StrCmpICW@8 +ConnectToConnectionPoint@24 +IUnknown_AtomicRelease@4 +IUnknown_GetWindow@8 +IUnknown_SetSite@8 +IUnknown_QueryService@16 +IStream_Read@12 +SHMessageBoxCheckA@24 +SHMessageBoxCheckW@24 +IUnknown_Set@8 +SHStripMneumonicA@4 +SHIsChildOrSelf@8 +IStream_Write@12 +IStream_Reset@4 +IStream_Size@8 +SHAnsiToUnicode@12 +SHUnicodeToAnsi@12 +QISearch@16 +SHStripMneumonicW@4 +IUnknown_GetSite@12 +WhichPlatform@0 +SHRegGetIntW@12 +SHAnsiToAnsi@12 +SHUnicodeToUnicode@12 +SHFormatDateTimeA@16 +SHFormatDateTimeW@16 +MLLoadLibraryA@12 +MLLoadLibraryW@12 +ShellMessageBoxW@0 +MLFreeLibrary@0 +SHSendMessageBroadcastA@12 +SHSendMessageBroadcastW@12 +IsOS@4 +UrlFixupW@12 +SHRunIndirectRegClientCommand@8 +SHLoadIndirectString@16 +AssocCreate@24 +AssocGetPerceivedType@16 +AssocIsDangerous@4 +AssocQueryKeyA@20 +AssocQueryKeyW@20 +IStream_ReadPidl@8 +IStream_WritePidl@8 +SHGetViewStatePropertyBag@20 +IsInternetESCEnabled@0 +SHPropertyBag_ReadStrAlloc@12 +IStream_Copy@12 +DelayLoadFailureHook@8 +SHPropertyBag_WriteBSTR@12 +AssocQueryStringA@24 +AssocQueryStringByKeyA@24 +AssocQueryStringByKeyW@24 +AssocQueryStringW@24 +ChrCmpIA@8 +ChrCmpIW@8 +ColorAdjustLuma@12 +ColorHLSToRGB@12 +ColorRGBToHLS@16 +DllGetVersion@4 +GetMenuPosFromID@8 +HashData@16 +IntlStrEqWorkerA@16 +IStream_ReadStr@8 +IStream_WriteStr@8 +IntlStrEqWorkerW@16 +IsCharSpaceA@4 +PathAddBackslashA@4 +PathAddBackslashW@4 +PathAddExtensionA@8 +SHCreateThreadWithHandle@20 +PathAddExtensionW@8 +PathAppendA@8 +PathAppendW@8 +PathBuildRootA@8 +PathBuildRootW@8 +PathCanonicalizeA@8 +PathCanonicalizeW@8 +PathCombineA@12 +PathCombineW@12 +PathCommonPrefixA@12 +PathCommonPrefixW@12 +PathCompactPathA@12 +PathCompactPathExA@16 +PathCompactPathExW@16 +PathCompactPathW@12 +PathCreateFromUrlA@16 +PathCreateFromUrlAlloc@12 +PathCreateFromUrlW@16 +PathFileExistsA@4 +PathFileExistsW@4 +PathFindExtensionA@4 +PathFindExtensionW@4 +PathFindFileNameA@4 +PathFindFileNameW@4 +PathFindNextComponentA@4 +PathFindNextComponentW@4 +PathFindOnPathA@8 +PathFindOnPathW@8 +PathFindSuffixArrayA@12 +PathFindSuffixArrayW@12 +PathGetArgsA@4 +PathGetArgsW@4 +PathGetCharTypeA@4 +PathGetCharTypeW@4 +PathGetDriveNumberA@4 +PathGetDriveNumberW@4 +PathIsContentTypeA@8 +PathIsContentTypeW@8 +PathIsDirectoryA@4 +PathIsDirectoryEmptyA@4 +PathIsDirectoryEmptyW@4 +PathIsDirectoryW@4 +PathIsFileSpecA@4 +PathIsFileSpecW@4 +PathIsLFNFileSpecA@4 +PathIsLFNFileSpecW@4 +PathIsNetworkPathA@4 +PathIsNetworkPathW@4 +PathIsPrefixA@8 +PathIsPrefixW@8 +PathIsRelativeA@4 +PathIsRelativeW@4 +PathIsRootA@4 +PathIsRootW@4 +PathIsSameRootA@8 +PathIsSameRootW@8 +PathIsSystemFolderA@8 +PathIsSystemFolderW@8 +PathIsUNCA@4 +PathIsUNCServerA@4 +PathIsUNCServerShareA@4 +PathIsUNCServerShareW@4 +PathIsUNCServerW@4 +PathIsUNCW@4 +PathIsURLA@4 +PathIsURLW@4 +PathMakePrettyA@4 +PathMakePrettyW@4 +PathMakeSystemFolderA@4 +PathMakeSystemFolderW@4 +PathMatchSpecA@8 +PathMatchSpecExA@12 +PathMatchSpecExW@12 +PathMatchSpecW@8 +PathParseIconLocationA@4 +PathParseIconLocationW@4 +PathQuoteSpacesA@4 +PathQuoteSpacesW@4 +PathRelativePathToA@20 +PathRelativePathToW@20 +PathRemoveArgsA@4 +PathRemoveArgsW@4 +PathRemoveBackslashA@4 +PathRemoveBackslashW@4 +PathRemoveBlanksA@4 +PathRemoveBlanksW@4 +PathRemoveExtensionA@4 +PathRemoveExtensionW@4 +PathRemoveFileSpecA@4 +PathRemoveFileSpecW@4 +PathRenameExtensionA@8 +PathRenameExtensionW@8 +PathSearchAndQualifyA@12 +PathSearchAndQualifyW@12 +PathSetDlgItemPathA@12 +PathSetDlgItemPathW@12 +PathSkipRootA@4 +PathSkipRootW@4 +PathStripPathA@4 +PathStripPathW@4 +PathStripToRootA@4 +PathStripToRootW@4 +PathUnExpandEnvStringsA@12 +PathUnExpandEnvStringsW@12 +PathUndecorateA@4 +PathUndecorateW@4 +PathUnmakeSystemFolderA@4 +PathUnmakeSystemFolderW@4 +PathUnquoteSpacesA@4 +PathUnquoteSpacesW@4 +SHAutoComplete@8 +SHCopyKeyA@16 +SHCopyKeyW@16 +SHCreateShellPalette@4 +SHCreateStreamOnFileA@12 +SHCreateStreamOnFileEx@24 +SHCreateStreamOnFileW@12 +SHCreateStreamWrapper@16 +SHCreateThreadRef@8 +SHDeleteEmptyKeyA@8 +SHDeleteEmptyKeyW@8 +SHDeleteKeyA@8 +SHDeleteKeyW@8 +SHDeleteOrphanKeyA@8 +SHDeleteOrphanKeyW@8 +SHDeleteValueA@12 +SHDeleteValueW@12 +SHEnumKeyExA@16 +SHEnumKeyExW@16 +SHEnumValueA@28 +SHEnumValueW@28 +SHGetInverseCMAP@8 +SHGetThreadRef@4 +SHGetValueA@24 +SHGetValueW@24 +SHIsLowMemoryMachine@4 +SHOpenRegStream2A@16 +SHOpenRegStream2W@16 +SHOpenRegStreamA@16 +SHOpenRegStreamW@16 +SHQueryInfoKeyA@20 +SHQueryInfoKeyW@20 +SHQueryValueExA@24 +SHQueryValueExW@24 +SHRegCloseUSKey@4 +SHRegCreateUSKeyA@20 +SHRegCreateUSKeyW@20 +SHRegDeleteEmptyUSKeyA@12 +SHRegDeleteEmptyUSKeyW@12 +SHRegDeleteUSValueA@12 +SHRegDeleteUSValueW@12 +SHRegDuplicateHKey@4 +SHRegEnumUSKeyA@20 +SHRegEnumUSKeyW@20 +SHRegEnumUSValueA@32 +SHRegEnumUSValueW@32 +SHRegGetBoolUSValueA@16 +SHRegGetBoolUSValueW@16 +SHRegGetPathA@20 +SHRegGetPathW@20 +SHRegGetUSValueA@32 +SHRegGetUSValueW@32 +SHRegGetValueA@28 +SHRegGetValueW@28 +SHRegOpenUSKeyA@20 +SHRegOpenUSKeyW@20 +SHRegQueryInfoUSKeyA@24 +SHRegQueryInfoUSKeyW@24 +SHRegQueryUSValueA@32 +SHRegQueryUSValueW@32 +SHRegSetPathA@20 +SHRegSetPathW@20 +SHRegSetUSValueA@24 +SHRegSetUSValueW@24 +SHRegWriteUSValueA@24 +SHRegWriteUSValueW@24 +SHRegisterValidateTemplate@8 +SHReleaseThreadRef@0 +SHSetThreadRef@4 +SHSetValueA@24 +SHSetValueW@24 +SHSkipJunction@8 +SHStrDupA@8 +SHStrDupW@8 +ShellMessageBoxA@0 +StrCSpnA@8 +StrCSpnIA@8 +StrCSpnIW@8 +StrCSpnW@8 +StrCatBuffA@12 +StrCatBuffW@12 +StrCatChainW@16 +StrCatW@8 +StrChrA@8 +StrChrIA@8 +StrChrIW@8 +StrChrNIW@12 +StrChrNW@12 +StrChrW@8 +StrCmpIW@8 +StrCmpLogicalW@8 +StrCmpNA@12 +StrCmpNIA@12 +StrCmpNIW@12 +StrCmpNW@12 +StrCmpW@8 +StrCpyNW@12 +StrCpyW@8 +StrDupA@4 +StrDupW@4 +StrFormatByteSize64A@16 +StrFormatByteSizeA@12 +StrFormatByteSizeEx@20 +StrFormatByteSizeW@16 +StrFormatKBSizeA@16 +StrFormatKBSizeW@16 +StrFromTimeIntervalA@16 +StrFromTimeIntervalW@16 +StrIsIntlEqualA@16 +StrIsIntlEqualW@16 +StrNCatA@12 +StrNCatW@12 +StrPBrkA@8 +StrPBrkW@8 +StrRChrA@12 +StrRChrIA@12 +StrRChrIW@12 +StrRChrW@12 +StrRStrIA@12 +StrRStrIW@12 +StrRetToBSTR@12 +StrRetToBufA@16 +StrRetToBufW@16 +StrRetToStrA@12 +StrRetToStrW@12 +StrSpnA@8 +StrSpnW@8 +StrStrA@8 +StrStrIA@8 +StrStrIW@8 +StrStrNIW@12 +StrStrNW@12 +StrStrW@8 +StrToInt64ExA@12 +StrToInt64ExW@12 +StrToIntA@4 +StrToIntExA@12 +StrToIntExW@12 +StrToIntW@4 +StrTrimA@8 +StrTrimW@8 +UrlApplySchemeA@16 +UrlApplySchemeW@16 +UrlCanonicalizeA@16 +UrlCanonicalizeW@16 +UrlCombineA@20 +UrlCombineW@20 +UrlCompareA@12 +UrlCompareW@12 +UrlCreateFromPathA@16 +UrlCreateFromPathW@16 +UrlEscapeA@16 +UrlEscapeW@16 +UrlGetLocationA@4 +UrlGetLocationW@4 +UrlGetPartA@20 +UrlGetPartW@20 +UrlHashA@12 +UrlHashW@12 +UrlIsA@8 +UrlIsNoHistoryA@4 +UrlIsNoHistoryW@4 +UrlIsOpaqueA@4 +UrlIsOpaqueW@4 +UrlIsW@8 +UrlUnescapeA@16 +UrlUnescapeW@16 +wnsprintfA +wnsprintfW +wvnsprintfA@16 +wvnsprintfW@16 diff --git a/src/link.cpp b/src/link.cpp index 0c02837630133e9f90f10ad1fd49126d25c6f47f..d4fc7ae228d0aeab0f395eb8e7cc42475b4918dc 100644 --- a/src/link.cpp +++ b/src/link.cpp @@ -593,6 +593,7 @@ static const MinGWDef mingw_def_list[] = { {"scarddlg",false}, {"setupapi",false}, {"shell32", true}, + {"shlwapi", false}, {"urlmon", false}, {"user32", true}, {"version", false}, -- 2.54.0 From b1e44adcba55e3839a3676db83ff61c344f3bbad Mon Sep 17 00:00:00 2001 From: Vexu Date: Wed, 8 Apr 2020 14:20:05 +0300 Subject: [PATCH 78/91] move array and struct const checks to more appropriate places --- src/ir.cpp | 27 +++++++++++++-------------- test/compile_errors.zig | 4 ++-- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/ir.cpp b/src/ir.cpp index 7dbf365355118e25e42a44f2acadaa80e972bfc1..02a6536d95a166a0124da5d28e5285b225b597fc 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -23552,10 +23552,14 @@ static IrInstGen *ir_analyze_instruction_container_init_list(IrAnalyze *ira, IrInstGen *result_loc = instruction->result_loc->child; if (type_is_invalid(result_loc->value->type)) return result_loc; + ir_assert(result_loc->value->type->id == ZigTypeIdPointer, &instruction->base.base); + if (result_loc->value->type->data.pointer.is_const) { + ir_add_error(ira, &instruction->base.base, buf_sprintf("cannot assign to constant")); + return ira->codegen->invalid_inst_gen; + } ZigType *container_type = result_loc->value->type->data.pointer.child_type; - size_t elem_count = instruction->item_count; if (is_slice(container_type)) { @@ -23706,6 +23710,11 @@ static IrInstGen *ir_analyze_instruction_container_init_fields(IrAnalyze *ira, return result_loc; ir_assert(result_loc->value->type->id == ZigTypeIdPointer, &instruction->base.base); + if (result_loc->value->type->data.pointer.is_const) { + ir_add_error(ira, &instruction->base.base, buf_sprintf("cannot assign to constant")); + return ira->codegen->invalid_inst_gen; + } + ZigType *container_type = result_loc->value->type->data.pointer.child_type; return ir_analyze_container_init_fields(ira, &instruction->base.base, container_type, @@ -27176,11 +27185,8 @@ done_with_return_type: return result_loc; } - if (result_loc->value->type->id == ZigTypeIdPointer && - result_loc->value->type->data.pointer.is_const && - instruction->result_loc->id == ResultLocIdInstruction && - !instruction->result_loc->allow_write_through_const) - { + ir_assert(result_loc->value->type->id == ZigTypeIdPointer, &instruction->base.base); + if (result_loc->value->type->data.pointer.is_const) { ir_add_error(ira, &instruction->base.base, buf_sprintf("cannot assign to constant")); return ira->codegen->invalid_inst_gen; } @@ -29918,15 +29924,8 @@ static IrInstGen *ir_analyze_instruction_end_expr(IrAnalyze *ira, IrInstSrcEndEx return result_loc; if (!was_written || instruction->result_loc->id == ResultLocIdPeer) { - bool can_write_to_const_ptr = true; - if (result_loc->value->type->id == ZigTypeIdPointer && - result_loc->value->type->data.pointer.is_const && - instruction->result_loc->id == ResultLocIdInstruction) - { - can_write_to_const_ptr = false; - } IrInstGen *store_ptr = ir_analyze_store_ptr(ira, &instruction->base.base, result_loc, value, - instruction->result_loc->allow_write_through_const && can_write_to_const_ptr); + instruction->result_loc->allow_write_through_const); if (type_is_invalid(store_ptr->value->type)) { return ira->codegen->invalid_inst_gen; } diff --git a/test/compile_errors.zig b/test/compile_errors.zig index c966f8771df529f831d10682cb0f2f54b2a0bd93..4a637fdc67c6f53a778b65c3496959b39cb4f16e 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -10,7 +10,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { \\ reassign(.{1, 2, 3}); \\} , &[_][]const u8{ - "tmp.zig:2:16: error: cannot assign to constant" + "tmp.zig:2:15: error: cannot assign to constant" }); cases.addTest("reassign to slice parameter", @@ -35,7 +35,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { \\ reassign(S{.x = 3}); \\} , &[_][]const u8{ - "tmp.zig:5:16: error: cannot assign to constant" + "tmp.zig:5:10: error: cannot assign to constant" }); cases.addTest("reference to const data", -- 2.54.0 From 7b5fb79b5b9625a1c2b7359c6653653a799ca114 Mon Sep 17 00:00:00 2001 From: Vexu Date: Sat, 7 Mar 2020 17:36:17 +0200 Subject: [PATCH 79/91] Translate C: Put an alignCast in c style pointer casts to allow opaque types to cast properly in C macros Translate C: add test case for aligning opaque types in pointer casts --- src-self-hosted/translate_c.zig | 31 ++++++++++++++++++++++++++----- test/translate_c.zig | 23 +++++++++++++++++++---- 2 files changed, 45 insertions(+), 9 deletions(-) diff --git a/src-self-hosted/translate_c.zig b/src-self-hosted/translate_c.zig index e115580244ba9ea98daa93363dff5748ce73488f..d5d751443d59fab52f36bc972ab1befb5d572efd 100644 --- a/src-self-hosted/translate_c.zig +++ b/src-self-hosted/translate_c.zig @@ -5519,12 +5519,12 @@ fn parseCPrimaryExpr(c: *Context, it: *CTokenList.Iterator, source: []const u8, return error.ParseError; } - //if (@typeInfo(@TypeOf(x)) == .Pointer) - // @ptrCast(dest, x) - //else if (@typeInfo(@TypeOf(x)) == .Int and @typeInfo(dest) == .Pointer) + //( if (@typeInfo(@TypeOf(x)) == .Pointer) + // @ptrCast(dest, @alignCast(@alignOf(dest.Child), x)) + //else if (@typeInfo(@TypeOf(x)) == .Integer and @typeInfo(dest) == .Pointer)) // @intToPtr(dest, x) //else - // @as(dest, x) + // @as(dest, x) ) const lparen = try appendToken(c, .LParen, "("); @@ -5546,9 +5546,30 @@ fn parseCPrimaryExpr(c: *Context, it: *CTokenList.Iterator, source: []const u8, if_1.condition = &cmp_1.base; _ = try appendToken(c, .RParen, ")"); + const period_tok = try appendToken(c, .Period, "."); + const child_ident = try transCreateNodeIdentifier(c, "Child"); + const inner_node_child = try c.a().create(ast.Node.InfixOp); + inner_node_child.* = .{ + .op_token = period_tok, + .lhs = inner_node, + .op = .Period, + .rhs = child_ident, + }; + + const align_of = try transCreateNodeBuiltinFnCall(c, "@alignOf"); + try align_of.params.push(&inner_node_child.base); + align_of.rparen_token = try appendToken(c, .RParen, ")"); + // hack to get zig fmt to render a comma in builtin calls + _ = try appendToken(c, .Comma, ","); + + const align_cast = try transCreateNodeBuiltinFnCall(c, "@alignCast"); + try align_cast.params.push(&align_of.base); + try align_cast.params.push(node_to_cast); + align_cast.rparen_token = try appendToken(c, .RParen, ")"); + const ptr_cast = try transCreateNodeBuiltinFnCall(c, "@ptrCast"); try ptr_cast.params.push(inner_node); - try ptr_cast.params.push(node_to_cast); + try ptr_cast.params.push(&align_cast.base); ptr_cast.rparen_token = try appendToken(c, .RParen, ")"); if_1.body = &ptr_cast.base; diff --git a/test/translate_c.zig b/test/translate_c.zig index 55414488f656eae41ebc61bf2017bf9fca18f772..8f65749f251b44442942f8331cdb419673fc9b3c 100644 --- a/test/translate_c.zig +++ b/test/translate_c.zig @@ -1458,7 +1458,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { cases.add("macro pointer cast", \\#define NRF_GPIO ((NRF_GPIO_Type *) NRF_GPIO_BASE) , &[_][]const u8{ - \\pub const NRF_GPIO = (if (@typeInfo(@TypeOf(NRF_GPIO_BASE)) == .Pointer) @ptrCast([*c]NRF_GPIO_Type, NRF_GPIO_BASE) else if (@typeInfo(@TypeOf(NRF_GPIO_BASE)) == .Int and @typeInfo([*c]NRF_GPIO_Type) == .Pointer) @intToPtr([*c]NRF_GPIO_Type, NRF_GPIO_BASE) else @as([*c]NRF_GPIO_Type, NRF_GPIO_BASE)); + \\pub const NRF_GPIO = (if (@typeInfo(@TypeOf(NRF_GPIO_BASE)) == .Pointer) @ptrCast([*c]NRF_GPIO_Type, @alignCast(@alignOf([*c]NRF_GPIO_Type.Child), NRF_GPIO_BASE)) else if (@typeInfo(@TypeOf(NRF_GPIO_BASE)) == .Int and @typeInfo([*c]NRF_GPIO_Type) == .Pointer) @intToPtr([*c]NRF_GPIO_Type, NRF_GPIO_BASE) else @as([*c]NRF_GPIO_Type, NRF_GPIO_BASE)); }); cases.add("basic macro function", @@ -2668,11 +2668,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\#define FOO(bar) baz((void *)(baz)) \\#define BAR (void*) a , &[_][]const u8{ - \\pub inline fn FOO(bar: var) @TypeOf(baz((if (@typeInfo(@TypeOf(baz)) == .Pointer) @ptrCast(*c_void, baz) else if (@typeInfo(@TypeOf(baz)) == .Int and @typeInfo(*c_void) == .Pointer) @intToPtr(*c_void, baz) else @as(*c_void, baz)))) { - \\ return baz((if (@typeInfo(@TypeOf(baz)) == .Pointer) @ptrCast(*c_void, baz) else if (@typeInfo(@TypeOf(baz)) == .Int and @typeInfo(*c_void) == .Pointer) @intToPtr(*c_void, baz) else @as(*c_void, baz))); + \\pub inline fn FOO(bar: var) @TypeOf(baz((if (@typeInfo(@TypeOf(baz)) == .Pointer) @ptrCast(*c_void, @alignCast(@alignOf(*c_void.Child), baz)) else if (@typeInfo(@TypeOf(baz)) == .Int and @typeInfo(*c_void) == .Pointer) @intToPtr(*c_void, baz) else @as(*c_void, baz)))) { + \\ return baz((if (@typeInfo(@TypeOf(baz)) == .Pointer) @ptrCast(*c_void, @alignCast(@alignOf(*c_void.Child), baz)) else if (@typeInfo(@TypeOf(baz)) == .Int and @typeInfo(*c_void) == .Pointer) @intToPtr(*c_void, baz) else @as(*c_void, baz))); \\} , - \\pub const BAR = (if (@typeInfo(@TypeOf(a)) == .Pointer) @ptrCast(*c_void, a) else if (@typeInfo(@TypeOf(a)) == .Int and @typeInfo(*c_void) == .Pointer) @intToPtr(*c_void, a) else @as(*c_void, a)); + \\pub const BAR = (if (@typeInfo(@TypeOf(a)) == .Pointer) @ptrCast(*c_void, @alignCast(@alignOf(*c_void.Child), a)) else if (@typeInfo(@TypeOf(a)) == .Int and @typeInfo(*c_void) == .Pointer) @intToPtr(*c_void, a) else @as(*c_void, a)); }); cases.add("macro conditional operator", @@ -2879,4 +2879,19 @@ pub fn addCases(cases: *tests.TranslateCContext) void { , &[_][]const u8{ \\pub const FOO = 0x61626364; }); + + cases.add("Make sure casts are grouped", + \\typedef struct + \\{ + \\ int i; + \\} + \\*_XPrivDisplay; + \\typedef struct _XDisplay Display; + \\#define DefaultScreen(dpy) (((_XPrivDisplay)(dpy))->default_screen) + \\ + , &[_][]const u8{ + \\pub inline fn DefaultScreen(dpy: var) @TypeOf((if (@typeInfo(@TypeOf(dpy)) == .Pointer) @ptrCast(_XPrivDisplay, @alignCast(@alignOf(_XPrivDisplay.Child), dpy)) else if (@typeInfo(@TypeOf(dpy)) == .Int and @typeInfo(_XPrivDisplay) == .Pointer) @intToPtr(_XPrivDisplay, dpy) else @as(_XPrivDisplay, dpy)).*.default_screen) { + \\ return (if (@typeInfo(@TypeOf(dpy)) == .Pointer) @ptrCast(_XPrivDisplay, @alignCast(@alignOf(_XPrivDisplay.Child), dpy)) else if (@typeInfo(@TypeOf(dpy)) == .Int and @typeInfo(_XPrivDisplay) == .Pointer) @intToPtr(_XPrivDisplay, dpy) else @as(_XPrivDisplay, dpy)).*.default_screen; + \\} + }); } -- 2.54.0 From d7902707bcc1faede9ef5490d02bcea935e3b8fc Mon Sep 17 00:00:00 2001 From: Lachlan Easton Date: Mon, 9 Mar 2020 20:46:18 +1100 Subject: [PATCH 80/91] Translate C: Allow casting literal ints to pointers --- src-self-hosted/translate_c.zig | 50 +++++++++++++++++++++++---------- test/translate_c.zig | 22 +++++++++++++-- 2 files changed, 54 insertions(+), 18 deletions(-) diff --git a/src-self-hosted/translate_c.zig b/src-self-hosted/translate_c.zig index d5d751443d59fab52f36bc972ab1befb5d572efd..e4d8cc4397f4118419554c3fadcf9571613b270b 100644 --- a/src-self-hosted/translate_c.zig +++ b/src-self-hosted/translate_c.zig @@ -5479,18 +5479,20 @@ fn parseCPrimaryExpr(c: *Context, it: *CTokenList.Iterator, source: []const u8, .LParen => { const inner_node = try parseCExpr(c, it, source, source_loc, scope); - if (it.next().?.id != .RParen) { + const next_id = it.next().?.id; + if (next_id != .RParen) { const first_tok = it.list.at(0); try failDecl( c, source_loc, source[first_tok.start..first_tok.end], - "unable to translate C expr: expected ')'' here", - .{}, + "unable to translate C expr: expected ')'' instead got: {}", + .{@tagName(next_id)}, ); return error.ParseError; } var saw_l_paren = false; + var saw_integer_literal = false; switch (it.peek().?.id) { // (type)(to_cast) .LParen => { @@ -5499,6 +5501,10 @@ fn parseCPrimaryExpr(c: *Context, it: *CTokenList.Iterator, source: []const u8, }, // (type)identifier .Identifier => {}, + // (type)integer + .IntegerLiteral => { + saw_integer_literal = true; + }, else => return inner_node, } @@ -5519,6 +5525,15 @@ fn parseCPrimaryExpr(c: *Context, it: *CTokenList.Iterator, source: []const u8, return error.ParseError; } + if (saw_integer_literal) { + // @intToPtr(dest, x) + const int_to_ptr = try transCreateNodeBuiltinFnCall(c, "@intToPtr"); + try int_to_ptr.params.push(inner_node); + try int_to_ptr.params.push(node_to_cast); + int_to_ptr.rparen_token = try appendToken(c, .RParen, ")"); + return &int_to_ptr.base; + } + //( if (@typeInfo(@TypeOf(x)) == .Pointer) // @ptrCast(dest, @alignCast(@alignOf(dest.Child), x)) //else if (@typeInfo(@TypeOf(x)) == .Integer and @typeInfo(dest) == .Pointer)) @@ -5750,19 +5765,24 @@ fn parseCSuffixOpExpr(c: *Context, it: *CTokenList.Iterator, source: []const u8, // hack to get zig fmt to render a comma in builtin calls _ = try appendToken(c, .Comma, ","); - const ptr_kind = blk: { - // * token - _ = it.prev(); - // last token of `node` - const prev_id = it.prev().?.id; - _ = it.next(); - _ = it.next(); - break :blk if (prev_id == .Keyword_void) .Asterisk else Token.Id.Identifier; - }; + // * token + _ = it.prev(); + // last token of `node` + const prev_id = it.prev().?.id; + _ = it.next(); + _ = it.next(); - const ptr = try transCreateNodePtrType(c, false, false, ptr_kind); - ptr.rhs = node; - return &ptr.base; + if (prev_id == .Keyword_void) { + const ptr = try transCreateNodePtrType(c, false, false, .Asterisk); + ptr.rhs = node; + const optional_node = try transCreateNodePrefixOp(c, .OptionalType, .QuestionMark, "?"); + optional_node.rhs = &ptr.base; + return &optional_node.base; + } else { + const ptr = try transCreateNodePtrType(c, false, false, Token.Id.Identifier); + ptr.rhs = node; + return &ptr.base; + } } else { // expr * expr op_token = try appendToken(c, .Asterisk, "*"); diff --git a/test/translate_c.zig b/test/translate_c.zig index 8f65749f251b44442942f8331cdb419673fc9b3c..9e935638e6341828320d40a26fe95292fc58349f 100644 --- a/test/translate_c.zig +++ b/test/translate_c.zig @@ -2668,11 +2668,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\#define FOO(bar) baz((void *)(baz)) \\#define BAR (void*) a , &[_][]const u8{ - \\pub inline fn FOO(bar: var) @TypeOf(baz((if (@typeInfo(@TypeOf(baz)) == .Pointer) @ptrCast(*c_void, @alignCast(@alignOf(*c_void.Child), baz)) else if (@typeInfo(@TypeOf(baz)) == .Int and @typeInfo(*c_void) == .Pointer) @intToPtr(*c_void, baz) else @as(*c_void, baz)))) { - \\ return baz((if (@typeInfo(@TypeOf(baz)) == .Pointer) @ptrCast(*c_void, @alignCast(@alignOf(*c_void.Child), baz)) else if (@typeInfo(@TypeOf(baz)) == .Int and @typeInfo(*c_void) == .Pointer) @intToPtr(*c_void, baz) else @as(*c_void, baz))); + \\pub inline fn FOO(bar: var) @TypeOf(baz((if (@typeInfo(@TypeOf(baz)) == .Pointer) @ptrCast(?*c_void, @alignCast(@alignOf(?*c_void.Child), baz)) else if (@typeInfo(@TypeOf(baz)) == .Int and @typeInfo(?*c_void) == .Pointer) @intToPtr(?*c_void, baz) else @as(?*c_void, baz)))) { + \\ return baz((if (@typeInfo(@TypeOf(baz)) == .Pointer) @ptrCast(?*c_void, @alignCast(@alignOf(?*c_void.Child), baz)) else if (@typeInfo(@TypeOf(baz)) == .Int and @typeInfo(?*c_void) == .Pointer) @intToPtr(?*c_void, baz) else @as(?*c_void, baz))); \\} , - \\pub const BAR = (if (@typeInfo(@TypeOf(a)) == .Pointer) @ptrCast(*c_void, @alignCast(@alignOf(*c_void.Child), a)) else if (@typeInfo(@TypeOf(a)) == .Int and @typeInfo(*c_void) == .Pointer) @intToPtr(*c_void, a) else @as(*c_void, a)); + \\pub const BAR = (if (@typeInfo(@TypeOf(a)) == .Pointer) @ptrCast(?*c_void, @alignCast(@alignOf(?*c_void.Child), a)) else if (@typeInfo(@TypeOf(a)) == .Int and @typeInfo(?*c_void) == .Pointer) @intToPtr(?*c_void, a) else @as(?*c_void, a)); }); cases.add("macro conditional operator", @@ -2894,4 +2894,20 @@ pub fn addCases(cases: *tests.TranslateCContext) void { \\ return (if (@typeInfo(@TypeOf(dpy)) == .Pointer) @ptrCast(_XPrivDisplay, @alignCast(@alignOf(_XPrivDisplay.Child), dpy)) else if (@typeInfo(@TypeOf(dpy)) == .Int and @typeInfo(_XPrivDisplay) == .Pointer) @intToPtr(_XPrivDisplay, dpy) else @as(_XPrivDisplay, dpy)).*.default_screen; \\} }); + + cases.add("Cast from integer literals to poiter", + \\#define NULL ((void*)0) + \\#define GPIO_0_MEM_MAP ((unsigned*)0x8000) + \\#define GPIO_1_MEM_MAP ((unsigned*)0x8004) + \\#define GPIO_2_MEM_MAP ((unsigned*)0x8008) + \\ + , &[_][]const u8{ + \\pub const NULL = @intToPtr(?*c_void, 0); + , + \\pub const GPIO_0_MEM_MAP = @intToPtr([*c]c_uint, 0x8000); + , + \\pub const GPIO_1_MEM_MAP = @intToPtr([*c]c_uint, 0x8004); + , + \\pub const GPIO_2_MEM_MAP = @intToPtr([*c]c_uint, 0x8008); + }); } -- 2.54.0 From d5087ccbc8729a252c6fd0d2fe71a55e4b136e3a Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 8 Apr 2020 17:41:51 -0400 Subject: [PATCH 81/91] cmake: expose ZIG_TARGET_MCPU option --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 14b490fa547c3dc1f30a5292e38ad53774c2259d..66015fe692910b97373f5e5b78aefb750681ce78 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,6 +63,7 @@ option(ZIG_TEST_COVERAGE "Build Zig with test coverage instrumentation" OFF) option(ZIG_FORCE_EXTERNAL_LLD "does nothing" OFF) set(ZIG_TARGET_TRIPLE "native" CACHE STRING "arch-os-abi to output binaries for") +set(ZIG_TARGET_MCPU "baseline" CACHE STRING "-mcpu parameter to output binaries for") set(ZIG_EXECUTABLE "" CACHE STRING "(when cross compiling) path to already-built zig binary") find_package(llvm) @@ -433,7 +434,7 @@ endif() set(BUILD_LIBSTAGE2_ARGS "build-lib" "src-self-hosted/stage2.zig" -target "${ZIG_TARGET_TRIPLE}" - -mcpu=baseline + "-mcpu=${ZIG_TARGET_MCPU}" --name zigstage2 --override-lib-dir "${CMAKE_SOURCE_DIR}/lib" --cache on -- 2.54.0 From c45ba49b8b6e8abeb2e96d28860273247e61ab18 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 8 Apr 2020 19:30:18 -0400 Subject: [PATCH 82/91] fix formatted printing warning needed to use ZIG_PRI_u64 instead of %lu --- src/ir.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ir.cpp b/src/ir.cpp index bcadc892432f43bec7afd122a5f8f9a74deed4f9..ba11d4f1e9a508333be80f71bdf03a8cf0a1b1ad 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -17689,7 +17689,7 @@ static IrInstGen *ir_analyze_tuple_mult(IrAnalyze *ira, IrInst* source_instr, TypeStructField *src_field = op1_type->data.structure.fields[i % op1_field_count]; TypeStructField *new_field = new_type->data.structure.fields[i]; - new_field->name = buf_sprintf("%lu", i); + new_field->name = buf_sprintf("%" ZIG_PRI_u64, i); new_field->type_entry = src_field->type_entry; new_field->type_val = src_field->type_val; new_field->src_index = i; -- 2.54.0 From 447dc2bb9011078e80acbe3f51135ff1ad2bf163 Mon Sep 17 00:00:00 2001 From: Yuri Pieters Date: Thu, 9 Apr 2020 01:49:42 +0100 Subject: [PATCH 83/91] sort.binarySearch: fix integer underflow (#4980) When the key was smaller than any value in the array, an error was ocurring with the mid being zero and having 1 subtracted from it. --- lib/std/sort.zig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/std/sort.zig b/lib/std/sort.zig index 3447a057695160d5ba47f4214120233cce898f5c..91d29dd22dcc4184a151c535910b2efb6ff72dff 100644 --- a/lib/std/sort.zig +++ b/lib/std/sort.zig @@ -10,16 +10,16 @@ pub fn binarySearch(comptime T: type, key: T, items: []const T, comptime compare return null; var left: usize = 0; - var right: usize = items.len - 1; + var right: usize = items.len; - while (left <= right) { + while (left < right) { // Avoid overflowing in the midpoint calculation const mid = left + (right - left) / 2; // Compare the key with the midpoint element switch (compareFn(key, items[mid])) { .eq => return mid, .gt => left = mid + 1, - .lt => right = mid - 1, + .lt => right = mid, } } -- 2.54.0 From b7e72cc4211d7b06e2b7095f48c579ce1daaf253 Mon Sep 17 00:00:00 2001 From: Yuri Pieters Date: Thu, 9 Apr 2020 02:00:08 +0100 Subject: [PATCH 84/91] sort.binarySearch: test for regresson of #4980 --- lib/std/sort.zig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/std/sort.zig b/lib/std/sort.zig index 91d29dd22dcc4184a151c535910b2efb6ff72dff..c6dcaac49e15359f03532c7450d902fc4969faa7 100644 --- a/lib/std/sort.zig +++ b/lib/std/sort.zig @@ -47,6 +47,10 @@ test "std.sort.binarySearch" { @as(?usize, null), binarySearch(u32, 1, &[_]u32{0}, S.order_u32), ); + testing.expectEqual( + @as(?usize, null), + binarySearch(u32, 0, &[_]u32{1}, S.order_u32), + ); testing.expectEqual( @as(?usize, 4), binarySearch(u32, 5, &[_]u32{ 1, 2, 3, 4, 5 }, S.order_u32), -- 2.54.0 From 57a2c5a63c1412c8c9ab458d160f320bba29db35 Mon Sep 17 00:00:00 2001 From: Michael Dusan Date: Wed, 8 Apr 2020 19:04:20 -0400 Subject: [PATCH 85/91] =?UTF-8?q?ci:=20bump=20static-qemu=205.0.0-rc1=20?= =?UTF-8?q?=E2=86=92=205.0.0-rc2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ci/azure/linux_script | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ci/azure/linux_script b/ci/azure/linux_script index d3a0d40b534a90cd72a8a5dabce47551af616970..466f42e6fe295dad2840801f39be444efe791a02 100755 --- a/ci/azure/linux_script +++ b/ci/azure/linux_script @@ -14,9 +14,9 @@ sudo apt-get remove -y llvm-* sudo rm -rf /usr/local/* sudo apt-get install -y libxml2-dev libclang-10-dev llvm-10 llvm-10-dev liblld-10-dev cmake s3cmd gcc-7 g++-7 -wget https://ziglang.org/deps/qemu-5.0.0-rc1-x86_64-alpinelinux.tar.xz -tar xf qemu-5.0.0-rc1-x86_64-alpinelinux.tar.xz -PATH=$PWD/qemu-5.0.0-rc1/bin:$PATH +wget https://ziglang.org/deps/qemu-5.0.0-rc2-x86_64-alpinelinux.tar.xz +tar xf qemu-5.0.0-rc2-x86_64-alpinelinux.tar.xz +PATH=$PWD/qemu-5.0.0-rc2/bin:$PATH # Make the `zig version` number consistent. # This will affect the cmake command below. -- 2.54.0 From c3afaa1f580510cf2ef304ce65d78a86314b38a5 Mon Sep 17 00:00:00 2001 From: markfirmware Date: Wed, 8 Apr 2020 16:58:01 -0400 Subject: [PATCH 86/91] Update langref.html.in --- doc/langref.html.in | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/doc/langref.html.in b/doc/langref.html.in index 46228d43af77e7bd205661cfc6a434b6fbdbf48e..cd1905ebfb8518afddb59e5a4aca3873cf45868a 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -1643,9 +1643,7 @@ x{} x.* x.? ! * / % ** *% || + - ++ +% -% << >> -& -^ -| +& ^ | == != < > <= >= and or -- 2.54.0 From f5f77089b76be2832640884f14c552c49c9fda1f Mon Sep 17 00:00:00 2001 From: Yuri Pieters Date: Thu, 9 Apr 2020 09:13:47 +0100 Subject: [PATCH 87/91] sort.binarySearch: Remove unneeded edge case check --- lib/std/sort.zig | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/std/sort.zig b/lib/std/sort.zig index c6dcaac49e15359f03532c7450d902fc4969faa7..8ed8f2c1c0ecfdfb081c8b1fa12904972f79f0c7 100644 --- a/lib/std/sort.zig +++ b/lib/std/sort.zig @@ -6,9 +6,6 @@ const math = std.math; const builtin = @import("builtin"); pub fn binarySearch(comptime T: type, key: T, items: []const T, comptime compareFn: fn (lhs: T, rhs: T) math.Order) ?usize { - if (items.len < 1) - return null; - var left: usize = 0; var right: usize = items.len; -- 2.54.0 From f1360bee1ce6096f1c123347313a7d24a0d90650 Mon Sep 17 00:00:00 2001 From: joachimschmidt557 Date: Thu, 9 Apr 2020 14:46:13 +0200 Subject: [PATCH 88/91] Update docgen to new ArrayList API --- doc/docgen.zig | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/doc/docgen.zig b/doc/docgen.zig index 9e4c8173c0d91741c11e6dfab04cf204e87be4bb..21bec3ba7e0bd4e9015f24d3bf25ad5922f17666 100644 --- a/doc/docgen.zig +++ b/doc/docgen.zig @@ -1108,7 +1108,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var if (expected_outcome == .BuildFail) { const result = try ChildProcess.exec(.{ .allocator = allocator, - .argv = build_args.span(), + .argv = build_args.items, .env_map = &env_map, .max_output_bytes = max_doc_file_size, }); @@ -1116,7 +1116,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var .Exited => |exit_code| { if (exit_code == 0) { warn("{}\nThe following command incorrectly succeeded:\n", .{result.stderr}); - for (build_args.span()) |arg| + for (build_args.items) |arg| warn("{} ", .{arg}) else warn("\n", .{}); @@ -1125,7 +1125,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var }, else => { warn("{}\nThe following command crashed:\n", .{result.stderr}); - for (build_args.span()) |arg| + for (build_args.items) |arg| warn("{} ", .{arg}) else warn("\n", .{}); @@ -1137,7 +1137,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var try out.print("\n{}\n", .{colored_stderr}); break :code_block; } - const exec_result = exec(allocator, &env_map, build_args.span()) catch + const exec_result = exec(allocator, &env_map, build_args.items) catch return parseError(tokenizer, code.source_token, "example failed to compile", .{}); if (code.target_str) |triple| { @@ -1238,7 +1238,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var try test_args.appendSlice(&[_][]const u8{ "-target", triple }); try out.print(" -target {}", .{triple}); } - const result = exec(allocator, &env_map, test_args.span()) catch return parseError(tokenizer, code.source_token, "test failed", .{}); + const result = exec(allocator, &env_map, test_args.items) catch return parseError(tokenizer, code.source_token, "test failed", .{}); const escaped_stderr = try escapeHtml(allocator, result.stderr); const escaped_stdout = try escapeHtml(allocator, result.stdout); try out.print("\n{}{}\n", .{ escaped_stderr, escaped_stdout }); @@ -1274,7 +1274,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var } const result = try ChildProcess.exec(.{ .allocator = allocator, - .argv = test_args.span(), + .argv = test_args.items, .env_map = &env_map, .max_output_bytes = max_doc_file_size, }); @@ -1282,7 +1282,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var .Exited => |exit_code| { if (exit_code == 0) { warn("{}\nThe following command incorrectly succeeded:\n", .{result.stderr}); - for (test_args.span()) |arg| + for (test_args.items) |arg| warn("{} ", .{arg}) else warn("\n", .{}); @@ -1291,7 +1291,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var }, else => { warn("{}\nThe following command crashed:\n", .{result.stderr}); - for (test_args.span()) |arg| + for (test_args.items) |arg| warn("{} ", .{arg}) else warn("\n", .{}); @@ -1337,7 +1337,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var const result = try ChildProcess.exec(.{ .allocator = allocator, - .argv = test_args.span(), + .argv = test_args.items, .env_map = &env_map, .max_output_bytes = max_doc_file_size, }); @@ -1345,7 +1345,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var .Exited => |exit_code| { if (exit_code == 0) { warn("{}\nThe following command incorrectly succeeded:\n", .{result.stderr}); - for (test_args.span()) |arg| + for (test_args.items) |arg| warn("{} ", .{arg}) else warn("\n", .{}); @@ -1354,7 +1354,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var }, else => { warn("{}\nThe following command crashed:\n", .{result.stderr}); - for (test_args.span()) |arg| + for (test_args.items) |arg| warn("{} ", .{arg}) else warn("\n", .{}); @@ -1434,7 +1434,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var if (maybe_error_match) |error_match| { const result = try ChildProcess.exec(.{ .allocator = allocator, - .argv = build_args.span(), + .argv = build_args.items, .env_map = &env_map, .max_output_bytes = max_doc_file_size, }); @@ -1442,7 +1442,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var .Exited => |exit_code| { if (exit_code == 0) { warn("{}\nThe following command incorrectly succeeded:\n", .{result.stderr}); - for (build_args.span()) |arg| + for (build_args.items) |arg| warn("{} ", .{arg}) else warn("\n", .{}); @@ -1451,7 +1451,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var }, else => { warn("{}\nThe following command crashed:\n", .{result.stderr}); - for (build_args.span()) |arg| + for (build_args.items) |arg| warn("{} ", .{arg}) else warn("\n", .{}); @@ -1466,7 +1466,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var const colored_stderr = try termColor(allocator, escaped_stderr); try out.print("\n{}", .{colored_stderr}); } else { - _ = exec(allocator, &env_map, build_args.span()) catch return parseError(tokenizer, code.source_token, "example failed to compile", .{}); + _ = exec(allocator, &env_map, build_args.items) catch return parseError(tokenizer, code.source_token, "example failed to compile", .{}); } if (!code.is_inline) { try out.print("\n", .{}); @@ -1503,7 +1503,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var try test_args.appendSlice(&[_][]const u8{ "-target", triple }); try out.print(" -target {}", .{triple}); } - const result = exec(allocator, &env_map, test_args.span()) catch return parseError(tokenizer, code.source_token, "test failed", .{}); + const result = exec(allocator, &env_map, test_args.items) catch return parseError(tokenizer, code.source_token, "test failed", .{}); const escaped_stderr = try escapeHtml(allocator, result.stderr); const escaped_stdout = try escapeHtml(allocator, result.stdout); try out.print("\n{}{}\n", .{ escaped_stderr, escaped_stdout }); -- 2.54.0 From aaf99371b22e816a4162391d799b9d22bba21120 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 9 Apr 2020 22:28:53 -0400 Subject: [PATCH 89/91] look for clang-cpp shared lib when it exists See #4799 --- cmake/Findclang.cmake | 104 +++++++++++++++++++++++++----------------- 1 file changed, 61 insertions(+), 43 deletions(-) diff --git a/cmake/Findclang.cmake b/cmake/Findclang.cmake index 13f9225a34b6c3e634fc6bea137027040cf65c1c..28ecc5f557cd016375ada008aa42ec13f0ca70c8 100644 --- a/cmake/Findclang.cmake +++ b/cmake/Findclang.cmake @@ -8,54 +8,72 @@ # CLANG_LIBDIRS find_path(CLANG_INCLUDE_DIRS NAMES clang/Frontend/ASTUnit.h + PATHS + /usr/lib/llvm/10/include + /usr/lib/llvm-10/include + /usr/lib/llvm-10.0/include + /usr/local/llvm100/include + /usr/local/llvm10/include + /mingw64/include +) + +if(NOT ZIG_STATIC_LLVM) + find_library(CLANG_CPP_DYLIB + NAMES + clang-cpp-10.0 + clang-cpp100 + clang-cpp PATHS - /usr/lib/llvm/10/include - /usr/lib/llvm-10/include - /usr/lib/llvm-10.0/include - /usr/local/llvm100/include - /usr/local/llvm10/include - /mingw64/include) + ${CLANG_LIBDIRS} + /usr/lib/llvm-10/lib + /usr/local/llvm100/lib + /usr/local/llvm10/lib + ) +endif() -macro(FIND_AND_ADD_CLANG_LIB _libname_) +if(CLANG_CPP_DYLIB) + set(CLANG_LIBRARIES ${CLANG_CPP_DYLIB}) +else() + macro(FIND_AND_ADD_CLANG_LIB _libname_) string(TOUPPER ${_libname_} _prettylibname_) find_library(CLANG_${_prettylibname_}_LIB NAMES ${_libname_} - PATHS - ${CLANG_LIBDIRS} - /usr/lib/llvm/10/lib - /usr/lib/llvm-10/lib - /usr/lib/llvm-10.0/lib - /usr/local/llvm100/lib - /usr/local/llvm10/lib - /mingw64/lib - /c/msys64/mingw64/lib - c:\\msys64\\mingw64\\lib) - if(CLANG_${_prettylibname_}_LIB) - set(CLANG_LIBRARIES ${CLANG_LIBRARIES} ${CLANG_${_prettylibname_}_LIB}) - endif() -endmacro(FIND_AND_ADD_CLANG_LIB) + PATHS + ${CLANG_LIBDIRS} + /usr/lib/llvm/10/lib + /usr/lib/llvm-10/lib + /usr/lib/llvm-10.0/lib + /usr/local/llvm100/lib + /usr/local/llvm10/lib + /mingw64/lib + /c/msys64/mingw64/lib + c:\\msys64\\mingw64\\lib + ) + set(CLANG_LIBRARIES ${CLANG_LIBRARIES} ${CLANG_${_prettylibname_}_LIB}) + endmacro(FIND_AND_ADD_CLANG_LIB) -FIND_AND_ADD_CLANG_LIB(clangFrontendTool) -FIND_AND_ADD_CLANG_LIB(clangCodeGen) -FIND_AND_ADD_CLANG_LIB(clangFrontend) -FIND_AND_ADD_CLANG_LIB(clangDriver) -FIND_AND_ADD_CLANG_LIB(clangSerialization) -FIND_AND_ADD_CLANG_LIB(clangSema) -FIND_AND_ADD_CLANG_LIB(clangStaticAnalyzerFrontend) -FIND_AND_ADD_CLANG_LIB(clangStaticAnalyzerCheckers) -FIND_AND_ADD_CLANG_LIB(clangStaticAnalyzerCore) -FIND_AND_ADD_CLANG_LIB(clangAnalysis) -FIND_AND_ADD_CLANG_LIB(clangASTMatchers) -FIND_AND_ADD_CLANG_LIB(clangAST) -FIND_AND_ADD_CLANG_LIB(clangParse) -FIND_AND_ADD_CLANG_LIB(clangSema) -FIND_AND_ADD_CLANG_LIB(clangBasic) -FIND_AND_ADD_CLANG_LIB(clangEdit) -FIND_AND_ADD_CLANG_LIB(clangLex) -FIND_AND_ADD_CLANG_LIB(clangARCMigrate) -FIND_AND_ADD_CLANG_LIB(clangRewriteFrontend) -FIND_AND_ADD_CLANG_LIB(clangRewrite) -FIND_AND_ADD_CLANG_LIB(clangCrossTU) -FIND_AND_ADD_CLANG_LIB(clangIndex) + FIND_AND_ADD_CLANG_LIB(clangFrontendTool) + FIND_AND_ADD_CLANG_LIB(clangCodeGen) + FIND_AND_ADD_CLANG_LIB(clangFrontend) + FIND_AND_ADD_CLANG_LIB(clangDriver) + FIND_AND_ADD_CLANG_LIB(clangSerialization) + FIND_AND_ADD_CLANG_LIB(clangSema) + FIND_AND_ADD_CLANG_LIB(clangStaticAnalyzerFrontend) + FIND_AND_ADD_CLANG_LIB(clangStaticAnalyzerCheckers) + FIND_AND_ADD_CLANG_LIB(clangStaticAnalyzerCore) + FIND_AND_ADD_CLANG_LIB(clangAnalysis) + FIND_AND_ADD_CLANG_LIB(clangASTMatchers) + FIND_AND_ADD_CLANG_LIB(clangAST) + FIND_AND_ADD_CLANG_LIB(clangParse) + FIND_AND_ADD_CLANG_LIB(clangSema) + FIND_AND_ADD_CLANG_LIB(clangBasic) + FIND_AND_ADD_CLANG_LIB(clangEdit) + FIND_AND_ADD_CLANG_LIB(clangLex) + FIND_AND_ADD_CLANG_LIB(clangARCMigrate) + FIND_AND_ADD_CLANG_LIB(clangRewriteFrontend) + FIND_AND_ADD_CLANG_LIB(clangRewrite) + FIND_AND_ADD_CLANG_LIB(clangCrossTU) + FIND_AND_ADD_CLANG_LIB(clangIndex) +endif() include(FindPackageHandleStandardArgs) find_package_handle_standard_args(clang DEFAULT_MSG CLANG_LIBRARIES CLANG_INCLUDE_DIRS) -- 2.54.0 From e857190dab2f1575dc3092f91bfb7fca5583b996 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 10 Apr 2020 01:25:15 -0400 Subject: [PATCH 90/91] put the previous commit behind cmake option ZIG_PREFER_CLANG_CPP_DYLIB Without this, building from source caused: CommandLine Error: Option 'mc-relax-all' registered more than once! LLVM ERROR: inconsistency in registered CommandLine options This is due to LLVM static libs compiled in multiple times. But without the LLVM static libs on the linker line, it caused undefined symbol linker errors. So our hands are tied. Homebrew users will have to specify `-DZIG_PREFER_CLANG_CPP_DYLIB`. --- CMakeLists.txt | 1 + cmake/Findclang.cmake | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 66015fe692910b97373f5e5b78aefb750681ce78..279156c93c86ee753fb87c48a53cad6af78ef62c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,7 @@ message("Configuring zig version ${ZIG_VERSION}") set(ZIG_STATIC off CACHE BOOL "Attempt to build a static zig executable (not compatible with glibc)") set(ZIG_STATIC_LLVM off CACHE BOOL "Prefer linking against static LLVM libraries") set(ZIG_ENABLE_MEM_PROFILE off CACHE BOOL "Activate memory usage instrumentation") +set(ZIG_PREFER_CLANG_CPP_DYLIB off CACHE BOOL "Try to link against -lclang-cpp") if(ZIG_STATIC) set(ZIG_STATIC_LLVM "on") diff --git a/cmake/Findclang.cmake b/cmake/Findclang.cmake index 28ecc5f557cd016375ada008aa42ec13f0ca70c8..c556455d1c34e57b42764cfacaa6c87d68717c55 100644 --- a/cmake/Findclang.cmake +++ b/cmake/Findclang.cmake @@ -17,7 +17,7 @@ find_path(CLANG_INCLUDE_DIRS NAMES clang/Frontend/ASTUnit.h /mingw64/include ) -if(NOT ZIG_STATIC_LLVM) +if(ZIG_PREFER_CLANG_CPP_DYLIB) find_library(CLANG_CPP_DYLIB NAMES clang-cpp-10.0 -- 2.54.0 From 4871345545ec9655a14d0bfe32668eda210953f7 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 10 Apr 2020 01:29:04 -0400 Subject: [PATCH 91/91] update readme instructions for homebrew --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fd8e51da1795392f2af83a505cd955ca9aff3673..65211e1c787f801d6902e7307be3762ac0b40f43 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ brew install cmake llvm brew outdated llvm || brew upgrade llvm mkdir build cd build -cmake .. -DCMAKE_PREFIX_PATH=$(brew --prefix llvm) +cmake .. -DCMAKE_PREFIX_PATH=$(brew --prefix llvm) -DZIG_PREFER_CLANG_CPP_DYLIB=ON make install ``` -- 2.54.0