broadway backend: allow building on OpenBSD

On OpenBSD shm_open(3) is part of libc and there is not librt, so add an
according check.
Check if we have posix_fallocate before using it.

https://bugzilla.gnome.org/show_bug.cgi?id=728272
This commit is contained in:
Antoine Jacoutot
2014-04-18 00:59:45 +02:00
parent 2e1d0df1ed
commit be9d1e0b3b
3 changed files with 11 additions and 2 deletions

View File

@ -397,6 +397,11 @@ else
fi fi
AC_SUBST(DISABLE_ON_QUARTZ) AC_SUBST(DISABLE_ON_QUARTZ)
AC_CHECK_LIB([rt], [shm_open], [SHM_LIBS="-lrt"], [SHM_LIBS=""])
AC_SUBST(SHM_LIBS)
AC_CHECK_FUNCS(posix_fallocate)
if test "x$enable_broadway_backend" = xyes; then if test "x$enable_broadway_backend" = xyes; then
GDK_BACKENDS="$GDK_BACKENDS broadway" GDK_BACKENDS="$GDK_BACKENDS broadway"
cairo_backends="$cairo_backends cairo" cairo_backends="$cairo_backends cairo"

View File

@ -1,5 +1,6 @@
## Process this file with automake to produce Makefile.in ## Process this file with automake to produce Makefile.in
include $(top_srcdir)/Makefile.decl include $(top_srcdir)/Makefile.decl
NULL =
libgdkincludedir = $(includedir)/gtk-3.0/gdk libgdkincludedir = $(includedir)/gtk-3.0/gdk
libgdkbroadwayincludedir = $(includedir)/gtk-3.0/gdk/broadway libgdkbroadwayincludedir = $(includedir)/gtk-3.0/gdk/broadway
@ -75,7 +76,8 @@ libgdk_broadway_la_SOURCES = \
if OS_UNIX if OS_UNIX
libgdk_broadway_la_LIBADD = \ libgdk_broadway_la_LIBADD = \
-lrt $(SHM_LIBS) \
$(NULL)
endif endif
broadwayd_SOURCES = \ broadwayd_SOURCES = \
@ -91,7 +93,7 @@ broadwayd_SOURCES = \
if OS_WIN32 if OS_WIN32
broadwayd_LDADD = $(GDK_DEP_LIBS) -lws2_32 broadwayd_LDADD = $(GDK_DEP_LIBS) -lws2_32
else else
broadwayd_LDADD = $(GDK_DEP_LIBS) -lrt broadwayd_LDADD = $(GDK_DEP_LIBS) @SHM_LIBS@
endif endif
MAINTAINERCLEANFILES = $(broadway_built_sources) MAINTAINERCLEANFILES = $(broadway_built_sources)

View File

@ -540,12 +540,14 @@ map_named_shm (char *name, gsize size)
res = ftruncate (fd, size); res = ftruncate (fd, size);
g_assert (res != -1); g_assert (res != -1);
#ifdef HAVE_POSIX_FALLOCATE
res = posix_fallocate (fd, 0, size); res = posix_fallocate (fd, 0, size);
if (res != 0) if (res != 0)
{ {
shm_unlink (name); shm_unlink (name);
g_error ("Not enough shared memory for window surface"); g_error ("Not enough shared memory for window surface");
} }
#endif
ptr = mmap(0, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); ptr = mmap(0, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);