| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. 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 * * Neither the name of Google Inc. nor the names of its | 10 * * Neither the name of Google Inc. nor the names of its |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 * with their own implementations. | 46 * with their own implementations. |
| 47 * | 47 * |
| 48 * See http://code.google.com/p/data-race-test/wiki/DynamicAnnotations for more
information. | 48 * See http://code.google.com/p/data-race-test/wiki/DynamicAnnotations for more
information. |
| 49 */ | 49 */ |
| 50 | 50 |
| 51 #include "wtf/WTFExport.h" | 51 #include "wtf/WTFExport.h" |
| 52 #include "wtf/build_config.h" | 52 #include "wtf/build_config.h" |
| 53 | 53 |
| 54 #if USE(DYNAMIC_ANNOTATIONS) | 54 #if USE(DYNAMIC_ANNOTATIONS) |
| 55 /* Tell data race detector that we're not interested in reports on the given add
ress range. */ | 55 /* Tell data race detector that we're not interested in reports on the given add
ress range. */ |
| 56 #define WTF_ANNOTATE_BENIGN_RACE_SIZED(address, size, description) WTFAnnotateBe
nignRaceSized(__FILE__, __LINE__, address, size, description) | 56 #define WTF_ANNOTATE_BENIGN_RACE_SIZED(address, size, description) \ |
| 57 #define WTF_ANNOTATE_BENIGN_RACE(pointer, description) WTFAnnotateBenignRaceSize
d(__FILE__, __LINE__, pointer, sizeof(*(pointer)), description) | 57 WTFAnnotateBenignRaceSized(__FILE__, __LINE__, address, size, description) |
| 58 #define WTF_ANNOTATE_BENIGN_RACE(pointer, description) \ |
| 59 WTFAnnotateBenignRaceSized(__FILE__, __LINE__, pointer, sizeof(*(pointer)), \ |
| 60 description) |
| 58 | 61 |
| 59 /* Annotations for user-defined synchronization mechanisms. | 62 /* Annotations for user-defined synchronization mechanisms. |
| 60 * These annotations can be used to define happens-before arcs in user-defined | 63 * These annotations can be used to define happens-before arcs in user-defined |
| 61 * synchronization mechanisms: the race detector will infer an arc from | 64 * synchronization mechanisms: the race detector will infer an arc from |
| 62 * the former to the latter when they share the same argument pointer. | 65 * the former to the latter when they share the same argument pointer. |
| 63 * | 66 * |
| 64 * The most common case requiring annotations is atomic reference counting: | 67 * The most common case requiring annotations is atomic reference counting: |
| 65 * bool deref() { | 68 * bool deref() { |
| 66 * ANNOTATE_HAPPENS_BEFORE(&m_refCount); | 69 * ANNOTATE_HAPPENS_BEFORE(&m_refCount); |
| 67 * if (!atomicDecrement(&m_refCount)) { | 70 * if (!atomicDecrement(&m_refCount)) { |
| 68 * // m_refCount is now 0 | 71 * // m_refCount is now 0 |
| 69 * ANNOTATE_HAPPENS_AFTER(&m_refCount); | 72 * ANNOTATE_HAPPENS_AFTER(&m_refCount); |
| 70 * // "return true; happens-after each atomicDecrement of m_refCount" | 73 * // "return true; happens-after each atomicDecrement of m_refCount" |
| 71 * return true; | 74 * return true; |
| 72 * } | 75 * } |
| 73 * return false; | 76 * return false; |
| 74 * } | 77 * } |
| 75 */ | 78 */ |
| 76 #define WTF_ANNOTATE_HAPPENS_BEFORE(address) WTFAnnotateHappensBefore(__FILE__,
__LINE__, address) | 79 #define WTF_ANNOTATE_HAPPENS_BEFORE(address) \ |
| 77 #define WTF_ANNOTATE_HAPPENS_AFTER(address) WTFAnnotateHappensAfter(__FILE__, __
LINE__, address) | 80 WTFAnnotateHappensBefore(__FILE__, __LINE__, address) |
| 81 #define WTF_ANNOTATE_HAPPENS_AFTER(address) \ |
| 82 WTFAnnotateHappensAfter(__FILE__, __LINE__, address) |
| 78 | 83 |
| 79 #ifdef __cplusplus | 84 #ifdef __cplusplus |
| 80 extern "C" { | 85 extern "C" { |
| 81 #endif | 86 #endif |
| 82 /* Don't use these directly, use the above macros instead. */ | 87 /* Don't use these directly, use the above macros instead. */ |
| 83 WTF_EXPORT void WTFAnnotateBenignRaceSized(const char* file, int line, const vol
atile void* memory, long size, const char* description); | 88 WTF_EXPORT void WTFAnnotateBenignRaceSized(const char* file, |
| 84 WTF_EXPORT void WTFAnnotateHappensBefore(const char* file, int line, const volat
ile void* address); | 89 int line, |
| 85 WTF_EXPORT void WTFAnnotateHappensAfter(const char* file, int line, const volati
le void* address); | 90 const volatile void* memory, |
| 91 long size, |
| 92 const char* description); |
| 93 WTF_EXPORT void WTFAnnotateHappensBefore(const char* file, |
| 94 int line, |
| 95 const volatile void* address); |
| 96 WTF_EXPORT void WTFAnnotateHappensAfter(const char* file, |
| 97 int line, |
| 98 const volatile void* address); |
| 86 #ifdef __cplusplus | 99 #ifdef __cplusplus |
| 87 } // extern "C" | 100 } // extern "C" |
| 88 #endif | 101 #endif |
| 89 | 102 |
| 90 #else // USE(DYNAMIC_ANNOTATIONS) | 103 #else // USE(DYNAMIC_ANNOTATIONS) |
| 91 /* These macros are empty when dynamic annotations are not enabled so you can | 104 /* These macros are empty when dynamic annotations are not enabled so you can |
| 92 * use them without affecting the performance of release binaries. */ | 105 * use them without affecting the performance of release binaries. */ |
| 93 #define WTF_ANNOTATE_BENIGN_RACE_SIZED(address, size, description) | 106 #define WTF_ANNOTATE_BENIGN_RACE_SIZED(address, size, description) |
| 94 #define WTF_ANNOTATE_BENIGN_RACE(pointer, description) | 107 #define WTF_ANNOTATE_BENIGN_RACE(pointer, description) |
| 95 #define WTF_ANNOTATE_HAPPENS_BEFORE(address) | 108 #define WTF_ANNOTATE_HAPPENS_BEFORE(address) |
| 96 #define WTF_ANNOTATE_HAPPENS_AFTER(address) | 109 #define WTF_ANNOTATE_HAPPENS_AFTER(address) |
| 97 #endif // USE(DYNAMIC_ANNOTATIONS) | 110 #endif // USE(DYNAMIC_ANNOTATIONS) |
| 98 | 111 |
| 99 #endif // WTF_DynamicAnnotations_h | 112 #endif // WTF_DynamicAnnotations_h |
| OLD | NEW |