Skip to content

Commit 4333ad6

Browse files
committed
add is_rosetta()
1 parent 0891858 commit 4333ad6

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

+stdlib/is_rosetta.m

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
function r = is_rosetta()
2+
% IS_ROSETTA Returns true if running on Apple Silicon using Rosetta (Matlab Intel binary)
3+
4+
r = false;
5+
6+
if ~ismac
7+
return
8+
end
9+
10+
% uname -m reports "x86_64" from within Matlab on Apple Silicon if using Rosetta
11+
12+
[ret, raw] = system("sysctl -n sysctl.proc_translated");
13+
r = ret == 0 && startsWith(raw, "1");
14+
15+
end

test/TestSys.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ function test_platform(tc)
2626
tc.verifyThat(stdlib.iswsl, IsOfClass('logical'))
2727
tc.verifyThat(stdlib.has_wsl, IsOfClass('logical'))
2828

29+
tc.verifyThat(stdlib.is_rosetta, IsOfClass('logical'))
30+
2931
tc.verifyThat(stdlib.isinteractive, IsOfClass('logical'))
3032

3133
tc.verifyThat(stdlib.is_windows_powershell, IsOfClass('logical'))

0 commit comments

Comments
 (0)