Enforce 32 bit IO-API for minizip on !Linux and !Windows.

By default minizip uses fopen64(), fseek64() and so on. Those may not
be defined on all system, especially the BSDs. While FreeBSD already
has a special case, for example OpenBSD hasn't. Work around this by
forcing minizip to use fopen(), fseek() and so on everything that's not
Linux or Windows. This is not 100% correct, it may prevent the usage of
ZIPs lager than 2GB on Solaris and other rarely used systems. But I
doubt that anyone has such large ZIPs with assets, they would likely hit
other internal limits.

In the future Quake II should use off_t instead of int were applicable.
With that we could set -D_FILE_OFFSET_BITS=64.

This change is based upon a patch send by @devnexen in pr #279.
This commit is contained in:
Yamagi Burmeister 2018-02-20 09:42:45 +01:00
parent c68aade396
commit d6f9cf64a4
2 changed files with 25 additions and 2 deletions

View File

@ -100,6 +100,10 @@ if(${ZIP_SUPPORT})
list(APPEND yquake2IncludeDirectories ${ZLIB_INCLUDE_DIRS})
list(APPEND yquake2ZLibLinkerFlags ${ZLIB_LIBRARIES})
add_definitions(-DZIP -DNOUNCRYPT)
if(NOT CMAKE_SYSTEM_NAME MATCHES "Linux" OR NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
add_definitions(-DIOAPI_NO_64)
endif()
endif()
if(${OGG_SUPPORT})

View File

@ -222,6 +222,25 @@ endif
# ----------
# Just set IOAPI_NO_64 on everything that's not Linux or Windows,
# otherwise minizip will use fopen64(), fseek64() and friends that
# may be unavailable. This is - of course - not really correct, in
# a better world we would set -DIOAPI_NO_64 to force everything to
# fopen(), fseek() and so on and -D_FILE_OFFSET_BITS=64 to let the
# libc headers do their work. Currently we can't do that because
# Quake II uses nearly everywere int instead of off_t...
#
# This may have the side effect that ZIP files larger than 2GB are
# unsupported. But I doubt that anyone has such large files, they
# would likely hit other internal limits.
ifneq ($(YQ2_OSTYPE),Windows)
ifneq ($(YQ2_OSTYPE),Linux)
ZIPCFLAGS += -DIOAPI_NO_64
endif
endif
# ----------
# Extra CFLAGS for SDL
ifeq ($(WITH_SDL2),yes)
SDLCFLAGS := $(shell sdl2-config --cflags)
@ -468,7 +487,7 @@ endif # !DLOPEN_OPENAL
endif # WITH_OPENAL
ifeq ($(WITH_ZIP),yes)
release/quake2 : CFLAGS += -DZIP -DNOUNCRYPT
release/quake2 : CFLAGS += $(ZIPCFLAGS) -DZIP -DNOUNCRYPT
release/quake2 : LDFLAGS += -lz
endif
@ -542,7 +561,7 @@ build/server/%.o: %.c
release/q2ded : CFLAGS += -DDEDICATED_ONLY -Wno-unused-result
ifeq ($(WITH_ZIP),yes)
release/q2ded : CFLAGS += -DZIP -DNOUNCRYPT
release/q2ded : CFLAGS += $(ZIPCFLAGS) -DZIP -DNOUNCRYPT
release/q2ded : LDFLAGS += -lz
endif
endif