tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

Globals.cpp (1699B)


      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 https://mozilla.org/MPL/2.0/. */
      4 
      5 #include "Globals.h"
      6 
      7 #ifdef XP_WIN
      8 #  include <processenv.h>
      9 #endif
     10 
     11 // ***************************************************************************
     12 // Constants defining allocator size classes and behavior.
     13 
     14 namespace mozilla {
     15 
     16 #ifndef MALLOC_STATIC_PAGESIZE
     17 #  define GLOBAL(type, name, value) type name;
     18 #  define GLOBAL_ASSERT(...)
     19 #  include "Globals_inc.h"
     20 #  undef GLOBAL_ASSERT
     21 #  undef GLOBAL
     22 
     23 size_t gRealPageSize = 0;
     24 size_t gPageSize = 0;
     25 
     26 void DefineGlobals() {
     27 #  define GLOBAL(type, name, value) name = value;
     28 #  define GLOBAL_LOG2 mozilla::FloorLog2
     29 #  define GLOBAL_ASSERT MOZ_RELEASE_ASSERT
     30 #  define GLOBAL_CONSTEXPR
     31 #  include "Globals_inc.h"
     32 #  undef GLOBAL_CONSTEXPR
     33 #  undef GLOBAL_ASSERT
     34 #  undef GLOBAL_LOG2
     35 #  undef GLOBAL
     36 }
     37 #endif
     38 
     39 #ifdef XP_WIN
     40 
     41 // Implement getenv without using malloc.
     42 static char mozillaMallocOptionsBuf[64];
     43 
     44 #  define getenv xgetenv
     45 static char* getenv(const char* name) {
     46  if (GetEnvironmentVariableA(name, mozillaMallocOptionsBuf,
     47                              sizeof(mozillaMallocOptionsBuf)) > 0) {
     48    return mozillaMallocOptionsBuf;
     49  }
     50 
     51  return nullptr;
     52 }
     53 #endif
     54 
     55 // *****************************
     56 // Runtime configuration options.
     57 
     58 size_t opt_dirty_max = DIRTY_MAX_DEFAULT;
     59 
     60 #ifdef MALLOC_RUNTIME_CONFIG
     61 bool opt_junk = OPT_JUNK_DEFAULT;
     62 bool opt_zero = OPT_ZERO_DEFAULT;
     63 PoisonType opt_poison = OPT_POISON_DEFAULT;
     64 size_t opt_poison_size = OPT_POISON_SIZE_DEFAULT;
     65 #endif
     66 
     67 bool opt_randomize_small = true;
     68 
     69 }  // namespace mozilla