1 /* Copyright (C) 2000-2022 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library 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 GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
17
18 /* We need to define:
19 #define _FILE_OFFSET_BITS 64
20 #define _LARGEFILE64_SOURCE 1
21 */
22
23 #include <assert.h>
24 #include <stddef.h>
25 #include <sys/stat.h>
26
27 static int
do_test(void)28 do_test (void)
29 {
30 /* With _FILE_OFFSET_BITS=64 struct stat and struct stat64 should
31 be identical. */
32 assert (sizeof (struct stat)
33 == sizeof (struct stat64));
34 assert (offsetof (struct stat, st_dev)
35 == offsetof (struct stat64, st_dev));
36 assert (offsetof (struct stat, st_ino)
37 == offsetof (struct stat64, st_ino));
38 assert (offsetof (struct stat, st_mode)
39 == offsetof (struct stat64, st_mode));
40 assert (offsetof (struct stat, st_nlink)
41 == offsetof (struct stat64, st_nlink));
42 assert (offsetof (struct stat, st_uid)
43 == offsetof (struct stat64, st_uid));
44 assert (offsetof (struct stat, st_gid)
45 == offsetof (struct stat64, st_gid));
46 assert (offsetof (struct stat, st_rdev)
47 == offsetof (struct stat64, st_rdev));
48 assert (offsetof (struct stat, st_size)
49 == offsetof (struct stat64, st_size));
50 assert (offsetof (struct stat, st_atime)
51 == offsetof (struct stat64, st_atime));
52 assert (offsetof (struct stat, st_mtime)
53 == offsetof (struct stat64, st_mtime));
54 assert (offsetof (struct stat, st_ctime)
55 == offsetof (struct stat64, st_ctime));
56 assert (offsetof (struct stat, st_blksize)
57 == offsetof (struct stat64, st_blksize));
58 assert (offsetof (struct stat, st_blocks)
59 == offsetof (struct stat64, st_blocks));
60 #if 0
61 /* Some systems have st_fstype but not all. Don't check it for now. */
62 assert (offsetof (struct stat, st_fstype)
63 == offsetof (struct stat64, st_fstype));
64 #endif
65 return 0;
66 }
67
68 #define TEST_FUNCTION do_test ()
69 #include "../test-skeleton.c"
70