From: Gianluca Guida <gianluca.guida@eu.citrix.com>
To: Sandesh <sandesh.ahiremath@wipro.com>
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: Re: definition of mfn_x() macro..
Date: Thu, 17 Jul 2008 19:03:49 +0100 [thread overview]
Message-ID: <487F8985.6080305@eu.citrix.com> (raw)
In-Reply-To: <1216315750.8237.2.camel@ec4t16cg-1518809>
Hi,
Sandesh wrote:
> can you please tell me where the definition of mfn_x is?? I see it is
> being used at many places but not able to find its definition in xen
> source.
It's a type safety feature for debug compilation. As you can see in
xen/include/asm-x86/mm.h:
/* With this defined, we do some ugly things to force the compiler to
* give us type safety between mfns and gfns and other integers.
* TYPE_SAFE(int foo) defines a foo_t, and _foo() and foo_x() functions
* that translate beween int and foo_t.
*
* It does have some performance cost because the types now have
* a different storage attribute, so may not want it on all the time. */
#ifndef NDEBUG
#define TYPE_SAFETY 1
#endif
#ifdef TYPE_SAFETY
#define TYPE_SAFE(_type,_name) \
typedef struct { _type _name; } _name##_t; \
static inline _name##_t _##_name(_type n) { return (_name##_t) { n }; } \
static inline _type _name##_x(_name##_t n) { return n._name; }
#else
#define TYPE_SAFE(_type,_name) \
typedef _type _name##_t; \
static inline _name##_t _##_name(_type n) { return n; } \
static inline _type _name##_x(_name##_t n) { return n; }
#endif
TYPE_SAFE(unsigned long,mfn);
prev parent reply other threads:[~2008-07-17 18:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-17 17:29 definition of mfn_x() macro Sandesh
2008-07-17 18:03 ` Gianluca Guida [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=487F8985.6080305@eu.citrix.com \
--to=gianluca.guida@eu.citrix.com \
--cc=sandesh.ahiremath@wipro.com \
--cc=xen-devel@lists.xensource.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.