authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-08-27 19:25:18-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-08-27 19:25:40-04:00
logfb6d3859e80faf98335c55414bb73490977d2089
treecc55d12a0eccf5b632bb72899f324e6646ef32d6
parent4f2d49fd138be67ad01d9c1b9086cb6a41530944
signaturelock-open Commit is signed but in an unrecognized format.

zig fmt


8 files changed, 635 insertions(+), 282 deletions(-)

std/event/tcp.zig+1-1
......@@ -89,7 +89,7 @@ pub const Server = struct {
8989 error.ProcessFdQuotaExceeded => {
9090 errdefer std.os.emfile_promise_queue.remove(&self.waiting_for_emfile_node);
9191 suspend {
92 self.waiting_for_emfile_node = PromiseNode.init( @handle() );
92 self.waiting_for_emfile_node = PromiseNode.init(@handle());
9393 std.os.emfile_promise_queue.append(&self.waiting_for_emfile_node);
9494 }
9595 continue;
std/fmt/index.zig+21-25
......@@ -188,12 +188,12 @@ pub fn formatType(
188188 },
189189 builtin.TypeId.Union => {
190190 const info = @typeInfo(T).Union;
191 if(info.tag_type) |UnionTagType| {
191 if (info.tag_type) |UnionTagType| {
192192 try output(context, "{ .");
193193 try output(context, @tagName(UnionTagType(value)));
194194 try output(context, " = ");
195 inline for(info.fields) |u_field| {
196 if(@enumToInt(UnionTagType(value)) == u_field.enum_field.?.value) {
195 inline for (info.fields) |u_field| {
196 if (@enumToInt(UnionTagType(value)) == u_field.enum_field.?.value) {
197197 try formatType(@field(value, u_field.name), "", context, Errors, output);
198198 }
199199 }
......@@ -1221,58 +1221,54 @@ test "fmt.format" {
12211221 a: u32,
12221222 b: error,
12231223 };
1224
1225 const inst = S {
1224
1225 const inst = S{
12261226 .a = 456,
12271227 .b = error.Unused,
12281228 };
1229
1229
12301230 try testFmt("S{ .a = 456, .b = error.Unused }", "{}", inst);
12311231 }
12321232 //union format
12331233 {
1234 const TU = union(enum)
1235 {
1234 const TU = union(enum) {
12361235 float: f32,
12371236 int: u32,
12381237 };
1239
1240 const UU = union
1241 {
1238
1239 const UU = union {
12421240 float: f32,
12431241 int: u32,
12441242 };
1245
1246 const EU = extern union
1247 {
1243
1244 const EU = extern union {
12481245 float: f32,
12491246 int: u32,
12501247 };
1251
1252 const tu_inst = TU{ .int = 123, };
1253 const uu_inst = UU{ .int = 456, };
1254 const eu_inst = EU{ .float = 321.123, };
1255
1248
1249 const tu_inst = TU{ .int = 123 };
1250 const uu_inst = UU{ .int = 456 };
1251 const eu_inst = EU{ .float = 321.123 };
1252
12561253 try testFmt("TU{ .int = 123 }", "{}", tu_inst);
1257
1254
12581255 var buf: [100]u8 = undefined;
12591256 const uu_result = try bufPrint(buf[0..], "{}", uu_inst);
12601257 debug.assert(mem.eql(u8, uu_result[0..3], "UU@"));
1261
1258
12621259 const eu_result = try bufPrint(buf[0..], "{}", eu_inst);
12631260 debug.assert(mem.eql(u8, uu_result[0..3], "EU@"));
12641261 }
12651262 //enum format
12661263 {
1267 const E = enum
1268 {
1264 const E = enum {
12691265 One,
12701266 Two,
12711267 Three,
12721268 };
1273
1269
12741270 const inst = E.Two;
1275
1271
12761272 try testFmt("E.Two", "{}", inst);
12771273 }
12781274}
std/macho.zig+552-206
......@@ -1,4 +1,3 @@
1
21pub const mach_header = extern struct {
32 magic: u32,
43 cputype: cpu_type_t,
......@@ -25,26 +24,43 @@ pub const load_command = extern struct {
2524 cmdsize: u32,
2625};
2726
28
2927/// The symtab_command contains the offsets and sizes of the link-edit 4.3BSD
3028/// "stab" style symbol table information as described in the header files
3129/// <nlist.h> and <stab.h>.
3230pub const symtab_command = extern struct {
33 cmd: u32, /// LC_SYMTAB
34 cmdsize: u32, /// sizeof(struct symtab_command)
35 symoff: u32, /// symbol table offset
36 nsyms: u32, /// number of symbol table entries
37 stroff: u32, /// string table offset
38 strsize: u32, /// string table size in bytes
31 /// LC_SYMTAB
32 cmd: u32,
33
34 /// sizeof(struct symtab_command)
35 cmdsize: u32,
36
37 /// symbol table offset
38 symoff: u32,
39
40 /// number of symbol table entries
41 nsyms: u32,
42
43 /// string table offset
44 stroff: u32,
45
46 /// string table size in bytes
47 strsize: u32,
3948};
4049
4150/// The linkedit_data_command contains the offsets and sizes of a blob
42/// of data in the __LINKEDIT segment.
51/// of data in the __LINKEDIT segment.
4352const linkedit_data_command = extern struct {
44 cmd: u32,/// LC_CODE_SIGNATURE, LC_SEGMENT_SPLIT_INFO, LC_FUNCTION_STARTS, LC_DATA_IN_CODE, LC_DYLIB_CODE_SIGN_DRS or LC_LINKER_OPTIMIZATION_HINT.
45 cmdsize: u32, /// sizeof(struct linkedit_data_command)
46 dataoff: u32 , /// file offset of data in __LINKEDIT segment
47 datasize: u32 , /// file size of data in __LINKEDIT segment
53 /// LC_CODE_SIGNATURE, LC_SEGMENT_SPLIT_INFO, LC_FUNCTION_STARTS, LC_DATA_IN_CODE, LC_DYLIB_CODE_SIGN_DRS or LC_LINKER_OPTIMIZATION_HINT.
54 cmd: u32,
55
56 /// sizeof(struct linkedit_data_command)
57 cmdsize: u32,
58
59 /// file offset of data in __LINKEDIT segment
60 dataoff: u32,
61
62 /// file size of data in __LINKEDIT segment
63 datasize: u32,
4864};
4965
5066/// The segment load command indicates that a part of this file is to be
......@@ -58,16 +74,35 @@ const linkedit_data_command = extern struct {
5874/// section structures directly follow the segment command and their size is
5975/// reflected in cmdsize.
6076pub const segment_command = extern struct {
61 cmd: u32,/// LC_SEGMENT
62 cmdsize: u32,/// includes sizeof section structs
63 segname: [16]u8,/// segment name
64 vmaddr: u32,/// memory address of this segment
65 vmsize: u32,/// memory size of this segment
66 fileoff: u32,/// file offset of this segment
67 filesize: u32,/// amount to map from the file
68 maxprot: vm_prot_t,/// maximum VM protection
69 initprot: vm_prot_t,/// initial VM protection
70 nsects: u32,/// number of sections in segment
77 /// LC_SEGMENT
78 cmd: u32,
79
80 /// includes sizeof section structs
81 cmdsize: u32,
82
83 /// segment name
84 segname: [16]u8,
85
86 /// memory address of this segment
87 vmaddr: u32,
88
89 /// memory size of this segment
90 vmsize: u32,
91
92 /// file offset of this segment
93 fileoff: u32,
94
95 /// amount to map from the file
96 filesize: u32,
97
98 /// maximum VM protection
99 maxprot: vm_prot_t,
100
101 /// initial VM protection
102 initprot: vm_prot_t,
103
104 /// number of sections in segment
105 nsects: u32,
71106 flags: u32,
72107};
73108
......@@ -76,17 +111,36 @@ pub const segment_command = extern struct {
76111/// sections then section_64 structures directly follow the 64-bit segment
77112/// command and their size is reflected in cmdsize.
78113pub const segment_command_64 = extern struct {
79 cmd: u32, /// LC_SEGMENT_64
80 cmdsize: u32, /// includes sizeof section_64 structs
81 segname: [16]u8, /// segment name
82 vmaddr: u64, /// memory address of this segment
83 vmsize: u64, /// memory size of this segment
84 fileoff: u64, /// file offset of this segment
85 filesize: u64, /// amount to map from the file
86 maxprot: vm_prot_t, /// maximum VM protection
87 initprot: vm_prot_t, /// initial VM protection
88 nsects: u32, /// number of sections in segment
89 flags: u32,
114 /// LC_SEGMENT_64
115 cmd: u32,
116
117 /// includes sizeof section_64 structs
118 cmdsize: u32,
119
120 /// segment name
121 segname: [16]u8,
122
123 /// memory address of this segment
124 vmaddr: u64,
125
126 /// memory size of this segment
127 vmsize: u64,
128
129 /// file offset of this segment
130 fileoff: u64,
131
132 /// amount to map from the file
133 filesize: u64,
134
135 /// maximum VM protection
136 maxprot: vm_prot_t,
137
138 /// initial VM protection
139 initprot: vm_prot_t,
140
141 /// number of sections in segment
142 nsects: u32,
143 flags: u32,
90144};
91145
92146/// A segment is made up of zero or more sections. Non-MH_OBJECT files have
......@@ -115,32 +169,76 @@ pub const segment_command_64 = extern struct {
115169/// fields of the section structure for mach object files is described in the
116170/// header file <reloc.h>.
117171pub const @"section" = extern struct {
118 sectname: [16]u8, /// name of this section
119 segname: [16]u8, /// segment this section goes in
120 addr: u32, /// memory address of this section
121 size: u32, /// size in bytes of this section
122 offset: u32, /// file offset of this section
123 @"align": u32, /// section alignment (power of 2)
124 reloff: u32, /// file offset of relocation entries
125 nreloc: u32, /// number of relocation entries
126 flags: u32, /// flags (section type and attributes
127 reserved1: u32, /// reserved (for offset or index)
128 reserved2: u32, /// reserved (for count or sizeof)
172 /// name of this section
173 sectname: [16]u8,
174
175 /// segment this section goes in
176 segname: [16]u8,
177
178 /// memory address of this section
179 addr: u32,
180
181 /// size in bytes of this section
182 size: u32,
183
184 /// file offset of this section
185 offset: u32,
186
187 /// section alignment (power of 2)
188 @"align": u32,
189
190 /// file offset of relocation entries
191 reloff: u32,
192
193 /// number of relocation entries
194 nreloc: u32,
195
196 /// flags (section type and attributes
197 flags: u32,
198
199 /// reserved (for offset or index)
200 reserved1: u32,
201
202 /// reserved (for count or sizeof)
203 reserved2: u32,
129204};
130205
131206pub const section_64 = extern struct {
132 sectname: [16]u8, /// name of this section
133 segname: [16]u8, /// segment this section goes in
134 addr: u64, /// memory address of this section
135 size: u64, /// size in bytes of this section
136 offset: u32, /// file offset of this section
137 @"align": u32, /// section alignment (power of 2)
138 reloff: u32, /// file offset of relocation entries
139 nreloc: u32, /// number of relocation entries
140 flags: u32, /// flags (section type and attributes
141 reserved1: u32, /// reserved (for offset or index)
142 reserved2: u32, /// reserved (for count or sizeof)
143 reserved3: u32, /// reserved
207 /// name of this section
208 sectname: [16]u8,
209
210 /// segment this section goes in
211 segname: [16]u8,
212
213 /// memory address of this section
214 addr: u64,
215
216 /// size in bytes of this section
217 size: u64,
218
219 /// file offset of this section
220 offset: u32,
221
222 /// section alignment (power of 2)
223 @"align": u32,
224
225 /// file offset of relocation entries
226 reloff: u32,
227
228 /// number of relocation entries
229 nreloc: u32,
230
231 /// flags (section type and attributes
232 flags: u32,
233
234 /// reserved (for offset or index)
235 reserved1: u32,
236
237 /// reserved (for count or sizeof)
238 reserved2: u32,
239
240 /// reserved
241 reserved3: u32,
144242};
145243
146244pub const nlist = extern struct {
......@@ -168,116 +266,287 @@ pub const nlist_64 = extern struct {
168266/// simply be ignored.
169267pub const LC_REQ_DYLD = 0x80000000;
170268
171pub const LC_SEGMENT = 0x1; /// segment of this file to be mapped
172pub const LC_SYMTAB = 0x2; /// link-edit stab symbol table info
173pub const LC_SYMSEG = 0x3; /// link-edit gdb symbol table info (obsolete)
174pub const LC_THREAD = 0x4; /// thread
175pub const LC_UNIXTHREAD = 0x5; /// unix thread (includes a stack)
176pub const LC_LOADFVMLIB = 0x6; /// load a specified fixed VM shared library
177pub const LC_IDFVMLIB = 0x7; /// fixed VM shared library identification
178pub const LC_IDENT = 0x8; /// object identification info (obsolete)
179pub const LC_FVMFILE = 0x9; /// fixed VM file inclusion (internal use)
180pub const LC_PREPAGE = 0xa; /// prepage command (internal use)
181pub const LC_DYSYMTAB = 0xb; /// dynamic link-edit symbol table info
182pub const LC_LOAD_DYLIB = 0xc; /// load a dynamically linked shared library
183pub const LC_ID_DYLIB = 0xd; /// dynamically linked shared lib ident
184pub const LC_LOAD_DYLINKER = 0xe; /// load a dynamic linker
185pub const LC_ID_DYLINKER = 0xf; /// dynamic linker identification
186pub const LC_PREBOUND_DYLIB = 0x10; /// modules prebound for a dynamically
187pub const LC_ROUTINES = 0x11; /// image routines
188pub const LC_SUB_FRAMEWORK = 0x12; /// sub framework
189pub const LC_SUB_UMBRELLA = 0x13; /// sub umbrella
190pub const LC_SUB_CLIENT = 0x14; /// sub client
191pub const LC_SUB_LIBRARY = 0x15; /// sub library
192pub const LC_TWOLEVEL_HINTS = 0x16; /// two-level namespace lookup hints
193pub const LC_PREBIND_CKSUM = 0x17; /// prebind checksum
269/// segment of this file to be mapped
270pub const LC_SEGMENT = 0x1;
271
272/// link-edit stab symbol table info
273pub const LC_SYMTAB = 0x2;
274
275/// link-edit gdb symbol table info (obsolete)
276pub const LC_SYMSEG = 0x3;
277
278/// thread
279pub const LC_THREAD = 0x4;
280
281/// unix thread (includes a stack)
282pub const LC_UNIXTHREAD = 0x5;
283
284/// load a specified fixed VM shared library
285pub const LC_LOADFVMLIB = 0x6;
286
287/// fixed VM shared library identification
288pub const LC_IDFVMLIB = 0x7;
289
290/// object identification info (obsolete)
291pub const LC_IDENT = 0x8;
292
293/// fixed VM file inclusion (internal use)
294pub const LC_FVMFILE = 0x9;
295
296/// prepage command (internal use)
297pub const LC_PREPAGE = 0xa;
298
299/// dynamic link-edit symbol table info
300pub const LC_DYSYMTAB = 0xb;
301
302/// load a dynamically linked shared library
303pub const LC_LOAD_DYLIB = 0xc;
304
305/// dynamically linked shared lib ident
306pub const LC_ID_DYLIB = 0xd;
307
308/// load a dynamic linker
309pub const LC_LOAD_DYLINKER = 0xe;
310
311/// dynamic linker identification
312pub const LC_ID_DYLINKER = 0xf;
313
314/// modules prebound for a dynamically
315pub const LC_PREBOUND_DYLIB = 0x10;
316
317/// image routines
318pub const LC_ROUTINES = 0x11;
319
320/// sub framework
321pub const LC_SUB_FRAMEWORK = 0x12;
322
323/// sub umbrella
324pub const LC_SUB_UMBRELLA = 0x13;
325
326/// sub client
327pub const LC_SUB_CLIENT = 0x14;
328
329/// sub library
330pub const LC_SUB_LIBRARY = 0x15;
331
332/// two-level namespace lookup hints
333pub const LC_TWOLEVEL_HINTS = 0x16;
334
335/// prebind checksum
336pub const LC_PREBIND_CKSUM = 0x17;
194337
195338/// load a dynamically linked shared library that is allowed to be missing
196339/// (all symbols are weak imported).
197340pub const LC_LOAD_WEAK_DYLIB = (0x18 | LC_REQ_DYLD);
198341
199pub const LC_SEGMENT_64 = 0x19; /// 64-bit segment of this file to be mapped
200pub const LC_ROUTINES_64 = 0x1a; /// 64-bit image routines
201pub const LC_UUID = 0x1b; /// the uuid
202pub const LC_RPATH = (0x1c | LC_REQ_DYLD); /// runpath additions
203pub const LC_CODE_SIGNATURE = 0x1d; /// local of code signature
204pub const LC_SEGMENT_SPLIT_INFO = 0x1e; /// local of info to split segments
205pub const LC_REEXPORT_DYLIB = (0x1f | LC_REQ_DYLD); /// load and re-export dylib
206pub const LC_LAZY_LOAD_DYLIB = 0x20; /// delay load of dylib until first use
207pub const LC_ENCRYPTION_INFO = 0x21; /// encrypted segment information
208pub const LC_DYLD_INFO = 0x22; /// compressed dyld information
209pub const LC_DYLD_INFO_ONLY = (0x22|LC_REQ_DYLD); /// compressed dyld information only
210pub const LC_LOAD_UPWARD_DYLIB = (0x23 | LC_REQ_DYLD); /// load upward dylib
211pub const LC_VERSION_MIN_MACOSX = 0x24; /// build for MacOSX min OS version
212pub const LC_VERSION_MIN_IPHONEOS = 0x25; /// build for iPhoneOS min OS version
213pub const LC_FUNCTION_STARTS = 0x26; /// compressed table of function start addresses
214pub const LC_DYLD_ENVIRONMENT = 0x27; /// string for dyld to treat like environment variable
215pub const LC_MAIN = (0x28|LC_REQ_DYLD); /// replacement for LC_UNIXTHREAD
216pub const LC_DATA_IN_CODE = 0x29; /// table of non-instructions in __text
217pub const LC_SOURCE_VERSION = 0x2A; /// source version used to build binary
218pub const LC_DYLIB_CODE_SIGN_DRS = 0x2B; /// Code signing DRs copied from linked dylibs
219pub const LC_ENCRYPTION_INFO_64 = 0x2C; /// 64-bit encrypted segment information
220pub const LC_LINKER_OPTION = 0x2D; /// linker options in MH_OBJECT files
221pub const LC_LINKER_OPTIMIZATION_HINT = 0x2E; /// optimization hints in MH_OBJECT files
222pub const LC_VERSION_MIN_TVOS = 0x2F; /// build for AppleTV min OS version
223pub const LC_VERSION_MIN_WATCHOS = 0x30; /// build for Watch min OS version
224pub const LC_NOTE = 0x31; /// arbitrary data included within a Mach-O file
225pub const LC_BUILD_VERSION = 0x32; /// build for platform min OS version
226
227pub const MH_MAGIC = 0xfeedface; /// the mach magic number
228pub const MH_CIGAM = 0xcefaedfe; /// NXSwapInt(MH_MAGIC)
229
230pub const MH_MAGIC_64 = 0xfeedfacf; /// the 64-bit mach magic number
231pub const MH_CIGAM_64 = 0xcffaedfe; /// NXSwapInt(MH_MAGIC_64)
232
233pub const MH_OBJECT = 0x1; /// relocatable object file
234pub const MH_EXECUTE = 0x2; /// demand paged executable file
235pub const MH_FVMLIB = 0x3; /// fixed VM shared library file
236pub const MH_CORE = 0x4; /// core file
237pub const MH_PRELOAD = 0x5; /// preloaded executable file
238pub const MH_DYLIB = 0x6; /// dynamically bound shared library
239pub const MH_DYLINKER = 0x7; /// dynamic link editor
240pub const MH_BUNDLE = 0x8; /// dynamically bound bundle file
241pub const MH_DYLIB_STUB = 0x9; /// shared library stub for static linking only, no section contents
242pub const MH_DSYM = 0xa; /// companion file with only debug sections
243pub const MH_KEXT_BUNDLE = 0xb; /// x86_64 kexts
342/// 64-bit segment of this file to be mapped
343pub const LC_SEGMENT_64 = 0x19;
344
345/// 64-bit image routines
346pub const LC_ROUTINES_64 = 0x1a;
347
348/// the uuid
349pub const LC_UUID = 0x1b;
350
351/// runpath additions
352pub const LC_RPATH = (0x1c | LC_REQ_DYLD);
353
354/// local of code signature
355pub const LC_CODE_SIGNATURE = 0x1d;
356
357/// local of info to split segments
358pub const LC_SEGMENT_SPLIT_INFO = 0x1e;
359
360/// load and re-export dylib
361pub const LC_REEXPORT_DYLIB = (0x1f | LC_REQ_DYLD);
362
363/// delay load of dylib until first use
364pub const LC_LAZY_LOAD_DYLIB = 0x20;
365
366/// encrypted segment information
367pub const LC_ENCRYPTION_INFO = 0x21;
368
369/// compressed dyld information
370pub const LC_DYLD_INFO = 0x22;
371
372/// compressed dyld information only
373pub const LC_DYLD_INFO_ONLY = (0x22 | LC_REQ_DYLD);
374
375/// load upward dylib
376pub const LC_LOAD_UPWARD_DYLIB = (0x23 | LC_REQ_DYLD);
377
378/// build for MacOSX min OS version
379pub const LC_VERSION_MIN_MACOSX = 0x24;
380
381/// build for iPhoneOS min OS version
382pub const LC_VERSION_MIN_IPHONEOS = 0x25;
383
384/// compressed table of function start addresses
385pub const LC_FUNCTION_STARTS = 0x26;
386
387/// string for dyld to treat like environment variable
388pub const LC_DYLD_ENVIRONMENT = 0x27;
389
390/// replacement for LC_UNIXTHREAD
391pub const LC_MAIN = (0x28 | LC_REQ_DYLD);
392
393/// table of non-instructions in __text
394pub const LC_DATA_IN_CODE = 0x29;
395
396/// source version used to build binary
397pub const LC_SOURCE_VERSION = 0x2A;
398
399/// Code signing DRs copied from linked dylibs
400pub const LC_DYLIB_CODE_SIGN_DRS = 0x2B;
401
402/// 64-bit encrypted segment information
403pub const LC_ENCRYPTION_INFO_64 = 0x2C;
404
405/// linker options in MH_OBJECT files
406pub const LC_LINKER_OPTION = 0x2D;
407
408/// optimization hints in MH_OBJECT files
409pub const LC_LINKER_OPTIMIZATION_HINT = 0x2E;
410
411/// build for AppleTV min OS version
412pub const LC_VERSION_MIN_TVOS = 0x2F;
413
414/// build for Watch min OS version
415pub const LC_VERSION_MIN_WATCHOS = 0x30;
416
417/// arbitrary data included within a Mach-O file
418pub const LC_NOTE = 0x31;
419
420/// build for platform min OS version
421pub const LC_BUILD_VERSION = 0x32;
422
423/// the mach magic number
424pub const MH_MAGIC = 0xfeedface;
425
426/// NXSwapInt(MH_MAGIC)
427pub const MH_CIGAM = 0xcefaedfe;
428
429/// the 64-bit mach magic number
430pub const MH_MAGIC_64 = 0xfeedfacf;
431
432/// NXSwapInt(MH_MAGIC_64)
433pub const MH_CIGAM_64 = 0xcffaedfe;
434
435/// relocatable object file
436pub const MH_OBJECT = 0x1;
437
438/// demand paged executable file
439pub const MH_EXECUTE = 0x2;
440
441/// fixed VM shared library file
442pub const MH_FVMLIB = 0x3;
443
444/// core file
445pub const MH_CORE = 0x4;
446
447/// preloaded executable file
448pub const MH_PRELOAD = 0x5;
449
450/// dynamically bound shared library
451pub const MH_DYLIB = 0x6;
452
453/// dynamic link editor
454pub const MH_DYLINKER = 0x7;
455
456/// dynamically bound bundle file
457pub const MH_BUNDLE = 0x8;
458
459/// shared library stub for static linking only, no section contents
460pub const MH_DYLIB_STUB = 0x9;
461
462/// companion file with only debug sections
463pub const MH_DSYM = 0xa;
464
465/// x86_64 kexts
466pub const MH_KEXT_BUNDLE = 0xb;
244467
245468// Constants for the flags field of the mach_header
246469
247pub const MH_NOUNDEFS = 0x1; /// the object file has no undefined references
248pub const MH_INCRLINK = 0x2; /// the object file is the output of an incremental link against a base file and can't be link edited again
249pub const MH_DYLDLINK = 0x4; /// the object file is input for the dynamic linker and can't be staticly link edited again
250pub const MH_BINDATLOAD = 0x8; /// the object file's undefined references are bound by the dynamic linker when loaded.
251pub const MH_PREBOUND = 0x10; /// the file has its dynamic undefined references prebound.
252pub const MH_SPLIT_SEGS = 0x20; /// the file has its read-only and read-write segments split
253pub const MH_LAZY_INIT = 0x40; /// the shared library init routine is to be run lazily via catching memory faults to its writeable segments (obsolete)
254pub const MH_TWOLEVEL = 0x80; /// the image is using two-level name space bindings
255pub const MH_FORCE_FLAT = 0x100; /// the executable is forcing all images to use flat name space bindings
256pub const MH_NOMULTIDEFS = 0x200; /// this umbrella guarantees no multiple defintions of symbols in its sub-images so the two-level namespace hints can always be used.
257pub const MH_NOFIXPREBINDING = 0x400; /// do not have dyld notify the prebinding agent about this executable
258pub const MH_PREBINDABLE = 0x800; /// the binary is not prebound but can have its prebinding redone. only used when MH_PREBOUND is not set.
259pub const MH_ALLMODSBOUND = 0x1000; /// indicates that this binary binds to all two-level namespace modules of its dependent libraries. only used when MH_PREBINDABLE and MH_TWOLEVEL are both set.
260pub const MH_SUBSECTIONS_VIA_SYMBOLS = 0x2000;/// safe to divide up the sections into sub-sections via symbols for dead code stripping
261pub const MH_CANONICAL = 0x4000; /// the binary has been canonicalized via the unprebind operation
262pub const MH_WEAK_DEFINES = 0x8000; /// the final linked image contains external weak symbols
263pub const MH_BINDS_TO_WEAK = 0x10000; /// the final linked image uses weak symbols
264
265pub const MH_ALLOW_STACK_EXECUTION = 0x20000;/// When this bit is set, all stacks in the task will be given stack execution privilege. Only used in MH_EXECUTE filetypes.
266pub const MH_ROOT_SAFE = 0x40000; /// When this bit is set, the binary declares it is safe for use in processes with uid zero
267
268pub const MH_SETUID_SAFE = 0x80000; /// When this bit is set, the binary declares it is safe for use in processes when issetugid() is true
269
270pub const MH_NO_REEXPORTED_DYLIBS = 0x100000; /// When this bit is set on a dylib, the static linker does not need to examine dependent dylibs to see if any are re-exported
271pub const MH_PIE = 0x200000; /// When this bit is set, the OS will load the main executable at a random address. Only used in MH_EXECUTE filetypes.
272pub const MH_DEAD_STRIPPABLE_DYLIB = 0x400000; /// Only for use on dylibs. When linking against a dylib that has this bit set, the static linker will automatically not create a LC_LOAD_DYLIB load command to the dylib if no symbols are being referenced from the dylib.
273pub const MH_HAS_TLV_DESCRIPTORS = 0x800000; /// Contains a section of type S_THREAD_LOCAL_VARIABLES
274
275pub const MH_NO_HEAP_EXECUTION = 0x1000000; /// When this bit is set, the OS will run the main executable with a non-executable heap even on platforms (e.g. i386) that don't require it. Only used in MH_EXECUTE filetypes.
276
277pub const MH_APP_EXTENSION_SAFE = 0x02000000; /// The code was linked for use in an application extension.
278
279pub const MH_NLIST_OUTOFSYNC_WITH_DYLDINFO = 0x04000000; /// The external symbols listed in the nlist symbol table do not include all the symbols listed in the dyld info.
470/// the object file has no undefined references
471pub const MH_NOUNDEFS = 0x1;
472
473/// the object file is the output of an incremental link against a base file and can't be link edited again
474pub const MH_INCRLINK = 0x2;
475
476/// the object file is input for the dynamic linker and can't be staticly link edited again
477pub const MH_DYLDLINK = 0x4;
478
479/// the object file's undefined references are bound by the dynamic linker when loaded.
480pub const MH_BINDATLOAD = 0x8;
481
482/// the file has its dynamic undefined references prebound.
483pub const MH_PREBOUND = 0x10;
484
485/// the file has its read-only and read-write segments split
486pub const MH_SPLIT_SEGS = 0x20;
487
488/// the shared library init routine is to be run lazily via catching memory faults to its writeable segments (obsolete)
489pub const MH_LAZY_INIT = 0x40;
490
491/// the image is using two-level name space bindings
492pub const MH_TWOLEVEL = 0x80;
493
494/// the executable is forcing all images to use flat name space bindings
495pub const MH_FORCE_FLAT = 0x100;
496
497/// this umbrella guarantees no multiple defintions of symbols in its sub-images so the two-level namespace hints can always be used.
498pub const MH_NOMULTIDEFS = 0x200;
499
500/// do not have dyld notify the prebinding agent about this executable
501pub const MH_NOFIXPREBINDING = 0x400;
502
503/// the binary is not prebound but can have its prebinding redone. only used when MH_PREBOUND is not set.
504pub const MH_PREBINDABLE = 0x800;
505
506/// indicates that this binary binds to all two-level namespace modules of its dependent libraries. only used when MH_PREBINDABLE and MH_TWOLEVEL are both set.
507pub const MH_ALLMODSBOUND = 0x1000;
508
509/// safe to divide up the sections into sub-sections via symbols for dead code stripping
510pub const MH_SUBSECTIONS_VIA_SYMBOLS = 0x2000;
511
512/// the binary has been canonicalized via the unprebind operation
513pub const MH_CANONICAL = 0x4000;
514
515/// the final linked image contains external weak symbols
516pub const MH_WEAK_DEFINES = 0x8000;
517
518/// the final linked image uses weak symbols
519pub const MH_BINDS_TO_WEAK = 0x10000;
520
521/// When this bit is set, all stacks in the task will be given stack execution privilege. Only used in MH_EXECUTE filetypes.
522pub const MH_ALLOW_STACK_EXECUTION = 0x20000;
523
524/// When this bit is set, the binary declares it is safe for use in processes with uid zero
525pub const MH_ROOT_SAFE = 0x40000;
526
527/// When this bit is set, the binary declares it is safe for use in processes when issetugid() is true
528pub const MH_SETUID_SAFE = 0x80000;
529
530/// When this bit is set on a dylib, the static linker does not need to examine dependent dylibs to see if any are re-exported
531pub const MH_NO_REEXPORTED_DYLIBS = 0x100000;
280532
533/// When this bit is set, the OS will load the main executable at a random address. Only used in MH_EXECUTE filetypes.
534pub const MH_PIE = 0x200000;
535
536/// Only for use on dylibs. When linking against a dylib that has this bit set, the static linker will automatically not create a LC_LOAD_DYLIB load command to the dylib if no symbols are being referenced from the dylib.
537pub const MH_DEAD_STRIPPABLE_DYLIB = 0x400000;
538
539/// Contains a section of type S_THREAD_LOCAL_VARIABLES
540pub const MH_HAS_TLV_DESCRIPTORS = 0x800000;
541
542/// When this bit is set, the OS will run the main executable with a non-executable heap even on platforms (e.g. i386) that don't require it. Only used in MH_EXECUTE filetypes.
543pub const MH_NO_HEAP_EXECUTION = 0x1000000;
544
545/// The code was linked for use in an application extension.
546pub const MH_APP_EXTENSION_SAFE = 0x02000000;
547
548/// The external symbols listed in the nlist symbol table do not include all the symbols listed in the dyld info.
549pub const MH_NLIST_OUTOFSYNC_WITH_DYLDINFO = 0x04000000;
281550
282551/// The flags field of a section structure is separated into two parts a section
283552/// type and section attributes. The section types are mutually exclusive (it
......@@ -285,52 +554,129 @@ pub const MH_NLIST_OUTOFSYNC_WITH_DYLDINFO = 0x04000000; /// The external symbol
285554/// than one attribute).
286555/// 256 section types
287556pub const SECTION_TYPE = 0x000000ff;
288pub const SECTION_ATTRIBUTES = 0xffffff00; /// 24 section attributes
289
290pub const S_REGULAR = 0x0; /// regular section
291pub const S_ZEROFILL = 0x1; /// zero fill on demand section
292pub const S_CSTRING_LITERALS = 0x2; /// section with only literal C string
293pub const S_4BYTE_LITERALS = 0x3; /// section with only 4 byte literals
294pub const S_8BYTE_LITERALS = 0x4; /// section with only 8 byte literals
295pub const S_LITERAL_POINTERS = 0x5; /// section with only pointers to
296
297
298pub const N_STAB = 0xe0; /// if any of these bits set, a symbolic debugging entry
299pub const N_PEXT = 0x10; /// private external symbol bit
300pub const N_TYPE = 0x0e; /// mask for the type bits
301pub const N_EXT = 0x01; /// external symbol bit, set for external symbols
302
303
304pub const N_GSYM = 0x20; /// global symbol: name,,NO_SECT,type,0
305pub const N_FNAME = 0x22; /// procedure name (f77 kludge): name,,NO_SECT,0,0
306pub const N_FUN = 0x24; /// procedure: name,,n_sect,linenumber,address
307pub const N_STSYM = 0x26; /// static symbol: name,,n_sect,type,address
308pub const N_LCSYM = 0x28; /// .lcomm symbol: name,,n_sect,type,address
309pub const N_BNSYM = 0x2e; /// begin nsect sym: 0,,n_sect,0,address
310pub const N_AST = 0x32; /// AST file path: name,,NO_SECT,0,0
311pub const N_OPT = 0x3c; /// emitted with gcc2_compiled and in gcc source
312pub const N_RSYM = 0x40; /// register sym: name,,NO_SECT,type,register
313pub const N_SLINE = 0x44; /// src line: 0,,n_sect,linenumber,address
314pub const N_ENSYM = 0x4e; /// end nsect sym: 0,,n_sect,0,address
315pub const N_SSYM = 0x60; /// structure elt: name,,NO_SECT,type,struct_offset
316pub const N_SO = 0x64; /// source file name: name,,n_sect,0,address
317pub const N_OSO = 0x66; /// object file name: name,,0,0,st_mtime
318pub const N_LSYM = 0x80; /// local sym: name,,NO_SECT,type,offset
319pub const N_BINCL = 0x82; /// include file beginning: name,,NO_SECT,0,sum
320pub const N_SOL = 0x84; /// #included file name: name,,n_sect,0,address
321pub const N_PARAMS = 0x86; /// compiler parameters: name,,NO_SECT,0,0
322pub const N_VERSION = 0x88; /// compiler version: name,,NO_SECT,0,0
323pub const N_OLEVEL = 0x8A; /// compiler -O level: name,,NO_SECT,0,0
324pub const N_PSYM = 0xa0; /// parameter: name,,NO_SECT,type,offset
325pub const N_EINCL = 0xa2; /// include file end: name,,NO_SECT,0,0
326pub const N_ENTRY = 0xa4; /// alternate entry: name,,n_sect,linenumber,address
327pub const N_LBRAC = 0xc0; /// left bracket: 0,,NO_SECT,nesting level,address
328pub const N_EXCL = 0xc2; /// deleted include file: name,,NO_SECT,0,sum
329pub const N_RBRAC = 0xe0; /// right bracket: 0,,NO_SECT,nesting level,address
330pub const N_BCOMM = 0xe2; /// begin common: name,,NO_SECT,0,0
331pub const N_ECOMM = 0xe4; /// end common: name,,n_sect,0,0
332pub const N_ECOML = 0xe8; /// end common (local name): 0,,n_sect,0,address
333pub const N_LENG = 0xfe; /// second stab entry with length information
557
558/// 24 section attributes
559pub const SECTION_ATTRIBUTES = 0xffffff00;
560
561/// regular section
562pub const S_REGULAR = 0x0;
563
564/// zero fill on demand section
565pub const S_ZEROFILL = 0x1;
566
567/// section with only literal C string
568pub const S_CSTRING_LITERALS = 0x2;
569
570/// section with only 4 byte literals
571pub const S_4BYTE_LITERALS = 0x3;
572
573/// section with only 8 byte literals
574pub const S_8BYTE_LITERALS = 0x4;
575
576/// section with only pointers to
577pub const S_LITERAL_POINTERS = 0x5;
578
579/// if any of these bits set, a symbolic debugging entry
580pub const N_STAB = 0xe0;
581
582/// private external symbol bit
583pub const N_PEXT = 0x10;
584
585/// mask for the type bits
586pub const N_TYPE = 0x0e;
587
588/// external symbol bit, set for external symbols
589pub const N_EXT = 0x01;
590
591/// global symbol: name,,NO_SECT,type,0
592pub const N_GSYM = 0x20;
593
594/// procedure name (f77 kludge): name,,NO_SECT,0,0
595pub const N_FNAME = 0x22;
596
597/// procedure: name,,n_sect,linenumber,address
598pub const N_FUN = 0x24;
599
600/// static symbol: name,,n_sect,type,address
601pub const N_STSYM = 0x26;
602
603/// .lcomm symbol: name,,n_sect,type,address
604pub const N_LCSYM = 0x28;
605
606/// begin nsect sym: 0,,n_sect,0,address
607pub const N_BNSYM = 0x2e;
608
609/// AST file path: name,,NO_SECT,0,0
610pub const N_AST = 0x32;
611
612/// emitted with gcc2_compiled and in gcc source
613pub const N_OPT = 0x3c;
614
615/// register sym: name,,NO_SECT,type,register
616pub const N_RSYM = 0x40;
617
618/// src line: 0,,n_sect,linenumber,address
619pub const N_SLINE = 0x44;
620
621/// end nsect sym: 0,,n_sect,0,address
622pub const N_ENSYM = 0x4e;
623
624/// structure elt: name,,NO_SECT,type,struct_offset
625pub const N_SSYM = 0x60;
626
627/// source file name: name,,n_sect,0,address
628pub const N_SO = 0x64;
629
630/// object file name: name,,0,0,st_mtime
631pub const N_OSO = 0x66;
632
633/// local sym: name,,NO_SECT,type,offset
634pub const N_LSYM = 0x80;
635
636/// include file beginning: name,,NO_SECT,0,sum
637pub const N_BINCL = 0x82;
638
639/// #included file name: name,,n_sect,0,address
640pub const N_SOL = 0x84;
641
642/// compiler parameters: name,,NO_SECT,0,0
643pub const N_PARAMS = 0x86;
644
645/// compiler version: name,,NO_SECT,0,0
646pub const N_VERSION = 0x88;
647
648/// compiler -O level: name,,NO_SECT,0,0
649pub const N_OLEVEL = 0x8A;
650
651/// parameter: name,,NO_SECT,type,offset
652pub const N_PSYM = 0xa0;
653
654/// include file end: name,,NO_SECT,0,0
655pub const N_EINCL = 0xa2;
656
657/// alternate entry: name,,n_sect,linenumber,address
658pub const N_ENTRY = 0xa4;
659
660/// left bracket: 0,,NO_SECT,nesting level,address
661pub const N_LBRAC = 0xc0;
662
663/// deleted include file: name,,NO_SECT,0,sum
664pub const N_EXCL = 0xc2;
665
666/// right bracket: 0,,NO_SECT,nesting level,address
667pub const N_RBRAC = 0xe0;
668
669/// begin common: name,,NO_SECT,0,0
670pub const N_BCOMM = 0xe2;
671
672/// end common: name,,n_sect,0,0
673pub const N_ECOMM = 0xe4;
674
675/// end common (local name): 0,,n_sect,0,address
676pub const N_ECOML = 0xe8;
677
678/// second stab entry with length information
679pub const N_LENG = 0xfe;
334680
335681/// If a segment contains any sections marked with S_ATTR_DEBUG then all
336682/// sections in that segment must have this attribute. No section other than
......@@ -339,10 +685,10 @@ pub const N_LENG = 0xfe; /// second stab entry with length information
339685/// a section type S_REGULAR. The static linker will not copy section contents
340686/// from sections with this attribute into its output file. These sections
341687/// generally contain DWARF debugging info.
342pub const S_ATTR_DEBUG = 0x02000000; /// a debug section
688/// a debug section
689pub const S_ATTR_DEBUG = 0x02000000;
343690
344691pub const cpu_type_t = integer_t;
345692pub const cpu_subtype_t = integer_t;
346693pub const integer_t = c_int;
347694pub const vm_prot_t = c_int;
348
std/os/windows/advapi32.zig+16-5
......@@ -23,11 +23,22 @@ pub extern "advapi32" stdcallcc fn CryptReleaseContext(hProv: HCRYPTPROV, dwFlag
2323
2424pub extern "advapi32" stdcallcc fn CryptGenRandom(hProv: HCRYPTPROV, dwLen: DWORD, pbBuffer: [*]BYTE) BOOL;
2525
26pub extern "advapi32" stdcallcc fn RegOpenKeyExW(hKey: HKEY, lpSubKey: LPCWSTR, ulOptions: DWORD, samDesired: REGSAM,
27 phkResult: &HKEY,) LSTATUS;
28
29pub extern "advapi32" stdcallcc fn RegQueryValueExW(hKey: HKEY, lpValueName: LPCWSTR, lpReserved: LPDWORD,
30 lpType: LPDWORD, lpData: LPBYTE, lpcbData: LPDWORD,) LSTATUS;
26pub extern "advapi32" stdcallcc fn RegOpenKeyExW(
27 hKey: HKEY,
28 lpSubKey: LPCWSTR,
29 ulOptions: DWORD,
30 samDesired: REGSAM,
31 phkResult: &HKEY,
32) LSTATUS;
33
34pub extern "advapi32" stdcallcc fn RegQueryValueExW(
35 hKey: HKEY,
36 lpValueName: LPCWSTR,
37 lpReserved: LPDWORD,
38 lpType: LPDWORD,
39 lpData: LPBYTE,
40 lpcbData: LPDWORD,
41) LSTATUS;
3142
3243// RtlGenRandom is known as SystemFunction036 under advapi32
3344// http://msdn.microsoft.com/en-us/library/windows/desktop/aa387694.aspx */
std/os/windows/index.zig+6-6
......@@ -288,27 +288,27 @@ pub const GUID = extern struct {
288288 assert(str[index] == '{');
289289 index += 1;
290290
291 guid.Data1 = std.fmt.parseUnsigned(c_ulong, str[index..index + 8], 16) catch unreachable;
291 guid.Data1 = std.fmt.parseUnsigned(c_ulong, str[index .. index + 8], 16) catch unreachable;
292292 index += 8;
293293
294294 assert(str[index] == '-');
295295 index += 1;
296296
297 guid.Data2 = std.fmt.parseUnsigned(c_ushort, str[index..index + 4], 16) catch unreachable;
297 guid.Data2 = std.fmt.parseUnsigned(c_ushort, str[index .. index + 4], 16) catch unreachable;
298298 index += 4;
299299
300300 assert(str[index] == '-');
301301 index += 1;
302302
303 guid.Data3 = std.fmt.parseUnsigned(c_ushort, str[index..index + 4], 16) catch unreachable;
303 guid.Data3 = std.fmt.parseUnsigned(c_ushort, str[index .. index + 4], 16) catch unreachable;
304304 index += 4;
305305
306306 assert(str[index] == '-');
307307 index += 1;
308308
309 guid.Data4[0] = std.fmt.parseUnsigned(u8, str[index..index + 2], 16) catch unreachable;
309 guid.Data4[0] = std.fmt.parseUnsigned(u8, str[index .. index + 2], 16) catch unreachable;
310310 index += 2;
311 guid.Data4[1] = std.fmt.parseUnsigned(u8, str[index..index + 2], 16) catch unreachable;
311 guid.Data4[1] = std.fmt.parseUnsigned(u8, str[index .. index + 2], 16) catch unreachable;
312312 index += 2;
313313
314314 assert(str[index] == '-');
......@@ -316,7 +316,7 @@ pub const GUID = extern struct {
316316
317317 var i: usize = 2;
318318 while (i < guid.Data4.len) : (i += 1) {
319 guid.Data4[i] = std.fmt.parseUnsigned(u8, str[index..index + 2], 16) catch unreachable;
319 guid.Data4[i] = std.fmt.parseUnsigned(u8, str[index .. index + 2], 16) catch unreachable;
320320 index += 2;
321321 }
322322
std/os/windows/ole32.zig-1
......@@ -5,7 +5,6 @@ pub extern "ole32.dll" stdcallcc fn CoUninitialize() void;
55pub extern "ole32.dll" stdcallcc fn CoGetCurrentProcess() DWORD;
66pub extern "ole32.dll" stdcallcc fn CoInitializeEx(pvReserved: LPVOID, dwCoInit: DWORD) HRESULT;
77
8
98pub const COINIT_APARTMENTTHREADED = COINIT.COINIT_APARTMENTTHREADED;
109pub const COINIT_MULTITHREADED = COINIT.COINIT_MULTITHREADED;
1110pub const COINIT_DISABLE_OLE1DDE = COINIT.COINIT_DISABLE_OLE1DDE;
std/os/zen.zig+24-25
......@@ -6,32 +6,32 @@ const assert = std.debug.assert;
66//////////////////////////
77
88pub const Message = struct {
9sender: MailboxId,
9 sender: MailboxId,
1010 receiver: MailboxId,
11 code: usize,
12 args: [5]usize,
13 payload: ?[]const u8,
11 code: usize,
12 args: [5]usize,
13 payload: ?[]const u8,
1414
1515 pub fn from(mailbox_id: *const MailboxId) Message {
16 return Message {
17 .sender = MailboxId.Undefined,
16 return Message{
17 .sender = MailboxId.Undefined,
1818 .receiver = mailbox_id.*,
19 .code = undefined,
20 .args = undefined,
21 .payload = null,
19 .code = undefined,
20 .args = undefined,
21 .payload = null,
2222 };
2323 }
2424
2525 pub fn to(mailbox_id: *const MailboxId, msg_code: usize, args: ...) Message {
26 var message = Message {
27 .sender = MailboxId.This,
26 var message = Message{
27 .sender = MailboxId.This,
2828 .receiver = mailbox_id.*,
29 .code = msg_code,
30 .args = undefined,
31 .payload = null,
29 .code = msg_code,
30 .args = undefined,
31 .payload = null,
3232 };
3333
34 assert (args.len <= message.args.len);
34 assert(args.len <= message.args.len);
3535 comptime var i = 0;
3636 inline while (i < args.len) : (i += 1) {
3737 message.args[i] = args[i];
......@@ -111,8 +111,7 @@ pub fn read(fd: i32, buf: [*]u8, count: usize) usize {
111111pub fn write(fd: i32, buf: [*]const u8, count: usize) usize {
112112 switch (fd) {
113113 STDOUT_FILENO, STDERR_FILENO => {
114 send(Message.to(Server.Terminal, 1)
115 .withPayload(buf[0..count]));
114 send(Message.to(Server.Terminal, 1).withPayload(buf[0..count]));
116115 },
117116 else => unreachable,
118117 }
......@@ -124,14 +123,14 @@ pub fn write(fd: i32, buf: [*]const u8, count: usize) usize {
124123///////////////////////////
125124
126125pub const Syscall = enum(usize) {
127 exit = 0,
128 send = 1,
129 receive = 2,
130 subscribeIRQ = 3,
131 inb = 4,
132 outb = 5,
133 map = 6,
134 createThread = 7,
126 exit = 0,
127 send = 1,
128 receive = 2,
129 subscribeIRQ = 3,
130 inb = 4,
131 outb = 5,
132 map = 6,
133 createThread = 7,
135134};
136135
137136////////////////////
std/rb.zig+15-13
......@@ -9,9 +9,7 @@ const Color = enum(u1) {
99const Red = Color.Red;
1010const Black = Color.Black;
1111
12const ReplaceError = error {
13 NotEqual,
14};
12const ReplaceError = error{NotEqual};
1513
1614/// Insert this into your struct that you want to add to a red-black tree.
1715/// Do not use a pointer. Turn the *rb.Node results of the functions in rb
......@@ -27,7 +25,9 @@ const ReplaceError = error {
2725pub const Node = struct {
2826 left: ?*Node,
2927 right: ?*Node,
30 parent_and_color: usize, /// parent | color
28
29 /// parent | color
30 parent_and_color: usize,
3131
3232 pub fn next(constnode: *Node) ?*Node {
3333 var node = constnode;
......@@ -130,7 +130,7 @@ pub const Node = struct {
130130
131131pub const Tree = struct {
132132 root: ?*Node,
133 compareFn: fn(*Node, *Node) mem.Compare,
133 compareFn: fn (*Node, *Node) mem.Compare,
134134
135135 /// If you have a need for a version that caches this, please file a bug.
136136 pub fn first(tree: *Tree) ?*Node {
......@@ -180,7 +180,7 @@ pub const Tree = struct {
180180 while (node.get_parent()) |*parent| {
181181 if (parent.*.is_black())
182182 break;
183 // the root is always black
183 // the root is always black
184184 var grandpa = parent.*.get_parent() orelse unreachable;
185185
186186 if (parent.* == grandpa.left) {
......@@ -206,7 +206,7 @@ pub const Tree = struct {
206206 }
207207 } else {
208208 var maybe_uncle = grandpa.left;
209
209
210210 if (maybe_uncle) |uncle| {
211211 if (uncle.is_black())
212212 break;
......@@ -259,7 +259,7 @@ pub const Tree = struct {
259259 if (node.left == null) {
260260 next = node.right.?; // Not both null as per above
261261 } else if (node.right == null) {
262 next = node.left.?; // Not both null as per above
262 next = node.left.?; // Not both null as per above
263263 } else
264264 next = node.right.?.get_first(); // Just checked for null above
265265
......@@ -313,7 +313,7 @@ pub const Tree = struct {
313313 var parent = maybe_parent.?;
314314 if (node == parent.left) {
315315 var sibling = parent.right.?; // Same number of black nodes.
316
316
317317 if (sibling.is_red()) {
318318 sibling.set_color(Black);
319319 parent.set_color(Red);
......@@ -321,7 +321,8 @@ pub const Tree = struct {
321321 sibling = parent.right.?; // Just rotated
322322 }
323323 if ((if (sibling.left) |n| n.is_black() else true) and
324 (if (sibling.right) |n| n.is_black() else true)) {
324 (if (sibling.right) |n| n.is_black() else true))
325 {
325326 sibling.set_color(Red);
326327 node = parent;
327328 maybe_parent = parent.get_parent();
......@@ -341,7 +342,7 @@ pub const Tree = struct {
341342 break;
342343 } else {
343344 var sibling = parent.left.?; // Same number of black nodes.
344
345
345346 if (sibling.is_red()) {
346347 sibling.set_color(Black);
347348 parent.set_color(Red);
......@@ -349,7 +350,8 @@ pub const Tree = struct {
349350 sibling = parent.left.?; // Just rotated
350351 }
351352 if ((if (sibling.left) |n| n.is_black() else true) and
352 (if (sibling.right) |n| n.is_black() else true)) {
353 (if (sibling.right) |n| n.is_black() else true))
354 {
353355 sibling.set_color(Red);
354356 node = parent;
355357 maybe_parent = parent.get_parent();
......@@ -397,7 +399,7 @@ pub const Tree = struct {
397399 new.* = old.*;
398400 }
399401
400 pub fn init(tree: *Tree, f: fn(*Node, *Node) mem.Compare) void {
402 pub fn init(tree: *Tree, f: fn (*Node, *Node) mem.Compare) void {
401403 tree.root = null;
402404 tree.compareFn = f;
403405 }