zig fmt the std lib

This commit is contained in:
Andrew Kelley
2021-03-01 20:04:28 -07:00
parent 7613e51a57
commit a20169a610
4 changed files with 22 additions and 22 deletions

View File

@@ -4,10 +4,6 @@
// The MIT license requires this copyright notice to be included in all copies
// and substantial portions of the software.
const std = @import("std");
const assert = std.debug.assert;
const Allocator = std.mem.Allocator;
//! This file defines several variants of bit sets. A bit set
//! is a densely stored set of integers with a known maximum,
//! in which each integer gets a single bit. Bit sets have very
@@ -40,6 +36,10 @@ const Allocator = std.mem.Allocator;
//! A variant of DynamicBitSet which does not store a pointer to its
//! allocator, in order to save space.
const std = @import("std");
const assert = std.debug.assert;
const Allocator = std.mem.Allocator;
/// Returns the optimal static bit set type for the specified number
/// of elements. The returned type will perform no allocations,
/// can be copied by value, and does not require deinitialization.
@@ -83,7 +83,7 @@ pub fn IntegerBitSet(comptime size: u16) type {
}
/// Returns the number of bits in this bit set
pub inline fn capacity(self: Self) usize {
pub fn capacity(self: Self) callconv(.Inline) usize {
return bit_length;
}
@@ -168,7 +168,7 @@ pub fn IntegerBitSet(comptime size: u16) type {
const mask = self.mask;
if (mask == 0) return null;
const index = @ctz(MaskInt, mask);
self.mask = mask & (mask-1);
self.mask = mask & (mask - 1);
return index;
}
@@ -306,7 +306,7 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {
}
/// Returns the number of bits in this bit set
pub inline fn capacity(self: Self) usize {
pub fn capacity(self: Self) callconv(.Inline) usize {
return bit_length;
}
@@ -566,7 +566,7 @@ pub const DynamicBitSetUnmanaged = struct {
}
/// Returns the number of bits in this bit set
pub inline fn capacity(self: Self) usize {
pub fn capacity(self: Self) callconv(.Inline) usize {
return self.bit_length;
}
@@ -691,7 +691,7 @@ pub const DynamicBitSetUnmanaged = struct {
offset += @bitSizeOf(MaskInt);
} else return null;
const index = @ctz(MaskInt, mask[0]);
mask[0] &= (mask[0]-1);
mask[0] &= (mask[0] - 1);
return offset + index;
}
@@ -777,7 +777,7 @@ pub const DynamicBitSet = struct {
}
/// Returns the number of bits in this bit set
pub inline fn capacity(self: Self) usize {
pub fn capacity(self: Self) callconv(.Inline) usize {
return self.unmanaged.capacity();
}
@@ -955,7 +955,7 @@ fn BitSetIterator(comptime MaskInt: type, comptime options: IteratorOptions) typ
// isn't a next word. If the next word is the
// last word, mask off the padding bits so we
// don't visit them.
inline fn nextWord(self: *Self, comptime is_first_word: bool) void {
fn nextWord(self: *Self, comptime is_first_word: bool) callconv(.Inline) void {
var word = switch (direction) {
.forward => self.words_remain[0],
.reverse => self.words_remain[self.words_remain.len - 1],
@@ -1114,8 +1114,9 @@ fn testBitSet(a: anytype, b: anytype, len: usize) void {
}
const test_bits = [_]usize{
0, 1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 22, 31, 32, 63, 64,
66, 95, 127, 160, 192, 1000 };
0, 1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 22, 31, 32, 63, 64,
66, 95, 127, 160, 192, 1000,
};
for (test_bits) |i| {
if (i < a.capacity()) {
a.set(i);

View File

@@ -60,7 +60,7 @@ pub fn getAppDataDir(allocator: *mem.Allocator, appname: []const u8) GetAppDataD
var dir_path_ptr: [*:0]u8 = undefined;
// TODO look into directory_which
const be_user_settings = 0xbbe;
const rc = os.system.find_directory(be_user_settings, -1, true, dir_path_ptr, 1) ;
const rc = os.system.find_directory(be_user_settings, -1, true, dir_path_ptr, 1);
const settings_dir = try allocator.dupeZ(u8, mem.spanZ(dir_path_ptr));
defer allocator.free(settings_dir);
switch (rc) {

View File

@@ -1334,7 +1334,7 @@ test "math.comptime" {
/// Returns a mask of all ones if value is true,
/// and a mask of all zeroes if value is false.
/// Compiles to one instruction for register sized integers.
pub inline fn boolMask(comptime MaskInt: type, value: bool) MaskInt {
pub fn boolMask(comptime MaskInt: type, value: bool) callconv(.Inline) MaskInt {
if (@typeInfo(MaskInt) != .Int)
@compileError("boolMask requires an integer mask type.");

View File

@@ -180,8 +180,8 @@ pub const dirent = extern struct {
};
pub const image_info = extern struct {
id: u32, //image_id
type: u32, // image_type
id: u32,
type: u32,
sequence: i32,
init_order: i32,
init_routine: *c_void,
@@ -806,17 +806,16 @@ pub const Sigaction = extern struct {
pub const _SIG_WORDS = 4;
pub const _SIG_MAXSIG = 128;
pub inline fn _SIG_IDX(sig: usize) usize {
pub fn _SIG_IDX(sig: usize) callconv(.Inline) usize {
return sig - 1;
}
pub inline fn _SIG_WORD(sig: usize) usize {
pub fn _SIG_WORD(sig: usize) callconv(.Inline) usize {
return_SIG_IDX(sig) >> 5;
}
pub inline fn _SIG_BIT(sig: usize) usize {
pub fn _SIG_BIT(sig: usize) callconv(.Inline) usize {
return 1 << (_SIG_IDX(sig) & 31);
}
pub inline fn _SIG_VALID(sig: usize) usize {
pub fn _SIG_VALID(sig: usize) callconv(.Inline) usize {
return sig <= _SIG_MAXSIG and sig > 0;
}