On Tue, May 23, 2017 at 5:12 PM, Ian Romanick <i...@freedesktop.org> wrote: > On 05/23/2017 12:49 PM, Rob Herring wrote: >> Simplify the handling of mmap for Android by using mmap64 instead. mmap64 >> may have not existed for Android when this was written, but it's been >> around since 2013. >> >> Signed-off-by: Rob Herring <r...@kernel.org> >> --- >> src/mesa/drivers/dri/i965/libdrm_macros.h | 17 ++--------------- >> 1 file changed, 2 insertions(+), 15 deletions(-) >> >> diff --git a/src/mesa/drivers/dri/i965/libdrm_macros.h >> b/src/mesa/drivers/dri/i965/libdrm_macros.h >> index 8be103c5b7ac..d6f44a52f86b 100644 >> --- a/src/mesa/drivers/dri/i965/libdrm_macros.h >> +++ b/src/mesa/drivers/dri/i965/libdrm_macros.h >> @@ -29,26 +29,13 @@ >> #include <sys/mman.h> >> >> #if defined(ANDROID) && !defined(__LP64__) > > Since this is inside a !defined(__LP64__) block... > >> -#include <errno.h> /* for EINVAL */ >> >> -extern void *__mmap2(void *, size_t, int, int, int, size_t); >> - >> -static inline void *drm_mmap(void *addr, size_t length, int prot, int flags, >> - int fd, loff_t offset) >> -{ >> - /* offset must be aligned to 4096 (not necessarily the page size) */ >> - if (offset & 4095) { >> - errno = EINVAL; >> - return MAP_FAILED; >> - } >> - >> - return __mmap2(addr, length, prot, flags, fd, (size_t) (offset >> 12)); >> -} >> +# define drm_mmap(addr, length, prot, flags, fd, offset) \ >> + mmap64(addr, length, prot, flags, fd, offset) > > ...is mmap64 actually the right thing to use? If it is, it might be > worth adding a comment why. That will prevent the next person from > wondering. :)
Yes, because on 64-bit mmap and mmap64 are the same thing. The other way this is solved on 32-bit systems is defining _FILE_OFFSET_BITS, but that was only added more recently in Android and won't work for older versions. Rob _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev