From: Samuel Thibault Subject: Re: [PATCH 4/5] libxc: minios: Introduce abstraction for files[] Date: Thu, 26 Feb 2015 14:10:10 +0100 Message-ID: <20150226131010.GC23750@type.bordeaux.inria.fr> References: <1424951781-14935-1-git-send-email-wei.liu2@citrix.com> <1424951781-14935-5-git-send-email-wei.liu2@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Content-Disposition: inline In-Reply-To: <1424951781-14935-5-git-send-email-wei.liu2@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Wei Liu Cc: Ian Jackson , ian.campbell@citrix.com, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org Wei Liu, le Thu 26 Feb 2015 11:56:20 +0000, a =E9crit : > From: Ian Jackson > = > We are going to want to reuse this code for NetBSD rump kernels, where > there is no gntmap device and we just want to call the MiniOS gntmap > code directly. > = > As part of this we want to abstract away the use of files[] inside the > actual functions. Do this with a #define whose definition we are > going to make conditional in just a moment. > = > No functional change in this patch. > = > Signed-off-by: Ian Jackson Acked-by: Samuel Thibault > --- > tools/libxc/xc_minios_privcmd.c | 15 +++++++-------- > 1 file changed, 7 insertions(+), 8 deletions(-) > = > diff --git a/tools/libxc/xc_minios_privcmd.c b/tools/libxc/xc_minios_priv= cmd.c > index 7766b86..27d9076 100644 > --- a/tools/libxc/xc_minios_privcmd.c > +++ b/tools/libxc/xc_minios_privcmd.c > @@ -208,12 +208,14 @@ struct xc_osdep_ops xc_privcmd_ops =3D { > }, > }; > = > +#define GNTMAP(h) (files[(int)(h)].gntmap) > + > static xc_osdep_handle minios_gnttab_open(xc_gnttab *xcg) > { > int fd =3D alloc_fd(FTYPE_GNTMAP); > if ( fd =3D=3D -1 ) > return XC_OSDEP_OPEN_ERROR; > - gntmap_init(&files[fd].gntmap); > + gntmap_init(&GNTMAP(h)); > return (xc_osdep_handle)fd; > } > = > @@ -225,7 +227,7 @@ static int minios_gnttab_close(xc_gnttab *xcg, xc_osd= ep_handle h) > = > void minios_gnttab_close_fd(int fd) > { > - gntmap_fini(&files[fd].gntmap); > + gntmap_fini(&GNTMAP(h)); > files[fd].type =3D FTYPE_NONE; > } > = > @@ -235,7 +237,6 @@ static void *minios_gnttab_grant_map(xc_gnttab *xcg, = xc_osdep_handle h, > uint32_t notify_offset, > evtchn_port_t notify_port) > { > - int fd =3D (int)h; > int stride =3D 1; > if (flags & XC_GRANT_MAP_SINGLE_DOMAIN) > stride =3D 0; > @@ -243,7 +244,7 @@ static void *minios_gnttab_grant_map(xc_gnttab *xcg, = xc_osdep_handle h, > errno =3D ENOSYS; > return NULL; > } > - return gntmap_map_grant_refs(&files[fd].gntmap, > + return gntmap_map_grant_refs(&GNTMAP(h), > count, domids, stride, > refs, prot & PROT_WRITE); > } > @@ -252,9 +253,8 @@ static int minios_gnttab_munmap(xc_gnttab *xcg, xc_os= dep_handle h, > void *start_address, > uint32_t count) > { > - int fd =3D (int)h; > int ret; > - ret =3D gntmap_munmap(&files[fd].gntmap, > + ret =3D gntmap_munmap(&GNTMAP(h), > (unsigned long) start_address, > count); > if (ret < 0) { > @@ -267,9 +267,8 @@ static int minios_gnttab_munmap(xc_gnttab *xcg, xc_os= dep_handle h, > static int minios_gnttab_set_max_grants(xc_gnttab *xcg, xc_osdep_handle = h, > uint32_t count) > { > - int fd =3D (int)h; > int ret; > - ret =3D gntmap_set_max_grants(&files[fd].gntmap, > + ret =3D gntmap_set_max_grants(&GNTMAP(h), > count); > if (ret < 0) { > errno =3D -ret; > -- = > 1.9.1 > = > = > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel > = -- = Samuel I am the "ILOVEGNU" signature virus. Just copy me to your signature. This email was infected under the terms of the GNU General Public License.