Skip to content

Commit

Permalink
2016-05-19 Maxim Ostapenko <m.ostapenko@samsung.com>
Browse files Browse the repository at this point in the history
	PR sanitizer/64354
	* cppbuiltin.c (define_builtin_macros_for_compilation_flags): Add new
	builtin __SANITIZE_THREAD__ macros for fsanitize=thread switch.
	* doc/cpp.texi: Document new macros.

	* c-c++-common/tsan/sanitize-thread-macro.c: New test.


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@236457 138bc75d-0d04-0410-961f-82ee72b054a4
  • Loading branch information
chefmax committed May 19, 2016
1 parent cdc645f commit ed0b056
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 0 deletions.
7 changes: 7 additions & 0 deletions gcc/ChangeLog
@@ -1,3 +1,10 @@
2016-05-19 Maxim Ostapenko <m.ostapenko@samsung.com>

PR sanitizer/64354
* cppbuiltin.c (define_builtin_macros_for_compilation_flags): Add new
builtin __SANITIZE_THREAD__ macros for fsanitize=thread switch.
* doc/cpp.texi: Document new macros.

2016-05-19 Bin Cheng <bin.cheng@arm.com>

PR tree-optimization/69848
Expand Down
3 changes: 3 additions & 0 deletions gcc/cppbuiltin.c
Expand Up @@ -92,6 +92,9 @@ define_builtin_macros_for_compilation_flags (cpp_reader *pfile)
if (flag_sanitize & SANITIZE_ADDRESS)
cpp_define (pfile, "__SANITIZE_ADDRESS__");

if (flag_sanitize & SANITIZE_THREAD)
cpp_define (pfile, "__SANITIZE_THREAD__");

if (optimize_size)
cpp_define (pfile, "__OPTIMIZE_SIZE__");
if (optimize)
Expand Down
3 changes: 3 additions & 0 deletions gcc/doc/cpp.texi
Expand Up @@ -2362,6 +2362,9 @@ in use.
This macro is defined, with value 1, when @option{-fsanitize=address}
or @option{-fsanitize=kernel-address} are in use.

@item __SANITIZE_THREAD__
This macro is defined, with value 1, when @option{-fsanitize=thread} is in use.

@item __TIMESTAMP__
This macro expands to a string constant that describes the date and time
of the last modification of the current source file. The string constant
Expand Down
5 changes: 5 additions & 0 deletions gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
2016-05-19 Maxim Ostapenko <m.ostapenko@samsung.com>

PR sanitizer/64354
* c-c++-common/tsan/sanitize-thread-macro.c: New test.

2016-05-19 Richard Biener <rguenther@suse.de>

PR tree-optimization/70729
Expand Down
12 changes: 12 additions & 0 deletions gcc/testsuite/c-c++-common/tsan/sanitize-thread-macro.c
@@ -0,0 +1,12 @@
/* Check that -fsanitize=thread options defines __SANITIZE_THREAD__ macros. */
/* { dg-do compile } */
/* { dg-skip-if "" { *-*-* } { "*" } { "-O0" } } */

int
main ()
{
#ifndef __SANITIZE_THREAD__
bad construction
#endif
return 0;
}

0 comments on commit ed0b056

Please sign in to comment.