| 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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 #endif /* DYNAMIC_ANNOTATIONS_ENABLED */ | 371 #endif /* DYNAMIC_ANNOTATIONS_ENABLED */ |
| 372 | 372 |
| 373 /* Macro definitions for GCC attributes that allow static thread safety | 373 /* Macro definitions for GCC attributes that allow static thread safety |
| 374 analysis to recognize and use some of the dynamic annotations as | 374 analysis to recognize and use some of the dynamic annotations as |
| 375 escape hatches. | 375 escape hatches. |
| 376 TODO(lcwu): remove the check for __SUPPORT_DYN_ANNOTATION__ once the | 376 TODO(lcwu): remove the check for __SUPPORT_DYN_ANNOTATION__ once the |
| 377 default crosstool/GCC supports these GCC attributes. */ | 377 default crosstool/GCC supports these GCC attributes. */ |
| 378 | 378 |
| 379 #define ANNOTALYSIS_STATIC_INLINE | 379 #define ANNOTALYSIS_STATIC_INLINE |
| 380 #define ANNOTALYSIS_SEMICOLON_OR_EMPTY_BODY ; | 380 #define ANNOTALYSIS_SEMICOLON_OR_EMPTY_BODY ; |
| 381 #define ANNOTALYSIS_IGNORE_READS_BEGIN |
| 382 #define ANNOTALYSIS_IGNORE_READS_END |
| 383 #define ANNOTALYSIS_IGNORE_WRITES_BEGIN |
| 384 #define ANNOTALYSIS_IGNORE_WRITES_END |
| 385 #define ANNOTALYSIS_UNPROTECTED_READ |
| 381 | 386 |
| 382 #if defined(__GNUC__) && defined(__SUPPORT_TS_ANNOTATION__) \ | 387 #if defined(__GNUC__) && (!defined(SWIG)) && (!defined(__clang__)) && \ |
| 383 && (!defined(SWIG)) && defined(__SUPPORT_DYN_ANNOTATION__) | 388 defined(__SUPPORT_TS_ANNOTATION__) && defined(__SUPPORT_DYN_ANNOTATION__) |
| 384 | 389 |
| 385 #if DYNAMIC_ANNOTATIONS_ENABLED == 0 | 390 #if DYNAMIC_ANNOTATIONS_ENABLED == 0 |
| 386 #define ANNOTALYSIS_ONLY 1 | 391 #define ANNOTALYSIS_ONLY 1 |
| 387 #undef ANNOTALYSIS_STATIC_INLINE | 392 #undef ANNOTALYSIS_STATIC_INLINE |
| 388 #define ANNOTALYSIS_STATIC_INLINE static inline | 393 #define ANNOTALYSIS_STATIC_INLINE static inline |
| 389 #undef ANNOTALYSIS_SEMICOLON_OR_EMPTY_BODY | 394 #undef ANNOTALYSIS_SEMICOLON_OR_EMPTY_BODY |
| 390 #define ANNOTALYSIS_SEMICOLON_OR_EMPTY_BODY { (void)file; (void)line; } | 395 #define ANNOTALYSIS_SEMICOLON_OR_EMPTY_BODY { (void)file; (void)line; } |
| 391 #endif | 396 #endif |
| 392 #define ANNOTALYSIS_IGNORE_READS_BEGIN __attribute__ ((ignore_reads_begin)) | |
| 393 #define ANNOTALYSIS_IGNORE_READS_END __attribute__ ((ignore_reads_end)) | |
| 394 #define ANNOTALYSIS_IGNORE_WRITES_BEGIN __attribute__ ((ignore_writes_begin)) | |
| 395 #define ANNOTALYSIS_IGNORE_WRITES_END __attribute__ ((ignore_writes_end)) | |
| 396 #define ANNOTALYSIS_UNPROTECTED_READ __attribute__ ((unprotected_read)) | |
| 397 | 397 |
| 398 #else | 398 /* Only emit attributes when annotalysis is enabled. */ |
| 399 #if defined(__SUPPORT_TS_ANNOTATION__) && defined(__SUPPORT_DYN_ANNOTATION__) |
| 400 #undef ANNOTALYSIS_IGNORE_READS_BEGIN |
| 401 #define ANNOTALYSIS_IGNORE_READS_BEGIN __attribute__ ((ignore_reads_begin)) |
| 402 #undef ANNOTALYSIS_IGNORE_READS_END |
| 403 #define ANNOTALYSIS_IGNORE_READS_END __attribute__ ((ignore_reads_end)) |
| 404 #undef ANNOTALYSIS_IGNORE_WRITES_BEGIN |
| 405 #define ANNOTALYSIS_IGNORE_WRITES_BEGIN __attribute__ ((ignore_writes_begin)) |
| 406 #undef ANNOTALYSIS_IGNORE_WRITES_END |
| 407 #define ANNOTALYSIS_IGNORE_WRITES_END __attribute__ ((ignore_writes_end)) |
| 408 #undef ANNOTALYSIS_UNPROTECTED_READ |
| 409 #define ANNOTALYSIS_UNPROTECTED_READ __attribute__ ((unprotected_read)) |
| 410 #endif |
| 399 | 411 |
| 400 #define ANNOTALYSIS_IGNORE_READS_BEGIN | 412 #endif // defined(__GNUC__) && (!defined(SWIG)) && (!defined(__clang__)) |
| 401 #define ANNOTALYSIS_IGNORE_READS_END | |
| 402 #define ANNOTALYSIS_IGNORE_WRITES_BEGIN | |
| 403 #define ANNOTALYSIS_IGNORE_WRITES_END | |
| 404 #define ANNOTALYSIS_UNPROTECTED_READ | |
| 405 | |
| 406 #endif | |
| 407 | 413 |
| 408 /* Use the macros above rather than using these functions directly. */ | 414 /* Use the macros above rather than using these functions directly. */ |
| 409 #ifdef __cplusplus | 415 #ifdef __cplusplus |
| 410 extern "C" { | 416 extern "C" { |
| 411 #endif | 417 #endif |
| 412 void AnnotateRWLockCreate(const char *file, int line, | 418 void AnnotateRWLockCreate(const char *file, int line, |
| 413 const volatile void *lock); | 419 const volatile void *lock); |
| 414 void AnnotateRWLockDestroy(const char *file, int line, | 420 void AnnotateRWLockDestroy(const char *file, int line, |
| 415 const volatile void *lock); | 421 const volatile void *lock); |
| 416 void AnnotateRWLockAcquired(const char *file, int line, | 422 void AnnotateRWLockAcquired(const char *file, int line, |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 #define ANNOTATE_IGNORE_READS_AND_WRITES_END() \ | 603 #define ANNOTATE_IGNORE_READS_AND_WRITES_END() \ |
| 598 do { \ | 604 do { \ |
| 599 ANNOTATE_IGNORE_WRITES_END(); \ | 605 ANNOTATE_IGNORE_WRITES_END(); \ |
| 600 ANNOTATE_IGNORE_READS_END(); \ | 606 ANNOTATE_IGNORE_READS_END(); \ |
| 601 }while(0) \ | 607 }while(0) \ |
| 602 | 608 |
| 603 #if defined(__cplusplus) | 609 #if defined(__cplusplus) |
| 604 #undef ANNOTATE_UNPROTECTED_READ | 610 #undef ANNOTATE_UNPROTECTED_READ |
| 605 template <class T> | 611 template <class T> |
| 606 inline T ANNOTATE_UNPROTECTED_READ(const volatile T &x) | 612 inline T ANNOTATE_UNPROTECTED_READ(const volatile T &x) |
| 607 __attribute__ ((unprotected_read)) { | 613 ANNOTALYSIS_UNPROTECTED_READ { |
| 608 ANNOTATE_IGNORE_READS_BEGIN(); | 614 ANNOTATE_IGNORE_READS_BEGIN(); |
| 609 T res = x; | 615 T res = x; |
| 610 ANNOTATE_IGNORE_READS_END(); | 616 ANNOTATE_IGNORE_READS_END(); |
| 611 return res; | 617 return res; |
| 612 } | 618 } |
| 613 #endif /* __cplusplus */ | 619 #endif /* __cplusplus */ |
| 614 | 620 |
| 615 #endif /* ANNOTALYSIS_ONLY */ | 621 #endif /* ANNOTALYSIS_ONLY */ |
| 616 | 622 |
| 617 /* Undefine the macros intended only in this file. */ | 623 /* Undefine the macros intended only in this file. */ |
| 618 #undef ANNOTALYSIS_STATIC_INLINE | 624 #undef ANNOTALYSIS_STATIC_INLINE |
| 619 #undef ANNOTALYSIS_SEMICOLON_OR_EMPTY_BODY | 625 #undef ANNOTALYSIS_SEMICOLON_OR_EMPTY_BODY |
| 620 | 626 |
| 621 #endif /* BASE_DYNAMIC_ANNOTATIONS_H_ */ | 627 #endif /* BASE_DYNAMIC_ANNOTATIONS_H_ */ |
| OLD | NEW |