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 version (D_LP64) 88 enum __WORDSIZE = 64; 89 else 90 enum __WORDSIZE = 32; 91 } 92 else version (CRuntime_UClibc) 93 { 94 enum _GNU_SOURCE = false; 95 enum _DEFAULT_SOURCE = false; 96 enum _ATFILE_SOURCE = false; 97 98 enum _FILE_OFFSET_BITS = 64; 99 enum __REDIRECT = false; 100 101 enum _REENTRANT = true; 102 103 enum __USE_FILE_OFFSET64 = _FILE_OFFSET_BITS == 64; 104 enum __USE_LARGEFILE = __USE_FILE_OFFSET64 && !__REDIRECT; 105 enum __USE_LARGEFILE64 = __USE_FILE_OFFSET64 && !__REDIRECT; 106 107 deprecated("use _XOPEN_SOURCE >= 600") 108 { 109 enum __USE_XOPEN2K = _XOPEN_SOURCE >= 600; 110 enum __USE_XOPEN2KXSI = _XOPEN_SOURCE >= 600; 111 } 112 deprecated("use _XOPEN_SOURCE >= 700") 113 { 114 enum __USE_XOPEN2K8 = _XOPEN_SOURCE >= 700; 115 enum __USE_XOPEN2K8XSI = _XOPEN_SOURCE >= 700; 116 } 117 118 deprecated("use _DEFAULT_SOURCE") 119 enum __USE_MISC = _DEFAULT_SOURCE; 120 deprecated("use _ATFILE_SOURCE") 121 enum __USE_ATFILE = _ATFILE_SOURCE; 122 deprecated("use _GNU_SOURCE") 123 enum __USE_GNU = _GNU_SOURCE; 124 deprecated("use _REENTRANT") 125 enum __USE_REENTRANT = _REENTRANT; 126 127 version (D_LP64) 128 enum __WORDSIZE = 64; 129 else 130 enum __WORDSIZE = 32; 131 } 132 else version (CRuntime_Bionic) 133 { 134 enum _GNU_SOURCE = false; 135 enum _DEFAULT_SOURCE = false; 136 enum _ATFILE_SOURCE = false; 137 138 enum __USE_FILE_OFFSET64 = false; // see https://android.googlesource.com/platform/bionic/+/master/docs/32-bit-abi.md 139 deprecated("use _GNU_SOURCE") 140 enum __USE_GNU = _GNU_SOURCE; 141 142 version (D_LP64) 143 enum __WORDSIZE = 64; 144 else 145 enum __WORDSIZE = 32; 146 } 147 else version (OpenBSD) 148 { 149 version (Alpha) 150 { 151 enum _ALIGNBYTES = 7; 152 enum _STACKALIGNBYTES = 7; 153 enum _MAX_PAGE_SHIFT = 13; 154 } 155 else version (X86_64) 156 { 157 enum _ALIGNBYTES = c_long.sizeof - 1; 158 enum _STACKALIGNBYTES = 15; 159 enum _MAX_PAGE_SHIFT = 12; 160 } 161 else version (AArch64) 162 { 163 enum _ALIGNBYTES = c_long.sizeof - 1; 164 enum _STACKALIGNBYTES = 15; 165 enum _MAX_PAGE_SHIFT = 12; 166 } 167 else version (ARM) 168 { 169 enum _ALIGNBYTES = 7; 170 enum _STACKALIGNBYTES = 7; 171 enum _MAX_PAGE_SHIFT = 12; 172 } 173 else version (HPPA) 174 { 175 enum _ALIGNBYTES = 7; 176 enum _STACKALIGNBYTES = 7; 177 enum _MAX_PAGE_SHIFT = 12; 178 } 179 else version (X86) 180 { 181 enum _ALIGNBYTES = 3; 182 enum _STACKALIGNBYTES = 15; 183 enum _MAX_PAGE_SHIFT = 12; 184 } 185 else version (PPC) 186 { 187 enum _ALIGNBYTES = 7; 188 enum _STACKALIGNBYTES = 15; 189 enum _MAX_PAGE_SHIFT = 12; 190 } 191 else version (SPARC64) 192 { 193 enum _ALIGNBYTES = 15; 194 enum _STACKALIGNBYTES = 15; 195 enum _MAX_PAGE_SHIFT = 13; 196 } 197 else 198 static assert(false, "Architecture not supported."); 199 } 200 else version (Solaris) 201 { 202 enum _FILE_OFFSET_BITS = 64; 203 enum __REDIRECT = false; 204 205 enum __USE_FILE_OFFSET64 = _FILE_OFFSET_BITS == 64; 206 enum __USE_LARGEFILE = __USE_FILE_OFFSET64 && !__REDIRECT; 207 enum __USE_LARGEFILE64 = __USE_FILE_OFFSET64 && !__REDIRECT; 208 209 deprecated("use _XOPEN_SOURCE >= 600") 210 { 211 enum __USE_XOPEN2K = _XOPEN_SOURCE >= 600; 212 enum __USE_XOPEN2KXSI = _XOPEN_SOURCE >= 600; 213 } 214 deprecated("use _XOPEN_SOURCE >= 700") 215 { 216 enum __USE_XOPEN2K8 = _XOPEN_SOURCE >= 700; 217 enum __USE_XOPEN2K8XSI = _XOPEN_SOURCE >= 700; 218 } 219 220 version (D_LP64) 221 enum __WORDSIZE = 64; 222 else 223 enum __WORDSIZE = 32; 224 }