Skip to content

Commit be9d607

Browse files
committed
cpu_arch more robust
1 parent 8a007f8 commit be9d607

File tree

4 files changed

+15
-16
lines changed

4 files changed

+15
-16
lines changed

+stdlib/+native/cpu_arch.m

Lines changed: 0 additions & 5 deletions
This file was deleted.

+stdlib/cpu_arch.m

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1-
%% CPU_ARCH get the CPU architecture
1+
%% CPU_ARCH get the Operating System CPU architecture
2+
%
3+
% This function retrieves the CPU architecture of the current operating system.
4+
% The physical CPU architecture can be obscured and even determining it in high-level
5+
% languages like Python is not exactly trivial.
6+
% This method is as used by
7+
% <https://cmake.org/cmake/help/latest/variable/CMAKE_HOST_SYSTEM_PROCESSOR.html CMake>.
28
%
39
%%% Outputs
4-
% * a: Returns the CPU architecture as a string.
5-
% * b: backend used
6-
7-
function [a, b] = cpu_arch(backend)
8-
arguments
9-
backend (1,:) string = ["java", "dotnet", "native"]
10-
end
10+
% * a: the CPU architecture as a character vector:
1111

12-
o = stdlib.Backend(mfilename(), backend);
13-
a = o.func();
12+
function a = cpu_arch()
1413

15-
b = o.backend;
14+
if ispc()
15+
a = getenv("PROCESSOR_ARCHITECTURE");
16+
else
17+
[~, a] = system('uname -m');
18+
a = strip(a);
19+
end
1620

1721
end
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)