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 11:54:13 -0800
commite8cbcdb648340f55f03551110052d24c5d0bd9c6 (patch)
treeb8f804057e2399eae1a1251e5103b56401d53f6d
parentb57b6d4f8f0bba10396b3d256fd9b5dc20c598be (diff)
Locate directory for shared memory files at configure time
Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--configure.ac43
-rw-r--r--src/xshmfence.c6
2 files changed, 48 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index 2780ac5..02359e1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -42,6 +42,49 @@ 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
+
XORG_RELEASE_VERSION
XORG_CHANGELOG
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)