Message ID | 20210112181242.1570-9-bouyer@antioche.eu.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | libs/call: fix build on NetBSD | expand |
On Tue, Jan 12, 2021 at 07:12:29PM +0100, Manuel Bouyer wrote: > From: Manuel Bouyer <bouyer@netbsd.org> > > Define PAGE_* if not already defined > Catch up with osdep interface change. > > Signed-off-by: Manuel Bouyer <bouyer@netbsd.org> Reviewed-by: Roger Pau Monné <roger.pau@citrix.com> Just one comment below, please keep the tag when resending with the fixed comment. > --- > tools/libs/call/netbsd.c | 19 +++++++++++-------- > tools/libs/call/private.h | 6 ++++-- > 2 files changed, 15 insertions(+), 10 deletions(-) > > diff --git a/tools/libs/call/netbsd.c b/tools/libs/call/netbsd.c > index a5502da377..4dcc2919ba 100644 > --- a/tools/libs/call/netbsd.c > +++ b/tools/libs/call/netbsd.c > @@ -19,12 +19,15 @@ > * Split from xc_netbsd.c > */ > > -#include "xc_private.h" > > #include <unistd.h> > #include <fcntl.h> > #include <malloc.h> > +#include <errno.h> > #include <sys/mman.h> > +#include <sys/ioctl.h> > + > +#include "private.h" > > int osdep_xencall_open(xencall_handle *xcall) > { > @@ -69,12 +72,13 @@ int osdep_xencall_close(xencall_handle *xcall) > return close(fd); > } > > -void *osdep_alloc_hypercall_buffer(xencall_handle *xcall, size_t npages) > +void *osdep_alloc_pages(xencall_handle *xcall, size_t npages) > { > - size_t size = npages * XC_PAGE_SIZE; > + size_t size = npages * PAGE_SIZE; > void *p; > + int ret; > > - ret = posix_memalign(&p, XC_PAGE_SIZE, size); > + ret = posix_memalign(&p, PAGE_SIZE, size); > if ( ret != 0 || !p ) > return NULL; > > @@ -86,14 +90,13 @@ void *osdep_alloc_hypercall_buffer(xencall_handle *xcall, size_t npages) > return p; > } > > -void osdep_free_hypercall_buffer(xencall_handle *xcall, void *ptr, > - size_t npages) > +void osdep_free_pages(xencall_handle *xcall, void *ptr, size_t npages) > { > - (void) munlock(ptr, npages * XC_PAGE_SIZE); > + munlock(ptr, npages * PAGE_SIZE); > free(ptr); > } > > -int do_xen_hypercall(xencall_handle *xcall, privcmd_hypercall_t *hypercall) > +int osdep_hypercall(xencall_handle *xcall, privcmd_hypercall_t *hypercall) > { > int fd = xcall->fd; > int error = ioctl(fd, IOCTL_PRIVCMD_HYPERCALL, hypercall); > diff --git a/tools/libs/call/private.h b/tools/libs/call/private.h > index 57e49356a1..2ca84d723b 100644 > --- a/tools/libs/call/private.h > +++ b/tools/libs/call/private.h > @@ -13,11 +13,13 @@ > #include <xen/sys/privcmd.h> > #endif > > -#ifndef PAGE_SHIFT /* Mini-os, Yukk */ > +#ifndef PAGE_SHIFT I would keep the comment somewhere that Mini-os already have all those defined, and hence we can just straight define them. Thanks, Roger.
diff --git a/tools/libs/call/netbsd.c b/tools/libs/call/netbsd.c index a5502da377..4dcc2919ba 100644 --- a/tools/libs/call/netbsd.c +++ b/tools/libs/call/netbsd.c @@ -19,12 +19,15 @@ * Split from xc_netbsd.c */ -#include "xc_private.h" #include <unistd.h> #include <fcntl.h> #include <malloc.h> +#include <errno.h> #include <sys/mman.h> +#include <sys/ioctl.h> + +#include "private.h" int osdep_xencall_open(xencall_handle *xcall) { @@ -69,12 +72,13 @@ int osdep_xencall_close(xencall_handle *xcall) return close(fd); } -void *osdep_alloc_hypercall_buffer(xencall_handle *xcall, size_t npages) +void *osdep_alloc_pages(xencall_handle *xcall, size_t npages) { - size_t size = npages * XC_PAGE_SIZE; + size_t size = npages * PAGE_SIZE; void *p; + int ret; - ret = posix_memalign(&p, XC_PAGE_SIZE, size); + ret = posix_memalign(&p, PAGE_SIZE, size); if ( ret != 0 || !p ) return NULL; @@ -86,14 +90,13 @@ void *osdep_alloc_hypercall_buffer(xencall_handle *xcall, size_t npages) return p; } -void osdep_free_hypercall_buffer(xencall_handle *xcall, void *ptr, - size_t npages) +void osdep_free_pages(xencall_handle *xcall, void *ptr, size_t npages) { - (void) munlock(ptr, npages * XC_PAGE_SIZE); + munlock(ptr, npages * PAGE_SIZE); free(ptr); } -int do_xen_hypercall(xencall_handle *xcall, privcmd_hypercall_t *hypercall) +int osdep_hypercall(xencall_handle *xcall, privcmd_hypercall_t *hypercall) { int fd = xcall->fd; int error = ioctl(fd, IOCTL_PRIVCMD_HYPERCALL, hypercall); diff --git a/tools/libs/call/private.h b/tools/libs/call/private.h index 57e49356a1..2ca84d723b 100644 --- a/tools/libs/call/private.h +++ b/tools/libs/call/private.h @@ -13,11 +13,13 @@ #include <xen/sys/privcmd.h> #endif -#ifndef PAGE_SHIFT /* Mini-os, Yukk */ +#ifndef PAGE_SHIFT #define PAGE_SHIFT 12 #endif -#ifndef __MINIOS__ /* Yukk */ +#ifndef PAGE_SIZE #define PAGE_SIZE (1UL << PAGE_SHIFT) +#endif +#ifndef PAGE_MASK #define PAGE_MASK (~(PAGE_SIZE-1)) #endif