OLD | NEW |
1 /* Copyright (c) 2009, Google Inc. | 1 /* Copyright (c) 2009, 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 static bool have_futex; | 55 static bool have_futex; |
56 static int futex_private_flag = FUTEX_PRIVATE_FLAG; | 56 static int futex_private_flag = FUTEX_PRIVATE_FLAG; |
57 | 57 |
58 namespace { | 58 namespace { |
59 static struct InitModule { | 59 static struct InitModule { |
60 InitModule() { | 60 InitModule() { |
61 int x = 0; | 61 int x = 0; |
62 // futexes are ints, so we can use them only when | 62 // futexes are ints, so we can use them only when |
63 // that's the same size as the lockword_ in SpinLock. | 63 // that's the same size as the lockword_ in SpinLock. |
| 64 #ifdef __arm__ |
| 65 // ARM linux doesn't support sys_futex1(void*, int, int, struct timespec*); |
| 66 have_futex = 0; |
| 67 #else |
64 have_futex = (sizeof (Atomic32) == sizeof (int) && | 68 have_futex = (sizeof (Atomic32) == sizeof (int) && |
65 syscall(__NR_futex, &x, FUTEX_WAKE, 1, 0) >= 0); | 69 syscall(__NR_futex, &x, FUTEX_WAKE, 1, 0) >= 0); |
| 70 #endif |
66 if (have_futex && | 71 if (have_futex && |
67 syscall(__NR_futex, &x, FUTEX_WAKE | futex_private_flag, 1, 0) < 0) { | 72 syscall(__NR_futex, &x, FUTEX_WAKE | futex_private_flag, 1, 0) < 0) { |
68 futex_private_flag = 0; | 73 futex_private_flag = 0; |
69 } | 74 } |
70 } | 75 } |
71 } init_module; | 76 } init_module; |
72 | 77 |
73 } // anonymous namespace | 78 } // anonymous namespace |
74 | 79 |
75 | 80 |
(...skipping 24 matching lines...) Expand all Loading... |
100 | 105 |
101 void SpinLockWake(volatile Atomic32 *w, bool all) { | 106 void SpinLockWake(volatile Atomic32 *w, bool all) { |
102 if (have_futex) { | 107 if (have_futex) { |
103 syscall(__NR_futex, reinterpret_cast<int *>(const_cast<Atomic32 *>(w)), | 108 syscall(__NR_futex, reinterpret_cast<int *>(const_cast<Atomic32 *>(w)), |
104 FUTEX_WAKE | futex_private_flag, 1, 0); | 109 FUTEX_WAKE | futex_private_flag, 1, 0); |
105 } | 110 } |
106 } | 111 } |
107 | 112 |
108 } // namespace internal | 113 } // namespace internal |
109 } // namespace base | 114 } // namespace base |
OLD | NEW |