| 1 |
/* Test of largefile module. |
| 2 |
Copyright (C) 2023-2025 Free Software Foundation, Inc. |
| 3 |
|
| 4 |
This program is free software: you can redistribute it and/or modify |
| 5 |
it under the terms of the GNU General Public License as published by |
| 6 |
the Free Software Foundation, either version 3 of the License, or |
| 7 |
(at your option) any later version. |
| 8 |
|
| 9 |
This program is distributed in the hope that it will be useful, |
| 10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
GNU General Public License for more details. |
| 13 |
|
| 14 |
You should have received a copy of the GNU General Public License |
| 15 |
along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
| 16 |
|
| 17 |
/* Written by Bruno Haible <[email protected]>, 2023. */ |
| 18 |
|
| 19 |
/* This test may fail if AC_SYS_LARGEFILE could not arrange for a 64-bit off_t. |
| 20 |
This should be rare, though: only very old systems don't have support for |
| 21 |
files larger than 2 GiB. */ |
| 22 |
|
| 23 |
#include <config.h> |
| 24 |
|
| 25 |
#include <sys/types.h> |
| 26 |
#include <sys/stat.h> |
| 27 |
#include "intprops.h" |
| 28 |
|
| 29 |
/* Although these tests could be done with static_assert, the test |
| 30 |
harness prefers dynamic checking. */ |
| 31 |
|
| 32 |
int |
| 33 |
main (void) |
| 34 |
{ |
| 35 |
int result = 0; |
| 36 |
|
| 37 |
/* Check the range of off_t. |
| 38 |
With MSVC, this test succeeds only thanks to the 'sys_types' module. */ |
| 39 |
if (TYPE_MAXIMUM (off_t) >> 31 >> 31 == 0) |
| 40 |
result |= 1; |
| 41 |
|
| 42 |
/* Check the size of the 'struct stat' field 'st_size'. |
| 43 |
With MSVC, this test succeeds only thanks to the 'sys_stat' module. */ |
| 44 |
{ |
| 45 |
struct stat st; |
| 46 |
if (sizeof st.st_size != sizeof (off_t)) |
| 47 |
result |= 2; |
| 48 |
} |
| 49 |
|
| 50 |
return result; |
| 51 |
} |