1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "crazy_linker_globals.h" 6 7 #include <pthread.h> 8 9 #include "crazy_linker_system.h" 10 11 namespace crazy { 12 13 namespace { 14 15 Globals* g_globals = NULL; 16 pthread_once_t g_globals_once = PTHREAD_ONCE_INIT; 17 CreateGlobalsInstance()18void CreateGlobalsInstance() { g_globals = new Globals(); } 19 20 } // namespace 21 Globals()22Globals::Globals() : search_paths_(), rdebug_() { 23 pthread_mutex_init(&lock_, NULL); 24 search_paths_.ResetFromEnv("LD_LIBRARY_PATH"); 25 } 26 ~Globals()27Globals::~Globals() { pthread_mutex_destroy(&lock_); } 28 Get()29Globals* Globals::Get() { 30 pthread_once(&g_globals_once, CreateGlobalsInstance); 31 return g_globals; 32 } 33 34 } // namespace crazy 35