1// Copyright 2014 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
11namespace crazy {
12
13namespace {
14
15Globals* g_globals = NULL;
16pthread_once_t g_globals_once = PTHREAD_ONCE_INIT;
17
18void CreateGlobalsInstance() { g_globals = new Globals(); }
19
20}  // namespace
21
22Globals::Globals() : search_paths_(), rdebug_() {
23  pthread_mutex_init(&lock_, NULL);
24  search_paths_.ResetFromEnv("LD_LIBRARY_PATH");
25}
26
27Globals::~Globals() { pthread_mutex_destroy(&lock_); }
28
29Globals* Globals::Get() {
30  pthread_once(&g_globals_once, CreateGlobalsInstance);
31  return g_globals;
32}
33
34}  // namespace crazy
35