Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * vim: set ts=8 sts=4 et sw=4 tw=99:
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "jit/mips/Architecture-mips.h"
9 #include <elf.h>
11 #include <fcntl.h>
12 #include <unistd.h>
14 #define HWCAP_MIPS (1 << 31)
15 #define HWCAP_FPU (1 << 0)
17 namespace js {
18 namespace jit {
20 uint32_t GetMIPSFlags()
21 {
22 static bool isSet = false;
23 static uint32_t flags = 0;
24 if (isSet)
25 return flags;
26 #if WTF_OS_LINUX
27 FILE *fp = fopen("/proc/cpuinfo", "r");
28 if (!fp)
29 return false;
31 char buf[1024];
32 memset(buf, 0, sizeof(buf));
33 fread(buf, sizeof(char), sizeof(buf)-1, fp);
34 fclose(fp);
35 if (strstr(buf, "FPU"))
36 flags |= HWCAP_FPU;
38 isSet = true;
39 return flags;
40 #endif
42 return false;
43 }
45 bool hasFPU()
46 {
47 return js::jit::GetMIPSFlags() & HWCAP_FPU;
48 }
50 Registers::Code
51 Registers::FromName(const char *name)
52 {
53 for (size_t i = 0; i < Total; i++) {
54 if (strcmp(GetName(i), name) == 0)
55 return Code(i);
56 }
58 return Invalid;
59 }
61 FloatRegisters::Code
62 FloatRegisters::FromName(const char *name)
63 {
64 for (size_t i = 0; i < Total; i++) {
65 if (strcmp(GetName(i), name) == 0)
66 return Code(i);
67 }
69 return Invalid;
70 }
74 } // namespace ion
75 } // namespace js