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