Grok 20.3.2
grk_fseek.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2016-2026 Grok Image Compression Inc.
3 *
4 * This source code is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Affero General Public License, version 3,
6 * as published by the Free Software Foundation.
7 *
8 * This source code is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Affero General Public License for more details.
12 *
13 * You should have received a copy of the GNU Affero General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18#pragma once
19
20/*
21 Use fseeko() and ftello() if they are available since they use
22 'int64_t' rather than 'long'. It is wrong to use fseeko() and
23 ftello() only on systems with special LFS support since some systems
24 (e.g. FreeBSD) support a 64-bit int64_t by default.
25 */
26#if defined(GROK_HAVE_FSEEKO) && !defined(fseek)
27#define fseek fseeko
28#define ftell ftello
29#endif
30#if defined(_WIN32)
31#define GRK_FSEEK(stream, offset, whence) _fseeki64(stream, /* __int64 */ offset, whence)
32#define GRK_FTELL(stream) /* __int64 */ _ftelli64(stream)
33#else
34#define GRK_FSEEK(stream, offset, whence) fseek(stream, offset, whence)
35#define GRK_FTELL(stream) ftell(stream)
36#endif