From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gianluca Guida Subject: Re: definition of mfn_x() macro.. Date: Thu, 17 Jul 2008 19:03:49 +0100 Message-ID: <487F8985.6080305@eu.citrix.com> References: <1216315750.8237.2.camel@ec4t16cg-1518809> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1216315750.8237.2.camel@ec4t16cg-1518809> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Sandesh Cc: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org 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);