mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Huang Ying <ying.huang@intel.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Joe Perches <joe@perches.com>,
	Steven Whitehouse <swhiteho@redhat.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [RFC 1/2] Unified UUID/GUID definition
Date: Fri, 16 Oct 2009 17:19:42 +0800	[thread overview]
Message-ID: <1255684782.1951.28.camel@yhuang-dev.sh.intel.com> (raw)
In-Reply-To: <200910161103.40689.laurent.pinchart@ideasonboard.com>

On Fri, 2009-10-16 at 17:03 +0800, Laurent Pinchart wrote:
[...] 
> > +#define UUID_LE(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)		\
> > +((uuid_le)								\
> > +{{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff,
> >  \ +   (b) & 0xff, ((b) >> 8) & 0xff,					\
> > +   (c) & 0xff, ((c) >> 8) & 0xff,					\
> > +   (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }})
> > +
> > +#define UUID_BE(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)		\
> > +((uuid_be)								\
> > +{{ ((a) >> 24) & 0xff, ((a) >> 16) & 0xff, ((a) >> 8) & 0xff, (a) & 0xff,
> >  \ +   ((b) >> 8) & 0xff, (b) & 0xff,					\
> > +   ((c) >> 8) & 0xff, (c) & 0xff,					\
> > +   (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }})
> > +
> > +#define NULL_UUID_LE							\
> > +	UUID_LE(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00,	\
> > +		0x00, 0x00, 0x00, 0x00)
> > +
> > +#define NULL_UUID_BE							\
> > +	UUID_BE(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00,	\
> > +		0x00, 0x00, 0x00, 0x00)
> > +
> > +static inline int uuid_le_cmp(const uuid_le u1, const uuid_le u2)
> > +{
> > +	return memcmp(&u1, &u2, sizeof(uuid_le));
> > +}
> > +
> > +static inline int uuid_be_cmp(const uuid_be u1, const uuid_be u2)
> > +{
> > +	return memcmp(&u1, &u2, sizeof(uuid_be));
> > +}
> 
> Shouldn't you pass pointers to those functions instead ?

This is intended for a typical usage model (in fact copied from efi.h).

#define MY_UUID_LE	UUID_LE(...)

if (uuid_le_cmp(uuid, MY_UUID_LE)) {
	...
}

You need not define another variable for comparing with a UUID constant.

> It would also be nice to have a single uuid_cmp function. Would it be possible 
> to use typeof(), __builtin_types_compatible_p() and BUILD_BUG_ON_ZERO magic to 
> make sure both arguments are of the same type and one of uuid_be and uuid_le ? 
> It might no work with the Intel compiler though.

It seems a little tricky and complex. This is just a very simple
function.

Best Regards,
Huang Ying



      reply	other threads:[~2009-10-16  9:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-14  6:30 Huang Ying
2009-10-14  7:01 ` Joe Perches
2009-10-14  7:06   ` Huang Ying
2009-10-16  9:03 ` Laurent Pinchart
2009-10-16  9:19   ` Huang Ying [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1255684782.1951.28.camel@yhuang-dev.sh.intel.com \
    --to=ying.huang@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=joe@perches.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=swhiteho@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®