| ... | @@ -399,14 +399,14 @@ test "detect" { | ... | @@ -399,14 +399,14 @@ test "detect" { |
| 399 | | 399 | |
| 400 | pub fn detectNativeCpuAndFeatures() ?Target.Cpu { | 400 | pub fn detectNativeCpuAndFeatures() ?Target.Cpu { |
| 401 | var cpu_family: std.c.CPUFAMILY = undefined; | 401 | var cpu_family: std.c.CPUFAMILY = undefined; |
| 402 | var len: usize = @sizeOf(std.c.CPUFAMILY); | 402 | var len: usize = @sizeOf(@TypeOf(cpu_family)); |
| 403 | switch (posix.errno(posix.system.sysctlbyname("hw.cpufamily", &cpu_family, &len, null, 0))) { | 403 | switch (posix.errno(posix.system.sysctlbyname("hw.cpufamily", &cpu_family, &len, null, 0))) { |
| 404 | .SUCCESS => {}, | 404 | .SUCCESS => {}, |
| 405 | .FAULT => unreachable, // segmentation fault | 405 | .FAULT => unreachable, // segmentation fault |
| 406 | .PERM => unreachable, // only when setting values, | 406 | .PERM => unreachable, // only when setting values, |
| 407 | .NOMEM => unreachable, // memory already on the stack | 407 | .NOMEM => unreachable, // memory already on the stack |
| 408 | .NOENT => unreachable, // constant, known good value | 408 | .NOENT => unreachable, // constant, known good value |
| 409 | else => unreachable, | 409 | else => return null, |
| 410 | } | 410 | } |
| 411 | | 411 | |
| 412 | const current_arch = builtin.cpu.arch; | 412 | const current_arch = builtin.cpu.arch; |
| ... | @@ -438,11 +438,7 @@ pub fn detectNativeCpuAndFeatures() ?Target.Cpu { | ... | @@ -438,11 +438,7 @@ pub fn detectNativeCpuAndFeatures() ?Target.Cpu { |
| 438 | else => return null, | 438 | else => return null, |
| 439 | }; | 439 | }; |
| 440 | | 440 | |
| 441 | return Target.Cpu{ | 441 | return model.toCpu(current_arch); |
| 442 | .arch = current_arch, | | |
| 443 | .model = model, | | |
| 444 | .features = model.features, | | |
| 445 | }; | | |
| 446 | }, | 442 | }, |
| 447 | else => {}, | 443 | else => {}, |
| 448 | } | 444 | } |