forked from BOINC/boinc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
client/hostinfo_unix: addapt for Apple Silicon M1 / arm64 CPU BOINC#2
- The native arm64 client tries to launch a separate helper program that is compiled only for the x86_64 architecture. If successful, this means that Rosetta2 is installed and the host can run x86_64 applications, so x86_64-apple-darwin is added as an alternative platform. The helper program 'detect_rosetta_cpu' gets the feature string for the emulated x86_64 CPU (e.g. SSE), and writes it to a file in the BOINC data directory. If this file exists, this file is read in hostinfo_unix_mac() and the features of the meulated CPU are added to that of the native CPU.
- Loading branch information
Showing
4 changed files
with
153 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// This file is part of BOINC. | ||
// http://boinc.berkeley.edu | ||
// Copyright (C) 2020 University of California | ||
// | ||
// BOINC is free software; you can redistribute it and/or modify it | ||
// under the terms of the GNU Lesser General Public License | ||
// as published by the Free Software Foundation, | ||
// either version 3 of the License, or (at your option) any later version. | ||
// | ||
// BOINC is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
// See the GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with BOINC. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
// This helper program should is used to detect an emulated x86_64 CPU | ||
// on Apples arm64 CPUs. It should be compiiled _only_ for x86_64 architecture | ||
// and writes the feature string of the meulated CPU to a file | ||
// EMULATED_CPU_INFO_FILENAME in the current working directory. | ||
|
||
#include <stdio.h> | ||
#include <string.h> | ||
#include <sys/types.h> | ||
#include <sys/sysctl.h> | ||
|
||
#include "hostinfo.h" // for P_FEATURES_SIZE | ||
#include "filesys.h" // for boinc_fopen() | ||
#include "file_names.h" // for EMULATED_CPU_INFO_FILENAME | ||
|
||
int main () { | ||
size_t len; | ||
char features[P_FEATURES_SIZE]; | ||
FILE*fp; | ||
|
||
len = sizeof(features); | ||
sysctlbyname("machdep.cpu.features", features, &len, NULL, 0); | ||
if ((fp = boinc_fopen(EMULATED_CPU_INFO_FILENAME, "w"))) { | ||
fprintf(fp," %s\n", features); | ||
fclose(fp); | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters