commit 4e7e0434f5d853b773d76e28452c15aa6d175699
parent 6c0713643153fc10f0467b617c5768e2513e3620
Author: shrub <maybeshrub@gmail.com>
Date: Tue, 3 Feb 2026 17:30:03 +0000
openbsd compatibility
Diffstat:
3 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
@@ -2,7 +2,7 @@
include config.mk
-PREFIX ?= /usr/local
+PREFIX ?= /usr
LIBDIR ?= $(PREFIX)/lib
INCLUDEDIR ?= $(PREFIX)/include
PKGCONFIGDIR ?= $(LIBDIR)/pkgconfig
@@ -87,8 +87,13 @@ WLD_PACKAGES = $(WLD_REQUIRES) $(WLD_REQUIRES_PRIVATE)
WLD_PACKAGE_CFLAGS ?= $(call pkgconfig,$(WLD_PACKAGES),cflags,CFLAGS)
WLD_PACKAGE_LIBS ?= $(call pkgconfig,$(WLD_PACKAGES),libs,LIBS)
+ifeq ($(shell uname),OpenBSD)
+ WLD_PACKAGE_LIBS += -lc
+endif
+
+
FINAL_CFLAGS = $(CFLAGS) -fvisibility=hidden -std=c99 -Wvla
-FINAL_CPPFLAGS = $(CPPFLAGS) -D_XOPEN_SOURCE=700
+FINAL_CPPFLAGS = $(CPPFLAGS)
# Warning/error flags
FINAL_CFLAGS += -Werror=implicit-function-declaration -Werror=implicit-int \
@@ -100,6 +105,10 @@ ifeq ($(shell uname),NetBSD)
FINAL_CPPFLAGS += -D_NETBSD_SOURCE
endif
+ifeq ($(shell uname),Linux)
+ FINAL_CPPFLAGS += -D_POSIX_C_SOURCE=200809L
+endif
+
ifeq ($(ENABLE_DEBUG),1)
FINAL_CPPFLAGS += -DENABLE_DEBUG=1
FINAL_CFLAGS += -g
@@ -188,4 +197,3 @@ clean:
rm -rf $(CLEAN_FILES)
-include .deps/*.d
-
diff --git a/drm.c b/drm.c
@@ -26,9 +26,13 @@
#include <sys/types.h>
#ifndef major
+
+#ifdef __linux__
#include <sys/sysmacros.h>
#endif
+#endif
+
const static struct drm_driver *drivers[] = {
#if WITH_DRM_INTEL
&intel_drm_driver,
diff --git a/wayland-shm.c b/wayland-shm.c
@@ -177,8 +177,15 @@ context_create_buffer(struct wld_context *base,
unlink(name);
+#if defined(__linux__)
+ /* try to preallocate */
if (posix_fallocate(fd, 0, size) != 0 && ftruncate(fd, size) != 0)
goto error2;
+#else
+ /* ftruncate() is enough otherwise */
+ if (ftruncate(fd, size) != 0)
+ goto error2;
+#endif
if (!(pool = wl_shm_create_pool(context->wl, fd, size)))
goto error2;