#include "pub_core_redir.h" // for VG_REPLACE_FUNCTION_*
#include "pub_core_replacemalloc.h"
-/* Assignment of behavioural equivalence class tags: 1NNN is intended
+/* Assignment of behavioural equivalence class tags: 1NNNP is intended
to be reserved for the Valgrind core. Current usage:
10010 ALLOC_or_NULL
}
/* Same problem with getpagesize. */
-static inline int my_getpagesize ( void ) {
+static inline int my_getpagesize ( void )
+{
# if defined(VGPV_arm_linux_android)
return 4096; /* kludge - link failure on Android, for some reason */
# else
// (from_so, from_fn, v's replacement)
// malloc
-ALLOC_or_NULL(VG_Z_LIBSTDCXX_SONAME, malloc, malloc);
-ALLOC_or_NULL(VG_Z_LIBC_SONAME, malloc, malloc);
-#if defined(VGO_darwin)
-ZONEALLOC_or_NULL(VG_Z_LIBC_SONAME, malloc_zone_malloc, malloc);
-#endif
+#if defined(VGO_linux)
+ ALLOC_or_NULL(VG_Z_LIBSTDCXX_SONAME, malloc, malloc);
+ ALLOC_or_NULL(VG_Z_LIBC_SONAME, malloc, malloc);
+#elif defined(VGO_darwin)
+ ALLOC_or_NULL(VG_Z_LIBSTDCXX_SONAME, malloc, malloc);
+ ALLOC_or_NULL(VG_Z_LIBC_SONAME, malloc, malloc);
+ ZONEALLOC_or_NULL(VG_Z_LIBC_SONAME, malloc_zone_malloc, malloc);
-/*---------------------- new ----------------------*/
+#endif
-// operator new(unsigned int), not mangled (for gcc 2.96)
-ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, builtin_new, __builtin_new);
-ALLOC_or_BOMB(VG_Z_LIBC_SONAME, builtin_new, __builtin_new);
-ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, __builtin_new, __builtin_new);
-ALLOC_or_BOMB(VG_Z_LIBC_SONAME, __builtin_new, __builtin_new);
+/*---------------------- new ----------------------*/
-// operator new(unsigned int), GNU mangling
-#if VG_WORDSIZE == 4
- ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, _Znwj, __builtin_new);
- ALLOC_or_BOMB(VG_Z_LIBC_SONAME, _Znwj, __builtin_new);
-#endif
+#if defined(VGO_linux)
+ // operator new(unsigned int), not mangled (for gcc 2.96)
+ ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, builtin_new, __builtin_new);
+ ALLOC_or_BOMB(VG_Z_LIBC_SONAME, builtin_new, __builtin_new);
+ ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, __builtin_new, __builtin_new);
+ ALLOC_or_BOMB(VG_Z_LIBC_SONAME, __builtin_new, __builtin_new);
+ // operator new(unsigned int), GNU mangling
+ #if VG_WORDSIZE == 4
+ ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, _Znwj, __builtin_new);
+ ALLOC_or_BOMB(VG_Z_LIBC_SONAME, _Znwj, __builtin_new);
+ #endif
+ // operator new(unsigned long), GNU mangling
+ #if VG_WORDSIZE == 8
+ ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, _Znwm, __builtin_new);
+ ALLOC_or_BOMB(VG_Z_LIBC_SONAME, _Znwm, __builtin_new);
+ #endif
+
+#elif defined(VGO_darwin)
+ // operator new(unsigned int), GNU mangling
+ #if VG_WORDSIZE == 4
+ ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, _Znwj, __builtin_new);
+ ALLOC_or_BOMB(VG_Z_LIBC_SONAME, _Znwj, __builtin_new);
+ #endif
+ // operator new(unsigned long), GNU mangling
+ #if 1 // FIXME: is this right?
+ ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, _Znwm, __builtin_new);
+ ALLOC_or_BOMB(VG_Z_LIBC_SONAME, _Znwm, __builtin_new);
+ #endif
-// operator new(unsigned long), GNU mangling
-#if VG_WORDSIZE == 8 || defined(VGO_darwin)
- ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, _Znwm, __builtin_new);
- ALLOC_or_BOMB(VG_Z_LIBC_SONAME, _Znwm, __builtin_new);
#endif
/*---------------------- new nothrow ----------------------*/
-// operator new(unsigned, std::nothrow_t const&), GNU mangling
-#if VG_WORDSIZE == 4
- ALLOC_or_NULL(VG_Z_LIBSTDCXX_SONAME, _ZnwjRKSt9nothrow_t, __builtin_new);
- ALLOC_or_NULL(VG_Z_LIBC_SONAME, _ZnwjRKSt9nothrow_t, __builtin_new);
-#endif
+#if defined(VGO_linux)
+ // operator new(unsigned, std::nothrow_t const&), GNU mangling
+ #if VG_WORDSIZE == 4
+ ALLOC_or_NULL(VG_Z_LIBSTDCXX_SONAME, _ZnwjRKSt9nothrow_t, __builtin_new);
+ ALLOC_or_NULL(VG_Z_LIBC_SONAME, _ZnwjRKSt9nothrow_t, __builtin_new);
+ #endif
+ // operator new(unsigned long, std::nothrow_t const&), GNU mangling
+ #if VG_WORDSIZE == 8
+ ALLOC_or_NULL(VG_Z_LIBSTDCXX_SONAME, _ZnwmRKSt9nothrow_t, __builtin_new);
+ ALLOC_or_NULL(VG_Z_LIBC_SONAME, _ZnwmRKSt9nothrow_t, __builtin_new);
+ #endif
+
+#elif defined(VGO_darwin)
+ // operator new(unsigned, std::nothrow_t const&), GNU mangling
+ #if VG_WORDSIZE == 4
+ ALLOC_or_NULL(VG_Z_LIBSTDCXX_SONAME, _ZnwjRKSt9nothrow_t, __builtin_new);
+ ALLOC_or_NULL(VG_Z_LIBC_SONAME, _ZnwjRKSt9nothrow_t, __builtin_new);
+ #endif
+ // operator new(unsigned long, std::nothrow_t const&), GNU mangling
+ #if 1 // FIXME: is this right?
+ ALLOC_or_NULL(VG_Z_LIBSTDCXX_SONAME, _ZnwmRKSt9nothrow_t, __builtin_new);
+ ALLOC_or_NULL(VG_Z_LIBC_SONAME, _ZnwmRKSt9nothrow_t, __builtin_new);
+ #endif
-// operator new(unsigned long, std::nothrow_t const&), GNU mangling
-#if VG_WORDSIZE == 8 || defined(VGO_darwin)
- ALLOC_or_NULL(VG_Z_LIBSTDCXX_SONAME, _ZnwmRKSt9nothrow_t, __builtin_new);
- ALLOC_or_NULL(VG_Z_LIBC_SONAME, _ZnwmRKSt9nothrow_t, __builtin_new);
#endif
/*---------------------- new [] ----------------------*/
-// operator new[](unsigned int), not mangled (for gcc 2.96)
-ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, __builtin_vec_new, __builtin_vec_new );
-ALLOC_or_BOMB(VG_Z_LIBC_SONAME, __builtin_vec_new, __builtin_vec_new );
+#if defined(VGO_linux)
+ // operator new[](unsigned int), not mangled (for gcc 2.96)
+ ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, __builtin_vec_new, __builtin_vec_new );
+ ALLOC_or_BOMB(VG_Z_LIBC_SONAME, __builtin_vec_new, __builtin_vec_new );
+ // operator new[](unsigned int), GNU mangling
+ #if VG_WORDSIZE == 4
+ ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, _Znaj, __builtin_vec_new );
+ ALLOC_or_BOMB(VG_Z_LIBC_SONAME, _Znaj, __builtin_vec_new );
+ #endif
+ // operator new[](unsigned long), GNU mangling
+ #if VG_WORDSIZE == 8
+ ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, _Znam, __builtin_vec_new );
+ ALLOC_or_BOMB(VG_Z_LIBC_SONAME, _Znam, __builtin_vec_new );
+ #endif
+
+#elif defined(VGO_darwin)
+ // operator new[](unsigned int), GNU mangling
+ #if VG_WORDSIZE == 4
+ ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, _Znaj, __builtin_vec_new );
+ ALLOC_or_BOMB(VG_Z_LIBC_SONAME, _Znaj, __builtin_vec_new );
+ #endif
+ // operator new[](unsigned long), GNU mangling
+ #if 1 // FIXME: is this right?
+ ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, _Znam, __builtin_vec_new );
+ ALLOC_or_BOMB(VG_Z_LIBC_SONAME, _Znam, __builtin_vec_new );
+ #endif
-// operator new[](unsigned int), GNU mangling
-#if VG_WORDSIZE == 4
- ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, _Znaj, __builtin_vec_new );
- ALLOC_or_BOMB(VG_Z_LIBC_SONAME, _Znaj, __builtin_vec_new );
-#endif
-
-// operator new[](unsigned long), GNU mangling
-#if VG_WORDSIZE == 8 || defined(VGO_darwin)
- ALLOC_or_BOMB(VG_Z_LIBSTDCXX_SONAME, _Znam, __builtin_vec_new );
- ALLOC_or_BOMB(VG_Z_LIBC_SONAME, _Znam, __builtin_vec_new );
#endif
/*---------------------- new [] nothrow ----------------------*/
-// operator new[](unsigned, std::nothrow_t const&), GNU mangling
-#if VG_WORDSIZE == 4
- ALLOC_or_NULL(VG_Z_LIBSTDCXX_SONAME, _ZnajRKSt9nothrow_t, __builtin_vec_new );
- ALLOC_or_NULL(VG_Z_LIBC_SONAME, _ZnajRKSt9nothrow_t, __builtin_vec_new );
-#endif
+#if defined(VGO_linux)
+ // operator new[](unsigned, std::nothrow_t const&), GNU mangling
+ #if VG_WORDSIZE == 4
+ ALLOC_or_NULL(VG_Z_LIBSTDCXX_SONAME, _ZnajRKSt9nothrow_t, __builtin_vec_new );
+ ALLOC_or_NULL(VG_Z_LIBC_SONAME, _ZnajRKSt9nothrow_t, __builtin_vec_new );
+ #endif
+ // operator new[](unsigned long, std::nothrow_t const&), GNU mangling
+ #if VG_WORDSIZE == 8
+ ALLOC_or_NULL(VG_Z_LIBSTDCXX_SONAME, _ZnamRKSt9nothrow_t, __builtin_vec_new );
+ ALLOC_or_NULL(VG_Z_LIBC_SONAME, _ZnamRKSt9nothrow_t, __builtin_vec_new );
+ #endif
+
+#elif defined(VGO_darwin)
+ // operator new[](unsigned, std::nothrow_t const&), GNU mangling
+ #if VG_WORDSIZE == 4
+ ALLOC_or_NULL(VG_Z_LIBSTDCXX_SONAME, _ZnajRKSt9nothrow_t, __builtin_vec_new );
+ ALLOC_or_NULL(VG_Z_LIBC_SONAME, _ZnajRKSt9nothrow_t, __builtin_vec_new );
+ #endif
+ // operator new[](unsigned long, std::nothrow_t const&), GNU mangling
+ #if 1 // FIXME: is this right?
+ ALLOC_or_NULL(VG_Z_LIBSTDCXX_SONAME, _ZnamRKSt9nothrow_t, __builtin_vec_new );
+ ALLOC_or_NULL(VG_Z_LIBC_SONAME, _ZnamRKSt9nothrow_t, __builtin_vec_new );
+ #endif
-// operator new[](unsigned long, std::nothrow_t const&), GNU mangling
-#if VG_WORDSIZE == 8 || defined(VGO_darwin)
- ALLOC_or_NULL(VG_Z_LIBSTDCXX_SONAME, _ZnamRKSt9nothrow_t, __builtin_vec_new );
- ALLOC_or_NULL(VG_Z_LIBC_SONAME, _ZnamRKSt9nothrow_t, __builtin_vec_new );
#endif
}
// free
-FREE(VG_Z_LIBSTDCXX_SONAME, free, free );
-FREE(VG_Z_LIBC_SONAME, free, free );
-#if defined(VGO_darwin)
-ZONEFREE(VG_Z_LIBC_SONAME, malloc_zone_free, free );
+#if defined(VGO_linux)
+ FREE(VG_Z_LIBSTDCXX_SONAME, free, free );
+ FREE(VG_Z_LIBC_SONAME, free, free );
+
+#elif defined(VGO_darwin)
+ FREE(VG_Z_LIBSTDCXX_SONAME, free, free );
+ FREE(VG_Z_LIBC_SONAME, free, free );
+ ZONEFREE(VG_Z_LIBC_SONAME, malloc_zone_free, free );
+
#endif
/*---------------------- cfree ----------------------*/
// cfree
-FREE(VG_Z_LIBSTDCXX_SONAME, cfree, free );
-FREE(VG_Z_LIBC_SONAME, cfree, free );
+#if defined(VGO_linux)
+ FREE(VG_Z_LIBSTDCXX_SONAME, cfree, free );
+ FREE(VG_Z_LIBC_SONAME, cfree, free );
+
+#elif defined(VGO_darwin)
+ FREE(VG_Z_LIBSTDCXX_SONAME, cfree, free );
+ FREE(VG_Z_LIBC_SONAME, cfree, free );
+
+#endif
/*---------------------- delete ----------------------*/
-// operator delete(void*), not mangled (for gcc 2.96)
-FREE(VG_Z_LIBSTDCXX_SONAME, __builtin_delete, __builtin_delete );
-FREE(VG_Z_LIBC_SONAME, __builtin_delete, __builtin_delete );
-// operator delete(void*), GNU mangling
-FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPv, __builtin_delete );
-FREE(VG_Z_LIBC_SONAME, _ZdlPv, __builtin_delete );
+#if defined(VGO_linux)
+ // operator delete(void*), not mangled (for gcc 2.96)
+ FREE(VG_Z_LIBSTDCXX_SONAME, __builtin_delete, __builtin_delete );
+ FREE(VG_Z_LIBC_SONAME, __builtin_delete, __builtin_delete );
+ // operator delete(void*), GNU mangling
+ FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPv, __builtin_delete );
+ FREE(VG_Z_LIBC_SONAME, _ZdlPv, __builtin_delete );
+
+#elif defined(VGO_darwin)
+ // operator delete(void*), GNU mangling
+ FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPv, __builtin_delete );
+ FREE(VG_Z_LIBC_SONAME, _ZdlPv, __builtin_delete );
+
+#endif
/*---------------------- delete nothrow ----------------------*/
-// operator delete(void*, std::nothrow_t const&), GNU mangling
-FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPvRKSt9nothrow_t, __builtin_delete );
-FREE(VG_Z_LIBC_SONAME, _ZdlPvRKSt9nothrow_t, __builtin_delete );
+#if defined(VGO_linux)
+ // operator delete(void*, std::nothrow_t const&), GNU mangling
+ FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPvRKSt9nothrow_t, __builtin_delete );
+ FREE(VG_Z_LIBC_SONAME, _ZdlPvRKSt9nothrow_t, __builtin_delete );
+
+#elif defined(VGO_darwin)
+ // operator delete(void*, std::nothrow_t const&), GNU mangling
+ FREE(VG_Z_LIBSTDCXX_SONAME, _ZdlPvRKSt9nothrow_t, __builtin_delete );
+ FREE(VG_Z_LIBC_SONAME, _ZdlPvRKSt9nothrow_t, __builtin_delete );
+
+#endif
/*---------------------- delete [] ----------------------*/
-// operator delete[](void*), not mangled (for gcc 2.96)
-FREE(VG_Z_LIBSTDCXX_SONAME, __builtin_vec_delete, __builtin_vec_delete );
-FREE(VG_Z_LIBC_SONAME, __builtin_vec_delete, __builtin_vec_delete );
-// operator delete[](void*), GNU mangling
-FREE(VG_Z_LIBSTDCXX_SONAME, _ZdaPv, __builtin_vec_delete );
-FREE(VG_Z_LIBC_SONAME, _ZdaPv, __builtin_vec_delete );
+#if defined(VGO_linux)
+ // operator delete[](void*), not mangled (for gcc 2.96)
+ FREE(VG_Z_LIBSTDCXX_SONAME, __builtin_vec_delete, __builtin_vec_delete );
+ FREE(VG_Z_LIBC_SONAME, __builtin_vec_delete, __builtin_vec_delete );
+ // operator delete[](void*), GNU mangling
+ FREE(VG_Z_LIBSTDCXX_SONAME, _ZdaPv, __builtin_vec_delete );
+ FREE(VG_Z_LIBC_SONAME, _ZdaPv, __builtin_vec_delete );
+
+#elif defined(VGO_darwin)
+ // operator delete[](void*), not mangled (for gcc 2.96)
+ FREE(VG_Z_LIBSTDCXX_SONAME, __builtin_vec_delete, __builtin_vec_delete );
+ FREE(VG_Z_LIBC_SONAME, __builtin_vec_delete, __builtin_vec_delete );
+ // operator delete[](void*), GNU mangling
+ FREE(VG_Z_LIBSTDCXX_SONAME, _ZdaPv, __builtin_vec_delete );
+ FREE(VG_Z_LIBC_SONAME, _ZdaPv, __builtin_vec_delete );
+
+#endif
/*---------------------- delete [] nothrow ----------------------*/
-// operator delete[](void*, std::nothrow_t const&), GNU mangling
-FREE(VG_Z_LIBSTDCXX_SONAME, _ZdaPvRKSt9nothrow_t, __builtin_vec_delete );
-FREE(VG_Z_LIBC_SONAME, _ZdaPvRKSt9nothrow_t, __builtin_vec_delete );
+#if defined(VGO_linux)
+ // operator delete[](void*, std::nothrow_t const&), GNU mangling
+ FREE(VG_Z_LIBSTDCXX_SONAME, _ZdaPvRKSt9nothrow_t, __builtin_vec_delete );
+ FREE(VG_Z_LIBC_SONAME, _ZdaPvRKSt9nothrow_t, __builtin_vec_delete );
+
+#elif defined(VGO_darwin)
+ // operator delete[](void*, std::nothrow_t const&), GNU mangling
+ FREE(VG_Z_LIBSTDCXX_SONAME, _ZdaPvRKSt9nothrow_t, __builtin_vec_delete );
+ FREE(VG_Z_LIBC_SONAME, _ZdaPvRKSt9nothrow_t, __builtin_vec_delete );
+
+#endif
/*---------------------- calloc ----------------------*/
return v; \
}
-CALLOC(VG_Z_LIBC_SONAME, calloc);
-#if defined(VGO_darwin)
-ZONECALLOC(VG_Z_LIBC_SONAME, malloc_zone_calloc);
+#if defined(VGO_linux)
+ CALLOC(VG_Z_LIBC_SONAME, calloc);
+
+#elif defined(VGO_darwin)
+ CALLOC(VG_Z_LIBC_SONAME, calloc);
+ ZONECALLOC(VG_Z_LIBC_SONAME, malloc_zone_calloc);
+
#endif
return v; \
}
-REALLOC(VG_Z_LIBC_SONAME, realloc);
-#if defined(VGO_darwin)
-ZONEREALLOC(VG_Z_LIBC_SONAME, malloc_zone_realloc);
+#if defined(VGO_linux)
+ REALLOC(VG_Z_LIBC_SONAME, realloc);
+
+#elif defined(VGO_darwin)
+ REALLOC(VG_Z_LIBC_SONAME, realloc);
+ ZONEREALLOC(VG_Z_LIBC_SONAME, malloc_zone_realloc);
+
#endif
return v; \
}
-MEMALIGN(VG_Z_LIBC_SONAME, memalign);
-#if defined(VGO_darwin)
-ZONEMEMALIGN(VG_Z_LIBC_SONAME, malloc_zone_memalign);
+#if defined(VGO_linux)
+ MEMALIGN(VG_Z_LIBC_SONAME, memalign);
+
+#elif defined(VGO_darwin)
+ MEMALIGN(VG_Z_LIBC_SONAME, memalign);
+ ZONEMEMALIGN(VG_Z_LIBC_SONAME, malloc_zone_memalign);
+
#endif
((SizeT)pszB, size); \
}
-VALLOC(VG_Z_LIBC_SONAME, valloc);
-#if defined(VGO_darwin)
-ZONEVALLOC(VG_Z_LIBC_SONAME, malloc_zone_valloc);
+#if defined(VGO_linux)
+ VALLOC(VG_Z_LIBC_SONAME, valloc);
+
+#elif defined(VGO_darwin)
+ VALLOC(VG_Z_LIBC_SONAME, valloc);
+ ZONEVALLOC(VG_Z_LIBC_SONAME, malloc_zone_valloc);
+
#endif
return 1; \
}
-MALLOPT(VG_Z_LIBC_SONAME, mallopt);
+#if defined(VGO_linux)
+ MALLOPT(VG_Z_LIBC_SONAME, mallopt);
+
+#elif defined(VGO_darwin)
+ MALLOPT(VG_Z_LIBC_SONAME, mallopt);
+
+#endif
/*---------------------- malloc_trim ----------------------*/
return 0; \
}
-MALLOC_TRIM(VG_Z_LIBC_SONAME, malloc_trim);
+#if defined(VGO_linux)
+ MALLOC_TRIM(VG_Z_LIBC_SONAME, malloc_trim);
+
+#elif defined(VGO_darwin)
+ MALLOC_TRIM(VG_Z_LIBC_SONAME, malloc_trim);
+
+#endif
/*---------------------- posix_memalign ----------------------*/
return VKI_ENOMEM; \
}
-POSIX_MEMALIGN(VG_Z_LIBC_SONAME, posix_memalign);
+#if defined(VGO_linux)
+ POSIX_MEMALIGN(VG_Z_LIBC_SONAME, posix_memalign);
+
+#elif defined(VGO_darwin)
+ POSIX_MEMALIGN(VG_Z_LIBC_SONAME, posix_memalign);
+
+#endif
/*---------------------- malloc_usable_size ----------------------*/
return pszB; \
}
-MALLOC_USABLE_SIZE(VG_Z_LIBC_SONAME, malloc_usable_size);
-MALLOC_USABLE_SIZE(VG_Z_LIBC_SONAME, malloc_size);
+#if defined(VGO_linux)
+ MALLOC_USABLE_SIZE(VG_Z_LIBC_SONAME, malloc_usable_size);
+ MALLOC_USABLE_SIZE(VG_Z_LIBC_SONAME, malloc_size);
+
+#elif defined(VGO_darwin)
+ MALLOC_USABLE_SIZE(VG_Z_LIBC_SONAME, malloc_usable_size);
+ MALLOC_USABLE_SIZE(VG_Z_LIBC_SONAME, malloc_size);
+
+#endif
/*---------------------- (unimplemented) ----------------------*/
panic(#fnname); \
}
-PANIC(VG_Z_LIBC_SONAME, pvalloc);
-PANIC(VG_Z_LIBC_SONAME, malloc_get_state);
-PANIC(VG_Z_LIBC_SONAME, malloc_set_state);
+#if defined(VGO_linux)
+ PANIC(VG_Z_LIBC_SONAME, pvalloc);
+ PANIC(VG_Z_LIBC_SONAME, malloc_get_state);
+ PANIC(VG_Z_LIBC_SONAME, malloc_set_state);
+
+#elif defined(VGO_darwin)
+ PANIC(VG_Z_LIBC_SONAME, pvalloc);
+ PANIC(VG_Z_LIBC_SONAME, malloc_get_state);
+ PANIC(VG_Z_LIBC_SONAME, malloc_set_state);
+
+#endif
+
#define MALLOC_STATS(soname, fnname) \
\
/* Valgrind's malloc_stats implementation does nothing. */ \
}
-MALLOC_STATS(VG_Z_LIBC_SONAME, malloc_stats);
+#if defined(VGO_linux)
+ MALLOC_STATS(VG_Z_LIBC_SONAME, malloc_stats);
+
+#elif defined(VGO_darwin)
+ MALLOC_STATS(VG_Z_LIBC_SONAME, malloc_stats);
+
+#endif
/*---------------------- mallinfo ----------------------*/
return mi; \
}
-MALLINFO(VG_Z_LIBC_SONAME, mallinfo);
+#if defined(VGO_linux)
+ MALLINFO(VG_Z_LIBC_SONAME, mallinfo);
+
+#elif defined(VGO_darwin)
+ MALLINFO(VG_Z_LIBC_SONAME, mallinfo);
+
+#endif
#if defined(VGO_darwin)
return &vg_default_zone; \
}
-#if defined(VGO_darwin)
DEFAULT_ZONE(VG_Z_LIBC_SONAME, malloc_zone_from_ptr);
DEFAULT_ZONE(VG_Z_LIBC_SONAME, malloc_default_zone);
-#endif
// GrP fixme bypass libc's use of zone->introspect->check
#define ZONE_CHECK(soname, fnname) \
return 1; \
}
-#if defined(VGO_darwin)
ZONE_CHECK(VG_Z_LIBC_SONAME, malloc_zone_check);
-#endif
-#endif
+#endif /* defined(VGO_darwin) */
/* All the code in here is unused until this function is called */
s, src, dst, len, 0)
+/*---------------------- strrchr ----------------------*/
+
#define STRRCHR(soname, fnname) \
char* VG_REPLACE_FUNCTION_EZU(20010,soname,fnname)( const char* s, int c ); \
char* VG_REPLACE_FUNCTION_EZU(20010,soname,fnname)( const char* s, int c ) \
}
// Apparently rindex() is the same thing as strrchr()
-STRRCHR(VG_Z_LIBC_SONAME, strrchr)
-STRRCHR(VG_Z_LIBC_SONAME, rindex)
#if defined(VGO_linux)
-STRRCHR(VG_Z_LIBC_SONAME, __GI_strrchr)
-STRRCHR(VG_Z_LD_LINUX_SO_2, rindex)
+ STRRCHR(VG_Z_LIBC_SONAME, strrchr)
+ STRRCHR(VG_Z_LIBC_SONAME, rindex)
+ STRRCHR(VG_Z_LIBC_SONAME, __GI_strrchr)
+ STRRCHR(VG_Z_LD_LINUX_SO_2, rindex)
#elif defined(VGO_darwin)
-STRRCHR(VG_Z_DYLD, strrchr)
-STRRCHR(VG_Z_DYLD, rindex)
+ STRRCHR(VG_Z_LIBC_SONAME, strrchr)
+ STRRCHR(VG_Z_LIBC_SONAME, rindex)
+ STRRCHR(VG_Z_DYLD, strrchr)
+ STRRCHR(VG_Z_DYLD, rindex)
#endif
+/*---------------------- strchr ----------------------*/
+
#define STRCHR(soname, fnname) \
char* VG_REPLACE_FUNCTION_EZU(20020,soname,fnname) ( const char* s, int c ); \
char* VG_REPLACE_FUNCTION_EZU(20020,soname,fnname) ( const char* s, int c ) \
}
// Apparently index() is the same thing as strchr()
-STRCHR(VG_Z_LIBC_SONAME, strchr)
-STRCHR(VG_Z_LIBC_SONAME, index)
#if defined(VGO_linux)
-STRCHR(VG_Z_LIBC_SONAME, __GI_strchr)
-#if !defined(VGP_x86_linux)
- STRCHR(VG_Z_LD_LINUX_SO_2, strchr)
- STRCHR(VG_Z_LD_LINUX_SO_2, index)
- STRCHR(VG_Z_LD_LINUX_X86_64_SO_2, strchr)
- STRCHR(VG_Z_LD_LINUX_X86_64_SO_2, index)
-#endif
+ STRCHR(VG_Z_LIBC_SONAME, strchr)
+ STRCHR(VG_Z_LIBC_SONAME, index)
+ STRCHR(VG_Z_LIBC_SONAME, __GI_strchr)
+# if !defined(VGP_x86_linux)
+ STRCHR(VG_Z_LD_LINUX_SO_2, strchr)
+ STRCHR(VG_Z_LD_LINUX_SO_2, index)
+ STRCHR(VG_Z_LD_LINUX_X86_64_SO_2, strchr)
+ STRCHR(VG_Z_LD_LINUX_X86_64_SO_2, index)
+# endif
#elif defined(VGO_darwin)
-STRCHR(VG_Z_DYLD, strchr)
-STRCHR(VG_Z_DYLD, index)
+ STRCHR(VG_Z_LIBC_SONAME, strchr)
+ STRCHR(VG_Z_LIBC_SONAME, index)
+ STRCHR(VG_Z_DYLD, strchr)
+ STRCHR(VG_Z_DYLD, index)
#endif
+/*---------------------- strcat ----------------------*/
+
#define STRCAT(soname, fnname) \
char* VG_REPLACE_FUNCTION_EZU(20030,soname,fnname) \
( char* dst, const char* src ); \
return dst_orig; \
}
-STRCAT(VG_Z_LIBC_SONAME, strcat)
#if defined(VGO_linux)
-STRCAT(VG_Z_LIBC_SONAME, __GI_strcat)
+ STRCAT(VG_Z_LIBC_SONAME, strcat)
+ STRCAT(VG_Z_LIBC_SONAME, __GI_strcat)
+#elif defined(VGO_darwin)
+ STRCAT(VG_Z_LIBC_SONAME, strcat)
#endif
+
+/*---------------------- strncat ----------------------*/
+
#define STRNCAT(soname, fnname) \
char* VG_REPLACE_FUNCTION_EZU(20040,soname,fnname) \
( char* dst, const char* src, SizeT n ); \
return dst_orig; \
}
-STRNCAT(VG_Z_LIBC_SONAME, strncat)
-#if defined(VGO_darwin)
-STRNCAT(VG_Z_DYLD, strncat)
+#if defined(VGO_linux)
+ STRNCAT(VG_Z_LIBC_SONAME, strncat)
+#elif defined(VGO_darwin)
+ STRNCAT(VG_Z_LIBC_SONAME, strncat)
+ STRNCAT(VG_Z_DYLD, strncat)
#endif
+/*---------------------- strlcat ----------------------*/
+
/* Append src to dst. n is the size of dst's buffer. dst is guaranteed
to be nul-terminated after the copy, unless n <= strlen(dst_orig).
Returns min(n, strlen(dst_orig)) + strlen(src_orig).
return m; \
}
-#if defined(VGO_darwin)
-STRLCAT(VG_Z_LIBC_SONAME, strlcat)
-STRLCAT(VG_Z_DYLD, strlcat)
+#if defined(VGO_linux)
+#elif defined(VGO_darwin)
+ STRLCAT(VG_Z_LIBC_SONAME, strlcat)
+ STRLCAT(VG_Z_DYLD, strlcat)
#endif
+/*---------------------- strnlen ----------------------*/
+
#define STRNLEN(soname, fnname) \
SizeT VG_REPLACE_FUNCTION_EZU(20060,soname,fnname) \
( const char* str, SizeT n ); \
return i; \
}
-STRNLEN(VG_Z_LIBC_SONAME, strnlen)
#if defined(VGO_linux)
-STRNLEN(VG_Z_LIBC_SONAME, __GI_strnlen)
+ STRNLEN(VG_Z_LIBC_SONAME, strnlen)
+ STRNLEN(VG_Z_LIBC_SONAME, __GI_strnlen)
+#elif defined(VGO_darwin)
+ STRNLEN(VG_Z_LIBC_SONAME, strnlen)
#endif
+/*---------------------- strlen ----------------------*/
+
// Note that this replacement often doesn't get used because gcc inlines
// calls to strlen() with its own built-in version. This can be very
-// confusing if you aren't expecting it. Other small functions in this file
-// may also be inline by gcc.
+// confusing if you aren't expecting it. Other small functions in
+// this file may also be inline by gcc.
+
#define STRLEN(soname, fnname) \
SizeT VG_REPLACE_FUNCTION_EZU(20070,soname,fnname) \
( const char* str ); \
return i; \
}
-STRLEN(VG_Z_LIBC_SONAME, strlen)
#if defined(VGO_linux)
-STRLEN(VG_Z_LIBC_SONAME, __GI_strlen)
+ STRLEN(VG_Z_LIBC_SONAME, strlen)
+ STRLEN(VG_Z_LIBC_SONAME, __GI_strlen)
+#elif defined(VGO_darwin)
+ STRLEN(VG_Z_LIBC_SONAME, strlen)
#endif
+/*---------------------- strcpy ----------------------*/
+
#define STRCPY(soname, fnname) \
char* VG_REPLACE_FUNCTION_EZU(20080,soname,fnname) \
( char* dst, const char* src ); \
return dst_orig; \
}
-STRCPY(VG_Z_LIBC_SONAME, strcpy)
#if defined(VGO_linux)
-STRCPY(VG_Z_LIBC_SONAME, __GI_strcpy)
+ STRCPY(VG_Z_LIBC_SONAME, strcpy)
+ STRCPY(VG_Z_LIBC_SONAME, __GI_strcpy)
#elif defined(VGO_darwin)
-STRCPY(VG_Z_DYLD, strcpy)
+ STRCPY(VG_Z_LIBC_SONAME, strcpy)
+ STRCPY(VG_Z_DYLD, strcpy)
#endif
+/*---------------------- strncpy ----------------------*/
+
#define STRNCPY(soname, fnname) \
char* VG_REPLACE_FUNCTION_EZU(20090,soname,fnname) \
( char* dst, const char* src, SizeT n ); \
if (is_overlap(dst_orig, src_orig, n, (m < n) ? m+1 : n)) \
RECORD_OVERLAP_ERROR("strncpy", dst, src, n); \
while (m++ < n) *dst++ = 0; /* must pad remainder with nulls */ \
- \
+ \
return dst_orig; \
}
-STRNCPY(VG_Z_LIBC_SONAME, strncpy)
#if defined(VGO_linux)
-STRNCPY(VG_Z_LIBC_SONAME, __GI_strncpy)
+ STRNCPY(VG_Z_LIBC_SONAME, strncpy)
+ STRNCPY(VG_Z_LIBC_SONAME, __GI_strncpy)
#elif defined(VGO_darwin)
-STRNCPY(VG_Z_DYLD, strncpy)
+ STRNCPY(VG_Z_LIBC_SONAME, strncpy)
+ STRNCPY(VG_Z_DYLD, strncpy)
#endif
+/*---------------------- strlcpy ----------------------*/
+
/* Copy up to n-1 bytes from src to dst. Then nul-terminate dst if n > 0.
Returns strlen(src). Does not zero-fill the remainder of dst. */
#define STRLCPY(soname, fnname) \
return src - src_orig; \
}
-#if defined(VGO_darwin)
-STRLCPY(VG_Z_LIBC_SONAME, strlcpy)
-STRLCPY(VG_Z_DYLD, strlcpy)
+#if defined(VGO_linux)
+#elif defined(VGO_darwin)
+ STRLCPY(VG_Z_LIBC_SONAME, strlcpy)
+ STRLCPY(VG_Z_DYLD, strlcpy)
#endif
+/*---------------------- strncmp ----------------------*/
+
#define STRNCMP(soname, fnname) \
int VG_REPLACE_FUNCTION_EZU(20110,soname,fnname) \
( const char* s1, const char* s2, SizeT nmax ); \
} \
}
-STRNCMP(VG_Z_LIBC_SONAME, strncmp)
#if defined(VGO_linux)
-STRNCMP(VG_Z_LIBC_SONAME, __GI_strncmp)
+ STRNCMP(VG_Z_LIBC_SONAME, strncmp)
+ STRNCMP(VG_Z_LIBC_SONAME, __GI_strncmp)
#elif defined(VGO_darwin)
-STRNCMP(VG_Z_DYLD, strncmp)
+ STRNCMP(VG_Z_LIBC_SONAME, strncmp)
+ STRNCMP(VG_Z_DYLD, strncmp)
#endif
+/*---------------------- strcasecmp ----------------------*/
+
#define STRCASECMP(soname, fnname) \
int VG_REPLACE_FUNCTION_EZU(20120,soname,fnname) \
( const char* s1, const char* s2 ); \
return 0; \
}
-#if !defined(VGPV_arm_linux_android)
-STRCASECMP(VG_Z_LIBC_SONAME, strcasecmp)
-#endif
-#if defined(VGO_linux) && !defined(VGPV_arm_linux_android)
-STRCASECMP(VG_Z_LIBC_SONAME, __GI_strcasecmp)
+#if defined(VGO_linux)
+# if !defined(VGPV_arm_linux_android)
+ STRCASECMP(VG_Z_LIBC_SONAME, strcasecmp)
+ STRCASECMP(VG_Z_LIBC_SONAME, __GI_strcasecmp)
+# endif
+#elif defined(VGO_darwin)
+ STRCASECMP(VG_Z_LIBC_SONAME, strcasecmp)
#endif
+/*---------------------- strncasecmp ----------------------*/
+
#define STRNCASECMP(soname, fnname) \
int VG_REPLACE_FUNCTION_EZU(20130,soname,fnname) \
( const char* s1, const char* s2, SizeT nmax ); \
} \
}
-#if !defined(VGPV_arm_linux_android)
-STRNCASECMP(VG_Z_LIBC_SONAME, strncasecmp)
-#endif
-#if defined(VGO_linux) && !defined(VGPV_arm_linux_android)
-STRNCASECMP(VG_Z_LIBC_SONAME, __GI_strncasecmp)
+#if defined(VGO_linux)
+# if !defined(VGPV_arm_linux_android)
+ STRNCASECMP(VG_Z_LIBC_SONAME, strncasecmp)
+ STRNCASECMP(VG_Z_LIBC_SONAME, __GI_strncasecmp)
+# endif
#elif defined(VGO_darwin)
-STRNCASECMP(VG_Z_DYLD, strncasecmp)
+ STRNCASECMP(VG_Z_LIBC_SONAME, strncasecmp)
+ STRNCASECMP(VG_Z_DYLD, strncasecmp)
#endif
+/*---------------------- strcasecmp_l ----------------------*/
+
#define STRCASECMP_L(soname, fnname) \
int VG_REPLACE_FUNCTION_EZU(20140,soname,fnname) \
( const char* s1, const char* s2, void* locale ); \
int VG_REPLACE_FUNCTION_EZU(20140,soname,fnname) \
( const char* s1, const char* s2, void* locale ) \
{ \
- extern int tolower_l(int, void*) __attribute__((weak)); \
+ extern int tolower_l(int, void*) __attribute__((weak)); \
register unsigned char c1; \
register unsigned char c2; \
while (True) { \
return 0; \
}
-STRCASECMP_L(VG_Z_LIBC_SONAME, strcasecmp_l)
#if defined(VGO_linux)
-STRCASECMP_L(VG_Z_LIBC_SONAME, __GI_strcasecmp_l)
-STRCASECMP_L(VG_Z_LIBC_SONAME, __GI___strcasecmp_l)
+ STRCASECMP_L(VG_Z_LIBC_SONAME, strcasecmp_l)
+ STRCASECMP_L(VG_Z_LIBC_SONAME, __GI_strcasecmp_l)
+ STRCASECMP_L(VG_Z_LIBC_SONAME, __GI___strcasecmp_l)
+#elif defined(VGO_darwin)
+ STRCASECMP_L(VG_Z_LIBC_SONAME, strcasecmp_l)
#endif
+/*---------------------- strncasecmp_l ----------------------*/
+
#define STRNCASECMP_L(soname, fnname) \
int VG_REPLACE_FUNCTION_EZU(20150,soname,fnname) \
( const char* s1, const char* s2, SizeT nmax, void* locale ); \
} \
}
-STRNCASECMP_L(VG_Z_LIBC_SONAME, strncasecmp_l)
#if defined(VGO_linux)
-STRNCASECMP_L(VG_Z_LIBC_SONAME, __GI_strncasecmp_l)
+ STRNCASECMP_L(VG_Z_LIBC_SONAME, strncasecmp_l)
+ STRNCASECMP_L(VG_Z_LIBC_SONAME, __GI_strncasecmp_l)
#elif defined(VGO_darwin)
-STRNCASECMP_L(VG_Z_DYLD, strncasecmp_l)
+ STRNCASECMP_L(VG_Z_LIBC_SONAME, strncasecmp_l)
+ STRNCASECMP_L(VG_Z_DYLD, strncasecmp_l)
#endif
+/*---------------------- strcmp ----------------------*/
+
#define STRCMP(soname, fnname) \
int VG_REPLACE_FUNCTION_EZU(20160,soname,fnname) \
( const char* s1, const char* s2 ); \
return 0; \
}
-STRCMP(VG_Z_LIBC_SONAME, strcmp)
#if defined(VGO_linux)
-STRCMP(VG_Z_LIBC_SONAME, __GI_strcmp)
-STRCMP(VG_Z_LD_LINUX_X86_64_SO_2, strcmp)
-STRCMP(VG_Z_LD64_SO_1, strcmp)
+ STRCMP(VG_Z_LIBC_SONAME, strcmp)
+ STRCMP(VG_Z_LIBC_SONAME, __GI_strcmp)
+ STRCMP(VG_Z_LD_LINUX_X86_64_SO_2, strcmp)
+ STRCMP(VG_Z_LD64_SO_1, strcmp)
+#elif defined(VGO_darwin)
+ STRCMP(VG_Z_LIBC_SONAME, strcmp)
#endif
+/*---------------------- memchr ----------------------*/
+
#define MEMCHR(soname, fnname) \
void* VG_REPLACE_FUNCTION_EZU(20170,soname,fnname) \
(const void *s, int c, SizeT n); \
return NULL; \
}
-MEMCHR(VG_Z_LIBC_SONAME, memchr)
-#if defined(VGO_darwin)
-MEMCHR(VG_Z_DYLD, memchr)
+#if defined(VGO_linux)
+ MEMCHR(VG_Z_LIBC_SONAME, memchr)
+#elif defined(VGO_darwin)
+ MEMCHR(VG_Z_LIBC_SONAME, memchr)
+ MEMCHR(VG_Z_DYLD, memchr)
#endif
+/*---------------------- memcpy ----------------------*/
+
#define MEMMOVE_OR_MEMCPY(becTag, soname, fnname, do_ol_check) \
void* VG_REPLACE_FUNCTION_EZZ(becTag,soname,fnname) \
( void *dst, const void *src, SizeT len ); \
MEMMOVE_OR_MEMCPY(20180, soname, fnname, 1)
#if defined(VGO_linux)
-/* For older memcpy we have to use memmove-like semantics and skip the
- overlap check; sigh; see #275284. */
-MEMMOVE(VG_Z_LIBC_SONAME, memcpyZAGLIBCZu2Zd2Zd5) /* memcpy@GLIBC_2.2.5 */
-MEMCPY(VG_Z_LIBC_SONAME, memcpyZAZAGLIBCZu2Zd14) /* memcpy@@GLIBC_2.14 */
-MEMCPY(VG_Z_LIBC_SONAME, memcpy) /* fallback case */
-MEMCPY(VG_Z_LD_SO_1, memcpy) /* ld.so.1 */
-MEMCPY(VG_Z_LD64_SO_1, memcpy) /* ld64.so.1 */
+ /* For older memcpy we have to use memmove-like semantics and skip
+ the overlap check; sigh; see #275284. */
+ MEMMOVE(VG_Z_LIBC_SONAME, memcpyZAGLIBCZu2Zd2Zd5) /* memcpy@GLIBC_2.2.5 */
+ MEMCPY(VG_Z_LIBC_SONAME, memcpyZAZAGLIBCZu2Zd14) /* memcpy@@GLIBC_2.14 */
+ MEMCPY(VG_Z_LIBC_SONAME, memcpy) /* fallback case */
+ MEMCPY(VG_Z_LD_SO_1, memcpy) /* ld.so.1 */
+ MEMCPY(VG_Z_LD64_SO_1, memcpy) /* ld64.so.1 */
#elif defined(VGO_darwin)
-MEMCPY(VG_Z_LIBC_SONAME, memcpy)
-MEMCPY(VG_Z_DYLD, memcpy)
-#endif
-/* icc9 blats these around all over the place. Not only in the main
- executable but various .so's. They are highly tuned and read
- memory beyond the source boundary (although work correctly and
- never go across page boundaries), so give errors when run natively,
- at least for misaligned source arg. Just intercepting in the exe
- only until we understand more about the problem. See
- http://bugs.kde.org/show_bug.cgi?id=139776
+ MEMCPY(VG_Z_LIBC_SONAME, memcpy)
+ MEMCPY(VG_Z_DYLD, memcpy)
+ /* icc9 blats these around all over the place. Not only in the main
+ executable but various .so's. They are highly tuned and read
+ memory beyond the source boundary (although work correctly and
+ never go across page boundaries), so give errors when run
+ natively, at least for misaligned source arg. Just intercepting
+ in the exe only until we understand more about the problem. See
+ http://bugs.kde.org/show_bug.cgi?id=139776
*/
-MEMCPY(NONE, ZuintelZufastZumemcpy)
+ MEMCPY(NONE, ZuintelZufastZumemcpy)
+#endif
+
+/*---------------------- memcmp ----------------------*/
#define MEMCMP(soname, fnname) \
int VG_REPLACE_FUNCTION_EZU(20190,soname,fnname) \
return 0; \
}
-MEMCMP(VG_Z_LIBC_SONAME, memcmp)
-MEMCMP(VG_Z_LIBC_SONAME, bcmp)
#if defined(VGO_linux)
-MEMCMP(VG_Z_LD_SO_1, bcmp)
+ MEMCMP(VG_Z_LIBC_SONAME, memcmp)
+ MEMCMP(VG_Z_LIBC_SONAME, bcmp)
+ MEMCMP(VG_Z_LD_SO_1, bcmp)
#elif defined(VGO_darwin)
-MEMCMP(VG_Z_DYLD, memcmp)
-MEMCMP(VG_Z_DYLD, bcmp)
+ MEMCMP(VG_Z_LIBC_SONAME, memcmp)
+ MEMCMP(VG_Z_LIBC_SONAME, bcmp)
+ MEMCMP(VG_Z_DYLD, memcmp)
+ MEMCMP(VG_Z_DYLD, bcmp)
#endif
+/*---------------------- stpcpy ----------------------*/
+
/* Copy SRC to DEST, returning the address of the terminating '\0' in
DEST. (minor variant of strcpy) */
#define STPCPY(soname, fnname) \
return dst; \
}
-STPCPY(VG_Z_LIBC_SONAME, stpcpy)
#if defined(VGO_linux)
-STPCPY(VG_Z_LIBC_SONAME, __GI_stpcpy)
-STPCPY(VG_Z_LD_LINUX_SO_2, stpcpy)
-STPCPY(VG_Z_LD_LINUX_X86_64_SO_2, stpcpy)
+ STPCPY(VG_Z_LIBC_SONAME, stpcpy)
+ STPCPY(VG_Z_LIBC_SONAME, __GI_stpcpy)
+ STPCPY(VG_Z_LD_LINUX_SO_2, stpcpy)
+ STPCPY(VG_Z_LD_LINUX_X86_64_SO_2, stpcpy)
#elif defined(VGO_darwin)
-STPCPY(VG_Z_DYLD, stpcpy)
+ STPCPY(VG_Z_LIBC_SONAME, stpcpy)
+ STPCPY(VG_Z_DYLD, stpcpy)
#endif
+/*---------------------- memset ----------------------*/
+
+/* Why are we bothering to intercept this? It seems entirely
+ pointless. */
#define MEMSET(soname, fnname) \
void* VG_REPLACE_FUNCTION_EZU(20210,soname,fnname) \
(void *s, Int c, SizeT n); \
return s; \
}
-MEMSET(VG_Z_LIBC_SONAME, memset)
-#if defined(VGO_darwin)
-MEMSET(VG_Z_DYLD, memset)
+#if defined(VGO_linux)
+ MEMSET(VG_Z_LIBC_SONAME, memset)
+#elif defined(VGO_darwin)
+ MEMSET(VG_Z_LIBC_SONAME, memset)
+ MEMSET(VG_Z_DYLD, memset)
#endif
+/*---------------------- memmove ----------------------*/
+
/* memmove -- use the MEMMOVE defn above. */
-MEMMOVE(VG_Z_LIBC_SONAME, memmove)
-#if defined(VGO_darwin)
-MEMMOVE(VG_Z_DYLD, memmove)
+#if defined(VGO_linux)
+ MEMMOVE(VG_Z_LIBC_SONAME, memmove)
+#elif defined(VGO_darwin)
+ MEMMOVE(VG_Z_LIBC_SONAME, memmove)
+ MEMMOVE(VG_Z_DYLD, memmove)
#endif
+/*---------------------- bcopy ----------------------*/
+
#define BCOPY(soname, fnname) \
void VG_REPLACE_FUNCTION_EZU(20230,soname,fnname) \
(const void *srcV, void *dstV, SizeT n); \
} \
}
-#if defined(VGO_darwin)
-BCOPY(VG_Z_LIBC_SONAME, bcopy)
-BCOPY(VG_Z_DYLD, bcopy)
+#if defined(VGO_linux)
+#elif defined(VGO_darwin)
+ BCOPY(VG_Z_LIBC_SONAME, bcopy)
+ BCOPY(VG_Z_DYLD, bcopy)
#endif
+/*-------------------- memmove_chk --------------------*/
+
/* glibc 2.5 variant of memmove which checks the dest is big enough.
There is no specific part of glibc that this is copied from. */
#define GLIBC25___MEMMOVE_CHK(soname, fnname) \
return NULL; \
}
-GLIBC25___MEMMOVE_CHK(VG_Z_LIBC_SONAME, __memmove_chk)
+#if defined(VGO_linux)
+ GLIBC25___MEMMOVE_CHK(VG_Z_LIBC_SONAME, __memmove_chk)
+#elif defined(VGO_darwin)
+#endif
+/*-------------------- strchrnul --------------------*/
+
/* Find the first occurrence of C in S or the final NUL byte. */
#define GLIBC232_STRCHRNUL(soname, fnname) \
char* VG_REPLACE_FUNCTION_EZU(20250,soname,fnname) \
} \
}
-GLIBC232_STRCHRNUL(VG_Z_LIBC_SONAME, strchrnul)
+#if defined(VGO_linux)
+ GLIBC232_STRCHRNUL(VG_Z_LIBC_SONAME, strchrnul)
+#elif defined(VGO_darwin)
+#endif
+
+/*---------------------- rawmemchr ----------------------*/
/* Find the first occurrence of C in S. */
#define GLIBC232_RAWMEMCHR(soname, fnname) \
} \
}
-GLIBC232_RAWMEMCHR(VG_Z_LIBC_SONAME, rawmemchr)
#if defined (VGO_linux)
-GLIBC232_RAWMEMCHR(VG_Z_LIBC_SONAME, __GI___rawmemchr)
+ GLIBC232_RAWMEMCHR(VG_Z_LIBC_SONAME, rawmemchr)
+ GLIBC232_RAWMEMCHR(VG_Z_LIBC_SONAME, __GI___rawmemchr)
+#elif defined(VGO_darwin)
#endif
+
+/*---------------------- strcpy_chk ----------------------*/
+
/* glibc variant of strcpy that checks the dest is big enough.
Copied from glibc-2.5/debug/test-strcpy_chk.c. */
#define GLIBC25___STRCPY_CHK(soname,fnname) \
return NULL; \
}
-GLIBC25___STRCPY_CHK(VG_Z_LIBC_SONAME, __strcpy_chk)
+#if defined(VGO_linux)
+ GLIBC25___STRCPY_CHK(VG_Z_LIBC_SONAME, __strcpy_chk)
+#elif defined(VGO_darwin)
+#endif
+
+/*---------------------- stpcpy_chk ----------------------*/
/* glibc variant of stpcpy that checks the dest is big enough.
Copied from glibc-2.5/debug/test-stpcpy_chk.c. */
return NULL; \
}
-GLIBC25___STPCPY_CHK(VG_Z_LIBC_SONAME, __stpcpy_chk)
+#if defined(VGO_linux)
+ GLIBC25___STPCPY_CHK(VG_Z_LIBC_SONAME, __stpcpy_chk)
+#elif defined(VGO_darwin)
+#endif
+
+/*---------------------- mempcpy ----------------------*/
/* mempcpy */
#define GLIBC25_MEMPCPY(soname, fnname) \
return (void*)( ((char*)dst) + len_saved ); \
}
-GLIBC25_MEMPCPY(VG_Z_LIBC_SONAME, mempcpy)
#if defined(VGO_linux)
-GLIBC25_MEMPCPY(VG_Z_LD_SO_1, mempcpy) /* ld.so.1 */
+ GLIBC25_MEMPCPY(VG_Z_LIBC_SONAME, mempcpy)
+ GLIBC25_MEMPCPY(VG_Z_LD_SO_1, mempcpy) /* ld.so.1 */
+#elif defined(VGO_darwin)
+ GLIBC25_MEMPCPY(VG_Z_LIBC_SONAME, mempcpy)
#endif
+/*-------------------- memcpy_chk --------------------*/
+
#define GLIBC26___MEMCPY_CHK(soname, fnname) \
void* VG_REPLACE_FUNCTION_EZU(20300,soname,fnname) \
(void* dst, const void* src, SizeT len, SizeT dstlen ); \
return NULL; \
}
-GLIBC26___MEMCPY_CHK(VG_Z_LIBC_SONAME, __memcpy_chk)
+#if defined(VGO_linux)
+ GLIBC26___MEMCPY_CHK(VG_Z_LIBC_SONAME, __memcpy_chk)
+#elif defined(VGO_darwin)
+#endif
+
+/*---------------------- strstr ----------------------*/
#define STRSTR(soname, fnname) \
void* VG_REPLACE_FUNCTION_EZU(20310,soname,fnname) \
}
#if defined(VGO_linux)
-STRSTR(VG_Z_LIBC_SONAME, strstr)
+ STRSTR(VG_Z_LIBC_SONAME, strstr)
+#elif defined(VGO_darwin)
#endif
+/*---------------------- strpbrk ----------------------*/
+
#define STRPBRK(soname, fnname) \
void* VG_REPLACE_FUNCTION_EZU(20320,soname,fnname) \
(void* sV, void* acceptV); \
}
#if defined(VGO_linux)
-STRPBRK(VG_Z_LIBC_SONAME, strpbrk)
+ STRPBRK(VG_Z_LIBC_SONAME, strpbrk)
+#elif defined(VGO_darwin)
#endif
+/*---------------------- strcspn ----------------------*/
+
#define STRCSPN(soname, fnname) \
SizeT VG_REPLACE_FUNCTION_EZU(20330,soname,fnname) \
(void* sV, void* rejectV); \
}
#if defined(VGO_linux)
-STRCSPN(VG_Z_LIBC_SONAME, strcspn)
+ STRCSPN(VG_Z_LIBC_SONAME, strcspn)
+#elif defined(VGO_darwin)
#endif
+/*---------------------- strspn ----------------------*/
+
#define STRSPN(soname, fnname) \
SizeT VG_REPLACE_FUNCTION_EZU(20340,soname,fnname) \
(void* sV, void* acceptV); \
}
#if defined(VGO_linux)
-STRSPN(VG_Z_LIBC_SONAME, strspn)
+ STRSPN(VG_Z_LIBC_SONAME, strspn)
+#elif defined(VGO_darwin)
#endif
versions of each function exist (as above), use the _EZU variants
to assign equivalance class tags. */
-/* putenv */
+/*---------------------- putenv ----------------------*/
+
int VG_WRAP_FUNCTION_ZU(VG_Z_LIBC_SONAME, putenv) (char* string);
int VG_WRAP_FUNCTION_ZU(VG_Z_LIBC_SONAME, putenv) (char* string)
{
traces when hitting undefined memory. */
if (p)
while (*p++)
- ;
+ __asm__ __volatile__("" ::: "memory");
CALL_FN_W_W(result, fn, string);
return result;
}
-/* unsetenv */
+
+/*---------------------- unsetenv ----------------------*/
+
int VG_WRAP_FUNCTION_ZU(VG_Z_LIBC_SONAME, unsetenv) (const char* name);
int VG_WRAP_FUNCTION_ZU(VG_Z_LIBC_SONAME, unsetenv) (const char* name)
{
traces when hitting undefined memory. */
if (p)
while (*p++)
- ;
+ __asm__ __volatile__("" ::: "memory");
CALL_FN_W_W(result, fn, name);
return result;
}
+
+/*---------------------- setenv ----------------------*/
+
/* setenv */
int VG_WRAP_FUNCTION_ZU(VG_Z_LIBC_SONAME, setenv)
(const char* name, const char* value, int overwrite);
traces when hitting undefined memory. */
if (name)
for (p = name; *p; p++)
- ;
+ __asm__ __volatile__("" ::: "memory");
if (value)
for (p = value; *p; p++)
- ;
+ __asm__ __volatile__("" ::: "memory");
VALGRIND_CHECK_VALUE_IS_DEFINED (overwrite);
CALL_FN_W_WWW(result, fn, name, value, overwrite);
return result;