Received: from eggs.gnu.org ([2001:4830:134:3::10]:52564) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c76FW-0000ei-GD for qemu-devel@nongnu.org; Wed, 16 Nov 2016 14:52:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c76FV-00072H-7K for qemu-devel@nongnu.org; Wed, 16 Nov 2016 14:52:02 -0500 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:35218) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c76FV-000728-0w for qemu-devel@nongnu.org; Wed, 16 Nov 2016 14:52:01 -0500 Received: by mail-wm0-x244.google.com with SMTP id a20so14578211wme.2 for ; Wed, 16 Nov 2016 11:52:00 -0800 (PST) Sender: Richard Henderson From: Richard Henderson Date: Wed, 16 Nov 2016 20:51:37 +0100 Message-Id: <1479325910-9060-2-git-send-email-rth@twiddle.net> In-Reply-To: <1479325910-9060-1-git-send-email-rth@twiddle.net> References: <1479325910-9060-1-git-send-email-rth@twiddle.net> Subject: [Qemu-devel] [RFC 01/14] tcg: Use NULL for TCGV_UNUSED_* List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aurelien@aurel32.net, peter.maydell@linaro.org Signed-off-by: Richard Henderson --- tcg/tcg.c | 6 +++++- tcg/tcg.h | 12 ++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index aabf94f..057c1ea 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -329,7 +329,11 @@ void tcg_context_init(TCGContext *s) GHashTable *helper_table; memset(s, 0, sizeof(*s)); - s->nb_globals = 0; + + /* Reserve global 0 so that, when foxing these integrals + as pointers, NULL is unused. */ + s->nb_globals = 1; + s->nb_temps = 1; /* Count total number of arguments and allocate the corresponding space */ diff --git a/tcg/tcg.h b/tcg/tcg.h index 5fd3733..b2cdaff 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -467,13 +467,13 @@ static inline intptr_t QEMU_ARTIFICIAL GET_TCGV_PTR(TCGv_ptr t) #define TCGV_EQUAL_PTR(a, b) (GET_TCGV_PTR(a) == GET_TCGV_PTR(b)) /* Dummy definition to avoid compiler warnings. */ -#define TCGV_UNUSED_I32(x) x = MAKE_TCGV_I32(-1) -#define TCGV_UNUSED_I64(x) x = MAKE_TCGV_I64(-1) -#define TCGV_UNUSED_PTR(x) x = MAKE_TCGV_PTR(-1) +#define TCGV_UNUSED_I32(x) x = NULL +#define TCGV_UNUSED_I64(x) x = NULL +#define TCGV_UNUSED_PTR(x) x = NULL -#define TCGV_IS_UNUSED_I32(x) (GET_TCGV_I32(x) == -1) -#define TCGV_IS_UNUSED_I64(x) (GET_TCGV_I64(x) == -1) -#define TCGV_IS_UNUSED_PTR(x) (GET_TCGV_PTR(x) == -1) +#define TCGV_IS_UNUSED_I32(x) ((x) == NULL) +#define TCGV_IS_UNUSED_I64(x) ((x) == NULL) +#define TCGV_IS_UNUSED_PTR(x) ((x) == NULL) /* call flags */ /* Helper does not read globals (either directly or through an exception). It -- 2.7.4