diff options
author | Keith Packard <keithp@keithp.com> | 2013-11-20 08:30:44 -0800 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2013-11-20 14:13:08 -0800 |
commit | c17583d05872e4d9fb39af1a9963dc3738556b27 (patch) | |
tree | 7602e1de2b00c5895150922624ad3bc2f3c30926 | |
parent | b394d499eeb6abb0f23a629f22f6634f137d279e (diff) |
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.ac | 44 | ||||
-rw-r--r-- | src/xshmfence.c | 6 |
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) |