summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2013-11-20 08:30:44 -0800
committerKeith Packard <keithp@keithp.com>2013-11-20 14:13:08 -0800
commitc17583d05872e4d9fb39af1a9963dc3738556b27 (patch)
tree7602e1de2b00c5895150922624ad3bc2f3c30926
parentb394d499eeb6abb0f23a629f22f6634f137d279e (diff)
downloadxorg-lib-libxshmfence-c17583d05872e4d9fb39af1a9963dc3738556b27.tar.gz
Locate directory for shared memory files at configure time
Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
-rw-r--r--configure.ac44
-rw-r--r--src/xshmfence.c6
2 files changed, 49 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index cb779da..58b3583 100644
--- a/configure.ac
+++ b/configure.ac
@@ -45,6 +45,50 @@ dnl Allow checking code with lint, sparse, etc.
XORG_WITH_LINT
LINT_FLAGS="${LINT_FLAGS} ${FONTENC_CFLAGS}"
+
+dnl
+dnl Locate a suitable tmp file system for creating shared memeory files
+dnl
+
+AC_ARG_WITH(shared-memory-dir, AS_HELP_STRING([--with-shared-memory-dir=PATH], [Path to directory in a world-writable temporary directory for anonymous shared memory (default: auto)]),
+[],
+[with_shared_memory_dir=yes])
+
+shmdirs="/run/shm /var/tmp /tmp"
+
+case x"$with_shared_memory_dir" in
+xyes)
+ for dir in $shmdirs; do
+ case x"$with_shared_memory_dir" in
+ xyes)
+ echo Checking temp dir "$dir"
+ if test -d "$dir"; then
+ with_shared_memory_dir="$dir"
+ fi
+ ;;
+ esac
+ done
+ ;;
+x/*)
+ ;;
+xno)
+ ;;
+*)
+ AC_MSG_ERROR([Invalid directory specified for --with-shared-memory-dir: $with_shared_memory_dir])
+ ;;
+esac
+
+case x"$with_shared_memory_dir" in
+xyes)
+ AC_MSG_ERROR([No directory found for shared memory temp files.])
+ ;;
+xno)
+ ;;
+*)
+ AC_DEFINE_UNQUOTED(SHMDIR, ["$with_shared_memory_dir"], [Directory for shared memory temp files])
+ ;;
+esac
+
AC_CONFIG_FILES([Makefile
src/Makefile
xshmfence.pc])
diff --git a/src/xshmfence.c b/src/xshmfence.c
index 83049de..ecf2f4a 100644
--- a/src/xshmfence.c
+++ b/src/xshmfence.c
@@ -20,6 +20,10 @@
* OF THIS SOFTWARE.
*/
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include "xshmfenceint.h"
struct xshmfence {
@@ -106,7 +110,7 @@ xshmfence_reset(struct xshmfence *f)
int
xshmfence_alloc_shm(void)
{
- char template[] = "/run/shm/shmfd-XXXXXX";
+ char template[] = SHMDIR "/shmfd-XXXXXX";
int fd = mkstemp(template);
if (fd < 0)