OLD | NEW |
---|---|
1 /* Copyright (c) 2010, Google Inc. | 1 /* Copyright (c) 2010, Google Inc. |
2 * All rights reserved. | 2 * All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 29 matching lines...) Expand all Loading... | |
40 // In all cases, it must return in bounded time even if SpinlockWake() is not | 40 // In all cases, it must return in bounded time even if SpinlockWake() is not |
41 // called. | 41 // called. |
42 | 42 |
43 #include "base/spinlock_internal.h" | 43 #include "base/spinlock_internal.h" |
44 | 44 |
45 // forward declaration for use by spinlock_*-inl.h | 45 // forward declaration for use by spinlock_*-inl.h |
46 namespace base { namespace internal { static int SuggestedDelayNS(int loop); }} | 46 namespace base { namespace internal { static int SuggestedDelayNS(int loop); }} |
47 | 47 |
48 #if defined(_WIN32) | 48 #if defined(_WIN32) |
49 #include "base/spinlock_win32-inl.h" | 49 #include "base/spinlock_win32-inl.h" |
50 #elif defined(__linux__) | 50 #elif defined(__linux__) && !defined(__ANDROID__) |
Dai Mikurube (NOT FULLTIME)
2013/05/03 08:53:00
spinlock_linux-inl doesn't work? How about adding
bulach
2013/05/07 14:55:51
good point! I mistakenly "un"defined HAVE_SYS_SYSC
| |
51 #include "base/spinlock_linux-inl.h" | 51 #include "base/spinlock_linux-inl.h" |
52 #else | 52 #else |
53 #include "base/spinlock_posix-inl.h" | 53 #include "base/spinlock_posix-inl.h" |
54 #endif | 54 #endif |
55 | 55 |
56 namespace base { | 56 namespace base { |
57 namespace internal { | 57 namespace internal { |
58 | 58 |
59 // See spinlock_internal.h for spec. | 59 // See spinlock_internal.h for spec. |
60 int32 SpinLockWait(volatile Atomic32 *w, int n, | 60 int32 SpinLockWait(volatile Atomic32 *w, int n, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
93 // Select top 20..24 bits of lower 48 bits, | 93 // Select top 20..24 bits of lower 48 bits, |
94 // giving approximately 0ms to 16ms. | 94 // giving approximately 0ms to 16ms. |
95 // Mean is exponential in loop for first 32 iterations, then 8ms. | 95 // Mean is exponential in loop for first 32 iterations, then 8ms. |
96 // The futex path multiplies this by 16, since we expect explicit wakeups | 96 // The futex path multiplies this by 16, since we expect explicit wakeups |
97 // almost always on that path. | 97 // almost always on that path. |
98 return r >> (44 - (loop >> 3)); | 98 return r >> (44 - (loop >> 3)); |
99 } | 99 } |
100 | 100 |
101 } // namespace internal | 101 } // namespace internal |
102 } // namespace base | 102 } // namespace base |
OLD | NEW |