commit bb5d247e7b3d0f68dda3990f9b2100aaaec85d28
parent 6446a28168045efffa8ccd3de0b6eb3599fb5339
Author: shrub <maybeshrub@gmail.com>
Date: Wed, 6 May 2026 17:06:40 +0000
portability
Diffstat:
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/drm.c b/drm.c
@@ -29,6 +29,8 @@
#ifdef __linux__
#include <sys/sysmacros.h>
+#elif defined(__sun)
+#include <sys/mkdev.h>
#endif
#endif
@@ -46,6 +48,10 @@ const static struct drm_driver *drivers[] = {
static const struct drm_driver *
find_driver(int fd)
{
+ #ifdef __sun
+ (void)fd;
+ return NULL;
+ #else
char path[64], id[32];
uint32_t vendor_id, device_id;
char *path_part;
@@ -85,6 +91,7 @@ find_driver(int fd)
}
return NULL;
+ #endif
}
EXPORT
diff --git a/wayland-shm.c b/wayland-shm.c
@@ -35,6 +35,25 @@
#include <unistd.h>
#include <wayland-client.h>
+static int
+wldtmp(char *name)
+{
+ int fd;
+ int flags;
+
+ fd = mkstemp(name);
+ if (fd < 0)
+ return -1;
+
+ flags = fcntl(fd, F_GETFD);
+ if (flags < 0 || fcntl(fd, F_SETFD, flags | FD_CLOEXEC) < 0) {
+ close(fd);
+ return -1;
+ }
+
+ return fd;
+}
+
struct shm_context {
struct wayland_context base;
struct wl_registry *registry;
@@ -170,7 +189,7 @@ context_create_buffer(struct wld_context *base,
if (!(buffer = malloc(sizeof *buffer)))
goto error0;
- fd = mkostemp(name, O_CLOEXEC);
+ fd = wldtmp(name);
if (fd < 0)
goto error1;