Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: base/third_party/dmg_fp/dtoa_wrapper.cc

Issue 1647803004: Move base to DEPS (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/third_party/dmg_fp/dtoa.cc ('k') | base/third_party/dmg_fp/float_precision_crash.patch » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 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 // The purpose of this file is to supply the macro definintions necessary
6 // to make third_party/dmg_fp/dtoa.cc threadsafe.
7 #include "base/lazy_instance.h"
8 #include "base/logging.h"
9 #include "base/synchronization/lock.h"
10
11 // We need two locks because they're sometimes grabbed at the same time.
12 // A single lock would lead to an attempted recursive grab.
13 static base::LazyInstance<base::Lock>::Leaky
14 dtoa_lock_0 = LAZY_INSTANCE_INITIALIZER;
15 static base::LazyInstance<base::Lock>::Leaky
16 dtoa_lock_1 = LAZY_INSTANCE_INITIALIZER;
17
18 /*
19 * This define and the code below is to trigger thread-safe behavior
20 * in dtoa.cc, per this comment from the file:
21 *
22 * #define MULTIPLE_THREADS if the system offers preemptively scheduled
23 * multiple threads. In this case, you must provide (or suitably
24 * #define) two locks, acquired by ACQUIRE_DTOA_LOCK(n) and freed
25 * by FREE_DTOA_LOCK(n) for n = 0 or 1. (The second lock, accessed
26 * in pow5mult, ensures lazy evaluation of only one copy of high
27 * powers of 5; omitting this lock would introduce a small
28 * probability of wasting memory, but would otherwise be harmless.)
29 * You must also invoke freedtoa(s) to free the value s returned by
30 * dtoa. You may do so whether or not MULTIPLE_THREADS is #defined.
31 */
32 #define MULTIPLE_THREADS
33
34 inline static void ACQUIRE_DTOA_LOCK(size_t n) {
35 DCHECK(n < 2);
36 base::Lock* lock = n == 0 ? dtoa_lock_0.Pointer() : dtoa_lock_1.Pointer();
37 lock->Acquire();
38 }
39
40 inline static void FREE_DTOA_LOCK(size_t n) {
41 DCHECK(n < 2);
42 base::Lock* lock = n == 0 ? dtoa_lock_0.Pointer() : dtoa_lock_1.Pointer();
43 lock->Release();
44 }
45
46 #include "base/third_party/dmg_fp/dtoa.cc"
OLDNEW
« no previous file with comments | « base/third_party/dmg_fp/dtoa.cc ('k') | base/third_party/dmg_fp/float_precision_crash.patch » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698