1 /** 2 * D header file for POSIX. 3 * 4 * Copyright: Copyright Sean Kelly 2005 - 2009. 5 * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). 6 * Authors: Sean Kelly, 7 Alex Rønne Petersen 8 * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition 9 */ 10 11 /* Copyright Sean Kelly 2005 - 2009. 12 * Distributed under the Boost Software License, Version 1.0. 13 * (See accompanying file LICENSE or copy at 14 * http://www.boost.org/LICENSE_1_0.txt) 15 */ 16 module core.sys.posix.config; 17 18 public import core.stdc.config; 19 20 version (Posix): 21 extern (C) nothrow @nogc: 22 23 enum _XOPEN_SOURCE = 600; 24 enum _POSIX_SOURCE = true; 25 enum _POSIX_C_SOURCE = 200112L; 26 27 version (CRuntime_Glibc) 28 { 29 // man 7 feature_test_macros 30 // http://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html 31 enum _GNU_SOURCE = false; 32 enum _DEFAULT_SOURCE = false; 33 enum _ATFILE_SOURCE = false; 34 35 // _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for _DEFAULT_SOURCE. 36 deprecated("use _DEFAULT_SOURCE") 37 { 38 enum _BSD_SOURCE = false; 39 enum _SVID_SOURCE = false; 40 } 41 42 enum _FILE_OFFSET_BITS = 64; 43 // <sys/cdefs.h> 44 enum __REDIRECT = false; 45 46 enum _REENTRANT = true; // set by compiler when linking -pthread 47 48 // deduced <features.h> 49 enum __USE_FILE_OFFSET64 = _FILE_OFFSET_BITS == 64; 50 enum __USE_LARGEFILE = __USE_FILE_OFFSET64 && !__REDIRECT; 51 enum __USE_LARGEFILE64 = __USE_FILE_OFFSET64 && !__REDIRECT; 52 53 deprecated("use _XOPEN_SOURCE >= 600") 54 { 55 enum __USE_XOPEN2K = _XOPEN_SOURCE >= 600; 56 enum __USE_XOPEN2KXSI = _XOPEN_SOURCE >= 600; 57 } 58 deprecated("use _XOPEN_SOURCE >= 700") 59 { 60 enum __USE_XOPEN2K8 = _XOPEN_SOURCE >= 700; 61 enum __USE_XOPEN2K8XSI = _XOPEN_SOURCE >= 700; 62 } 63 64 deprecated("use _DEFAULT_SOURCE") 65 enum __USE_MISC = _DEFAULT_SOURCE; 66 deprecated("use _ATFILE_SOURCE") 67 enum __USE_ATFILE = _ATFILE_SOURCE; 68 deprecated("use _GNU_SOURCE") 69 enum __USE_GNU = _GNU_SOURCE; 70 deprecated("use _REENTRANT") 71 enum __USE_REENTRANT = _REENTRANT; 72 73 version (D_LP64) 74 enum __WORDSIZE = 64; 75 else 76 enum __WORDSIZE = 32; 77 } 78 else version (CRuntime_Musl) 79 { 80 enum _GNU_SOURCE = false; 81 enum _DEFAULT_SOURCE = false; 82 enum _ATFILE_SOURCE = false; 83 84 // off_t is always 64 bits on Musl 85 enum _FILE_OFFSET_BITS = 64; 86 87 // Not present in Musl sources 88 enum __REDIRECT = false; 89 90 // Those three are irrelevant for Musl as it always uses 64 bits off_t 91 enum __USE_FILE_OFFSET64 = _FILE_OFFSET_BITS == 64; 92 enum __USE_LARGEFILE = __USE_FILE_OFFSET64 && !__REDIRECT; 93 enum __USE_LARGEFILE64 = __USE_FILE_OFFSET64 && !__REDIRECT; 94 95 version (D_LP64) 96 enum __WORDSIZE = 64; 97 else 98 enum __WORDSIZE = 32; 99 } 100 else version (CRuntime_UClibc) 101 { 102 enum _GNU_SOURCE = false; 103 enum _DEFAULT_SOURCE = false; 104 enum _ATFILE_SOURCE = false; 105 106 enum _FILE_OFFSET_BITS = 64; 107 enum __REDIRECT = false; 108 109 enum _REENTRANT = true; 110 111 enum __USE_FILE_OFFSET64 = _FILE_OFFSET_BITS == 64; 112 enum __USE_LARGEFILE = __USE_FILE_OFFSET64 && !__REDIRECT; 113 enum __USE_LARGEFILE64 = __USE_FILE_OFFSET64 && !__REDIRECT; 114 115 deprecated("use _XOPEN_SOURCE >= 600") 116 { 117 enum __USE_XOPEN2K = _XOPEN_SOURCE >= 600; 118 enum __USE_XOPEN2KXSI = _XOPEN_SOURCE >= 600; 119 } 120 deprecated("use _XOPEN_SOURCE >= 700") 121 { 122 enum __USE_XOPEN2K8 = _XOPEN_SOURCE >= 700; 123 enum __USE_XOPEN2K8XSI = _XOPEN_SOURCE >= 700; 124 } 125 126 deprecated("use _DEFAULT_SOURCE") 127 enum __USE_MISC = _DEFAULT_SOURCE; 128 deprecated("use _ATFILE_SOURCE") 129 enum __USE_ATFILE = _ATFILE_SOURCE; 130 deprecated("use _GNU_SOURCE") 131 enum __USE_GNU = _GNU_SOURCE; 132 deprecated("use _REENTRANT") 133 enum __USE_REENTRANT = _REENTRANT; 134 135 version (D_LP64) 136 enum __WORDSIZE = 64; 137 else 138 enum __WORDSIZE = 32; 139 } 140 else version (CRuntime_Bionic) 141 { 142 enum _GNU_SOURCE = false; 143 enum _DEFAULT_SOURCE = false; 144 enum _ATFILE_SOURCE = false; 145 146 enum __USE_FILE_OFFSET64 = false; // see https://android.googlesource.com/platform/bionic/+/master/docs/32-bit-abi.md 147 deprecated("use _GNU_SOURCE") 148 enum __USE_GNU = _GNU_SOURCE; 149 150 version (D_LP64) 151 enum __WORDSIZE = 64; 152 else 153 enum __WORDSIZE = 32; 154 } 155 else version (OpenBSD) 156 { 157 version (Alpha) 158 { 159 enum _ALIGNBYTES = 7; 160 enum _STACKALIGNBYTES = 7; 161 enum _MAX_PAGE_SHIFT = 13; 162 } 163 else version (X86_64) 164 { 165 enum _ALIGNBYTES = c_long.sizeof - 1; 166 enum _STACKALIGNBYTES = 15; 167 enum _MAX_PAGE_SHIFT = 12; 168 } 169 else version (AArch64) 170 { 171 enum _ALIGNBYTES = c_long.sizeof - 1; 172 enum _STACKALIGNBYTES = 15; 173 enum _MAX_PAGE_SHIFT = 12; 174 } 175 else version (ARM) 176 { 177 enum _ALIGNBYTES = 7; 178 enum _STACKALIGNBYTES = 7; 179 enum _MAX_PAGE_SHIFT = 12; 180 } 181 else version (HPPA) 182 { 183 enum _ALIGNBYTES = 7; 184 enum _STACKALIGNBYTES = 7; 185 enum _MAX_PAGE_SHIFT = 12; 186 } 187 else version (X86) 188 { 189 enum _ALIGNBYTES = 3; 190 enum _STACKALIGNBYTES = 15; 191 enum _MAX_PAGE_SHIFT = 12; 192 } 193 else version (PPC) 194 { 195 enum _ALIGNBYTES = 7; 196 enum _STACKALIGNBYTES = 15; 197 enum _MAX_PAGE_SHIFT = 12; 198 } 199 else version (SPARC64) 200 { 201 enum _ALIGNBYTES = 15; 202 enum _STACKALIGNBYTES = 15; 203 enum _MAX_PAGE_SHIFT = 13; 204 } 205 else 206 static assert(false, "Architecture not supported."); 207 } 208 else version (Solaris) 209 { 210 enum _FILE_OFFSET_BITS = 64; 211 enum __REDIRECT = false; 212 213 enum __USE_FILE_OFFSET64 = _FILE_OFFSET_BITS == 64; 214 enum __USE_LARGEFILE = __USE_FILE_OFFSET64 && !__REDIRECT; 215 enum __USE_LARGEFILE64 = __USE_FILE_OFFSET64 && !__REDIRECT; 216 217 deprecated("use _XOPEN_SOURCE >= 600") 218 { 219 enum __USE_XOPEN2K = _XOPEN_SOURCE >= 600; 220 enum __USE_XOPEN2KXSI = _XOPEN_SOURCE >= 600; 221 } 222 deprecated("use _XOPEN_SOURCE >= 700") 223 { 224 enum __USE_XOPEN2K8 = _XOPEN_SOURCE >= 700; 225 enum __USE_XOPEN2K8XSI = _XOPEN_SOURCE >= 700; 226 } 227 228 version (D_LP64) 229 enum __WORDSIZE = 64; 230 else 231 enum __WORDSIZE = 32; 232 }