struct_stat_time64_helper.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. //
  2. // Copyright 2026 Aarav Ravindra Kharade
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. /* Definition for helper to define struct stat with 64-bit time.
  17. Copyright (C) 2021-2026 Free Software Foundation, Inc.
  18. This file is part of the GNU C Library.
  19. The GNU C Library is free software; you can redistribute it and/or
  20. modify it under the terms of the GNU Lesser General Public
  21. License as published by the Free Software Foundation; either
  22. version 2.1 of the License, or (at your option) any later version.
  23. The GNU C Library is distributed in the hope that it will be useful,
  24. but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  26. Lesser General Public License for more details.
  27. You should have received a copy of the GNU Lesser General Public
  28. License along with the GNU C Library. If not, see
  29. <https://www.gnu.org/licenses/>. */
  30. /* Content of internal __stat64_t64 struct. */
  31. __dev_t st_dev; /* Device. */
  32. __ino64_t st_ino; /* file serial number. */
  33. __mode_t st_mode; /* File mode. */
  34. __nlink_t st_nlink; /* Link count. */
  35. __uid_t st_uid; /* User ID of the file's owner. */
  36. __gid_t st_gid; /* Group ID of the file's group. */
  37. __dev_t st_rdev; /* Device number, if device. */
  38. __off64_t st_size; /* Size of file, in bytes. */
  39. __blksize_t st_blksize; /* Optimal block size for I/O. */
  40. __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
  41. #ifdef __USE_XOPEN2K8
  42. # ifndef __struct_timespec
  43. # define __struct_timespec struct timespec
  44. # endif
  45. /* Nanosecond resolution timestamps are stored in a format
  46. equivalent to 'struct timespec'. This is the type used
  47. whenever possible but the Unix namespace rules do not allow the
  48. identifier 'timespec' to appear in the <sys/stat.h> header.
  49. Therefore we have to handle the use of this header in strictly
  50. standard-compliant sources special. */
  51. __struct_timespec st_atim;
  52. __struct_timespec st_mtim;
  53. __struct_timespec st_ctim;
  54. # define st_atime st_atim.tv_sec
  55. # define st_mtime st_mtim.tv_sec
  56. # define st_ctime st_ctim.tv_sec
  57. # undef __struct_timespec
  58. #else
  59. /* The definition should be equal to the 'struct __timespec64' internal
  60. layout. */
  61. # if __BYTE_ORDER == __BIG_ENDIAN
  62. # define __fieldts64(name) \
  63. __time64_t name; __int32_t :32; __int32_t name ## nsec
  64. # else
  65. # define __fieldts64(name) \
  66. __time64_t name; __int32_t name ## nsec; __int32_t :32
  67. # endif
  68. __fieldts64 (st_atime);
  69. __fieldts64 (st_mtime);
  70. __fieldts64 (st_ctime);
  71. unsigned long int __glibc_reserved4;
  72. unsigned long int __glibc_reserved5;
  73. # undef __fieldts64
  74. #endif