From dfd30035b9003cecda1c9f739aef9b083c09180c Mon Sep 17 00:00:00 2001 From: Icecream95 Date: Sun, 1 Aug 2021 23:11:41 +1200 Subject: [PATCH] drm-shim: Add a function for mmap64 rather than using an alias Fixes build on 32-bit systems. Reviewed-by: Emma Anholt Part-of: --- src/drm-shim/drm_shim.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/drm-shim/drm_shim.c b/src/drm-shim/drm_shim.c index 9566d42eeb3..2ba164c1017 100644 --- a/src/drm-shim/drm_shim.c +++ b/src/drm-shim/drm_shim.c @@ -70,6 +70,7 @@ REAL_FUNCTION_POINTER(fcntl); REAL_FUNCTION_POINTER(fopen); REAL_FUNCTION_POINTER(ioctl); REAL_FUNCTION_POINTER(mmap); +REAL_FUNCTION_POINTER(mmap64); REAL_FUNCTION_POINTER(open); REAL_FUNCTION_POINTER(opendir); REAL_FUNCTION_POINTER(readdir); @@ -209,6 +210,7 @@ init_shim(void) GET_FUNCTION_POINTER(fopen); GET_FUNCTION_POINTER(ioctl); GET_FUNCTION_POINTER(mmap); + GET_FUNCTION_POINTER(mmap64); GET_FUNCTION_POINTER(open); GET_FUNCTION_POINTER(opendir); GET_FUNCTION_POINTER(readdir); @@ -705,5 +707,15 @@ mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset) return real_mmap(addr, length, prot, flags, fd, offset); } -PUBLIC void *mmap64(void*, size_t, int, int, int, off_t) - __attribute__((alias("mmap"))); + +PUBLIC void * +mmap64(void* addr, size_t length, int prot, int flags, int fd, off64_t offset) +{ + init_shim(); + + struct shim_fd *shim_fd = drm_shim_fd_lookup(fd); + if (shim_fd) + return drm_shim_mmap(shim_fd, length, prot, flags, fd, offset); + + return real_mmap64(addr, length, prot, flags, fd, offset); +}