[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 05/19: Revert "drop the deprecated malloc/free hooks in hurd/mach
From: |
Samuel Thibault |
Subject: |
[hurd] 05/19: Revert "drop the deprecated malloc/free hooks in hurd/mach-defpager" |
Date: |
Wed, 10 Aug 2016 00:05:49 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch upstream
in repository hurd.
commit 6f6d157c55b6973f0a557b65269b212d9dcd1fbe
Author: Samuel Thibault <address@hidden>
Date: Mon May 30 23:34:23 2016 +0200
Revert "drop the deprecated malloc/free hooks in hurd/mach-defpager"
This reverts commit 8c49801c8f7e3f800cabedf8fca8ccec3cf35a22.
The malloc hook is needed for calloc.
---
mach-defpager/kalloc.c | 29 +++++++++++++++++++++++++----
1 file changed, 25 insertions(+), 4 deletions(-)
diff --git a/mach-defpager/kalloc.c b/mach-defpager/kalloc.c
index 35ddf9a..ef844ac 100644
--- a/mach-defpager/kalloc.c
+++ b/mach-defpager/kalloc.c
@@ -34,9 +34,23 @@
#include <mach.h>
#include <pthread.h> /* for spin locks */
+#include <malloc.h> /* for malloc_hook/free_hook */
#include "wiring.h"
+static void init_hook (void);
+static void *malloc_hook (size_t size, const void *caller);
+static void free_hook (void *ptr, const void *caller);
+
+/* GNU libc 2.14 defines this macro to declare hook variables as volatile.
+ Define it as empty for older libc versions. */
+#ifndef __MALLOC_HOOK_VOLATILE
+# define __MALLOC_HOOK_VOLATILE
+#endif
+
+void (*__MALLOC_HOOK_VOLATILE __malloc_initialize_hook) (void) = init_hook;
+
+
/* #define DEBUG */
/*
@@ -250,14 +264,21 @@ kfree( void *data,
}
}
-void *
-malloc (size_t size)
+static void
+init_hook (void)
+{
+ __malloc_hook = malloc_hook;
+ __free_hook = free_hook;
+}
+
+static void *
+malloc_hook (size_t size, const void *caller)
{
return (void *) kalloc ((vm_size_t) size);
}
-void
-free (void *ptr)
+static void
+free_hook (void *ptr, const void *caller)
{
/* Just ignore harmless attempts at cleanliness. */
/* panic("free not implemented"); */
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git
- [hurd] branch upstream updated (04cfa52 -> 02f5c02), Samuel Thibault, 2016/08/09
- [hurd] 18/19: Support MSG_DONTWAIT in pflocal send/recv, Samuel Thibault, 2016/08/09
- [hurd] 19/19: trans/crash: core file name templates, Samuel Thibault, 2016/08/09
- [hurd] 05/19: Revert "drop the deprecated malloc/free hooks in hurd/mach-defpager",
Samuel Thibault <=
- [hurd] 09/19: trans/crash: fix resource leaks, Samuel Thibault, 2016/08/09
- [hurd] 06/19: Complete allocation hooks, Samuel Thibault, 2016/08/09
- [hurd] 12/19: pfinet: fix memory leak, Samuel Thibault, 2016/08/09
- [hurd] 13/19: proc: Fix references to the startup server., Samuel Thibault, 2016/08/09
- [hurd] 02/19: ext2fs: fix pager use-after-free, Samuel Thibault, 2016/08/09
- [hurd] 01/19: libdiskfs: fix error handling, Samuel Thibault, 2016/08/09
- [hurd] 07/19: Fix pipe_send() with no data, Samuel Thibault, 2016/08/09
- [hurd] 11/19: trans/crash: fix blunder, Samuel Thibault, 2016/08/09
- [hurd] 16/19: proc: Fix permission check., Samuel Thibault, 2016/08/09
- [hurd] 14/19: libpager: provide 'pager_create_alloc', Samuel Thibault, 2016/08/09