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 | |
68 have_futex = (sizeof (Atomic32) == sizeof (int) && | 64 have_futex = (sizeof (Atomic32) == sizeof (int) && |
69 syscall(__NR_futex, &x, FUTEX_WAKE, 1, 0) >= 0); | 65 syscall(__NR_futex, &x, FUTEX_WAKE, 1, 0) >= 0); |
70 #endif | |
71 if (have_futex && | 66 if (have_futex && |
72 syscall(__NR_futex, &x, FUTEX_WAKE | futex_private_flag, 1, 0) < 0) { | 67 syscall(__NR_futex, &x, FUTEX_WAKE | futex_private_flag, 1, 0) < 0) { |
73 futex_private_flag = 0; | 68 futex_private_flag = 0; |
74 } | 69 } |
75 } | 70 } |
76 } init_module; | 71 } init_module; |
77 | 72 |
78 } // anonymous namespace | 73 } // anonymous namespace |
79 | 74 |
80 | 75 |
(...skipping 24 matching lines...) Expand all Loading... |
105 | 100 |
106 void SpinLockWake(volatile Atomic32 *w, bool all) { | 101 void SpinLockWake(volatile Atomic32 *w, bool all) { |
107 if (have_futex) { | 102 if (have_futex) { |
108 syscall(__NR_futex, reinterpret_cast<int *>(const_cast<Atomic32 *>(w)), | 103 syscall(__NR_futex, reinterpret_cast<int *>(const_cast<Atomic32 *>(w)), |
109 FUTEX_WAKE | futex_private_flag, 1, 0); | 104 FUTEX_WAKE | futex_private_flag, 1, 0); |
110 } | 105 } |
111 } | 106 } |
112 | 107 |
113 } // namespace internal | 108 } // namespace internal |
114 } // namespace base | 109 } // namespace base |
OLD | NEW |