[PATCH] Disable DRI3 and sync fence FD functions if xshmfence isn't available

Keith Packard keithp at keithp.com
Sun Nov 3 22:16:11 CET 2013


Make sure the server can build when the xshmfence library isn't present

Signed-off-by: Keith Packard <keithp at keithp.com>
---
 Xext/sync.c              |  8 ++++++++
 configure.ac             | 42 ++++++++++++++++++++++++++++++++++++++++--
 dri3/dri3.h              |  6 ++++++
 include/xorg-server.h.in |  3 +++
 miext/sync/Makefile.am   |  7 ++++++-
 5 files changed, 63 insertions(+), 3 deletions(-)

diff --git a/Xext/sync.c b/Xext/sync.c
index a04c383..dd18cde 100644
--- a/Xext/sync.c
+++ b/Xext/sync.c
@@ -919,6 +919,7 @@ SyncCreate(ClientPtr client, XID id, unsigned char type)
 int
 SyncCreateFenceFromFD(ClientPtr client, DrawablePtr pDraw, XID id, int fd, BOOL initially_triggered)
 {
+#if HAVE_XSHMFENCE
     SyncFence  *pFence;
     int         status;
 
@@ -936,12 +937,19 @@ SyncCreateFenceFromFD(ClientPtr client, DrawablePtr pDraw, XID id, int fd, BOOL
         return BadAlloc;
 
     return Success;
+#else
+    return BadImplementation;
+#endif
 }
 
 int
 SyncFDFromFence(ClientPtr client, DrawablePtr pDraw, SyncFence *pFence)
 {
+#if HAVE_XSHMFENCE
     return miSyncFDFromFence(pDraw, pFence);
+#else
+    return BadImplementation;
+#endif
 }
 
 static SyncCounter *
diff --git a/configure.ac b/configure.ac
index 0d855f2..1c2050d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -792,6 +792,7 @@ DMXPROTO="dmxproto >= 2.2.99.1"
 VIDMODEPROTO="xf86vidmodeproto >= 2.2.99.1"
 WINDOWSWMPROTO="windowswmproto"
 APPLEWMPROTO="applewmproto >= 1.4"
+XSHMFENCE="xshmfence"
 
 dnl Required modules
 XPROTO="xproto >= 7.0.22"
@@ -1119,17 +1120,55 @@ AM_CONDITIONAL(DRI2, test "x$DRI2" = xyes)
 
 PKG_CHECK_MODULES([DRI3PROTO], $DRI3PROTO,
                   [HAVE_DRI3PROTO=yes], [HAVE_DRI3PROTO=no])
+
 case "$DRI3,$HAVE_DRI3PROTO" in
+	yes,yes | auto,yes)
+		;;
 	yes,no)
 		AC_MSG_ERROR([DRI3 requested, but dri3proto not found.])
+		DRI3=no
+		;;
+	*)
+		AC_MSG_NOTICE([DRI3 disabled because dri3proto not found.])
+		DRI3=no
 		;;
+esac
+
+PKG_CHECK_MODULES([XSHMFENCE], $XSHMFENCE,
+		  [HAVE_XSHMFENCE=yes], [HAVE_XSHMFENCE=no])
+
+AM_CONDITIONAL(XSHMFENCE, test "x$HAVE_XSHMFENCE" = xyes)
+
+case x"$HAVE_XSHMFENCE" in
+	xyes)
+		AC_DEFINE(HAVE_XSHMFENCE, 1, [Have X Shared Memory Fence library])
+		;;
+esac
+
+
+case "$DRI3,$HAVE_XSHMFENCE" in
 	yes,yes | auto,yes)
-		AC_DEFINE(DRI3, 1, [Build DRI3 extension])
+		;;
+	yes,no)
+		AC_MSG_ERROR("DRI3 requested, but xshmfence not found.])
+		DRI3=no
+		;;
+	*)
+		AC_MSG_NOTICE([DRI3 disabled because xshmfence not found.])
+		DRI3=no
+		;;
+esac		
+
+case x"$DRI3" in
+	xyes|xauto)
 		DRI3=yes
+		AC_DEFINE(DRI3, 1, [Build DRI3 extension])
 		DRI3_LIB='$(top_builddir)/dri3/libdri3.la'
 		SDK_REQUIRED_MODULES="$SDK_REQUIRED_MODULES $DRI3PROTO"
+		AC_MSG_NOTICE([DRI3 enabled]);
 		;;
 esac
+
 AM_CONDITIONAL(DRI3, test "x$DRI3" = xyes)
 
 if test "x$DRI" = xyes || test "x$DRI2" = xyes || test "x$DRI3" = xyes || test "x$CONFIG_UDEV_KMS" = xyes; then
@@ -1333,7 +1372,6 @@ if test "x$XDMAUTH" = xyes; then
 		XDMCP_MODULES="xdmcp"
 	fi
 fi
-REQUIRED_LIBS="$REQUIRED_LIBS xshmfence"
 
 AC_DEFINE_DIR(COMPILEDDEFAULTFONTPATH, FONTPATH, [Default font path])
 AC_DEFINE_DIR(SERVER_MISC_CONFIG_PATH, SERVERCONFIG, [Server miscellaneous config path])
diff --git a/dri3/dri3.h b/dri3/dri3.h
index 7774c87..7c0c330 100644
--- a/dri3/dri3.h
+++ b/dri3/dri3.h
@@ -23,6 +23,10 @@
 #ifndef _DRI3_H_
 #define _DRI3_H_
 
+#include <xorg-server.h>
+
+#ifdef DRI3
+
 #include <X11/extensions/dri3proto.h>
 #include <randrstr.h>
 
@@ -56,4 +60,6 @@ typedef struct dri3_screen_info {
 extern _X_EXPORT Bool
 dri3_screen_init(ScreenPtr screen, dri3_screen_info_ptr info);
 
+#endif
+
 #endif /* _DRI3_H_ */
diff --git a/include/xorg-server.h.in b/include/xorg-server.h.in
index 1281b3e..960817e 100644
--- a/include/xorg-server.h.in
+++ b/include/xorg-server.h.in
@@ -218,4 +218,7 @@
 #define _XSERVER64 1
 #endif
 
+/* Have support for X shared memory fence library (xshmfence) */
+#undef HAVE_XSHMFENCE
+
 #endif /* _XORG_SERVER_H_ */
diff --git a/miext/sync/Makefile.am b/miext/sync/Makefile.am
index e25ceac..ac13c52 100644
--- a/miext/sync/Makefile.am
+++ b/miext/sync/Makefile.am
@@ -8,8 +8,13 @@ if XORG
 sdk_HEADERS = misync.h misyncstr.h misyncshm.h
 endif
 
+XSHMFENCE_SRCS = misyncshm.c
+
 libsync_la_SOURCES =	\
 	misync.c	\
 	misync.h	\
-	misyncshm.c	\
 	misyncstr.h
+
+if XSHMFENCE
+libsync_la_SOURCES += $(XSHMFENCE_SRCS)
+endif
-- 
1.8.4.2



More information about the xorg-devel mailing list