OLD | NEW |
(Empty) | |
| 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 |
| 18 void CreateGlobalsInstance() { |
| 19 g_globals = new Globals(); |
| 20 } |
| 21 |
| 22 } // namespace |
| 23 |
| 24 Globals::Globals() : search_paths_(), rdebug_() { |
| 25 pthread_mutex_init(&lock_, NULL); |
| 26 search_paths_.ResetFromEnv("LD_LIBRARY_PATH"); |
| 27 } |
| 28 |
| 29 Globals::~Globals() { |
| 30 pthread_mutex_destroy(&lock_); |
| 31 } |
| 32 |
| 33 Globals* Globals::Get() { |
| 34 pthread_once(&g_globals_once, CreateGlobalsInstance); |
| 35 return g_globals; |
| 36 } |
| 37 |
| 38 } // namespace crazy |
OLD | NEW |