maplelinux-bootstrap/patches/mesa-drm-maple.patch
Alexander Hill 9a562846c0 Successfully built Mesa!
Special thanks to L3m0n-Cao for helping me set up the Python build environment!
2025-07-18 23:03:11 -04:00

226 lines
5.3 KiB
Diff

--- src/drm-shim/drm_shim.c 2025-07-14 02:47:27.834000000 +0000
+++ src/drm-shim/drm_shim.c 2025-07-14 02:58:33.373000000 +0000
@@ -324,8 +324,6 @@
return real_fopen(path, mode);
}
-PUBLIC FILE *fopen64(const char *path, const char *mode)
- __attribute__((alias("fopen")));
/* Intercepts access(render_node_path) to trick drmGetMinorType */
PUBLIC int access(const char *path, int mode)
@@ -371,7 +369,6 @@
return fd;
}
-PUBLIC int open64(const char*, int, ...) __attribute__((alias("open")));
/* __open64_2 isn't declared unless _FORTIFY_SOURCE is defined. */
PUBLIC int __open64_2(const char *path, int flags);
@@ -429,45 +426,6 @@
return 0;
}
-/* Fakes stat to return character device stuff for our fake render node. */
-PUBLIC int __xstat64(int ver, const char *path, struct stat64 *st)
-{
- init_shim();
-
- /* Note: call real stat if we're in the process of probing for a free
- * render node!
- */
- if (render_node_minor == -1)
- return real___xstat64(ver, path, st);
-
- if (hide_drm_device_path(path)) {
- errno = ENOENT;
- return -1;
- }
-
- /* Fool libdrm's probe of whether the /sys dir for this char dev is
- * there.
- */
- char *sys_dev_drm_dir;
- nfasprintf(&sys_dev_drm_dir,
- "/sys/dev/char/%d:%d/device/drm",
- DRM_MAJOR, render_node_minor);
- if (strcmp(path, sys_dev_drm_dir) == 0) {
- free(sys_dev_drm_dir);
- return 0;
- }
- free(sys_dev_drm_dir);
-
- if (strcmp(path, render_node_path) != 0)
- return real___xstat64(ver, path, st);
-
- memset(st, 0, sizeof(*st));
- st->st_rdev = makedev(DRM_MAJOR, render_node_minor);
- st->st_mode = S_IFCHR;
-
- return 0;
-}
-
/* Fakes fstat to return character device stuff for our fake render node. */
PUBLIC int __fxstat(int ver, int fd, struct stat *st)
{
@@ -485,22 +443,6 @@
return 0;
}
-PUBLIC int __fxstat64(int ver, int fd, struct stat64 *st)
-{
- init_shim();
-
- struct shim_fd *shim_fd = drm_shim_fd_lookup(fd);
-
- if (!shim_fd)
- return real___fxstat64(ver, fd, st);
-
- memset(st, 0, sizeof(*st));
- st->st_rdev = makedev(DRM_MAJOR, render_node_minor);
- st->st_mode = S_IFCHR;
-
- return 0;
-}
-
#else
PUBLIC int stat(const char* path, struct stat* stat_buf)
@@ -541,44 +483,6 @@
return 0;
}
-PUBLIC int stat64(const char* path, struct stat64* stat_buf)
-{
- init_shim();
-
- /* Note: call real stat if we're in the process of probing for a free
- * render node!
- */
- if (render_node_minor == -1)
- return real_stat64(path, stat_buf);
-
- if (hide_drm_device_path(path)) {
- errno = ENOENT;
- return -1;
- }
-
- /* Fool libdrm's probe of whether the /sys dir for this char dev is
- * there.
- */
- char *sys_dev_drm_dir;
- nfasprintf(&sys_dev_drm_dir,
- "/sys/dev/char/%d:%d/device/drm",
- DRM_MAJOR, render_node_minor);
- if (strcmp(path, sys_dev_drm_dir) == 0) {
- free(sys_dev_drm_dir);
- return 0;
- }
- free(sys_dev_drm_dir);
-
- if (strcmp(path, render_node_path) != 0)
- return real_stat64(path, stat_buf);
-
- memset(stat_buf, 0, sizeof(*stat_buf));
- stat_buf->st_rdev = makedev(DRM_MAJOR, render_node_minor);
- stat_buf->st_mode = S_IFCHR;
-
- return 0;
-}
-
PUBLIC int fstat(int fd, struct stat* stat_buf)
{
init_shim();
@@ -594,22 +498,6 @@
return 0;
}
-
-PUBLIC int fstat64(int fd, struct stat64* stat_buf)
-{
- init_shim();
-
- struct shim_fd *shim_fd = drm_shim_fd_lookup(fd);
-
- if (!shim_fd)
- return real_fstat64(fd, stat_buf);
-
- memset(stat_buf, 0, sizeof(*stat_buf));
- stat_buf->st_rdev = makedev(DRM_MAJOR, render_node_minor);
- stat_buf->st_mode = S_IFCHR;
-
- return 0;
-}
#endif
/* Tracks if the opendir was on /dev/dri. */
@@ -664,34 +552,6 @@
return ent;
}
-/* If we're looking at /dev/dri, add our render node to the list
- * before the real entries in the directory.
- */
-PUBLIC struct dirent64 *
-readdir64(DIR *dir)
-{
- init_shim();
-
- struct dirent64 *ent = NULL;
-
- static struct dirent64 render_node_dirent = { 0 };
-
- simple_mtx_lock(&shim_lock);
- if (_mesa_set_search(opendir_set, dir)) {
- strcpy(render_node_dirent.d_name,
- render_node_dirent_name);
- render_node_dirent.d_type = DT_CHR;
- ent = &render_node_dirent;
- _mesa_set_remove_key(opendir_set, dir);
- }
- simple_mtx_unlock(&shim_lock);
-
- if (!ent && dir != fake_dev_dri)
- ent = real_readdir64(dir);
-
- return ent;
-}
-
/* Cleans up tracking of opendir("/dev/dri") */
PUBLIC int
closedir(DIR *dir)
@@ -774,7 +634,7 @@
* our DRM fd to drm_shim_ioctl().
*/
PUBLIC int
-ioctl(int fd, unsigned long request, ...)
+ioctl(int fd, int request, ...)
{
init_shim();
@@ -810,8 +670,6 @@
return ret;
}
-PUBLIC int fcntl64(int, int, ...)
- __attribute__((alias("fcntl")));
/* I wrote this when trying to fix gallium screen creation, leaving it around
* since it's probably good to have.
@@ -841,15 +699,3 @@
return real_mmap(addr, length, prot, flags, fd, offset);
}
-
-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);
-}