[compiler-rt] r180102 - [MSan] Make a few interface functions accept 'const void *' instead of 'void*'

Alexey Samsonov samsonov at google.com
Tue Apr 23 06:34:19 PDT 2013


Author: samsonov
Date: Tue Apr 23 08:34:19 2013
New Revision: 180102

URL: http://llvm.org/viewvc/llvm-project?rev=180102&view=rev
Log:
[MSan] Make a few interface functions accept 'const void *' instead of 'void*'

Modified:
    compiler-rt/trunk/include/sanitizer/msan_interface.h
    compiler-rt/trunk/lib/msan/msan.cc
    compiler-rt/trunk/lib/msan/msan_interceptors.cc
    compiler-rt/trunk/lib/msan/msan_interface_internal.h

Modified: compiler-rt/trunk/include/sanitizer/msan_interface.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/include/sanitizer/msan_interface.h?rev=180102&r1=180101&r2=180102&view=diff
==============================================================================
--- compiler-rt/trunk/include/sanitizer/msan_interface.h (original)
+++ compiler-rt/trunk/include/sanitizer/msan_interface.h Tue Apr 23 08:34:19 2013
@@ -27,10 +27,10 @@ extern "C" {
 
 
   /* Set raw origin for the memory range. */
-  void __msan_set_origin(void *a, size_t size, uint32_t origin);
+  void __msan_set_origin(const void *a, size_t size, uint32_t origin);
 
   /* Get raw origin for an address. */
-  uint32_t __msan_get_origin(void *a);
+  uint32_t __msan_get_origin(const void *a);
 
   /* Returns non-zero if tracking origins. */
   int __msan_get_track_origins();
@@ -39,14 +39,14 @@ extern "C" {
   uint32_t __msan_get_umr_origin();
 
   /* Make memory region fully initialized (without changing its contents). */
-  void __msan_unpoison(void *a, size_t size);
+  void __msan_unpoison(const void *a, size_t size);
 
   /* Make memory region fully uninitialized (without changing its contents). */
-  void __msan_poison(void *a, size_t size);
+  void __msan_poison(const void *a, size_t size);
 
   /* Make memory region partially uninitialized (without changing its contents).
    */
-  void __msan_partial_poison(void* data, void* shadow, size_t size);
+  void __msan_partial_poison(const void* data, void* shadow, size_t size);
 
   /* Returns the offset of the first (at least partially) poisoned byte in the
      memory range, or -1 if the whole range is good. */
@@ -76,7 +76,7 @@ extern "C" {
 
   /* Tell MSan about newly allocated memory (ex.: custom allocator).
      Memory will be marked uninitialized, with origin at the call site. */
-  void __msan_allocated_memory(void* data, size_t size);
+  void __msan_allocated_memory(const void* data, size_t size);
 
 #else  // __has_feature(memory_sanitizer)
 

Modified: compiler-rt/trunk/lib/msan/msan.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan.cc?rev=180102&r1=180101&r2=180102&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan.cc (original)
+++ compiler-rt/trunk/lib/msan/msan.cc Tue Apr 23 08:34:19 2013
@@ -379,7 +379,7 @@ int __msan_get_param_tls_offset() {
   return param_tls_p - tls_base_p;
 }
 
-void __msan_partial_poison(void* data, void* shadow, uptr size) {
+void __msan_partial_poison(const void* data, void* shadow, uptr size) {
   internal_memcpy((void*)MEM_TO_SHADOW((uptr)data), shadow, size);
 }
 
@@ -388,7 +388,7 @@ void __msan_load_unpoisoned(void *src, u
   __msan_unpoison(dst, size);
 }
 
-void __msan_set_origin(void *a, uptr size, u32 origin) {
+void __msan_set_origin(const void *a, uptr size, u32 origin) {
   // Origin mapping is 4 bytes per 4 bytes of application memory.
   // Here we extend the range such that its left and right bounds are both
   // 4 byte aligned.
@@ -442,7 +442,7 @@ const char *__msan_get_origin_descr_if_s
 }
 
 
-u32 __msan_get_origin(void *a) {
+u32 __msan_get_origin(const void *a) {
   if (!__msan_track_origins) return 0;
   uptr x = (uptr)a;
   uptr aligned = x & ~3ULL;

Modified: compiler-rt/trunk/lib/msan/msan_interceptors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_interceptors.cc?rev=180102&r1=180101&r2=180102&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/msan/msan_interceptors.cc Tue Apr 23 08:34:19 2013
@@ -746,7 +746,7 @@ INTERCEPTOR(void *, malloc, SIZE_T size)
   return MsanReallocate(&stack, 0, size, sizeof(u64), false);
 }
 
-void __msan_allocated_memory(void* data, uptr size) {
+void __msan_allocated_memory(const void* data, uptr size) {
   GET_MALLOC_STACK_TRACE;
   if (flags()->poison_in_malloc)
     __msan_poison(data, size);
@@ -981,12 +981,12 @@ void *fast_memcpy(void *dst, const void
 
 // These interface functions reside here so that they can use
 // fast_memset, etc.
-void __msan_unpoison(void *a, uptr size) {
+void __msan_unpoison(const void *a, uptr size) {
   if (!MEM_IS_APP(a)) return;
   fast_memset((void*)MEM_TO_SHADOW((uptr)a), 0, size);
 }
 
-void __msan_poison(void *a, uptr size) {
+void __msan_poison(const void *a, uptr size) {
   if (!MEM_IS_APP(a)) return;
   fast_memset((void*)MEM_TO_SHADOW((uptr)a),
               __msan::flags()->poison_heap_with_zeroes ? 0 : -1, size);

Modified: compiler-rt/trunk/lib/msan/msan_interface_internal.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_interface_internal.h?rev=180102&r1=180101&r2=180102&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan_interface_internal.h (original)
+++ compiler-rt/trunk/lib/msan/msan_interface_internal.h Tue Apr 23 08:34:19 2013
@@ -38,7 +38,7 @@ SANITIZER_INTERFACE_ATTRIBUTE __attribut
 void __msan_warning_noreturn();
 
 SANITIZER_INTERFACE_ATTRIBUTE
-void __msan_unpoison(void *a, uptr size);
+void __msan_unpoison(const void *a, uptr size);
 SANITIZER_INTERFACE_ATTRIBUTE
 void __msan_clear_and_unpoison(void *a, uptr size);
 SANITIZER_INTERFACE_ATTRIBUTE
@@ -54,7 +54,7 @@ void __msan_copy_origin(void *dst, const
 SANITIZER_INTERFACE_ATTRIBUTE
 void __msan_move_poison(void *dst, const void *src, uptr size);
 SANITIZER_INTERFACE_ATTRIBUTE
-void __msan_poison(void *a, uptr size);
+void __msan_poison(const void *a, uptr size);
 SANITIZER_INTERFACE_ATTRIBUTE
 void __msan_poison_stack(void *a, uptr size);
 
@@ -69,11 +69,11 @@ SANITIZER_INTERFACE_ATTRIBUTE
 sptr __msan_test_shadow(const void *x, uptr size);
 
 SANITIZER_INTERFACE_ATTRIBUTE
-void __msan_set_origin(void *a, uptr size, u32 origin);
+void __msan_set_origin(const void *a, uptr size, u32 origin);
 SANITIZER_INTERFACE_ATTRIBUTE
 void __msan_set_alloca_origin(void *a, uptr size, const char *descr);
 SANITIZER_INTERFACE_ATTRIBUTE
-u32 __msan_get_origin(void *a);
+u32 __msan_get_origin(const void *a);
 
 SANITIZER_INTERFACE_ATTRIBUTE
 void __msan_clear_on_return();
@@ -114,12 +114,12 @@ u32 __msan_get_umr_origin();
 SANITIZER_INTERFACE_ATTRIBUTE
 const char *__msan_get_origin_descr_if_stack(u32 id);
 SANITIZER_INTERFACE_ATTRIBUTE
-void __msan_partial_poison(void* data, void* shadow, uptr size);
+void __msan_partial_poison(const void* data, void* shadow, uptr size);
 
 // Tell MSan about newly allocated memory (ex.: custom allocator).
 // Memory will be marked uninitialized, with origin at the call site.
 SANITIZER_INTERFACE_ATTRIBUTE
-void __msan_allocated_memory(void* data, uptr size);
+void __msan_allocated_memory(const void* data, uptr size);
 }  // extern "C"
 
 #endif  // MSAN_INTERFACE_INTERNAL_H





More information about the llvm-commits mailing list