OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // The purpose of this file is to supply the macro definintions necessary | 5 // The purpose of this file is to supply the macro definintions necessary |
6 // to make third_party/dmg_fp/dtoa.cc threadsafe. | 6 // to make third_party/dmg_fp/dtoa.cc threadsafe. |
| 7 #include <time.h> |
| 8 |
| 9 #include "base/basictypes.h" |
| 10 #include "base/logging.h" |
7 #include "base/synchronization/lock.h" | 11 #include "base/synchronization/lock.h" |
8 #include "base/logging.h" | |
9 | 12 |
10 // We need two locks because they're sometimes grabbed at the same time. | 13 // We need two locks because they're sometimes grabbed at the same time. |
11 // A single lock would lead to an attempted recursive grab. | 14 // A single lock would lead to an attempted recursive grab. |
12 static base::Lock dtoa_locks[2]; | 15 static base::Lock dtoa_locks[2]; |
13 | 16 |
14 /* | 17 /* |
15 * This define and the code below is to trigger thread-safe behavior | 18 * This define and the code below is to trigger thread-safe behavior |
16 * in dtoa.cc, per this comment from the file: | 19 * in dtoa.cc, per this comment from the file: |
17 * | 20 * |
18 * #define MULTIPLE_THREADS if the system offers preemptively scheduled | 21 * #define MULTIPLE_THREADS if the system offers preemptively scheduled |
(...skipping 12 matching lines...) Expand all Loading... |
31 DCHECK(n < arraysize(dtoa_locks)); | 34 DCHECK(n < arraysize(dtoa_locks)); |
32 dtoa_locks[n].Acquire(); | 35 dtoa_locks[n].Acquire(); |
33 } | 36 } |
34 | 37 |
35 inline static void FREE_DTOA_LOCK(size_t n) { | 38 inline static void FREE_DTOA_LOCK(size_t n) { |
36 DCHECK(n < arraysize(dtoa_locks)); | 39 DCHECK(n < arraysize(dtoa_locks)); |
37 dtoa_locks[n].Release(); | 40 dtoa_locks[n].Release(); |
38 } | 41 } |
39 | 42 |
40 #include "base/third_party/dmg_fp/dtoa.cc" | 43 #include "base/third_party/dmg_fp/dtoa.cc" |
OLD | NEW |