blob: a4e8ffde01e9be50da0a7ec290d267e39b742654 [file] [log] [blame]
bartd66ac2d2008-07-09 09:23:28 +00001#!/bin/bash
2
3if [ ! -e coregrind/m_replacemalloc/vg_replace_malloc.c ]; then
4 echo "Error: please start this script from the Valgrind source directory."
5 exit 1
6fi
7
8if grep -q -w libjemallocZdsoZa coregrind/m_replacemalloc/vg_replace_malloc.c;
9then
10 echo "The libjemalloc patch is already present."
11 exit 0
12fi
13
14{ cat <<'EOF' | patch -p0; } || exit $?
15Index: coregrind/m_replacemalloc/vg_replace_malloc.c
16===================================================================
17--- coregrind/m_replacemalloc/vg_replace_malloc.c (revision 7759)
18+++ coregrind/m_replacemalloc/vg_replace_malloc.c (revision 7778)
19@@ -68,6 +68,10 @@
20 # error "Unknown platform"
21 #endif
22
23+/* --- Soname of libjemalloc. --- */
24+
25+#define m_jemalloc_soname libjemallocZdsoZa /* libjemalloc.so* */
26+
27 /* --- Soname of the GNU C++ library. --- */
28
29 #define m_libstdcxx_soname libstdcZpZpZa // libstdc++*
30@@ -203,6 +207,7 @@
31 // (from_so, from_fn, v's replacement)
32
33 // malloc
34+ALLOC_or_NULL(m_jemalloc_soname, malloc, malloc);
35 ALLOC_or_NULL(m_libstdcxx_soname, malloc, malloc);
36 ALLOC_or_NULL(m_libc_soname, malloc, malloc);
37 #if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5)
38@@ -319,6 +324,7 @@
39 }
40
41 // free
42+FREE(m_jemalloc_soname, free, free );
43 FREE(m_libstdcxx_soname, free, free );
44 FREE(m_libc_soname, free, free );
45 #if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5)
46@@ -394,6 +400,7 @@
47 return v; \
48 }
49
50+CALLOC(m_jemalloc_soname, calloc);
51 CALLOC(m_libc_soname, calloc);
52 #if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5)
53 CALLOC(m_libc_soname, calloc_common);
54@@ -426,6 +433,7 @@
55 return v; \
56 }
57
58+REALLOC(m_jemalloc_soname, realloc);
59 REALLOC(m_libc_soname, realloc);
60 #if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5)
61 REALLOC(m_libc_soname, realloc_common);
62@@ -457,6 +465,7 @@
63 return v; \
64 }
65
66+MEMALIGN(m_jemalloc_soname, memalign);
67 MEMALIGN(m_libc_soname, memalign);
68
69
70@@ -483,6 +492,7 @@
71 ((SizeT)pszB, size); \
72 }
73
74+VALLOC(m_jemalloc_soname, valloc);
75 VALLOC(m_libc_soname, valloc);
76
77
78@@ -566,6 +576,7 @@
79 return VKI_ENOMEM; \
80 }
81
82+POSIX_MEMALIGN(m_jemalloc_soname, posix_memalign);
83 POSIX_MEMALIGN(m_libc_soname, posix_memalign);
84 #if defined(VGP_ppc32_aix5) || defined(VGP_ppc64_aix5)
85 /* 27 Nov 07: it appears that xlc links into executables, a
86@@ -596,6 +607,7 @@
87 return pszB; \
88 }
89
90+MALLOC_USABLE_SIZE(m_jemalloc_soname, malloc_usable_size);
91 MALLOC_USABLE_SIZE(m_libc_soname, malloc_usable_size);
92
93
94EOF
95
96make -s