Thu, 15 Jan 2015 15:59:08 +0100
Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | /* |
michael@0 | 2 | * Copyright (c) 2010 The WebM project authors. All Rights Reserved. |
michael@0 | 3 | * |
michael@0 | 4 | * Use of this source code is governed by a BSD-style license |
michael@0 | 5 | * that can be found in the LICENSE file in the root of the source |
michael@0 | 6 | * tree. An additional intellectual property rights grant can be found |
michael@0 | 7 | * in the file PATENTS. All contributing project authors may |
michael@0 | 8 | * be found in the AUTHORS file in the root of the source tree. |
michael@0 | 9 | */ |
michael@0 | 10 | |
michael@0 | 11 | |
michael@0 | 12 | #include "vpx_config.h" |
michael@0 | 13 | #include "vp8_rtcd.h" |
michael@0 | 14 | #if ARCH_ARM |
michael@0 | 15 | #include "vpx_ports/arm.h" |
michael@0 | 16 | #elif ARCH_X86 || ARCH_X86_64 |
michael@0 | 17 | #include "vpx_ports/x86.h" |
michael@0 | 18 | #endif |
michael@0 | 19 | #include "vp8/common/onyxc_int.h" |
michael@0 | 20 | |
michael@0 | 21 | #if CONFIG_MULTITHREAD |
michael@0 | 22 | #if HAVE_UNISTD_H && !defined(__OS2__) |
michael@0 | 23 | #include <unistd.h> |
michael@0 | 24 | #elif defined(_WIN32) |
michael@0 | 25 | #include <windows.h> |
michael@0 | 26 | typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO); |
michael@0 | 27 | #elif defined(__OS2__) |
michael@0 | 28 | #define INCL_DOS |
michael@0 | 29 | #define INCL_DOSSPINLOCK |
michael@0 | 30 | #include <os2.h> |
michael@0 | 31 | #endif |
michael@0 | 32 | #endif |
michael@0 | 33 | |
michael@0 | 34 | #if CONFIG_MULTITHREAD |
michael@0 | 35 | static int get_cpu_count() |
michael@0 | 36 | { |
michael@0 | 37 | int core_count = 16; |
michael@0 | 38 | |
michael@0 | 39 | #if HAVE_UNISTD_H && !defined(__OS2__) |
michael@0 | 40 | #if defined(_SC_NPROCESSORS_ONLN) |
michael@0 | 41 | core_count = sysconf(_SC_NPROCESSORS_ONLN); |
michael@0 | 42 | #elif defined(_SC_NPROC_ONLN) |
michael@0 | 43 | core_count = sysconf(_SC_NPROC_ONLN); |
michael@0 | 44 | #endif |
michael@0 | 45 | #elif defined(_WIN32) |
michael@0 | 46 | { |
michael@0 | 47 | PGNSI pGNSI; |
michael@0 | 48 | SYSTEM_INFO sysinfo; |
michael@0 | 49 | |
michael@0 | 50 | /* Call GetNativeSystemInfo if supported or |
michael@0 | 51 | * GetSystemInfo otherwise. */ |
michael@0 | 52 | |
michael@0 | 53 | pGNSI = (PGNSI) GetProcAddress( |
michael@0 | 54 | GetModuleHandle(TEXT("kernel32.dll")), "GetNativeSystemInfo"); |
michael@0 | 55 | if (pGNSI != NULL) |
michael@0 | 56 | pGNSI(&sysinfo); |
michael@0 | 57 | else |
michael@0 | 58 | GetSystemInfo(&sysinfo); |
michael@0 | 59 | |
michael@0 | 60 | core_count = sysinfo.dwNumberOfProcessors; |
michael@0 | 61 | } |
michael@0 | 62 | #elif defined(__OS2__) |
michael@0 | 63 | { |
michael@0 | 64 | ULONG proc_id; |
michael@0 | 65 | ULONG status; |
michael@0 | 66 | |
michael@0 | 67 | core_count = 0; |
michael@0 | 68 | for (proc_id = 1; ; proc_id++) |
michael@0 | 69 | { |
michael@0 | 70 | if (DosGetProcessorStatus(proc_id, &status)) |
michael@0 | 71 | break; |
michael@0 | 72 | |
michael@0 | 73 | if (status == PROC_ONLINE) |
michael@0 | 74 | core_count++; |
michael@0 | 75 | } |
michael@0 | 76 | } |
michael@0 | 77 | #else |
michael@0 | 78 | /* other platforms */ |
michael@0 | 79 | #endif |
michael@0 | 80 | |
michael@0 | 81 | return core_count > 0 ? core_count : 1; |
michael@0 | 82 | } |
michael@0 | 83 | #endif |
michael@0 | 84 | |
michael@0 | 85 | void vp8_clear_system_state_c() {}; |
michael@0 | 86 | |
michael@0 | 87 | void vp8_machine_specific_config(VP8_COMMON *ctx) |
michael@0 | 88 | { |
michael@0 | 89 | #if CONFIG_MULTITHREAD |
michael@0 | 90 | ctx->processor_core_count = get_cpu_count(); |
michael@0 | 91 | #endif /* CONFIG_MULTITHREAD */ |
michael@0 | 92 | |
michael@0 | 93 | #if ARCH_ARM |
michael@0 | 94 | ctx->cpu_caps = arm_cpu_caps(); |
michael@0 | 95 | #elif ARCH_X86 || ARCH_X86_64 |
michael@0 | 96 | ctx->cpu_caps = x86_simd_caps(); |
michael@0 | 97 | #endif |
michael@0 | 98 | } |