Browse Source

- bugfix, if mmap detected, the macro _HAVE_MMAP should be defined

- bugfix, use correct macro _HAVE_MMAP
- HINT: fix resulting in speedup by factor 2 in general
development
art1pirat 2 months ago
committed by Andreas Romeyke
parent
commit
34e6d2bf01
  1. 2
      src/CMakeLists.txt
  2. 10
      src/helper/check_tiffparse.c

2
src/CMakeLists.txt

@ -45,7 +45,6 @@ else()
message(STATUS "IPO / LTO unsupported: <${LTO_CHECK_ERROR}>")
endif()
# add default CFLAGS
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector-strong -Wformat -Werror=format-security")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,relro -fPIE")
@ -111,6 +110,7 @@ CHECK_FUNCTION_EXISTS(munmap _HAVE_MUNMAP)
if(_HAVE_MMAP AND _HAVE_MUNMAP)
message(INFO "mmap found")
set(_HAVE__MMAP 1)
add_definitions(-D_HAVE_MMAP)
endif()

10
src/helper/check_tiffparse.c

@ -12,13 +12,14 @@
#include <assert.h>
#include <fcntl.h>
#ifdef _HAVE__MMAP
#ifdef _HAVE_MMAP
#include <sys/mman.h>
#include <errno.h>
#endif
off_t ct_seek(ctiff_t * ctif, off_t pos, int whence) {
#ifdef _HAVE__MMAP
#ifdef _HAVE_MMAP
switch (ctif->ioflag) {
case is_filep:
assert(ctif->fd >= 0);
@ -71,7 +72,7 @@ ssize_t ct_read(ctiff_t * ctif, void *buf, size_t count) {
perror("Buffer buf is a NULL-pointer");
exit( EXIT_FAILURE );
}
#ifdef _HAVE__MMAP
#ifdef _HAVE_MMAP
switch (ctif->ioflag) {
case is_filep:
// TODO: add checks if seek will be outside of file!!!
@ -713,13 +714,14 @@ ctiff_t * initialize_ctif(const char * tiff_file, ct_ioflag_t ioflag) {
for (int i= 0; i<MAXTAGS; i++) { /* init with -1 indicating 'not found' */
ctif->tag_cache[i]= -1;
}
#ifdef _HAVE__MMAP
#ifdef _HAVE_MMAP
switch (ioflag) {
case is_filep: {
/* streamlen */
break;
}
case is_memmap: {
void * tifmap = mmap( NULL, ctif->streamlen, PROT_READ, MAP_PRIVATE, tif, 0 );
if (MAP_FAILED == tifmap) {
fprintf( stderr, "file '%s' could not be mem-mapped, %s\n", tiff_file, strerror(errno));

Loading…
Cancel
Save