Commit 3cf4d32e authored by Henrik Gramner's avatar Henrik Gramner Committed by Henrik Gramner

Use 64-bit versions of fseek and ftell

parent 0d18b15a
Pipeline #4515 passed with stages
in 8 minutes and 5 seconds
......@@ -89,6 +89,12 @@ if host_machine.system() == 'windows'
cdata.set('UNICODE', 1) # Define to 1 for Unicode (Wide Chars) APIs
cdata.set('_UNICODE', 1) # Define to 1 for Unicode (Wide Chars) APIs
cdata.set('__USE_MINGW_ANSI_STDIO', 1) # Define to force use of MinGW printf
if cc.has_function('fseeko', prefix : '#include <stdio.h>', args : test_args)
cdata.set('_FILE_OFFSET_BITS', 64) # Not set by default by Meson on Windows
else
cdata.set('fseeko', '_fseeki64')
cdata.set('ftello', '_ftelli64')
endif
endif
# On Windows, we use a compatibility layer to emulate pthread
......
......@@ -62,7 +62,7 @@ static unsigned parse_proc_cpuinfo(const char *flag) {
// if line is incomplete seek back to avoid splitting the search
// string into two buffers
if (!strchr(line, '\n') && strlen(line) > strlen(flag)) {
if (fseek(file, -strlen(flag), SEEK_CUR))
if (fseeko(file, -strlen(flag), SEEK_CUR))
break;
}
}
......
......@@ -25,7 +25,10 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include <errno.h>
#include <inttypes.h>
#include <limits.h>
#include <stddef.h>
#include <stdint.h>
......@@ -40,7 +43,7 @@
int main(const int argc, char *const *const argv) {
int ret = -1;
FILE *f = NULL;
long fsize;
int64_t fsize;
const char *filename = NULL;
uint8_t *data = NULL;
size_t size = 0;
......@@ -56,22 +59,22 @@ int main(const int argc, char *const *const argv) {
goto error;
}
if (fseek(f, 0L, SEEK_END) == -1) {
if (fseeko(f, 0, SEEK_END) == -1) {
fprintf(stderr, "fseek(%s, 0, SEEK_END) failed: %s\n", filename,
strerror(errno));
goto error;
}
if ((fsize = ftell(f)) == -1) {
if ((fsize = ftello(f)) == -1) {
fprintf(stderr, "ftell(%s) failed: %s\n", filename, strerror(errno));
goto error;
}
rewind(f);
if (fsize < 0 || fsize > INT_MAX) {
fprintf(stderr, "%s is too large: %ld\n", filename, fsize);
fprintf(stderr, "%s is too large: %"PRId64"\n", filename, fsize);
goto error;
}
size = fsize;
size = (size_t)fsize;
if (!(data = malloc(size))) {
fprintf(stderr, "failed to allocate: %zu bytes\n", size);
......
......@@ -77,9 +77,9 @@ static int annexb_open(AnnexbInputContext *const c, const char *const file,
res = leb128(c, &len);
if (res < 0)
break;
fseek(c->f, len, SEEK_CUR);
fseeko(c->f, len, SEEK_CUR);
}
fseek(c->f, 0, SEEK_SET);
fseeko(c->f, 0, SEEK_SET);
return 0;
}
......
......@@ -36,10 +36,6 @@
#include "input/demuxer.h"
#ifdef _MSC_VER
#define ftello _ftelli64
#endif
typedef struct DemuxerPriv {
FILE *f;
} IvfInputContext;
......@@ -85,11 +81,11 @@ static int ivf_open(IvfInputContext *const c, const char *const file,
for (*num_frames = 0;; (*num_frames)++) {
if ((res = fread(data, 4, 1, c->f)) != 1)
break; // EOF
fseek(c->f, rl32(data) + 8, SEEK_CUR);
fseeko(c->f, rl32(data) + 8, SEEK_CUR);
}
fps[0] *= *num_frames;
fps[1] *= duration;
fseek(c->f, 32, SEEK_SET);
fseeko(c->f, 32, SEEK_SET);
return 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment