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 | |
386 | 381 |
387 #if defined(__GNUC__) && (!defined(SWIG)) && (!defined(__clang__)) && \ | 382 #if defined(__GNUC__) && defined(__SUPPORT_TS_ANNOTATION__) \ |
388 defined(__SUPPORT_TS_ANNOTATION__) && defined(__SUPPORT_DYN_ANNOTATION__) | 383 && (!defined(SWIG)) && defined(__SUPPORT_DYN_ANNOTATION__) |
389 | 384 |
390 #if DYNAMIC_ANNOTATIONS_ENABLED == 0 | 385 #if DYNAMIC_ANNOTATIONS_ENABLED == 0 |
391 #define ANNOTALYSIS_ONLY 1 | 386 #define ANNOTALYSIS_ONLY 1 |
392 #undef ANNOTALYSIS_STATIC_INLINE | 387 #undef ANNOTALYSIS_STATIC_INLINE |
393 #define ANNOTALYSIS_STATIC_INLINE static inline | 388 #define ANNOTALYSIS_STATIC_INLINE static inline |
394 #undef ANNOTALYSIS_SEMICOLON_OR_EMPTY_BODY | 389 #undef ANNOTALYSIS_SEMICOLON_OR_EMPTY_BODY |
395 #define ANNOTALYSIS_SEMICOLON_OR_EMPTY_BODY { (void)file; (void)line; } | 390 #define ANNOTALYSIS_SEMICOLON_OR_EMPTY_BODY { (void)file; (void)line; } |
396 #endif | 391 #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 /* Only emit attributes when annotalysis is enabled. */ | 398 #else |
399 #if defined(__SUPPORT_TS_ANNOTATION__) && defined(__SUPPORT_DYN_ANNOTATION__) | 399 |
400 #undef ANNOTALYSIS_IGNORE_READS_BEGIN | 400 #define ANNOTALYSIS_IGNORE_READS_BEGIN |
401 #define ANNOTALYSIS_IGNORE_READS_BEGIN __attribute__ ((ignore_reads_begin)) | 401 #define ANNOTALYSIS_IGNORE_READS_END |
402 #undef ANNOTALYSIS_IGNORE_READS_END | 402 #define ANNOTALYSIS_IGNORE_WRITES_BEGIN |
403 #define ANNOTALYSIS_IGNORE_READS_END __attribute__ ((ignore_reads_end)) | 403 #define ANNOTALYSIS_IGNORE_WRITES_END |
404 #undef ANNOTALYSIS_IGNORE_WRITES_BEGIN | 404 #define ANNOTALYSIS_UNPROTECTED_READ |
405 #define ANNOTALYSIS_IGNORE_WRITES_BEGIN __attribute__ ((ignore_writes_begin)) | 405 |
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 | 406 #endif |
411 | 407 |
412 #endif // defined(__GNUC__) && (!defined(SWIG)) && (!defined(__clang__)) | |
413 | |
414 /* Use the macros above rather than using these functions directly. */ | 408 /* Use the macros above rather than using these functions directly. */ |
415 #ifdef __cplusplus | 409 #ifdef __cplusplus |
416 extern "C" { | 410 extern "C" { |
417 #endif | 411 #endif |
418 void AnnotateRWLockCreate(const char *file, int line, | 412 void AnnotateRWLockCreate(const char *file, int line, |
419 const volatile void *lock); | 413 const volatile void *lock); |
420 void AnnotateRWLockDestroy(const char *file, int line, | 414 void AnnotateRWLockDestroy(const char *file, int line, |
421 const volatile void *lock); | 415 const volatile void *lock); |
422 void AnnotateRWLockAcquired(const char *file, int line, | 416 void AnnotateRWLockAcquired(const char *file, int line, |
423 const volatile void *lock, long is_w); | 417 const volatile void *lock, long is_w); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 #define ANNOTATE_IGNORE_READS_AND_WRITES_END() \ | 597 #define ANNOTATE_IGNORE_READS_AND_WRITES_END() \ |
604 do { \ | 598 do { \ |
605 ANNOTATE_IGNORE_WRITES_END(); \ | 599 ANNOTATE_IGNORE_WRITES_END(); \ |
606 ANNOTATE_IGNORE_READS_END(); \ | 600 ANNOTATE_IGNORE_READS_END(); \ |
607 }while(0) \ | 601 }while(0) \ |
608 | 602 |
609 #if defined(__cplusplus) | 603 #if defined(__cplusplus) |
610 #undef ANNOTATE_UNPROTECTED_READ | 604 #undef ANNOTATE_UNPROTECTED_READ |
611 template <class T> | 605 template <class T> |
612 inline T ANNOTATE_UNPROTECTED_READ(const volatile T &x) | 606 inline T ANNOTATE_UNPROTECTED_READ(const volatile T &x) |
613 ANNOTALYSIS_UNPROTECTED_READ { | 607 __attribute__ ((unprotected_read)) { |
614 ANNOTATE_IGNORE_READS_BEGIN(); | 608 ANNOTATE_IGNORE_READS_BEGIN(); |
615 T res = x; | 609 T res = x; |
616 ANNOTATE_IGNORE_READS_END(); | 610 ANNOTATE_IGNORE_READS_END(); |
617 return res; | 611 return res; |
618 } | 612 } |
619 #endif /* __cplusplus */ | 613 #endif /* __cplusplus */ |
620 | 614 |
621 #endif /* ANNOTALYSIS_ONLY */ | 615 #endif /* ANNOTALYSIS_ONLY */ |
622 | 616 |
623 /* Undefine the macros intended only in this file. */ | 617 /* Undefine the macros intended only in this file. */ |
624 #undef ANNOTALYSIS_STATIC_INLINE | 618 #undef ANNOTALYSIS_STATIC_INLINE |
625 #undef ANNOTALYSIS_SEMICOLON_OR_EMPTY_BODY | 619 #undef ANNOTALYSIS_SEMICOLON_OR_EMPTY_BODY |
626 | 620 |
627 #endif /* BASE_DYNAMIC_ANNOTATIONS_H_ */ | 621 #endif /* BASE_DYNAMIC_ANNOTATIONS_H_ */ |
OLD | NEW |