[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 4/4] tools: add offsetof() to xen-tools/common-macros.h


  • To: Juergen Gross <jgross@xxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 6 Mar 2023 09:00:59 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=eVidFXoQ0TImv9+Uo+6DJD93B3ElRJR+9kbL/je1y4g=; b=nWw/FE0hYk1UUaWMd/+ZNA9C3VR35PR80fELTuQp1ey3Oqufwzbf4lEuiONYjjN0iDldwxNlxnLbiN4Du5BSKIE/JYGJCL9MPzsw+CH1NRzTwg+Gf2Tbtz8d6wF5wkh+MWqAKKEh7dyTotgc9IHNLD+7vMziSSojYPYth8bWpomW+gzjbxb48Wa+rsFotOjesQqys74tV3ldRxfZKHEHaYmTuFZGjAgOXs/6XZl7RAaZkLocsoU0V76jr970M57rT3lxcfZhU2gs+M7S6e/1rD6kWBk6YiEPhZTdABcp0hhhlVvENd+zNqUaJnaRnSSWd/1klfJRrvk3uSx/TA9fEA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ia5g6ZewEk6A4j7CtabKWykKY1wcuHu+bnBmFkuU8l8z97+90g1lv3cX7FZxX14dOK/3Za435xxzVSGS5IM2xtPc/U9Bt9s/VkX/tNpxd3yQK4PfrmvxcjEbR65M6ZmcGajKr3B4OOi2xNQ/UBLspngCXftMN+/jSwVMmwJGwlFr7Ve+GJ066qTDvbipRY1N4K6dsMM1cSZ2M7z2M21YJLJl6RDrYprMb81ESZOjOBmPPUe1SL9QdCmW1s3wWecoNsFiJN0zz/oZAuRvGkAN92ZKkpEL12LyP5Jg67acj/xYdP2aErAUfcB26Q2RFGogDTdlYipBMESdeGFvWniReg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Mon, 06 Mar 2023 08:01:27 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 06.03.2023 08:21, Juergen Gross wrote:
> --- a/tools/include/xen-tools/common-macros.h
> +++ b/tools/include/xen-tools/common-macros.h
> @@ -80,4 +80,8 @@
>      typeof( ((type *)0)->member ) *__mptr = (ptr);        \
>      (type *)( (char *)__mptr - offsetof(type,member) );})
>  
> +#ifndef offsetof
> +#define offsetof(a, b) __builtin_offsetof(a, b)
> +#endif

How's this going to work reliably with parties perhaps also including
stddef.h, which also is expected to define this macro, and which may
do so with a different sequence of tokens (even if that ends up
having the same effect)? There shouldn't be a need to define this
macro for any "normal" environments, e.g. ...

> --- a/tools/libfsimage/xfs/fsys_xfs.c
> +++ b/tools/libfsimage/xfs/fsys_xfs.c
> @@ -19,6 +19,7 @@
>  
>  #include <xenfsimage_grub.h>
>  #include "xfs.h"
> +#include <xen-tools/common-macros.h>
>  
>  #define MAX_LINK_COUNT       8
>  
> @@ -182,9 +183,6 @@ fsb2daddr (xfs_fsblock_t fsbno)
>                        (xfs_agblock_t)(fsbno & mask32lo(xfs.agblklog)));
>  }
>  
> -#undef offsetof
> -#define offsetof(t,m)        ((size_t)&(((t *)0)->m))
> -
>  static inline int
>  btroot_maxrecs (fsi_file_t *ffi)
>  {

... this library or ...

> --- a/tools/libs/vchan/init.c
> +++ b/tools/libs/vchan/init.c
> @@ -69,10 +69,6 @@
>  #define MAX_RING_SHIFT 20
>  #define MAX_RING_SIZE (1 << MAX_RING_SHIFT)
>  
> -#ifndef offsetof
> -#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
> -#endif
> -
>  static int init_gnt_srv(struct libxenvchan *ctrl, int domain)
>  {
>       int pages_left = ctrl->read.order >= PAGE_SHIFT ? 1 << 
> (ctrl->read.order - PAGE_SHIFT) : 0;

... this tool or ...

> --- a/tools/tests/vhpet/emul.h
> +++ b/tools/tests/vhpet/emul.h
> @@ -115,8 +115,6 @@ enum
>      NR_COMMON_SOFTIRQS
>  };
>  
> -#define offsetof(t, m) ((unsigned long )&((t *)0)->m)
> -
>  struct domain;
>  
>  struct vcpu

... this test binary (which is an ordinary host one as well). They all
should include stddef.h and be done.

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.