At request of Ulrich Drepper, call __libc_freeres() after final __NR_exit
so as to free memory allocated by glibc.  This reduces the leaks reported
in glibc, but causes a stack of read/write-after-free errors which have
to be suppressed :-(


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@507 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/vg_include.h b/coregrind/vg_include.h
index 31ba8e9..0d38c92 100644
--- a/coregrind/vg_include.h
+++ b/coregrind/vg_include.h
@@ -519,6 +519,9 @@
 #define VG_USERREQ__SET_FHSTACK_ENTRY       0x3027
 #define VG_USERREQ__GET_FHSTACK_ENTRY       0x3028
 
+/* Denote the finish of VG_(__libc_freeres_wrapper). */
+#define VG_USERREQ__LIBC_FREERES_DONE       0x3029
+
 /* Cosmetic ... */
 #define VG_USERREQ__GET_PTHREAD_TRACE_LEVEL 0x3101
 /* Log a pthread error from client-space.  Cosmetic. */
@@ -529,6 +532,10 @@
 #define VG_USERREQ__SIGNAL_RETURNS          0x4001
 */
 
+/* The scheduler does need to know the address of it so it can be
+   called at program exit. */
+extern void VG_(__libc_freeres_wrapper)( void );
+
 
 /* ---------------------------------------------------------------------
    Constants pertaining to the simulated CPU state, VG_(baseBlock),