commit bb5d247
shrub
·
2026-05-06 17:06:40 +0000 UTC
parent 6446a28
portability
2 files changed,
+27,
-1
M
drm.c
M
drm.c
+7,
-0
1@@ -29,6 +29,8 @@
2
3 #ifdef __linux__
4 #include <sys/sysmacros.h>
5+#elif defined(__sun)
6+#include <sys/mkdev.h>
7 #endif
8
9 #endif
10@@ -46,6 +48,10 @@ const static struct drm_driver *drivers[] = {
11 static const struct drm_driver *
12 find_driver(int fd)
13 {
14+ #ifdef __sun
15+ (void)fd;
16+ return NULL;
17+ #else
18 char path[64], id[32];
19 uint32_t vendor_id, device_id;
20 char *path_part;
21@@ -85,6 +91,7 @@ find_driver(int fd)
22 }
23
24 return NULL;
25+ #endif
26 }
27
28 EXPORT
+20,
-1
1@@ -35,6 +35,25 @@
2 #include <unistd.h>
3 #include <wayland-client.h>
4
5+static int
6+wldtmp(char *name)
7+{
8+ int fd;
9+ int flags;
10+
11+ fd = mkstemp(name);
12+ if (fd < 0)
13+ return -1;
14+
15+ flags = fcntl(fd, F_GETFD);
16+ if (flags < 0 || fcntl(fd, F_SETFD, flags | FD_CLOEXEC) < 0) {
17+ close(fd);
18+ return -1;
19+ }
20+
21+ return fd;
22+}
23+
24 struct shm_context {
25 struct wayland_context base;
26 struct wl_registry *registry;
27@@ -170,7 +189,7 @@ context_create_buffer(struct wld_context *base,
28 if (!(buffer = malloc(sizeof *buffer)))
29 goto error0;
30
31- fd = mkostemp(name, O_CLOEXEC);
32+ fd = wldtmp(name);
33
34 if (fd < 0)
35 goto error1;