Re: how to tell 64 vs 32 bit architecture ?

From: Fabio Checconi <fabio_at_freebsd.org>
Date: Fri, 7 Sep 2007 16:21:09 +0200
On Fri, Sep 07, 2007 at 05:03:10AM -0700, Luigi Rizzo wrote:
> i need to do this:
> 
> #ifdef BUILT_FOR_64BIT_POINTERS
> #define	MY_MAGIC	0xdeadbeefd00de123	/* 64 bit */
> #else
> #define	MY_MAGIC	0xdeadbeef		/* 32 bit */
> 
> If you know of a way to implement this without preprocessor
> magic, i am all ears. If the values were simpler (eg all ones or so)
> i could have used ~((unitptr_t)0) but this is not the case here

#include <stdint.h>

#if UINTPTR_MAX < 0xdeadbeefd00de123	/* <= 0xffffffff */
#define MY_MAGIC	0xdeadbeef
#else
#define MY_MAGIC	0xdeadbeefd00de123
#endif

does something like that look good to you ?

fabio
Received on Fri Sep 07 2007 - 13:21:24 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:17 UTC