aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-02-11 11:42:21 +0100
committerThomas White <taw@physics.org>2020-02-11 11:42:21 +0100
commita607da9373e4cbf8609fac477ef5ecd3323ca234 (patch)
treeb5e083ba61d76a714859a11e3318d71695b931e5
parent6f2ca6294851780290877c387ada86744bbbebc6 (diff)
Don't use gzbuffer if it's not available
Enables compatability with zlib < 1.2.3.5
-rw-r--r--libcrystfel/CMakeLists.txt5
-rw-r--r--libcrystfel/config.h.cmake.in1
-rw-r--r--libcrystfel/src/image.c2
3 files changed, 8 insertions, 0 deletions
diff --git a/libcrystfel/CMakeLists.txt b/libcrystfel/CMakeLists.txt
index 87b621b0..9f79b0c4 100644
--- a/libcrystfel/CMakeLists.txt
+++ b/libcrystfel/CMakeLists.txt
@@ -16,6 +16,11 @@ set(HAVE_XGANDALF ${XGANDALF_FOUND})
set(HAVE_PINKINDEXER ${PINKINDEXER_FOUND})
set(HAVE_FDIP ${FDIP_FOUND})
+# Recent enough version of zlib?
+set(CMAKE_REQUIRED_LIBRARIES "-lz")
+check_symbol_exists(gzbuffer "zlib.h" HAVE_GZBUFFER)
+unset(CMAKE_REQUIRED_LIBRARIES)
+
# Find out where forkpty() is declared
set(CMAKE_REQUIRED_LIBRARIES "-lutil")
check_symbol_exists(forkpty "pty.h" HAVE_FORKPTY_PTY_H)
diff --git a/libcrystfel/config.h.cmake.in b/libcrystfel/config.h.cmake.in
index b7ad4c7a..20ae7399 100644
--- a/libcrystfel/config.h.cmake.in
+++ b/libcrystfel/config.h.cmake.in
@@ -8,6 +8,7 @@
#cmakedefine HAVE_PINKINDEXER
#cmakedefine HAVE_FDIP
#cmakedefine HAVE_CURSES
+#cmakedefine HAVE_GZBUFFER
#cmakedefine HAVE_FORKPTY_PTY_H
#cmakedefine HAVE_FORKPTY_UTIL_H
diff --git a/libcrystfel/src/image.c b/libcrystfel/src/image.c
index 9768e15d..6358a9d0 100644
--- a/libcrystfel/src/image.c
+++ b/libcrystfel/src/image.c
@@ -787,8 +787,10 @@ static float *read_cbf_data(struct imagefile *f, int *w, int *h)
gzfh = gzopen(f->filename, "rb");
if ( gzfh == NULL ) return NULL;
+ #ifdef HAVE_GZBUFFER
/* Set larger buffer size for hopefully faster uncompression */
gzbuffer(gzfh, 128*1024);
+ #endif
buf = malloc(bufsz);
if ( buf == NULL ) return NULL;