From owner-freebsd-current@FreeBSD.ORG Fri Sep 7 12:50:11 2007 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3DEEC16A417 for ; Fri, 7 Sep 2007 12:50:11 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from igloo.linux.gr (igloo.linux.gr [62.1.205.36]) by mx1.freebsd.org (Postfix) with ESMTP id B43EA13C457 for ; Fri, 7 Sep 2007 12:50:10 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from kobe.laptop (vader.bytemobile.ondsl.gr [83.235.244.135]) (authenticated bits=128) by igloo.linux.gr (8.14.1/8.14.1/Debian-8) with ESMTP id l87CnuVr025449 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 7 Sep 2007 15:50:02 +0300 Received: from kobe.laptop (kobe.laptop [127.0.0.1]) by kobe.laptop (8.14.1/8.14.1) with ESMTP id l87CneC9003477; Fri, 7 Sep 2007 15:49:55 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost) by kobe.laptop (8.14.1/8.14.1/Submit) id l87CndPd003476; Fri, 7 Sep 2007 15:49:39 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Date: Fri, 7 Sep 2007 15:49:39 +0300 From: Giorgos Keramidas To: Luigi Rizzo Message-ID: <20070907124938.GE3164@kobe.laptop> References: <20070906111028.A83649@xorpc.icir.org> <20070906222647.GB2737@kobe.laptop> <20070907000950.A91211@xorpc.icir.org> <20070907115021.GA2718@kobe.laptop> <20070907050310.A94579@xorpc.icir.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20070907050310.A94579@xorpc.icir.org> X-Hellug-MailScanner: Found to be clean X-Hellug-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-3.96, required 5, autolearn=not spam, ALL_TRUSTED -1.80, AWL 0.44, BAYES_00 -2.60) X-Hellug-MailScanner-From: keramida@ceid.upatras.gr X-Spam-Status: No Cc: current@freebsd.org Subject: Re: how to tell 64 vs 32 bit architecture ? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Sep 2007 12:50:11 -0000 On 2007-09-07 05:03, Luigi Rizzo wrote: >On Fri, Sep 07, 2007 at 02:50:21PM +0300, Giorgos Keramidas wrote: >>> i am actually looking at pointer sizes, as i need to do some pointer >>> manipulation going through intptr_t, and need to know that in the >>> preprocessor because some constants need to be 32 or 64 bit depending >>> on that, and are not trivial (i.e. not 0, 1 or something i can build >>> with size-agnostic expressions) >> >> An intptr_t can safely hold any void pointer value [..a.] >> What sort of manipulation? Can this sort of manipulation be written in >> a way that uses sizeof(intptr_t) instead of 4, 8, or preprocessor magic? > > 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 You essentially want sizeof() at the preprocessor context. I don't think this is possible to write portably without preprocessor magic.