From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f173.google.com (mail-wi0-f173.google.com [209.85.212.173]) by dpdk.org (Postfix) with ESMTP id 9BB7358EE for ; Fri, 26 Jul 2013 13:33:41 +0200 (CEST) Received: by mail-wi0-f173.google.com with SMTP id en1so636109wid.0 for ; Fri, 26 Jul 2013 04:34:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:subject:date:message-id:x-mailer:x-gm-message-state; bh=EwwXY1XBSr8s2+SPHvvgdlu9ESUgw0po5tXg0piYAoI=; b=kI/PnzO0SGXoiHGLVwNkyaeCRJcCh+rTnjgQ6ew+cELXaH4HWN3X3CU95ZMyqcdjjs X7v4e6j23uLfeMdbwJyVTkJKBTNfUP2j1Dpmopy1XvPeNXZ0EplVQEX3y7A0INTT7StR 4BNFaTKxJ/ZoZnRzpLB81o/Alepdmpz59/GLj+zXYd5xBS6hLGQTonbxmA0uhaKNGDpx Cj8Nmb08L1zhbxKg6e4oBVHPWGgUJPMi8qOaEzPflABO19dvAVxRNm1E0KZn4x57Vm2L AtZ5edYjLIKchsqWIbgPK7arGzlml5SooqzFdI6NZDgAjKgpk0KB+DkukKDHUAAHJMJJ osGw== X-Received: by 10.180.73.103 with SMTP id k7mr5392213wiv.24.1374838444431; Fri, 26 Jul 2013 04:34:04 -0700 (PDT) Received: from 6wind.com (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id j20sm4071697wie.7.2013.07.26.04.34.01 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 26 Jul 2013 04:34:03 -0700 (PDT) Received: by 6wind.com (sSMTP sendmail emulation); Fri, 26 Jul 2013 13:34:00 +0200 From: Thomas Monjalon To: dev@dpdk.org Date: Fri, 26 Jul 2013 13:34:00 +0200 Message-Id: <1374838440-21429-1-git-send-email-thomas.monjalon@6wind.com> X-Mailer: git-send-email 1.7.10.4 X-Gm-Message-State: ALoCoQntx0XDDNfw3ot1XIGv0XwbvsbH+dvvCe/UTLEnZfzWnTciAn94ebdd1cHCVXmw0V4S9Obt Subject: [dpdk-dev] [PATCH] eal: fix type of pointer arithmetic result X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Jul 2013 11:33:41 -0000 Adding or subtracting a value to a pointer makes a new pointer of unknown type. So typeof() is replaced by (void*) in RTE_PTR_ADD() and RTE_PTR_SUB(). But RTE_PTR_ALIGN_* macros have in their explicit API to return a pointer of the same type. Since RTE_PTR_ALIGN_CEIL is based on RTE_PTR_ADD, a typeof() is added to keep the original behaviour. Signed-off-by: Thomas Monjalon --- lib/librte_eal/common/include/rte_common.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h index 96aeeee..d2e096d 100644 --- a/lib/librte_eal/common/include/rte_common.h +++ b/lib/librte_eal/common/include/rte_common.h @@ -70,12 +70,12 @@ extern "C" { /** * add a byte-value offset from a pointer */ -#define RTE_PTR_ADD(ptr, x) ((typeof(ptr))((uintptr_t)ptr + (x))) +#define RTE_PTR_ADD(ptr, x) ((void*)((uintptr_t)ptr + (x))) /** * subtract a byte-value offset from a pointer */ -#define RTE_PTR_SUB(ptr, x) ((typeof(ptr))((uintptr_t)ptr - (x))) +#define RTE_PTR_SUB(ptr, x) ((void*)((uintptr_t)ptr - (x))) /** * get the difference between two pointer values, i.e. how far apart @@ -131,7 +131,7 @@ rte_align_floor_int(uintptr_t ptr, uintptr_t align) * must be a power-of-two value. */ #define RTE_PTR_ALIGN_CEIL(ptr, align) \ - RTE_PTR_ALIGN_FLOOR(RTE_PTR_ADD(ptr, align - 1), align) + RTE_PTR_ALIGN_FLOOR((typeof(ptr))RTE_PTR_ADD(ptr, align - 1), align) /** * Macro to align a value to a given power-of-two. The resultant value -- 1.7.10.4