1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 /* compile-time and runtime tests for whether to use MIPS-specific extensions */
14 MIPS_FLAG_LOONGSON3
= 1,
17 static unsigned get_mips_cpu_flags(void) {
21 fin
= fopen("/proc/cpuinfo", "r");
24 memset(buf
, 0, sizeof(buf
));
25 fread(buf
, sizeof(char), sizeof(buf
) - 1, fin
);
27 if (strstr(buf
, "Loongson-3")) flags
|= MIPS_FLAG_LOONGSON3
;
32 static bool check_loongson3(void) {
33 // Cache a local copy so we only have to read /proc/cpuinfo once.
34 static unsigned mips_cpu_flags
= get_mips_cpu_flags();
35 return (mips_cpu_flags
& MIPS_FLAG_LOONGSON3
) != 0;
39 namespace mips_private
{
40 bool isLoongson3
= check_loongson3();
41 } // namespace mips_private
42 } // namespace mozilla