1
0

environments.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. /* Copyright (C) 1999-2026 Free Software Foundation, Inc.
  17. This file is part of the GNU C Library.
  18. The GNU C Library is free software; you can redistribute it and/or
  19. modify it under the terms of the GNU Lesser General Public
  20. License as published by the Free Software Foundation; either
  21. version 2.1 of the License, or (at your option) any later version.
  22. The GNU C Library is distributed in the hope that it will be useful,
  23. but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  25. Lesser General Public License for more details.
  26. You should have received a copy of the GNU Lesser General Public
  27. License along with the GNU C Library; if not, see
  28. <https://www.gnu.org/licenses/>. */
  29. #ifndef _UNISTD_H
  30. # error "Never include this file directly. Use <unistd.h> instead"
  31. #endif
  32. #include <bits/wordsize.h>
  33. /* This header should define the following symbols under the described
  34. situations. A value `1' means that the model is always supported,
  35. `-1' means it is never supported. Undefined means it cannot be
  36. statically decided.
  37. _POSIX_V7_ILP32_OFF32 32bit int, long, pointers, and off_t type
  38. _POSIX_V7_ILP32_OFFBIG 32bit int, long, and pointers and larger off_t type
  39. _POSIX_V7_LP64_OFF32 64bit long and pointers and 32bit off_t type
  40. _POSIX_V7_LPBIG_OFFBIG 64bit long and pointers and large off_t type
  41. The macros _POSIX_V6_ILP32_OFF32, _POSIX_V6_ILP32_OFFBIG,
  42. _POSIX_V6_LP64_OFF32, _POSIX_V6_LPBIG_OFFBIG, _XBS5_ILP32_OFF32,
  43. _XBS5_ILP32_OFFBIG, _XBS5_LP64_OFF32, and _XBS5_LPBIG_OFFBIG were
  44. used in previous versions of the Unix standard and are available
  45. only for compatibility.
  46. */
  47. #if __WORDSIZE == 64
  48. /* Environments with 32-bit wide pointers are optionally provided.
  49. Therefore following macros aren't defined:
  50. # undef _POSIX_V7_ILP32_OFF32
  51. # undef _POSIX_V7_ILP32_OFFBIG
  52. # undef _POSIX_V6_ILP32_OFF32
  53. # undef _POSIX_V6_ILP32_OFFBIG
  54. # undef _XBS5_ILP32_OFF32
  55. # undef _XBS5_ILP32_OFFBIG
  56. and users need to check at runtime. */
  57. /* We also have no use (for now) for an environment with bigger pointers
  58. and offsets. */
  59. # define _POSIX_V7_LPBIG_OFFBIG -1
  60. # define _POSIX_V6_LPBIG_OFFBIG -1
  61. # define _XBS5_LPBIG_OFFBIG -1
  62. /* By default we have 64-bit wide `long int', pointers and `off_t'. */
  63. # define _POSIX_V7_LP64_OFF64 1
  64. # define _POSIX_V6_LP64_OFF64 1
  65. # define _XBS5_LP64_OFF64 1
  66. #else /* __WORDSIZE == 32 */
  67. /* We have 32-bit wide `int', `long int' and pointers and all platforms
  68. support LFS. -mx32 has 64-bit wide `off_t'. */
  69. # define _POSIX_V7_ILP32_OFFBIG 1
  70. # define _POSIX_V6_ILP32_OFFBIG 1
  71. # define _XBS5_ILP32_OFFBIG 1
  72. # ifndef __x86_64__
  73. /* -m32 has 32-bit wide `off_t'. */
  74. # define _POSIX_V7_ILP32_OFF32 1
  75. # define _POSIX_V6_ILP32_OFF32 1
  76. # define _XBS5_ILP32_OFF32 1
  77. # endif
  78. /* We optionally provide an environment with the above size but an 64-bit
  79. side `off_t'. Therefore we don't define _POSIX_V7_ILP32_OFFBIG. */
  80. /* Environments with 64-bit wide pointers can be provided,
  81. so these macros aren't defined:
  82. # undef _POSIX_V7_LP64_OFF64
  83. # undef _POSIX_V7_LPBIG_OFFBIG
  84. # undef _POSIX_V6_LP64_OFF64
  85. # undef _POSIX_V6_LPBIG_OFFBIG
  86. # undef _XBS5_LP64_OFF64
  87. # undef _XBS5_LPBIG_OFFBIG
  88. and sysconf tests for it at runtime. */
  89. #endif /* __WORDSIZE == 32 */
  90. #define __ILP32_OFF32_CFLAGS "-m32"
  91. #define __ILP32_OFF32_LDFLAGS "-m32"
  92. #if defined __x86_64__ && defined __ILP32__
  93. # define __ILP32_OFFBIG_CFLAGS "-mx32"
  94. # define __ILP32_OFFBIG_LDFLAGS "-mx32"
  95. #else
  96. # define __ILP32_OFFBIG_CFLAGS "-m32 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
  97. # define __ILP32_OFFBIG_LDFLAGS "-m32"
  98. #endif
  99. #define __LP64_OFF64_CFLAGS "-m64"
  100. #define __LP64_OFF64_LDFLAGS "-m64"