--- dma-buf-compat.h.orig	2026-09-11 00:00:00 UTC
+++ dma-buf-compat.h	2026-09-11 00:00:00 UTC
@@ -0,0 +1,38 @@
+#ifndef DMA_BUF_COMPAT_H
+#define DMA_BUF_COMPAT_H
+
+#ifdef __linux__
+#include <linux/dma-buf.h>
+#include <linux/udmabuf.h>
+#else
+#include <stdint.h>
+#include <sys/ioctl.h>
+
+#define DMA_BUF_SYNC_READ  (1 << 0)
+#define DMA_BUF_SYNC_WRITE (2 << 0)
+#define DMA_BUF_SYNC_RW    (DMA_BUF_SYNC_READ | DMA_BUF_SYNC_WRITE)
+#define DMA_BUF_SYNC_START (0 << 2)
+#define DMA_BUF_SYNC_END   (1 << 2)
+
+struct dma_buf_sync
+{
+  uint64_t flags;
+};
+
+#define DMA_BUF_BASE 'b'
+#define DMA_BUF_IOCTL_SYNC _IOW(DMA_BUF_BASE, 0, struct dma_buf_sync)
+
+struct udmabuf_create
+{
+  uint32_t memfd;
+  uint32_t flags;
+  uint64_t offset;
+  uint64_t size;
+};
+
+#define UDMABUF_FLAGS_CLOEXEC 0x01
+#define UDMABUF_IOCTL_BASE 'u'
+#define UDMABUF_CREATE _IOW(UDMABUF_IOCTL_BASE, 0x42, struct udmabuf_create)
+#endif
+
+#endif
--- gdk/gdkdmabuf.c.orig	2026-09-11 00:00:00 UTC
+++ gdk/gdkdmabuf.c	2026-09-11 00:00:00 UTC
@@ -29,9 +29,6 @@
 #include <fcntl.h>
 #include <sys/mman.h>
 #include <sys/ioctl.h>
-#include <linux/dma-buf.h>
-#ifdef HAVE_UDMABUF
-#include <linux/udmabuf.h>
-#endif
+#include "../dma-buf-compat.h"
 #include <epoxy/egl.h>
 #include <errno.h>
--- gsk/gpu/gskgpudownloadop.c.orig	2026-09-11 00:00:00 UTC
+++ gsk/gpu/gskgpudownloadop.c	2026-09-11 00:00:00 UTC
@@ -24,4 +24,4 @@
 #ifdef HAVE_DMABUF
 #include <glib-unix.h>
-#include <linux/dma-buf.h>
+#include "../../dma-buf-compat.h"
 #endif
 
 typedef struct _GskGpuDownloadOp GskGpuDownloadOp;
--- gsk/gpu/gskvulkanimage.c.orig	2026-09-11 00:00:00 UTC
+++ gsk/gpu/gskvulkanimage.c	2026-09-11 00:00:00 UTC
@@ -17,5 +17,5 @@
 #include <fcntl.h>
 #include <string.h>
 #ifdef HAVE_DMABUF
-#include <linux/dma-buf.h>
+#include "../../dma-buf-compat.h"
 #endif
 
 struct _GskVulkanImage
--- testsuite/gdk/udmabuf.c.orig	2026-09-11 00:00:00 UTC
+++ testsuite/gdk/udmabuf.c	2026-09-11 00:00:00 UTC
@@ -8,7 +8,7 @@
 #include <inttypes.h>
 #include <fcntl.h>
 #include <sys/mman.h>
 #include <sys/ioctl.h>
-#include <linux/udmabuf.h>
+#include "../../dma-buf-compat.h"
 #include <errno.h>
 #include <gtk/gtk.h>
 #include <gio/gio.h>
--- testsuite/gdk/meson.build.orig	2026-09-11 00:00:00 UTC
+++ testsuite/gdk/meson.build	2026-09-11 00:00:00 UTC
@@ -45,4 +45,4 @@
 else
   tests += [
-    { 'name': 'colorstate' }
+    { 'name': 'colorstate', 'sources': [ 'udmabuf.c' ] },
   ]
 endif
 
--- meson.build.orig	2026-09-11 00:00:00 UTC
+++ meson.build	2026-09-11 00:00:00 UTC
@@ -729,2 +729,2 @@
-cdata.set('HAVE_DMABUF', cc.has_header('linux/dma-buf.h'))
-cdata.set('HAVE_UDMABUF', cc.has_header('linux/udmabuf.h'))
+cdata.set('HAVE_DMABUF', true)
+cdata.set('HAVE_UDMABUF', true)
