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 {...@@ -89,7 +89,7 @@ pub const Server = struct {
89 error.ProcessFdQuotaExceeded => {89 error.ProcessFdQuotaExceeded => {
90 errdefer std.os.emfile_promise_queue.remove(&self.waiting_for_emfile_node);90 errdefer std.os.emfile_promise_queue.remove(&self.waiting_for_emfile_node);
91 suspend {91 suspend {
92 self.waiting_for_emfile_node = PromiseNode.init( @handle() );92 self.waiting_for_emfile_node = PromiseNode.init(@handle());
93 std.os.emfile_promise_queue.append(&self.waiting_for_emfile_node);93 std.os.emfile_promise_queue.append(&self.waiting_for_emfile_node);
94 }94 }
95 continue;95 continue;
std/fmt/index.zig+21-25
...@@ -188,12 +188,12 @@ pub fn formatType(...@@ -188,12 +188,12 @@ pub fn formatType(
188 },188 },
189 builtin.TypeId.Union => {189 builtin.TypeId.Union => {
190 const info = @typeInfo(T).Union;190 const info = @typeInfo(T).Union;
191 if(info.tag_type) |UnionTagType| {191 if (info.tag_type) |UnionTagType| {
192 try output(context, "{ .");192 try output(context, "{ .");
193 try output(context, @tagName(UnionTagType(value)));193 try output(context, @tagName(UnionTagType(value)));
194 try output(context, " = ");194 try output(context, " = ");
195 inline for(info.fields) |u_field| {195 inline for (info.fields) |u_field| {
196 if(@enumToInt(UnionTagType(value)) == u_field.enum_field.?.value) {196 if (@enumToInt(UnionTagType(value)) == u_field.enum_field.?.value) {
197 try formatType(@field(value, u_field.name), "", context, Errors, output);197 try formatType(@field(value, u_field.name), "", context, Errors, output);
198 }198 }
199 }199 }
...@@ -1221,58 +1221,54 @@ test "fmt.format" {...@@ -1221,58 +1221,54 @@ test "fmt.format" {
1221 a: u32,1221 a: u32,
1222 b: error,1222 b: error,
1223 };1223 };
1224 1224
1225 const inst = S {1225 const inst = S{
1226 .a = 456,1226 .a = 456,
1227 .b = error.Unused,1227 .b = error.Unused,
1228 };1228 };
1229 1229
1230 try testFmt("S{ .a = 456, .b = error.Unused }", "{}", inst);1230 try testFmt("S{ .a = 456, .b = error.Unused }", "{}", inst);
1231 }1231 }
1232 //union format1232 //union format
1233 {1233 {
1234 const TU = union(enum)1234 const TU = union(enum) {
1235 {
1236 float: f32,1235 float: f32,
1237 int: u32,1236 int: u32,
1238 };1237 };
1239 1238
1240 const UU = union1239 const UU = union {
1241 {
1242 float: f32,1240 float: f32,
1243 int: u32,1241 int: u32,
1244 };1242 };
1245 1243
1246 const EU = extern union1244 const EU = extern union {
1247 {
1248 float: f32,1245 float: f32,
1249 int: u32,1246 int: u32,
1250 };1247 };
1251 1248
1252 const tu_inst = TU{ .int = 123, };1249 const tu_inst = TU{ .int = 123 };
1253 const uu_inst = UU{ .int = 456, };1250 const uu_inst = UU{ .int = 456 };
1254 const eu_inst = EU{ .float = 321.123, };1251 const eu_inst = EU{ .float = 321.123 };
1255 1252
1256 try testFmt("TU{ .int = 123 }", "{}", tu_inst);1253 try testFmt("TU{ .int = 123 }", "{}", tu_inst);
1257 1254
1258 var buf: [100]u8 = undefined;1255 var buf: [100]u8 = undefined;
1259 const uu_result = try bufPrint(buf[0..], "{}", uu_inst);1256 const uu_result = try bufPrint(buf[0..], "{}", uu_inst);
1260 debug.assert(mem.eql(u8, uu_result[0..3], "UU@"));1257 debug.assert(mem.eql(u8, uu_result[0..3], "UU@"));
1261 1258
1262 const eu_result = try bufPrint(buf[0..], "{}", eu_inst);1259 const eu_result = try bufPrint(buf[0..], "{}", eu_inst);
1263 debug.assert(mem.eql(u8, uu_result[0..3], "EU@"));1260 debug.assert(mem.eql(u8, uu_result[0..3], "EU@"));
1264 }1261 }
1265 //enum format1262 //enum format
1266 {1263 {
1267 const E = enum1264 const E = enum {
1268 {
1269 One,1265 One,
1270 Two,1266 Two,
1271 Three,1267 Three,
1272 };1268 };
1273 1269
1274 const inst = E.Two;1270 const inst = E.Two;
1275 1271
1276 try testFmt("E.Two", "{}", inst);1272 try testFmt("E.Two", "{}", inst);
1277 }1273 }
1278}1274}
std/macho.zig+552-206
...@@ -1,4 +1,3 @@...@@ -1,4 +1,3 @@
1
2pub const mach_header = extern struct {1pub const mach_header = extern struct {
3 magic: u32,2 magic: u32,
4 cputype: cpu_type_t,3 cputype: cpu_type_t,
...@@ -25,26 +24,43 @@ pub const load_command = extern struct {...@@ -25,26 +24,43 @@ pub const load_command = extern struct {
25 cmdsize: u32,24 cmdsize: u32,
26};25};
2726
28
29/// The symtab_command contains the offsets and sizes of the link-edit 4.3BSD27/// The symtab_command contains the offsets and sizes of the link-edit 4.3BSD
30/// "stab" style symbol table information as described in the header files28/// "stab" style symbol table information as described in the header files
31/// <nlist.h> and <stab.h>.29/// <nlist.h> and <stab.h>.
32pub const symtab_command = extern struct {30pub const symtab_command = extern struct {
33 cmd: u32, /// LC_SYMTAB31 /// LC_SYMTAB
34 cmdsize: u32, /// sizeof(struct symtab_command)32 cmd: u32,
35 symoff: u32, /// symbol table offset33
36 nsyms: u32, /// number of symbol table entries34 /// sizeof(struct symtab_command)
37 stroff: u32, /// string table offset35 cmdsize: u32,
38 strsize: u32, /// string table size in bytes36
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,
39};48};
4049
41/// The linkedit_data_command contains the offsets and sizes of a blob50/// 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.
43const linkedit_data_command = extern struct {52const 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.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.
45 cmdsize: u32, /// sizeof(struct linkedit_data_command)54 cmd: u32,
46 dataoff: u32 , /// file offset of data in __LINKEDIT segment55
47 datasize: u32 , /// file size of data in __LINKEDIT segment 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,
48};64};
4965
50/// The segment load command indicates that a part of this file is to be66/// The segment load command indicates that a part of this file is to be
...@@ -58,16 +74,35 @@ const linkedit_data_command = extern struct {...@@ -58,16 +74,35 @@ const linkedit_data_command = extern struct {
58/// section structures directly follow the segment command and their size is74/// section structures directly follow the segment command and their size is
59/// reflected in cmdsize.75/// reflected in cmdsize.
60pub const segment_command = extern struct {76pub const segment_command = extern struct {
61 cmd: u32,/// LC_SEGMENT77 /// LC_SEGMENT
62 cmdsize: u32,/// includes sizeof section structs78 cmd: u32,
63 segname: [16]u8,/// segment name79
64 vmaddr: u32,/// memory address of this segment80 /// includes sizeof section structs
65 vmsize: u32,/// memory size of this segment81 cmdsize: u32,
66 fileoff: u32,/// file offset of this segment82
67 filesize: u32,/// amount to map from the file83 /// segment name
68 maxprot: vm_prot_t,/// maximum VM protection84 segname: [16]u8,
69 initprot: vm_prot_t,/// initial VM protection85
70 nsects: u32,/// number of sections in segment86 /// 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,
71 flags: u32,106 flags: u32,
72};107};
73108
...@@ -76,17 +111,36 @@ pub const segment_command = extern struct {...@@ -76,17 +111,36 @@ pub const segment_command = extern struct {
76/// sections then section_64 structures directly follow the 64-bit segment111/// sections then section_64 structures directly follow the 64-bit segment
77/// command and their size is reflected in cmdsize.112/// command and their size is reflected in cmdsize.
78pub const segment_command_64 = extern struct {113pub const segment_command_64 = extern struct {
79 cmd: u32, /// LC_SEGMENT_64114 /// LC_SEGMENT_64
80 cmdsize: u32, /// includes sizeof section_64 structs115 cmd: u32,
81 segname: [16]u8, /// segment name116
82 vmaddr: u64, /// memory address of this segment117 /// includes sizeof section_64 structs
83 vmsize: u64, /// memory size of this segment118 cmdsize: u32,
84 fileoff: u64, /// file offset of this segment119
85 filesize: u64, /// amount to map from the file120 /// segment name
86 maxprot: vm_prot_t, /// maximum VM protection121 segname: [16]u8,
87 initprot: vm_prot_t, /// initial VM protection122
88 nsects: u32, /// number of sections in segment123 /// memory address of this segment
89 flags: u32, 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,
90};144};
91145
92/// A segment is made up of zero or more sections. Non-MH_OBJECT files have146/// 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 {...@@ -115,32 +169,76 @@ pub const segment_command_64 = extern struct {
115/// fields of the section structure for mach object files is described in the169/// fields of the section structure for mach object files is described in the
116/// header file <reloc.h>.170/// header file <reloc.h>.
117pub const @"section" = extern struct {171pub const @"section" = extern struct {
118 sectname: [16]u8, /// name of this section172 /// name of this section
119 segname: [16]u8, /// segment this section goes in173 sectname: [16]u8,
120 addr: u32, /// memory address of this section174
121 size: u32, /// size in bytes of this section175 /// segment this section goes in
122 offset: u32, /// file offset of this section176 segname: [16]u8,
123 @"align": u32, /// section alignment (power of 2)177
124 reloff: u32, /// file offset of relocation entries178 /// memory address of this section
125 nreloc: u32, /// number of relocation entries179 addr: u32,
126 flags: u32, /// flags (section type and attributes180
127 reserved1: u32, /// reserved (for offset or index)181 /// size in bytes of this section
128 reserved2: u32, /// reserved (for count or sizeof)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,
129};204};
130205
131pub const section_64 = extern struct {206pub const section_64 = extern struct {
132 sectname: [16]u8, /// name of this section207 /// name of this section
133 segname: [16]u8, /// segment this section goes in208 sectname: [16]u8,
134 addr: u64, /// memory address of this section209
135 size: u64, /// size in bytes of this section210 /// segment this section goes in
136 offset: u32, /// file offset of this section211 segname: [16]u8,
137 @"align": u32, /// section alignment (power of 2)212
138 reloff: u32, /// file offset of relocation entries213 /// memory address of this section
139 nreloc: u32, /// number of relocation entries214 addr: u64,
140 flags: u32, /// flags (section type and attributes215
141 reserved1: u32, /// reserved (for offset or index)216 /// size in bytes of this section
142 reserved2: u32, /// reserved (for count or sizeof)217 size: u64,
143 reserved3: u32, /// reserved218
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,
144};242};
145243
146pub const nlist = extern struct {244pub const nlist = extern struct {
...@@ -168,116 +266,287 @@ pub const nlist_64 = extern struct {...@@ -168,116 +266,287 @@ pub const nlist_64 = extern struct {
168/// simply be ignored.266/// simply be ignored.
169pub const LC_REQ_DYLD = 0x80000000;267pub const LC_REQ_DYLD = 0x80000000;
170268
171pub const LC_SEGMENT = 0x1; /// segment of this file to be mapped269/// segment of this file to be mapped
172pub const LC_SYMTAB = 0x2; /// link-edit stab symbol table info270pub const LC_SEGMENT = 0x1;
173pub const LC_SYMSEG = 0x3; /// link-edit gdb symbol table info (obsolete)271
174pub const LC_THREAD = 0x4; /// thread272/// link-edit stab symbol table info
175pub const LC_UNIXTHREAD = 0x5; /// unix thread (includes a stack)273pub const LC_SYMTAB = 0x2;
176pub const LC_LOADFVMLIB = 0x6; /// load a specified fixed VM shared library274
177pub const LC_IDFVMLIB = 0x7; /// fixed VM shared library identification275/// link-edit gdb symbol table info (obsolete)
178pub const LC_IDENT = 0x8; /// object identification info (obsolete)276pub const LC_SYMSEG = 0x3;
179pub const LC_FVMFILE = 0x9; /// fixed VM file inclusion (internal use)277
180pub const LC_PREPAGE = 0xa; /// prepage command (internal use)278/// thread
181pub const LC_DYSYMTAB = 0xb; /// dynamic link-edit symbol table info279pub const LC_THREAD = 0x4;
182pub const LC_LOAD_DYLIB = 0xc; /// load a dynamically linked shared library280
183pub const LC_ID_DYLIB = 0xd; /// dynamically linked shared lib ident281/// unix thread (includes a stack)
184pub const LC_LOAD_DYLINKER = 0xe; /// load a dynamic linker282pub const LC_UNIXTHREAD = 0x5;
185pub const LC_ID_DYLINKER = 0xf; /// dynamic linker identification283
186pub const LC_PREBOUND_DYLIB = 0x10; /// modules prebound for a dynamically284/// load a specified fixed VM shared library
187pub const LC_ROUTINES = 0x11; /// image routines285pub const LC_LOADFVMLIB = 0x6;
188pub const LC_SUB_FRAMEWORK = 0x12; /// sub framework286
189pub const LC_SUB_UMBRELLA = 0x13; /// sub umbrella287/// fixed VM shared library identification
190pub const LC_SUB_CLIENT = 0x14; /// sub client288pub const LC_IDFVMLIB = 0x7;
191pub const LC_SUB_LIBRARY = 0x15; /// sub library289
192pub const LC_TWOLEVEL_HINTS = 0x16; /// two-level namespace lookup hints290/// object identification info (obsolete)
193pub const LC_PREBIND_CKSUM = 0x17; /// prebind checksum291pub 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
195/// load a dynamically linked shared library that is allowed to be missing338/// load a dynamically linked shared library that is allowed to be missing
196/// (all symbols are weak imported).339/// (all symbols are weak imported).
197pub const LC_LOAD_WEAK_DYLIB = (0x18 | LC_REQ_DYLD);340pub const LC_LOAD_WEAK_DYLIB = (0x18 | LC_REQ_DYLD);
198341
199pub const LC_SEGMENT_64 = 0x19; /// 64-bit segment of this file to be mapped342/// 64-bit segment of this file to be mapped
200pub const LC_ROUTINES_64 = 0x1a; /// 64-bit image routines343pub const LC_SEGMENT_64 = 0x19;
201pub const LC_UUID = 0x1b; /// the uuid344
202pub const LC_RPATH = (0x1c | LC_REQ_DYLD); /// runpath additions345/// 64-bit image routines
203pub const LC_CODE_SIGNATURE = 0x1d; /// local of code signature346pub const LC_ROUTINES_64 = 0x1a;
204pub const LC_SEGMENT_SPLIT_INFO = 0x1e; /// local of info to split segments347
205pub const LC_REEXPORT_DYLIB = (0x1f | LC_REQ_DYLD); /// load and re-export dylib348/// the uuid
206pub const LC_LAZY_LOAD_DYLIB = 0x20; /// delay load of dylib until first use349pub const LC_UUID = 0x1b;
207pub const LC_ENCRYPTION_INFO = 0x21; /// encrypted segment information350
208pub const LC_DYLD_INFO = 0x22; /// compressed dyld information351/// runpath additions
209pub const LC_DYLD_INFO_ONLY = (0x22|LC_REQ_DYLD); /// compressed dyld information only352pub const LC_RPATH = (0x1c | LC_REQ_DYLD);
210pub const LC_LOAD_UPWARD_DYLIB = (0x23 | LC_REQ_DYLD); /// load upward dylib353
211pub const LC_VERSION_MIN_MACOSX = 0x24; /// build for MacOSX min OS version354/// local of code signature
212pub const LC_VERSION_MIN_IPHONEOS = 0x25; /// build for iPhoneOS min OS version355pub const LC_CODE_SIGNATURE = 0x1d;
213pub const LC_FUNCTION_STARTS = 0x26; /// compressed table of function start addresses356
214pub const LC_DYLD_ENVIRONMENT = 0x27; /// string for dyld to treat like environment variable357/// local of info to split segments
215pub const LC_MAIN = (0x28|LC_REQ_DYLD); /// replacement for LC_UNIXTHREAD358pub const LC_SEGMENT_SPLIT_INFO = 0x1e;
216pub const LC_DATA_IN_CODE = 0x29; /// table of non-instructions in __text359
217pub const LC_SOURCE_VERSION = 0x2A; /// source version used to build binary360/// load and re-export dylib
218pub const LC_DYLIB_CODE_SIGN_DRS = 0x2B; /// Code signing DRs copied from linked dylibs361pub const LC_REEXPORT_DYLIB = (0x1f | LC_REQ_DYLD);
219pub const LC_ENCRYPTION_INFO_64 = 0x2C; /// 64-bit encrypted segment information362
220pub const LC_LINKER_OPTION = 0x2D; /// linker options in MH_OBJECT files363/// delay load of dylib until first use
221pub const LC_LINKER_OPTIMIZATION_HINT = 0x2E; /// optimization hints in MH_OBJECT files364pub const LC_LAZY_LOAD_DYLIB = 0x20;
222pub const LC_VERSION_MIN_TVOS = 0x2F; /// build for AppleTV min OS version365
223pub const LC_VERSION_MIN_WATCHOS = 0x30; /// build for Watch min OS version366/// encrypted segment information
224pub const LC_NOTE = 0x31; /// arbitrary data included within a Mach-O file367pub const LC_ENCRYPTION_INFO = 0x21;
225pub const LC_BUILD_VERSION = 0x32; /// build for platform min OS version368
226369/// compressed dyld information
227pub const MH_MAGIC = 0xfeedface; /// the mach magic number370pub const LC_DYLD_INFO = 0x22;
228pub const MH_CIGAM = 0xcefaedfe; /// NXSwapInt(MH_MAGIC)371
229372/// compressed dyld information only
230pub const MH_MAGIC_64 = 0xfeedfacf; /// the 64-bit mach magic number373pub const LC_DYLD_INFO_ONLY = (0x22 | LC_REQ_DYLD);
231pub const MH_CIGAM_64 = 0xcffaedfe; /// NXSwapInt(MH_MAGIC_64)374
232375/// load upward dylib
233pub const MH_OBJECT = 0x1; /// relocatable object file376pub const LC_LOAD_UPWARD_DYLIB = (0x23 | LC_REQ_DYLD);
234pub const MH_EXECUTE = 0x2; /// demand paged executable file377
235pub const MH_FVMLIB = 0x3; /// fixed VM shared library file378/// build for MacOSX min OS version
236pub const MH_CORE = 0x4; /// core file379pub const LC_VERSION_MIN_MACOSX = 0x24;
237pub const MH_PRELOAD = 0x5; /// preloaded executable file380
238pub const MH_DYLIB = 0x6; /// dynamically bound shared library381/// build for iPhoneOS min OS version
239pub const MH_DYLINKER = 0x7; /// dynamic link editor382pub const LC_VERSION_MIN_IPHONEOS = 0x25;
240pub const MH_BUNDLE = 0x8; /// dynamically bound bundle file383
241pub const MH_DYLIB_STUB = 0x9; /// shared library stub for static linking only, no section contents384/// compressed table of function start addresses
242pub const MH_DSYM = 0xa; /// companion file with only debug sections385pub const LC_FUNCTION_STARTS = 0x26;
243pub const MH_KEXT_BUNDLE = 0xb; /// x86_64 kexts386
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
245// Constants for the flags field of the mach_header468// Constants for the flags field of the mach_header
246469
247pub const MH_NOUNDEFS = 0x1; /// the object file has no undefined references470/// 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 again471pub const MH_NOUNDEFS = 0x1;
249pub const MH_DYLDLINK = 0x4; /// the object file is input for the dynamic linker and can't be staticly link edited again472
250pub const MH_BINDATLOAD = 0x8; /// the object file's undefined references are bound by the dynamic linker when loaded.473/// the object file is the output of an incremental link against a base file and can't be link edited again
251pub const MH_PREBOUND = 0x10; /// the file has its dynamic undefined references prebound.474pub const MH_INCRLINK = 0x2;
252pub const MH_SPLIT_SEGS = 0x20; /// the file has its read-only and read-write segments split475
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)476/// the object file is input for the dynamic linker and can't be staticly link edited again
254pub const MH_TWOLEVEL = 0x80; /// the image is using two-level name space bindings477pub const MH_DYLDLINK = 0x4;
255pub const MH_FORCE_FLAT = 0x100; /// the executable is forcing all images to use flat name space bindings478
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.479/// the object file's undefined references are bound by the dynamic linker when loaded.
257pub const MH_NOFIXPREBINDING = 0x400; /// do not have dyld notify the prebinding agent about this executable480pub const MH_BINDATLOAD = 0x8;
258pub const MH_PREBINDABLE = 0x800; /// the binary is not prebound but can have its prebinding redone. only used when MH_PREBOUND is not set.481
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. 482/// the file has its dynamic undefined references prebound.
260pub const MH_SUBSECTIONS_VIA_SYMBOLS = 0x2000;/// safe to divide up the sections into sub-sections via symbols for dead code stripping483pub const MH_PREBOUND = 0x10;
261pub const MH_CANONICAL = 0x4000; /// the binary has been canonicalized via the unprebind operation484
262pub const MH_WEAK_DEFINES = 0x8000; /// the final linked image contains external weak symbols485/// the file has its read-only and read-write segments split
263pub const MH_BINDS_TO_WEAK = 0x10000; /// the final linked image uses weak symbols486pub const MH_SPLIT_SEGS = 0x20;
264487
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.488/// the shared library init routine is to be run lazily via catching memory faults to its writeable segments (obsolete)
266pub const MH_ROOT_SAFE = 0x40000; /// When this bit is set, the binary declares it is safe for use in processes with uid zero489pub const MH_LAZY_INIT = 0x40;
267 490
268pub const MH_SETUID_SAFE = 0x80000; /// When this bit is set, the binary declares it is safe for use in processes when issetugid() is true491/// the image is using two-level name space bindings
269492pub const MH_TWOLEVEL = 0x80;
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-exported493
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.494/// the executable is forcing all images to use flat name space bindings
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.495pub const MH_FORCE_FLAT = 0x100;
273pub const MH_HAS_TLV_DESCRIPTORS = 0x800000; /// Contains a section of type S_THREAD_LOCAL_VARIABLES496
274497/// this umbrella guarantees no multiple defintions of symbols in its sub-images so the two-level namespace hints can always be used.
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.498pub const MH_NOMULTIDEFS = 0x200;
276499
277pub const MH_APP_EXTENSION_SAFE = 0x02000000; /// The code was linked for use in an application extension.500/// do not have dyld notify the prebinding agent about this executable
278501pub const MH_NOFIXPREBINDING = 0x400;
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.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
282/// The flags field of a section structure is separated into two parts a section551/// The flags field of a section structure is separated into two parts a section
283/// type and section attributes. The section types are mutually exclusive (it552/// 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...@@ -285,52 +554,129 @@ pub const MH_NLIST_OUTOFSYNC_WITH_DYLDINFO = 0x04000000; /// The external symbol
285/// than one attribute).554/// than one attribute).
286/// 256 section types555/// 256 section types
287pub const SECTION_TYPE = 0x000000ff;556pub const SECTION_TYPE = 0x000000ff;
288pub const SECTION_ATTRIBUTES = 0xffffff00; /// 24 section attributes557
289558/// 24 section attributes
290pub const S_REGULAR = 0x0; /// regular section559pub const SECTION_ATTRIBUTES = 0xffffff00;
291pub const S_ZEROFILL = 0x1; /// zero fill on demand section560
292pub const S_CSTRING_LITERALS = 0x2; /// section with only literal C string561/// regular section
293pub const S_4BYTE_LITERALS = 0x3; /// section with only 4 byte literals562pub const S_REGULAR = 0x0;
294pub const S_8BYTE_LITERALS = 0x4; /// section with only 8 byte literals563
295pub const S_LITERAL_POINTERS = 0x5; /// section with only pointers to564/// zero fill on demand section
296565pub const S_ZEROFILL = 0x1;
297566
298pub const N_STAB = 0xe0; /// if any of these bits set, a symbolic debugging entry567/// section with only literal C string
299pub const N_PEXT = 0x10; /// private external symbol bit568pub const S_CSTRING_LITERALS = 0x2;
300pub const N_TYPE = 0x0e; /// mask for the type bits569
301pub const N_EXT = 0x01; /// external symbol bit, set for external symbols570/// section with only 4 byte literals
302571pub const S_4BYTE_LITERALS = 0x3;
303572
304pub const N_GSYM = 0x20; /// global symbol: name,,NO_SECT,type,0573/// section with only 8 byte literals
305pub const N_FNAME = 0x22; /// procedure name (f77 kludge): name,,NO_SECT,0,0574pub const S_8BYTE_LITERALS = 0x4;
306pub const N_FUN = 0x24; /// procedure: name,,n_sect,linenumber,address575
307pub const N_STSYM = 0x26; /// static symbol: name,,n_sect,type,address576/// section with only pointers to
308pub const N_LCSYM = 0x28; /// .lcomm symbol: name,,n_sect,type,address577pub const S_LITERAL_POINTERS = 0x5;
309pub const N_BNSYM = 0x2e; /// begin nsect sym: 0,,n_sect,0,address578
310pub const N_AST = 0x32; /// AST file path: name,,NO_SECT,0,0579/// if any of these bits set, a symbolic debugging entry
311pub const N_OPT = 0x3c; /// emitted with gcc2_compiled and in gcc source580pub const N_STAB = 0xe0;
312pub const N_RSYM = 0x40; /// register sym: name,,NO_SECT,type,register581
313pub const N_SLINE = 0x44; /// src line: 0,,n_sect,linenumber,address582/// private external symbol bit
314pub const N_ENSYM = 0x4e; /// end nsect sym: 0,,n_sect,0,address583pub const N_PEXT = 0x10;
315pub const N_SSYM = 0x60; /// structure elt: name,,NO_SECT,type,struct_offset584
316pub const N_SO = 0x64; /// source file name: name,,n_sect,0,address585/// mask for the type bits
317pub const N_OSO = 0x66; /// object file name: name,,0,0,st_mtime586pub const N_TYPE = 0x0e;
318pub const N_LSYM = 0x80; /// local sym: name,,NO_SECT,type,offset587
319pub const N_BINCL = 0x82; /// include file beginning: name,,NO_SECT,0,sum588/// external symbol bit, set for external symbols
320pub const N_SOL = 0x84; /// #included file name: name,,n_sect,0,address589pub const N_EXT = 0x01;
321pub const N_PARAMS = 0x86; /// compiler parameters: name,,NO_SECT,0,0590
322pub const N_VERSION = 0x88; /// compiler version: name,,NO_SECT,0,0591/// global symbol: name,,NO_SECT,type,0
323pub const N_OLEVEL = 0x8A; /// compiler -O level: name,,NO_SECT,0,0592pub const N_GSYM = 0x20;
324pub const N_PSYM = 0xa0; /// parameter: name,,NO_SECT,type,offset593
325pub const N_EINCL = 0xa2; /// include file end: name,,NO_SECT,0,0594/// procedure name (f77 kludge): name,,NO_SECT,0,0
326pub const N_ENTRY = 0xa4; /// alternate entry: name,,n_sect,linenumber,address595pub const N_FNAME = 0x22;
327pub const N_LBRAC = 0xc0; /// left bracket: 0,,NO_SECT,nesting level,address596
328pub const N_EXCL = 0xc2; /// deleted include file: name,,NO_SECT,0,sum597/// procedure: name,,n_sect,linenumber,address
329pub const N_RBRAC = 0xe0; /// right bracket: 0,,NO_SECT,nesting level,address598pub const N_FUN = 0x24;
330pub const N_BCOMM = 0xe2; /// begin common: name,,NO_SECT,0,0599
331pub const N_ECOMM = 0xe4; /// end common: name,,n_sect,0,0600/// static symbol: name,,n_sect,type,address
332pub const N_ECOML = 0xe8; /// end common (local name): 0,,n_sect,0,address601pub const N_STSYM = 0x26;
333pub const N_LENG = 0xfe; /// second stab entry with length information602
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
335/// If a segment contains any sections marked with S_ATTR_DEBUG then all681/// If a segment contains any sections marked with S_ATTR_DEBUG then all
336/// sections in that segment must have this attribute. No section other than682/// 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...@@ -339,10 +685,10 @@ pub const N_LENG = 0xfe; /// second stab entry with length information
339/// a section type S_REGULAR. The static linker will not copy section contents685/// a section type S_REGULAR. The static linker will not copy section contents
340/// from sections with this attribute into its output file. These sections686/// from sections with this attribute into its output file. These sections
341/// generally contain DWARF debugging info.687/// generally contain DWARF debugging info.
342pub const S_ATTR_DEBUG = 0x02000000; /// a debug section688/// a debug section
689pub const S_ATTR_DEBUG = 0x02000000;
343690
344pub const cpu_type_t = integer_t;691pub const cpu_type_t = integer_t;
345pub const cpu_subtype_t = integer_t;692pub const cpu_subtype_t = integer_t;
346pub const integer_t = c_int;693pub const integer_t = c_int;
347pub const vm_prot_t = c_int;694pub 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...@@ -23,11 +23,22 @@ pub extern "advapi32" stdcallcc fn CryptReleaseContext(hProv: HCRYPTPROV, dwFlag
2323
24pub extern "advapi32" stdcallcc fn CryptGenRandom(hProv: HCRYPTPROV, dwLen: DWORD, pbBuffer: [*]BYTE) BOOL;24pub 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,26pub extern "advapi32" stdcallcc fn RegOpenKeyExW(
27 phkResult: &HKEY,) LSTATUS;27 hKey: HKEY,
2828 lpSubKey: LPCWSTR,
29pub extern "advapi32" stdcallcc fn RegQueryValueExW(hKey: HKEY, lpValueName: LPCWSTR, lpReserved: LPDWORD,29 ulOptions: DWORD,
30 lpType: LPDWORD, lpData: LPBYTE, lpcbData: LPDWORD,) LSTATUS;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
32// RtlGenRandom is known as SystemFunction036 under advapi3243// RtlGenRandom is known as SystemFunction036 under advapi32
33// http://msdn.microsoft.com/en-us/library/windows/desktop/aa387694.aspx */44// 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 {...@@ -288,27 +288,27 @@ pub const GUID = extern struct {
288 assert(str[index] == '{');288 assert(str[index] == '{');
289 index += 1;289 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;
292 index += 8;292 index += 8;
293293
294 assert(str[index] == '-');294 assert(str[index] == '-');
295 index += 1;295 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;
298 index += 4;298 index += 4;
299299
300 assert(str[index] == '-');300 assert(str[index] == '-');
301 index += 1;301 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;
304 index += 4;304 index += 4;
305305
306 assert(str[index] == '-');306 assert(str[index] == '-');
307 index += 1;307 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;
310 index += 2;310 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;
312 index += 2;312 index += 2;
313313
314 assert(str[index] == '-');314 assert(str[index] == '-');
...@@ -316,7 +316,7 @@ pub const GUID = extern struct {...@@ -316,7 +316,7 @@ pub const GUID = extern struct {
316316
317 var i: usize = 2;317 var i: usize = 2;
318 while (i < guid.Data4.len) : (i += 1) {318 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;
320 index += 2;320 index += 2;
321 }321 }
322322
std/os/windows/ole32.zig-1
...@@ -5,7 +5,6 @@ pub extern "ole32.dll" stdcallcc fn CoUninitialize() void;...@@ -5,7 +5,6 @@ pub extern "ole32.dll" stdcallcc fn CoUninitialize() void;
5pub extern "ole32.dll" stdcallcc fn CoGetCurrentProcess() DWORD;5pub extern "ole32.dll" stdcallcc fn CoGetCurrentProcess() DWORD;
6pub extern "ole32.dll" stdcallcc fn CoInitializeEx(pvReserved: LPVOID, dwCoInit: DWORD) HRESULT;6pub extern "ole32.dll" stdcallcc fn CoInitializeEx(pvReserved: LPVOID, dwCoInit: DWORD) HRESULT;
77
8
9pub const COINIT_APARTMENTTHREADED = COINIT.COINIT_APARTMENTTHREADED;8pub const COINIT_APARTMENTTHREADED = COINIT.COINIT_APARTMENTTHREADED;
10pub const COINIT_MULTITHREADED = COINIT.COINIT_MULTITHREADED;9pub const COINIT_MULTITHREADED = COINIT.COINIT_MULTITHREADED;
11pub const COINIT_DISABLE_OLE1DDE = COINIT.COINIT_DISABLE_OLE1DDE;10pub const COINIT_DISABLE_OLE1DDE = COINIT.COINIT_DISABLE_OLE1DDE;
std/os/zen.zig+24-25
...@@ -6,32 +6,32 @@ const assert = std.debug.assert;...@@ -6,32 +6,32 @@ const assert = std.debug.assert;
6//////////////////////////6//////////////////////////
77
8pub const Message = struct {8pub const Message = struct {
9sender: MailboxId,9 sender: MailboxId,
10 receiver: MailboxId,10 receiver: MailboxId,
11 code: usize,11 code: usize,
12 args: [5]usize,12 args: [5]usize,
13 payload: ?[]const u8,13 payload: ?[]const u8,
1414
15 pub fn from(mailbox_id: *const MailboxId) Message {15 pub fn from(mailbox_id: *const MailboxId) Message {
16 return Message {16 return Message{
17 .sender = MailboxId.Undefined,17 .sender = MailboxId.Undefined,
18 .receiver = mailbox_id.*,18 .receiver = mailbox_id.*,
19 .code = undefined,19 .code = undefined,
20 .args = undefined,20 .args = undefined,
21 .payload = null,21 .payload = null,
22 };22 };
23 }23 }
2424
25 pub fn to(mailbox_id: *const MailboxId, msg_code: usize, args: ...) Message {25 pub fn to(mailbox_id: *const MailboxId, msg_code: usize, args: ...) Message {
26 var message = Message {26 var message = Message{
27 .sender = MailboxId.This,27 .sender = MailboxId.This,
28 .receiver = mailbox_id.*,28 .receiver = mailbox_id.*,
29 .code = msg_code,29 .code = msg_code,
30 .args = undefined,30 .args = undefined,
31 .payload = null,31 .payload = null,
32 };32 };
3333
34 assert (args.len <= message.args.len);34 assert(args.len <= message.args.len);
35 comptime var i = 0;35 comptime var i = 0;
36 inline while (i < args.len) : (i += 1) {36 inline while (i < args.len) : (i += 1) {
37 message.args[i] = args[i];37 message.args[i] = args[i];
...@@ -111,8 +111,7 @@ pub fn read(fd: i32, buf: [*]u8, count: usize) usize {...@@ -111,8 +111,7 @@ pub fn read(fd: i32, buf: [*]u8, count: usize) usize {
111pub fn write(fd: i32, buf: [*]const u8, count: usize) usize {111pub fn write(fd: i32, buf: [*]const u8, count: usize) usize {
112 switch (fd) {112 switch (fd) {
113 STDOUT_FILENO, STDERR_FILENO => {113 STDOUT_FILENO, STDERR_FILENO => {
114 send(Message.to(Server.Terminal, 1)114 send(Message.to(Server.Terminal, 1).withPayload(buf[0..count]));
115 .withPayload(buf[0..count]));
116 },115 },
117 else => unreachable,116 else => unreachable,
118 }117 }
...@@ -124,14 +123,14 @@ pub fn write(fd: i32, buf: [*]const u8, count: usize) usize {...@@ -124,14 +123,14 @@ pub fn write(fd: i32, buf: [*]const u8, count: usize) usize {
124///////////////////////////123///////////////////////////
125124
126pub const Syscall = enum(usize) {125pub const Syscall = enum(usize) {
127 exit = 0,126 exit = 0,
128 send = 1,127 send = 1,
129 receive = 2,128 receive = 2,
130 subscribeIRQ = 3,129 subscribeIRQ = 3,
131 inb = 4,130 inb = 4,
132 outb = 5,131 outb = 5,
133 map = 6,132 map = 6,
134 createThread = 7,133 createThread = 7,
135};134};
136135
137////////////////////136////////////////////
std/rb.zig+15-13
...@@ -9,9 +9,7 @@ const Color = enum(u1) {...@@ -9,9 +9,7 @@ const Color = enum(u1) {
9const Red = Color.Red;9const Red = Color.Red;
10const Black = Color.Black;10const Black = Color.Black;
1111
12const ReplaceError = error {12const ReplaceError = error{NotEqual};
13 NotEqual,
14};
1513
16/// Insert this into your struct that you want to add to a red-black tree.14/// Insert this into your struct that you want to add to a red-black tree.
17/// Do not use a pointer. Turn the *rb.Node results of the functions in rb15/// Do not use a pointer. Turn the *rb.Node results of the functions in rb
...@@ -27,7 +25,9 @@ const ReplaceError = error {...@@ -27,7 +25,9 @@ const ReplaceError = error {
27pub const Node = struct {25pub const Node = struct {
28 left: ?*Node,26 left: ?*Node,
29 right: ?*Node,27 right: ?*Node,
30 parent_and_color: usize, /// parent | color28
29 /// parent | color
30 parent_and_color: usize,
3131
32 pub fn next(constnode: *Node) ?*Node {32 pub fn next(constnode: *Node) ?*Node {
33 var node = constnode;33 var node = constnode;
...@@ -130,7 +130,7 @@ pub const Node = struct {...@@ -130,7 +130,7 @@ pub const Node = struct {
130130
131pub const Tree = struct {131pub const Tree = struct {
132 root: ?*Node,132 root: ?*Node,
133 compareFn: fn(*Node, *Node) mem.Compare,133 compareFn: fn (*Node, *Node) mem.Compare,
134134
135 /// If you have a need for a version that caches this, please file a bug.135 /// If you have a need for a version that caches this, please file a bug.
136 pub fn first(tree: *Tree) ?*Node {136 pub fn first(tree: *Tree) ?*Node {
...@@ -180,7 +180,7 @@ pub const Tree = struct {...@@ -180,7 +180,7 @@ pub const Tree = struct {
180 while (node.get_parent()) |*parent| {180 while (node.get_parent()) |*parent| {
181 if (parent.*.is_black())181 if (parent.*.is_black())
182 break;182 break;
183 // the root is always black183 // the root is always black
184 var grandpa = parent.*.get_parent() orelse unreachable;184 var grandpa = parent.*.get_parent() orelse unreachable;
185185
186 if (parent.* == grandpa.left) {186 if (parent.* == grandpa.left) {
...@@ -206,7 +206,7 @@ pub const Tree = struct {...@@ -206,7 +206,7 @@ pub const Tree = struct {
206 }206 }
207 } else {207 } else {
208 var maybe_uncle = grandpa.left;208 var maybe_uncle = grandpa.left;
209 209
210 if (maybe_uncle) |uncle| {210 if (maybe_uncle) |uncle| {
211 if (uncle.is_black())211 if (uncle.is_black())
212 break;212 break;
...@@ -259,7 +259,7 @@ pub const Tree = struct {...@@ -259,7 +259,7 @@ pub const Tree = struct {
259 if (node.left == null) {259 if (node.left == null) {
260 next = node.right.?; // Not both null as per above260 next = node.right.?; // Not both null as per above
261 } else if (node.right == null) {261 } else if (node.right == null) {
262 next = node.left.?; // Not both null as per above262 next = node.left.?; // Not both null as per above
263 } else263 } else
264 next = node.right.?.get_first(); // Just checked for null above264 next = node.right.?.get_first(); // Just checked for null above
265265
...@@ -313,7 +313,7 @@ pub const Tree = struct {...@@ -313,7 +313,7 @@ pub const Tree = struct {
313 var parent = maybe_parent.?;313 var parent = maybe_parent.?;
314 if (node == parent.left) {314 if (node == parent.left) {
315 var sibling = parent.right.?; // Same number of black nodes.315 var sibling = parent.right.?; // Same number of black nodes.
316 316
317 if (sibling.is_red()) {317 if (sibling.is_red()) {
318 sibling.set_color(Black);318 sibling.set_color(Black);
319 parent.set_color(Red);319 parent.set_color(Red);
...@@ -321,7 +321,8 @@ pub const Tree = struct {...@@ -321,7 +321,8 @@ pub const Tree = struct {
321 sibling = parent.right.?; // Just rotated321 sibling = parent.right.?; // Just rotated
322 }322 }
323 if ((if (sibling.left) |n| n.is_black() else true) and323 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 {
325 sibling.set_color(Red);326 sibling.set_color(Red);
326 node = parent;327 node = parent;
327 maybe_parent = parent.get_parent();328 maybe_parent = parent.get_parent();
...@@ -341,7 +342,7 @@ pub const Tree = struct {...@@ -341,7 +342,7 @@ pub const Tree = struct {
341 break;342 break;
342 } else {343 } else {
343 var sibling = parent.left.?; // Same number of black nodes.344 var sibling = parent.left.?; // Same number of black nodes.
344 345
345 if (sibling.is_red()) {346 if (sibling.is_red()) {
346 sibling.set_color(Black);347 sibling.set_color(Black);
347 parent.set_color(Red);348 parent.set_color(Red);
...@@ -349,7 +350,8 @@ pub const Tree = struct {...@@ -349,7 +350,8 @@ pub const Tree = struct {
349 sibling = parent.left.?; // Just rotated350 sibling = parent.left.?; // Just rotated
350 }351 }
351 if ((if (sibling.left) |n| n.is_black() else true) and352 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 {
353 sibling.set_color(Red);355 sibling.set_color(Red);
354 node = parent;356 node = parent;
355 maybe_parent = parent.get_parent();357 maybe_parent = parent.get_parent();
...@@ -397,7 +399,7 @@ pub const Tree = struct {...@@ -397,7 +399,7 @@ pub const Tree = struct {
397 new.* = old.*;399 new.* = old.*;
398 }400 }
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 {
401 tree.root = null;403 tree.root = null;
402 tree.compareFn = f;404 tree.compareFn = f;
403 }405 }