| OLD | NEW |
| 1 /* Copyright (c) 2008, Google Inc. | 1 /* Copyright (c) 2008, 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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 // } | 196 // } |
| 197 // tmp->DoSomething(); | 197 // tmp->DoSomething(); |
| 198 // } | 198 // } |
| 199 #define ANNOTATE_SWAP_MEMORY_RANGE(pointer, size) \ | 199 #define ANNOTATE_SWAP_MEMORY_RANGE(pointer, size) \ |
| 200 do { \ | 200 do { \ |
| 201 ANNOTATE_UNPUBLISH_MEMORY_RANGE(pointer, size); \ | 201 ANNOTATE_UNPUBLISH_MEMORY_RANGE(pointer, size); \ |
| 202 ANNOTATE_PUBLISH_MEMORY_RANGE(pointer, size); \ | 202 ANNOTATE_PUBLISH_MEMORY_RANGE(pointer, size); \ |
| 203 } while (0) | 203 } while (0) |
| 204 | 204 |
| 205 // Instruct the tool to create a happens-before arc between mu->Unlock() and | 205 // Instruct the tool to create a happens-before arc between mu->Unlock() and |
| 206 // mu->Lock(). This annotation may slow down the race detector; normally it | 206 // mu->Lock(). This annotation may slow down the race detector and hide real |
| 207 // is used only when it would be difficult to annotate each of the mutex's | 207 // races. Normally it is used only when it would be difficult to annotate each |
| 208 // critical sections individually using the annotations above. | 208 // of the mutex's critical sections individually using the annotations above. |
| 209 // This annotation makes sense only for hybrid race detectors. For pure |
| 210 // happens-before detectors this is a no-op. For more details see |
| 211 // http://code.google.com/p/data-race-test/wiki/PureHappensBeforeVsHybrid . |
| 212 #define ANNOTATE_PURE_HAPPENS_BEFORE_MUTEX(mu) \ |
| 213 AnnotateMutexIsUsedAsCondVar(__FILE__, __LINE__, mu) |
| 214 |
| 215 // Deprecated. Use ANNOTATE_PURE_HAPPENS_BEFORE_MUTEX. |
| 209 #define ANNOTATE_MUTEX_IS_USED_AS_CONDVAR(mu) \ | 216 #define ANNOTATE_MUTEX_IS_USED_AS_CONDVAR(mu) \ |
| 210 AnnotateMutexIsUsedAsCondVar(__FILE__, __LINE__, mu) | 217 AnnotateMutexIsUsedAsCondVar(__FILE__, __LINE__, mu) |
| 211 | 218 |
| 212 // ------------------------------------------------------------- | 219 // ------------------------------------------------------------- |
| 213 // Annotations useful when defining memory allocators, or when memory that | 220 // Annotations useful when defining memory allocators, or when memory that |
| 214 // was protected in one way starts to be protected in another. | 221 // was protected in one way starts to be protected in another. |
| 215 | 222 |
| 216 // Report that a new memory at "address" of size "size" has been allocated. | 223 // Report that a new memory at "address" of size "size" has been allocated. |
| 217 // This might be used when the memory has been retrieved from a free list and | 224 // This might be used when the memory has been retrieved from a free list and |
| 218 // is about to be reused, or when a the locking discipline for a variable | 225 // is about to be reused, or when a the locking discipline for a variable |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 #define ANNOTATE_PUBLISH_MEMORY_RANGE(address, size) // empty | 357 #define ANNOTATE_PUBLISH_MEMORY_RANGE(address, size) // empty |
| 351 #define ANNOTATE_UNPUBLISH_MEMORY_RANGE(address, size) // empty | 358 #define ANNOTATE_UNPUBLISH_MEMORY_RANGE(address, size) // empty |
| 352 #define ANNOTATE_SWAP_MEMORY_RANGE(address, size) // empty | 359 #define ANNOTATE_SWAP_MEMORY_RANGE(address, size) // empty |
| 353 #define ANNOTATE_PCQ_CREATE(pcq) // empty | 360 #define ANNOTATE_PCQ_CREATE(pcq) // empty |
| 354 #define ANNOTATE_PCQ_DESTROY(pcq) // empty | 361 #define ANNOTATE_PCQ_DESTROY(pcq) // empty |
| 355 #define ANNOTATE_PCQ_PUT(pcq) // empty | 362 #define ANNOTATE_PCQ_PUT(pcq) // empty |
| 356 #define ANNOTATE_PCQ_GET(pcq) // empty | 363 #define ANNOTATE_PCQ_GET(pcq) // empty |
| 357 #define ANNOTATE_NEW_MEMORY(address, size) // empty | 364 #define ANNOTATE_NEW_MEMORY(address, size) // empty |
| 358 #define ANNOTATE_EXPECT_RACE(address, description) // empty | 365 #define ANNOTATE_EXPECT_RACE(address, description) // empty |
| 359 #define ANNOTATE_BENIGN_RACE(address, description) // empty | 366 #define ANNOTATE_BENIGN_RACE(address, description) // empty |
| 367 #define ANNOTATE_PURE_HAPPENS_BEFORE_MUTEX(mu) // empty |
| 360 #define ANNOTATE_MUTEX_IS_USED_AS_CONDVAR(mu) // empty | 368 #define ANNOTATE_MUTEX_IS_USED_AS_CONDVAR(mu) // empty |
| 361 #define ANNOTATE_TRACE_MEMORY(arg) // empty | 369 #define ANNOTATE_TRACE_MEMORY(arg) // empty |
| 362 #define ANNOTATE_THREAD_NAME(name) // empty | 370 #define ANNOTATE_THREAD_NAME(name) // empty |
| 363 #define ANNOTATE_IGNORE_READS_BEGIN() // empty | 371 #define ANNOTATE_IGNORE_READS_BEGIN() // empty |
| 364 #define ANNOTATE_IGNORE_READS_END() // empty | 372 #define ANNOTATE_IGNORE_READS_END() // empty |
| 365 #define ANNOTATE_IGNORE_WRITES_BEGIN() // empty | 373 #define ANNOTATE_IGNORE_WRITES_BEGIN() // empty |
| 366 #define ANNOTATE_IGNORE_WRITES_END() // empty | 374 #define ANNOTATE_IGNORE_WRITES_END() // empty |
| 367 #define ANNOTATE_IGNORE_READS_AND_WRITES_BEGIN() // empty | 375 #define ANNOTATE_IGNORE_READS_AND_WRITES_BEGIN() // empty |
| 368 #define ANNOTATE_IGNORE_READS_AND_WRITES_END() // empty | 376 #define ANNOTATE_IGNORE_READS_AND_WRITES_END() // empty |
| 369 #define ANNOTATE_NO_OP(arg) // empty | 377 #define ANNOTATE_NO_OP(arg) // empty |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 #define ANNOTATE_UNPROTECTED_READ(x) (x) | 466 #define ANNOTATE_UNPROTECTED_READ(x) (x) |
| 459 #define ANNOTATE_BENIGN_RACE_STATIC(static_var, description) // empty | 467 #define ANNOTATE_BENIGN_RACE_STATIC(static_var, description) // empty |
| 460 | 468 |
| 461 #endif // !NDEBUG | 469 #endif // !NDEBUG |
| 462 | 470 |
| 463 // Return non-zero value if running under valgrind. | 471 // Return non-zero value if running under valgrind. |
| 464 extern "C" int RunningOnValgrind(); | 472 extern "C" int RunningOnValgrind(); |
| 465 | 473 |
| 466 | 474 |
| 467 #endif // BASE_DYNAMIC_ANNOTATIONS_H_ | 475 #endif // BASE_DYNAMIC_ANNOTATIONS_H_ |
| OLD | NEW |