Re: [PATCH] devmem: support more than 4GB of physical memory on 32 bit systems

2016-07-03 Thread Denys Vlasenko
On Thu, Jun 30, 2016 at 1:24 PM, Robert Schiele  wrote:
> Signed-off-by: Robert Schiele 
> ---
>  miscutils/devmem.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/miscutils/devmem.c b/miscutils/devmem.c
> index 786a21b..5515da5 100644
> --- a/miscutils/devmem.c
> +++ b/miscutils/devmem.c
> @@ -20,7 +20,7 @@ int devmem_main(int argc UNUSED_PARAM, char **argv)
> void *map_base, *virt_addr;
> uint64_t read_result;
> uint64_t writeval = writeval; /* for compiler */
> -   off_t target;
> +   off64_t target;
> unsigned page_size, mapped_size, offset_in_page;
> int fd;
> unsigned width = 8 * sizeof(int);
> @@ -72,12 +72,12 @@ int devmem_main(int argc UNUSED_PARAM, char **argv)
>  * Must map two pages to make it possible: */
> mapped_size *= 2;
> }
> -   map_base = mmap(NULL,
> +   map_base = mmap64(NULL,
> mapped_size,
> argv[3] ? (PROT_READ | PROT_WRITE) : PROT_READ,
> MAP_SHARED,
> fd,
> -   target & ~(off_t)(page_size - 1));
> +   target & ~(off64_t)(page_size - 1));
> if (map_base == MAP_FAILED)
> bb_perror_msg_and_die("mmap");


Wouldn't it work without this path if you select CONFIG_LFS=y ?
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH] devmem: support more than 4GB of physical memory on 32 bit systems

2016-06-30 Thread Laurent Bercot

On 30/06/2016 13:24, Robert Schiele wrote:

-   off_t target;
+   off64_t target;


 http://stackoverflow.com/a/3221920

 If you need 64-bit types, compile your programs with -D_FILE_OFFSET_BITS=64,
which should be the default on reasonable systems (not sure how common
reasonable systems are nowadays though).
 Please don't use the foobar64_t types, which are a very ugly piece of
glibc bugware and make the code actually incorrect on 32-bit machines.

--
 Laurent

___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[PATCH] devmem: support more than 4GB of physical memory on 32 bit systems

2016-06-30 Thread Robert Schiele
Signed-off-by: Robert Schiele 
---
 miscutils/devmem.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/miscutils/devmem.c b/miscutils/devmem.c
index 786a21b..5515da5 100644
--- a/miscutils/devmem.c
+++ b/miscutils/devmem.c
@@ -20,7 +20,7 @@ int devmem_main(int argc UNUSED_PARAM, char **argv)
void *map_base, *virt_addr;
uint64_t read_result;
uint64_t writeval = writeval; /* for compiler */
-   off_t target;
+   off64_t target;
unsigned page_size, mapped_size, offset_in_page;
int fd;
unsigned width = 8 * sizeof(int);
@@ -72,12 +72,12 @@ int devmem_main(int argc UNUSED_PARAM, char **argv)
 * Must map two pages to make it possible: */
mapped_size *= 2;
}
-   map_base = mmap(NULL,
+   map_base = mmap64(NULL,
mapped_size,
argv[3] ? (PROT_READ | PROT_WRITE) : PROT_READ,
MAP_SHARED,
fd,
-   target & ~(off_t)(page_size - 1));
+   target & ~(off64_t)(page_size - 1));
if (map_base == MAP_FAILED)
bb_perror_msg_and_die("mmap");
 
-- 
2.8.4
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox