From 1a36fdfe7cf17aa23f0bd43eb6cca4d28e510def Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 30 May 2016 23:57:49 +0200 Subject: 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. --- mach-defpager/kalloc.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'mach-defpager/kalloc.c') 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) { -- cgit v1.2.3