diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2016-05-30 23:57:49 +0200 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2016-05-30 23:57:49 +0200 |
commit | 1a36fdfe7cf17aa23f0bd43eb6cca4d28e510def (patch) | |
tree | dc73e2740250ed2b8cbf973131bb673daa0faae7 | |
parent | 6f6d157c55b6973f0a557b65269b212d9dcd1fbe (diff) |
Complete allocation hooks
* mach-defpager/kalloc.c (realloc_hook, memalign_hook): New functions.
(init_hook): Set __realloc_hook to realloc_hook and __memalign_hook to
memalign_hook.
-rw-r--r-- | mach-defpager/kalloc.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/mach-defpager/kalloc.c b/mach-defpager/kalloc.c index ef844acc..e4ed12fb 100644 --- a/mach-defpager/kalloc.c +++ b/mach-defpager/kalloc.c @@ -40,6 +40,8 @@ static void init_hook (void); static void *malloc_hook (size_t size, const void *caller); +static void *realloc_hook (void *ptr, size_t size, const void *caller); +static void *memalign_hook (size_t alignment, 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. @@ -268,6 +270,8 @@ static void init_hook (void) { __malloc_hook = malloc_hook; + __realloc_hook = realloc_hook; + __memalign_hook = memalign_hook; __free_hook = free_hook; } @@ -277,6 +281,20 @@ malloc_hook (size_t size, const void *caller) return (void *) kalloc ((vm_size_t) size); } +static void * +realloc_hook (void *ptr, size_t size, const void *caller) +{ + panic("realloc_hook not implemented"); +} + +static void * +memalign_hook (size_t alignment, size_t size, const void *caller) +{ + if (alignment > vm_page_size) + panic("memalign_hook not implemented"); + return malloc_hook(size, caller); +} + static void free_hook (void *ptr, const void *caller) { |