From cf570d22242daae63a9763efcd05c45bc8a6c6b8 Mon Sep 17 00:00:00 2001 From: Owen Shepherd Date: Sun, 23 Nov 2014 18:30:13 +0000 Subject: [PATCH] [gandr]: implement /_PDCLIB_(alloc|free)pages/ --- .../gandr/functions/_PDCLIB/_PDCLIB_allocpages.c | 15 ++++++++++----- .../gandr/functions/_PDCLIB/_PDCLIB_freepages.c | 7 ++++++- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/platform/gandr/functions/_PDCLIB/_PDCLIB_allocpages.c b/platform/gandr/functions/_PDCLIB/_PDCLIB_allocpages.c index bdcd525..4851779 100644 --- a/platform/gandr/functions/_PDCLIB/_PDCLIB_allocpages.c +++ b/platform/gandr/functions/_PDCLIB/_PDCLIB_allocpages.c @@ -6,18 +6,23 @@ Permission is granted to use, modify, and / or redistribute at will. */ -/* This is a stub implementation of _PDCLIB_allocpages -*/ - #include #include #include <_PDCLIB_glue.h> #include +#include void * _PDCLIB_allocpages( size_t n ) { - errno = ENOTSUP; - return NULL; + void *p = NULL; + int rv = gd_alloc_pages( gd_loader_data, &p, n ); + + if (rv) { + errno = rv; + return NULL; + } else { + return p; + } } #ifdef TEST diff --git a/platform/gandr/functions/_PDCLIB/_PDCLIB_freepages.c b/platform/gandr/functions/_PDCLIB/_PDCLIB_freepages.c index c776876..285589f 100644 --- a/platform/gandr/functions/_PDCLIB/_PDCLIB_freepages.c +++ b/platform/gandr/functions/_PDCLIB/_PDCLIB_freepages.c @@ -13,10 +13,15 @@ #include #include <_PDCLIB_glue.h> #include +#include void _PDCLIB_freepages( void * p, size_t n ) { - return; + int rv = 0; + if((rv = gd_free_pages( p, n ))) { + perror("_PDCLIB_freepages"); + abort(); + } } #ifdef TEST -- 2.40.0