32bit linux support

This commit is contained in:
Mathias Panzenböck 2013-01-03 20:21:13 +01:00
parent 479749024a
commit ed4fec7171
4 changed files with 22 additions and 7 deletions

View File

@ -24,7 +24,7 @@ OBJ=\
$(BUILDDIR)/bink.o
CC=gcc
LD=gcc
COMMON_CFLAGS=-Wall -Werror -pedantic -Wextra -std=gnu99 -O2 -fmessage-length=0 -g $(INCLUDE) $(LIBDIRS)
COMMON_CFLAGS=-Wall -Werror -pedantic -Wextra -std=gnu99 -O2 -g $(INCLUDE) $(LIBDIRS) -D_FILE_OFFSET_BITS=64
CFLAGS=$(COMMON_CFLAGS)
APPNAME=audioextract
BIN=$(BUILDDIR)/$(APPNAME)

View File

@ -17,9 +17,9 @@ Or:
make TARGET=win64
Note that 32bit binaries can only read files up to about 4 GB
because of memory limitations of the 32bit address space. 64bit
binaries can read up to about 16 EB (16 Exabyte).
Note that 32bit binaries can only read files up to about 2 GB because of the
limitations of the 32bit address space. 64bit binaries can read up to about
8 EB (8 Exabyte).
Usage
-----

View File

@ -45,13 +45,19 @@ int extract(const struct extract_options *options, size_t *numfilesptr)
fprintf(stderr, "%s: Is a directory\n", options->filepath);
goto error;
}
filesize = statdata.st_size;
if (filesize == 0)
if (statdata.st_size == 0)
{
goto cleanup;
}
else if ((uint64_t)statdata.st_size > (size_t)-1)
{
fprintf(stderr, "error: cannot map file of this size (file size: %llu bytes, max. possible: %zu bytes)\n",
(long long unsigned int)statdata.st_size, (size_t)-1);
goto error;
}
filesize = statdata.st_size;
filedata = mmap(NULL, filesize, PROT_READ, MAP_PRIVATE, fd, 0);
if (filedata == MAP_FAILED)
{

View File

@ -3,6 +3,14 @@
#include <windows.h>
#include <stdio.h>
#ifdef _WIN64
# define ZU_FMT "%l64u"
# pragma GCC diagnostic ignored "-Wformat"
# pragma GCC diagnostic ignored "-Wformat-extra-args"
#else
# define ZU_FMT "%u"
#endif
static void PrintError(const char *msg)
{
char ErrStr[512];
@ -58,7 +66,8 @@ int extract(const struct extract_options *options, size_t *numfilesptr)
goto cleanup;
else if ((ULONGLONG)filesize.QuadPart > (size_t)-1)
{
fprintf(stderr, "error: cannot map file of this size\n");
fprintf(stderr, "error: cannot map file of this size (file size: %l64u bytes, max. possible: "
ZU_FMT " bytes)\n", (ULONGLONG)filesize.QuadPart, (size_t)-1);
goto error;
}