OLD | NEW |
---|---|
1 // Copyright (c) 2005, Google Inc. | 1 // Copyright (c) 2005, 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 } | 117 } |
118 if (!__isthreaded) { | 118 if (!__isthreaded) { |
119 init_routine(); | 119 init_routine(); |
120 pthread_once_ran_before_threads = true; | 120 pthread_once_ran_before_threads = true; |
121 return 0; | 121 return 0; |
122 } | 122 } |
123 #endif | 123 #endif |
124 if (pthread_once) { | 124 if (pthread_once) { |
125 return pthread_once(ctl, init_routine); | 125 return pthread_once(ctl, init_routine); |
126 } else { | 126 } else { |
127 #if defined(__ANDROID__) | |
128 // Android's pthread_once_t is typedef volatile and memcmp only takes | |
Jeffrey Yasskin
2013/05/21 17:09:43
Are there any situations where Android is missing
digit1
2013/05/21 18:16:24
No, pthread_once() and pthread_once_t are definite
bulach
2013/05/22 07:41:41
thanks both! so it seems pthread_once is guarantee
| |
129 // const void*, cast the volatile away. | |
130 if (memcmp(const_cast<const void*>(reinterpret_cast<const volatile void*>( | |
Jeffrey Yasskin
2013/05/21 17:09:43
http://goto.google.com/c++03pdf [dcl.type.cv]p7 sa
Dai Mikurube (NOT FULLTIME)
2013/05/21 17:21:46
A comment from a side:
It's just a local change t
Dai Mikurube (NOT FULLTIME)
2013/05/21 17:26:12
Hmm, sorry. I might make a misunderstanding of yo
bulach
2013/05/22 07:41:41
thanks jeffrey! yeah, one of the previous patches
| |
131 ctl)), | |
132 const_cast<const void*>(reinterpret_cast<const volatile void*>( | |
133 &pthread_once_init)), | |
134 sizeof(*ctl)) == 0) { | |
135 #else | |
127 if (memcmp(ctl, &pthread_once_init, sizeof(*ctl)) == 0) { | 136 if (memcmp(ctl, &pthread_once_init, sizeof(*ctl)) == 0) { |
137 #endif | |
128 init_routine(); | 138 init_routine(); |
129 ++*(char*)(ctl); // make it so it's no longer equal to init | 139 ++*(char*)(ctl); // make it so it's no longer equal to init |
130 } | 140 } |
131 return 0; | 141 return 0; |
132 } | 142 } |
133 } | 143 } |
OLD | NEW |