[dpdk-dev] [PATCH 2/2] mem: fix build on 32bits system

David Marchand david.marchand at 6wind.com
Fri Feb 28 09:21:36 CET 2014


Rebase commit 57c24af85d9eaa81549a212169605b4e2468a29f introduced a build
regression for 32bits system.

  CC eal_memory.o
/home/marchand/dpdk.org/lib/librte_eal/linuxapp/eal/eal_memory.c: In function
‘rte_mem_virt2phy’:
/home/marchand/dpdk.org/lib/librte_eal/linuxapp/eal/eal_memory.c:140:12: error: cast
from pointer to integer of different size [-Werror=pointer-to-int-cast]
  virtual = (uint64_t) virtaddr;
            ^
cc1: all warnings being treated as errors

Rework this patch so that it is equivalent to what we had in 1.5.2.

Signed-off-by: David Marchand <david.marchand at 6wind.com>
---
 lib/librte_eal/linuxapp/eal/eal_memory.c |   14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c
index 296f172..242f1b3 100644
--- a/lib/librte_eal/linuxapp/eal/eal_memory.c
+++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
@@ -131,13 +131,14 @@ phys_addr_t
 rte_mem_virt2phy(const void *virtaddr)
 {
 	int fd;
-	uint64_t page, physaddr, virtual;
-	unsigned long virt_pfn;
 	int page_size;
+	unsigned long virtual;
+	uint64_t page;
+	off_t offset;
 
 	/* standard page size */
 	page_size = getpagesize();
-	virtual = (uint64_t) virtaddr;
+	virtual = (unsigned long) virtaddr;
 
 	fd = open("/proc/self/pagemap", O_RDONLY);
 	if (fd < 0) {
@@ -146,9 +147,7 @@ rte_mem_virt2phy(const void *virtaddr)
 		return (uint64_t) -1;
 	}
 
-	off_t offset;
-	virt_pfn = (unsigned long)virtaddr / page_size;
-	offset = sizeof(uint64_t) * virt_pfn;
+	offset = sizeof(uint64_t) * virtual / page_size;
 	if (lseek(fd, offset, SEEK_SET) == (off_t) -1) {
 		RTE_LOG(ERR, EAL, "%s(): seek error in /proc/self/pagemap: %s\n",
 				__func__, strerror(errno));
@@ -166,9 +165,8 @@ rte_mem_virt2phy(const void *virtaddr)
 	 * the pfn (page frame number) are bits 0-54 (see
 	 * pagemap.txt in linux Documentation)
 	 */
-	physaddr = ((page & 0x7fffffffffffffULL) * page_size) + (virtual % page_size);
 	close(fd);
-	return physaddr;
+	return ((page & 0x7fffffffffffffULL) * page_size) + (virtual % page_size);
 }
 
 /*
-- 
1.7.10.4



More information about the dev mailing list