Permalink
Browse files

Add FreeBSD support

Partially based on an earlier porting attempt by Johannes Lundberg from
https://github.com/FreeBSDDesktop/freebsd-ports-graphics
(specifically, the vt switching code)
  • Loading branch information...
myfreeweb committed Nov 30, 2017
1 parent 8093fd5 commit 5df4a6830884a04a94b4694dc0e05095b64fd719
View
@@ -67,6 +67,7 @@ weston-nested-client
weston-presentation-shm
weston-resizor
weston-scaler
weston-simple-dmabuf-drm
weston-simple-dmabuf-intel
weston-simple-dmabuf-v4l
weston-simple-egl
View
@@ -1605,7 +1605,7 @@ $(if $(findstring unstable,$1),unstable,stable)
endef
define protoname
$(shell echo $1 | sed 's/\([a-z\-]\+\)-[a-z]\+-v[0-9]\+/\1/')
$(shell echo $1 | $(SED) 's/\([a-z\-]\+\)-[a-z]\+-v[0-9]\+/\1/')
endef
protocol/%-protocol.c : $(WAYLAND_PROTOCOLS_DATADIR)/$$(call protostability,$$*)/$$(call protoname,$$*)/$$*.xml
View
@@ -41,6 +41,9 @@
#include <ctype.h>
#include <time.h>
#include <assert.h>
#ifdef __FreeBSD__
#include <signal.h>
#endif
#include <wayland-client.h>
#include "window.h"
View
@@ -32,7 +32,11 @@
#include <unistd.h>
#include <math.h>
#include <time.h>
#ifdef __linux__
#include <pty.h>
#elif __FreeBSD__
#include <libutil.h>
#endif
#include <ctype.h>
#include <cairo.h>
#include <sys/epoll.h>
View
@@ -605,9 +605,15 @@ clock_name(clockid_t clk_id)
static const char *names[] = {
[CLOCK_REALTIME] = "CLOCK_REALTIME",
[CLOCK_MONOTONIC] = "CLOCK_MONOTONIC",
#ifdef __linux__
[CLOCK_MONOTONIC_RAW] = "CLOCK_MONOTONIC_RAW",
[CLOCK_REALTIME_COARSE] = "CLOCK_REALTIME_COARSE",
[CLOCK_MONOTONIC_COARSE] = "CLOCK_MONOTONIC_COARSE",
#elif __FreeBSD__
[CLOCK_REALTIME_FAST] = "CLOCK_REALTIME_FAST",
[CLOCK_MONOTONIC_FAST] = "CLOCK_MONOTONIC_FAST",
#endif
#ifdef CLOCK_BOOTTIME
[CLOCK_BOOTTIME] = "CLOCK_BOOTTIME",
#endif
View
@@ -41,7 +41,11 @@
#include <sys/socket.h>
#include <libinput.h>
#include <sys/time.h>
#ifdef __linux__
#include <linux/limits.h>
#else
#include <sys/param.h>
#endif
#ifdef HAVE_LIBUNWIND
#define UNW_LOCAL_ONLY
@@ -681,9 +685,14 @@ clock_name(clockid_t clk_id)
static const char *names[] = {
[CLOCK_REALTIME] = "CLOCK_REALTIME",
[CLOCK_MONOTONIC] = "CLOCK_MONOTONIC",
#ifdef __linux__
[CLOCK_MONOTONIC_RAW] = "CLOCK_MONOTONIC_RAW",
[CLOCK_REALTIME_COARSE] = "CLOCK_REALTIME_COARSE",
[CLOCK_MONOTONIC_COARSE] = "CLOCK_MONOTONIC_COARSE",
#elif __FreeBSD__
[CLOCK_REALTIME_FAST] = "CLOCK_REALTIME_FAST",
[CLOCK_MONOTONIC_FAST] = "CLOCK_MONOTONIC_FAST",
#endif
#ifdef CLOCK_BOOTTIME
[CLOCK_BOOTTIME] = "CLOCK_BOOTTIME",
#endif
View
@@ -106,6 +106,27 @@ AC_CHECK_HEADERS([execinfo.h])
AC_CHECK_FUNCS([mkostemp strchrnul initgroups posix_fallocate])
AC_MSG_CHECKING([for program_invocation_short_name])
AC_TRY_COMPILE([#include <errno.h>],
[const char *pn = program_invocation_short_name;],
AC_DEFINE(HAVE_PROGRAM_INVOCATION_SHORT_NAME, 1, [Define to 1 if program_invocation_short_name exists])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))
AC_MSG_CHECKING([for getprogname])
AC_TRY_COMPILE([#include <stdlib.h>],
[getprogname();],
AC_DEFINE(HAVE_GETPROGNAME, 1, [Define to 1 if getprogname exists])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))
AH_BOTTOM([#ifndef HAVE_PROGRAM_INVOCATION_SHORT_NAME
#ifdef HAVE_GETPROGNAME
#include <stdlib.h>
#define program_invocation_short_name getprogname()
#endif
#endif])
# check for libdrm as a build-time dependency only
# libdrm 2.4.30 introduced drm_fourcc.h.
PKG_CHECK_MODULES(LIBDRM, [libdrm >= 2.4.30], [], [AC_MSG_ERROR([
View
@@ -34,7 +34,9 @@
#include <fcntl.h>
#include <unistd.h>
#include <linux/input.h>
#ifdef __linux__
#include <linux/vt.h>
#endif
#include <assert.h>
#include <sys/mman.h>
#include <dlfcn.h>
@@ -3729,11 +3731,26 @@ drm_device_is_kms(struct drm_backend *b, struct udev_device *device)
static struct udev_device*
find_primary_gpu(struct drm_backend *b, const char *seat)
{
struct udev_device *device;
#ifndef __FreeBSD__
struct udev_device *drm_device, *pci;
struct udev_enumerate *e;
struct udev_list_entry *entry;
const char *path, *device_seat, *id;
struct udev_device *device, *drm_device, *pci;
#endif
#ifdef __FreeBSD__
// libudev-devd doesn't support matching
device = udev_device_new_from_syspath(b->udev, "/dev/dri/card0");
/* Make sure this device is actually capable of modesetting;
* if this call succeeds, b->drm.{fd,filename} will be set,
* and any old values freed. */
if (!drm_device_is_kms(b, device)) {
udev_device_unref(device);
device = NULL;
}
return device;
#else
e = udev_enumerate_new(b->udev);
udev_enumerate_add_match_subsystem(e, "drm");
udev_enumerate_add_match_sysname(e, "card[0-9]*");
@@ -3801,6 +3818,7 @@ find_primary_gpu(struct drm_backend *b, const char *seat)
udev_enumerate_unref(e);
return drm_device;
#endif
}
static void
@@ -37,6 +37,9 @@
#include <errno.h>
#include <sys/time.h>
#include <sys/shm.h>
#ifdef __FreeBSD__
#include <sys/stat.h>
#endif
#include <linux/input.h>
#include <xcb/xcb.h>
View
@@ -5435,10 +5435,18 @@ weston_compositor_set_presentation_clock_software(
{
/* In order of preference */
static const clockid_t clocks[] = {
#ifdef __linux__
CLOCK_MONOTONIC_RAW, /* no jumps, no crawling */
CLOCK_MONOTONIC_COARSE, /* no jumps, may crawl, fast & coarse */
#elif __FreeBSD__
CLOCK_MONOTONIC_FAST, /* no jumps, may crawl, fast & coarse */
#endif
CLOCK_MONOTONIC, /* no jumps, may crawl */
#ifdef __linux__
CLOCK_REALTIME_COARSE, /* may jump and crawl, fast & coarse */
#elif __FreeBSD__
CLOCK_REALTIME_FAST, /* may jump and crawl, fast & coarse */
#endif
CLOCK_REALTIME /* may jump and crawl */
};
unsigned i;
View
@@ -42,11 +42,13 @@
#include <unistd.h>
#include <sys/ioctl.h>
#ifdef __linux__
#ifdef HAVE_LINUX_SYNC_FILE_H
#include <linux/sync_file.h>
#else
#include "weston-sync-file.h"
#endif
#endif
#include "timeline.h"
@@ -302,6 +304,7 @@ get_renderer(struct weston_compositor *ec)
return (struct gl_renderer *)ec->renderer;
}
#ifdef __linux__
static int
linux_sync_file_read_timestamp(int fd, uint64_t *ts)
{
@@ -320,6 +323,13 @@ linux_sync_file_read_timestamp(int fd, uint64_t *ts)
return 0;
}
#else
static int
linux_sync_file_read_timestamp(int fd __attribute__((unused)), uint64_t *ts __attribute__((unused)))
{
return -1;
}
#endif
static void
timeline_render_point_destroy(struct timeline_render_point *trp)
View
@@ -32,7 +32,7 @@
#include <sys/mman.h>
#include <assert.h>
#include <unistd.h>
#include <values.h>
#include <float.h>
#include <fcntl.h>
#include <limits.h>
Oops, something went wrong.

0 comments on commit 5df4a68

Please sign in to comment.