authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-03-01 20:04:28-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-03-01 20:04:28-07:00
loga20169a610b693794756bbc0139f0955c1294b48
tree5b1e42aba9760bf8b3355cf4014a9d15f59e5a6e
parent7613e51a57d2e2d0ae7d1101d059002f12b96c43

zig fmt the std lib


4 files changed, 22 insertions(+), 22 deletions(-)

lib/std/bit_set.zig+14-13
...@@ -4,10 +4,6 @@...@@ -4,10 +4,6 @@
4// The MIT license requires this copyright notice to be included in all copies4// The MIT license requires this copyright notice to be included in all copies
5// and substantial portions of the software.5// and substantial portions of the software.
66
7const std = @import("std");
8const assert = std.debug.assert;
9const Allocator = std.mem.Allocator;
10
11//! This file defines several variants of bit sets. A bit set7//! This file defines several variants of bit sets. A bit set
12//! is a densely stored set of integers with a known maximum,8//! is a densely stored set of integers with a known maximum,
13//! in which each integer gets a single bit. Bit sets have very9//! in which each integer gets a single bit. Bit sets have very
...@@ -40,6 +36,10 @@ const Allocator = std.mem.Allocator;...@@ -40,6 +36,10 @@ const Allocator = std.mem.Allocator;
40//! A variant of DynamicBitSet which does not store a pointer to its36//! A variant of DynamicBitSet which does not store a pointer to its
41//! allocator, in order to save space.37//! allocator, in order to save space.
4238
39const std = @import("std");
40const assert = std.debug.assert;
41const Allocator = std.mem.Allocator;
42
43/// Returns the optimal static bit set type for the specified number43/// Returns the optimal static bit set type for the specified number
44/// of elements. The returned type will perform no allocations,44/// of elements. The returned type will perform no allocations,
45/// can be copied by value, and does not require deinitialization.45/// can be copied by value, and does not require deinitialization.
...@@ -83,7 +83,7 @@ pub fn IntegerBitSet(comptime size: u16) type {...@@ -83,7 +83,7 @@ pub fn IntegerBitSet(comptime size: u16) type {
83 }83 }
8484
85 /// Returns the number of bits in this bit set85 /// Returns the number of bits in this bit set
86 pub inline fn capacity(self: Self) usize {86 pub fn capacity(self: Self) callconv(.Inline) usize {
87 return bit_length;87 return bit_length;
88 }88 }
8989
...@@ -168,7 +168,7 @@ pub fn IntegerBitSet(comptime size: u16) type {...@@ -168,7 +168,7 @@ pub fn IntegerBitSet(comptime size: u16) type {
168 const mask = self.mask;168 const mask = self.mask;
169 if (mask == 0) return null;169 if (mask == 0) return null;
170 const index = @ctz(MaskInt, mask);170 const index = @ctz(MaskInt, mask);
171 self.mask = mask & (mask-1);171 self.mask = mask & (mask - 1);
172 return index;172 return index;
173 }173 }
174174
...@@ -306,7 +306,7 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {...@@ -306,7 +306,7 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {
306 }306 }
307307
308 /// Returns the number of bits in this bit set308 /// Returns the number of bits in this bit set
309 pub inline fn capacity(self: Self) usize {309 pub fn capacity(self: Self) callconv(.Inline) usize {
310 return bit_length;310 return bit_length;
311 }311 }
312312
...@@ -566,7 +566,7 @@ pub const DynamicBitSetUnmanaged = struct {...@@ -566,7 +566,7 @@ pub const DynamicBitSetUnmanaged = struct {
566 }566 }
567567
568 /// Returns the number of bits in this bit set568 /// Returns the number of bits in this bit set
569 pub inline fn capacity(self: Self) usize {569 pub fn capacity(self: Self) callconv(.Inline) usize {
570 return self.bit_length;570 return self.bit_length;
571 }571 }
572572
...@@ -691,7 +691,7 @@ pub const DynamicBitSetUnmanaged = struct {...@@ -691,7 +691,7 @@ pub const DynamicBitSetUnmanaged = struct {
691 offset += @bitSizeOf(MaskInt);691 offset += @bitSizeOf(MaskInt);
692 } else return null;692 } else return null;
693 const index = @ctz(MaskInt, mask[0]);693 const index = @ctz(MaskInt, mask[0]);
694 mask[0] &= (mask[0]-1);694 mask[0] &= (mask[0] - 1);
695 return offset + index;695 return offset + index;
696 }696 }
697697
...@@ -777,7 +777,7 @@ pub const DynamicBitSet = struct {...@@ -777,7 +777,7 @@ pub const DynamicBitSet = struct {
777 }777 }
778778
779 /// Returns the number of bits in this bit set779 /// Returns the number of bits in this bit set
780 pub inline fn capacity(self: Self) usize {780 pub fn capacity(self: Self) callconv(.Inline) usize {
781 return self.unmanaged.capacity();781 return self.unmanaged.capacity();
782 }782 }
783783
...@@ -955,7 +955,7 @@ fn BitSetIterator(comptime MaskInt: type, comptime options: IteratorOptions) typ...@@ -955,7 +955,7 @@ fn BitSetIterator(comptime MaskInt: type, comptime options: IteratorOptions) typ
955 // isn't a next word. If the next word is the955 // isn't a next word. If the next word is the
956 // last word, mask off the padding bits so we956 // last word, mask off the padding bits so we
957 // don't visit them.957 // don't visit them.
958 inline fn nextWord(self: *Self, comptime is_first_word: bool) void {958 fn nextWord(self: *Self, comptime is_first_word: bool) callconv(.Inline) void {
959 var word = switch (direction) {959 var word = switch (direction) {
960 .forward => self.words_remain[0],960 .forward => self.words_remain[0],
961 .reverse => self.words_remain[self.words_remain.len - 1],961 .reverse => self.words_remain[self.words_remain.len - 1],
...@@ -1114,8 +1114,9 @@ fn testBitSet(a: anytype, b: anytype, len: usize) void {...@@ -1114,8 +1114,9 @@ fn testBitSet(a: anytype, b: anytype, len: usize) void {
1114 }1114 }
11151115
1116 const test_bits = [_]usize{1116 const test_bits = [_]usize{
1117 0, 1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 22, 31, 32, 63, 64,1117 0, 1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 22, 31, 32, 63, 64,
1118 66, 95, 127, 160, 192, 1000 };1118 66, 95, 127, 160, 192, 1000,
1119 };
1119 for (test_bits) |i| {1120 for (test_bits) |i| {
1120 if (i < a.capacity()) {1121 if (i < a.capacity()) {
1121 a.set(i);1122 a.set(i);
lib/std/fs/get_app_data_dir.zig+1-1
...@@ -60,7 +60,7 @@ pub fn getAppDataDir(allocator: *mem.Allocator, appname: []const u8) GetAppDataD...@@ -60,7 +60,7 @@ pub fn getAppDataDir(allocator: *mem.Allocator, appname: []const u8) GetAppDataD
60 var dir_path_ptr: [*:0]u8 = undefined;60 var dir_path_ptr: [*:0]u8 = undefined;
61 // TODO look into directory_which61 // TODO look into directory_which
62 const be_user_settings = 0xbbe;62 const be_user_settings = 0xbbe;
63 const rc = os.system.find_directory(be_user_settings, -1, true, dir_path_ptr, 1) ;63 const rc = os.system.find_directory(be_user_settings, -1, true, dir_path_ptr, 1);
64 const settings_dir = try allocator.dupeZ(u8, mem.spanZ(dir_path_ptr));64 const settings_dir = try allocator.dupeZ(u8, mem.spanZ(dir_path_ptr));
65 defer allocator.free(settings_dir);65 defer allocator.free(settings_dir);
66 switch (rc) {66 switch (rc) {
lib/std/math.zig+1-1
...@@ -1334,7 +1334,7 @@ test "math.comptime" {...@@ -1334,7 +1334,7 @@ test "math.comptime" {
1334/// Returns a mask of all ones if value is true,1334/// Returns a mask of all ones if value is true,
1335/// and a mask of all zeroes if value is false.1335/// and a mask of all zeroes if value is false.
1336/// Compiles to one instruction for register sized integers.1336/// Compiles to one instruction for register sized integers.
1337pub inline fn boolMask(comptime MaskInt: type, value: bool) MaskInt {1337pub fn boolMask(comptime MaskInt: type, value: bool) callconv(.Inline) MaskInt {
1338 if (@typeInfo(MaskInt) != .Int)1338 if (@typeInfo(MaskInt) != .Int)
1339 @compileError("boolMask requires an integer mask type.");1339 @compileError("boolMask requires an integer mask type.");
13401340
lib/std/os/bits/haiku.zig+6-7
...@@ -180,8 +180,8 @@ pub const dirent = extern struct {...@@ -180,8 +180,8 @@ pub const dirent = extern struct {
180};180};
181181
182pub const image_info = extern struct {182pub const image_info = extern struct {
183 id: u32, //image_id183 id: u32,
184 type: u32, // image_type184 type: u32,
185 sequence: i32,185 sequence: i32,
186 init_order: i32,186 init_order: i32,
187 init_routine: *c_void,187 init_routine: *c_void,
...@@ -806,17 +806,16 @@ pub const Sigaction = extern struct {...@@ -806,17 +806,16 @@ pub const Sigaction = extern struct {
806806
807pub const _SIG_WORDS = 4;807pub const _SIG_WORDS = 4;
808pub const _SIG_MAXSIG = 128;808pub const _SIG_MAXSIG = 128;
809809pub fn _SIG_IDX(sig: usize) callconv(.Inline) usize {
810pub inline fn _SIG_IDX(sig: usize) usize {
811 return sig - 1;810 return sig - 1;
812}811}
813pub inline fn _SIG_WORD(sig: usize) usize {812pub fn _SIG_WORD(sig: usize) callconv(.Inline) usize {
814 return_SIG_IDX(sig) >> 5;813 return_SIG_IDX(sig) >> 5;
815}814}
816pub inline fn _SIG_BIT(sig: usize) usize {815pub fn _SIG_BIT(sig: usize) callconv(.Inline) usize {
817 return 1 << (_SIG_IDX(sig) & 31);816 return 1 << (_SIG_IDX(sig) & 31);
818}817}
819pub inline fn _SIG_VALID(sig: usize) usize {818pub fn _SIG_VALID(sig: usize) callconv(.Inline) usize {
820 return sig <= _SIG_MAXSIG and sig > 0;819 return sig <= _SIG_MAXSIG and sig > 0;
821}820}
822821