better comptime
This commit is contained in:
parent
efdc919195
commit
9bd922a55a
@ -248,9 +248,12 @@ pub fn fieldOffsets(lengths: DBNumbers) DBNumbers {
|
||||
var result: DBNumbers = undefined;
|
||||
result.header = 0;
|
||||
var offset = comptime nblocks_n(u64, @sizeOf(Header));
|
||||
comptime assert(mem.eql(u8, DB_fields[0].name, "header"));
|
||||
inline for (DB_fields[1..]) |field, i| {
|
||||
comptime assert(mem.eql(u8, field.name, meta.fields(DBNumbers)[i + 1].name));
|
||||
inline for (DB_fields[0..]) |field, i| {
|
||||
comptime {
|
||||
assert(mem.eql(u8, field.name, meta.fields(DBNumbers)[i].name));
|
||||
if (mem.eql(u8, field.name, "header")) continue;
|
||||
}
|
||||
|
||||
@field(result, field.name) = offset;
|
||||
offset += @field(lengths, field.name);
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ const State = struct {
|
||||
|
||||
// global_state is initialized on first call to an nss function
|
||||
var global_state: State = undefined;
|
||||
var global_start = once(init);
|
||||
var global_init = once(init);
|
||||
|
||||
// assigns State from environment variables et al
|
||||
fn init() void {
|
||||
@ -80,7 +80,7 @@ export fn _nss_turbo_getpwuid_r(
|
||||
len: usize,
|
||||
errnop: *c_int,
|
||||
) c.enum_nss_status {
|
||||
global_start.call();
|
||||
global_init.call();
|
||||
|
||||
if (global_state.file == null) {
|
||||
errnop.* = @enumToInt(os.E.AGAIN);
|
||||
|
Loading…
Reference in New Issue
Block a user