From 449b872916c29a7b9d4155b176f7aca85b8c2c84 Mon Sep 17 00:00:00 2001 From: Alexander Bayandin Date: Tue, 15 Nov 2022 11:02:56 +0000 Subject: [PATCH 1/2] CPU: fix M2 detection --- Library/Homebrew/extend/os/mac/hardware/cpu.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/extend/os/mac/hardware/cpu.rb b/Library/Homebrew/extend/os/mac/hardware/cpu.rb index 7d08694d85..59e650c322 100644 --- a/Library/Homebrew/extend/os/mac/hardware/cpu.rb +++ b/Library/Homebrew/extend/os/mac/hardware/cpu.rb @@ -152,7 +152,11 @@ module Hardware end def sysctl_int(key) - sysctl_n(key).to_i + if (x = sysctl_n(key).to_i) >= 0 + x + else + x & 0xffffffff + end end def sysctl_n(*keys) From f9b4bf93164101d811284e7a6b333113899b2af4 Mon Sep 17 00:00:00 2001 From: Alexander Bayandin Date: Wed, 16 Nov 2022 10:51:59 +0000 Subject: [PATCH 2/2] CPU: cleanup sysctl_int method Co-authored-by: Bo Anderson --- Library/Homebrew/extend/os/mac/hardware/cpu.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Library/Homebrew/extend/os/mac/hardware/cpu.rb b/Library/Homebrew/extend/os/mac/hardware/cpu.rb index 59e650c322..280525c4e7 100644 --- a/Library/Homebrew/extend/os/mac/hardware/cpu.rb +++ b/Library/Homebrew/extend/os/mac/hardware/cpu.rb @@ -152,11 +152,7 @@ module Hardware end def sysctl_int(key) - if (x = sysctl_n(key).to_i) >= 0 - x - else - x & 0xffffffff - end + sysctl_n(key).to_i & 0xffffffff end def sysctl_n(*keys)