| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef WTF_ContainerAnnotations_h | 5 #include "platform/wtf/ContainerAnnotations.h" |
| 6 #define WTF_ContainerAnnotations_h | |
| 7 | 6 |
| 8 #include "wtf/AddressSanitizer.h" | 7 // The contents of this header was moved to platform/wtf as part of |
| 9 #include "wtf/CPU.h" | 8 // WTF migration project. See the following post for details: |
| 10 | 9 // https://groups.google.com/a/chromium.org/d/msg/blink-dev/tLdAZCTlcAA/bYXVT8gY
CAAJ |
| 11 // TODO(ochang): Remove the CPU(X86_64) condition to enable this for X86 once | |
| 12 // the crashes there have been fixed: http://crbug.com/461406 | |
| 13 #if defined(ADDRESS_SANITIZER) && OS(LINUX) && CPU(X86_64) | |
| 14 #define ANNOTATE_CONTIGUOUS_CONTAINER | |
| 15 #define ANNOTATE_NEW_BUFFER(buffer, capacity, newSize) \ | |
| 16 if (buffer) { \ | |
| 17 __sanitizer_annotate_contiguous_container(buffer, (buffer) + (capacity), \ | |
| 18 (buffer) + (capacity), \ | |
| 19 (buffer) + (newSize)); \ | |
| 20 } | |
| 21 #define ANNOTATE_DELETE_BUFFER(buffer, capacity, oldSize) \ | |
| 22 if (buffer) { \ | |
| 23 __sanitizer_annotate_contiguous_container(buffer, (buffer) + (capacity), \ | |
| 24 (buffer) + (oldSize), \ | |
| 25 (buffer) + (capacity)); \ | |
| 26 } | |
| 27 #define ANNOTATE_CHANGE_SIZE(buffer, capacity, oldSize, newSize) \ | |
| 28 if (buffer) { \ | |
| 29 __sanitizer_annotate_contiguous_container(buffer, (buffer) + (capacity), \ | |
| 30 (buffer) + (oldSize), \ | |
| 31 (buffer) + (newSize)); \ | |
| 32 } | |
| 33 #define ANNOTATE_CHANGE_CAPACITY(buffer, oldCapacity, bufferSize, newCapacity) \ | |
| 34 ANNOTATE_DELETE_BUFFER(buffer, oldCapacity, bufferSize); \ | |
| 35 ANNOTATE_NEW_BUFFER(buffer, newCapacity, bufferSize); | |
| 36 // Annotations require buffers to begin on an 8-byte boundary. | |
| 37 #else // defined(ADDRESS_SANITIZER) && OS(LINUX) && CPU(X86_64) | |
| 38 #define ANNOTATE_NEW_BUFFER(buffer, capacity, newSize) | |
| 39 #define ANNOTATE_DELETE_BUFFER(buffer, capacity, oldSize) | |
| 40 #define ANNOTATE_CHANGE_SIZE(buffer, capacity, oldSize, newSize) | |
| 41 #define ANNOTATE_CHANGE_CAPACITY(buffer, oldCapacity, bufferSize, newCapacity) | |
| 42 #endif // defined(ADDRESS_SANITIZER) && OS(LINUX) && CPU(X86_64) | |
| 43 | |
| 44 #endif // WTF_ContainerAnnotations_h | |
| OLD | NEW |