[PATCH libxshmfence v2] futex: unbreak build on FreeBSD 11.0+

2017-07-07 Thread Jan Beich
From: Jung-uk Kim <j...@freebsd.org>
Date: Tue, 15 Apr 2014 17:08:46 +

In file included from src/xshmfence_alloc.c:27:
In file included from src/xshmfenceint.h:32:
src/xshmfence_futex.h:40:39: error: use of undeclared identifier 'INT_MAX'
return sys_futex(addr, UMTX_OP_WAKE, INT_MAX);
 ^
1 error generated.

Signed-off-by: Jan Beich <jbe...@freebsd.org>
---
 src/xshmfence_futex.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/xshmfence_futex.h b/src/xshmfence_futex.h
index ea96cf4..ccfdc67 100644
--- a/src/xshmfence_futex.h
+++ b/src/xshmfence_futex.h
@@ -28,6 +28,7 @@
 
 #ifdef HAVE_UMTX
 
+#include 
 #include 
 #include 
 
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH xserver 1/2] shm, xwayland: prefer atomic close-on-exec without O_TMPFILE

2017-07-07 Thread Jan Beich
Julien Cristau <jcris...@debian.org> writes:

> On Fri, Jul  7, 2017 at 16:31:48 +0200, Jan Beich wrote:
>> -flags = fcntl(fd, F_GETFD);
>> +#ifndef HAVE_MKOSTEMP
>> +int flags = fcntl(fd, F_GETFD);
>
> Do we allow mixed declarations and code nowadays?

xserver has quite a few of those already, even in Xext/shm.c e.g.,

  doShmPutImage(DrawablePtr dst, GCPtr pGC,
  ...
  else {
  GCPtr putGC = GetScratchGC(depth, dst->pScreen);
  ...
  ProcShmPutImage(ClientPtr client)
  ...
  if (stuff->sendEvent) {
  xShmCompletionEvent ev = {
  .type = ShmCompletionCode,
  .drawable = stuff->drawable,
  .minorEvent = X_ShmPutImage,
  .majorEvent = ShmReqCode,
  .shmseg = stuff->shmseg,
  .offset = stuff->offset
  };
  ...
  ProcPanoramiXShmCreatePixmap(ClientPtr client)
  ...
  FOR_NSCREENS(j) {
  ShmScrPrivateRec *screen_priv;
  ...
  ShmExtensionInit(void)
  ...
  for (i = 0; i < screenInfo.numScreens; i++) {
  ShmScrPrivateRec *screen_priv =
  ShmInitScreenPriv(screenInfo.screens[i]);
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver] dix: unbreak --with-dtrace (default) on FreeBSD 11.1+

2017-07-07 Thread Jan Beich
gmake[2]: Entering directory '/path/to/xserver/dix'
/usr/sbin/dtrace -G -C -o dtrace-dix.o -s ../dix/Xserver.d .libs/atom.o ...
dtrace: failed to compile script ../dix/Xserver.d: line 26: useless declaration
gmake[2]: *** [Makefile:1007: dtrace-dix.o] Error 1

Signed-off-by: Jan Beich <jbe...@freebsd.org>
---
 dix/Xserver.d | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/dix/Xserver.d b/dix/Xserver.d
index f4f229d84..4a233e1f6 100644
--- a/dix/Xserver.d
+++ b/dix/Xserver.d
@@ -27,6 +27,8 @@
 #define string char *
 #define pid_t uint32_t
 #define zoneid_t uint32_t
+#elif defined(__FreeBSD__)
+#define zoneid_t id_t
 #else
 #include 
 #endif
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH libxshmfence 2/2] alloc: close-on-exec without O_TMPFILE as well

2017-07-07 Thread Jan Beich
The patch is v2 of 
https://lists.x.org/archives/xorg-devel/2013-December/039482.html
v1 leaked files, see https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=217676
but no one noticed because FreeBSD < 12.0 (drm-next) lacks DRI3 support.
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH libxshmfence 2/2] alloc: close-on-exec without O_TMPFILE as well

2017-07-07 Thread Jan Beich

Signed-off-by: Jan Beich <jbe...@freebsd.org>
---
 configure.ac  |  2 +-
 src/xshmfence_alloc.c | 13 +
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 0c98875..2d55890 100644
--- a/configure.ac
+++ b/configure.ac
@@ -89,7 +89,7 @@ AC_SUBST([XPROTO_CFLAGS])
 
 CFLAGS="$CFLAGS $XPROTO_CFLAGS"
 
-AC_CHECK_FUNCS(memfd_create)
+AC_CHECK_FUNCS(memfd_create mkostemp)
 
 AC_CHECK_DECLS([__NR_memfd_create], [], [], [[#include ]])
 
diff --git a/src/xshmfence_alloc.c b/src/xshmfence_alloc.c
index 05cf953..427335f 100644
--- a/src/xshmfence_alloc.c
+++ b/src/xshmfence_alloc.c
@@ -26,6 +26,8 @@
 
 #include "xshmfenceint.h"
 
+#include 
+
 #if !HAVE_MEMFD_CREATE
 #if HAVE_DECL___NR_MEMFD_CREATE
 #include 
@@ -79,10 +81,21 @@ xshmfence_alloc_shm(void)
if (fd < 0)
 #endif
{
+#ifdef HAVE_MKOSTEMP
+   fd = mkostemp(template, O_CLOEXEC);
+#else
fd = mkstemp(template);
+#endif
if (fd < 0)
return fd;
unlink(template);
+#ifndef HAVE_MKOSTEMP
+   int flags = fcntl(fd, F_GETFD);
+   if (flags != -1) {
+   flags |= FD_CLOEXEC;
+   (void) fcntl(fd, F_SETFD, );
+   }
+#endif
}
}
if (ftruncate(fd, sizeof (struct xshmfence)) < 0) {
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver 1/2] shm, xwayland: prefer atomic close-on-exec without O_TMPFILE

2017-07-07 Thread Jan Beich

Signed-off-by: Jan Beich <jbe...@freebsd.org>
---
 Xext/shm.c  | 9 +++--
 configure.ac| 2 +-
 include/dix-config.h.in | 3 +++
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/Xext/shm.c b/Xext/shm.c
index 91ea90b14..6edeba6fb 100644
--- a/Xext/shm.c
+++ b/Xext/shm.c
@@ -1199,7 +1199,6 @@ shm_tmpfile(void)
 {
 #ifdef SHMDIR
int fd;
-   int flags;
chartemplate[] = SHMDIR "/shmfd-XX";
 #ifdef O_TMPFILE
fd = open(SHMDIR, O_TMPFILE|O_RDWR|O_CLOEXEC|O_EXCL, 0666);
@@ -1209,15 +1208,21 @@ shm_tmpfile(void)
}
ErrorF ("Not using O_TMPFILE\n");
 #endif
+#ifdef HAVE_MKOSTEMP
+   fd = mkostemp(template, O_CLOEXEC);
+#else
fd = mkstemp(template);
+#endif
if (fd < 0)
return -1;
unlink(template);
-   flags = fcntl(fd, F_GETFD);
+#ifndef HAVE_MKOSTEMP
+   int flags = fcntl(fd, F_GETFD);
if (flags != -1) {
flags |= FD_CLOEXEC;
(void) fcntl(fd, F_SETFD, );
}
+#endif
return fd;
 #else
 return -1;
diff --git a/configure.ac b/configure.ac
index e202770c1..a795ecf1e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -157,7 +157,7 @@ dnl Checks for library functions.
 AC_CHECK_FUNCS([backtrace ffs geteuid getuid issetugid getresuid \
getdtablesize getifaddrs getpeereid getpeerucred getprogname getzoneid \
mmap posix_fallocate seteuid shmctl64 strncasecmp vasprintf vsnprintf \
-   walkcontext setitimer poll epoll_create1])
+   walkcontext setitimer poll epoll_create1 mkostemp])
 AC_CONFIG_LIBOBJ_DIR([os])
 AC_REPLACE_FUNCS([reallocarray strcasecmp strcasestr strlcat strlcpy strndup\
timingsafe_memcmp])
diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index ad1ab20a6..367d75c27 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -140,6 +140,9 @@
 /* Define to 1 if you have the  header file. */
 #undef HAVE_LINUX_FB_H
 
+/* Define to 1 if you have the `mkostemp' function. */
+#undef HAVE_MKOSTEMP
+
 /* Define to 1 if you have the `mmap' function. */
 #undef HAVE_MMAP
 
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH libxshmfence] futex: unbreak build on FreeBSD 11.0+

2017-07-07 Thread Jan Beich
From: Jung-uk Kim <j...@freebsd.org>
Date: Tue, 15 Apr 2014 17:08:46 +

In file included from src/xshmfence_alloc.c:27:
In file included from src/xshmfenceint.h:32:
src/xshmfence_futex.h:40:39: error: use of undeclared identifier 'INT_MAX'
return sys_futex(addr, UMTX_OP_WAKE, INT_MAX);
 ^
1 error generated.

Signed-off-by: Jan Beich <jbe...@freebsd.org>
---
 src/xshmfence_futex.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/xshmfence_futex.h b/src/xshmfence_futex.h
index ea96cf4..c1b743d 100644
--- a/src/xshmfence_futex.h
+++ b/src/xshmfence_futex.h
@@ -29,6 +29,7 @@
 #ifdef HAVE_UMTX
 
 #include 
+#include 
 #include 
 
 static inline int sys_futex(void *addr, int op, int32_t val)
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel